X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fchanges%2FEnhancedChangesList.php;h=3f106bdc278532e2fd3c5ea53f1ec6a237f59227;hp=e5916bd7f25467e0a5ad44c563ad92076a8cca83;hb=f8659ae6ea90d7bc8ce28bfc1caa56153878836f;hpb=33f676d70df3d22c2ee77b9153917dacfc1f694c diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php index e5916bd7f2..3f106bdc27 100644 --- a/includes/changes/EnhancedChangesList.php +++ b/includes/changes/EnhancedChangesList.php @@ -270,6 +270,17 @@ class EnhancedChangesList extends ChangesList { $queryParams['curid'] = $curId; + # Sub-entries + $lines = ''; + foreach ( $block as $i => $rcObj ) { + $line = $this->getLineData( $block, $rcObj, $queryParams ); + $lines .= $line; + if ( !$line ) { + // completely ignore this RC entry if we don't want to render it + unset( $block[$i] ); + } + } + $r .= $this->getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden ); $r .= ' . . '; @@ -299,116 +310,133 @@ class EnhancedChangesList extends ChangesList { $r .= $this->numberofWatchingusers( $block[0]->numberofWatchingusers ); $r .= ''; - # Sub-entries - foreach ( $block as $rcObj ) { - # Classes to apply -- TODO implement - $classes = array(); - $type = $rcObj->mAttribs['rc_type']; - $data = array(); - - $trClass = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched - ? ' class="mw-enhanced-watched"' : ''; - $separator = ' . . '; - - $data['recentChangesFlags'] = array( - 'newpage' => $type == RC_NEW, - 'minor' => $rcObj->mAttribs['rc_minor'], - 'unpatrolled' => $rcObj->unpatrolled, - 'bot' => $rcObj->mAttribs['rc_bot'], - ); + if ( !$lines ) { + // if there are no lines to be rendered (all aborted by hook), don't render the block + return ''; + } - $params = $queryParams; + $r .= $lines; + $r .= "\n"; - if ( $rcObj->mAttribs['rc_this_oldid'] != 0 ) { - $params['oldid'] = $rcObj->mAttribs['rc_this_oldid']; - } + $this->rcCacheIndex++; + + return $r; + } - # Log timestamp - if ( $type == RC_LOG ) { - $link = $rcObj->timestamp; + /** + * @param RCCacheEntry[] $block + * @param RCCacheEntry $rcObj + * @param array $queryParams + * @return string + * @throws Exception + * @throws FatalError + * @throws MWException + */ + protected function getLineData( array $block, RCCacheEntry $rcObj, array $queryParams = array() ) { + $RCShowChangedSize = $this->getConfig()->get( 'RCShowChangedSize' ); + + # Classes to apply -- TODO implement + $classes = array(); + $type = $rcObj->mAttribs['rc_type']; + $data = array(); + + $trClass = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched + ? ' class="mw-enhanced-watched"' : ''; + $separator = ' . . '; + + $data['recentChangesFlags'] = array( + 'newpage' => $type == RC_NEW, + 'minor' => $rcObj->mAttribs['rc_minor'], + 'unpatrolled' => $rcObj->unpatrolled, + 'bot' => $rcObj->mAttribs['rc_bot'], + ); + + $params = $queryParams; + + if ( $rcObj->mAttribs['rc_this_oldid'] != 0 ) { + $params['oldid'] = $rcObj->mAttribs['rc_this_oldid']; + } + + # Log timestamp + if ( $type == RC_LOG ) { + $link = $rcObj->timestamp; # Revision link - } elseif ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) { - $link = '' . $rcObj->timestamp . ' '; - } else { - $link = Linker::linkKnown( - $rcObj->getTitle(), - $rcObj->timestamp, - array(), - $params - ); - if ( $this->isDeleted( $rcObj, Revision::DELETED_TEXT ) ) { - $link = '' . $link . ' '; - } + } elseif ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) { + $link = '' . $rcObj->timestamp . ' '; + } else { + $link = Linker::linkKnown( + $rcObj->getTitle(), + $rcObj->timestamp, + array(), + $params + ); + if ( $this->isDeleted( $rcObj, Revision::DELETED_TEXT ) ) { + $link = '' . $link . ' '; } - $data['timestampLink'] = $link; + } + $data['timestampLink'] = $link; - $currentAndLastLinks = ''; - if ( !$type == RC_LOG || $type == RC_NEW ) { - $currentAndLastLinks .= ' ' . $this->msg( 'parentheses' )->rawParams( + $currentAndLastLinks = ''; + if ( !$type == RC_LOG || $type == RC_NEW ) { + $currentAndLastLinks .= ' ' . $this->msg( 'parentheses' )->rawParams( $rcObj->curlink . - $this->message['pipe-separator'] . - $rcObj->lastlink + $this->message['pipe-separator'] . + $rcObj->lastlink )->escaped(); - } - $data['currentAndLastLinks'] = $currentAndLastLinks; - $data['separatorAfterCurrentAndLastLinks'] = $separator; - - # Character diff - if ( $RCShowChangedSize ) { - $cd = $this->formatCharacterDifference( $rcObj ); - if ( $cd !== '' ) { - $data['characterDiff'] = $cd; - $data['separatorAfterCharacterDiff'] = $separator; - } - } + } + $data['currentAndLastLinks'] = $currentAndLastLinks; + $data['separatorAfterCurrentAndLastLinks'] = $separator; - if ( $rcObj->mAttribs['rc_type'] == RC_LOG ) { - $data['logEntry'] = $this->insertLogEntry( $rcObj ); - } else { - # User links - $data['userLink'] = $rcObj->userlink; - $data['userTalkLink'] = $rcObj->usertalklink; - $data['comment'] = $this->insertComment( $rcObj ); + # Character diff + if ( $RCShowChangedSize ) { + $cd = $this->formatCharacterDifference( $rcObj ); + if ( $cd !== '' ) { + $data['characterDiff'] = $cd; + $data['separatorAfterCharacterDiff'] = $separator; } + } - # Rollback - $data['rollback'] = $this->getRollback( $rcObj ); - - # Tags - $data['tags'] = $this->getTags( $rcObj, $classes ); + if ( $rcObj->mAttribs['rc_type'] == RC_LOG ) { + $data['logEntry'] = $this->insertLogEntry( $rcObj ); + } else { + # User links + $data['userLink'] = $rcObj->userlink; + $data['userTalkLink'] = $rcObj->usertalklink; + $data['comment'] = $this->insertComment( $rcObj ); + } - // give the hook a chance to modify the data - $success = Hooks::run( 'EnhancedChangesListModifyLineData', - array( $this, &$data, $block, $rcObj ) ); - if ( !$success ) { - // skip entry if hook aborted it - continue; - } + # Rollback + $data['rollback'] = $this->getRollback( $rcObj ); - $line = ''; - if ( isset( $data['recentChangesFlags'] ) ) { - $line .= $this->recentChangesFlags( $data['recentChangesFlags'] ); - unset( $data['recentChangesFlags'] ); - } - $line .= ' '; - - if ( isset( $data['timestampLink'] ) ) { - $line .= '' . $data['timestampLink'] . ''; - unset( $data['timestampLink'] ); - } + # Tags + $data['tags'] = $this->getTags( $rcObj, $classes ); - // everything else: makes it easier for extensions to add or remove data - $line .= implode( '', $data ); + // give the hook a chance to modify the data + $success = Hooks::run( 'EnhancedChangesListModifyLineData', + array( $this, &$data, $block, $rcObj ) ); + if ( !$success ) { + // skip entry if hook aborted it + return ''; + } - $line .= "\n"; + $line = ''; + if ( isset( $data['recentChangesFlags'] ) ) { + $line .= $this->recentChangesFlags( $data['recentChangesFlags'] ); + unset( $data['recentChangesFlags'] ); + } + $line .= ' '; - $r .= $line; + if ( isset( $data['timestampLink'] ) ) { + $line .= '' . $data['timestampLink'] . ''; + unset( $data['timestampLink'] ); } - $r .= "\n"; - $this->rcCacheIndex++; + // everything else: makes it easier for extensions to add or remove data + $line .= implode( '', $data ); - return $r; + $line .= "\n"; + + return $line; } /**