cvs: pear /HTML_QuickForm QuickForm.php
| From: | Jason Rust | Date: | Fri, 07 Jun 2002 19:29:35 +0000 |
| Subject: | cvs: pear /HTML_QuickForm QuickForm.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-4485@lists.php.net to get a copy of this message | ||
jrust Fri Jun 7 15:29:35 2002 EDT
Modified files:
/pear/HTML_QuickForm QuickForm.php
Log:
Changed while loops to foreach
Added ability to apply a filter in setConstant()
Index: pear/HTML_QuickForm/QuickForm.php
diff -u pear/HTML_QuickForm/QuickForm.php:1.20 pear/HTML_QuickForm/QuickForm.php:1.21
--- pear/HTML_QuickForm/QuickForm.php:1.20 Fri May 31 07:34:08 2002
+++ pear/HTML_QuickForm/QuickForm.php Fri Jun 7 15:29:34 2002
@@ -17,7 +17,7 @@
// | Bertrand Mansion <bmansion@mamasam.com> |
// +----------------------------------------------------------------------+
//
-// $Id: QuickForm.php,v 1.20 2002/05/31 11:34:08 mansion Exp $
+// $Id: QuickForm.php,v 1.21 2002/06/07 19:29:34 jrust Exp $
require_once("PEAR.php");
require_once("HTML/Common.php");
@@ -402,14 +402,14 @@
if (is_array($defaultValues)) {
if (isset($filter)) {
if (is_array($filter)) {
- while(list(,$val) = each($filter)) {
+ foreach ($filter as $val) {
$defaultValues = $this->_recursiveFilter($val, $defaultValues);
}
} else {
$defaultValues = $this->_recursiveFilter($filter, $defaultValues);
}
}
- while(list($key, $value) = each($defaultValues)) {
+ foreach ($defaultValues as $key => $value) {
$this->_defaultValues[$key] = $value;
}
}
@@ -423,15 +423,25 @@
* 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
+ *
* @since 2.0
* @access public
* @return void
*/
- function setConstants($constantValues=null)
+ function setConstants($constantValues=null, $filter=null)
{
if (is_array($constantValues)) {
+ if (isset($filter)) {
+ if (is_array($filter)) {
+ foreach ($filter as $val) {
+ $constantValues = $this->_recursiveFilter($val, $constantValues);
+ }
+ } else {
+ $constantValues = $this->_recursiveFilter($filter, $constantValues);
+ }
+ }
foreach ($constantValues as $key => $value) {
- $value = is_string($value) ? stripslashes($value) : $value;
$this->_constantValues[$key] = $value;
}
}
@@ -1692,7 +1702,7 @@
{
$html = "";
reset($this->_elements);
- while (list(, $element) = each($this->_elements)) {
+ foreach ($this->_elements as $element) {
if (isset($element["header"])) {
$html .= $this->_buildHeader($element);
} elseif (isset($element["data"])) {
@@ -1924,4 +1934,4 @@
// }}}
}
-?>
\ No newline at end of file
+?>