MediaWiki master
Interwiki.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Interwiki;
22
29class Interwiki {
30
32 protected $mPrefix;
33
35 protected $mURL;
36
38 protected $mAPI;
39
43 protected $mWikiID;
44
46 protected $mLocal;
47
49 protected $mTrans;
50
51 public function __construct( $prefix = null, $url = '', $api = '', $wikiId = '', $local = 0,
52 $trans = 0
53 ) {
54 $this->mPrefix = $prefix;
55 $this->mURL = $url;
56 $this->mAPI = $api;
57 $this->mWikiID = $wikiId;
58 $this->mLocal = (bool)$local;
59 $this->mTrans = (bool)$trans;
60 }
61
71 public function getURL( $title = null ) {
73 if ( $title !== null ) {
74 $url = str_replace( "$1", wfUrlencode( $title ), $url );
75 }
76
77 return $url;
78 }
79
85 public function getAPI() {
86 return $this->mAPI;
87 }
88
94 public function getWikiID() {
95 return $this->mWikiID;
96 }
97
104 public function isLocal() {
105 return $this->mLocal;
106 }
107
114 public function isTranscludable() {
115 return $this->mTrans;
116 }
117
123 public function getName() {
124 $msg = wfMessage( 'interwiki-name-' . $this->mPrefix )->inContentLanguage();
125
126 return !$msg->exists() ? '' : $msg->text();
127 }
128
134 public function getDescription() {
135 $msg = wfMessage( 'interwiki-desc-' . $this->mPrefix )->inContentLanguage();
136
137 return !$msg->exists() ? '' : $msg->text();
138 }
139
140}
141
143class_alias( Interwiki::class, 'Interwiki' );
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
An interwiki record value object.
Definition Interwiki.php:29
string $mWikiID
The name of the database (for a connection to be established with LBFactory::getMainLB( 'domainId' ))
Definition Interwiki.php:43
__construct( $prefix=null, $url='', $api='', $wikiId='', $local=0, $trans=0)
Definition Interwiki.php:51
string $mAPI
The URL to the api.php entry point of the wiki.
Definition Interwiki.php:38
string $mURL
The article path URL of the wiki, with "$1" as a placeholder for an article name.
Definition Interwiki.php:35
bool $mTrans
Whether interwiki transclusions are allowed.
Definition Interwiki.php:49
getWikiID()
Get the DB name for this wiki.
Definition Interwiki.php:94
getURL( $title=null)
Get the URL for a particular title (or with $1 if no title given)
Definition Interwiki.php:71
getName()
Get the name for the interwiki site.
getAPI()
Get the API URL for this wiki.
Definition Interwiki.php:85
isLocal()
Is this a local link from a sister project, or is it something outside, like Google.
string $mPrefix
The interwiki prefix, (e.g.
Definition Interwiki.php:32
isTranscludable()
Can pages from this wiki be transcluded? Still requires $wgEnableScaryTransclusion.
bool $mLocal
Whether the wiki is in this project.
Definition Interwiki.php:46
getDescription()
Get a description for this interwiki.