40 if ( $obj instanceof
Skin ) {
45 throw new MWException(
'EnhancedChangesList must be constructed with a '
46 .
'context source or skin.' );
67 $this->rcMoveIndex = 0;
68 $this->rcCacheIndex = 0;
70 $this->rclistOpen =
false;
72 'mediawiki.special.changeslist',
73 'mediawiki.special.changeslist.enhanced',
76 'jquery.makeCollapsible',
80 return '<div class="mw-changeslist">';
95 $rc->mAttribs[
'rc_timestamp'],
101 # If it's a new day, add the headline and flush the cache
102 if ( $date != $this->lastdate ) {
103 # Process current cache
105 $this->rc_cache = [];
107 $this->lastdate = $date;
110 $cacheEntry = $this->cacheEntryFactory->newFromRecentChange( $rc, $watched );
125 if ( !isset( $this->rc_cache[$cacheGroupingKey] ) ) {
126 $this->rc_cache[$cacheGroupingKey] = [];
129 array_push( $this->rc_cache[$cacheGroupingKey], $cacheEntry );
141 $cacheGroupingKey =
$title->getPrefixedDBkey();
143 $type = $cacheEntry->mAttribs[
'rc_type'];
149 $cacheEntry->mAttribs[
'rc_log_type']
150 )->getPrefixedDBkey();
153 return $cacheGroupingKey;
163 $recentChangesFlags = $this->
getConfig()->get(
'RecentChangesFlags' );
165 # Add the namespace and title of the block as part of the class
166 $tableClasses = [
'mw-collapsible',
'mw-collapsed',
'mw-enhanced-rc' ];
167 if ( $block[0]->mAttribs[
'rc_log_type'] ) {
170 . $block[0]->mAttribs[
'rc_log_type'] );
173 . $block[0]->mAttribs[
'rc_namespace'] .
'-' . $block[0]->mAttribs[
'rc_title'] );
175 if ( $block[0]->watched
176 && $block[0]->mAttribs[
'rc_timestamp'] >= $block[0]->watched
178 $tableClasses[] =
'mw-changeslist-line-watched';
180 $tableClasses[] =
'mw-changeslist-line-not-watched';
183 # Collate list of users
187 # Some catalyst variables...
190 $RCShowChangedSize = $this->
getConfig()->get(
'RCShowChangedSize' );
192 # Default values for RC flags
193 $collectedRcFlags = [];
195 $flagGrouping = ( isset( $recentChangesFlags[
$key][
'grouping'] ) ?
196 $recentChangesFlags[
$key][
'grouping'] :
'any' );
197 switch ( $flagGrouping ) {
199 $collectedRcFlags[
$key] =
true;
202 $collectedRcFlags[
$key] =
false;
205 throw new DomainException(
"Unknown grouping type \"{$flagGrouping}\"" );
208 foreach ( $block
as $rcObj ) {
214 $u = $rcObj->userlink;
215 if ( !isset( $userlinks[$u] ) ) {
218 if ( $rcObj->mAttribs[
'rc_type'] !=
RC_LOG ) {
221 # Get the latest entry with a page_id and oldid
222 # since logs may not have these.
223 if ( !$curId && $rcObj->mAttribs[
'rc_cur_id'] ) {
224 $curId = $rcObj->mAttribs[
'rc_cur_id'];
230 # Sort the list and convert to text
231 krsort( $userlinks );
234 foreach ( $userlinks
as $userlink =>
$count ) {
240 $text .=
' ' . $this->
msg(
'parentheses' )->rawParams( $formattedCount )->escaped();
242 array_push( $users, $text );
247 $revDeletedMsg =
false;
249 $revDeletedMsg = $this->
msg(
'rev-deleted-event' )->escaped();
250 } elseif ( $allLogs ) {
253 $articleLink = $this->
getArticleLink( $block[0], $block[0]->unpatrolled, $block[0]->watched );
256 $queryParams[
'curid'] = $curId;
260 foreach ( $block
as $i => $rcObj ) {
270 $flagGrouping = ( isset( $recentChangesFlags[
$key][
'grouping'] ) ?
271 $recentChangesFlags[
$key][
'grouping'] :
'any' );
272 switch ( $flagGrouping ) {
275 $collectedRcFlags[
$key] =
false;
280 $collectedRcFlags[
$key] =
true;
284 throw new DomainException(
"Unknown grouping type \"{$flagGrouping}\"" );
293 $block = array_values( $block );
295 if ( empty( $block ) || !
$lines ) {
300 $logText = $this->
getLogText( $block, $queryParams, $allLogs,
301 $collectedRcFlags[
'newpage'], $namehidden
304 # Character difference (does not apply if only log items)
305 $charDifference =
false;
306 if ( $RCShowChangedSize && !$allLogs ) {
308 $first = count( $block ) - 1;
309 # Some events (like logs and category changes) have an "empty" size, so we need to skip those...
310 while (
$last < $first && $block[
$last]->mAttribs[
'rc_new_len'] === null ) {
313 while (
$last < $first && $block[$first]->mAttribs[
'rc_old_len'] === null ) {
321 $usersList = $this->
msg(
'brackets' )->rawParams(
322 implode( $this->
message[
'semicolon-separator'], $users )
326 'articleLink' => $articleLink,
327 'charDifference' => $charDifference,
329 'languageDirMark' => $this->
getLanguage()->getDirMark(),
331 'logText' => $logText,
332 'numberofWatchingusers' => $numberofWatchingusers,
333 'rev-deleted-event' => $revDeletedMsg,
334 'tableClasses' => $tableClasses,
335 'timestamp' => $block[0]->timestamp,
336 'users' => $usersList,
339 $this->rcCacheIndex++;
343 'EnhancedChangesListGroup',
358 $RCShowChangedSize = $this->
getConfig()->get(
'RCShowChangedSize' );
360 # Classes to apply -- TODO implement
362 $type = $rcObj->mAttribs[
'rc_type'];
367 && $rcObj->mAttribs[
'rc_timestamp'] >= $rcObj->watched
369 $lineParams[
'classes'] = [
'mw-enhanced-watched' ];
371 $separator =
' <span class="mw-changeslist-separator">. .</span> ';
373 $data[
'recentChangesFlags'] = [
375 'minor' => $rcObj->mAttribs[
'rc_minor'],
376 'unpatrolled' => $rcObj->unpatrolled,
377 'bot' => $rcObj->mAttribs[
'rc_bot'],
382 if ( $rcObj->mAttribs[
'rc_this_oldid'] != 0 ) {
383 $params[
'oldid'] = $rcObj->mAttribs[
'rc_this_oldid'];
388 $link = $rcObj->timestamp;
391 $link =
'<span class="history-deleted">' . $rcObj->timestamp .
'</span> ';
400 $link =
'<span class="history-deleted">' .
$link .
'</span> ';
403 $data[
'timestampLink'] =
$link;
405 $currentAndLastLinks =
'';
407 $currentAndLastLinks .=
' ' . $this->
msg(
'parentheses' )->rawParams(
409 $this->message[
'pipe-separator'] .
413 $data[
'currentAndLastLinks'] = $currentAndLastLinks;
414 $data[
'separatorAfterCurrentAndLastLinks'] = $separator;
417 if ( $RCShowChangedSize ) {
420 $data[
'characterDiff'] = $cd;
421 $data[
'separatorAfterCharacterDiff'] = $separator;
425 if ( $rcObj->mAttribs[
'rc_type'] ==
RC_LOG ) {
431 $data[
'userLink'] = $rcObj->userlink;
432 $data[
'userTalkLink'] = $rcObj->usertalklink;
440 $data[
'tags'] = $this->
getTags( $rcObj, $classes );
444 [ $this, &$data, $block, $rcObj ] );
450 $lineParams[
'recentChangesFlagsRaw'] = [];
451 if ( isset( $data[
'recentChangesFlags'] ) ) {
452 $lineParams[
'recentChangesFlags'] = $this->
recentChangesFlags( $data[
'recentChangesFlags'] );
453 # FIXME: This is used by logic, don't return it in the template params.
454 $lineParams[
'recentChangesFlagsRaw'] = $data[
'recentChangesFlags'];
455 unset( $data[
'recentChangesFlags'] );
458 if ( isset( $data[
'timestampLink'] ) ) {
459 $lineParams[
'timestampLink'] = $data[
'timestampLink'];
460 unset( $data[
'timestampLink'] );
464 $lineParams[
'data'] = array_values( $data );
479 protected function getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden ) {
480 if ( empty( $block ) ) {
485 static $nchanges = [];
486 static $sinceLastVisitMsg = [];
488 $n = count( $block );
489 if ( !isset( $nchanges[$n] ) ) {
490 $nchanges[$n] = $this->
msg(
'nchanges' )->numParams( $n )->escaped();
494 $unvisitedOldid = null;
496 foreach ( $block
as $rcObj ) {
498 if ( $rcObj->watched && $rcObj->mAttribs[
'rc_timestamp'] >= $rcObj->watched ) {
500 $unvisitedOldid = $rcObj->mAttribs[
'rc_last_oldid'];
503 if ( !isset( $sinceLastVisitMsg[$sinceLast] ) ) {
504 $sinceLastVisitMsg[$sinceLast] =
505 $this->
msg(
'enhancedrc-since-last-visit' )->numParams( $sinceLast )->escaped();
508 $currentRevision = 0;
509 foreach ( $block
as $rcObj ) {
510 if ( !$currentRevision ) {
511 $currentRevision = $rcObj->mAttribs[
'rc_this_oldid'];
519 $last = $block[count( $block ) - 1];
525 $links[
'total-changes'] = $nchanges[$n];
532 'diff' => $currentRevision,
533 'oldid' =>
$last->mAttribs[
'rc_last_oldid'],
535 [
'known',
'noclasses' ]
537 if ( $sinceLast > 0 && $sinceLast < $n ) {
540 $sinceLastVisitMsg[$sinceLast],
543 'diff' => $currentRevision,
544 'oldid' => $unvisitedOldid,
546 [
'known',
'noclasses' ]
553 if ( $allLogs || $rcObj->mAttribs[
'rc_type'] ==
RC_CATEGORIZE ) {
555 } elseif ( $namehidden || !$block0->getTitle()->exists() ) {
556 $links[
'history'] = $this->
message[
'enhancedrc-history'];
563 $this->
message[
'enhancedrc-history'],
569 # Allow others to alter, remove or add to these links
570 Hooks::run(
'EnhancedChangesList::getLogText',
571 [ $this, &$links, $block ] );
577 $logtext = implode( $this->
message[
'pipe-separator'], $links );
578 $logtext = $this->
msg(
'parentheses' )->rawParams( $logtext )->escaped();
579 return ' ' . $logtext;
591 $query[
'curid'] = $rcObj->mAttribs[
'rc_cur_id'];
593 $type = $rcObj->mAttribs[
'rc_type'];
594 $logType = $rcObj->mAttribs[
'rc_log_type'];
596 $classes[] =
'mw-enhanced-rc';
603 $rcObj->mAttribs[
'rc_namespace'] .
'-' . $rcObj->mAttribs[
'rc_title'] );
607 $data[
'recentChangesFlags'] = [
609 'minor' => $rcObj->mAttribs[
'rc_minor'],
610 'unpatrolled' => $rcObj->unpatrolled,
611 'bot' => $rcObj->mAttribs[
'rc_bot'],
615 $data[
'timestampLink'] = $rcObj->timestamp;
617 # Article or log link
619 $logPage =
new LogPage( $logType );
621 $logName = $logPage->getName()->escaped();
622 $data[
'logLink'] = $this->
msg(
'parentheses' )
625 $data[
'articleLink'] = $this->
getArticleLink( $rcObj, $rcObj->unpatrolled, $rcObj->watched );
628 # Diff and hist links
630 $query[
'action'] =
'history';
633 $data[
'separatorAfterLinks'] =
' <span class="mw-changeslist-separator">. .</span> ';
636 if ( $this->
getConfig()->
get(
'RCShowChangedSize' ) ) {
639 $data[
'characterDiff'] = $cd;
640 $data[
'separatorAftercharacterDiff'] =
' <span class="mw-changeslist-separator">. .</span> ';
649 $data[
'userLink'] = $rcObj->userlink;
650 $data[
'userTalkLink'] = $rcObj->usertalklink;
659 $data[
'tags'] = $this->
getTags( $rcObj, $classes );
661 # Show how many people are watching this if enabled
666 [ $this, &$data, $rcObj ] );
674 $line .=
'<td class="mw-enhanced-rc"><span class="mw-enhancedchanges-arrow-space"></span>';
676 if ( isset( $data[
'recentChangesFlags'] ) ) {
678 unset( $data[
'recentChangesFlags'] );
681 if ( isset( $data[
'timestampLink'] ) ) {
682 $line .=
' ' . $data[
'timestampLink'];
683 unset( $data[
'timestampLink'] );
685 $line .=
' </td><td>';
688 $line .= implode(
'', $data );
690 $line .=
"</td></tr></table>\n";
712 $retVal =
' ' . $this->
msg(
'parentheses' )
713 ->rawParams( $rc->difflink . $this->message[
'pipe-separator'] .
Linker::linkKnown(
715 $this->message[
'hist'],
729 if ( count( $this->rc_cache ) == 0 ) {
734 foreach ( $this->rc_cache
as $block ) {
735 if ( count( $block ) < 2 ) {
742 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.
static linkKnown($target, $html=null, $customAttribs=[], $query=[], $options=[ 'known', 'noclasses'])
Identical to link(), except $options defaults to 'known'.
magic word the default is to use $key to get the and $key value or $key value text $key value html to format the value $key
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.
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.
static isDeleted($rc, $field)
Determine if said field of a revision is hidden.
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
getTags(RecentChange $rc, array &$classes)
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 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
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.
the value to return A Title object or null for latest to be modified or replaced by the hook handler or if authentication is not possible after cache objects are set for highlighting & $link
Class to simplify the use of log pages.
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
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
static link($target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
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.