From e7b590cdbf44f5e9c8dab58f13b45b685c211a30 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mart=C3=ADn=20Marrese?= Date: Tue, 19 Aug 2003 17:51:18 +0000 Subject: [PATCH] Se modifico el Renderer de MECON. Ahora se puede llamar a la funcion $FORM->renderer->setTable() y pasarle una tabla con estilos diferentes a los comunes. --- lib/MECON/HTML/QuickForm.php | 66 +++++++++--------- lib/MECON/HTML/QuickForm/Renderer/Tabla.php | 53 ++++++++++++++- lib/MECON/HTML/Tabla.php | 7 +- .../{conf_Tabla.php => estilo_comun.php} | 0 lib/MECON/HTML/Tabla/estilo_servicio.php | 67 +++++++++++++++++++ 5 files changed, 154 insertions(+), 39 deletions(-) rename lib/MECON/HTML/Tabla/{conf_Tabla.php => estilo_comun.php} (100%) create mode 100644 lib/MECON/HTML/Tabla/estilo_servicio.php diff --git a/lib/MECON/HTML/QuickForm.php b/lib/MECON/HTML/QuickForm.php index 96a0372..be8a7f9 100644 --- a/lib/MECON/HTML/QuickForm.php +++ b/lib/MECON/HTML/QuickForm.php @@ -26,15 +26,15 @@ $Id$ require_once 'HTML/QuickForm.php'; require_once 'MECON/HTML/QuickForm/Renderer/Tabla.php'; -require_once 'MECON/HTML/QuickForm/Renderer/Tabla_Servicios.php'; /** * QuickForm de uso general del MECON. */ class MECON_HTML_QuickForm extends HTML_QuickForm { + var $_rendererOpts = array(); - var $_renderer = 'MECON_HTML_QuickForm_Renderer_Tabla'; -// var $_renderer = 'MECON_HTML_QuickForm_Renderer_Tabla()'; + var $renderer; + function MECON_HTML_QuickForm($formName='', $method='post', $action='', $target='_self', $attributes=null) { parent::HTML_QuickForm($formName, $method, $action, $target, $attributes); @@ -42,6 +42,9 @@ class MECON_HTML_QuickForm extends HTML_QuickForm { $this->registerRule('fecha', 'function', 'validate', 'HTML_QuickForm_mdate'); $this->setRequiredNote('* indica un campo obligatorio'); $this->setJsWarnings('Hay errores en el formulario:', 'Por favor corríjalos antes de continuar.'); + + $this->renderer =& new MECON_HTML_QuickForm_Renderer_Tabla($this->_rendererOpts); + } function addRule($element, $message, $type, $format='', $validation='client', $reset = false, $force = false) { @@ -51,42 +54,39 @@ class MECON_HTML_QuickForm extends HTML_QuickForm { { parent::addGroupRule($group, $arg1, $type, $format, $howmany, $validation); } - function toHtml() { - - //AGREGADO por mmarre - //TODO ver porque no puedo utilizar $this->_renderer en el new -> es lo - //comentado - switch ($this->_renderer) { - case 'MECON_HTML_QuickForm_Renderer_Tabla': - $renderer =& new MECON_HTML_QuickForm_Renderer_Tabla($this->_rendererOpts); - break; - case 'MECON_HTML_QuickForm_Renderer_Tabla_Servicios': - $renderer =& new MECON_HTML_QuickForm_Renderer_Tabla_Servicios($this->_rendererOpts); - break; - } -// $renderer =& new $this->_renderer ($this->_rendererOpts); - - $this->accept($renderer); - return $renderer->toHtml(); + function toHtml() + { + $this->accept($this->renderer); + return $this->renderer->toHtml(); } + + /** + * TODO aclarar que usar + * $FORM->renderer->updateAttributes() + * + * @deprecated + */ function setRendererOpts($opts) { - $this->_rendererOpts = $opts; + $this->renderer->setAttributes($opts); } - function getRendererOpts($opts) { - return $this->_rendererOpts;; + /** + * TODO aclarar que usar + * $FORM->renderer->updateAttributes() + * + * @deprecated + */ + function getRendererOpts() { + return $this->renderer->getAttributes(); } + /** + * TODO aclarar que usar + * $FORM->renderer->updateAttributes() + * + * @deprecated + */ function updateRendererOpts($opts) { - $this->_rendererOpts = array_merge($this->_rendererOpts, $opts); - } - - //AGREGADO POR mmarre PARA PODER DECIDIR CUAL DE NUESTROS RENDERES UTILIZAR - //Por defecto utiliza el renderer que deja las tablas como estaban en un - //principio. - function setRenderer($renderer = 'MECON_HTML_QuickForm_Renderer_Tabla') { - $this->_renderer = $renderer; -// $this->_renderer = $renderer.'()'; + $this->renderer->updateAttributes($opts); } - } ?> \ No newline at end of file diff --git a/lib/MECON/HTML/QuickForm/Renderer/Tabla.php b/lib/MECON/HTML/QuickForm/Renderer/Tabla.php index a767a19..2d804c0 100644 --- a/lib/MECON/HTML/QuickForm/Renderer/Tabla.php +++ b/lib/MECON/HTML/QuickForm/Renderer/Tabla.php @@ -88,14 +88,20 @@ class MECON_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 MECON_HTML_QuickForm_Renderer_Tabla($style = array()) + 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 Tabla($param); + } } // end constructor /** @@ -264,6 +270,47 @@ class MECON_HTML_QuickForm_Renderer_Tabla extends HTML_QuickForm_Renderer { } $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; + } } // end class HTML_QuickForm_Renderer_Default diff --git a/lib/MECON/HTML/Tabla.php b/lib/MECON/HTML/Tabla.php index d67711c..a4eb4d8 100644 --- a/lib/MECON/HTML/Tabla.php +++ b/lib/MECON/HTML/Tabla.php @@ -58,14 +58,15 @@ class Tabla extends HTML_Table { * quieren dar a la tabla en cuestion. Estos atributos estan * seteados por default segun el archivo de configuracion. * - * @param $atributos Atributos diferentes a los estandares para la + * @param mixed $atributos Atributos diferentes a los estandares para la * tabla + * @param string $estilo Tipo de tabla. (comun, servicio) * * @access public */ - function Tabla($attrs = null) + function Tabla($attrs = null, $estilo = 'comun') { - $this->_conf = include 'MECON/HTML/Tabla/conf_Tabla.php'; // Obtengo los valores particulares de configuracion + $this->_conf = include 'MECON/HTML/Tabla/estilo_'.$estilo.'.php'; // Obtengo los valores particulares de configuracion // Seteo los atributos para la tabla $this->_attrs = $this->_conf['atributos']['tabla_comun']; //Genero el objeto HTML_Table diff --git a/lib/MECON/HTML/Tabla/conf_Tabla.php b/lib/MECON/HTML/Tabla/estilo_comun.php similarity index 100% rename from lib/MECON/HTML/Tabla/conf_Tabla.php rename to lib/MECON/HTML/Tabla/estilo_comun.php diff --git a/lib/MECON/HTML/Tabla/estilo_servicio.php b/lib/MECON/HTML/Tabla/estilo_servicio.php new file mode 100644 index 0000000..b1caba4 --- /dev/null +++ b/lib/MECON/HTML/Tabla/estilo_servicio.php @@ -0,0 +1,67 @@ + +------------------------------------------------------------------------------- +$Id$ +-----------------------------------------------------------------------------*/ + +// Opciones para la tabla {{{ +return array ( + 'atributos' => array ( // {{{ + 'tabla_comun' => array( // {{{ + 'width' => '100%', + 'align' => 'center', + 'cellpadding' => 2, + 'cellspacing' => 2, + 'border' => 0, + 'bgcolor' => '#336699', + ), // }}} + 'tabla_contenedora' => array( // {{{ + 'width' => '100%', + 'align' => 'center', + 'cellpadding' => 0, + 'cellspacing' => 0, + 'border' => 0, + 'bgcolor' => '#336699', + ), // }}} + 'celda_cabecera' => array( // {{{ + 'align' => 'center', + 'bgcolor' => '#FFFFFF', + 'class' => 'titulo_form', + ), // }}} + 'celda_comun' => array( // {{{ + 'align' => 'center', + 'bgcolor' => '#FFFFFF', + 'class' => 'txt1', + ), // }}} + 'celda_titulo' => array( // {{{ + 'align' => 'center', + 'bgcolor' => '#FFFFFF', + 'class' => 'txt1', + ), // }}} + 'celda_contenedora' => array( // {{{ + ), // }}} + ), // }}} +); +// }}} + +?> \ No newline at end of file -- 2.43.0