X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fchanges%2FEnhancedChangesList.php;h=def6457ebf026e567861f6e510941723162b8a7a;hp=64d4aa79e480ead6681a419cdc952224607b438f;hb=89539f2aa1b158fdcc703ad053e2580cb97a6385;hpb=885f3775cdcb5a61bece504190ff0b636483ab0f diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php index 64d4aa79e4..def6457ebf 100644 --- a/includes/changes/EnhancedChangesList.php +++ b/includes/changes/EnhancedChangesList.php @@ -91,27 +91,28 @@ class EnhancedChangesList extends ChangesList { /** * Format a line for enhanced recentchange (aka with javascript and block of lines). * - * @param RecentChange $rc + * @param RecentChange &$rc * @param bool $watched * @param int $linenumber (default null) * * @return string */ public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) { - $date = $this->getLanguage()->userDate( $rc->mAttribs['rc_timestamp'], $this->getUser() ); + if ( $this->lastdate === '' ) { + $this->lastdate = $date; + } $ret = ''; - # If it's a new day, add the headline and flush the cache - if ( $date != $this->lastdate ) { - # Process current cache + # If it's a new day, flush the cache and update $this->lastdate + if ( $date !== $this->lastdate ) { + # Process current cache (uses $this->lastdate to generate a heading) $ret = $this->recentChangesBlock(); $this->rc_cache = []; - $ret .= Xml::element( 'h4', null, $date ) . "\n"; $this->lastdate = $date; } @@ -171,12 +172,14 @@ class EnhancedChangesList extends ChangesList { $recentChangesFlags = $this->getConfig()->get( 'RecentChangesFlags' ); # Add the namespace and title of the block as part of the class - $tableClasses = [ 'mw-collapsible', 'mw-collapsed', 'mw-enhanced-rc' ]; + $tableClasses = [ 'mw-collapsible', 'mw-collapsed', 'mw-enhanced-rc', 'mw-changeslist-line' ]; if ( $block[0]->mAttribs['rc_log_type'] ) { # Log entry + $tableClasses[] = 'mw-changeslist-log'; $tableClasses[] = Sanitizer::escapeClass( 'mw-changeslist-log-' . $block[0]->mAttribs['rc_log_type'] ); } else { + $tableClasses[] = 'mw-changeslist-edit'; $tableClasses[] = Sanitizer::escapeClass( 'mw-changeslist-ns' . $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title'] ); } @@ -329,6 +332,11 @@ class EnhancedChangesList extends ChangesList { implode( $this->message['semicolon-separator'], $users ) )->escaped(); + $prefix = ''; + if ( is_callable( $this->changeLinePrefixer ) ) { + $prefix = call_user_func( $this->changeLinePrefixer, $block[0], $this, true ); + } + $templateParams = [ 'articleLink' => $articleLink, 'charDifference' => $charDifference, @@ -337,6 +345,7 @@ class EnhancedChangesList extends ChangesList { 'lines' => $lines, 'logText' => $logText, 'numberofWatchingusers' => $numberofWatchingusers, + 'prefix' => $prefix, 'rev-deleted-event' => $revDeletedMsg, 'tableClasses' => $tableClasses, 'timestamp' => $block[0]->timestamp, @@ -365,7 +374,7 @@ class EnhancedChangesList extends ChangesList { $type = $rcObj->mAttribs['rc_type']; $data = []; - $lineParams = []; + $lineParams = [ 'targetTitle' => $rcObj->getTitle() ]; $classes = [ 'mw-enhanced-rc' ]; if ( $rcObj->watched @@ -608,8 +617,10 @@ class EnhancedChangesList extends ChangesList { if ( $logType ) { # Log entry + $classes[] = 'mw-changeslist-log'; $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-' . $logType ); } else { + $classes[] = 'mw-changeslist-edit'; $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns' . $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title'] ); } @@ -689,8 +700,15 @@ class EnhancedChangesList extends ChangesList { return $key === 'class' || Sanitizer::isReservedDataAttribute( $key ); } ); + $prefix = ''; + if ( is_callable( $this->changeLinePrefixer ) ) { + $prefix = call_user_func( $this->changeLinePrefixer, $rcObj, $this, false ); + } + $line = Html::openElement( 'table', $attribs ) . Html::openElement( 'tr' ); - $line .= ''; + $line .= Html::rawElement( 'td', [], '' ); + $line .= Html::rawElement( 'td', [ 'class' => 'mw-changeslist-line-prefix' ], $prefix ); + $line .= ''; if ( isset( $data['recentChangesFlags'] ) ) { $line .= $this->recentChangesFlags( $data['recentChangesFlags'] ); @@ -701,7 +719,12 @@ class EnhancedChangesList extends ChangesList { $line .= ' ' . $data['timestampLink']; unset( $data['timestampLink'] ); } - $line .= ' '; + $line .= ' '; + $line .= Html::openElement( 'td', [ + 'class' => 'mw-changeslist-line-inner', + // Used for reliable determination of the affiliated page + 'data-target-page' => $rcObj->getTitle(), + ] ); // everything else: makes it easier for extensions to add or remove data $line .= implode( '', $data ); @@ -764,7 +787,11 @@ class EnhancedChangesList extends ChangesList { } } - return '
' . $blockOut . '
'; + if ( $blockOut === '' ) { + return ''; + } + // $this->lastdate is kept up to date by recentChangesLine() + return Xml::element( 'h4', null, $this->lastdate ) . "\n
" . $blockOut . '
'; } /**