Merge "Special:Upload should not crash on failing previews"
[mediawiki.git] / includes / linker / LinkTarget.php
blobdbd97a7a028bd06d58401ed9fb072b742b316eb7
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
19 * @license GPL 2+
20 * @author Addshore
22 namespace MediaWiki\Linker;
24 /**
25 * @since 1.27
27 interface LinkTarget {
29 /**
30 * Get the namespace index.
31 * @since 1.27
33 * @return int Namespace index
35 public function getNamespace();
37 /**
38 * Convenience function to test if it is in the namespace
39 * @since 1.27
41 * @param int $ns
42 * @return bool
44 public function inNamespace( $ns );
46 /**
47 * Get the link fragment (i.e. the bit after the #) in text form.
48 * @since 1.27
50 * @return string link fragment
52 public function getFragment();
54 /**
55 * Whether the link target has a fragment
56 * @since 1.27
58 * @return bool
60 public function hasFragment();
62 /**
63 * Get the main part with underscores.
64 * @since 1.27
66 * @return string Main part of the link, with underscores (for use in href attributes)
68 public function getDBkey();
70 /**
71 * Returns the link in text form, without namespace prefix or fragment.
72 * This is computed from the DB key by replacing any underscores with spaces.
73 * @since 1.27
75 * @return string
77 public function getText();
79 /**
80 * Creates a new LinkTarget for a different fragment of the same page.
81 * It is expected that the same type of object will be returned, but the
82 * only requirement is that it is a LinkTarget.
83 * @since 1.27
85 * @param string $fragment The fragment name, or "" for the entire page.
87 * @return LinkTarget
89 public function createFragmentTarget( $fragment );
91 /**
92 * Whether this LinkTarget has an interwiki component
93 * @since 1.27
95 * @return bool
97 public function isExternal();
99 /**
100 * The interwiki component of this LinkTarget
101 * @since 1.27
103 * @return string
105 public function getInterwiki();