MediaWiki  1.29.1
SpecialRecentchanges.php
Go to the documentation of this file.
1 <?php
27 
34  // @codingStandardsIgnoreStart Needed "useless" override to change parameters.
35  public function __construct( $name = 'Recentchanges', $restriction = '' ) {
36  parent::__construct( $name, $restriction );
37  }
38  // @codingStandardsIgnoreEnd
39 
45  public function execute( $subpage ) {
46  // Backwards-compatibility: redirect to new feed URLs
47  $feedFormat = $this->getRequest()->getVal( 'feed' );
48  if ( !$this->including() && $feedFormat ) {
49  $query = $this->getFeedQuery();
50  $query['feedformat'] = $feedFormat === 'atom' ? 'atom' : 'rss';
51  $this->getOutput()->redirect( wfAppendQuery( wfScript( 'api' ), $query ) );
52 
53  return;
54  }
55 
56  // 10 seconds server-side caching max
57  $out = $this->getOutput();
58  $out->setCdnMaxage( 10 );
59  // Check if the client has a cached version
60  $lastmod = $this->checkLastModified();
61  if ( $lastmod === false ) {
62  return;
63  }
64 
65  $this->addHelpLink(
66  '//meta.wikimedia.org/wiki/Special:MyLanguage/Help:Recent_changes',
67  true
68  );
69  parent::execute( $subpage );
70 
71  if ( $this->isStructuredFilterUiEnabled() ) {
72  $jsData = $this->getStructuredFilterJsData();
73 
74  $messages = [];
75  foreach ( $jsData['messageKeys'] as $key ){
76  $messages[$key] = $this->msg( $key )->plain();
77  }
78 
79  $out->addHTML(
80  ResourceLoader::makeInlineScript(
81  ResourceLoader::makeMessageSetScript( $messages )
82  )
83  );
84 
85  $out->addJsConfigVars( 'wgStructuredChangeFilters', $jsData['groups'] );
86  }
87  }
88 
92  protected function transformFilterDefinition( array $filterDefinition ) {
93  if ( isset( $filterDefinition['showHideSuffix'] ) ) {
94  $filterDefinition['showHide'] = 'rc' . $filterDefinition['showHideSuffix'];
95  }
96 
97  return $filterDefinition;
98  }
99 
103  protected function registerFilters() {
104  parent::registerFilters();
105 
106  $user = $this->getUser();
107 
108  $significance = $this->getFilterGroup( 'significance' );
109  $hideMinor = $significance->getFilter( 'hideminor' );
110  $hideMinor->setDefault( $user->getBoolOption( 'hideminor' ) );
111 
112  $automated = $this->getFilterGroup( 'automated' );
113  $hideBots = $automated->getFilter( 'hidebots' );
114  $hideBots->setDefault( true );
115 
116  $reviewStatus = $this->getFilterGroup( 'reviewStatus' );
117  if ( $reviewStatus !== null ) {
118  // Conditional on feature being available and rights
119  $hidePatrolled = $reviewStatus->getFilter( 'hidepatrolled' );
120  $hidePatrolled->setDefault( $user->getBoolOption( 'hidepatrolled' ) );
121  }
122 
123  $changeType = $this->getFilterGroup( 'changeType' );
124  $hideCategorization = $changeType->getFilter( 'hidecategorization' );
125  if ( $hideCategorization !== null ) {
126  // Conditional on feature being available
127  $hideCategorization->setDefault( $user->getBoolOption( 'hidecategorization' ) );
128  }
129  }
130 
136  public function getDefaultOptions() {
137  $opts = parent::getDefaultOptions();
138  $user = $this->getUser();
139 
140  $opts->add( 'days', $user->getIntOption( 'rcdays' ) );
141  $opts->add( 'limit', $user->getIntOption( 'rclimit' ) );
142  $opts->add( 'from', '' );
143 
144  $opts->add( 'categories', '' );
145  $opts->add( 'categories_any', false );
146  $opts->add( 'tagfilter', '' );
147 
148  return $opts;
149  }
150 
156  protected function getCustomFilters() {
157  if ( $this->customFilters === null ) {
158  $this->customFilters = parent::getCustomFilters();
159  Hooks::run( 'SpecialRecentChangesFilters', [ $this, &$this->customFilters ], '1.23' );
160  }
161 
162  return $this->customFilters;
163  }
164 
171  public function parseParameters( $par, FormOptions $opts ) {
172  parent::parseParameters( $par, $opts );
173 
174  $bits = preg_split( '/\s*,\s*/', trim( $par ) );
175  foreach ( $bits as $bit ) {
176  if ( is_numeric( $bit ) ) {
177  $opts['limit'] = $bit;
178  }
179 
180  $m = [];
181  if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
182  $opts['limit'] = $m[1];
183  }
184  if ( preg_match( '/^days=(\d+)$/', $bit, $m ) ) {
185  $opts['days'] = $m[1];
186  }
187  if ( preg_match( '/^namespace=(\d+)$/', $bit, $m ) ) {
188  $opts['namespace'] = $m[1];
189  }
190  if ( preg_match( '/^tagfilter=(.*)$/', $bit, $m ) ) {
191  $opts['tagfilter'] = $m[1];
192  }
193  }
194  }
195 
196  public function validateOptions( FormOptions $opts ) {
197  $opts->validateIntBounds( 'limit', 0, 5000 );
198  parent::validateOptions( $opts );
199  }
200 
204  protected function buildQuery( &$tables, &$fields, &$conds,
205  &$query_options, &$join_conds, FormOptions $opts ) {
206 
207  $dbr = $this->getDB();
208  parent::buildQuery( $tables, $fields, $conds,
209  $query_options, $join_conds, $opts );
210 
211  // Calculate cutoff
212  $cutoff_unixtime = time() - ( $opts['days'] * 86400 );
213  $cutoff_unixtime = $cutoff_unixtime - ( $cutoff_unixtime % 86400 );
214  $cutoff = $dbr->timestamp( $cutoff_unixtime );
215 
216  $fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
217  if ( $fromValid && $opts['from'] > wfTimestamp( TS_MW, $cutoff ) ) {
218  $cutoff = $dbr->timestamp( $opts['from'] );
219  } else {
220  $opts->reset( 'from' );
221  }
222 
223  $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
224  }
225 
229  protected function doMainQuery( $tables, $fields, $conds, $query_options,
230  $join_conds, FormOptions $opts ) {
231 
232  $dbr = $this->getDB();
233  $user = $this->getUser();
234 
235  $tables[] = 'recentchanges';
236  $fields = array_merge( RecentChange::selectFields(), $fields );
237 
238  // JOIN on watchlist for users
239  if ( $user->getId() && $user->isAllowed( 'viewmywatchlist' ) ) {
240  $tables[] = 'watchlist';
241  $fields[] = 'wl_user';
242  $fields[] = 'wl_notificationtimestamp';
243  $join_conds['watchlist'] = [ 'LEFT JOIN', [
244  'wl_user' => $user->getId(),
245  'wl_title=rc_title',
246  'wl_namespace=rc_namespace'
247  ] ];
248  }
249 
250  if ( $user->isAllowed( 'rollback' ) ) {
251  $tables[] = 'page';
252  $fields[] = 'page_latest';
253  $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
254  }
255 
257  $tables,
258  $fields,
259  $conds,
260  $join_conds,
261  $query_options,
262  $opts['tagfilter']
263  );
264 
265  if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
266  $opts )
267  ) {
268  return false;
269  }
270 
271  if ( $this->areFiltersInConflict() ) {
272  return false;
273  }
274 
275  // array_merge() is used intentionally here so that hooks can, should
276  // they so desire, override the ORDER BY / LIMIT condition(s); prior to
277  // MediaWiki 1.26 this used to use the plus operator instead, which meant
278  // that extensions weren't able to change these conditions
279  $query_options = array_merge( [
280  'ORDER BY' => 'rc_timestamp DESC',
281  'LIMIT' => $opts['limit'] ], $query_options );
282  $rows = $dbr->select(
283  $tables,
284  $fields,
285  // rc_new is not an ENUM, but adding a redundant rc_new IN (0,1) gives mysql enough
286  // knowledge to use an index merge if it wants (it may use some other index though).
287  $conds + [ 'rc_new' => [ 0, 1 ] ],
288  __METHOD__,
289  $query_options,
290  $join_conds
291  );
292 
293  // Build the final data
294  if ( $this->getConfig()->get( 'AllowCategorizedRecentChanges' ) ) {
295  $this->filterByCategories( $rows, $opts );
296  }
297 
298  return $rows;
299  }
300 
301  protected function runMainQueryHook( &$tables, &$fields, &$conds,
302  &$query_options, &$join_conds, $opts
303  ) {
304  return parent::runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts )
305  && Hooks::run(
306  'SpecialRecentChangesQuery',
307  [ &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ],
308  '1.23'
309  );
310  }
311 
312  protected function getDB() {
313  return wfGetDB( DB_REPLICA, 'recentchanges' );
314  }
315 
316  public function outputFeedLinks() {
317  $this->addFeedLinks( $this->getFeedQuery() );
318  }
319 
325  protected function getFeedQuery() {
326  $query = array_filter( $this->getOptions()->getAllValues(), function ( $value ) {
327  // API handles empty parameters in a different way
328  return $value !== '';
329  } );
330  $query['action'] = 'feedrecentchanges';
331  $feedLimit = $this->getConfig()->get( 'FeedLimit' );
332  if ( $query['limit'] > $feedLimit ) {
333  $query['limit'] = $feedLimit;
334  }
335 
336  return $query;
337  }
338 
345  public function outputChangesList( $rows, $opts ) {
346  $limit = $opts['limit'];
347 
348  $showWatcherCount = $this->getConfig()->get( 'RCShowWatchingUsers' )
349  && $this->getUser()->getOption( 'shownumberswatching' );
350  $watcherCache = [];
351 
352  $dbr = $this->getDB();
353 
354  $counter = 1;
355  $list = ChangesList::newFromContext( $this->getContext(), $this->filterGroups );
356  $list->initChangesListRows( $rows );
357 
358  $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
359  $rclistOutput = $list->beginRecentChangesList();
360  foreach ( $rows as $obj ) {
361  if ( $limit == 0 ) {
362  break;
363  }
364  $rc = RecentChange::newFromRow( $obj );
365 
366  # Skip CatWatch entries for hidden cats based on user preference
367  if (
368  $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE &&
369  !$userShowHiddenCats &&
370  $rc->getParam( 'hidden-cat' )
371  ) {
372  continue;
373  }
374 
375  $rc->counter = $counter++;
376  # Check if the page has been updated since the last visit
377  if ( $this->getConfig()->get( 'ShowUpdatedMarker' )
378  && !empty( $obj->wl_notificationtimestamp )
379  ) {
380  $rc->notificationtimestamp = ( $obj->rc_timestamp >= $obj->wl_notificationtimestamp );
381  } else {
382  $rc->notificationtimestamp = false; // Default
383  }
384  # Check the number of users watching the page
385  $rc->numberofWatchingusers = 0; // Default
386  if ( $showWatcherCount && $obj->rc_namespace >= 0 ) {
387  if ( !isset( $watcherCache[$obj->rc_namespace][$obj->rc_title] ) ) {
388  $watcherCache[$obj->rc_namespace][$obj->rc_title] =
389  MediaWikiServices::getInstance()->getWatchedItemStore()->countWatchers(
390  new TitleValue( (int)$obj->rc_namespace, $obj->rc_title )
391  );
392  }
393  $rc->numberofWatchingusers = $watcherCache[$obj->rc_namespace][$obj->rc_title];
394  }
395 
396  $changeLine = $list->recentChangesLine( $rc, !empty( $obj->wl_user ), $counter );
397  if ( $changeLine !== false ) {
398  $rclistOutput .= $changeLine;
399  --$limit;
400  }
401  }
402  $rclistOutput .= $list->endRecentChangesList();
403 
404  if ( $rows->numRows() === 0 ) {
405  $this->outputNoResults();
406  if ( !$this->including() ) {
407  $this->getOutput()->setStatusCode( 404 );
408  }
409  } else {
410  $this->getOutput()->addHTML( $rclistOutput );
411  }
412  }
413 
420  public function doHeader( $opts, $numRows ) {
421  $this->setTopText( $opts );
422 
423  $defaults = $opts->getAllValues();
424  $nondefaults = $opts->getChangedValues();
425 
426  $panel = [];
427  $panel[] = $this->makeLegend();
428  $panel[] = $this->optionsPanel( $defaults, $nondefaults, $numRows );
429  $panel[] = '<hr />';
430 
431  $extraOpts = $this->getExtraOptions( $opts );
432  $extraOptsCount = count( $extraOpts );
433  $count = 0;
434  $submit = ' ' . Xml::submitButton( $this->msg( 'recentchanges-submit' )->text() );
435 
436  $out = Xml::openElement( 'table', [ 'class' => 'mw-recentchanges-table' ] );
437  foreach ( $extraOpts as $name => $optionRow ) {
438  # Add submit button to the last row only
439  ++$count;
440  $addSubmit = ( $count === $extraOptsCount ) ? $submit : '';
441 
442  $out .= Xml::openElement( 'tr' );
443  if ( is_array( $optionRow ) ) {
444  $out .= Xml::tags(
445  'td',
446  [ 'class' => 'mw-label mw-' . $name . '-label' ],
447  $optionRow[0]
448  );
449  $out .= Xml::tags(
450  'td',
451  [ 'class' => 'mw-input' ],
452  $optionRow[1] . $addSubmit
453  );
454  } else {
455  $out .= Xml::tags(
456  'td',
457  [ 'class' => 'mw-input', 'colspan' => 2 ],
458  $optionRow . $addSubmit
459  );
460  }
461  $out .= Xml::closeElement( 'tr' );
462  }
463  $out .= Xml::closeElement( 'table' );
464 
465  $unconsumed = $opts->getUnconsumedValues();
466  foreach ( $unconsumed as $key => $value ) {
467  $out .= Html::hidden( $key, $value );
468  }
469 
470  $t = $this->getPageTitle();
471  $out .= Html::hidden( 'title', $t->getPrefixedText() );
472  $form = Xml::tags( 'form', [ 'action' => wfScript() ], $out );
473  $panel[] = $form;
474  $panelString = implode( "\n", $panel );
475 
476  $rcoptions = Xml::fieldset(
477  $this->msg( 'recentchanges-legend' )->text(),
478  $panelString,
479  [ 'class' => 'rcoptions' ]
480  );
481 
482  // Insert a placeholder for RCFilters
483  if ( $this->getUser()->getOption( 'rcenhancedfilters' ) ) {
484  $rcfilterContainer = Html::element(
485  'div',
486  [ 'class' => 'rcfilters-container' ]
487  );
488 
489  // Wrap both with rcfilters-head
490  $this->getOutput()->addHTML(
492  'div',
493  [ 'class' => 'rcfilters-head' ],
494  $rcfilterContainer . $rcoptions
495  )
496  );
497  } else {
498  $this->getOutput()->addHTML( $rcoptions );
499  }
500 
501  $this->setBottomText( $opts );
502  }
503 
509  function setTopText( FormOptions $opts ) {
511 
512  $message = $this->msg( 'recentchangestext' )->inContentLanguage();
513  if ( !$message->isDisabled() ) {
514  $this->getOutput()->addWikiText(
515  Html::rawElement( 'div',
516  [ 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ],
517  "\n" . $message->plain() . "\n"
518  ),
519  /* $lineStart */ true,
520  /* $interface */ false
521  );
522  }
523  }
524 
531  function getExtraOptions( $opts ) {
532  $opts->consumeValues( [
533  'namespace', 'invert', 'associated', 'tagfilter', 'categories', 'categories_any'
534  ] );
535 
536  $extraOpts = [];
537  $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
538 
539  if ( $this->getConfig()->get( 'AllowCategorizedRecentChanges' ) ) {
540  $extraOpts['category'] = $this->categoryFilterForm( $opts );
541  }
542 
544  $opts['tagfilter'], false, $this->getContext() );
545  if ( count( $tagFilter ) ) {
546  $extraOpts['tagfilter'] = $tagFilter;
547  }
548 
549  // Don't fire the hook for subclasses. (Or should we?)
550  if ( $this->getName() === 'Recentchanges' ) {
551  Hooks::run( 'SpecialRecentChangesPanel', [ &$extraOpts, $opts ] );
552  }
553 
554  return $extraOpts;
555  }
556 
562  protected function isStructuredFilterUiEnabled() {
563  return $this->getUser()->getOption(
564  'rcenhancedfilters'
565  );
566  }
567 
571  protected function addModules() {
572  parent::addModules();
573  $out = $this->getOutput();
574  $out->addModules( 'mediawiki.special.recentchanges' );
575  if ( $this->isStructuredFilterUiEnabled() ) {
576  $out->addModules( 'mediawiki.rcfilters.filters.ui' );
577  $out->addModuleStyles( 'mediawiki.rcfilters.filters.base.styles' );
578  }
579  }
580 
588  public function checkLastModified() {
589  $dbr = $this->getDB();
590  $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __METHOD__ );
591 
592  return $lastmod;
593  }
594 
601  protected function namespaceFilterForm( FormOptions $opts ) {
602  $nsSelect = Html::namespaceSelector(
603  [ 'selected' => $opts['namespace'], 'all' => '' ],
604  [ 'name' => 'namespace', 'id' => 'namespace' ]
605  );
606  $nsLabel = Xml::label( $this->msg( 'namespace' )->text(), 'namespace' );
607  $invert = Xml::checkLabel(
608  $this->msg( 'invert' )->text(), 'invert', 'nsinvert',
609  $opts['invert'],
610  [ 'title' => $this->msg( 'tooltip-invert' )->text() ]
611  );
612  $associated = Xml::checkLabel(
613  $this->msg( 'namespace_association' )->text(), 'associated', 'nsassociated',
614  $opts['associated'],
615  [ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
616  );
617 
618  return [ $nsLabel, "$nsSelect $invert $associated" ];
619  }
620 
627  protected function categoryFilterForm( FormOptions $opts ) {
628  list( $label, $input ) = Xml::inputLabelSep( $this->msg( 'rc_categories' )->text(),
629  'categories', 'mw-categories', false, $opts['categories'] );
630 
631  $input .= ' ' . Xml::checkLabel( $this->msg( 'rc_categories_any' )->text(),
632  'categories_any', 'mw-categories_any', $opts['categories_any'] );
633 
634  return [ $label, $input ];
635  }
636 
643  function filterByCategories( &$rows, FormOptions $opts ) {
644  $categories = array_map( 'trim', explode( '|', $opts['categories'] ) );
645 
646  if ( !count( $categories ) ) {
647  return;
648  }
649 
650  # Filter categories
651  $cats = [];
652  foreach ( $categories as $cat ) {
653  $cat = trim( $cat );
654  if ( $cat == '' ) {
655  continue;
656  }
657  $cats[] = $cat;
658  }
659 
660  # Filter articles
661  $articles = [];
662  $a2r = [];
663  $rowsarr = [];
664  foreach ( $rows as $k => $r ) {
665  $nt = Title::makeTitle( $r->rc_namespace, $r->rc_title );
666  $id = $nt->getArticleID();
667  if ( $id == 0 ) {
668  continue; # Page might have been deleted...
669  }
670  if ( !in_array( $id, $articles ) ) {
671  $articles[] = $id;
672  }
673  if ( !isset( $a2r[$id] ) ) {
674  $a2r[$id] = [];
675  }
676  $a2r[$id][] = $k;
677  $rowsarr[$k] = $r;
678  }
679 
680  # Shortcut?
681  if ( !count( $articles ) || !count( $cats ) ) {
682  return;
683  }
684 
685  # Look up
686  $catFind = new CategoryFinder;
687  $catFind->seed( $articles, $cats, $opts['categories_any'] ? 'OR' : 'AND' );
688  $match = $catFind->run();
689 
690  # Filter
691  $newrows = [];
692  foreach ( $match as $id ) {
693  foreach ( $a2r[$id] as $rev ) {
694  $k = $rev;
695  $newrows[$k] = $rowsarr[$k];
696  }
697  }
698  $rows = new FakeResultWrapper( array_values( $newrows ) );
699  }
700 
710  function makeOptionsLink( $title, $override, $options, $active = false ) {
711  $params = $override + $options;
712 
713  // T38524: false values have be converted to "0" otherwise
714  // wfArrayToCgi() will omit it them.
715  foreach ( $params as &$value ) {
716  if ( $value === false ) {
717  $value = '0';
718  }
719  }
720  unset( $value );
721 
722  if ( $active ) {
723  $title = new HtmlArmor( '<strong>' . htmlspecialchars( $title ) . '</strong>' );
724  }
725 
726  return $this->getLinkRenderer()->makeKnownLink( $this->getPageTitle(), $title, [
727  'data-params' => json_encode( $override ),
728  'data-keys' => implode( ',', array_keys( $override ) ),
729  ], $params );
730  }
731 
740  function optionsPanel( $defaults, $nondefaults, $numRows ) {
741  $options = $nondefaults + $defaults;
742 
743  $note = '';
744  $msg = $this->msg( 'rclegend' );
745  if ( !$msg->isDisabled() ) {
746  $note .= '<div class="mw-rclegend">' . $msg->parse() . "</div>\n";
747  }
748 
749  $lang = $this->getLanguage();
750  $user = $this->getUser();
751  $config = $this->getConfig();
752  if ( $options['from'] ) {
753  $resetLink = $this->makeOptionsLink( $this->msg( 'rclistfromreset' ),
754  [ 'from' => '' ], $nondefaults );
755 
756  $note .= $this->msg( 'rcnotefrom' )
757  ->numParams( $options['limit'] )
758  ->params(
759  $lang->userTimeAndDate( $options['from'], $user ),
760  $lang->userDate( $options['from'], $user ),
761  $lang->userTime( $options['from'], $user )
762  )
763  ->numParams( $numRows )
764  ->parse() . ' ' .
766  'span',
767  [ 'class' => 'rcoptions-listfromreset' ],
768  $this->msg( 'parentheses' )->rawParams( $resetLink )->parse()
769  ) .
770  '<br />';
771  }
772 
773  # Sort data for display and make sure it's unique after we've added user data.
774  $linkLimits = $config->get( 'RCLinkLimits' );
775  $linkLimits[] = $options['limit'];
776  sort( $linkLimits );
777  $linkLimits = array_unique( $linkLimits );
778 
779  $linkDays = $config->get( 'RCLinkDays' );
780  $linkDays[] = $options['days'];
781  sort( $linkDays );
782  $linkDays = array_unique( $linkDays );
783 
784  // limit links
785  $cl = [];
786  foreach ( $linkLimits as $value ) {
787  $cl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
788  [ 'limit' => $value ], $nondefaults, $value == $options['limit'] );
789  }
790  $cl = $lang->pipeList( $cl );
791 
792  // day links, reset 'from' to none
793  $dl = [];
794  foreach ( $linkDays as $value ) {
795  $dl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
796  [ 'days' => $value, 'from' => '' ], $nondefaults, $value == $options['days'] );
797  }
798  $dl = $lang->pipeList( $dl );
799 
800  $showhide = [ 'show', 'hide' ];
801 
802  $links = [];
803 
804  $filterGroups = $this->getFilterGroups();
805 
806  $context = $this->getContext();
807  foreach ( $filterGroups as $groupName => $group ) {
808  if ( !$group->isPerGroupRequestParameter() ) {
809  foreach ( $group->getFilters() as $key => $filter ) {
810  if ( $filter->displaysOnUnstructuredUi( $this ) ) {
811  $msg = $filter->getShowHide();
812  $linkMessage = $this->msg( $msg . '-' . $showhide[1 - $options[$key]] );
813  // Extensions can define additional filters, but don't need to define the corresponding
814  // messages. If they don't exist, just fall back to 'show' and 'hide'.
815  if ( !$linkMessage->exists() ) {
816  $linkMessage = $this->msg( $showhide[1 - $options[$key]] );
817  }
818 
819  $link = $this->makeOptionsLink( $linkMessage->text(),
820  [ $key => 1 - $options[$key] ], $nondefaults );
821 
822  $attribs = [
823  'class' => "$msg rcshowhideoption",
824  'data-filter-name' => $filter->getName(),
825  ];
826 
827  if ( $filter->isFeatureAvailableOnStructuredUi( $this ) ) {
828  $attribs['data-feature-in-structured-ui'] = true;
829  }
830 
831  $links[] = Html::rawElement(
832  'span',
833  $attribs,
834  $this->msg( $msg )->rawParams( $link )->escaped()
835  );
836  }
837  }
838  }
839  }
840 
841  // show from this onward link
842  $timestamp = wfTimestampNow();
843  $now = $lang->userTimeAndDate( $timestamp, $user );
844  $timenow = $lang->userTime( $timestamp, $user );
845  $datenow = $lang->userDate( $timestamp, $user );
846  $pipedLinks = '<span class="rcshowhide">' . $lang->pipeList( $links ) . '</span>';
847 
848  $rclinks = '<span class="rclinks">' . $this->msg( 'rclinks' )->rawParams( $cl, $dl, '' )
849  ->parse() . '</span>';
850 
851  $rclistfrom = '<span class="rclistfrom">' . $this->makeOptionsLink(
852  $this->msg( 'rclistfrom' )->rawParams( $now, $timenow, $datenow )->parse(),
853  [ 'from' => $timestamp ],
854  $nondefaults
855  ) . '</span>';
856 
857  return "{$note}$rclinks<br />$pipedLinks<br />$rclistfrom";
858  }
859 
860  public function isIncludable() {
861  return true;
862  }
863 
864  protected function getCacheTTL() {
865  return 60 * 5;
866  }
867 }
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:628
Page
Interface for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
Definition: Page.php:24
$context
error also a ContextSource you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition: hooks.txt:2612
HtmlArmor
Marks HTML that shouldn't be escaped.
Definition: HtmlArmor.php:28
SpecialRecentChanges\parseParameters
parseParameters( $par, FormOptions $opts)
Process $par and put options found in $opts.
Definition: SpecialRecentchanges.php:171
SpecialRecentChanges\doMainQuery
doMainQuery( $tables, $fields, $conds, $query_options, $join_conds, FormOptions $opts)
Process the query.Array of tables; see IDatabase::select $table Array of fields; see IDatabase::selec...
Definition: SpecialRecentchanges.php:229
$tables
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
Definition: hooks.txt:990
Xml\tags
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:131
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:675
SpecialRecentChanges\isStructuredFilterUiEnabled
isStructuredFilterUiEnabled()
Check whether the structured filter UI is enabled.
Definition: SpecialRecentchanges.php:562
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
SpecialRecentChanges\filterByCategories
filterByCategories(&$rows, FormOptions $opts)
Filter $rows by categories set in $opts.
Definition: SpecialRecentchanges.php:643
SpecialRecentChanges\namespaceFilterForm
namespaceFilterForm(FormOptions $opts)
Creates the choose namespace selection.
Definition: SpecialRecentchanges.php:601
Xml\label
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
Definition: Xml.php:358
captcha-old.count
count
Definition: captcha-old.py:225
ChangesListSpecialPage\makeLegend
makeLegend()
Return the legend displayed within the fieldset.
Definition: ChangesListSpecialPage.php:1137
SpecialRecentChanges\validateOptions
validateOptions(FormOptions $opts)
Validate a FormOptions object generated by getDefaultOptions() with values already populated.
Definition: SpecialRecentchanges.php:196
text
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:12
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1994
SpecialRecentChanges\__construct
__construct( $name='Recentchanges', $restriction='')
Definition: SpecialRecentchanges.php:35
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
ChangesListSpecialPage
Special page which uses a ChangesList to show query results.
Definition: ChangesListSpecialPage.php:33
SpecialRecentChanges\outputChangesList
outputChangesList( $rows, $opts)
Build and output the actual changes list.
Definition: SpecialRecentchanges.php:345
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:246
SpecialRecentChanges\getCacheTTL
getCacheTTL()
Definition: SpecialRecentchanges.php:864
Xml\inputLabelSep
static inputLabelSep( $label, $name, $id, $size=false, $value=false, $attribs=[])
Same as Xml::inputLabel() but return input and label in an array.
Definition: Xml.php:399
$params
$params
Definition: styleTest.css.php:40
SpecialRecentChanges\registerFilters
registerFilters()
Register all filters and their groups (including those from hooks), plus handle conflicts and default...
Definition: SpecialRecentchanges.php:103
FormOptions\reset
reset( $name)
Delete the option value.
Definition: FormOptions.php:205
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:304
SpecialRecentChanges\getCustomFilters
getCustomFilters()
Get all custom filters.
Definition: SpecialRecentchanges.php:156
FormOptions\validateIntBounds
validateIntBounds( $name, $min, $max)
Definition: FormOptions.php:250
Wikimedia\Rdbms\ResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: ResultWrapper.php:24
ChangeTags\buildTagFilterSelector
static buildTagFilterSelector( $selected='', $ooui=false, IContextSource $context=null)
Build a text box to select a change tag.
Definition: ChangeTags.php:678
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:705
SpecialRecentChanges\isIncludable
isIncludable()
Whether it's allowed to transclude the special page via {{Special:Foo/params}}.
Definition: SpecialRecentchanges.php:860
SpecialPage\getName
getName()
Get the name of this Special Page.
Definition: SpecialPage.php:150
Wikimedia\Rdbms\FakeResultWrapper
Overloads the relevant methods of the real ResultsWrapper so it doesn't go anywhere near an actual da...
Definition: FakeResultWrapper.php:11
$messages
$messages
Definition: LogTests.i18n.php:8
Xml\openElement
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:109
ChangesListSpecialPage\$filterGroups
$filterGroups
Filter groups, and their contained filters This is an associative array (with group name as key) of C...
Definition: ChangesListSpecialPage.php:75
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
ChangesListSpecialPage\outputNoResults
outputNoResults()
Add the "no results" message to the output.
Definition: ChangesListSpecialPage.php:522
Xml\fieldset
static fieldset( $legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
Definition: Xml.php:577
wfAppendQuery
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
Definition: GlobalFunctions.php:500
SpecialRecentChanges\addModules
addModules()
Add page-specific modules.
Definition: SpecialRecentchanges.php:571
$query
null for the wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1572
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:785
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:714
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:934
SpecialPage\addFeedLinks
addFeedLinks( $params)
Adds RSS/atom links.
Definition: SpecialPage.php:767
ChangeTags\modifyDisplayQuery
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag=false)
Applies all tags-related changes to a query.
Definition: ChangeTags.php:632
wfScript
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
Definition: GlobalFunctions.php:3138
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3060
$input
if(is_array( $mode)) switch( $mode) $input
Definition: postprocess-phan.php:141
SpecialRecentChanges\transformFilterDefinition
transformFilterDefinition(array $filterDefinition)
Transforms filter definition to prepare it for constructor.See overrides of this method as well....
Definition: SpecialRecentchanges.php:92
$attribs
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Definition: hooks.txt:1956
ChangesListSpecialPage\getStructuredFilterJsData
getStructuredFilterJsData()
Gets structured filter information needed by JS.
Definition: ChangesListSpecialPage.php:821
$limit
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers please use GetContentModels hook to make them known to core if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive $limit
Definition: hooks.txt:1049
RecentChange\newFromRow
static newFromRow( $row)
Definition: RecentChange.php:115
SpecialRecentChanges\getFeedQuery
getFeedQuery()
Get URL query parameters for action=feedrecentchanges API feed of current recent changes view.
Definition: SpecialRecentchanges.php:325
ChangesListSpecialPage\getFilterGroups
getFilterGroups()
Gets the currently registered filters groups.
Definition: ChangesListSpecialPage.php:792
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:685
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:514
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
wfTimestampNow
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
Definition: GlobalFunctions.php:2023
CategoryFinder\seed
seed( $articleIds, $categories, $mode='AND')
Initializes the instance.
Definition: CategoryFinder.php:78
SpecialRecentChanges\execute
execute( $subpage)
Main execution point.
Definition: SpecialRecentchanges.php:45
SpecialRecentChanges\getDB
getDB()
Return a IDatabase object for reading.
Definition: SpecialRecentchanges.php:312
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:648
ChangesList\newFromContext
static newFromContext(IContextSource $context, array $groups=[])
Fetch an appropriate changes list class for the specified context Some users might want to use an enh...
Definition: ChangesList.php:85
execute
$batch execute()
Html\hidden
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition: Html.php:746
SpecialRecentChanges\buildQuery
buildQuery(&$tables, &$fields, &$conds, &$query_options, &$join_conds, FormOptions $opts)
Sets appropriate tables, fields, conditions, etc.depending on which filters the user requested....
Definition: SpecialRecentchanges.php:204
$value
$value
Definition: styleTest.css.php:45
SpecialPage\msg
msg()
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:746
SpecialRecentChanges\runMainQueryHook
runMainQueryHook(&$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts)
Definition: SpecialRecentchanges.php:301
Html\namespaceSelector
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
Definition: Html.php:834
SpecialRecentChanges\getDefaultOptions
getDefaultOptions()
Get a FormOptions object containing the default options.
Definition: SpecialRecentchanges.php:136
CategoryFinder
The "CategoryFinder" class takes a list of articles, creates an internal representation of all their ...
Definition: CategoryFinder.php:46
ChangesListSpecialPage\getFilterGroup
getFilterGroup( $groupName)
Gets a specified ChangesListFilterGroup by name.
Definition: ChangesListSpecialPage.php:803
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:665
SpecialRecentChanges
A special page that lists last changes made to the wiki.
Definition: SpecialRecentchanges.php:33
SpecialRecentChanges\categoryFilterForm
categoryFilterForm(FormOptions $opts)
Create an input to filter changes by categories.
Definition: SpecialRecentchanges.php:627
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:856
SpecialRecentChanges\optionsPanel
optionsPanel( $defaults, $nondefaults, $numRows)
Creates the options panel.
Definition: SpecialRecentchanges.php:740
ChangesListSpecialPage\areFiltersInConflict
areFiltersInConflict()
Check if filters are in conflict and guaranteed to return no results.
Definition: ChangesListSpecialPage.php:430
SpecialRecentChanges\setTopText
setTopText(FormOptions $opts)
Send the text to be displayed above the options.
Definition: SpecialRecentchanges.php:509
SpecialRecentChanges\doHeader
doHeader( $opts, $numRows)
Set the text to be displayed above the changes.
Definition: SpecialRecentchanges.php:420
RecentChange\selectFields
static selectFields()
Return the list of recentchanges fields that should be selected to create a new recentchanges object.
Definition: RecentChange.php:204
Xml\closeElement
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:118
SpecialRecentChanges\getExtraOptions
getExtraOptions( $opts)
Get options to be displayed in a form.
Definition: SpecialRecentchanges.php:531
$dbr
if(! $regexes) $dbr
Definition: cleanup.php:94
SpecialRecentChanges\outputFeedLinks
outputFeedLinks()
Output feed links.
Definition: SpecialRecentchanges.php:316
$rev
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Definition: hooks.txt:1741
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:2929
RC_CATEGORIZE
const RC_CATEGORIZE
Definition: Defines.php:144
FormOptions
Helper class to keep track of options when mixing links and form elements.
Definition: FormOptions.php:35
$t
$t
Definition: testCompression.php:67
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
MediaWikiServices
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
ChangesListSpecialPage\setBottomText
setBottomText(FormOptions $opts)
Send the text to be displayed after the options.
Definition: ChangesListSpecialPage.php:1115
ChangesListSpecialPage\getOptions
getOptions()
Get the current FormOptions for this request.
Definition: ChangesListSpecialPage.php:553
$options
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Definition: hooks.txt:1049
SpecialPage\including
including( $x=null)
Whether the special page is being evaluated via transclusion.
Definition: SpecialPage.php:226
SpecialRecentChanges\checkLastModified
checkLastModified()
Get last modified date, for client caching Don't use this if we are using the patrol feature,...
Definition: SpecialRecentchanges.php:588
ChangesListSpecialPage\$customFilters
array $customFilters
Definition: ChangesListSpecialPage.php:41
SpecialRecentChanges\makeOptionsLink
makeOptionsLink( $title, $override, $options, $active=false)
Makes change an option link which carries all the other options.
Definition: SpecialRecentchanges.php:710
array
the array() calling protocol came about after MediaWiki 1.4rc1.
Xml\submitButton
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
Definition: Xml.php:459
Xml\checkLabel
static checkLabel( $label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
Definition: Xml.php:419
TitleValue
Represents a page (or page fragment) title within MediaWiki.
Definition: TitleValue.php:36
$wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
Definition: design.txt:56
$out
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition: hooks.txt:783