X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fchanges%2FEnhancedChangesList.php;h=8f32ba20078a2ce44632e55cd410686cc2e626b6;hb=7462d3075a23095fd627cebeb0f66e081ad2bede;hp=51a26baab72ceea63bc8b522412af567cea78078;hpb=2e9c34c562297f3cfa0fa4d78c00a5adb603f607;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php index 51a26baab7..8f32ba2007 100644 --- a/includes/changes/EnhancedChangesList.php +++ b/includes/changes/EnhancedChangesList.php @@ -78,6 +78,7 @@ class EnhancedChangesList extends ChangesList { $this->rclistOpen = false; $this->getOutput()->addModuleStyles( [ 'mediawiki.icon', + 'mediawiki.interface.helpers.styles', 'mediawiki.special.changeslist', 'mediawiki.special.changeslist.enhanced', ] ); @@ -183,9 +184,7 @@ class EnhancedChangesList extends ChangesList { $tableClasses[] = Sanitizer::escapeClass( 'mw-changeslist-ns' . $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title'] ); } - if ( $block[0]->watched - && $block[0]->mAttribs['rc_timestamp'] >= $block[0]->watched - ) { + if ( $block[0]->watched ) { $tableClasses[] = 'mw-changeslist-line-watched'; } else { $tableClasses[] = 'mw-changeslist-line-not-watched'; @@ -218,7 +217,7 @@ class EnhancedChangesList extends ChangesList { foreach ( $block as $rcObj ) { // If all log actions to this page were hidden, then don't // give the name of the affected page for this block! - if ( !$this->isDeleted( $rcObj, LogPage::DELETED_ACTION ) ) { + if ( !static::isDeleted( $rcObj, LogPage::DELETED_ACTION ) ) { $namehidden = false; } $u = $rcObj->userlink; @@ -259,7 +258,8 @@ class EnhancedChangesList extends ChangesList { } elseif ( $allLogs ) { $articleLink = $this->maybeWatchedLink( $block[0]->link, $block[0]->watched ); } else { - $articleLink = $this->getArticleLink( $block[0], $block[0]->unpatrolled, $block[0]->watched ); + $articleLink = $this->getArticleLink( + $block[0], $block[0]->unpatrolled, $block[0]->watched ); } $queryParams['curid'] = $curId; @@ -385,14 +385,12 @@ class EnhancedChangesList extends ChangesList { $lineParams = [ 'targetTitle' => $rcObj->getTitle() ]; $classes = [ 'mw-enhanced-rc' ]; - if ( $rcObj->watched - && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched - ) { + if ( $rcObj->watched ) { $classes[] = 'mw-enhanced-watched'; } $classes = array_merge( $classes, $this->getHTMLClasses( $rcObj, $rcObj->watched ) ); - $separator = ' . . '; + $separator = ' '; $data['recentChangesFlags'] = [ 'newpage' => $type == RC_NEW, @@ -420,7 +418,7 @@ class EnhancedChangesList extends ChangesList { [], $params ); - if ( $this->isDeleted( $rcObj, Revision::DELETED_TEXT ) ) { + if ( static::isDeleted( $rcObj, Revision::DELETED_TEXT ) ) { $link = '' . $link . ' '; } } @@ -502,7 +500,7 @@ class EnhancedChangesList extends ChangesList { /** * Generates amount of changes (linking to diff ) & link to history. * - * @param array $block + * @param RCCacheEntry[] $block * @param array $queryParams * @param bool $allLogs * @param bool $isnew @@ -528,7 +526,7 @@ class EnhancedChangesList extends ChangesList { /** @var RCCacheEntry $rcObj */ foreach ( $block as $rcObj ) { // Same logic as below inside main foreach - if ( $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched ) { + if ( $rcObj->watched ) { $sinceLast++; $unvisitedOldid = $rcObj->mAttribs['rc_last_oldid']; } @@ -551,32 +549,42 @@ class EnhancedChangesList extends ChangesList { $block0 = $block[0]; $last = $block[count( $block ) - 1]; if ( !$allLogs ) { - if ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) || + if ( $isnew || - $rcObj->mAttribs['rc_type'] == RC_CATEGORIZE + $rcObj->mAttribs['rc_type'] == RC_CATEGORIZE || + !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) { - $links['total-changes'] = $nchanges[$n]; + $links['total-changes'] = Html::rawElement( 'span', [], $nchanges[$n] ); } else { - $links['total-changes'] = $this->linkRenderer->makeKnownLink( - $block0->getTitle(), - new HtmlArmor( $nchanges[$n] ), - [ 'class' => 'mw-changeslist-groupdiff' ], - $queryParams + [ - 'diff' => $currentRevision, - 'oldid' => $last->mAttribs['rc_last_oldid'], - ] + $links['total-changes'] = Html::rawElement( 'span', [], + $this->linkRenderer->makeKnownLink( + $block0->getTitle(), + new HtmlArmor( $nchanges[$n] ), + [ 'class' => 'mw-changeslist-groupdiff' ], + $queryParams + [ + 'diff' => $currentRevision, + 'oldid' => $last->mAttribs['rc_last_oldid'], + ] + ) + ); + } + + if ( + $rcObj->mAttribs['rc_type'] != RC_CATEGORIZE && + $sinceLast > 0 && + $sinceLast < $n + ) { + $links['total-changes-since-last'] = Html::rawElement( 'span', [], + $this->linkRenderer->makeKnownLink( + $block0->getTitle(), + new HtmlArmor( $sinceLastVisitMsg[$sinceLast] ), + [ 'class' => 'mw-changeslist-groupdiff' ], + $queryParams + [ + 'diff' => $currentRevision, + 'oldid' => $unvisitedOldid, + ] + ) ); - if ( $sinceLast > 0 && $sinceLast < $n ) { - $links['total-changes-since-last'] = $this->linkRenderer->makeKnownLink( - $block0->getTitle(), - new HtmlArmor( $sinceLastVisitMsg[$sinceLast] ), - [ 'class' => 'mw-changeslist-groupdiff' ], - $queryParams + [ - 'diff' => $currentRevision, - 'oldid' => $unvisitedOldid, - ] - ); - } } } @@ -584,17 +592,19 @@ class EnhancedChangesList extends ChangesList { 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']; + $links['history'] = Html::rawElement( 'span', [], $this->message['enhancedrc-history'] ); } else { $params = $queryParams; $params['action'] = 'history'; - $links['history'] = $this->linkRenderer->makeKnownLink( + $links['history'] = Html::rawElement( 'span', [], + $this->linkRenderer->makeKnownLink( $block0->getTitle(), new HtmlArmor( $this->message['enhancedrc-history'] ), [ 'class' => 'mw-changeslist-history' ], $params - ); + ) + ); } # Allow others to alter, remove or add to these links @@ -605,8 +615,8 @@ class EnhancedChangesList extends ChangesList { return ''; } - $logtext = implode( $this->message['pipe-separator'], $links ); - $logtext = $this->msg( 'parentheses' )->rawParams( $logtext )->escaped(); + $logtext = Html::rawElement( 'span', [ 'class' => 'mw-changeslist-links' ], + implode( ' ', $links ) ); return ' ' . $logtext; } @@ -652,10 +662,9 @@ class EnhancedChangesList extends ChangesList { $logPage = new LogPage( $logType ); $logTitle = SpecialPage::getTitleFor( 'Log', $logType ); $logName = $logPage->getName()->text(); - $data['logLink'] = $this->msg( 'parentheses' ) - ->rawParams( - $this->linkRenderer->makeKnownLink( $logTitle, $logName ) - )->escaped(); + $data['logLink'] = Html::rawElement( 'span', [ 'class' => 'mw-changeslist-links' ], + $this->linkRenderer->makeKnownLink( $logTitle, $logName ) + ); } else { $data['articleLink'] = $this->getArticleLink( $rcObj, $rcObj->unpatrolled, $rcObj->watched ); } @@ -663,16 +672,16 @@ class EnhancedChangesList extends ChangesList { # Diff and hist links if ( $type != RC_LOG && $type != RC_CATEGORIZE ) { $query['action'] = 'history'; - $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query ); + $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query, false ); } - $data['separatorAfterLinks'] = ' . . '; + $data['separatorAfterLinks'] = ' '; # Character diff if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) { $cd = $this->formatCharacterDifference( $rcObj ); if ( $cd !== '' ) { $data['characterDiff'] = $cd; - $data['separatorAftercharacterDiff'] = ' . . '; + $data['separatorAftercharacterDiff'] = ' '; } } @@ -685,7 +694,7 @@ class EnhancedChangesList extends ChangesList { $data['userTalkLink'] = $rcObj->usertalklink; $data['comment'] = $this->insertComment( $rcObj ); if ( $type == RC_CATEGORIZE ) { - $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query ); + $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query, false ); } $data['rollback'] = $this->getRollback( $rcObj ); } @@ -743,7 +752,11 @@ class EnhancedChangesList extends ChangesList { ] ); // everything else: makes it easier for extensions to add or remove data - $line .= implode( '', $data ); + foreach ( $data as $key => $dataItem ) { + $line .= Html::rawElement( 'span', [ + 'class' => 'mw-changeslist-line-inner-' . $key, + ], $dataItem ); + } $line .= "\n"; @@ -758,9 +771,10 @@ class EnhancedChangesList extends ChangesList { * * @param RCCacheEntry $rc * @param array $query array of key/value pairs to append as a query string + * @param bool $useParentheses (optional) Wrap comments in parentheses where needed * @return string HTML */ - public function getDiffHistLinks( RCCacheEntry $rc, array $query ) { + public function getDiffHistLinks( RCCacheEntry $rc, array $query, $useParentheses = true ) { $pageTitle = $rc->getTitle(); if ( $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE ) { // For categorizations we must swap the category title with the page title! @@ -772,15 +786,23 @@ class EnhancedChangesList extends ChangesList { } } - $retVal = ' ' . $this->msg( 'parentheses' ) - ->rawParams( $rc->difflink . $this->message['pipe-separator'] - . $this->linkRenderer->makeKnownLink( - $pageTitle, - new HtmlArmor( $this->message['hist'] ), - [ 'class' => 'mw-changeslist-history' ], - $query - ) )->escaped(); - return $retVal; + $histLink = $this->linkRenderer->makeKnownLink( + $pageTitle, + new HtmlArmor( $this->message['hist'] ), + [ 'class' => 'mw-changeslist-history' ], + $query + ); + if ( $useParentheses ) { + $retVal = $this->msg( 'parentheses' ) + ->rawParams( $rc->difflink . $this->message['pipe-separator'] + . $histLink )->escaped(); + } else { + $retVal = Html::rawElement( 'span', [ 'class' => 'mw-changeslist-links' ], + Html::rawElement( 'span', [], $rc->difflink ) . + Html::rawElement( 'span', [], $histLink ) + ); + } + return ' ' . $retVal; } /**