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\IResultWrapper
;
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
38 protected static $collapsedPreferenceName = 'rcfilters-rc-collapsed';
40 private $watchlistFilterGroupDefinition;
42 public function __construct( $name = 'Recentchanges', $restriction = '' ) {
43 parent
::__construct( $name, $restriction );
45 $this->watchlistFilterGroupDefinition
= [
46 'name' => 'watchlist',
47 'title' => 'rcfilters-filtergroup-watchlist',
48 'class' => ChangesListStringOptionsFilterGroup
::class,
50 'isFullCoverage' => true,
54 'label' => 'rcfilters-filter-watchlist-watched-label',
55 'description' => 'rcfilters-filter-watchlist-watched-description',
56 'cssClassSuffix' => 'watched',
57 'isRowApplicableCallable' => function ( $ctx, $rc ) {
58 return $rc->getAttribute( 'wl_user' );
62 'name' => 'watchednew',
63 'label' => 'rcfilters-filter-watchlist-watchednew-label',
64 'description' => 'rcfilters-filter-watchlist-watchednew-description',
65 'cssClassSuffix' => 'watchednew',
66 'isRowApplicableCallable' => function ( $ctx, $rc ) {
67 return $rc->getAttribute( 'wl_user' ) &&
68 $rc->getAttribute( 'rc_timestamp' ) &&
69 $rc->getAttribute( 'wl_notificationtimestamp' ) &&
70 $rc->getAttribute( 'rc_timestamp' ) >= $rc->getAttribute( 'wl_notificationtimestamp' );
74 'name' => 'notwatched',
75 'label' => 'rcfilters-filter-watchlist-notwatched-label',
76 'description' => 'rcfilters-filter-watchlist-notwatched-description',
77 'cssClassSuffix' => 'notwatched',
78 'isRowApplicableCallable' => function ( $ctx, $rc ) {
79 return $rc->getAttribute( 'wl_user' ) === null;
83 'default' => ChangesListStringOptionsFilterGroup
::NONE
,
84 'queryCallable' => function ( $specialPageClassName, $context, $dbr,
85 &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) {
86 sort( $selectedValues );
87 $notwatchedCond = 'wl_user IS NULL';
88 $watchedCond = 'wl_user IS NOT NULL';
89 $newCond = 'rc_timestamp >= wl_notificationtimestamp';
91 if ( $selectedValues === [ 'notwatched' ] ) {
92 $conds[] = $notwatchedCond;
96 if ( $selectedValues === [ 'watched' ] ) {
97 $conds[] = $watchedCond;
101 if ( $selectedValues === [ 'watchednew' ] ) {
102 $conds[] = $dbr->makeList( [
109 if ( $selectedValues === [ 'notwatched', 'watched' ] ) {
114 if ( $selectedValues === [ 'notwatched', 'watchednew' ] ) {
115 $conds[] = $dbr->makeList( [
125 if ( $selectedValues === [ 'watched', 'watchednew' ] ) {
126 $conds[] = $watchedCond;
130 if ( $selectedValues === [ 'notwatched', 'watched', 'watchednew' ] ) {
139 * Main execution point
141 * @param string $subpage
143 public function execute( $subpage ) {
144 // Backwards-compatibility: redirect to new feed URLs
145 $feedFormat = $this->getRequest()->getVal( 'feed' );
146 if ( !$this->including() && $feedFormat ) {
147 $query = $this->getFeedQuery();
148 $query['feedformat'] = $feedFormat === 'atom' ?
'atom' : 'rss';
149 $this->getOutput()->redirect( wfAppendQuery( wfScript( 'api' ), $query ) );
154 // 10 seconds server-side caching max
155 $out = $this->getOutput();
156 $out->setCdnMaxage( 10 );
157 // Check if the client has a cached version
158 $lastmod = $this->checkLastModified();
159 if ( $lastmod === false ) {
164 '//meta.wikimedia.org/wiki/Special:MyLanguage/Help:Recent_changes',
167 parent
::execute( $subpage );
173 protected function transformFilterDefinition( array $filterDefinition ) {
174 if ( isset( $filterDefinition['showHideSuffix'] ) ) {
175 $filterDefinition['showHide'] = 'rc' . $filterDefinition['showHideSuffix'];
178 return $filterDefinition;
184 protected function registerFilters() {
185 parent
::registerFilters();
188 !$this->including() &&
189 $this->getUser()->isLoggedIn() &&
190 $this->getUser()->isAllowed( 'viewmywatchlist' )
192 $this->registerFiltersFromDefinitions( [ $this->watchlistFilterGroupDefinition
] );
193 $watchlistGroup = $this->getFilterGroup( 'watchlist' );
194 $watchlistGroup->getFilter( 'watched' )->setAsSupersetOf(
195 $watchlistGroup->getFilter( 'watchednew' )
199 $user = $this->getUser();
201 $significance = $this->getFilterGroup( 'significance' );
202 $hideMinor = $significance->getFilter( 'hideminor' );
203 $hideMinor->setDefault( $user->getBoolOption( 'hideminor' ) );
205 $automated = $this->getFilterGroup( 'automated' );
206 $hideBots = $automated->getFilter( 'hidebots' );
207 $hideBots->setDefault( true );
209 $reviewStatus = $this->getFilterGroup( 'reviewStatus' );
210 if ( $reviewStatus !== null ) {
211 // Conditional on feature being available and rights
212 if ( $user->getBoolOption( 'hidepatrolled' ) ) {
213 $reviewStatus->setDefault( 'unpatrolled' );
214 $legacyReviewStatus = $this->getFilterGroup( 'legacyReviewStatus' );
215 $legacyHidePatrolled = $legacyReviewStatus->getFilter( 'hidepatrolled' );
216 $legacyHidePatrolled->setDefault( true );
220 $changeType = $this->getFilterGroup( 'changeType' );
221 $hideCategorization = $changeType->getFilter( 'hidecategorization' );
222 if ( $hideCategorization !== null ) {
223 // Conditional on feature being available
224 $hideCategorization->setDefault( $user->getBoolOption( 'hidecategorization' ) );
229 * Process $par and put options found in $opts. Used when including the page.
232 * @param FormOptions $opts
234 public function parseParameters( $par, FormOptions
$opts ) {
235 parent
::parseParameters( $par, $opts );
237 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
238 foreach ( $bits as $bit ) {
239 if ( is_numeric( $bit ) ) {
240 $opts['limit'] = $bit;
244 if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
245 $opts['limit'] = $m[1];
247 if ( preg_match( '/^days=(\d+(?:\.\d+)?)$/', $bit, $m ) ) {
248 $opts['days'] = $m[1];
250 if ( preg_match( '/^namespace=(.*)$/', $bit, $m ) ) {
251 $opts['namespace'] = $m[1];
253 if ( preg_match( '/^tagfilter=(.*)$/', $bit, $m ) ) {
254 $opts['tagfilter'] = $m[1];
262 protected function doMainQuery( $tables, $fields, $conds, $query_options,
263 $join_conds, FormOptions
$opts
265 $dbr = $this->getDB();
266 $user = $this->getUser();
268 $rcQuery = RecentChange
::getQueryInfo();
269 $tables = array_merge( $tables, $rcQuery['tables'] );
270 $fields = array_merge( $rcQuery['fields'], $fields );
271 $join_conds = array_merge( $join_conds, $rcQuery['joins'] );
273 // JOIN on watchlist for users
274 if ( $user->isLoggedIn() && $user->isAllowed( 'viewmywatchlist' ) ) {
275 $tables[] = 'watchlist';
276 $fields[] = 'wl_user';
277 $fields[] = 'wl_notificationtimestamp';
278 $join_conds['watchlist'] = [ 'LEFT JOIN', [
279 'wl_user' => $user->getId(),
281 'wl_namespace=rc_namespace'
285 // JOIN on page, used for 'last revision' filter highlight
287 $fields[] = 'page_latest';
288 $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
290 $tagFilter = $opts['tagfilter'] ?
explode( '|', $opts['tagfilter'] ) : [];
291 ChangeTags
::modifyDisplayQuery(
300 if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
306 if ( $this->areFiltersInConflict() ) {
311 'ORDER BY' => 'rc_timestamp DESC',
312 'LIMIT' => $opts['limit']
314 if ( in_array( 'DISTINCT', $query_options ) ) {
315 // ChangeTags::modifyDisplayQuery() adds DISTINCT when filtering on multiple tags.
316 // In order to prevent DISTINCT from causing query performance problems,
317 // we have to GROUP BY the primary key. This in turn requires us to add
318 // the primary key to the end of the ORDER BY, and the old ORDER BY to the
319 // start of the GROUP BY
320 $orderByAndLimit['ORDER BY'] = 'rc_timestamp DESC, rc_id DESC';
321 $orderByAndLimit['GROUP BY'] = 'rc_timestamp, rc_id';
323 // array_merge() is used intentionally here so that hooks can, should
324 // they so desire, override the ORDER BY / LIMIT condition(s); prior to
325 // MediaWiki 1.26 this used to use the plus operator instead, which meant
326 // that extensions weren't able to change these conditions
327 $query_options = array_merge( $orderByAndLimit, $query_options );
328 $rows = $dbr->select(
331 // rc_new is not an ENUM, but adding a redundant rc_new IN (0,1) gives mysql enough
332 // knowledge to use an index merge if it wants (it may use some other index though).
333 $conds +
[ 'rc_new' => [ 0, 1 ] ],
342 protected function getDB() {
343 return wfGetDB( DB_REPLICA
, 'recentchanges' );
346 public function outputFeedLinks() {
347 $this->addFeedLinks( $this->getFeedQuery() );
351 * Get URL query parameters for action=feedrecentchanges API feed of current recent changes view.
355 protected function getFeedQuery() {
356 $query = array_filter( $this->getOptions()->getAllValues(), function ( $value ) {
357 // API handles empty parameters in a different way
358 return $value !== '';
360 $query['action'] = 'feedrecentchanges';
361 $feedLimit = $this->getConfig()->get( 'FeedLimit' );
362 if ( $query['limit'] > $feedLimit ) {
363 $query['limit'] = $feedLimit;
370 * Build and output the actual changes list.
372 * @param IResultWrapper $rows Database rows
373 * @param FormOptions $opts
375 public function outputChangesList( $rows, $opts ) {
376 $limit = $opts['limit'];
378 $showWatcherCount = $this->getConfig()->get( 'RCShowWatchingUsers' )
379 && $this->getUser()->getOption( 'shownumberswatching' );
383 $list = ChangesList
::newFromContext( $this->getContext(), $this->filterGroups
);
384 $list->initChangesListRows( $rows );
386 $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
387 $rclistOutput = $list->beginRecentChangesList();
388 if ( $this->isStructuredFilterUiEnabled() ) {
389 $rclistOutput .= $this->makeLegend();
392 foreach ( $rows as $obj ) {
396 $rc = RecentChange
::newFromRow( $obj );
398 # Skip CatWatch entries for hidden cats based on user preference
400 $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE
&&
401 !$userShowHiddenCats &&
402 $rc->getParam( 'hidden-cat' )
407 $rc->counter
= $counter++
;
408 # Check if the page has been updated since the last visit
409 if ( $this->getConfig()->get( 'ShowUpdatedMarker' )
410 && !empty( $obj->wl_notificationtimestamp
)
412 $rc->notificationtimestamp
= ( $obj->rc_timestamp
>= $obj->wl_notificationtimestamp
);
414 $rc->notificationtimestamp
= false; // Default
416 # Check the number of users watching the page
417 $rc->numberofWatchingusers
= 0; // Default
418 if ( $showWatcherCount && $obj->rc_namespace
>= 0 ) {
419 if ( !isset( $watcherCache[$obj->rc_namespace
][$obj->rc_title
] ) ) {
420 $watcherCache[$obj->rc_namespace
][$obj->rc_title
] =
421 MediaWikiServices
::getInstance()->getWatchedItemStore()->countWatchers(
422 new TitleValue( (int)$obj->rc_namespace
, $obj->rc_title
)
425 $rc->numberofWatchingusers
= $watcherCache[$obj->rc_namespace
][$obj->rc_title
];
428 $changeLine = $list->recentChangesLine( $rc, !empty( $obj->wl_user
), $counter );
429 if ( $changeLine !== false ) {
430 $rclistOutput .= $changeLine;
434 $rclistOutput .= $list->endRecentChangesList();
436 if ( $rows->numRows() === 0 ) {
437 $this->outputNoResults();
438 if ( !$this->including() ) {
439 $this->getOutput()->setStatusCode( 404 );
442 $this->getOutput()->addHTML( $rclistOutput );
447 * Set the text to be displayed above the changes
449 * @param FormOptions $opts
450 * @param int $numRows Number of rows in the result to show after this header
452 public function doHeader( $opts, $numRows ) {
453 $this->setTopText( $opts );
455 $defaults = $opts->getAllValues();
456 $nondefaults = $opts->getChangedValues();
459 if ( !$this->isStructuredFilterUiEnabled() ) {
460 $panel[] = $this->makeLegend();
462 $panel[] = $this->optionsPanel( $defaults, $nondefaults, $numRows );
465 $extraOpts = $this->getExtraOptions( $opts );
466 $extraOptsCount = count( $extraOpts );
468 $submit = ' ' . Xml
::submitButton( $this->msg( 'recentchanges-submit' )->text() );
470 $out = Xml
::openElement( 'table', [ 'class' => 'mw-recentchanges-table' ] );
471 foreach ( $extraOpts as $name => $optionRow ) {
472 # Add submit button to the last row only
474 $addSubmit = ( $count === $extraOptsCount ) ?
$submit : '';
476 $out .= Xml
::openElement( 'tr', [ 'class' => $name . 'Form' ] );
477 if ( is_array( $optionRow ) ) {
480 [ 'class' => 'mw-label mw-' . $name . '-label' ],
485 [ 'class' => 'mw-input' ],
486 $optionRow[1] . $addSubmit
491 [ 'class' => 'mw-input', 'colspan' => 2 ],
492 $optionRow . $addSubmit
495 $out .= Xml
::closeElement( 'tr' );
497 $out .= Xml
::closeElement( 'table' );
499 $unconsumed = $opts->getUnconsumedValues();
500 foreach ( $unconsumed as $key => $value ) {
501 $out .= Html
::hidden( $key, $value );
504 $t = $this->getPageTitle();
505 $out .= Html
::hidden( 'title', $t->getPrefixedText() );
506 $form = Xml
::tags( 'form', [ 'action' => wfScript() ], $out );
508 $panelString = implode( "\n", $panel );
510 $rcoptions = Xml
::fieldset(
511 $this->msg( 'recentchanges-legend' )->text(),
513 [ 'class' => 'rcoptions cloptions' ]
516 // Insert a placeholder for RCFilters
517 if ( $this->isStructuredFilterUiEnabled() ) {
518 $rcfilterContainer = Html
::element(
520 [ 'class' => 'rcfilters-container' ]
523 $loadingContainer = Html
::rawElement(
525 [ 'class' => 'rcfilters-spinner' ],
528 [ 'class' => 'rcfilters-spinner-bounce' ]
532 // Wrap both with rcfilters-head
533 $this->getOutput()->addHTML(
536 [ 'class' => 'rcfilters-head' ],
537 $rcfilterContainer . $rcoptions
542 $this->getOutput()->addHTML( $loadingContainer );
544 $this->getOutput()->addHTML( $rcoptions );
547 $this->setBottomText( $opts );
551 * Send the text to be displayed above the options
553 * @param FormOptions $opts Unused
555 function setTopText( FormOptions
$opts ) {
556 $message = $this->msg( 'recentchangestext' )->inContentLanguage();
557 if ( !$message->isDisabled() ) {
558 $contLang = MediaWikiServices
::getInstance()->getContentLanguage();
559 // Parse the message in this weird ugly way to preserve the ability to include interlanguage
560 // links in it (T172461). In the future when T66969 is resolved, perhaps we can just use
561 // $message->parse() instead. This code is copied from Message::parseText().
562 $parserOutput = MessageCache
::singleton()->parse(
564 $this->getPageTitle(),
566 // Message class sets the interface flag to false when parsing in a language different than
567 // user language, and this is wiki content language
571 $content = $parserOutput->getText( [
572 'enableSectionEditLinks' => false,
574 // Add only metadata here (including the language links), text is added below
575 $this->getOutput()->addParserOutputMetadata( $parserOutput );
578 'lang' => $contLang->getHtmlCode(),
579 'dir' => $contLang->getDir(),
582 $topLinksAttributes = [ 'class' => 'mw-recentchanges-toplinks' ];
584 if ( $this->isStructuredFilterUiEnabled() ) {
585 // Check whether the widget is already collapsed or expanded
586 $collapsedState = $this->getRequest()->getCookie( 'rcfilters-toplinks-collapsed-state' );
587 // Note that an empty/unset cookie means collapsed, so check for !== 'expanded'
588 $topLinksAttributes[ 'class' ] .= $collapsedState !== 'expanded' ?
589 ' mw-recentchanges-toplinks-collapsed' : '';
591 $this->getOutput()->enableOOUI();
592 $contentTitle = new OOUI\
ButtonWidget( [
593 'classes' => [ 'mw-recentchanges-toplinks-title' ],
594 'label' => new OOUI\
HtmlSnippet( $this->msg( 'rcfilters-other-review-tools' )->parse() ),
596 'indicator' => $collapsedState !== 'expanded' ?
'down' : 'up',
597 'flags' => [ 'progressive' ],
600 $contentWrapper = Html
::rawElement( 'div',
602 [ 'class' => 'mw-recentchanges-toplinks-content mw-collapsible-content' ],
607 $content = $contentTitle . $contentWrapper;
609 // Language direction should be on the top div only
610 // if the title is not there. If it is there, it's
611 // interface direction, and the language/dir attributes
612 // should be on the content itself
613 $topLinksAttributes = array_merge( $topLinksAttributes, $langAttributes );
616 $this->getOutput()->addHTML(
617 Html
::rawElement( 'div', $topLinksAttributes, $content )
623 * Get options to be displayed in a form
625 * @param FormOptions $opts
628 function getExtraOptions( $opts ) {
629 $opts->consumeValues( [
630 'namespace', 'invert', 'associated', 'tagfilter'
634 $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
636 $tagFilter = ChangeTags
::buildTagFilterSelector(
637 $opts['tagfilter'], false, $this->getContext() );
638 if ( count( $tagFilter ) ) {
639 $extraOpts['tagfilter'] = $tagFilter;
642 // Don't fire the hook for subclasses. (Or should we?)
643 if ( $this->getName() === 'Recentchanges' ) {
644 Hooks
::run( 'SpecialRecentChangesPanel', [ &$extraOpts, $opts ] );
651 * Add page-specific modules.
653 protected function addModules() {
654 parent
::addModules();
655 $out = $this->getOutput();
656 $out->addModules( 'mediawiki.special.recentchanges' );
660 * Get last modified date, for client caching
661 * Don't use this if we are using the patrol feature, patrol changes don't
662 * update the timestamp
664 * @return string|bool
666 public function checkLastModified() {
667 $dbr = $this->getDB();
668 $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', '', __METHOD__
);
674 * Creates the choose namespace selection
676 * @param FormOptions $opts
679 protected function namespaceFilterForm( FormOptions
$opts ) {
680 $nsSelect = Html
::namespaceSelector(
681 [ 'selected' => $opts['namespace'], 'all' => '', 'in-user-lang' => true ],
682 [ 'name' => 'namespace', 'id' => 'namespace' ]
684 $nsLabel = Xml
::label( $this->msg( 'namespace' )->text(), 'namespace' );
685 $invert = Xml
::checkLabel(
686 $this->msg( 'invert' )->text(), 'invert', 'nsinvert',
688 [ 'title' => $this->msg( 'tooltip-invert' )->text() ]
690 $associated = Xml
::checkLabel(
691 $this->msg( 'namespace_association' )->text(), 'associated', 'nsassociated',
693 [ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
696 return [ $nsLabel, "$nsSelect $invert $associated" ];
700 * Filter $rows by categories set in $opts
702 * @deprecated since 1.31
704 * @param IResultWrapper &$rows Database rows
705 * @param FormOptions $opts
707 function filterByCategories( &$rows, FormOptions
$opts ) {
708 wfDeprecated( __METHOD__
, '1.31' );
710 $categories = array_map( 'trim', explode( '|', $opts['categories'] ) );
712 if ( !count( $categories ) ) {
718 foreach ( $categories as $cat ) {
730 foreach ( $rows as $k => $r ) {
731 $nt = Title
::makeTitle( $r->rc_namespace
, $r->rc_title
);
732 $id = $nt->getArticleID();
734 continue; # Page might have been deleted...
736 if ( !in_array( $id, $articles ) ) {
739 if ( !isset( $a2r[$id] ) ) {
747 if ( !count( $articles ) ||
!count( $cats ) ) {
752 $catFind = new CategoryFinder
;
753 $catFind->seed( $articles, $cats, $opts['categories_any'] ?
'OR' : 'AND' );
754 $match = $catFind->run();
758 foreach ( $match as $id ) {
759 foreach ( $a2r[$id] as $rev ) {
761 $newrows[$k] = $rowsarr[$k];
764 $rows = new FakeResultWrapper( array_values( $newrows ) );
768 * Makes change an option link which carries all the other options
770 * @param string $title
771 * @param array $override Options to override
772 * @param array $options Current options
773 * @param bool $active Whether to show the link in bold
776 function makeOptionsLink( $title, $override, $options, $active = false ) {
777 $params = $this->convertParamsForLink( $override +
$options );
780 $title = new HtmlArmor( '<strong>' . htmlspecialchars( $title ) . '</strong>' );
783 return $this->getLinkRenderer()->makeKnownLink( $this->getPageTitle(), $title, [
784 'data-params' => json_encode( $override ),
785 'data-keys' => implode( ',', array_keys( $override ) ),
790 * Creates the options panel.
792 * @param array $defaults
793 * @param array $nondefaults
794 * @param int $numRows Number of rows in the result to show after this header
797 function optionsPanel( $defaults, $nondefaults, $numRows ) {
798 $options = $nondefaults +
$defaults;
801 $msg = $this->msg( 'rclegend' );
802 if ( !$msg->isDisabled() ) {
803 $note .= Html
::rawElement(
805 [ 'class' => 'mw-rclegend' ],
810 $lang = $this->getLanguage();
811 $user = $this->getUser();
812 $config = $this->getConfig();
813 if ( $options['from'] ) {
814 $resetLink = $this->makeOptionsLink( $this->msg( 'rclistfromreset' ),
815 [ 'from' => '' ], $nondefaults );
817 $noteFromMsg = $this->msg( 'rcnotefrom' )
818 ->numParams( $options['limit'] )
820 $lang->userTimeAndDate( $options['from'], $user ),
821 $lang->userDate( $options['from'], $user ),
822 $lang->userTime( $options['from'], $user )
824 ->numParams( $numRows );
825 $note .= Html
::rawElement(
827 [ 'class' => 'rcnotefrom' ],
828 $noteFromMsg->parse()
833 [ 'class' => 'rcoptions-listfromreset' ],
834 $this->msg( 'parentheses' )->rawParams( $resetLink )->parse()
839 # Sort data for display and make sure it's unique after we've added user data.
840 $linkLimits = $config->get( 'RCLinkLimits' );
841 $linkLimits[] = $options['limit'];
843 $linkLimits = array_unique( $linkLimits );
845 $linkDays = $config->get( 'RCLinkDays' );
846 $linkDays[] = $options['days'];
848 $linkDays = array_unique( $linkDays );
852 foreach ( $linkLimits as $value ) {
853 $cl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
854 [ 'limit' => $value ], $nondefaults, $value == $options['limit'] );
856 $cl = $lang->pipeList( $cl );
858 // day links, reset 'from' to none
860 foreach ( $linkDays as $value ) {
861 $dl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
862 [ 'days' => $value, 'from' => '' ], $nondefaults, $value == $options['days'] );
864 $dl = $lang->pipeList( $dl );
866 $showhide = [ 'show', 'hide' ];
870 foreach ( $this->getLegacyShowHideFilters() as $key => $filter ) {
871 $msg = $filter->getShowHide();
872 $linkMessage = $this->msg( $msg . '-' . $showhide[1 - $options[$key]] );
873 // Extensions can define additional filters, but don't need to define the corresponding
874 // messages. If they don't exist, just fall back to 'show' and 'hide'.
875 if ( !$linkMessage->exists() ) {
876 $linkMessage = $this->msg( $showhide[1 - $options[$key]] );
879 $link = $this->makeOptionsLink( $linkMessage->text(),
880 [ $key => 1 - $options[$key] ], $nondefaults );
883 'class' => "$msg rcshowhideoption clshowhideoption",
884 'data-filter-name' => $filter->getName(),
887 if ( $filter->isFeatureAvailableOnStructuredUi( $this ) ) {
888 $attribs['data-feature-in-structured-ui'] = true;
891 $links[] = Html
::rawElement(
894 $this->msg( $msg )->rawParams( $link )->parse()
898 // show from this onward link
899 $timestamp = wfTimestampNow();
900 $now = $lang->userTimeAndDate( $timestamp, $user );
901 $timenow = $lang->userTime( $timestamp, $user );
902 $datenow = $lang->userDate( $timestamp, $user );
903 $pipedLinks = '<span class="rcshowhide">' . $lang->pipeList( $links ) . '</span>';
905 $rclinks = Html
::rawElement(
907 [ 'class' => 'rclinks' ],
908 $this->msg( 'rclinks' )->rawParams( $cl, $dl, '' )->parse()
911 $rclistfrom = Html
::rawElement(
913 [ 'class' => 'rclistfrom' ],
914 $this->makeOptionsLink(
915 $this->msg( 'rclistfrom' )->rawParams( $now, $timenow, $datenow )->parse(),
916 [ 'from' => $timestamp ],
921 return "{$note}$rclinks<br />$pipedLinks<br />$rclistfrom";
924 public function isIncludable() {
928 protected function getCacheTTL() {
932 public function getDefaultLimit() {
933 $systemPrefValue = $this->getUser()->getIntOption( 'rclimit' );
934 // Prefer the RCFilters-specific preference if RCFilters is enabled
935 if ( $this->isStructuredFilterUiEnabled() ) {
936 return $this->getUser()->getIntOption( static::$limitPreferenceName, $systemPrefValue );
939 // Otherwise, use the system rclimit preference value
940 return $systemPrefValue;