MediaWiki  REL1_24
SpecialPageFactory Class Reference

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

List of all members.

Static Public Member Functions

static capturePath (Title $title, IContextSource $context)
 Just like executePath() but will override global variables and execute the page in "inclusion" mode.
static executePath (Title &$title, IContextSource &$context, $including=false)
 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 getGroup (&$page)
 Get the group that the special page belongs in on Special:SpecialPage.
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 setGroup ($page, $group)
 Add a page to a certain display group for Special:SpecialPages.

Static Private Member Functions

static getAliasListObject ()
 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 $list
 List of special page names to the subclass of SpecialPage which handles them.

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 46 of file SpecialPageFactory.php.


Member Function Documentation

static SpecialPageFactory::capturePath ( Title title,
IContextSource context 
) [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
Returns:
string HTML fragment

Definition at line 583 of file SpecialPageFactory.php.

References $oldTitle, $ret, $title, $wgLang, $wgOut, $wgTitle, $wgUser, executePath(), IContextSource\getLanguage(), IContextSource\getOutput(), IContextSource\getRequest(), IContextSource\getUser(), and global.

static SpecialPageFactory::executePath ( Title &$  title,
IContextSource &$  context,
including = false 
) [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}}
Returns:
bool

Definition at line 502 of file SpecialPageFactory.php.

References $name, $query, $title, Title\getDBkey(), Title\getFullURL(), IContextSource\getOutput(), getPage(), IContextSource\getRequest(), global, wfProfileIn(), and wfProfileOut().

Referenced by capturePath().

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 362 of file SpecialPageFactory.php.

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

static SpecialPageFactory::getAliasListObject ( ) [static, private]

Initialise and return the list of special page aliases.

Returns an object with properties which can be accessed $obj->pagename - each property is an array of aliases; the first in the array is the canonical alias. All registered special pages are guaranteed to have a property entry, and for that property array to contain at least one entry (English fallbacks will be added if necessary).

Returns:
object

Definition at line 271 of file SpecialPageFactory.php.

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

Referenced by resolveAlias().

static SpecialPageFactory::getGroup ( &$  page) [static]

Get the group that the special page belongs in on Special:SpecialPage.

Parameters:
SpecialPage$page
Returns:
string
Deprecated:
since 1.21 Use SpecialPage::getFinalGroupName

Definition at line 350 of file SpecialPageFactory.php.

References wfDeprecated().

static SpecialPageFactory::getList ( ) [static]

Get the special page list as an array.

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

Definition at line 204 of file SpecialPageFactory.php.

References getPageList(), and wfDeprecated().

static SpecialPageFactory::getLocalNameFor ( name,
subpage = false 
) [static]

Get the local name for a specified canonical name.

Parameters:
string$name
string | bool$subpage
Returns:
string

Definition at line 620 of file SpecialPageFactory.php.

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

Referenced by SpecialPageFactoryTest\testGetLocalNameFor().

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 194 of file SpecialPageFactory.php.

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

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 375 of file SpecialPageFactory.php.

References $name, getPageList(), list, MWFunction\newObj(), resolveAlias(), wfDeprecated(), and wfLogWarning().

Referenced by UpdateSpecialPages\execute(), executePath(), getRegularPages(), getRestrictedPages(), getUsablePages(), RevisiondeleteAction\show(), PrefixSearch\specialSearch(), and SpecialPageFactoryTest\testGetPage().

static SpecialPageFactory::getPageList ( ) [static, private]

Get the special page list as an array.

Returns:
array

Definition at line 214 of file SpecialPageFactory.php.

References $list, array(), global, wfProfileIn(), wfProfileOut(), and wfRunHooks().

Referenced by exists(), getAliasListObject(), getList(), and getPage().

Return categorised listable special pages for all users.

Returns:
array ( string => Specialpage )

Definition at line 449 of file SpecialPageFactory.php.

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

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 468 of file SpecialPageFactory.php.

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

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 659 of file SpecialPageFactory.php.

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

Referenced by SpecialPageFactoryTest\testGetTitleForAlias().

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 423 of file SpecialPageFactory.php.

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

Referenced by SpecialSpecialpages\getPageGroups().

static SpecialPageFactory::resetList ( ) [static]

Reset the internal list of special pages.

Useful when changing $wgSpecialPages after the internal list has already been initialized, e.g. during testing.

Definition at line 183 of file SpecialPageFactory.php.

Referenced by SpecialPageFactoryTest\testGetLocalNameFor(), SpecialPageFactoryTest\testGetNames(), SpecialPageFactoryTest\testGetPage(), SpecialPageFactoryTest\testGetTitleForAlias(), and SpecialPageFactoryTest\testResolveAlias().

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 307 of file SpecialPageFactory.php.

References $name, $wgContLang, array(), getAliasListObject(), and global.

Referenced by exists(), OldChangesList\formatChangeLine(), getPage(), Skin\getPageClasses(), getTitleForAlias(), Linker\normaliseSpecialPage(), CoreParserFunctions\special(), and SpecialPageFactoryTest\testResolveAlias().

static SpecialPageFactory::setGroup ( page,
group 
) [static]

Add a page to a certain display group for Special:SpecialPages.

Parameters:
SpecialPage | string$page
string$group
Deprecated:
since 1.21 Override SpecialPage::getGroupName

Definition at line 335 of file SpecialPageFactory.php.

References $name, global, and wfDeprecated().


Member Data Documentation

SpecialPageFactory::$aliases [static, private]

Definition at line 177 of file SpecialPageFactory.php.

Referenced by getAliasListObject(), and getLocalNameFor().

SpecialPageFactory::$list [static, private]

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

Definition at line 50 of file SpecialPageFactory.php.

Referenced by getPageList().


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