Go to the documentation of this file.
37 public static function getWiki( $wikiID ) {
39 if ( $wikiReference ) {
40 return $wikiReference;
56 list( $major, $minor ) =
$wgConf->siteFromDB( $wikiID );
57 if ( $major ===
null ) {
60 $server =
$wgConf->get(
'wgServer', $wikiID, $major,
61 [
'lang' => $minor,
'site' => $major ] );
63 $canonicalServer =
$wgConf->get(
'wgCanonicalServer', $wikiID, $major,
64 [
'lang' => $minor,
'site' => $major ] );
65 if ( $canonicalServer ===
false || $canonicalServer ===
null ) {
66 $canonicalServer = $server;
70 [
'lang' => $minor,
'site' => $major ] );
75 if ( !is_string( $canonicalServer ) || !is_string(
$path ) || strpos(
$path,
'$1' ) ===
false ) {
87 $siteLookup = MediaWikiServices::getInstance()->getSiteLookup();
88 $site = $siteLookup->getSite( $wikiID );
96 if ( $urlParts ===
false || !isset( $urlParts[
'path'] ) || !isset( $urlParts[
'host'] ) ) {
102 $path = $urlParts[
'path'];
103 if ( isset( $urlParts[
'query'] ) ) {
104 $path .=
'?' . $urlParts[
'query'];
107 $canonicalServer = $urlParts[
'scheme'] ??
'http';
108 $canonicalServer .=
'://' . $urlParts[
'host'];
124 return $wiki->getDisplayName();
155 if ( $url ===
false ) {
171 public static function getForeignURL( $wikiID, $page, $fragmentId =
null ) {
175 return $wiki->getFullUrl( $page, $fragmentId );
188 $cache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
190 return $cache->getWithSetCallback(
191 $cache->makeGlobalKey(
'wikimap',
'canonical-urls' ),
200 $infoMap[$wikiId] = [
207 if ( $wikiReference ) {
208 $url = $wikiReference->getCanonicalServer();
209 $infoMap[$wikiId] = [
'url' => $url,
'parts' =>
wfParseUrl( $url ) ];
226 if ( strpos( $url,
"$wgCanonicalServer/" ) === 0 ) {
233 if ( $urlPartsCheck ===
false ) {
237 static $relevantKeys = [
'host' => 1,
'port' => 1 ];
238 $urlPartsCheck = array_intersect_key( $urlPartsCheck, $relevantKeys );
240 foreach ( self::getCanonicalServerInfoForAllWikis() as $wikiId => $info ) {
241 $urlParts = $info[
'parts'];
242 if ( $urlParts ===
false ) {
246 $urlParts = array_intersect_key( $urlParts, $relevantKeys );
247 if ( $urlParts == $urlPartsCheck ) {
269 $domain = DatabaseDomain::newFromId( $domain );
275 if ( !in_array( $domain->getSchema(), [
null,
'mediawiki' ],
true ) ) {
279 return "{$domain->getDatabase()}-{$domain->getSchema()}-{$domain->getTablePrefix()}";
283 return strlen( $domain->getTablePrefix() )
284 ?
"{$domain->getDatabase()}-{$domain->getTablePrefix()}"
285 : (
string)$domain->getDatabase();
313 return ( self::getWikiIdFromDbDomain( self::getCurrentWikiDbDomain() ) === $wikiId );
$wgConf
wgConf hold the site configuration.
static isCurrentWikiDbDomain( $domain)
static foreignUserLink( $wikiID, $user, $text=null)
Convenience to get a link to a user page on a foreign wiki.
string[] $wgLocalDatabases
Other wikis on this site, can be administered from a single developer account.
static getCurrentWikiDbDomain()
$wgDBname
Current wiki database name.
static isCurrentWikiId( $wikiId)
static getWikiFromUrl( $url)
static getForeignURL( $wikiID, $page, $fragmentId=null)
Convenience to get a url to a page on a foreign wiki.
$wgDBmwschema
Current wiki database schema name.
$wgDBprefix
Current wiki database table name prefix.
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
static getWikiIdFromDbDomain( $domain)
Get the wiki ID of a database domain.
static getWiki( $wikiID)
Get a WikiReference object for $wikiID.
static makeExternalLink( $url, $text, $escape=true, $linktype='', $attribs=[], $title=null)
Make an external link.
$wgCanonicalServer
Canonical URL of the server, to use in IRC feeds and notification e-mails.
static getWikiReferenceFromWgConf( $wikiID)
static getWikiWikiReferenceFromSites( $wikiID)
static makeForeignLink( $wikiID, $page, $text=null)
Convenience to get a link to a page on a foreign wiki.
Helper tools for dealing with other locally-hosted wikis.
Reference to a locally-hosted wiki.
Class to handle database/schema/prefix specifications for IDatabase.
static getWikiName( $wikiID)
Convenience to get the wiki's display name.
static getCanonicalServerInfoForAllWikis()
Get canonical server info for all local wikis in the map that have one.