MediaWiki master
Interwiki.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Interwiki;
8
15class Interwiki {
16
18 protected $mPrefix;
19
21 protected $mURL;
22
24 protected $mAPI;
25
29 protected $mWikiID;
30
32 protected $mLocal;
33
35 protected $mTrans;
36
45 public function __construct( $prefix = null, $url = '', $api = '', $wikiId = '', $local = 0,
46 $trans = 0
47 ) {
48 $this->mPrefix = $prefix;
49 $this->mURL = $url;
50 $this->mAPI = $api;
51 $this->mWikiID = $wikiId;
52 $this->mLocal = (bool)$local;
53 $this->mTrans = (bool)$trans;
54 }
55
65 public function getURL( $title = null ) {
67 if ( $title !== null ) {
68 $url = str_replace( "$1", wfUrlencode( $title ), $url );
69 }
70
71 return $url;
72 }
73
79 public function getAPI() {
80 return $this->mAPI;
81 }
82
88 public function getWikiID() {
89 return $this->mWikiID;
90 }
91
98 public function isLocal() {
99 return $this->mLocal;
100 }
101
108 public function isTranscludable() {
109 return $this->mTrans;
110 }
111
117 public function getName() {
118 $msg = wfMessage( 'interwiki-name-' . $this->mPrefix )->inContentLanguage();
119
120 return !$msg->exists() ? '' : $msg->text();
121 }
122
128 public function getDescription() {
129 $msg = wfMessage( 'interwiki-desc-' . $this->mPrefix )->inContentLanguage();
130
131 return !$msg->exists() ? '' : $msg->text();
132 }
133
134}
135
137class_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:15
string $mWikiID
The name of the database (for a connection to be established with LBFactory::getMainLB( 'domainId' ))
Definition Interwiki.php:29
__construct( $prefix=null, $url='', $api='', $wikiId='', $local=0, $trans=0)
Definition Interwiki.php:45
string $mAPI
The URL to the api.php entry point of the wiki.
Definition Interwiki.php:24
string $mURL
The article path URL of the wiki, with "$1" as a placeholder for an article name.
Definition Interwiki.php:21
bool $mTrans
Whether interwiki transclusions are allowed.
Definition Interwiki.php:35
getWikiID()
Get the DB name for this wiki.
Definition Interwiki.php:88
getURL( $title=null)
Get the URL for a particular title (or with $1 if no title given)
Definition Interwiki.php:65
getName()
Get the name for the interwiki site.
getAPI()
Get the API URL for this wiki.
Definition Interwiki.php:79
isLocal()
Is this a local link from a sister project, or is it something outside, like Google.
Definition Interwiki.php:98
string $mPrefix
The interwiki prefix, (e.g.
Definition Interwiki.php:18
isTranscludable()
Can pages from this wiki be transcluded? Still requires $wgEnableScaryTransclusion.
bool $mLocal
Whether the wiki is in this project.
Definition Interwiki.php:32
getDescription()
Get a description for this interwiki.