X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fchanges%2FChangesList.php;h=bf275b36d3e56a9fdc72c92f4eb223c9363de42e;hb=8a14f73a643f61bb13121a114aa082f35ec657b6;hp=b1dff1492488ef1a8b0fb2b4c46231786b5f05ce;hpb=d2b7662bbae2b6ff6599e72eb449cb2ce444e877;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/changes/ChangesList.php b/includes/changes/ChangesList.php index b1dff14924..34adea9c4c 100644 --- a/includes/changes/ChangesList.php +++ b/includes/changes/ChangesList.php @@ -23,7 +23,7 @@ */ use MediaWiki\Linker\LinkRenderer; use MediaWiki\MediaWikiServices; -use Wikimedia\Rdbms\ResultWrapper; +use Wikimedia\Rdbms\IResultWrapper; class ChangesList extends ContextSource { const CSS_CLASS_PREFIX = 'mw-changeslist-'; @@ -58,8 +58,6 @@ class ChangesList extends ContextSource { protected $filterGroups; /** - * Changeslist constructor - * * @param Skin|IContextSource $obj * @param array $filterGroups Array of ChangesListFilterGroup objects (currently optional) */ @@ -194,7 +192,7 @@ class ChangesList extends ContextSource { * @param RecentChange|RCCacheEntry $rc * @param string|bool $watched Optionally timestamp for adding watched class * - * @return array of classes + * @return string[] List of CSS class names */ protected function getHTMLClasses( $rc, $watched ) { $classes = [ self::CSS_CLASS_PREFIX . 'line' ]; @@ -291,13 +289,16 @@ class ChangesList extends ContextSource { $this->rcCacheIndex = 0; $this->lastdate = ''; $this->rclistOpen = false; - $this->getOutput()->addModuleStyles( 'mediawiki.special.changeslist' ); + $this->getOutput()->addModuleStyles( [ + 'mediawiki.interface.helpers.styles', + 'mediawiki.special.changeslist' + ] ); return '
'; } /** - * @param ResultWrapper|array $rows + * @param IResultWrapper|array $rows */ public function initChangesListRows( $rows ) { Hooks::run( 'ChangesListInitRows', [ $this, $rows ] ); @@ -394,6 +395,36 @@ class ChangesList extends ContextSource { return $out; } + /** + * Render the date and time of a revision in the current user language + * based on whether the user is able to view this information or not. + * @param Revision $rev + * @param User $user + * @param Language $lang + * @param Title|null $title (optional) where Title does not match + * the Title associated with the Revision + * @internal For usage by Pager classes only (e.g. HistoryPager and ContribsPager). + * @return string HTML + */ + public static function revDateLink( Revision $rev, User $user, Language $lang, $title = null ) { + $ts = $rev->getTimestamp(); + $date = $lang->userTimeAndDate( $ts, $user ); + if ( $rev->userCan( Revision::DELETED_TEXT, $user ) ) { + $link = MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink( + $title ?? $rev->getTitle(), + $date, + [ 'class' => 'mw-changeslist-date' ], + [ 'oldid' => $rev->getId() ] + ); + } else { + $link = htmlspecialchars( $date ); + } + if ( $rev->isDeleted( Revision::DELETED_TEXT ) ) { + $link = "$link"; + } + return $link; + } + /** * @param string &$s HTML to update * @param mixed $rc_timestamp @@ -454,11 +485,9 @@ class ChangesList extends ContextSource { ); } if ( $rc->mAttribs['rc_type'] == RC_CATEGORIZE ) { - $diffhist = $diffLink . $this->message['pipe-separator'] . $this->message['hist']; + $histLink = $this->message['hist']; } else { - $diffhist = $diffLink . $this->message['pipe-separator']; - # History link - $diffhist .= $this->linkRenderer->makeKnownLink( + $histLink = $this->linkRenderer->makeKnownLink( $rc->getTitle(), new HtmlArmor( $this->message['hist'] ), [ 'class' => 'mw-changeslist-history' ], @@ -469,20 +498,11 @@ class ChangesList extends ContextSource { ); } - // @todo FIXME: Hard coded ". .". Is there a message for this? Should there be? - $s .= $this->msg( 'parentheses' )->rawParams( $diffhist )->escaped() . - ' . . '; - } - - /** - * @param string &$s Article link will be appended to this string, in place. - * @param RecentChange $rc - * @param bool $unpatrolled - * @param bool $watched - * @deprecated since 1.27, use getArticleLink instead. - */ - public function insertArticleLink( &$s, RecentChange $rc, $unpatrolled, $watched ) { - $s .= $this->getArticleLink( $rc, $unpatrolled, $watched ); + $s .= Html::rawElement( 'div', [ 'class' => 'mw-changeslist-links' ], + Html::rawElement( 'span', [], $diffLink ) . + Html::rawElement( 'span', [], $histLink ) + ) . + ' '; } /** @@ -527,6 +547,7 @@ class ChangesList extends ContextSource { * and a separator * * @param RecentChange $rc + * @deprecated use revDateLink instead. * @return string HTML fragment */ public function getTimestamp( $rc ) { @@ -535,7 +556,7 @@ class ChangesList extends ContextSource { htmlspecialchars( $this->getLanguage()->userTime( $rc->mAttribs['rc_timestamp'], $this->getUser() - ) ) . ' . . '; + ) ) . ' '; } /** @@ -561,7 +582,13 @@ class ChangesList extends ContextSource { } else { $s .= $this->getLanguage()->getDirMark() . Linker::userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] ); - $s .= Linker::userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] ); + $s .= Linker::userToolLinks( + $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'], + false, 0, null, + // The text content of tools is not wrapped with parenthesises or "piped". + // This will be handled in CSS (T205581). + false + ); } } @@ -590,7 +617,13 @@ class ChangesList extends ContextSource { return ' ' . $this->msg( 'rev-deleted-comment' )->escaped() . ''; } else { - return Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() ); + return Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle(), + // Whether section links should refer to local page (using default false) + false, + // wikid to generate links for (using default null) */ + null, + // whether parentheses should be rendered as part of the message + false ); } } @@ -607,7 +640,7 @@ class ChangesList extends ContextSource { return $this->watchMsgCache->getWithSetCallback( "watching-users-msg:$count", function () use ( $count ) { - return $this->msg( 'number_of_watching_users_RCview' ) + return $this->msg( 'number-of-watching-users-for-recent-changes' ) ->numParams( $count )->escaped(); } );