29 class Site implements Serializable {
49 const SERIAL_VERSION_ID =
'2013-01-23';
63 protected $type = self::TYPE_UNKNOWN;
157 throw new MWException(
'$globalId needs to be string or null' );
195 if ( !is_string(
$group ) ) {
196 throw new MWException(
'$group needs to be a string' );
224 throw new MWException(
'$source needs to be a string' );
253 if ( !is_bool( $shouldForward ) ) {
254 throw new MWException(
'$shouldForward needs to be a boolean' );
257 $this->forward = $shouldForward;
271 if (
$path === null ) {
275 return parse_url(
$path, PHP_URL_HOST );
289 if (
$path === null ) {
293 $protocol = parse_url(
$path, PHP_URL_SCHEME );
296 if ( $protocol ===
false ) {
297 throw new MWException(
"failed to parse URL '$path'" );
301 if ( $protocol === null ) {
322 if (
$type === null ) {
323 throw new MWException(
"This Site does not support link paths." );
354 return self::PATH_LINK;
375 if ( $url ===
false ) {
379 if ( $pageName !==
false ) {
380 $url = str_replace(
'$1', rawurlencode( $pageName ), $url );
501 if ( $this->localIds ===
false ) {
502 $this->localIds = [];
505 if ( !array_key_exists(
$type, $this->localIds ) ) {
506 $this->localIds[
$type] = [];
509 if ( !in_array( $identifier, $this->localIds[
$type] ) ) {
510 $this->localIds[
$type][] = $identifier;
522 $this->
addLocalId( self::ID_INTERWIKI, $identifier );
533 $this->
addLocalId( self::ID_EQUIVALENT, $identifier );
544 return array_key_exists( self::ID_INTERWIKI, $this->localIds )
545 ? $this->localIds[self::ID_INTERWIKI]
558 return array_key_exists( self::ID_EQUIVALENT, $this->localIds )
559 ? $this->localIds[self::ID_EQUIVALENT] :
585 public function setPath( $pathType, $fullUrl ) {
586 if ( !is_string( $fullUrl ) ) {
587 throw new MWException(
'$fullUrl needs to be a string' );
590 if ( !array_key_exists(
'paths', $this->extraData ) ) {
591 $this->extraData[
'paths'] = [];
594 $this->extraData[
'paths'][$pathType] = $fullUrl;
608 return array_key_exists( $pathType, $paths ) ? $paths[$pathType] : null;
620 return array_key_exists(
'paths', $this->extraData ) ? $this->extraData[
'paths'] : [];
631 if ( array_key_exists(
'paths', $this->extraData ) ) {
632 unset( $this->extraData[
'paths'][$pathType] );
646 if ( array_key_exists( $siteType, $wgSiteTypes ) ) {
647 return new $wgSiteTypes[$siteType]();
691 $this->
setGroup( $fields[
'group'] );
694 $this->localIds = $fields[
'localids'];
getInterwikiIds()
Returns the interwiki link identifiers that can be used for this site.
the array() calling protocol came about after MediaWiki 1.4rc1.
addNavigationId($identifier)
Adds a navigation id to the site.
removePath($pathType)
Removes the path of the provided type if it's set.
normalizePageName($pageName)
Returns $pageName without changes.
setLanguageCode($languageCode)
Sets language code of the sites primary language.
addLocalId($type, $identifier)
Adds a local identifier.
getSource()
Returns the source of the site data (ie 'local', 'wikidata', 'my-magical-repo').
getExtraData()
Returns the type specific fields.
getDomain()
Returns the domain of the site, ie en.wikipedia.org Or false if it's not known.
when a variable name is used in a it is silently declared as a new local masking the global
getLanguageCode()
Returns language code of the sites primary language.
setInternalId($internalId=null)
Sets the internal identifier for the site.
getLocalIds()
Returns all local ids.
setForward($shouldForward)
Sets if site.tld/path/key:pageTitle should forward users to the page on the actual site...
setPath($pathType, $fullUrl)
Sets the path used to construct links with.
getGroup()
Gets the group of the site (ie wikipedia).
setSource($source)
Sets the source of the site data (ie 'local', 'wikidata', 'my-magical-repo').
setExtraConfig(array $extraConfig)
Sets the type specific config.
getAllPaths()
Returns the paths as associative array.
getInternalId()
Returns the set internal identifier for the site.
getLinkPathType()
Returns the main path type, that is the type of the path that should generally be used to construct l...
setLinkPath($fullUrl)
Sets the path used to construct links with.
shouldForward()
Gets if site.tld/path/key:pageTitle should forward users to the page on the actual site...
getPath($pathType)
Returns the path of the provided type or false if there is no such path.
getPageUrl($pageName=false)
Returns the full URL for the given page on the site.
addInterwikiId($identifier)
Adds an interwiki id to the site.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
getLinkPath()
Returns the path used to construct links with or false if there is no such path.
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN type
getNavigationIds()
Returns the equivalent link identifiers that can be used to make the site show up in interfaces such ...
getGlobalId()
Returns the global site identifier (ie enwiktionary).
getProtocol()
Returns the protocol of the site.
getType()
Returns the type of the site (ie mediawiki).
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify prev or next refreshes the diff cache allow viewing deleted revs difference engine object to be used for diff source
string null $languageCode
getExtraConfig()
Returns the type specific config.
array[] $localIds
Holds the local ids for this site.
foreach($res as $row) $serialized
setExtraData(array $extraData)
Sets the type specific fields.
__construct($type=self::TYPE_UNKNOWN)
Constructor.
setGroup($group)
Sets the group of the site (ie wikipedia).
setGlobalId($globalId)
Sets the global site identifier (ie enwiktionary).
static newForType($siteType)