Location: PHPKode > projects > phpAWE > phpAWE.0.4.beta.demo-page/awe/classes/TawePageTable.php
<?php

class TawePageTable extends TaweBaseItem{

protected $awePageTableTempOpt = array (0, 1, 2, "distinct_first" => 1, "distinct_alternate" => 2);

  public function view($data, $template, $templateOpt) {
      global $pageTableCellSeparator;
      global $pageTableRowSeparator;
      global $tempItemFirstSufix;
      
      if (!isset($data)) return NULL;
      if (strlen($data)==0) return NULL;
      
      $templateOpt = optionsToTable($templateOpt, $this->awePageTableTempOpt);
      
      if (!is_array($data)) {
        $data = explode($pageTableRowSeparator, $data);
        for ($i=0; $i<sizeof($data); $i++) {
         $data[$i] = explode($pageTableCellSeparator, $data[$i]); 
        }
      }

      $cellTemplate = file_get_contents(getCellTemplate($this->moduleName,$template));
      $tableTemplate = file_get_contents(getTableTemplate($this->moduleName,$template));
      
      $last = start_value;
      
      for ($row=0; $row<sizeof($data); $row++) {
        if ($row==0 && $templateOpt[$this->awePageTableTempOpt["distinct_first"]])
          {$extra .= $tempItemFirstSufix;};

        if (!(($row+$templateOpt[$this->awePageTableTempOpt["distinct_alternate"]]) % 2) && $templateOpt[$this->awePageTableTempOpt["distinct_alternate"]])
           {$extra .= "alternate.";};
                
      if (strcmp($last,$extra))
        {
        $rowTemplate = file_get_contents(getRowTemplate($this->moduleName,$template,$extra)); 
        $last =$extra; $extra="";
        };
        
      for ($col=0, $line=""; $col<sizeof($data[0]); $col++) {
        $line .= str_replace("%data%", $data[$row][$col], $cellTemplate);
          
        }
      $table .= str_replace("%data%", $line, $rowTemplate);
      
      }
      $result = str_replace("%data%", $table, $tableTemplate); 

      return $result;
      
  }
}
Return current item: phpAWE