includes/wikiengine/Parse/Default/Colortext.php
changeset 1027 98c052fc3337
parent 1026 f0431eb8161e
child 1028 dde4416dea00
equal deleted inserted replaced
1026:f0431eb8161e 1027:98c052fc3337
     1 <?php
       
     2 
       
     3 /**
       
     4 * 
       
     5 * Parses for colorized text.
       
     6 * 
       
     7 * @category Text
       
     8 * 
       
     9 * @package Text_Wiki
       
    10 * 
       
    11 * @author Paul M. Jones <pmjones@php.net>
       
    12 * 
       
    13 * @license LGPL
       
    14 * 
       
    15 * @version $Id: Colortext.php,v 1.3 2005/02/23 17:38:29 pmjones Exp $
       
    16 * 
       
    17 */
       
    18 
       
    19 /**
       
    20 * 
       
    21 * Parses for colorized text.
       
    22 * 
       
    23 * @category Text
       
    24 * 
       
    25 * @package Text_Wiki
       
    26 * 
       
    27 * @author Paul M. Jones <pmjones@php.net>
       
    28 * 
       
    29 */
       
    30 
       
    31 class Text_Wiki_Parse_Colortext extends Text_Wiki_Parse {
       
    32     
       
    33     /**
       
    34     * 
       
    35     * The regular expression used to parse the source text and find
       
    36     * matches conforming to this rule.  Used by the parse() method.
       
    37     * 
       
    38     * @access public
       
    39     * 
       
    40     * @var string
       
    41     * 
       
    42     * @see parse()
       
    43     * 
       
    44     */
       
    45     
       
    46     var $regex = "/\#\#(.+?)\|(.+?)\#\#/";
       
    47     
       
    48     
       
    49     /**
       
    50     * 
       
    51     * Generates a replacement for the matched text.  Token options are:
       
    52     * 
       
    53     * 'type' => ['start'|'end'] The starting or ending point of the
       
    54     * emphasized text.  The text itself is left in the source.
       
    55     * 
       
    56     * 'color' => the color indicator
       
    57     * 
       
    58     * @access public
       
    59     *
       
    60     * @param array &$matches The array of matches from parse().
       
    61     *
       
    62     * @return string A pair of delimited tokens to be used as a
       
    63     * placeholder in the source text surrounding the text to be
       
    64     * emphasized.
       
    65     *
       
    66     */
       
    67     
       
    68     function process(&$matches)
       
    69     {
       
    70         $start = $this->wiki->addToken(
       
    71             $this->rule, 
       
    72             array(
       
    73                 'type' => 'start',
       
    74                 'color' => $matches[1]
       
    75             )
       
    76         );
       
    77         
       
    78         $end = $this->wiki->addToken(
       
    79             $this->rule, 
       
    80             array(
       
    81                 'type' => 'end',
       
    82                 'color' => $matches[1]
       
    83             )
       
    84         );
       
    85         
       
    86         return $start . $matches[2] . $end;
       
    87     }
       
    88 }
       
    89 ?>