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 ) {
108 $mode = self::getMode( $this->
getRequest(), $mode );
112 $out->setPageTitle( $this->
msg(
'watchlistedit-raw-title' ) );
114 if ( $form->show() ) {
115 $out->addHTML( $this->successMessage );
119 case self::EDIT_CLEAR:
120 $out->setPageTitle( $this->
msg(
'watchlistedit-clear-title' ) );
122 if ( $form->show() ) {
123 $out->addHTML( $this->successMessage );
128 case self::EDIT_NORMAL:
156 $out->setPageTitle( $this->
msg(
'watchlistedit-normal-title' ) );
158 if ( $form->show() ) {
159 $out->addHTML( $this->successMessage );
161 } elseif ( $this->toc !==
false ) {
162 $out->prependHTML( $this->toc );
163 $out->addModules(
'mediawiki.toc' );
190 $list = explode(
"\n", trim( $list ) );
191 if ( !is_array( $list ) ) {
197 foreach ( $list
as $text ) {
198 $text = trim( $text );
199 if ( strlen( $text ) > 0 ) {
207 MediaWikiServices::getInstance()->getGenderCache()->doTitlesArray(
$titles );
212 $list[] = $title->getPrefixedText();
215 return array_unique( $list );
222 if ( count( $wanted ) > 0 ) {
223 $toWatch = array_diff( $wanted, $current );
224 $toUnwatch = array_diff( $current, $wanted );
227 $this->
getUser()->invalidateCache();
229 if ( count( $toWatch ) > 0 || count( $toUnwatch ) > 0 ) {
230 $this->successMessage = $this->
msg(
'watchlistedit-raw-done' )->parse();
235 if ( count( $toWatch ) > 0 ) {
236 $this->successMessage .=
' ' . $this->
msg(
'watchlistedit-raw-added' )
237 ->numParams( count( $toWatch ) )->parse();
238 $this->
showTitles( $toWatch, $this->successMessage );
241 if ( count( $toUnwatch ) > 0 ) {
242 $this->successMessage .=
' ' . $this->
msg(
'watchlistedit-raw-removed' )
243 ->numParams( count( $toUnwatch ) )->parse();
244 $this->
showTitles( $toUnwatch, $this->successMessage );
248 $this->
getUser()->invalidateCache();
250 if ( count( $current ) > 0 ) {
251 $this->successMessage = $this->
msg(
'watchlistedit-raw-done' )->parse();
256 $this->successMessage .=
' ' . $this->
msg(
'watchlistedit-raw-removed' )
257 ->numParams( count( $current ) )->parse();
258 $this->
showTitles( $current, $this->successMessage );
267 $this->
getUser()->invalidateCache();
268 $this->successMessage = $this->
msg(
'watchlistedit-clear-done' )->parse();
269 $this->successMessage .=
' ' . $this->
msg(
'watchlistedit-clear-removed' )
270 ->numParams( count( $current ) )->parse();
271 $this->
showTitles( $current, $this->successMessage );
286 $talk = $this->
msg(
'talkpagelinktext' )->text();
289 if ( count(
$titles ) >= 100 ) {
290 $output = $this->
msg(
'watchlistedit-too-many' )->parse();
294 if ( !$title instanceof
Title ) {
298 if ( $title instanceof Title ) {
300 $batch->addObj( $title->getTalkPage() );
311 if ( !$title instanceof
Title ) {
315 if ( $title instanceof Title ) {
318 $this->
msg(
'parentheses' )->rawParams(
337 $watchedItems = MediaWikiServices::getInstance()->getWatchedItemStore()->getWatchedItemsForUser(
339 [
'forWrite' => $this->
getRequest()->wasPosted() ]
342 if ( $watchedItems ) {
345 foreach ( $watchedItems
as $watchedItem ) {
346 $namespace = $watchedItem->getLinkTarget()->getNamespace();
347 $dbKey = $watchedItem->getLinkTarget()->getDBkey();
357 MediaWikiServices::getInstance()->getGenderCache()->doTitlesArray(
$titles );
360 $list[] = $title->getPrefixedText();
378 $watchedItems = MediaWikiServices::getInstance()->getWatchedItemStore()
383 foreach ( $watchedItems
as $watchedItem ) {
384 $namespace = $watchedItem->getLinkTarget()->getNamespace();
385 $dbKey = $watchedItem->getLinkTarget()->getDBkey();
386 $lb->add( $namespace, $dbKey );
388 $titles[$namespace][$dbKey] = 1;
408 ||
$title->getNamespace() < 0
415 ||
$title->getNamespace() != $namespace
416 ||
$title->getDBkey() != $dbKey
418 $this->badItems[] = [
$title, $namespace, $dbKey ];
428 if ( !count( $this->badItems ) ) {
435 $store = MediaWikiServices::getInstance()->getWatchedItemStore();
438 $action =
$title ?
'cleaning up' :
'deleting';
439 wfDebug(
"User {$user->getName()} has broken watchlist item " .
440 "ns($namespace):$dbKey, $action.\n" );
442 $store->removeWatch(
$user,
new TitleValue( (
int)$namespace, $dbKey ) );
458 [
'wl_user' => $this->
getUser()->getId() ],
469 $expandedTargets = [];
470 foreach ( $targets
as $target ) {
473 $target = $this->titleParser->parseTitle( $target,
NS_MAIN );
480 $ns = $target->getNamespace();
481 $dbKey = $target->getDBkey();
486 MediaWikiServices::getInstance()->getWatchedItemStore()->addWatchBatchForUser(
501 $store = MediaWikiServices::getInstance()->getWatchedItemStore();
504 if ( !$title instanceof
Title ) {
508 if ( $title instanceof Title ) {
509 $store->removeWatch( $this->
getUser(), $title->getSubjectPage() );
510 $store->removeWatch( $this->
getUser(), $title->getTalkPage() );
523 $removed = array_merge( $removed, $titles );
526 if ( count( $removed ) > 0 ) {
527 $this->successMessage = $this->
msg(
'watchlistedit-normal-done'
528 )->numParams( count( $removed ) )->parse();
529 $this->
showTitles( $removed, $this->successMessage );
552 'WatchlistEditorBeforeFormRender',
556 foreach ( $watchlistInfo
as $namespace => $pages ) {
559 foreach ( array_keys( $pages )
as $dbkey ) {
571 $fields[
'TitlesNs' . $namespace] = [
572 'class' =>
'EditWatchlistCheckboxSeriesField',
574 'section' =>
"ns$namespace",
580 if ( count( $fields ) > 1 &&
$count > 30 ) {
584 foreach ( $fields
as $data ) {
585 # strip out the 'ns' prefix from the section name:
586 $ns = substr( $data[
'section'], 2 );
589 ? $this->
msg(
'blanknamespace' )->escaped()
590 : htmlspecialchars( $wgContLang->getFormattedNsText( $ns ) );
591 $this->toc .=
Linker::tocLine(
"editwatchlist-{$data['section']}", $nsText,
603 $form->setSubmitTextMsg(
'watchlistedit-normal-submit' );
604 $form->setSubmitDestructive();
606 # 'accesskey-watchlistedit-normal-submit', 'tooltip-watchlistedit-normal-submit'
607 $form->setSubmitTooltip(
'watchlistedit-normal-submit' );
608 $form->setWrapperLegendMsg(
'watchlistedit-normal-legend' );
609 $form->addHeaderText( $this->
msg(
'watchlistedit-normal-explain' )->parse() );
610 $form->setSubmitCallback( [ $this,
'submitNormal' ] );
627 $this->
msg(
'talkpagelinktext' )->text()
633 $this->
msg(
'history_short' )->
text(),
635 [
'action' =>
'history' ]
642 $this->
msg(
'contributions' )->text()
647 'WatchlistEditorBuildRemoveLine',
651 if (
$title->isRedirect() ) {
653 $link =
'<span class="watchlistredir">' .
$link .
'</span>';
657 $this->
msg(
'parentheses' )->rawParams( $this->
getLanguage()->pipeList( $tools ) )->escaped();
669 'type' =>
'textarea',
670 'label-message' =>
'watchlistedit-raw-titles',
677 $form->setSubmitTextMsg(
'watchlistedit-raw-submit' );
678 # Used message keys: 'accesskey-watchlistedit-raw-submit', 'tooltip-watchlistedit-raw-submit'
679 $form->setSubmitTooltip(
'watchlistedit-raw-submit' );
680 $form->setWrapperLegendMsg(
'watchlistedit-raw-legend' );
681 $form->addHeaderText( $this->
msg(
'watchlistedit-raw-explain' )->parse() );
682 $form->setSubmitCallback( [ $this,
'submitRaw' ] );
696 $form->setSubmitTextMsg(
'watchlistedit-clear-submit' );
697 # Used message keys: 'accesskey-watchlistedit-clear-submit', 'tooltip-watchlistedit-clear-submit'
698 $form->setSubmitTooltip(
'watchlistedit-clear-submit' );
699 $form->setWrapperLegendMsg(
'watchlistedit-clear-legend' );
700 $form->addHeaderText( $this->
msg(
'watchlistedit-clear-explain' )->parse() );
701 $form->setSubmitCallback( [ $this,
'submitClear' ] );
702 $form->setSubmitDestructive();
716 $mode = strtolower(
$request->getVal(
'action', $par ) );
720 case self::EDIT_CLEAR:
721 return self::EDIT_CLEAR;
724 return self::EDIT_RAW;
726 case self::EDIT_NORMAL:
727 return self::EDIT_NORMAL;
748 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
753 'view' => [
'Watchlist',
false ],
754 'edit' => [
'EditWatchlist',
false ],
755 'raw' => [
'EditWatchlist',
'raw' ],
756 'clear' => [
'EditWatchlist',
'clear' ],
759 foreach ( $modes
as $mode => $arr ) {
769 [
'class' =>
'mw-watchlist-toollinks' ],
770 wfMessage(
'parentheses' )->rawParams(
$lang->pipeList( $tools ) )->escaped()
780 $namespace = substr( $namespace, 2 );
783 ? $this->
msg(
'blanknamespace' )->escaped()
788 return $this->
displaySection( $this->mFieldTree,
'',
'editwatchlist-' );
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
static tocLineEnd()
End a Table Of Contents line.
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
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.
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
getLanguage()
Get the Language object.
Shortcut to construct a special page which is unlisted by default.
getContext()
Gets the context this SpecialPage is executed in.
processing should stop and the error should be shown to the user * false
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 If you don't need a full Title object...
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
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
if(!isset($args[0])) $lang
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?
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.
getRawForm()
Get a form for editing the watchlist in "raw" mode.
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
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.
when a variable name is used in a it is silently declared as a new local masking the global
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
outputHeader($summaryMessageKey= '')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
usually copyright or history_copyright This message must be in HTML not wikitext & $link
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 ...
msg()
Get a Message object with context set Parameters are the same as wfMessage()
showTitles($titles, &$output)
Print out a list of linked titles.
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 unsetoffset-wrap String Wrap the message in html(usually something like"<
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
execute($mode)
Main execution point.
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).
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! ...
static makeTitleSafe($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
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
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.
static tocLine($anchor, $tocline, $tocnumber, $level, $sectionIndex=false)
parameter level defines if we are on an indentation level
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 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
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
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
outputSubtitle()
Renders a subheader on the watchlist page.
static getTalk($index)
Get the talk namespace index for a given namespace.
static buildTools($lang, LinkRenderer $linkRenderer=null)
Build a set of links for convenient navigation between watchlist viewing and editing modes...
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
error also a ContextSource you ll probably need to make sure the header is varied on $request
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
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
getWatchlistInfo()
Get a list of titles on a user's watchlist, excluding talk pages, and return as a two-dimensional arr...
static tocIndent()
Add another level to the Table of Contents.
static addCallableUpdate($callable, $stage=self::POSTSEND, IDatabase $dbw=null)
Add a callable update.
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
getPageTitle($subpage=false)
Get a self-referential title object.
MediaWiki Linker LinkRenderer null $linkRenderer