Merge "Simplify code to avoid interpreting "$" characters in string replacement"
[mediawiki.git] / includes / interwiki / InterwikiLookup.php
blobdb9d1b5e948b6c31b1d18a5c46ccb9551bc222a7
1 <?php
2 /**
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
18 * @file
21 namespace MediaWiki\Interwiki;
23 use Interwiki;
25 /**
26 * Service interface for looking up Interwiki records.
28 * Default implementation is ClassicInterwikiLookup.
30 * @since 1.28
32 interface InterwikiLookup {
34 /**
35 * Check whether an interwiki prefix exists
37 * @param string $prefix Interwiki prefix
38 * @return bool Whether it exists
40 public function isValidInterwiki( $prefix );
42 /**
43 * Get the Interwiki object for a given prefix
45 * @param string $prefix Interwiki prefix
46 * @return Interwiki|null|false Null for invalid, false for not found
48 public function fetch( $prefix );
50 /**
51 * Returns information about all interwiki prefixes, in the form of rows
52 * of the interwiki table. Each row may have the following keys:
54 * - iw_prefix: the prefix. Always present.
55 * - iw_url: the URL to use for linking, with $1 as a placeholder for the target page.
56 * Always present.
57 * - iw_api: the URL of the API. Optional.
58 * - iw_wikiid: the wiki ID (usually the database name for local wikis). Optional.
59 * - iw_local: whether the wiki is local, and the "magic redirect" mechanism should apply.
60 * Defaults to false.
61 * - iw_trans: whether "scary transclusion" is allowed for this site.
62 * Defaults to false.
64 * The order of the rows matters! The *first* row matching a
65 * given URL is used by VisualEditor/Parsoid when converting external URLs to
66 * interwiki links. If, for example, both `labsconsole:` and
67 * `wikitech:` resolve to the same URL, but you want VisualEditor to prefer
68 * `wikitech` when adding new links, then the row for `wikitech` should
69 * come before the row for `labsconsole`.
71 * @param bool|null $local If set, limit output to local or non-local interwikis
72 * @return array[] interwiki rows.
74 public function getAllPrefixes( $local = null );
76 /**
77 * Purge the in-process and any persistent cache (e.g. memcached) for an interwiki prefix.
79 * @param string $prefix
81 public function invalidateCache( $prefix );