MediaWiki  REL1_22
MagicWordArray Class Reference

Class for handling an array of magic words. More...

List of all members.

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

Detailed Description

Class for handling an array of magic words.

Definition at line 648 of file MagicWord.php.


Constructor & Destructor Documentation

Parameters:
$namesarray

Definition at line 657 of file MagicWord.php.

References $names.


Member Function Documentation

MagicWordArray::add ( name)

Add a magic word by name.

Parameters:
$namestring

Definition at line 666 of file MagicWord.php.

References $name.

Add a number of magic words by name.

Parameters:
$namesarray

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().

Since:
1.20
Returns:
array

Definition at line 790 of file MagicWord.php.

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.

Returns:
array

Definition at line 757 of file MagicWord.php.

References array(), and getBaseRegex().

Referenced by matchStartAndRemove().

Get a regex for matching variables with parameters.

Returns:
string

Definition at line 748 of file MagicWord.php.

References getRegex().

Get an anchored regex for matching variables with parameters.

Returns:
array

Definition at line 774 of file MagicWord.php.

References array(), and getBaseRegex().

Referenced by matchVariableStartToEnd().

Returns an associative array, ID => param value, for all items that match Removes the matched items from the input string (passed by reference)

Parameters:
$textstring
Returns:
array

Definition at line 876 of file MagicWord.php.

References $matches, $name, $regex, array(), as, getRegex(), list, and parseMatch().

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.

Parameters:
$textstring
Returns:
int|bool False on failure

Definition at line 903 of file MagicWord.php.

References $regex, as, getRegexStart(), list, and parseMatch().

Match some text, without parameter capture Returns the magic word name, or false if there was no capture.

Parameters:
$textstring
Returns:
string|bool False on failure

Definition at line 855 of file MagicWord.php.

References $hash, $wgContLang, getHash(), and global.

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.

Parameters:
$textstring
Returns:
array

Definition at line 834 of file MagicWord.php.

References $regex, array(), as, getVariableStartToEndRegex(), and parseMatch().

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.

Parameters:
$marray
Exceptions:
MWException
Returns:
array

Definition at line 804 of file MagicWord.php.

References $key, $value, array(), and list.

Referenced by matchAndRemove(), matchStartAndRemove(), and matchVariableStartToEnd().


Member Data Documentation

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().


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