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