예제 #1
0
 function render($data = null, $frh = null)
 {
     if (strtolower(get_class($this)) != 'htmltable') {
         $ht = new HtmlTable($data);
         $ht->firstRowHeaders($frh);
         return $ht->render();
     }
     if (!is_null($data)) {
         $this->setData($data);
     }
     if (!is_null($frh)) {
         $this->firstRowHeaders($frh);
     }
     $o = '<table';
     if ($this->border !== false) {
         $o .= ' border="' . $this->border . '"';
     }
     if ($this->padding !== false) {
         $o .= ' cellpadding="' . $this->padding . '"';
     }
     if ($this->spacing !== false) {
         $o .= ' cellspacing="' . $this->spacing . '"';
     }
     if ($this->width !== false) {
         $o .= ' width="' . $this->width . '"';
     }
     if ($this->class !== false) {
         $o .= ' class="' . $this->class . '"';
     }
     if ($this->style !== false) {
         $o .= ' style="' . $this->style . '"';
     }
     if ($this->id !== false) {
         $o .= ' id="' . $this->id . '"';
     }
     $o .= ">\n";
     $first = true;
     foreach ($this->data as $key => $row) {
         $o .= "\t<tr>\n";
         $col = 0;
         foreach ($row as $k => $v) {
             if ($first && $this->frh) {
                 $o .= "\t\t<th";
                 if (isset($this->widths[$col])) {
                     $o .= ' width="' . $this->widths[$col] . '"';
                 }
                 $o .= '>' . $v . "</th>\n";
             } else {
                 $o .= "\t\t<td";
                 if (isset($this->widths[$col])) {
                     $o .= ' width="' . $this->widths[$col] . '"';
                 }
                 $o .= '>' . $v . "</td>\n";
             }
             $col++;
         }
         $o .= "\t</tr>\n";
         $first = false;
     }
     $o .= "</table>\n";
     return $o;
 }