MediaWiki  master
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)
 
 getFileUrl ( $path=false)
 Get the full URL to an entry point under a wiki's script path. More...
 
 getLinkPathType ()
 Get the constant for getting or setting the script path. More...
 
 getPageUrl ( $pageName=false)
 Get the full URL for the given page on the site. More...
 
 getRelativeFilePath ()
 Get the script script, as relative path only (without server). More...
 
 getRelativePagePath ()
 Get the article path, as relative path only (without server). More...
 
 normalizePageName ( $pageName, $followRedirect=MediaWikiPageNameNormalizer::FOLLOW_REDIRECT)
 Get the normalized form of the given page title. More...
 
 setFilePath ( $path)
 Set the script path. More...
 
 setPagePath ( $path)
 Set the article path. More...
 
 toDBKey ( $title)
 Get the database form of the given title. More...
 
- Public Member Functions inherited from Site
 __serialize ()
 
 __unserialize ( $fields)
 
 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 null 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...
 
 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...
 
 getPath ( $pathType)
 Returns the path of the provided type or null 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...
 
 removePath ( $pathType)
 Removes the path of the provided type if it's set. More...
 
 setExtraConfig (array $extraConfig)
 Sets the type specific config. More...
 
 setExtraData (array $extraData)
 Sets the type specific fields. More...
 
 setForward (bool $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 (?string $globalId)
 Sets the global site identifier (ie enwiktionary). More...
 
 setGroup (string $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)
 Set the path used to construct links with. More...
 
 setPath ( $pathType, string $fullUrl)
 Set the path used to construct links with. More...
 
 setSource (string $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...
 

Public Attributes

const PATH_FILE = 'file_path'
 The script path of a site, e.g. More...
 
const PATH_PAGE = 'page_path'
 The article path of a site, e.g. More...
 
- 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
 
string[][] false $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
Author
John Erling Blad < jebla.nosp@m.d@gm.nosp@m.ail.c.nosp@m.om >
Daniel Kinzler
Jeroen De Dauw < jeroe.nosp@m.nded.nosp@m.auw@g.nosp@m.mail.nosp@m..com >

Definition at line 33 of file MediaWikiSite.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWikiSite::__construct (   $type = self::TYPE_MEDIAWIKI)
Since
1.21
Parameters
string$type

Reimplemented from Site.

Definition at line 43 of file MediaWikiSite.php.

References Site\$type.

Member Function Documentation

◆ getFileUrl()

MediaWikiSite::getFileUrl (   $path = false)

Get the full URL to an entry point under a wiki's script path.

This is the equivalent of wfScript() for other sites.

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 | false$pathNot passing a string for this is deprecated since 1.40.
Returns
string

Definition at line 201 of file MediaWikiSite.php.

References $path, Site\getPath(), and wfDeprecatedMsg().

Referenced by normalizePageName().

◆ getLinkPathType()

MediaWikiSite::getLinkPathType ( )

Get the constant for getting or setting the script path.

This configures how Site::setLinkPath() and Site::getLinkPath() will work internally in terms of Site::setPath() and Site::getPath().

See also
Site::getLinkPathType
Since
1.21
Returns
string

Reimplemented from Site.

Definition at line 117 of file MediaWikiSite.php.

References PATH_PAGE.

◆ getPageUrl()

MediaWikiSite::getPageUrl (   $pageName = false)

Get the full URL for the given page on the site.

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.

See also
Site::getPageUrl
Since
1.21
Parameters
string | false$pageNamePage name or false (default: false)
Returns
string|null

Reimplemented from Site.

Definition at line 174 of file MediaWikiSite.php.

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

◆ getRelativeFilePath()

MediaWikiSite::getRelativeFilePath ( )

Get the script script, as relative path only (without server).

Since
1.21
Returns
string

Definition at line 137 of file MediaWikiSite.php.

References Site\getPath().

◆ getRelativePagePath()

MediaWikiSite::getRelativePagePath ( )

Get the article path, as relative path only (without server).

Since
1.21
Returns
string

Definition at line 127 of file MediaWikiSite.php.

References Site\getPath().

◆ normalizePageName()

MediaWikiSite::normalizePageName (   $pageName,
  $followRedirect = MediaWikiPageNameNormalizer::FOLLOW_REDIRECT 
)

Get the normalized form of the given page title.

This uses to normalization rules of the given site. If $followRedirect is set to true and the given title is a redirect, the redirect will be resolved and the redirect target is returned. Only titles of existing pages will be 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
1.37 Added $followRedirect
Parameters
string$pageName
int$followRedirecteither MediaWikiPageNameNormalizer::FOLLOW_REDIRECT or MediaWikiPageNameNormalizer::NOFOLLOW_REDIRECT
Returns
string|false The normalized form of the title, or false to indicate an invalid title, a missing page, or some other kind of error.

Reimplemented from Site.

Definition at line 83 of file MediaWikiSite.php.

References CoreParserFunctions\null\$t, and getFileUrl().

◆ setFilePath()

MediaWikiSite::setFilePath (   $path)

Set the script path.

Since
1.21
Parameters
string$path

Definition at line 157 of file MediaWikiSite.php.

References $path, and Site\setPath().

◆ setPagePath()

MediaWikiSite::setPagePath (   $path)

Set the article path.

Since
1.21
Parameters
string$path

Definition at line 147 of file MediaWikiSite.php.

References $path, and Site\setPath().

◆ toDBKey()

MediaWikiSite::toDBKey (   $title)

Get 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 54 of file MediaWikiSite.php.

Referenced by getPageUrl().

Member Data Documentation

◆ PATH_FILE

const MediaWikiSite::PATH_FILE = 'file_path'

The script path of a site, e.g.

/w/$1 related to $wgScriptPath

Definition at line 35 of file MediaWikiSite.php.

◆ PATH_PAGE

const MediaWikiSite::PATH_PAGE = 'page_path'

The article path of a site, e.g.

/wiki/$1 like $wgArticlePath

Definition at line 37 of file MediaWikiSite.php.

Referenced by getLinkPathType().


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