MediaWiki  1.30.0
SpecialEditWatchlist.php
Go to the documentation of this file.
1 <?php
32 
46  const EDIT_CLEAR = 1;
47  const EDIT_RAW = 2;
48  const EDIT_NORMAL = 3;
49 
50  protected $successMessage;
51 
52  protected $toc;
53 
54  private $badItems = [];
55 
59  private $titleParser;
60 
61  public function __construct() {
62  parent::__construct( 'EditWatchlist', 'editmywatchlist' );
63  }
64 
69  private function initServices() {
70  if ( !$this->titleParser ) {
71  $this->titleParser = MediaWikiServices::getInstance()->getTitleParser();
72  }
73  }
74 
75  public function doesWrites() {
76  return true;
77  }
78 
84  public function execute( $mode ) {
85  $this->initServices();
86  $this->setHeaders();
87 
88  # Anons don't get a watchlist
89  $this->requireLogin( 'watchlistanontext' );
90 
91  $out = $this->getOutput();
92 
93  $this->checkPermissions();
94  $this->checkReadOnly();
95 
96  $this->outputHeader();
97  $this->outputSubtitle();
98  $out->addModuleStyles( 'mediawiki.special' );
99 
100  # B/C: $mode used to be waaay down the parameter list, and the first parameter
101  # was $wgUser
102  if ( $mode instanceof User ) {
103  $args = func_get_args();
104  if ( count( $args ) >= 4 ) {
105  $mode = $args[3];
106  }
107  }
108  $mode = self::getMode( $this->getRequest(), $mode );
109 
110  switch ( $mode ) {
111  case self::EDIT_RAW:
112  $out->setPageTitle( $this->msg( 'watchlistedit-raw-title' ) );
113  $form = $this->getRawForm();
114  if ( $form->show() ) {
115  $out->addHTML( $this->successMessage );
116  $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
117  }
118  break;
119  case self::EDIT_CLEAR:
120  $out->setPageTitle( $this->msg( 'watchlistedit-clear-title' ) );
121  $form = $this->getClearForm();
122  if ( $form->show() ) {
123  $out->addHTML( $this->successMessage );
124  $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
125  }
126  break;
127 
128  case self::EDIT_NORMAL:
129  default:
130  $this->executeViewEditWatchlist();
131  break;
132  }
133  }
134 
138  protected function outputSubtitle() {
139  $out = $this->getOutput();
140  $out->addSubtitle( $this->msg( 'watchlistfor2', $this->getUser()->getName() )
141  ->rawParams(
142  self::buildTools(
143  $this->getLanguage(),
144  $this->getLinkRenderer()
145  )
146  )
147  );
148  }
149 
153  protected function executeViewEditWatchlist() {
154  $out = $this->getOutput();
155  $out->setPageTitle( $this->msg( 'watchlistedit-normal-title' ) );
156  $form = $this->getNormalForm();
157  if ( $form->show() ) {
158  $out->addHTML( $this->successMessage );
159  $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
160  } elseif ( $this->toc !== false ) {
161  $out->prependHTML( $this->toc );
162  $out->addModules( 'mediawiki.toc' );
163  }
164  }
165 
172  public function getSubpagesForPrefixSearch() {
173  // SpecialWatchlist uses SpecialEditWatchlist::getMode, so new types should be added
174  // here and there - no 'edit' here, because that the default for this page
175  return [
176  'clear',
177  'raw',
178  ];
179  }
180 
188  private function extractTitles( $list ) {
189  $list = explode( "\n", trim( $list ) );
190  if ( !is_array( $list ) ) {
191  return [];
192  }
193 
194  $titles = [];
195 
196  foreach ( $list as $text ) {
197  $text = trim( $text );
198  if ( strlen( $text ) > 0 ) {
199  $title = Title::newFromText( $text );
200  if ( $title instanceof Title && $title->isWatchable() ) {
201  $titles[] = $title;
202  }
203  }
204  }
205 
206  MediaWikiServices::getInstance()->getGenderCache()->doTitlesArray( $titles );
207 
208  $list = [];
210  foreach ( $titles as $title ) {
211  $list[] = $title->getPrefixedText();
212  }
213 
214  return array_unique( $list );
215  }
216 
217  public function submitRaw( $data ) {
218  $wanted = $this->extractTitles( $data['Titles'] );
219  $current = $this->getWatchlist();
220 
221  if ( count( $wanted ) > 0 ) {
222  $toWatch = array_diff( $wanted, $current );
223  $toUnwatch = array_diff( $current, $wanted );
224  $this->watchTitles( $toWatch );
225  $this->unwatchTitles( $toUnwatch );
226  $this->getUser()->invalidateCache();
227 
228  if ( count( $toWatch ) > 0 || count( $toUnwatch ) > 0 ) {
229  $this->successMessage = $this->msg( 'watchlistedit-raw-done' )->parse();
230  } else {
231  return false;
232  }
233 
234  if ( count( $toWatch ) > 0 ) {
235  $this->successMessage .= ' ' . $this->msg( 'watchlistedit-raw-added' )
236  ->numParams( count( $toWatch ) )->parse();
237  $this->showTitles( $toWatch, $this->successMessage );
238  }
239 
240  if ( count( $toUnwatch ) > 0 ) {
241  $this->successMessage .= ' ' . $this->msg( 'watchlistedit-raw-removed' )
242  ->numParams( count( $toUnwatch ) )->parse();
243  $this->showTitles( $toUnwatch, $this->successMessage );
244  }
245  } else {
246  $this->clearWatchlist();
247  $this->getUser()->invalidateCache();
248 
249  if ( count( $current ) > 0 ) {
250  $this->successMessage = $this->msg( 'watchlistedit-raw-done' )->parse();
251  } else {
252  return false;
253  }
254 
255  $this->successMessage .= ' ' . $this->msg( 'watchlistedit-raw-removed' )
256  ->numParams( count( $current ) )->parse();
257  $this->showTitles( $current, $this->successMessage );
258  }
259 
260  return true;
261  }
262 
263  public function submitClear( $data ) {
264  $current = $this->getWatchlist();
265  $this->clearWatchlist();
266  $this->getUser()->invalidateCache();
267  $this->successMessage = $this->msg( 'watchlistedit-clear-done' )->parse();
268  $this->successMessage .= ' ' . $this->msg( 'watchlistedit-clear-removed' )
269  ->numParams( count( $current ) )->parse();
270  $this->showTitles( $current, $this->successMessage );
271 
272  return true;
273  }
274 
284  private function showTitles( $titles, &$output ) {
285  $talk = $this->msg( 'talkpagelinktext' )->text();
286  // Do a batch existence check
287  $batch = new LinkBatch();
288  if ( count( $titles ) >= 100 ) {
289  $output = $this->msg( 'watchlistedit-too-many' )->parse();
290  return;
291  }
292  foreach ( $titles as $title ) {
293  if ( !$title instanceof Title ) {
295  }
296 
297  if ( $title instanceof Title ) {
298  $batch->addObj( $title );
299  $batch->addObj( $title->getTalkPage() );
300  }
301  }
302 
303  $batch->execute();
304 
305  // Print out the list
306  $output .= "<ul>\n";
307 
308  $linkRenderer = $this->getLinkRenderer();
309  foreach ( $titles as $title ) {
310  if ( !$title instanceof Title ) {
312  }
313 
314  if ( $title instanceof Title ) {
315  $output .= '<li>' .
316  $linkRenderer->makeLink( $title ) . ' ' .
317  $this->msg( 'parentheses' )->rawParams(
318  $linkRenderer->makeLink( $title->getTalkPage(), $talk )
319  )->escaped() .
320  "</li>\n";
321  }
322  }
323 
324  $output .= "</ul>\n";
325  }
326 
333  private function getWatchlist() {
334  $list = [];
335 
336  $watchedItems = MediaWikiServices::getInstance()->getWatchedItemStore()->getWatchedItemsForUser(
337  $this->getUser(),
338  [ 'forWrite' => $this->getRequest()->wasPosted() ]
339  );
340 
341  if ( $watchedItems ) {
343  $titles = [];
344  foreach ( $watchedItems as $watchedItem ) {
345  $namespace = $watchedItem->getLinkTarget()->getNamespace();
346  $dbKey = $watchedItem->getLinkTarget()->getDBkey();
347  $title = Title::makeTitleSafe( $namespace, $dbKey );
348 
349  if ( $this->checkTitle( $title, $namespace, $dbKey )
350  && !$title->isTalkPage()
351  ) {
352  $titles[] = $title;
353  }
354  }
355 
356  MediaWikiServices::getInstance()->getGenderCache()->doTitlesArray( $titles );
357 
358  foreach ( $titles as $title ) {
359  $list[] = $title->getPrefixedText();
360  }
361  }
362 
363  $this->cleanupWatchlist();
364 
365  return $list;
366  }
367 
374  protected function getWatchlistInfo() {
375  $titles = [];
376 
377  $watchedItems = MediaWikiServices::getInstance()->getWatchedItemStore()
378  ->getWatchedItemsForUser( $this->getUser(), [ 'sort' => WatchedItemStore::SORT_ASC ] );
379 
380  $lb = new LinkBatch();
381 
382  foreach ( $watchedItems as $watchedItem ) {
383  $namespace = $watchedItem->getLinkTarget()->getNamespace();
384  $dbKey = $watchedItem->getLinkTarget()->getDBkey();
385  $lb->add( $namespace, $dbKey );
386  if ( !MWNamespace::isTalk( $namespace ) ) {
387  $titles[$namespace][$dbKey] = 1;
388  }
389  }
390 
391  $lb->execute();
392 
393  return $titles;
394  }
395 
404  private function checkTitle( $title, $namespace, $dbKey ) {
405  if ( $title
406  && ( $title->isExternal()
407  || $title->getNamespace() < 0
408  )
409  ) {
410  $title = false; // unrecoverable
411  }
412 
413  if ( !$title
414  || $title->getNamespace() != $namespace
415  || $title->getDBkey() != $dbKey
416  ) {
417  $this->badItems[] = [ $title, $namespace, $dbKey ];
418  }
419 
420  return (bool)$title;
421  }
422 
426  private function cleanupWatchlist() {
427  if ( !count( $this->badItems ) ) {
428  return; // nothing to do
429  }
430 
431  $user = $this->getUser();
434  $store = MediaWikiServices::getInstance()->getWatchedItemStore();
435  foreach ( $badItems as $row ) {
436  list( $title, $namespace, $dbKey ) = $row;
437  $action = $title ? 'cleaning up' : 'deleting';
438  wfDebug( "User {$user->getName()} has broken watchlist item " .
439  "ns($namespace):$dbKey, $action.\n" );
440 
441  $store->removeWatch( $user, new TitleValue( (int)$namespace, $dbKey ) );
442  // Can't just do an UPDATE instead of DELETE/INSERT due to unique index
443  if ( $title ) {
444  $user->addWatch( $title );
445  }
446  }
447  } );
448  }
449 
453  private function clearWatchlist() {
454  $dbw = wfGetDB( DB_MASTER );
455  $dbw->delete(
456  'watchlist',
457  [ 'wl_user' => $this->getUser()->getId() ],
458  __METHOD__
459  );
460  }
461 
467  private function watchTitles( $targets ) {
468  $expandedTargets = [];
469  foreach ( $targets as $target ) {
470  if ( !$target instanceof LinkTarget ) {
471  try {
472  $target = $this->titleParser->parseTitle( $target, NS_MAIN );
473  }
474  catch ( MalformedTitleException $e ) {
475  continue;
476  }
477  }
478 
479  $ns = $target->getNamespace();
480  $dbKey = $target->getDBkey();
481  $expandedTargets[] = new TitleValue( MWNamespace::getSubject( $ns ), $dbKey );
482  $expandedTargets[] = new TitleValue( MWNamespace::getTalk( $ns ), $dbKey );
483  }
484 
485  MediaWikiServices::getInstance()->getWatchedItemStore()->addWatchBatchForUser(
486  $this->getUser(),
487  $expandedTargets
488  );
489  }
490 
499  private function unwatchTitles( $titles ) {
500  $store = MediaWikiServices::getInstance()->getWatchedItemStore();
501 
502  foreach ( $titles as $title ) {
503  if ( !$title instanceof Title ) {
505  }
506 
507  if ( $title instanceof Title ) {
508  $store->removeWatch( $this->getUser(), $title->getSubjectPage() );
509  $store->removeWatch( $this->getUser(), $title->getTalkPage() );
510 
511  $page = WikiPage::factory( $title );
512  Hooks::run( 'UnwatchArticleComplete', [ $this->getUser(), &$page ] );
513  }
514  }
515  }
516 
517  public function submitNormal( $data ) {
518  $removed = [];
519 
520  foreach ( $data as $titles ) {
521  $this->unwatchTitles( $titles );
522  $removed = array_merge( $removed, $titles );
523  }
524 
525  if ( count( $removed ) > 0 ) {
526  $this->successMessage = $this->msg( 'watchlistedit-normal-done'
527  )->numParams( count( $removed ) )->parse();
528  $this->showTitles( $removed, $this->successMessage );
529 
530  return true;
531  } else {
532  return false;
533  }
534  }
535 
541  protected function getNormalForm() {
543 
544  $fields = [];
545  $count = 0;
546 
547  // Allow subscribers to manipulate the list of watched pages (or use it
548  // to preload lots of details at once)
549  $watchlistInfo = $this->getWatchlistInfo();
550  Hooks::run(
551  'WatchlistEditorBeforeFormRender',
552  [ &$watchlistInfo ]
553  );
554 
555  foreach ( $watchlistInfo as $namespace => $pages ) {
556  $options = [];
557 
558  foreach ( array_keys( $pages ) as $dbkey ) {
559  $title = Title::makeTitleSafe( $namespace, $dbkey );
560 
561  if ( $this->checkTitle( $title, $namespace, $dbkey ) ) {
562  $text = $this->buildRemoveLine( $title );
563  $options[$text] = $title->getPrefixedText();
564  $count++;
565  }
566  }
567 
568  // checkTitle can filter some options out, avoid empty sections
569  if ( count( $options ) > 0 ) {
570  $fields['TitlesNs' . $namespace] = [
571  'class' => 'EditWatchlistCheckboxSeriesField',
572  'options' => $options,
573  'section' => "ns$namespace",
574  ];
575  }
576  }
577  $this->cleanupWatchlist();
578 
579  if ( count( $fields ) > 1 && $count > 30 ) {
580  $this->toc = Linker::tocIndent();
581  $tocLength = 0;
582 
583  foreach ( $fields as $data ) {
584  # strip out the 'ns' prefix from the section name:
585  $ns = substr( $data['section'], 2 );
586 
587  $nsText = ( $ns == NS_MAIN )
588  ? $this->msg( 'blanknamespace' )->escaped()
589  : htmlspecialchars( $wgContLang->getFormattedNsText( $ns ) );
590  $this->toc .= Linker::tocLine( "editwatchlist-{$data['section']}", $nsText,
591  $this->getLanguage()->formatNum( ++$tocLength ), 1 ) . Linker::tocLineEnd();
592  }
593 
594  $this->toc = Linker::tocList( $this->toc );
595  } else {
596  $this->toc = false;
597  }
598 
599  $context = new DerivativeContext( $this->getContext() );
600  $context->setTitle( $this->getPageTitle() ); // Remove subpage
601  $form = new EditWatchlistNormalHTMLForm( $fields, $context );
602  $form->setSubmitTextMsg( 'watchlistedit-normal-submit' );
603  $form->setSubmitDestructive();
604  # Used message keys:
605  # 'accesskey-watchlistedit-normal-submit', 'tooltip-watchlistedit-normal-submit'
606  $form->setSubmitTooltip( 'watchlistedit-normal-submit' );
607  $form->setWrapperLegendMsg( 'watchlistedit-normal-legend' );
608  $form->addHeaderText( $this->msg( 'watchlistedit-normal-explain' )->parse() );
609  $form->setSubmitCallback( [ $this, 'submitNormal' ] );
610 
611  return $form;
612  }
613 
620  private function buildRemoveLine( $title ) {
621  $linkRenderer = $this->getLinkRenderer();
622  $link = $linkRenderer->makeLink( $title );
623 
624  $tools['talk'] = $linkRenderer->makeLink(
625  $title->getTalkPage(),
626  $this->msg( 'talkpagelinktext' )->text()
627  );
628 
629  if ( $title->exists() ) {
630  $tools['history'] = $linkRenderer->makeKnownLink(
631  $title,
632  $this->msg( 'history_small' )->text(),
633  [],
634  [ 'action' => 'history' ]
635  );
636  }
637 
638  if ( $title->getNamespace() == NS_USER && !$title->isSubpage() ) {
639  $tools['contributions'] = $linkRenderer->makeKnownLink(
640  SpecialPage::getTitleFor( 'Contributions', $title->getText() ),
641  $this->msg( 'contributions' )->text()
642  );
643  }
644 
645  Hooks::run(
646  'WatchlistEditorBuildRemoveLine',
647  [ &$tools, $title, $title->isRedirect(), $this->getSkin(), &$link ]
648  );
649 
650  if ( $title->isRedirect() ) {
651  // Linker already makes class mw-redirect, so this is redundant
652  $link = '<span class="watchlistredir">' . $link . '</span>';
653  }
654 
655  return $link . ' ' .
656  $this->msg( 'parentheses' )->rawParams( $this->getLanguage()->pipeList( $tools ) )->escaped();
657  }
658 
664  protected function getRawForm() {
665  $titles = implode( $this->getWatchlist(), "\n" );
666  $fields = [
667  'Titles' => [
668  'type' => 'textarea',
669  'label-message' => 'watchlistedit-raw-titles',
670  'default' => $titles,
671  ],
672  ];
673  $context = new DerivativeContext( $this->getContext() );
674  $context->setTitle( $this->getPageTitle( 'raw' ) ); // Reset subpage
675  $form = new HTMLForm( $fields, $context );
676  $form->setSubmitTextMsg( 'watchlistedit-raw-submit' );
677  # Used message keys: 'accesskey-watchlistedit-raw-submit', 'tooltip-watchlistedit-raw-submit'
678  $form->setSubmitTooltip( 'watchlistedit-raw-submit' );
679  $form->setWrapperLegendMsg( 'watchlistedit-raw-legend' );
680  $form->addHeaderText( $this->msg( 'watchlistedit-raw-explain' )->parse() );
681  $form->setSubmitCallback( [ $this, 'submitRaw' ] );
682 
683  return $form;
684  }
685 
691  protected function getClearForm() {
692  $context = new DerivativeContext( $this->getContext() );
693  $context->setTitle( $this->getPageTitle( 'clear' ) ); // Reset subpage
694  $form = new HTMLForm( [], $context );
695  $form->setSubmitTextMsg( 'watchlistedit-clear-submit' );
696  # Used message keys: 'accesskey-watchlistedit-clear-submit', 'tooltip-watchlistedit-clear-submit'
697  $form->setSubmitTooltip( 'watchlistedit-clear-submit' );
698  $form->setWrapperLegendMsg( 'watchlistedit-clear-legend' );
699  $form->addHeaderText( $this->msg( 'watchlistedit-clear-explain' )->parse() );
700  $form->setSubmitCallback( [ $this, 'submitClear' ] );
701  $form->setSubmitDestructive();
702 
703  return $form;
704  }
705 
714  public static function getMode( $request, $par ) {
715  $mode = strtolower( $request->getVal( 'action', $par ) );
716 
717  switch ( $mode ) {
718  case 'clear':
719  case self::EDIT_CLEAR:
720  return self::EDIT_CLEAR;
721  case 'raw':
722  case self::EDIT_RAW:
723  return self::EDIT_RAW;
724  case 'edit':
725  case self::EDIT_NORMAL:
726  return self::EDIT_NORMAL;
727  default:
728  return false;
729  }
730  }
731 
740  public static function buildTools( $lang, LinkRenderer $linkRenderer = null ) {
741  if ( !$lang instanceof Language ) {
742  // back-compat where the first parameter was $unused
743  global $wgLang;
744  $lang = $wgLang;
745  }
746  if ( !$linkRenderer ) {
747  $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
748  }
749 
750  $tools = [];
751  $modes = [
752  'view' => [ 'Watchlist', false ],
753  'edit' => [ 'EditWatchlist', false ],
754  'raw' => [ 'EditWatchlist', 'raw' ],
755  'clear' => [ 'EditWatchlist', 'clear' ],
756  ];
757 
758  foreach ( $modes as $mode => $arr ) {
759  // can use messages 'watchlisttools-view', 'watchlisttools-edit', 'watchlisttools-raw'
760  $tools[] = $linkRenderer->makeKnownLink(
761  SpecialPage::getTitleFor( $arr[0], $arr[1] ),
762  wfMessage( "watchlisttools-{$mode}" )->text()
763  );
764  }
765 
766  return Html::rawElement(
767  'span',
768  [ 'class' => 'mw-watchlist-toollinks' ],
769  wfMessage( 'parentheses' )->rawParams( $lang->pipeList( $tools ) )->escaped()
770  );
771  }
772 }
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:628
SpecialEditWatchlist\submitNormal
submitNormal( $data)
Definition: SpecialEditWatchlist.php:517
SpecialEditWatchlist\EDIT_CLEAR
const EDIT_CLEAR
Editing modes.
Definition: SpecialEditWatchlist.php:46
$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:244
SpecialEditWatchlist\getWatchlist
getWatchlist()
Prepare a list of titles on a user's watchlist (excluding talk pages) and return an array of (prefixe...
Definition: SpecialEditWatchlist.php:333
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:268
SpecialEditWatchlist\unwatchTitles
unwatchTitles( $titles)
Remove a list of titles from a user's watchlist.
Definition: SpecialEditWatchlist.php:499
SpecialEditWatchlist\EDIT_RAW
const EDIT_RAW
Definition: SpecialEditWatchlist.php:47
SpecialPage\msg
msg( $key)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:746
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
SpecialEditWatchlist\checkTitle
checkTitle( $title, $namespace, $dbKey)
Validates watchlist entry.
Definition: SpecialEditWatchlist.php:404
$context
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition: hooks.txt:2581
MWNamespace\isTalk
static isTalk( $index)
Is the given namespace a talk namespace?
Definition: MWNamespace.php:96
SpecialEditWatchlist\initServices
initServices()
Initialize any services we'll need (unless it has already been provided via a setter).
Definition: SpecialEditWatchlist.php:69
LinkBatch
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:34
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:675
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
UnlistedSpecialPage
Shortcut to construct a special page which is unlisted by default.
Definition: UnlistedSpecialPage.php:29
captcha-old.count
count
Definition: captcha-old.py:249
Linker\tocIndent
static tocIndent()
Add another level to the Table of Contents.
Definition: Linker.php:1509
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
MediaWiki\Linker\LinkRenderer
Class that generates HTML links for pages.
Definition: LinkRenderer.php:42
SpecialEditWatchlist\__construct
__construct()
Definition: SpecialEditWatchlist.php:61
SpecialEditWatchlist\submitRaw
submitRaw( $data)
Definition: SpecialEditWatchlist.php:217
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
SpecialPage\checkPermissions
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
Definition: SpecialPage.php:306
SpecialEditWatchlist\buildRemoveLine
buildRemoveLine( $title)
Build the label for a checkbox, with a link to the title, and various additional bits.
Definition: SpecialEditWatchlist.php:620
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Definition: SpecialPage.php:82
SpecialPage\getSkin
getSkin()
Shortcut to get the skin being used for this instance.
Definition: SpecialPage.php:695
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:705
SpecialPage\getName
getName()
Get the name of this Special Page.
Definition: SpecialPage.php:150
Linker\tocLine
static tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex=false)
parameter level defines if we are on an indentation level
Definition: Linker.php:1535
$output
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place $output
Definition: hooks.txt:2198
SpecialEditWatchlist\$badItems
$badItems
Definition: SpecialEditWatchlist.php:54
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
SpecialEditWatchlist\$titleParser
TitleParser $titleParser
Definition: SpecialEditWatchlist.php:59
SpecialEditWatchlist\execute
execute( $mode)
Main execution point.
Definition: SpecialEditWatchlist.php:84
NS_MAIN
const NS_MAIN
Definition: Defines.php:65
EditWatchlistNormalHTMLForm
Extend HTMLForm purely so we can have a more sane way of getting the section headers.
Definition: EditWatchlistNormalHTMLForm.php:24
DeferredUpdates\addCallableUpdate
static addCallableUpdate( $callable, $stage=self::POSTSEND, IDatabase $dbw=null)
Add a callable update.
Definition: DeferredUpdates.php:111
DerivativeContext
An IContextSource implementation which will inherit context from another source but allow individual ...
Definition: DerivativeContext.php:31
SpecialEditWatchlist\EDIT_NORMAL
const EDIT_NORMAL
Definition: SpecialEditWatchlist.php:48
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:932
WikiPage\factory
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:121
$titles
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
SpecialEditWatchlist\getRawForm
getRawForm()
Get a form for editing the watchlist in "raw" mode.
Definition: SpecialEditWatchlist.php:664
SpecialEditWatchlist\clearWatchlist
clearWatchlist()
Remove all titles from a user's watchlist.
Definition: SpecialEditWatchlist.php:453
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2856
Linker\tocList
static tocList( $toc, $lang=false)
Wraps the TOC in a table and provides the hide/collapse javascript.
Definition: Linker.php:1571
SpecialEditWatchlist\executeViewEditWatchlist
executeViewEditWatchlist()
Executes an edit mode for the watchlist view, from which you can manage your watchlist.
Definition: SpecialEditWatchlist.php:153
SpecialEditWatchlist\extractTitles
extractTitles( $list)
Extract a list of titles from a blob of text, returning (prefixed) strings; unwatchable titles are ig...
Definition: SpecialEditWatchlist.php:188
Linker\tocLineEnd
static tocLineEnd()
End a Table Of Contents line.
Definition: Linker.php:1559
SpecialEditWatchlist
Provides the UI through which users can perform editing operations on their watchlist.
Definition: SpecialEditWatchlist.php:41
$wgLang
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
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:484
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:685
SpecialEditWatchlist\showTitles
showTitles( $titles, &$output)
Print out a list of linked titles.
Definition: SpecialEditWatchlist.php:284
TitleParser
A title parser service for MediaWiki.
Definition: TitleParser.php:34
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
DB_MASTER
const DB_MASTER
Definition: defines.php:26
wfDebug
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:1047
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
SpecialPage\requireLogin
requireLogin( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin')
If the user is not logged in, throws UserNotLoggedIn error.
Definition: SpecialPage.php:336
$request
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
Definition: hooks.txt:2581
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:557
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:2141
SpecialEditWatchlist\getMode
static getMode( $request, $par)
Determine whether we are editing the watchlist, and if so, what kind of editing operation.
Definition: SpecialEditWatchlist.php:714
SpecialEditWatchlist\getSubpagesForPrefixSearch
getSubpagesForPrefixSearch()
Return an array of subpages that this special page will accept.
Definition: SpecialEditWatchlist.php:172
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:665
SpecialEditWatchlist\cleanupWatchlist
cleanupWatchlist()
Attempts to clean up broken items.
Definition: SpecialEditWatchlist.php:426
SpecialEditWatchlist\doesWrites
doesWrites()
Indicates whether this special page may perform database writes.
Definition: SpecialEditWatchlist.php:75
SpecialEditWatchlist\outputSubtitle
outputSubtitle()
Renders a subheader on the watchlist page.
Definition: SpecialEditWatchlist.php:138
SpecialEditWatchlist\$toc
$toc
Definition: SpecialEditWatchlist.php:52
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:860
SpecialEditWatchlist\buildTools
static buildTools( $lang, LinkRenderer $linkRenderer=null)
Build a set of links for convenient navigation between watchlist viewing and editing modes.
Definition: SpecialEditWatchlist.php:740
$args
if( $line===false) $args
Definition: cdb.php:63
Title
Represents a title within MediaWiki.
Definition: Title.php:39
SpecialEditWatchlist\getClearForm
getClearForm()
Get a form for clearing the watchlist.
Definition: SpecialEditWatchlist.php:691
MalformedTitleException
MalformedTitleException is thrown when a TitleParser is unable to parse a title string.
Definition: MalformedTitleException.php:25
$options
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 & $options
Definition: hooks.txt:1965
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
NS_USER
const NS_USER
Definition: Defines.php:67
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:2981
$batch
$batch
Definition: linkcache.txt:23
SpecialEditWatchlist\getNormalForm
getNormalForm()
Get the standard watchlist editing form.
Definition: SpecialEditWatchlist.php:541
SpecialEditWatchlist\watchTitles
watchTitles( $targets)
Add a list of targets to a user's watchlist.
Definition: SpecialEditWatchlist.php:467
wfMessage
either a unescaped string or a HtmlArmor object 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 unset offset - wrap String Wrap the message in html(usually something like "&lt
SpecialPage\checkReadOnly
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
Definition: SpecialPage.php:319
SpecialPage\$linkRenderer
MediaWiki Linker LinkRenderer null $linkRenderer
Definition: SpecialPage.php:66
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
MediaWiki\Linker\LinkTarget
Definition: LinkTarget.php:27
SpecialEditWatchlist\getWatchlistInfo
getWatchlistInfo()
Get a list of titles on a user's watchlist, excluding talk pages, and return as a two-dimensional arr...
Definition: SpecialEditWatchlist.php:374
MWNamespace\getTalk
static getTalk( $index)
Get the talk namespace index for a given namespace.
Definition: MWNamespace.php:107
MWNamespace\getSubject
static getSubject( $index)
Get the subject namespace index for a given namespace Special namespaces (NS_MEDIA,...
Definition: MWNamespace.php:121
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:51
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:203
SpecialEditWatchlist\submitClear
submitClear( $data)
Definition: SpecialEditWatchlist.php:263
SpecialPage\outputHeader
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
Definition: SpecialPage.php:583
Language
Internationalisation code.
Definition: Language.php:35
SpecialEditWatchlist\$successMessage
$successMessage
Definition: SpecialEditWatchlist.php:50
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
HTMLForm
Object handling generic submission, CSRF protection, layout and other logic for UI forms.
Definition: HTMLForm.php:128
$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:781
WatchedItemStore\SORT_ASC
const SORT_ASC
Definition: WatchedItemStore.php:26