MediaWiki REL1_35
|
A codec for MediaWiki page titles. More...
Public Member Functions | |
__construct (Language $language, GenderCache $genderCache, $localInterwikis=[], InterwikiLookup $interwikiLookup=null, NamespaceInfo $nsInfo=null) | |
formatTitle ( $namespace, $text, $fragment='', $interwiki='') | |
getFullText (LinkTarget $title) | |
getNamespaceName ( $namespace, $text) | |
getPrefixedDBkey (LinkTarget $target) | |
getPrefixedText (LinkTarget $title) | |
getText (LinkTarget $title) | |
makeTitleValueSafe ( $namespace, $text, $fragment='', $interwiki='') | |
Given a namespace and title, return a TitleValue if valid, or null if invalid. | |
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 |
string[] | $localInterwikis |
NamespaceInfo | $nsInfo |
A codec for MediaWiki page titles.
Definition at line 39 of file MediaWikiTitleCodec.php.
MediaWikiTitleCodec::__construct | ( | Language | $language, |
GenderCache | $genderCache, | ||
$localInterwikis = [] , |
|||
InterwikiLookup | $interwikiLookup = null , |
||
NamespaceInfo | $nsInfo = null |
||
) |
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 | null | $interwikiLookup | |
NamespaceInfo | null | $nsInfo |
Definition at line 73 of file MediaWikiTitleCodec.php.
References wfDeprecated().
MediaWikiTitleCodec::formatTitle | ( | $namespace, | |
$text, | |||
$fragment = '' , |
|||
$interwiki = '' |
|||
) |
int | bool | $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 TitleFormatter.
Definition at line 131 of file MediaWikiTitleCodec.php.
References getNamespaceName(), and NS_SPECIAL.
Referenced by getFullText(), getPrefixedDBkey(), and getPrefixedText().
MediaWikiTitleCodec::getFullText | ( | LinkTarget | $title | ) |
LinkTarget | $title |
Implements TitleFormatter.
Definition at line 272 of file MediaWikiTitleCodec.php.
References $title, and formatTitle().
MediaWikiTitleCodec::getNamespaceName | ( | $namespace, | |
$text | |||
) |
int | $namespace | |
string | $text |
InvalidArgumentException | If the namespace is invalid |
Implements TitleFormatter.
Definition at line 101 of file MediaWikiTitleCodec.php.
Referenced by formatTitle().
MediaWikiTitleCodec::getPrefixedDBkey | ( | LinkTarget | $target | ) |
LinkTarget | $target |
Implements TitleFormatter.
Definition at line 256 of file MediaWikiTitleCodec.php.
References formatTitle(), MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\Linker\LinkTarget\getInterwiki(), and MediaWiki\Linker\LinkTarget\getNamespace().
MediaWikiTitleCodec::getPrefixedText | ( | LinkTarget | $title | ) |
LinkTarget | $title |
Implements TitleFormatter.
Definition at line 237 of file MediaWikiTitleCodec.php.
References $title, and formatTitle().
MediaWikiTitleCodec::getText | ( | LinkTarget | $title | ) |
LinkTarget | $title |
Implements TitleFormatter.
Definition at line 225 of file MediaWikiTitleCodec.php.
References $title.
|
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 518 of file MediaWikiTitleCodec.php.
Referenced by MediaWiki\Languages\LanguageNameUtils\isValidCode().
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 TitleParser.
Definition at line 194 of file MediaWikiTitleCodec.php.
References splitTitleString().
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 per default (usually NS_MAIN) |
MalformedTitleException |
Implements TitleParser.
Definition at line 167 of file MediaWikiTitleCodec.php.
References splitTitleString().
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 |
Definition at line 302 of file MediaWikiTitleCodec.php.
References $matches, TitleValue\assertValidSpec(), NS_MAIN, NS_SPECIAL, NS_TALK, NS_USER, NS_USER_TALK, and Message\numParam().
Referenced by makeTitleValueSafe(), and parseTitle().
|
protected |
Definition at line 48 of file MediaWikiTitleCodec.php.
|
protected |
Definition at line 58 of file MediaWikiTitleCodec.php.
|
protected |
Definition at line 43 of file MediaWikiTitleCodec.php.
|
protected |
Definition at line 53 of file MediaWikiTitleCodec.php.
|
protected |
Definition at line 63 of file MediaWikiTitleCodec.php.