X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fchanges%2FEnhancedChangesList.php;h=b59437e0946c128cb1f8b8f492a39aa478042ae5;hb=682e2b9c6b7c439fe5ba0be083f0479af95e1db3;hp=d912e3a2dd3496354123aac14773f26b8e3968d0;hpb=f1a890c34cebd8744bf3a6277734275fb975575a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php index d912e3a2dd..b59437e094 100644 --- a/includes/changes/EnhancedChangesList.php +++ b/includes/changes/EnhancedChangesList.php @@ -83,15 +83,16 @@ class EnhancedChangesList extends ChangesList { /** * Format a line for enhanced recentchange (aka with javascript and block of lines). * - * @param RecentChange $baseRC + * @param RecentChange $rc * @param bool $watched + * @param int $linenumber (default null) * * @return string */ - public function recentChangesLine( &$baseRC, $watched = false ) { + public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) { $date = $this->getLanguage()->userDate( - $baseRC->mAttribs['rc_timestamp'], + $rc->mAttribs['rc_timestamp'], $this->getUser() ); @@ -106,7 +107,7 @@ class EnhancedChangesList extends ChangesList { $this->lastdate = $date; } - $cacheEntry = $this->cacheEntryFactory->newFromRecentChange( $baseRC, $watched ); + $cacheEntry = $this->cacheEntryFactory->newFromRecentChange( $rc, $watched ); $this->addCacheEntry( $cacheEntry ); return $ret; @@ -283,6 +284,10 @@ class EnhancedChangesList extends ChangesList { // Further down are some assumptions that $block is a 0-indexed array // with (count-1) as last key. Let's make sure it is. $block = array_values( $block ); + if ( empty( $block ) ) { + // if we can't show anything, don't display this block altogether + return ''; + } $r .= $this->getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden ); @@ -401,6 +406,8 @@ class EnhancedChangesList extends ChangesList { if ( $rcObj->mAttribs['rc_type'] == RC_LOG ) { $data['logEntry'] = $this->insertLogEntry( $rcObj ); + } elseif ( $this->isCategorizationWithoutRevision( $rcObj ) ) { + $data['comment'] = $this->insertComment( $rcObj ); } else { # User links $data['userLink'] = $rcObj->userlink; @@ -453,6 +460,10 @@ class EnhancedChangesList extends ChangesList { * @return string */ protected function getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden ) { + if ( empty( $block ) ) { + return ''; + } + # Changes message static $nchanges = array(); static $sinceLastVisitMsg = array(); @@ -489,7 +500,7 @@ class EnhancedChangesList extends ChangesList { /** @var $block0 RecentChange */ $block0 = $block[0]; $last = $block[count( $block ) - 1]; - if ( !$allLogs ) { + if ( !$allLogs && $rcObj->mAttribs['rc_type'] != RC_CATEGORIZE ) { if ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) { $links['total-changes'] = $nchanges[$n]; } elseif ( $isnew ) { @@ -521,7 +532,7 @@ class EnhancedChangesList extends ChangesList { } # History - if ( $allLogs ) { + if ( $allLogs || $rcObj->mAttribs['rc_type'] == RC_CATEGORIZE ) { // don't show history link for logs } elseif ( $namehidden || !$block0->getTitle()->exists() ) { $links['history'] = $this->message['enhancedrc-history']; @@ -597,15 +608,9 @@ class EnhancedChangesList extends ChangesList { } # Diff and hist links - if ( $type != RC_LOG ) { + if ( $type == RC_LOG && $type != RC_CATEGORIZE ) { $query['action'] = 'history'; - $data['historyLink'] = ' ' . $this->msg( 'parentheses' ) - ->rawParams( $rcObj->difflink . $this->message['pipe-separator'] . Linker::linkKnown( - $rcObj->getTitle(), - $this->message['hist'], - array(), - $query - ) )->escaped(); + $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query ); } $data['separatorAfterLinks'] = ' . . '; @@ -620,10 +625,15 @@ class EnhancedChangesList extends ChangesList { if ( $type == RC_LOG ) { $data['logEntry'] = $this->insertLogEntry( $rcObj ); + } elseif ( $this->isCategorizationWithoutRevision( $rcObj ) ) { + $data['comment'] = $this->insertComment( $rcObj ); } else { $data['userLink'] = $rcObj->userlink; $data['userTalkLink'] = $rcObj->usertalklink; $data['comment'] = $this->insertComment( $rcObj ); + if ( $type == RC_CATEGORIZE ) { + $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query ); + } $data['rollback'] = $this->getRollback( $rcObj ); } @@ -664,6 +674,33 @@ class EnhancedChangesList extends ChangesList { return $line; } + /** + * Returns value to be used in 'historyLink' element of $data param in + * EnhancedChangesListModifyBlockLineData hook. + * + * @since 1.27 + * + * @param RCCacheEntry $rc + * @param array $query array of key/value pairs to append as a query string + * @return string HTML + */ + public function getDiffHistLinks( RCCacheEntry $rc, array $query ) { + $pageTitle = $rc->getTitle(); + if ( $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE ) { + // For categorizations we must swap the category title with the page title! + $pageTitle = Title::newFromID( $rc->getAttribute( 'rc_cur_id' ) ); + } + + $retVal = ' ' . $this->msg( 'parentheses' ) + ->rawParams( $rc->difflink . $this->message['pipe-separator'] . Linker::linkKnown( + $pageTitle, + $this->message['hist'], + array(), + $query + ) )->escaped(); + return $retVal; + } + /** * If enhanced RC is in use, this function takes the previously cached * RC lines, arranges them, and outputs the HTML