GPL Headers for all!
[lhc/web/wiklou.git] / includes / specials / SpecialRecentchanges.php
1 <?php
2 /**
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 * http://www.gnu.org/copyleft/gpl.html
18 */
19
20 /**
21 * Implements Special:Recentchanges
22 * @ingroup SpecialPage
23 */
24 class SpecialRecentChanges extends SpecialPage {
25 var $rcOptions, $rcSubpage;
26
27 public function __construct() {
28 parent::__construct( 'Recentchanges' );
29 $this->includable( true );
30 }
31
32 /**
33 * Get a FormOptions object containing the default options
34 *
35 * @return FormOptions
36 */
37 public function getDefaultOptions() {
38 global $wgUser;
39 $opts = new FormOptions();
40
41 $opts->add( 'days', (int)$wgUser->getOption( 'rcdays' ) );
42 $opts->add( 'limit', (int)$wgUser->getOption( 'rclimit' ) );
43 $opts->add( 'from', '' );
44
45 $opts->add( 'hideminor', $wgUser->getBoolOption( 'hideminor' ) );
46 $opts->add( 'hidebots', true );
47 $opts->add( 'hideanons', false );
48 $opts->add( 'hideliu', false );
49 $opts->add( 'hidepatrolled', $wgUser->getBoolOption( 'hidepatrolled' ) );
50 $opts->add( 'hidemyself', false );
51
52 $opts->add( 'namespace', '', FormOptions::INTNULL );
53 $opts->add( 'invert', false );
54
55 $opts->add( 'categories', '' );
56 $opts->add( 'categories_any', false );
57 $opts->add( 'tagfilter', '' );
58 return $opts;
59 }
60
61 /**
62 * Create a FormOptions object with options as specified by the user
63 *
64 * @return FormOptions
65 */
66 public function setup( $parameters ) {
67 global $wgRequest;
68
69 $opts = $this->getDefaultOptions();
70 $opts->fetchValuesFromRequest( $wgRequest );
71
72 // Give precedence to subpage syntax
73 if( $parameters !== null ) {
74 $this->parseParameters( $parameters, $opts );
75 }
76
77 $opts->validateIntBounds( 'limit', 0, 5000 );
78 return $opts;
79 }
80
81 /**
82 * Create a FormOptions object specific for feed requests and return it
83 *
84 * @return FormOptions
85 */
86 public function feedSetup() {
87 global $wgFeedLimit, $wgRequest;
88 $opts = $this->getDefaultOptions();
89 # Feed is cached on limit,hideminor,namespace; other params would randomly not work
90 $opts->fetchValuesFromRequest( $wgRequest, array( 'limit', 'hideminor', 'namespace' ) );
91 $opts->validateIntBounds( 'limit', 0, $wgFeedLimit );
92 return $opts;
93 }
94
95 /**
96 * Get the current FormOptions for this request
97 */
98 public function getOptions() {
99 if ( $this->rcOptions === null ) {
100 global $wgRequest;
101 $feedFormat = $wgRequest->getVal( 'feed' );
102 $this->rcOptions = $feedFormat ? $this->feedSetup() : $this->setup( $this->rcSubpage );
103 }
104 return $this->rcOptions;
105 }
106
107
108 /**
109 * Main execution point
110 *
111 * @param $subpage string
112 */
113 public function execute( $subpage ) {
114 global $wgRequest, $wgOut;
115 $this->rcSubpage = $subpage;
116 $feedFormat = $wgRequest->getVal( 'feed' );
117
118 # 10 seconds server-side caching max
119 $wgOut->setSquidMaxage( 10 );
120 # Check if the client has a cached version
121 $lastmod = $this->checkLastModified( $feedFormat );
122 if( $lastmod === false ) {
123 return;
124 }
125
126 $opts = $this->getOptions();
127 $this->setHeaders();
128 $this->outputHeader();
129
130 // Fetch results, prepare a batch link existence check query
131 $conds = $this->buildMainQueryConds( $opts );
132 $rows = $this->doMainQuery( $conds, $opts );
133 if( $rows === false ){
134 if( !$this->including() ) {
135 $this->doHeader( $opts );
136 }
137 return;
138 }
139
140 if( !$feedFormat ) {
141 $batch = new LinkBatch;
142 foreach( $rows as $row ) {
143 $batch->add( NS_USER, $row->rc_user_text );
144 $batch->add( NS_USER_TALK, $row->rc_user_text );
145 $batch->add( $row->rc_namespace, $row->rc_title );
146 }
147 $batch->execute();
148 }
149 if( $feedFormat ) {
150 list( $changesFeed, $formatter ) = $this->getFeedObject( $feedFormat );
151 $changesFeed->execute( $formatter, $rows, $lastmod, $opts );
152 } else {
153 $this->webOutput( $rows, $opts );
154 }
155
156 $rows->free();
157 }
158
159 /**
160 * Return an array with a ChangesFeed object and ChannelFeed object
161 *
162 * @return array
163 */
164 public function getFeedObject( $feedFormat ){
165 $changesFeed = new ChangesFeed( $feedFormat, 'rcfeed' );
166 $formatter = $changesFeed->getFeedObject(
167 wfMsgForContent( 'recentchanges' ),
168 wfMsgForContent( 'recentchanges-feed-description' )
169 );
170 return array( $changesFeed, $formatter );
171 }
172
173 /**
174 * Process $par and put options found if $opts
175 * Mainly used when including the page
176 *
177 * @param $par String
178 * @param $opts FormOptions
179 */
180 public function parseParameters( $par, FormOptions $opts ) {
181 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
182 foreach( $bits as $bit ) {
183 if( 'hidebots' === $bit ) $opts['hidebots'] = true;
184 if( 'bots' === $bit ) $opts['hidebots'] = false;
185 if( 'hideminor' === $bit ) $opts['hideminor'] = true;
186 if( 'minor' === $bit ) $opts['hideminor'] = false;
187 if( 'hideliu' === $bit ) $opts['hideliu'] = true;
188 if( 'hidepatrolled' === $bit ) $opts['hidepatrolled'] = true;
189 if( 'hideanons' === $bit ) $opts['hideanons'] = true;
190 if( 'hidemyself' === $bit ) $opts['hidemyself'] = true;
191
192 if( is_numeric( $bit ) ) $opts['limit'] = $bit;
193
194 $m = array();
195 if( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) $opts['limit'] = $m[1];
196 if( preg_match( '/^days=(\d+)$/', $bit, $m ) ) $opts['days'] = $m[1];
197 }
198 }
199
200 /**
201 * Get last modified date, for client caching
202 * Don't use this if we are using the patrol feature, patrol changes don't
203 * update the timestamp
204 *
205 * @param $feedFormat String
206 * @return string or false
207 */
208 public function checkLastModified( $feedFormat ) {
209 global $wgUseRCPatrol, $wgOut;
210 $dbr = wfGetDB( DB_SLAVE );
211 $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __METHOD__ );
212 if( $feedFormat || !$wgUseRCPatrol ) {
213 if( $lastmod && $wgOut->checkLastModified( $lastmod ) ) {
214 # Client cache fresh and headers sent, nothing more to do.
215 return false;
216 }
217 }
218 return $lastmod;
219 }
220
221 /**
222 * Return an array of conditions depending of options set in $opts
223 *
224 * @param $opts FormOptions
225 * @return array
226 */
227 public function buildMainQueryConds( FormOptions $opts ) {
228 global $wgUser;
229
230 $dbr = wfGetDB( DB_SLAVE );
231 $conds = array();
232
233 # It makes no sense to hide both anons and logged-in users
234 # Where this occurs, force anons to be shown
235 $forcebot = false;
236 if( $opts['hideanons'] && $opts['hideliu'] ){
237 # Check if the user wants to show bots only
238 if( $opts['hidebots'] ){
239 $opts['hideanons'] = false;
240 } else {
241 $forcebot = true;
242 $opts['hidebots'] = false;
243 }
244 }
245
246 // Calculate cutoff
247 $cutoff_unixtime = time() - ( $opts['days'] * 86400 );
248 $cutoff_unixtime = $cutoff_unixtime - ($cutoff_unixtime % 86400);
249 $cutoff = $dbr->timestamp( $cutoff_unixtime );
250
251 $fromValid = preg_match('/^[0-9]{14}$/', $opts['from']);
252 if( $fromValid && $opts['from'] > wfTimestamp(TS_MW,$cutoff) ) {
253 $cutoff = $dbr->timestamp($opts['from']);
254 } else {
255 $opts->reset( 'from' );
256 }
257
258 $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
259
260
261 $hidePatrol = $wgUser->useRCPatrol() && $opts['hidepatrolled'];
262 $hideLoggedInUsers = $opts['hideliu'] && !$forcebot;
263 $hideAnonymousUsers = $opts['hideanons'] && !$forcebot;
264
265 if( $opts['hideminor'] ) $conds['rc_minor'] = 0;
266 if( $opts['hidebots'] ) $conds['rc_bot'] = 0;
267 if( $hidePatrol ) $conds['rc_patrolled'] = 0;
268 if( $forcebot ) $conds['rc_bot'] = 1;
269 if( $hideLoggedInUsers ) $conds[] = 'rc_user = 0';
270 if( $hideAnonymousUsers ) $conds[] = 'rc_user != 0';
271
272 if( $opts['hidemyself'] ) {
273 if( $wgUser->getId() ) {
274 $conds[] = 'rc_user != ' . $dbr->addQuotes( $wgUser->getId() );
275 } else {
276 $conds[] = 'rc_user_text != ' . $dbr->addQuotes( $wgUser->getName() );
277 }
278 }
279
280 # Namespace filtering
281 if( $opts['namespace'] !== '' ) {
282 if( !$opts['invert'] ) {
283 $conds[] = 'rc_namespace = ' . $dbr->addQuotes( $opts['namespace'] );
284 } else {
285 $conds[] = 'rc_namespace != ' . $dbr->addQuotes( $opts['namespace'] );
286 }
287 }
288
289 return $conds;
290 }
291
292 /**
293 * Process the query
294 *
295 * @param $conds array
296 * @param $opts FormOptions
297 * @return database result or false (for Recentchangeslinked only)
298 */
299 public function doMainQuery( $conds, $opts ) {
300 global $wgUser;
301
302 $tables = array( 'recentchanges' );
303 $join_conds = array();
304 $query_options = array( 'USE INDEX' => array('recentchanges' => 'rc_timestamp') );
305
306 $uid = $wgUser->getId();
307 $dbr = wfGetDB( DB_SLAVE );
308 $limit = $opts['limit'];
309 $namespace = $opts['namespace'];
310 $invert = $opts['invert'];
311
312 // JOIN on watchlist for users
313 if( $uid ) {
314 $tables[] = 'watchlist';
315 $join_conds['watchlist'] = array('LEFT JOIN',
316 "wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace");
317 }
318 if ($wgUser->isAllowed("rollback")) {
319 $tables[] = 'page';
320 $join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id');
321 }
322 // Tag stuff.
323 $fields = array();
324 // Fields are * in this case, so let the function modify an empty array to keep it happy.
325 ChangeTags::modifyDisplayQuery(
326 $tables, $fields, $conds, $join_conds, $query_options, $opts['tagfilter']
327 );
328
329 if ( !wfRunHooks( 'SpecialRecentChangesQuery', array( &$conds, &$tables, &$join_conds, $opts, &$query_options ) ) )
330 return false;
331
332 // Don't use the new_namespace_time timestamp index if:
333 // (a) "All namespaces" selected
334 // (b) We want all pages NOT in a certain namespaces (inverted)
335 // (c) There is a tag to filter on (use tag index instead)
336 // (d) UNION + sort/limit is not an option for the DBMS
337 if( is_null($namespace)
338 || $invert
339 || $opts['tagfilter'] != ''
340 || !$dbr->unionSupportsOrderAndLimit() )
341 {
342 $res = $dbr->select( $tables, '*', $conds, __METHOD__,
343 array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit ) +
344 $query_options,
345 $join_conds );
346 // We have a new_namespace_time index! UNION over new=(0,1) and sort result set!
347 } else {
348 // New pages
349 $sqlNew = $dbr->selectSQLText( $tables, '*',
350 array( 'rc_new' => 1 ) + $conds,
351 __METHOD__,
352 array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit,
353 'USE INDEX' => array('recentchanges' => 'rc_timestamp') ),
354 $join_conds );
355 // Old pages
356 $sqlOld = $dbr->selectSQLText( $tables, '*',
357 array( 'rc_new' => 0 ) + $conds,
358 __METHOD__,
359 array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit,
360 'USE INDEX' => array('recentchanges' => 'rc_timestamp') ),
361 $join_conds );
362 # Join the two fast queries, and sort the result set
363 $sql = $dbr->unionQueries(array($sqlNew, $sqlOld), false).' ORDER BY rc_timestamp DESC';
364 $sql = $dbr->limitResult($sql, $limit, false);
365 $res = $dbr->query( $sql, __METHOD__ );
366 }
367
368 return $res;
369 }
370
371 /**
372 * Send output to $wgOut, only called if not used feeds
373 *
374 * @param $rows array of database rows
375 * @param $opts FormOptions
376 */
377 public function webOutput( $rows, $opts ) {
378 global $wgOut, $wgUser, $wgRCShowWatchingUsers, $wgShowUpdatedMarker;
379 global $wgAllowCategorizedRecentChanges;
380
381 $limit = $opts['limit'];
382
383 if( !$this->including() ) {
384 // Output options box
385 $this->doHeader( $opts );
386 }
387
388 // And now for the content
389 $wgOut->setFeedAppendQuery( $this->getFeedQuery() );
390
391 if( $wgAllowCategorizedRecentChanges ) {
392 $this->filterByCategories( $rows, $opts );
393 }
394
395 $showWatcherCount = $wgRCShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' );
396 $watcherCache = array();
397
398 $dbr = wfGetDB( DB_SLAVE );
399
400 $counter = 1;
401 $list = ChangesList::newFromUser( $wgUser );
402
403 $s = $list->beginRecentChangesList();
404 foreach( $rows as $obj ) {
405 if( $limit == 0 ) break;
406 $rc = RecentChange::newFromRow( $obj );
407 $rc->counter = $counter++;
408 # Check if the page has been updated since the last visit
409 if( $wgShowUpdatedMarker && !empty($obj->wl_notificationtimestamp) ) {
410 $rc->notificationtimestamp = ($obj->rc_timestamp >= $obj->wl_notificationtimestamp);
411 } else {
412 $rc->notificationtimestamp = false; // Default
413 }
414 # Check the number of users watching the page
415 $rc->numberofWatchingusers = 0; // Default
416 if( $showWatcherCount && $obj->rc_namespace >= 0 ) {
417 if( !isset($watcherCache[$obj->rc_namespace][$obj->rc_title]) ) {
418 $watcherCache[$obj->rc_namespace][$obj->rc_title] =
419 $dbr->selectField( 'watchlist',
420 'COUNT(*)',
421 array(
422 'wl_namespace' => $obj->rc_namespace,
423 'wl_title' => $obj->rc_title,
424 ),
425 __METHOD__ . '-watchers' );
426 }
427 $rc->numberofWatchingusers = $watcherCache[$obj->rc_namespace][$obj->rc_title];
428 }
429 $s .= $list->recentChangesLine( $rc, !empty( $obj->wl_user ), $counter );
430 --$limit;
431 }
432 $s .= $list->endRecentChangesList();
433 $wgOut->addHTML( $s );
434 }
435
436 /**
437 * Get the query string to append to feed link URLs.
438 * This is overridden by RCL to add the target parameter
439 */
440 public function getFeedQuery() {
441 return false;
442 }
443
444 /**
445 * Return the text to be displayed above the changes
446 *
447 * @param $opts FormOptions
448 * @return String: XHTML
449 */
450 public function doHeader( $opts ) {
451 global $wgScript, $wgOut;
452
453 $this->setTopText( $wgOut, $opts );
454
455 $defaults = $opts->getAllValues();
456 $nondefaults = $opts->getChangedValues();
457 $opts->consumeValues( array( 'namespace', 'invert', 'tagfilter',
458 'categories', 'categories_any' ) );
459
460 $panel = array();
461 $panel[] = $this->optionsPanel( $defaults, $nondefaults );
462 $panel[] = '<hr />';
463
464 $extraOpts = $this->getExtraOptions( $opts );
465 $extraOptsCount = count( $extraOpts );
466 $count = 0;
467 $submit = ' ' . Xml::submitbutton( wfMsg( 'allpagessubmit' ) );
468
469 $out = Xml::openElement( 'table', array( 'class' => 'mw-recentchanges-table' ) );
470 foreach( $extraOpts as $optionRow ) {
471 # Add submit button to the last row only
472 ++$count;
473 $addSubmit = $count === $extraOptsCount ? $submit : '';
474
475 $out .= Xml::openElement( 'tr' );
476 if( is_array( $optionRow ) ) {
477 $out .= Xml::tags( 'td', array( 'class' => 'mw-label' ), $optionRow[0] );
478 $out .= Xml::tags( 'td', array( 'class' => 'mw-input' ), $optionRow[1] . $addSubmit );
479 } else {
480 $out .= Xml::tags( 'td', array( 'class' => 'mw-input', 'colspan' => 2 ), $optionRow . $addSubmit );
481 }
482 $out .= Xml::closeElement( 'tr' );
483 }
484 $out .= Xml::closeElement( 'table' );
485
486 $unconsumed = $opts->getUnconsumedValues();
487 foreach( $unconsumed as $key => $value ) {
488 $out .= Xml::hidden( $key, $value );
489 }
490
491 $t = $this->getTitle();
492 $out .= Xml::hidden( 'title', $t->getPrefixedText() );
493 $form = Xml::tags( 'form', array( 'action' => $wgScript ), $out );
494 $panel[] = $form;
495 $panelString = implode( "\n", $panel );
496
497 $wgOut->addHTML(
498 Xml::fieldset( wfMsg( 'recentchanges-legend' ), $panelString, array( 'class' => 'rcoptions' ) )
499 );
500
501 $wgOut->addHTML( ChangesList::flagLegend() );
502
503 $this->setBottomText( $wgOut, $opts );
504 }
505
506 /**
507 * Get options to be displayed in a form
508 *
509 * @param $opts FormOptions
510 * @return array
511 */
512 function getExtraOptions( $opts ){
513 $extraOpts = array();
514 $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
515
516 global $wgAllowCategorizedRecentChanges;
517 if( $wgAllowCategorizedRecentChanges ) {
518 $extraOpts['category'] = $this->categoryFilterForm( $opts );
519 }
520
521 $tagFilter = ChangeTags::buildTagFilterSelector( $opts['tagfilter'] );
522 if ( count($tagFilter) )
523 $extraOpts['tagfilter'] = $tagFilter;
524
525 wfRunHooks( 'SpecialRecentChangesPanel', array( &$extraOpts, $opts ) );
526 return $extraOpts;
527 }
528
529 /**
530 * Send the text to be displayed above the options
531 *
532 * @param $out OutputPage
533 * @param $opts FormOptions
534 */
535 function setTopText( OutputPage $out, FormOptions $opts ){
536 $out->addWikiText( wfMsgForContentNoTrans( 'recentchangestext' ) );
537 }
538
539 /**
540 * Send the text to be displayed after the options, for use in
541 * Recentchangeslinked
542 *
543 * @param $out OutputPage
544 * @param $opts FormOptions
545 */
546 function setBottomText( OutputPage $out, FormOptions $opts ){}
547
548 /**
549 * Creates the choose namespace selection
550 *
551 * @param $opts FormOptions
552 * @return string
553 */
554 protected function namespaceFilterForm( FormOptions $opts ) {
555 $nsSelect = Xml::namespaceSelector( $opts['namespace'], '' );
556 $nsLabel = Xml::label( wfMsg('namespace'), 'namespace' );
557 $invert = Xml::checkLabel( wfMsg('invert'), 'invert', 'nsinvert', $opts['invert'] );
558 return array( $nsLabel, "$nsSelect $invert" );
559 }
560
561 /**
562 * Create a input to filter changes by categories
563 *
564 * @param $opts FormOptions
565 * @return array
566 */
567 protected function categoryFilterForm( FormOptions $opts ) {
568 list( $label, $input ) = Xml::inputLabelSep( wfMsg('rc_categories'),
569 'categories', 'mw-categories', false, $opts['categories'] );
570
571 $input .= ' ' . Xml::checkLabel( wfMsg('rc_categories_any'),
572 'categories_any', 'mw-categories_any', $opts['categories_any'] );
573
574 return array( $label, $input );
575 }
576
577 /**
578 * Filter $rows by categories set in $opts
579 *
580 * @param $rows array of database rows
581 * @param $opts FormOptions
582 */
583 function filterByCategories( &$rows, FormOptions $opts ) {
584 $categories = array_map( 'trim', explode( '|' , $opts['categories'] ) );
585
586 if( !count( $categories ) ) {
587 return;
588 }
589
590 # Filter categories
591 $cats = array();
592 foreach( $categories as $cat ) {
593 $cat = trim( $cat );
594 if( $cat == '' ) continue;
595 $cats[] = $cat;
596 }
597
598 # Filter articles
599 $articles = array();
600 $a2r = array();
601 $rowsarr = array();
602 foreach( $rows AS $k => $r ) {
603 $nt = Title::makeTitle( $r->rc_namespace, $r->rc_title );
604 $id = $nt->getArticleID();
605 if( $id == 0 ) continue; # Page might have been deleted...
606 if( !in_array( $id, $articles ) ) {
607 $articles[] = $id;
608 }
609 if( !isset( $a2r[$id] ) ) {
610 $a2r[$id] = array();
611 }
612 $a2r[$id][] = $k;
613 $rowsarr[$k] = $r;
614 }
615
616 # Shortcut?
617 if( !count( $articles ) || !count( $cats ) )
618 return ;
619
620 # Look up
621 $c = new Categoryfinder;
622 $c->seed( $articles, $cats, $opts['categories_any'] ? "OR" : "AND" ) ;
623 $match = $c->run();
624
625 # Filter
626 $newrows = array();
627 foreach( $match AS $id ) {
628 foreach( $a2r[$id] AS $rev ) {
629 $k = $rev;
630 $newrows[$k] = $rowsarr[$k];
631 }
632 }
633 $rows = $newrows;
634 }
635
636 /**
637 * Makes change an option link which carries all the other options
638 * @param $title see Title
639 * @param $override
640 * @param $options
641 */
642 function makeOptionsLink( $title, $override, $options, $active = false ) {
643 global $wgUser;
644 $sk = $wgUser->getSkin();
645 $params = $override + $options;
646 if ( $active ) {
647 return $sk->link( $this->getTitle(), '<strong>' . htmlspecialchars( $title ) . '</strong>',
648 array(), $params, array( 'known' ) );
649 } else {
650 return $sk->link( $this->getTitle(), htmlspecialchars( $title ), array() , $params, array( 'known' ) );
651 }
652 }
653
654 /**
655 * Creates the options panel.
656 * @param $defaults array
657 * @param $nondefaults array
658 */
659 function optionsPanel( $defaults, $nondefaults ) {
660 global $wgLang, $wgUser, $wgRCLinkLimits, $wgRCLinkDays;
661
662 $options = $nondefaults + $defaults;
663
664 $note = '';
665 if( !wfEmptyMsg( 'rclegend', wfMsg('rclegend') ) ) {
666 $note .= '<div class="mw-rclegend">' . wfMsgExt( 'rclegend', array('parseinline') ) . "</div>\n";
667 }
668 if( $options['from'] ) {
669 $note .= wfMsgExt( 'rcnotefrom', array( 'parseinline' ),
670 $wgLang->formatNum( $options['limit'] ),
671 $wgLang->timeanddate( $options['from'], true ),
672 $wgLang->date( $options['from'], true ),
673 $wgLang->time( $options['from'], true ) ) . '<br />';
674 }
675
676 # Sort data for display and make sure it's unique after we've added user data.
677 $wgRCLinkLimits[] = $options['limit'];
678 $wgRCLinkDays[] = $options['days'];
679 sort( $wgRCLinkLimits );
680 sort( $wgRCLinkDays );
681 $wgRCLinkLimits = array_unique( $wgRCLinkLimits );
682 $wgRCLinkDays = array_unique( $wgRCLinkDays );
683
684 // limit links
685 foreach( $wgRCLinkLimits as $value ) {
686 $cl[] = $this->makeOptionsLink( $wgLang->formatNum( $value ),
687 array( 'limit' => $value ), $nondefaults, $value == $options['limit'] ) ;
688 }
689 $cl = $wgLang->pipeList( $cl );
690
691 // day links, reset 'from' to none
692 foreach( $wgRCLinkDays as $value ) {
693 $dl[] = $this->makeOptionsLink( $wgLang->formatNum( $value ),
694 array( 'days' => $value, 'from' => '' ), $nondefaults, $value == $options['days'] ) ;
695 }
696 $dl = $wgLang->pipeList( $dl );
697
698
699 // show/hide links
700 $showhide = array( wfMsg( 'show' ), wfMsg( 'hide' ) );
701 $minorLink = $this->makeOptionsLink( $showhide[1-$options['hideminor']],
702 array( 'hideminor' => 1-$options['hideminor'] ), $nondefaults);
703 $botLink = $this->makeOptionsLink( $showhide[1-$options['hidebots']],
704 array( 'hidebots' => 1-$options['hidebots'] ), $nondefaults);
705 $anonsLink = $this->makeOptionsLink( $showhide[ 1 - $options['hideanons'] ],
706 array( 'hideanons' => 1 - $options['hideanons'] ), $nondefaults );
707 $liuLink = $this->makeOptionsLink( $showhide[1-$options['hideliu']],
708 array( 'hideliu' => 1-$options['hideliu'] ), $nondefaults);
709 $patrLink = $this->makeOptionsLink( $showhide[1-$options['hidepatrolled']],
710 array( 'hidepatrolled' => 1-$options['hidepatrolled'] ), $nondefaults);
711 $myselfLink = $this->makeOptionsLink( $showhide[1-$options['hidemyself']],
712 array( 'hidemyself' => 1-$options['hidemyself'] ), $nondefaults);
713
714 $links[] = wfMsgHtml( 'rcshowhideminor', $minorLink );
715 $links[] = wfMsgHtml( 'rcshowhidebots', $botLink );
716 $links[] = wfMsgHtml( 'rcshowhideanons', $anonsLink );
717 $links[] = wfMsgHtml( 'rcshowhideliu', $liuLink );
718 if( $wgUser->useRCPatrol() )
719 $links[] = wfMsgHtml( 'rcshowhidepatr', $patrLink );
720 $links[] = wfMsgHtml( 'rcshowhidemine', $myselfLink );
721 $hl = $wgLang->pipeList( $links );
722
723 // show from this onward link
724 $now = $wgLang->timeanddate( wfTimestampNow(), true );
725 $tl = $this->makeOptionsLink( $now, array( 'from' => wfTimestampNow() ), $nondefaults );
726
727 $rclinks = wfMsgExt( 'rclinks', array( 'parseinline', 'replaceafter' ),
728 $cl, $dl, $hl );
729 $rclistfrom = wfMsgExt( 'rclistfrom', array( 'parseinline', 'replaceafter' ), $tl );
730 return "{$note}$rclinks<br />$rclistfrom";
731 }
732 }