MediaWiki master
|
A title parser service for MediaWiki. More...
Public Member Functions | |
__construct (Language $language, InterwikiLookup $interwikiLookup, NamespaceInfo $nsInfo, $localInterwikis) | |
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. | |
A title parser 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.
Definition at line 43 of file TitleParser.php.
MediaWiki\Title\TitleParser::__construct | ( | Language | $language, |
InterwikiLookup | $interwikiLookup, | ||
NamespaceInfo | $nsInfo, | ||
$localInterwikis ) |
Language | $language | The language object to use for localizing namespace names, capitalization, etc. |
InterwikiLookup | $interwikiLookup | |
NamespaceInfo | $nsInfo | |
string[] | string | $localInterwikis |
Definition at line 67 of file TitleParser.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.
Definition at line 423 of file TitleParser.php.
References MediaWiki\Title\Title\legalChars().
Referenced by MediaWiki\Title\MediaWikiTitleCodec\getTitleInvalidRegex(), and MediaWiki\Title\TitleParser\splitTitleString().
MediaWiki\Title\TitleParser::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 |
Definition at line 138 of file TitleParser.php.
References MediaWiki\Title\TitleParser\splitTitleString().
MediaWiki\Title\TitleParser::overrideCreateMalformedTitleExceptionCallback | ( | callable | $callback | ) |
MediaWiki\Title\TitleParser::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 |
Definition at line 111 of file TitleParser.php.
References MediaWiki\Title\TitleParser\splitTitleString().
MediaWiki\Title\TitleParser::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 183 of file TitleParser.php.
References $matches, MediaWiki\Title\TitleValue\assertValidSpec(), MediaWiki\Title\TitleParser\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\TitleParser\makeTitleValueSafe(), and MediaWiki\Title\TitleParser\parseTitle().