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

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