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
24 use MediaWiki\MediaWikiServices
;
25 use Wikimedia\Rdbms\ResultWrapper
;
26 use Wikimedia\Rdbms\FakeResultWrapper
;
29 * A special page that lists last changes made to the wiki
31 * @ingroup SpecialPage
33 class SpecialRecentChanges
extends ChangesListSpecialPage
{
35 protected static $savedQueriesPreferenceName = 'rcfilters-saved-queries';
36 protected static $daysPreferenceName = 'rcdays'; // Use general RecentChanges preference
37 protected static $limitPreferenceName = 'rcfilters-limit'; // Use RCFilters-specific preference
39 private $watchlistFilterGroupDefinition;
41 public function __construct( $name = 'Recentchanges', $restriction = '' ) {
42 parent
::__construct( $name, $restriction );
44 $this->watchlistFilterGroupDefinition
= [
45 'name' => 'watchlist',
46 'title' => 'rcfilters-filtergroup-watchlist',
47 'class' => ChangesListStringOptionsFilterGroup
::class,
49 'isFullCoverage' => true,
53 'label' => 'rcfilters-filter-watchlist-watched-label',
54 'description' => 'rcfilters-filter-watchlist-watched-description',
55 'cssClassSuffix' => 'watched',
56 'isRowApplicableCallable' => function ( $ctx, $rc ) {
57 return $rc->getAttribute( 'wl_user' );
61 'name' => 'watchednew',
62 'label' => 'rcfilters-filter-watchlist-watchednew-label',
63 'description' => 'rcfilters-filter-watchlist-watchednew-description',
64 'cssClassSuffix' => 'watchednew',
65 'isRowApplicableCallable' => function ( $ctx, $rc ) {
66 return $rc->getAttribute( 'wl_user' ) &&
67 $rc->getAttribute( 'rc_timestamp' ) &&
68 $rc->getAttribute( 'wl_notificationtimestamp' ) &&
69 $rc->getAttribute( 'rc_timestamp' ) >= $rc->getAttribute( 'wl_notificationtimestamp' );
73 'name' => 'notwatched',
74 'label' => 'rcfilters-filter-watchlist-notwatched-label',
75 'description' => 'rcfilters-filter-watchlist-notwatched-description',
76 'cssClassSuffix' => 'notwatched',
77 'isRowApplicableCallable' => function ( $ctx, $rc ) {
78 return $rc->getAttribute( 'wl_user' ) === null;
82 'default' => ChangesListStringOptionsFilterGroup
::NONE
,
83 'queryCallable' => function ( $specialPageClassName, $context, $dbr,
84 &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) {
85 sort( $selectedValues );
86 $notwatchedCond = 'wl_user IS NULL';
87 $watchedCond = 'wl_user IS NOT NULL';
88 $newCond = 'rc_timestamp >= wl_notificationtimestamp';
90 if ( $selectedValues === [ 'notwatched' ] ) {
91 $conds[] = $notwatchedCond;
95 if ( $selectedValues === [ 'watched' ] ) {
96 $conds[] = $watchedCond;
100 if ( $selectedValues === [ 'watchednew' ] ) {
101 $conds[] = $dbr->makeList( [
108 if ( $selectedValues === [ 'notwatched', 'watched' ] ) {
113 if ( $selectedValues === [ 'notwatched', 'watchednew' ] ) {
114 $conds[] = $dbr->makeList( [
124 if ( $selectedValues === [ 'watched', 'watchednew' ] ) {
125 $conds[] = $watchedCond;
129 if ( $selectedValues === [ 'notwatched', 'watched', 'watchednew' ] ) {
138 * Main execution point
140 * @param string $subpage
142 public function execute( $subpage ) {
143 // Backwards-compatibility: redirect to new feed URLs
144 $feedFormat = $this->getRequest()->getVal( 'feed' );
145 if ( !$this->including() && $feedFormat ) {
146 $query = $this->getFeedQuery();
147 $query['feedformat'] = $feedFormat === 'atom' ?
'atom' : 'rss';
148 $this->getOutput()->redirect( wfAppendQuery( wfScript( 'api' ), $query ) );
153 // 10 seconds server-side caching max
154 $out = $this->getOutput();
155 $out->setCdnMaxage( 10 );
156 // Check if the client has a cached version
157 $lastmod = $this->checkLastModified();
158 if ( $lastmod === false ) {
163 '//meta.wikimedia.org/wiki/Special:MyLanguage/Help:Recent_changes',
166 parent
::execute( $subpage );
172 protected function transformFilterDefinition( array $filterDefinition ) {
173 if ( isset( $filterDefinition['showHideSuffix'] ) ) {
174 $filterDefinition['showHide'] = 'rc' . $filterDefinition['showHideSuffix'];
177 return $filterDefinition;
183 protected function registerFilters() {
184 parent
::registerFilters();
187 !$this->including() &&
188 $this->getUser()->isLoggedIn() &&
189 $this->getUser()->isAllowed( 'viewmywatchlist' )
191 $this->registerFiltersFromDefinitions( [ $this->watchlistFilterGroupDefinition
] );
192 $watchlistGroup = $this->getFilterGroup( 'watchlist' );
193 $watchlistGroup->getFilter( 'watched' )->setAsSupersetOf(
194 $watchlistGroup->getFilter( 'watchednew' )
198 $user = $this->getUser();
200 $significance = $this->getFilterGroup( 'significance' );
201 $hideMinor = $significance->getFilter( 'hideminor' );
202 $hideMinor->setDefault( $user->getBoolOption( 'hideminor' ) );
204 $automated = $this->getFilterGroup( 'automated' );
205 $hideBots = $automated->getFilter( 'hidebots' );
206 $hideBots->setDefault( true );
208 $reviewStatus = $this->getFilterGroup( 'reviewStatus' );
209 if ( $reviewStatus !== null ) {
210 // Conditional on feature being available and rights
211 if ( $user->getBoolOption( 'hidepatrolled' ) ) {
212 $reviewStatus->setDefault( 'unpatrolled' );
213 $legacyReviewStatus = $this->getFilterGroup( 'legacyReviewStatus' );
214 $legacyHidePatrolled = $legacyReviewStatus->getFilter( 'hidepatrolled' );
215 $legacyHidePatrolled->setDefault( true );
219 $changeType = $this->getFilterGroup( 'changeType' );
220 $hideCategorization = $changeType->getFilter( 'hidecategorization' );
221 if ( $hideCategorization !== null ) {
222 // Conditional on feature being available
223 $hideCategorization->setDefault( $user->getBoolOption( 'hidecategorization' ) );
228 * Get all custom filters
230 * @return array Map of filter URL param names to properties (msg/default)
232 protected function getCustomFilters() {
233 if ( $this->customFilters
=== null ) {
234 $this->customFilters
= parent
::getCustomFilters();
235 Hooks
::run( 'SpecialRecentChangesFilters', [ $this, &$this->customFilters
], '1.23' );
238 return $this->customFilters
;
242 * Process $par and put options found in $opts. Used when including the page.
245 * @param FormOptions $opts
247 public function parseParameters( $par, FormOptions
$opts ) {
248 parent
::parseParameters( $par, $opts );
250 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
251 foreach ( $bits as $bit ) {
252 if ( is_numeric( $bit ) ) {
253 $opts['limit'] = $bit;
257 if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
258 $opts['limit'] = $m[1];
260 if ( preg_match( '/^days=(\d+(?:\.\d+)?)$/', $bit, $m ) ) {
261 $opts['days'] = $m[1];
263 if ( preg_match( '/^namespace=(.*)$/', $bit, $m ) ) {
264 $opts['namespace'] = $m[1];
266 if ( preg_match( '/^tagfilter=(.*)$/', $bit, $m ) ) {
267 $opts['tagfilter'] = $m[1];
275 protected function doMainQuery( $tables, $fields, $conds, $query_options,
276 $join_conds, FormOptions
$opts
278 $dbr = $this->getDB();
279 $user = $this->getUser();
281 $rcQuery = RecentChange
::getQueryInfo();
282 $tables = array_merge( $tables, $rcQuery['tables'] );
283 $fields = array_merge( $rcQuery['fields'], $fields );
284 $join_conds = array_merge( $join_conds, $rcQuery['joins'] );
286 // JOIN on watchlist for users
287 if ( $user->isLoggedIn() && $user->isAllowed( 'viewmywatchlist' ) ) {
288 $tables[] = 'watchlist';
289 $fields[] = 'wl_user';
290 $fields[] = 'wl_notificationtimestamp';
291 $join_conds['watchlist'] = [ 'LEFT JOIN', [
292 'wl_user' => $user->getId(),
294 'wl_namespace=rc_namespace'
298 // JOIN on page, used for 'last revision' filter highlight
300 $fields[] = 'page_latest';
301 $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
303 $tagFilter = $opts['tagfilter'] ?
explode( '|', $opts['tagfilter'] ) : [];
304 ChangeTags
::modifyDisplayQuery(
313 if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
319 if ( $this->areFiltersInConflict() ) {
324 'ORDER BY' => 'rc_timestamp DESC',
325 'LIMIT' => $opts['limit']
327 if ( in_array( 'DISTINCT', $query_options ) ) {
328 // ChangeTags::modifyDisplayQuery() adds DISTINCT when filtering on multiple tags.
329 // In order to prevent DISTINCT from causing query performance problems,
330 // we have to GROUP BY the primary key. This in turn requires us to add
331 // the primary key to the end of the ORDER BY, and the old ORDER BY to the
332 // start of the GROUP BY
333 $orderByAndLimit['ORDER BY'] = 'rc_timestamp DESC, rc_id DESC';
334 $orderByAndLimit['GROUP BY'] = 'rc_timestamp, rc_id';
336 // array_merge() is used intentionally here so that hooks can, should
337 // they so desire, override the ORDER BY / LIMIT condition(s); prior to
338 // MediaWiki 1.26 this used to use the plus operator instead, which meant
339 // that extensions weren't able to change these conditions
340 $query_options = array_merge( $orderByAndLimit, $query_options );
341 $rows = $dbr->select(
344 // rc_new is not an ENUM, but adding a redundant rc_new IN (0,1) gives mysql enough
345 // knowledge to use an index merge if it wants (it may use some other index though).
346 $conds +
[ 'rc_new' => [ 0, 1 ] ],
355 protected function runMainQueryHook( &$tables, &$fields, &$conds,
356 &$query_options, &$join_conds, $opts
358 return parent
::runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts )
360 'SpecialRecentChangesQuery',
361 [ &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ],
366 protected function getDB() {
367 return wfGetDB( DB_REPLICA
, 'recentchanges' );
370 public function outputFeedLinks() {
371 $this->addFeedLinks( $this->getFeedQuery() );
375 * Get URL query parameters for action=feedrecentchanges API feed of current recent changes view.
379 protected function getFeedQuery() {
380 $query = array_filter( $this->getOptions()->getAllValues(), function ( $value ) {
381 // API handles empty parameters in a different way
382 return $value !== '';
384 $query['action'] = 'feedrecentchanges';
385 $feedLimit = $this->getConfig()->get( 'FeedLimit' );
386 if ( $query['limit'] > $feedLimit ) {
387 $query['limit'] = $feedLimit;
394 * Build and output the actual changes list.
396 * @param ResultWrapper $rows Database rows
397 * @param FormOptions $opts
399 public function outputChangesList( $rows, $opts ) {
400 $limit = $opts['limit'];
402 $showWatcherCount = $this->getConfig()->get( 'RCShowWatchingUsers' )
403 && $this->getUser()->getOption( 'shownumberswatching' );
407 $list = ChangesList
::newFromContext( $this->getContext(), $this->filterGroups
);
408 $list->initChangesListRows( $rows );
410 $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
411 $rclistOutput = $list->beginRecentChangesList();
412 if ( $this->isStructuredFilterUiEnabled() ) {
413 $rclistOutput .= $this->makeLegend();
416 foreach ( $rows as $obj ) {
420 $rc = RecentChange
::newFromRow( $obj );
422 # Skip CatWatch entries for hidden cats based on user preference
424 $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE
&&
425 !$userShowHiddenCats &&
426 $rc->getParam( 'hidden-cat' )
431 $rc->counter
= $counter++
;
432 # Check if the page has been updated since the last visit
433 if ( $this->getConfig()->get( 'ShowUpdatedMarker' )
434 && !empty( $obj->wl_notificationtimestamp
)
436 $rc->notificationtimestamp
= ( $obj->rc_timestamp
>= $obj->wl_notificationtimestamp
);
438 $rc->notificationtimestamp
= false; // Default
440 # Check the number of users watching the page
441 $rc->numberofWatchingusers
= 0; // Default
442 if ( $showWatcherCount && $obj->rc_namespace
>= 0 ) {
443 if ( !isset( $watcherCache[$obj->rc_namespace
][$obj->rc_title
] ) ) {
444 $watcherCache[$obj->rc_namespace
][$obj->rc_title
] =
445 MediaWikiServices
::getInstance()->getWatchedItemStore()->countWatchers(
446 new TitleValue( (int)$obj->rc_namespace
, $obj->rc_title
)
449 $rc->numberofWatchingusers
= $watcherCache[$obj->rc_namespace
][$obj->rc_title
];
452 $changeLine = $list->recentChangesLine( $rc, !empty( $obj->wl_user
), $counter );
453 if ( $changeLine !== false ) {
454 $rclistOutput .= $changeLine;
458 $rclistOutput .= $list->endRecentChangesList();
460 if ( $rows->numRows() === 0 ) {
461 $this->outputNoResults();
462 if ( !$this->including() ) {
463 $this->getOutput()->setStatusCode( 404 );
466 $this->getOutput()->addHTML( $rclistOutput );
471 * Set the text to be displayed above the changes
473 * @param FormOptions $opts
474 * @param int $numRows Number of rows in the result to show after this header
476 public function doHeader( $opts, $numRows ) {
477 $this->setTopText( $opts );
479 $defaults = $opts->getAllValues();
480 $nondefaults = $opts->getChangedValues();
483 if ( !$this->isStructuredFilterUiEnabled() ) {
484 $panel[] = $this->makeLegend();
486 $panel[] = $this->optionsPanel( $defaults, $nondefaults, $numRows );
489 $extraOpts = $this->getExtraOptions( $opts );
490 $extraOptsCount = count( $extraOpts );
492 $submit = ' ' . Xml
::submitButton( $this->msg( 'recentchanges-submit' )->text() );
494 $out = Xml
::openElement( 'table', [ 'class' => 'mw-recentchanges-table' ] );
495 foreach ( $extraOpts as $name => $optionRow ) {
496 # Add submit button to the last row only
498 $addSubmit = ( $count === $extraOptsCount ) ?
$submit : '';
500 $out .= Xml
::openElement( 'tr', [ 'class' => $name . 'Form' ] );
501 if ( is_array( $optionRow ) ) {
504 [ 'class' => 'mw-label mw-' . $name . '-label' ],
509 [ 'class' => 'mw-input' ],
510 $optionRow[1] . $addSubmit
515 [ 'class' => 'mw-input', 'colspan' => 2 ],
516 $optionRow . $addSubmit
519 $out .= Xml
::closeElement( 'tr' );
521 $out .= Xml
::closeElement( 'table' );
523 $unconsumed = $opts->getUnconsumedValues();
524 foreach ( $unconsumed as $key => $value ) {
525 $out .= Html
::hidden( $key, $value );
528 $t = $this->getPageTitle();
529 $out .= Html
::hidden( 'title', $t->getPrefixedText() );
530 $form = Xml
::tags( 'form', [ 'action' => wfScript() ], $out );
532 $panelString = implode( "\n", $panel );
534 $rcoptions = Xml
::fieldset(
535 $this->msg( 'recentchanges-legend' )->text(),
537 [ 'class' => 'rcoptions cloptions' ]
540 // Insert a placeholder for RCFilters
541 if ( $this->isStructuredFilterUiEnabled() ) {
542 $rcfilterContainer = Html
::element(
544 [ 'class' => 'rcfilters-container' ]
547 $loadingContainer = Html
::rawElement(
549 [ 'class' => 'rcfilters-spinner' ],
552 [ 'class' => 'rcfilters-spinner-bounce' ]
556 // Wrap both with rcfilters-head
557 $this->getOutput()->addHTML(
560 [ 'class' => 'rcfilters-head' ],
561 $rcfilterContainer . $rcoptions
566 $this->getOutput()->addHTML( $loadingContainer );
568 $this->getOutput()->addHTML( $rcoptions );
571 $this->setBottomText( $opts );
575 * Send the text to be displayed above the options
577 * @param FormOptions $opts Unused
579 function setTopText( FormOptions
$opts ) {
582 $message = $this->msg( 'recentchangestext' )->inContentLanguage();
583 if ( !$message->isDisabled() ) {
584 // Parse the message in this weird ugly way to preserve the ability to include interlanguage
585 // links in it (T172461). In the future when T66969 is resolved, perhaps we can just use
586 // $message->parse() instead. This code is copied from Message::parseText().
587 $parserOutput = MessageCache
::singleton()->parse(
589 $this->getPageTitle(),
591 // Message class sets the interface flag to false when parsing in a language different than
592 // user language, and this is wiki content language
596 $content = $parserOutput->getText( [
597 'enableSectionEditLinks' => false,
599 // Add only metadata here (including the language links), text is added below
600 $this->getOutput()->addParserOutputMetadata( $parserOutput );
603 'lang' => $wgContLang->getHtmlCode(),
604 'dir' => $wgContLang->getDir(),
607 $topLinksAttributes = [ 'class' => 'mw-recentchanges-toplinks' ];
609 if ( $this->isStructuredFilterUiEnabled() ) {
610 // Check whether the widget is already collapsed or expanded
611 $collapsedState = $this->getRequest()->getCookie( 'rcfilters-toplinks-collapsed-state' );
612 // Note that an empty/unset cookie means collapsed, so check for !== 'expanded'
613 $topLinksAttributes[ 'class' ] .= $collapsedState !== 'expanded' ?
614 ' mw-recentchanges-toplinks-collapsed' : '';
616 $this->getOutput()->enableOOUI();
617 $contentTitle = new OOUI\
ButtonWidget( [
618 'classes' => [ 'mw-recentchanges-toplinks-title' ],
619 'label' => new OOUI\
HtmlSnippet( $this->msg( 'rcfilters-other-review-tools' )->parse() ),
621 'indicator' => $collapsedState !== 'expanded' ?
'down' : 'up',
622 'flags' => [ 'progressive' ],
625 $contentWrapper = Html
::rawElement( 'div',
627 [ 'class' => 'mw-recentchanges-toplinks-content mw-collapsible-content' ],
632 $content = $contentTitle . $contentWrapper;
634 // Language direction should be on the top div only
635 // if the title is not there. If it is there, it's
636 // interface direction, and the language/dir attributes
637 // should be on the content itself
638 $topLinksAttributes = array_merge( $topLinksAttributes, $langAttributes );
641 $this->getOutput()->addHTML(
642 Html
::rawElement( 'div', $topLinksAttributes, $content )
648 * Get options to be displayed in a form
650 * @param FormOptions $opts
653 function getExtraOptions( $opts ) {
654 $opts->consumeValues( [
655 'namespace', 'invert', 'associated', 'tagfilter'
659 $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
661 $tagFilter = ChangeTags
::buildTagFilterSelector(
662 $opts['tagfilter'], false, $this->getContext() );
663 if ( count( $tagFilter ) ) {
664 $extraOpts['tagfilter'] = $tagFilter;
667 // Don't fire the hook for subclasses. (Or should we?)
668 if ( $this->getName() === 'Recentchanges' ) {
669 Hooks
::run( 'SpecialRecentChangesPanel', [ &$extraOpts, $opts ] );
676 * Add page-specific modules.
678 protected function addModules() {
679 parent
::addModules();
680 $out = $this->getOutput();
681 $out->addModules( 'mediawiki.special.recentchanges' );
685 * Get last modified date, for client caching
686 * Don't use this if we are using the patrol feature, patrol changes don't
687 * update the timestamp
689 * @return string|bool
691 public function checkLastModified() {
692 $dbr = $this->getDB();
693 $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', '', __METHOD__
);
699 * Creates the choose namespace selection
701 * @param FormOptions $opts
704 protected function namespaceFilterForm( FormOptions
$opts ) {
705 $nsSelect = Html
::namespaceSelector(
706 [ 'selected' => $opts['namespace'], 'all' => '' ],
707 [ 'name' => 'namespace', 'id' => 'namespace' ]
709 $nsLabel = Xml
::label( $this->msg( 'namespace' )->text(), 'namespace' );
710 $invert = Xml
::checkLabel(
711 $this->msg( 'invert' )->text(), 'invert', 'nsinvert',
713 [ 'title' => $this->msg( 'tooltip-invert' )->text() ]
715 $associated = Xml
::checkLabel(
716 $this->msg( 'namespace_association' )->text(), 'associated', 'nsassociated',
718 [ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
721 return [ $nsLabel, "$nsSelect $invert $associated" ];
725 * Filter $rows by categories set in $opts
727 * @deprecated since 1.31
729 * @param ResultWrapper &$rows Database rows
730 * @param FormOptions $opts
732 function filterByCategories( &$rows, FormOptions
$opts ) {
733 wfDeprecated( __METHOD__
, '1.31' );
735 $categories = array_map( 'trim', explode( '|', $opts['categories'] ) );
737 if ( !count( $categories ) ) {
743 foreach ( $categories as $cat ) {
755 foreach ( $rows as $k => $r ) {
756 $nt = Title
::makeTitle( $r->rc_namespace
, $r->rc_title
);
757 $id = $nt->getArticleID();
759 continue; # Page might have been deleted...
761 if ( !in_array( $id, $articles ) ) {
764 if ( !isset( $a2r[$id] ) ) {
772 if ( !count( $articles ) ||
!count( $cats ) ) {
777 $catFind = new CategoryFinder
;
778 $catFind->seed( $articles, $cats, $opts['categories_any'] ?
'OR' : 'AND' );
779 $match = $catFind->run();
783 foreach ( $match as $id ) {
784 foreach ( $a2r[$id] as $rev ) {
786 $newrows[$k] = $rowsarr[$k];
789 $rows = new FakeResultWrapper( array_values( $newrows ) );
793 * Makes change an option link which carries all the other options
795 * @param string $title
796 * @param array $override Options to override
797 * @param array $options Current options
798 * @param bool $active Whether to show the link in bold
801 function makeOptionsLink( $title, $override, $options, $active = false ) {
802 $params = $this->convertParamsForLink( $override +
$options );
805 $title = new HtmlArmor( '<strong>' . htmlspecialchars( $title ) . '</strong>' );
808 return $this->getLinkRenderer()->makeKnownLink( $this->getPageTitle(), $title, [
809 'data-params' => json_encode( $override ),
810 'data-keys' => implode( ',', array_keys( $override ) ),
815 * Creates the options panel.
817 * @param array $defaults
818 * @param array $nondefaults
819 * @param int $numRows Number of rows in the result to show after this header
822 function optionsPanel( $defaults, $nondefaults, $numRows ) {
823 $options = $nondefaults +
$defaults;
826 $msg = $this->msg( 'rclegend' );
827 if ( !$msg->isDisabled() ) {
828 $note .= '<div class="mw-rclegend">' . $msg->parse() . "</div>\n";
831 $lang = $this->getLanguage();
832 $user = $this->getUser();
833 $config = $this->getConfig();
834 if ( $options['from'] ) {
835 $resetLink = $this->makeOptionsLink( $this->msg( 'rclistfromreset' ),
836 [ 'from' => '' ], $nondefaults );
838 $noteFromMsg = $this->msg( 'rcnotefrom' )
839 ->numParams( $options['limit'] )
841 $lang->userTimeAndDate( $options['from'], $user ),
842 $lang->userDate( $options['from'], $user ),
843 $lang->userTime( $options['from'], $user )
845 ->numParams( $numRows );
846 $note .= Html
::rawElement(
848 [ 'class' => 'rcnotefrom' ],
849 $noteFromMsg->parse()
854 [ 'class' => 'rcoptions-listfromreset' ],
855 $this->msg( 'parentheses' )->rawParams( $resetLink )->parse()
860 # Sort data for display and make sure it's unique after we've added user data.
861 $linkLimits = $config->get( 'RCLinkLimits' );
862 $linkLimits[] = $options['limit'];
864 $linkLimits = array_unique( $linkLimits );
866 $linkDays = $config->get( 'RCLinkDays' );
867 $linkDays[] = $options['days'];
869 $linkDays = array_unique( $linkDays );
873 foreach ( $linkLimits as $value ) {
874 $cl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
875 [ 'limit' => $value ], $nondefaults, $value == $options['limit'] );
877 $cl = $lang->pipeList( $cl );
879 // day links, reset 'from' to none
881 foreach ( $linkDays as $value ) {
882 $dl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
883 [ 'days' => $value, 'from' => '' ], $nondefaults, $value == $options['days'] );
885 $dl = $lang->pipeList( $dl );
887 $showhide = [ 'show', 'hide' ];
891 foreach ( $this->getLegacyShowHideFilters() as $key => $filter ) {
892 $msg = $filter->getShowHide();
893 $linkMessage = $this->msg( $msg . '-' . $showhide[1 - $options[$key]] );
894 // Extensions can define additional filters, but don't need to define the corresponding
895 // messages. If they don't exist, just fall back to 'show' and 'hide'.
896 if ( !$linkMessage->exists() ) {
897 $linkMessage = $this->msg( $showhide[1 - $options[$key]] );
900 $link = $this->makeOptionsLink( $linkMessage->text(),
901 [ $key => 1 - $options[$key] ], $nondefaults );
904 'class' => "$msg rcshowhideoption clshowhideoption",
905 'data-filter-name' => $filter->getName(),
908 if ( $filter->isFeatureAvailableOnStructuredUi( $this ) ) {
909 $attribs['data-feature-in-structured-ui'] = true;
912 $links[] = Html
::rawElement(
915 $this->msg( $msg )->rawParams( $link )->parse()
919 // show from this onward link
920 $timestamp = wfTimestampNow();
921 $now = $lang->userTimeAndDate( $timestamp, $user );
922 $timenow = $lang->userTime( $timestamp, $user );
923 $datenow = $lang->userDate( $timestamp, $user );
924 $pipedLinks = '<span class="rcshowhide">' . $lang->pipeList( $links ) . '</span>';
926 $rclinks = '<span class="rclinks">' . $this->msg( 'rclinks' )->rawParams( $cl, $dl, '' )
927 ->parse() . '</span>';
929 $rclistfrom = '<span class="rclistfrom">' . $this->makeOptionsLink(
930 $this->msg( 'rclistfrom' )->rawParams( $now, $timenow, $datenow )->parse(),
931 [ 'from' => $timestamp ],
935 return "{$note}$rclinks<br />$pipedLinks<br />$rclistfrom";
938 public function isIncludable() {
942 protected function getCacheTTL() {
946 public function getDefaultLimit() {
947 $systemPrefValue = $this->getUser()->getIntOption( 'rclimit' );
948 // Prefer the RCFilters-specific preference if RCFilters is enabled
949 if ( $this->isStructuredFilterUiEnabled() ) {
950 return $this->getUser()->getIntOption( static::$limitPreferenceName, $systemPrefValue );
953 // Otherwise, use the system rclimit preference value
954 return $systemPrefValue;