summaryrefslogtreecommitdiff
path: root/kohana/helpers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-12-17 19:28:26 +0000
committerBharat Mediratta <bharat@menalto.com>2008-12-17 19:28:26 +0000
commitfe396410894f9fcf430e31216312f70db800d96e (patch)
treefc1222c074e0f8ffd2d952688353f5bf79e360f5 /kohana/helpers
parent093fb407a839b1bdacd0cd6036b349a42dcfea7d (diff)
Update Kohana code to r3799 from their svn head. All tests pass.
Resolved upstream tickets: http://dev.kohanaphp.com/ticket/972 Command: svn merge -c19275 vendor/kohana/modified/kohana trunk/kohana
Diffstat (limited to 'kohana/helpers')
-rw-r--r--kohana/helpers/form.php4
-rw-r--r--kohana/helpers/html.php2
-rw-r--r--kohana/helpers/valid.php13
3 files changed, 15 insertions, 4 deletions
diff --git a/kohana/helpers/form.php b/kohana/helpers/form.php
index 30753f1e..5162a1ad 100644
--- a/kohana/helpers/form.php
+++ b/kohana/helpers/form.php
@@ -241,6 +241,7 @@ class form_Core {
*/
public static function dropdown($data, $options = NULL, $selected = NULL, $extra = '')
{
+
if ( ! is_array($data))
{
$data = array('name' => $data);
@@ -266,6 +267,9 @@ class form_Core {
// Key should always be a string
$key = (string) $key;
+ // Selected must always be a string
+ $selected = (string) $selected;
+
if (is_array($val))
{
$input .= '<optgroup label="'.$key.'">'."\n";
diff --git a/kohana/helpers/html.php b/kohana/helpers/html.php
index b11ea755..d1f09612 100644
--- a/kohana/helpers/html.php
+++ b/kohana/helpers/html.php
@@ -307,7 +307,7 @@ class html_Core {
$length = strlen($suffix);
- if (substr_compare($href, $suffix, -$length, $length, FALSE) !== 0)
+ if ( $length > 0 AND substr_compare($href, $suffix, -$length, $length, FALSE) !== 0)
{
// Add the defined suffix
$href .= $suffix;
diff --git a/kohana/helpers/valid.php b/kohana/helpers/valid.php
index d71dbcae..3d3206c8 100644
--- a/kohana/helpers/valid.php
+++ b/kohana/helpers/valid.php
@@ -87,10 +87,12 @@ class valid_Core {
* @param boolean allow IPv6 addresses
* @return boolean
*/
- public static function ip($ip, $ipv6 = FALSE)
+ public static function ip($ip, $ipv6 = FALSE, $allow_private = FALSE)
{
- // Do not allow private and reserved range IPs
+ // By default do not allow private and reserved range IPs
$flags = FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE;
+ if ($allow_private === TRUE)
+ $flags = FILTER_FLAG_NO_RES_RANGE;
if ($ipv6 === TRUE)
return (bool) filter_var($ip, FILTER_VALIDATE_IP, $flags);
@@ -264,12 +266,17 @@ class valid_Core {
/**
* Checks whether a string is a valid number (negative and decimal numbers allowed).
*
+ * @see Uses locale conversion to allow decimal point to be locale specific.
+ * @see http://www.php.net/manual/en/function.localeconv.php
+ *
* @param string input string
* @return boolean
*/
public static function numeric($str)
{
- return (is_numeric($str) AND preg_match('/^[-0-9.]++$/D', (string) $str));
+ // Use localeconv to set the decimal_point value: Usually a comma or period.
+ $locale = localeconv();
+ return (preg_match('/^[-0-9'.$locale['decimal_point'].']++$/D', (string) $str));
}
/**