MediaWiki  REL1_24
MediaWikiTitleCodec Class Reference

A codec for MediaWiki page titles. More...

Inheritance diagram for MediaWikiTitleCodec:
Collaboration diagram for MediaWikiTitleCodec:

List of all members.

Public Member Functions

 __construct (Language $language, GenderCache $genderCache, $localInterwikis=array())
 formatTitle ($namespace, $text, $fragment= '')
 getFullText (TitleValue $title)
 getNamespaceName ($namespace, $text)
 getPrefixedText (TitleValue $title)
 getText (TitleValue $title)
 parseTitle ($text, $defaultNamespace)
 Parses the given text and constructs a TitleValue.
 splitTitleString ($text, $defaultNamespace=NS_MAIN)
 Normalizes and splits a title string.

Protected Attributes

GenderCache $genderCache
Language $language
string[] $localInterwikis

Detailed Description

A codec for MediaWiki page titles.

Note:
Normalization and validation is applied while parsing, not when formatting. It's possible to construct a TitleValue with an invalid title, and use MediaWikiTitleCodec to generate an (invalid) title string from it. TitleValues should be constructed only via parseTitle() or from a (semi)trusted source, such as the database.
See also:
https://www.mediawiki.org/wiki/Requests_for_comment/TitleValue

Definition at line 35 of file MediaWikiTitleCodec.php.


Constructor & Destructor Documentation

MediaWikiTitleCodec::__construct ( Language language,
GenderCache genderCache,
localInterwikis = array() 
)
Parameters:
Language$languageThe language object to use for localizing namespace names.
GenderCache$genderCacheThe gender cache for generating gendered namespace names
string[]|string$localInterwikis

Definition at line 53 of file MediaWikiTitleCodec.php.


Member Function Documentation

MediaWikiTitleCodec::formatTitle ( namespace,
text,
fragment = '' 
)
See also:
TitleFormatter::formatTitle()
Parameters:
int | bool$namespaceThe namespace ID (or false, if the namespace should be ignored)
string$textThe page title. Should be valid. Only minimal normalization is applied. Underscores will be replaced.
string$fragmentThe fragment name (may be empty).
Exceptions:
InvalidArgumentExceptionIf the namespace is invalid
Returns:
string

Implements TitleFormatter.

Definition at line 100 of file MediaWikiTitleCodec.php.

See also:
TitleFormatter::getText()
Parameters:
TitleValue$title
Returns:
string

Implements TitleFormatter.

Definition at line 176 of file MediaWikiTitleCodec.php.

MediaWikiTitleCodec::getNamespaceName ( namespace,
text 
)
See also:
TitleFormatter::getNamespaceName()
Parameters:
int$namespace
string$text
Exceptions:
InvalidArgumentExceptionIf the namespace is invalid
Returns:
string

Implements TitleFormatter.

Definition at line 70 of file MediaWikiTitleCodec.php.

See also:
TitleFormatter::getText()
Parameters:
TitleValue$title
Returns:
string

Implements TitleFormatter.

Definition at line 165 of file MediaWikiTitleCodec.php.

See also:
TitleFormatter::getText()
Parameters:
TitleValue$title
Returns:
string $title->getText()

Implements TitleFormatter.

Definition at line 154 of file MediaWikiTitleCodec.php.

MediaWikiTitleCodec::parseTitle ( text,
defaultNamespace 
)

Parses the given text and constructs a TitleValue.

Normalization is applied according to the rules appropriate for the form specified by $form.

Parameters:
string$textThe text to parse
int$defaultNamespaceNamespace to assume per default (usually NS_MAIN)
Exceptions:
MalformedTitleException
Returns:
TitleValue

Implements TitleParser.

Definition at line 128 of file MediaWikiTitleCodec.php.

MediaWikiTitleCodec::splitTitleString ( text,
defaultNamespace = NS_MAIN 
)

Normalizes and splits a title string.

This function removes illegal characters, splits off the interwiki and namespace prefixes, sets the other forms, and canonicalizes everything.

Todo:
this method is only exposed as a temporary measure to ease refactoring. It was copied with minimal changes from Title::secureAndSplit().
Todo:
This method should be split up and an appropriate interface defined for use by the Title class.
Parameters:
string$text
int$defaultNamespace
Exceptions:
MalformedTitleExceptionIf $text is not a valid title string.
Returns:
array A mapp with the fields 'interwiki', 'fragment', 'namespace', 'user_case_dbkey', and 'dbkey'.

Definition at line 200 of file MediaWikiTitleCodec.php.


Member Data Documentation

GenderCache MediaWikiTitleCodec::$genderCache [protected]

Definition at line 42 of file MediaWikiTitleCodec.php.

Language MediaWikiTitleCodec::$language [protected]

Definition at line 38 of file MediaWikiTitleCodec.php.

string [] MediaWikiTitleCodec::$localInterwikis [protected]

Definition at line 46 of file MediaWikiTitleCodec.php.


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