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