X-Git-Url: https://git.llucax.com/mecon/meconlib.git/blobdiff_plain/cacc1525e7102dfef7964462a50e4ff13f02dcc6..b371ffddb6dbdf292f496845e4b27d83bd70fa3f:/lib/MECON/HTML/QuickForm/Renderer/Tabla.php diff --git a/lib/MECON/HTML/QuickForm/Renderer/Tabla.php b/lib/MECON/HTML/QuickForm/Renderer/Tabla.php index 5e04f71..79c3f14 100644 --- a/lib/MECON/HTML/QuickForm/Renderer/Tabla.php +++ b/lib/MECON/HTML/QuickForm/Renderer/Tabla.php @@ -1,35 +1,39 @@ - | -// | Adam Daniel | -// | Bertrand Mansion | -// +----------------------------------------------------------------------+ -// -// $Id$ + +------------------------------------------------------------------------------- +$Id$ +-----------------------------------------------------------------------------*/ require_once 'HTML/QuickForm/Renderer.php'; require_once 'MECON/HTML/Tabla.php'; /** - * A concrete renderer for HTML_QuickForm, - * based on QuickForm 2.x built-in one + * QuickForm renderer que usa Tabla como backend. + * Basado en el QuickForm Renderer basico. * * @access public */ -class HTML_QuickForm_Renderer_Tabla extends HTML_QuickForm_Renderer { +class MECON_HTML_QuickForm_Renderer_Tabla extends HTML_QuickForm_Renderer { /** * Tabla usada para dibujar el formulario. @@ -84,14 +88,20 @@ class HTML_QuickForm_Renderer_Tabla extends HTML_QuickForm_Renderer { /** * Constructor. * - * @param mixed $style Estilo de la tabla. + * @param mixed $param Array o sting con el estilo de la tabla u objeto + * tabla alternativo para usar. * * @access public */ - function HTML_QuickForm_Renderer_Tabla($style = 'width="400"') + function MECON_HTML_QuickForm_Renderer_Tabla($param = array()) { $this->HTML_QuickForm_Renderer(); - $this->_tabla =& new Tabla($style); + if (is_a($param, 'Tabla')) { + $this->setTable($param); + } + else { + $this->_tabla =& new MECON_HTML_Tabla($param); + } } // end constructor /** @@ -119,7 +129,7 @@ class HTML_QuickForm_Renderer_Tabla extends HTML_QuickForm_Renderer { # FIXME - deberia sacarlo del QuickForm #$this->_prepend = $form->getFormStart(); $attrs = $form->getAttributesString(); - $this->_prepend = "\n\n"; + $this->_prepend = "\n\n"; } // end func startForm /** @@ -135,8 +145,8 @@ class HTML_QuickForm_Renderer_Tabla extends HTML_QuickForm_Renderer { // add a required note, if one is needed if (!empty($form->_required) && !$form->_freezeAll) { $id = $this->_tabla->addRow( - array($form->getRequiredNote()), - array('colspan' => 2, 'align' => 'center', 'cabecera' => true) + array(''.$form->getRequiredNote().''), + array('colspan' => 2, 'cabecera' => true) ); //$this->_tabla->updateCellAttributes($id, array('colspan' => 2)); } @@ -146,7 +156,7 @@ class HTML_QuickForm_Renderer_Tabla extends HTML_QuickForm_Renderer { $this->_script = strval($form->getValidationScript()); # FIXME - deberia sacarlo del QuickForm #$this->_append = $form->getFormEnd(); - $this->_append = "\n\n"; + $this->_append = "\n\n"; } // end func finishForm /** @@ -161,7 +171,7 @@ class HTML_QuickForm_Renderer_Tabla extends HTML_QuickForm_Renderer { $name = $header->getName(); $this->_tabla->addRow( array($header->toHtml()), - array('colspan' => 2, $name => true, 'align' => 'center') + array('colspan' => 2, $name => true) ); } // end func renderHeader @@ -180,11 +190,11 @@ class HTML_QuickForm_Renderer_Tabla extends HTML_QuickForm_Renderer { if (!$this->_inGroup) { $id = $this->_tabla->addRow( array( - $element->getLabel() . ($required ? '*' : ''), - $element->toHtml() . ($error ? "
$error" : ''), + $element->getLabel() . ($required ? '*' : ''), + $element->toHtml() . ($error ? "
$error" : ''), ) ); - $this->_tabla->updateCellAttributes($id, 0, array('titulo' => true, 'align' => 'left', 'nowrap' => true)); + $this->_tabla->updateCellAttributes($id, 0, array('titulo' => true, 'align' => 'left')); $this->_tabla->updateCellAttributes($id, 1, array('align' => 'left')); } else { $this->_groupElements[] = ($element->getLabel() ? ($element->getLabel().' ') : '') . $element->toHtml(); @@ -250,15 +260,61 @@ class HTML_QuickForm_Renderer_Tabla extends HTML_QuickForm_Renderer { $id = $this->_tabla->addRow( array(join('', $this->_groupElements)) ); - $this->_tabla->updateCellAttributes($id, 0, array('align' => 'right', 'colspan' => 2)); + $this->_tabla->updateCellAttributes($id, 0, array('valign' => 'middle', 'align' => 'center', 'colspan' => 2)); } else { $id = $this->_tabla->addRow( array($group->getLabel(), join($sep, $this->_groupElements)), - array('align' => 'left') + array('valign' => 'middle', 'align' => 'left') ); - $this->_tabla->updateCellAttributes($id, 0, array('titulo' => true, 'align' => 'left', 'nowrap' => true)); + $this->_tabla->updateCellAttributes($id, 0, array('titulo' => true, 'align' => 'left')); } + $this->_inGroup = false; } // end func finishGroup + + /** + * + * + * @param mixed $attrs Html attributes + * @access public + * @return void + */ + function updateAttributes($attrs) { + $this->_tabla->updateAttributes($attrs); + } + /** + * + * + * @param mixed $attrs Html attributes + * @access public + * @return void + */ + function setAttributes($attrs) { + $this->_tabla->setAttributes($attrs); + } + /** + * + * + * @access public + * @return mixed + */ + function getAttributes() { + return $this->_tabla->getAttributes(); + } + + /** + * + * + * @param Tabla $param Objeto tabla alternativo para utilizar + * + * @access public + */ + function setTable($param) { + $this->_tabla =& $param; + } + + function getCSS() { + return $this->_tabla->getCSS(); + } } // end class HTML_QuickForm_Renderer_Default