MediaWiki  REL1_20
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 643 of file MagicWord.php.


Constructor & Destructor Documentation

MagicWordArray::__construct ( names = array())
Parameters:
$namesarray

Definition at line 652 of file MagicWord.php.

References $names.


Member Function Documentation

MagicWordArray::add ( name)

Add a magic word by name.

Parameters:
$namestring

Definition at line 661 of file MagicWord.php.

Add a number of magic words by name.

Parameters:
$namesarray

Definition at line 671 of file MagicWord.php.

References $names.

Get the base regex.

Definition at line 700 of file MagicWord.php.

References MagicWord\get().

Referenced by getRegex(), getRegexStart(), and getVariableStartToEndRegex().

Get a 2-d hashtable for this array.

Definition at line 679 of file MagicWord.php.

References $wgContLang, and MagicWord\get().

Referenced by matchStartToEnd().

Since:
1.20
Returns:
array

Definition at line 783 of file MagicWord.php.

Get an unanchored regex that does not match parameters.

Definition at line 722 of file MagicWord.php.

References 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 750 of file MagicWord.php.

References getBaseRegex().

Referenced by matchStartAndRemove().

Get a regex for matching variables with parameters.

Returns:
string

Definition at line 741 of file MagicWord.php.

References getRegex().

Get an anchored regex for matching variables with parameters.

Returns:
array

Definition at line 767 of file MagicWord.php.

References 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 869 of file MagicWord.php.

References $matches, $regex, getRegex(), 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 896 of file MagicWord.php.

References $regex, getRegexStart(), 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 848 of file MagicWord.php.

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

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 827 of file MagicWord.php.

References $regex, 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 797 of file MagicWord.php.

References $value.

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


Member Data Documentation

MagicWordArray::$baseRegex

Definition at line 646 of file MagicWord.php.

MagicWordArray::$hash

Definition at line 645 of file MagicWord.php.

Referenced by matchStartToEnd().

MagicWordArray::$matches

Definition at line 647 of file MagicWord.php.

Referenced by matchAndRemove().

MagicWordArray::$names = array()

Definition at line 644 of file MagicWord.php.

Referenced by __construct(), and addArray().

MagicWordArray::$regex

Definition at line 646 of file MagicWord.php.

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


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