3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
22 * An interwiki record value object.
24 * By default, these represent a row in the `interwiki` database table.
25 * See @ref \MediaWiki\Interwiki\ClassicInterwikiLookup for where this is used.
29 /** @var string The interwiki prefix, (e.g. "Meatball", or the language prefix "de") */
32 /** @var string The article path URL of the wiki, with "$1" as a placeholder for an article name. */
35 /** @var string The URL to the api.php entry point of the wiki. */
38 /** @var string The name of the database (for a connection to be established
39 * with LBFactory::getMainLB( 'domainId' ))
43 /** @var bool Whether the wiki is in this project */
46 /** @var bool Whether interwiki transclusions are allowed */
49 public function __construct( $prefix = null, $url = '', $api = '', $wikiId = '', $local = 0,
52 $this->mPrefix
= $prefix;
55 $this->mWikiID
= $wikiId;
56 $this->mLocal
= (bool)$local;
57 $this->mTrans
= (bool)$trans;
61 * Get the URL for a particular title (or with $1 if no title given)
63 * @param string|null $title What text to put for the article name
64 * @return string The URL
65 * @note Prior to 1.19 The getURL with an argument was broken.
66 * If you use this arg in an extension that supports MW earlier
67 * than 1.19 please wfUrlencode and substitute $1 on your own.
69 public function getURL( $title = null ) {
71 if ( $title !== null ) {
72 $url = str_replace( "$1", wfUrlencode( $title ), $url );
79 * Get the API URL for this wiki
81 * @return string The URL
83 public function getAPI() {
88 * Get the DB name for this wiki
90 * @return string The DB name
92 public function getWikiID() {
93 return $this->mWikiID
;
97 * Is this a local link from a sister project, or is
98 * it something outside, like Google
102 public function isLocal() {
103 return $this->mLocal
;
107 * Can pages from this wiki be transcluded?
108 * Still requires $wgEnableScaryTransclusion
112 public function isTranscludable() {
113 return $this->mTrans
;
117 * Get the name for the interwiki site
121 public function getName() {
122 $msg = wfMessage( 'interwiki-name-' . $this->mPrefix
)->inContentLanguage();
124 return !$msg->exists() ?
'' : $msg->text();
128 * Get a description for this interwiki
132 public function getDescription() {
133 $msg = wfMessage( 'interwiki-desc-' . $this->mPrefix
)->inContentLanguage();
135 return !$msg->exists() ?
'' : $msg->text();