Merge "mw.Feedback: If the message is posted remotely, link the title correctly"
[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 * @author Addshore
20 */
21 namespace MediaWiki\Linker;
22
23 /**
24 * @since 1.27
25 */
26 interface LinkTarget {
27
28 /**
29 * Get the namespace index.
30 * @since 1.27
31 *
32 * @return int Namespace index
33 */
34 public function getNamespace();
35
36 /**
37 * Convenience function to test if it is in the namespace
38 * @since 1.27
39 *
40 * @param int $ns
41 * @return bool
42 */
43 public function inNamespace( $ns );
44
45 /**
46 * Get the link fragment (i.e. the bit after the #) in text form.
47 * @since 1.27
48 *
49 * @return string link fragment
50 */
51 public function getFragment();
52
53 /**
54 * Whether the link target has a fragment
55 * @since 1.27
56 *
57 * @return bool
58 */
59 public function hasFragment();
60
61 /**
62 * Get the main part with underscores.
63 * @since 1.27
64 *
65 * @return string Main part of the link, with underscores (for use in href attributes)
66 */
67 public function getDBkey();
68
69 /**
70 * Returns the link in text form, without namespace prefix or fragment.
71 * This is computed from the DB key by replacing any underscores with spaces.
72 * @since 1.27
73 *
74 * @return string
75 */
76 public function getText();
77
78 /**
79 * Creates a new LinkTarget for a different fragment of the same page.
80 * It is expected that the same type of object will be returned, but the
81 * only requirement is that it is a LinkTarget.
82 * @since 1.27
83 *
84 * @param string $fragment The fragment name, or "" for the entire page.
85 *
86 * @return LinkTarget
87 */
88 public function createFragmentTarget( $fragment );
89
90 /**
91 * Whether this LinkTarget has an interwiki component
92 * @since 1.27
93 *
94 * @return bool
95 */
96 public function isExternal();
97
98 /**
99 * The interwiki component of this LinkTarget
100 * @since 1.27
101 *
102 * @return string
103 */
104 public function getInterwiki();
105
106 /**
107 * Returns an informative human readable representation of the link target,
108 * for use in logging and debugging. There is no requirement for the return
109 * value to have any relationship with the input of TitleParser.
110 * @since 1.31
111 *
112 * @return string
113 */
114 public function __toString();
115
116 }