------------------------------------------------------------------------------- $Id$ -----------------------------------------------------------------------------*/ require_once 'HTML/QuickForm/Renderer.php'; require_once 'MECON/HTML/Tabla.php'; /** * QuickForm renderer que usa Tabla como backend. * Basado en el QuickForm Renderer basico. * * @access public */ class MECON_HTML_QuickForm_Renderer_Tabla extends HTML_QuickForm_Renderer { /** * Tabla usada para dibujar el formulario. * @var object Tabla * @access private */ var $_tabla; /** * HTML con los scripts para poner antes del formulario (tipicamente * un javascript). * @var string * @access private */ var $_script = ''; /** * HTML para agregar antes de la tabla (tipicamente un javascript). * @var string * @access private */ var $_prepend = ''; /** * HTML para agregar despues de la tabla. * @var string * @access private */ var $_append = ''; /** * True if we are inside a group * @var bool * @access private */ var $_inGroup = false; /** * Group error related message. * @var string * @access private */ var $_groupError = ''; /** * Array with HTML generated for group elements * @var array * @access private */ var $_groupElements = array(); /** * Constructor. * * @param mixed $style Estilo de la tabla. * * @access public */ function MECON_HTML_QuickForm_Renderer_Tabla($style = array()) { $this->HTML_QuickForm_Renderer(); $this->_tabla =& new Tabla($style); } // end constructor /** * returns the HTML generated for the form * * @access public * @return string */ function toHtml() { return $this->_script . $this->_prepend . $this->_tabla->toHtml() . $this->_append; } // end func toHtml /** * Called when visiting a form, before processing any form elements * * @param object An HTML_QuickForm object being visited * @access public * @return void */ function startForm(&$form) { # FIXME - deberia sacarlo del QuickForm #$this->_prepend = $form->getFormStart(); $attrs = $form->getAttributesString(); $this->_prepend = "\n
\n"; } // end func finishForm /** * Called when visiting a header element * * @param object An HTML_QuickForm_header element being visited * @access public * @return void */ function renderHeader(&$header) { $name = $header->getName(); $this->_tabla->addRow( array($header->toHtml()), array('colspan' => 2, $name => true, 'align' => 'center') ); } // end func renderHeader /** * Renders an element Html * Called when visiting an element * * @param object An HTML_QuickForm_element object being visited * @param bool Whether an element is required * @param string An error message associated with an element * @access public * @return void */ function renderElement(&$element, $required, $error) { if (!$this->_inGroup) { $id = $this->_tabla->addRow( array( $element->getLabel() . ($required ? '*' : ''), $element->toHtml() . ($error ? "