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

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)
 Returns the full URL for the given page on the site.
 
 getPath ( $pathType)
 Returns the path of the provided type or false 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)
 Attempt to normalize the page name in some fashion.
 
 removePath ( $pathType)
 Removes the path of the provided type if it's set.
 
 serialize ()
 
 setExtraConfig (array $extraConfig)
 Sets the type specific config.
 
 setExtraData (array $extraData)
 Sets the type specific fields.
 
 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.
 
 setGlobalId ( $globalId)
 Sets the global site identifier (ie enwiktionary).
 
 setGroup ( $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)
 Sets the path used to construct links with.
 
 setPath ( $pathType, $fullUrl)
 Sets the path used to construct links with.
 
 setSource ( $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.
 
 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[] false $localIds = []
 Holds the local ids for this site.
 
string $source = self::SOURCE_LOCAL
 
string $type = self::TYPE_UNKNOWN
 

Detailed Description

Definition at line 31 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 131 of file Site.php.

References $type.

Member Function Documentation

◆ __serialize()

Site::__serialize ( )
See also
Serializable::serialize
Since
1.35.6
Returns
array

Definition at line 686 of file Site.php.

References $source, and $type.

◆ __unserialize()

Site::__unserialize (   $fields)
See also
Serializable::unserialize
Since
1.35.6
Parameters
array$fields

Definition at line 719 of file Site.php.

◆ addInterwikiId()

Site::addInterwikiId (   $identifier)

Adds an interwiki id to the site.

Since
1.21
Parameters
string$identifier

Definition at line 536 of file Site.php.

◆ addLocalId()

Site::addLocalId (   $type,
  $identifier 
)

Adds a local identifier.

Since
1.21
Parameters
string$type
string$identifier

Definition at line 515 of file Site.php.

References $type.

◆ addNavigationId()

Site::addNavigationId (   $identifier)

Adds a navigation id to the site.

Since
1.21
Parameters
string$identifier

Definition at line 547 of file Site.php.

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

Referenced by SiteExporter\exportSite().

◆ getDomain()

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

◆ getExtraConfig()

Site::getExtraConfig ( )

Returns the type specific config.

Since
1.21
Returns
array

Definition at line 439 of file Site.php.

◆ getExtraData()

Site::getExtraData ( )

Returns the type specific fields.

Since
1.21
Returns
array

Definition at line 417 of file Site.php.

◆ getGlobalId()

Site::getGlobalId ( )

Returns the global site identifier (ie enwiktionary).

Since
1.21
Returns
string|null

Definition at line 142 of file Site.php.

References $globalId.

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

◆ getGroup()

Site::getGroup ( )

Gets the group of the site (ie wikipedia).

Since
1.21
Returns
string

Definition at line 181 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 491 of file Site.php.

◆ getInterwikiIds()

Site::getInterwikiIds ( )

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

Since
1.21
Returns
string[]

Definition at line 558 of file Site.php.

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

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

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

References $type.

Referenced by MediaWikiSite\getPageUrl().

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

◆ getLocalIds()

Site::getLocalIds ( )

Returns all local ids.

Since
1.21
Returns
array[]

Definition at line 585 of file Site.php.

Referenced by 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 572 of file Site.php.

◆ getPageUrl()

Site::getPageUrl (   $pageName = false)

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

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

Reimplemented in MediaWikiSite.

Definition at line 378 of file Site.php.

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

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

◆ getProtocol()

Site::getProtocol ( )

Returns the protocol of the site.

Since
1.21
Exceptions
MWException
Returns
string

Definition at line 292 of file Site.php.

References $path.

◆ getSource()

Site::getSource ( )

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

Since
1.21
Returns
string

Definition at line 209 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 170 of file Site.php.

References $type.

Referenced by SiteExporter\exportSite().

◆ newForType()

static Site::newForType (   $siteType)
static
Since
1.21
Parameters
string$siteType
Returns
Site

Definition at line 658 of file Site.php.

References $wgSiteTypes.

Referenced by DBSiteStore\loadSites(), and SiteImporter\makeSite().

◆ normalizePageName()

Site::normalizePageName (   $pageName)

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

Reimplemented in MediaWikiSite.

Definition at line 406 of file Site.php.

◆ removePath()

Site::removePath (   $pathType)

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

Since
1.21
Parameters
string$pathType

Definition at line 645 of file Site.php.

◆ serialize()

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

Definition at line 675 of file Site.php.

◆ setExtraConfig()

Site::setExtraConfig ( array  $extraConfig)

Sets the type specific config.

Since
1.21
Parameters
array$extraConfig

Definition at line 450 of file Site.php.

◆ setExtraData()

Site::setExtraData ( array  $extraData)

Sets the type specific fields.

Since
1.21
Parameters
array$extraData

Definition at line 428 of file Site.php.

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

◆ setGlobalId()

Site::setGlobalId (   $globalId)

Sets the global site identifier (ie enwiktionary).

Since
1.21
Parameters
string | null$globalId
Exceptions
MWException

Definition at line 155 of file Site.php.

References $globalId.

◆ setGroup()

Site::setGroup (   $group)

Sets the group of the site (ie wikipedia).

Since
1.21
Parameters
string$group
Exceptions
MWException

Definition at line 194 of file Site.php.

References $group.

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

◆ setLanguageCode()

Site::setLanguageCode (   $languageCode)

Sets language code of the sites primary language.

Since
1.21
Parameters
string | null$languageCode

Definition at line 473 of file Site.php.

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

References $type.

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

Referenced by MediaWikiSite\setFilePath(), and MediaWikiSite\setPagePath().

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

References $source.

◆ 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 238 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 708 of file Site.php.

Member Data Documentation

◆ $extraConfig

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

Definition at line 110 of file Site.php.

◆ $extraData

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

Definition at line 103 of file Site.php.

◆ $forward

bool Site::$forward = false
protected
Since
1.21

Definition at line 117 of file Site.php.

Referenced by shouldForward().

◆ $globalId

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

Definition at line 58 of file Site.php.

Referenced by getGlobalId(), and setGlobalId().

◆ $group

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

Definition at line 72 of file Site.php.

Referenced by getGroup(), and setGroup().

◆ $internalId

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

Definition at line 124 of file Site.php.

◆ $languageCode

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

Definition at line 86 of file Site.php.

◆ $localIds

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

Holds the local ids for this site.

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

Since
1.21

Definition at line 96 of file Site.php.

◆ $source

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

Definition at line 79 of file Site.php.

Referenced by getSource(), and setSource().

◆ $type

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

Definition at line 65 of file Site.php.

Referenced by __construct(), and getType().

◆ GROUP_NONE

const Site::GROUP_NONE = 'none'

Definition at line 35 of file Site.php.

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

◆ ID_EQUIVALENT

const Site::ID_EQUIVALENT = 'equivalent'

Definition at line 38 of file Site.php.

◆ ID_INTERWIKI

const Site::ID_INTERWIKI = 'interwiki'

Definition at line 37 of file Site.php.

◆ PATH_LINK

const Site::PATH_LINK = 'link'

Definition at line 42 of file Site.php.

◆ SOURCE_LOCAL

const Site::SOURCE_LOCAL = 'local'

Definition at line 40 of file Site.php.

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

◆ TYPE_MEDIAWIKI

const Site::TYPE_MEDIAWIKI = 'mediawiki'

Definition at line 33 of file Site.php.

◆ TYPE_UNKNOWN

const Site::TYPE_UNKNOWN = 'unknown'

Definition at line 32 of file Site.php.

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


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