From f6d65e533c62f6deb21342d4901ece24497b433e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 4 Jun 2015 07:31:04 +0200 Subject: Update to MediaWiki 1.25.1 --- includes/changes/EnhancedChangesList.php | 213 ++++++++++++++++--------------- 1 file changed, 112 insertions(+), 101 deletions(-) (limited to 'includes/changes/EnhancedChangesList.php') diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php index 4ab77297..19277f10 100644 --- a/includes/changes/EnhancedChangesList.php +++ b/includes/changes/EnhancedChangesList.php @@ -34,6 +34,7 @@ class EnhancedChangesList extends ChangesList { /** * @param IContextSource|Skin $obj + * @throws MWException */ public function __construct( $obj ) { if ( $obj instanceof Skin ) { @@ -88,7 +89,6 @@ class EnhancedChangesList extends ChangesList { * @return string */ public function recentChangesLine( &$baseRC, $watched = false ) { - wfProfileIn( __METHOD__ ); $date = $this->getLanguage()->userDate( $baseRC->mAttribs['rc_timestamp'], @@ -109,8 +109,6 @@ class EnhancedChangesList extends ChangesList { $cacheEntry = $this->cacheEntryFactory->newFromRecentChange( $baseRC, $watched ); $this->addCacheEntry( $cacheEntry ); - wfProfileOut( __METHOD__ ); - return $ret; } @@ -160,7 +158,6 @@ class EnhancedChangesList extends ChangesList { * @return string */ protected function recentChangesBlockGroup( $block ) { - wfProfileIn( __METHOD__ ); # Add the namespace and title of the block as part of the class $classes = array( 'mw-collapsible', 'mw-collapsed', 'mw-enhanced-rc' ); @@ -184,14 +181,12 @@ class EnhancedChangesList extends ChangesList { $isnew = false; $allBots = true; $allMinors = true; - $curId = $currentRevision = 0; + $curId = 0; # Some catalyst variables... $namehidden = true; $allLogs = true; - $oldid = ''; $RCShowChangedSize = $this->getConfig()->get( 'RCShowChangedSize' ); foreach ( $block as $rcObj ) { - $oldid = $rcObj->mAttribs['rc_last_oldid']; if ( $rcObj->mAttribs['rc_type'] == RC_NEW ) { $isnew = true; } @@ -215,9 +210,6 @@ class EnhancedChangesList extends ChangesList { if ( !$curId && $rcObj->mAttribs['rc_cur_id'] ) { $curId = $rcObj->mAttribs['rc_cur_id']; } - if ( !$currentRevision && $rcObj->mAttribs['rc_this_oldid'] ) { - $currentRevision = $rcObj->mAttribs['rc_this_oldid']; - } if ( !$rcObj->mAttribs['rc_bot'] ) { $allBots = false; @@ -278,87 +270,7 @@ class EnhancedChangesList extends ChangesList { $queryParams['curid'] = $curId; - # Changes message - static $nchanges = array(); - static $sinceLastVisitMsg = array(); - - $n = count( $block ); - if ( !isset( $nchanges[$n] ) ) { - $nchanges[$n] = $this->msg( 'nchanges' )->numParams( $n )->escaped(); - } - - $sinceLast = 0; - $unvisitedOldid = null; - /** @var $rcObj RCCacheEntry */ - foreach ( $block as $rcObj ) { - // Same logic as below inside main foreach - if ( $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched ) { - $sinceLast++; - $unvisitedOldid = $rcObj->mAttribs['rc_last_oldid']; - } - } - if ( !isset( $sinceLastVisitMsg[$sinceLast] ) ) { - $sinceLastVisitMsg[$sinceLast] = - $this->msg( 'enhancedrc-since-last-visit' )->numParams( $sinceLast )->escaped(); - } - - # Total change link - $r .= ' '; - $logtext = ''; - /** @var $block0 RecentChange */ - $block0 = $block[0]; - if ( !$allLogs ) { - if ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) { - $logtext .= $nchanges[$n]; - } elseif ( $isnew ) { - $logtext .= $nchanges[$n]; - } else { - $logtext .= Linker::link( - $block0->getTitle(), - $nchanges[$n], - array(), - $queryParams + array( - 'diff' => $currentRevision, - 'oldid' => $oldid, - ), - array( 'known', 'noclasses' ) - ); - if ( $sinceLast > 0 && $sinceLast < $n ) { - $logtext .= $this->message['pipe-separator'] . Linker::link( - $block0->getTitle(), - $sinceLastVisitMsg[$sinceLast], - array(), - $queryParams + array( - 'diff' => $currentRevision, - 'oldid' => $unvisitedOldid, - ), - array( 'known', 'noclasses' ) - ); - } - } - } - - # History - if ( $allLogs ) { - // don't show history link for logs - } elseif ( $namehidden || !$block0->getTitle()->exists() ) { - $logtext .= $this->message['pipe-separator'] . $this->message['enhancedrc-history']; - } else { - $params = $queryParams; - $params['action'] = 'history'; - - $logtext .= $this->message['pipe-separator'] . - Linker::linkKnown( - $block0->getTitle(), - $this->message['enhancedrc-history'], - array(), - $params - ); - } - - if ( $logtext !== '' ) { - $r .= $this->msg( 'parentheses' )->rawParams( $logtext )->escaped(); - } + $r .= $this->getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden ); $r .= ' . . '; @@ -384,7 +296,7 @@ class EnhancedChangesList extends ChangesList { } $r .= $users; - $r .= $this->numberofWatchingusers( $block0->numberofWatchingusers ); + $r .= $this->numberofWatchingusers( $block[0]->numberofWatchingusers ); $r .= ''; # Sub-entries @@ -468,11 +380,117 @@ class EnhancedChangesList extends ChangesList { $this->rcCacheIndex++; - wfProfileOut( __METHOD__ ); - return $r; } + /** + * Generates amount of changes (linking to diff ) & link to history. + * + * @param array $block + * @param array $queryParams + * @param bool $allLogs + * @param bool $isnew + * @param bool $namehidden + * @return string + */ + protected function getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden ) { + # Changes message + static $nchanges = array(); + static $sinceLastVisitMsg = array(); + + $n = count( $block ); + if ( !isset( $nchanges[$n] ) ) { + $nchanges[$n] = $this->msg( 'nchanges' )->numParams( $n )->escaped(); + } + + $sinceLast = 0; + $unvisitedOldid = null; + /** @var $rcObj RCCacheEntry */ + foreach ( $block as $rcObj ) { + // Same logic as below inside main foreach + if ( $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched ) { + $sinceLast++; + $unvisitedOldid = $rcObj->mAttribs['rc_last_oldid']; + } + } + if ( !isset( $sinceLastVisitMsg[$sinceLast] ) ) { + $sinceLastVisitMsg[$sinceLast] = + $this->msg( 'enhancedrc-since-last-visit' )->numParams( $sinceLast )->escaped(); + } + + $currentRevision = 0; + foreach ( $block as $rcObj ) { + if ( !$currentRevision ) { + $currentRevision = $rcObj->mAttribs['rc_this_oldid']; + } + } + + # Total change link + $links = array(); + /** @var $block0 RecentChange */ + $block0 = $block[0]; + $last = $block[count( $block ) - 1]; + if ( !$allLogs ) { + if ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) { + $links['total-changes'] = $nchanges[$n]; + } elseif ( $isnew ) { + $links['total-changes'] = $nchanges[$n]; + } else { + $links['total-changes'] = Linker::link( + $block0->getTitle(), + $nchanges[$n], + array(), + $queryParams + array( + 'diff' => $currentRevision, + 'oldid' => $last->mAttribs['rc_last_oldid'], + ), + array( 'known', 'noclasses' ) + ); + if ( $sinceLast > 0 && $sinceLast < $n ) { + $links['total-changes-since-last'] = Linker::link( + $block0->getTitle(), + $sinceLastVisitMsg[$sinceLast], + array(), + $queryParams + array( + 'diff' => $currentRevision, + 'oldid' => $unvisitedOldid, + ), + array( 'known', 'noclasses' ) + ); + } + } + } + + # History + if ( $allLogs ) { + // don't show history link for logs + } elseif ( $namehidden || !$block0->getTitle()->exists() ) { + $links['history'] = $this->message['enhancedrc-history']; + } else { + $params = $queryParams; + $params['action'] = 'history'; + + $links['history'] = Linker::linkKnown( + $block0->getTitle(), + $this->message['enhancedrc-history'], + array(), + $params + ); + } + + # Allow others to alter, remove or add to these links + Hooks::run( 'EnhancedChangesList::getLogText', + array( $this, &$links, $block ) ); + + if ( !$links ) { + return ''; + } + + $logtext = implode( $this->message['pipe-separator'], $links ); + $logtext = $this->msg( 'parentheses' )->rawParams( $logtext )->escaped(); + return ' ' . $logtext; + } + /** * Enhanced RC ungrouped line. * @@ -480,7 +498,6 @@ class EnhancedChangesList extends ChangesList { * @return string A HTML formatted line (generated using $r) */ protected function recentChangesBlockLine( $rcObj ) { - wfProfileIn( __METHOD__ ); $query['curid'] = $rcObj->mAttribs['rc_cur_id']; $type = $rcObj->mAttribs['rc_type']; @@ -552,8 +569,6 @@ class EnhancedChangesList extends ChangesList { $r .= "\n"; - wfProfileOut( __METHOD__ ); - return $r; } @@ -568,8 +583,6 @@ class EnhancedChangesList extends ChangesList { return ''; } - wfProfileIn( __METHOD__ ); - $blockOut = ''; foreach ( $this->rc_cache as $block ) { if ( count( $block ) < 2 ) { @@ -579,8 +592,6 @@ class EnhancedChangesList extends ChangesList { } } - wfProfileOut( __METHOD__ ); - return '
' . $blockOut . '
'; } -- cgit v1.2.2