X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fchanges%2FEnhancedChangesList.php;h=e5916bd7f25467e0a5ad44c563ad92076a8cca83;hb=88f243d2c4b87f8de34e2a9c91a5570cbb0636c1;hp=545ea26e19a9d8be761c97c2842ade4c6079c2dd;hpb=0c7c5c297df43f5a9a3c1f6ecc601a9b9435a649;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php index 545ea26e19..e5916bd7f2 100644 --- a/includes/changes/EnhancedChangesList.php +++ b/includes/changes/EnhancedChangesList.php @@ -378,8 +378,12 @@ class EnhancedChangesList extends ChangesList { $data['tags'] = $this->getTags( $rcObj, $classes ); // give the hook a chance to modify the data - Hooks::run( 'EnhancedChangesListModifyLineData', + $success = Hooks::run( 'EnhancedChangesListModifyLineData', array( $this, &$data, $block, $rcObj ) ); + if ( !$success ) { + // skip entry if hook aborted it + continue; + } $line = ''; if ( isset( $data['recentChangesFlags'] ) ) { @@ -522,6 +526,8 @@ class EnhancedChangesList extends ChangesList { * @return string A HTML formatted line (generated using $r) */ protected function recentChangesBlockLine( $rcObj ) { + $data = array(); + $query['curid'] = $rcObj->mAttribs['rc_cur_id']; $type = $rcObj->mAttribs['rc_type']; @@ -536,32 +542,33 @@ class EnhancedChangesList extends ChangesList { } $classes[] = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched'; - $r = Html::openElement( 'table', array( 'class' => $classes ) ) . - Html::openElement( 'tr' ); - $r .= ''; # Flag and Timestamp - $r .= $this->recentChangesFlags( array( + $data['recentChangesFlags'] = array( 'newpage' => $type == RC_NEW, 'minor' => $rcObj->mAttribs['rc_minor'], 'unpatrolled' => $rcObj->unpatrolled, 'bot' => $rcObj->mAttribs['rc_bot'], - ) ); - $r .= ' ' . $rcObj->timestamp . ' '; + ); + // timestamp is not really a link here, but is called timestampLink + // for consistency with EnhancedChangesListModifyLineData + $data['timestampLink'] = $rcObj->timestamp; + # Article or log link if ( $logType ) { $logPage = new LogPage( $logType ); $logTitle = SpecialPage::getTitleFor( 'Log', $logType ); $logName = $logPage->getName()->escaped(); - $r .= $this->msg( 'parentheses' ) + $data['logLink'] = $this->msg( 'parentheses' ) ->rawParams( Linker::linkKnown( $logTitle, $logName ) )->escaped(); } else { - $this->insertArticleLink( $r, $rcObj, $rcObj->unpatrolled, $rcObj->watched ); + $data['articleLink'] = $this->getArticleLink( $rcObj, $rcObj->unpatrolled, $rcObj->watched ); } + # Diff and hist links if ( $type != RC_LOG ) { $query['action'] = 'history'; - $r .= ' ' . $this->msg( 'parentheses' ) + $data['historyLink'] = ' ' . $this->msg( 'parentheses' ) ->rawParams( $rcObj->difflink . $this->message['pipe-separator'] . Linker::linkKnown( $rcObj->getTitle(), $this->message['hist'], @@ -569,31 +576,61 @@ class EnhancedChangesList extends ChangesList { $query ) )->escaped(); } - $r .= ' . . '; + $data['separatorAfterLinks'] = ' . . '; + # Character diff if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) { $cd = $this->formatCharacterDifference( $rcObj ); if ( $cd !== '' ) { - $r .= $cd . ' . . '; + $data['characterDiff'] = $cd; + $data['separatorAftercharacterDiff'] = ' . . '; } } if ( $type == RC_LOG ) { - $r .= $this->insertLogEntry( $rcObj ); + $data['logEntry'] = $this->insertLogEntry( $rcObj ); } else { - $r .= ' ' . $rcObj->userlink . $rcObj->usertalklink; - $r .= $this->insertComment( $rcObj ); - $this->insertRollback( $r, $rcObj ); + $data['userLink'] = $rcObj->userlink; + $data['userTalkLink'] = $rcObj->usertalklink; + $data['comment'] = $this->insertComment( $rcObj ); + $data['rollback'] = $this->getRollback( $rcObj ); } # Tags - $this->insertTags( $r, $rcObj, $classes ); + $data['tags'] = $this->getTags( $rcObj, $classes ); + # Show how many people are watching this if enabled - $r .= $this->numberofWatchingusers( $rcObj->numberofWatchingusers ); + $data['watchingUsers'] = $this->numberofWatchingusers( $rcObj->numberofWatchingusers ); - $r .= "\n"; + // give the hook a chance to modify the data + $success = Hooks::run( 'EnhancedChangesListModifyBlockLineData', + array( $this, &$data, $rcObj ) ); + if ( !$success ) { + // skip entry if hook aborted it + return ''; + } - return $r; + $line = Html::openElement( 'table', array( 'class' => $classes ) ) . + Html::openElement( 'tr' ); + $line .= ''; + + if ( isset( $data['recentChangesFlags'] ) ) { + $line .= $this->recentChangesFlags( $data['recentChangesFlags'] ); + unset( $data['recentChangesFlags'] ); + } + + if ( isset( $data['timestampLink'] ) ) { + $line .= ' ' . $data['timestampLink']; + unset( $data['timestampLink'] ); + } + $line .= ' '; + + // everything else: makes it easier for extensions to add or remove data + $line .= implode( '', $data ); + + $line .= "\n"; + + return $line; } /**