includes/wikiengine/Render/Xhtml/Phplookup.php
changeset 1 fe660c52c48f
equal deleted inserted replaced
0:902822492a68 1:fe660c52c48f
       
     1 <?php
       
     2 // vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
       
     3 /**
       
     4  * Phplookup 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: Phplookup.php,v 1.11 2006/02/10 23:07:03 toggg Exp $
       
    13  * @link       http://pear.php.net/package/Text_Wiki
       
    14  */
       
    15 
       
    16 /**
       
    17  * This class renders a link to php functions description 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_Phplookup extends Text_Wiki_Render {
       
    27 
       
    28     var $conf = array(
       
    29         'target' => '_blank',
       
    30         'css' => null
       
    31     );
       
    32 
       
    33 
       
    34     /**
       
    35     *
       
    36     * Renders a token into text matching the requested format.
       
    37     *
       
    38     * @access public
       
    39     *
       
    40     * @param array $options The "options" portion of the token (second
       
    41     * element).
       
    42     *
       
    43     * @return string The text rendered from the token options.
       
    44     *
       
    45     */
       
    46 
       
    47     function token($options)
       
    48     {
       
    49         $text = trim($options['text']);
       
    50         $css = $this->formatConf(' class="%s"', 'css');
       
    51 
       
    52         // start the html
       
    53         $output = "<a$css";
       
    54 
       
    55         // are we targeting another window?
       
    56         $target = $this->getConf('target', '');
       
    57         if ($target) {
       
    58             // use a "popup" window.  this is XHTML compliant, suggested by
       
    59             // Aaron Kalin.  uses the $target as the new window name.
       
    60             $target = $this->textEncode($target);
       
    61             $output .= " onclick=\"window.open(this.href, '$target');";
       
    62             $output .= " return false;\"";
       
    63         }
       
    64 
       
    65         // take off the final parens for functions
       
    66         if (substr($text, -2) == '()') {
       
    67             $q = substr($text, 0, -2);
       
    68         } else {
       
    69             $q = $text;
       
    70         }
       
    71 
       
    72         // toggg 2006/02/05 page name must be url encoded (e.g. may contain spaces)
       
    73         $q = $this->urlEncode($q);
       
    74         $text = $this->textEncode($text);
       
    75 
       
    76         // finish and return
       
    77         $output .= " href=\"http://php.net/$q\">$text</a>";
       
    78         return $output;
       
    79     }
       
    80 }
       
    81 ?>