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 'caption_start':
  49.                 return "\\caption{";
  50.  
  51.             case 'caption_end':
  52.                 return "}\n";
  53.  
  54.             case 'row_start':
  55.                 $this->is_spanning = false;
  56.                 $this->cell_id = 0;
  57.                 return "\\hline\n";
  58.  
  59.             case 'row_end':
  60.                 return "\\\\\n";
  61.  
  62.             case 'cell_start':
  63.                 if ($span > 1{
  64.                     $col_spec '';
  65.                     if ($this->cell_id == 0{
  66.                         $col_spec '|';
  67.                     }
  68.                     $col_spec .= 'l|';
  69.  
  70.                     $this->cell_id += $span;
  71.                     $this->is_spanning = true;
  72.  
  73.                     return '\multicolumn{' $span '}{' $col_spec '}{';
  74.                 }
  75.  
  76.                 $this->cell_id += 1;
  77.                 return '';
  78.  
  79.             case 'cell_end':
  80.                 $out '';
  81.                 if ($this->is_spanning{
  82.                     $this->is_spanning = false;
  83.                     $out '}';
  84.                 }
  85.  
  86.                 if ($this->cell_id != $this->cell_count{
  87.                     $out .= ' & ';
  88.                 }
  89.  
  90.                 return $out;
  91.  
  92.             default:
  93.                 return '';
  94.  
  95.             }
  96.     }
  97. }
  98. ?>

Documentation generated on Tue, 12 Mar 2019 21:49:22 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.