Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 1
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2/**
3 * A title formatter service for MediaWiki.
4 *
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.
9 *
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.
14 *
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
19 *
20 * @file
21 * @author Daniel Kinzler
22 */
23
24namespace MediaWiki\Title;
25
26use InvalidArgumentException;
27use MediaWiki\Linker\LinkTarget;
28use MediaWiki\Page\PageReference;
29
30/**
31 * A title formatter service for MediaWiki.
32 *
33 * This is designed to encapsulate knowledge about conventions for the title
34 * forms to be used in the database, in urls, in wikitext, etc.
35 *
36 * @see https://www.mediawiki.org/wiki/Requests_for_comment/TitleValue
37 * @since 1.23
38 */
39interface TitleFormatter {
40    /**
41     * Returns the title formatted for display.
42     * Per default, this includes the namespace but not the fragment.
43     *
44     * @note Normalization is applied if $title is not in TitleValue::TITLE_FORM.
45     *
46     * @param int|bool $namespace The namespace ID (or false, if the namespace should be ignored)
47     * @param string $text The page title
48     * @param string $fragment The fragment name (may be empty).
49     * @param string $interwiki The interwiki prefix (may be empty).
50     *
51     * @return string
52     */
53    public function formatTitle( $namespace, $text, $fragment = '', $interwiki = '' );
54
55    /**
56     * Returns the title text formatted for display, without namespace or fragment.
57     *
58     * @param LinkTarget|PageReference $title The title to format
59     *
60     * @return string
61     */
62    public function getText( $title );
63
64    /**
65     * Returns the title formatted for display, including the namespace name.
66     *
67     * @param LinkTarget|PageReference $title The title to format
68     *
69     * @return string
70     */
71    public function getPrefixedText( $title );
72
73    /**
74     * Return the title in prefixed database key form, with interwiki
75     * and namespace.
76     *
77     * @since 1.27
78     *
79     * @param LinkTarget|PageReference $target
80     *
81     * @return string
82     */
83    public function getPrefixedDBkey( $target );
84
85    /**
86     * Returns the title formatted for display, with namespace and fragment.
87     *
88     * @param LinkTarget|PageReference $title The title to format
89     *
90     * @return string
91     */
92    public function getFullText( $title );
93
94    /**
95     * Returns the name of the namespace for the given title.
96     *
97     * @note This must take into account gender sensitive namespace names.
98     * @todo Move this to a separate interface
99     *
100     * @param int $namespace
101     * @param string $text
102     *
103     * @throws InvalidArgumentException
104     * @return string Namespace name with underscores (not spaces), e.g. 'User_talk'
105     */
106    public function getNamespaceName( $namespace, $text );
107}
108
109/** @deprecated class alias since 1.41 */
110class_alias( TitleFormatter::class, 'TitleFormatter' );