[ Index ]
 

Code source de Serendipity 1.2

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/bundled-libs/Text/Wiki/Render/Latex/ -> Table.php (source)

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


Généré le : Sat Nov 24 09:00:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics