return PEAR::raiseError(null, QUICKFORM_INVALID_DATASOURCE, null, E_USER_WARNING, "Datasource is not an object in QuickForm::setDatasource()", 'HTML_QuickForm_Error', true);
}
}
// }}}
// {{{ setDefaults()
@ -415,13 +386,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);
throw new \Exception("Callback function does not exist in QuickForm::setDefaults()");
return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setDefaults()", 'HTML_QuickForm_Error', true);
throw new \Exception("Callback function does not exist in QuickForm::setDefaults()");
@ -450,20 +421,20 @@ class HTML_QuickForm extends HTML_Common
* @return void
* @throws HTML_QuickForm_Error
*/
function setConstants($constantValues = null, $filter = null)
public function setConstants($constantValues = null, $filter = null)
{
if (is_array($constantValues)) {
if (isset($filter)) {
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);
throw new \Exception("Callback function does not exist in QuickForm::setConstants()");
return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setConstants()", 'HTML_QuickForm_Error', true);
throw new \Exception("Callback function does not exist in QuickForm::setConstants()");
"Element '$elementName' already exists in HTML_QuickForm::addElement()", 'HTML_QuickForm_Error',
true
);
return $error;
throw new \Exception("Element '$elementName' already exists in HTML_QuickForm::addElement()");
}
} else {
$this->_elements[] =& $elementObject;
@ -697,14 +660,13 @@ class HTML_QuickForm extends HTML_Common
* @return HTML_QuickForm_element reference to inserted element
* @throws HTML_QuickForm_Error
*/
function &insertElementBefore(&$element, $nameAfter)
public 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);
return $error;
throw new \Exception('Several elements named "' . $nameAfter . '" exist in HTML_QuickForm::insertElementBefore().');
} 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);
return $error;
throw new \Exception("Element '$nameAfter' does not exist in HTML_QuickForm::insertElementBefore()");
}
$elementName = $element->getName();
$targetIdx = $this->_elementIndex[$nameAfter];
@ -712,8 +674,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_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::getElement()", 'HTML_QuickForm_Error', true);
return $error;
throw new \Exception("Element '$element' does not exist in HTML_QuickForm::getElement()");
}
} // end func getElement
// }}}
// {{{ &getElementValue()
}
/**
* Returns the element's raw value
@ -816,16 +774,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
);
return $error;
throw new \Exception("Element '$element' does not exist in HTML_QuickForm::getElementValue()");
@ -1059,8 +1008,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);
return $error;
throw new \Exception("Element '$elementName' does not exist in HTML_QuickForm::removeElement()");
@ -1190,7 +1138,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);
throw new \Exception("Rule '$type' is not registered in HTML_QuickForm::addGroupRule()");
} elseif (is_string($newName)) {
$type = $newName;
}
@ -1220,7 +1168,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);
throw new \Exception("Rule '$type' is not registered in HTML_QuickForm::addGroupRule()");
} elseif (is_string($newName)) {
$type = $newName;
}
@ -1270,7 +1218,7 @@ class HTML_QuickForm extends HTML_Common
public 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);
throw new \Exception('Callback function does not exist in HTML_QuickForm::addFormRule()');
}
$this->_formRules[] = $rule;
}
@ -1290,7 +1238,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);
throw new \Exception("Callback function does not exist in QuickForm::applyFilter()");
@ -1627,7 +1575,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);
throw new \Exception('Form rule callback returned invalid value in HTML_QuickForm::validate()');
}
}
}
@ -1664,8 +1612,9 @@ class HTML_QuickForm extends HTML_Common
throw new \Exception("Nonexistant element(s): '" . implode("', '", array_keys($elementList)) . "' in HTML_QuickForm::freeze()");
}
return true;
}
@ -1694,9 +1643,10 @@ class HTML_QuickForm extends HTML_Common
public 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);
throw new \Exception("Callback function does not exist in QuickForm::process()");
@ -1901,7 +1851,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);
throw new \Exception("Element '$element' does not exist in HTML_QuickForm::getElementValue()");
throw new \Exception('HTML_QuickForm_Controller: Unhandled action "' . $actionName . '" in page "' . $page->getAttribute('id') . '"');
} // switch
}
@ -410,13 +412,13 @@ class HTML_QuickForm_Controller
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_Controller::_setDefaultsOrConstants()", 'HTML_QuickForm_Error', true);
throw new \Exception("Callback function does not exist in QuickForm_Controller::_setDefaultsOrConstants()");
return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm_Controller::_setDefaultsOrConstants()", 'HTML_QuickForm_Error', true);
throw new \Exception("Callback function does not exist in QuickForm_Controller::_setDefaultsOrConstants()");