Merge "Refactor Watchlist code so mobile can be more consistent"
[lhc/web/wiklou.git] / includes / specials / SpecialRecentchanges.php
1 <?php
2 /**
3 * Implements Special:Recentchanges
4 *
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.
9 *
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.
14 *
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
19 *
20 * @file
21 * @ingroup SpecialPage
22 */
23
24 /**
25 * A special page that lists last changes made to the wiki
26 *
27 * @ingroup SpecialPage
28 */
29 class SpecialRecentChanges extends ChangesListSpecialPage {
30 // @codingStandardsIgnoreStart Needed "useless" override to change parameters.
31 public function __construct( $name = 'Recentchanges', $restriction = '' ) {
32 parent::__construct( $name, $restriction );
33 }
34 // @codingStandardsIgnoreEnd
35
36 /**
37 * Main execution point
38 *
39 * @param string $subpage
40 */
41 public function execute( $subpage ) {
42 // Backwards-compatibility: redirect to new feed URLs
43 $feedFormat = $this->getRequest()->getVal( 'feed' );
44 if ( !$this->including() && $feedFormat ) {
45 $query = $this->getFeedQuery();
46 $query['feedformat'] = $feedFormat === 'atom' ? 'atom' : 'rss';
47 $this->getOutput()->redirect( wfAppendQuery( wfScript( 'api' ), $query ) );
48
49 return;
50 }
51
52 // 10 seconds server-side caching max
53 $this->getOutput()->setSquidMaxage( 10 );
54 // Check if the client has a cached version
55 $lastmod = $this->checkLastModified();
56 if ( $lastmod === false ) {
57 return;
58 }
59
60 parent::execute( $subpage );
61 }
62
63 /**
64 * Get a FormOptions object containing the default options
65 *
66 * @return FormOptions
67 */
68 public function getDefaultOptions() {
69 $opts = parent::getDefaultOptions();
70 $user = $this->getUser();
71
72 $opts->add( 'days', $user->getIntOption( 'rcdays' ) );
73 $opts->add( 'limit', $user->getIntOption( 'rclimit' ) );
74 $opts->add( 'from', '' );
75
76 $opts->add( 'hideminor', $user->getBoolOption( 'hideminor' ) );
77 $opts->add( 'hidebots', true );
78 $opts->add( 'hideanons', false );
79 $opts->add( 'hideliu', false );
80 $opts->add( 'hidepatrolled', $user->getBoolOption( 'hidepatrolled' ) );
81 $opts->add( 'hidemyself', false );
82
83 $opts->add( 'categories', '' );
84 $opts->add( 'categories_any', false );
85 $opts->add( 'tagfilter', '' );
86
87 return $opts;
88 }
89
90 /**
91 * Get custom show/hide filters
92 *
93 * @return array Map of filter URL param names to properties (msg/default)
94 */
95 protected function getCustomFilters() {
96 if ( $this->customFilters === null ) {
97 $this->customFilters = parent::getCustomFilters();
98 wfRunHooks( 'SpecialRecentChangesFilters', array( $this, &$this->customFilters ), '1.23' );
99 }
100
101 return $this->customFilters;
102 }
103
104 /**
105 * Process $par and put options found in $opts. Used when including the page.
106 *
107 * @param string $par
108 * @param FormOptions $opts
109 */
110 public function parseParameters( $par, FormOptions $opts ) {
111 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
112 foreach ( $bits as $bit ) {
113 if ( 'hidebots' === $bit ) {
114 $opts['hidebots'] = true;
115 }
116 if ( 'bots' === $bit ) {
117 $opts['hidebots'] = false;
118 }
119 if ( 'hideminor' === $bit ) {
120 $opts['hideminor'] = true;
121 }
122 if ( 'minor' === $bit ) {
123 $opts['hideminor'] = false;
124 }
125 if ( 'hideliu' === $bit ) {
126 $opts['hideliu'] = true;
127 }
128 if ( 'hidepatrolled' === $bit ) {
129 $opts['hidepatrolled'] = true;
130 }
131 if ( 'hideanons' === $bit ) {
132 $opts['hideanons'] = true;
133 }
134 if ( 'hidemyself' === $bit ) {
135 $opts['hidemyself'] = true;
136 }
137
138 if ( is_numeric( $bit ) ) {
139 $opts['limit'] = $bit;
140 }
141
142 $m = array();
143 if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
144 $opts['limit'] = $m[1];
145 }
146 if ( preg_match( '/^days=(\d+)$/', $bit, $m ) ) {
147 $opts['days'] = $m[1];
148 }
149 if ( preg_match( '/^namespace=(\d+)$/', $bit, $m ) ) {
150 $opts['namespace'] = $m[1];
151 }
152 }
153 }
154
155 public function validateOptions( FormOptions $opts ) {
156 $opts->validateIntBounds( 'limit', 0, 5000 );
157 parent::validateOptions( $opts );
158 }
159
160 /**
161 * Return an array of conditions depending of options set in $opts
162 *
163 * @param FormOptions $opts
164 * @return array
165 */
166 public function buildMainQueryConds( FormOptions $opts ) {
167 $dbr = $this->getDB();
168 $conds = parent::buildMainQueryConds( $opts );
169
170 // Calculate cutoff
171 $cutoff_unixtime = time() - ( $opts['days'] * 86400 );
172 $cutoff_unixtime = $cutoff_unixtime - ( $cutoff_unixtime % 86400 );
173 $cutoff = $dbr->timestamp( $cutoff_unixtime );
174
175 $fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
176 if ( $fromValid && $opts['from'] > wfTimestamp( TS_MW, $cutoff ) ) {
177 $cutoff = $dbr->timestamp( $opts['from'] );
178 } else {
179 $opts->reset( 'from' );
180 }
181
182 $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
183
184 return $conds;
185 }
186
187 /**
188 * Process the query
189 *
190 * @param array $conds
191 * @param FormOptions $opts
192 * @return bool|ResultWrapper Result or false (for Recentchangeslinked only)
193 */
194 public function doMainQuery( $conds, $opts ) {
195 global $wgAllowCategorizedRecentChanges;
196
197 $dbr = $this->getDB();
198 $user = $this->getUser();
199
200 $tables = array( 'recentchanges' );
201 $fields = RecentChange::selectFields();
202 $query_options = array();
203 $join_conds = array();
204
205 // JOIN on watchlist for users
206 if ( $user->getId() && $user->isAllowed( 'viewmywatchlist' ) ) {
207 $tables[] = 'watchlist';
208 $fields[] = 'wl_user';
209 $fields[] = 'wl_notificationtimestamp';
210 $join_conds['watchlist'] = array( 'LEFT JOIN', array(
211 'wl_user' => $user->getId(),
212 'wl_title=rc_title',
213 'wl_namespace=rc_namespace'
214 ) );
215 }
216
217 if ( $user->isAllowed( 'rollback' ) ) {
218 $tables[] = 'page';
219 $fields[] = 'page_latest';
220 $join_conds['page'] = array( 'LEFT JOIN', 'rc_cur_id=page_id' );
221 }
222
223 ChangeTags::modifyDisplayQuery(
224 $tables,
225 $fields,
226 $conds,
227 $join_conds,
228 $query_options,
229 $opts['tagfilter']
230 );
231
232 if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
233 $opts )
234 ) {
235 return false;
236 }
237
238 // rc_new is not an ENUM, but adding a redundant rc_new IN (0,1) gives mysql enough
239 // knowledge to use an index merge if it wants (it may use some other index though).
240 $rows = $dbr->select(
241 $tables,
242 $fields,
243 $conds + array( 'rc_new' => array( 0, 1 ) ),
244 __METHOD__,
245 array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $opts['limit'] ) + $query_options,
246 $join_conds
247 );
248
249 // Build the final data
250 if ( $wgAllowCategorizedRecentChanges ) {
251 $this->filterByCategories( $rows, $opts );
252 }
253
254 return $rows;
255 }
256
257 protected function runMainQueryHook( &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts ) {
258 return parent::runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts )
259 && wfRunHooks(
260 'SpecialRecentChangesQuery',
261 array( &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ),
262 '1.23'
263 );
264 }
265
266 public function outputFeedLinks() {
267 $this->addFeedLinks( $this->getFeedQuery() );
268 }
269
270 /**
271 * Get URL query parameters for action=feedrecentchanges API feed of current recent changes view.
272 *
273 * @return array
274 */
275 private function getFeedQuery() {
276 global $wgFeedLimit;
277 $query = array_filter( $this->getOptions()->getAllValues(), function ( $value ) {
278 // API handles empty parameters in a different way
279 return $value !== '';
280 } );
281 $query['action'] = 'feedrecentchanges';
282 if ( $query['limit'] > $wgFeedLimit ) {
283 $query['limit'] = $wgFeedLimit;
284 }
285
286 return $query;
287 }
288
289 /**
290 * Build and output the actual changes list.
291 *
292 * @param array $rows Database rows
293 * @param FormOptions $opts
294 */
295 public function outputChangesList( $rows, $opts ) {
296 global $wgRCShowWatchingUsers, $wgShowUpdatedMarker;
297
298 $limit = $opts['limit'];
299
300 $showWatcherCount = $wgRCShowWatchingUsers
301 && $this->getUser()->getOption( 'shownumberswatching' );
302 $watcherCache = array();
303
304 $dbr = $this->getDB();
305
306 $counter = 1;
307 $list = ChangesList::newFromContext( $this->getContext() );
308 $list->initChangesListRows( $rows );
309
310 $rclistOutput = $list->beginRecentChangesList();
311 foreach ( $rows as $obj ) {
312 if ( $limit == 0 ) {
313 break;
314 }
315 $rc = RecentChange::newFromRow( $obj );
316 $rc->counter = $counter++;
317 # Check if the page has been updated since the last visit
318 if ( $wgShowUpdatedMarker && !empty( $obj->wl_notificationtimestamp ) ) {
319 $rc->notificationtimestamp = ( $obj->rc_timestamp >= $obj->wl_notificationtimestamp );
320 } else {
321 $rc->notificationtimestamp = false; // Default
322 }
323 # Check the number of users watching the page
324 $rc->numberofWatchingusers = 0; // Default
325 if ( $showWatcherCount && $obj->rc_namespace >= 0 ) {
326 if ( !isset( $watcherCache[$obj->rc_namespace][$obj->rc_title] ) ) {
327 $watcherCache[$obj->rc_namespace][$obj->rc_title] =
328 $dbr->selectField(
329 'watchlist',
330 'COUNT(*)',
331 array(
332 'wl_namespace' => $obj->rc_namespace,
333 'wl_title' => $obj->rc_title,
334 ),
335 __METHOD__ . '-watchers'
336 );
337 }
338 $rc->numberofWatchingusers = $watcherCache[$obj->rc_namespace][$obj->rc_title];
339 }
340
341 $changeLine = $list->recentChangesLine( $rc, !empty( $obj->wl_user ), $counter );
342 if ( $changeLine !== false ) {
343 $rclistOutput .= $changeLine;
344 --$limit;
345 }
346 }
347 $rclistOutput .= $list->endRecentChangesList();
348
349 if ( $rows->numRows() === 0 ) {
350 $this->getOutput()->addHtml(
351 '<div class="mw-changeslist-empty">' .
352 $this->msg( 'recentchanges-noresult' )->parse() .
353 '</div>'
354 );
355 if ( !$this->including() ) {
356 $this->getOutput()->setStatusCode( 404 );
357 }
358 } else {
359 $this->getOutput()->addHTML( $rclistOutput );
360 }
361 }
362
363 /**
364 * Set the text to be displayed above the changes
365 *
366 * @param FormOptions $opts
367 * @param int $numRows Number of rows in the result to show after this header
368 */
369 public function doHeader( $opts, $numRows ) {
370 global $wgScript;
371
372 $this->setTopText( $opts );
373
374 $defaults = $opts->getAllValues();
375 $nondefaults = $opts->getChangedValues();
376
377 $panel = array();
378 $panel[] = self::makeLegend( $this->getContext() );
379 $panel[] = $this->optionsPanel( $defaults, $nondefaults, $numRows );
380 $panel[] = '<hr />';
381
382 $extraOpts = $this->getExtraOptions( $opts );
383 $extraOptsCount = count( $extraOpts );
384 $count = 0;
385 $submit = ' ' . Xml::submitbutton( $this->msg( 'allpagessubmit' )->text() );
386
387 $out = Xml::openElement( 'table', array( 'class' => 'mw-recentchanges-table' ) );
388 foreach ( $extraOpts as $name => $optionRow ) {
389 # Add submit button to the last row only
390 ++$count;
391 $addSubmit = ( $count === $extraOptsCount ) ? $submit : '';
392
393 $out .= Xml::openElement( 'tr' );
394 if ( is_array( $optionRow ) ) {
395 $out .= Xml::tags(
396 'td',
397 array( 'class' => 'mw-label mw-' . $name . '-label' ),
398 $optionRow[0]
399 );
400 $out .= Xml::tags(
401 'td',
402 array( 'class' => 'mw-input' ),
403 $optionRow[1] . $addSubmit
404 );
405 } else {
406 $out .= Xml::tags(
407 'td',
408 array( 'class' => 'mw-input', 'colspan' => 2 ),
409 $optionRow . $addSubmit
410 );
411 }
412 $out .= Xml::closeElement( 'tr' );
413 }
414 $out .= Xml::closeElement( 'table' );
415
416 $unconsumed = $opts->getUnconsumedValues();
417 foreach ( $unconsumed as $key => $value ) {
418 $out .= Html::hidden( $key, $value );
419 }
420
421 $t = $this->getPageTitle();
422 $out .= Html::hidden( 'title', $t->getPrefixedText() );
423 $form = Xml::tags( 'form', array( 'action' => $wgScript ), $out );
424 $panel[] = $form;
425 $panelString = implode( "\n", $panel );
426
427 $this->getOutput()->addHTML(
428 Xml::fieldset(
429 $this->msg( 'recentchanges-legend' )->text(),
430 $panelString,
431 array( 'class' => 'rcoptions' )
432 )
433 );
434
435 $this->setBottomText( $opts );
436 }
437
438 /**
439 * Send the text to be displayed above the options
440 *
441 * @param FormOptions $opts Unused
442 */
443 function setTopText( FormOptions $opts ) {
444 global $wgContLang;
445
446 $message = $this->msg( 'recentchangestext' )->inContentLanguage();
447 if ( !$message->isDisabled() ) {
448 $this->getOutput()->addWikiText(
449 Html::rawElement( 'p',
450 array( 'lang' => $wgContLang->getCode(), 'dir' => $wgContLang->getDir() ),
451 "\n" . $message->plain() . "\n"
452 ),
453 /* $lineStart */ false,
454 /* $interface */ false
455 );
456 }
457 }
458
459 /**
460 * Get options to be displayed in a form
461 *
462 * @param FormOptions $opts
463 * @return array
464 */
465 function getExtraOptions( $opts ) {
466 $opts->consumeValues( array(
467 'namespace', 'invert', 'associated', 'tagfilter', 'categories', 'categories_any'
468 ) );
469
470 $extraOpts = array();
471 $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
472
473 global $wgAllowCategorizedRecentChanges;
474 if ( $wgAllowCategorizedRecentChanges ) {
475 $extraOpts['category'] = $this->categoryFilterForm( $opts );
476 }
477
478 $tagFilter = ChangeTags::buildTagFilterSelector( $opts['tagfilter'] );
479 if ( count( $tagFilter ) ) {
480 $extraOpts['tagfilter'] = $tagFilter;
481 }
482
483 // Don't fire the hook for subclasses. (Or should we?)
484 if ( $this->getName() === 'Recentchanges' ) {
485 wfRunHooks( 'SpecialRecentChangesPanel', array( &$extraOpts, $opts ) );
486 }
487
488 return $extraOpts;
489 }
490
491 /**
492 * Add page-specific modules.
493 */
494 protected function addModules() {
495 parent::addModules();
496 $out = $this->getOutput();
497 $out->addModules( 'mediawiki.special.recentchanges' );
498 }
499
500 /**
501 * Get last modified date, for client caching
502 * Don't use this if we are using the patrol feature, patrol changes don't
503 * update the timestamp
504 *
505 * @return string|bool
506 */
507 public function checkLastModified() {
508 $dbr = $this->getDB();
509 $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __METHOD__ );
510
511 return $lastmod;
512 }
513
514 /**
515 * Creates the choose namespace selection
516 *
517 * @param FormOptions $opts
518 * @return string
519 */
520 protected function namespaceFilterForm( FormOptions $opts ) {
521 $nsSelect = Html::namespaceSelector(
522 array( 'selected' => $opts['namespace'], 'all' => '' ),
523 array( 'name' => 'namespace', 'id' => 'namespace' )
524 );
525 $nsLabel = Xml::label( $this->msg( 'namespace' )->text(), 'namespace' );
526 $invert = Xml::checkLabel(
527 $this->msg( 'invert' )->text(), 'invert', 'nsinvert',
528 $opts['invert'],
529 array( 'title' => $this->msg( 'tooltip-invert' )->text() )
530 );
531 $associated = Xml::checkLabel(
532 $this->msg( 'namespace_association' )->text(), 'associated', 'nsassociated',
533 $opts['associated'],
534 array( 'title' => $this->msg( 'tooltip-namespace_association' )->text() )
535 );
536
537 return array( $nsLabel, "$nsSelect $invert $associated" );
538 }
539
540 /**
541 * Create an input to filter changes by categories
542 *
543 * @param FormOptions $opts
544 * @return array
545 */
546 protected function categoryFilterForm( FormOptions $opts ) {
547 list( $label, $input ) = Xml::inputLabelSep( $this->msg( 'rc_categories' )->text(),
548 'categories', 'mw-categories', false, $opts['categories'] );
549
550 $input .= ' ' . Xml::checkLabel( $this->msg( 'rc_categories_any' )->text(),
551 'categories_any', 'mw-categories_any', $opts['categories_any'] );
552
553 return array( $label, $input );
554 }
555
556 /**
557 * Filter $rows by categories set in $opts
558 *
559 * @param ResultWrapper $rows Database rows
560 * @param FormOptions $opts
561 */
562 function filterByCategories( &$rows, FormOptions $opts ) {
563 $categories = array_map( 'trim', explode( '|', $opts['categories'] ) );
564
565 if ( !count( $categories ) ) {
566 return;
567 }
568
569 # Filter categories
570 $cats = array();
571 foreach ( $categories as $cat ) {
572 $cat = trim( $cat );
573 if ( $cat == '' ) {
574 continue;
575 }
576 $cats[] = $cat;
577 }
578
579 # Filter articles
580 $articles = array();
581 $a2r = array();
582 $rowsarr = array();
583 foreach ( $rows as $k => $r ) {
584 $nt = Title::makeTitle( $r->rc_namespace, $r->rc_title );
585 $id = $nt->getArticleID();
586 if ( $id == 0 ) {
587 continue; # Page might have been deleted...
588 }
589 if ( !in_array( $id, $articles ) ) {
590 $articles[] = $id;
591 }
592 if ( !isset( $a2r[$id] ) ) {
593 $a2r[$id] = array();
594 }
595 $a2r[$id][] = $k;
596 $rowsarr[$k] = $r;
597 }
598
599 # Shortcut?
600 if ( !count( $articles ) || !count( $cats ) ) {
601 return;
602 }
603
604 # Look up
605 $c = new Categoryfinder;
606 $c->seed( $articles, $cats, $opts['categories_any'] ? 'OR' : 'AND' );
607 $match = $c->run();
608
609 # Filter
610 $newrows = array();
611 foreach ( $match as $id ) {
612 foreach ( $a2r[$id] as $rev ) {
613 $k = $rev;
614 $newrows[$k] = $rowsarr[$k];
615 }
616 }
617 $rows = $newrows;
618 }
619
620 /**
621 * Makes change an option link which carries all the other options
622 *
623 * @param string $title Title
624 * @param array $override Options to override
625 * @param array $options Current options
626 * @param bool $active Whether to show the link in bold
627 * @return string
628 */
629 function makeOptionsLink( $title, $override, $options, $active = false ) {
630 $params = $override + $options;
631
632 // Bug 36524: false values have be converted to "0" otherwise
633 // wfArrayToCgi() will omit it them.
634 foreach ( $params as &$value ) {
635 if ( $value === false ) {
636 $value = '0';
637 }
638 }
639 unset( $value );
640
641 $text = htmlspecialchars( $title );
642 if ( $active ) {
643 $text = '<strong>' . $text . '</strong>';
644 }
645
646 return Linker::linkKnown( $this->getPageTitle(), $text, array(), $params );
647 }
648
649 /**
650 * Creates the options panel.
651 *
652 * @param array $defaults
653 * @param array $nondefaults
654 * @param int $numRows Number of rows in the result to show after this header
655 * @return string
656 */
657 function optionsPanel( $defaults, $nondefaults, $numRows ) {
658 global $wgRCLinkLimits, $wgRCLinkDays;
659
660 $options = $nondefaults + $defaults;
661
662 $note = '';
663 $msg = $this->msg( 'rclegend' );
664 if ( !$msg->isDisabled() ) {
665 $note .= '<div class="mw-rclegend">' . $msg->parse() . "</div>\n";
666 }
667
668 $lang = $this->getLanguage();
669 $user = $this->getUser();
670 if ( $options['from'] ) {
671 $note .= $this->msg( 'rcnotefrom' )
672 ->numParams( $options['limit'] )
673 ->params(
674 $lang->userTimeAndDate( $options['from'], $user ),
675 $lang->userDate( $options['from'], $user ),
676 $lang->userTime( $options['from'], $user )
677 )
678 ->numParams( $numRows )
679 ->parse() . '<br />';
680 }
681
682 # Sort data for display and make sure it's unique after we've added user data.
683 $linkLimits = $wgRCLinkLimits;
684 $linkLimits[] = $options['limit'];
685 sort( $linkLimits );
686 $linkLimits = array_unique( $linkLimits );
687
688 $linkDays = $wgRCLinkDays;
689 $linkDays[] = $options['days'];
690 sort( $linkDays );
691 $linkDays = array_unique( $linkDays );
692
693 // limit links
694 $cl = array();
695 foreach ( $linkLimits as $value ) {
696 $cl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
697 array( 'limit' => $value ), $nondefaults, $value == $options['limit'] );
698 }
699 $cl = $lang->pipeList( $cl );
700
701 // day links, reset 'from' to none
702 $dl = array();
703 foreach ( $linkDays as $value ) {
704 $dl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
705 array( 'days' => $value, 'from' => '' ), $nondefaults, $value == $options['days'] );
706 }
707 $dl = $lang->pipeList( $dl );
708
709 // show/hide links
710 $filters = array(
711 'hideminor' => 'rcshowhideminor',
712 'hidebots' => 'rcshowhidebots',
713 'hideanons' => 'rcshowhideanons',
714 'hideliu' => 'rcshowhideliu',
715 'hidepatrolled' => 'rcshowhidepatr',
716 'hidemyself' => 'rcshowhidemine'
717 );
718
719 $showhide = array( 'show', 'hide' );
720
721 foreach ( $this->getCustomFilters() as $key => $params ) {
722 $filters[$key] = $params['msg'];
723 }
724 // Disable some if needed
725 if ( !$user->useRCPatrol() ) {
726 unset( $filters['hidepatrolled'] );
727 }
728
729 $links = array();
730 foreach ( $filters as $key => $msg ) {
731 // The following messages are used here:
732 // rcshowhideminor-show, rcshowhideminor-hide, rcshowhidebots-show, rcshowhidebots-hide,
733 // rcshowhideanons-show, rcshowhideanons-hide, rcshowhideliu-show, rcshowhideliu-hide,
734 // rcshowhidepatr-show, rcshowhidepatr-hide, rcshowhidemine-show, rcshowhidemine-hide.
735 $linkMessage = $this->msg( $msg . '-' . $showhide[1 - $options[$key]] );
736 // Extensions can define additional filters, but don't need to define the corresponding
737 // messages. If they don't exist, just fall back to 'show' and 'hide'.
738 if ( !$linkMessage->exists() ) {
739 $linkMessage = $this->msg( $showhide[1 - $options[$key]] );
740 }
741
742 $link = $this->makeOptionsLink( $linkMessage->text(),
743 array( $key => 1 - $options[$key] ), $nondefaults );
744 $links[] = $this->msg( $msg )->rawParams( $link )->escaped();
745 }
746
747 // show from this onward link
748 $timestamp = wfTimestampNow();
749 $now = $lang->userTimeAndDate( $timestamp, $user );
750 $timenow = $lang->userTime( $timestamp, $user );
751 $datenow = $lang->userDate( $timestamp, $user );
752 $rclinks = $this->msg( 'rclinks' )->rawParams( $cl, $dl, $lang->pipeList( $links ) )
753 ->parse();
754 $rclistfrom = $this->makeOptionsLink(
755 $this->msg( 'rclistfrom' )->rawParams( $now, $timenow, $datenow )->parse(),
756 array( 'from' => $timestamp ),
757 $nondefaults
758 );
759
760 return "{$note}$rclinks<br />$rclistfrom";
761 }
762
763 public function isIncludable() {
764 return true;
765 }
766 }