3 * Interwiki table entry.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 use MediaWiki\MediaWikiServices
;
25 * Value object for representing interwiki records.
29 /** @var string The interwiki prefix, (e.g. "Meatball", or the language prefix "de") */
32 /** @var string The URL of the wiki, with "$1" as a placeholder for an article name. */
35 /** @var string The URL of the file api.php */
38 /** @var string The name of the database (for a connection to be established
39 * with LBFactory::getMainLB( 'wikiid' ))
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 * Check whether an interwiki prefix exists
63 * @deprecated since 1.28, use InterwikiLookup instead
65 * @param string $prefix Interwiki prefix to use
66 * @return bool Whether it exists
68 public static function isValidInterwiki( $prefix ) {
69 wfDeprecated( __METHOD__
, '1.28' );
70 return MediaWikiServices
::getInstance()->getInterwikiLookup()->isValidInterwiki( $prefix );
74 * Fetch an Interwiki object
76 * @deprecated since 1.28, use InterwikiLookup instead
78 * @param string $prefix Interwiki prefix to use
79 * @return Interwiki|null|bool
81 public static function fetch( $prefix ) {
82 wfDeprecated( __METHOD__
, '1.28' );
83 return MediaWikiServices
::getInstance()->getInterwikiLookup()->fetch( $prefix );
87 * Purge the cache (local and persistent) for an interwiki prefix.
89 * @param string $prefix
92 public static function invalidateCache( $prefix ) {
93 wfDeprecated( __METHOD__
, '1.28' );
94 MediaWikiServices
::getInstance()->getInterwikiLookup()->invalidateCache( $prefix );
98 * Returns all interwiki prefix definitions.
100 * @deprecated since 1.28, unused. Use InterwikiLookup instead.
102 * @param string|null $local If set, limits output to local/non-local interwikis
103 * @return array[] List of interwiki rows
106 public static function getAllPrefixes( $local = null ) {
107 wfDeprecated( __METHOD__
, '1.28' );
108 return MediaWikiServices
::getInstance()->getInterwikiLookup()->getAllPrefixes( $local );
112 * Get the URL for a particular title (or with $1 if no title given)
114 * @param string $title What text to put for the article name
115 * @return string The URL
116 * @note Prior to 1.19 The getURL with an argument was broken.
117 * If you if you use this arg in an extension that supports MW earlier
118 * than 1.19 please wfUrlencode and substitute $1 on your own.
120 public function getURL( $title = null ) {
122 if ( $title !== null ) {
123 $url = str_replace( "$1", wfUrlencode( $title ), $url );
130 * Get the API URL for this wiki
132 * @return string The URL
134 public function getAPI() {
139 * Get the DB name for this wiki
141 * @return string The DB name
143 public function getWikiID() {
144 return $this->mWikiID
;
148 * Is this a local link from a sister project, or is
149 * it something outside, like Google
153 public function isLocal() {
154 return $this->mLocal
;
158 * Can pages from this wiki be transcluded?
159 * Still requires $wgEnableScaryTransclusion
163 public function isTranscludable() {
164 return $this->mTrans
;
168 * Get the name for the interwiki site
172 public function getName() {
173 $msg = wfMessage( 'interwiki-name-' . $this->mPrefix
)->inContentLanguage();
175 return !$msg->exists() ?
'' : $msg->text();
179 * Get a description for this interwiki
183 public function getDescription() {
184 $msg = wfMessage( 'interwiki-desc-' . $this->mPrefix
)->inContentLanguage();
186 return !$msg->exists() ?
'' : $msg->text();