X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FChangesList.php;h=3efa66f9c5aa55041c3275f64f990551fc765bc8;hb=7a605cce46eb688dfb697487a1b1d300bef4361c;hp=bcdb6d34154c837afd135f0234876cc3bf408033;hpb=abe2627248bfd59bb80f4dd5b840f0a984598a6a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ChangesList.php b/includes/ChangesList.php index bcdb6d3415..3efa66f9c5 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -106,9 +106,21 @@ class ChangesList { * @returns string */ public static function showCharacterDifference( $old, $new ) { - global $wgRCChangedSizeThreshold, $wgLang; + global $wgRCChangedSizeThreshold, $wgLang, $wgMiserMode; $szdiff = $new - $old; - $formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape'), $wgLang->formatNum($szdiff) ); + + $code = $wgLang->getCode(); + static $fastCharDiff = array(); + if ( !isset($fastCharDiff[$code]) ) { + $fastCharDiff[$code] = $wgMiserMode || wfMsgNoTrans( 'rc-change-size' ) === '$1'; + } + + $formatedSize = $wgLang->formatNum($szdiff); + + if ( !$fastCharDiff[$code] ) { + $formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape' ), $formatedSize ); + } + if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) { $tag = 'strong'; } else { @@ -139,8 +151,8 @@ class ChangesList { # Diff $s .= '(' . $this->message['diff'] . ') ('; # Hist - $s .= $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), $this->message['hist'], 'action=history' ) . - ') . . '; + $s .= $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), $this->message['hist'], + 'action=history' ) . ') . . '; # "[[x]] moved to [[y]]" $msg = ( $rc->mAttribs['rc_type'] == RC_MOVE ) ? '1movedto2' : '1movedto2_redir'; $s .= wfMsg( $msg, $this->skin->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ), @@ -168,13 +180,12 @@ class ChangesList { protected function insertDiffHist( &$s, &$rc, $unpatrolled ) { # Diff link - if( !$this->userCan($rc,Revision::DELETED_TEXT) ) { + if( $rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG ) { $diffLink = $this->message['diff']; - } else if( $rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG ) { + } else if( !$this->userCan($rc,Revision::DELETED_TEXT) ) { $diffLink = $this->message['diff']; } else { - $rcidparam = $unpatrolled ? - array( 'rcid' => $rc->mAttribs['rc_id'] ) : array(); + $rcidparam = $unpatrolled ? array( 'rcid' => $rc->mAttribs['rc_id'] ) : array(); $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'], wfArrayToCGI( array( 'curid' => $rc->mAttribs['rc_cur_id'], @@ -219,13 +230,14 @@ class ChangesList { protected function insertTimestamp( &$s, $rc ) { global $wgLang; - $s .= $this->message['semicolon-separator'] . $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . '; + $s .= $this->message['semicolon-separator'] . + $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . '; } /** Insert links to user page, user talk page and eventually a blocking link */ - public function insertUserRelatedLinks(&$s, &$rc) { - if ( $this->isDeleted($rc,Revision::DELETED_USER) ) { - $s .= ' ' . wfMsgHtml('rev-deleted-user') . ''; + public function insertUserRelatedLinks( &$s, &$rc ) { + if( $this->isDeleted( $rc, Revision::DELETED_USER ) ) { + $s .= ' ' . wfMsgHtml( 'rev-deleted-user' ) . ''; } else { $s .= $this->skin->userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] ); $s .= $this->skin->userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] ); @@ -233,26 +245,22 @@ class ChangesList { } /** insert a formatted action */ - protected function insertAction(&$s, &$rc) { - # Add action + protected function insertAction( &$s, &$rc ) { if( $rc->mAttribs['rc_type'] == RC_LOG ) { - // log action - if ( $this->isDeleted($rc,LogPage::DELETED_ACTION) ) { - $s .= ' ' . wfMsgHtml('rev-deleted-event') . ''; + if( $this->isDeleted( $rc, LogPage::DELETED_ACTION ) ) { + $s .= ' ' . wfMsgHtml( 'rev-deleted-event' ) . ''; } else { - $s .= ' ' . LogPage::actionText( $rc->mAttribs['rc_log_type'], $rc->mAttribs['rc_log_action'], - $rc->getTitle(), $this->skin, LogPage::extractParams($rc->mAttribs['rc_params']), true, true ); + $s .= ' '.LogPage::actionText( $rc->mAttribs['rc_log_type'], $rc->mAttribs['rc_log_action'], + $rc->getTitle(), $this->skin, LogPage::extractParams( $rc->mAttribs['rc_params'] ), true, true ); } } } /** insert a formatted comment */ - protected function insertComment(&$s, &$rc) { - # Add comment + protected function insertComment( &$s, &$rc ) { if( $rc->mAttribs['rc_type'] != RC_MOVE && $rc->mAttribs['rc_type'] != RC_MOVE_OVER_REDIRECT ) { - // log comment - if ( $this->isDeleted($rc,Revision::DELETED_COMMENT) ) { - $s .= ' ' . wfMsgHtml('rev-deleted-comment') . ''; + if( $this->isDeleted( $rc, Revision::DELETED_COMMENT ) ) { + $s .= ' ' . wfMsgHtml( 'rev-deleted-comment' ) . ''; } else { $s .= $this->skin->commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() ); } @@ -274,10 +282,10 @@ class ChangesList { protected function numberofWatchingusers( $count ) { global $wgLang; static $cache = array(); - if ( $count > 0 ) { - if ( !isset( $cache[$count] ) ) { - $cache[$count] = wfMsgExt('number_of_watching_users_RCview', - array('parsemag', 'escape'), $wgLang->formatNum($count)); + if( $count > 0 ) { + if( !isset( $cache[$count] ) ) { + $cache[$count] = wfMsgExt( 'number_of_watching_users_RCview', + array('parsemag', 'escape' ), $wgLang->formatNum( $count ) ); } return $cache[$count]; } else { @@ -292,7 +300,7 @@ class ChangesList { * @return bool */ public static function isDeleted( $rc, $field ) { - return ($rc->mAttribs['rc_deleted'] & $field) == $field; + return ( $rc->mAttribs['rc_deleted'] & $field ) == $field; } /** @@ -308,7 +316,7 @@ class ChangesList { $permission = ( $rc->mAttribs['rc_deleted'] & Revision::DELETED_RESTRICTED ) == Revision::DELETED_RESTRICTED ? 'suppressrevision' : 'deleterevision'; - wfDebug( "Checking for $permission due to $field match on $rc->mAttribs['rc_deleted']\n" ); + wfDebug( "Checking for $permission due to $field match on {$rc->mAttribs['rc_deleted']}\n" ); return $wgUser->isAllowed( $permission ); } else { return true; @@ -317,12 +325,45 @@ class ChangesList { protected function maybeWatchedLink( $link, $watched=false ) { if( $watched ) { - // FIXME: css style might be more appropriate return '' . $link . ''; } else { return '' . $link . ''; } } + + /** Inserts a rollback link */ + protected function insertRollback( &$s, &$rc ) { + global $wgUser; + if( !$rc->mAttribs['rc_new'] && $rc->mAttribs['rc_this_oldid'] && $rc->mAttribs['rc_cur_id'] ) { + $page = $rc->getTitle(); + /** Check for rollback and edit permissions, disallow special pages, and only + * show a link on the top-most revision */ + if ($wgUser->isAllowed('rollback') && $rc->mAttribs['page_latest'] == $rc->mAttribs['rc_this_oldid'] ) + { + $rev = new Revision( array( + 'id' => $rc->mAttribs['rc_this_oldid'], + 'user' => $rc->mAttribs['rc_user'], + 'user_text' => $rc->mAttribs['rc_user_text'], + 'deleted' => $rc->mAttribs['rc_deleted'] + ) ); + $rev->setTitle( $page ); + $s .= ' '.$this->skin->generateRollback( $rev ); + } + } + } + + protected function insertTags( &$s, &$rc, &$classes ) { + if ( empty($rc->mAttribs['ts_tags']) ) + return; + + list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow( $rc->mAttribs['ts_tags'], 'changeslist' ); + $classes = array_merge( $classes, $newClasses ); + $s .= ' ' . $tagSummary; + } + + protected function insertExtra( &$s, &$rc, &$classes ) { + ## Empty, used for subclassers to add anything special. + } } @@ -333,80 +374,92 @@ class OldChangesList extends ChangesList { /** * Format a line using the old system (aka without any javascript). */ - public function recentChangesLine( &$rc, $watched = false ) { - global $wgContLang, $wgRCShowChangedSize, $wgUser; - + public function recentChangesLine( &$rc, $watched = false, $linenumber = NULL ) { + global $wgLang, $wgRCShowChangedSize, $wgUser; wfProfileIn( __METHOD__ ); - - # Extract DB fields into local scope - // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables. - extract( $rc->mAttribs ); - # Should patrol-related stuff be shown? - $unpatrolled = $wgUser->useRCPatrol() && $rc_patrolled == 0; + $unpatrolled = $wgUser->useRCPatrol() && !$rc->mAttribs['rc_patrolled']; - $dateheader = ""; // $s now contains only
  • ...
  • , for hooks' convenience. - $this->insertDateHeader($dateheader,$rc_timestamp); + $dateheader = ''; // $s now contains only
  • ...
  • , for hooks' convenience. + $this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] ); $s = ''; + $classes = array(); + // use mw-line-even/mw-line-odd class only if linenumber is given (feature from bug 14468) + if( $linenumber ) { + if( $linenumber & 1 ) { + $classes[] = 'mw-line-odd'; + } + else { + $classes[] = 'mw-line-even'; + } + } // Moved pages - if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { + if( $rc->mAttribs['rc_type'] == RC_MOVE || $rc->mAttribs['rc_type'] == RC_MOVE_OVER_REDIRECT ) { $this->insertMove( $s, $rc ); // Log entries - } elseif( $rc_log_type ) { - $logtitle = Title::newFromText( "Log/$rc_log_type", NS_SPECIAL ); - $this->insertLog( $s, $logtitle, $rc_log_type ); + } elseif( $rc->mAttribs['rc_log_type'] ) { + $logtitle = Title::newFromText( 'Log/'.$rc->mAttribs['rc_log_type'], NS_SPECIAL ); + $this->insertLog( $s, $logtitle, $rc->mAttribs['rc_log_type'] ); // Log entries (old format) or log targets, and special pages - } elseif( $rc_namespace == NS_SPECIAL ) { - list( $specialName, $specialSubpage ) = SpecialPage::resolveAliasWithSubpage( $rc_title ); - if ( $specialName == 'Log' ) { - $this->insertLog( $s, $rc->getTitle(), $specialSubpage ); - } else { - wfDebug( "Unexpected special page in recentchanges\n" ); + } elseif( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) { + list( $name, $subpage ) = SpecialPage::resolveAliasWithSubpage( $rc->mAttribs['rc_title'] ); + if( $name == 'Log' ) { + $this->insertLog( $s, $rc->getTitle(), $subpage ); } // Regular entries } else { - $this->insertDiffHist($s, $rc, $unpatrolled); + $this->insertDiffHist( $s, $rc, $unpatrolled ); # M, N, b and ! (minor, new, bot and unpatrolled) - $s .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $unpatrolled, '', $rc_bot ); - $this->insertArticleLink($s, $rc, $unpatrolled, $watched); + $s .= $this->recentChangesFlags( $rc->mAttribs['rc_new'], $rc->mAttribs['rc_minor'], + $unpatrolled, '', $rc->mAttribs['rc_bot'] ); + $this->insertArticleLink( $s, $rc, $unpatrolled, $watched ); } - - $this->insertTimestamp($s,$rc); - + # Edit/log timestamp + $this->insertTimestamp( $s, $rc ); + # Bytes added or removed if( $wgRCShowChangedSize ) { - $s .= ( $rc->getCharacterDifference() == '' ? '' : $rc->getCharacterDifference() . ' . . ' ); + $cd = $rc->getCharacterDifference(); + if( $cd != '' ) { + $s .= "$cd . . "; + } } # User tool links - $this->insertUserRelatedLinks($s,$rc); + $this->insertUserRelatedLinks( $s, $rc ); # Log action text (if any) - $this->insertAction($s, $rc); + $this->insertAction( $s, $rc ); # Edit or log comment - $this->insertComment($s, $rc); - + $this->insertComment( $s, $rc ); + # Tags + $this->insertTags( $s, $rc, $classes ); + # Rollback + $this->insertRollback( $s, $rc ); + # For subclasses + $this->insertExtra( $s, $rc, $classes ); + # Mark revision as deleted if so - if ( !$rc_log_type && $this->isDeleted($rc,Revision::DELETED_TEXT) ) + if( !$rc->mAttribs['rc_log_type'] && $this->isDeleted($rc,Revision::DELETED_TEXT) ) { $s .= ' ' . wfMsgHtml( 'deletedrev' ) . ''; - if($rc->numberofWatchingusers > 0) { - $s .= ' ' . wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rc->numberofWatchingusers)); + } + # How many users watch this page + if( $rc->numberofWatchingusers > 0 ) { + $s .= ' ' . wfMsgExt( 'number_of_watching_users_RCview', + array( 'parsemag', 'escape' ), $wgLang->formatNum( $rc->numberofWatchingusers ) ); } wfRunHooks( 'OldChangesListRecentChangesLine', array(&$this, &$s, $rc) ); - - $s = "
  • $s
  • \n"; wfProfileOut( __METHOD__ ); - return $dateheader . $s; + return "$dateheader
  • $s
  • \n"; } } /** - * Generate a list of changes using an Enhanced system (use javascript). + * Generate a list of changes using an Enhanced system (uses javascript). */ class EnhancedChangesList extends ChangesList { - /** * Add the JavaScript file for enhanced changeslist * @ return string @@ -427,15 +480,18 @@ class EnhancedChangesList extends ChangesList { * Format a line for enhanced recentchange (aka with javascript and block of lines). */ public function recentChangesLine( &$baseRC, $watched = false ) { - global $wgLang, $wgContLang, $wgUser; + global $wgLang, $wgUser; + + wfProfileIn( __METHOD__ ); # Create a specialised object $rc = RCCacheEntry::newFromParent( $baseRC ); # Extract fields from DB into the function scope (rc_xxxx variables) - // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables. + // FIXME: Would be good to replace this extract() call with something + // that explicitly initializes variables. extract( $rc->mAttribs ); - $curIdEq = 'curid=' . $rc_cur_id; + $curIdEq = array( 'curid' => $rc_cur_id ); # If it's a new day, add the headline and flush the cache $date = $wgLang->date( $rc_timestamp, true ); @@ -460,18 +516,21 @@ class EnhancedChangesList extends ChangesList { // Page moves if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { $msg = ( $rc_type == RC_MOVE ) ? "1movedto2" : "1movedto2_redir"; - $clink = wfMsg( $msg, $this->skin->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ), - $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) ); + $clink = wfMsg( $msg, $this->skin->linkKnown( $rc->getTitle(), null, + array(), array( 'redirect' => 'no' ) ), + $this->skin->linkKnown( $rc->getMovedToTitle() ) ); // New unpatrolled pages } else if( $rc->unpatrolled && $rc_type == RC_NEW ) { - $clink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" ); + $clink = $this->skin->linkKnown( $rc->getTitle(), null, array(), + array( 'rcid' => $rc_id ) ); // Log entries } else if( $rc_type == RC_LOG ) { if( $rc_log_type ) { $logtitle = SpecialPage::getTitleFor( 'Log', $rc_log_type ); - $clink = '(' . $this->skin->makeKnownLinkObj( $logtitle, LogPage::logName($rc_log_type) ) . ')'; + $clink = '(' . $this->skin->linkKnown( $logtitle, + LogPage::logName($rc_log_type) ) . ')'; } else { - $clink = $this->skin->makeLinkObj( $rc->getTitle(), '' ); + $clink = $this->skin->link( $rc->getTitle() ); } $watched = false; // Log entries (old format) and special pages @@ -480,14 +539,14 @@ class EnhancedChangesList extends ChangesList { if ( $specialName == 'Log' ) { # Log updates, etc $logname = LogPage::logName( $logtype ); - $clink = '(' . $this->skin->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')'; + $clink = '(' . $this->skin->linkKnown( $rc->getTitle(), $logname ) . ')'; } else { wfDebug( "Unexpected special page in recentchanges\n" ); $clink = ''; } // Edits } else { - $clink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '' ); + $clink = $this->skin->linkKnown( $rc->getTitle() ); } # Don't show unusable diff links @@ -495,49 +554,54 @@ class EnhancedChangesList extends ChangesList { $showdifflinks = false; } - $time = $wgContLang->time( $rc_timestamp, true, true ); + $time = $wgLang->time( $rc_timestamp, true, true ); $rc->watched = $watched; $rc->link = $clink; $rc->timestamp = $time; $rc->numberofWatchingusers = $baseRC->numberofWatchingusers; - # Make "cur" and "diff" links + # Make "cur" and "diff" links. Don't use link(), it's too slow if + # called too many times (50% of CPU time on RecentChanges!). if( $rc->unpatrolled ) { - $rcIdQuery = "&rcid={$rc_id}"; + $rcIdQuery = array( 'rcid' => $rc_id ); } else { - $rcIdQuery = ''; + $rcIdQuery = array(); } - $querycur = $curIdEq."&diff=0&oldid=$rc_this_oldid"; - $querydiff = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid$rcIdQuery"; - $aprops = ' tabindex="'.$baseRC->counter.'"'; - $curLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['cur'], $querycur, '' ,'', $aprops ); + $querycur = $curIdEq + array( 'diff' => '0', 'oldid' => $rc_this_oldid ); + $querydiff = $curIdEq + array( 'diff' => $rc_this_oldid, 'oldid' => + $rc_last_oldid ) + $rcIdQuery; - # Make "diff" an "cur" links if( !$showdifflinks ) { - $curLink = $this->message['cur']; - $diffLink = $this->message['diff']; - } else if( $rc_type == RC_NEW || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { - if( $rc_type != RC_NEW ) { + $curLink = $this->message['cur']; + $diffLink = $this->message['diff']; + } else if( in_array( $rc_type, array(RC_NEW,RC_LOG,RC_MOVE,RC_MOVE_OVER_REDIRECT) ) ) { + if ( $rc_type != RC_NEW ) { $curLink = $this->message['cur']; + } else { + $curUrl = htmlspecialchars( $rc->getTitle()->getLinkUrl( $querycur ) ); + $curLink = "counter}\">{$this->message['cur']}"; } $diffLink = $this->message['diff']; } else { - $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'], $querydiff, '' ,'', $aprops ); + $diffUrl = htmlspecialchars( $rc->getTitle()->getLinkUrl( $querydiff ) ); + $curUrl = htmlspecialchars( $rc->getTitle()->getLinkUrl( $querycur ) ); + $diffLink = "counter}\">{$this->message['diff']}"; + $curLink = "counter}\">{$this->message['cur']}"; } # Make "last" link - if( !$showdifflinks ) { + if( !$showdifflinks || !$rc_last_oldid ) { $lastLink = $this->message['last']; - } else if( $rc_last_oldid == 0 || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { + } else if( $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { $lastLink = $this->message['last']; } else { - $lastLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['last'], - $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery ); + $lastLink = $this->skin->linkKnown( $rc->getTitle(), $this->message['last'], + array(), $curIdEq + array('diff' => $rc_this_oldid, 'oldid' => $rc_last_oldid) + $rcIdQuery ); } # Make user links if( $this->isDeleted($rc,Revision::DELETED_USER) ) { - $rc->userlink = ' ' . wfMsgHtml('rev-deleted-user') . ''; + $rc->userlink = ' ' . wfMsgHtml( 'rev-deleted-user' ) . ''; } else { $rc->userlink = $this->skin->userLink( $rc_user, $rc_user_text ); $rc->usertalklink = $this->skin->userToolLinks( $rc_user, $rc_user_text ); @@ -562,8 +626,12 @@ class EnhancedChangesList extends ChangesList { if( !isset( $this->rc_cache[$secureName] ) ) { $this->rc_cache[$secureName] = array(); } + array_push( $this->rc_cache[$secureName], $rc ); } + + wfProfileOut( __METHOD__ ); + return $ret; } @@ -572,6 +640,9 @@ class EnhancedChangesList extends ChangesList { */ protected function recentChangesBlockGroup( $block ) { global $wgLang, $wgContLang, $wgRCShowChangedSize; + + wfProfileIn( __METHOD__ ); + $r = ''; # Collate list of users @@ -629,17 +700,18 @@ class EnhancedChangesList extends ChangesList { array_push( $users, $text ); } - $users = ' [' . implode( $this->message['semicolon-separator'], $users ) . ']'; + $users = ' [' . + implode( $this->message['semicolon-separator'], $users ) . ']'; # ID for JS visibility toggle $jsid = $this->rcCacheIndex; # onclick handler to toggle hidden/expanded $toggleLink = "onclick='toggleVisibility($jsid); return false'"; # Title for tags - $expandTitle = htmlspecialchars( wfMsg('rc-enhanced-expand') ); - $closeTitle = htmlspecialchars( wfMsg('rc-enhanced-hide') ); + $expandTitle = htmlspecialchars( wfMsg( 'rc-enhanced-expand' ) ); + $closeTitle = htmlspecialchars( wfMsg( 'rc-enhanced-hide' ) ); - $tl = "" . $this->sideArrow() . ""; + $tl = ""; $tl .= ""; $r .= '
    '.$tl.' '; @@ -651,7 +723,7 @@ class EnhancedChangesList extends ChangesList { # Article link if( $namehidden ) { - $r .= ' ' . wfMsgHtml('rev-deleted-event') . ''; + $r .= ' ' . wfMsgHtml( 'rev-deleted-event' ) . ''; } else if( $allLogs ) { $r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched ); } else { @@ -671,7 +743,7 @@ class EnhancedChangesList extends ChangesList { $r .= ' '; if( !$allLogs ) { $r .= '('; - if( !ChangesList::userCan($rcObj,Revision::DELETED_TEXT) ) { + if( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT ) ) { $r .= $nchanges[$n]; } else if( $isnew ) { $r .= $nchanges[$n]; @@ -723,8 +795,11 @@ class EnhancedChangesList extends ChangesList { $r .= '
    '; $r .= ''; foreach( $block as $rcObj ) { - # Get rc_xxxx variables - // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables. + # Extract fields from DB into the function scope (rc_xxxx variables) + // FIXME: Would be good to replace this extract() call with something + // that explicitly initializes variables. + # Classes to apply -- TODO implement + $classes = array(); extract( $rcObj->mAttribs ); #$r .= '
    '.$this->spacerArrow(); @@ -770,9 +845,14 @@ class EnhancedChangesList extends ChangesList { $r .= $rcObj->userlink; $r .= $rcObj->usertalklink; // log action - parent::insertAction( $r, $rcObj ); + $this->insertAction( $r, $rcObj ); // log comment - parent::insertComment( $r, $rcObj ); + $this->insertComment( $r, $rcObj ); + # Rollback + $this->insertRollback( $r, $rcObj ); + # Tags + $this->insertTags( $r, $rcObj, $classes ); + # Mark revision as deleted if( !$rc_log_type && $this->isDeleted($rcObj,Revision::DELETED_TEXT) ) { $r .= ' ' . wfMsgHtml( 'deletedrev' ) . ''; @@ -783,6 +863,9 @@ class EnhancedChangesList extends ChangesList { $r .= "
    \n"; $this->rcCacheIndex++; + + wfProfileOut( __METHOD__ ); + return $r; } @@ -809,7 +892,7 @@ class EnhancedChangesList extends ChangesList { protected function sideArrow() { global $wgContLang; $dir = $wgContLang->isRTL() ? 'l' : 'r'; - return $this->arrow( $dir, '+', wfMsg('rc-enhanced-expand') ); + return $this->arrow( $dir, '+', wfMsg( 'rc-enhanced-expand' ) ); } /** @@ -818,7 +901,7 @@ class EnhancedChangesList extends ChangesList { * @return string HTML tag */ protected function downArrow() { - return $this->arrow( 'd', '-', wfMsg('rc-enhanced-hide') ); + return $this->arrow( 'd', '-', wfMsg( 'rc-enhanced-hide' ) ); } /** @@ -842,9 +925,14 @@ class EnhancedChangesList extends ChangesList { * @return string a HTML formated line (generated using $r) */ protected function recentChangesBlockLine( $rcObj ) { - global $wgContLang, $wgRCShowChangedSize; - # Get rc_xxxx variables - // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables. + global $wgRCShowChangedSize; + + wfProfileIn( __METHOD__ ); + + # Extract fields from DB into the function scope (rc_xxxx variables) + // FIXME: Would be good to replace this extract() call with something + // that explicitly initializes variables. + $classes = array(); // TODO implement extract( $rcObj->mAttribs ); $curIdEq = "curid={$rc_cur_id}"; @@ -867,13 +955,14 @@ class EnhancedChangesList extends ChangesList { } # Diff and hist links if ( $rc_type != RC_LOG ) { - $r .= ' ('. $rcObj->difflink . $this->message['semicolon-separator']; - $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ')'; + $r .= ' ('. $rcObj->difflink . $this->message['semicolon-separator']; + $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), $this->message['hist'], + $curIdEq.'&action=history' ) . ')'; } $r .= ' . . '; # Character diff - if( $wgRCShowChangedSize ) { - $r .= ( $rcObj->getCharacterDifference() == '' ? '' : $rcObj->getCharacterDifference() . ' . . ' ) ; + if( $wgRCShowChangedSize && ($cd = $rcObj->getCharacterDifference()) ) { + $r .= "$cd . . "; } # User/talk $r .= ' '.$rcObj->userlink . $rcObj->usertalklink; @@ -886,19 +975,17 @@ class EnhancedChangesList extends ChangesList { $this->skin, LogPage::extractParams($rc_params), true, true ); } } - # Edit or log comment - if( $rc_type != RC_MOVE && $rc_type != RC_MOVE_OVER_REDIRECT ) { - // log comment - if ( $this->isDeleted($rcObj,LogPage::DELETED_COMMENT) ) { - $r .= ' ' . wfMsg('rev-deleted-comment') . ''; - } else { - $r .= $this->skin->commentBlock( $rc_comment, $rcObj->getTitle() ); - } - } + $this->insertComment( $r, $rcObj ); + $this->insertRollback( $r, $rcObj ); + # Tags + $this->insertTags( $r, $rcObj, $classes ); # Show how many people are watching this if enabled $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers); $r .= "
    \n"; + + wfProfileOut( __METHOD__ ); + return $r; } @@ -910,6 +997,9 @@ class EnhancedChangesList extends ChangesList { if( count ( $this->rc_cache ) == 0 ) { return ''; } + + wfProfileIn( __METHOD__ ); + $blockOut = ''; foreach( $this->rc_cache as $block ) { if( count( $block ) < 2 ) { @@ -918,6 +1008,9 @@ class EnhancedChangesList extends ChangesList { $blockOut .= $this->recentChangesBlockGroup( $block ); } } + + wfProfileOut( __METHOD__ ); + return '
    '.$blockOut.'
    '; }