MediaWiki  1.27.2
SpecialEditWatchlist.php
Go to the documentation of this file.
1 <?php
6 
43  const EDIT_CLEAR = 1;
44  const EDIT_RAW = 2;
45  const EDIT_NORMAL = 3;
46 
47  protected $successMessage;
48 
49  protected $toc;
50 
51  private $badItems = [];
52 
56  private $titleParser;
57 
58  public function __construct() {
59  parent::__construct( 'EditWatchlist', 'editmywatchlist' );
60  }
61 
66  private function initServices() {
67  if ( !$this->titleParser ) {
68  $lang = $this->getContext()->getLanguage();
69  $this->titleParser = new MediaWikiTitleCodec( $lang, GenderCache::singleton() );
70  }
71  }
72 
73  public function doesWrites() {
74  return true;
75  }
76 
82  public function execute( $mode ) {
83  $this->initServices();
84  $this->setHeaders();
85 
86  # Anons don't get a watchlist
87  $this->requireLogin( 'watchlistanontext' );
88 
89  $out = $this->getOutput();
90 
91  $this->checkPermissions();
92  $this->checkReadOnly();
93 
94  $this->outputHeader();
95  $this->outputSubtitle();
96  $out->addModuleStyles( 'mediawiki.special' );
97 
98  # B/C: $mode used to be waaay down the parameter list, and the first parameter
99  # was $wgUser
100  if ( $mode instanceof User ) {
101  $args = func_get_args();
102  if ( count( $args ) >= 4 ) {
103  $mode = $args[3];
104  }
105  }
106  $mode = self::getMode( $this->getRequest(), $mode );
107 
108  switch ( $mode ) {
109  case self::EDIT_RAW:
110  $out->setPageTitle( $this->msg( 'watchlistedit-raw-title' ) );
111  $form = $this->getRawForm();
112  if ( $form->show() ) {
113  $out->addHTML( $this->successMessage );
114  $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
115  }
116  break;
117  case self::EDIT_CLEAR:
118  $out->setPageTitle( $this->msg( 'watchlistedit-clear-title' ) );
119  $form = $this->getClearForm();
120  if ( $form->show() ) {
121  $out->addHTML( $this->successMessage );
122  $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
123  }
124  break;
125 
126  case self::EDIT_NORMAL:
127  default:
128  $this->executeViewEditWatchlist();
129  break;
130  }
131  }
132 
136  protected function outputSubtitle() {
137  $out = $this->getOutput();
138  $out->addSubtitle( $this->msg( 'watchlistfor2', $this->getUser()->getName() )
139  ->rawParams( SpecialEditWatchlist::buildTools( null ) ) );
140  }
141 
146  protected function executeViewEditWatchlist() {
147  $out = $this->getOutput();
148  $out->setPageTitle( $this->msg( 'watchlistedit-normal-title' ) );
149  $form = $this->getNormalForm();
150  if ( $form->show() ) {
151  $out->addHTML( $this->successMessage );
152  $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
153  } elseif ( $this->toc !== false ) {
154  $out->prependHTML( $this->toc );
155  $out->addModules( 'mediawiki.toc' );
156  }
157  }
158 
165  public function getSubpagesForPrefixSearch() {
166  // SpecialWatchlist uses SpecialEditWatchlist::getMode, so new types should be added
167  // here and there - no 'edit' here, because that the default for this page
168  return [
169  'clear',
170  'raw',
171  ];
172  }
173 
181  private function extractTitles( $list ) {
182  $list = explode( "\n", trim( $list ) );
183  if ( !is_array( $list ) ) {
184  return [];
185  }
186 
187  $titles = [];
188 
189  foreach ( $list as $text ) {
190  $text = trim( $text );
191  if ( strlen( $text ) > 0 ) {
192  $title = Title::newFromText( $text );
193  if ( $title instanceof Title && $title->isWatchable() ) {
194  $titles[] = $title;
195  }
196  }
197  }
198 
199  GenderCache::singleton()->doTitlesArray( $titles );
200 
201  $list = [];
203  foreach ( $titles as $title ) {
204  $list[] = $title->getPrefixedText();
205  }
206 
207  return array_unique( $list );
208  }
209 
210  public function submitRaw( $data ) {
211  $wanted = $this->extractTitles( $data['Titles'] );
212  $current = $this->getWatchlist();
213 
214  if ( count( $wanted ) > 0 ) {
215  $toWatch = array_diff( $wanted, $current );
216  $toUnwatch = array_diff( $current, $wanted );
217  $this->watchTitles( $toWatch );
218  $this->unwatchTitles( $toUnwatch );
219  $this->getUser()->invalidateCache();
220 
221  if ( count( $toWatch ) > 0 || count( $toUnwatch ) > 0 ) {
222  $this->successMessage = $this->msg( 'watchlistedit-raw-done' )->parse();
223  } else {
224  return false;
225  }
226 
227  if ( count( $toWatch ) > 0 ) {
228  $this->successMessage .= ' ' . $this->msg( 'watchlistedit-raw-added' )
229  ->numParams( count( $toWatch ) )->parse();
230  $this->showTitles( $toWatch, $this->successMessage );
231  }
232 
233  if ( count( $toUnwatch ) > 0 ) {
234  $this->successMessage .= ' ' . $this->msg( 'watchlistedit-raw-removed' )
235  ->numParams( count( $toUnwatch ) )->parse();
236  $this->showTitles( $toUnwatch, $this->successMessage );
237  }
238  } else {
239  $this->clearWatchlist();
240  $this->getUser()->invalidateCache();
241 
242  if ( count( $current ) > 0 ) {
243  $this->successMessage = $this->msg( 'watchlistedit-raw-done' )->parse();
244  } else {
245  return false;
246  }
247 
248  $this->successMessage .= ' ' . $this->msg( 'watchlistedit-raw-removed' )
249  ->numParams( count( $current ) )->parse();
250  $this->showTitles( $current, $this->successMessage );
251  }
252 
253  return true;
254  }
255 
256  public function submitClear( $data ) {
257  $current = $this->getWatchlist();
258  $this->clearWatchlist();
259  $this->getUser()->invalidateCache();
260  $this->successMessage = $this->msg( 'watchlistedit-clear-done' )->parse();
261  $this->successMessage .= ' ' . $this->msg( 'watchlistedit-clear-removed' )
262  ->numParams( count( $current ) )->parse();
263  $this->showTitles( $current, $this->successMessage );
264 
265  return true;
266  }
267 
277  private function showTitles( $titles, &$output ) {
278  $talk = $this->msg( 'talkpagelinktext' )->escaped();
279  // Do a batch existence check
280  $batch = new LinkBatch();
281  if ( count( $titles ) >= 100 ) {
282  $output = $this->msg( 'watchlistedit-too-many' )->parse();
283  return;
284  }
285  foreach ( $titles as $title ) {
286  if ( !$title instanceof Title ) {
287  $title = Title::newFromText( $title );
288  }
289 
290  if ( $title instanceof Title ) {
291  $batch->addObj( $title );
292  $batch->addObj( $title->getTalkPage() );
293  }
294  }
295 
296  $batch->execute();
297 
298  // Print out the list
299  $output .= "<ul>\n";
300 
301  foreach ( $titles as $title ) {
302  if ( !$title instanceof Title ) {
303  $title = Title::newFromText( $title );
304  }
305 
306  if ( $title instanceof Title ) {
307  $output .= '<li>' .
308  Linker::link( $title ) . ' ' .
309  $this->msg( 'parentheses' )->rawParams(
310  Linker::link( $title->getTalkPage(), $talk )
311  )->escaped() .
312  "</li>\n";
313  }
314  }
315 
316  $output .= "</ul>\n";
317  }
318 
325  private function getWatchlist() {
326  $list = [];
327 
328  $watchedItems = WatchedItemStore::getDefaultInstance()->getWatchedItemsForUser(
329  $this->getUser(),
330  [ 'forWrite' => $this->getRequest()->wasPosted() ]
331  );
332 
333  if ( $watchedItems ) {
335  $titles = [];
336  foreach ( $watchedItems as $watchedItem ) {
337  $namespace = $watchedItem->getLinkTarget()->getNamespace();
338  $dbKey = $watchedItem->getLinkTarget()->getDBkey();
339  $title = Title::makeTitleSafe( $namespace, $dbKey );
340 
341  if ( $this->checkTitle( $title, $namespace, $dbKey )
342  && !$title->isTalkPage()
343  ) {
344  $titles[] = $title;
345  }
346  }
347 
348  GenderCache::singleton()->doTitlesArray( $titles );
349 
350  foreach ( $titles as $title ) {
351  $list[] = $title->getPrefixedText();
352  }
353  }
354 
355  $this->cleanupWatchlist();
356 
357  return $list;
358  }
359 
366  protected function getWatchlistInfo() {
367  $titles = [];
368 
369  $watchedItems = WatchedItemStore::getDefaultInstance()
370  ->getWatchedItemsForUser( $this->getUser(), [ 'sort' => WatchedItemStore::SORT_ASC ] );
371 
372  $lb = new LinkBatch();
373 
374  foreach ( $watchedItems as $watchedItem ) {
375  $namespace = $watchedItem->getLinkTarget()->getNamespace();
376  $dbKey = $watchedItem->getLinkTarget()->getDBkey();
377  $lb->add( $namespace, $dbKey );
378  if ( !MWNamespace::isTalk( $namespace ) ) {
379  $titles[$namespace][$dbKey] = 1;
380  }
381  }
382 
383  $lb->execute();
384 
385  return $titles;
386  }
387 
396  private function checkTitle( $title, $namespace, $dbKey ) {
397  if ( $title
398  && ( $title->isExternal()
399  || $title->getNamespace() < 0
400  )
401  ) {
402  $title = false; // unrecoverable
403  }
404 
405  if ( !$title
406  || $title->getNamespace() != $namespace
407  || $title->getDBkey() != $dbKey
408  ) {
409  $this->badItems[] = [ $title, $namespace, $dbKey ];
410  }
411 
412  return (bool)$title;
413  }
414 
418  private function cleanupWatchlist() {
419  if ( !count( $this->badItems ) ) {
420  return; // nothing to do
421  }
422 
423  $user = $this->getUser();
425 
426  foreach ( $this->badItems as $row ) {
427  list( $title, $namespace, $dbKey ) = $row;
428  $action = $title ? 'cleaning up' : 'deleting';
429  wfDebug( "User {$user->getName()} has broken watchlist item ns($namespace):$dbKey, $action.\n" );
430 
431  $store->removeWatch( $user, new TitleValue( (int)$namespace, $dbKey ) );
432 
433  // Can't just do an UPDATE instead of DELETE/INSERT due to unique index
434  if ( $title ) {
435  $user->addWatch( $title );
436  }
437  }
438  }
439 
443  private function clearWatchlist() {
444  $dbw = wfGetDB( DB_MASTER );
445  $dbw->delete(
446  'watchlist',
447  [ 'wl_user' => $this->getUser()->getId() ],
448  __METHOD__
449  );
450  }
451 
457  private function watchTitles( $targets ) {
458  $expandedTargets = [];
459  foreach ( $targets as $target ) {
460  if ( !$target instanceof LinkTarget ) {
461  try {
462  $target = $this->titleParser->parseTitle( $target, NS_MAIN );
463  }
464  catch ( MalformedTitleException $e ) {
465  continue;
466  }
467  }
468 
469  $ns = $target->getNamespace();
470  $dbKey = $target->getDBkey();
471  $expandedTargets[] = new TitleValue( MWNamespace::getSubject( $ns ), $dbKey );
472  $expandedTargets[] = new TitleValue( MWNamespace::getTalk( $ns ), $dbKey );
473  }
474 
475  WatchedItemStore::getDefaultInstance()->addWatchBatchForUser(
476  $this->getUser(),
477  $expandedTargets
478  );
479  }
480 
489  private function unwatchTitles( $titles ) {
491 
492  foreach ( $titles as $title ) {
493  if ( !$title instanceof Title ) {
494  $title = Title::newFromText( $title );
495  }
496 
497  if ( $title instanceof Title ) {
498  $store->removeWatch( $this->getUser(), $title->getSubjectPage() );
499  $store->removeWatch( $this->getUser(), $title->getTalkPage() );
500 
501  $page = WikiPage::factory( $title );
502  Hooks::run( 'UnwatchArticleComplete', [ $this->getUser(), &$page ] );
503  }
504  }
505  }
506 
507  public function submitNormal( $data ) {
508  $removed = [];
509 
510  foreach ( $data as $titles ) {
511  $this->unwatchTitles( $titles );
512  $removed = array_merge( $removed, $titles );
513  }
514 
515  if ( count( $removed ) > 0 ) {
516  $this->successMessage = $this->msg( 'watchlistedit-normal-done'
517  )->numParams( count( $removed ) )->parse();
518  $this->showTitles( $removed, $this->successMessage );
519 
520  return true;
521  } else {
522  return false;
523  }
524  }
525 
531  protected function getNormalForm() {
533 
534  $fields = [];
535  $count = 0;
536 
537  // Allow subscribers to manipulate the list of watched pages (or use it
538  // to preload lots of details at once)
539  $watchlistInfo = $this->getWatchlistInfo();
540  Hooks::run(
541  'WatchlistEditorBeforeFormRender',
542  [ &$watchlistInfo ]
543  );
544 
545  foreach ( $watchlistInfo as $namespace => $pages ) {
546  $options = [];
547 
548  foreach ( array_keys( $pages ) as $dbkey ) {
549  $title = Title::makeTitleSafe( $namespace, $dbkey );
550 
551  if ( $this->checkTitle( $title, $namespace, $dbkey ) ) {
552  $text = $this->buildRemoveLine( $title );
553  $options[$text] = $title->getPrefixedText();
554  $count++;
555  }
556  }
557 
558  // checkTitle can filter some options out, avoid empty sections
559  if ( count( $options ) > 0 ) {
560  $fields['TitlesNs' . $namespace] = [
561  'class' => 'EditWatchlistCheckboxSeriesField',
562  'options' => $options,
563  'section' => "ns$namespace",
564  ];
565  }
566  }
567  $this->cleanupWatchlist();
568 
569  if ( count( $fields ) > 1 && $count > 30 ) {
570  $this->toc = Linker::tocIndent();
571  $tocLength = 0;
572 
573  foreach ( $fields as $data ) {
574  # strip out the 'ns' prefix from the section name:
575  $ns = substr( $data['section'], 2 );
576 
577  $nsText = ( $ns == NS_MAIN )
578  ? $this->msg( 'blanknamespace' )->escaped()
579  : htmlspecialchars( $wgContLang->getFormattedNsText( $ns ) );
580  $this->toc .= Linker::tocLine( "editwatchlist-{$data['section']}", $nsText,
581  $this->getLanguage()->formatNum( ++$tocLength ), 1 ) . Linker::tocLineEnd();
582  }
583 
584  $this->toc = Linker::tocList( $this->toc );
585  } else {
586  $this->toc = false;
587  }
588 
589  $context = new DerivativeContext( $this->getContext() );
590  $context->setTitle( $this->getPageTitle() ); // Remove subpage
591  $form = new EditWatchlistNormalHTMLForm( $fields, $context );
592  $form->setSubmitTextMsg( 'watchlistedit-normal-submit' );
593  $form->setSubmitDestructive();
594  # Used message keys:
595  # 'accesskey-watchlistedit-normal-submit', 'tooltip-watchlistedit-normal-submit'
596  $form->setSubmitTooltip( 'watchlistedit-normal-submit' );
597  $form->setWrapperLegendMsg( 'watchlistedit-normal-legend' );
598  $form->addHeaderText( $this->msg( 'watchlistedit-normal-explain' )->parse() );
599  $form->setSubmitCallback( [ $this, 'submitNormal' ] );
600 
601  return $form;
602  }
603 
610  private function buildRemoveLine( $title ) {
612 
613  $tools['talk'] = Linker::link(
614  $title->getTalkPage(),
615  $this->msg( 'talkpagelinktext' )->escaped()
616  );
617 
618  if ( $title->exists() ) {
619  $tools['history'] = Linker::linkKnown(
620  $title,
621  $this->msg( 'history_short' )->escaped(),
622  [],
623  [ 'action' => 'history' ]
624  );
625  }
626 
627  if ( $title->getNamespace() == NS_USER && !$title->isSubpage() ) {
628  $tools['contributions'] = Linker::linkKnown(
629  SpecialPage::getTitleFor( 'Contributions', $title->getText() ),
630  $this->msg( 'contributions' )->escaped()
631  );
632  }
633 
634  Hooks::run(
635  'WatchlistEditorBuildRemoveLine',
636  [ &$tools, $title, $title->isRedirect(), $this->getSkin(), &$link ]
637  );
638 
639  if ( $title->isRedirect() ) {
640  // Linker already makes class mw-redirect, so this is redundant
641  $link = '<span class="watchlistredir">' . $link . '</span>';
642  }
643 
644  return $link . ' ' .
645  $this->msg( 'parentheses' )->rawParams( $this->getLanguage()->pipeList( $tools ) )->escaped();
646  }
647 
653  protected function getRawForm() {
654  $titles = implode( $this->getWatchlist(), "\n" );
655  $fields = [
656  'Titles' => [
657  'type' => 'textarea',
658  'label-message' => 'watchlistedit-raw-titles',
659  'default' => $titles,
660  ],
661  ];
662  $context = new DerivativeContext( $this->getContext() );
663  $context->setTitle( $this->getPageTitle( 'raw' ) ); // Reset subpage
664  $form = new HTMLForm( $fields, $context );
665  $form->setSubmitTextMsg( 'watchlistedit-raw-submit' );
666  # Used message keys: 'accesskey-watchlistedit-raw-submit', 'tooltip-watchlistedit-raw-submit'
667  $form->setSubmitTooltip( 'watchlistedit-raw-submit' );
668  $form->setWrapperLegendMsg( 'watchlistedit-raw-legend' );
669  $form->addHeaderText( $this->msg( 'watchlistedit-raw-explain' )->parse() );
670  $form->setSubmitCallback( [ $this, 'submitRaw' ] );
671 
672  return $form;
673  }
674 
680  protected function getClearForm() {
681  $context = new DerivativeContext( $this->getContext() );
682  $context->setTitle( $this->getPageTitle( 'clear' ) ); // Reset subpage
683  $form = new HTMLForm( [], $context );
684  $form->setSubmitTextMsg( 'watchlistedit-clear-submit' );
685  # Used message keys: 'accesskey-watchlistedit-clear-submit', 'tooltip-watchlistedit-clear-submit'
686  $form->setSubmitTooltip( 'watchlistedit-clear-submit' );
687  $form->setWrapperLegendMsg( 'watchlistedit-clear-legend' );
688  $form->addHeaderText( $this->msg( 'watchlistedit-clear-explain' )->parse() );
689  $form->setSubmitCallback( [ $this, 'submitClear' ] );
690  $form->setSubmitDestructive();
691 
692  return $form;
693  }
694 
703  public static function getMode( $request, $par ) {
704  $mode = strtolower( $request->getVal( 'action', $par ) );
705 
706  switch ( $mode ) {
707  case 'clear':
708  case self::EDIT_CLEAR:
709  return self::EDIT_CLEAR;
710  case 'raw':
711  case self::EDIT_RAW:
712  return self::EDIT_RAW;
713  case 'edit':
714  case self::EDIT_NORMAL:
715  return self::EDIT_NORMAL;
716  default:
717  return false;
718  }
719  }
720 
728  public static function buildTools( $unused ) {
729  global $wgLang;
730 
731  $tools = [];
732  $modes = [
733  'view' => [ 'Watchlist', false ],
734  'edit' => [ 'EditWatchlist', false ],
735  'raw' => [ 'EditWatchlist', 'raw' ],
736  'clear' => [ 'EditWatchlist', 'clear' ],
737  ];
738 
739  foreach ( $modes as $mode => $arr ) {
740  // can use messages 'watchlisttools-view', 'watchlisttools-edit', 'watchlisttools-raw'
741  $tools[] = Linker::linkKnown(
742  SpecialPage::getTitleFor( $arr[0], $arr[1] ),
743  wfMessage( "watchlisttools-{$mode}" )->escaped()
744  );
745  }
746 
747  return Html::rawElement(
748  'span',
749  [ 'class' => 'mw-watchlist-toollinks' ],
750  wfMessage( 'parentheses' )->rawParams( $wgLang->pipeList( $tools ) )->escaped()
751  );
752  }
753 }
754 
759  public function getLegend( $namespace ) {
760  $namespace = substr( $namespace, 2 );
761 
762  return $namespace == NS_MAIN
763  ? $this->msg( 'blanknamespace' )->escaped()
764  : htmlspecialchars( $this->getContext()->getLanguage()->getFormattedNsText( $namespace ) );
765  }
766 
767  public function getBody() {
768  return $this->displaySection( $this->mFieldTree, '', 'editwatchlist-' );
769  }
770 }
771 
784  function validate( $value, $alldata ) {
785  // Need to call into grandparent to be a good citizen. :)
786  return HTMLFormField::validate( $value, $alldata );
787  }
788 }
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:99
A codec for MediaWiki page titles.
static tocLineEnd()
End a Table Of Contents line.
Definition: Linker.php:1734
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
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
static tocList($toc, $lang=false)
Wraps the TOC in a table and provides the hide/collapse javascript.
Definition: Linker.php:1745
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:762
getLanguage()
Get the Language object.
Shortcut to construct a special page which is unlisted by default.
static linkKnown($target, $html=null, $customAttribs=[], $query=[], $options=[ 'known', 'noclasses'])
Identical to link(), except $options defaults to 'known'.
Definition: Linker.php:264
MalformedTitleException is thrown when a TitleParser is unable to parse a title string.
$context
Definition: load.php:44
getContext()
Gets the context this SpecialPage is executed in.
const NS_MAIN
Definition: Defines.php:69
buildRemoveLine($title)
Build the label for a checkbox, with a link to the title, and various additional bits.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
static getTitleFor($name, $subpage=false, $fragment= '')
Get a localised Title object for a specified special page name.
Definition: SpecialPage.php:75
const EDIT_CLEAR
Editing modes.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
Definition: hooks.txt:1932
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
Definition: Html.php:210
static singleton()
Definition: GenderCache.php:39
if(!isset($args[0])) $lang
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
getClearForm()
Get a form for clearing the watchlist.
cleanupWatchlist()
Attempts to clean up broken items.
static isTalk($index)
Is the given namespace a talk namespace?
Definition: MWNamespace.php:97
An IContextSource implementation which will inherit context from another source but allow individual ...
extractTitles($list)
Extract a list of titles from a blob of text, returning (prefixed) strings; unwatchable titles are ig...
Represents a page (or page fragment) title within MediaWiki.
Definition: TitleValue.php:36
$value
getRawForm()
Get a form for editing the watchlist in "raw" mode.
msg()
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:277
Represents a title within MediaWiki.
Definition: Title.php:34
when a variable name is used in a it is silently declared as a new local masking the global
Definition: design.txt:93
checkTitle($title, $namespace, $dbKey)
Validates watchlist entry.
getWatchlist()
Prepare a list of titles on a user's watchlist (excluding talk pages) and return an array of (prefixe...
clearWatchlist()
Remove all titles from a user's watchlist.
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
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 $wgLang
Definition: design.txt:56
outputHeader($summaryMessageKey= '')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
if($line===false) $args
Definition: cdb.php:64
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:2581
$batch
Definition: linkcache.txt:23
getSubpagesForPrefixSearch()
Return an array of subpages that this special page will accept.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:31
Multi-select field.
msg()
Get a Message object with context set Parameters are the same as wfMessage()
showTitles($titles, &$output)
Print out a list of linked titles.
validate($value, $alldata)
Override this function to add specific validation checks on the field input.
getNormalForm()
Get the standard watchlist editing form.
unwatchTitles($titles)
Remove a list of titles from a user's watchlist.
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:1004
execute($mode)
Main execution point.
Extend HTMLForm purely so we can have a more sane way of getting the section headers.
validate($value, $alldata)
HTMLMultiSelectField throws validation errors if we get input data that doesn't match the data set in...
initServices()
Initialize any services we'll need (unless it has already been provided via a setter).
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 after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock()-offset Set to overwrite offset parameter in $wgRequest set to ''to unsetoffset-wrap String Wrap the message in html(usually something like"&lt
getContext()
Get the base IContextSource object.
getSkin()
Shortcut to get the skin being used for this instance.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
Object handling generic submission, CSRF protection, layout and other logic for UI forms...
Definition: HTMLForm.php:123
static makeTitleSafe($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:548
watchTitles($targets)
Add a list of targets to a user's watchlist.
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:912
static getMode($request, $par)
Determine whether we are editing the watchlist, and if so, what kind of editing operation.
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
static tocLine($anchor, $tocline, $tocnumber, $level, $sectionIndex=false)
parameter level defines if we are on an indentation level
Definition: Linker.php:1717
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
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:242
static link($target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
Definition: Linker.php:195
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 & $output
Definition: hooks.txt:1004
displaySection($fields, $sectionName= '', $fieldsetIDPrefix= '', &$hasUserVisibleFields=false)
Definition: HTMLForm.php:1476
outputSubtitle()
Renders a subheader on the watchlist page.
static getTalk($index)
Get the talk namespace index for a given namespace.
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
error also a ContextSource you ll probably need to make sure the header is varied on $request
Definition: hooks.txt:2418
getName()
Get the name of this Special Page.
linkcache txt The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database This is used to mark up links when displaying a page If the same link appears more than once on any page then it only has to be looked up once In most cases link lookups are done in batches with the LinkBatch class or the equivalent in so the link cache is mostly useful for short snippets of parsed and for links in the navigation areas of the skin The link cache was formerly used to track links used in a document for the purposes of updating the link tables This application is now deprecated To create a you can use the following $titles
Definition: linkcache.txt:17
requireLogin($reasonMsg= 'exception-nologin-text', $titleMsg= 'exception-nologin')
If the user is not logged in, throws UserNotLoggedIn error.
getUser()
Shortcut to get the User executing this instance.
getLanguage()
Shortcut to get user's language.
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:56
getWatchlistInfo()
Get a list of titles on a user's watchlist, excluding talk pages, and return as a two-dimensional arr...
static buildTools($unused)
Build a set of links for convenient navigation between watchlist viewing and editing modes...
$count
static tocIndent()
Add another level to the Table of Contents.
Definition: Linker.php:1693
const DB_MASTER
Definition: Defines.php:47
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
getRequest()
Get the WebRequest being used for this instance.
executeViewEditWatchlist()
Executes an edit mode for the watchlist view, from which you can manage your watchlist.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
static getSubject($index)
Get the subject namespace index for a given namespace Special namespaces (NS_MEDIA, NS_SPECIAL) are always the subject.
Provides the UI through which users can perform editing operations on their watchlist.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
Definition: hooks.txt:2338
getPageTitle($subpage=false)
Get a self-referential title object.