Last active
July 22, 2018 05:16
-
-
Save seamuslee001/0674a976c4526d2e8abf8a066546a489 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/HTML/QuickForm/Renderer/Array.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Renderer/Array.php | |
index f2e51ce..eaa325f 100644 | |
--- a/HTML/QuickForm/Renderer/Array.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Renderer/Array.php | |
@@ -168,9 +168,9 @@ class HTML_QuickForm_Renderer_Array extends HTML_QuickForm_Renderer | |
* @param bool true: render an array of labels to many labels, $key 0 to 'label' and the oterh to "label_$key" | |
* @access public | |
*/ | |
- function __construct($collectHidden = false, $staticLabels = false) | |
+ function HTML_QuickForm_Renderer_Array($collectHidden = false, $staticLabels = false) | |
{ | |
- parent::__construct(); | |
+ $this->HTML_QuickForm_Renderer(); | |
$this->_collectHidden = $collectHidden; | |
$this->_staticLabels = $staticLabels; | |
} // end constructor | |
@@ -226,16 +226,12 @@ class HTML_QuickForm_Renderer_Array extends HTML_QuickForm_Renderer | |
} // end func renderElement | |
- function renderHidden(&$element, $required = FALSE, $error = FALSE) | |
+ function renderHidden(&$element) | |
{ | |
if ($this->_collectHidden) { | |
- // add to error array | |
- if (!empty($error)) { | |
- $this->_ary['errors']['hidden'] = $error; | |
- } | |
$this->_ary['hidden'] .= $element->toHtml() . "\n"; | |
} else { | |
- $this->renderElement($element, $required, $error); | |
+ $this->renderElement($element, false, null); | |
} | |
} // end func renderHidden | |
@@ -275,12 +271,6 @@ class HTML_QuickForm_Renderer_Array extends HTML_QuickForm_Renderer | |
'required' => $required, | |
'error' => $error | |
); | |
- | |
- $id = $element->getAttribute('id'); | |
- if ( $id ) { | |
- $ret['id'] = $id; | |
- } | |
- | |
// render label(s) | |
$labels = $element->getLabel(); | |
if (is_array($labels) && $this->_staticLabels) { | |
diff --git a/HTML/QuickForm/Renderer/ArraySmarty.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Renderer/ArraySmarty.php | |
index 2c3df6e..8a5de48 100644 | |
--- a/HTML/QuickForm/Renderer/ArraySmarty.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Renderer/ArraySmarty.php | |
@@ -136,9 +136,9 @@ class HTML_QuickForm_Renderer_ArraySmarty extends HTML_QuickForm_Renderer_Array | |
* @param bool true: collect all hidden elements into string; false: process them as usual form elements | |
* @access public | |
*/ | |
- function __construct(&$tpl, $staticLabels = false, $collectHidden = true) | |
+ function HTML_QuickForm_Renderer_ArraySmarty(&$tpl, $staticLabels = false, $collectHidden = true) | |
{ | |
- parent::__construct($collectHidden, $staticLabels); | |
+ $this->HTML_QuickForm_Renderer_Array($collectHidden, $staticLabels); | |
$this->_tpl =& $tpl; | |
} // end constructor | |
@@ -257,14 +257,15 @@ class HTML_QuickForm_Renderer_ArraySmarty extends HTML_QuickForm_Renderer_Array | |
function _storeArray($elAry) | |
{ | |
if ($elAry) { | |
- $keys = explode('][', substr(str_replace(["['", "']", '["', '"]'], ['[', ']', '[', ']'], $elAry['keys']), 1, -1)); | |
+ $sKeys = $elAry['keys']; | |
unset($elAry['keys']); | |
// where should we put this element... | |
if (is_array($this->_currentGroup) && ('group' != $elAry['type'])) { | |
- $this->_currentGroup = CRM_Utils_Array::recursiveBuild($keys, $elAry, $this->_currentGroup); | |
+ $toEval = '$this->_currentGroup' . $sKeys . ' = $elAry;'; | |
} else { | |
- $this->_ary = CRM_Utils_Array::recursiveBuild($keys, $elAry, $this->_ary); | |
+ $toEval = '$this->_ary' . $sKeys . ' = $elAry;'; | |
} | |
+ eval($toEval); | |
} | |
return; | |
} | |
diff --git a/HTML/QuickForm/Renderer/Default.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Renderer/Default.php | |
index 9690694..bc6415a 100644 | |
--- a/HTML/QuickForm/Renderer/Default.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Renderer/Default.php | |
@@ -152,9 +152,9 @@ class HTML_QuickForm_Renderer_Default extends HTML_QuickForm_Renderer | |
* | |
* @access public | |
*/ | |
- function __construct() | |
+ function HTML_QuickForm_Renderer_Default() | |
{ | |
- parent::__construct(); | |
+ $this->HTML_QuickForm_Renderer(); | |
} // end constructor | |
/** | |
@@ -291,10 +291,6 @@ class HTML_QuickForm_Renderer_Default extends HTML_QuickForm_Renderer | |
*/ | |
function renderElement(&$element, $required, $error) | |
{ | |
- // make sure that all elements are id'ed even in a group! | |
- | |
- CRM_Core_Form_Renderer::updateAttributes( $element, $required, $error ); | |
- | |
if (!$this->_inGroup) { | |
$html = $this->_prepareTemplate($element->getName(), $element->getLabel(), $required, $error); | |
$this->_html .= str_replace('{element}', $element->toHtml(), $html); | |
diff --git a/HTML/QuickForm/Renderer/ITDynamic.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Renderer/ITDynamic.php | |
index 097c7b8..12eec9e 100644 | |
--- a/HTML/QuickForm/Renderer/ITDynamic.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Renderer/ITDynamic.php | |
@@ -17,7 +17,7 @@ | |
* @author Alexey Borzov <avb@php.net> | |
* @copyright 2001-2011 The PHP Group | |
* @license http://www.php.net/license/3_01.txt PHP License 3.01 | |
- * @version CVS: $Id: ITDynamic.php,v 1.7 2009/04/04 21:34:04 avb Exp $ | |
+ * @version CVS: $Id$ | |
* @link http://pear.php.net/package/HTML_QuickForm | |
*/ | |
@@ -97,9 +97,9 @@ class HTML_QuickForm_Renderer_ITDynamic extends HTML_QuickForm_Renderer | |
* | |
* @param HTML_Template_ITX|HTML_Template_Sigma Template object to use | |
*/ | |
- function __construct(&$tpl) | |
+ function HTML_QuickForm_Renderer_ITDynamic(&$tpl) | |
{ | |
- parent::__construct(); | |
+ $this->HTML_QuickForm_Renderer(); | |
$this->_tpl =& $tpl; | |
$this->_tpl->setCurrentBlock('qf_main_loop'); | |
} | |
diff --git a/HTML/QuickForm/Renderer/ITStatic.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Renderer/ITStatic.php | |
index 4bd3475..571ca8d 100644 | |
--- a/HTML/QuickForm/Renderer/ITStatic.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Renderer/ITStatic.php | |
@@ -112,9 +112,9 @@ class HTML_QuickForm_Renderer_ITStatic extends HTML_QuickForm_Renderer | |
* | |
* @param HTML_Template_IT|HTML_Template_Sigma Template object to use | |
*/ | |
- function __construct(&$tpl) | |
+ function HTML_QuickForm_Renderer_ITStatic(&$tpl) | |
{ | |
- parent::__construct(); | |
+ $this->HTML_QuickForm_Renderer(); | |
$this->_tpl =& $tpl; | |
} // end constructor | |
diff --git a/HTML/QuickForm/Renderer/Object.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Renderer/Object.php | |
index f94205e..2c8e9c0 100644 | |
--- a/HTML/QuickForm/Renderer/Object.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Renderer/Object.php | |
@@ -92,9 +92,9 @@ class HTML_QuickForm_Renderer_Object extends HTML_QuickForm_Renderer | |
* @param bool true: collect all hidden elements | |
* @access public | |
*/ | |
- function __construct($collecthidden = false) | |
+ function HTML_QuickForm_Renderer_Object($collecthidden = false) | |
{ | |
- parent::__construct(); | |
+ $this->HTML_QuickForm_Renderer(); | |
$this->_collectHidden = $collecthidden; | |
$this->_obj = new QuickformForm; | |
} | |
@@ -270,7 +270,7 @@ class HTML_QuickForm_Renderer_Object extends HTML_QuickForm_Renderer | |
* @category HTML | |
* @package HTML_QuickForm | |
* @author Ron McClain <ron@humaniq.com> | |
- * @version Release: 3.2.11 | |
+ * @version Release: 3.2.15 | |
* @since 3.1.1 | |
*/ | |
class QuickformForm | |
@@ -359,7 +359,7 @@ class QuickformForm | |
* @category HTML | |
* @package HTML_QuickForm | |
* @author Ron McClain <ron@humaniq.com> | |
- * @version Release: 3.2.11 | |
+ * @version Release: 3.2.15 | |
* @since 3.1.1 | |
*/ | |
class QuickformElement | |
diff --git a/HTML/QuickForm/Renderer/ObjectFlexy.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Renderer/ObjectFlexy.php | |
index da3d6a7..d2989df 100644 | |
--- a/HTML/QuickForm/Renderer/ObjectFlexy.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Renderer/ObjectFlexy.php | |
@@ -104,9 +104,9 @@ class HTML_QuickForm_Renderer_ObjectFlexy extends HTML_QuickForm_Renderer_Object | |
* @param HTML_Template_Flexy template object to use | |
* @public | |
*/ | |
- function __construct(&$flexy) | |
+ function HTML_QuickForm_Renderer_ObjectFlexy(&$flexy) | |
{ | |
- parent::__construct(true); | |
+ $this->HTML_QuickForm_Renderer_Object(true); | |
$this->_obj = new QuickformFlexyForm(); | |
$this->_flexy =& $flexy; | |
} // end constructor | |
diff --git a/HTML/QuickForm/Renderer/QuickHtml.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Renderer/QuickHtml.php | |
index e5fe1b9..aeed0e5 100644 | |
--- a/HTML/QuickForm/Renderer/QuickHtml.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Renderer/QuickHtml.php | |
@@ -59,9 +59,9 @@ class HTML_QuickForm_Renderer_QuickHtml extends HTML_QuickForm_Renderer_Default | |
* @access public | |
* @return void | |
*/ | |
- function __construct() | |
+ function HTML_QuickForm_Renderer_QuickHtml() | |
{ | |
- parent::__construct(); | |
+ $this->HTML_QuickForm_Renderer_Default(); | |
// The default templates aren't used for this renderer | |
$this->clearAllTemplates(); | |
} // end constructor | |
diff --git a/HTML/QuickForm/Renderer.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Renderer.php | |
index e8064c4..dc490e3 100644 | |
--- a/HTML/QuickForm/Renderer.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Renderer.php | |
@@ -15,7 +15,7 @@ | |
* @category HTML | |
* @package HTML_QuickForm | |
* @author Alexey Borzov <avb@php.net> | |
- * @copyright 2001-2009 The PHP Group | |
+ * @copyright 2001-2011 The PHP Group | |
* @license http://www.php.net/license/3_01.txt PHP License 3.01 | |
* @version CVS: $Id$ | |
* @link http://pear.php.net/package/HTML_QuickForm | |
@@ -40,7 +40,7 @@ class HTML_QuickForm_Renderer | |
* | |
* @access public | |
*/ | |
- function __construct() | |
+ function HTML_QuickForm_Renderer() | |
{ | |
} // end constructor | |
diff --git a/HTML/QuickForm/Rule/Compare.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Rule/Compare.php | |
index d97ab7a..ede60d1 100644 | |
--- a/HTML/QuickForm/Rule/Compare.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Rule/Compare.php | |
@@ -17,7 +17,7 @@ | |
* @author Alexey Borzov <avb@php.net> | |
* @copyright 2001-2011 The PHP Group | |
* @license http://www.php.net/license/3_01.txt PHP License 3.01 | |
- * @version CVS: $Id$ Compare.php,v 1.7 2009/04/04 21:34:04 avb Exp $ | |
+ * @version CVS: $Id$ | |
* @link http://pear.php.net/package/HTML_QuickForm | |
*/ | |
diff --git a/HTML/QuickForm/Rule/Email.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Rule/Email.php | |
index b99fa76..4cac578 100644 | |
--- a/HTML/QuickForm/Rule/Email.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Rule/Email.php | |
@@ -37,9 +37,7 @@ require_once 'HTML/QuickForm/Rule.php'; | |
*/ | |
class HTML_QuickForm_Rule_Email extends HTML_QuickForm_Rule | |
{ | |
- // switching to a better regex as per CRM-40 | |
- // var $regex = '/^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/'; | |
- var $regex = '/^([a-zA-Z0-9&_?\/`!|#*$^%=~{}+\'-]+|"([\x00-\x0C\x0E-\x21\x23-\x5B\x5D-\x7F]|\\[\x00-\x7F])*")(\.([a-zA-Z0-9&_?\/`!|#*$^%=~{}+\'-]+|"([\x00-\x0C\x0E-\x21\x23-\x5B\x5D-\x7F]|\\[\x00-\x7F])*"))*@([a-zA-Z0-9&_?\/`!|#*$^%=~{}+\'-]+|\[([\x00-\x0C\x0E-\x5A\x5E-\x7F]|\\[\x00-\x7F])*\])(\.([a-zA-Z0-9&_?\/`!|#*$^%=~{}+\'-]+|\[([\x00-\x0C\x0E-\x5A\x5E-\x7F]|\\[\x00-\x7F])*\]))*$/'; | |
+ var $regex = '/^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/'; | |
/** | |
* Validates an email address | |
@@ -51,17 +49,6 @@ class HTML_QuickForm_Rule_Email extends HTML_QuickForm_Rule | |
*/ | |
function validate($email, $checkDomain = false) | |
{ | |
- if (function_exists('idn_to_ascii')) { | |
- if ($parts = explode('@', $email)) { | |
- if (sizeof($parts) == 2) { | |
- foreach ($parts as &$part) { | |
- $part = idn_to_ascii($part); | |
- } | |
- $email = implode('@', $parts); | |
- } | |
- } | |
- } | |
- | |
// Fix for bug #10799: add 'D' modifier to regex | |
if (preg_match($this->regex . 'D', $email)) { | |
if ($checkDomain && function_exists('checkdnsrr')) { | |
diff --git a/HTML/QuickForm/Rule/Range.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Rule/Range.php | |
index 2c9fccc..d5807b0 100644 | |
--- a/HTML/QuickForm/Rule/Range.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Rule/Range.php | |
@@ -45,7 +45,7 @@ class HTML_QuickForm_Rule_Range extends HTML_QuickForm_Rule | |
* @access public | |
* @return boolean true if value is valid | |
*/ | |
- function validate($value, $options) | |
+ function validate($value, $options = null) | |
{ | |
$length = strlen($value); | |
switch ($this->name) { | |
diff --git a/HTML/QuickForm/Rule/Required.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Rule/Required.php | |
index f3fc0cb..919db2a 100644 | |
--- a/HTML/QuickForm/Rule/Required.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/Rule/Required.php | |
@@ -48,28 +48,7 @@ class HTML_QuickForm_Rule_Required extends HTML_QuickForm_Rule | |
function validate($value, $options = null) | |
{ | |
if (is_array($value)) { | |
- // check if file type, if so permit empty type | |
- $fileType = | |
- array_key_exists( 'name', $value ) && | |
- array_key_exists( 'tmp_name', $value ); | |
- // hack to fix required issue with advcheckbox, but in general if any value is present then | |
- // it should pass required check | |
- $return = false; | |
- foreach ( $value as $k => $v ) { | |
- // dont check type field. Safari3 Beta does not set this | |
- if ( $fileType && $k == 'type' ) { | |
- continue; | |
- } | |
- if ( is_array($v) ) { | |
- if ( $v ) { | |
- $return = true; | |
- } | |
- } | |
- elseif ( ( string ) $v != '' ) { | |
- $return = true; | |
- } | |
- } | |
- return $return; | |
+ return (bool) $value; | |
} else if ((string)$value == '') { | |
return false; | |
} | |
diff --git a/HTML/QuickForm/RuleRegistry.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/RuleRegistry.php | |
index 28cda03..b1e9c9e 100644 | |
--- a/HTML/QuickForm/RuleRegistry.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/RuleRegistry.php | |
@@ -54,7 +54,7 @@ class HTML_QuickForm_RuleRegistry | |
* @static | |
* @return HTML_QuickForm_RuleRegistry | |
*/ | |
- static function &singleton() | |
+ function &singleton() | |
{ | |
static $obj; | |
if (!isset($obj)) { | |
@@ -125,7 +125,7 @@ class HTML_QuickForm_RuleRegistry | |
if (!empty($path)) { | |
include_once($path); | |
} | |
- $this->_rules[$class] = new $class(); | |
+ $this->_rules[$class] =& new $class(); | |
} | |
$this->_rules[$class]->setName($ruleName); | |
return $this->_rules[$class]; | |
diff --git a/HTML/QuickForm/advcheckbox.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/advcheckbox.php | |
index 3625f63..78d8618 100644 | |
--- a/HTML/QuickForm/advcheckbox.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/advcheckbox.php | |
@@ -86,9 +86,9 @@ class HTML_QuickForm_advcheckbox extends HTML_QuickForm_checkbox | |
* @access public | |
* @return void | |
*/ | |
- function __construct($elementName=null, $elementLabel=null, $text=null, $attributes=null, $values=null) | |
+ function HTML_QuickForm_advcheckbox($elementName=null, $elementLabel=null, $text=null, $attributes=null, $values=null) | |
{ | |
- parent::__construct($elementName, $elementLabel, $text, $attributes); | |
+ $this->HTML_QuickForm_checkbox($elementName, $elementLabel, $text, $attributes); | |
$this->setValues($values); | |
} //end constructor | |
diff --git a/HTML/QuickForm/autocomplete.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/autocomplete.php | |
index e33ef3a..21481ba 100644 | |
--- a/HTML/QuickForm/autocomplete.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/autocomplete.php | |
@@ -84,9 +84,9 @@ class HTML_QuickForm_autocomplete extends HTML_QuickForm_text | |
* @access public | |
* @return void | |
*/ | |
- function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null) | |
+ function HTML_QuickForm_autocomplete($elementName = null, $elementLabel = null, $options = null, $attributes = null) | |
{ | |
- parent::__construct($elementName, $elementLabel, $attributes); | |
+ $this->HTML_QuickForm_text($elementName, $elementLabel, $attributes); | |
$this->_persistantFreeze = true; | |
$this->_type = 'autocomplete'; | |
if (isset($options)) { | |
@@ -124,7 +124,7 @@ class HTML_QuickForm_autocomplete extends HTML_QuickForm_text | |
$arrayName = str_replace(array('[', ']'), array('__', ''), $this->getName()) . '_values'; | |
$this->updateAttributes(array( | |
- 'onkeypress' => 'return autocomplete(this, event, ' . $arrayName . ');' | |
+ 'onkeypress' => 'return window.autocomplete(this, event, ' . $arrayName . ');' | |
)); | |
if ($this->_flagFrozen) { | |
$js = ''; | |
diff --git a/HTML/QuickForm/button.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/button.php | |
index 04be552..88c0ec1 100644 | |
--- a/HTML/QuickForm/button.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/button.php | |
@@ -52,9 +52,9 @@ class HTML_QuickForm_button extends HTML_QuickForm_input | |
* @access public | |
* @return void | |
*/ | |
- function __construct($elementName=null, $value=null, $attributes=null) | |
+ function HTML_QuickForm_button($elementName=null, $value=null, $attributes=null) | |
{ | |
- parent::__construct($elementName, null, $attributes); | |
+ HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes); | |
$this->_persistantFreeze = false; | |
$this->setValue($value); | |
$this->setType('button'); | |
diff --git a/HTML/QuickForm/checkbox.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/checkbox.php | |
index 11d8a6c..9b9a806 100644 | |
--- a/HTML/QuickForm/checkbox.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/checkbox.php | |
@@ -66,19 +66,9 @@ class HTML_QuickForm_checkbox extends HTML_QuickForm_input | |
* @access public | |
* @return void | |
*/ | |
- function __construct($elementName=null, $elementLabel=null, $text='', $attributes=null) | |
+ function HTML_QuickForm_checkbox($elementName=null, $elementLabel=null, $text='', $attributes=null) | |
{ | |
- //hack to add 'id' for checkbox | |
- if ( !$attributes ) { | |
- $attributes = array( 'id' => $elementName ); | |
- } else { | |
- // set element id only if its not set | |
- if ( !isset( $attributes['id'] ) ) { | |
- $attributes['id'] = $elementName; | |
- } | |
- } | |
- | |
- parent::__construct($elementName, $elementLabel, $attributes); | |
+ HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes); | |
$this->_persistantFreeze = true; | |
$this->_text = $text; | |
$this->setType('checkbox'); | |
@@ -133,17 +123,13 @@ class HTML_QuickForm_checkbox extends HTML_QuickForm_input | |
*/ | |
function toHtml() | |
{ | |
- $attributes = $this->getAttributes(); | |
- | |
if (0 == strlen($this->_text)) { | |
$label = ''; | |
- } elseif ($this->_flagFrozen || isset( $attributes['skiplabel']) ) { | |
+ } elseif ($this->_flagFrozen) { | |
$label = $this->_text; | |
} else { | |
$label = '<label for="' . $this->getAttribute('id') . '">' . $this->_text . '</label>'; | |
} | |
- | |
- unset( $attributes['skipLabel'] ); | |
return HTML_QuickForm_input::toHtml() . $label; | |
} //end func toHtml | |
diff --git a/HTML/QuickForm/date.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/date.php | |
index 2494e88..cf74ef0 100644 | |
--- a/HTML/QuickForm/date.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/date.php | |
@@ -53,9 +53,10 @@ class HTML_QuickForm_date extends HTML_QuickForm_group | |
* @var array | |
*/ | |
var $_options = array( | |
+ 'language' => 'en', | |
'format' => 'dMY', | |
'minYear' => 2001, | |
- 'maxYear' => 2012, | |
+ 'maxYear' => null, // set in the constructor | |
'addEmptyOption' => false, | |
'emptyOptionValue' => '', | |
'emptyOptionText' => ' ', | |
@@ -70,12 +71,184 @@ class HTML_QuickForm_date extends HTML_QuickForm_group | |
var $_wrap = array('', ''); | |
/** | |
- * Locale array build from CRM_Utils_Date-provided names | |
+ * Options in different languages | |
+ * | |
+ * Note to potential translators: to avoid encoding problems please send | |
+ * your translations with "weird" letters encoded as HTML Unicode entities | |
* | |
* @access private | |
* @var array | |
*/ | |
- var $_locale = array(); | |
+ var $_locale = array( | |
+ 'en' => array ( | |
+ 'weekdays_short'=> array ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'), | |
+ 'weekdays_long' => array ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'), | |
+ 'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), | |
+ 'months_long' => array ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December') | |
+ ), | |
+ 'de' => array ( | |
+ 'weekdays_short'=> array ('So', 'Mon', 'Di', 'Mi', 'Do', 'Fr', 'Sa'), | |
+ 'weekdays_long' => array ('Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'), | |
+ 'months_short' => array ('Jan', 'Feb', 'März', 'April', 'Mai', 'Juni', 'Juli', 'Aug', 'Sept', 'Okt', 'Nov', 'Dez'), | |
+ 'months_long' => array ('Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember') | |
+ ), | |
+ 'fr' => array ( | |
+ 'weekdays_short'=> array ('Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'), | |
+ 'weekdays_long' => array ('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'), | |
+ 'months_short' => array ('Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Juin', 'Juil', 'Août', 'Sep', 'Oct', 'Nov', 'Déc'), | |
+ 'months_long' => array ('Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre') | |
+ ), | |
+ 'hu' => array ( | |
+ 'weekdays_short'=> array ('V', 'H', 'K', 'Sze', 'Cs', 'P', 'Szo'), | |
+ 'weekdays_long' => array ('vasárnap', 'hétfő', 'kedd', 'szerda', 'csütörtök', 'péntek', 'szombat'), | |
+ 'months_short' => array ('jan', 'feb', 'márc', 'ápr', 'máj', 'jún', 'júl', 'aug', 'szept', 'okt', 'nov', 'dec'), | |
+ 'months_long' => array ('január', 'február', 'március', 'április', 'május', 'június', 'július', 'augusztus', 'szeptember', 'október', 'november', 'december') | |
+ ), | |
+ 'pl' => array ( | |
+ 'weekdays_short'=> array ('Nie', 'Pn', 'Wt', 'Śr', 'Czw', 'Pt', 'Sob'), | |
+ 'weekdays_long' => array ('Niedziela', 'Poniedziałek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek', 'Sobota'), | |
+ 'months_short' => array ('Sty', 'Lut', 'Mar', 'Kwi', 'Maj', 'Cze', 'Lip', 'Sie', 'Wrz', 'Paź', 'Lis', 'Gru'), | |
+ 'months_long' => array ('Styczeń', 'Luty', 'Marzec', 'Kwiecień', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpień', 'Wrzesień', 'Październik', 'Listopad', 'Grudzień') | |
+ ), | |
+ 'sl' => array ( | |
+ 'weekdays_short'=> array ('Ned', 'Pon', 'Tor', 'Sre', 'Cet', 'Pet', 'Sob'), | |
+ 'weekdays_long' => array ('Nedelja', 'Ponedeljek', 'Torek', 'Sreda', 'Cetrtek', 'Petek', 'Sobota'), | |
+ 'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Avg', 'Sep', 'Okt', 'Nov', 'Dec'), | |
+ 'months_long' => array ('Januar', 'Februar', 'Marec', 'April', 'Maj', 'Junij', 'Julij', 'Avgust', 'September', 'Oktober', 'November', 'December') | |
+ ), | |
+ 'ru' => array ( | |
+ 'weekdays_short'=> array ('Вс', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб'), | |
+ 'weekdays_long' => array ('Воскресенье', 'Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота'), | |
+ 'months_short' => array ('Янв', 'Фев', 'Мар', 'Апр', 'Май', 'Июн', 'Июл', 'Авг', 'Сен', 'Окт', 'Ноя', 'Дек'), | |
+ 'months_long' => array ('Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь') | |
+ ), | |
+ 'es' => array ( | |
+ 'weekdays_short'=> array ('Dom', 'Lun', 'Mar', 'Mié', 'Jue', 'Vie', 'Sáb'), | |
+ 'weekdays_long' => array ('Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'), | |
+ 'months_short' => array ('Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'), | |
+ 'months_long' => array ('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre') | |
+ ), | |
+ 'da' => array ( | |
+ 'weekdays_short'=> array ('Søn', 'Man', 'Tir', 'Ons', 'Tor', 'Fre', 'Lør'), | |
+ 'weekdays_long' => array ('Søndag', 'Mandag', 'Tirsdag', 'Onsdag', 'Torsdag', 'Fredag', 'Lørdag'), | |
+ 'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'), | |
+ 'months_long' => array ('Januar', 'Februar', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December') | |
+ ), | |
+ 'is' => array ( | |
+ 'weekdays_short'=> array ('Sun', 'Mán', 'Þri', 'Mið', 'Fim', 'Fös', 'Lau'), | |
+ 'weekdays_long' => array ('Sunnudagur', 'Mánudagur', 'Þriðjudagur', 'Miðvikudagur', 'Fimmtudagur', 'Föstudagur', 'Laugardagur'), | |
+ 'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maí', 'Jún', 'Júl', 'Ágú', 'Sep', 'Okt', 'Nóv', 'Des'), | |
+ 'months_long' => array ('Janúar', 'Febrúar', 'Mars', 'Apríl', 'Maí', 'Júní', 'Júlí', 'Ágúst', 'September', 'Október', 'Nóvember', 'Desember') | |
+ ), | |
+ 'it' => array ( | |
+ 'weekdays_short'=> array ('Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab'), | |
+ 'weekdays_long' => array ('Domenica', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato'), | |
+ 'months_short' => array ('Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic'), | |
+ 'months_long' => array ('Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre') | |
+ ), | |
+ 'sk' => array ( | |
+ 'weekdays_short'=> array ('Ned', 'Pon', 'Uto', 'Str', 'Štv', 'Pia', 'Sob'), | |
+ 'weekdays_long' => array ('Nedeža', 'Pondelok', 'Utorok', 'Streda', 'Štvrtok', 'Piatok', 'Sobota'), | |
+ 'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Máj', 'Jún', 'Júl', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'), | |
+ 'months_long' => array ('Január', 'Február', 'Marec', 'Apríl', 'Máj', 'Jún', 'Júl', 'August', 'September', 'Október', 'November', 'December') | |
+ ), | |
+ 'cs' => array ( | |
+ 'weekdays_short'=> array ('Ne', 'Po', 'Út', 'St', 'Čt', 'Pá', 'So'), | |
+ 'weekdays_long' => array ('Neděle', 'Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota'), | |
+ 'months_short' => array ('Led', 'Úno', 'Bře', 'Dub', 'Kvě', 'Čen', 'Čec', 'Srp', 'Zář', 'Říj', 'Lis', 'Pro'), | |
+ 'months_long' => array ('Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec') | |
+ ), | |
+ 'hy' => array ( | |
+ 'weekdays_short'=> array ('Կրկ', 'Երկ', 'Երք', 'Չրք', 'Հնգ', 'Ուր', 'Շբթ'), | |
+ 'weekdays_long' => array ('Կիրակի', 'Երկուշաբթի', 'Երեքշաբթի', 'Չորեքշաբթի', 'Հինգշաբթի', 'Ուրբաթ', 'Շաբաթ'), | |
+ 'months_short' => array ('Հնվ', 'Փտր', 'Մրտ', 'Ապր', 'Մյս', 'Հնս', 'Հլս', 'Օգս', 'Սպտ', 'Հկտ', 'Նյմ', 'Դկտ'), | |
+ 'months_long' => array ('Հունվար', 'Փետրվար', 'Մարտ', 'Ապրիլ', 'Մայիս', 'Հունիս', 'Հուլիս', 'Օգոստոս', 'Սեպտեմբեր', 'Հոկտեմբեր', 'Նոյեմբեր', 'Դեկտեմբեր') | |
+ ), | |
+ 'nl' => array ( | |
+ 'weekdays_short'=> array ('Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za'), | |
+ 'weekdays_long' => array ('Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'), | |
+ 'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'), | |
+ 'months_long' => array ('Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni', 'Juli', 'Augustus', 'September', 'Oktober', 'November', 'December') | |
+ ), | |
+ 'et' => array ( | |
+ 'weekdays_short'=> array ('P', 'E', 'T', 'K', 'N', 'R', 'L'), | |
+ 'weekdays_long' => array ('Pühapäev', 'Esmaspäev', 'Teisipäev', 'Kolmapäev', 'Neljapäev', 'Reede', 'Laupäev'), | |
+ 'months_short' => array ('Jaan', 'Veebr', 'Märts', 'Aprill', 'Mai', 'Juuni', 'Juuli', 'Aug', 'Sept', 'Okt', 'Nov', 'Dets'), | |
+ 'months_long' => array ('Jaanuar', 'Veebruar', 'Märts', 'Aprill', 'Mai', 'Juuni', 'Juuli', 'August', 'September', 'Oktoober', 'November', 'Detsember') | |
+ ), | |
+ 'tr' => array ( | |
+ 'weekdays_short'=> array ('Paz', 'Pzt', 'Sal', 'Çar', 'Per', 'Cum', 'Cts'), | |
+ 'weekdays_long' => array ('Pazar', 'Pazartesi', 'Salı', 'Çarşamba', 'Perşembe', 'Cuma', 'Cumartesi'), | |
+ 'months_short' => array ('Ock', 'Şbt', 'Mrt', 'Nsn', 'Mys', 'Hzrn', 'Tmmz', 'Ağst', 'Eyl', 'Ekm', 'Ksm', 'Arlk'), | |
+ 'months_long' => array ('Ocak', 'Şubat', 'Mart', 'Nisan', 'Mayıs', 'Haziran', 'Temmuz', 'Ağustos', 'Eylül', 'Ekim', 'Kasım', 'Aralık') | |
+ ), | |
+ 'no' => array ( | |
+ 'weekdays_short'=> array ('Søn', 'Man', 'Tir', 'Ons', 'Tor', 'Fre', 'Lør'), | |
+ 'weekdays_long' => array ('Søndag', 'Mandag', 'Tirsdag', 'Onsdag', 'Torsdag', 'Fredag', 'Lørdag'), | |
+ 'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Des'), | |
+ 'months_long' => array ('Januar', 'Februar', 'Mars', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Desember') | |
+ ), | |
+ 'eo' => array ( | |
+ 'weekdays_short'=> array ('Dim', 'Lun', 'Mar', 'Mer', 'Ĵaŭ', 'Ven', 'Sab'), | |
+ 'weekdays_long' => array ('Dimanĉo', 'Lundo', 'Mardo', 'Merkredo', 'Ĵaŭdo', 'Vendredo', 'Sabato'), | |
+ 'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aŭg', 'Sep', 'Okt', 'Nov', 'Dec'), | |
+ 'months_long' => array ('Januaro', 'Februaro', 'Marto', 'Aprilo', 'Majo', 'Junio', 'Julio', 'Aŭgusto', 'Septembro', 'Oktobro', 'Novembro', 'Decembro') | |
+ ), | |
+ 'ua' => array ( | |
+ 'weekdays_short'=> array('Ндл', 'Пнд', 'Втр', 'Срд', 'Чтв', 'Птн', 'Сбт'), | |
+ 'weekdays_long' => array('Неділя', 'Понеділок', 'Вівторок', 'Середа', 'Четвер', 'П\'ятниця', 'Субота'), | |
+ 'months_short' => array('Січ', 'Лют', 'Бер', 'Кві', 'Тра', 'Чер', 'Лип', 'Сер', 'Вер', 'Жов', 'Лис', 'Гру'), | |
+ 'months_long' => array('Січень', 'Лютий', 'Березень', 'Квітень', 'Травень', 'Червень', 'Липень', 'Серпень', 'Вересень', 'Жовтень', 'Листопад', 'Грудень') | |
+ ), | |
+ 'ro' => array ( | |
+ 'weekdays_short'=> array ('Dum', 'Lun', 'Mar', 'Mie', 'Joi', 'Vin', 'Sam'), | |
+ 'weekdays_long' => array ('Duminica', 'Luni', 'Marti', 'Miercuri', 'Joi', 'Vineri', 'Sambata'), | |
+ 'months_short' => array ('Ian', 'Feb', 'Mar', 'Apr', 'Mai', 'Iun', 'Iul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), | |
+ 'months_long' => array ('Ianuarie', 'Februarie', 'Martie', 'Aprilie', 'Mai', 'Iunie', 'Iulie', 'August', 'Septembrie', 'Octombrie', 'Noiembrie', 'Decembrie') | |
+ ), | |
+ 'he' => array ( | |
+ 'weekdays_short'=> array ('ראשון', 'שני', 'שלישי', 'רביעי', 'חמישי', 'שישי', 'שבת'), | |
+ 'weekdays_long' => array ('יום ראשון', 'יום שני', 'יום שלישי', 'יום רביעי', 'יום חמישי', 'יום שישי', 'שבת'), | |
+ 'months_short' => array ('ינואר', 'פברואר', 'מרץ', 'אפריל', 'מאי', 'יוני', 'יולי', 'אוגוסט', 'ספטמבר', 'אוקטובר', 'נובמבר', 'דצמבר'), | |
+ 'months_long' => array ('ינואר', 'פברואר', 'מרץ', 'אפריל', 'מאי', 'יוני', 'יולי', 'אוגוסט', 'ספטמבר', 'אוקטובר', 'נובמבר', 'דצמבר') | |
+ ), | |
+ 'sv' => array ( | |
+ 'weekdays_short'=> array ('Sön', 'Mån', 'Tis', 'Ons', 'Tor', 'Fre', 'Lör'), | |
+ 'weekdays_long' => array ('Söndag', 'Måndag', 'Tisdag', 'Onsdag', 'Torsdag', 'Fredag', 'Lördag'), | |
+ 'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'), | |
+ 'months_long' => array ('Januari', 'Februari', 'Mars', 'April', 'Maj', 'Juni', 'Juli', 'Augusti', 'September', 'Oktober', 'November', 'December') | |
+ ), | |
+ 'pt' => array ( | |
+ 'weekdays_short'=> array ('Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'), | |
+ 'weekdays_long' => array ('Domingo', 'Segunda-feira', 'Terça-feira', 'Quarta-feira', 'Quinta-feira', 'Sexta-feira', 'Sábado'), | |
+ 'months_short' => array ('Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'), | |
+ 'months_long' => array ('Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro') | |
+ ), | |
+ 'tw' => array ( | |
+ 'weekdays_short'=> array ('週日','週一', '週二','週三', '週四','週五', '週六'), | |
+ 'weekdays_long' => array ('星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'), | |
+ 'months_short' => array ('一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'), | |
+ 'months_long' => array ('一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月') | |
+ ), | |
+ 'pt-br' => array ( | |
+ 'weekdays_short'=> array ('Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'), | |
+ 'weekdays_long' => array ('Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'), | |
+ 'months_short' => array ('Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'), | |
+ 'months_long' => array ('Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro') | |
+ ), | |
+ 'sr' => array ( | |
+ 'weekdays_short'=> array ('Нед', 'Пон', 'Уто', 'Сре', 'Чет', 'Пет', 'Суб'), | |
+ 'weekdays_long' => array ('Недеља', 'Понедељак', 'Уторак', 'Среда', 'Четвртак', 'Петак', 'Субота'), | |
+ 'months_short' => array ('Јан', 'Феб', 'Мар', 'Апр', 'Мај', 'Јун', 'Јул', 'Авг', 'Сеп', 'Окт', 'Нов', 'Дец'), | |
+ 'months_long' => array ('Јануар', 'Фебруар', 'Март', 'Април', 'Мај', 'Јун', 'Јул', 'Август', 'Септембар', 'Октобар', 'Новембар', 'Децембар') | |
+ ), | |
+ 'el' => array ( | |
+ 'weekdays_short'=> array ('Δευ', 'Τρί', 'Τετ', 'Πέμ', 'Παρ', 'Σάβ', 'Κυρ'), | |
+ 'weekdays_long' => array ('Δευτέρα', 'Τρίτη', 'Τετάρτη', 'Πέμπτη', 'Παρασκευή', 'Σάββατο', 'Κυριακή'), | |
+ 'months_short' => array ('Ιαν', 'Φεβ', 'Μάρ', 'Απρ', 'Μάϊ', 'Ioύν', 'Ιούλ', 'Αύγ', 'Σεπ', 'Οκτ', 'Νοέ', 'Δεκ'), | |
+ 'months_long' => array ('Ιανουάριος', 'Φεβρουάριος', 'Μάρτιος', 'Απρίλιος', 'Μάϊος', 'Ιούνιος', 'Ioύλιος', 'Αύγουστος', 'Σεπτέμβριος', 'Οκτώβριος', 'Νοέμβριος', 'Δεκέμβριος') | |
+ ) | |
+ ); | |
// }}} | |
// {{{ constructor | |
@@ -117,22 +290,22 @@ class HTML_QuickForm_date extends HTML_QuickForm_group | |
* @param array Options to control the element's display | |
* @param mixed Either a typical HTML attribute string or an associative array | |
*/ | |
- function __construct($elementName = null, $elementLabel = null, $options = array(), $attributes = null) | |
+ function HTML_QuickForm_date($elementName = null, $elementLabel = null, $options = array(), $attributes = null) | |
{ | |
- $this->_locale = array( | |
- 'weekdays_short'=> CRM_Utils_Date::getAbbrWeekdayNames(), | |
- 'weekdays_long' => CRM_Utils_Date::getFullWeekdayNames(), | |
- 'months_short' => CRM_Utils_Date::getAbbrMonthNames(), | |
- 'months_long' => CRM_Utils_Date::getFullMonthNames() | |
- ); | |
- parent::__construct($elementName, $elementLabel, null, null, null, $attributes); | |
+ $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes); | |
$this->_persistantFreeze = true; | |
$this->_appendName = true; | |
$this->_type = 'date'; | |
+ | |
+ // http://pear.php.net/bugs/bug.php?id=18171 | |
+ $this->_options['maxYear'] = date('Y'); | |
+ | |
// set the options, do not bother setting bogus ones | |
if (is_array($options)) { | |
foreach ($options as $name => $value) { | |
- if (isset($this->_options[$name])) { | |
+ if ('language' == $name) { | |
+ $this->_options['language'] = isset($this->_locale[$value])? $value: 'en'; | |
+ } elseif (isset($this->_options[$name])) { | |
if (is_array($value) && is_array($this->_options[$name])) { | |
$this->_options[$name] = @array_merge($this->_options[$name], $value); | |
} else { | |
@@ -150,7 +323,7 @@ class HTML_QuickForm_date extends HTML_QuickForm_group | |
{ | |
$this->_separator = $this->_elements = array(); | |
$separator = ''; | |
- $locale =& $this->_locale; | |
+ $locale =& $this->_locale[$this->_options['language']]; | |
$backslash = false; | |
for ($i = 0, $length = strlen($this->_options['format']); $i < $length; $i++) { | |
$sign = $this->_options['format']{$i}; | |
@@ -159,48 +332,29 @@ class HTML_QuickForm_date extends HTML_QuickForm_group | |
$separator .= $sign; | |
} else { | |
$loadSelect = true; | |
- $ariaLabel = $this->getLabel() ?: ''; | |
switch ($sign) { | |
case 'D': | |
// Sunday is 0 like with 'w' in date() | |
$options = $locale['weekdays_short']; | |
- $emptyText = ts('-day of week-'); | |
- $ariaLabel .= ts(' day of week'); | |
break; | |
case 'l': | |
$options = $locale['weekdays_long']; | |
- $emptyText = ts('-day of week-'); | |
- $ariaLabel .= ts(' day of week'); | |
break; | |
case 'd': | |
$options = $this->_createOptionList(1, 31); | |
- $emptyText = ts('-day-'); | |
- $ariaLabel .= ts(' day'); | |
- break; | |
- case 'j': | |
- // the no-zero-padding option (CRM-2793) | |
- $options = $this->_createOptionList(1, 31, 1, false); | |
- $emptyText = ts('-day-'); | |
- $ariaLabel .= ts(' day'); | |
break; | |
case 'M': | |
$options = $locale['months_short']; | |
array_unshift($options , ''); | |
unset($options[0]); | |
- $emptyText = ts('-month-'); | |
- $ariaLabel .= ts(' month'); | |
break; | |
case 'm': | |
$options = $this->_createOptionList(1, 12); | |
- $emptyText = ts('-month-'); | |
- $ariaLabel .= ts(' month'); | |
break; | |
case 'F': | |
$options = $locale['months_long']; | |
array_unshift($options , ''); | |
unset($options[0]); | |
- $emptyText = ts('-month-'); | |
- $ariaLabel .= ts(' month'); | |
break; | |
case 'Y': | |
$options = $this->_createOptionList( | |
@@ -208,8 +362,6 @@ class HTML_QuickForm_date extends HTML_QuickForm_group | |
$this->_options['maxYear'], | |
$this->_options['minYear'] > $this->_options['maxYear']? -1: 1 | |
); | |
- $emptyText = ts('-year-'); | |
- $ariaLabel .= ts(' year'); | |
break; | |
case 'y': | |
$options = $this->_createOptionList( | |
@@ -218,13 +370,9 @@ class HTML_QuickForm_date extends HTML_QuickForm_group | |
$this->_options['minYear'] > $this->_options['maxYear']? -1: 1 | |
); | |
array_walk($options, create_function('&$v,$k','$v = substr($v,-2);')); | |
- $emptyText = ts('-year-'); | |
- $ariaLabel .= ts(' year'); | |
break; | |
case 'h': | |
$options = $this->_createOptionList(1, 12); | |
- $emptyText = ts('-hour-'); | |
- $ariaLabel .= ts(' hour'); | |
break; | |
case 'g': | |
$options = $this->_createOptionList(1, 12); | |
@@ -232,28 +380,18 @@ class HTML_QuickForm_date extends HTML_QuickForm_group | |
break; | |
case 'H': | |
$options = $this->_createOptionList(0, 23); | |
- $emptyText = ts('-hour-'); | |
- $ariaLabel .= ts(' hour'); | |
break; | |
case 'i': | |
$options = $this->_createOptionList(0, 59, $this->_options['optionIncrement']['i']); | |
- $emptyText = ts('-min-'); | |
- $ariaLabel .= ts(' minute'); | |
break; | |
case 's': | |
$options = $this->_createOptionList(0, 59, $this->_options['optionIncrement']['s']); | |
- $emptyText = ts('-sec-'); | |
- $ariaLabel .= ts(' second'); | |
break; | |
case 'a': | |
$options = array('am' => 'am', 'pm' => 'pm'); | |
- $emptyText = '-am/pm-'; | |
- $ariaLabel .= ts(' am or pm'); | |
break; | |
case 'A': | |
$options = array('AM' => 'AM', 'PM' => 'PM'); | |
- $emptyText = '-AM/PM-'; | |
- $ariaLabel .= ts(' AM or PM'); | |
break; | |
case 'W': | |
$options = $this->_createOptionList(1, 53); | |
@@ -280,23 +418,12 @@ class HTML_QuickForm_date extends HTML_QuickForm_group | |
// Using '+' array operator to preserve the keys | |
if (is_array($this->_options['emptyOptionText']) && !empty($this->_options['emptyOptionText'][$sign])) { | |
- $text = $emptyText ? $emptyText : $this->_options['emptyOptionText'][$sign]; | |
- $options = array($this->_options['emptyOptionValue'] => $text) + $options; | |
+ $options = array($this->_options['emptyOptionValue'] => $this->_options['emptyOptionText'][$sign]) + $options; | |
} else { | |
- $text = $emptyText ? $emptyText : $this->_options['emptyOptionText']; | |
- $options = array($this->_options['emptyOptionValue'] => $text) + $options; | |
- } | |
+ $options = array($this->_options['emptyOptionValue'] => $this->_options['emptyOptionText']) + $options; | |
} | |
- | |
- //modified autogenerated id for date select boxes. | |
- $attribs = $this->getAttributes(); | |
- $elementName = $this->getName(); | |
- $attribs['id'] = $elementName.'['.$sign.']'; | |
- if ($ariaLabel !== '') { | |
- $attribs['aria-label'] = $ariaLabel; | |
} | |
- | |
- $this->_elements[] = new HTML_QuickForm_select($sign, null, $options, $attribs); | |
+ $this->_elements[] =& new HTML_QuickForm_select($sign, null, $options, $this->getAttributes()); | |
} | |
} | |
} | |
@@ -312,14 +439,13 @@ class HTML_QuickForm_date extends HTML_QuickForm_group | |
* @param int The start number | |
* @param int The end number | |
* @param int Increment by this value | |
- * @param bool Whether to pad the result with leading zero (CRM-2793) | |
* @access private | |
* @return array An array of numeric options. | |
*/ | |
- function _createOptionList($start, $end, $step = 1, $pad = true) | |
+ function _createOptionList($start, $end, $step = 1) | |
{ | |
for ($i = $start, $options = array(); $start > $end? $i >= $end: $i <= $end; $i += $step) { | |
- $options[$i] = $pad ? sprintf('%02d', $i) : sprintf('%d', $i); | |
+ $options[$i] = sprintf('%02d', $i); | |
} | |
return $options; | |
} | |
@@ -385,7 +511,7 @@ class HTML_QuickForm_date extends HTML_QuickForm_group | |
function toHtml() | |
{ | |
include_once('HTML/QuickForm/Renderer/Default.php'); | |
- $renderer = new HTML_QuickForm_Renderer_Default(); | |
+ $renderer =& new HTML_QuickForm_Renderer_Default(); | |
$renderer->setElementTemplate('{element}'); | |
parent::accept($renderer); | |
return $this->_wrap[0] . $renderer->toHtml() . $this->_wrap[1]; | |
diff --git a/HTML/QuickForm/element.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/element.php | |
index c8d4a83..87f9921 100644 | |
--- a/HTML/QuickForm/element.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/element.php | |
@@ -93,9 +93,9 @@ class HTML_QuickForm_element extends HTML_Common | |
* @access public | |
* @return void | |
*/ | |
- function __construct($elementName=null, $elementLabel=null, $attributes=null) | |
+ function HTML_QuickForm_element($elementName=null, $elementLabel=null, $attributes=null) | |
{ | |
- parent::__construct($attributes); | |
+ HTML_Common::HTML_Common($attributes); | |
if (isset($elementName)) { | |
$this->setName($elementName); | |
} | |
@@ -348,8 +348,14 @@ class HTML_QuickForm_element extends HTML_Common | |
if (isset($values[$elementName])) { | |
return $values[$elementName]; | |
} elseif (strpos($elementName, '[')) { | |
- $keys = explode('[', str_replace(']', '', $elementName)); | |
- return CRM_Utils_Array::recursiveValue($values, $keys); | |
+ | |
+ $keys = str_replace( | |
+ array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), | |
+ $elementName | |
+ ); | |
+ $arrayKeys = explode("']['", $keys); | |
+ return HTML_QuickForm_utils::recursiveValue($values, $arrayKeys); | |
+ | |
} else { | |
return null; | |
} | |
@@ -372,7 +378,8 @@ class HTML_QuickForm_element extends HTML_Common | |
{ | |
switch ($event) { | |
case 'createElement': | |
- $this->__construct($arg[0], $arg[1], $arg[2], $arg[3], $arg[4]); | |
+ $className = get_class($this); | |
+ $this->$className($arg[0], $arg[1], $arg[2], $arg[3], $arg[4]); | |
break; | |
case 'addElement': | |
$this->onQuickFormEvent('createElement', $arg, $caller); | |
@@ -478,8 +485,13 @@ class HTML_QuickForm_element extends HTML_Common | |
if (!strpos($name, '[')) { | |
return array($name => $value); | |
} else { | |
- $keys = explode('[', str_replace(']', '', $name)); | |
- return CRM_Utils_Array::recursiveBuild($keys, $value); | |
+ | |
+ $keys = str_replace( | |
+ array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), | |
+ $name | |
+ ); | |
+ $keysArray = explode("']['", $keys); | |
+ return HTML_QuickForm_utils::recursiveBuild($keysArray, $value); | |
} | |
} | |
} | |
diff --git a/HTML/QuickForm/file.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/file.php | |
index ad32003..71b3107 100644 | |
--- a/HTML/QuickForm/file.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/file.php | |
@@ -70,9 +70,9 @@ class HTML_QuickForm_file extends HTML_QuickForm_input | |
* @since 1.0 | |
* @access public | |
*/ | |
- function __construct($elementName=null, $elementLabel=null, $attributes=null) | |
+ function HTML_QuickForm_file($elementName=null, $elementLabel=null, $attributes=null) | |
{ | |
- parent::__construct($elementName, $elementLabel, $attributes); | |
+ HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes); | |
$this->setType('file'); | |
} //end constructor | |
@@ -176,8 +176,7 @@ class HTML_QuickForm_file extends HTML_QuickForm_input | |
if ($caller->getAttribute('method') == 'get') { | |
return PEAR::raiseError('Cannot add a file upload field to a GET method form'); | |
} | |
- $placeholder = array(); | |
- $this->_value = $this->_findValue($placeholder); | |
+ $this->_value = $this->_findValue(); | |
$caller->updateAttributes(array('enctype' => 'multipart/form-data')); | |
$caller->setMaxFileSize(); | |
break; | |
@@ -187,7 +186,7 @@ class HTML_QuickForm_file extends HTML_QuickForm_input | |
break; | |
case 'createElement': | |
$className = get_class($this); | |
- $this->__construct($arg[0], $arg[1], $arg[2]); | |
+ $this->$className($arg[0], $arg[1], $arg[2]); | |
break; | |
} | |
return true; | |
@@ -237,7 +236,7 @@ class HTML_QuickForm_file extends HTML_QuickForm_input | |
* @access private | |
* @return bool true if file has been uploaded, false otherwise | |
*/ | |
- static function _ruleIsUploadedFile($elementValue) | |
+ function _ruleIsUploadedFile($elementValue) | |
{ | |
if ((isset($elementValue['error']) && $elementValue['error'] == 0) || | |
(!empty($elementValue['tmp_name']) && $elementValue['tmp_name'] != 'none')) { | |
@@ -258,7 +257,7 @@ class HTML_QuickForm_file extends HTML_QuickForm_input | |
* @access private | |
* @return bool true if filesize is lower than maxsize, false otherwise | |
*/ | |
- static function _ruleCheckMaxFileSize($elementValue, $maxSize) | |
+ function _ruleCheckMaxFileSize($elementValue, $maxSize) | |
{ | |
if (!empty($elementValue['error']) && | |
(UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error'])) { | |
@@ -281,7 +280,7 @@ class HTML_QuickForm_file extends HTML_QuickForm_input | |
* @access private | |
* @return bool true if mimetype is correct, false otherwise | |
*/ | |
- static function _ruleCheckMimeType($elementValue, $mimeType) | |
+ function _ruleCheckMimeType($elementValue, $mimeType) | |
{ | |
if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) { | |
return true; | |
@@ -303,7 +302,7 @@ class HTML_QuickForm_file extends HTML_QuickForm_input | |
* @access private | |
* @return bool true if name matches regex, false otherwise | |
*/ | |
- static function _ruleCheckFileName($elementValue, $regex) | |
+ function _ruleCheckFileName($elementValue, $regex) | |
{ | |
if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) { | |
return true; | |
@@ -320,10 +319,12 @@ class HTML_QuickForm_file extends HTML_QuickForm_input | |
* Needs to be redefined here as $_FILES is populated differently from | |
* other arrays when element name is of the form foo[bar] | |
* | |
+ * @param bool $sc1 unused, for signature compatibility | |
+ * | |
* @access private | |
* @return mixed | |
*/ | |
- function _findValue(&$values) | |
+ function _findValue(&$sc1 = null) | |
{ | |
if (empty($_FILES)) { | |
return null; | |
@@ -332,21 +333,23 @@ class HTML_QuickForm_file extends HTML_QuickForm_input | |
if (isset($_FILES[$elementName])) { | |
return $_FILES[$elementName]; | |
} elseif (false !== ($pos = strpos($elementName, '['))) { | |
- $base = substr($elementName, 0, $pos); | |
- $idx = explode('][', str_replace(["['", "']", '["', '"]'], ['[', ']', '[', ']'], substr($elementName, $pos + 1, -1))); | |
- $idx = array_merge([$base, 'name'], $idx); | |
- if (!CRM_Utils_Array::recursiveIsset($_FILES, $idx)) { | |
- return NULL; | |
- } | |
- else { | |
- $props = ['name', 'type', 'size', 'tmp_name', 'error']; | |
- $value = []; | |
+ $base = str_replace( | |
+ array('\\', '\''), array('\\\\', '\\\''), | |
+ substr($elementName, 0, $pos) | |
+ ); | |
+ $idx = "['" . str_replace( | |
+ array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), | |
+ substr($elementName, $pos + 1, -1) | |
+ ) . "']"; | |
+ $props = array('name', 'type', 'size', 'tmp_name', 'error'); | |
+ $code = "if (!isset(\$_FILES['{$base}']['name']{$idx})) {\n" . | |
+ " return null;\n" . | |
+ "} else {\n" . | |
+ " \$value = array();\n"; | |
foreach ($props as $prop) { | |
- $idx[1] = $prop; | |
- $value[$prop] = CRM_Utils_Array::recursiveValue($_FILES, $idx); | |
- } | |
- return $value; | |
+ $code .= " \$value['{$prop}'] = \$_FILES['{$base}']['{$prop}']{$idx};\n"; | |
} | |
+ return eval($code . " return \$value;\n}\n"); | |
} else { | |
return null; | |
} | |
diff --git a/HTML/QuickForm/group.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/group.php | |
index 00a0863..adfd378 100644 | |
--- a/HTML/QuickForm/group.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/group.php | |
@@ -97,15 +97,13 @@ class HTML_QuickForm_group extends HTML_QuickForm_element | |
* @param bool $appendName (optional)whether to change elements' names to | |
* the form $groupName[$elementName] or leave | |
* them as is. | |
- * @param mixed $attributes (optional)Either a typical HTML attribute string | |
- * or an associative array. Date format is passed along the attributes. | |
* @since 1.0 | |
* @access public | |
* @return void | |
*/ | |
- function __construct($elementName=null, $elementLabel=null, $elements=null, $separator=null, $appendName = true, $attributes = null) | |
+ function HTML_QuickForm_group($elementName=null, $elementLabel=null, $elements=null, $separator=null, $appendName = true) | |
{ | |
- parent::__construct($elementName, $elementLabel, $attributes); | |
+ $this->HTML_QuickForm_element($elementName, $elementLabel); | |
$this->_type = 'group'; | |
if (isset($elements) && is_array($elements)) { | |
$this->setElements($elements); | |
@@ -301,7 +299,7 @@ class HTML_QuickForm_group extends HTML_QuickForm_element | |
function toHtml() | |
{ | |
include_once('HTML/QuickForm/Renderer/Default.php'); | |
- $renderer = new HTML_QuickForm_Renderer_Default(); | |
+ $renderer =& new HTML_QuickForm_Renderer_Default(); | |
$renderer->setElementTemplate('{element}'); | |
$this->accept($renderer); | |
return $renderer->toHtml(); | |
@@ -444,10 +442,7 @@ class HTML_QuickForm_group extends HTML_QuickForm_element | |
if ($this->_appendName) { | |
$elementName = $element->getName(); | |
if (isset($elementName)) { | |
- $newName = $name . '['. (strlen($elementName)? $elementName: $key) .']'; | |
- $newID = str_replace(array(']', '['), array('', '_'), $newName); | |
- $element->setName($newName); | |
- $element->updateAttributes( array( 'id' => $newID ) ); | |
+ $element->setName($name . '['. (strlen($elementName)? $elementName: $key) .']'); | |
} else { | |
$element->setName($name); | |
} | |
diff --git a/HTML/QuickForm/header.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/header.php | |
index d978afa..851a5d4 100644 | |
--- a/HTML/QuickForm/header.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/header.php | |
@@ -47,9 +47,9 @@ class HTML_QuickForm_header extends HTML_QuickForm_static | |
* @access public | |
* @return void | |
*/ | |
- function __construct($elementName = null, $text = null) | |
+ function HTML_QuickForm_header($elementName = null, $text = null) | |
{ | |
- parent::__construct($elementName, null, $text); | |
+ $this->HTML_QuickForm_static($elementName, null, $text); | |
$this->_type = 'header'; | |
} | |
diff --git a/HTML/QuickForm/hidden.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/hidden.php | |
index 5cc54c3..43b435d 100644 | |
--- a/HTML/QuickForm/hidden.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/hidden.php | |
@@ -52,9 +52,9 @@ class HTML_QuickForm_hidden extends HTML_QuickForm_input | |
* @access public | |
* @return void | |
*/ | |
- function __construct($elementName=null, $value='', $attributes=null) | |
+ function HTML_QuickForm_hidden($elementName=null, $value='', $attributes=null) | |
{ | |
- parent::__construct($elementName, null, $attributes); | |
+ HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes); | |
$this->setType('hidden'); | |
$this->setValue($value); | |
} //end constructor | |
@@ -80,14 +80,14 @@ class HTML_QuickForm_hidden extends HTML_QuickForm_input | |
* Accepts a renderer | |
* | |
* @param HTML_QuickForm_Renderer renderer object | |
- * @param bool Whether an element is required | |
- * @param string An error message associated with an element | |
+ * @param bool $sc1 unused, for signature compatibility | |
+ * @param bool $sc2 unused, for signature compatibility | |
* @access public | |
* @return void | |
*/ | |
- function accept(&$renderer, $required=false, $error=null) | |
+ function accept(&$renderer, $sc1 = false, $sc2 = null) | |
{ | |
- $renderer->renderHidden($this, $required, $error); | |
+ $renderer->renderHidden($this); | |
} // end func accept | |
// }}} | |
diff --git a/HTML/QuickForm/hiddenselect.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/hiddenselect.php | |
index 6ef34d4..d4aa39d 100644 | |
--- a/HTML/QuickForm/hiddenselect.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/hiddenselect.php | |
@@ -56,9 +56,9 @@ class HTML_QuickForm_hiddenselect extends HTML_QuickForm_select | |
* @access public | |
* @return void | |
*/ | |
- function __construct($elementName=null, $elementLabel=null, $options=null, $attributes=null) | |
+ function HTML_QuickForm_hiddenselect($elementName=null, $elementLabel=null, $options=null, $attributes=null) | |
{ | |
- parent::__construct($elementName, $elementLabel, $attributes); | |
+ HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes); | |
$this->_persistantFreeze = true; | |
$this->_type = 'hiddenselect'; | |
if (isset($options)) { | |
diff --git a/HTML/QuickForm/hierselect.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/hierselect.php | |
index e44c6f8..1d35283 100644 | |
--- a/HTML/QuickForm/hierselect.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/hierselect.php | |
@@ -59,42 +59,7 @@ class HTML_QuickForm_hierselect extends HTML_QuickForm_group | |
/** | |
* Options for all the select elements | |
* | |
- * Format is a bit more complex as we need to know which options | |
- * are related to the ones in the previous select: | |
- * | |
- * Ex: | |
- * // 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 depracated 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)); | |
- * | |
+ * @see setOptions() | |
* @var array | |
* @access private | |
*/ | |
@@ -116,11 +81,6 @@ class HTML_QuickForm_hierselect extends HTML_QuickForm_group | |
*/ | |
var $_js = ''; | |
- /** | |
- * The javascript array name | |
- */ | |
- var $_jsArrayName = ''; | |
- | |
// }}} | |
// {{{ constructor | |
@@ -136,9 +96,9 @@ class HTML_QuickForm_hierselect extends HTML_QuickForm_group | |
* @access public | |
* @return void | |
*/ | |
- function __construct($elementName=null, $elementLabel=null, $attributes=null, $separator=null) | |
+ function HTML_QuickForm_hierselect($elementName=null, $elementLabel=null, $attributes=null, $separator=null) | |
{ | |
- parent::__construct($elementName, $elementLabel, null, null, null, $attributes); | |
+ $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes); | |
$this->_persistantFreeze = true; | |
if (isset($separator)) { | |
$this->_separator = $separator; | |
@@ -154,8 +114,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. | |
* | |
- * @param array $options Array of options defining each element | |
+ * 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> | |
+ * | |
+ * @param array $options Array of options defining each element | |
* @access public | |
* @return void | |
*/ | |
@@ -171,13 +168,12 @@ class HTML_QuickForm_hierselect extends HTML_QuickForm_group | |
// check if all elements have been created | |
$totalNbElements = count($this->_options); | |
for ($i = $this->_nbElements; $i < $totalNbElements; $i ++) { | |
- $this->_elements[] = new HTML_QuickForm_select($i, null, array(), $this->getAttributes()); | |
+ $this->_elements[] =& new HTML_QuickForm_select($i, null, array(), $this->getAttributes()); | |
$this->_nbElements++; | |
} | |
} | |
$this->_setOptions(); | |
- $this->_setJS(); | |
} // end func setMainOptions | |
// }}} | |
@@ -225,13 +223,12 @@ class HTML_QuickForm_hierselect extends HTML_QuickForm_group | |
// check if all elements have been created | |
$totalNbElements = 2; | |
for ($i = $this->_nbElements; $i < $totalNbElements; $i ++) { | |
- $this->_elements[] = new HTML_QuickForm_select($i, null, array(), $this->getAttributes()); | |
+ $this->_elements[] =& new HTML_QuickForm_select($i, null, array(), $this->getAttributes()); | |
$this->_nbElements++; | |
} | |
} | |
$this->_setOptions(); | |
- $this->_setJS(); | |
} // end func setSecOptions | |
// }}} | |
@@ -248,8 +245,8 @@ class HTML_QuickForm_hierselect extends HTML_QuickForm_group | |
$arrayKeys = []; | |
foreach (array_keys($this->_elements) AS $key) { | |
if (isset($this->_options[$key])) { | |
- if ((empty($arrayKeys)) || CRM_Utils_Array::recursiveIsset($this->_options[$key], $arrayKeys)) { | |
- $array = empty($arrayKeys) ? $this->_options[$key] : CRM_Utils_Array::recursiveValue($this->_options[$key], $arrayKeys); | |
+ if ((empty($arrayKeys)) || HTML_QuickForm_utils::recursiveIsset($this->_options[$key], $arrayKeys)) { | |
+ $array = empty($arrayKeys) ? $this->_options[$key] : HTML_QuickForm_utils::recursiveValue($this->_options[$key], $arrayKeys); | |
if (is_array($array)) { | |
$select =& $this->_elements[$key]; | |
$select->_options = array(); | |
@@ -277,7 +274,10 @@ class HTML_QuickForm_hierselect extends HTML_QuickForm_group | |
*/ | |
function setValue($value) | |
{ | |
- $this->_nbElements = count($value); | |
+ // fix for bug #6766. Hope this doesn't break anything more | |
+ // after bug #7961. Forgot that _nbElements was used in | |
+ // _createElements() called in several places... | |
+ $this->_nbElements = max($this->_nbElements, count($value)); | |
parent::setValue($value); | |
$this->_setOptions(); | |
} // end func setValue | |
@@ -293,196 +293,202 @@ class HTML_QuickForm_hierselect extends HTML_QuickForm_group | |
*/ | |
function _createElements() | |
{ | |
- //hack to add id attribute for hier select | |
- $attributes = $this->getAttributes(); | |
- $id = null; | |
- if ( isset( $attributes['id'] ) ) { | |
- $id = "{$attributes['id']}"; | |
- } | |
- | |
for ($i = 0; $i < $this->_nbElements; $i++) { | |
- if ( isset( $id ) ) { | |
- $attributes['id'] = "{$id}_{$i}"; | |
- } | |
- | |
- $this->_elements[] = new HTML_QuickForm_select($i, null, array(), $attributes); | |
+ $this->_elements[] =& new HTML_QuickForm_select($i, null, array(), $this->getAttributes()); | |
} | |
} // end func _createElements | |
// }}} | |
- // {{{ _setJS() | |
+ // {{{ toHtml() | |
- /** | |
- * Set the JavaScript for each select element (excluding de main one). | |
- * | |
- * @access private | |
- * @return void | |
- */ | |
- function _setJS() | |
+ function toHtml() | |
{ | |
- static $jsArrayName = null; | |
+ $this->_js = ''; | |
+ if (!$this->_flagFrozen) { | |
+ // set the onchange attribute for each element except last | |
+ $keys = array_keys($this->_elements); | |
+ $onChange = array(); | |
+ for ($i = 0; $i < count($keys) - 1; $i++) { | |
+ $select =& $this->_elements[$keys[$i]]; | |
+ $onChange[$i] = $select->getAttribute('onchange'); | |
+ $select->updateAttributes( | |
+ array('onchange' => '_hs_swapOptions(this.form, \'' . $this->_escapeString($this->getName()) . '\', ' . $keys[$i] . ');' . $onChange[$i]) | |
+ ); | |
+ } | |
- $this->_js = $js = ''; | |
- if ( ! $jsArrayName ) { | |
- $this->_jsArrayName = 'hs_' . preg_replace('/\[|\]/', '_', $this->getName()); | |
- for ($i = 1; $i < $this->_nbElements; $i++) { | |
- $this->_setJSArray($this->_jsArrayName, $this->_options[$i], $js); | |
+ // create the js function to call | |
+ if (!defined('HTML_QUICKFORM_HIERSELECT_EXISTS')) { | |
+ $this->_js .= <<<JAVASCRIPT | |
+function _hs_findOptions(ary, keys) | |
+{ | |
+ if (ary == undefined) { | |
+ return {}; | |
} | |
- $jsArrayName = $this->_jsArrayName; | |
+ var key = keys.shift(); | |
+ if (!key in ary) { | |
+ return {}; | |
+ } else if (0 == keys.length) { | |
+ return ary[key]; | |
} else { | |
- $this->_jsArrayName = $jsArrayName; | |
+ return _hs_findOptions(ary[key], keys); | |
+ } | |
} | |
- } // end func _setJS | |
- | |
- // }}} | |
- // {{{ _setJSArray() | |
- /** | |
- * Recursively builds the JavaScript array defining the options that a select | |
- * element can have. | |
- * | |
- * @param string $grpName Group Name attribute | |
- * @param array $options Select element options | |
- * @param string $js JavaScript definition is build using this variable | |
- * @param string $optValue The value for the current JavaScript option | |
- * | |
- * @access private | |
- * @return void | |
- */ | |
- function _setJSArray($grpName, $options, &$js, $optValue = '') | |
+function _hs_findSelect(form, groupName, selectIndex) | |
{ | |
- static $jsNameCache = array( ); | |
- if (is_array($options)) { | |
- $js = ''; | |
- // For a hierselect containing 3 elements: | |
- // if option 1 has been selected for the 1st element | |
- // and option 3 has been selected for the 2nd element, | |
- // then the javascript array containing the values to load | |
- // on the 3rd element will have the following name: grpName_1_3 | |
- $name = ($optValue === '') ? $grpName : $grpName.'_'.$optValue; | |
- foreach($options AS $k => $v) { | |
- $this->_setJSArray($name, $v, $js, $k); | |
- } | |
- | |
- // if $js !== '' add it to the JavaScript | |
- | |
- if ( $js !== '' ) { | |
- // check if we have already this js in cache, if so reuse it | |
- $cacheKey = md5( $js ); | |
- if ( array_key_exists( $cacheKey, $jsNameCache ) ) { | |
- $this->_js .= "$name = {$jsNameCache[$cacheKey]}\n"; | |
+ if (groupName+'['+ selectIndex +']' in form) { | |
+ return form[groupName+'['+ selectIndex +']']; | |
} else { | |
- $this->_js .= $name." = {\n".$js."\n}\n"; | |
- $jsNameCache[$cacheKey] = $name; | |
+ return form[groupName+'['+ selectIndex +'][]']; | |
} | |
} | |
- $js = ''; | |
+ | |
+function _hs_unescapeEntities(str) | |
+{ | |
+ var div = document.createElement('div'); | |
+ div.innerHTML = str; | |
+ return div.childNodes[0] ? div.childNodes[0].nodeValue : ''; | |
+} | |
+ | |
+function _hs_replaceOptions(ctl, options) | |
+{ | |
+ var j = 0; | |
+ ctl.options.length = 0; | |
+ for (var i = 0; i < options.values.length; i++) { | |
+ ctl.options[i] = new Option( | |
+ (-1 == String(options.texts[i]).indexOf('&'))? options.texts[i]: _hs_unescapeEntities(options.texts[i]), | |
+ options.values[i], false, false | |
+ ); | |
+ } | |
+} | |
+ | |
+function _hs_setValue(ctl, value) | |
+{ | |
+ var testValue = {}; | |
+ if (value instanceof Array) { | |
+ for (var i = 0; i < value.length; i++) { | |
+ testValue[value[i]] = true; | |
+ } | |
} else { | |
- // $js empty means that we are adding the first element to the JavaScript. | |
- if ($js != '') { | |
- $js .= ",\n"; | |
+ testValue[value] = true; | |
+ } | |
+ for (var i = 0; i < ctl.options.length; i++) { | |
+ if (ctl.options[i].value in testValue) { | |
+ ctl.options[i].selected = true; | |
} | |
- $js .= '"'.$optValue.'":'.json_encode($options); | |
} | |
} | |
- // }}} | |
- // {{{ toHtml() | |
+function _hs_swapOptions(form, groupName, selectIndex) | |
+{ | |
+ var hsValue = []; | |
+ for (var i = 0; i <= selectIndex; i++) { | |
+ hsValue[i] = _hs_findSelect(form, groupName, i).value; | |
+ } | |
- /** | |
- * Returns Html for the group | |
- * | |
- * @access public | |
- * @return string | |
- */ | |
- function toHtml() | |
+ _hs_replaceOptions(_hs_findSelect(form, groupName, selectIndex + 1), | |
+ _hs_findOptions(_hs_options[groupName][selectIndex], hsValue)); | |
+ if (selectIndex + 1 < _hs_options[groupName].length) { | |
+ _hs_swapOptions(form, groupName, selectIndex + 1); | |
+ } | |
+} | |
+ | |
+function _hs_onReset(form, groupNames) | |
{ | |
- if ($this->_flagFrozen) { | |
- $this->_js = ''; | |
- } else { | |
- // set the onchange attribute for each element | |
- $keys = array_keys($this->_elements); | |
- $nbElements = count($keys); | |
- $nbElementsUsingFnc = $nbElements - 1; // last element doesn't need it | |
- for ($i = 0; $i < $nbElementsUsingFnc; $i++) { | |
- $select =& $this->_elements[$keys[$i]]; | |
- $select->updateAttributes( | |
- array('onChange' => 'swapOptions(this.form, \''.$this->getName().'\', '.$keys[$i].', '.$nbElements.', \''.$this->_jsArrayName.'\');') | |
- ); | |
+ for (var i = 0; i < groupNames.length; i++) { | |
+ try { | |
+ for (var j = 0; j <= _hs_options[groupNames[i]].length; j++) { | |
+ _hs_setValue(_hs_findSelect(form, groupNames[i], j), _hs_defaults[groupNames[i]][j]); | |
+ if (j < _hs_options[groupNames[i]].length) { | |
+ _hs_replaceOptions(_hs_findSelect(form, groupNames[i], j + 1), | |
+ _hs_findOptions(_hs_options[groupNames[i]][j], _hs_defaults[groupNames[i]].slice(0, j + 1))); | |
+ } | |
+ } | |
+ } catch (e) { | |
+ if (!(e instanceof TypeError)) { | |
+ throw e; | |
+ } | |
+ } | |
+ } | |
} | |
- // create the js function to call | |
- if (!defined('HTML_QUICKFORM_HIERSELECT_EXISTS')) { | |
- $this->_js .= "function swapOptions(frm, grpName, eleIndex, nbElements, arName)\n" | |
- ."{\n" | |
- ." var n = \"\";\n" | |
- ." var ctl;\n\n" | |
- ." for (var i = 0; i < nbElements; i++) {\n" | |
- ." ctl = frm[grpName+'['+i+']'];\n" | |
- ." if (!ctl) {\n" | |
- ." ctl = frm[grpName+'['+i+'][]'];\n" | |
- ." }\n" | |
- ." if (i <= eleIndex) {\n" | |
- ." n += \"_\"+ctl.value;\n" | |
- ." } else {\n" | |
- ." ctl.length = 0;\n" | |
- ." }\n" | |
- ." }\n\n" | |
- ." var t = eval(\"typeof(\"+arName + n +\")\");\n" | |
- ." if (t != 'undefined') {\n" | |
- ." var the_array = eval(arName+n);\n" | |
- ." var j = 0;\n" | |
- ." n = eleIndex + 1;\n" | |
- ." ctl = frm[grpName+'['+ n +']'];\n" | |
- ." if (!ctl) {\n" | |
- ." ctl = frm[grpName+'['+ n +'][]'];\n" | |
- ." }\n" | |
- ." ctl.style.display = 'inline';\n" | |
- ." for (var i in the_array) {\n" | |
- ." opt = new Option(the_array[i], i, false, false);\n" | |
- ." ctl.options[j++] = opt;\n" | |
- ." }\n" | |
- ." } else {\n" | |
- ." n = eleIndex + 1;\n" | |
- ." ctl = frm[grpName+'['+n+']'];\n" | |
- ." if (!ctl) {\n" | |
- ." ctl = frm[grpName+'['+ n +'][]'];\n" | |
- ." }\n" | |
- ." if (ctl) {\n" | |
- ." ctl.style.display = 'none';\n" | |
- ." }\n" | |
- ." }\n" | |
- ." if (eleIndex+1 < nbElements) {\n" | |
- ." swapOptions(frm, grpName, eleIndex+1, nbElements, arName);\n" | |
- ." }\n" | |
- ."}\n"; | |
+function _hs_setupOnReset(form, groupNames) | |
+{ | |
+ setTimeout(function() { _hs_onReset(form, groupNames); }, 25); | |
+} | |
+ | |
+function _hs_onReload() | |
+{ | |
+ var ctl; | |
+ for (var i = 0; i < document.forms.length; i++) { | |
+ for (var j in _hs_defaults) { | |
+ if (ctl = _hs_findSelect(document.forms[i], j, 0)) { | |
+ for (var k = 0; k < _hs_defaults[j].length; k++) { | |
+ _hs_setValue(_hs_findSelect(document.forms[i], j, k), _hs_defaults[j][k]); | |
+ } | |
+ } | |
+ } | |
+ } | |
+ | |
+ if (_hs_prevOnload) { | |
+ _hs_prevOnload(); | |
+ } | |
+} | |
+ | |
+var _hs_prevOnload = null; | |
+if (window.onload) { | |
+ _hs_prevOnload = window.onload; | |
+} | |
+window.onload = _hs_onReload; | |
+ | |
+var _hs_options = {}; | |
+var _hs_defaults = {}; | |
+ | |
+JAVASCRIPT; | |
define('HTML_QUICKFORM_HIERSELECT_EXISTS', true); | |
} | |
+ // option lists | |
+ $jsParts = array(); | |
+ for ($i = 1; $i < $this->_nbElements; $i++) { | |
+ $jsParts[] = $this->_convertArrayToJavascript($this->_prepareOptions($this->_options[$i], $i)); | |
+ } | |
+ $this->_js .= "\n_hs_options['" . $this->_escapeString($this->getName()) . "'] = [\n" . | |
+ implode(",\n", $jsParts) . | |
+ "\n];\n"; | |
+ // default value; if we don't actually have any values yet just use | |
+ // the first option (for single selects) or empty array (for multiple) | |
+ $values = array(); | |
+ foreach (array_keys($this->_elements) as $key) { | |
+ if (is_array($v = $this->_elements[$key]->getValue())) { | |
+ $values[] = count($v) > 1? $v: $v[0]; | |
+ } else { | |
+ // XXX: accessing the supposedly private _options array | |
+ $values[] = $this->_elements[$key]->getMultiple() || empty($this->_elements[$key]->_options[0])? | |
+ array(): | |
+ $this->_elements[$key]->_options[0]['attr']['value']; | |
+ } | |
+ } | |
+ $this->_js .= "_hs_defaults['" . $this->_escapeString($this->getName()) . "'] = " . | |
+ $this->_convertArrayToJavascript($values) . ";\n"; | |
} | |
include_once('HTML/QuickForm/Renderer/Default.php'); | |
- $renderer = new HTML_QuickForm_Renderer_Default(); | |
+ $renderer =& new HTML_QuickForm_Renderer_Default(); | |
$renderer->setElementTemplate('{element}'); | |
parent::accept($renderer); | |
- $result = null; | |
- if ( ! empty( $this->_js ) ) { | |
- $result .= "<script type=\"text/javascript\">\n//<![CDATA[\n" . $this->_js . "//]]>\n</script>"; | |
+ | |
+ if (!empty($onChange)) { | |
+ $keys = array_keys($this->_elements); | |
+ for ($i = 0; $i < count($keys) - 1; $i++) { | |
+ $this->_elements[$keys[$i]]->updateAttributes(array('onchange' => $onChange[$i])); | |
} | |
- return $result . | |
+ } | |
+ return (empty($this->_js)? '': "<script type=\"text/javascript\">\n//<![CDATA[\n" . $this->_js . "//]]>\n</script>") . | |
$renderer->toHtml(); | |
} // end func toHtml | |
// }}} | |
// {{{ accept() | |
- /** | |
- * Accepts a renderer | |
- * | |
- * @param object An HTML_QuickForm_Renderer object | |
- * @param bool Whether a group is required | |
- * @param string An error message associated with a group | |
- * @access public | |
- * @return void | |
- */ | |
function accept(&$renderer, $required = false, $error = null) | |
{ | |
$renderer->renderElement($this, $required, $error); | |
@@ -498,10 +504,147 @@ class HTML_QuickForm_hierselect extends HTML_QuickForm_group | |
// matches the main option | |
return HTML_QuickForm_element::onQuickFormEvent($event, $arg, $caller); | |
} else { | |
- return parent::onQuickFormEvent($event, $arg, $caller); | |
+ $ret = parent::onQuickFormEvent($event, $arg, $caller); | |
+ // add onreset handler to form to properly reset hierselect (see bug #2970) | |
+ if ('addElement' == $event) { | |
+ $onReset = $caller->getAttribute('onreset'); | |
+ if (strlen($onReset)) { | |
+ if (strpos($onReset, '_hs_setupOnReset')) { | |
+ $caller->updateAttributes(array('onreset' => str_replace('_hs_setupOnReset(this, [', "_hs_setupOnReset(this, ['" . $this->_escapeString($this->getName()) . "', ", $onReset))); | |
+ } else { | |
+ $caller->updateAttributes(array('onreset' => "var temp = function() { {$onReset} } ; if (!temp()) { return false; } ; if (typeof _hs_setupOnReset != 'undefined') { return _hs_setupOnReset(this, ['" . $this->_escapeString($this->getName()) . "']); } ")); | |
+ } | |
+ } else { | |
+ $caller->updateAttributes(array('onreset' => "if (typeof _hs_setupOnReset != 'undefined') { return _hs_setupOnReset(this, ['" . $this->_escapeString($this->getName()) . "']); } ")); | |
+ } | |
+ } | |
+ return $ret; | |
} | |
} // end func onQuickFormEvent | |
+ // }}} | |
+ // {{{ _prepareOptions() | |
+ | |
+ /** | |
+ * Prepares options for JS encoding | |
+ * | |
+ * We need to preserve order of options when adding them via javascript, so | |
+ * cannot use object literal and for/in loop (see bug #16603). Therefore we | |
+ * convert an associative array of options to two arrays of their values | |
+ * and texts. Backport from HTML_QuickForm2. | |
+ * | |
+ * @param array Options array | |
+ * @param int Depth within options array | |
+ * @link http://pear.php.net/bugs/bug.php?id=16603 | |
+ * @return array | |
+ * @access private | |
+ */ | |
+ function _prepareOptions($ary, $depth) | |
+ { | |
+ if (!is_array($ary)) { | |
+ $ret = $ary; | |
+ } elseif (0 == $depth) { | |
+ $ret = array('values' => array_keys($ary), 'texts' => array_values($ary)); | |
+ } else { | |
+ $ret = array(); | |
+ foreach ($ary as $k => $v) { | |
+ $ret[$k] = $this->_prepareOptions($v, $depth - 1); | |
+ } | |
+ } | |
+ return $ret; | |
+ } | |
+ | |
+ // }}} | |
+ // {{{ _convertArrayToJavascript() | |
+ | |
+ /** | |
+ * Converts PHP array to its Javascript analog | |
+ * | |
+ * @access private | |
+ * @param array PHP array to convert | |
+ * @return string Javascript representation of the value | |
+ */ | |
+ function _convertArrayToJavascript($array) | |
+ { | |
+ if (!is_array($array)) { | |
+ return $this->_convertScalarToJavascript($array); | |
+ } elseif (count($array) && array_keys($array) != range(0, count($array) - 1)) { | |
+ return '{' . implode(',', array_map( | |
+ array($this, '_encodeNameValue'), | |
+ array_keys($array), array_values($array) | |
+ )) . '}'; | |
+ } else { | |
+ return '[' . implode(',', array_map( | |
+ array($this, '_convertArrayToJavascript'), | |
+ $array | |
+ )) . ']'; | |
+ } | |
+ } | |
+ | |
+ // }}} | |
+ // {{{ _encodeNameValue() | |
+ | |
+ /** | |
+ * Callback for array_map used to generate JS name-value pairs | |
+ * | |
+ * @param mixed | |
+ * @param mixed | |
+ * @return string | |
+ */ | |
+ function _encodeNameValue($name, $value) | |
+ { | |
+ return $this->_convertScalarToJavascript((string)$name) . ':' | |
+ . $this->_convertArrayToJavascript($value); | |
+ } | |
+ | |
+ // }}} | |
+ // {{{ _convertScalarToJavascript() | |
+ | |
+ /** | |
+ * Converts PHP's scalar value to its Javascript analog | |
+ * | |
+ * @access private | |
+ * @param mixed PHP value to convert | |
+ * @return string Javascript representation of the value | |
+ */ | |
+ function _convertScalarToJavascript($val) | |
+ { | |
+ if (is_bool($val)) { | |
+ return $val ? 'true' : 'false'; | |
+ } elseif (is_int($val) || is_double($val)) { | |
+ return $val; | |
+ } elseif (is_string($val)) { | |
+ return "'" . $this->_escapeString($val) . "'"; | |
+ } elseif (is_null($val)) { | |
+ return 'null'; | |
+ } else { | |
+ // don't bother | |
+ return '{}'; | |
+ } | |
+ } | |
+ | |
+ // }}} | |
+ // {{{ _escapeString() | |
+ | |
+ /** | |
+ * Quotes the string so that it can be used in Javascript string constants | |
+ * | |
+ * @access private | |
+ * @param string | |
+ * @return string | |
+ */ | |
+ function _escapeString($str) | |
+ { | |
+ return strtr($str,array( | |
+ "\r" => '\r', | |
+ "\n" => '\n', | |
+ "\t" => '\t', | |
+ "'" => "\\'", | |
+ '"' => '\"', | |
+ '\\' => '\\\\' | |
+ )); | |
+ } | |
+ | |
// }}} | |
} // end class HTML_QuickForm_hierselect | |
?> | |
\ No newline at end of file | |
diff --git a/HTML/QuickForm/html.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/html.php | |
index 132e54c..335b08e 100644 | |
--- a/HTML/QuickForm/html.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/html.php | |
@@ -50,9 +50,9 @@ class HTML_QuickForm_html extends HTML_QuickForm_static | |
* @access public | |
* @return void | |
*/ | |
- function __construct($text = null) | |
+ function HTML_QuickForm_html($text = null) | |
{ | |
- parent::__construct(null, null, $text); | |
+ $this->HTML_QuickForm_static(null, null, $text); | |
$this->_type = 'html'; | |
} | |
diff --git a/HTML/QuickForm/image.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/image.php | |
index 558ba5c..3dbf9cc 100644 | |
--- a/HTML/QuickForm/image.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/image.php | |
@@ -52,9 +52,9 @@ class HTML_QuickForm_image extends HTML_QuickForm_input | |
* @access public | |
* @return void | |
*/ | |
- function __construct($elementName=null, $src='', $attributes=null) | |
+ function HTML_QuickForm_image($elementName=null, $src='', $attributes=null) | |
{ | |
- parent::__construct($elementName, null, $attributes); | |
+ HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes); | |
$this->setType('image'); | |
$this->setSource($src); | |
} // end class constructor | |
diff --git a/HTML/QuickForm/input.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/input.php | |
index 86ebc03..a23d81e 100644 | |
--- a/HTML/QuickForm/input.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/input.php | |
@@ -52,9 +52,9 @@ class HTML_QuickForm_input extends HTML_QuickForm_element | |
* @access public | |
* @return void | |
*/ | |
- function __construct($elementName=null, $elementLabel=null, $attributes=null) | |
+ function HTML_QuickForm_input($elementName=null, $elementLabel=null, $attributes=null) | |
{ | |
- parent::__construct($elementName, $elementLabel, $attributes); | |
+ $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes); | |
} //end constructor | |
// }}} | |
diff --git a/HTML/QuickForm/link.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/link.php | |
index aae4dc9..0c77e7a 100644 | |
--- a/HTML/QuickForm/link.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/link.php | |
@@ -65,9 +65,9 @@ class HTML_QuickForm_link extends HTML_QuickForm_static | |
* @return void | |
* @throws | |
*/ | |
- function __construct($elementName=null, $elementLabel=null, $href=null, $text=null, $attributes=null) | |
+ function HTML_QuickForm_link($elementName=null, $elementLabel=null, $href=null, $text=null, $attributes=null) | |
{ | |
- parent::__construct($elementName, $elementLabel, $attributes); | |
+ HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes); | |
$this->_persistantFreeze = false; | |
$this->_type = 'link'; | |
$this->setHref($href); | |
diff --git a/HTML/QuickForm/password.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/password.php | |
index ee71721..4c446fc 100644 | |
--- a/HTML/QuickForm/password.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/password.php | |
@@ -53,9 +53,9 @@ class HTML_QuickForm_password extends HTML_QuickForm_input | |
* @return void | |
* @throws | |
*/ | |
- function __construct($elementName=null, $elementLabel=null, $attributes=null) | |
+ function HTML_QuickForm_password($elementName=null, $elementLabel=null, $attributes=null) | |
{ | |
- parent::__construct($elementName, $elementLabel, $attributes); | |
+ HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes); | |
$this->setType('password'); | |
} //end constructor | |
diff --git a/HTML/QuickForm/radio.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/radio.php | |
index 91b10e8..1a6976d 100644 | |
--- a/HTML/QuickForm/radio.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/radio.php | |
@@ -64,31 +64,16 @@ class HTML_QuickForm_radio extends HTML_QuickForm_input | |
* @access public | |
* @return void | |
*/ | |
- function __construct($elementName=null, $elementLabel=null, $text=null, $value=null, $attributes=null) | |
+ function HTML_QuickForm_radio($elementName=null, $elementLabel=null, $text=null, $value=null, $attributes=null) | |
{ | |
- | |
- parent::__construct($elementName, $elementLabel, $attributes); | |
+ $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes); | |
if (isset($value)) { | |
$this->setValue($value); | |
} | |
$this->_persistantFreeze = true; | |
$this->setType('radio'); | |
$this->_text = $text; | |
- // $this->_generateId(); | |
- if ( ! $this->getAttribute('id') ) { | |
- //hack to add 'id' for radio | |
- static $idTextStr = 1; | |
- if (CRM_Utils_Array::value('id_suffix', $attributes)) { | |
- $idSuffix = $attributes['id_suffix']; | |
- $this->removeAttribute('id_suffix'); | |
- } | |
- else { | |
- $idSuffix = $idTextStr; | |
- $idTextStr++; | |
- } | |
- | |
- $this->updateAttributes( array('id' => CRM_Utils_String::munge( "CIVICRM_QFID_{$value}_{$idSuffix}" ) ) ); | |
- } | |
+ $this->_generateId(); | |
} //end constructor | |
// }}} | |
@@ -217,13 +202,11 @@ class HTML_QuickForm_radio extends HTML_QuickForm_input | |
switch ($event) { | |
case 'updateValue': | |
// constant values override both default and submitted ones | |
+ // default values are overriden by submitted | |
$value = $this->_findValue($caller->_constantValues); | |
if (null === $value) { | |
- // we should retrieve value from submitted values when form is submitted, | |
- // else set value from defaults values | |
- if ( $caller->isSubmitted( ) ) { | |
$value = $this->_findValue($caller->_submitValues); | |
- } else { | |
+ if (null === $value) { | |
$value = $this->_findValue($caller->_defaultValues); | |
} | |
} | |
@@ -256,10 +239,7 @@ class HTML_QuickForm_radio extends HTML_QuickForm_input | |
{ | |
$value = $this->_findValue($submitValues); | |
if (null === $value) { | |
- // fix to return blank value when all radio's are unselected / not selected | |
- // always use submitted values rather than defaults | |
- //$value = $this->getChecked()? $this->getValue(): null; | |
- $value = ''; | |
+ $value = $this->getChecked()? $this->getValue(): null; | |
} elseif ($value != $this->getValue()) { | |
$value = null; | |
} | |
diff --git a/HTML/QuickForm/reset.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/reset.php | |
index a9ca39c..8483800 100644 | |
--- a/HTML/QuickForm/reset.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/reset.php | |
@@ -52,9 +52,9 @@ class HTML_QuickForm_reset extends HTML_QuickForm_input | |
* @access public | |
* @return void | |
*/ | |
- function __construct($elementName=null, $value=null, $attributes=null) | |
+ function HTML_QuickForm_reset($elementName=null, $value=null, $attributes=null) | |
{ | |
- parent::__construct($elementName, null, $attributes); | |
+ HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes); | |
$this->setValue($value); | |
$this->setType('reset'); | |
} //end constructor | |
diff --git a/HTML/QuickForm/select.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/select.php | |
index d341560..c3419cc 100644 | |
--- a/HTML/QuickForm/select.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/select.php | |
@@ -75,9 +75,9 @@ class HTML_QuickForm_select extends HTML_QuickForm_element { | |
* @access public | |
* @return void | |
*/ | |
- function __construct($elementName=null, $elementLabel=null, $options=null, $attributes=null) | |
+ function HTML_QuickForm_select($elementName=null, $elementLabel=null, $options=null, $attributes=null) | |
{ | |
- parent::__construct($elementName, $elementLabel, $attributes); | |
+ HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes); | |
$this->_persistantFreeze = true; | |
$this->_type = 'select'; | |
if (isset($options)) { | |
@@ -403,7 +403,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element { | |
{ | |
if (is_string($conn)) { | |
require_once('DB.php'); | |
- $dbConn = DB::connect($conn, true); | |
+ $dbConn = &DB::connect($conn, true); | |
if (DB::isError($dbConn)) { | |
return $dbConn; | |
} | |
@@ -521,16 +521,14 @@ class HTML_QuickForm_select extends HTML_QuickForm_element { | |
$value = array(); | |
if (is_array($this->_values)) { | |
foreach ($this->_values as $key => $val) { | |
- if ( $val || is_numeric($val) ) { | |
- foreach ($this->_options as $oKey => $oVal ) { | |
- if (0 == strcmp($val, $this->_options[$oKey]['attr']['value'])) { | |
- $value[$key] = $oVal['text']; | |
+ for ($i = 0, $optCount = count($this->_options); $i < $optCount; $i++) { | |
+ if (0 == strcmp($val, $this->_options[$i]['attr']['value'])) { | |
+ $value[$key] = $this->_options[$i]['text']; | |
break; | |
} | |
} | |
} | |
} | |
- } | |
$html = empty($value)? ' ': join('<br />', $value); | |
if ($this->_persistantFreeze) { | |
$name = $this->getPrivateName(); | |
@@ -563,9 +561,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element { | |
{ | |
$value = $this->_findValue($submitValues); | |
if (is_null($value)) { | |
- // if value is null, default value is set for advselect | |
- // fix for CRM-1431 - kurund | |
- //$value = $this->getValue(); | |
+ $value = $this->getValue(); | |
} elseif(!is_array($value)) { | |
$value = array($value); | |
} | |
@@ -579,20 +575,11 @@ class HTML_QuickForm_select extends HTML_QuickForm_element { | |
} | |
} | |
} | |
- } else { | |
- //if value is null make it empty array, checked most of | |
- // the stuff, value is null for advselect | |
- // fix for CRM-1431 - kurund | |
- if (is_null($value)) { | |
- $cleanValue = array(); | |
} else { | |
$cleanValue = $value; | |
} | |
- } | |
if (is_array($cleanValue) && !$this->getMultiple()) { | |
- if ( isset( $cleanValue[0] ) ) { | |
return $this->_prepareValue($cleanValue[0], $assoc); | |
- } | |
} else { | |
return $this->_prepareValue($cleanValue, $assoc); | |
} | |
diff --git a/HTML/QuickForm/static.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/static.php | |
index cb8d068..16562ee 100644 | |
--- a/HTML/QuickForm/static.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/static.php | |
@@ -57,9 +57,9 @@ class HTML_QuickForm_static extends HTML_QuickForm_element { | |
* @access public | |
* @return void | |
*/ | |
- function __construct($elementName=null, $elementLabel=null, $text=null) | |
+ function HTML_QuickForm_static($elementName=null, $elementLabel=null, $text=null) | |
{ | |
- parent::__construct($elementName, $elementLabel); | |
+ HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel); | |
$this->_persistantFreeze = false; | |
$this->_type = 'static'; | |
$this->_text = $text; | |
diff --git a/HTML/QuickForm/submit.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/submit.php | |
index 9af6d4a..a8c9152 100644 | |
--- a/HTML/QuickForm/submit.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/submit.php | |
@@ -51,9 +51,9 @@ class HTML_QuickForm_submit extends HTML_QuickForm_input | |
* @access public | |
* @return void | |
*/ | |
- function __construct($elementName=null, $value=null, $attributes=null) | |
+ function HTML_QuickForm_submit($elementName=null, $value=null, $attributes=null) | |
{ | |
- parent::__construct($elementName, null, $attributes); | |
+ HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes); | |
$this->setValue($value); | |
$this->setType('submit'); | |
} //end constructor | |
diff --git a/HTML/QuickForm/text.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/text.php | |
index 5fc9d56..c0aa140 100644 | |
--- a/HTML/QuickForm/text.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/text.php | |
@@ -53,9 +53,9 @@ class HTML_QuickForm_text extends HTML_QuickForm_input | |
* @access public | |
* @return void | |
*/ | |
- function __construct($elementName=null, $elementLabel=null, $attributes=null) | |
+ function HTML_QuickForm_text($elementName=null, $elementLabel=null, $attributes=null) | |
{ | |
- parent::__construct($elementName, $elementLabel, $attributes); | |
+ HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes); | |
$this->_persistantFreeze = true; | |
$this->setType('text'); | |
} //end constructor | |
diff --git a/HTML/QuickForm/textarea.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/textarea.php | |
index cb0e4d1..3e26e39 100644 | |
--- a/HTML/QuickForm/textarea.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/textarea.php | |
@@ -62,9 +62,9 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element | |
* @access public | |
* @return void | |
*/ | |
- function __construct($elementName=null, $elementLabel=null, $attributes=null) | |
+ function HTML_QuickForm_textarea($elementName=null, $elementLabel=null, $attributes=null) | |
{ | |
- parent::__construct($elementName, $elementLabel, $attributes); | |
+ HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes); | |
$this->_persistantFreeze = true; | |
$this->_type = 'textarea'; | |
} //end constructor | |
@@ -197,7 +197,7 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element | |
return $this->_getTabs() . | |
'<textarea' . $this->_getAttrString($this->_attributes) . '>' . | |
// because we wrap the form later we don't want the text indented | |
- preg_replace("/(\r\n|\n|\r)/", '
', htmlspecialchars($this->_value)) . | |
+ preg_replace("/(\r\n|\n|\r)/", '
', htmlspecialchars($this->_value)) . | |
'</textarea>'; | |
} | |
} //end func toHtml | |
diff --git a/HTML/QuickForm/xbutton.php b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/xbutton.php | |
index 5cec547..84324cc 100644 | |
--- a/HTML/QuickForm/xbutton.php | |
+++ b/home/seamus/HTML_QuickForm-3.2.15/QuickForm/xbutton.php | |
@@ -52,9 +52,9 @@ class HTML_QuickForm_xbutton extends HTML_QuickForm_element | |
* @param mixed Either a typical HTML attribute string or an associative array | |
* @access public | |
*/ | |
- function __construct($elementName = null, $elementContent = null, $attributes = null) | |
+ function HTML_QuickForm_xbutton($elementName = null, $elementContent = null, $attributes = null) | |
{ | |
- parent::__construct($elementName, null, $attributes); | |
+ $this->HTML_QuickForm_element($elementName, null, $attributes); | |
$this->setContent($elementContent); | |
$this->setPersistantFreeze(false); | |
$this->_type = 'xbutton'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment