Merge "Add page_restrictions to readlock in lockSearchindex"
[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 Hooks::run( '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 $dbr = $this->getDB();
196 $user = $this->getUser();
197
198 $tables = array( 'recentchanges' );
199 $fields = RecentChange::selectFields();
200 $query_options = array();
201 $join_conds = array();
202
203 // JOIN on watchlist for users
204 if ( $user->getId() && $user->isAllowed( 'viewmywatchlist' ) ) {
205 $tables[] = 'watchlist';
206 $fields[] = 'wl_user';
207 $fields[] = 'wl_notificationtimestamp';
208 $join_conds['watchlist'] = array( 'LEFT JOIN', array(
209 'wl_user' => $user->getId(),
210 'wl_title=rc_title',
211 'wl_namespace=rc_namespace'
212 ) );
213 }
214
215 if ( $user->isAllowed( 'rollback' ) ) {
216 $tables[] = 'page';
217 $fields[] = 'page_latest';
218 $join_conds['page'] = array( 'LEFT JOIN', 'rc_cur_id=page_id' );
219 }
220
221 ChangeTags::modifyDisplayQuery(
222 $tables,
223 $fields,
224 $conds,
225 $join_conds,
226 $query_options,
227 $opts['tagfilter']
228 );
229
230 if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
231 $opts )
232 ) {
233 return false;
234 }
235
236 // rc_new is not an ENUM, but adding a redundant rc_new IN (0,1) gives mysql enough
237 // knowledge to use an index merge if it wants (it may use some other index though).
238 $rows = $dbr->select(
239 $tables,
240 $fields,
241 $conds + array( 'rc_new' => array( 0, 1 ) ),
242 __METHOD__,
243 array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $opts['limit'] ) + $query_options,
244 $join_conds
245 );
246
247 // Build the final data
248 if ( $this->getConfig()->get( 'AllowCategorizedRecentChanges' ) ) {
249 $this->filterByCategories( $rows, $opts );
250 }
251
252 return $rows;
253 }
254
255 protected function runMainQueryHook( &$tables, &$fields, &$conds,
256 &$query_options, &$join_conds, $opts
257 ) {
258 return parent::runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts )
259 && Hooks::run(
260 'SpecialRecentChangesQuery',
261 array( &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ),
262 '1.23'
263 );
264 }
265
266 protected function getDB() {
267 return wfGetDB( DB_SLAVE, 'recentchanges' );
268 }
269
270 public function outputFeedLinks() {
271 $this->addFeedLinks( $this->getFeedQuery() );
272 }
273
274 /**
275 * Get URL query parameters for action=feedrecentchanges API feed of current recent changes view.
276 *
277 * @return array
278 */
279 private function getFeedQuery() {
280 $query = array_filter( $this->getOptions()->getAllValues(), function ( $value ) {
281 // API handles empty parameters in a different way
282 return $value !== '';
283 } );
284 $query['action'] = 'feedrecentchanges';
285 $feedLimit = $this->getConfig()->get( 'FeedLimit' );
286 if ( $query['limit'] > $feedLimit ) {
287 $query['limit'] = $feedLimit;
288 }
289
290 return $query;
291 }
292
293 /**
294 * Build and output the actual changes list.
295 *
296 * @param array $rows Database rows
297 * @param FormOptions $opts
298 */
299 public function outputChangesList( $rows, $opts ) {
300 $limit = $opts['limit'];
301
302 $showWatcherCount = $this->getConfig()->get( 'RCShowWatchingUsers' )
303 && $this->getUser()->getOption( 'shownumberswatching' );
304 $watcherCache = array();
305
306 $dbr = $this->getDB();
307
308 $counter = 1;
309 $list = ChangesList::newFromContext( $this->getContext() );
310 $list->initChangesListRows( $rows );
311
312 $rclistOutput = $list->beginRecentChangesList();
313 foreach ( $rows as $obj ) {
314 if ( $limit == 0 ) {
315 break;
316 }
317 $rc = RecentChange::newFromRow( $obj );
318 $rc->counter = $counter++;
319 # Check if the page has been updated since the last visit
320 if ( $this->getConfig()->get( 'ShowUpdatedMarker' )
321 && !empty( $obj->wl_notificationtimestamp )
322 ) {
323 $rc->notificationtimestamp = ( $obj->rc_timestamp >= $obj->wl_notificationtimestamp );
324 } else {
325 $rc->notificationtimestamp = false; // Default
326 }
327 # Check the number of users watching the page
328 $rc->numberofWatchingusers = 0; // Default
329 if ( $showWatcherCount && $obj->rc_namespace >= 0 ) {
330 if ( !isset( $watcherCache[$obj->rc_namespace][$obj->rc_title] ) ) {
331 $watcherCache[$obj->rc_namespace][$obj->rc_title] =
332 $dbr->selectField(
333 'watchlist',
334 'COUNT(*)',
335 array(
336 'wl_namespace' => $obj->rc_namespace,
337 'wl_title' => $obj->rc_title,
338 ),
339 __METHOD__ . '-watchers'
340 );
341 }
342 $rc->numberofWatchingusers = $watcherCache[$obj->rc_namespace][$obj->rc_title];
343 }
344
345 $changeLine = $list->recentChangesLine( $rc, !empty( $obj->wl_user ), $counter );
346 if ( $changeLine !== false ) {
347 $rclistOutput .= $changeLine;
348 --$limit;
349 }
350 }
351 $rclistOutput .= $list->endRecentChangesList();
352
353 if ( $rows->numRows() === 0 ) {
354 $this->getOutput()->addHtml(
355 '<div class="mw-changeslist-empty">' .
356 $this->msg( 'recentchanges-noresult' )->parse() .
357 '</div>'
358 );
359 if ( !$this->including() ) {
360 $this->getOutput()->setStatusCode( 404 );
361 }
362 } else {
363 $this->getOutput()->addHTML( $rclistOutput );
364 }
365 }
366
367 /**
368 * Set the text to be displayed above the changes
369 *
370 * @param FormOptions $opts
371 * @param int $numRows Number of rows in the result to show after this header
372 */
373 public function doHeader( $opts, $numRows ) {
374 $this->setTopText( $opts );
375
376 $defaults = $opts->getAllValues();
377 $nondefaults = $opts->getChangedValues();
378
379 $panel = array();
380 $panel[] = self::makeLegend( $this->getContext() );
381 $panel[] = $this->optionsPanel( $defaults, $nondefaults, $numRows );
382 $panel[] = '<hr />';
383
384 $extraOpts = $this->getExtraOptions( $opts );
385 $extraOptsCount = count( $extraOpts );
386 $count = 0;
387 $submit = ' ' . Xml::submitbutton( $this->msg( 'allpagessubmit' )->text() );
388
389 $out = Xml::openElement( 'table', array( 'class' => 'mw-recentchanges-table' ) );
390 foreach ( $extraOpts as $name => $optionRow ) {
391 # Add submit button to the last row only
392 ++$count;
393 $addSubmit = ( $count === $extraOptsCount ) ? $submit : '';
394
395 $out .= Xml::openElement( 'tr' );
396 if ( is_array( $optionRow ) ) {
397 $out .= Xml::tags(
398 'td',
399 array( 'class' => 'mw-label mw-' . $name . '-label' ),
400 $optionRow[0]
401 );
402 $out .= Xml::tags(
403 'td',
404 array( 'class' => 'mw-input' ),
405 $optionRow[1] . $addSubmit
406 );
407 } else {
408 $out .= Xml::tags(
409 'td',
410 array( 'class' => 'mw-input', 'colspan' => 2 ),
411 $optionRow . $addSubmit
412 );
413 }
414 $out .= Xml::closeElement( 'tr' );
415 }
416 $out .= Xml::closeElement( 'table' );
417
418 $unconsumed = $opts->getUnconsumedValues();
419 foreach ( $unconsumed as $key => $value ) {
420 $out .= Html::hidden( $key, $value );
421 }
422
423 $t = $this->getPageTitle();
424 $out .= Html::hidden( 'title', $t->getPrefixedText() );
425 $form = Xml::tags( 'form', array( 'action' => wfScript() ), $out );
426 $panel[] = $form;
427 $panelString = implode( "\n", $panel );
428
429 $this->getOutput()->addHTML(
430 Xml::fieldset(
431 $this->msg( 'recentchanges-legend' )->text(),
432 $panelString,
433 array( 'class' => 'rcoptions' )
434 )
435 );
436
437 $this->setBottomText( $opts );
438 }
439
440 /**
441 * Send the text to be displayed above the options
442 *
443 * @param FormOptions $opts Unused
444 */
445 function setTopText( FormOptions $opts ) {
446 global $wgContLang;
447
448 $message = $this->msg( 'recentchangestext' )->inContentLanguage();
449 if ( !$message->isDisabled() ) {
450 $this->getOutput()->addWikiText(
451 Html::rawElement( 'div',
452 array( 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ),
453 "\n" . $message->plain() . "\n"
454 ),
455 /* $lineStart */ true,
456 /* $interface */ false
457 );
458 }
459 }
460
461 /**
462 * Get options to be displayed in a form
463 *
464 * @param FormOptions $opts
465 * @return array
466 */
467 function getExtraOptions( $opts ) {
468 $opts->consumeValues( array(
469 'namespace', 'invert', 'associated', 'tagfilter', 'categories', 'categories_any'
470 ) );
471
472 $extraOpts = array();
473 $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
474
475 if ( $this->getConfig()->get( 'AllowCategorizedRecentChanges' ) ) {
476 $extraOpts['category'] = $this->categoryFilterForm( $opts );
477 }
478
479 $tagFilter = ChangeTags::buildTagFilterSelector( $opts['tagfilter'] );
480 if ( count( $tagFilter ) ) {
481 $extraOpts['tagfilter'] = $tagFilter;
482 }
483
484 // Don't fire the hook for subclasses. (Or should we?)
485 if ( $this->getName() === 'Recentchanges' ) {
486 Hooks::run( 'SpecialRecentChangesPanel', array( &$extraOpts, $opts ) );
487 }
488
489 return $extraOpts;
490 }
491
492 /**
493 * Add page-specific modules.
494 */
495 protected function addModules() {
496 parent::addModules();
497 $out = $this->getOutput();
498 $out->addModules( 'mediawiki.special.recentchanges' );
499 }
500
501 /**
502 * Get last modified date, for client caching
503 * Don't use this if we are using the patrol feature, patrol changes don't
504 * update the timestamp
505 *
506 * @return string|bool
507 */
508 public function checkLastModified() {
509 $dbr = $this->getDB();
510 $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __METHOD__ );
511
512 return $lastmod;
513 }
514
515 /**
516 * Creates the choose namespace selection
517 *
518 * @param FormOptions $opts
519 * @return string
520 */
521 protected function namespaceFilterForm( FormOptions $opts ) {
522 $nsSelect = Html::namespaceSelector(
523 array( 'selected' => $opts['namespace'], 'all' => '' ),
524 array( 'name' => 'namespace', 'id' => 'namespace' )
525 );
526 $nsLabel = Xml::label( $this->msg( 'namespace' )->text(), 'namespace' );
527 $invert = Xml::checkLabel(
528 $this->msg( 'invert' )->text(), 'invert', 'nsinvert',
529 $opts['invert'],
530 array( 'title' => $this->msg( 'tooltip-invert' )->text() )
531 );
532 $associated = Xml::checkLabel(
533 $this->msg( 'namespace_association' )->text(), 'associated', 'nsassociated',
534 $opts['associated'],
535 array( 'title' => $this->msg( 'tooltip-namespace_association' )->text() )
536 );
537
538 return array( $nsLabel, "$nsSelect $invert $associated" );
539 }
540
541 /**
542 * Create an input to filter changes by categories
543 *
544 * @param FormOptions $opts
545 * @return array
546 */
547 protected function categoryFilterForm( FormOptions $opts ) {
548 list( $label, $input ) = Xml::inputLabelSep( $this->msg( 'rc_categories' )->text(),
549 'categories', 'mw-categories', false, $opts['categories'] );
550
551 $input .= ' ' . Xml::checkLabel( $this->msg( 'rc_categories_any' )->text(),
552 'categories_any', 'mw-categories_any', $opts['categories_any'] );
553
554 return array( $label, $input );
555 }
556
557 /**
558 * Filter $rows by categories set in $opts
559 *
560 * @param ResultWrapper $rows Database rows
561 * @param FormOptions $opts
562 */
563 function filterByCategories( &$rows, FormOptions $opts ) {
564 $categories = array_map( 'trim', explode( '|', $opts['categories'] ) );
565
566 if ( !count( $categories ) ) {
567 return;
568 }
569
570 # Filter categories
571 $cats = array();
572 foreach ( $categories as $cat ) {
573 $cat = trim( $cat );
574 if ( $cat == '' ) {
575 continue;
576 }
577 $cats[] = $cat;
578 }
579
580 # Filter articles
581 $articles = array();
582 $a2r = array();
583 $rowsarr = array();
584 foreach ( $rows as $k => $r ) {
585 $nt = Title::makeTitle( $r->rc_namespace, $r->rc_title );
586 $id = $nt->getArticleID();
587 if ( $id == 0 ) {
588 continue; # Page might have been deleted...
589 }
590 if ( !in_array( $id, $articles ) ) {
591 $articles[] = $id;
592 }
593 if ( !isset( $a2r[$id] ) ) {
594 $a2r[$id] = array();
595 }
596 $a2r[$id][] = $k;
597 $rowsarr[$k] = $r;
598 }
599
600 # Shortcut?
601 if ( !count( $articles ) || !count( $cats ) ) {
602 return;
603 }
604
605 # Look up
606 $catFind = new CategoryFinder;
607 $catFind->seed( $articles, $cats, $opts['categories_any'] ? 'OR' : 'AND' );
608 $match = $catFind->run();
609
610 # Filter
611 $newrows = array();
612 foreach ( $match as $id ) {
613 foreach ( $a2r[$id] as $rev ) {
614 $k = $rev;
615 $newrows[$k] = $rowsarr[$k];
616 }
617 }
618 $rows = $newrows;
619 }
620
621 /**
622 * Makes change an option link which carries all the other options
623 *
624 * @param string $title Title
625 * @param array $override Options to override
626 * @param array $options Current options
627 * @param bool $active Whether to show the link in bold
628 * @return string
629 */
630 function makeOptionsLink( $title, $override, $options, $active = false ) {
631 $params = $override + $options;
632
633 // Bug 36524: false values have be converted to "0" otherwise
634 // wfArrayToCgi() will omit it them.
635 foreach ( $params as &$value ) {
636 if ( $value === false ) {
637 $value = '0';
638 }
639 }
640 unset( $value );
641
642 $text = htmlspecialchars( $title );
643 if ( $active ) {
644 $text = '<strong>' . $text . '</strong>';
645 }
646
647 return Linker::linkKnown( $this->getPageTitle(), $text, array(), $params );
648 }
649
650 /**
651 * Creates the options panel.
652 *
653 * @param array $defaults
654 * @param array $nondefaults
655 * @param int $numRows Number of rows in the result to show after this header
656 * @return string
657 */
658 function optionsPanel( $defaults, $nondefaults, $numRows ) {
659 $options = $nondefaults + $defaults;
660
661 $note = '';
662 $msg = $this->msg( 'rclegend' );
663 if ( !$msg->isDisabled() ) {
664 $note .= '<div class="mw-rclegend">' . $msg->parse() . "</div>\n";
665 }
666
667 $lang = $this->getLanguage();
668 $user = $this->getUser();
669 if ( $options['from'] ) {
670 $note .= $this->msg( 'rcnotefrom' )
671 ->numParams( $options['limit'] )
672 ->params(
673 $lang->userTimeAndDate( $options['from'], $user ),
674 $lang->userDate( $options['from'], $user ),
675 $lang->userTime( $options['from'], $user )
676 )
677 ->numParams( $numRows )
678 ->parse() . '<br />';
679 }
680
681 # Sort data for display and make sure it's unique after we've added user data.
682 $linkLimits = $this->getConfig()->get( 'RCLinkLimits' );
683 $linkLimits[] = $options['limit'];
684 sort( $linkLimits );
685 $linkLimits = array_unique( $linkLimits );
686
687 $linkDays = $this->getConfig()->get( 'RCLinkDays' );
688 $linkDays[] = $options['days'];
689 sort( $linkDays );
690 $linkDays = array_unique( $linkDays );
691
692 // limit links
693 $cl = array();
694 foreach ( $linkLimits as $value ) {
695 $cl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
696 array( 'limit' => $value ), $nondefaults, $value == $options['limit'] );
697 }
698 $cl = $lang->pipeList( $cl );
699
700 // day links, reset 'from' to none
701 $dl = array();
702 foreach ( $linkDays as $value ) {
703 $dl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
704 array( 'days' => $value, 'from' => '' ), $nondefaults, $value == $options['days'] );
705 }
706 $dl = $lang->pipeList( $dl );
707
708 // show/hide links
709 $filters = array(
710 'hideminor' => 'rcshowhideminor',
711 'hidebots' => 'rcshowhidebots',
712 'hideanons' => 'rcshowhideanons',
713 'hideliu' => 'rcshowhideliu',
714 'hidepatrolled' => 'rcshowhidepatr',
715 'hidemyself' => 'rcshowhidemine'
716 );
717
718 $showhide = array( 'show', 'hide' );
719
720 foreach ( $this->getCustomFilters() as $key => $params ) {
721 $filters[$key] = $params['msg'];
722 }
723 // Disable some if needed
724 if ( !$user->useRCPatrol() ) {
725 unset( $filters['hidepatrolled'] );
726 }
727
728 $links = array();
729 foreach ( $filters as $key => $msg ) {
730 // The following messages are used here:
731 // rcshowhideminor-show, rcshowhideminor-hide, rcshowhidebots-show, rcshowhidebots-hide,
732 // rcshowhideanons-show, rcshowhideanons-hide, rcshowhideliu-show, rcshowhideliu-hide,
733 // rcshowhidepatr-show, rcshowhidepatr-hide, rcshowhidemine-show, rcshowhidemine-hide.
734 $linkMessage = $this->msg( $msg . '-' . $showhide[1 - $options[$key]] );
735 // Extensions can define additional filters, but don't need to define the corresponding
736 // messages. If they don't exist, just fall back to 'show' and 'hide'.
737 if ( !$linkMessage->exists() ) {
738 $linkMessage = $this->msg( $showhide[1 - $options[$key]] );
739 }
740
741 $link = $this->makeOptionsLink( $linkMessage->text(),
742 array( $key => 1 - $options[$key] ), $nondefaults );
743 $links[] = "<span class=\"$msg rcshowhideoption\">"
744 . $this->msg( $msg )->rawParams( $link )->escaped() . '</span>';
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 $pipedLinks = '<span class="rcshowhide">' . $lang->pipeList( $links ) . '</span>';
753
754 $rclinks = '<span class="rclinks">' . $this->msg( 'rclinks' )->rawParams( $cl, $dl, $pipedLinks )
755 ->parse() . '</span>';
756
757 $rclistfrom = '<span class="rclistfrom">' . $this->makeOptionsLink(
758 $this->msg( 'rclistfrom' )->rawParams( $now, $timenow, $datenow )->parse(),
759 array( 'from' => $timestamp ),
760 $nondefaults
761 ) . '</span>';
762
763 return "{$note}$rclinks<br />$rclistfrom";
764 }
765
766 public function isIncludable() {
767 return true;
768 }
769 }