includes/wikiengine/Render/Xhtml/Colortext.php
changeset 1027 98c052fc3337
parent 1026 f0431eb8161e
child 1028 dde4416dea00
equal deleted inserted replaced
1026:f0431eb8161e 1027:98c052fc3337
     1 <?php
       
     2 // vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
       
     3 /**
       
     4  * Colortext rule end renderer for Xhtml
       
     5  *
       
     6  * PHP versions 4 and 5
       
     7  *
       
     8  * @category   Text
       
     9  * @package    Text_Wiki
       
    10  * @author     Paul M. Jones <pmjones@php.net>
       
    11  * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
       
    12  * @version    CVS: $Id: Colortext.php,v 1.6 2005/07/30 08:03:28 toggg Exp $
       
    13  * @link       http://pear.php.net/package/Text_Wiki
       
    14  */
       
    15 
       
    16 /**
       
    17  * This class renders colored text in XHTML.
       
    18  *
       
    19  * @category   Text
       
    20  * @package    Text_Wiki
       
    21  * @author     Paul M. Jones <pmjones@php.net>
       
    22  * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
       
    23  * @version    Release: @package_version@
       
    24  * @link       http://pear.php.net/package/Text_Wiki
       
    25  */
       
    26 class Text_Wiki_Render_Xhtml_Colortext extends Text_Wiki_Render {
       
    27 
       
    28     var $colors = array(
       
    29         'aqua',
       
    30         'black',
       
    31         'blue',
       
    32         'fuchsia',
       
    33         'gray',
       
    34         'green',
       
    35         'lime',
       
    36         'maroon',
       
    37         'navy',
       
    38         'olive',
       
    39         'purple',
       
    40         'red',
       
    41         'silver',
       
    42         'teal',
       
    43         'white',
       
    44         'yellow'
       
    45     );
       
    46 
       
    47 
       
    48     /**
       
    49     *
       
    50     * Renders a token into text matching the requested format.
       
    51     *
       
    52     * @access public
       
    53     *
       
    54     * @param array $options The "options" portion of the token (second
       
    55     * element).
       
    56     *
       
    57     * @return string The text rendered from the token options.
       
    58     *
       
    59     */
       
    60 
       
    61     function token($options)
       
    62     {
       
    63         $type = $options['type'];
       
    64         $color = $options['color'];
       
    65 
       
    66         if (! in_array($color, $this->colors) && $color{0} != '#') {
       
    67             $color = '#' . $color;
       
    68         }
       
    69 
       
    70         if ($type == 'start') {
       
    71             return "<span style=\"color: $color;\">";
       
    72         }
       
    73 
       
    74         if ($options['type'] == 'end') {
       
    75             return '</span>';
       
    76         }
       
    77     }
       
    78 }
       
    79 ?>