MediaWiki REL1_27
SpecialRecentchanges.php
Go to the documentation of this file.
1<?php
30 // @codingStandardsIgnoreStart Needed "useless" override to change parameters.
31 public function __construct( $name = 'Recentchanges', $restriction = '' ) {
32 parent::__construct( $name, $restriction );
33 }
34 // @codingStandardsIgnoreEnd
35
41 public function execute( $subpage ) {
42 // Backwards-compatibility: redirect to new feed URLs
43 $feedFormat = $this->getRequest()->getVal( 'feed' );
44 if ( !$this->including() && $feedFormat ) {
45 $query = $this->getFeedQuery();
46 $query['feedformat'] = $feedFormat === 'atom' ? 'atom' : 'rss';
47 $this->getOutput()->redirect( wfAppendQuery( wfScript( 'api' ), $query ) );
48
49 return;
50 }
51
52 // 10 seconds server-side caching max
53 $this->getOutput()->setCdnMaxage( 10 );
54 // Check if the client has a cached version
55 $lastmod = $this->checkLastModified();
56 if ( $lastmod === false ) {
57 return;
58 }
59
60 $this->addHelpLink(
61 '//meta.wikimedia.org/wiki/Special:MyLanguage/Help:Recent_changes',
62 true
63 );
64 parent::execute( $subpage );
65 }
66
72 public function getDefaultOptions() {
73 $opts = parent::getDefaultOptions();
74 $user = $this->getUser();
75
76 $opts->add( 'days', $user->getIntOption( 'rcdays' ) );
77 $opts->add( 'limit', $user->getIntOption( 'rclimit' ) );
78 $opts->add( 'from', '' );
79
80 $opts->add( 'hideminor', $user->getBoolOption( 'hideminor' ) );
81 $opts->add( 'hidebots', true );
82 $opts->add( 'hideanons', false );
83 $opts->add( 'hideliu', false );
84 $opts->add( 'hidepatrolled', $user->getBoolOption( 'hidepatrolled' ) );
85 $opts->add( 'hidemyself', false );
86 $opts->add( 'hidecategorization', $user->getBoolOption( 'hidecategorization' ) );
87
88 $opts->add( 'categories', '' );
89 $opts->add( 'categories_any', false );
90 $opts->add( 'tagfilter', '' );
91
92 return $opts;
93 }
94
100 protected function getCustomFilters() {
101 if ( $this->customFilters === null ) {
102 $this->customFilters = parent::getCustomFilters();
103 Hooks::run( 'SpecialRecentChangesFilters', [ $this, &$this->customFilters ], '1.23' );
104 }
105
107 }
108
115 public function parseParameters( $par, FormOptions $opts ) {
116 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
117 foreach ( $bits as $bit ) {
118 if ( 'hidebots' === $bit ) {
119 $opts['hidebots'] = true;
120 }
121 if ( 'bots' === $bit ) {
122 $opts['hidebots'] = false;
123 }
124 if ( 'hideminor' === $bit ) {
125 $opts['hideminor'] = true;
126 }
127 if ( 'minor' === $bit ) {
128 $opts['hideminor'] = false;
129 }
130 if ( 'hideliu' === $bit ) {
131 $opts['hideliu'] = true;
132 }
133 if ( 'hidepatrolled' === $bit ) {
134 $opts['hidepatrolled'] = true;
135 }
136 if ( 'hideanons' === $bit ) {
137 $opts['hideanons'] = true;
138 }
139 if ( 'hidemyself' === $bit ) {
140 $opts['hidemyself'] = true;
141 }
142 if ( 'hidecategorization' === $bit ) {
143 $opts['hidecategorization'] = true;
144 }
145
146 if ( is_numeric( $bit ) ) {
147 $opts['limit'] = $bit;
148 }
149
150 $m = [];
151 if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
152 $opts['limit'] = $m[1];
153 }
154 if ( preg_match( '/^days=(\d+)$/', $bit, $m ) ) {
155 $opts['days'] = $m[1];
156 }
157 if ( preg_match( '/^namespace=(\d+)$/', $bit, $m ) ) {
158 $opts['namespace'] = $m[1];
159 }
160 }
161 }
162
163 public function validateOptions( FormOptions $opts ) {
164 $opts->validateIntBounds( 'limit', 0, 5000 );
165 parent::validateOptions( $opts );
166 }
167
174 public function buildMainQueryConds( FormOptions $opts ) {
175 $dbr = $this->getDB();
176 $conds = parent::buildMainQueryConds( $opts );
177
178 // Calculate cutoff
179 $cutoff_unixtime = time() - ( $opts['days'] * 86400 );
180 $cutoff_unixtime = $cutoff_unixtime - ( $cutoff_unixtime % 86400 );
181 $cutoff = $dbr->timestamp( $cutoff_unixtime );
182
183 $fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
184 if ( $fromValid && $opts['from'] > wfTimestamp( TS_MW, $cutoff ) ) {
185 $cutoff = $dbr->timestamp( $opts['from'] );
186 } else {
187 $opts->reset( 'from' );
188 }
189
190 $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
191
192 return $conds;
193 }
194
202 public function doMainQuery( $conds, $opts ) {
203 $dbr = $this->getDB();
204 $user = $this->getUser();
205
206 $tables = [ 'recentchanges' ];
207 $fields = RecentChange::selectFields();
208 $query_options = [];
209 $join_conds = [];
210
211 // JOIN on watchlist for users
212 if ( $user->getId() && $user->isAllowed( 'viewmywatchlist' ) ) {
213 $tables[] = 'watchlist';
214 $fields[] = 'wl_user';
215 $fields[] = 'wl_notificationtimestamp';
216 $join_conds['watchlist'] = [ 'LEFT JOIN', [
217 'wl_user' => $user->getId(),
218 'wl_title=rc_title',
219 'wl_namespace=rc_namespace'
220 ] ];
221 }
222
223 if ( $user->isAllowed( 'rollback' ) ) {
224 $tables[] = 'page';
225 $fields[] = 'page_latest';
226 $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
227 }
228
230 $tables,
231 $fields,
232 $conds,
233 $join_conds,
234 $query_options,
235 $opts['tagfilter']
236 );
237
238 if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
239 $opts )
240 ) {
241 return false;
242 }
243
244 // array_merge() is used intentionally here so that hooks can, should
245 // they so desire, override the ORDER BY / LIMIT condition(s); prior to
246 // MediaWiki 1.26 this used to use the plus operator instead, which meant
247 // that extensions weren't able to change these conditions
248 $query_options = array_merge( [
249 'ORDER BY' => 'rc_timestamp DESC',
250 'LIMIT' => $opts['limit'] ], $query_options );
251 $rows = $dbr->select(
252 $tables,
253 $fields,
254 // rc_new is not an ENUM, but adding a redundant rc_new IN (0,1) gives mysql enough
255 // knowledge to use an index merge if it wants (it may use some other index though).
256 $conds + [ 'rc_new' => [ 0, 1 ] ],
257 __METHOD__,
258 $query_options,
259 $join_conds
260 );
261
262 // Build the final data
263 if ( $this->getConfig()->get( 'AllowCategorizedRecentChanges' ) ) {
264 $this->filterByCategories( $rows, $opts );
265 }
266
267 return $rows;
268 }
269
270 protected function runMainQueryHook( &$tables, &$fields, &$conds,
271 &$query_options, &$join_conds, $opts
272 ) {
273 return parent::runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts )
274 && Hooks::run(
275 'SpecialRecentChangesQuery',
276 [ &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ],
277 '1.23'
278 );
279 }
280
281 protected function getDB() {
282 return wfGetDB( DB_SLAVE, 'recentchanges' );
283 }
284
285 public function outputFeedLinks() {
286 $this->addFeedLinks( $this->getFeedQuery() );
287 }
288
294 protected function getFeedQuery() {
295 $query = array_filter( $this->getOptions()->getAllValues(), function ( $value ) {
296 // API handles empty parameters in a different way
297 return $value !== '';
298 } );
299 $query['action'] = 'feedrecentchanges';
300 $feedLimit = $this->getConfig()->get( 'FeedLimit' );
301 if ( $query['limit'] > $feedLimit ) {
302 $query['limit'] = $feedLimit;
303 }
304
305 return $query;
306 }
307
314 public function outputChangesList( $rows, $opts ) {
315 $limit = $opts['limit'];
316
317 $showWatcherCount = $this->getConfig()->get( 'RCShowWatchingUsers' )
318 && $this->getUser()->getOption( 'shownumberswatching' );
319 $watcherCache = [];
320
321 $dbr = $this->getDB();
322
323 $counter = 1;
324 $list = ChangesList::newFromContext( $this->getContext() );
325 $list->initChangesListRows( $rows );
326
327 $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
328 $rclistOutput = $list->beginRecentChangesList();
329 foreach ( $rows as $obj ) {
330 if ( $limit == 0 ) {
331 break;
332 }
333 $rc = RecentChange::newFromRow( $obj );
334
335 # Skip CatWatch entries for hidden cats based on user preference
336 if (
337 $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE &&
338 !$userShowHiddenCats &&
339 $rc->getParam( 'hidden-cat' )
340 ) {
341 continue;
342 }
343
344 $rc->counter = $counter++;
345 # Check if the page has been updated since the last visit
346 if ( $this->getConfig()->get( 'ShowUpdatedMarker' )
347 && !empty( $obj->wl_notificationtimestamp )
348 ) {
349 $rc->notificationtimestamp = ( $obj->rc_timestamp >= $obj->wl_notificationtimestamp );
350 } else {
351 $rc->notificationtimestamp = false; // Default
352 }
353 # Check the number of users watching the page
354 $rc->numberofWatchingusers = 0; // Default
355 if ( $showWatcherCount && $obj->rc_namespace >= 0 ) {
356 if ( !isset( $watcherCache[$obj->rc_namespace][$obj->rc_title] ) ) {
357 $watcherCache[$obj->rc_namespace][$obj->rc_title] =
359 new TitleValue( (int)$obj->rc_namespace, $obj->rc_title )
360 );
361 }
362 $rc->numberofWatchingusers = $watcherCache[$obj->rc_namespace][$obj->rc_title];
363 }
364
365 $changeLine = $list->recentChangesLine( $rc, !empty( $obj->wl_user ), $counter );
366 if ( $changeLine !== false ) {
367 $rclistOutput .= $changeLine;
368 --$limit;
369 }
370 }
371 $rclistOutput .= $list->endRecentChangesList();
372
373 if ( $rows->numRows() === 0 ) {
374 $this->getOutput()->addHTML(
375 '<div class="mw-changeslist-empty">' .
376 $this->msg( 'recentchanges-noresult' )->parse() .
377 '</div>'
378 );
379 if ( !$this->including() ) {
380 $this->getOutput()->setStatusCode( 404 );
381 }
382 } else {
383 $this->getOutput()->addHTML( $rclistOutput );
384 }
385 }
386
393 public function doHeader( $opts, $numRows ) {
394 $this->setTopText( $opts );
395
396 $defaults = $opts->getAllValues();
397 $nondefaults = $opts->getChangedValues();
398
399 $panel = [];
400 $panel[] = $this->makeLegend();
401 $panel[] = $this->optionsPanel( $defaults, $nondefaults, $numRows );
402 $panel[] = '<hr />';
403
404 $extraOpts = $this->getExtraOptions( $opts );
405 $extraOptsCount = count( $extraOpts );
406 $count = 0;
407 $submit = ' ' . Xml::submitButton( $this->msg( 'recentchanges-submit' )->text() );
408
409 $out = Xml::openElement( 'table', [ 'class' => 'mw-recentchanges-table' ] );
410 foreach ( $extraOpts as $name => $optionRow ) {
411 # Add submit button to the last row only
412 ++$count;
413 $addSubmit = ( $count === $extraOptsCount ) ? $submit : '';
414
415 $out .= Xml::openElement( 'tr' );
416 if ( is_array( $optionRow ) ) {
417 $out .= Xml::tags(
418 'td',
419 [ 'class' => 'mw-label mw-' . $name . '-label' ],
420 $optionRow[0]
421 );
422 $out .= Xml::tags(
423 'td',
424 [ 'class' => 'mw-input' ],
425 $optionRow[1] . $addSubmit
426 );
427 } else {
428 $out .= Xml::tags(
429 'td',
430 [ 'class' => 'mw-input', 'colspan' => 2 ],
431 $optionRow . $addSubmit
432 );
433 }
434 $out .= Xml::closeElement( 'tr' );
435 }
436 $out .= Xml::closeElement( 'table' );
437
438 $unconsumed = $opts->getUnconsumedValues();
439 foreach ( $unconsumed as $key => $value ) {
440 $out .= Html::hidden( $key, $value );
441 }
442
443 $t = $this->getPageTitle();
444 $out .= Html::hidden( 'title', $t->getPrefixedText() );
445 $form = Xml::tags( 'form', [ 'action' => wfScript() ], $out );
446 $panel[] = $form;
447 $panelString = implode( "\n", $panel );
448
449 $this->getOutput()->addHTML(
451 $this->msg( 'recentchanges-legend' )->text(),
452 $panelString,
453 [ 'class' => 'rcoptions' ]
454 )
455 );
456
457 $this->setBottomText( $opts );
458 }
459
465 function setTopText( FormOptions $opts ) {
467
468 $message = $this->msg( 'recentchangestext' )->inContentLanguage();
469 if ( !$message->isDisabled() ) {
470 $this->getOutput()->addWikiText(
471 Html::rawElement( 'div',
472 [ 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ],
473 "\n" . $message->plain() . "\n"
474 ),
475 /* $lineStart */ true,
476 /* $interface */ false
477 );
478 }
479 }
480
487 function getExtraOptions( $opts ) {
488 $opts->consumeValues( [
489 'namespace', 'invert', 'associated', 'tagfilter', 'categories', 'categories_any'
490 ] );
491
492 $extraOpts = [];
493 $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
494
495 if ( $this->getConfig()->get( 'AllowCategorizedRecentChanges' ) ) {
496 $extraOpts['category'] = $this->categoryFilterForm( $opts );
497 }
498
499 $tagFilter = ChangeTags::buildTagFilterSelector( $opts['tagfilter'] );
500 if ( count( $tagFilter ) ) {
501 $extraOpts['tagfilter'] = $tagFilter;
502 }
503
504 // Don't fire the hook for subclasses. (Or should we?)
505 if ( $this->getName() === 'Recentchanges' ) {
506 Hooks::run( 'SpecialRecentChangesPanel', [ &$extraOpts, $opts ] );
507 }
508
509 return $extraOpts;
510 }
511
515 protected function addModules() {
516 parent::addModules();
517 $out = $this->getOutput();
518 $out->addModules( 'mediawiki.special.recentchanges' );
519 }
520
528 public function checkLastModified() {
529 $dbr = $this->getDB();
530 $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __METHOD__ );
531
532 return $lastmod;
533 }
534
541 protected function namespaceFilterForm( FormOptions $opts ) {
542 $nsSelect = Html::namespaceSelector(
543 [ 'selected' => $opts['namespace'], 'all' => '' ],
544 [ 'name' => 'namespace', 'id' => 'namespace' ]
545 );
546 $nsLabel = Xml::label( $this->msg( 'namespace' )->text(), 'namespace' );
547 $invert = Xml::checkLabel(
548 $this->msg( 'invert' )->text(), 'invert', 'nsinvert',
549 $opts['invert'],
550 [ 'title' => $this->msg( 'tooltip-invert' )->text() ]
551 );
552 $associated = Xml::checkLabel(
553 $this->msg( 'namespace_association' )->text(), 'associated', 'nsassociated',
554 $opts['associated'],
555 [ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
556 );
557
558 return [ $nsLabel, "$nsSelect $invert $associated" ];
559 }
560
567 protected function categoryFilterForm( FormOptions $opts ) {
568 list( $label, $input ) = Xml::inputLabelSep( $this->msg( 'rc_categories' )->text(),
569 'categories', 'mw-categories', false, $opts['categories'] );
570
571 $input .= ' ' . Xml::checkLabel( $this->msg( 'rc_categories_any' )->text(),
572 'categories_any', 'mw-categories_any', $opts['categories_any'] );
573
574 return [ $label, $input ];
575 }
576
583 function filterByCategories( &$rows, FormOptions $opts ) {
584 $categories = array_map( 'trim', explode( '|', $opts['categories'] ) );
585
586 if ( !count( $categories ) ) {
587 return;
588 }
589
590 # Filter categories
591 $cats = [];
592 foreach ( $categories as $cat ) {
593 $cat = trim( $cat );
594 if ( $cat == '' ) {
595 continue;
596 }
597 $cats[] = $cat;
598 }
599
600 # Filter articles
601 $articles = [];
602 $a2r = [];
603 $rowsarr = [];
604 foreach ( $rows as $k => $r ) {
605 $nt = Title::makeTitle( $r->rc_namespace, $r->rc_title );
606 $id = $nt->getArticleID();
607 if ( $id == 0 ) {
608 continue; # Page might have been deleted...
609 }
610 if ( !in_array( $id, $articles ) ) {
611 $articles[] = $id;
612 }
613 if ( !isset( $a2r[$id] ) ) {
614 $a2r[$id] = [];
615 }
616 $a2r[$id][] = $k;
617 $rowsarr[$k] = $r;
618 }
619
620 # Shortcut?
621 if ( !count( $articles ) || !count( $cats ) ) {
622 return;
623 }
624
625 # Look up
626 $catFind = new CategoryFinder;
627 $catFind->seed( $articles, $cats, $opts['categories_any'] ? 'OR' : 'AND' );
628 $match = $catFind->run();
629
630 # Filter
631 $newrows = [];
632 foreach ( $match as $id ) {
633 foreach ( $a2r[$id] as $rev ) {
634 $k = $rev;
635 $newrows[$k] = $rowsarr[$k];
636 }
637 }
638 $rows = $newrows;
639 }
640
650 function makeOptionsLink( $title, $override, $options, $active = false ) {
651 $params = $override + $options;
652
653 // Bug 36524: false values have be converted to "0" otherwise
654 // wfArrayToCgi() will omit it them.
655 foreach ( $params as &$value ) {
656 if ( $value === false ) {
657 $value = '0';
658 }
659 }
660 unset( $value );
661
662 $text = htmlspecialchars( $title );
663 if ( $active ) {
664 $text = '<strong>' . $text . '</strong>';
665 }
666
667 return Linker::linkKnown( $this->getPageTitle(), $text, [], $params );
668 }
669
678 function optionsPanel( $defaults, $nondefaults, $numRows ) {
679 $options = $nondefaults + $defaults;
680
681 $note = '';
682 $msg = $this->msg( 'rclegend' );
683 if ( !$msg->isDisabled() ) {
684 $note .= '<div class="mw-rclegend">' . $msg->parse() . "</div>\n";
685 }
686
687 $lang = $this->getLanguage();
688 $user = $this->getUser();
689 $config = $this->getConfig();
690 if ( $options['from'] ) {
691 $note .= $this->msg( 'rcnotefrom' )
692 ->numParams( $options['limit'] )
693 ->params(
694 $lang->userTimeAndDate( $options['from'], $user ),
695 $lang->userDate( $options['from'], $user ),
696 $lang->userTime( $options['from'], $user )
697 )
698 ->numParams( $numRows )
699 ->parse() . '<br />';
700 }
701
702 # Sort data for display and make sure it's unique after we've added user data.
703 $linkLimits = $config->get( 'RCLinkLimits' );
704 $linkLimits[] = $options['limit'];
705 sort( $linkLimits );
706 $linkLimits = array_unique( $linkLimits );
707
708 $linkDays = $config->get( 'RCLinkDays' );
709 $linkDays[] = $options['days'];
710 sort( $linkDays );
711 $linkDays = array_unique( $linkDays );
712
713 // limit links
714 $cl = [];
715 foreach ( $linkLimits as $value ) {
716 $cl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
717 [ 'limit' => $value ], $nondefaults, $value == $options['limit'] );
718 }
719 $cl = $lang->pipeList( $cl );
720
721 // day links, reset 'from' to none
722 $dl = [];
723 foreach ( $linkDays as $value ) {
724 $dl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
725 [ 'days' => $value, 'from' => '' ], $nondefaults, $value == $options['days'] );
726 }
727 $dl = $lang->pipeList( $dl );
728
729 // show/hide links
730 $filters = [
731 'hideminor' => 'rcshowhideminor',
732 'hidebots' => 'rcshowhidebots',
733 'hideanons' => 'rcshowhideanons',
734 'hideliu' => 'rcshowhideliu',
735 'hidepatrolled' => 'rcshowhidepatr',
736 'hidemyself' => 'rcshowhidemine'
737 ];
738
739 if ( $config->get( 'RCWatchCategoryMembership' ) ) {
740 $filters['hidecategorization'] = 'rcshowhidecategorization';
741 }
742
743 $showhide = [ 'show', 'hide' ];
744
745 foreach ( $this->getCustomFilters() as $key => $params ) {
746 $filters[$key] = $params['msg'];
747 }
748 // Disable some if needed
749 if ( !$user->useRCPatrol() ) {
750 unset( $filters['hidepatrolled'] );
751 }
752
753 $links = [];
754 foreach ( $filters as $key => $msg ) {
755 // The following messages are used here:
756 // rcshowhideminor-show, rcshowhideminor-hide, rcshowhidebots-show, rcshowhidebots-hide,
757 // rcshowhideanons-show, rcshowhideanons-hide, rcshowhideliu-show, rcshowhideliu-hide,
758 // rcshowhidepatr-show, rcshowhidepatr-hide, rcshowhidemine-show, rcshowhidemine-hide,
759 // rcshowhidecategorization-show, rcshowhidecategorization-hide.
760 $linkMessage = $this->msg( $msg . '-' . $showhide[1 - $options[$key]] );
761 // Extensions can define additional filters, but don't need to define the corresponding
762 // messages. If they don't exist, just fall back to 'show' and 'hide'.
763 if ( !$linkMessage->exists() ) {
764 $linkMessage = $this->msg( $showhide[1 - $options[$key]] );
765 }
766
767 $link = $this->makeOptionsLink( $linkMessage->text(),
768 [ $key => 1 - $options[$key] ], $nondefaults );
769 $links[] = "<span class=\"$msg rcshowhideoption\">"
770 . $this->msg( $msg )->rawParams( $link )->escaped() . '</span>';
771 }
772
773 // show from this onward link
775 $now = $lang->userTimeAndDate( $timestamp, $user );
776 $timenow = $lang->userTime( $timestamp, $user );
777 $datenow = $lang->userDate( $timestamp, $user );
778 $pipedLinks = '<span class="rcshowhide">' . $lang->pipeList( $links ) . '</span>';
779
780 $rclinks = '<span class="rclinks">' . $this->msg( 'rclinks' )->rawParams( $cl, $dl, $pipedLinks )
781 ->parse() . '</span>';
782
783 $rclistfrom = '<span class="rclistfrom">' . $this->makeOptionsLink(
784 $this->msg( 'rclistfrom' )->rawParams( $now, $timenow, $datenow )->parse(),
785 [ 'from' => $timestamp ],
786 $nondefaults
787 ) . '</span>';
788
789 return "{$note}$rclinks<br />$rclistfrom";
790 }
791
792 public function isIncludable() {
793 return true;
794 }
795}
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
The "CategoryFinder" class takes a list of articles, creates an internal representation of all their ...
seed( $articleIds, $categories, $mode='AND')
Initializes the instance.
static buildTagFilterSelector( $selected='', $fullForm=false, Title $title=null, $ooui=false)
Build a text box to select a change tag.
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag=false)
Applies all tags-related changes to a query.
Special page which uses a ChangesList to show query results.
getOptions()
Get the current FormOptions for this request.
setBottomText(FormOptions $opts)
Send the text to be displayed after the options.
makeLegend()
Return the legend displayed within the fieldset.
static newFromContext(IContextSource $context)
Fetch an appropriate changes list class for the specified context Some users might want to use an enh...
Helper class to keep track of options when mixing links and form elements.
reset( $name)
Delete the option value.
validateIntBounds( $name, $min, $max)
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition Html.php:210
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
Definition Html.php:847
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition Html.php:759
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known', 'noclasses'])
Identical to link(), except $options defaults to 'known'.
Definition Linker.php:264
static newFromRow( $row)
static selectFields()
Return the list of recentchanges fields that should be selected to create a new recentchanges object.
getName()
Get the name of this Special Page.
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
addFeedLinks( $params)
Adds RSS/atom links.
getContext()
Gets the context this SpecialPage is executed in.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
getPageTitle( $subpage=false)
Get a self-referential title object.
getLanguage()
Shortcut to get user's language.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
including( $x=null)
Whether the special page is being evaluated via transclusion.
msg()
Wrapper around wfMessage that sets the current context.
A special page that lists last changes made to the wiki.
filterByCategories(&$rows, FormOptions $opts)
Filter $rows by categories set in $opts.
optionsPanel( $defaults, $nondefaults, $numRows)
Creates the options panel.
isIncludable()
Whether it's allowed to transclude the special page via {{Special:Foo/params}}.
setTopText(FormOptions $opts)
Send the text to be displayed above the options.
getExtraOptions( $opts)
Get options to be displayed in a form.
makeOptionsLink( $title, $override, $options, $active=false)
Makes change an option link which carries all the other options.
getDB()
Return a IDatabase object for reading.
execute( $subpage)
Main execution point.
addModules()
Add page-specific modules.
getFeedQuery()
Get URL query parameters for action=feedrecentchanges API feed of current recent changes view.
checkLastModified()
Get last modified date, for client caching Don't use this if we are using the patrol feature,...
doHeader( $opts, $numRows)
Set the text to be displayed above the changes.
doMainQuery( $conds, $opts)
Process the query.
parseParameters( $par, FormOptions $opts)
Process $par and put options found in $opts.
buildMainQueryConds(FormOptions $opts)
Return an array of conditions depending of options set in $opts.
categoryFilterForm(FormOptions $opts)
Create an input to filter changes by categories.
__construct( $name='Recentchanges', $restriction='')
namespaceFilterForm(FormOptions $opts)
Creates the choose namespace selection.
validateOptions(FormOptions $opts)
Validate a FormOptions object generated by getDefaultOptions() with values already populated.
getDefaultOptions()
Get a FormOptions object containing the default options.
runMainQueryHook(&$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts)
outputChangesList( $rows, $opts)
Build and output the actual changes list.
outputFeedLinks()
Output feed links.
getCustomFilters()
Get custom show/hide filters.
Represents a page (or page fragment) title within MediaWiki.
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition Title.php:524
static closeElement( $element)
Shortcut to close an XML element.
Definition Xml.php:118
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:400
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
Definition Xml.php:359
static openElement( $element, $attribs=null)
This opens an XML element.
Definition Xml.php:109
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
Definition Xml.php:460
static checkLabel( $label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
Definition Xml.php:420
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition Xml.php:131
static fieldset( $legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
Definition Xml.php:578
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
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 local content language as $wgContLang
Definition design.txt:57
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
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:18
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
const DB_SLAVE
Definition Defines.php:47
const RC_CATEGORIZE
Definition Defines.php:174
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 local account $user
Definition hooks.txt:249
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
Definition hooks.txt:986
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist 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:1042
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:944
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist 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 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:1081
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:846
the value to return A Title object or null for latest to be modified or replaced by the hook handler or if authentication is not possible after cache objects are set for highlighting & $link
Definition hooks.txt:2692
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:314
null for the local 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:1458
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:1597
if( $limit) $timestamp
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:37
Interface for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
Definition Page.php:24
$params
if(!isset( $args[0])) $lang