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