Go to the documentation of this file.
34 public static function getWiki( $wikiID ) {
36 if ( $wikiReference ) {
37 return $wikiReference;
53 list( $major, $minor ) =
$wgConf->siteFromDB( $wikiID );
54 if ( $major ===
null ) {
57 $server =
$wgConf->get(
'wgServer', $wikiID, $major,
58 [
'lang' => $minor,
'site' => $major ] );
60 $canonicalServer =
$wgConf->get(
'wgCanonicalServer', $wikiID, $major,
61 [
'lang' => $minor,
'site' => $major ] );
62 if ( $canonicalServer ===
false || $canonicalServer ===
null ) {
63 $canonicalServer = $server;
67 [
'lang' => $minor,
'site' => $major ] );
72 if ( !is_string( $canonicalServer ) || !is_string(
$path ) || strpos(
$path,
'$1' ) ===
false ) {
84 $siteLookup = \MediaWiki\MediaWikiServices::getInstance()->getSiteLookup();
85 $site = $siteLookup->getSite( $wikiID );
93 if ( $urlParts ===
false || !isset( $urlParts[
'path'] ) || !isset( $urlParts[
'host'] ) ) {
99 $path = $urlParts[
'path'];
100 if ( isset( $urlParts[
'query'] ) ) {
101 $path .=
'?' . $urlParts[
'query'];
104 $canonicalServer = isset( $urlParts[
'scheme'] ) ? $urlParts[
'scheme'] :
'http';
105 $canonicalServer .=
'://' . $urlParts[
'host'];
121 return $wiki->getDisplayName();
152 if ( $url ===
false ) {
172 return $wiki->getFullUrl(
$page, $fragmentId );
193 $this->mCanonicalServer = $canonicalServer;
194 $this->mPath =
$path;
195 $this->mServer = $server ===
null ? $canonicalServer : $server;
205 $parsed =
wfParseUrl( $this->mCanonicalServer );
207 return $parsed[
'host'];
229 if ( is_string( $fragmentId ) && $fragmentId !==
'' ) {
233 return str_replace(
'$1',
$page, $this->mPath );
277 return $this->mServer .
$wgConf
wgConf hold the site configuration.
__construct( $canonicalServer, $path, $server=null)
getUrl( $page, $fragmentId=null)
Alias for getCanonicalUrl(), for backwards compatibility.
static foreignUserLink( $wikiID, $user, $text=null)
Convenience to get a link to a user page on a foreign wiki.
getFullUrl( $page, $fragmentId=null)
Get a URL based on $wgServer, like Title::getFullURL() would produce when called locally on the wiki.
$mCanonicalServer
canonical server URL, e.g. 'https://www.mediawiki.org'
static getForeignURL( $wikiID, $page, $fragmentId=null)
Convenience to get a url to a page on a foreign wiki.
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
getLocalUrl( $page, $fragmentId=null)
Helper function for getUrl()
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
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
getDisplayName()
Get the URL in a way to be displayed to the user More or less Wikimedia specific.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
static getWiki( $wikiID)
Get a WikiReference object for $wikiID.
static makeExternalLink( $url, $text, $escape=true, $linktype='', $attribs=[], $title=null)
Make an external link.
when a variable name is used in a it is silently declared as a new masking the global
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
$mServer
server URL, may be protocol-relative, e.g. '//www.mediawiki.org'
static getWikiReferenceFromWgConf( $wikiID)
static getWikiWikiReferenceFromSites( $wikiID)
static makeForeignLink( $wikiID, $page, $text=null)
Convenience to get a link to a page on a foreign wiki.
getCanonicalUrl( $page, $fragmentId=null)
Get a canonical (i.e.
Helper tools for dealing with other wikis.
Reference to a locally-hosted wiki.
getCanonicalServer()
Get a canonical server URL.
static getWikiName( $wikiID)
Convenience to get the wiki's display name.