BlueSpice MediaWiki master
 All Classes Namespaces Files Functions Variables Groups Pages
SpecialPage Class Reference

Inherits MessageLocalizer.

Inherited by AuthManagerSpecialPage, BlueSpice\Social\Groups\Special\Groups, BS\ExtendedSearch\MediaWiki\Specials\SearchAdmin, BS\ExtendedSearch\MediaWiki\Specials\SearchCenter, BsSpecialPage, CategoryTreePage, ChangesListSpecialPage, ConfiguredPages, DeletedContributionsPage, EDGetData, FormSpecialPage, IncludableSpecialPage, LoginForm, PendingChanges, PFCreateCategory, PFCreateClass, PFCreateForm, PFCreateProperty, PFCreateTemplate, PFForms, PFFormStart, PFTemplates, ProblemChanges, QualityOversight, QueryPage, RandomPage, ReviewedPages, SFCreateCategory, SFCreateClass, SFCreateForm, SFCreateProperty, SFCreateTemplate, SFForms, SFFormStart, SFTemplates, SMW\MediaWiki\Specials\SpecialAdmin, SMW\MediaWiki\Specials\SpecialBrowse, SMW\MediaWiki\Specials\SpecialDeferredRequestDispatcher, SMW\MediaWiki\Specials\SpecialProcessingErrorList, SMW\MediaWiki\Specials\SpecialPropertyLabelSimilarity, SMW\MediaWiki\Specials\SpecialSearchByProperty, SMW\SpecialPage, SMWAskPage, SMWPageProperty, SMWSpecialOWLExport, SMWSpecialTypes, SMWURIResolver, SpecialActiveUsers, SpecialAllMessages, SpecialApiSandbox, SpecialAutoblockList, SpecialBlockList, SpecialBookSources, SpecialCachedPage, SpecialCategories, SpecialCollabPad, SpecialComparePages, SpecialDuplicator, SpecialExpandTemplates, SpecialExport, SpecialGadgets, SpecialImport, SpecialJavaScriptTest, SpecialListGrants, SpecialListGroupRights, SpecialLog, SpecialMapEditor, SpecialMergeHistory, SpecialNotifications, SpecialNuke, SpecialPageData, SpecialPreferences, SpecialProtectedpages, SpecialProtectedtitles, SpecialRating, SpecialRenameuser, SpecialReplaceText, SpecialSearch, SpecialStatistics, SpecialTags, SpecialTrackingCategories, SpecialUnblock, SpecialUndelete, SpecialUpload, SpecialVersion, SpecialWikiExplorer, StablePages, UnlistedSpecialPage, UnreviewedPages, and UserrightsPage.

Collaboration diagram for SpecialPage:

Public Member Functions

 __construct ($name= '', $restriction= '', $listed=true, $function=false, $file= '', $includable=false)
 
 getName ()
 
 getRestriction ()
 
 isListed ()
 
 setListed ($listed)
 
 listed ($x=null)
 
 isIncludable ()
 
 maxIncludeCacheTime ()
 
 including ($x=null)
 
 getLocalName ()
 
 isExpensive ()
 
 isCached ()
 
 isRestricted ()
 
 userCanExecute (User $user)
 
 displayRestrictionError ()
 
 checkPermissions ()
 
 checkReadOnly ()
 
 requireLogin ($reasonMsg= 'exception-nologin-text', $titleMsg= 'exception-nologin')
 
 prefixSearchSubpages ($search, $limit, $offset)
 
 setHeaders ()
 
 run ($subPage)
 
 execute ($subPage)
 
 outputHeader ($summaryMessageKey= '')
 
 getDescription ()
 
 getTitle ($subpage=false)
 
 getPageTitle ($subpage=false)
 
 setContext ($context)
 
 getContext ()
 
 getRequest ()
 
 getOutput ()
 
 getUser ()
 
 getSkin ()
 
 getLanguage ()
 
 getConfig ()
 
 getFullTitle ()
 
 msg ($key)
 
 addHelpLink ($to, $overrideBaseUrl=false)
 
 getFinalGroupName ()
 
 doesWrites ()
 
 getLinkRenderer ()
 
 setLinkRenderer (LinkRenderer $linkRenderer)
 

Static Public Member Functions

static getTitleFor ($name, $subpage=false, $fragment= '')
 
static getTitleValueFor ($name, $subpage=false, $fragment= '')
 
static getSafeTitleFor ($name, $subpage=false)
 

Protected Member Functions

 getCacheTTL ()
 
 getLoginSecurityLevel ()
 
 checkLoginSecurityLevel ($level=null)
 
 getSubpagesForPrefixSearch ()
 
 prefixSearchString ($search, $limit, $offset)
 
 beforeExecute ($subPage)
 
 afterExecute ($subPage)
 
 getRobotPolicy ()
 
 addFeedLinks ($params)
 
 getGroupName ()
 
 useTransactionalTimeLimit ()
 

Static Protected Member Functions

static prefixSearchArray ($search, $limit, array $subpages, $offset)
 

Protected Attributes

 $mName
 
 $mRestriction
 
 $mIncluding
 
 $mIncludable
 
 $mContext
 

Detailed Description

Parent class for all special pages.

Includes some static functions for handling the special page list deprecated in favor of SpecialPageFactory.

Constructor & Destructor Documentation

SpecialPage::__construct (   $name = '',
  $restriction = '',
  $listed = true,
  $function = false,
  $file = '',
  $includable = false 
)

Default constructor for special pages Derivative classes should call this from their constructor Note that if the user does not have the required level, an error message will be displayed by the default execute() method, without the global function ever being called.

If you override execute(), you can recover the default behavior with userCanExecute() and displayRestrictionError()

Parameters
string$nameName of the special page, as seen in links and URLs
string$restrictionUser right required, e.g. "block" or "delete"
bool$listedWhether the page is listed in Special:Specialpages
callable | bool$functionUnused
string$fileUnused
bool$includableWhether the page can be included in normal pages

Member Function Documentation

SpecialPage::addFeedLinks (   $params)
protected

Adds RSS/atom links

Parameters
array$params
SpecialPage::addHelpLink (   $to,
  $overrideBaseUrl = false 
)

Adds help link with an icon via page indicators. Link target can be overridden by a local message containing a wikilink: the message key is: lowercase special page name + '-helppage'.

Parameters
string$toTarget MediaWiki.org page title or encoded URL.
bool$overrideBaseUrlWhether $url is a full URL, to avoid MW.o.
Since
1.25
SpecialPage::afterExecute (   $subPage)
protected

Gets called after

See Also
SpecialPage::execute.
Since
1.20
Parameters
string | null$subPage
SpecialPage::beforeExecute (   $subPage)
protected

Gets called before

See Also
SpecialPage::execute. Return false to prevent calling execute() (since 1.27+).
Since
1.20
Parameters
string | null$subPage
Returns
bool|void
SpecialPage::checkLoginSecurityLevel (   $level = null)
protected

Verifies that the user meets the security level, possibly reauthenticating them in the process.

This should be used when the page does something security-sensitive and needs extra defense against a stolen account (e.g. a reauthentication). The authentication framework will make an extra effort to make sure the user account is not compromised. What that exactly means will depend on the system and user settings; e.g. the user might be required to log in again unless their last login happened recently, or they might be given a second-factor challenge.

Calling this method will result in one if these actions:

  • return true: all good.
  • return false and set a redirect: caller should abort; the redirect will take the user to the login page for reauthentication, and back.
  • throw an exception if there is no way for the user to meet the requirements without using a different access method (e.g. this functionality is only available from a specific IP).

Note that this does not in any way check that the user is authorized to use this special page (use checkPermissions() for that).

Parameters
string$levelA security level. Can be an arbitrary string, defaults to the page name.
Returns
bool False means a redirect to the reauthentication page has been set and processing of the special page should be aborted.
Exceptions
ErrorPageErrorIf the security level cannot be met, even with reauthentication.
SpecialPage::checkPermissions ( )

Checks if userCanExecute, and if not throws a PermissionsError

Since
1.19
Returns
void
Exceptions
PermissionsError
SpecialPage::checkReadOnly ( )

If the wiki is currently in readonly mode, throws a ReadOnlyError

Since
1.19
Returns
void
Exceptions
ReadOnlyError
SpecialPage::displayRestrictionError ( )

Output an error message telling the user what access level they have to have

Exceptions
PermissionsError
SpecialPage::doesWrites ( )

Indicates whether this special page may perform database writes

Returns
bool
Since
1.27
SpecialPage::execute (   $subPage)

Default execute method Checks user permissions

This must be overridden by subclasses; it will be made abstract in a future version

Parameters
string | null$subPage
SpecialPage::getCacheTTL ( )
protected
Returns
int Seconds that this page can be cached
SpecialPage::getConfig ( )

Shortcut to get main config object

Returns
Config
Since
1.24
SpecialPage::getContext ( )

Gets the context this SpecialPage is executed in

Returns
IContextSource|RequestContext
Since
1.18
SpecialPage::getDescription ( )

Returns the name that goes in the <h1> in the special page itself, and also the name that will be listed in Special:Specialpages

Derived classes can override this, but usually it is easier to keep the default behavior.

Returns
string
SpecialPage::getFinalGroupName ( )

Get the group that the special page belongs in on Special:SpecialPage Use this method, instead of getGroupName to allow customization of the group name from the wiki side

Returns
string Group of this special page
Since
1.21
SpecialPage::getFullTitle ( )

Return the full title, including $par

Returns
Title
Since
1.18
SpecialPage::getGroupName ( )
protected

Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-group-*' for valid names This method defaults to group 'other'

Returns
string
Since
1.21
SpecialPage::getLanguage ( )

Shortcut to get user's language

Returns
Language
Since
1.19
SpecialPage::getLinkRenderer ( )
Since
1.28
Returns
SpecialPage::getLocalName ( )

Get the localised name of the special page

Returns
string
SpecialPage::getLoginSecurityLevel ( )
protected

Tells if the special page does something security-sensitive and needs extra defense against a stolen account (e.g. a reauthentication). What exactly that will mean is decided by the authentication framework.

Returns
bool|string False or the argument for AuthManager::securitySensitiveOperationStatus(). Typically a special page needing elevated security would return its name here.
SpecialPage::getName ( )

Get the name of this Special Page.

Returns
string
SpecialPage::getOutput ( )

Get the OutputPage being used for this instance

Returns
OutputPage
Since
1.18
SpecialPage::getPageTitle (   $subpage = false)

Get a self-referential title object

Parameters
string | bool$subpage
Returns
Title
Since
1.23
SpecialPage::getRequest ( )

Get the WebRequest being used for this instance

Returns
WebRequest
Since
1.18
SpecialPage::getRestriction ( )

Get the permission that a user must have to execute this page

Returns
string
SpecialPage::getRobotPolicy ( )
protected

Return the robot policy. Derived classes that override this can change the robot policy set by setHeaders() from the default 'noindex,nofollow'.

Returns
string
Since
1.23
static SpecialPage::getSafeTitleFor (   $name,
  $subpage = false 
)
static

Get a localised Title object for a page name with a possibly unvalidated subpage

Parameters
string$name
string | bool$subpageSubpage string, or false to not use a subpage
Returns
Title|null Title object or null if the page doesn't exist
SpecialPage::getSkin ( )

Shortcut to get the skin being used for this instance

Returns
Skin
Since
1.18
SpecialPage::getSubpagesForPrefixSearch ( )
protected

Return an array of subpages that this special page will accept for prefix searches. If this method requires a query you might instead want to implement prefixSearchSubpages() directly so you can support $limit and $offset. This method is better for static-ish lists of things.

Returns
string[] subpages to search from
SpecialPage::getTitle (   $subpage = false)

Get a self-referential title object

Parameters
string | bool$subpage
Returns
Title
Deprecated:
since 1.23, use SpecialPage::getPageTitle
static SpecialPage::getTitleFor (   $name,
  $subpage = false,
  $fragment = '' 
)
static

Get a localised Title object for a specified special page name If you don't need a full Title object, consider using TitleValue through getTitleValueFor() below.

Since
1.9
1.21 $fragment parameter added
Parameters
string$name
string | bool$subpageSubpage string, or false to not use a subpage
string$fragmentThe link fragment (after the "#")
Returns
Title
Exceptions
MWException
static SpecialPage::getTitleValueFor (   $name,
  $subpage = false,
  $fragment = '' 
)
static

Get a localised TitleValue object for a specified special page name

Since
1.28
Parameters
string$name
string | bool$subpageSubpage string, or false to not use a subpage
string$fragmentThe link fragment (after the "#")
Returns
TitleValue
SpecialPage::getUser ( )

Shortcut to get the User executing this instance

Returns
User
Since
1.18
SpecialPage::including (   $x = null)

Whether the special page is being evaluated via transclusion

Parameters
bool$x
Returns
bool
SpecialPage::isCached ( )

Is this page cached? Expensive pages are cached or disabled in miser mode. Used by QueryPage and subclasses, moved here so that Special:SpecialPages can safely call it for all special pages.

Returns
bool
Since
1.21
SpecialPage::isExpensive ( )

Is this page expensive (for some definition of expensive)? Expensive pages are disabled or cached in miser mode. Originally used (and still overridden) by QueryPage and subclasses, moved here so that Special:SpecialPages can safely call it for all special pages.

Returns
bool
SpecialPage::isIncludable ( )

Whether it's allowed to transclude the special page via {{Special:Foo/params}}

Returns
bool
SpecialPage::isListed ( )

Whether this special page is listed in Special:SpecialPages

Since
1.3 (r3583)
Returns
bool
SpecialPage::isRestricted ( )

Can be overridden by subclasses with more complicated permissions schemes.

Returns
bool Should the page be displayed with the restricted-access pages?
SpecialPage::listed (   $x = null)

Get or set whether this special page is listed in Special:SpecialPages

Since
1.6
Parameters
bool$x
Returns
bool
SpecialPage::maxIncludeCacheTime ( )

How long to cache page when it is being included.

Note
If cache time is not 0, then the current user becomes an anon if you want to do any per-user customizations, than this method must be overriden to return 0.
Since
1.26
Returns
int Time in seconds, 0 to disable caching altogether, false to use the parent page's cache settings
SpecialPage::msg (   $key)

Wrapper around wfMessage that sets the current context.

Since
1.16
Returns
Message
See Also
wfMessage

Implements MessageLocalizer.

SpecialPage::outputHeader (   $summaryMessageKey = '')

Outputs a summary message on top of special pages Per default the message key is the canonical name of the special page May be overridden, i.e. by extensions to stick with the naming conventions for message keys: 'extensionname-xxx'

Parameters
string$summaryMessageKeyMessage key of the summary
static SpecialPage::prefixSearchArray (   $search,
  $limit,
array  $subpages,
  $offset 
)
staticprotected

Helper function for implementations of prefixSearchSubpages() that filter the values in memory (as opposed to making a query).

Since
1.24
Parameters
string$search
int$limit
array$subpages
int$offset
Returns
string[]
SpecialPage::prefixSearchString (   $search,
  $limit,
  $offset 
)
protected

Perform a regular substring search for prefixSearchSubpages

Parameters
string$searchPrefix to search for
int$limitMaximum number of results to return (usually 10)
int$offsetNumber of results to skip (usually 0)
Returns
string[] Matching subpages
SpecialPage::prefixSearchSubpages (   $search,
  $limit,
  $offset 
)

Return an array of subpages beginning with $search that this special page will accept.

For example, if a page supports subpages "foo", "bar" and "baz" (as in Special:PageName/foo, etc.):

  • prefixSearchSubpages( "ba" ) should return array( "bar", "baz" )
  • prefixSearchSubpages( "f" ) should return array( "foo" )
  • prefixSearchSubpages( "z" ) should return array()
  • prefixSearchSubpages( "" ) should return array( foo", "bar", "baz" )
Parameters
string$searchPrefix to search for
int$limitMaximum number of results to return (usually 10)
int$offsetNumber of results to skip (usually 0)
Returns
string[] Matching subpages
SpecialPage::requireLogin (   $reasonMsg = 'exception-nologin-text',
  $titleMsg = 'exception-nologin' 
)

If the user is not logged in, throws UserNotLoggedIn error

The user will be redirected to Special:Userlogin with the given message as an error on the form.

Since
1.23
Parameters
string$reasonMsg[optional] Message key to be displayed on login page
string$titleMsg[optional] Passed on to UserNotLoggedIn constructor
Exceptions
UserNotLoggedIn
SpecialPage::run (   $subPage)
final

Entry point.

Since
1.20
Parameters
string | null$subPage

Gets called before

See Also
SpecialPage::execute. Return false to prevent calling execute() (since 1.27+).
Since
1.20
Parameters
SpecialPage$this
string | null$subPage

Gets called after

See Also
SpecialPage::execute.
Since
1.20
Parameters
SpecialPage$this
string | null$subPage
SpecialPage::setContext (   $context)

Sets the context this SpecialPage is executed in

Parameters
IContextSource$context
Since
1.18
SpecialPage::setHeaders ( )

Sets headers - this should be called from the execute() method of all derived classes!

SpecialPage::setLinkRenderer ( LinkRenderer  $linkRenderer)
Since
1.28
Parameters
\MediaWiki\Linker\LinkRenderer$linkRenderer
SpecialPage::setListed (   $listed)

Set whether this page is listed in Special:Specialpages, at run-time

Since
1.3
Parameters
bool$listed
Returns
bool
SpecialPage::userCanExecute ( User  $user)

Checks if the given user (identified by an object) can execute this special page (as defined by $mRestriction). Can be overridden by sub- classes with more complicated permissions schemes.

Parameters
User$userThe user to check
Returns
bool Does the user have permission to view the page?
SpecialPage::useTransactionalTimeLimit ( )
protected

Call wfTransactionalTimeLimit() if this request was POSTed

Since
1.26

The documentation for this class was generated from the following file: