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.     var $cell_id    = 0;
  4.     var $cell_count = 0;
  5.     var $is_spanning = false;
  6.     
  7.     var $conf = array(
  8.                       'css_table' => null,
  9.                       'css_tr' => null,
  10.                       'css_th' => null,
  11.                       'css_td' => null
  12.                       );
  13.  
  14.     /**
  15.      *
  16.      * Renders a token into text matching the requested format.
  17.      *
  18.      * @access public
  19.      *
  20.      * @param array $options The "options" portion of the token (second
  21.      *  element).
  22.      *
  23.      * @return string The text rendered from the token options.
  24.      *
  25.      */
  26.  
  27.     function token($options)
  28.     {
  29.         // make nice variable names (type, attr, span)
  30.         extract($options);
  31.  
  32.         switch ($type)
  33.             {
  34.             case 'table_start':
  35.                 $this->cell_count = $cols;
  36.                 
  37.                 $tbl_start '\begin{tabular}{|';
  38.                 for ($a=0; $a $this->cell_count$a++{
  39.                     $tbl_start .= 'l|';
  40.                 }
  41.                 $tbl_start .= "}\n";
  42.                 
  43.                 return $tbl_start;
  44.  
  45.             case 'table_end':
  46.                 return "\\hline\n\\end{tabular}\n";
  47.  
  48.             case 'row_start':
  49.                 $this->is_spanning = false;
  50.                 $this->cell_id = 0;
  51.                 return "\\hline\n";
  52.  
  53.             case 'row_end':
  54.                 return "\\\\\n";
  55.  
  56.             case 'cell_start':
  57.                 if ($span > 1{
  58.                     $col_spec '';
  59.                     if ($this->cell_id == 0{
  60.                         $col_spec '|';
  61.                     }
  62.                     $col_spec .= 'l|';
  63.                         
  64.                     $this->cell_id += $span;
  65.                     $this->is_spanning = true;
  66.                     
  67.                     return "\\multicolumn\{$span}\{$col_spec}{";
  68.                 }
  69.  
  70.                 $this->cell_id += 1;
  71.                 return '';
  72.  
  73.             case 'cell_end':
  74.                 $out '';
  75.                 if ($this->is_spanning{
  76.                     $this->is_spanning = false;
  77.                     $out '}';
  78.                 }
  79.                 
  80.                 if ($this->cell_id != $this->cell_count{
  81.                     $out .= ' & ';
  82.                 }
  83.  
  84.                 return $out;
  85.  
  86.             default:
  87.                 return '';
  88.  
  89.             }
  90.     }
  91. }
  92. ?>

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