MediaWiki  master
MediaWiki\SpecialPage\SpecialPageFactory Class Reference

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

Collaboration diagram for MediaWiki\SpecialPage\SpecialPageFactory:

Public Member Functions

 __construct (ServiceOptions $options, Language $contLang, ObjectFactory $objectFactory, TitleFactory $titleFactory, HookContainer $hookContainer)
 
 capturePath (PageReference $page, IContextSource $context, LinkRenderer $linkRenderer=null)
 Just like executePath() but will override global variables and execute the page in "inclusion" mode. More...
 
 executePath ( $path, IContextSource $context, $including=false, LinkRenderer $linkRenderer=null)
 Execute a special page path. More...
 
 exists ( $name)
 Check if a given name exist as a special page or as a special page alias. More...
 
 getLocalNameFor ( $name, $subpage=false)
 Get the local name for a specified canonical name. More...
 
 getNames ()
 Returns a list of canonical special page names. More...
 
 getPage ( $name)
 Find the object with a given name and return it (or NULL) More...
 
 getRegularPages ()
 Get listed special pages available to everyone by default. More...
 
 getTitleForAlias ( $alias)
 Get a title for a given alias. More...
 
 getUsablePages (User $user)
 Get listed special pages available to the current user. More...
 
 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. More...
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 

Private Member Functions

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

Private Attributes

array $aliases
 
Language $contLang
 
HookContainer $hookContainer
 
HookRunner $hookRunner
 
array $list
 Special page name => class name. More...
 
ObjectFactory $objectFactory
 
ServiceOptions $options
 
TitleFactory $titleFactory
 
const CORE_LIST
 List of special page names to the subclass of SpecialPage which handles them. More...
 

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

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\SpecialPage\SpecialPageFactory::__construct ( ServiceOptions  $options,
Language  $contLang,
ObjectFactory  $objectFactory,
TitleFactory  $titleFactory,
HookContainer  $hookContainer 
)

Member Function Documentation

◆ capturePath()

MediaWiki\SpecialPage\SpecialPageFactory::capturePath ( PageReference  $page,
IContextSource  $context,
LinkRenderer  $linkRenderer = null 
)

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
PageReference$page
IContextSource$context
LinkRenderer | null$linkRenderer(since 1.28)
Returns
string HTML fragment

Definition at line 1435 of file SpecialPageFactory.php.

References $title, $wgLang, $wgOut, $wgRequest, $wgTitle, $wgUser, IContextSource\getLanguage(), RequestContext\getMain(), IContextSource\getOutput(), IContextSource\getRequest(), and IContextSource\getUser().

◆ executePath()

MediaWiki\SpecialPage\SpecialPageFactory::executePath (   $path,
IContextSource  $context,
  $including = false,
LinkRenderer  $linkRenderer = null 
)

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
PageReference | string$path
IContextSource$context
bool$includingBool output is being captured for use in {{special:whatever}}
LinkRenderer | null$linkRenderer(since 1.28)
Returns
bool|Title

Definition at line 1347 of file SpecialPageFactory.php.

References $path, $title, IContextSource\getConfig(), IContextSource\getOutput(), IContextSource\getRequest(), and Profiler\instance().

◆ exists()

MediaWiki\SpecialPage\SpecialPageFactory::exists (   $name)

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

References $title.

◆ getAliasList()

MediaWiki\SpecialPage\SpecialPageFactory::getAliasList ( )
private

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

References wfWarn().

◆ getLocalNameFor()

MediaWiki\SpecialPage\SpecialPageFactory::getLocalNameFor (   $name,
  $subpage = false 
)

Get the local name for a specified canonical name.

Parameters
string$name
string | bool$subpage
Returns
string

Definition at line 1504 of file SpecialPageFactory.php.

References wfWarn().

◆ getNames()

MediaWiki\SpecialPage\SpecialPageFactory::getNames ( )

Returns a list of canonical special page names.

May be used to iterate over all registered special pages.

Returns
string[]

Definition at line 1064 of file SpecialPageFactory.php.

◆ getPage()

MediaWiki\SpecialPage\SpecialPageFactory::getPage (   $name)

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

References wfLogWarning().

◆ getPageList()

◆ getRegularPages()

MediaWiki\SpecialPage\SpecialPageFactory::getRegularPages ( )

Get listed special pages available to everyone by default.

Returns
SpecialPage[]

Definition at line 1320 of file SpecialPageFactory.php.

◆ getTitleForAlias()

MediaWiki\SpecialPage\SpecialPageFactory::getTitleForAlias (   $alias)

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

References SpecialPage\getTitleFor().

◆ getUsablePages()

MediaWiki\SpecialPage\SpecialPageFactory::getUsablePages ( User  $user)

Get listed special pages available to the current user.

This includes both unrestricted pages, and restricted pages that the current user has the required permissions for.

Parameters
User$userUser object to check permissions provided
Returns
SpecialPage[]

Definition at line 1298 of file SpecialPageFactory.php.

References RequestContext\getMain().

◆ resolveAlias()

MediaWiki\SpecialPage\SpecialPageFactory::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.

Parameters
string$alias
Returns
array [ String, String|null ], or [ null, null ] if the page is invalid

Definition at line 1220 of file SpecialPageFactory.php.

Member Data Documentation

◆ $aliases

array MediaWiki\SpecialPage\SpecialPageFactory::$aliases
private

Definition at line 1000 of file SpecialPageFactory.php.

◆ $contLang

Language MediaWiki\SpecialPage\SpecialPageFactory::$contLang
private

◆ $hookContainer

HookContainer MediaWiki\SpecialPage\SpecialPageFactory::$hookContainer
private

◆ $hookRunner

HookRunner MediaWiki\SpecialPage\SpecialPageFactory::$hookRunner
private

Definition at line 1015 of file SpecialPageFactory.php.

◆ $list

array MediaWiki\SpecialPage\SpecialPageFactory::$list
private

Special page name => class name.

Definition at line 997 of file SpecialPageFactory.php.

◆ $objectFactory

ObjectFactory MediaWiki\SpecialPage\SpecialPageFactory::$objectFactory
private

◆ $options

ServiceOptions MediaWiki\SpecialPage\SpecialPageFactory::$options
private

◆ $titleFactory

TitleFactory MediaWiki\SpecialPage\SpecialPageFactory::$titleFactory
private

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\SpecialPage\SpecialPageFactory::CONSTRUCTOR_OPTIONS
Initial value:
= [
]
const EnableJavaScriptTest
Name constant for the EnableJavaScriptTest setting, for use with Config::get()
const DisableInternalSearch
Name constant for the DisableInternalSearch setting, for use with Config::get()
const SpecialPages
Name constant for the SpecialPages setting, for use with Config::get()
const EnableSpecialMute
Name constant for the EnableSpecialMute setting, for use with Config::get()
const EnableEmail
Name constant for the EnableEmail setting, for use with Config::get()
const EmailAuthentication
Name constant for the EmailAuthentication setting, for use with Config::get()
const PageLanguageUseDB
Name constant for the PageLanguageUseDB setting, for use with Config::get()
Access: internal
For use by ServiceWiring

Definition at line 1020 of file SpecialPageFactory.php.

◆ CORE_LIST

const MediaWiki\SpecialPage\SpecialPageFactory::CORE_LIST
private

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

Definition at line 69 of file SpecialPageFactory.php.


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