Go to the documentation of this file.
106 public static function getTitleFor( $name, $subpage =
false, $fragment =
'' ) {
108 self::getTitleValueFor( $name, $subpage, $fragment )
122 $name = MediaWikiServices::getInstance()->getSpecialPageFactory()->
123 getLocalNameFor( $name, $subpage );
136 $name = MediaWikiServices::getInstance()->getSpecialPageFactory()->
137 getLocalNameFor( $name, $subpage );
165 $name =
'', $restriction =
'', $listed =
true,
166 $function =
false,
$file =
'', $includable =
false
168 $this->mName = $name;
169 $this->mRestriction = $restriction;
170 $this->mListed = $listed;
171 $this->mIncludable = $includable;
212 return wfSetVar( $this->mListed, $listed );
225 return wfSetVar( $this->mListed, $x );
266 return wfSetVar( $this->mIncluding, $x );
275 if ( !isset( $this->mLocalName ) ) {
319 return $this->mRestriction !=
'' && !MediaWikiServices::getInstance()
320 ->getPermissionManager()
321 ->groupHasPermission(
'*', $this->mRestriction );
334 return MediaWikiServices::getInstance()
335 ->getPermissionManager()
336 ->userHasRight( $user, $this->mRestriction );
387 $reasonMsg =
'exception-nologin-text', $titleMsg =
'exception-nologin'
389 if ( $this->
getUser()->isAnon() ) {
452 $level = $level ?: $this->
getName();
453 $key =
'SpecialPage:reauth:' . $this->
getName();
456 $securityStatus = $this->
getAuthManager()->securitySensitiveOperationStatus( $level );
457 if ( $securityStatus === AuthManager::SEC_OK ) {
458 $uniqueId = $request->getVal(
'postUniqueId' );
460 $key .=
':' . $uniqueId;
461 $session = $request->getSession();
462 $data = $session->getSecret( $key );
464 $session->remove( $key );
469 } elseif ( $securityStatus === AuthManager::SEC_REAUTH ) {
471 $queryParams = $request->getQueryValues();
473 if ( $request->wasPosted() ) {
474 $data = array_diff_assoc( $request->getValues(), $request->getQueryValues() );
478 $key .=
':' . $uniqueId;
479 $queryParams[
'postUniqueId'] = $uniqueId;
480 $session = $request->getSession();
482 $session->setSecret( $key, $data );
487 'returnto' => $this->
getFullTitle()->getPrefixedDBkey(),
488 'returntoquery' =>
wfArrayToCgi( array_diff_key( $queryParams, [
'title' =>
true ] ) ),
497 $titleMessage =
wfMessage(
'specialpage-securitylevel-not-allowed-title' );
498 $errorMessage =
wfMessage(
'specialpage-securitylevel-not-allowed' );
519 if ( $this->authManager ===
null ) {
522 $this->authManager = MediaWikiServices::getInstance()->getAuthManager();
582 $searchEngine = $searchEngineFactory
583 ? $searchEngineFactory->create()
586 : MediaWikiServices::getInstance()->newSearchEngine();
587 $searchEngine->setLimitOffset( $limit, $offset );
588 $searchEngine->setNamespaces( [] );
589 $result = $searchEngine->defaultPrefixSearch( $search );
590 return array_map(
static function (
Title $t ) {
591 return $t->getPrefixedText();
607 $escaped = preg_quote( $search,
'/' );
608 return array_slice( preg_grep(
"/^$escaped/i",
609 array_slice( $subpages, $offset ) ), 0, $limit );
618 $out->setArticleRelated(
false );
621 if ( $this->
getConfig()->
get(
'UseMediaWikiUIEverywhere' ) ) {
622 $out->addModuleStyles( [
623 'mediawiki.ui.input',
624 'mediawiki.ui.radio',
625 'mediawiki.ui.checkbox',
637 final public function run( $subPage ) {
638 if ( !$this->
getHookRunner()->onSpecialPageBeforeExecute( $this, $subPage ) ) {
648 $this->
getHookRunner()->onSpecialPageAfterExecute( $this, $subPage );
708 if ( $summaryMessageKey ==
'' ) {
712 $msg = $summaryMessageKey;
714 if ( !$this->
msg( $msg )->isDisabled() && !$this->
including() ) {
716 "<div class='mw-specialpage-summary'>\n$1\n</div>", $msg );
732 return $this->
msg( strtolower( $this->mName ) )->text();
753 $this->mContext = $context;
764 wfDebug( __METHOD__ .
" called and \$mContext is null. " .
765 "Using RequestContext::getMain(); for sanity" );
829 if ( $this->contentLanguage ===
null ) {
832 $this->contentLanguage = MediaWikiServices::getInstance()->getContentLanguage();
857 return MediaWikiServices::getInstance()->getLanguageConverterFactory()
858 ->getLanguageConverter();
888 return 'noindex,nofollow';
900 public function msg( $key, ...$params ) {
901 $message = $this->
getContext()->msg( $key, ...$params );
907 $message->setInterfaceMessageFlag(
false );
921 foreach ( $this->
getConfig()->
get(
'FeedClasses' ) as $format => $class ) {
922 $theseParams = $params + [
'feedformat' => $format ];
924 $this->
getOutput()->addFeedLink( $format, $url );
943 if ( !$msg->isDisabled() ) {
949 $this->
getOutput()->addHelpLink( $to, $overrideBaseUrl );
965 $msg = $this->
msg(
'specialpages-specialpagegroup-' . strtolower( $name ) )->inContentLanguage();
966 if ( !$msg->isBlank() ) {
967 $group = $msg->text();
1017 if ( $this->linkRenderer ===
null ) {
1019 $this->linkRenderer = MediaWikiServices::getInstance()->getLinkRendererFactory()
1020 ->createForUser( $this->
getUser() );
1053 return $prevNext->buildPrevNextNavigation(
$title, $offset, $limit, $query, $atend );
1071 if ( !$this->hookContainer ) {
1072 $this->hookContainer = MediaWikiServices::getInstance()->getHookContainer();
1084 if ( !$this->hookRunner ) {
1104 if ( !$this->specialPageFactory ) {
1107 $this->specialPageFactory = MediaWikiServices::getInstance()->getSpecialPageFactory();
Show an error when the wiki is locked/read-only and the user tries to do something that requires writ...
LinkRenderer null $linkRenderer
getPageTitle( $subpage=false)
Get a self-referential title object.
getFinalGroupName()
Get the group that the special page belongs in on Special:SpecialPage Use this method,...
bool $mIncludable
Whether the special page can be included in an article.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
SpecialPageFactory $specialPageFactory
getOutput()
Get the OutputPage being used for this instance.
string $mRestriction
Minimum user level required to access this page, or "" for anyone.
isExpensive()
Is this page expensive (for some definition of expensive)? Expensive pages are disabled or cached in ...
maxIncludeCacheTime()
How long to cache page when it is being included.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
wfSetVar(&$dest, $source, $force=false)
Sets dest to source and returns the original value of dest If source is NULL, it just returns the val...
Factory for handling the special page list and generating SpecialPage objects.
Redirect a user to the login page.
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
setReauthPostData(array $data)
Record preserved POST data after a reauthentication.
__construct( $name='', $restriction='', $listed=true, $function=false, $file='', $includable=false)
Default constructor for special pages Derivative classes should call this from their constructor Note...
displayRestrictionError()
Output an error message telling the user what access level they have to have Stable to override.
setListed( $listed)
Set whether this page is listed in Special:Specialpages, at run-time.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
wfReadOnly()
Check whether the wiki is in read-only mode.
getLocalName()
Get the localised name of the special page Stable to override.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Factory class for SearchEngine.
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,...
IContextSource $mContext
Current request context.
getSkin()
Shortcut to get the skin being used for this instance.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
Show an error when a user tries to do something they do not have the necessary permissions for.
getLanguage()
Shortcut to get user's language.
getName()
Get the name of this Special Page.
isListed()
Whether this special page is listed in Special:SpecialPages Stable to override.
AuthManager null $authManager
Interface for localizing messages in MediaWiki.
getRestriction()
Get the permission that a user must have to execute this page.
prefixSearchString( $search, $limit, $offset, SearchEngineFactory $searchEngineFactory=null)
Perform a regular substring search for prefixSearchSubpages.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
static getSafeTitleFor( $name, $subpage=false)
Get a localised Title object for a page name with a possibly unvalidated subpage.
getDescription()
Returns the name that goes in the <h1> in the special page itself, and also the name that will be l...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
getConfig()
Shortcut to get main config object.
bool $mIncluding
Whether or not this special page is being included from an article.
addFeedLinks( $params)
Adds RSS/atom links.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
Language null $contentLanguage
getCacheTTL()
Stable to override.
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
checkLoginSecurityLevel( $level=null)
Verifies that the user meets the security level, possibly reauthenticating them in the process.
static getTitleValueFor( $name, $subpage=false, $fragment='')
Get a localised TitleValue object for a specified special page name.
wfTransactionalTimeLimit()
Raise the request time limit to $wgTransactionalTimeLimit.
getFullTitle()
Return the full title, including $par.
isRestricted()
Can be overridden by subclasses with more complicated permissions schemes.
setAuthManager(AuthManager $authManager)
Set the injected AuthManager from the special page constructor.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!...
getUser()
Shortcut to get the User executing this instance.
isIncludable()
Whether it's allowed to transclude the special page via {{Special:Foo/params}} Stable to override.
afterExecute( $subPage)
Gets called after.
beforeExecute( $subPage)
Gets called before.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
setSpecialPageFactory(SpecialPageFactory $specialPageFactory)
HookContainer null $hookContainer
getContext()
Gets the context this SpecialPage is executed in.
requireLogin( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin')
If the user is not logged in, throws UserNotLoggedIn error.
setLinkRenderer(LinkRenderer $linkRenderer)
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
userCanExecute(User $user)
Checks if the given user (identified by an object) can execute this special page (as defined by $mRes...
getRobotPolicy()
Return the robot policy.
The shared interface for all language converters.
static prefixSearchArray( $search, $limit, array $subpages, $offset)
Helper function for implementations of prefixSearchSubpages() that filter the values in memory (as op...
Parent class for all special pages.
listed( $x=null)
Get or set whether this special page is listed in Special:SpecialPages.
buildPrevNextNavigation( $offset, $limit, array $query=[], $atend=false, $subpage=false)
Generate (prev x| next x) (20|50|100...) type links for paging.
isCached()
Is this page cached? Expensive pages are cached or disabled in miser mode.
getRequest()
Get the WebRequest being used for this instance.
getLoginSecurityLevel()
Tells if the special page does something security-sensitive and needs extra defense against a stolen ...
static generateHex( $chars)
Generate a run of cryptographically random data and return it in hexadecimal string format.
static getMain()
Get the RequestContext object associated with the main request.
static newFromLinkTarget(LinkTarget $linkTarget, $forceClone='')
Returns a Title given a LinkTarget.
run( $subPage)
Entry point.
execute( $subPage)
Default execute method Checks user permissions.
Interface for objects which can provide a MediaWiki context on request.
setContentLanguage(Language $contentLanguage)
Set content language.
Represents a title within MediaWiki.
HookRunner null $hookRunner
getSubpagesForPrefixSearch()
Return an array of subpages that this special page will accept for prefix searches.
string $mLocalName
The local name of this special page.
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
setContext( $context)
Sets the context this SpecialPage is executed in.
string $mName
The canonical name of this special page Also used for the default.
setHookContainer(HookContainer $hookContainer)
getLanguageConverter()
Shortcut to get language's converter.
doesWrites()
Indicates whether this special page may perform database writes.
getContentLanguage()
Shortcut to get content language.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
An error page which can definitely be safely rendered using the OutputPage.
bool $mListed
Listed in Special:Specialpages?
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
including( $x=null)
Whether the special page is being evaluated via transclusion.
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Represents a page (or page fragment) title within MediaWiki.
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....