AddItem($item); $this->SetClass($class); } function SetAlign($value) { return $this->options['align'] = $value; } function SetRowSpan($value) { return $this->options['rowspan'] = strval($value); } function SetColSpan($value) { return $this->options['colspan'] =strval($value); } } class CRow extends CTag { /* public */ function CRow($item=NULL,$class=NULL) { parent::CTag("tr","yes"); $this->AddItem($item); $this->SetClass($class); } function SetAlign($value) { return $this->options['align'] = $value; } function AddItem($item=NULL) { if(is_a($item,'ccol')) { parent::AddItem($item); } elseif(is_array($item)) { foreach($item as $el) { if(is_a($el,'ccol')) { parent::AddItem($el); } elseif(!is_null($el)) { parent::AddItem(''.unpack_object($el).''); } } } elseif(!is_null($item)) { parent::AddItem(''.unpack_object($item).''); } } } class CTable extends CTag { /* protected */ var $oddRowClass; var $evenRowClass; var $header; var $headerClass; var $colnum; var $rownum; var $footer; var $footerClass; var $message; /* public */ function CTable($message=NULL,$class=NULL) { parent::CTag("table","yes"); $this->SetClass($class); $this->rownum = 0; $this->oddRowClass = NULL; $this->evenRowClass = NULL; $this->header = ''; $this->headerClass = NULL; $this->footer = ''; $this->footerClass = NULL; $this->colnum = 0; $this->message = $message; } function SetOddRowClass($value=NULL) { $this->oddRowClass = $value; } function SetEvenRowClass($value=NULL) { $this->evenRowClass = $value; } function SetAlign($value) { return $this->options['align'] = $value; } function SetCellPadding($value) { return $this->options['cellpadding'] = strval($value); } function SetCellSpacing($value) { return $this->options['cellspacing'] = strval($value); } function PrepareRow($item,$rowClass=NULL) { if(is_null($item)) return NULL; if(is_a($item,'ccol')) { if(isset($this->header) && !isset($item->options['colspan'])) $item->options['colspan'] = $this->colnum; $item = new CRow($item,$rowClass); } elseif(is_a($item,'crow')) { if(isset($rowClass)) $item->options['class'] = $rowClass; } else { $item = new CRow($item,$rowClass); } if(!isset($item->options['class'])) { $item->options['class'] = ($this->rownum % 2) ? $this->evenRowClass: $this->oddRowClass; }/**/ return $item->ToString(); } function SetHeader($value=NULL,$class=NULL) { if(is_null($class)) $class = $this->headerClass; if(is_a($value,'crow')) { if(isset($class)) $value->SetClass($class); }else{ $value = new CRow($value,$class); } $this->colnum = $value->ItemsCount(); $this->header = $value->ToString(); } function SetFooter($value=NULL,$class=NULL) { if(is_null($class)) $class = $this->footerClass; $this->footer = $this->PrepareRow($value,$class);; } function AddRow($item,$rowClass=NULL) { ++$this->rownum; return $this->AddItem($this->PrepareRow($item,$rowClass)); } function ShowRow($item,$rowClass=NULL) { ++$this->rownum; echo $this->PrepareRow($item,$rowClass); } /* protected */ function GetNumRows() { return $this->rownum; } function StartToString() { $ret = parent::StartToString(); $ret .= $this->header; return $ret; } function EndToString() { $ret = ""; if($this->rownum == 0 && isset($this->message)) { ++$this->rownum; $ret = $this->PrepareRow(new CCol($this->message,'message')); } $ret .= $this->footer; $ret .= parent::EndToString(); return $ret; } } ?>