MediaWiki  1.28.0
MediaWikiSite Class Reference

Class representing a MediaWiki site. More...

Inheritance diagram for MediaWikiSite:
Collaboration diagram for MediaWikiSite:

Public Member Functions

 __construct ($type=self::TYPE_MEDIAWIKI)
 Constructor. More...
 
 getFileUrl ($path=false)
 Returns the full file path (ie site url + relative file path). More...
 
 getLinkPathType ()
 
 getPageUrl ($pageName=false)
 
 getRelativeFilePath ()
 Returns the relative file path. More...
 
 getRelativePagePath ()
 Returns the relative page path. More...
 
 normalizePageName ($pageName)
 Returns the normalized form of the given page title, using the normalization rules of the given site. More...
 
 setFilePath ($path)
 Sets the relative file path. More...
 
 setPagePath ($path)
 Sets the relative page path. More...
 
 toDBKey ($title)
 Returns the database form of the given title. More...
 
- Public Member Functions inherited from Site
 __construct ($type=self::TYPE_UNKNOWN)
 Constructor. More...
 
 addInterwikiId ($identifier)
 Adds an interwiki id to the site. More...
 
 addLocalId ($type, $identifier)
 Adds a local identifier. More...
 
 addNavigationId ($identifier)
 Adds a navigation id to the site. More...
 
 getAllPaths ()
 Returns the paths as associative array. More...
 
 getDomain ()
 Returns the domain of the site, ie en.wikipedia.org Or false if it's not known. More...
 
 getExtraConfig ()
 Returns the type specific config. More...
 
 getExtraData ()
 Returns the type specific fields. More...
 
 getGlobalId ()
 Returns the global site identifier (ie enwiktionary). More...
 
 getGroup ()
 Gets the group of the site (ie wikipedia). More...
 
 getInternalId ()
 Returns the set internal identifier for the site. More...
 
 getInterwikiIds ()
 Returns the interwiki link identifiers that can be used for this site. More...
 
 getLanguageCode ()
 Returns language code of the sites primary language. More...
 
 getLinkPath ()
 Returns the path used to construct links with or false if there is no such path. More...
 
 getLinkPathType ()
 Returns the main path type, that is the type of the path that should generally be used to construct links to the target site. More...
 
 getLocalIds ()
 Returns all local ids. More...
 
 getNavigationIds ()
 Returns the equivalent link identifiers that can be used to make the site show up in interfaces such as the "language links" section. More...
 
 getPageUrl ($pageName=false)
 Returns the full URL for the given page on the site. More...
 
 getPath ($pathType)
 Returns the path of the provided type or false if there is no such path. More...
 
 getProtocol ()
 Returns the protocol of the site. More...
 
 getSource ()
 Returns the source of the site data (ie 'local', 'wikidata', 'my-magical-repo'). More...
 
 getType ()
 Returns the type of the site (ie mediawiki). More...
 
 normalizePageName ($pageName)
 Returns $pageName without changes. More...
 
 removePath ($pathType)
 Removes the path of the provided type if it's set. More...
 
 serialize ()
 
 setExtraConfig (array $extraConfig)
 Sets the type specific config. More...
 
 setExtraData (array $extraData)
 Sets the type specific fields. More...
 
 setForward ($shouldForward)
 Sets if site.tld/path/key:pageTitle should forward users to the page on the actual site, where "key" is the local identifier. More...
 
 setGlobalId ($globalId)
 Sets the global site identifier (ie enwiktionary). More...
 
 setGroup ($group)
 Sets the group of the site (ie wikipedia). More...
 
 setInternalId ($internalId=null)
 Sets the internal identifier for the site. More...
 
 setLanguageCode ($languageCode)
 Sets language code of the sites primary language. More...
 
 setLinkPath ($fullUrl)
 Sets the path used to construct links with. More...
 
 setPath ($pathType, $fullUrl)
 Sets the path used to construct links with. More...
 
 setSource ($source)
 Sets the source of the site data (ie 'local', 'wikidata', 'my-magical-repo'). More...
 
 shouldForward ()
 Gets if site.tld/path/key:pageTitle should forward users to the page on the actual site, where "key" is the local identifier. More...
 
 unserialize ($serialized)
 

Public Attributes

const PATH_FILE = 'file_path'
 
const PATH_PAGE = 'page_path'
 
- Public Attributes inherited from Site
const GROUP_NONE = 'none'
 
const ID_EQUIVALENT = 'equivalent'
 
const ID_INTERWIKI = 'interwiki'
 
const PATH_LINK = 'link'
 
const SOURCE_LOCAL = 'local'
 
const TYPE_MEDIAWIKI = 'mediawiki'
 
const TYPE_UNKNOWN = 'unknown'
 

Additional Inherited Members

- Static Public Member Functions inherited from Site
static newForType ($siteType)
 
- Protected Attributes inherited from Site
array $extraConfig = []
 
array $extraData = []
 
bool $forward = false
 
string null $globalId = null
 
string $group = self::GROUP_NONE
 
int null $internalId = null
 
string null $languageCode = null
 
array[] $localIds = []
 Holds the local ids for this site. More...
 
string $source = self::SOURCE_LOCAL
 
string $type = self::TYPE_UNKNOWN
 

Detailed Description

Class representing a MediaWiki site.

Since
1.21

Definition at line 38 of file MediaWikiSite.php.

Constructor & Destructor Documentation

MediaWikiSite::__construct (   $type = self::TYPE_MEDIAWIKI)

Constructor.

Since
1.21
Parameters
string$type

Definition at line 49 of file MediaWikiSite.php.

References Site\$type.

Member Function Documentation

MediaWikiSite::getFileUrl (   $path = false)

Returns the full file path (ie site url + relative file path).

The path should go at the $1 marker. If the $path argument is provided, the marker will be replaced by it's value.

Since
1.21
Parameters
string | bool$path
Returns
string

Definition at line 206 of file MediaWikiSite.php.

References $path, and Site\getPath().

Referenced by normalizePageName().

MediaWikiSite::getLinkPathType ( )
See also
Site::getLinkPathType Returns Site::PATH_PAGE
Since
1.21
Returns
string

Definition at line 118 of file MediaWikiSite.php.

MediaWikiSite::getPageUrl (   $pageName = false)
See also
Site::getPageUrl

This implementation returns a URL constructed using the path returned by getLinkPath(). In addition to the default behavior implemented by Site::getPageUrl(), this method converts the $pageName to DBKey-format by replacing spaces with underscores before using it in the URL.

Since
1.21
Parameters
string | bool$pageNamePage name or false (default: false)
Returns
string

Definition at line 180 of file MediaWikiSite.php.

References Site\getLinkPath(), toDBKey(), and wfUrlencode().

MediaWikiSite::getRelativeFilePath ( )

Returns the relative file path.

Since
1.21
Returns
string

Definition at line 140 of file MediaWikiSite.php.

References Site\getPath().

MediaWikiSite::getRelativePagePath ( )

Returns the relative page path.

Since
1.21
Returns
string

Definition at line 129 of file MediaWikiSite.php.

References Site\getPath().

MediaWikiSite::normalizePageName (   $pageName)

Returns the normalized form of the given page title, using the normalization rules of the given site.

If the given title is a redirect, the redirect weill be resolved and the redirect target is returned.

Note
This actually makes an API request to the remote site, so beware that this function is slow and depends on an external service.
If MW_PHPUNIT_TEST is defined, the call to the external site is skipped, and the title is normalized using the local normalization rules as implemented by the Title class.
See also
Site::normalizePageName
Since
1.21
Parameters
string$pageName
Returns
string
Exceptions
MWException

Definition at line 87 of file MediaWikiSite.php.

References $t, getFileUrl(), and Title\newFromText().

MediaWikiSite::setFilePath (   $path)

Sets the relative file path.

Since
1.21
Parameters
string$path

Definition at line 162 of file MediaWikiSite.php.

References $path, and Site\setPath().

MediaWikiSite::setPagePath (   $path)

Sets the relative page path.

Since
1.21
Parameters
string$path

Definition at line 151 of file MediaWikiSite.php.

References $path, and Site\setPath().

MediaWikiSite::toDBKey (   $title)

Returns the database form of the given title.

Since
1.21
Parameters
string$titleThe target page's title, in normalized form.
Returns
string

Definition at line 62 of file MediaWikiSite.php.

References $title.

Referenced by getPageUrl().

Member Data Documentation

const MediaWikiSite::PATH_FILE = 'file_path'

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