62 parent::__construct(
'EditWatchlist',
'editmywatchlist' );
70 if ( !$this->titleParser ) {
71 $this->titleParser = MediaWikiServices::getInstance()->getTitleParser();
88 # Anons don't get a watchlist
98 $out->addModuleStyles(
'mediawiki.special' );
100 # B/C: $mode used to be waaay down the parameter list, and the first parameter
102 if ( $mode instanceof
User ) {
103 $args = func_get_args();
104 if ( count(
$args ) >= 4 ) {
112 $out->setPageTitle( $this->
msg(
'watchlistedit-raw-title' ) );
114 if ( $form->show() ) {
115 $out->addHTML( $this->successMessage );
120 $out->setPageTitle( $this->
msg(
'watchlistedit-clear-title' ) );
122 if ( $form->show() ) {
123 $out->addHTML( $this->successMessage );
155 $out->setPageTitle( $this->
msg(
'watchlistedit-normal-title' ) );
157 if ( $form->show() ) {
158 $out->addHTML( $this->successMessage );
160 } elseif ( $this->toc !==
false ) {
161 $out->prependHTML( $this->toc );
162 $out->addModules(
'mediawiki.toc' );
189 $list = explode(
"\n", trim( $list ) );
190 if ( !is_array( $list ) ) {
196 foreach ( $list as $text ) {
197 $text = trim( $text );
198 if ( strlen( $text ) > 0 ) {
199 $title = Title::newFromText( $text );
206 MediaWikiServices::getInstance()->getGenderCache()->doTitlesArray(
$titles );
210 foreach (
$titles as $title ) {
211 $list[] = $title->getPrefixedText();
214 return array_unique( $list );
221 if ( count( $wanted ) > 0 ) {
222 $toWatch = array_diff( $wanted, $current );
223 $toUnwatch = array_diff( $current, $wanted );
226 $this->
getUser()->invalidateCache();
228 if ( count( $toWatch ) > 0 || count( $toUnwatch ) > 0 ) {
229 $this->successMessage = $this->
msg(
'watchlistedit-raw-done' )->parse();
234 if ( count( $toWatch ) > 0 ) {
235 $this->successMessage .=
' ' . $this->
msg(
'watchlistedit-raw-added' )
236 ->numParams( count( $toWatch ) )->parse();
237 $this->
showTitles( $toWatch, $this->successMessage );
240 if ( count( $toUnwatch ) > 0 ) {
241 $this->successMessage .=
' ' . $this->
msg(
'watchlistedit-raw-removed' )
242 ->numParams( count( $toUnwatch ) )->parse();
243 $this->
showTitles( $toUnwatch, $this->successMessage );
247 $this->
getUser()->invalidateCache();
249 if ( count( $current ) > 0 ) {
250 $this->successMessage = $this->
msg(
'watchlistedit-raw-done' )->parse();
255 $this->successMessage .=
' ' . $this->
msg(
'watchlistedit-raw-removed' )
256 ->numParams( count( $current ) )->parse();
257 $this->
showTitles( $current, $this->successMessage );
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 );
285 $talk = $this->
msg(
'talkpagelinktext' )->text();
288 if ( count(
$titles ) >= 100 ) {
289 $output = $this->
msg(
'watchlistedit-too-many' )->parse();
292 foreach (
$titles as $title ) {
293 if ( !$title instanceof
Title ) {
294 $title = Title::newFromText( $title );
297 if ( $title instanceof
Title ) {
299 $batch->addObj( $title->getTalkPage() );
309 foreach (
$titles as $title ) {
310 if ( !$title instanceof
Title ) {
311 $title = Title::newFromText( $title );
314 if ( $title instanceof
Title ) {
317 $this->
msg(
'parentheses' )->rawParams(
336 $watchedItems = MediaWikiServices::getInstance()->getWatchedItemStore()->getWatchedItemsForUser(
338 [
'forWrite' => $this->
getRequest()->wasPosted() ]
341 if ( $watchedItems ) {
344 foreach ( $watchedItems as $watchedItem ) {
345 $namespace = $watchedItem->getLinkTarget()->getNamespace();
346 $dbKey = $watchedItem->getLinkTarget()->getDBkey();
347 $title = Title::makeTitleSafe( $namespace, $dbKey );
349 if ( $this->
checkTitle( $title, $namespace, $dbKey )
350 && !$title->isTalkPage()
356 MediaWikiServices::getInstance()->getGenderCache()->doTitlesArray(
$titles );
358 foreach (
$titles as $title ) {
359 $list[] = $title->getPrefixedText();
377 $watchedItems = MediaWikiServices::getInstance()->getWatchedItemStore()
378 ->getWatchedItemsForUser( $this->
getUser(), [
'sort' => WatchedItemStore::SORT_ASC ] );
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;
406 && ( $title->isExternal()
407 || $title->getNamespace() < 0
414 || $title->getNamespace() != $namespace
415 || $title->getDBkey() != $dbKey
417 $this->badItems[] = [
$title, $namespace, $dbKey ];
427 if ( !count( $this->badItems ) ) {
433 DeferredUpdates::addCallableUpdate(
function () use ( $user,
$badItems ) {
434 $store = MediaWikiServices::getInstance()->getWatchedItemStore();
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" );
441 $store->removeWatch( $user,
new TitleValue( (
int)$namespace, $dbKey ) );
444 $user->addWatch( $title );
457 [
'wl_user' => $this->
getUser()->getId() ],
468 $expandedTargets = [];
469 foreach ( $targets as $target ) {
472 $target = $this->titleParser->parseTitle( $target,
NS_MAIN );
479 $ns = $target->getNamespace();
480 $dbKey = $target->getDBkey();
481 $expandedTargets[] =
new TitleValue( MWNamespace::getSubject( $ns ), $dbKey );
482 $expandedTargets[] =
new TitleValue( MWNamespace::getTalk( $ns ), $dbKey );
485 MediaWikiServices::getInstance()->getWatchedItemStore()->addWatchBatchForUser(
500 $store = MediaWikiServices::getInstance()->getWatchedItemStore();
502 foreach (
$titles as $title ) {
503 if ( !$title instanceof
Title ) {
504 $title = Title::newFromText( $title );
507 if ( $title instanceof
Title ) {
508 $store->removeWatch( $this->
getUser(), $title->getSubjectPage() );
509 $store->removeWatch( $this->
getUser(), $title->getTalkPage() );
512 Hooks::run(
'UnwatchArticleComplete', [ $this->
getUser(), &$page ] );
522 $removed = array_merge( $removed,
$titles );
525 if ( count( $removed ) > 0 ) {
526 $this->successMessage = $this->
msg(
'watchlistedit-normal-done'
527 )->numParams( count( $removed ) )->parse();
528 $this->
showTitles( $removed, $this->successMessage );
551 'WatchlistEditorBeforeFormRender',
555 foreach ( $watchlistInfo as $namespace => $pages ) {
558 foreach ( array_keys( $pages ) as $dbkey ) {
559 $title = Title::makeTitleSafe( $namespace, $dbkey );
561 if ( $this->
checkTitle( $title, $namespace, $dbkey ) ) {
563 $options[$text] = $title->getPrefixedText();
570 $fields[
'TitlesNs' . $namespace] = [
571 'class' =>
'EditWatchlistCheckboxSeriesField',
573 'section' =>
"ns$namespace",
579 if ( count( $fields ) > 1 && $count > 30 ) {
583 foreach ( $fields as $data ) {
584 # strip out the 'ns' prefix from the section name:
585 $ns = substr( $data[
'section'], 2 );
588 ? $this->
msg(
'blanknamespace' )->escaped()
589 : htmlspecialchars(
$wgContLang->getFormattedNsText( $ns ) );
590 $this->toc .=
Linker::tocLine(
"editwatchlist-{$data['section']}", $nsText,
602 $form->setSubmitTextMsg(
'watchlistedit-normal-submit' );
603 $form->setSubmitDestructive();
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' ] );
625 $title->getTalkPage(),
626 $this->msg(
'talkpagelinktext' )->text()
629 if ( $title->exists() ) {
632 $this->
msg(
'history_small' )->
text(),
634 [
'action' =>
'history' ]
638 if ( $title->getNamespace() == NS_USER && !$title->isSubpage() ) {
641 $this->msg(
'contributions' )->text()
646 'WatchlistEditorBuildRemoveLine',
647 [ &$tools, $title, $title->isRedirect(), $this->getSkin(), &
$link ]
650 if ( $title->isRedirect() ) {
652 $link =
'<span class="watchlistredir">' .
$link .
'</span>';
656 $this->
msg(
'parentheses' )->rawParams( $this->
getLanguage()->pipeList( $tools ) )->escaped();
668 'type' =>
'textarea',
669 'label-message' =>
'watchlistedit-raw-titles',
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' ] );
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();
715 $mode = strtolower(
$request->getVal(
'action', $par ) );
747 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
752 'view' => [
'Watchlist',
false ],
753 'edit' => [
'EditWatchlist',
false ],
754 'raw' => [
'EditWatchlist',
'raw' ],
755 'clear' => [
'EditWatchlist',
'clear' ],
758 foreach ( $modes as $mode => $arr ) {
766 return Html::rawElement(
768 [
'class' =>
'mw-watchlist-toollinks' ],
769 wfMessage(
'parentheses' )->rawParams(
$lang->pipeList( $tools ) )->escaped()
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
An IContextSource implementation which will inherit context from another source but allow individual ...
Internationalisation code.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
static tocList( $toc, $lang=false)
Wraps the TOC in a table and provides the hide/collapse javascript.
static tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex=false)
parameter level defines if we are on an indentation level
static tocIndent()
Add another level to the Table of Contents.
static tocLineEnd()
End a Table Of Contents line.
Provides the UI through which users can perform editing operations on their watchlist.
getRawForm()
Get a form for editing the watchlist in "raw" mode.
extractTitles( $list)
Extract a list of titles from a blob of text, returning (prefixed) strings; unwatchable titles are ig...
getNormalForm()
Get the standard watchlist editing form.
doesWrites()
Indicates whether this special page may perform database writes.
cleanupWatchlist()
Attempts to clean up broken items.
executeViewEditWatchlist()
Executes an edit mode for the watchlist view, from which you can manage your watchlist.
getSubpagesForPrefixSearch()
Return an array of subpages that this special page will accept.
static buildTools( $lang, LinkRenderer $linkRenderer=null)
Build a set of links for convenient navigation between watchlist viewing and editing modes.
getWatchlistInfo()
Get a list of titles on a user's watchlist, excluding talk pages, and return as a two-dimensional arr...
watchTitles( $targets)
Add a list of targets to a user's watchlist.
checkTitle( $title, $namespace, $dbKey)
Validates watchlist entry.
getClearForm()
Get a form for clearing the watchlist.
const EDIT_CLEAR
Editing modes.
buildRemoveLine( $title)
Build the label for a checkbox, with a link to the title, and various additional bits.
execute( $mode)
Main execution point.
initServices()
Initialize any services we'll need (unless it has already been provided via a setter).
outputSubtitle()
Renders a subheader on the watchlist page.
unwatchTitles( $titles)
Remove a list of titles from a user's watchlist.
showTitles( $titles, &$output)
Print out a list of linked titles.
static getMode( $request, $par)
Determine whether we are editing the watchlist, and if so, what kind of editing operation.
clearWatchlist()
Remove all titles from a user's watchlist.
getWatchlist()
Prepare a list of titles on a user's watchlist (excluding talk pages) and return an array of (prefixe...
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
getName()
Get the name of this Special Page.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
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.
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
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,...
getContext()
Gets the context this SpecialPage is executed in.
msg( $key)
Wrapper around wfMessage that sets the current context.
getRequest()
Get the WebRequest being used for this instance.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
getPageTitle( $subpage=false)
Get a self-referential title object.
getLanguage()
Shortcut to get user's language.
MediaWiki Linker LinkRenderer null $linkRenderer
Represents a page (or page fragment) title within MediaWiki.
Represents a title within MediaWiki.
isWatchable()
Can this title be added to a user's watchlist?
Shortcut to construct a special page which is unlisted by default.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
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
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
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
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
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
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
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
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
namespace and then decline to actually register it file or subcat img or subcat $title
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 "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
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
usually copyright or history_copyright This message must be in HTML not wikitext & $link
processing should stop and the error should be shown to the user * false
returning false will NOT prevent logging $e
A title parser service for MediaWiki.
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
if(!isset( $args[0])) $lang