MediaWiki  1.30.0
Site Class Reference
Inheritance diagram for Site:
Collaboration diagram for Site:

Public Member Functions

 __construct ( $type=self::TYPE_UNKNOWN)
 
 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)
 

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
 
array[] $localIds = []
 Holds the local ids for this site. More...
 
string $source = self::SOURCE_LOCAL
 
string $type = self::TYPE_UNKNOWN
 

Detailed Description

Definition at line 29 of file Site.php.

Constructor & Destructor Documentation

◆ __construct()

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

Reimplemented in MediaWikiSite.

Definition at line 129 of file Site.php.

References $type, and type.

Referenced by unserialize().

Member Function Documentation

◆ addInterwikiId()

Site::addInterwikiId (   $identifier)

Adds an interwiki id to the site.

Since
1.21
Parameters
string$identifier

Definition at line 522 of file Site.php.

References addLocalId().

Referenced by SiteTest\testAddInterwikiId().

◆ addLocalId()

Site::addLocalId (   $type,
  $identifier 
)

Adds a local identifier.

Since
1.21
Parameters
string$type
string$identifier

Definition at line 501 of file Site.php.

References $type.

Referenced by addInterwikiId(), and addNavigationId().

◆ addNavigationId()

Site::addNavigationId (   $identifier)

Adds a navigation id to the site.

Since
1.21
Parameters
string$identifier

Definition at line 533 of file Site.php.

References addLocalId().

Referenced by SiteTest\testAddNavigationId().

◆ getAllPaths()

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 620 of file Site.php.

Referenced by SiteExporter\exportSite(), getPath(), SiteTest\testGetAllPaths(), and SiteTest\testSetAndRemovePath().

◆ getDomain()

Site::getDomain ( )

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

Since
1.21
Returns
string|null

Definition at line 266 of file Site.php.

References $path, and getLinkPath().

◆ getExtraConfig()

Site::getExtraConfig ( )

Returns the type specific config.

Since
1.21
Returns
array

Definition at line 429 of file Site.php.

References $extraConfig.

◆ getExtraData()

Site::getExtraData ( )

Returns the type specific fields.

Since
1.21
Returns
array

Definition at line 407 of file Site.php.

References $extraData.

◆ getGlobalId()

Site::getGlobalId ( )

Returns the global site identifier (ie enwiktionary).

Since
1.21
Returns
string|null

Definition at line 140 of file Site.php.

References $globalId.

Referenced by SiteExporter\exportSite(), MediaWiki\Interwiki\InterwikiLookupAdapter\getSiteInterwikis(), HashSiteStore\saveSite(), SiteTest\testGetGlobalId(), and SiteTest\testSetGlobalId().

◆ getGroup()

Site::getGroup ( )

Gets the group of the site (ie wikipedia).

Since
1.21
Returns
string

Definition at line 179 of file Site.php.

References $group.

Referenced by SiteExporter\exportSite().

◆ getInternalId()

Site::getInternalId ( )

Returns the set internal identifier for the site.

Since
1.21
Returns
string|null

Definition at line 477 of file Site.php.

References $internalId.

◆ getInterwikiIds()

Site::getInterwikiIds ( )

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

Since
1.21
Returns
string[]

Definition at line 544 of file Site.php.

References ID_INTERWIKI.

Referenced by MediaWiki\Interwiki\InterwikiLookupAdapter\getSiteInterwikis(), SiteTest\testAddInterwikiId(), and SiteTest\testGetInterwikiIds().

◆ getLanguageCode()

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 452 of file Site.php.

References $languageCode.

Referenced by SiteTest\testGetLanguageCode(), and SiteTest\testSetLanguageCode().

◆ getLinkPath()

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 334 of file Site.php.

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

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

◆ getLinkPathType()

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 MediaWikiSite.

Definition at line 351 of file Site.php.

References PATH_LINK.

Referenced by getLinkPath(), and setLinkPath().

◆ getLocalIds()

Site::getLocalIds ( )

Returns all local ids.

Since
1.21
Returns
array[]

Definition at line 571 of file Site.php.

References $localIds.

Referenced by SitesCacheFileBuilder\buildLocalIdentifiers(), and SiteExporter\exportSite().

◆ getNavigationIds()

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 558 of file Site.php.

References ID_EQUIVALENT.

Referenced by SiteTest\testAddNavigationId(), and SiteTest\testGetNavigationIds().

◆ getPageUrl()

Site::getPageUrl (   $pageName = false)

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

Or false 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
bool | string$pageName
Returns
string|bool

Reimplemented in MediaWikiSite.

Definition at line 370 of file Site.php.

References getLinkPath().

Referenced by MediaWiki\Interwiki\InterwikiLookupAdapter\getSiteInterwikis().

◆ getPath()

Site::getPath (   $pathType)

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

Since
1.21
Parameters
string$pathType
Returns
string|null

Definition at line 607 of file Site.php.

References getAllPaths().

Referenced by MediaWikiSite\getFileUrl(), getLinkPath(), MediaWikiSite\getRelativeFilePath(), MediaWikiSite\getRelativePagePath(), SiteTest\testGetPath(), and SiteTest\testSetAndRemovePath().

◆ getProtocol()

Site::getProtocol ( )

Returns the protocol of the site.

Since
1.21
Exceptions
MWException
Returns
string

Definition at line 284 of file Site.php.

References $path, and getLinkPath().

◆ getSource()

Site::getSource ( )

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

Since
1.21
Returns
string

Definition at line 207 of file Site.php.

References $source.

Referenced by SiteExporter\exportSite(), and MediaWiki\Interwiki\InterwikiLookupAdapter\getSiteInterwikis().

◆ getType()

Site::getType ( )

Returns the type of the site (ie mediawiki).

Since
1.21
Returns
string

Definition at line 168 of file Site.php.

References $type.

Referenced by SiteExporter\exportSite(), and SiteTest\testGetType().

◆ newForType()

◆ normalizePageName()

Site::normalizePageName (   $pageName)

Returns $pageName without changes.

Subclasses may override this to apply some kind of normalization.

See also
Site::normalizePageName
Since
1.21
Parameters
string$pageName
Returns
string

Reimplemented in MediaWikiSite.

Definition at line 396 of file Site.php.

Referenced by SiteTest\testNormalizePageName().

◆ removePath()

Site::removePath (   $pathType)

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

Since
1.21
Parameters
string$pathType

Definition at line 631 of file Site.php.

Referenced by SiteTest\testSetAndRemovePath().

◆ serialize()

Site::serialize ( )
See also
Serializable::serialize
Since
1.21
Returns
string

Definition at line 661 of file Site.php.

References $extraConfig, $extraData, $forward, $globalId, $group, $internalId, $languageCode, $localIds, $source, and $type.

Referenced by SitesCacheFileBuilder\getSiteAsArray().

◆ setExtraConfig()

Site::setExtraConfig ( array  $extraConfig)

Sets the type specific config.

Since
1.21
Parameters
array$extraConfig

Definition at line 440 of file Site.php.

References $extraConfig.

Referenced by unserialize().

◆ setExtraData()

Site::setExtraData ( array  $extraData)

Sets the type specific fields.

Since
1.21
Parameters
array$extraData

Definition at line 418 of file Site.php.

References $extraData.

Referenced by unserialize().

◆ setForward()

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

Since
1.21
Parameters
bool$shouldForward
Exceptions
MWException

Definition at line 250 of file Site.php.

Referenced by unserialize().

◆ setGlobalId()

Site::setGlobalId (   $globalId)

Sets the global site identifier (ie enwiktionary).

Since
1.21
Parameters
string | null$globalId
Exceptions
MWException

Definition at line 153 of file Site.php.

References $globalId.

Referenced by SiteTest\testSetGlobalId(), and unserialize().

◆ setGroup()

Site::setGroup (   $group)

Sets the group of the site (ie wikipedia).

Since
1.21
Parameters
string$group
Exceptions
MWException

Definition at line 192 of file Site.php.

References $group, and group.

Referenced by unserialize().

◆ setInternalId()

Site::setInternalId (   $internalId = null)

Sets the internal identifier for the site.

This typically is a primary key in a db table.

Since
1.21
Parameters
int | null$internalId

Definition at line 489 of file Site.php.

References $internalId.

Referenced by unserialize().

◆ setLanguageCode()

Site::setLanguageCode (   $languageCode)

Sets language code of the sites primary language.

Since
1.21
Parameters
string$languageCode

Definition at line 463 of file Site.php.

References $languageCode, and Language\isValidCode().

Referenced by SiteTest\testSetLanguageCode(), and unserialize().

◆ setLinkPath()

Site::setLinkPath (   $fullUrl)

Sets the path used to construct links with.

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

Parameters
string$fullUrl
Since
1.21
Exceptions
MWException

Definition at line 317 of file Site.php.

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

◆ setPath()

Site::setPath (   $pathType,
  $fullUrl 
)

Sets the path used to construct links with.

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

Since
1.21
Parameters
string$pathType
string$fullUrl
Exceptions
MWException

Definition at line 586 of file Site.php.

Referenced by MediaWikiSite\setFilePath(), setLinkPath(), MediaWikiSite\setPagePath(), and SiteTest\testSetAndRemovePath().

◆ setSource()

Site::setSource (   $source)

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

Since
1.21
Parameters
string$source
Exceptions
MWException

Definition at line 220 of file Site.php.

References $source, and source.

Referenced by unserialize().

◆ shouldForward()

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.

Since
1.21
Returns
bool

Definition at line 236 of file Site.php.

References $forward.

Referenced by SiteExporter\exportSite().

◆ unserialize()

Site::unserialize (   $serialized)
See also
Serializable::unserialize
Since
1.21
Parameters
string$serialized

Definition at line 686 of file Site.php.

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

Member Data Documentation

◆ $extraConfig

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

Definition at line 108 of file Site.php.

Referenced by getExtraConfig(), serialize(), and setExtraConfig().

◆ $extraData

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

Definition at line 101 of file Site.php.

Referenced by getExtraData(), serialize(), and setExtraData().

◆ $forward

bool Site::$forward = false
protected
Since
1.21

Definition at line 115 of file Site.php.

Referenced by serialize(), and shouldForward().

◆ $globalId

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

Definition at line 56 of file Site.php.

Referenced by getGlobalId(), serialize(), and setGlobalId().

◆ $group

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

Definition at line 70 of file Site.php.

Referenced by getGroup(), serialize(), and setGroup().

◆ $internalId

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

Definition at line 122 of file Site.php.

Referenced by getInternalId(), serialize(), and setInternalId().

◆ $languageCode

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

Definition at line 84 of file Site.php.

Referenced by getLanguageCode(), serialize(), and setLanguageCode().

◆ $localIds

array [] Site::$localIds = []
protected

Holds the local ids for this site.

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

Since
1.21

Definition at line 94 of file Site.php.

Referenced by getLocalIds(), and serialize().

◆ $source

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

Definition at line 77 of file Site.php.

Referenced by getSource(), serialize(), and setSource().

◆ $type

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

Definition at line 63 of file Site.php.

Referenced by MediaWikiSite\__construct(), __construct(), addLocalId(), getLinkPath(), getType(), serialize(), and setLinkPath().

◆ GROUP_NONE

const Site::GROUP_NONE = 'none'

Definition at line 33 of file Site.php.

Referenced by SiteExporter\exportSite(), and SiteImporter\makeSite().

◆ ID_EQUIVALENT

const Site::ID_EQUIVALENT = 'equivalent'

◆ ID_INTERWIKI

◆ PATH_LINK

◆ SOURCE_LOCAL

const Site::SOURCE_LOCAL = 'local'

Definition at line 38 of file Site.php.

Referenced by SiteExporter\exportSite(), and SiteImporter\makeSite().

◆ TYPE_MEDIAWIKI

const Site::TYPE_MEDIAWIKI = 'mediawiki'

◆ TYPE_UNKNOWN


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