MediaWiki REL1_41
MediaWiki\Title\TitleFormatter Interface Reference

A title formatter service for MediaWiki. More...

Inherited by MediaWiki\Title\MediaWikiTitleCodec.

Public Member Functions

 formatTitle ( $namespace, $text, $fragment='', $interwiki='')
 Returns the title formatted for display.
 
 getFullText ( $title)
 Returns the title formatted for display, with namespace and fragment.
 
 getNamespaceName ( $namespace, $text)
 Returns the name of the namespace for the given title.
 
 getPrefixedDBkey ( $target)
 Return the title in prefixed database key form, with interwiki and namespace.
 
 getPrefixedText ( $title)
 Returns the title formatted for display, including the namespace name.
 
 getText ( $title)
 Returns the title text formatted for display, without namespace or fragment.
 

Detailed Description

A title formatter service for MediaWiki.

This is designed to encapsulate knowledge about conventions for the title forms to be used in the database, in urls, in wikitext, etc.

See also
https://www.mediawiki.org/wiki/Requests_for_comment/TitleValue
Since
1.23

Definition at line 39 of file TitleFormatter.php.

Member Function Documentation

◆ formatTitle()

MediaWiki\Title\TitleFormatter::formatTitle ( $namespace,
$text,
$fragment = '',
$interwiki = '' )

Returns the title formatted for display.

Per default, this includes the namespace but not the fragment.

Note
Normalization is applied if $title is not in TitleValue::TITLE_FORM.
Parameters
int | bool$namespaceThe namespace ID (or false, if the namespace should be ignored)
string$textThe page title
string$fragmentThe fragment name (may be empty).
string$interwikiThe interwiki prefix (may be empty).
Returns
string

Implemented in MediaWiki\Title\MediaWikiTitleCodec.

◆ getFullText()

MediaWiki\Title\TitleFormatter::getFullText ( $title)

Returns the title formatted for display, with namespace and fragment.

Parameters
LinkTarget | PageReference$titleThe title to format
Returns
string

Implemented in MediaWiki\Title\MediaWikiTitleCodec.

◆ getNamespaceName()

MediaWiki\Title\TitleFormatter::getNamespaceName ( $namespace,
$text )

Returns the name of the namespace for the given title.

Note
This must take into account gender sensitive namespace names.
Todo
Move this to a separate interface
Parameters
int$namespace
string$text
Exceptions
InvalidArgumentException
Returns
string Namespace name with underscores (not spaces), e.g. 'User_talk'

Implemented in MediaWiki\Title\MediaWikiTitleCodec.

◆ getPrefixedDBkey()

MediaWiki\Title\TitleFormatter::getPrefixedDBkey ( $target)

Return the title in prefixed database key form, with interwiki and namespace.

Since
1.27
Parameters
LinkTarget | PageReference$target
Returns
string

Implemented in MediaWiki\Title\MediaWikiTitleCodec.

◆ getPrefixedText()

MediaWiki\Title\TitleFormatter::getPrefixedText ( $title)

Returns the title formatted for display, including the namespace name.

Parameters
LinkTarget | PageReference$titleThe title to format
Returns
string

Implemented in MediaWiki\Title\MediaWikiTitleCodec.

◆ getText()

MediaWiki\Title\TitleFormatter::getText ( $title)

Returns the title text formatted for display, without namespace or fragment.

Parameters
LinkTarget | PageReference$titleThe title to format
Returns
string

Implemented in MediaWiki\Title\MediaWikiTitleCodec.


The documentation for this interface was generated from the following file: