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 private $watchlistFilterGroupDefinition;
37 // @codingStandardsIgnoreStart Needed "useless" override to change parameters.
38 public function __construct( $name = 'Recentchanges', $restriction = '' ) {
39 parent
::__construct( $name, $restriction );
41 $this->watchlistFilterGroupDefinition
= [
42 'name' => 'watchlist',
43 'title' => 'rcfilters-filtergroup-watchlist',
44 'class' => ChangesListStringOptionsFilterGroup
::class,
46 'isFullCoverage' => true,
50 'label' => 'rcfilters-filter-watchlist-watched-label',
51 'description' => 'rcfilters-filter-watchlist-watched-description',
52 'cssClassSuffix' => 'watched',
53 'isRowApplicableCallable' => function ( $ctx, $rc ) {
54 return $rc->getAttribute( 'wl_user' );
58 'name' => 'watchednew',
59 'label' => 'rcfilters-filter-watchlist-watchednew-label',
60 'description' => 'rcfilters-filter-watchlist-watchednew-description',
61 'cssClassSuffix' => 'watchednew',
62 'isRowApplicableCallable' => function ( $ctx, $rc ) {
63 return $rc->getAttribute( 'wl_user' ) &&
64 $rc->getAttribute( 'rc_timestamp' ) &&
65 $rc->getAttribute( 'wl_notificationtimestamp' ) &&
66 $rc->getAttribute( 'rc_timestamp' ) >= $rc->getAttribute( 'wl_notificationtimestamp' );
70 'name' => 'notwatched',
71 'label' => 'rcfilters-filter-watchlist-notwatched-label',
72 'description' => 'rcfilters-filter-watchlist-notwatched-description',
73 'cssClassSuffix' => 'notwatched',
74 'isRowApplicableCallable' => function ( $ctx, $rc ) {
75 return $rc->getAttribute( 'wl_user' ) === null;
79 'default' => ChangesListStringOptionsFilterGroup
::NONE
,
80 'queryCallable' => function ( $specialPageClassName, $context, $dbr,
81 &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) {
82 sort( $selectedValues );
83 $notwatchedCond = 'wl_user IS NULL';
84 $watchedCond = 'wl_user IS NOT NULL';
85 $newCond = 'rc_timestamp >= wl_notificationtimestamp';
87 if ( $selectedValues === [ 'notwatched' ] ) {
88 $conds[] = $notwatchedCond;
92 if ( $selectedValues === [ 'watched' ] ) {
93 $conds[] = $watchedCond;
97 if ( $selectedValues === [ 'watchednew' ] ) {
98 $conds[] = $dbr->makeList( [
105 if ( $selectedValues === [ 'notwatched', 'watched' ] ) {
110 if ( $selectedValues === [ 'notwatched', 'watchednew' ] ) {
111 $conds[] = $dbr->makeList( [
121 if ( $selectedValues === [ 'watched', 'watchednew' ] ) {
122 $conds[] = $watchedCond;
126 if ( $selectedValues === [ 'notwatched', 'watched', 'watchednew' ] ) {
133 // @codingStandardsIgnoreEnd
136 * Main execution point
138 * @param string $subpage
140 public function execute( $subpage ) {
141 global $wgStructuredChangeFiltersEnableSaving;
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 );
168 if ( $this->isStructuredFilterUiEnabled() ) {
169 $jsData = $this->getStructuredFilterJsData();
172 foreach ( $jsData['messageKeys'] as $key ) {
173 $messages[$key] = $this->msg( $key )->plain();
177 ResourceLoader
::makeInlineScript(
178 ResourceLoader
::makeMessageSetScript( $messages )
182 $out->addJsConfigVars( 'wgStructuredChangeFilters', $jsData['groups'] );
183 $out->addJsConfigVars(
184 'wgStructuredChangeFiltersEnableSaving',
185 $wgStructuredChangeFiltersEnableSaving
193 protected function transformFilterDefinition( array $filterDefinition ) {
194 if ( isset( $filterDefinition['showHideSuffix'] ) ) {
195 $filterDefinition['showHide'] = 'rc' . $filterDefinition['showHideSuffix'];
198 return $filterDefinition;
204 protected function registerFilters() {
205 parent
::registerFilters();
208 !$this->including() &&
209 $this->getUser()->isLoggedIn() &&
210 $this->getUser()->isAllowed( 'viewmywatchlist' )
212 $this->registerFiltersFromDefinitions( [ $this->watchlistFilterGroupDefinition
] );
213 $watchlistGroup = $this->getFilterGroup( 'watchlist' );
214 $watchlistGroup->getFilter( 'watched' )->setAsSupersetOf(
215 $watchlistGroup->getFilter( 'watchednew' )
219 $user = $this->getUser();
221 $significance = $this->getFilterGroup( 'significance' );
222 $hideMinor = $significance->getFilter( 'hideminor' );
223 $hideMinor->setDefault( $user->getBoolOption( 'hideminor' ) );
225 $automated = $this->getFilterGroup( 'automated' );
226 $hideBots = $automated->getFilter( 'hidebots' );
227 $hideBots->setDefault( true );
229 $reviewStatus = $this->getFilterGroup( 'reviewStatus' );
230 if ( $reviewStatus !== null ) {
231 // Conditional on feature being available and rights
232 $hidePatrolled = $reviewStatus->getFilter( 'hidepatrolled' );
233 $hidePatrolled->setDefault( $user->getBoolOption( 'hidepatrolled' ) );
236 $changeType = $this->getFilterGroup( 'changeType' );
237 $hideCategorization = $changeType->getFilter( 'hidecategorization' );
238 if ( $hideCategorization !== null ) {
239 // Conditional on feature being available
240 $hideCategorization->setDefault( $user->getBoolOption( 'hidecategorization' ) );
245 * Get a FormOptions object containing the default options
247 * @return FormOptions
249 public function getDefaultOptions() {
250 $opts = parent
::getDefaultOptions();
251 $user = $this->getUser();
253 $opts->add( 'days', $user->getIntOption( 'rcdays' ) );
254 $opts->add( 'limit', $user->getIntOption( 'rclimit' ) );
255 $opts->add( 'from', '' );
257 $opts->add( 'categories', '' );
258 $opts->add( 'categories_any', false );
259 $opts->add( 'tagfilter', '' );
265 * Get all custom filters
267 * @return array Map of filter URL param names to properties (msg/default)
269 protected function getCustomFilters() {
270 if ( $this->customFilters
=== null ) {
271 $this->customFilters
= parent
::getCustomFilters();
272 Hooks
::run( 'SpecialRecentChangesFilters', [ $this, &$this->customFilters
], '1.23' );
275 return $this->customFilters
;
279 * Process $par and put options found in $opts. Used when including the page.
282 * @param FormOptions $opts
284 public function parseParameters( $par, FormOptions
$opts ) {
285 parent
::parseParameters( $par, $opts );
287 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
288 foreach ( $bits as $bit ) {
289 if ( is_numeric( $bit ) ) {
290 $opts['limit'] = $bit;
294 if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
295 $opts['limit'] = $m[1];
297 if ( preg_match( '/^days=(\d+)$/', $bit, $m ) ) {
298 $opts['days'] = $m[1];
300 if ( preg_match( '/^namespace=(.*)$/', $bit, $m ) ) {
301 $opts['namespace'] = $m[1];
303 if ( preg_match( '/^tagfilter=(.*)$/', $bit, $m ) ) {
304 $opts['tagfilter'] = $m[1];
309 public function validateOptions( FormOptions
$opts ) {
310 $opts->validateIntBounds( 'limit', 0, 5000 );
311 parent
::validateOptions( $opts );
317 protected function buildQuery( &$tables, &$fields, &$conds,
318 &$query_options, &$join_conds, FormOptions
$opts ) {
320 $dbr = $this->getDB();
321 parent
::buildQuery( $tables, $fields, $conds,
322 $query_options, $join_conds, $opts );
325 $cutoff_unixtime = time() - ( $opts['days'] * 86400 );
326 $cutoff_unixtime = $cutoff_unixtime - ( $cutoff_unixtime %
86400 );
327 $cutoff = $dbr->timestamp( $cutoff_unixtime );
329 $fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
330 if ( $fromValid && $opts['from'] > wfTimestamp( TS_MW
, $cutoff ) ) {
331 $cutoff = $dbr->timestamp( $opts['from'] );
333 $opts->reset( 'from' );
336 $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
342 protected function doMainQuery( $tables, $fields, $conds, $query_options,
343 $join_conds, FormOptions
$opts ) {
345 $dbr = $this->getDB();
346 $user = $this->getUser();
348 $tables[] = 'recentchanges';
349 $fields = array_merge( RecentChange
::selectFields(), $fields );
351 // JOIN on watchlist for users
352 if ( $user->isLoggedIn() && $user->isAllowed( 'viewmywatchlist' ) ) {
353 $tables[] = 'watchlist';
354 $fields[] = 'wl_user';
355 $fields[] = 'wl_notificationtimestamp';
356 $join_conds['watchlist'] = [ 'LEFT JOIN', [
357 'wl_user' => $user->getId(),
359 'wl_namespace=rc_namespace'
363 // JOIN on page, used for 'last revision' filter highlight
365 $fields[] = 'page_latest';
366 $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
368 ChangeTags
::modifyDisplayQuery(
377 if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
383 if ( $this->areFiltersInConflict() ) {
387 // array_merge() is used intentionally here so that hooks can, should
388 // they so desire, override the ORDER BY / LIMIT condition(s); prior to
389 // MediaWiki 1.26 this used to use the plus operator instead, which meant
390 // that extensions weren't able to change these conditions
391 $query_options = array_merge( [
392 'ORDER BY' => 'rc_timestamp DESC',
393 'LIMIT' => $opts['limit'] ], $query_options );
394 $rows = $dbr->select(
397 // rc_new is not an ENUM, but adding a redundant rc_new IN (0,1) gives mysql enough
398 // knowledge to use an index merge if it wants (it may use some other index though).
399 $conds +
[ 'rc_new' => [ 0, 1 ] ],
405 // Build the final data
406 if ( $this->getConfig()->get( 'AllowCategorizedRecentChanges' ) ) {
407 $this->filterByCategories( $rows, $opts );
413 protected function runMainQueryHook( &$tables, &$fields, &$conds,
414 &$query_options, &$join_conds, $opts
416 return parent
::runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts )
418 'SpecialRecentChangesQuery',
419 [ &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ],
424 protected function getDB() {
425 return wfGetDB( DB_REPLICA
, 'recentchanges' );
428 public function outputFeedLinks() {
429 $this->addFeedLinks( $this->getFeedQuery() );
433 * Get URL query parameters for action=feedrecentchanges API feed of current recent changes view.
437 protected function getFeedQuery() {
438 $query = array_filter( $this->getOptions()->getAllValues(), function ( $value ) {
439 // API handles empty parameters in a different way
440 return $value !== '';
442 $query['action'] = 'feedrecentchanges';
443 $feedLimit = $this->getConfig()->get( 'FeedLimit' );
444 if ( $query['limit'] > $feedLimit ) {
445 $query['limit'] = $feedLimit;
452 * Build and output the actual changes list.
454 * @param ResultWrapper $rows Database rows
455 * @param FormOptions $opts
457 public function outputChangesList( $rows, $opts ) {
458 $limit = $opts['limit'];
460 $showWatcherCount = $this->getConfig()->get( 'RCShowWatchingUsers' )
461 && $this->getUser()->getOption( 'shownumberswatching' );
464 $dbr = $this->getDB();
467 $list = ChangesList
::newFromContext( $this->getContext(), $this->filterGroups
);
468 $list->initChangesListRows( $rows );
470 $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
471 $rclistOutput = $list->beginRecentChangesList();
472 foreach ( $rows as $obj ) {
476 $rc = RecentChange
::newFromRow( $obj );
478 # Skip CatWatch entries for hidden cats based on user preference
480 $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE
&&
481 !$userShowHiddenCats &&
482 $rc->getParam( 'hidden-cat' )
487 $rc->counter
= $counter++
;
488 # Check if the page has been updated since the last visit
489 if ( $this->getConfig()->get( 'ShowUpdatedMarker' )
490 && !empty( $obj->wl_notificationtimestamp
)
492 $rc->notificationtimestamp
= ( $obj->rc_timestamp
>= $obj->wl_notificationtimestamp
);
494 $rc->notificationtimestamp
= false; // Default
496 # Check the number of users watching the page
497 $rc->numberofWatchingusers
= 0; // Default
498 if ( $showWatcherCount && $obj->rc_namespace
>= 0 ) {
499 if ( !isset( $watcherCache[$obj->rc_namespace
][$obj->rc_title
] ) ) {
500 $watcherCache[$obj->rc_namespace
][$obj->rc_title
] =
501 MediaWikiServices
::getInstance()->getWatchedItemStore()->countWatchers(
502 new TitleValue( (int)$obj->rc_namespace
, $obj->rc_title
)
505 $rc->numberofWatchingusers
= $watcherCache[$obj->rc_namespace
][$obj->rc_title
];
508 $changeLine = $list->recentChangesLine( $rc, !empty( $obj->wl_user
), $counter );
509 if ( $changeLine !== false ) {
510 $rclistOutput .= $changeLine;
514 $rclistOutput .= $list->endRecentChangesList();
516 if ( $rows->numRows() === 0 ) {
517 $this->outputNoResults();
518 if ( !$this->including() ) {
519 $this->getOutput()->setStatusCode( 404 );
522 $this->getOutput()->addHTML( $rclistOutput );
527 * Set the text to be displayed above the changes
529 * @param FormOptions $opts
530 * @param int $numRows Number of rows in the result to show after this header
532 public function doHeader( $opts, $numRows ) {
533 $this->setTopText( $opts );
535 $defaults = $opts->getAllValues();
536 $nondefaults = $opts->getChangedValues();
539 $panel[] = $this->makeLegend();
540 $panel[] = $this->optionsPanel( $defaults, $nondefaults, $numRows );
543 $extraOpts = $this->getExtraOptions( $opts );
544 $extraOptsCount = count( $extraOpts );
546 $submit = ' ' . Xml
::submitButton( $this->msg( 'recentchanges-submit' )->text() );
548 $out = Xml
::openElement( 'table', [ 'class' => 'mw-recentchanges-table' ] );
549 foreach ( $extraOpts as $name => $optionRow ) {
550 # Add submit button to the last row only
552 $addSubmit = ( $count === $extraOptsCount ) ?
$submit : '';
554 $out .= Xml
::openElement( 'tr' );
555 if ( is_array( $optionRow ) ) {
558 [ 'class' => 'mw-label mw-' . $name . '-label' ],
563 [ 'class' => 'mw-input' ],
564 $optionRow[1] . $addSubmit
569 [ 'class' => 'mw-input', 'colspan' => 2 ],
570 $optionRow . $addSubmit
573 $out .= Xml
::closeElement( 'tr' );
575 $out .= Xml
::closeElement( 'table' );
577 $unconsumed = $opts->getUnconsumedValues();
578 foreach ( $unconsumed as $key => $value ) {
579 $out .= Html
::hidden( $key, $value );
582 $t = $this->getPageTitle();
583 $out .= Html
::hidden( 'title', $t->getPrefixedText() );
584 $form = Xml
::tags( 'form', [ 'action' => wfScript() ], $out );
586 $panelString = implode( "\n", $panel );
588 $rcoptions = Xml
::fieldset(
589 $this->msg( 'recentchanges-legend' )->text(),
591 [ 'class' => 'rcoptions' ]
594 // Insert a placeholder for RCFilters
595 if ( $this->getUser()->getOption( 'rcenhancedfilters' ) ) {
596 $rcfilterContainer = Html
::element(
598 [ 'class' => 'rcfilters-container' ]
601 // Wrap both with rcfilters-head
602 $this->getOutput()->addHTML(
605 [ 'class' => 'rcfilters-head' ],
606 $rcfilterContainer . $rcoptions
610 $this->getOutput()->addHTML( $rcoptions );
613 $this->setBottomText( $opts );
617 * Send the text to be displayed above the options
619 * @param FormOptions $opts Unused
621 function setTopText( FormOptions
$opts ) {
624 $message = $this->msg( 'recentchangestext' )->inContentLanguage();
625 if ( !$message->isDisabled() ) {
626 $this->getOutput()->addWikiText(
627 Html
::rawElement( 'div',
629 'class' => 'mw-recentchanges-toplinks',
630 'lang' => $wgContLang->getHtmlCode(),
631 'dir' => $wgContLang->getDir()
633 "\n" . $message->plain() . "\n"
635 /* $lineStart */ true,
636 /* $interface */ false
642 * Get options to be displayed in a form
644 * @param FormOptions $opts
647 function getExtraOptions( $opts ) {
648 $opts->consumeValues( [
649 'namespace', 'invert', 'associated', 'tagfilter', 'categories', 'categories_any'
653 $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
655 if ( $this->getConfig()->get( 'AllowCategorizedRecentChanges' ) ) {
656 $extraOpts['category'] = $this->categoryFilterForm( $opts );
659 $tagFilter = ChangeTags
::buildTagFilterSelector(
660 $opts['tagfilter'], false, $this->getContext() );
661 if ( count( $tagFilter ) ) {
662 $extraOpts['tagfilter'] = $tagFilter;
665 // Don't fire the hook for subclasses. (Or should we?)
666 if ( $this->getName() === 'Recentchanges' ) {
667 Hooks
::run( 'SpecialRecentChangesPanel', [ &$extraOpts, $opts ] );
674 * Check whether the structured filter UI is enabled
678 protected function isStructuredFilterUiEnabled() {
679 return $this->getUser()->getOption(
685 * Add page-specific modules.
687 protected function addModules() {
688 parent
::addModules();
689 $out = $this->getOutput();
690 $out->addModules( 'mediawiki.special.recentchanges' );
691 if ( $this->isStructuredFilterUiEnabled() ) {
692 $out->addModules( 'mediawiki.rcfilters.filters.ui' );
693 $out->addModuleStyles( 'mediawiki.rcfilters.filters.base.styles' );
698 * Get last modified date, for client caching
699 * Don't use this if we are using the patrol feature, patrol changes don't
700 * update the timestamp
702 * @return string|bool
704 public function checkLastModified() {
705 $dbr = $this->getDB();
706 $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __METHOD__
);
712 * Creates the choose namespace selection
714 * @param FormOptions $opts
717 protected function namespaceFilterForm( FormOptions
$opts ) {
718 $nsSelect = Html
::namespaceSelector(
719 [ 'selected' => $opts['namespace'], 'all' => '' ],
720 [ 'name' => 'namespace', 'id' => 'namespace' ]
722 $nsLabel = Xml
::label( $this->msg( 'namespace' )->text(), 'namespace' );
723 $invert = Xml
::checkLabel(
724 $this->msg( 'invert' )->text(), 'invert', 'nsinvert',
726 [ 'title' => $this->msg( 'tooltip-invert' )->text() ]
728 $associated = Xml
::checkLabel(
729 $this->msg( 'namespace_association' )->text(), 'associated', 'nsassociated',
731 [ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
734 return [ $nsLabel, "$nsSelect $invert $associated" ];
738 * Create an input to filter changes by categories
740 * @param FormOptions $opts
743 protected function categoryFilterForm( FormOptions
$opts ) {
744 list( $label, $input ) = Xml
::inputLabelSep( $this->msg( 'rc_categories' )->text(),
745 'categories', 'mw-categories', false, $opts['categories'] );
747 $input .= ' ' . Xml
::checkLabel( $this->msg( 'rc_categories_any' )->text(),
748 'categories_any', 'mw-categories_any', $opts['categories_any'] );
750 return [ $label, $input ];
754 * Filter $rows by categories set in $opts
756 * @param ResultWrapper $rows Database rows
757 * @param FormOptions $opts
759 function filterByCategories( &$rows, FormOptions
$opts ) {
760 $categories = array_map( 'trim', explode( '|', $opts['categories'] ) );
762 if ( !count( $categories ) ) {
768 foreach ( $categories as $cat ) {
780 foreach ( $rows as $k => $r ) {
781 $nt = Title
::makeTitle( $r->rc_namespace
, $r->rc_title
);
782 $id = $nt->getArticleID();
784 continue; # Page might have been deleted...
786 if ( !in_array( $id, $articles ) ) {
789 if ( !isset( $a2r[$id] ) ) {
797 if ( !count( $articles ) ||
!count( $cats ) ) {
802 $catFind = new CategoryFinder
;
803 $catFind->seed( $articles, $cats, $opts['categories_any'] ?
'OR' : 'AND' );
804 $match = $catFind->run();
808 foreach ( $match as $id ) {
809 foreach ( $a2r[$id] as $rev ) {
811 $newrows[$k] = $rowsarr[$k];
814 $rows = new FakeResultWrapper( array_values( $newrows ) );
818 * Makes change an option link which carries all the other options
820 * @param string $title Title
821 * @param array $override Options to override
822 * @param array $options Current options
823 * @param bool $active Whether to show the link in bold
826 function makeOptionsLink( $title, $override, $options, $active = false ) {
827 $params = $this->convertParamsForLink( $override +
$options );
830 $title = new HtmlArmor( '<strong>' . htmlspecialchars( $title ) . '</strong>' );
833 return $this->getLinkRenderer()->makeKnownLink( $this->getPageTitle(), $title, [
834 'data-params' => json_encode( $override ),
835 'data-keys' => implode( ',', array_keys( $override ) ),
840 * Creates the options panel.
842 * @param array $defaults
843 * @param array $nondefaults
844 * @param int $numRows Number of rows in the result to show after this header
847 function optionsPanel( $defaults, $nondefaults, $numRows ) {
848 $options = $nondefaults +
$defaults;
851 $msg = $this->msg( 'rclegend' );
852 if ( !$msg->isDisabled() ) {
853 $note .= '<div class="mw-rclegend">' . $msg->parse() . "</div>\n";
856 $lang = $this->getLanguage();
857 $user = $this->getUser();
858 $config = $this->getConfig();
859 if ( $options['from'] ) {
860 $resetLink = $this->makeOptionsLink( $this->msg( 'rclistfromreset' ),
861 [ 'from' => '' ], $nondefaults );
863 $note .= $this->msg( 'rcnotefrom' )
864 ->numParams( $options['limit'] )
866 $lang->userTimeAndDate( $options['from'], $user ),
867 $lang->userDate( $options['from'], $user ),
868 $lang->userTime( $options['from'], $user )
870 ->numParams( $numRows )
874 [ 'class' => 'rcoptions-listfromreset' ],
875 $this->msg( 'parentheses' )->rawParams( $resetLink )->parse()
880 # Sort data for display and make sure it's unique after we've added user data.
881 $linkLimits = $config->get( 'RCLinkLimits' );
882 $linkLimits[] = $options['limit'];
884 $linkLimits = array_unique( $linkLimits );
886 $linkDays = $config->get( 'RCLinkDays' );
887 $linkDays[] = $options['days'];
889 $linkDays = array_unique( $linkDays );
893 foreach ( $linkLimits as $value ) {
894 $cl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
895 [ 'limit' => $value ], $nondefaults, $value == $options['limit'] );
897 $cl = $lang->pipeList( $cl );
899 // day links, reset 'from' to none
901 foreach ( $linkDays as $value ) {
902 $dl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
903 [ 'days' => $value, 'from' => '' ], $nondefaults, $value == $options['days'] );
905 $dl = $lang->pipeList( $dl );
907 $showhide = [ 'show', 'hide' ];
911 $filterGroups = $this->getFilterGroups();
913 $context = $this->getContext();
914 foreach ( $filterGroups as $groupName => $group ) {
915 if ( !$group->isPerGroupRequestParameter() ) {
916 foreach ( $group->getFilters() as $key => $filter ) {
917 if ( $filter->displaysOnUnstructuredUi( $this ) ) {
918 $msg = $filter->getShowHide();
919 $linkMessage = $this->msg( $msg . '-' . $showhide[1 - $options[$key]] );
920 // Extensions can define additional filters, but don't need to define the corresponding
921 // messages. If they don't exist, just fall back to 'show' and 'hide'.
922 if ( !$linkMessage->exists() ) {
923 $linkMessage = $this->msg( $showhide[1 - $options[$key]] );
926 $link = $this->makeOptionsLink( $linkMessage->text(),
927 [ $key => 1 - $options[$key] ], $nondefaults );
930 'class' => "$msg rcshowhideoption",
931 'data-filter-name' => $filter->getName(),
934 if ( $filter->isFeatureAvailableOnStructuredUi( $this ) ) {
935 $attribs['data-feature-in-structured-ui'] = true;
938 $links[] = Html
::rawElement(
941 $this->msg( $msg )->rawParams( $link )->escaped()
948 // show from this onward link
949 $timestamp = wfTimestampNow();
950 $now = $lang->userTimeAndDate( $timestamp, $user );
951 $timenow = $lang->userTime( $timestamp, $user );
952 $datenow = $lang->userDate( $timestamp, $user );
953 $pipedLinks = '<span class="rcshowhide">' . $lang->pipeList( $links ) . '</span>';
955 $rclinks = '<span class="rclinks">' . $this->msg( 'rclinks' )->rawParams( $cl, $dl, '' )
956 ->parse() . '</span>';
958 $rclistfrom = '<span class="rclistfrom">' . $this->makeOptionsLink(
959 $this->msg( 'rclistfrom' )->rawParams( $now, $timenow, $datenow )->parse(),
960 [ 'from' => $timestamp ],
964 return "{$note}$rclinks<br />$pipedLinks<br />$rclistfrom";
967 public function isIncludable() {
971 protected function getCacheTTL() {