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 * @param string|null $subpage
141 public function execute( $subpage ) {
142 // Backwards-compatibility: redirect to new feed URLs
143 $feedFormat = $this->getRequest()->getVal( 'feed' );
144 if ( !$this->including() && $feedFormat ) {
145 $query = $this->getFeedQuery();
146 $query['feedformat'] = $feedFormat === 'atom' ?
'atom' : 'rss';
147 $this->getOutput()->redirect( wfAppendQuery( wfScript( 'api' ), $query ) );
152 // 10 seconds server-side caching max
153 $out = $this->getOutput();
154 $out->setCdnMaxage( 10 );
155 // Check if the client has a cached version
156 $lastmod = $this->checkLastModified();
157 if ( $lastmod === false ) {
162 '//meta.wikimedia.org/wiki/Special:MyLanguage/Help:Recent_changes',
165 parent
::execute( $subpage );
171 protected function transformFilterDefinition( array $filterDefinition ) {
172 if ( isset( $filterDefinition['showHideSuffix'] ) ) {
173 $filterDefinition['showHide'] = 'rc' . $filterDefinition['showHideSuffix'];
176 return $filterDefinition;
182 protected function registerFilters() {
183 parent
::registerFilters();
186 !$this->including() &&
187 $this->getUser()->isLoggedIn() &&
188 $this->getUser()->isAllowed( 'viewmywatchlist' )
190 $this->registerFiltersFromDefinitions( [ $this->watchlistFilterGroupDefinition
] );
191 $watchlistGroup = $this->getFilterGroup( 'watchlist' );
192 $watchlistGroup->getFilter( 'watched' )->setAsSupersetOf(
193 $watchlistGroup->getFilter( 'watchednew' )
197 $user = $this->getUser();
199 $significance = $this->getFilterGroup( 'significance' );
200 $hideMinor = $significance->getFilter( 'hideminor' );
201 $hideMinor->setDefault( $user->getBoolOption( 'hideminor' ) );
203 $automated = $this->getFilterGroup( 'automated' );
204 $hideBots = $automated->getFilter( 'hidebots' );
205 $hideBots->setDefault( true );
207 $reviewStatus = $this->getFilterGroup( 'reviewStatus' );
208 if ( $reviewStatus !== null ) {
209 // Conditional on feature being available and rights
210 if ( $user->getBoolOption( 'hidepatrolled' ) ) {
211 $reviewStatus->setDefault( 'unpatrolled' );
212 $legacyReviewStatus = $this->getFilterGroup( 'legacyReviewStatus' );
213 $legacyHidePatrolled = $legacyReviewStatus->getFilter( 'hidepatrolled' );
214 $legacyHidePatrolled->setDefault( true );
218 $changeType = $this->getFilterGroup( 'changeType' );
219 $hideCategorization = $changeType->getFilter( 'hidecategorization' );
220 if ( $hideCategorization !== null ) {
221 // Conditional on feature being available
222 $hideCategorization->setDefault( $user->getBoolOption( 'hidecategorization' ) );
227 * Process $par and put options found in $opts. Used when including the page.
230 * @param FormOptions $opts
232 public function parseParameters( $par, FormOptions
$opts ) {
233 parent
::parseParameters( $par, $opts );
235 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
236 foreach ( $bits as $bit ) {
237 if ( is_numeric( $bit ) ) {
238 $opts['limit'] = $bit;
242 if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
243 $opts['limit'] = $m[1];
245 if ( preg_match( '/^days=(\d+(?:\.\d+)?)$/', $bit, $m ) ) {
246 $opts['days'] = $m[1];
248 if ( preg_match( '/^namespace=(.*)$/', $bit, $m ) ) {
249 $opts['namespace'] = $m[1];
251 if ( preg_match( '/^tagfilter=(.*)$/', $bit, $m ) ) {
252 $opts['tagfilter'] = $m[1];
260 protected function doMainQuery( $tables, $fields, $conds, $query_options,
261 $join_conds, FormOptions
$opts
263 $dbr = $this->getDB();
264 $user = $this->getUser();
266 $rcQuery = RecentChange
::getQueryInfo();
267 $tables = array_merge( $tables, $rcQuery['tables'] );
268 $fields = array_merge( $rcQuery['fields'], $fields );
269 $join_conds = array_merge( $join_conds, $rcQuery['joins'] );
271 // JOIN on watchlist for users
272 if ( $user->isLoggedIn() && $user->isAllowed( 'viewmywatchlist' ) ) {
273 $tables[] = 'watchlist';
274 $fields[] = 'wl_user';
275 $fields[] = 'wl_notificationtimestamp';
276 $join_conds['watchlist'] = [ 'LEFT JOIN', [
277 'wl_user' => $user->getId(),
279 'wl_namespace=rc_namespace'
283 // JOIN on page, used for 'last revision' filter highlight
285 $fields[] = 'page_latest';
286 $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
288 $tagFilter = $opts['tagfilter'] ?
explode( '|', $opts['tagfilter'] ) : [];
289 ChangeTags
::modifyDisplayQuery(
298 if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
304 if ( $this->areFiltersInConflict() ) {
309 'ORDER BY' => 'rc_timestamp DESC',
310 'LIMIT' => $opts['limit']
312 if ( in_array( 'DISTINCT', $query_options ) ) {
313 // ChangeTags::modifyDisplayQuery() adds DISTINCT when filtering on multiple tags.
314 // In order to prevent DISTINCT from causing query performance problems,
315 // we have to GROUP BY the primary key. This in turn requires us to add
316 // the primary key to the end of the ORDER BY, and the old ORDER BY to the
317 // start of the GROUP BY
318 $orderByAndLimit['ORDER BY'] = 'rc_timestamp DESC, rc_id DESC';
319 $orderByAndLimit['GROUP BY'] = 'rc_timestamp, rc_id';
321 // array_merge() is used intentionally here so that hooks can, should
322 // they so desire, override the ORDER BY / LIMIT condition(s); prior to
323 // MediaWiki 1.26 this used to use the plus operator instead, which meant
324 // that extensions weren't able to change these conditions
325 $query_options = array_merge( $orderByAndLimit, $query_options );
326 $rows = $dbr->select(
329 // rc_new is not an ENUM, but adding a redundant rc_new IN (0,1) gives mysql enough
330 // knowledge to use an index merge if it wants (it may use some other index though).
331 $conds +
[ 'rc_new' => [ 0, 1 ] ],
340 protected function getDB() {
341 return wfGetDB( DB_REPLICA
, 'recentchanges' );
344 public function outputFeedLinks() {
345 $this->addFeedLinks( $this->getFeedQuery() );
349 * Get URL query parameters for action=feedrecentchanges API feed of current recent changes view.
353 protected function getFeedQuery() {
354 $query = array_filter( $this->getOptions()->getAllValues(), function ( $value ) {
355 // API handles empty parameters in a different way
356 return $value !== '';
358 $query['action'] = 'feedrecentchanges';
359 $feedLimit = $this->getConfig()->get( 'FeedLimit' );
360 if ( $query['limit'] > $feedLimit ) {
361 $query['limit'] = $feedLimit;
368 * Build and output the actual changes list.
370 * @param IResultWrapper $rows Database rows
371 * @param FormOptions $opts
373 public function outputChangesList( $rows, $opts ) {
374 $limit = $opts['limit'];
376 $showWatcherCount = $this->getConfig()->get( 'RCShowWatchingUsers' )
377 && $this->getUser()->getOption( 'shownumberswatching' );
381 $list = ChangesList
::newFromContext( $this->getContext(), $this->filterGroups
);
382 $list->initChangesListRows( $rows );
384 $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
385 $rclistOutput = $list->beginRecentChangesList();
386 if ( $this->isStructuredFilterUiEnabled() ) {
387 $rclistOutput .= $this->makeLegend();
390 foreach ( $rows as $obj ) {
394 $rc = RecentChange
::newFromRow( $obj );
396 # Skip CatWatch entries for hidden cats based on user preference
398 $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE
&&
399 !$userShowHiddenCats &&
400 $rc->getParam( 'hidden-cat' )
405 $rc->counter
= $counter++
;
406 # Check if the page has been updated since the last visit
407 if ( $this->getConfig()->get( 'ShowUpdatedMarker' )
408 && !empty( $obj->wl_notificationtimestamp
)
410 $rc->notificationtimestamp
= ( $obj->rc_timestamp
>= $obj->wl_notificationtimestamp
);
412 $rc->notificationtimestamp
= false; // Default
414 # Check the number of users watching the page
415 $rc->numberofWatchingusers
= 0; // Default
416 if ( $showWatcherCount && $obj->rc_namespace
>= 0 ) {
417 if ( !isset( $watcherCache[$obj->rc_namespace
][$obj->rc_title
] ) ) {
418 $watcherCache[$obj->rc_namespace
][$obj->rc_title
] =
419 MediaWikiServices
::getInstance()->getWatchedItemStore()->countWatchers(
420 new TitleValue( (int)$obj->rc_namespace
, $obj->rc_title
)
423 $rc->numberofWatchingusers
= $watcherCache[$obj->rc_namespace
][$obj->rc_title
];
426 $changeLine = $list->recentChangesLine( $rc, !empty( $obj->wl_user
), $counter );
427 if ( $changeLine !== false ) {
428 $rclistOutput .= $changeLine;
432 $rclistOutput .= $list->endRecentChangesList();
434 if ( $rows->numRows() === 0 ) {
435 $this->outputNoResults();
436 if ( !$this->including() ) {
437 $this->getOutput()->setStatusCode( 404 );
440 $this->getOutput()->addHTML( $rclistOutput );
445 * Set the text to be displayed above the changes
447 * @param FormOptions $opts
448 * @param int $numRows Number of rows in the result to show after this header
450 public function doHeader( $opts, $numRows ) {
451 $this->setTopText( $opts );
453 $defaults = $opts->getAllValues();
454 $nondefaults = $opts->getChangedValues();
457 if ( !$this->isStructuredFilterUiEnabled() ) {
458 $panel[] = $this->makeLegend();
460 $panel[] = $this->optionsPanel( $defaults, $nondefaults, $numRows );
463 $extraOpts = $this->getExtraOptions( $opts );
464 $extraOptsCount = count( $extraOpts );
466 $submit = ' ' . Xml
::submitButton( $this->msg( 'recentchanges-submit' )->text() );
468 $out = Xml
::openElement( 'table', [ 'class' => 'mw-recentchanges-table' ] );
469 foreach ( $extraOpts as $name => $optionRow ) {
470 # Add submit button to the last row only
472 $addSubmit = ( $count === $extraOptsCount ) ?
$submit : '';
474 $out .= Xml
::openElement( 'tr', [ 'class' => $name . 'Form' ] );
475 if ( is_array( $optionRow ) ) {
478 [ 'class' => 'mw-label mw-' . $name . '-label' ],
483 [ 'class' => 'mw-input' ],
484 $optionRow[1] . $addSubmit
489 [ 'class' => 'mw-input', 'colspan' => 2 ],
490 $optionRow . $addSubmit
493 $out .= Xml
::closeElement( 'tr' );
495 $out .= Xml
::closeElement( 'table' );
497 $unconsumed = $opts->getUnconsumedValues();
498 foreach ( $unconsumed as $key => $value ) {
499 $out .= Html
::hidden( $key, $value );
502 $t = $this->getPageTitle();
503 $out .= Html
::hidden( 'title', $t->getPrefixedText() );
504 $form = Xml
::tags( 'form', [ 'action' => wfScript() ], $out );
506 $panelString = implode( "\n", $panel );
508 $rcoptions = Xml
::fieldset(
509 $this->msg( 'recentchanges-legend' )->text(),
511 [ 'class' => 'rcoptions cloptions' ]
514 // Insert a placeholder for RCFilters
515 if ( $this->isStructuredFilterUiEnabled() ) {
516 $rcfilterContainer = Html
::element(
518 // TODO: Remove deprecated rcfilters-container class
519 [ 'class' => 'rcfilters-container mw-rcfilters-container' ]
522 $loadingContainer = Html
::rawElement(
524 [ 'class' => 'mw-rcfilters-spinner' ],
527 [ 'class' => 'mw-rcfilters-spinner-bounce' ]
531 // Wrap both with rcfilters-head
532 $this->getOutput()->addHTML(
535 // TODO: Remove deprecated rcfilters-head class
536 [ 'class' => 'rcfilters-head mw-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 $attribs = [ 'class' => [ 'mw-input-with-label' ] ];
686 // Hide the checkboxes when the namespace filter is set to 'all'.
687 if ( $opts['namespace'] === '' ) {
688 $attribs['class'][] = 'mw-input-hidden';
690 $invert = Html
::rawElement( 'span', $attribs, Xml
::checkLabel(
691 $this->msg( 'invert' )->text(), 'invert', 'nsinvert',
693 [ 'title' => $this->msg( 'tooltip-invert' )->text() ]
695 $associated = Html
::rawElement( 'span', $attribs, Xml
::checkLabel(
696 $this->msg( 'namespace_association' )->text(), 'associated', 'nsassociated',
698 [ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
701 return [ $nsLabel, "$nsSelect $invert $associated" ];
705 * Filter $rows by categories set in $opts
707 * @deprecated since 1.31
709 * @param IResultWrapper &$rows Database rows
710 * @param FormOptions $opts
712 function filterByCategories( &$rows, FormOptions
$opts ) {
713 wfDeprecated( __METHOD__
, '1.31' );
715 $categories = array_map( 'trim', explode( '|', $opts['categories'] ) );
717 if ( $categories === [] ) {
723 foreach ( $categories as $cat ) {
735 foreach ( $rows as $k => $r ) {
736 $nt = Title
::makeTitle( $r->rc_namespace
, $r->rc_title
);
737 $id = $nt->getArticleID();
739 continue; # Page might have been deleted...
741 if ( !in_array( $id, $articles ) ) {
744 if ( !isset( $a2r[$id] ) ) {
752 if ( $articles === [] ||
$cats === [] ) {
757 $catFind = new CategoryFinder
;
758 $catFind->seed( $articles, $cats, $opts['categories_any'] ?
'OR' : 'AND' );
759 $match = $catFind->run();
763 foreach ( $match as $id ) {
764 foreach ( $a2r[$id] as $rev ) {
766 $newrows[$k] = $rowsarr[$k];
769 $rows = new FakeResultWrapper( array_values( $newrows ) );
773 * Makes change an option link which carries all the other options
775 * @param string $title
776 * @param array $override Options to override
777 * @param array $options Current options
778 * @param bool $active Whether to show the link in bold
781 function makeOptionsLink( $title, $override, $options, $active = false ) {
782 $params = $this->convertParamsForLink( $override +
$options );
785 $title = new HtmlArmor( '<strong>' . htmlspecialchars( $title ) . '</strong>' );
788 return $this->getLinkRenderer()->makeKnownLink( $this->getPageTitle(), $title, [
789 'data-params' => json_encode( $override ),
790 'data-keys' => implode( ',', array_keys( $override ) ),
795 * Creates the options panel.
797 * @param array $defaults
798 * @param array $nondefaults
799 * @param int $numRows Number of rows in the result to show after this header
802 function optionsPanel( $defaults, $nondefaults, $numRows ) {
803 $options = $nondefaults +
$defaults;
806 $msg = $this->msg( 'rclegend' );
807 if ( !$msg->isDisabled() ) {
808 $note .= Html
::rawElement(
810 [ 'class' => 'mw-rclegend' ],
815 $lang = $this->getLanguage();
816 $user = $this->getUser();
817 $config = $this->getConfig();
818 if ( $options['from'] ) {
819 $resetLink = $this->makeOptionsLink( $this->msg( 'rclistfromreset' ),
820 [ 'from' => '' ], $nondefaults );
822 $noteFromMsg = $this->msg( 'rcnotefrom' )
823 ->numParams( $options['limit'] )
825 $lang->userTimeAndDate( $options['from'], $user ),
826 $lang->userDate( $options['from'], $user ),
827 $lang->userTime( $options['from'], $user )
829 ->numParams( $numRows );
830 $note .= Html
::rawElement(
832 [ 'class' => 'rcnotefrom' ],
833 $noteFromMsg->parse()
838 [ 'class' => 'rcoptions-listfromreset' ],
839 $this->msg( 'parentheses' )->rawParams( $resetLink )->parse()
844 # Sort data for display and make sure it's unique after we've added user data.
845 $linkLimits = $config->get( 'RCLinkLimits' );
846 $linkLimits[] = $options['limit'];
848 $linkLimits = array_unique( $linkLimits );
850 $linkDays = $config->get( 'RCLinkDays' );
851 $linkDays[] = $options['days'];
853 $linkDays = array_unique( $linkDays );
857 foreach ( $linkLimits as $value ) {
858 $cl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
859 [ 'limit' => $value ], $nondefaults, $value == $options['limit'] );
861 $cl = $lang->pipeList( $cl );
863 // day links, reset 'from' to none
865 foreach ( $linkDays as $value ) {
866 $dl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
867 [ 'days' => $value, 'from' => '' ], $nondefaults, $value == $options['days'] );
869 $dl = $lang->pipeList( $dl );
871 $showhide = [ 'show', 'hide' ];
875 foreach ( $this->getLegacyShowHideFilters() as $key => $filter ) {
876 $msg = $filter->getShowHide();
877 $linkMessage = $this->msg( $msg . '-' . $showhide[1 - $options[$key]] );
878 // Extensions can define additional filters, but don't need to define the corresponding
879 // messages. If they don't exist, just fall back to 'show' and 'hide'.
880 if ( !$linkMessage->exists() ) {
881 $linkMessage = $this->msg( $showhide[1 - $options[$key]] );
884 $link = $this->makeOptionsLink( $linkMessage->text(),
885 [ $key => 1 - $options[$key] ], $nondefaults );
888 'class' => "$msg rcshowhideoption clshowhideoption",
889 'data-filter-name' => $filter->getName(),
892 if ( $filter->isFeatureAvailableOnStructuredUi( $this ) ) {
893 $attribs['data-feature-in-structured-ui'] = true;
896 $links[] = Html
::rawElement(
899 $this->msg( $msg )->rawParams( $link )->parse()
903 // show from this onward link
904 $timestamp = wfTimestampNow();
905 $now = $lang->userTimeAndDate( $timestamp, $user );
906 $timenow = $lang->userTime( $timestamp, $user );
907 $datenow = $lang->userDate( $timestamp, $user );
908 $pipedLinks = '<span class="rcshowhide">' . $lang->pipeList( $links ) . '</span>';
910 $rclinks = Html
::rawElement(
912 [ 'class' => 'rclinks' ],
913 $this->msg( 'rclinks' )->rawParams( $cl, $dl, '' )->parse()
916 $rclistfrom = Html
::rawElement(
918 [ 'class' => 'rclistfrom' ],
919 $this->makeOptionsLink(
920 $this->msg( 'rclistfrom' )->plaintextParams( $now, $timenow, $datenow )->parse(),
921 [ 'from' => $timestamp, 'fromFormatted' => $now ],
926 return "{$note}$rclinks<br />$pipedLinks<br />$rclistfrom";
929 public function isIncludable() {
933 protected function getCacheTTL() {
937 public function getDefaultLimit() {
938 $systemPrefValue = $this->getUser()->getIntOption( 'rclimit' );
939 // Prefer the RCFilters-specific preference if RCFilters is enabled
940 if ( $this->isStructuredFilterUiEnabled() ) {
941 return $this->getUser()->getIntOption( static::$limitPreferenceName, $systemPrefValue );
944 // Otherwise, use the system rclimit preference value
945 return $systemPrefValue;