Rename messages from r90670
[mediawiki.git] / includes / specials / SpecialRecentchanges.php
blob4743d6eed8c9914e6b9ed11ffc556269c5fb6fe1
1 <?php
2 /**
3 * Implements Special:Recentchanges
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.
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.
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
20 * @file
21 * @ingroup SpecialPage
24 /**
25 * A special page that lists last changes made to the wiki
27 * @ingroup SpecialPage
29 class SpecialRecentChanges extends IncludableSpecialPage {
30 var $rcOptions, $rcSubpage;
31 protected $customFilters;
33 public function __construct( $name = 'Recentchanges' ) {
34 parent::__construct( $name );
37 /**
38 * Get a FormOptions object containing the default options
40 * @return FormOptions
42 public function getDefaultOptions() {
43 $opts = new FormOptions();
45 $opts->add( 'days', (int)$this->getUser()->getOption( 'rcdays' ) );
46 $opts->add( 'limit', (int)$this->getUser()->getOption( 'rclimit' ) );
47 $opts->add( 'from', '' );
49 $opts->add( 'hideminor', $this->getUser()->getBoolOption( 'hideminor' ) );
50 $opts->add( 'hidebots', true );
51 $opts->add( 'hideanons', false );
52 $opts->add( 'hideliu', false );
53 $opts->add( 'hidepatrolled', $this->getUser()->getBoolOption( 'hidepatrolled' ) );
54 $opts->add( 'hidemyself', false );
56 $opts->add( 'namespace', '', FormOptions::INTNULL );
57 $opts->add( 'invert', false );
58 $opts->add( 'associated', false );
60 $opts->add( 'categories', '' );
61 $opts->add( 'categories_any', false );
62 $opts->add( 'tagfilter', '' );
63 return $opts;
66 /**
67 * Create a FormOptions object with options as specified by the user
69 * @param $parameters array
71 * @return FormOptions
73 public function setup( $parameters ) {
74 global $wgRequest;
76 $opts = $this->getDefaultOptions();
78 $this->customFilters = array();
79 wfRunHooks( 'SpecialRecentChangesFilters', array( $this, &$this->customFilters ) );
80 foreach( $this->customFilters as $key => $params ) {
81 $opts->add( $key, $params['default'] );
84 $opts->fetchValuesFromRequest( $wgRequest );
86 // Give precedence to subpage syntax
87 if( $parameters !== null ) {
88 $this->parseParameters( $parameters, $opts );
91 $opts->validateIntBounds( 'limit', 0, 5000 );
92 return $opts;
95 /**
96 * Create a FormOptions object specific for feed requests and return it
98 * @return FormOptions
100 public function feedSetup() {
101 global $wgFeedLimit, $wgRequest;
102 $opts = $this->getDefaultOptions();
103 # Feed is cached on limit,hideminor,namespace; other params would randomly not work
104 $opts->fetchValuesFromRequest( $wgRequest, array( 'limit', 'hideminor', 'namespace' ) );
105 $opts->validateIntBounds( 'limit', 0, $wgFeedLimit );
106 return $opts;
110 * Get the current FormOptions for this request
112 public function getOptions() {
113 if ( $this->rcOptions === null ) {
114 global $wgRequest;
115 $feedFormat = $wgRequest->getVal( 'feed' );
116 $this->rcOptions = $feedFormat ? $this->feedSetup() : $this->setup( $this->rcSubpage );
118 return $this->rcOptions;
123 * Main execution point
125 * @param $subpage String
127 public function execute( $subpage ) {
128 global $wgRequest, $wgOut;
129 $this->rcSubpage = $subpage;
130 $feedFormat = $wgRequest->getVal( 'feed' );
132 # 10 seconds server-side caching max
133 $wgOut->setSquidMaxage( 10 );
134 # Check if the client has a cached version
135 $lastmod = $this->checkLastModified( $feedFormat );
136 if( $lastmod === false ) {
137 return;
140 $opts = $this->getOptions();
141 $this->setHeaders();
142 $this->outputHeader();
144 // Fetch results, prepare a batch link existence check query
145 $conds = $this->buildMainQueryConds( $opts );
146 $rows = $this->doMainQuery( $conds, $opts );
147 if( $rows === false ){
148 if( !$this->including() ) {
149 $this->doHeader( $opts );
151 return;
154 if( !$feedFormat ) {
155 $batch = new LinkBatch;
156 foreach( $rows as $row ) {
157 $batch->add( NS_USER, $row->rc_user_text );
158 $batch->add( NS_USER_TALK, $row->rc_user_text );
159 $batch->add( $row->rc_namespace, $row->rc_title );
161 $batch->execute();
163 if( $feedFormat ) {
164 list( $changesFeed, $formatter ) = $this->getFeedObject( $feedFormat );
165 $changesFeed->execute( $formatter, $rows, $lastmod, $opts );
166 } else {
167 $this->webOutput( $rows, $opts );
170 $rows->free();
174 * Return an array with a ChangesFeed object and ChannelFeed object
176 * @return Array
178 public function getFeedObject( $feedFormat ){
179 $changesFeed = new ChangesFeed( $feedFormat, 'rcfeed' );
180 $formatter = $changesFeed->getFeedObject(
181 wfMsgForContent( 'recentchanges' ),
182 wfMsgForContent( 'recentchanges-feed-description' ),
183 $this->getTitle()->getFullURL()
185 return array( $changesFeed, $formatter );
189 * Process $par and put options found if $opts
190 * Mainly used when including the page
192 * @param $par String
193 * @param $opts FormOptions
195 public function parseParameters( $par, FormOptions $opts ) {
196 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
197 foreach( $bits as $bit ) {
198 if( 'hidebots' === $bit ) {
199 $opts['hidebots'] = true;
201 if( 'bots' === $bit ) {
202 $opts['hidebots'] = false;
204 if( 'hideminor' === $bit ) {
205 $opts['hideminor'] = true;
207 if( 'minor' === $bit ) {
208 $opts['hideminor'] = false;
210 if( 'hideliu' === $bit ) {
211 $opts['hideliu'] = true;
213 if( 'hidepatrolled' === $bit ) {
214 $opts['hidepatrolled'] = true;
216 if( 'hideanons' === $bit ) {
217 $opts['hideanons'] = true;
219 if( 'hidemyself' === $bit ) {
220 $opts['hidemyself'] = true;
223 if( is_numeric( $bit ) ) {
224 $opts['limit'] = $bit;
227 $m = array();
228 if( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
229 $opts['limit'] = $m[1];
231 if( preg_match( '/^days=(\d+)$/', $bit, $m ) ) {
232 $opts['days'] = $m[1];
238 * Get last modified date, for client caching
239 * Don't use this if we are using the patrol feature, patrol changes don't
240 * update the timestamp
242 * @param $feedFormat String
243 * @return String or false
245 public function checkLastModified( $feedFormat ) {
246 $dbr = wfGetDB( DB_SLAVE );
247 $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __METHOD__ );
248 if( $feedFormat || !$this->getUser()->useRCPatrol() ) {
249 if( $lastmod && $this->getOutput()->checkLastModified( $lastmod ) ) {
250 # Client cache fresh and headers sent, nothing more to do.
251 return false;
254 return $lastmod;
258 * Return an array of conditions depending of options set in $opts
260 * @param $opts FormOptions
261 * @return array
263 public function buildMainQueryConds( FormOptions $opts ) {
264 $dbr = wfGetDB( DB_SLAVE );
265 $conds = array();
267 # It makes no sense to hide both anons and logged-in users
268 # Where this occurs, force anons to be shown
269 $forcebot = false;
270 if( $opts['hideanons'] && $opts['hideliu'] ){
271 # Check if the user wants to show bots only
272 if( $opts['hidebots'] ){
273 $opts['hideanons'] = false;
274 } else {
275 $forcebot = true;
276 $opts['hidebots'] = false;
280 // Calculate cutoff
281 $cutoff_unixtime = time() - ( $opts['days'] * 86400 );
282 $cutoff_unixtime = $cutoff_unixtime - ($cutoff_unixtime % 86400);
283 $cutoff = $dbr->timestamp( $cutoff_unixtime );
285 $fromValid = preg_match('/^[0-9]{14}$/', $opts['from']);
286 if( $fromValid && $opts['from'] > wfTimestamp(TS_MW,$cutoff) ) {
287 $cutoff = $dbr->timestamp($opts['from']);
288 } else {
289 $opts->reset( 'from' );
292 $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
295 $hidePatrol = $this->getUser()->useRCPatrol() && $opts['hidepatrolled'];
296 $hideLoggedInUsers = $opts['hideliu'] && !$forcebot;
297 $hideAnonymousUsers = $opts['hideanons'] && !$forcebot;
299 if( $opts['hideminor'] ) {
300 $conds['rc_minor'] = 0;
302 if( $opts['hidebots'] ) {
303 $conds['rc_bot'] = 0;
305 if( $hidePatrol ) {
306 $conds['rc_patrolled'] = 0;
308 if( $forcebot ) {
309 $conds['rc_bot'] = 1;
311 if( $hideLoggedInUsers ) {
312 $conds[] = 'rc_user = 0';
314 if( $hideAnonymousUsers ) {
315 $conds[] = 'rc_user != 0';
318 if( $opts['hidemyself'] ) {
319 if( $this->getUser()->getId() ) {
320 $conds[] = 'rc_user != ' . $dbr->addQuotes( $this->getUser()->getId() );
321 } else {
322 $conds[] = 'rc_user_text != ' . $dbr->addQuotes( $this->getUser()->getName() );
326 # Namespace filtering
327 if( $opts['namespace'] !== '' ) {
328 $namespaces[] = $opts['namespace'];
330 $inversionSuffix = $opts['invert'] ? '!' : '';
332 if( $opts['associated'] ) {
333 # namespace association (bug 2429)
334 $namespaces[] = MWNamespace::getAssociated( $opts['namespace'] );
337 $condition = $dbr->makeList(
338 array( 'rc_namespace' . $inversionSuffix
339 => $namespaces ),
340 LIST_AND
343 $conds[] = $condition;
346 return $conds;
350 * Process the query
352 * @param $conds Array
353 * @param $opts FormOptions
354 * @return database result or false (for Recentchangeslinked only)
356 public function doMainQuery( $conds, $opts ) {
357 $tables = array( 'recentchanges' );
358 $join_conds = array();
359 $query_options = array(
360 'USE INDEX' => array( 'recentchanges' => 'rc_timestamp' )
363 $uid = $this->getUser()->getId();
364 $dbr = wfGetDB( DB_SLAVE );
365 $limit = $opts['limit'];
366 $namespace = $opts['namespace'];
367 $invert = $opts['invert'];
369 $fields = array( $dbr->tableName( 'recentchanges' ) . '.*' ); // all rc columns
370 // JOIN on watchlist for users
371 if ( $uid ) {
372 $tables[] = 'watchlist';
373 $fields[] = 'wl_user';
374 $fields[] = 'wl_notificationtimestamp';
375 $join_conds['watchlist'] = array('LEFT JOIN',
376 "wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace");
378 if ( $this->getUser()->isAllowed( 'rollback' ) ) {
379 $tables[] = 'page';
380 $fields[] = 'page_latest';
381 $join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id');
383 if ( !$this->including() ) {
384 // Tag stuff.
385 // Doesn't work when transcluding. See bug 23293
386 ChangeTags::modifyDisplayQuery(
387 $tables, $fields, $conds, $join_conds, $query_options,
388 $opts['tagfilter']
392 if ( !wfRunHooks( 'SpecialRecentChangesQuery',
393 array( &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ) ) )
395 return false;
398 // Don't use the new_namespace_time timestamp index if:
399 // (a) "All namespaces" selected
400 // (b) We want all pages NOT in a certain namespaces (inverted)
401 // (c) There is a tag to filter on (use tag index instead)
402 // (d) UNION + sort/limit is not an option for the DBMS
403 if( is_null( $namespace )
404 || ( $invert && !is_null( $namespace ) )
405 || $opts['tagfilter'] != ''
406 || !$dbr->unionSupportsOrderAndLimit() )
408 $res = $dbr->select( $tables, $fields, $conds, __METHOD__,
409 array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit ) +
410 $query_options,
411 $join_conds );
412 // We have a new_namespace_time index! UNION over new=(0,1) and sort result set!
413 } else {
414 // New pages
415 $sqlNew = $dbr->selectSQLText(
416 $tables,
417 $fields,
418 array( 'rc_new' => 1 ) + $conds,
419 __METHOD__,
420 array(
421 'ORDER BY' => 'rc_timestamp DESC',
422 'LIMIT' => $limit,
423 'USE INDEX' => array( 'recentchanges' => 'rc_timestamp' )
425 $join_conds
427 // Old pages
428 $sqlOld = $dbr->selectSQLText(
429 $tables,
430 $fields,
431 array( 'rc_new' => 0 ) + $conds,
432 __METHOD__,
433 array(
434 'ORDER BY' => 'rc_timestamp DESC',
435 'LIMIT' => $limit,
436 'USE INDEX' => array( 'recentchanges' => 'rc_timestamp' )
438 $join_conds
440 # Join the two fast queries, and sort the result set
441 $sql = $dbr->unionQueries( array( $sqlNew, $sqlOld ), false ) .
442 ' ORDER BY rc_timestamp DESC';
443 $sql = $dbr->limitResult( $sql, $limit, false );
444 $res = $dbr->query( $sql, __METHOD__ );
447 return $res;
451 * Send output to $wgOut, only called if not used feeds
453 * @param $rows Array of database rows
454 * @param $opts FormOptions
456 public function webOutput( $rows, $opts ) {
457 global $wgOut, $wgRCShowWatchingUsers, $wgShowUpdatedMarker;
458 global $wgAllowCategorizedRecentChanges;
460 $limit = $opts['limit'];
462 if( !$this->including() ) {
463 // Output options box
464 $this->doHeader( $opts );
467 // And now for the content
468 $wgOut->setFeedAppendQuery( $this->getFeedQuery() );
470 if( $wgAllowCategorizedRecentChanges ) {
471 $this->filterByCategories( $rows, $opts );
474 $showWatcherCount = $wgRCShowWatchingUsers && $this->getUser()->getOption( 'shownumberswatching' );
475 $watcherCache = array();
477 $dbr = wfGetDB( DB_SLAVE );
479 $counter = 1;
480 $list = ChangesList::newFromUser( $this->getUser() );
482 $s = $list->beginRecentChangesList();
483 foreach( $rows as $obj ) {
484 if( $limit == 0 ) {
485 break;
487 $rc = RecentChange::newFromRow( $obj );
488 $rc->counter = $counter++;
489 # Check if the page has been updated since the last visit
490 if( $wgShowUpdatedMarker && !empty( $obj->wl_notificationtimestamp ) ) {
491 $rc->notificationtimestamp = ( $obj->rc_timestamp >= $obj->wl_notificationtimestamp );
492 } else {
493 $rc->notificationtimestamp = false; // Default
495 # Check the number of users watching the page
496 $rc->numberofWatchingusers = 0; // Default
497 if( $showWatcherCount && $obj->rc_namespace >= 0 ) {
498 if( !isset( $watcherCache[$obj->rc_namespace][$obj->rc_title] ) ) {
499 $watcherCache[$obj->rc_namespace][$obj->rc_title] =
500 $dbr->selectField(
501 'watchlist',
502 'COUNT(*)',
503 array(
504 'wl_namespace' => $obj->rc_namespace,
505 'wl_title' => $obj->rc_title,
507 __METHOD__ . '-watchers'
510 $rc->numberofWatchingusers = $watcherCache[$obj->rc_namespace][$obj->rc_title];
512 $s .= $list->recentChangesLine( $rc, !empty( $obj->wl_user ), $counter );
513 --$limit;
515 $s .= $list->endRecentChangesList();
516 $wgOut->addHTML( $s );
520 * Get the query string to append to feed link URLs.
521 * This is overridden by RCL to add the target parameter
523 public function getFeedQuery() {
524 return false;
528 * Return the text to be displayed above the changes
530 * @param $opts FormOptions
531 * @return String: XHTML
533 public function doHeader( $opts ) {
534 global $wgScript, $wgOut;
536 $this->setTopText( $wgOut, $opts );
538 $defaults = $opts->getAllValues();
539 $nondefaults = $opts->getChangedValues();
540 $opts->consumeValues( array(
541 'namespace', 'invert', 'associated', 'tagfilter',
542 'categories', 'categories_any'
543 ) );
545 $panel = array();
546 $panel[] = $this->optionsPanel( $defaults, $nondefaults );
547 $panel[] = '<hr />';
549 $extraOpts = $this->getExtraOptions( $opts );
550 $extraOptsCount = count( $extraOpts );
551 $count = 0;
552 $submit = ' ' . Xml::submitbutton( wfMsg( 'allpagessubmit' ) );
554 $out = Xml::openElement( 'table', array( 'class' => 'mw-recentchanges-table' ) );
555 foreach( $extraOpts as $optionRow ) {
556 # Add submit button to the last row only
557 ++$count;
558 $addSubmit = $count === $extraOptsCount ? $submit : '';
560 $out .= Xml::openElement( 'tr' );
561 if( is_array( $optionRow ) ) {
562 $out .= Xml::tags( 'td', array( 'class' => 'mw-label' ), $optionRow[0] );
563 $out .= Xml::tags( 'td', array( 'class' => 'mw-input' ), $optionRow[1] . $addSubmit );
564 } else {
565 $out .= Xml::tags( 'td', array( 'class' => 'mw-input', 'colspan' => 2 ), $optionRow . $addSubmit );
567 $out .= Xml::closeElement( 'tr' );
569 $out .= Xml::closeElement( 'table' );
571 $unconsumed = $opts->getUnconsumedValues();
572 foreach( $unconsumed as $key => $value ) {
573 $out .= Html::hidden( $key, $value );
576 $t = $this->getTitle();
577 $out .= Html::hidden( 'title', $t->getPrefixedText() );
578 $form = Xml::tags( 'form', array( 'action' => $wgScript ), $out );
579 $panel[] = $form;
580 $panelString = implode( "\n", $panel );
582 $wgOut->addHTML(
583 Xml::fieldset( wfMsg( 'recentchanges-legend' ), $panelString, array( 'class' => 'rcoptions' ) )
586 $this->setBottomText( $wgOut, $opts );
590 * Get options to be displayed in a form
592 * @param $opts FormOptions
593 * @return Array
595 function getExtraOptions( $opts ) {
596 $extraOpts = array();
597 $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
599 global $wgAllowCategorizedRecentChanges;
600 if( $wgAllowCategorizedRecentChanges ) {
601 $extraOpts['category'] = $this->categoryFilterForm( $opts );
604 $tagFilter = ChangeTags::buildTagFilterSelector( $opts['tagfilter'] );
605 if ( count( $tagFilter ) ) {
606 $extraOpts['tagfilter'] = $tagFilter;
609 wfRunHooks( 'SpecialRecentChangesPanel', array( &$extraOpts, $opts ) );
610 return $extraOpts;
614 * Send the text to be displayed above the options
616 * @param $out OutputPage
617 * @param $opts FormOptions
619 function setTopText( OutputPage $out, FormOptions $opts ) {
620 $out->addWikiText( wfMsgForContentNoTrans( 'recentchangestext' ) );
624 * Send the text to be displayed after the options, for use in
625 * Recentchangeslinked
627 * @param $out OutputPage
628 * @param $opts FormOptions
630 function setBottomText( OutputPage $out, FormOptions $opts ) {}
633 * Creates the choose namespace selection
635 * @todo Uses radio buttons (HASHAR)
636 * @param $opts FormOptions
637 * @return String
639 protected function namespaceFilterForm( FormOptions $opts ) {
640 $nsSelect = Xml::namespaceSelector( $opts['namespace'], '' );
641 $nsLabel = Xml::label( wfMsg( 'namespace' ), 'namespace' );
642 $invert = Xml::checkLabel(
643 wfMsg( 'invert' ), 'invert', 'nsinvert',
644 $opts['invert'],
645 array( 'title' => wfMsg( 'tooltip-invert' ) )
647 $associated = Xml::checkLabel(
648 wfMsg( 'namespace_association' ), 'associated', 'nsassociated',
649 $opts['associated'],
650 array( 'title' => wfMsg( 'tooltip-namespace_association' ) )
652 return array( $nsLabel, "$nsSelect $invert $associated" );
656 * Create a input to filter changes by categories
658 * @param $opts FormOptions
659 * @return Array
661 protected function categoryFilterForm( FormOptions $opts ) {
662 list( $label, $input ) = Xml::inputLabelSep( wfMsg( 'rc_categories' ),
663 'categories', 'mw-categories', false, $opts['categories'] );
665 $input .= ' ' . Xml::checkLabel( wfMsg( 'rc_categories_any' ),
666 'categories_any', 'mw-categories_any', $opts['categories_any'] );
668 return array( $label, $input );
672 * Filter $rows by categories set in $opts
674 * @param $rows Array of database rows
675 * @param $opts FormOptions
677 function filterByCategories( &$rows, FormOptions $opts ) {
678 $categories = array_map( 'trim', explode( '|' , $opts['categories'] ) );
680 if( !count( $categories ) ) {
681 return;
684 # Filter categories
685 $cats = array();
686 foreach( $categories as $cat ) {
687 $cat = trim( $cat );
688 if( $cat == '' ) {
689 continue;
691 $cats[] = $cat;
694 # Filter articles
695 $articles = array();
696 $a2r = array();
697 $rowsarr = array();
698 foreach( $rows as $k => $r ) {
699 $nt = Title::makeTitle( $r->rc_namespace, $r->rc_title );
700 $id = $nt->getArticleID();
701 if( $id == 0 ) {
702 continue; # Page might have been deleted...
704 if( !in_array( $id, $articles ) ) {
705 $articles[] = $id;
707 if( !isset( $a2r[$id] ) ) {
708 $a2r[$id] = array();
710 $a2r[$id][] = $k;
711 $rowsarr[$k] = $r;
714 # Shortcut?
715 if( !count( $articles ) || !count( $cats ) ) {
716 return;
719 # Look up
720 $c = new Categoryfinder;
721 $c->seed( $articles, $cats, $opts['categories_any'] ? 'OR' : 'AND' );
722 $match = $c->run();
724 # Filter
725 $newrows = array();
726 foreach( $match as $id ) {
727 foreach( $a2r[$id] as $rev ) {
728 $k = $rev;
729 $newrows[$k] = $rowsarr[$k];
732 $rows = $newrows;
736 * Makes change an option link which carries all the other options
738 * @param $title Title
739 * @param $override Array: options to override
740 * @param $options Array: current options
741 * @param $active Boolean: whether to show the link in bold
743 function makeOptionsLink( $title, $override, $options, $active = false ) {
744 $params = $override + $options;
745 if ( $active ) {
746 return $this->getSkin()->link(
747 $this->getTitle(),
748 '<strong>' . htmlspecialchars( $title ) . '</strong>',
749 array(), $params, array( 'known' ) );
750 } else {
751 return $this->getSkin()->link(
752 $this->getTitle(), htmlspecialchars( $title ), array(),
753 $params, array( 'known' ) );
758 * Creates the options panel.
760 * @param $defaults Array
761 * @param $nondefaults Array
763 function optionsPanel( $defaults, $nondefaults ) {
764 global $wgLang, $wgRCLinkLimits, $wgRCLinkDays;
766 $options = $nondefaults + $defaults;
768 $note = '';
769 if( !wfEmptyMsg( 'rclegend' ) ) {
770 $note .= '<div class="mw-rclegend">' .
771 wfMsgExt( 'rclegend', array( 'parseinline' ) ) . "</div>\n";
773 if( $options['from'] ) {
774 $note .= wfMsgExt( 'rcnotefrom', array( 'parseinline' ),
775 $wgLang->formatNum( $options['limit'] ),
776 $wgLang->timeanddate( $options['from'], true ),
777 $wgLang->date( $options['from'], true ),
778 $wgLang->time( $options['from'], true ) ) . '<br />';
781 # Sort data for display and make sure it's unique after we've added user data.
782 $wgRCLinkLimits[] = $options['limit'];
783 $wgRCLinkDays[] = $options['days'];
784 sort( $wgRCLinkLimits );
785 sort( $wgRCLinkDays );
786 $wgRCLinkLimits = array_unique( $wgRCLinkLimits );
787 $wgRCLinkDays = array_unique( $wgRCLinkDays );
789 // limit links
790 foreach( $wgRCLinkLimits as $value ) {
791 $cl[] = $this->makeOptionsLink( $wgLang->formatNum( $value ),
792 array( 'limit' => $value ), $nondefaults, $value == $options['limit'] );
794 $cl = $wgLang->pipeList( $cl );
796 // day links, reset 'from' to none
797 foreach( $wgRCLinkDays as $value ) {
798 $dl[] = $this->makeOptionsLink( $wgLang->formatNum( $value ),
799 array( 'days' => $value, 'from' => '' ), $nondefaults, $value == $options['days'] );
801 $dl = $wgLang->pipeList( $dl );
804 // show/hide links
805 $showhide = array( wfMsg( 'show' ), wfMsg( 'hide' ) );
806 $filters = array(
807 'hideminor' => 'rcshowhideminor',
808 'hidebots' => 'rcshowhidebots',
809 'hideanons' => 'rcshowhideanons',
810 'hideliu' => 'rcshowhideliu',
811 'hidepatrolled' => 'rcshowhidepatr',
812 'hidemyself' => 'rcshowhidemine'
814 foreach ( $this->customFilters as $key => $params ) {
815 $filters[$key] = $params['msg'];
817 // Disable some if needed
818 if ( !$this->getUser()->useRCPatrol() ) {
819 unset( $filters['hidepatrolled'] );
822 $links = array();
823 foreach ( $filters as $key => $msg ) {
824 $link = $this->makeOptionsLink( $showhide[1 - $options[$key]],
825 array( $key => 1-$options[$key] ), $nondefaults );
826 $links[] = wfMsgHtml( $msg, $link );
829 // show from this onward link
830 $timestamp = wfTimestampNow();
831 $now = $wgLang->timeanddate( $timestamp, true );
832 $tl = $this->makeOptionsLink(
833 $now, array( 'from' => $timestamp ), $nondefaults
836 $rclinks = wfMsgExt( 'rclinks', array( 'parseinline', 'replaceafter' ),
837 $cl, $dl, $wgLang->pipeList( $links ) );
838 $rclistfrom = wfMsgExt( 'rclistfrom', array( 'parseinline', 'replaceafter' ), $tl );
839 return "{$note}$rclinks<br />$rclistfrom";