cvs: pear /HTML_QuickForm/QuickForm date.php
| From: | Alexey Borzov | Date: | Fri, 05 Oct 2007 10:58:54 +0000 |
| Subject: | cvs: pear /HTML_QuickForm/QuickForm date.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-48751@lists.php.net to get a copy of this message | ||
avb Fri Oct 5 10:58:54 2007 UTC
Modified files:
/pear/HTML_QuickForm/QuickForm date.php
Log:
Due to a bug in code removing leading zeros it was impossible to set empty value as a default (bug
#11717)
http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm/QuickForm/date.php?r1=1.60&r2=1.61&diff_format=u
Index: pear/HTML_QuickForm/QuickForm/date.php
diff -u pear/HTML_QuickForm/QuickForm/date.php:1.60 pear/HTML_QuickForm/QuickForm/date.php:1.61
--- pear/HTML_QuickForm/QuickForm/date.php:1.60 Mon Jun 4 19:22:23 2007
+++ pear/HTML_QuickForm/QuickForm/date.php Fri Oct 5 10:58:54 2007
@@ -17,7 +17,7 @@
* @author Alexey Borzov <avb@php.net>
* @copyright 2001-2007 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
- * @version CVS: $Id: date.php,v 1.60 2007/06/04 19:22:23 avb Exp $
+ * @version CVS: $Id: date.php,v 1.61 2007/10/05 10:58:54 avb Exp $
* @link http://pear.php.net/package/HTML_QuickForm
*/
@@ -435,11 +435,28 @@
}
// }}}
+ // {{{ _trimLeadingZeros()
+
+ /**
+ * Trims leading zeros from the (numeric) string
+ *
+ * @param string A numeric string, possibly with leading zeros
+ * @return string String with leading zeros removed
+ */
+ function _trimLeadingZeros($str)
+ {
+ if (0 == strcmp($str, $this->_options['emptyOptionValue'])) {
+ return $str;
+ }
+ $trimmed = ltrim($str, '0');
+ return strlen($trimmed)? $trimmed: '0';
+ }
+
+ // }}}
// {{{ setValue()
function setValue($value)
{
- $trimLeadingZeros = create_function('$a', '$b = ltrim($a, \'0\');
return strlen($b)? $b: \'0\';');
if (empty($value)) {
$value = array();
} elseif (is_scalar($value)) {
@@ -460,14 +477,14 @@
'h' => $arr[4],
'g' => $arr[4],
'H' => $arr[5],
- 'i' => $trimLeadingZeros($arr[6]),
- 's' => $trimLeadingZeros($arr[7]),
+ 'i' => $this->_trimLeadingZeros($arr[6]),
+ 's' => $this->_trimLeadingZeros($arr[7]),
'a' => $arr[8],
'A' => $arr[9],
- 'W' => $trimLeadingZeros($arr[10])
+ 'W' => $this->_trimLeadingZeros($arr[10])
);
} else {
- $value = array_map($trimLeadingZeros, $value);
+ $value = array_map(array($this, '_trimLeadingZeros'), $value);
}
parent::setValue($value);
}