69 $this->
skin = $obj->getSkin();
75 $this->watchMsgCache =
new HashBagOStuff( [
'maxKeys' => 50 ] );
76 $this->linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
92 if ( Hooks::run(
'FetchChangesList', [ $user, &$sk, &$list ] ) ) {
115 throw new RuntimeException(
'recentChangesLine should be implemented' );
123 $this->watchlist =
$value;
139 if ( !isset( $this->message ) ) {
141 'cur',
'diff',
'hist',
'enhancedrc-history',
'last',
'blocklink',
'history',
142 'semicolon-separator',
'pipe-separator' ] as $msg
144 $this->message[$msg] = $this->
msg( $msg )->escaped();
157 foreach ( array_keys( $this->
getConfig()->
get(
'RecentChangesFlags' ) ) as $flag ) {
175 $classes = [ self::CSS_CLASS_PREFIX .
'line' ];
176 $logType = $rc->mAttribs[
'rc_log_type'];
179 $classes[] = self::CSS_CLASS_PREFIX .
'log';
180 $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX .
'log-' . $logType );
182 $classes[] = self::CSS_CLASS_PREFIX .
'edit';
183 $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX .
'ns' .
184 $rc->mAttribs[
'rc_namespace'] .
'-' . $rc->mAttribs[
'rc_title'] );
186 $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX .
'ns-' .
187 $rc->mAttribs[
'rc_namespace'] );
191 $classes[] = $watched && $rc->mAttribs[
'rc_timestamp'] >= $watched
192 ? self::CSS_CLASS_PREFIX .
'line-watched'
193 : self::CSS_CLASS_PREFIX .
'line-not-watched';
209 if ( $this->filterGroups !==
null ) {
210 foreach ( $this->filterGroups as $filterGroup ) {
211 foreach ( $filterGroup->getFilters() as $filter ) {
212 $filter->applyCssClassIfNeeded( $this, $rc, $classes );
229 static $map = [
'minoredit' =>
'minor',
'botedit' =>
'bot' ];
230 static $flagInfos =
null;
232 if ( is_null( $flagInfos ) ) {
236 $flagInfos[$key][
'letter'] =
$value[
'letter'];
237 $flagInfos[$key][
'title'] =
$value[
'title'];
239 $flagInfos[$key][
'class'] = isset(
$value[
'class'] ) ?
$value[
'class'] : $key;
246 if ( isset( $map[$flag] ) ) {
250 $info = $flagInfos[$flag];
251 return Html::element(
'abbr', [
252 'class' => $info[
'class'],
262 $this->rc_cache = [];
263 $this->rcMoveIndex = 0;
264 $this->rcCacheIndex = 0;
265 $this->lastdate =
'';
266 $this->rclistOpen =
false;
267 $this->
getOutput()->addModuleStyles(
'mediawiki.special.changeslist' );
269 return '<div class="mw-changeslist">';
276 Hooks::run(
'ChangesListInitRows', [ $this,
$rows ] );
296 $szdiff = $new - $old;
301 static $fastCharDiff = [];
302 if ( !isset( $fastCharDiff[
$code] ) ) {
303 $fastCharDiff[
$code] = $config->get(
'MiserMode' )
304 ||
$context->
msg(
'rc-change-size' )->plain() ===
'$1';
307 $formattedSize =
$lang->formatNum( $szdiff );
309 if ( !$fastCharDiff[
$code] ) {
310 $formattedSize =
$context->
msg(
'rc-change-size', $formattedSize )->text();
313 if ( abs( $szdiff ) > abs( $config->get(
'RCChangedSizeThreshold' ) ) ) {
319 if ( $szdiff === 0 ) {
320 $formattedSizeClass =
'mw-plusminus-null';
321 } elseif ( $szdiff > 0 ) {
322 $formattedSize =
'+' . $formattedSize;
323 $formattedSizeClass =
'mw-plusminus-pos';
325 $formattedSizeClass =
'mw-plusminus-neg';
328 $formattedTotalSize =
$context->
msg(
'rc-change-size-new' )->numParams( $new )->text();
330 return Html::element( $tag,
331 [
'dir' =>
'ltr',
'class' => $formattedSizeClass,
'title' => $formattedTotalSize ],
332 $context->
msg(
'parentheses', $formattedSize )->plain() ) .
$lang->getDirMark();
343 $oldlen = $old->mAttribs[
'rc_old_len'];
346 $newlen = $new->mAttribs[
'rc_new_len'];
348 $newlen = $old->mAttribs[
'rc_new_len'];
351 if ( $oldlen ===
null || $newlen ===
null ) {
363 $out = $this->rclistOpen ?
"</ul>\n" :
'';
374 # Make date header if necessary
376 if ( $date != $this->lastdate ) {
377 if ( $this->lastdate !=
'' ) {
380 $s .= Xml::element(
'h4',
null, $date ) .
"\n<ul class=\"special\">";
381 $this->lastdate = $date;
382 $this->rclistOpen =
true;
392 $page =
new LogPage( $logtype );
393 $logname = $page->getName()->setContext( $this->
getContext() )->text();
394 $s .= $this->
msg(
'parentheses' )->rawParams(
395 $this->linkRenderer->makeKnownLink( $title, $logname )
407 $rc->mAttribs[
'rc_type'] ==
RC_NEW ||
408 $rc->mAttribs[
'rc_type'] ==
RC_LOG ||
411 $diffLink = $this->message[
'diff'];
413 $diffLink = $this->message[
'diff'];
416 'curid' => $rc->mAttribs[
'rc_cur_id'],
417 'diff' => $rc->mAttribs[
'rc_this_oldid'],
418 'oldid' => $rc->mAttribs[
'rc_last_oldid']
421 $diffLink = $this->linkRenderer->makeKnownLink(
424 [
'class' =>
'mw-changeslist-diff' ],
429 $diffhist = $diffLink . $this->message[
'pipe-separator'] . $this->message[
'hist'];
431 $diffhist = $diffLink . $this->message[
'pipe-separator'];
433 $diffhist .= $this->linkRenderer->makeKnownLink(
436 [
'class' =>
'mw-changeslist-history' ],
438 'curid' => $rc->mAttribs[
'rc_cur_id'],
439 'action' =>
'history'
445 $s .= $this->
msg(
'parentheses' )->rawParams( $diffhist )->escaped() .
446 ' <span class="mw-changeslist-separator">. .</span> ';
469 if ( $rc->getTitle()->isRedirect() ) {
470 $params = [
'redirect' =>
'no' ];
473 $articlelink = $this->linkRenderer->makeLink(
476 [
'class' =>
'mw-changeslist-title' ],
480 $articlelink =
'<span class="history-deleted">' . $articlelink .
'</span>';
482 # To allow for boldening pages watched by this user
483 $articlelink =
"<span class=\"mw-title\">{$articlelink}</span>";
485 $articlelink .= $this->
getLanguage()->getDirMark();
487 # TODO: Deprecate the $s argument, it seems happily unused.
489 # Avoid PHP 7.1 warning from passing $this by reference
491 Hooks::run(
'ChangesListInsertArticleLink',
492 [ &
$changesList, &$articlelink, &
$s, &$rc, $unpatrolled, $watched ] );
494 return "{$s} {$articlelink}";
506 return $this->message[
'semicolon-separator'] .
'<span class="mw-changeslist-date">' .
508 $rc->mAttribs[
'rc_timestamp'],
510 ) .
'</span> <span class="mw-changeslist-separator">. .</span> ';
531 $s .=
' <span class="history-deleted">' .
532 $this->
msg(
'rev-deleted-user' )->escaped() .
'</span>';
535 $rc->mAttribs[
'rc_user_text'] );
548 $formatter->setContext( $this->
getContext() );
549 $formatter->setShowUserToolLinks(
true );
552 return $formatter->getActionText() .
" $mark" . $formatter->getComment();
562 return ' <span class="history-deleted">' .
563 $this->
msg(
'rev-deleted-comment' )->escaped() .
'</span>';
580 function () use ( $count ) {
581 return $this->
msg(
'number_of_watching_users_RCview' )
582 ->numParams( $count )->escaped();
594 return ( $rc->mAttribs[
'rc_deleted'] & $field ) == $field;
605 public static function userCan( $rc, $field,
User $user =
null ) {
606 if ( $rc->mAttribs[
'rc_type'] ==
RC_LOG ) {
620 return '<strong class="mw-watched">' .
$link .
'</strong>';
622 return '<span class="mw-rc-unwatched">' .
$link .
'</span>';
632 if ( $rc->mAttribs[
'rc_type'] ==
RC_EDIT
633 && $rc->mAttribs[
'rc_this_oldid']
634 && $rc->mAttribs[
'rc_cur_id']
636 $page = $rc->getTitle();
639 if ( $this->
getUser()->isAllowed(
'rollback' )
640 && $rc->mAttribs[
'page_latest'] == $rc->mAttribs[
'rc_this_oldid']
644 'id' => $rc->mAttribs[
'rc_this_oldid'],
645 'user' => $rc->mAttribs[
'rc_user'],
646 'user_text' => $rc->mAttribs[
'rc_user_text'],
647 'deleted' => $rc->mAttribs[
'rc_deleted']
671 if ( empty( $rc->mAttribs[
'ts_tags'] ) ) {
676 $rc->mAttribs[
'ts_tags'],
680 $classes = array_merge( $classes, $newClasses );
681 $s .=
' ' . $tagSummary;
711 $isPatrolled = $rc->mAttribs[
'rc_patrolled'];
712 $rcType = $rc->mAttribs[
'rc_type'];
713 $rcLogType = $rc->mAttribs[
'rc_log_type'];
715 $isPatrolled = $rc->rc_patrolled;
716 $rcType = $rc->rc_type;
717 $rcLogType = $rc->rc_log_type;
720 if ( !$isPatrolled ) {
721 if ( $user->useRCPatrol() ) {
724 if ( $user->useNPPatrol() && $rcType ==
RC_NEW ) {
727 if ( $user->useFilePatrol() && $rcLogType ==
'upload' ) {
745 return intval( $rcObj->getAttribute(
'rc_type' ) ) ===
RC_CATEGORIZE
746 && intval( $rcObj->getAttribute(
'rc_this_oldid' ) ) === 0;
757 $type = $rc->getAttribute(
'rc_source' );
761 $attrs[
'data-mw-revid'] = $rc->mAttribs[
'rc_this_oldid'];
764 $attrs[
'data-mw-logid'] = $rc->mAttribs[
'rc_logid'];
765 $attrs[
'data-mw-logaction'] =
766 $rc->mAttribs[
'rc_log_type'] .
'/' . $rc->mAttribs[
'rc_log_action'];
770 $attrs[
'data-mw-ts' ] = $rc->getAttribute(
'rc_timestamp' );
783 $this->changeLinePrefixer = $prefixer;
$wgRecentChangesFlags
Flags (letter symbols) shown in recent changes and watchlist to indicate certain types of edits.
interface is intended to be more or less compatible with the PHP memcached client.
getWithSetCallback( $key, $ttl, $callback, $flags=0)
Get an item with the given key, regenerating and setting it if not found.
static newFromContext(IContextSource $context, array $groups=[])
Fetch an appropriate changes list class for the specified context Some users might want to use an enh...
maybeWatchedLink( $link, $watched=false)
static userCan( $rc, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this revision,...
recentChangesFlags( $flags, $nothing=' ')
Returns the appropriate flags for new page, minor change and patrolling.
setWatchlistDivs( $value=true)
Sets the list to use a "<li class='watchlist-(namespace)-(page)'>" tag.
formatCharacterDifference(RecentChange $old, RecentChange $new=null)
Format the character difference of one or several changes.
insertDateHeader(&$s, $rc_timestamp)
insertRollback(&$s, &$rc)
Inserts a rollback link.
showAsUnpatrolled(RecentChange $rc)
static isUnpatrolled( $rc, User $user)
recentChangesLine(&$rc, $watched=false, $linenumber=null)
Format a line.
getDataAttributes(RecentChange $rc)
Get recommended data attributes for a change line.
numberofWatchingusers( $count)
Returns the string which indicates the number of watching users.
getHTMLClasses( $rc, $watched)
Get an array of default HTML class attributes for the change.
insertLog(&$s, $title, $logtype)
callable $changeLinePrefixer
getTags(RecentChange $rc, array &$classes)
getArticleLink(&$rc, $unpatrolled, $watched)
insertUserRelatedLinks(&$s, &$rc)
Insert links to user page, user talk page and eventually a blocking link.
insertArticleLink(&$s, RecentChange $rc, $unpatrolled, $watched)
static showCharacterDifference( $old, $new, IContextSource $context=null)
Show formatted char difference.
getRollback(RecentChange $rc)
endRecentChangesList()
Returns text for the end of RC.
static flag( $flag, IContextSource $context=null)
Make an "<abbr>" element for a given change flag.
LinkRenderer $linkRenderer
preCacheMessages()
As we use the same small set of messages in various methods and that they are called often,...
insertLogEntry( $rc)
Insert a formatted action.
setChangeLinePrefixer(callable $prefixer)
Sets the callable that generates a change line prefix added to the beginning of each line.
static isDeleted( $rc, $field)
Determine if said field of a revision is hidden.
insertTags(&$s, &$rc, &$classes)
insertComment( $rc)
Insert a formatted comment.
insertExtra(&$s, &$rc, &$classes)
__construct( $obj, array $filterGroups=[])
Changeslist constructor.
initChangesListRows( $rows)
getTimestamp( $rc)
Get the timestamp from $rc formatted with current user's settings and a separator.
isCategorizationWithoutRevision( $rcObj)
Determines whether a revision is linked to this change; this may not be the case when the categorizat...
getHTMLClassesForFilters( $rc)
Get an array of CSS classes attributed to filters for this row.
insertDiffHist(&$s, &$rc, $unpatrolled=null)
insertTimestamp(&$s, $rc)
Insert time timestamp string from $rc into $s.
beginRecentChangesList()
Returns text for the start of the tabular part of RC.
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
getUser()
Get the User object.
getConfig()
Get the Config object.
getOutput()
Get the OutputPage object.
getLanguage()
Get the Language object.
getContext()
Get the base IContextSource object.
setContext(IContextSource $context)
Set the IContextSource object.
Simple store for keeping values in an associative array for the current process.
Marks HTML that shouldn't be escaped.
static generateRollback( $rev, IContextSource $context=null, $options=[ 'verify'])
Generate a rollback link for a given revision.
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
static commentBlock( $comment, $title=null, $local=false, $wikiId=null)
Wrap a comment in standard punctuation and formatting if it's non-empty, otherwise return empty strin...
static userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null)
Generate standard user tool links (talk, contributions, block link, etc.)
static userCanBitfield( $bitfield, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this log row,...
Class to simplify the use of log pages.
Utility class for creating new RC entries.
static getMain()
Static methods.
static userCanBitfield( $bitfield, $field, User $user=null, Title $title=null)
Determine if the current user is allowed to view a particular field of this revision,...
The main skin class which provides methods and properties for all other skins.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a skin(according to that user 's preference)
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction $rows
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges $changesList
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
it s the revision text itself In either if gzip is the revision text is gzipped $flags
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
usually copyright or history_copyright This message must be in HTML not wikitext & $link
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Interface for objects which can provide a MediaWiki context on request.
getRequest()
Get the WebRequest object.
getConfig()
Get the site configuration.
getSkin()
Get the Skin object.
getUser()
Get the User object.
getLanguage()
Get the Language object.
msg( $key)
This is the method for getting translated interface messages.
if(!isset( $args[0])) $lang