Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / title / TitleFormatter.php
blob8fcf28851c380658f4a8e665ac31508ff2372ada
1 <?php
2 /**
3 * A title formatter service for MediaWiki.
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
20 * @file
21 * @author Daniel Kinzler
24 namespace MediaWiki\Title;
26 use MediaWiki\Linker\LinkTarget;
27 use MediaWiki\Page\PageReference;
29 /**
30 * A title formatter service for MediaWiki.
32 * This is designed to encapsulate knowledge about conventions for the title
33 * forms to be used in the database, in urls, in wikitext, etc.
35 * @see https://www.mediawiki.org/wiki/Requests_for_comment/TitleValue
36 * @since 1.23
38 interface TitleFormatter {
39 /**
40 * Returns the title formatted for display.
41 * By default, this includes the namespace but not the fragment.
43 * @note Normalization is applied if $title is not in TitleValue::TITLE_FORM.
45 * @param int|bool $namespace The namespace ID (or false, if the namespace should be ignored)
46 * @param string $text The page title
47 * @param string $fragment The fragment name (may be empty).
48 * @param string $interwiki The interwiki prefix (may be empty).
50 * @return string
52 public function formatTitle( $namespace, $text, $fragment = '', $interwiki = '' );
54 /**
55 * Returns the title text formatted for display, without namespace or fragment.
57 * @param LinkTarget|PageReference $title The title to format
59 * @return string
61 public function getText( $title );
63 /**
64 * Returns the title formatted for display, including the namespace name.
66 * @param LinkTarget|PageReference $title The title to format
68 * @return string
70 public function getPrefixedText( $title );
72 /**
73 * Return the title in prefixed database key form, with interwiki
74 * and namespace.
76 * @since 1.27
78 * @param LinkTarget|PageReference $target
80 * @return string
82 public function getPrefixedDBkey( $target );
84 /**
85 * Returns the title formatted for display, with namespace and fragment.
87 * @param LinkTarget|PageReference $title The title to format
89 * @return string
91 public function getFullText( $title );
93 /**
94 * Returns the name of the namespace for the given title.
96 * @note This must take into account gender sensitive namespace names.
97 * @todo Move this to a separate interface
99 * @param int $namespace
100 * @param string $text
102 * @return string Namespace name with underscores (not spaces), e.g. 'User_talk'
104 public function getNamespaceName( $namespace, $text );
107 /** @deprecated class alias since 1.41 */
108 class_alias( TitleFormatter::class, 'TitleFormatter' );