Text_Wiki
[ class tree: Text_Wiki ] [ index: Text_Wiki ] [ all elements ]

Source for file List.php

Documentation is available at List.php

  1. <?php
  2.  
  3.  
  4. class Text_Wiki_Render_Xhtml_List extends Text_Wiki_Render {
  5.     
  6.     var $conf = array(
  7.         'css_ol' => null,
  8.         'css_ol_li' => null,
  9.         'css_ul' => null,
  10.         'css_ul_li' => null
  11.     );
  12.     
  13.     /**
  14.     * 
  15.     * Renders a token into text matching the requested format.
  16.     * 
  17.     * This rendering method is syntactically and semantically compliant
  18.     * with XHTML 1.1 in that sub-lists are part of the previous list item.
  19.     * 
  20.     * @access public
  21.     * 
  22.     * @param array $options The "options" portion of the token (second
  23.     *  element).
  24.     * 
  25.     * @return string The text rendered from the token options.
  26.     * 
  27.     */
  28.     
  29.     function token($options)
  30.     {
  31.         // make nice variables (type, level, count)
  32.         extract($options);
  33.         
  34.         // set up indenting so that the results look nice; we do this
  35.         // in two steps to avoid str_pad mathematics.  ;-)
  36.         $pad str_pad(''$level"\t");
  37.         $pad str_replace("\t"'    '$pad);
  38.                 
  39.         switch ($type{
  40.         
  41.         case 'bullet_list_start':
  42.         
  43.             // pick the CSS class
  44.             $css $this->getConf('css_ul''');
  45.             if ($css{
  46.                 $css = " class=\"$css\"";
  47.             }
  48.             
  49.             // build the base HTML
  50.             $html = "<ul$css>";
  51.             
  52.             // if this is the opening block for the list,
  53.             // put an extra newline in front of it so the
  54.             // output looks nice.
  55.             if ($level == 0{
  56.                 $html = "\n$html";
  57.             }
  58.             
  59.             // done!
  60.             return $html;
  61.             break;
  62.         
  63.         case 'bullet_list_end':
  64.         
  65.             // build the base HTML
  66.             $html = "</li>\n$pad</ul>";
  67.             
  68.             // if this is the closing block for the list,
  69.             // put extra newlines after it so the output
  70.             // looks nice.
  71.             if ($level == 0{
  72.                 $html .= "\n\n";
  73.             }
  74.             
  75.             // done!
  76.             return $html;
  77.             break;
  78.         
  79.         case 'number_list_start':
  80.         
  81.             // pick the CSS class
  82.             $css $this->getConf('css_ol''');
  83.             if ($css{
  84.                 $css = " class=\"$css\"";
  85.             }
  86.             
  87.             // build the base HTML
  88.             $html = "<ol$css>";
  89.             
  90.             // if this is the opening block for the list,
  91.             // put an extra newline in front of it so the
  92.             // output looks nice.
  93.             if ($level == 0{
  94.                 $html = "\n$html";
  95.             }
  96.             
  97.             // done!
  98.             return $html;
  99.             break;
  100.         
  101.         case 'number_list_end':
  102.         
  103.             // build the base HTML
  104.             $html = "</li>\n$pad</ol>";
  105.             
  106.             // if this is the closing block for the list,
  107.             // put extra newlines after it so the output
  108.             // looks nice.
  109.             if ($level == 0{
  110.                 $html .= "\n\n";
  111.             }
  112.             
  113.             // done!
  114.             return $html;
  115.             break;
  116.         
  117.         case 'bullet_item_start':
  118.         case 'number_item_start':
  119.         
  120.             // pick the proper CSS class
  121.             if ($type == 'bullet_item_start'{
  122.                 $css $this->getConf('css_ul_li''');
  123.             else {
  124.                 $css $this->getConf('css_ol_li''');
  125.             }
  126.             
  127.             if ($css{
  128.                 $css = " class=\"$css\"";
  129.             }
  130.             
  131.             // build the base HTML
  132.             $html = "\n$pad<li$css>";
  133.             
  134.             // for the very first item in the list, do nothing.
  135.             // but for additional items, be sure to close the
  136.             // previous item.
  137.             if ($count > 0{
  138.                 $html = "</li>$html";
  139.             }
  140.             
  141.             // done!
  142.             return $html;
  143.             break;
  144.         
  145.         case 'bullet_item_end':
  146.         case 'number_item_end':
  147.         default:
  148.             // ignore item endings and all other types.
  149.             // item endings are taken care of by the other types
  150.             // depending on their place in the list.
  151.             return '';
  152.             break;
  153.         }
  154.     }
  155. }
  156. ?>

Documentation generated on Mon, 11 Mar 2019 13:51:28 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.