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);
$this->registerRule('fecha', 'function', 'validate', 'HTML_QuickForm_mdate');
$this->setRequiredNote('<FONT color="red">*</FONT> 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)
{
{
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
/**
* 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
/**
}
$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
* 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
--- /dev/null
+<?php /* vim: set binary expandtab tabstop=4 shiftwidth=4 tw=80 fdm=marker:
+-------------------------------------------------------------------------------
+ Ministerio de Economía
+ meconlib
+-------------------------------------------------------------------------------
+This file is part of meconlib.
+
+meconlib is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2 of the License, or (at your option)
+any later version.
+
+meconlib is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License; if not,
+write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+Boston, MA 02111-1307 USA
+-------------------------------------------------------------------------------
+Creado: mar ago 19 13:41:38 ART 2003
+Autor: Martin Marrese <mmarre@mecon.gov.ar>
+-------------------------------------------------------------------------------
+$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