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