MediaWiki REL1_28
SpecialPageFactory Class Reference

Factory for handling the special page list and generating SpecialPage objects. More...

Static Public Member Functions

static capturePath (Title $title, IContextSource $context, LinkRenderer $linkRenderer=null)
 Just like executePath() but will override global variables and execute the page in "inclusion" mode.
 
static executePath (Title &$title, IContextSource &$context, $including=false, LinkRenderer $linkRenderer=null)
 Execute a special page path.
 
static exists ( $name)
 Check if a given name exist as a special page or as a special page alias.
 
static getList ()
 Get the special page list as an array.
 
static getLocalNameFor ( $name, $subpage=false)
 Get the local name for a specified canonical name.
 
static getNames ()
 Returns a list of canonical special page names.
 
static getPage ( $name)
 Find the object with a given name and return it (or NULL)
 
static getRegularPages ()
 Return categorised listable special pages for all users.
 
static getRestrictedPages (User $user=null)
 Return categorised listable special pages which are available for the current user, but not for everyone.
 
static getTitleForAlias ( $alias)
 Get a title for a given alias.
 
static getUsablePages (User $user=null)
 Return categorised listable special pages which are available for the current user, and everyone.
 
static resetList ()
 Reset the internal list of special pages.
 
static resolveAlias ( $alias)
 Given a special page name with a possible subpage, return an array where the first element is the special page name and the second is the subpage.
 

Static Private Member Functions

static getAliasList ()
 Initialise and return the list of special page aliases.
 
static getPageList ()
 Get the special page list as an array.
 

Static Private Attributes

static $aliases
 
static $coreList
 List of special page names to the subclass of SpecialPage which handles them.
 
static $list
 

Detailed Description

Factory for handling the special page list and generating SpecialPage objects.

To add a special page in an extension, add to $wgSpecialPages either an object instance or an array containing the name and constructor parameters. The latter is preferred for performance reasons.

The object instantiated must be either an instance of SpecialPage or a sub-class thereof. It must have an execute() method, which sends the HTML for the special page to $wgOut. The parent class has an execute() method which distributes the call to the historical global functions. Additionally, execute() also checks if the user has the necessary access privileges and bails out if not.

To add a core special page, use the similar static list in SpecialPageFactory::$list. To remove a core static special page at runtime, use a SpecialPage_initList hook.

Since
1.17

Definition at line 47 of file SpecialPageFactory.php.

Member Function Documentation

◆ capturePath()

static SpecialPageFactory::capturePath ( Title  $title,
IContextSource  $context,
LinkRenderer  $linkRenderer = null 
)
static

Just like executePath() but will override global variables and execute the page in "inclusion" mode.

Returns true if the execution was successful or false if there was no such special page, or a title object if it was a redirect.

Also saves the current $wgTitle, $wgOut, $wgRequest, $wgUser and $wgLang variables so that the special page will get the context it'd expect on a normal request, and then restores them to their previous values after.

Parameters
Title$title
IContextSource$context
LinkRenderer | null$linkRenderer(since 1.28)
Returns
string HTML fragment

Definition at line 597 of file SpecialPageFactory.php.

References $context, $linkRenderer, $ret, $title, $wgLang, $wgOut, $wgRequest, $wgTitle, $wgUser, executePath(), ContextSource\getLanguage(), RequestContext\getMain(), and global.

Referenced by Parser\braceSubstitution().

◆ executePath()

static SpecialPageFactory::executePath ( Title $title,
IContextSource $context,
  $including = false,
LinkRenderer  $linkRenderer = null 
)
static

Execute a special page path.

The path may contain parameters, e.g. Special:Name/Params Extracts the special page name and call the execute method, passing the parameters

Returns a title object if the page is redirected, false if there was no such special page, and true if it was successful.

Parameters
Title$title
IContextSource$context
bool$includingBool output is being captured for use in {{special:whatever}}
LinkRenderer | null$linkRenderer(since 1.28)
Returns
bool

Definition at line 510 of file SpecialPageFactory.php.

References $context, $linkRenderer, $name, $page, $query, $title, $wgSend404Code, getPage(), global, Profiler\instance(), and Hooks\run().

Referenced by capturePath(), MediaWiki\performRequest(), and SpecialSearchText\testSubPageRedirect().

◆ exists()

static SpecialPageFactory::exists (   $name)
static

Check if a given name exist as a special page or as a special page alias.

Parameters
string$nameName of a special page
Returns
bool True if a special page exists with this name

Definition at line 365 of file SpecialPageFactory.php.

References $name, $title, getPageList(), list, and resolveAlias().

Referenced by Title\isAlwaysKnown().

◆ getAliasList()

static SpecialPageFactory::getAliasList ( )
staticprivate

Initialise and return the list of special page aliases.

Returns an array where the key is an alias, and the value is the canonical name of the special page. All registered special pages are guaranteed to map to themselves.

Returns
array

Definition at line 280 of file SpecialPageFactory.php.

References $aliases, $name, $wgContLang, as, getPageList(), global, and wfWarn().

Referenced by getLocalNameFor(), and resolveAlias().

◆ getList()

static SpecialPageFactory::getList ( )
static

Get the special page list as an array.

Deprecated:
since 1.24, use getNames() instead.
Returns
array

Definition at line 218 of file SpecialPageFactory.php.

References getPageList(), and wfDeprecated().

◆ getLocalNameFor()

static SpecialPageFactory::getLocalNameFor (   $name,
  $subpage = false 
)
static

◆ getNames()

static SpecialPageFactory::getNames ( )
static

Returns a list of canonical special page names.

May be used to iterate over all registered special pages.

Returns
string[]

Definition at line 208 of file SpecialPageFactory.php.

Referenced by ApiQuerySiteinfo\appendSpecialPageAliases(), PrefixSearch\specialSearch(), SpecialPageFactoryTest\testGetNames(), SpecialPageFactoryTest\testHookNotCalledTwice(), and SpecialPageFactoryTest\testResetList().

◆ getPage()

static SpecialPageFactory::getPage (   $name)
static

Find the object with a given name and return it (or NULL)

Parameters
string$nameSpecial page name, may be localised and/or an alias
Returns
SpecialPage|null SpecialPage object or null if the page doesn't exist

Definition at line 378 of file SpecialPageFactory.php.

References $name, $page, getPageList(), list, resolveAlias(), wfDeprecated(), and wfLogWarning().

Referenced by Parser\braceSubstitution(), UpdateSpecialPages\execute(), executePath(), getRegularPages(), getRestrictedPages(), SpecialPageAction\getSpecialPage(), getUsablePages(), MediaWiki\performRequest(), RevisiondeleteAction\show(), PrefixSearch\specialSearch(), SpecialPageFactoryTest\testGetPage(), and MediaWiki\triggerJobs().

◆ getPageList()

static SpecialPageFactory::getPageList ( )
staticprivate

◆ getRegularPages()

static SpecialPageFactory::getRegularPages ( )
static

Return categorised listable special pages for all users.

Returns
array ( string => Specialpage )

Definition at line 456 of file SpecialPageFactory.php.

References $name, $page, as, and getPage().

◆ getRestrictedPages()

static SpecialPageFactory::getRestrictedPages ( User  $user = null)
static

Return categorised listable special pages which are available for the current user, but not for everyone.

Parameters
User | null$userUser object to use or null for $wgUser
Returns
array ( string => Specialpage )

Definition at line 475 of file SpecialPageFactory.php.

References $name, $page, $user, $wgUser, as, getPage(), and global.

◆ getTitleForAlias()

static SpecialPageFactory::getTitleForAlias (   $alias)
static

Get a title for a given alias.

Parameters
string$alias
Returns
Title|null Title or null if there is no such alias

Definition at line 710 of file SpecialPageFactory.php.

References $name, SpecialPage\getTitleFor(), list, and resolveAlias().

Referenced by SpecialPageFactoryTest\testGetTitleForAlias().

◆ getUsablePages()

static SpecialPageFactory::getUsablePages ( User  $user = null)
static

Return categorised listable special pages which are available for the current user, and everyone.

Parameters
User$userUser object to check permissions, $wgUser will be used if not provided
Returns
array ( string => Specialpage )

Definition at line 430 of file SpecialPageFactory.php.

References $name, $page, $user, $wgUser, as, RequestContext\getMain(), getPage(), and global.

Referenced by SpecialSpecialpages\getPageGroups().

◆ resetList()

◆ resolveAlias()

static SpecialPageFactory::resolveAlias (   $alias)
static

Given a special page name with a possible subpage, return an array where the first element is the special page name and the second is the subpage.

Parameters
string$alias
Returns
array Array( String, String|null ), or array( null, null ) if the page is invalid

Definition at line 337 of file SpecialPageFactory.php.

References $aliases, $name, $wgContLang, getAliasList(), and global.

Referenced by SkinTemplate\buildPersonalUrls(), Title\checkReadPermissions(), exists(), Title\fixSpecialName(), OldChangesList\formatChangeLine(), OutputPage\getJSVars(), getPage(), Skin\getPageClasses(), getTitleForAlias(), LogPage\getTitleLink(), Title\isSpecial(), Linker\normaliseSpecialPage(), MediaWiki\performRequest(), CoreParserFunctions\special(), SpecialPageFactoryTest\testConflictResolution(), SpecialPageFactoryTest\testResolveAlias(), and MediaWiki\tryNormaliseRedirect().

Member Data Documentation

◆ $aliases

SpecialPageFactory::$aliases
staticprivate

Definition at line 191 of file SpecialPageFactory.php.

Referenced by getAliasList(), getLocalNameFor(), and resolveAlias().

◆ $coreList

SpecialPageFactory::$coreList
staticprivate

List of special page names to the subclass of SpecialPage which handles them.

Definition at line 51 of file SpecialPageFactory.php.

Referenced by getPageList().

◆ $list

SpecialPageFactory::$list
staticprivate

Definition at line 190 of file SpecialPageFactory.php.

Referenced by getPageList().


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