Minor - format code.

1.10.x
Julio Montoya 10 years ago
parent 70ba623b6b
commit 76dca6eb4a
  1. 18
      main/inc/lib/pear/HTML/QuickForm.php
  2. 8
      main/inc/lib/pear/HTML/QuickForm/Rule/Required.php
  3. 3
      main/inc/lib/pear/HTML/QuickForm/RuleRegistry.php

@ -1066,9 +1066,6 @@ class HTML_QuickForm extends HTML_Common
return $el; return $el;
} // end func removeElement } // end func removeElement
// }}}
// {{{ addRule()
/** /**
* Adds a validation rule for the given field * Adds a validation rule for the given field
* *
@ -1159,10 +1156,8 @@ class HTML_QuickForm extends HTML_Common
'reset' => $reset, 'reset' => $reset,
'dependent' => $dependent 'dependent' => $dependent
); );
} // end func addRule }
// }}}
// {{{ addGroupRule()
/** /**
* Adds a validation rule for the given group of elements * Adds a validation rule for the given group of elements
@ -1212,7 +1207,8 @@ class HTML_QuickForm extends HTML_Common
'message' => $rule[0], 'message' => $rule[0],
'validation' => $validation, 'validation' => $validation,
'reset' => $reset, 'reset' => $reset,
'group' => $group); 'group' => $group,
);
if ('required' == $type || 'uploadedfile' == $type) { if ('required' == $type || 'uploadedfile' == $type) {
$groupObj->_required[] = $elementName; $groupObj->_required[] = $elementName;
@ -1224,6 +1220,7 @@ class HTML_QuickForm extends HTML_Common
} }
} }
} }
if ($required > 0 && count($groupObj->getElements()) == $required) { if ($required > 0 && count($groupObj->getElements()) == $required) {
$this->_required[] = $group; $this->_required[] = $group;
} }
@ -1244,12 +1241,14 @@ class HTML_QuickForm extends HTML_Common
} }
} }
$this->_rules[$group][] = array('type' => $type, $this->_rules[$group][] = array(
'type' => $type,
'format' => $format, 'format' => $format,
'message' => $arg1, 'message' => $arg1,
'validation' => $validation, 'validation' => $validation,
'howmany' => $howmany, 'howmany' => $howmany,
'reset' => $reset); 'reset' => $reset,
);
if ($type == 'required') { if ($type == 'required') {
$this->_required[] = $group; $this->_required[] = $group;
} }
@ -1620,7 +1619,6 @@ class HTML_QuickForm extends HTML_Common
} elseif (is_array($submitValue) && !isset($rule['howmany'])) { } elseif (is_array($submitValue) && !isset($rule['howmany'])) {
$result = $registry->validate($rule['type'], $submitValue, $rule['format'], true); $result = $registry->validate($rule['type'], $submitValue, $rule['format'], true);
} else { } else {
$result = $registry->validate($rule['type'], $submitValue, $rule['format'], false); $result = $registry->validate($rule['type'], $submitValue, $rule['format'], false);
} }

@ -1,5 +1,4 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Required elements validation * Required elements validation
@ -40,7 +39,7 @@ class HTML_QuickForm_Rule_Required extends HTML_QuickForm_Rule
* @access public * @access public
* @return boolean true if value is not empty * @return boolean true if value is not empty
*/ */
function validate($value, $options = null) public function validate($value, $options = null)
{ {
// It seems this is a file. // It seems this is a file.
if (is_array($value)) { if (is_array($value)) {
@ -51,19 +50,22 @@ class HTML_QuickForm_Rule_Required extends HTML_QuickForm_Rule
isset($value['error']) isset($value['error'])
){ ){
if (empty($value['tmp_name'])) { if (empty($value['tmp_name'])) {
return false; return false;
} }
} }
} else { } else {
if ((string)$value == '') { if ((string)$value == '') {
return false; return false;
} }
} }
return true; return true;
} }
function getValidationScript($options = null) public function getValidationScript($options = null)
{ {
return array('', "{jsVar} == ''"); return array('', "{jsVar} == ''");
} }

@ -187,7 +187,6 @@ class HTML_QuickForm_RuleRegistry
function validate($ruleName, $values, $options = null, $multiple = false) function validate($ruleName, $values, $options = null, $multiple = false)
{ {
$rule =& $this->getRule($ruleName); $rule =& $this->getRule($ruleName);
if (is_array($values) && !$multiple) { if (is_array($values) && !$multiple) {
$result = 0; $result = 0;
foreach ($values as $value) { foreach ($values as $value) {
@ -195,8 +194,10 @@ class HTML_QuickForm_RuleRegistry
$result++; $result++;
} }
} }
return ($result == 0) ? false : $result; return ($result == 0) ? false : $result;
} else { } else {
return $rule->validate($values, $options); return $rule->validate($values, $options);
} }
} // end func validate } // end func validate

Loading…
Cancel
Save