3 * Implements Special:Recentchanges
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup SpecialPage
25 * A special page that lists last changes made to the wiki
27 * @ingroup SpecialPage
29 class SpecialRecentChanges
extends SpecialPage
{
30 var $rcOptions, $rcSubpage;
31 protected $customFilters;
34 * The feed format to output as (either 'rss' or 'atom'), or null if no
35 * feed output was requested
37 * @var string $feedFormat
39 protected $feedFormat;
41 public function __construct( $name = 'Recentchanges', $restriction = '' ) {
42 parent
::__construct( $name, $restriction );
45 public function isIncludable() {
50 * Get a FormOptions object containing the default options
54 public function getDefaultOptions() {
55 $opts = new FormOptions();
56 $user = $this->getUser();
58 $opts->add( 'days', $user->getIntOption( 'rcdays' ) );
59 $opts->add( 'limit', $user->getIntOption( 'rclimit' ) );
60 $opts->add( 'from', '' );
62 $opts->add( 'hideminor', $user->getBoolOption( 'hideminor' ) );
63 $opts->add( 'hidebots', true );
64 $opts->add( 'hideanons', false );
65 $opts->add( 'hideliu', false );
66 $opts->add( 'hidepatrolled', $user->getBoolOption( 'hidepatrolled' ) );
67 $opts->add( 'hidemyself', false );
69 $opts->add( 'namespace', '', FormOptions
::INTNULL
);
70 $opts->add( 'invert', false );
71 $opts->add( 'associated', false );
73 $opts->add( 'categories', '' );
74 $opts->add( 'categories_any', false );
75 $opts->add( 'tagfilter', '' );
81 * Create a FormOptions object with options as specified by the user
83 * @param array $parameters
86 public function setup( $parameters ) {
89 $opts = $this->getDefaultOptions();
90 foreach ( $this->getCustomFilters() as $key => $params ) {
91 $opts->add( $key, $params['default'] );
94 $opts = $this->fetchOptionsFromRequest( $opts );
96 // Give precedence to subpage syntax
97 if ( $parameters !== null ) {
98 $this->parseParameters( $parameters, $opts );
101 $opts->validateIntBounds( 'limit', 0, $this->feedFormat ?
$wgFeedLimit : 5000 );
107 * Fetch values for a FormOptions object from the WebRequest associated with this instance.
109 * Intended for subclassing, e.g. to add a backwards-compatibility layer.
111 * @param FormOptions $parameters
112 * @return FormOptions
114 protected function fetchOptionsFromRequest( $opts ) {
115 $opts->fetchValuesFromRequest( $this->getRequest() );
120 * Get custom show/hide filters
122 * @return array Map of filter URL param names to properties (msg/default)
124 protected function getCustomFilters() {
125 if ( $this->customFilters
=== null ) {
126 $this->customFilters
= array();
127 wfRunHooks( 'SpecialRecentChangesFilters', array( $this, &$this->customFilters
) );
130 return $this->customFilters
;
134 * Get the current FormOptions for this request
136 public function getOptions() {
137 if ( $this->rcOptions
=== null ) {
138 $this->rcOptions
= $this->setup( $this->rcSubpage
);
141 return $this->rcOptions
;
145 * Main execution point
147 * @param string $subpage
149 public function execute( $subpage ) {
150 $this->rcSubpage
= $subpage;
151 $this->feedFormat
= $this->including() ?
null : $this->getRequest()->getVal( 'feed' );
153 # 10 seconds server-side caching max
154 $this->getOutput()->setSquidMaxage( 10 );
155 # Check if the client has a cached version
156 $lastmod = $this->checkLastModified( $this->feedFormat
);
157 if ( $lastmod === false ) {
161 $opts = $this->getOptions();
163 $this->outputHeader();
166 // Fetch results, prepare a batch link existence check query
167 $conds = $this->buildMainQueryConds( $opts );
168 $rows = $this->doMainQuery( $conds, $opts );
169 if ( $rows === false ) {
170 if ( !$this->including() ) {
171 $this->doHeader( $opts );
177 if ( !$this->feedFormat
) {
178 $batch = new LinkBatch
;
179 foreach ( $rows as $row ) {
180 $batch->add( NS_USER
, $row->rc_user_text
);
181 $batch->add( NS_USER_TALK
, $row->rc_user_text
);
182 $batch->add( $row->rc_namespace
, $row->rc_title
);
186 if ( $this->feedFormat
) {
187 list( $changesFeed, $formatter ) = $this->getFeedObject( $this->feedFormat
);
188 /** @var ChangesFeed $changesFeed */
189 $changesFeed->execute( $formatter, $rows, $lastmod, $opts );
191 $this->webOutput( $rows, $opts );
198 * Return an array with a ChangesFeed object and ChannelFeed object
200 * @param string $feedFormat Feed's format (either 'rss' or 'atom')
203 public function getFeedObject( $feedFormat ) {
204 $changesFeed = new ChangesFeed( $feedFormat, 'rcfeed' );
205 $formatter = $changesFeed->getFeedObject(
206 $this->msg( 'recentchanges' )->inContentLanguage()->text(),
207 $this->msg( 'recentchanges-feed-description' )->inContentLanguage()->text(),
208 $this->getPageTitle()->getFullURL()
211 return array( $changesFeed, $formatter );
215 * Process $par and put options found if $opts
216 * Mainly used when including the page
219 * @param FormOptions $opts
221 public function parseParameters( $par, FormOptions
$opts ) {
222 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
223 foreach ( $bits as $bit ) {
224 if ( 'hidebots' === $bit ) {
225 $opts['hidebots'] = true;
227 if ( 'bots' === $bit ) {
228 $opts['hidebots'] = false;
230 if ( 'hideminor' === $bit ) {
231 $opts['hideminor'] = true;
233 if ( 'minor' === $bit ) {
234 $opts['hideminor'] = false;
236 if ( 'hideliu' === $bit ) {
237 $opts['hideliu'] = true;
239 if ( 'hidepatrolled' === $bit ) {
240 $opts['hidepatrolled'] = true;
242 if ( 'hideanons' === $bit ) {
243 $opts['hideanons'] = true;
245 if ( 'hidemyself' === $bit ) {
246 $opts['hidemyself'] = true;
249 if ( is_numeric( $bit ) ) {
250 $opts['limit'] = $bit;
254 if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
255 $opts['limit'] = $m[1];
257 if ( preg_match( '/^days=(\d+)$/', $bit, $m ) ) {
258 $opts['days'] = $m[1];
260 if ( preg_match( '/^namespace=(\d+)$/', $bit, $m ) ) {
261 $opts['namespace'] = $m[1];
267 * Get last modified date, for client caching
268 * Don't use this if we are using the patrol feature, patrol changes don't
269 * update the timestamp
271 * @param string $feedFormat
272 * @return string|bool
274 public function checkLastModified( $feedFormat ) {
275 $dbr = wfGetDB( DB_SLAVE
);
276 $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __METHOD__
);
277 if ( $feedFormat ||
!$this->getUser()->useRCPatrol() ) {
278 if ( $lastmod && $this->getOutput()->checkLastModified( $lastmod ) ) {
279 # Client cache fresh and headers sent, nothing more to do.
288 * Return an array of conditions depending of options set in $opts
290 * @param FormOptions $opts
293 public function buildMainQueryConds( FormOptions
$opts ) {
294 $dbr = wfGetDB( DB_SLAVE
);
297 # It makes no sense to hide both anons and logged-in users
298 # Where this occurs, force anons to be shown
300 if ( $opts['hideanons'] && $opts['hideliu'] ) {
301 # Check if the user wants to show bots only
302 if ( $opts['hidebots'] ) {
303 $opts['hideanons'] = false;
306 $opts['hidebots'] = false;
311 $cutoff_unixtime = time() - ( $opts['days'] * 86400 );
312 $cutoff_unixtime = $cutoff_unixtime - ( $cutoff_unixtime %
86400 );
313 $cutoff = $dbr->timestamp( $cutoff_unixtime );
315 $fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
316 if ( $fromValid && $opts['from'] > wfTimestamp( TS_MW
, $cutoff ) ) {
317 $cutoff = $dbr->timestamp( $opts['from'] );
319 $opts->reset( 'from' );
322 $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
324 $hidePatrol = $this->getUser()->useRCPatrol() && $opts['hidepatrolled'];
325 $hideLoggedInUsers = $opts['hideliu'] && !$forcebot;
326 $hideAnonymousUsers = $opts['hideanons'] && !$forcebot;
328 if ( $opts['hideminor'] ) {
329 $conds['rc_minor'] = 0;
331 if ( $opts['hidebots'] ) {
332 $conds['rc_bot'] = 0;
335 $conds['rc_patrolled'] = 0;
338 $conds['rc_bot'] = 1;
340 if ( $hideLoggedInUsers ) {
341 $conds[] = 'rc_user = 0';
343 if ( $hideAnonymousUsers ) {
344 $conds[] = 'rc_user != 0';
347 if ( $opts['hidemyself'] ) {
348 if ( $this->getUser()->getId() ) {
349 $conds[] = 'rc_user != ' . $dbr->addQuotes( $this->getUser()->getId() );
351 $conds[] = 'rc_user_text != ' . $dbr->addQuotes( $this->getUser()->getName() );
355 # Namespace filtering
356 if ( $opts['namespace'] !== '' ) {
357 $selectedNS = $dbr->addQuotes( $opts['namespace'] );
358 $operator = $opts['invert'] ?
'!=' : '=';
359 $boolean = $opts['invert'] ?
'AND' : 'OR';
361 # namespace association (bug 2429)
362 if ( !$opts['associated'] ) {
363 $condition = "rc_namespace $operator $selectedNS";
365 # Also add the associated namespace
366 $associatedNS = $dbr->addQuotes(
367 MWNamespace
::getAssociated( $opts['namespace'] )
369 $condition = "(rc_namespace $operator $selectedNS "
371 . " rc_namespace $operator $associatedNS)";
374 $conds[] = $condition;
383 * @param array $conds
384 * @param FormOptions $opts
385 * @return bool|ResultWrapper Result or false (for Recentchangeslinked only)
387 public function doMainQuery( $conds, $opts ) {
388 $tables = array( 'recentchanges' );
389 $join_conds = array();
390 $query_options = array();
392 $uid = $this->getUser()->getId();
393 $dbr = wfGetDB( DB_SLAVE
);
394 $limit = $opts['limit'];
395 $namespace = $opts['namespace'];
396 $invert = $opts['invert'];
397 $associated = $opts['associated'];
399 $fields = RecentChange
::selectFields();
400 // JOIN on watchlist for users
401 if ( $uid && $this->getUser()->isAllowed( 'viewmywatchlist' ) ) {
402 $tables[] = 'watchlist';
403 $fields[] = 'wl_user';
404 $fields[] = 'wl_notificationtimestamp';
405 $join_conds['watchlist'] = array( 'LEFT JOIN', array(
408 'wl_namespace=rc_namespace'
411 if ( $this->getUser()->isAllowed( 'rollback' ) ) {
413 $fields[] = 'page_latest';
414 $join_conds['page'] = array( 'LEFT JOIN', 'rc_cur_id=page_id' );
417 ChangeTags
::modifyDisplayQuery(
426 if ( !wfRunHooks( 'SpecialRecentChangesQuery',
427 array( &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ) )
432 // rc_new is not an ENUM, but adding a redundant rc_new IN (0,1) gives mysql enough
433 // knowledge to use an index merge if it wants (it may use some other index though).
437 $conds +
array( 'rc_new' => array( 0, 1 ) ),
439 array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit ) +
$query_options,
445 * Send output to the OutputPage object, only called if not used feeds
447 * @param array $rows Database rows
448 * @param FormOptions $opts
450 public function webOutput( $rows, $opts ) {
451 global $wgRCShowWatchingUsers, $wgShowUpdatedMarker, $wgAllowCategorizedRecentChanges;
453 // Build the final data
455 if ( $wgAllowCategorizedRecentChanges ) {
456 $this->filterByCategories( $rows, $opts );
459 $limit = $opts['limit'];
461 $showWatcherCount = $wgRCShowWatchingUsers && $this->getUser()->getOption( 'shownumberswatching' );
462 $watcherCache = array();
464 $dbr = wfGetDB( DB_SLAVE
);
467 $list = ChangesList
::newFromContext( $this->getContext() );
469 $rclistOutput = $list->beginRecentChangesList();
470 foreach ( $rows as $obj ) {
474 $rc = RecentChange
::newFromRow( $obj );
475 $rc->counter
= $counter++
;
476 # Check if the page has been updated since the last visit
477 if ( $wgShowUpdatedMarker && !empty( $obj->wl_notificationtimestamp
) ) {
478 $rc->notificationtimestamp
= ( $obj->rc_timestamp
>= $obj->wl_notificationtimestamp
);
480 $rc->notificationtimestamp
= false; // Default
482 # Check the number of users watching the page
483 $rc->numberofWatchingusers
= 0; // Default
484 if ( $showWatcherCount && $obj->rc_namespace
>= 0 ) {
485 if ( !isset( $watcherCache[$obj->rc_namespace
][$obj->rc_title
] ) ) {
486 $watcherCache[$obj->rc_namespace
][$obj->rc_title
] =
491 'wl_namespace' => $obj->rc_namespace
,
492 'wl_title' => $obj->rc_title
,
494 __METHOD__
. '-watchers'
497 $rc->numberofWatchingusers
= $watcherCache[$obj->rc_namespace
][$obj->rc_title
];
500 $changeLine = $list->recentChangesLine( $rc, !empty( $obj->wl_user
), $counter );
501 if ( $changeLine !== false ) {
502 $rclistOutput .= $changeLine;
506 $rclistOutput .= $list->endRecentChangesList();
510 if ( !$this->including() ) {
511 // Output options box
512 $this->doHeader( $opts );
515 // And now for the content
516 $feedQuery = $this->getFeedQuery();
517 if ( $feedQuery !== '' ) {
518 $this->getOutput()->setFeedAppendQuery( $feedQuery );
520 $this->getOutput()->setFeedAppendQuery( false );
523 if ( $rows->numRows() === 0 ) {
524 $this->getOutput()->addHtml(
525 '<div class="mw-changeslist-empty">' . $this->msg( 'recentchanges-noresult' )->parse() . '</div>'
528 $this->getOutput()->addHTML( $rclistOutput );
533 * Get the query string to append to feed link URLs.
537 public function getFeedQuery() {
540 $this->getOptions()->validateIntBounds( 'limit', 0, $wgFeedLimit );
541 $options = $this->getOptions()->getChangedValues();
543 // wfArrayToCgi() omits options set to null or false
544 foreach ( $options as &$value ) {
545 if ( $value === false ) {
551 return wfArrayToCgi( $options );
555 * Return the text to be displayed above the changes
557 * @param FormOptions $opts
558 * @return string XHTML
560 public function doHeader( $opts ) {
563 $this->setTopText( $opts );
565 $defaults = $opts->getAllValues();
566 $nondefaults = $opts->getChangedValues();
569 $panel[] = self
::makeLegend( $this->getContext() );
570 $panel[] = $this->optionsPanel( $defaults, $nondefaults );
573 $extraOpts = $this->getExtraOptions( $opts );
574 $extraOptsCount = count( $extraOpts );
576 $submit = ' ' . Xml
::submitbutton( $this->msg( 'allpagessubmit' )->text() );
578 $out = Xml
::openElement( 'table', array( 'class' => 'mw-recentchanges-table' ) );
579 foreach ( $extraOpts as $name => $optionRow ) {
580 # Add submit button to the last row only
582 $addSubmit = ( $count === $extraOptsCount ) ?
$submit : '';
584 $out .= Xml
::openElement( 'tr' );
585 if ( is_array( $optionRow ) ) {
588 array( 'class' => 'mw-label mw-' . $name . '-label' ),
593 array( 'class' => 'mw-input' ),
594 $optionRow[1] . $addSubmit
599 array( 'class' => 'mw-input', 'colspan' => 2 ),
600 $optionRow . $addSubmit
603 $out .= Xml
::closeElement( 'tr' );
605 $out .= Xml
::closeElement( 'table' );
607 $unconsumed = $opts->getUnconsumedValues();
608 foreach ( $unconsumed as $key => $value ) {
609 $out .= Html
::hidden( $key, $value );
612 $t = $this->getPageTitle();
613 $out .= Html
::hidden( 'title', $t->getPrefixedText() );
614 $form = Xml
::tags( 'form', array( 'action' => $wgScript ), $out );
616 $panelString = implode( "\n", $panel );
618 $this->getOutput()->addHTML(
620 $this->msg( 'recentchanges-legend' )->text(),
622 array( 'class' => 'rcoptions' )
626 $this->setBottomText( $opts );
630 * Get options to be displayed in a form
632 * @param FormOptions $opts
635 function getExtraOptions( $opts ) {
636 $opts->consumeValues( array(
637 'namespace', 'invert', 'associated', 'tagfilter', 'categories', 'categories_any'
640 $extraOpts = array();
641 $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
643 global $wgAllowCategorizedRecentChanges;
644 if ( $wgAllowCategorizedRecentChanges ) {
645 $extraOpts['category'] = $this->categoryFilterForm( $opts );
648 $tagFilter = ChangeTags
::buildTagFilterSelector( $opts['tagfilter'] );
649 if ( count( $tagFilter ) ) {
650 $extraOpts['tagfilter'] = $tagFilter;
653 // Don't fire the hook for subclasses. (Or should we?)
654 if ( $this->getName() === 'Recentchanges' ) {
655 wfRunHooks( 'SpecialRecentChangesPanel', array( &$extraOpts, $opts ) );
662 * Return the legend displayed within the fieldset.
664 * This method is also called from SpecialWatchlist.
666 * @param $context the object available as $this in non-static functions
669 public static function makeLegend( IContextSource
$context ) {
670 global $wgRecentChangesFlags;
671 $user = $context->getUser();
672 # The legend showing what the letters and stuff mean
673 $legend = Xml
::openElement( 'dl' ) . "\n";
674 # Iterates through them and gets the messages for both letter and tooltip
675 $legendItems = $wgRecentChangesFlags;
676 if ( !$user->useRCPatrol() ) {
677 unset( $legendItems['unpatrolled'] );
679 foreach ( $legendItems as $key => $legendInfo ) { # generate items of the legend
680 $label = $legendInfo['title'];
681 $letter = $legendInfo['letter'];
682 $cssClass = isset( $legendInfo['class'] ) ?
$legendInfo['class'] : $key;
684 $legend .= Xml
::element( 'dt',
685 array( 'class' => $cssClass ), $context->msg( $letter )->text()
687 if ( $key === 'newpage' ) {
688 $legend .= Xml
::openElement( 'dd' );
689 $legend .= $context->msg( $label )->escaped();
690 $legend .= ' ' . $context->msg( 'recentchanges-legend-newpage' )->parse();
691 $legend .= Xml
::closeElement( 'dd' ) . "\n";
693 $legend .= Xml
::element( 'dd', array(),
694 $context->msg( $label )->text()
699 $legend .= Xml
::tags( 'dt',
700 array( 'class' => 'mw-plusminus-pos' ),
701 $context->msg( 'recentchanges-legend-plusminus' )->parse()
703 $legend .= Xml
::element(
705 array( 'class' => 'mw-changeslist-legend-plusminus' ),
706 $context->msg( 'recentchanges-label-plusminus' )->text()
708 $legend .= Xml
::closeElement( 'dl' ) . "\n";
712 '<div class="mw-changeslist-legend">' .
713 $context->msg( 'recentchanges-legend-heading' )->parse() .
714 '<div class="mw-collapsible-content">' . $legend . '</div>' .
721 * Send the text to be displayed above the options
723 * @param FormOptions $opts Unused
725 function setTopText( FormOptions
$opts ) {
728 $message = $this->msg( 'recentchangestext' )->inContentLanguage();
729 if ( !$message->isDisabled() ) {
730 $this->getOutput()->addWikiText(
731 Html
::rawElement( 'p',
732 array( 'lang' => $wgContLang->getCode(), 'dir' => $wgContLang->getDir() ),
733 "\n" . $message->plain() . "\n"
735 /* $lineStart */ false,
736 /* $interface */ false
742 * Send the text to be displayed after the options, for use in subclasses.
744 * @param FormOptions $opts
746 function setBottomText( FormOptions
$opts ) {
750 * Creates the choose namespace selection
752 * @param FormOptions $opts
755 protected function namespaceFilterForm( FormOptions
$opts ) {
756 $nsSelect = Html
::namespaceSelector(
757 array( 'selected' => $opts['namespace'], 'all' => '' ),
758 array( 'name' => 'namespace', 'id' => 'namespace' )
760 $nsLabel = Xml
::label( $this->msg( 'namespace' )->text(), 'namespace' );
761 $invert = Xml
::checkLabel(
762 $this->msg( 'invert' )->text(), 'invert', 'nsinvert',
764 array( 'title' => $this->msg( 'tooltip-invert' )->text() )
766 $associated = Xml
::checkLabel(
767 $this->msg( 'namespace_association' )->text(), 'associated', 'nsassociated',
769 array( 'title' => $this->msg( 'tooltip-namespace_association' )->text() )
772 return array( $nsLabel, "$nsSelect $invert $associated" );
776 * Create a input to filter changes by categories
778 * @param FormOptions $opts
781 protected function categoryFilterForm( FormOptions
$opts ) {
782 list( $label, $input ) = Xml
::inputLabelSep( $this->msg( 'rc_categories' )->text(),
783 'categories', 'mw-categories', false, $opts['categories'] );
785 $input .= ' ' . Xml
::checkLabel( $this->msg( 'rc_categories_any' )->text(),
786 'categories_any', 'mw-categories_any', $opts['categories_any'] );
788 return array( $label, $input );
792 * Filter $rows by categories set in $opts
794 * @param array $rows Database rows
795 * @param FormOptions $opts
797 function filterByCategories( &$rows, FormOptions
$opts ) {
798 $categories = array_map( 'trim', explode( '|', $opts['categories'] ) );
800 if ( !count( $categories ) ) {
806 foreach ( $categories as $cat ) {
818 foreach ( $rows as $k => $r ) {
819 $nt = Title
::makeTitle( $r->rc_namespace
, $r->rc_title
);
820 $id = $nt->getArticleID();
822 continue; # Page might have been deleted...
824 if ( !in_array( $id, $articles ) ) {
827 if ( !isset( $a2r[$id] ) ) {
835 if ( !count( $articles ) ||
!count( $cats ) ) {
840 $c = new Categoryfinder
;
841 $c->seed( $articles, $cats, $opts['categories_any'] ?
'OR' : 'AND' );
846 foreach ( $match as $id ) {
847 foreach ( $a2r[$id] as $rev ) {
849 $newrows[$k] = $rowsarr[$k];
856 * Makes change an option link which carries all the other options
858 * @param string $title Title
859 * @param array $override Options to override
860 * @param array $options Current options
861 * @param bool $active Whether to show the link in bold
864 function makeOptionsLink( $title, $override, $options, $active = false ) {
865 $params = $override +
$options;
867 // Bug 36524: false values have be converted to "0" otherwise
868 // wfArrayToCgi() will omit it them.
869 foreach ( $params as &$value ) {
870 if ( $value === false ) {
876 $text = htmlspecialchars( $title );
878 $text = '<strong>' . $text . '</strong>';
881 return Linker
::linkKnown( $this->getPageTitle(), $text, array(), $params );
885 * Creates the options panel.
887 * @param array $defaults
888 * @param array $nondefaults
891 function optionsPanel( $defaults, $nondefaults ) {
892 global $wgRCLinkLimits, $wgRCLinkDays;
894 $options = $nondefaults +
$defaults;
897 $msg = $this->msg( 'rclegend' );
898 if ( !$msg->isDisabled() ) {
899 $note .= '<div class="mw-rclegend">' . $msg->parse() . "</div>\n";
902 $lang = $this->getLanguage();
903 $user = $this->getUser();
904 if ( $options['from'] ) {
905 $note .= $this->msg( 'rcnotefrom' )->numParams( $options['limit'] )->params(
906 $lang->userTimeAndDate( $options['from'], $user ),
907 $lang->userDate( $options['from'], $user ),
908 $lang->userTime( $options['from'], $user ) )->parse() . '<br />';
911 # Sort data for display and make sure it's unique after we've added user data.
912 $linkLimits = $wgRCLinkLimits;
913 $linkLimits[] = $options['limit'];
915 $linkLimits = array_unique( $linkLimits );
917 $linkDays = $wgRCLinkDays;
918 $linkDays[] = $options['days'];
920 $linkDays = array_unique( $linkDays );
924 foreach ( $linkLimits as $value ) {
925 $cl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
926 array( 'limit' => $value ), $nondefaults, $value == $options['limit'] );
928 $cl = $lang->pipeList( $cl );
930 // day links, reset 'from' to none
932 foreach ( $linkDays as $value ) {
933 $dl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
934 array( 'days' => $value, 'from' => '' ), $nondefaults, $value == $options['days'] );
936 $dl = $lang->pipeList( $dl );
939 $showhide = array( $this->msg( 'show' )->text(), $this->msg( 'hide' )->text() );
941 'hideminor' => 'rcshowhideminor',
942 'hidebots' => 'rcshowhidebots',
943 'hideanons' => 'rcshowhideanons',
944 'hideliu' => 'rcshowhideliu',
945 'hidepatrolled' => 'rcshowhidepatr',
946 'hidemyself' => 'rcshowhidemine'
948 foreach ( $this->getCustomFilters() as $key => $params ) {
949 $filters[$key] = $params['msg'];
951 // Disable some if needed
952 if ( !$user->useRCPatrol() ) {
953 unset( $filters['hidepatrolled'] );
957 foreach ( $filters as $key => $msg ) {
958 $link = $this->makeOptionsLink( $showhide[1 - $options[$key]],
959 array( $key => 1 - $options[$key] ), $nondefaults );
960 $links[] = $this->msg( $msg )->rawParams( $link )->escaped();
963 // show from this onward link
964 $timestamp = wfTimestampNow();
965 $now = $lang->userTimeAndDate( $timestamp, $user );
966 $tl = $this->makeOptionsLink(
967 $now, array( 'from' => $timestamp ), $nondefaults
970 $rclinks = $this->msg( 'rclinks' )->rawParams( $cl, $dl, $lang->pipeList( $links ) )
972 $rclistfrom = $this->msg( 'rclistfrom' )->rawParams( $tl )->parse();
974 return "{$note}$rclinks<br />$rclistfrom";
978 * Add page-specific modules.
980 protected function addModules() {
981 $out = $this->getOutput();
982 $out->addModules( 'mediawiki.special.recentchanges' );
983 // This modules include styles and behavior for the legend box, load it unconditionally
984 $out->addModuleStyles( 'mediawiki.special.changeslist' );
985 $out->addModules( 'mediawiki.special.changeslist.js' );
988 protected function getGroupName() {