$Id$
-----------------------------------------------------------------------------*/
-require_once 'HTML/QuickForm.php';
+require_once 'MECON/HTML/QuickFormSimple.php';
require_once 'MECON/HTML/QuickForm/Renderer/Tabla.php';
/**
* QuickForm de uso general del MECON.
*/
-class MECON_HTML_QuickForm extends HTML_QuickForm {
+class MECON_HTML_QuickForm extends MECON_HTML_QuickFormSimple {
- var $_rendererOpts = array();
var $renderer;
function MECON_HTML_QuickForm($formName='', $method='post', $action='', $target='_self', $attributes=null)
{
- parent::HTML_QuickForm($formName, $method, $action, $target, $attributes);
- $this->registerElementType('mdate', 'MECON/HTML/QuickForm/mdate.php', 'HTML_QuickForm_mdate');
- $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.');
-
+ parent::MECON_HTML_QuickFormSimple($formName, $method, $action, $target, $attributes);
$this->renderer =& new MECON_HTML_QuickForm_Renderer_Tabla($this->_rendererOpts);
-
- }
- function addRule($element, $message, $type, $format='', $validation='client', $reset = false, $force = false)
- {
- parent::addRule($element, $message, $type, $format, $validation, $reset, $force);
- }
- function addGroupRule($group, $arg1, $type='', $format='', $howmany=0, $validation = 'client')
- {
- parent::addGroupRule($group, $arg1, $type, $format, $howmany, $validation);
}
+
function toHtml()
{
$this->accept($this->renderer);
function setRendererOpts($opts) {
$this->renderer->setAttributes($opts);
}
+
/**
* TODO aclarar que usar
* $FORM->renderer->updateAttributes()
function getRendererOpts() {
return $this->renderer->getAttributes();
}
+
/**
* TODO aclarar que usar
* $FORM->renderer->updateAttributes()
function updateRendererOpts($opts) {
$this->renderer->updateAttributes($opts);
}
+
}
?>
\ No newline at end of file
+++ /dev/null
-<?php /* vim: set binary expandtab tabstop=4 shiftwidth=4 textwidth=80:
--------------------------------------------------------------------------------
- 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: jue jul 17 15:36:26 ART 2003
-Autor: Leandro Lucarella <llucar@mecon.gov.ar>
--------------------------------------------------------------------------------
-$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_Servicios 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_Servicios($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<FORM$attrs>\n";
- } // end func startForm
-
- /**
- * Called when visiting a form, after processing all form elements
- * Adds required note, form attributes, validation javascript and form content.
- *
- * @param object An HTML_QuickForm object being visited
- * @access public
- * @return void
- */
- function finishForm(&$form)
- {
- // 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')
- );
- //$this->_tabla->updateCellAttributes($id, array('colspan' => 2));
- }
- // add form attributes and content
- //$this->_html = str_replace('{content}', $this->_html, $html);
- // add a validation script
- $this->_script = strval($form->getValidationScript());
- # FIXME - deberia sacarlo del QuickForm
- #$this->_append = $form->getFormEnd();
- $this->_append = "\n</FORM>\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' => 'left',
- 'class' => 'titulo_form')
- );
- } // 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 ? '<FONT color="red">*</FONT>' : ''),
- $element->toHtml() . ($error ? "<BR><FONT color=\"red\">$error</FONT>" : ''),
- )
- );
- $this->_tabla->updateCellAttributes($id, 0, array('align' => 'left',
- 'class' => 'txt1'));
- $this->_tabla->updateCellAttributes($id, 1, array('align' => 'center',
- 'class' => 'txt1'));
- } else {
- $this->_groupElements[] = ($element->getLabel() ? ($element->getLabel().' ') : '') . $element->toHtml();
- }
- } // end func renderElement
-
- /**
- * Renders an hidden element
- * Called when visiting a hidden element
- *
- * @param object An HTML_QuickForm_hidden object being visited
- * @access public
- * @return void
- */
- function renderHidden(&$element)
- {
- $this->_prepend .= "\n\t". $element->toHtml();
- } // end func renderHidden
-
- /**
- * Called when visiting a raw HTML/text pseudo-element
- *
- * @param object An HTML_QuickForm_html element being visited
- * @access public
- * @return void
- */
- function renderHtml(&$data)
- {
- $this->_tabla->addRow(
- array($header->toHtml()),
- array('colspan' => 2)
- );
- } // end func renderHtml
-
- /**
- * Called when visiting a group, before processing any group elements
- *
- * @param object An HTML_QuickForm_group object being visited
- * @param bool Whether a group is required
- * @param string An error message associated with a group
- * @access public
- * @return void
- */
- function startGroup(&$group, $required, $error)
- {
- $this->_groupElements = array();
- $this->_groupError = $error;
- $this->_inGroup = true;
- } // end func startGroup
-
- /**
- * Called when visiting a group, after processing all group elements
- *
- * @param object An HTML_QuickForm_group object being visited
- * @access public
- * @return void
- */
- function finishGroup(&$group)
- {
- $name = $group->getName();
- $sep = $group->_separator;
- if (strtolower($name) == 'botones') {
- $id = $this->_tabla->addRow(
- array(join('', $this->_groupElements))
- );
- $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('valign' => 'middle', 'align' => 'left')
- );
- $this->_tabla->updateCellAttributes($id, 0, array('comun' => true,
- 'align' => 'left', 'class' => 'txt1'));
- $this->_tabla->updateCellAttributes($id, 1, array('comun' => true,
- 'align' => 'center', 'class' => 'txt1'));
- }
- $this->_inGroup = false;
- } // end func finishGroup
-
-} // end class HTML_QuickForm_Renderer_Default
-
-?>
--- /dev/null
+<?php /* vim: set binary expandtab tabstop=4 shiftwidth=4 textwidth=80:
+-------------------------------------------------------------------------------
+ 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: mié jun 18 15:08:05 ART 2003
+Autor: Leandro Lucarella <llucar@mecon.gov.ar>
+-------------------------------------------------------------------------------
+$Id$
+-----------------------------------------------------------------------------*/
+
+require_once 'HTML/QuickForm.php';
+
+/**
+ * QuickForm de uso general del MECON.
+ */
+class MECON_HTML_QuickFormSimple extends HTML_QuickForm {
+
+ function MECON_HTML_QuickFormSimple($formName='', $method='post', $action='', $target='_self', $attributes=null)
+ {
+ parent::HTML_QuickForm($formName, $method, $action, $target, $attributes);
+ $this->registerElementType('mdate', 'MECON/HTML/QuickForm/mdate.php', 'HTML_QuickForm_mdate');
+ $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.');
+ }
+
+ /**
+ * Igual que QuickForm pero pone por default validación en el cliente además
+ * de en el servidor.
+ */
+ function addRule($element, $message, $type, $format='', $validation='client', $reset = false, $force = false)
+ {
+ parent::addRule($element, $message, $type, $format, $validation, $reset, $force);
+ }
+
+ /**
+ * Igual que QuickForm pero pone por default validación en el cliente además
+ * de en el servidor.
+ */
+ function addGroupRule($group, $arg1, $type='', $format='', $howmany=0, $validation = 'client')
+ {
+ parent::addGroupRule($group, $arg1, $type, $format, $howmany, $validation);
+ }
+
+ /**
+ * Obtiene el inicio del formulario.
+ *
+ * @return string
+ * @access public
+ */
+ function getBegin() {
+ $attrs = $this->getAttributesString();
+ return "<form$attrs>";
+ }
+
+ /**
+ * Obtiene el fin del formulario.
+ *
+ * @return string
+ * @access public
+ */
+ function getEnd() {
+ return '</form>';
+ }
+
+}
+
+?>
\ No newline at end of file