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

Source for file Table.php

Documentation is available at Table.php

  1. <?php
  2.  
  3. class Text_Wiki_Render_Xhtml_Table extends Text_Wiki_Render {
  4.     
  5.     var $conf = array(
  6.         'css_table' => null,
  7.         'css_tr' => null,
  8.         'css_th' => null,
  9.         'css_td' => null
  10.     );
  11.     
  12.     
  13.     /**
  14.     * 
  15.     * Renders a token into text matching the requested format.
  16.     * 
  17.     * @access public
  18.     * 
  19.     * @param array $options The "options" portion of the token (second
  20.     *  element).
  21.     * 
  22.     * @return string The text rendered from the token options.
  23.     * 
  24.     */
  25.     
  26.     function token($options)
  27.     {
  28.         // make nice variable names (type, attr, span)
  29.         extract($options);
  30.         
  31.         $pad '    ';
  32.         
  33.         switch ($type{
  34.         
  35.         case 'table_start':
  36.             
  37.             // pick the CSS class
  38.             $css $this->getConf('css_table''');
  39.             if ($css{
  40.                 $css = " class=\"$css\"";
  41.             }
  42.             
  43.             // done!
  44.             return "\n\n<table$css>\n";
  45.             break;
  46.         
  47.         case 'table_end':
  48.             return "</table>\n\n";
  49.             break;
  50.         
  51.         case 'row_start':
  52.             $html = "$pad<tr";
  53.             
  54.             // pick the CSS class
  55.             $css $this->getConf('css_tr''');
  56.             if ($css{
  57.                 $css = " class=\"$css\"";
  58.             }
  59.             
  60.             // done
  61.             return "$pad<tr$css>\n";
  62.             break;
  63.         
  64.         case 'row_end':
  65.             return "$pad</tr>\n";
  66.             break;
  67.         
  68.         case 'cell_start':
  69.             
  70.             // base html
  71.             $html $pad $pad;
  72.             
  73.             // is this a TH or TD cell?
  74.             if ($attr == 'header'{
  75.                 
  76.                 // start a header cell
  77.                 $html .= '<th';
  78.                 
  79.                 // add CSS class
  80.                 $css $this->getConf('css_th''');
  81.                 if ($css{
  82.                     $html .= " class=\"$css\"";
  83.                 }
  84.                 
  85.             else {
  86.             
  87.                 // start a normal cell
  88.                 $html .= '<td';
  89.                 
  90.                 // add the CSS class
  91.                 $css $this->getConf('css_td''');
  92.                 if ($css{
  93.                     $html .= " class=\"$css\"";
  94.                 }
  95.             }
  96.             
  97.             // add the column span
  98.             if ($span > 1{
  99.                 $html .= " colspan=\"$span\"";
  100.             }
  101.             
  102.             // add alignment
  103.             if ($attr != 'header' && $attr != ''{
  104.                 $html .= " style=\"text-align: $attr;\"";
  105.             }
  106.             
  107.             // done!
  108.             $html .= '>';
  109.             return $html;
  110.             break;
  111.         
  112.         case 'cell_end':
  113.             if ($attr == 'header'{
  114.                 return "</th>\n";
  115.             else {
  116.                 return "</td>\n";
  117.             }
  118.             break;
  119.         
  120.         default:
  121.             return '';
  122.         
  123.         }
  124.     }
  125. }
  126. ?>

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