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