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 // Backwards-compatibility: redirect to new feed URLs
142 $feedFormat = $this->getRequest()->getVal( 'feed' );
143 if ( !$this->including() && $feedFormat ) {
144 $query = $this->getFeedQuery();
145 $query['feedformat'] = $feedFormat === 'atom' ?
'atom' : 'rss';
146 $this->getOutput()->redirect( wfAppendQuery( wfScript( 'api' ), $query ) );
151 // 10 seconds server-side caching max
152 $out = $this->getOutput();
153 $out->setCdnMaxage( 10 );
154 // Check if the client has a cached version
155 $lastmod = $this->checkLastModified();
156 if ( $lastmod === false ) {
161 '//meta.wikimedia.org/wiki/Special:MyLanguage/Help:Recent_changes',
164 parent
::execute( $subpage );
166 if ( $this->isStructuredFilterUiEnabled() ) {
167 $jsData = $this->getStructuredFilterJsData();
170 foreach ( $jsData['messageKeys'] as $key ){
171 $messages[$key] = $this->msg( $key )->plain();
175 ResourceLoader
::makeInlineScript(
176 ResourceLoader
::makeMessageSetScript( $messages )
180 $out->addJsConfigVars( 'wgStructuredChangeFilters', $jsData['groups'] );
187 protected function transformFilterDefinition( array $filterDefinition ) {
188 if ( isset( $filterDefinition['showHideSuffix'] ) ) {
189 $filterDefinition['showHide'] = 'rc' . $filterDefinition['showHideSuffix'];
192 return $filterDefinition;
198 protected function registerFilters() {
199 parent
::registerFilters();
202 !$this->including() &&
203 $this->getUser()->isLoggedIn() &&
204 $this->getUser()->isAllowed( 'viewmywatchlist' )
206 $this->registerFiltersFromDefinitions( [ $this->watchlistFilterGroupDefinition
] );
207 $watchlistGroup = $this->getFilterGroup( 'watchlist' );
208 $watchlistGroup->getFilter( 'watched' )->setAsSupersetOf(
209 $watchlistGroup->getFilter( 'watchednew' )
213 $user = $this->getUser();
215 $significance = $this->getFilterGroup( 'significance' );
216 $hideMinor = $significance->getFilter( 'hideminor' );
217 $hideMinor->setDefault( $user->getBoolOption( 'hideminor' ) );
219 $automated = $this->getFilterGroup( 'automated' );
220 $hideBots = $automated->getFilter( 'hidebots' );
221 $hideBots->setDefault( true );
223 $reviewStatus = $this->getFilterGroup( 'reviewStatus' );
224 if ( $reviewStatus !== null ) {
225 // Conditional on feature being available and rights
226 $hidePatrolled = $reviewStatus->getFilter( 'hidepatrolled' );
227 $hidePatrolled->setDefault( $user->getBoolOption( 'hidepatrolled' ) );
230 $changeType = $this->getFilterGroup( 'changeType' );
231 $hideCategorization = $changeType->getFilter( 'hidecategorization' );
232 if ( $hideCategorization !== null ) {
233 // Conditional on feature being available
234 $hideCategorization->setDefault( $user->getBoolOption( 'hidecategorization' ) );
239 * Get a FormOptions object containing the default options
241 * @return FormOptions
243 public function getDefaultOptions() {
244 $opts = parent
::getDefaultOptions();
245 $user = $this->getUser();
247 $opts->add( 'days', $user->getIntOption( 'rcdays' ) );
248 $opts->add( 'limit', $user->getIntOption( 'rclimit' ) );
249 $opts->add( 'from', '' );
251 $opts->add( 'categories', '' );
252 $opts->add( 'categories_any', false );
253 $opts->add( 'tagfilter', '' );
259 * Get all custom filters
261 * @return array Map of filter URL param names to properties (msg/default)
263 protected function getCustomFilters() {
264 if ( $this->customFilters
=== null ) {
265 $this->customFilters
= parent
::getCustomFilters();
266 Hooks
::run( 'SpecialRecentChangesFilters', [ $this, &$this->customFilters
], '1.23' );
269 return $this->customFilters
;
273 * Process $par and put options found in $opts. Used when including the page.
276 * @param FormOptions $opts
278 public function parseParameters( $par, FormOptions
$opts ) {
279 parent
::parseParameters( $par, $opts );
281 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
282 foreach ( $bits as $bit ) {
283 if ( is_numeric( $bit ) ) {
284 $opts['limit'] = $bit;
288 if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
289 $opts['limit'] = $m[1];
291 if ( preg_match( '/^days=(\d+)$/', $bit, $m ) ) {
292 $opts['days'] = $m[1];
294 if ( preg_match( '/^namespace=(\d+)$/', $bit, $m ) ) {
295 $opts['namespace'] = $m[1];
297 if ( preg_match( '/^tagfilter=(.*)$/', $bit, $m ) ) {
298 $opts['tagfilter'] = $m[1];
303 public function validateOptions( FormOptions
$opts ) {
304 $opts->validateIntBounds( 'limit', 0, 5000 );
305 parent
::validateOptions( $opts );
311 protected function buildQuery( &$tables, &$fields, &$conds,
312 &$query_options, &$join_conds, FormOptions
$opts ) {
314 $dbr = $this->getDB();
315 parent
::buildQuery( $tables, $fields, $conds,
316 $query_options, $join_conds, $opts );
319 $cutoff_unixtime = time() - ( $opts['days'] * 86400 );
320 $cutoff_unixtime = $cutoff_unixtime - ( $cutoff_unixtime %
86400 );
321 $cutoff = $dbr->timestamp( $cutoff_unixtime );
323 $fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
324 if ( $fromValid && $opts['from'] > wfTimestamp( TS_MW
, $cutoff ) ) {
325 $cutoff = $dbr->timestamp( $opts['from'] );
327 $opts->reset( 'from' );
330 $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
336 protected function doMainQuery( $tables, $fields, $conds, $query_options,
337 $join_conds, FormOptions
$opts ) {
339 $dbr = $this->getDB();
340 $user = $this->getUser();
342 $tables[] = 'recentchanges';
343 $fields = array_merge( RecentChange
::selectFields(), $fields );
345 // JOIN on watchlist for users
346 if ( $user->isLoggedIn() && $user->isAllowed( 'viewmywatchlist' ) ) {
347 $tables[] = 'watchlist';
348 $fields[] = 'wl_user';
349 $fields[] = 'wl_notificationtimestamp';
350 $join_conds['watchlist'] = [ 'LEFT JOIN', [
351 'wl_user' => $user->getId(),
353 'wl_namespace=rc_namespace'
357 // JOIN on page, used for 'last revision' filter highlight
359 $fields[] = 'page_latest';
360 $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
362 ChangeTags
::modifyDisplayQuery(
371 if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
377 if ( $this->areFiltersInConflict() ) {
381 // array_merge() is used intentionally here so that hooks can, should
382 // they so desire, override the ORDER BY / LIMIT condition(s); prior to
383 // MediaWiki 1.26 this used to use the plus operator instead, which meant
384 // that extensions weren't able to change these conditions
385 $query_options = array_merge( [
386 'ORDER BY' => 'rc_timestamp DESC',
387 'LIMIT' => $opts['limit'] ], $query_options );
388 $rows = $dbr->select(
391 // rc_new is not an ENUM, but adding a redundant rc_new IN (0,1) gives mysql enough
392 // knowledge to use an index merge if it wants (it may use some other index though).
393 $conds +
[ 'rc_new' => [ 0, 1 ] ],
399 // Build the final data
400 if ( $this->getConfig()->get( 'AllowCategorizedRecentChanges' ) ) {
401 $this->filterByCategories( $rows, $opts );
407 protected function runMainQueryHook( &$tables, &$fields, &$conds,
408 &$query_options, &$join_conds, $opts
410 return parent
::runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts )
412 'SpecialRecentChangesQuery',
413 [ &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ],
418 protected function getDB() {
419 return wfGetDB( DB_REPLICA
, 'recentchanges' );
422 public function outputFeedLinks() {
423 $this->addFeedLinks( $this->getFeedQuery() );
427 * Get URL query parameters for action=feedrecentchanges API feed of current recent changes view.
431 protected function getFeedQuery() {
432 $query = array_filter( $this->getOptions()->getAllValues(), function ( $value ) {
433 // API handles empty parameters in a different way
434 return $value !== '';
436 $query['action'] = 'feedrecentchanges';
437 $feedLimit = $this->getConfig()->get( 'FeedLimit' );
438 if ( $query['limit'] > $feedLimit ) {
439 $query['limit'] = $feedLimit;
446 * Build and output the actual changes list.
448 * @param ResultWrapper $rows Database rows
449 * @param FormOptions $opts
451 public function outputChangesList( $rows, $opts ) {
452 $limit = $opts['limit'];
454 $showWatcherCount = $this->getConfig()->get( 'RCShowWatchingUsers' )
455 && $this->getUser()->getOption( 'shownumberswatching' );
458 $dbr = $this->getDB();
461 $list = ChangesList
::newFromContext( $this->getContext(), $this->filterGroups
);
462 $list->initChangesListRows( $rows );
464 $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
465 $rclistOutput = $list->beginRecentChangesList();
466 foreach ( $rows as $obj ) {
470 $rc = RecentChange
::newFromRow( $obj );
472 # Skip CatWatch entries for hidden cats based on user preference
474 $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE
&&
475 !$userShowHiddenCats &&
476 $rc->getParam( 'hidden-cat' )
481 $rc->counter
= $counter++
;
482 # Check if the page has been updated since the last visit
483 if ( $this->getConfig()->get( 'ShowUpdatedMarker' )
484 && !empty( $obj->wl_notificationtimestamp
)
486 $rc->notificationtimestamp
= ( $obj->rc_timestamp
>= $obj->wl_notificationtimestamp
);
488 $rc->notificationtimestamp
= false; // Default
490 # Check the number of users watching the page
491 $rc->numberofWatchingusers
= 0; // Default
492 if ( $showWatcherCount && $obj->rc_namespace
>= 0 ) {
493 if ( !isset( $watcherCache[$obj->rc_namespace
][$obj->rc_title
] ) ) {
494 $watcherCache[$obj->rc_namespace
][$obj->rc_title
] =
495 MediaWikiServices
::getInstance()->getWatchedItemStore()->countWatchers(
496 new TitleValue( (int)$obj->rc_namespace
, $obj->rc_title
)
499 $rc->numberofWatchingusers
= $watcherCache[$obj->rc_namespace
][$obj->rc_title
];
502 $changeLine = $list->recentChangesLine( $rc, !empty( $obj->wl_user
), $counter );
503 if ( $changeLine !== false ) {
504 $rclistOutput .= $changeLine;
508 $rclistOutput .= $list->endRecentChangesList();
510 if ( $rows->numRows() === 0 ) {
511 $this->outputNoResults();
512 if ( !$this->including() ) {
513 $this->getOutput()->setStatusCode( 404 );
516 $this->getOutput()->addHTML( $rclistOutput );
521 * Set the text to be displayed above the changes
523 * @param FormOptions $opts
524 * @param int $numRows Number of rows in the result to show after this header
526 public function doHeader( $opts, $numRows ) {
527 $this->setTopText( $opts );
529 $defaults = $opts->getAllValues();
530 $nondefaults = $opts->getChangedValues();
533 $panel[] = $this->makeLegend();
534 $panel[] = $this->optionsPanel( $defaults, $nondefaults, $numRows );
537 $extraOpts = $this->getExtraOptions( $opts );
538 $extraOptsCount = count( $extraOpts );
540 $submit = ' ' . Xml
::submitButton( $this->msg( 'recentchanges-submit' )->text() );
542 $out = Xml
::openElement( 'table', [ 'class' => 'mw-recentchanges-table' ] );
543 foreach ( $extraOpts as $name => $optionRow ) {
544 # Add submit button to the last row only
546 $addSubmit = ( $count === $extraOptsCount ) ?
$submit : '';
548 $out .= Xml
::openElement( 'tr' );
549 if ( is_array( $optionRow ) ) {
552 [ 'class' => 'mw-label mw-' . $name . '-label' ],
557 [ 'class' => 'mw-input' ],
558 $optionRow[1] . $addSubmit
563 [ 'class' => 'mw-input', 'colspan' => 2 ],
564 $optionRow . $addSubmit
567 $out .= Xml
::closeElement( 'tr' );
569 $out .= Xml
::closeElement( 'table' );
571 $unconsumed = $opts->getUnconsumedValues();
572 foreach ( $unconsumed as $key => $value ) {
573 $out .= Html
::hidden( $key, $value );
576 $t = $this->getPageTitle();
577 $out .= Html
::hidden( 'title', $t->getPrefixedText() );
578 $form = Xml
::tags( 'form', [ 'action' => wfScript() ], $out );
580 $panelString = implode( "\n", $panel );
582 $rcoptions = Xml
::fieldset(
583 $this->msg( 'recentchanges-legend' )->text(),
585 [ 'class' => 'rcoptions' ]
588 // Insert a placeholder for RCFilters
589 if ( $this->getUser()->getOption( 'rcenhancedfilters' ) ) {
590 $rcfilterContainer = Html
::element(
592 [ 'class' => 'rcfilters-container' ]
595 // Wrap both with rcfilters-head
596 $this->getOutput()->addHTML(
599 [ 'class' => 'rcfilters-head' ],
600 $rcfilterContainer . $rcoptions
604 $this->getOutput()->addHTML( $rcoptions );
607 $this->setBottomText( $opts );
611 * Send the text to be displayed above the options
613 * @param FormOptions $opts Unused
615 function setTopText( FormOptions
$opts ) {
618 $message = $this->msg( 'recentchangestext' )->inContentLanguage();
619 if ( !$message->isDisabled() ) {
620 $this->getOutput()->addWikiText(
621 Html
::rawElement( 'div',
622 [ 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ],
623 "\n" . $message->plain() . "\n"
625 /* $lineStart */ true,
626 /* $interface */ false
632 * Get options to be displayed in a form
634 * @param FormOptions $opts
637 function getExtraOptions( $opts ) {
638 $opts->consumeValues( [
639 'namespace', 'invert', 'associated', 'tagfilter', 'categories', 'categories_any'
643 $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
645 if ( $this->getConfig()->get( 'AllowCategorizedRecentChanges' ) ) {
646 $extraOpts['category'] = $this->categoryFilterForm( $opts );
649 $tagFilter = ChangeTags
::buildTagFilterSelector(
650 $opts['tagfilter'], false, $this->getContext() );
651 if ( count( $tagFilter ) ) {
652 $extraOpts['tagfilter'] = $tagFilter;
655 // Don't fire the hook for subclasses. (Or should we?)
656 if ( $this->getName() === 'Recentchanges' ) {
657 Hooks
::run( 'SpecialRecentChangesPanel', [ &$extraOpts, $opts ] );
664 * Check whether the structured filter UI is enabled
668 protected function isStructuredFilterUiEnabled() {
669 return $this->getUser()->getOption(
675 * Add page-specific modules.
677 protected function addModules() {
678 parent
::addModules();
679 $out = $this->getOutput();
680 $out->addModules( 'mediawiki.special.recentchanges' );
681 if ( $this->isStructuredFilterUiEnabled() ) {
682 $out->addModules( 'mediawiki.rcfilters.filters.ui' );
683 $out->addModuleStyles( 'mediawiki.rcfilters.filters.base.styles' );
688 * Get last modified date, for client caching
689 * Don't use this if we are using the patrol feature, patrol changes don't
690 * update the timestamp
692 * @return string|bool
694 public function checkLastModified() {
695 $dbr = $this->getDB();
696 $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __METHOD__
);
702 * Creates the choose namespace selection
704 * @param FormOptions $opts
707 protected function namespaceFilterForm( FormOptions
$opts ) {
708 $nsSelect = Html
::namespaceSelector(
709 [ 'selected' => $opts['namespace'], 'all' => '' ],
710 [ 'name' => 'namespace', 'id' => 'namespace' ]
712 $nsLabel = Xml
::label( $this->msg( 'namespace' )->text(), 'namespace' );
713 $invert = Xml
::checkLabel(
714 $this->msg( 'invert' )->text(), 'invert', 'nsinvert',
716 [ 'title' => $this->msg( 'tooltip-invert' )->text() ]
718 $associated = Xml
::checkLabel(
719 $this->msg( 'namespace_association' )->text(), 'associated', 'nsassociated',
721 [ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
724 return [ $nsLabel, "$nsSelect $invert $associated" ];
728 * Create an input to filter changes by categories
730 * @param FormOptions $opts
733 protected function categoryFilterForm( FormOptions
$opts ) {
734 list( $label, $input ) = Xml
::inputLabelSep( $this->msg( 'rc_categories' )->text(),
735 'categories', 'mw-categories', false, $opts['categories'] );
737 $input .= ' ' . Xml
::checkLabel( $this->msg( 'rc_categories_any' )->text(),
738 'categories_any', 'mw-categories_any', $opts['categories_any'] );
740 return [ $label, $input ];
744 * Filter $rows by categories set in $opts
746 * @param ResultWrapper $rows Database rows
747 * @param FormOptions $opts
749 function filterByCategories( &$rows, FormOptions
$opts ) {
750 $categories = array_map( 'trim', explode( '|', $opts['categories'] ) );
752 if ( !count( $categories ) ) {
758 foreach ( $categories as $cat ) {
770 foreach ( $rows as $k => $r ) {
771 $nt = Title
::makeTitle( $r->rc_namespace
, $r->rc_title
);
772 $id = $nt->getArticleID();
774 continue; # Page might have been deleted...
776 if ( !in_array( $id, $articles ) ) {
779 if ( !isset( $a2r[$id] ) ) {
787 if ( !count( $articles ) ||
!count( $cats ) ) {
792 $catFind = new CategoryFinder
;
793 $catFind->seed( $articles, $cats, $opts['categories_any'] ?
'OR' : 'AND' );
794 $match = $catFind->run();
798 foreach ( $match as $id ) {
799 foreach ( $a2r[$id] as $rev ) {
801 $newrows[$k] = $rowsarr[$k];
804 $rows = new FakeResultWrapper( array_values( $newrows ) );
808 * Makes change an option link which carries all the other options
810 * @param string $title Title
811 * @param array $override Options to override
812 * @param array $options Current options
813 * @param bool $active Whether to show the link in bold
816 function makeOptionsLink( $title, $override, $options, $active = false ) {
817 $params = $override +
$options;
819 // T38524: false values have be converted to "0" otherwise
820 // wfArrayToCgi() will omit it them.
821 foreach ( $params as &$value ) {
822 if ( $value === false ) {
829 $title = new HtmlArmor( '<strong>' . htmlspecialchars( $title ) . '</strong>' );
832 return $this->getLinkRenderer()->makeKnownLink( $this->getPageTitle(), $title, [
833 'data-params' => json_encode( $override ),
834 'data-keys' => implode( ',', array_keys( $override ) ),
839 * Creates the options panel.
841 * @param array $defaults
842 * @param array $nondefaults
843 * @param int $numRows Number of rows in the result to show after this header
846 function optionsPanel( $defaults, $nondefaults, $numRows ) {
847 $options = $nondefaults +
$defaults;
850 $msg = $this->msg( 'rclegend' );
851 if ( !$msg->isDisabled() ) {
852 $note .= '<div class="mw-rclegend">' . $msg->parse() . "</div>\n";
855 $lang = $this->getLanguage();
856 $user = $this->getUser();
857 $config = $this->getConfig();
858 if ( $options['from'] ) {
859 $resetLink = $this->makeOptionsLink( $this->msg( 'rclistfromreset' ),
860 [ 'from' => '' ], $nondefaults );
862 $note .= $this->msg( 'rcnotefrom' )
863 ->numParams( $options['limit'] )
865 $lang->userTimeAndDate( $options['from'], $user ),
866 $lang->userDate( $options['from'], $user ),
867 $lang->userTime( $options['from'], $user )
869 ->numParams( $numRows )
873 [ 'class' => 'rcoptions-listfromreset' ],
874 $this->msg( 'parentheses' )->rawParams( $resetLink )->parse()
879 # Sort data for display and make sure it's unique after we've added user data.
880 $linkLimits = $config->get( 'RCLinkLimits' );
881 $linkLimits[] = $options['limit'];
883 $linkLimits = array_unique( $linkLimits );
885 $linkDays = $config->get( 'RCLinkDays' );
886 $linkDays[] = $options['days'];
888 $linkDays = array_unique( $linkDays );
892 foreach ( $linkLimits as $value ) {
893 $cl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
894 [ 'limit' => $value ], $nondefaults, $value == $options['limit'] );
896 $cl = $lang->pipeList( $cl );
898 // day links, reset 'from' to none
900 foreach ( $linkDays as $value ) {
901 $dl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
902 [ 'days' => $value, 'from' => '' ], $nondefaults, $value == $options['days'] );
904 $dl = $lang->pipeList( $dl );
906 $showhide = [ 'show', 'hide' ];
910 $filterGroups = $this->getFilterGroups();
912 $context = $this->getContext();
913 foreach ( $filterGroups as $groupName => $group ) {
914 if ( !$group->isPerGroupRequestParameter() ) {
915 foreach ( $group->getFilters() as $key => $filter ) {
916 if ( $filter->displaysOnUnstructuredUi( $this ) ) {
917 $msg = $filter->getShowHide();
918 $linkMessage = $this->msg( $msg . '-' . $showhide[1 - $options[$key]] );
919 // Extensions can define additional filters, but don't need to define the corresponding
920 // messages. If they don't exist, just fall back to 'show' and 'hide'.
921 if ( !$linkMessage->exists() ) {
922 $linkMessage = $this->msg( $showhide[1 - $options[$key]] );
925 $link = $this->makeOptionsLink( $linkMessage->text(),
926 [ $key => 1 - $options[$key] ], $nondefaults );
929 'class' => "$msg rcshowhideoption",
930 'data-filter-name' => $filter->getName(),
933 if ( $filter->isFeatureAvailableOnStructuredUi( $this ) ) {
934 $attribs['data-feature-in-structured-ui'] = true;
937 $links[] = Html
::rawElement(
940 $this->msg( $msg )->rawParams( $link )->escaped()
947 // show from this onward link
948 $timestamp = wfTimestampNow();
949 $now = $lang->userTimeAndDate( $timestamp, $user );
950 $timenow = $lang->userTime( $timestamp, $user );
951 $datenow = $lang->userDate( $timestamp, $user );
952 $pipedLinks = '<span class="rcshowhide">' . $lang->pipeList( $links ) . '</span>';
954 $rclinks = '<span class="rclinks">' . $this->msg( 'rclinks' )->rawParams( $cl, $dl, '' )
955 ->parse() . '</span>';
957 $rclistfrom = '<span class="rclistfrom">' . $this->makeOptionsLink(
958 $this->msg( 'rclistfrom' )->rawParams( $now, $timenow, $datenow )->parse(),
959 [ 'from' => $timestamp ],
963 return "{$note}$rclinks<br />$pipedLinks<br />$rclistfrom";
966 public function isIncludable() {
970 protected function getCacheTTL() {