MediaWiki  1.23.8
SiteList.php
Go to the documentation of this file.
1 <?php
2 
30 
38  protected $byInternalId = array();
39 
47  protected $byGlobalId = array();
48 
57  protected $byNavigationId = array();
58 
66  public function getObjectType() {
67  return 'Site';
68  }
69 
80  protected function preSetElement( $index, $site ) {
81  if ( $this->hasSite( $site->getGlobalId() ) ) {
82  $this->removeSite( $site->getGlobalId() );
83  }
84 
85  $this->byGlobalId[$site->getGlobalId()] = $index;
86  $this->byInternalId[$site->getInternalId()] = $index;
87 
88  $ids = $site->getNavigationIds();
89  foreach ( $ids as $navId ) {
90  $this->byNavigationId[$navId] = $index;
91  }
92 
93  return true;
94  }
95 
103  public function offsetUnset( $index ) {
104  if ( $this->offsetExists( $index ) ) {
108  $site = $this->offsetGet( $index );
109 
110  unset( $this->byGlobalId[$site->getGlobalId()] );
111  unset( $this->byInternalId[$site->getInternalId()] );
112 
113  $ids = $site->getNavigationIds();
114  foreach ( $ids as $navId ) {
115  unset( $this->byNavigationId[$navId] );
116  }
117  }
118 
119  parent::offsetUnset( $index );
120  }
121 
130  public function getGlobalIdentifiers() {
131  return array_keys( $this->byGlobalId );
132  }
133 
141  public function hasSite( $globalSiteId ) {
142  return array_key_exists( $globalSiteId, $this->byGlobalId );
143  }
144 
155  public function getSite( $globalSiteId ) {
156  return $this->offsetGet( $this->byGlobalId[$globalSiteId] );
157  }
158 
167  public function removeSite( $globalSiteId ) {
168  $this->offsetUnset( $this->byGlobalId[$globalSiteId] );
169  }
170 
178  public function isEmpty() {
179  return $this->byGlobalId === array();
180  }
181 
189  public function hasInternalId( $id ) {
190  return array_key_exists( $id, $this->byInternalId );
191  }
192 
203  public function getSiteByInternalId( $id ) {
204  return $this->offsetGet( $this->byInternalId[$id] );
205  }
206 
215  public function removeSiteByInternalId( $id ) {
216  $this->offsetUnset( $this->byInternalId[$id] );
217  }
218 
226  public function hasNavigationId( $id ) {
227  return array_key_exists( $id, $this->byNavigationId );
228  }
229 
240  public function getSiteByNavigationId( $id ) {
241  return $this->offsetGet( $this->byNavigationId[$id] );
242  }
243 
252  public function removeSiteByNavigationId( $id ) {
253  $this->offsetUnset( $this->byNavigationId[$id] );
254  }
255 
264  public function setSite( Site $site ) {
265  $this[] = $site;
266  }
267 
277  public function getGroup( $groupName ) {
278  $group = new self();
279 
283  foreach ( $this as $site ) {
284  if ( $site->getGroup() === $groupName ) {
285  $group[] = $site;
286  }
287  }
288 
289  return $group;
290  }
291 
300  const SERIAL_VERSION_ID = '2014-03-17';
301 
311  public static function getSerialVersionId() {
312  return self::SERIAL_VERSION_ID . '+Site:' . Site::SERIAL_VERSION_ID;
313  }
314 
322  protected function getSerializationData() {
323  //NOTE: When changing the structure, either implement unserialize() to handle the
324  // old structure too, or update SERIAL_VERSION_ID to kill any caches.
325  return array_merge(
326  parent::getSerializationData(),
327  array(
328  'internalIds' => $this->byInternalId,
329  'globalIds' => $this->byGlobalId,
330  'navigationIds' => $this->byNavigationId
331  )
332  );
333  }
334 
344  public function unserialize( $serialization ) {
345  $serializationData = parent::unserialize( $serialization );
346 
347  $this->byInternalId = $serializationData['internalIds'];
348  $this->byGlobalId = $serializationData['globalIds'];
349  $this->byNavigationId = $serializationData['navigationIds'];
350 
351  return $serializationData;
352  }
353 
354 }
355 
359 class SiteArray extends SiteList {}
SiteList\$byGlobalId
array $byGlobalId
Global site identifiers pointing to their sites offset value.
Definition: SiteList.php:45
SiteList\getSerialVersionId
static getSerialVersionId()
Returns the version ID that identifies the serialization structure used by getSerializationData() and...
Definition: SiteList.php:308
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
SiteList\getGroup
getGroup( $groupName)
Returns the sites that are in the provided group.
Definition: SiteList.php:274
GenericArrayObject
Definition: GenericArrayObject.php:35
SiteList\hasSite
hasSite( $globalSiteId)
Returns if the list contains the site with the provided global site identifier.
Definition: SiteList.php:138
SiteList\getObjectType
getObjectType()
Definition: SiteList.php:63
SiteList\SERIAL_VERSION_ID
const SERIAL_VERSION_ID
Definition: SiteList.php:297
SiteList\hasInternalId
hasInternalId( $id)
Returns if the list contains the site with the provided site id.
Definition: SiteList.php:186
SiteList\getSiteByNavigationId
getSiteByNavigationId( $id)
Returns the Site with the provided navigational site id.
Definition: SiteList.php:237
SiteList\offsetUnset
offsetUnset( $index)
Definition: SiteList.php:100
SiteList
Definition: SiteList.php:29
SiteArray
Definition: SiteList.php:356
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
SiteList\preSetElement
preSetElement( $index, $site)
Definition: SiteList.php:77
Site\SERIAL_VERSION_ID
const SERIAL_VERSION_ID
Definition: Site.php:50
Site
Definition: Site.php:29
SiteList\getSerializationData
getSerializationData()
Definition: SiteList.php:319
SiteList\isEmpty
isEmpty()
Returns if the list contains no sites.
Definition: SiteList.php:175
SiteList\removeSite
removeSite( $globalSiteId)
Removes the site with the specified global site identifier.
Definition: SiteList.php:164
SiteList\setSite
setSite(Site $site)
Sets a site in the list.
Definition: SiteList.php:261
SiteList\unserialize
unserialize( $serialization)
Definition: SiteList.php:341
SiteList\removeSiteByNavigationId
removeSiteByNavigationId( $id)
Removes the site with the specified navigational site id.
Definition: SiteList.php:249
SiteList\getSiteByInternalId
getSiteByInternalId( $id)
Returns the Site with the provided site id.
Definition: SiteList.php:200
SiteList\getGlobalIdentifiers
getGlobalIdentifiers()
Returns all the global site identifiers.
Definition: SiteList.php:127
SiteList\hasNavigationId
hasNavigationId( $id)
Returns if the list contains the site with the provided navigational site id.
Definition: SiteList.php:223
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
SiteList\$byNavigationId
array $byNavigationId
Navigational site identifiers alias inter-language prefixes pointing to their sites offset value.
Definition: SiteList.php:54
SiteList\getSite
getSite( $globalSiteId)
Returns the Site with the provided global site identifier.
Definition: SiteList.php:152
SiteList\removeSiteByInternalId
removeSiteByInternalId( $id)
Removes the site with the specified site id.
Definition: SiteList.php:212
SiteList\$byInternalId
array $byInternalId
Internal site identifiers pointing to their sites offset value.
Definition: SiteList.php:37