Skip to content

Commit

Permalink
MDL-23486 fixed regression, sorrrrry
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Jul 24, 2010
1 parent ff85f90 commit e56458a
Showing 1 changed file with 42 additions and 40 deletions.
82 changes: 42 additions & 40 deletions lib/pear/HTML/QuickForm.php
Expand Up @@ -22,7 +22,7 @@
require_once('PEAR.php');
require_once('HTML/Common.php');

$GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'] =
$GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'] =
array(
'group' =>array('HTML/QuickForm/group.php','HTML_QuickForm_group'),
'hidden' =>array('HTML/QuickForm/hidden.php','HTML_QuickForm_hidden'),
Expand Down Expand Up @@ -126,23 +126,23 @@ class HTML_QuickForm extends HTML_Common {
* @since 1.0
* @var array
* @access private
*/
*/
var $_required = array();

/**
* Prefix message in javascript alert if error
* @since 1.0
* @var string
* @access public
*/
*/
var $_jsPrefix = 'Invalid information entered.';

/**
* Postfix message in javascript alert if error
* @since 1.0
* @var string
* @access public
*/
*/
var $_jsPostfix = 'Please correct these fields.';

/**
Expand Down Expand Up @@ -298,7 +298,7 @@ function HTML_QuickForm($formName='', $method='post', $action='', $target='', $a
default:
$this->_maxFileSize = $matches['1'];
}
}
}
} // end constructor

// }}}
Expand Down Expand Up @@ -446,8 +446,8 @@ function setDefaults($defaultValues = null, $filter = null)
* Initializes constant form values.
* These values won't get overridden by POST or GET vars
*
* @param array $constantValues values used to fill the form
* @param mixed $filter (optional) filter(s) to apply to all default values
* @param array $constantValues values used to fill the form
* @param mixed $filter (optional) filter(s) to apply to all default values
*
* @since 2.0
* @access public
Expand Down Expand Up @@ -522,8 +522,8 @@ function getMaxFileSize()

/**
* Creates a new form element of the given type.
*
* This method accepts variable number of parameters, their
*
* This method accepts variable number of parameters, their
* meaning and count depending on $elementType
*
* @param string $elementType type of element to add (text, textarea, file...)
Expand Down Expand Up @@ -581,9 +581,9 @@ function &_loadElement($event, $type, $args)

/**
* Adds an element into the form
*
* If $element is a string representing element type, then this
* method accepts variable number of parameters, their meaning
*
* If $element is a string representing element type, then this
* method accepts variable number of parameters, their meaning
* and count depending on $element
*
* @param mixed $element element object or type of element to add (text, textarea, file...)
Expand Down Expand Up @@ -628,7 +628,7 @@ function &addElement($element)

return $elementObject;
} // end func addElement

// }}}
// {{{ insertElementBefore()

Expand Down Expand Up @@ -725,7 +725,7 @@ function &addGroup($elements, $name=null, $groupLabel='', $separator=null, $appe
$group =& $this->addElement('group', $name, $groupLabel, $elements, $separator, $appendName);
return $group;
} // end func addGroup

// }}}
// {{{ &getElement()

Expand Down Expand Up @@ -753,8 +753,8 @@ function &getElement($element)

/**
* Returns the element's raw value
*
* This returns the value as submitted by the form (not filtered)
*
* This returns the value as submitted by the form (not filtered)
* or set via setDefaults() or setConstants()
*
* @param string $element Element name
Expand Down Expand Up @@ -794,7 +794,7 @@ function &getElementValue($element)
* @since 2.0
* @access public
* @return mixed submitted element value or null if not set
*/
*/
function getSubmitValue($elementName)
{
$value = null;
Expand Down Expand Up @@ -831,7 +831,7 @@ function getSubmitValue($elementName)
}
}
}

// This is only supposed to work for groups with appendName = false
if (null === $value && 'group' == $this->getElementType($elementName)) {
$group =& $this->getElement($elementName);
Expand Down Expand Up @@ -889,7 +889,7 @@ function getElementError($element)
return $this->_errors[$element];
}
} // end func getElementError

// }}}
// {{{ setElementError()

Expand All @@ -898,7 +898,7 @@ function getElementError($element)
*
* @param string $element Name of form element to set error for
* @param string $message Error message, if empty then removes the current error message
* @since 1.0
* @since 1.0
* @access public
* @return void
*/
Expand All @@ -910,7 +910,7 @@ function setElementError($element, $message = null)
unset($this->_errors[$element]);
}
} // end func setElementError

// }}}
// {{{ getElementType()

Expand Down Expand Up @@ -968,11 +968,11 @@ function updateElementAttr($elements, $attrs)
* Removes an element
*
* The method "unlinks" an element from the form, returning the reference
* to the element object. If several elements named $elementName exist,
* to the element object. If several elements named $elementName exist,
* it removes the first one, leaving the others intact.
*
*
* @param string $elementName The element name
* @param boolean $removeRules True if rules for this element are to be removed too
* @param boolean $removeRules True if rules for this element are to be removed too
* @access public
* @since 2.0
* @return object HTML_QuickForm_element a reference to the removed element
Expand Down Expand Up @@ -1004,7 +1004,7 @@ function &removeElement($elementName, $removeRules = true)
* Adds a validation rule for the given field
*
* If the element is in fact a group, it will be considered as a whole.
* To validate grouped elements as separated entities,
* To validate grouped elements as separated entities,
* use addGroupRule instead of addRule.
*
* @param string $element Form element name
Expand Down Expand Up @@ -1108,7 +1108,7 @@ function addGroupRule($group, $arg1, $type='', $format=null, $howmany=0, $valida

$this->_rules[$elementName][] = array(
'type' => $type,
'format' => $format,
'format' => $format,
'message' => $rule[0],
'validation' => $validation,
'reset' => $reset,
Expand Down Expand Up @@ -1145,7 +1145,7 @@ function addGroupRule($group, $arg1, $type='', $format=null, $howmany=0, $valida
}

$this->_rules[$group][] = array('type' => $type,
'format' => $format,
'format' => $format,
'message' => $arg1,
'validation' => $validation,
'howmany' => $howmany,
Expand All @@ -1163,13 +1163,13 @@ function addGroupRule($group, $arg1, $type='', $format=null, $howmany=0, $valida
// {{{ addFormRule()

/**
* Adds a global validation rule
*
* Adds a global validation rule
*
* This should be used when for a rule involving several fields or if
* you want to use some completely custom validation for your form.
* The rule function/method should return true in case of successful
* The rule function/method should return true in case of successful
* validation and array('element name' => 'error') when there were errors.
*
*
* @access public
* @param mixed Callback, either function name or array(&$object, 'method')
* @throws HTML_QuickForm_Error
Expand All @@ -1181,7 +1181,7 @@ function addFormRule($rule)
}
$this->_formRules[] = $rule;
}

// }}}
// {{{ applyFilter()

Expand Down Expand Up @@ -1415,7 +1415,7 @@ function setJsWarnings($pref, $post)
$this->_jsPrefix = $pref;
$this->_jsPostfix = $post;
} // end func setJsWarnings

// }}}
// {{{ setRequiredNote()

Expand Down Expand Up @@ -1458,7 +1458,7 @@ function getRequiredNote()
*/
function validate()
{
if (count($this->_rules) == 0 && count($this->_formRules) == 0 &&
if (count($this->_rules) == 0 && count($this->_formRules) == 0 &&
$this->isSubmitted()) {
return (0 == count($this->_errors));
} elseif (!$this->isSubmitted()) {
Expand Down Expand Up @@ -1506,6 +1506,8 @@ function validate()
//horrible horrible hack
if (!isset($submitValue['text']) or $submitValue['text'] === '') {
$result = false;
} else {
$result = true;
}
} elseif (is_array($submitValue) && !isset($rule['howmany'])) {
$result = $registry->validate($rule['type'], $submitValue, $rule['format'], true);
Expand Down Expand Up @@ -1573,7 +1575,7 @@ function freeze($elementList=null)
}
return true;
} // end func freeze

// }}}
// {{{ isFrozen()

Expand Down Expand Up @@ -1752,7 +1754,7 @@ function getValidationScript()
if (count($test) > 0) {
return
"\n<script type=\"text/javascript\">\n" .
"//<![CDATA[\n" .
"//<![CDATA[\n" .
"function validate_" . $this->_attributes['id'] . "(frm) {\n" .
" var value = '';\n" .
" var errFlag = new Array();\n" .
Expand Down Expand Up @@ -1796,7 +1798,7 @@ function getSubmitValues($mergeFiles = false)
* Returns the form's contents in an array.
*
* The description of the array structure is in HTML_QuickForm_Renderer_Array docs
*
*
* @since 2.0
* @access public
* @param bool Whether to collect hidden elements (passed to the Renderer's constructor)
Expand All @@ -1815,7 +1817,7 @@ function toArray($collectHidden = false)

/**
* Returns a 'safe' element's value
*
*
* This method first tries to find a cleaned-up submitted value,
* it will return a value set by setValue()/setDefaults()/setConstants()
* if submitted value does not exist for the given element.
Expand Down Expand Up @@ -1850,9 +1852,9 @@ function exportValue($element)
/**
* Returns 'safe' elements' values
*
* Unlike getSubmitValues(), this will return only the values
* Unlike getSubmitValues(), this will return only the values
* corresponding to the elements present in the form.
*
*
* @param mixed Array/string of element names, whose values we want. If not set then return all elements.
* @access public
* @return array An assoc array of elements' values
Expand Down

0 comments on commit e56458a

Please sign in to comment.