MediaWiki
REL1_22
|
Class for handling an array of magic words. More...
Public Member Functions | |
__construct ($names=array()) | |
add ($name) | |
Add a magic word by name. | |
addArray ($names) | |
Add a number of magic words by name. | |
getBaseRegex () | |
Get the base regex. | |
getHash () | |
Get a 2-d hashtable for this array. | |
getNames () | |
getRegex () | |
Get an unanchored regex that does not match parameters. | |
getRegexStart () | |
Get a regex anchored to the start of the string that does not match parameters. | |
getVariableRegex () | |
Get a regex for matching variables with parameters. | |
getVariableStartToEndRegex () | |
Get an anchored regex for matching variables with parameters. | |
matchAndRemove (&$text) | |
Returns an associative array, ID => param value, for all items that match Removes the matched items from the input string (passed by reference) | |
matchStartAndRemove (&$text) | |
Return the ID of the magic word at the start of $text, and remove the prefix from $text. | |
matchStartToEnd ($text) | |
Match some text, without parameter capture Returns the magic word name, or false if there was no capture. | |
matchVariableStartToEnd ($text) | |
Match some text, with parameter capture Returns an array with the magic word name in the first element and the parameter in the second element. | |
parseMatch ($m) | |
Parse a match array from preg_match Returns array(magic word ID, parameter value) If there is no parameter value, that element will be false. | |
Public Attributes | |
$baseRegex | |
$hash | |
$matches | |
$names = array() | |
$regex |
Class for handling an array of magic words.
Definition at line 648 of file MagicWord.php.
MagicWordArray::__construct | ( | $ | names = array() | ) |
MagicWordArray::add | ( | $ | name | ) |
Add a magic word by name.
$name | string |
Definition at line 666 of file MagicWord.php.
References $name.
MagicWordArray::addArray | ( | $ | names | ) |
Add a number of magic words by name.
$names | array |
Definition at line 676 of file MagicWord.php.
References $names.
Get the base regex.
Definition at line 705 of file MagicWord.php.
References $name, array(), as, and MagicWord\get().
Referenced by getRegex(), getRegexStart(), and getVariableStartToEndRegex().
Get a 2-d hashtable for this array.
Definition at line 684 of file MagicWord.php.
References $name, $wgContLang, array(), as, MagicWord\get(), and global.
Referenced by matchStartToEnd().
Get an unanchored regex that does not match parameters.
Definition at line 729 of file MagicWord.php.
References array(), and getBaseRegex().
Referenced by getVariableRegex(), and matchAndRemove().
Get a regex anchored to the start of the string that does not match parameters.
Definition at line 757 of file MagicWord.php.
References array(), and getBaseRegex().
Referenced by matchStartAndRemove().
Get a regex for matching variables with parameters.
Definition at line 748 of file MagicWord.php.
References getRegex().
Get an anchored regex for matching variables with parameters.
Definition at line 774 of file MagicWord.php.
References array(), and getBaseRegex().
Referenced by matchVariableStartToEnd().
MagicWordArray::matchAndRemove | ( | &$ | text | ) |
Returns an associative array, ID => param value, for all items that match Removes the matched items from the input string (passed by reference)
$text | string |
Definition at line 876 of file MagicWord.php.
References $matches, $name, $regex, array(), as, getRegex(), list, and parseMatch().
MagicWordArray::matchStartAndRemove | ( | &$ | text | ) |
Return the ID of the magic word at the start of $text, and remove the prefix from $text.
Return false if no match found and $text is not modified. Does not match parameters.
$text | string |
Definition at line 903 of file MagicWord.php.
References $regex, as, getRegexStart(), list, and parseMatch().
MagicWordArray::matchStartToEnd | ( | $ | text | ) |
Match some text, without parameter capture Returns the magic word name, or false if there was no capture.
$text | string |
Definition at line 855 of file MagicWord.php.
References $hash, $wgContLang, getHash(), and global.
MagicWordArray::matchVariableStartToEnd | ( | $ | text | ) |
Match some text, with parameter capture Returns an array with the magic word name in the first element and the parameter in the second element.
Both elements are false if there was no match.
$text | string |
Definition at line 834 of file MagicWord.php.
References $regex, array(), as, getVariableStartToEndRegex(), and parseMatch().
MagicWordArray::parseMatch | ( | $ | m | ) |
Parse a match array from preg_match Returns array(magic word ID, parameter value) If there is no parameter value, that element will be false.
$m | array |
MWException |
Definition at line 804 of file MagicWord.php.
References $key, $value, array(), and list.
Referenced by matchAndRemove(), matchStartAndRemove(), and matchVariableStartToEnd().
MagicWordArray::$baseRegex |
Definition at line 651 of file MagicWord.php.
MagicWordArray::$hash |
Definition at line 650 of file MagicWord.php.
Referenced by matchStartToEnd().
MagicWordArray::$matches |
Definition at line 652 of file MagicWord.php.
Referenced by matchAndRemove().
MagicWordArray::$names = array() |
Definition at line 649 of file MagicWord.php.
Referenced by __construct(), and addArray().
MagicWordArray::$regex |
Definition at line 651 of file MagicWord.php.
Referenced by matchAndRemove(), matchStartAndRemove(), and matchVariableStartToEnd().