MediaWiki master
MediaWiki\Site\Site Class Reference

Represents a single site. More...

Inherited by MediaWiki\Site\MediaWikiSite.

Public Member Functions

 __construct ( $type=self::TYPE_UNKNOWN)
 __serialize ()
 __unserialize ( $fields)
 addInterwikiId ( $identifier)
 Adds an interwiki id to the site.
 addLocalId ( $type, $identifier)
 Adds a local identifier.
 addNavigationId ( $identifier)
 Adds a navigation id to the site.
 getAllPaths ()
 Returns the paths as associative array.
 getDomain ()
 Returns the domain of the site, ie en.wikipedia.org Or null if it's not known.
 getExtraConfig ()
 Returns the type specific config.
 getExtraData ()
 Returns the type specific fields.
 getGlobalId ()
 Returns the global site identifier (ie enwiktionary).
 getGroup ()
 Gets the group of the site (ie wikipedia).
 getInternalId ()
 Returns the set internal identifier for the site.
 getInterwikiIds ()
 Returns the interwiki link identifiers that can be used for this site.
 getLanguageCode ()
 Returns language code of the sites primary language.
 getLinkPath ()
 Returns the path used to construct links with or false if there is no such path.
 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.
 getLocalIds ()
 Returns all local ids.
 getNavigationIds ()
 Returns the equivalent link identifiers that can be used to make the site show up in interfaces such as the "language links" section.
 getPageUrl ( $pageName=false)
 Get the full URL for the given page on the site.
 getPath ( $pathType)
 Returns the path of the provided type or null if there is no such path.
 getProtocol ()
 Returns the protocol of the site.
 getSource ()
 Returns the source of the site data (ie 'local', 'wikidata', 'my-magical-repo').
 getType ()
 Returns the type of the site (ie mediawiki).
 normalizePageName ( $pageName, $followRedirect=MediaWikiPageNameNormalizer::FOLLOW_REDIRECT)
 Attempt to normalize the page name in some fashion.
 removePath ( $pathType)
 Removes the path of the provided type if it's set.
 setExtraConfig (array $extraConfig)
 Sets the type specific config.
 setExtraData (array $extraData)
 Sets the type specific fields.
 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.
 setGlobalId (?string $globalId)
 Sets the global site identifier (ie enwiktionary).
 setGroup (string $group)
 Sets the group of the site (ie wikipedia).
 setInternalId ( $internalId=null)
 Sets the internal identifier for the site.
 setLanguageCode ( $languageCode)
 Sets language code of the sites primary language.
 setLinkPath ( $fullUrl)
 Set the path used to construct links with.
 setPath ( $pathType, string $fullUrl)
 Set the path used to construct links with.
 setSource (string $source)
 Sets the source of the site data (ie 'local', 'wikidata', 'my-magical-repo').
 shouldForward ()
 Gets if site.tld/path/key:pageTitle should forward users to the page on the actual site, where "key" is the local identifier.

Static Public Member Functions

static newForType ( $siteType)

Public Attributes

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'

Protected Attributes

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.
string $source = self::SOURCE_LOCAL
string $type = self::TYPE_UNKNOWN

Detailed Description

Represents a single site.

Since
1.21
Author
Jeroen De Dauw < jeroe.nosp@m.nded.nosp@m.auw@g.nosp@m.mail.nosp@m..com >

Definition at line 20 of file Site.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Site\Site::__construct ( $type = self::TYPE_UNKNOWN)
Since
1.21
Parameters
string$type

Reimplemented in MediaWiki\Site\MediaWikiSite.

Definition at line 120 of file Site.php.

References $type.

Referenced by __unserialize().

Member Function Documentation

◆ __serialize()

MediaWiki\Site\Site::__serialize ( )
See also
Serializable::serialize
Since
1.38
Returns
array

Definition at line 608 of file Site.php.

References $source.

◆ __unserialize()

MediaWiki\Site\Site::__unserialize ( $fields)
See also
Serializable::unserialize
Since
1.38
Parameters
array$fields

Definition at line 630 of file Site.php.

References __construct(), setExtraConfig(), setExtraData(), setForward(), setGlobalId(), setGroup(), setInternalId(), setLanguageCode(), and setSource().

◆ addInterwikiId()

MediaWiki\Site\Site::addInterwikiId ( $identifier)

Adds an interwiki id to the site.

Since
1.21
Parameters
string$identifier

Definition at line 488 of file Site.php.

References addLocalId().

◆ addLocalId()

MediaWiki\Site\Site::addLocalId ( $type,
$identifier )

Adds a local identifier.

Since
1.21
Parameters
string$type
string$identifier

Definition at line 469 of file Site.php.

References $type.

Referenced by addInterwikiId(), and addNavigationId().

◆ addNavigationId()

MediaWiki\Site\Site::addNavigationId ( $identifier)

Adds a navigation id to the site.

Since
1.21
Parameters
string$identifier

Definition at line 499 of file Site.php.

References addLocalId().

◆ getAllPaths()

MediaWiki\Site\Site::getAllPaths ( )

Returns the paths as associative array.

The keys are path types, the values are the path urls.

Since
1.21
Returns
string[]

Definition at line 572 of file Site.php.

Referenced by getPath().

◆ getDomain()

MediaWiki\Site\Site::getDomain ( )

Returns the domain of the site, ie en.wikipedia.org Or null if it's not known.

Since
1.21
Returns
string|null

Definition at line 233 of file Site.php.

References $path, and getLinkPath().

◆ getExtraConfig()

MediaWiki\Site\Site::getExtraConfig ( )

Returns the type specific config.

Deprecated
since 1.47
Since
1.21
Returns
array

Definition at line 397 of file Site.php.

◆ getExtraData()

MediaWiki\Site\Site::getExtraData ( )

Returns the type specific fields.

Since
1.21
Returns
array

Definition at line 374 of file Site.php.

◆ getGlobalId()

MediaWiki\Site\Site::getGlobalId ( )

Returns the global site identifier (ie enwiktionary).

Since
1.21
Returns
string|null

Definition at line 131 of file Site.php.

References $globalId.

◆ getGroup()

MediaWiki\Site\Site::getGroup ( )

Gets the group of the site (ie wikipedia).

Since
1.21
Returns
string

Definition at line 163 of file Site.php.

References $group.

◆ getInternalId()

MediaWiki\Site\Site::getInternalId ( )

Returns the set internal identifier for the site.

Deprecated
since 1.47, use getGlobalId if a unique identifier is needed.
Since
1.21
Returns
int|null

Definition at line 444 of file Site.php.

◆ getInterwikiIds()

MediaWiki\Site\Site::getInterwikiIds ( )

Returns the interwiki link identifiers that can be used for this site.

Since
1.21
Returns
string[]

Definition at line 510 of file Site.php.

◆ getLanguageCode()

MediaWiki\Site\Site::getLanguageCode ( )

Returns language code of the sites primary language.

Or null if it's not known.

Since
1.21
Returns
string|null

Definition at line 421 of file Site.php.

Referenced by MediaWiki\Site\SiteSanitizer\sanitizeSite().

◆ getLinkPath()

MediaWiki\Site\Site::getLinkPath ( )

Returns the path used to construct links with or false if there is no such path.

Shall be equivalent to getPath( getLinkPathType() ).

Returns
string|null

Definition at line 298 of file Site.php.

References getLinkPathType(), and getPath().

Referenced by getDomain(), MediaWiki\Site\MediaWikiSite\getPageUrl(), getPageUrl(), and getProtocol().

◆ getLinkPathType()

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

This default implementation returns Site::PATH_LINK as the default path type. Subclasses can override this to define a different default path type, or return false to disable site links.

Since
1.21
Returns
string|null

Reimplemented in MediaWiki\Site\MediaWikiSite.

Definition at line 314 of file Site.php.

Referenced by getLinkPath(), and setLinkPath().

◆ getLocalIds()

MediaWiki\Site\Site::getLocalIds ( )

Returns all local ids.

Since
1.21
Returns
array[]

Definition at line 533 of file Site.php.

◆ getNavigationIds()

MediaWiki\Site\Site::getNavigationIds ( )

Returns the equivalent link identifiers that can be used to make the site show up in interfaces such as the "language links" section.

Since
1.21
Returns
string[]

Definition at line 522 of file Site.php.

◆ getPageUrl()

MediaWiki\Site\Site::getPageUrl ( $pageName = false)

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

Returns null if the needed information is not known.

This generated URL is usually based upon the path returned by getLinkPath(), but this is not a requirement.

This implementation returns a URL constructed using the path returned by getLinkPath().

Since
1.21
Parameters
string | false$pageName
Returns
string|null

Reimplemented in MediaWiki\Site\MediaWikiSite.

Definition at line 332 of file Site.php.

References $url, and getLinkPath().

◆ getPath()

MediaWiki\Site\Site::getPath ( $pathType)

Returns the path of the provided type or null if there is no such path.

Since
1.21
Parameters
string$pathType
Returns
string|null

Definition at line 559 of file Site.php.

References getAllPaths().

Referenced by MediaWiki\Site\MediaWikiSite\getFileUrl(), getLinkPath(), MediaWiki\Site\MediaWikiSite\getRelativeFilePath(), and MediaWiki\Site\MediaWikiSite\getRelativePagePath().

◆ getProtocol()

MediaWiki\Site\Site::getProtocol ( )

Returns the protocol of the site.

Since
1.21
Returns
string

Definition at line 255 of file Site.php.

References $path, and getLinkPath().

◆ getSource()

MediaWiki\Site\Site::getSource ( )

Returns the source of the site data (ie 'local', 'wikidata', 'my-magical-repo').

Deprecated
since 1.47
Since
1.21
Returns
string

Definition at line 185 of file Site.php.

References $source.

◆ getType()

MediaWiki\Site\Site::getType ( )

Returns the type of the site (ie mediawiki).

Since
1.21
Returns
string

Definition at line 152 of file Site.php.

References $type.

◆ newForType()

MediaWiki\Site\Site::newForType ( $siteType)
static
Deprecated
since 1.47
Since
1.21
Parameters
string$siteType
Returns
Site

Definition at line 597 of file Site.php.

References MediaWiki\MediaWikiServices\getInstance().

◆ normalizePageName()

MediaWiki\Site\Site::normalizePageName ( $pageName,
$followRedirect = MediaWikiPageNameNormalizer::FOLLOW_REDIRECT )

Attempt to normalize the page name in some fashion.

May return false to indicate various kinds of failure.

This implementation returns $pageName without changes.

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

Reimplemented in MediaWiki\Site\MediaWikiSite.

Definition at line 363 of file Site.php.

References MediaWiki\Site\MediaWikiPageNameNormalizer\FOLLOW_REDIRECT.

◆ removePath()

MediaWiki\Site\Site::removePath ( $pathType)

Removes the path of the provided type if it's set.

Since
1.21
Parameters
string$pathType

Definition at line 583 of file Site.php.

◆ setExtraConfig()

MediaWiki\Site\Site::setExtraConfig ( array $extraConfig)

Sets the type specific config.

Deprecated
since 1.47
Since
1.21
Parameters
array$extraConfig

Definition at line 409 of file Site.php.

References $extraConfig.

Referenced by __unserialize().

◆ setExtraData()

MediaWiki\Site\Site::setExtraData ( array $extraData)

Sets the type specific fields.

Since
1.21
Parameters
array$extraData

Definition at line 385 of file Site.php.

References $extraData.

Referenced by __unserialize().

◆ setForward()

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

Deprecated
since 1.47
Since
1.21
Parameters
bool$shouldForward

Definition at line 221 of file Site.php.

Referenced by __unserialize().

◆ setGlobalId()

MediaWiki\Site\Site::setGlobalId ( ?string $globalId)

Sets the global site identifier (ie enwiktionary).

Since
1.21
Parameters
string | null$globalId

Definition at line 141 of file Site.php.

References $globalId.

Referenced by __unserialize().

◆ setGroup()

MediaWiki\Site\Site::setGroup ( string $group)

Sets the group of the site (ie wikipedia).

Since
1.21
Parameters
string$group

Definition at line 173 of file Site.php.

References $group.

Referenced by __unserialize().

◆ setInternalId()

MediaWiki\Site\Site::setInternalId ( $internalId = null)

Sets the internal identifier for the site.

This typically is a primary key in a db table.

Deprecated
since 1.47
Since
1.21
Parameters
int | null$internalId

Definition at line 457 of file Site.php.

References $internalId.

Referenced by __unserialize().

◆ setLanguageCode()

MediaWiki\Site\Site::setLanguageCode ( $languageCode)

Sets language code of the sites primary language.

Since
1.21
Parameters
string | null$languageCode

Definition at line 432 of file Site.php.

References $languageCode.

Referenced by __unserialize(), and MediaWiki\Site\SiteSanitizer\sanitizeSite().

◆ setLinkPath()

MediaWiki\Site\Site::setLinkPath ( $fullUrl)

Set the path used to construct links with.

Shall be equivalent to setPath( getLinkPathType(), $fullUrl ).

Parameters
string$fullUrl
Since
1.21

Definition at line 281 of file Site.php.

References $type, getLinkPathType(), and setPath().

◆ setPath()

MediaWiki\Site\Site::setPath ( $pathType,
string $fullUrl )

Set the path used to construct links with.

Shall be equivalent to setPath( getLinkPathType(), $fullUrl ).

Since
1.21
Parameters
string$pathType
string$fullUrl

Definition at line 546 of file Site.php.

Referenced by MediaWiki\Site\MediaWikiSite\setFilePath(), setLinkPath(), and MediaWiki\Site\MediaWikiSite\setPagePath().

◆ setSource()

MediaWiki\Site\Site::setSource ( string $source)

Sets the source of the site data (ie 'local', 'wikidata', 'my-magical-repo').

Deprecated
since 1.47
Since
1.21
Parameters
string$source

Definition at line 196 of file Site.php.

References $source.

Referenced by __unserialize().

◆ shouldForward()

MediaWiki\Site\Site::shouldForward ( )

Gets if site.tld/path/key:pageTitle should forward users to the page on the actual site, where "key" is the local identifier.

Deprecated
since 1.47
Since
1.21
Returns
bool

Definition at line 209 of file Site.php.

References $forward.

Member Data Documentation

◆ $extraConfig

array MediaWiki\Site\Site::$extraConfig = []
protected
Since
1.21

Definition at line 99 of file Site.php.

Referenced by setExtraConfig().

◆ $extraData

array MediaWiki\Site\Site::$extraData = []
protected
Since
1.21

Definition at line 92 of file Site.php.

Referenced by setExtraData().

◆ $forward

bool MediaWiki\Site\Site::$forward = false
protected
Since
1.21

Definition at line 106 of file Site.php.

Referenced by shouldForward().

◆ $globalId

string null MediaWiki\Site\Site::$globalId = null
protected
Since
1.21

Definition at line 47 of file Site.php.

Referenced by getGlobalId(), and setGlobalId().

◆ $group

string MediaWiki\Site\Site::$group = self::GROUP_NONE
protected
Since
1.21

Definition at line 61 of file Site.php.

Referenced by getGroup(), and setGroup().

◆ $internalId

int null MediaWiki\Site\Site::$internalId = null
protected
Since
1.21

Definition at line 113 of file Site.php.

Referenced by setInternalId().

◆ $languageCode

string null MediaWiki\Site\Site::$languageCode = null
protected
Since
1.21

Definition at line 75 of file Site.php.

Referenced by setLanguageCode().

◆ $localIds

string [][] false MediaWiki\Site\Site::$localIds = []
protected

Holds the local ids for this site.

local id type => [ ids for this type (strings) ]

Since
1.21

Definition at line 85 of file Site.php.

◆ $source

string MediaWiki\Site\Site::$source = self::SOURCE_LOCAL
protected
Since
1.21

Definition at line 68 of file Site.php.

Referenced by getSource(), and setSource().

◆ $type

string MediaWiki\Site\Site::$type = self::TYPE_UNKNOWN
protected
Since
1.21

Definition at line 54 of file Site.php.

Referenced by MediaWiki\Site\MediaWikiSite\__construct(), __construct(), addLocalId(), getType(), and setLinkPath().

◆ GROUP_NONE

const MediaWiki\Site\Site::GROUP_NONE = 'none'

Definition at line 24 of file Site.php.

Referenced by MediaWiki\Site\SiteImporter\makeSite().

◆ ID_EQUIVALENT

const MediaWiki\Site\Site::ID_EQUIVALENT = 'equivalent'

Definition at line 27 of file Site.php.

◆ ID_INTERWIKI

const MediaWiki\Site\Site::ID_INTERWIKI = 'interwiki'

Definition at line 26 of file Site.php.

◆ PATH_LINK

const MediaWiki\Site\Site::PATH_LINK = 'link'

Definition at line 31 of file Site.php.

◆ SOURCE_LOCAL

const MediaWiki\Site\Site::SOURCE_LOCAL = 'local'

Definition at line 29 of file Site.php.

◆ TYPE_MEDIAWIKI

const MediaWiki\Site\Site::TYPE_MEDIAWIKI = 'mediawiki'

Definition at line 22 of file Site.php.

◆ TYPE_UNKNOWN

const MediaWiki\Site\Site::TYPE_UNKNOWN = 'unknown'

Definition at line 21 of file Site.php.

Referenced by MediaWiki\Site\SiteImporter\makeSite().


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