|
@@ -1,52 +1,52 @@
|
|
|
<?php
|
|
|
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
|
|
-
|
|
|
-/**
|
|
|
- * Hierarchical select element
|
|
|
- *
|
|
|
- * PHP versions 4 and 5
|
|
|
- *
|
|
|
- * LICENSE: This source file is subject to version 3.01 of the PHP license
|
|
|
- * that is available through the world-wide-web at the following URI:
|
|
|
- * http://www.php.net/license/3_01.txt If you did not receive a copy of
|
|
|
- * the PHP License and are unable to obtain it through the web, please
|
|
|
- * send a note to license@php.net so we can mail you a copy immediately.
|
|
|
- *
|
|
|
- * @category HTML
|
|
|
- * @package HTML_QuickForm
|
|
|
- * @author Herim Vasquez <vasquezh@iro.umontreal.ca>
|
|
|
- * @author Bertrand Mansion <bmansion@mamasam.com>
|
|
|
- * @author Alexey Borzov <avb@php.net>
|
|
|
- * @copyright 2001-2009 The PHP Group
|
|
|
- * @license http://www.php.net/license/3_01.txt PHP License 3.01
|
|
|
- * @version CVS: $Id: hierselect.php,v 1.20 2009/04/04 21:34:03 avb Exp $
|
|
|
- * @link http://pear.php.net/package/HTML_QuickForm
|
|
|
- */
|
|
|
-
|
|
|
-/**
|
|
|
- * Class for a group of form elements
|
|
|
- */
|
|
|
-require_once 'HTML/QuickForm/group.php';
|
|
|
-/**
|
|
|
- * Class for <select></select> elements
|
|
|
- */
|
|
|
-require_once 'HTML/QuickForm/select.php';
|
|
|
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
|
|
|
|
|
/**
|
|
|
- * Hierarchical select element
|
|
|
- *
|
|
|
+ * Hierarchical select element
|
|
|
+ *
|
|
|
+ * PHP versions 4 and 5
|
|
|
+ *
|
|
|
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
|
|
|
+ * that is available through the world-wide-web at the following URI:
|
|
|
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
|
|
|
+ * the PHP License and are unable to obtain it through the web, please
|
|
|
+ * send a note to license@php.net so we can mail you a copy immediately.
|
|
|
+ *
|
|
|
+ * @category HTML
|
|
|
+ * @package HTML_QuickForm
|
|
|
+ * @author Herim Vasquez <vasquezh@iro.umontreal.ca>
|
|
|
+ * @author Bertrand Mansion <bmansion@mamasam.com>
|
|
|
+ * @author Alexey Borzov <avb@php.net>
|
|
|
+ * @copyright 2001-2009 The PHP Group
|
|
|
+ * @license http://www.php.net/license/3_01.txt PHP License 3.01
|
|
|
+ * @version CVS: $Id: hierselect.php,v 1.20 2009/04/04 21:34:03 avb Exp $
|
|
|
+ * @link http://pear.php.net/package/HTML_QuickForm
|
|
|
+ */
|
|
|
+
|
|
|
+/**
|
|
|
+ * Class for a group of form elements
|
|
|
+ */
|
|
|
+//require_once 'HTML/QuickForm/group.php';
|
|
|
+/**
|
|
|
+ * Class for <select></select> elements
|
|
|
+ */
|
|
|
+//require_once 'HTML/QuickForm/select.php';
|
|
|
+
|
|
|
+/**
|
|
|
+ * Hierarchical select element
|
|
|
+ *
|
|
|
* Class to dynamically create two or more HTML Select elements
|
|
|
* The first select changes the content of the second select and so on.
|
|
|
* This element is considered as a group. Selects will be named
|
|
|
* groupName[0], groupName[1], groupName[2]...
|
|
|
*
|
|
|
- * @category HTML
|
|
|
- * @package HTML_QuickForm
|
|
|
- * @author Herim Vasquez <vasquezh@iro.umontreal.ca>
|
|
|
- * @author Bertrand Mansion <bmansion@mamasam.com>
|
|
|
- * @author Alexey Borzov <avb@php.net>
|
|
|
- * @version Release: 3.2.11
|
|
|
- * @since 3.1
|
|
|
+ * @category HTML
|
|
|
+ * @package HTML_QuickForm
|
|
|
+ * @author Herim Vasquez <vasquezh@iro.umontreal.ca>
|
|
|
+ * @author Bertrand Mansion <bmansion@mamasam.com>
|
|
|
+ * @author Alexey Borzov <avb@php.net>
|
|
|
+ * @version Release: 3.2.11
|
|
|
+ * @since 3.1
|
|
|
*/
|
|
|
class HTML_QuickForm_hierselect extends HTML_QuickForm_group
|
|
|
{
|
|
@@ -55,7 +55,7 @@ class HTML_QuickForm_hierselect extends HTML_QuickForm_group
|
|
|
/**
|
|
|
* Options for all the select elements
|
|
|
*
|
|
|
- * @see setOptions()
|
|
|
+ * @see setOptions()
|
|
|
* @var array
|
|
|
* @access private
|
|
|
*/
|
|
@@ -110,45 +110,45 @@ class HTML_QuickForm_hierselect extends HTML_QuickForm_group
|
|
|
* Initialize the array structure containing the options for each select element.
|
|
|
* Call the functions that actually do the magic.
|
|
|
*
|
|
|
- * Format is a bit more complex than for a simple select as we need to know
|
|
|
- * which options are related to the ones in the previous select:
|
|
|
- *
|
|
|
- * Ex:
|
|
|
- * <code>
|
|
|
- * // first select
|
|
|
- * $select1[0] = 'Pop';
|
|
|
- * $select1[1] = 'Classical';
|
|
|
- * $select1[2] = 'Funeral doom';
|
|
|
- *
|
|
|
- * // second select
|
|
|
- * $select2[0][0] = 'Red Hot Chil Peppers';
|
|
|
- * $select2[0][1] = 'The Pixies';
|
|
|
- * $select2[1][0] = 'Wagner';
|
|
|
- * $select2[1][1] = 'Strauss';
|
|
|
- * $select2[2][0] = 'Pantheist';
|
|
|
- * $select2[2][1] = 'Skepticism';
|
|
|
- *
|
|
|
- * // If only need two selects
|
|
|
- * // - and using the deprecated functions
|
|
|
- * $sel =& $form->addElement('hierselect', 'cds', 'Choose CD:');
|
|
|
- * $sel->setMainOptions($select1);
|
|
|
- * $sel->setSecOptions($select2);
|
|
|
- *
|
|
|
- * // - and using the new setOptions function
|
|
|
- * $sel =& $form->addElement('hierselect', 'cds', 'Choose CD:');
|
|
|
- * $sel->setOptions(array($select1, $select2));
|
|
|
- *
|
|
|
- * // If you have a third select with prices for the cds
|
|
|
- * $select3[0][0][0] = '15.00$';
|
|
|
- * $select3[0][0][1] = '17.00$';
|
|
|
- * // etc
|
|
|
- *
|
|
|
- * // You can now use
|
|
|
- * $sel =& $form->addElement('hierselect', 'cds', 'Choose CD:');
|
|
|
- * $sel->setOptions(array($select1, $select2, $select3));
|
|
|
- * </code>
|
|
|
+ * Format is a bit more complex than for a simple select as we need to know
|
|
|
+ * which options are related to the ones in the previous select:
|
|
|
+ *
|
|
|
+ * Ex:
|
|
|
+ * <code>
|
|
|
+ * // first select
|
|
|
+ * $select1[0] = 'Pop';
|
|
|
+ * $select1[1] = 'Classical';
|
|
|
+ * $select1[2] = 'Funeral doom';
|
|
|
+ *
|
|
|
+ * // second select
|
|
|
+ * $select2[0][0] = 'Red Hot Chil Peppers';
|
|
|
+ * $select2[0][1] = 'The Pixies';
|
|
|
+ * $select2[1][0] = 'Wagner';
|
|
|
+ * $select2[1][1] = 'Strauss';
|
|
|
+ * $select2[2][0] = 'Pantheist';
|
|
|
+ * $select2[2][1] = 'Skepticism';
|
|
|
+ *
|
|
|
+ * // If only need two selects
|
|
|
+ * // - and using the deprecated functions
|
|
|
+ * $sel =& $form->addElement('hierselect', 'cds', 'Choose CD:');
|
|
|
+ * $sel->setMainOptions($select1);
|
|
|
+ * $sel->setSecOptions($select2);
|
|
|
*
|
|
|
- * @param array $options Array of options defining each element
|
|
|
+ * // - and using the new setOptions function
|
|
|
+ * $sel =& $form->addElement('hierselect', 'cds', 'Choose CD:');
|
|
|
+ * $sel->setOptions(array($select1, $select2));
|
|
|
+ *
|
|
|
+ * // If you have a third select with prices for the cds
|
|
|
+ * $select3[0][0][0] = '15.00$';
|
|
|
+ * $select3[0][0][1] = '17.00$';
|
|
|
+ * // etc
|
|
|
+ *
|
|
|
+ * // You can now use
|
|
|
+ * $sel =& $form->addElement('hierselect', 'cds', 'Choose CD:');
|
|
|
+ * $sel->setOptions(array($select1, $select2, $select3));
|
|
|
+ * </code>
|
|
|
+ *
|
|
|
+ * @param array $options Array of options defining each element
|
|
|
* @access public
|
|
|
* @return void
|
|
|
*/
|
|
@@ -313,9 +313,9 @@ class HTML_QuickForm_hierselect extends HTML_QuickForm_group
|
|
|
$this->_js .= <<<JAVASCRIPT
|
|
|
function _hs_findOptions(ary, keys)
|
|
|
{
|
|
|
- if (ary == undefined) {
|
|
|
- return {};
|
|
|
- }
|
|
|
+ if (ary == undefined) {
|
|
|
+ return {};
|
|
|
+ }
|
|
|
var key = keys.shift();
|
|
|
if (!key in ary) {
|
|
|
return {};
|
|
@@ -461,7 +461,6 @@ JAVASCRIPT;
|
|
|
$this->_js .= "_hs_defaults['" . $this->_escapeString($this->getName()) . "'] = " .
|
|
|
$this->_convertArrayToJavascript($values, false) . ";\n";
|
|
|
}
|
|
|
- include_once('HTML/QuickForm/Renderer/Default.php');
|
|
|
$renderer =& new HTML_QuickForm_Renderer_Default();
|
|
|
$renderer->setElementTemplate('{element}');
|
|
|
parent::accept($renderer);
|
|
@@ -593,4 +592,4 @@ JAVASCRIPT;
|
|
|
|
|
|
// }}}
|
|
|
} // end class HTML_QuickForm_hierselect
|
|
|
-?>
|
|
|
+?>
|