Merge "Rephrase tog-norollbackdiff"
[lhc/web/wiklou.git] / includes / linker / LinkTarget.php
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.
7 *
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.
12 *
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
17 *
18 * @file
19 * @license GPL 2+
20 * @author Addshore
21 */
22 namespace MediaWiki\Linker;
23
24 /**
25 * @since 1.27
26 */
27 interface LinkTarget {
28
29 /**
30 * Get the namespace index.
31 *
32 * @return int Namespace index
33 */
34 public function getNamespace();
35
36 /**
37 * Get the link fragment (i.e. the bit after the #) in text form.
38 *
39 * @return string link fragment
40 */
41 public function getFragment();
42
43 /**
44 * Whether the link target has a fragment
45 *
46 * @return bool
47 */
48 public function hasFragment();
49
50 /**
51 * Get the main part with underscores.
52 *
53 * @return string Main part of the link, with underscores (for use in href attributes)
54 */
55 public function getDBkey();
56
57 /**
58 * Returns the link in text form, without namespace prefix or fragment.
59 *
60 * This is computed from the DB key by replacing any underscores with spaces.
61 *
62 * @return string
63 */
64 public function getText();
65
66 /**
67 * Creates a new LinkTarget for a different fragment of the same page.
68 * It is expected that the same type of object will be returned, but the
69 * only requirement is that it is a LinkTarget.
70 *
71 * @param string $fragment The fragment name, or "" for the entire page.
72 *
73 * @return LinkTarget
74 */
75 public function createFragmentTarget( $fragment );
76
77 /**
78 * Whether this LinkTarget has an interwiki component
79 *
80 * @return bool
81 */
82 public function isExternal();
83
84 /**
85 * The interwiki component of this LinkTarget
86 *
87 * @return string
88 */
89 public function getInterwiki();
90 }