40 if ( $obj instanceof
Skin ) {
45 throw new MWException(
'EnhancedChangesList must be constructed with a '
46 .
'context source or skin.' );
68 $this->rcMoveIndex = 0;
69 $this->rcCacheIndex = 0;
71 $this->rclistOpen =
false;
73 'mediawiki.special.changeslist',
74 'mediawiki.special.changeslist.enhanced',
77 'jquery.makeCollapsible',
81 return '<div class="mw-changeslist">';
96 $rc->mAttribs[
'rc_timestamp'],
102 # If it's a new day, add the headline and flush the cache
103 if ( $date != $this->lastdate ) {
104 # Process current cache
106 $this->rc_cache = [];
108 $this->lastdate = $date;
111 $cacheEntry = $this->cacheEntryFactory->newFromRecentChange( $rc, $watched );
126 if ( !isset( $this->rc_cache[$cacheGroupingKey] ) ) {
127 $this->rc_cache[$cacheGroupingKey] = [];
130 array_push( $this->rc_cache[$cacheGroupingKey], $cacheEntry );
142 $cacheGroupingKey =
$title->getPrefixedDBkey();
144 $type = $cacheEntry->mAttribs[
'rc_type'];
150 $cacheEntry->mAttribs[
'rc_log_type']
151 )->getPrefixedDBkey();
154 return $cacheGroupingKey;
164 $recentChangesFlags = $this->
getConfig()->get(
'RecentChangesFlags' );
166 # Add the namespace and title of the block as part of the class
167 $tableClasses = [
'mw-collapsible',
'mw-collapsed',
'mw-enhanced-rc' ];
168 if ( $block[0]->mAttribs[
'rc_log_type'] ) {
171 . $block[0]->mAttribs[
'rc_log_type'] );
174 . $block[0]->mAttribs[
'rc_namespace'] .
'-' . $block[0]->mAttribs[
'rc_title'] );
176 if ( $block[0]->watched
177 && $block[0]->mAttribs[
'rc_timestamp'] >= $block[0]->watched
179 $tableClasses[] =
'mw-changeslist-line-watched';
181 $tableClasses[] =
'mw-changeslist-line-not-watched';
184 # Collate list of users
188 # Some catalyst variables...
191 $RCShowChangedSize = $this->
getConfig()->get(
'RCShowChangedSize' );
193 # Default values for RC flags
194 $collectedRcFlags = [];
195 foreach ( $recentChangesFlags
as $key =>
$value ) {
196 $flagGrouping = ( isset( $recentChangesFlags[$key][
'grouping'] ) ?
197 $recentChangesFlags[$key][
'grouping'] :
'any' );
198 switch ( $flagGrouping ) {
200 $collectedRcFlags[$key] =
true;
203 $collectedRcFlags[$key] =
false;
206 throw new DomainException(
"Unknown grouping type \"{$flagGrouping}\"" );
209 foreach ( $block
as $rcObj ) {
215 $u = $rcObj->userlink;
216 if ( !isset( $userlinks[$u] ) ) {
219 if ( $rcObj->mAttribs[
'rc_type'] !=
RC_LOG ) {
222 # Get the latest entry with a page_id and oldid
223 # since logs may not have these.
224 if ( !$curId && $rcObj->mAttribs[
'rc_cur_id'] ) {
225 $curId = $rcObj->mAttribs[
'rc_cur_id'];
231 # Sort the list and convert to text
232 krsort( $userlinks );
235 foreach ( $userlinks
as $userlink =>
$count ) {
241 $text .=
' ' . $this->
msg(
'parentheses' )->rawParams( $formattedCount )->escaped();
243 array_push( $users, $text );
248 $revDeletedMsg =
false;
250 $revDeletedMsg = $this->
msg(
'rev-deleted-event' )->escaped();
251 } elseif ( $allLogs ) {
254 $articleLink = $this->
getArticleLink( $block[0], $block[0]->unpatrolled, $block[0]->watched );
257 $queryParams[
'curid'] = $curId;
261 foreach ( $block
as $i => $rcObj ) {
270 foreach (
$line[
'recentChangesFlagsRaw']
as $key =>
$value ) {
271 $flagGrouping = ( isset( $recentChangesFlags[$key][
'grouping'] ) ?
272 $recentChangesFlags[$key][
'grouping'] :
'any' );
273 switch ( $flagGrouping ) {
276 $collectedRcFlags[$key] =
false;
281 $collectedRcFlags[$key] =
true;
285 throw new DomainException(
"Unknown grouping type \"{$flagGrouping}\"" );
294 $block = array_values( $block );
296 if ( empty( $block ) || !
$lines ) {
301 $logText = $this->
getLogText( $block, $queryParams, $allLogs,
302 $collectedRcFlags[
'newpage'], $namehidden
305 # Character difference (does not apply if only log items)
306 $charDifference =
false;
307 if ( $RCShowChangedSize && !$allLogs ) {
309 $first = count( $block ) - 1;
310 # Some events (like logs and category changes) have an "empty" size, so we need to skip those...
311 while (
$last < $first && $block[
$last]->mAttribs[
'rc_new_len'] === null ) {
314 while (
$last < $first && $block[$first]->mAttribs[
'rc_old_len'] === null ) {
322 $usersList = $this->
msg(
'brackets' )->rawParams(
323 implode( $this->
message[
'semicolon-separator'], $users )
327 'articleLink' => $articleLink,
328 'charDifference' => $charDifference,
330 'languageDirMark' => $this->
getLanguage()->getDirMark(),
332 'logText' => $logText,
333 'numberofWatchingusers' => $numberofWatchingusers,
334 'rev-deleted-event' => $revDeletedMsg,
335 'tableClasses' => $tableClasses,
336 'timestamp' => $block[0]->timestamp,
337 'users' => $usersList,
340 $this->rcCacheIndex++;
344 'EnhancedChangesListGroup',
359 $RCShowChangedSize = $this->
getConfig()->get(
'RCShowChangedSize' );
361 $classes = [
'mw-enhanced-rc' ];
362 $type = $rcObj->mAttribs[
'rc_type'];
367 && $rcObj->mAttribs[
'rc_timestamp'] >= $rcObj->watched
369 $classes = [
'mw-enhanced-watched' ];
372 $separator =
' <span class="mw-changeslist-separator">. .</span> ';
374 $data[
'recentChangesFlags'] = [
376 'minor' => $rcObj->mAttribs[
'rc_minor'],
377 'unpatrolled' => $rcObj->unpatrolled,
378 'bot' => $rcObj->mAttribs[
'rc_bot'],
383 if ( $rcObj->mAttribs[
'rc_this_oldid'] != 0 ) {
384 $params[
'oldid'] = $rcObj->mAttribs[
'rc_this_oldid'];
389 $link = $rcObj->timestamp;
392 $link =
'<span class="history-deleted">' . $rcObj->timestamp .
'</span> ';
394 $link = $this->linkRenderer->makeKnownLink(
401 $link =
'<span class="history-deleted">' .
$link .
'</span> ';
404 $data[
'timestampLink'] =
$link;
406 $currentAndLastLinks =
'';
408 $currentAndLastLinks .=
' ' . $this->
msg(
'parentheses' )->rawParams(
410 $this->message[
'pipe-separator'] .
414 $data[
'currentAndLastLinks'] = $currentAndLastLinks;
415 $data[
'separatorAfterCurrentAndLastLinks'] = $separator;
418 if ( $RCShowChangedSize ) {
421 $data[
'characterDiff'] = $cd;
422 $data[
'separatorAfterCharacterDiff'] = $separator;
426 if ( $rcObj->mAttribs[
'rc_type'] ==
RC_LOG ) {
432 $data[
'userLink'] = $rcObj->userlink;
433 $data[
'userTalkLink'] = $rcObj->usertalklink;
441 $data[
'tags'] = $this->
getTags( $rcObj, $classes );
445 [ $this, &$data, $block, $rcObj, &$classes ] );
451 $lineParams[
'recentChangesFlagsRaw'] = [];
452 if ( isset( $data[
'recentChangesFlags'] ) ) {
453 $lineParams[
'recentChangesFlags'] = $this->
recentChangesFlags( $data[
'recentChangesFlags'] );
454 # FIXME: This is used by logic, don't return it in the template params.
455 $lineParams[
'recentChangesFlagsRaw'] = $data[
'recentChangesFlags'];
456 unset( $data[
'recentChangesFlags'] );
459 if ( isset( $data[
'timestampLink'] ) ) {
460 $lineParams[
'timestampLink'] = $data[
'timestampLink'];
461 unset( $data[
'timestampLink'] );
464 $lineParams[
'classes'] = array_values( $classes );
467 $lineParams[
'data'] = array_values( $data );
482 protected function getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden ) {
483 if ( empty( $block ) ) {
488 static $nchanges = [];
489 static $sinceLastVisitMsg = [];
491 $n = count( $block );
492 if ( !isset( $nchanges[$n] ) ) {
493 $nchanges[$n] = $this->
msg(
'nchanges' )->numParams( $n )->escaped();
497 $unvisitedOldid = null;
499 foreach ( $block
as $rcObj ) {
501 if ( $rcObj->watched && $rcObj->mAttribs[
'rc_timestamp'] >= $rcObj->watched ) {
503 $unvisitedOldid = $rcObj->mAttribs[
'rc_last_oldid'];
506 if ( !isset( $sinceLastVisitMsg[$sinceLast] ) ) {
507 $sinceLastVisitMsg[$sinceLast] =
508 $this->
msg(
'enhancedrc-since-last-visit' )->numParams( $sinceLast )->escaped();
511 $currentRevision = 0;
512 foreach ( $block
as $rcObj ) {
513 if ( !$currentRevision ) {
514 $currentRevision = $rcObj->mAttribs[
'rc_this_oldid'];
522 $last = $block[count( $block ) - 1];
528 $links[
'total-changes'] = $nchanges[$n];
530 $links[
'total-changes'] = $this->linkRenderer->makeKnownLink(
535 'diff' => $currentRevision,
536 'oldid' =>
$last->mAttribs[
'rc_last_oldid'],
539 if ( $sinceLast > 0 && $sinceLast < $n ) {
540 $links[
'total-changes-since-last'] = $this->linkRenderer->makeKnownLink(
542 new HtmlArmor( $sinceLastVisitMsg[$sinceLast] ),
545 'diff' => $currentRevision,
546 'oldid' => $unvisitedOldid,
554 if ( $allLogs || $rcObj->mAttribs[
'rc_type'] ==
RC_CATEGORIZE ) {
556 } elseif ( $namehidden || !$block0->getTitle()->exists() ) {
557 $links[
'history'] = $this->
message[
'enhancedrc-history'];
562 $links[
'history'] = $this->linkRenderer->makeKnownLink(
570 # Allow others to alter, remove or add to these links
571 Hooks::run(
'EnhancedChangesList::getLogText',
572 [ $this, &$links, $block ] );
578 $logtext = implode( $this->
message[
'pipe-separator'], $links );
579 $logtext = $this->
msg(
'parentheses' )->rawParams( $logtext )->escaped();
580 return ' ' . $logtext;
592 $query[
'curid'] = $rcObj->mAttribs[
'rc_cur_id'];
594 $type = $rcObj->mAttribs[
'rc_type'];
595 $logType = $rcObj->mAttribs[
'rc_log_type'];
597 $classes[] =
'mw-enhanced-rc';
604 $rcObj->mAttribs[
'rc_namespace'] .
'-' . $rcObj->mAttribs[
'rc_title'] );
608 $data[
'recentChangesFlags'] = [
610 'minor' => $rcObj->mAttribs[
'rc_minor'],
611 'unpatrolled' => $rcObj->unpatrolled,
612 'bot' => $rcObj->mAttribs[
'rc_bot'],
616 $data[
'timestampLink'] = $rcObj->timestamp;
618 # Article or log link
620 $logPage =
new LogPage( $logType );
622 $logName = $logPage->getName()->text();
623 $data[
'logLink'] = $this->
msg(
'parentheses' )
625 $this->linkRenderer->makeKnownLink( $logTitle, $logName )
628 $data[
'articleLink'] = $this->
getArticleLink( $rcObj, $rcObj->unpatrolled, $rcObj->watched );
631 # Diff and hist links
633 $query[
'action'] =
'history';
636 $data[
'separatorAfterLinks'] =
' <span class="mw-changeslist-separator">. .</span> ';
639 if ( $this->
getConfig()->
get(
'RCShowChangedSize' ) ) {
642 $data[
'characterDiff'] = $cd;
643 $data[
'separatorAftercharacterDiff'] =
' <span class="mw-changeslist-separator">. .</span> ';
652 $data[
'userLink'] = $rcObj->userlink;
653 $data[
'userTalkLink'] = $rcObj->usertalklink;
662 $data[
'tags'] = $this->
getTags( $rcObj, $classes );
664 # Show how many people are watching this if enabled
669 [ $this, &$data, $rcObj ] );
677 $line .=
'<td class="mw-enhanced-rc"><span class="mw-enhancedchanges-arrow-space"></span>';
679 if ( isset( $data[
'recentChangesFlags'] ) ) {
681 unset( $data[
'recentChangesFlags'] );
684 if ( isset( $data[
'timestampLink'] ) ) {
685 $line .=
' ' . $data[
'timestampLink'];
686 unset( $data[
'timestampLink'] );
688 $line .=
' </td><td>';
691 $line .= implode(
'', $data );
693 $line .=
"</td></tr></table>\n";
715 $retVal =
' ' . $this->
msg(
'parentheses' )
716 ->rawParams( $rc->difflink . $this->message[
'pipe-separator']
717 . $this->linkRenderer->makeKnownLink(
733 if ( count( $this->rc_cache ) == 0 ) {
738 foreach ( $this->rc_cache
as $block ) {
739 if ( count( $block ) < 2 ) {
746 return '<div>' . $blockOut .
'</div>';
static newFromID($id, $flags=0)
Create a new Title from an article ID.
Interface for objects which can provide a MediaWiki context on request.
static userCan($rc, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this revision, if it's marked as deleted.
the array() calling protocol came about after MediaWiki 1.4rc1.
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
getLanguage()
Get the Language object.
The main skin class which provides methods and properties for all other skins.
getLogText($block, $queryParams, $allLogs, $isnew, $namehidden)
Generates amount of changes (linking to diff ) & link to history.
static element($element, $attribs=null, $contents= '', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
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
recentChangesFlags($flags, $nothing= ' ')
Returns the appropriate flags for new page, minor change and patrolling.
static getTitleFor($name, $subpage=false, $fragment= '')
Get a localised Title object for a specified special page name If you don't need a full Title object...
static isDeleted($rc, $field)
Determine if said field of a revision is hidden.
getTags(RecentChange $rc, array &$classes)
numberofWatchingusers($count)
Returns the string which indicates the number of watching users.
formatCharacterDifference(RecentChange $old, RecentChange $new=null)
Format the character difference of one or several changes.
static escapeClass($class)
Given a value, escape it so that it can be used as a CSS class and return it.
getDiffHistLinks(RCCacheEntry $rc, array $query)
Returns value to be used in 'historyLink' element of $data param in EnhancedChangesListModifyBlockLin...
getAttribute($name)
Get an attribute value.
recentChangesBlockGroup($block)
Enhanced RC group.
Class to simplify the use of log pages.
usually copyright or history_copyright This message must be in HTML not wikitext & $link
msg()
Get a Message object with context set Parameters are the same as wfMessage()
static openElement($element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
RCCacheEntryFactory $cacheEntryFactory
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 message
getLineData(array $block, RCCacheEntry $rcObj, array $queryParams=[])
getConfig()
Get the Config object.
getRollback(RecentChange $rc)
getArticleLink(&$rc, $unpatrolled, $watched)
array $rc_cache
Array of array of RCCacheEntry.
makeCacheGroupingKey(RCCacheEntry $cacheEntry)
recentChangesBlock()
If enhanced RC is in use, this function takes the previously cached RC lines, arranges them...
namespace and then decline to actually register it file or subcat img or subcat $title
isCategorizationWithoutRevision($rcObj)
Determines whether a revision is linked to this change; this may not be the case when the categorizat...
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
beginRecentChangesList()
Add the JavaScript file for enhanced changeslist.
recentChangesBlockLine($rcObj)
Enhanced RC ungrouped line.
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
endRecentChangesList()
Returns text for the end of RC If enhanced RC is in use, returns pretty much all the text...
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
addCacheEntry(RCCacheEntry $cacheEntry)
Put accumulated information into the cache, for later display.
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
insertLogEntry($rc)
Insert a formatted action.
insertComment($rc)
Insert a formatted comment.
getHTMLClasses($rc, $watched)
Get an array of default HTML class attributes for the change.
recentChangesLine(&$rc, $watched=false, $linenumber=null)
Format a line for enhanced recentchange (aka with javascript and block of lines). ...
getUser()
Get the User object.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
maybeWatchedLink($link, $watched=false)
getOutput()
Get the OutputPage object.