MediaWiki master
|
A codec for MediaWiki page titles. More...
Inherits MediaWiki\Title\TitleFormatter, and MediaWiki\Title\TitleParser.
Public Member Functions | |
__construct (Language $language, GenderCache $genderCache, $localInterwikis, InterwikiLookup $interwikiLookup, NamespaceInfo $nsInfo) | |
formatTitle ( $namespace, $text, $fragment='', $interwiki='') | |
getFullText ( $title) | |
getNamespaceName ( $namespace, $text) | |
getPrefixedDBkey ( $target) | |
getPrefixedText ( $title) | |
getText ( $title) | |
makeTitleValueSafe ( $namespace, $text, $fragment='', $interwiki='') | |
Given a namespace and title, return a TitleValue if valid, or null if invalid. | |
overrideCreateMalformedTitleExceptionCallback (callable $callback) | |
parseTitle ( $text, $defaultNamespace=NS_MAIN) | |
Parses the given text and constructs a TitleValue. | |
splitTitleString ( $text, $defaultNamespace=NS_MAIN) | |
Validates, normalizes and splits a title string. | |
Static Public Member Functions | |
static | getTitleInvalidRegex () |
Returns a simple regex that will match on characters and sequences invalid in titles. | |
Protected Attributes | |
GenderCache | $genderCache |
InterwikiLookup | $interwikiLookup |
Language | $language |
array string[] | $localInterwikis |
NamespaceInfo | $nsInfo |
A codec for MediaWiki page titles.
Definition at line 48 of file MediaWikiTitleCodec.php.
MediaWiki\Title\MediaWikiTitleCodec::__construct | ( | Language | $language, |
GenderCache | $genderCache, | ||
$localInterwikis, | |||
InterwikiLookup | $interwikiLookup, | ||
NamespaceInfo | $nsInfo ) |
Language | $language | The language object to use for localizing namespace names, capitalization, etc. |
GenderCache | $genderCache | The gender cache for generating gendered namespace names |
string[] | string | $localInterwikis | |
InterwikiLookup | $interwikiLookup | |
NamespaceInfo | $nsInfo |
Definition at line 73 of file MediaWikiTitleCodec.php.
References MediaWiki\Title\MediaWikiTitleCodec\$genderCache, MediaWiki\Title\MediaWikiTitleCodec\$interwikiLookup, MediaWiki\Title\MediaWikiTitleCodec\$language, MediaWiki\Title\MediaWikiTitleCodec\$localInterwikis, and MediaWiki\Title\MediaWikiTitleCodec\$nsInfo.
MediaWiki\Title\MediaWikiTitleCodec::formatTitle | ( | $namespace, | |
$text, | |||
$fragment = '', | |||
$interwiki = '' ) |
int | false | $namespace | The namespace ID (or false, if the namespace should be ignored) |
string | $text | The page title. Should be valid. Only minimal normalization is applied. Underscores will be replaced. |
string | $fragment | The fragment name (may be empty). |
string | $interwiki | The interwiki name (may be empty). |
InvalidArgumentException | If the namespace is invalid |
Implements MediaWiki\Title\TitleFormatter.
Definition at line 149 of file MediaWikiTitleCodec.php.
References MediaWiki\Title\MediaWikiTitleCodec\getNamespaceName(), and NS_SPECIAL.
Referenced by MediaWiki\Title\MediaWikiTitleCodec\getFullText(), MediaWiki\Title\MediaWikiTitleCodec\getPrefixedDBkey(), and MediaWiki\Title\MediaWikiTitleCodec\getPrefixedText().
MediaWiki\Title\MediaWikiTitleCodec::getFullText | ( | $title | ) |
LinkTarget | PageReference | $title |
Implements MediaWiki\Title\TitleFormatter.
Definition at line 315 of file MediaWikiTitleCodec.php.
References MediaWiki\Title\MediaWikiTitleCodec\formatTitle().
MediaWiki\Title\MediaWikiTitleCodec::getNamespaceName | ( | $namespace, | |
$text ) |
int | $namespace | |
string | $text |
InvalidArgumentException | If the namespace is invalid |
Implements MediaWiki\Title\TitleFormatter.
Definition at line 119 of file MediaWikiTitleCodec.php.
Referenced by MediaWiki\Title\MediaWikiTitleCodec\formatTitle().
MediaWiki\Title\MediaWikiTitleCodec::getPrefixedDBkey | ( | $target | ) |
LinkTarget | PageReference | $target |
Implements MediaWiki\Title\TitleFormatter.
Definition at line 289 of file MediaWikiTitleCodec.php.
References MediaWiki\Title\MediaWikiTitleCodec\formatTitle().
MediaWiki\Title\MediaWikiTitleCodec::getPrefixedText | ( | $title | ) |
LinkTarget | PageReference | $title |
Implements MediaWiki\Title\TitleFormatter.
Definition at line 261 of file MediaWikiTitleCodec.php.
References MediaWiki\Title\MediaWikiTitleCodec\formatTitle().
MediaWiki\Title\MediaWikiTitleCodec::getText | ( | $title | ) |
LinkTarget | PageReference | $title |
Implements MediaWiki\Title\TitleFormatter.
Definition at line 243 of file MediaWikiTitleCodec.php.
|
static |
Returns a simple regex that will match on characters and sequences invalid in titles.
Note that this doesn't pick up many things that could be wrong with titles, but that replacing this regex with something valid will make many titles valid. Previously Title::getTitleInvalidRegex()
Definition at line 596 of file MediaWikiTitleCodec.php.
References MediaWiki\Title\Title\legalChars().
Referenced by MediaWiki\Languages\LanguageNameUtils\isValidCode(), and MediaWiki\Title\MediaWikiTitleCodec\splitTitleString().
MediaWiki\Title\MediaWikiTitleCodec::makeTitleValueSafe | ( | $namespace, | |
$text, | |||
$fragment = '', | |||
$interwiki = '' ) |
Given a namespace and title, return a TitleValue if valid, or null if invalid.
int | $namespace | |
string | $text | |
string | $fragment | |
string | $interwiki |
Implements MediaWiki\Title\TitleParser.
Definition at line 212 of file MediaWikiTitleCodec.php.
References MediaWiki\Title\MediaWikiTitleCodec\splitTitleString().
MediaWiki\Title\MediaWikiTitleCodec::overrideCreateMalformedTitleExceptionCallback | ( | callable | $callback | ) |
callable | $callback |
Definition at line 101 of file MediaWikiTitleCodec.php.
MediaWiki\Title\MediaWikiTitleCodec::parseTitle | ( | $text, | |
$defaultNamespace = NS_MAIN ) |
Parses the given text and constructs a TitleValue.
string | $text | The text to parse |
int | $defaultNamespace | Namespace to assume by default (usually NS_MAIN) |
MalformedTitleException |
Implements MediaWiki\Title\TitleParser.
Definition at line 185 of file MediaWikiTitleCodec.php.
References MediaWiki\Title\MediaWikiTitleCodec\splitTitleString().
MediaWiki\Title\MediaWikiTitleCodec::splitTitleString | ( | $text, | |
$defaultNamespace = NS_MAIN ) |
Validates, normalizes and splits a title string.
This is the "source of truth" for title validity.
This function removes illegal characters, splits off the interwiki and namespace prefixes, sets the other forms, and canonicalizes everything.
string | $text | |
int | $defaultNamespace |
MalformedTitleException | If $text is not a valid title string. |
Definition at line 355 of file MediaWikiTitleCodec.php.
References $matches, MediaWiki\Title\TitleValue\assertValidSpec(), MediaWiki\Title\MediaWikiTitleCodec\getTitleInvalidRegex(), MediaWiki\Title\Title\newMainPage(), NS_MAIN, NS_SPECIAL, NS_TALK, NS_USER, NS_USER_TALK, and MediaWiki\Message\Message\numParam().
Referenced by MediaWiki\Title\MediaWikiTitleCodec\makeTitleValueSafe(), and MediaWiki\Title\MediaWikiTitleCodec\parseTitle().
|
protected |
Definition at line 50 of file MediaWikiTitleCodec.php.
Referenced by MediaWiki\Title\MediaWikiTitleCodec\__construct().
|
protected |
Definition at line 53 of file MediaWikiTitleCodec.php.
Referenced by MediaWiki\Title\MediaWikiTitleCodec\__construct().
|
protected |
Definition at line 49 of file MediaWikiTitleCodec.php.
Referenced by MediaWiki\Title\MediaWikiTitleCodec\__construct().
|
protected |
Definition at line 52 of file MediaWikiTitleCodec.php.
Referenced by MediaWiki\Title\MediaWikiTitleCodec\__construct().
|
protected |
Definition at line 54 of file MediaWikiTitleCodec.php.
Referenced by MediaWiki\Title\MediaWikiTitleCodec\__construct().