46 if ( $obj instanceof
Skin ) {
51 throw new MWException(
'EnhancedChangesList must be constructed with a '
52 .
'context source or skin.' );
66 $this->templateParser =
new TemplateParser();
75 $this->rcMoveIndex = 0;
76 $this->rcCacheIndex = 0;
78 $this->rclistOpen =
false;
81 'mediawiki.interface.helpers.styles',
82 'mediawiki.special.changeslist',
83 'mediawiki.special.changeslist.enhanced',
86 'jquery.makeCollapsible',
89 return '<div class="mw-changeslist">';
103 $rc->mAttribs[
'rc_timestamp'],
106 if ( $this->lastdate ===
'' ) {
107 $this->lastdate = $date;
112 # If it's a new day, flush the cache and update $this->lastdate
113 if ( $date !== $this->lastdate ) {
114 # Process current cache (uses $this->lastdate to generate a heading)
116 $this->rc_cache = [];
117 $this->lastdate = $date;
120 $cacheEntry = $this->cacheEntryFactory->newFromRecentChange( $rc, $watched );
135 if ( !isset( $this->rc_cache[$cacheGroupingKey] ) ) {
136 $this->rc_cache[$cacheGroupingKey] = [];
139 array_push( $this->rc_cache[$cacheGroupingKey], $cacheEntry );
151 $cacheGroupingKey =
$title->getPrefixedDBkey();
153 $type = $cacheEntry->mAttribs[
'rc_type'];
157 $cacheGroupingKey = SpecialPage::getTitleFor(
159 $cacheEntry->mAttribs[
'rc_log_type']
160 )->getPrefixedDBkey();
163 return $cacheGroupingKey;
173 $recentChangesFlags = $this->
getConfig()->get(
'RecentChangesFlags' );
175 # Add the namespace and title of the block as part of the class
176 $tableClasses = [
'mw-collapsible',
'mw-collapsed',
'mw-enhanced-rc',
'mw-changeslist-line' ];
177 if ( $block[0]->mAttribs[
'rc_log_type'] ) {
179 $tableClasses[] =
'mw-changeslist-log';
180 $tableClasses[] = Sanitizer::escapeClass(
'mw-changeslist-log-'
181 . $block[0]->mAttribs[
'rc_log_type'] );
183 $tableClasses[] =
'mw-changeslist-edit';
184 $tableClasses[] = Sanitizer::escapeClass(
'mw-changeslist-ns'
185 . $block[0]->mAttribs[
'rc_namespace'] .
'-' . $block[0]->mAttribs[
'rc_title'] );
187 if ( $block[0]->watched
188 && $block[0]->mAttribs[
'rc_timestamp'] >= $block[0]->watched
190 $tableClasses[] =
'mw-changeslist-line-watched';
192 $tableClasses[] =
'mw-changeslist-line-not-watched';
195 # Collate list of users
199 # Some catalyst variables...
202 $RCShowChangedSize = $this->
getConfig()->get(
'RCShowChangedSize' );
204 # Default values for RC flags
205 $collectedRcFlags = [];
206 foreach ( $recentChangesFlags
as $key =>
$value ) {
207 $flagGrouping = ( $recentChangesFlags[$key][
'grouping'] ??
'any' );
208 switch ( $flagGrouping ) {
210 $collectedRcFlags[$key] =
true;
213 $collectedRcFlags[$key] =
false;
216 throw new DomainException(
"Unknown grouping type \"{$flagGrouping}\"" );
219 foreach ( $block
as $rcObj ) {
225 $u = $rcObj->userlink;
226 if ( !isset( $userlinks[$u] ) ) {
229 if ( $rcObj->mAttribs[
'rc_type'] !=
RC_LOG ) {
232 # Get the latest entry with a page_id and oldid
233 # since logs may not have these.
234 if ( !$curId && $rcObj->mAttribs[
'rc_cur_id'] ) {
235 $curId = $rcObj->mAttribs[
'rc_cur_id'];
241 # Sort the list and convert to text
242 krsort( $userlinks );
245 foreach ( $userlinks
as $userlink => $count ) {
249 $formattedCount = $this->
msg(
'ntimes' )->numParams( $count )->escaped();
250 $text .=
' ' . $this->
msg(
'parentheses' )->rawParams( $formattedCount )->escaped();
252 array_push( $users, $text );
257 $revDeletedMsg =
false;
259 $revDeletedMsg = $this->
msg(
'rev-deleted-event' )->escaped();
260 } elseif ( $allLogs ) {
263 $articleLink = $this->
getArticleLink( $block[0], $block[0]->unpatrolled, $block[0]->watched );
266 $queryParams[
'curid'] = $curId;
271 foreach ( $block
as $i => $rcObj ) {
280 foreach (
$line[
'recentChangesFlagsRaw']
as $key =>
$value ) {
281 $flagGrouping = ( $recentChangesFlags[$key][
'grouping'] ??
'any' );
282 switch ( $flagGrouping ) {
285 $collectedRcFlags[$key] =
false;
290 $collectedRcFlags[$key] =
true;
294 throw new DomainException(
"Unknown grouping type \"{$flagGrouping}\"" );
301 $this->
getTags( $rcObj, $filterClasses );
302 $filterClasses = array_unique( $filterClasses );
309 $block = array_values( $block );
310 $filterClasses = array_values( $filterClasses );
312 if ( empty( $block ) || !
$lines ) {
317 $logText = $this->
getLogText( $block, $queryParams, $allLogs,
318 $collectedRcFlags[
'newpage'], $namehidden
321 # Character difference (does not apply if only log items)
322 $charDifference =
false;
323 if ( $RCShowChangedSize && !$allLogs ) {
325 $first = count( $block ) - 1;
326 # Some events (like logs and category changes) have an "empty" size, so we need to skip those...
327 while (
$last < $first && $block[
$last]->mAttribs[
'rc_new_len'] ===
null ) {
330 while (
$last < $first && $block[$first]->mAttribs[
'rc_old_len'] ===
null ) {
338 $usersList = $this->
msg(
'brackets' )->rawParams(
339 implode( $this->
message[
'semicolon-separator'], $users )
343 if ( is_callable( $this->changeLinePrefixer ) ) {
344 $prefix = call_user_func( $this->changeLinePrefixer, $block[0], $this,
true );
348 'articleLink' => $articleLink,
349 'charDifference' => $charDifference,
351 'filterClasses' => $filterClasses,
352 'languageDirMark' => $this->
getLanguage()->getDirMark(),
354 'logText' => $logText,
355 'numberofWatchingusers' => $numberofWatchingusers,
357 'rev-deleted-event' => $revDeletedMsg,
358 'tableClasses' => $tableClasses,
359 'timestamp' => $block[0]->timestamp,
360 'fullTimestamp' => $block[0]->getAttribute(
'rc_timestamp' ),
361 'users' => $usersList,
364 $this->rcCacheIndex++;
366 return $this->templateParser->processTemplate(
367 'EnhancedChangesListGroup',
382 $RCShowChangedSize = $this->
getConfig()->get(
'RCShowChangedSize' );
384 $type = $rcObj->mAttribs[
'rc_type'];
386 $lineParams = [
'targetTitle' => $rcObj->
getTitle() ];
388 $classes = [
'mw-enhanced-rc' ];
390 && $rcObj->mAttribs[
'rc_timestamp'] >= $rcObj->watched
392 $classes[] =
'mw-enhanced-watched';
394 $classes = array_merge( $classes, $this->
getHTMLClasses( $rcObj, $rcObj->watched ) );
396 $separator =
' <span class="mw-changeslist-separator"></span> ';
398 $data[
'recentChangesFlags'] = [
400 'minor' => $rcObj->mAttribs[
'rc_minor'],
401 'unpatrolled' => $rcObj->unpatrolled,
402 'bot' => $rcObj->mAttribs[
'rc_bot'],
407 if ( $rcObj->mAttribs[
'rc_this_oldid'] != 0 ) {
408 $params[
'oldid'] = $rcObj->mAttribs[
'rc_this_oldid'];
413 $link = htmlspecialchars( $rcObj->timestamp );
416 $link = Html::element(
'span', [
'class' =>
'history-deleted' ], $rcObj->timestamp );
418 $link = $this->linkRenderer->makeKnownLink(
425 $link =
'<span class="history-deleted">' .
$link .
'</span> ';
430 $currentAndLastLinks =
'';
432 $currentAndLastLinks .=
' ' . $this->
msg(
'parentheses' )->rawParams(
434 $this->message[
'pipe-separator'] .
438 $data[
'currentAndLastLinks'] = $currentAndLastLinks;
439 $data[
'separatorAfterCurrentAndLastLinks'] = $separator;
442 if ( $RCShowChangedSize ) {
445 $data[
'characterDiff'] = $cd;
446 $data[
'separatorAfterCharacterDiff'] = $separator;
450 if ( $rcObj->mAttribs[
'rc_type'] ==
RC_LOG ) {
456 $data[
'userLink'] = $rcObj->userlink;
457 $data[
'userTalkLink'] = $rcObj->usertalklink;
470 $success = Hooks::run(
'EnhancedChangesListModifyLineData',
477 [ Sanitizer::class,
'isReservedDataAttribute' ],
481 $lineParams[
'recentChangesFlagsRaw'] = [];
482 if ( isset(
$data[
'recentChangesFlags'] ) ) {
484 # FIXME: This is used by logic, don't return it in the template params.
485 $lineParams[
'recentChangesFlagsRaw'] =
$data[
'recentChangesFlags'];
486 unset(
$data[
'recentChangesFlags'] );
489 if ( isset(
$data[
'timestampLink'] ) ) {
490 $lineParams[
'timestampLink'] =
$data[
'timestampLink'];
491 unset(
$data[
'timestampLink'] );
494 $lineParams[
'classes'] = array_values( $classes );
495 $lineParams[
'attribs'] = Html::expandAttributes(
$attribs );
498 $lineParams[
'data'] = array_values(
$data );
513 protected function getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden ) {
514 if ( empty( $block ) ) {
519 static $nchanges = [];
520 static $sinceLastVisitMsg = [];
522 $n = count( $block );
523 if ( !isset( $nchanges[$n] ) ) {
524 $nchanges[$n] = $this->
msg(
'nchanges' )->numParams( $n )->escaped();
528 $unvisitedOldid =
null;
530 foreach ( $block
as $rcObj ) {
532 if ( $rcObj->watched && $rcObj->mAttribs[
'rc_timestamp'] >= $rcObj->watched ) {
534 $unvisitedOldid = $rcObj->mAttribs[
'rc_last_oldid'];
537 if ( !isset( $sinceLastVisitMsg[$sinceLast] ) ) {
538 $sinceLastVisitMsg[$sinceLast] =
539 $this->
msg(
'enhancedrc-since-last-visit' )->numParams( $sinceLast )->escaped();
542 $currentRevision = 0;
543 foreach ( $block
as $rcObj ) {
544 if ( !$currentRevision ) {
545 $currentRevision = $rcObj->mAttribs[
'rc_this_oldid'];
553 $last = $block[count( $block ) - 1];
559 $links[
'total-changes'] = Html::rawElement(
'span', [], $nchanges[$n] );
561 $links[
'total-changes'] = Html::rawElement(
'span', [],
562 $this->linkRenderer->makeKnownLink(
565 [
'class' =>
'mw-changeslist-groupdiff' ],
567 'diff' => $currentRevision,
568 'oldid' =>
$last->mAttribs[
'rc_last_oldid'],
572 if ( $sinceLast > 0 && $sinceLast < $n ) {
573 $links[
'total-changes-since-last'] = Html::rawElement(
'span', [],
574 $this->linkRenderer->makeKnownLink(
576 new HtmlArmor( $sinceLastVisitMsg[$sinceLast] ),
577 [
'class' =>
'mw-changeslist-groupdiff' ],
579 'diff' => $currentRevision,
580 'oldid' => $unvisitedOldid,
589 if ( $allLogs || $rcObj->mAttribs[
'rc_type'] ==
RC_CATEGORIZE ) {
591 } elseif ( $namehidden || !$block0->getTitle()->exists() ) {
592 $links[
'history'] = Html::rawElement(
'span', [], $this->
message[
'enhancedrc-history'] );
597 $links[
'history'] = Html::rawElement(
'span', [],
598 $this->linkRenderer->makeKnownLink(
601 [
'class' =>
'mw-changeslist-history' ],
607 # Allow others to alter, remove or add to these links
608 Hooks::run(
'EnhancedChangesList::getLogText',
609 [ $this, &$links, $block ] );
615 $logtext = Html::rawElement(
'span', [
'class' =>
'mw-changeslist-links' ],
616 implode(
' ', $links ) );
617 return ' ' . $logtext;
629 $query[
'curid'] = $rcObj->mAttribs[
'rc_cur_id'];
631 $type = $rcObj->mAttribs[
'rc_type'];
632 $logType = $rcObj->mAttribs[
'rc_log_type'];
634 $classes[] =
'mw-enhanced-rc';
638 $classes[] =
'mw-changeslist-log';
639 $classes[] = Sanitizer::escapeClass(
'mw-changeslist-log-' . $logType );
641 $classes[] =
'mw-changeslist-edit';
642 $classes[] = Sanitizer::escapeClass(
'mw-changeslist-ns' .
643 $rcObj->mAttribs[
'rc_namespace'] .
'-' . $rcObj->mAttribs[
'rc_title'] );
647 $data[
'recentChangesFlags'] = [
649 'minor' => $rcObj->mAttribs[
'rc_minor'],
650 'unpatrolled' => $rcObj->unpatrolled,
651 'bot' => $rcObj->mAttribs[
'rc_bot'],
655 $data[
'timestampLink'] = htmlspecialchars( $rcObj->timestamp );
657 # Article or log link
659 $logPage =
new LogPage( $logType );
660 $logTitle = SpecialPage::getTitleFor(
'Log', $logType );
661 $logName = $logPage->getName()->text();
662 $data[
'logLink'] = Html::rawElement(
'span', [
'class' =>
'mw-changeslist-links' ],
663 $this->linkRenderer->makeKnownLink( $logTitle, $logName )
666 $data[
'articleLink'] = $this->
getArticleLink( $rcObj, $rcObj->unpatrolled, $rcObj->watched );
669 # Diff and hist links
671 $query[
'action'] =
'history';
674 $data[
'separatorAfterLinks'] =
' <span class="mw-changeslist-separator"></span> ';
677 if ( $this->
getConfig()->
get(
'RCShowChangedSize' ) ) {
680 $data[
'characterDiff'] = $cd;
681 $data[
'separatorAftercharacterDiff'] =
' <span class="mw-changeslist-separator"></span> ';
690 $data[
'userLink'] = $rcObj->userlink;
691 $data[
'userTalkLink'] = $rcObj->usertalklink;
702 # Show how many people are watching this if enabled
708 $success = Hooks::run(
'EnhancedChangesListModifyBlockLineData',
709 [ $this, &
$data, $rcObj ] );
715 unset(
$data[
'attribs'] );
717 return $key ===
'class' || Sanitizer::isReservedDataAttribute( $key );
718 }, ARRAY_FILTER_USE_KEY );
721 if ( is_callable( $this->changeLinePrefixer ) ) {
722 $prefix = call_user_func( $this->changeLinePrefixer, $rcObj, $this,
false );
725 $line = Html::openElement(
'table',
$attribs ) . Html::openElement(
'tr' );
727 $line .= Html::rawElement(
'td', [],
731 $line .= Html::rawElement(
'td', [],
'<span class="mw-enhancedchanges-arrow-space"></span>' );
732 $line .= Html::rawElement(
'td', [
'class' =>
'mw-changeslist-line-prefix' ], $prefix );
733 $line .=
'<td class="mw-enhanced-rc" colspan="2">';
735 if ( isset(
$data[
'recentChangesFlags'] ) ) {
737 unset(
$data[
'recentChangesFlags'] );
740 if ( isset(
$data[
'timestampLink'] ) ) {
742 unset(
$data[
'timestampLink'] );
744 $line .=
"\u{00A0}</td>";
745 $line .= Html::openElement(
'td', [
746 'class' =>
'mw-changeslist-line-inner',
748 'data-target-page' => $rcObj->getTitle(),
752 foreach (
$data as $key => $dataItem ) {
753 $line .= Html::rawElement(
'span', [
754 'class' =>
'mw-changeslist-line-inner-' . $key,
758 $line .=
"</td></tr></table>\n";
778 $pageTitle = Title::newFromID( $rc->
getAttribute(
'rc_cur_id' ) );
786 $histLink = $this->linkRenderer->makeKnownLink(
789 [
'class' =>
'mw-changeslist-history' ],
792 if ( $useParentheses ) {
793 $retVal = $this->
msg(
'parentheses' )
794 ->rawParams( $rc->difflink . $this->message[
'pipe-separator']
795 . $histLink )->escaped();
797 $retVal = Html::rawElement(
'span', [
'class' =>
'mw-changeslist-links' ],
798 Html::rawElement(
'span', [], $rc->difflink ) .
799 Html::rawElement(
'span', [], $histLink )
802 return ' ' . $retVal;
812 if ( count( $this->rc_cache ) == 0 ) {
817 foreach ( $this->rc_cache
as $block ) {
818 if ( count( $block ) < 2 ) {
825 if ( $blockOut ===
'' ) {
829 return Xml::element(
'h4',
null, $this->lastdate ) .
"\n<div>" . $blockOut .
'</div>';
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,...
formatCharacterDifference(RecentChange $old, RecentChange $new=null)
Format the character difference of one or several changes.
getHighlightsContainerDiv()
Get the container for highlights that are used in the new StructuredFilters system.
recentChangesFlags( $flags, $nothing="\u{00A0}")
Returns the appropriate flags for new page, minor change and patrolling.
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.
getTags(RecentChange $rc, array &$classes)
getArticleLink(&$rc, $unpatrolled, $watched)
getRollback(RecentChange $rc)
insertLogEntry( $rc)
Insert a formatted action.
static isDeleted( $rc, $field)
Determine if said field of a revision is hidden.
insertComment( $rc)
Insert a formatted comment.
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.
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
TemplateParser $templateParser
recentChangesBlock()
If enhanced RC is in use, this function takes the previously cached RC lines, arranges them,...
makeCacheGroupingKey(RCCacheEntry $cacheEntry)
beginRecentChangesList()
Add the JavaScript file for enhanced changeslist.
endRecentChangesList()
Returns text for the end of RC If enhanced RC is in use, returns pretty much all the text.
getDiffHistLinks(RCCacheEntry $rc, array $query, $useParentheses=true)
Returns value to be used in 'historyLink' element of $data param in EnhancedChangesListModifyBlockLin...
addCacheEntry(RCCacheEntry $cacheEntry)
Put accumulated information into the cache, for later display.
RCCacheEntryFactory $cacheEntryFactory
recentChangesBlockGroup( $block)
Enhanced RC group.
getLineData(array $block, RCCacheEntry $rcObj, array $queryParams=[])
array $rc_cache
Array of array of RCCacheEntry.
recentChangesBlockLine( $rcObj)
Enhanced RC ungrouped line.
__construct( $obj, array $filterGroups=[])
recentChangesLine(&$rc, $watched=false, $linenumber=null)
Format a line for enhanced recentchange (aka with javascript and block of lines).
getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden)
Generates amount of changes (linking to diff ) & link to history.
Marks HTML that shouldn't be escaped.
Class to simplify the use of log pages.
getAttribute( $name)
Get an attribute value.
The main skin class which provides methods and properties for all other skins.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template to be included in the link
namespace and then decline to actually register it file or subcat img or subcat $title
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
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 use $formDescriptor instead 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 message
usually copyright or history_copyright This message must be in HTML not wikitext & $link
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
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
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Interface for objects which can provide a MediaWiki context on request.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))