X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fchanges%2FEnhancedChangesList.php;h=cbbbfebc850238888980ca5f3ac57bf4d32b50d8;hb=6c9a2923fe1ee3a65cb027be5e781772f2b12fbd;hp=03f63f673f5e8157927d6fe162025fc19781f1b0;hpb=dae4c94d893057345f62a3d498fb85c0a54de5a6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php index 03f63f673f..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'] ); } @@ -243,8 +246,7 @@ class EnhancedChangesList extends ChangesList { $text = $userlink; $text .= $this->getLanguage()->getDirMark(); if ( $count > 1 ) { - // @todo FIXME: Hardcoded '×'. Should be a message. - $formattedCount = $this->getLanguage()->formatNum( $count ) . '×'; + $formattedCount = $this->msg( 'ntimes' )->numParams( $count )->escaped(); $text .= ' ' . $this->msg( 'parentheses' )->rawParams( $formattedCount )->escaped(); } array_push( $users, $text ); @@ -330,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, @@ -338,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, @@ -366,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 @@ -609,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'] ); } @@ -686,10 +696,19 @@ class EnhancedChangesList extends ChangesList { } $attribs = $data['attribs']; unset( $data['attribs'] ); - $attribs = wfArrayFilterByKey( $attribs, [ Sanitizer::class, 'isReservedDataAttribute' ] ); + $attribs = wfArrayFilterByKey( $attribs, function ( $key ) { + 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'] ); @@ -700,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 ); @@ -763,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 . '
'; } /**