|
|
|
@@ -398,7 +398,7 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
$this->setConstants($datasource->constantValues($this), $constantsFilter);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return PEAR::raiseError(null, QUICKFORM_INVALID_DATASOURCE, null, E_USER_WARNING, "Datasource is not an object in QuickForm::setDatasource()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return self::raiseError(null, QUICKFORM_INVALID_DATASOURCE, null, E_USER_WARNING, "Datasource is not an object in QuickForm::setDatasource()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
}
|
|
|
|
|
} // end func setDatasource
|
|
|
|
|
|
|
|
|
@@ -421,13 +421,13 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
if (is_array($filter) && (2 != count($filter) || !is_callable($filter))) {
|
|
|
|
|
foreach ($filter as $val) {
|
|
|
|
|
if (!is_callable($val)) {
|
|
|
|
|
return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setDefaults()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return self::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setDefaults()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
} else {
|
|
|
|
|
$defaultValues = $this->_recursiveFilter($val, $defaultValues);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} elseif (!is_callable($filter)) {
|
|
|
|
|
return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setDefaults()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return self::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setDefaults()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
} else {
|
|
|
|
|
$defaultValues = $this->_recursiveFilter($filter, $defaultValues);
|
|
|
|
|
}
|
|
|
|
@@ -460,13 +460,13 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
if (is_array($filter) && (2 != count($filter) || !is_callable($filter))) {
|
|
|
|
|
foreach ($filter as $val) {
|
|
|
|
|
if (!is_callable($val)) {
|
|
|
|
|
return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setConstants()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return self::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setConstants()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
} else {
|
|
|
|
|
$constantValues = $this->_recursiveFilter($val, $constantValues);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} elseif (!is_callable($filter)) {
|
|
|
|
|
return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setConstants()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return self::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setConstants()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
} else {
|
|
|
|
|
$constantValues = $this->_recursiveFilter($filter, $constantValues);
|
|
|
|
|
}
|
|
|
|
@@ -557,7 +557,7 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
{
|
|
|
|
|
$type = strtolower($type);
|
|
|
|
|
if (!HTML_QuickForm::isTypeRegistered($type)) {
|
|
|
|
|
$error = PEAR::raiseError(null, QUICKFORM_UNREGISTERED_ELEMENT, null, E_USER_WARNING, "Element '$type' does not exist in HTML_QuickForm::_loadElement()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
$error = self::raiseError(null, QUICKFORM_UNREGISTERED_ELEMENT, null, E_USER_WARNING, "Element '$type' does not exist in HTML_QuickForm::_loadElement()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return $error;
|
|
|
|
|
}
|
|
|
|
|
$className = $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'][$type][1];
|
|
|
|
@@ -614,7 +614,7 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
$elKeys = array_keys($this->_elements);
|
|
|
|
|
$this->_duplicateIndex[$elementName][] = end($elKeys);
|
|
|
|
|
} else {
|
|
|
|
|
$error = PEAR::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, "Element '$elementName' already exists in HTML_QuickForm::addElement()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
$error = self::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, "Element '$elementName' already exists in HTML_QuickForm::addElement()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return $error;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
@@ -650,10 +650,10 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
function &insertElementBefore(&$element, $nameAfter)
|
|
|
|
|
{
|
|
|
|
|
if (!empty($this->_duplicateIndex[$nameAfter])) {
|
|
|
|
|
$error = PEAR::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, 'Several elements named "' . $nameAfter . '" exist in HTML_QuickForm::insertElementBefore().', 'HTML_QuickForm_Error', true);
|
|
|
|
|
$error = self::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, 'Several elements named "' . $nameAfter . '" exist in HTML_QuickForm::insertElementBefore().', 'HTML_QuickForm_Error', true);
|
|
|
|
|
return $error;
|
|
|
|
|
} elseif (!$this->elementExists($nameAfter)) {
|
|
|
|
|
$error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$nameAfter' does not exist in HTML_QuickForm::insertElementBefore()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
$error = self::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$nameAfter' does not exist in HTML_QuickForm::insertElementBefore()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return $error;
|
|
|
|
|
}
|
|
|
|
|
$elementName = $element->getName();
|
|
|
|
@@ -662,7 +662,7 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
// Like in addElement(), check that it's not an incompatible duplicate
|
|
|
|
|
if (!empty($elementName) && isset($this->_elementIndex[$elementName])) {
|
|
|
|
|
if ($this->_elements[$this->_elementIndex[$elementName]]->getType() != $element->getType()) {
|
|
|
|
|
$error = PEAR::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, "Element '$elementName' already exists in HTML_QuickForm::insertElementBefore()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
$error = self::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, "Element '$elementName' already exists in HTML_QuickForm::insertElementBefore()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return $error;
|
|
|
|
|
}
|
|
|
|
|
$duplicate = true;
|
|
|
|
@@ -745,7 +745,7 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
if (isset($this->_elementIndex[$element])) {
|
|
|
|
|
return $this->_elements[$this->_elementIndex[$element]];
|
|
|
|
|
} else {
|
|
|
|
|
$error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::getElement()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
$error = self::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::getElement()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return $error;
|
|
|
|
|
}
|
|
|
|
|
} // end func getElement
|
|
|
|
@@ -768,7 +768,7 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
function &getElementValue($element)
|
|
|
|
|
{
|
|
|
|
|
if (!isset($this->_elementIndex[$element])) {
|
|
|
|
|
$error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::getElementValue()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
$error = self::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::getElementValue()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return $error;
|
|
|
|
|
}
|
|
|
|
|
$value = $this->_elements[$this->_elementIndex[$element]]->getValue();
|
|
|
|
@@ -983,7 +983,7 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
function &removeElement($elementName, $removeRules = true)
|
|
|
|
|
{
|
|
|
|
|
if (!isset($this->_elementIndex[$elementName])) {
|
|
|
|
|
$error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$elementName' does not exist in HTML_QuickForm::removeElement()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
$error = self::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$elementName' does not exist in HTML_QuickForm::removeElement()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return $error;
|
|
|
|
|
}
|
|
|
|
|
$el =& $this->_elements[$this->_elementIndex[$elementName]];
|
|
|
|
@@ -1024,17 +1024,17 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
{
|
|
|
|
|
if (!$force) {
|
|
|
|
|
if (!is_array($element) && !$this->elementExists($element)) {
|
|
|
|
|
return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return self::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
} elseif (is_array($element)) {
|
|
|
|
|
foreach ($element as $el) {
|
|
|
|
|
if (!$this->elementExists($el)) {
|
|
|
|
|
return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$el' does not exist in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return self::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$el' does not exist in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (false === ($newName = $this->isRuleRegistered($type, true))) {
|
|
|
|
|
return PEAR::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return self::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
} elseif (is_string($newName)) {
|
|
|
|
|
$type = $newName;
|
|
|
|
|
}
|
|
|
|
@@ -1089,7 +1089,7 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
function addGroupRule($group, $arg1, $type='', $format=null, $howmany=0, $validation = 'server', $reset = false)
|
|
|
|
|
{
|
|
|
|
|
if (!$this->elementExists($group)) {
|
|
|
|
|
return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Group '$group' does not exist in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return self::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Group '$group' does not exist in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$groupObj =& $this->getElement($group);
|
|
|
|
@@ -1103,7 +1103,7 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
$reset = isset($rule[4]) && $rule[4];
|
|
|
|
|
$type = $rule[1];
|
|
|
|
|
if (false === ($newName = $this->isRuleRegistered($type, true))) {
|
|
|
|
|
return PEAR::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return self::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
} elseif (is_string($newName)) {
|
|
|
|
|
$type = $newName;
|
|
|
|
|
}
|
|
|
|
@@ -1131,7 +1131,7 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
}
|
|
|
|
|
} elseif (is_string($arg1)) {
|
|
|
|
|
if (false === ($newName = $this->isRuleRegistered($type, true))) {
|
|
|
|
|
return PEAR::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return self::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
} elseif (is_string($newName)) {
|
|
|
|
|
$type = $newName;
|
|
|
|
|
}
|
|
|
|
@@ -1179,7 +1179,7 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
function addFormRule($rule)
|
|
|
|
|
{
|
|
|
|
|
if (!is_callable($rule)) {
|
|
|
|
|
return PEAR::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, 'Callback function does not exist in HTML_QuickForm::addFormRule()', 'HTML_QuickForm_Error', true);
|
|
|
|
|
return self::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, 'Callback function does not exist in HTML_QuickForm::addFormRule()', 'HTML_QuickForm_Error', true);
|
|
|
|
|
}
|
|
|
|
|
$this->_formRules[] = $rule;
|
|
|
|
|
}
|
|
|
|
@@ -1198,7 +1198,7 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
function applyFilter($element, $filter)
|
|
|
|
|
{
|
|
|
|
|
if (!is_callable($filter)) {
|
|
|
|
|
return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::applyFilter()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return self::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::applyFilter()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
}
|
|
|
|
|
if ($element == '__ALL__') {
|
|
|
|
|
$this->_submitValues = $this->_recursiveFilter($filter, $this->_submitValues);
|
|
|
|
@@ -1528,7 +1528,7 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
if (is_array($res)) {
|
|
|
|
|
$this->_errors += $res;
|
|
|
|
|
} else {
|
|
|
|
|
return PEAR::raiseError(null, QUICKFORM_ERROR, null, E_USER_WARNING, 'Form rule callback returned invalid value in HTML_QuickForm::validate()', 'HTML_QuickForm_Error', true);
|
|
|
|
|
return self::raiseError(null, QUICKFORM_ERROR, null, E_USER_WARNING, 'Form rule callback returned invalid value in HTML_QuickForm::validate()', 'HTML_QuickForm_Error', true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -1568,7 +1568,7 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!empty($elementList)) {
|
|
|
|
|
return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Nonexistant element(s): '" . implode("', '", array_keys($elementList)) . "' in HTML_QuickForm::freeze()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return self::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Nonexistant element(s): '" . implode("', '", array_keys($elementList)) . "' in HTML_QuickForm::freeze()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
} // end func freeze
|
|
|
|
@@ -1603,7 +1603,7 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
function process($callback, $mergeFiles = true)
|
|
|
|
|
{
|
|
|
|
|
if (!is_callable($callback)) {
|
|
|
|
|
return PEAR::raiseError(null, QUICKFORM_INVALID_PROCESS, null, E_USER_WARNING, "Callback function does not exist in QuickForm::process()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return self::raiseError(null, QUICKFORM_INVALID_PROCESS, null, E_USER_WARNING, "Callback function does not exist in QuickForm::process()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
}
|
|
|
|
|
$values = ($mergeFiles === true) ? HTML_QuickForm::arrayMerge($this->_submitValues, $this->_submitFiles) : $this->_submitValues;
|
|
|
|
|
return call_user_func($callback, $values);
|
|
|
|
@@ -1826,7 +1826,7 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
function exportValue($element)
|
|
|
|
|
{
|
|
|
|
|
if (!isset($this->_elementIndex[$element])) {
|
|
|
|
|
return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::getElementValue()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
return self::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::getElementValue()", 'HTML_QuickForm_Error', true);
|
|
|
|
|
}
|
|
|
|
|
$value = $this->_elements[$this->_elementIndex[$element]]->exportValue($this->_submitValues, false);
|
|
|
|
|
if (isset($this->_duplicateIndex[$element])) {
|
|
|
|
@@ -1912,7 +1912,7 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
* @param mixed result code
|
|
|
|
|
* @return bool whether $value is an error
|
|
|
|
|
*/
|
|
|
|
|
function isError($value)
|
|
|
|
|
static function isError($value)
|
|
|
|
|
{
|
|
|
|
|
return (is_object($value) && is_a($value, 'html_quickform_error'));
|
|
|
|
|
} // end func isError
|
|
|
|
@@ -1927,7 +1927,7 @@ class HTML_QuickForm extends HTML_Common {
|
|
|
|
|
* @param int error code
|
|
|
|
|
* @return string error message
|
|
|
|
|
*/
|
|
|
|
|
function errorMessage($value)
|
|
|
|
|
static function errorMessage($value)
|
|
|
|
|
{
|
|
|
|
|
// make the variable static so that it only has to do the defining on the first call
|
|
|
|
|
static $errorMessages;
|
|
|
|
|