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 );
192 public function __construct( $canonicalServer, $path, $server =
null ) {
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.
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
static makeExternalLink( $url, $text, $escape=true, $linktype='', $attribs=[], $title=null)
Make an external link.
Helper tools for dealing with other wikis.
static getWikiWikiReferenceFromSites( $wikiID)
static makeForeignLink( $wikiID, $page, $text=null)
Convenience to get a link to a page on a foreign wiki.
static getWiki( $wikiID)
Get a WikiReference object for $wikiID.
static getWikiReferenceFromWgConf( $wikiID)
static getWikiName( $wikiID)
Convenience to get the wiki's display name.
static foreignUserLink( $wikiID, $user, $text=null)
Convenience to get a link to a user page on a foreign wiki.
static getForeignURL( $wikiID, $page, $fragmentId=null)
Convenience to get a url to a page on a foreign wiki.
Reference to a locally-hosted wiki.
getDisplayName()
Get the URL in a way to be displayed to the user More or less Wikimedia specific.
getCanonicalUrl( $page, $fragmentId=null)
Get a canonical (i.e.
__construct( $canonicalServer, $path, $server=null)
$mServer
server URL, may be protocol-relative, e.g. '//www.mediawiki.org'
getFullUrl( $page, $fragmentId=null)
Get a URL based on $wgServer, like Title::getFullURL() would produce when called locally on the wiki.
getCanonicalServer()
Get a canonical server URL.
getUrl( $page, $fragmentId=null)
Alias for getCanonicalUrl(), for backwards compatibility.
getLocalUrl( $page, $fragmentId=null)
Helper function for getUrl()
$mCanonicalServer
canonical server URL, e.g. 'https://www.mediawiki.org'
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
when a variable name is used in a it is silently declared as a new local masking the global
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' 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
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