From ebf1501f6d253ef906c44bae278a2f80ffcb9f54 Mon Sep 17 00:00:00 2001 From: Ben Coburn Date: Thu, 7 Dec 2006 08:49:06 +0100 Subject: changelog type strings replaced with constants Using more verbose constant names in the place of single character strings should make the code much more readable. This does not change the behavior of the changelog. darcs-hash:20061207074906-05dcb-0bdc35e7241bf14063b2b43a6ff26d8a3c307cb9.gz --- inc/changelog.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'inc/changelog.php') diff --git a/inc/changelog.php b/inc/changelog.php index 43d18f148..c985e5694 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -6,6 +6,14 @@ * @author Andreas Gohr */ +// Constants for known core changelog line types. +// Use these in place of string literals for more readable code. +define('DOKU_CHANGE_TYPE_CREATE', 'C'); +define('DOKU_CHANGE_TYPE_EDIT', 'E'); +define('DOKU_CHANGE_TYPE_MINOR_EDIT', 'e'); +define('DOKU_CHANGE_TYPE_DELETE', 'D'); +define('DOKU_CHANGE_TYPE_REVERT', 'R'); + /** * parses a changelog line into it's components * @@ -33,7 +41,7 @@ function parseChangelogLine($line) { * @author Esther Brunner * @author Ben Coburn */ -function addLogEntry($date, $id, $type='E', $summary='', $extra='', $flags=null){ +function addLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='', $extra='', $flags=null){ global $conf, $INFO; // check for special flags as keys @@ -43,8 +51,8 @@ function addLogEntry($date, $id, $type='E', $summary='', $extra='', $flags=null) $id = cleanid($id); $file = wikiFN($id); $created = @filectime($file); - $minor = ($type==='e'); - $wasRemoved = ($type==='D'); + $minor = ($type===DOKU_CHANGE_TYPE_MINOR_EDIT); + $wasRemoved = ($type===DOKU_CHANGE_TYPE_DELETE); if(!$date) $date = time(); //use current time if none supplied $remote = (!$flagExternalEdit)?$_SERVER['REMOTE_ADDR']:'127.0.0.1'; @@ -147,7 +155,7 @@ function _handleRecent($line,$ns,$flags){ if(isset($seen[$recent['id']])) return false; // skip minors - if($recent['type']==='e' && ($flags & RECENTS_SKIP_MINORS)) return false; + if($recent['type']===DOKU_CHANGE_TYPE_MINOR_EDIT && ($flags & RECENTS_SKIP_MINORS)) return false; // remember in seen to skip additional sights $seen[$recent['id']] = 1; -- cgit v1.2.3