X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fchanges%2FChangesList.php;h=5b8559e68ad618f1f1a50dae7a3c1ac80c548310;hb=d2b5c86eac27b0ce60076502f195b1b37d762c60;hp=2182c6cb7eee25dfed159aa1bf771898ce54931c;hpb=055780106a1d863c936850501fc51894f816ee27;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/changes/ChangesList.php b/includes/changes/ChangesList.php index 2182c6cb7e..5b8559e68a 100644 --- a/includes/changes/ChangesList.php +++ b/includes/changes/ChangesList.php @@ -41,6 +41,9 @@ class ChangesList extends ContextSource { protected $rclistOpen; protected $rcMoveIndex; + /** @var callable */ + protected $changeLinePrefixer; + /** @var BagOStuff */ protected $watchMsgCache; @@ -102,7 +105,7 @@ class ChangesList extends ContextSource { * * @since 1.27 * - * @param RecentChange $rc Passed by reference + * @param RecentChange &$rc Passed by reference * @param bool $watched (default false) * @param int $linenumber (default null) * @@ -169,17 +172,19 @@ class ChangesList extends ContextSource { * @return array of classes */ protected function getHTMLClasses( $rc, $watched ) { - $classes = []; + $classes = [ self::CSS_CLASS_PREFIX . 'line' ]; $logType = $rc->mAttribs['rc_log_type']; if ( $logType ) { + $classes[] = self::CSS_CLASS_PREFIX . 'log'; $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'log-' . $logType ); } else { + $classes[] = self::CSS_CLASS_PREFIX . 'edit'; $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns' . $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] ); - $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns-' . - $rc->mAttribs['rc_namespace'] ); } + $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns-' . + $rc->mAttribs['rc_namespace'] ); // Indicate watched status on the line to allow for more // comprehensive styling. @@ -362,7 +367,7 @@ class ChangesList extends ContextSource { } /** - * @param string $s HTML to update + * @param string &$s HTML to update * @param mixed $rc_timestamp */ public function insertDateHeader( &$s, $rc_timestamp ) { @@ -379,7 +384,7 @@ class ChangesList extends ContextSource { } /** - * @param string $s HTML to update + * @param string &$s HTML to update * @param Title $title * @param string $logtype */ @@ -392,8 +397,8 @@ class ChangesList extends ContextSource { } /** - * @param string $s HTML to update - * @param RecentChange $rc + * @param string &$s HTML to update + * @param RecentChange &$rc * @param bool|null $unpatrolled Unused variable, since 1.27. */ public function insertDiffHist( &$s, &$rc, $unpatrolled = null ) { @@ -442,7 +447,7 @@ class ChangesList extends ContextSource { } /** - * @param string $s Article link will be appended to this string, in place. + * @param string &$s Article link will be appended to this string, in place. * @param RecentChange $rc * @param bool $unpatrolled * @param bool $watched @@ -453,7 +458,7 @@ class ChangesList extends ContextSource { } /** - * @param RecentChange $rc + * @param RecentChange &$rc * @param bool $unpatrolled * @param bool $watched * @return string HTML @@ -508,7 +513,7 @@ class ChangesList extends ContextSource { /** * Insert time timestamp string from $rc into $s * - * @param string $s HTML to update + * @param string &$s HTML to update * @param RecentChange $rc */ public function insertTimestamp( &$s, $rc ) { @@ -571,7 +576,9 @@ class ChangesList extends ContextSource { return ''; } $cache = $this->watchMsgCache; - return $cache->getWithSetCallback( $count, $cache::TTL_INDEFINITE, + return $cache->getWithSetCallback( + $cache->makeKey( 'watching-users-msg', $count ), + $cache::TTL_INDEFINITE, function () use ( $count ) { return $this->msg( 'number_of_watching_users_RCview' ) ->numParams( $count )->escaped(); @@ -620,8 +627,8 @@ class ChangesList extends ContextSource { /** Inserts a rollback link * - * @param string $s - * @param RecentChange $rc + * @param string &$s + * @param RecentChange &$rc */ public function insertRollback( &$s, &$rc ) { if ( $rc->mAttribs['rc_type'] == RC_EDIT @@ -658,9 +665,9 @@ class ChangesList extends ContextSource { } /** - * @param string $s - * @param RecentChange $rc - * @param array $classes + * @param string &$s + * @param RecentChange &$rc + * @param array &$classes */ public function insertTags( &$s, &$rc, &$classes ) { if ( empty( $rc->mAttribs['ts_tags'] ) ) { @@ -678,7 +685,7 @@ class ChangesList extends ContextSource { /** * @param RecentChange $rc - * @param array $classes + * @param array &$classes * @return string * @since 1.26 */ @@ -753,11 +760,12 @@ class ChangesList extends ContextSource { switch ( $type ) { case RecentChange::SRC_EDIT: case RecentChange::SRC_NEW: - $attrs[ 'data-mw-revid' ] = $rc->mAttribs['rc_this_oldid']; + $attrs['data-mw-revid'] = $rc->mAttribs['rc_this_oldid']; break; case RecentChange::SRC_LOG: - $attrs[ 'data-mw-logid' ] = $rc->mAttribs['rc_logid']; - $attrs[ 'data-mw-logaction' ] = $rc->mAttribs['rc_log_type'] . '/' . $rc->mAttribs['rc_log_action']; + $attrs['data-mw-logid'] = $rc->mAttribs['rc_logid']; + $attrs['data-mw-logaction'] = + $rc->mAttribs['rc_log_type'] . '/' . $rc->mAttribs['rc_log_action']; break; } @@ -765,4 +773,15 @@ class ChangesList extends ContextSource { return $attrs; } + + /** + * Sets the callable that generates a change line prefix added to the beginning of each line. + * + * @param callable $prefixer Callable to run that generates the change line prefix. + * Takes three parameters: a RecentChange object, a ChangesList object, + * and whether the current entry is a grouped entry. + */ + public function setChangeLinePrefixer( callable $prefixer ) { + $this->changeLinePrefixer = $prefixer; + } }