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