PageRenderTime 58ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/includes/specials/SpecialRecentchanges.php

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