includes/wikiengine/Render/Xhtml/Heading.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  * Heading 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: Heading.php,v 1.10 2005/09/18 13:39:39 toggg Exp $
       
    13  * @link       http://pear.php.net/package/Text_Wiki
       
    14  */
       
    15 
       
    16 /**
       
    17  * This class renders headings 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_Heading extends Text_Wiki_Render {
       
    27 
       
    28     var $conf = array(
       
    29         'css_h1' => null,
       
    30         'css_h2' => null,
       
    31         'css_h3' => null,
       
    32         'css_h4' => null,
       
    33         'css_h5' => null,
       
    34         'css_h6' => null
       
    35     );
       
    36 
       
    37     function token($options)
       
    38     {
       
    39     	$collapse = null;
       
    40         static $jsOutput = false;
       
    41         // get nice variable names (id, type, level)
       
    42         extract($options);
       
    43 
       
    44         switch($type) {
       
    45         case 'start':
       
    46             $css = $this->formatConf(' class="%s"', "css_h$level");
       
    47             return '
       
    48 <h'.$level.$css.' id="'.$id.'"'.($collapse !== null ? ' onclick="hideTOC(\''.$id.'\');"' : '').'>';
       
    49 
       
    50         case 'end':
       
    51             return '</h'.$level.'>
       
    52 '.($collapse !== null ? '<a id="'.$id.'__link" href="javascript:void();" onclick="hideTOC(\''.$id.'\')">['.($collapse ? '+' : '-').']</a>
       
    53 ' : '');
       
    54         case 'startContent':
       
    55             if ($collapse !== null) {
       
    56                 if ($jsOutput) {
       
    57                     $js = '';
       
    58                 } else {
       
    59                     $js = '
       
    60 <script language="javascript">
       
    61 function hideTOC(id) {
       
    62     div = document.getElementById(id+"__content");
       
    63     link = document.getElementById(id+"__link");
       
    64     if (div.style.display == "none") {
       
    65         div.style.display = "";
       
    66         link.innerHTML = "[-]";
       
    67     } else {
       
    68         div.style.display = "none";
       
    69         link.innerHTML = "[+]";
       
    70     }
       
    71 }
       
    72 </script>
       
    73 ';
       
    74                 }
       
    75             } else {
       
    76                 $js = '';
       
    77             }
       
    78             return  $js.'
       
    79 <div style="'.($collapse === true ? 'display: none; ' : '').'padding: 0px; margin: 0px; border: none;" id="'.$id.'__content">
       
    80 ';
       
    81         case 'endContent':
       
    82             return '
       
    83 </div>
       
    84 ';
       
    85         }
       
    86     }
       
    87 }
       
    88 ?>