-<?php\r
-/* vim: set expandtab tabstop=4 shiftwidth=4: */\r
-// +----------------------------------------------------------------------+\r
-// | PHP version 4.0 |\r
-// +----------------------------------------------------------------------+\r
-// | Copyright (c) 1997-2003 The PHP Group |\r
-// +----------------------------------------------------------------------+\r
-// | This source file is subject to version 2.0 of the PHP license, |\r
-// | that is bundled with this package in the file LICENSE, and is |\r
-// | available at through the world-wide-web at |\r
-// | http://www.php.net/license/2_02.txt. |\r
-// | If you did not receive a copy of the PHP license and are unable to |\r
-// | obtain it through the world-wide-web, please send a note to |\r
-// | license@php.net so we can mail you a copy immediately. |\r
-// +----------------------------------------------------------------------+\r
-// | Authors: Alexey Borzov <borz_off@cs.msu.su> |\r
-// | Adam Daniel <adaniel1@eesus.jnj.com> |\r
-// | Bertrand Mansion <bmansion@mamasam.com> |\r
-// +----------------------------------------------------------------------+\r
-//\r
-// $Id$\r
-\r
-require_once 'HTML/QuickForm/Renderer.php';\r
-require_once 'HTML/Tabla.php';\r
-\r
-/**\r
- * A concrete renderer for HTML_QuickForm,\r
- * based on QuickForm 2.x built-in one\r
- * \r
- * @access public\r
- */\r
-class HTML_QuickForm_Renderer_Tabla extends HTML_QuickForm_Renderer {\r
-\r
- /**\r
- * Tabla usada para dibujar el formulario.\r
- * @var object Tabla\r
- * @access private\r
- */\r
- var $_tabla;\r
-\r
- /**\r
- * HTML con los scripts para poner antes del formulario (tipicamente\r
- * un javascript).\r
- * @var string\r
- * @access private\r
- */\r
- var $_script = '';\r
-\r
- /**\r
- * HTML para agregar antes de la tabla (tipicamente un javascript).\r
- * @var string\r
- * @access private\r
- */\r
- var $_prepend = '';\r
-\r
- /**\r
- * HTML para agregar despues de la tabla.\r
- * @var string\r
- * @access private\r
- */\r
- var $_append = '';\r
-\r
- /**\r
- * True if we are inside a group \r
- * @var bool\r
- * @access private\r
- */\r
- var $_inGroup = false;\r
-\r
- /**\r
- * Array with HTML generated for group elements\r
- * @var array\r
- * @access private\r
- */\r
- var $_groupElements = array();\r
-\r
- /**\r
- * Constructor.\r
- *\r
- * @param mixed $style Estilo de la tabla.\r
- *\r
- * @access public\r
- */\r
- function HTML_QuickForm_Renderer_Tabla($style = 'width="400"')\r
- {\r
- $this->HTML_QuickForm_Renderer();\r
- $this->_tabla =& new Tabla($style);\r
- } // end constructor\r
-\r
- /**\r
- * returns the HTML generated for the form\r
- *\r
- * @access public\r
- * @return string\r
- */\r
- function toHtml()\r
- {\r
- return $this->_script . $this->_prepend .\r
- $this->_tabla->toHtml() .\r
- $this->_append;\r
- } // end func toHtml\r
- \r
- /**\r
- * Called when visiting a form, before processing any form elements\r
- *\r
- * @param object An HTML_QuickForm object being visited\r
- * @access public\r
- * @return void\r
- */\r
- function startForm(&$form)\r
- {\r
- # FIXME - deberia sacarlo del QuickForm\r
- #$this->_prepend = $form->getFormStart();\r
- $this->_prepend = "\n<FORM>\n";\r
- } // end func startForm\r
-\r
- /**\r
- * Called when visiting a form, after processing all form elements\r
- * Adds required note, form attributes, validation javascript and form content.\r
- * \r
- * @param object An HTML_QuickForm object being visited\r
- * @access public\r
- * @return void\r
- */\r
- function finishForm(&$form)\r
- {\r
- // add a required note, if one is needed\r
- if (!empty($form->_required) && !$form->_freezeAll) {\r
- $id = $this->_tabla->addRow(array($form->getRequiredNote()), array('colspan' => 2, 'align' => 'center', 'cabecera' => true));\r
- //$this->_tabla->updateCellAttributes($id, array('colspan' => 2));\r
- }\r
- // add form attributes and content\r
- //$html = str_replace('{attributes}', $form->getAttributesString(), $this->_formTemplate);\r
- //$this->_html = str_replace('{content}', $this->_html, $html);\r
- // add a validation script\r
- $this->_script = strval($form->getValidationScript());\r
- # FIXME - deberia sacarlo del QuickForm\r
- #$this->_append = $form->getFormEnd();\r
- $this->_append = "\n</FORM>\n";\r
- } // end func finishForm\r
- \r
- /**\r
- * Called when visiting a header element\r
- *\r
- * @param object An HTML_QuickForm_header element being visited\r
- * @access public\r
- * @return void\r
- */\r
- function renderHeader(&$header)\r
- {\r
- $name = $header->getName();\r
- $this->_tabla->addRow(array($header->toHtml()), array('colspan' => 2, $name => true, 'align' => 'center'));\r
- } // end func renderHeader\r
-\r
- /**\r
- * Renders an element Html\r
- * Called when visiting an element\r
- *\r
- * @param object An HTML_QuickForm_element object being visited\r
- * @param bool Whether an element is required\r
- * @param string An error message associated with an element\r
- * @access public\r
- * @return void\r
- */\r
- function renderElement(&$element, $required, $error)\r
- {\r
- if (!$this->_inGroup) {\r
- if ($element->getLabel()) {\r
- $id = $this->_tabla->addRow(\r
- array(\r
- $element->getLabel() . ($required ? '<FONT color="red">*</FONT>' : ''),\r
- $element->toHtml(),\r
- )\r
- );\r
- $this->_tabla->updateCellAttributes($id, 0, array('titulo' => true, 'align' => 'left', 'nowrap' => true));\r
- $this->_tabla->updateCellAttributes($id, 1, array('align' => 'left'));\r
- } else {\r
- $id = $this->_tabla->addRow(\r
- array(\r
- $element->toHtml(),\r
- )\r
- );\r
- $this->_tabla->updateCellAttributes($id, 0, array('colspan' => 2, 'align' => 'center'));\r
- }\r
- } else {\r
- $this->_groupElements[] = $element->toHtml();\r
- }\r
- } // end func renderElement\r
- \r
- /**\r
- * Renders an hidden element\r
- * Called when visiting a hidden element\r
- * \r
- * @param object An HTML_QuickForm_hidden object being visited\r
- * @access public\r
- * @return void\r
- */\r
- function renderHidden(&$element)\r
- {\r
- $this->_prepend .= "\n\t". $element->toHtml();\r
- } // end func renderHidden\r
-\r
- /**\r
- * Called when visiting a raw HTML/text pseudo-element\r
- * \r
- * @param object An HTML_QuickForm_html element being visited\r
- * @access public\r
- * @return void\r
- */\r
- function renderHtml(&$data)\r
- {\r
- $this->_tabla->addRow(array($header->toHtml()), array('colspan' => 2));\r
- } // end func renderHtml\r
-\r
- /**\r
- * Called when visiting a group, before processing any group elements\r
- *\r
- * @param object An HTML_QuickForm_group object being visited\r
- * @param bool Whether a group is required\r
- * @param string An error message associated with a group\r
- * @access public\r
- * @return void\r
- */\r
- function startGroup(&$group, $required, $error)\r
- {\r
- $this->_groupElements = array();\r
- $this->_inGroup = true;\r
- } // end func startGroup\r
-\r
- /**\r
- * Called when visiting a group, after processing all group elements\r
- *\r
- * @param object An HTML_QuickForm_group object being visited\r
- * @access public\r
- * @return void\r
- */\r
- function finishGroup(&$group)\r
- {\r
- $id = $this->_tabla->addRow(array($group->getLabel(), join('', $this->_groupElements)));\r
- $this->_tabla->updateCellAttributes($id, 0, array('titulo' => true, 'align' => 'right', 'nowrap' => true));\r
- $this->_tabla->updateCellAttributes($id, 1, array('align' => 'left'));\r
-/* if (!empty($this->_groupWrap)) {\r
- $html = str_replace('{content}', implode('', $this->_groupElements), $this->_groupWrap);\r
- } else {\r
- $separator = $group->_separator;\r
- if (is_array($separator)) {\r
- $count = count($separator);\r
- $html = '';\r
- for ($i = 0; $i < count($this->_groupElements); $i++) {\r
- $html .= $this->_groupElements[$i] . $separator[$i % $count];\r
- }\r
- $html = substr($html, 0, -strlen($separator[($i - 1) % $count]));\r
- } else {\r
- if (is_null($separator)) {\r
- $separator = ' ';\r
- }\r
- $html = implode((string)$separator, $this->_groupElements);\r
- }\r
- }\r
- $this->_html .= str_replace('{element}', $html, $this->_groupTemplate);\r
- $this->_inGroup = false;*/\r
- } // end func finishGroup\r
-\r
-} // end class HTML_QuickForm_Renderer_Default\r
-\r
-?>\r
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4: */
+// +----------------------------------------------------------------------+
+// | PHP version 4.0 |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2003 The PHP Group |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.0 of the PHP license, |
+// | that is bundled with this package in the file LICENSE, and is |
+// | available at through the world-wide-web at |
+// | http://www.php.net/license/2_02.txt. |
+// | If you did not receive a copy of the PHP license and are unable to |
+// | obtain it through the world-wide-web, please send a note to |
+// | license@php.net so we can mail you a copy immediately. |
+// +----------------------------------------------------------------------+
+// | Authors: Alexey Borzov <borz_off@cs.msu.su> |
+// | Adam Daniel <adaniel1@eesus.jnj.com> |
+// | Bertrand Mansion <bmansion@mamasam.com> |
+// +----------------------------------------------------------------------+
+//
+// $Id$
+
+require_once 'HTML/QuickForm/Renderer.php';
+require_once 'HTML/Tabla.php';
+
+/**
+ * A concrete renderer for HTML_QuickForm,
+ * based on QuickForm 2.x built-in one
+ *
+ * @access public
+ */
+class 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 HTML_QuickForm_Renderer_Tabla($style = 'width="400"')
+ {
+ $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', 'cabecera' => true)
+ );
+ //$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' => '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 ? '<FONT color="red">*</FONT>' : ''),
+ $element->toHtml() . ($error ? "<BR><FONT color=\"red\">$error</FONT>" : ''),
+ )
+ );
+ $this->_tabla->updateCellAttributes($id, 0, array('titulo' => true, 'align' => 'left', 'nowrap' => true));
+ $this->_tabla->updateCellAttributes($id, 1, array('align' => 'left'));
+ } 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('align' => 'right', 'colspan' => 2));
+ } else {
+ $id = $this->_tabla->addRow(
+ array($group->getLabel(), join($sep, $this->_groupElements)),
+ array('align' => 'left')
+ );
+ $this->_tabla->updateCellAttributes($id, 0, array('titulo' => true, 'align' => 'left', 'nowrap' => true));
+ }
+ } // end func finishGroup
+
+} // end class HTML_QuickForm_Renderer_Default
+
+?>