setText($text); return $el; } static function createAttribute1NChk(&$atStorage, $atName,$text='') { $chk = new TableElement('checkbox'); if ($text) $chk->setText($text); $chk->setSelected($atStorage[$atName][0]['value_left']=='1'); $chk->setName($atName); $chk->setId($atName); $chk->setValue(1); return $chk; } static function createAttribute2NChk(&$atStorage, $atName,$foot, $text='') { $chk = new TableElement('checkbox'); if ($text) $chk->setText($text); if ($foot==0) $valueName = 'value_left'; else $valueName = 'value_right'; $chk->setSelected($atStorage[$atName][0][$valueName]=='1'); $chk->setName($atName.'['.$foot.']'); $chk->setId($atName.$foot); $chk->setValue(1); return $chk; } function getSrc() { return $this->_src; } function setSrc($src) { $this->_src = $src; } function setSelected($sel) { $this->_selected = $sel; } function getSelected() { return $this->_selected; } function setText($txt) { $this->_text = $txt; } function getText($text) { return $this->_text; } function setValue($val) { $this->_value = $val; } function getValue() { return $this->_value; } function setName($na) { $this->_name = $na; } function getName() { return $this->_name; } function setId($id){ $this->_id = $id; } function getId() { return $this->_id; } function __construct($type) { $this->_type = $type; } function setType($typ) { $this->_type = $typ; } function getClass() { return $this->_class; } function setClass($cl) { $this->_class = $cl; } function getHTML() { $html = ''; switch($this->_type) { case 'text': $html .= $this->_text; break; case 'checkbox': $html .= "_selected?'checked':'')." value=\"".$this->_value."\" id=\"".$this->_id."\" name=\"".$this->_name."\" />"; if ($this->_text) { $html .=" "; $html .= $this->_text; } break; case 'radio': $html .= "_selected?'checked':'')." value=\"".$this->_value."\" id=\"".$this->_id."\" name=\"".$this->_name."\" />"; if ($this->_text) { $html .=" ". $this->_text; } break; case 'image': $html .= "_src."\" />"; break; } return $html; } } class TableCell { private $_elements = array(); private $_type = ''; private $_html = ''; private $_style = ''; private $_class = ''; private $_colspan = 1; function getStyle() { return $this->_style; } function getColspan() { return $this->_colspan; } function setColspan($colSpan ) { $this->_colspan = $colSpan; } function getClass() { return $this->_class; } function setClass($cl) { $this->_class = $cl; } function addElement(&$el) { $this->_elements[] = $el; } function clearElements() { $this->_elements = array(); } function getHTMLArray() { $html =array(); foreach($this->_elements as $el) $html[] = $el->getHTML(); return $html; } } class TableRendererHelper { private $_rowColor1 = '#E0F8F7'; private $_rowColor2 = '#E0ECF8'; function getRowColor1() { return $this->_rowColor1; } function getRowColor2() { return $this->_rowColor2; } function setRowColor($color) { $this->_rowColor1 = $this->_rowColor2 = $color; } function getHTML(&$manuOptsTable) { $html = ''; $tableOpen = false; $rowNumber = 0; $generalRowNumber =0; $pages = array(); $jsRowsInfo=array(); foreach($manuOptsTable as $row) { if ($row['startTable']) { if ($tableOpen) // ya hay una tabla abierta { $html .= ""; } $tableIdStr = ''; if ($row['tableId']) { $tableIdStr = "id=\"".$row['tableId']."\""; $pages[] = $row['tableId']; } $tableAtsStr =''; if ($row['tableAts']) { foreach($row['tableAts'] as $key => $value) { if ($tableAtsStr) $tableAtsStr .= " "; $tableAtsStr.="$key='$value'"; } } $html .= " "; $tableOpen = true; $rowNumber = 0; } if ($rowNumber%2==0) $rowColor = $this->_rowColor1; else $rowColor = $this->_rowColor2; if ($rowColor) $rowColorS = "background-color:$rowColor"; else $rowColorS=''; $row['id'] = 'row'.$generalRowNumber; $html .= ""; $hideRow = false; foreach($row['cells'] as $cell) { $cellColspan = $cell->getColspan(); if ($cellColspan!=0) { $cellStyle = $cell->getStyle(); $cellClass = $cell->getClass(); $cellHTMLArray = $cell->getHTMLArray(); $cellHTML = implode(' ',$cellHTMLArray); if ($cellStyle=='display:none') $hideRow = true; $html .= ""; } } if (!$hideRow) { $jsRowsInfo[] = array('id'=>$row['id'],'fields'=>$row['fields']); $rowNumber++; $generalRowNumber++; } $html .= ""; } if ($tableOpen) $html .= "
"; if (!$cellHTML) $html .= " "; else $html .= $cellHTML; $html .= "
"; return $html; } } ?>