From 1378f79297baa84590738839ec11cef90ac21bc4 Mon Sep 17 00:00:00 2001 From: robocoder Date: Fri, 29 Jan 2010 09:02:30 +0000 Subject: update wrt Zend Framework 1.10.0; remove svn:eol-style property git-svn-id: http://dev.piwik.org/svn/trunk@1813 59fd770c-687e-43c8-a1e3-f5a4ff64c105 --- libs/Zend/Validate/Int.php | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'libs/Zend/Validate/Int.php') diff --git a/libs/Zend/Validate/Int.php b/libs/Zend/Validate/Int.php index 1e34ee3427..4c14f25e47 100644 --- a/libs/Zend/Validate/Int.php +++ b/libs/Zend/Validate/Int.php @@ -14,9 +14,9 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Int.php 17470 2009-08-08 22:27:09Z thomas $ + * @version $Id: Int.php 20532 2010-01-22 20:18:23Z thomas $ */ /** @@ -32,7 +32,7 @@ require_once 'Zend/Locale/Format.php'; /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Int extends Zend_Validate_Abstract @@ -44,8 +44,8 @@ class Zend_Validate_Int extends Zend_Validate_Abstract * @var array */ protected $_messageTemplates = array( - self::INVALID => "Invalid type given, value should be a string or a integer", - self::NOT_INT => "'%value%' does not appear to be an integer" + self::INVALID => "Invalid type given, value should be string or integer", + self::NOT_INT => "'%value%' does not appear to be an integer", ); protected $_locale; @@ -53,10 +53,29 @@ class Zend_Validate_Int extends Zend_Validate_Abstract /** * Constructor for the integer validator * - * @param string|Zend_Locale $locale + * @param string|Zend_Config|Zend_Locale $locale */ public function __construct($locale = null) { + if ($locale instanceof Zend_Config) { + $locale = $locale->toArray(); + } + + if (is_array($locale)) { + if (array_key_exists('locale', $locale)) { + $locale = $locale['locale']; + } else { + $locale = null; + } + } + + if (empty($locale)) { + require_once 'Zend/Registry.php'; + if (Zend_Registry::isRegistered('Zend_Locale')) { + $locale = Zend_Registry::get('Zend_Locale'); + } + } + if ($locale !== null) { $this->setLocale($locale); } @@ -97,6 +116,10 @@ class Zend_Validate_Int extends Zend_Validate_Abstract return false; } + if (is_int($value)) { + return true; + } + $this->_setValue($value); if ($this->_locale === null) { $locale = localeconv(); @@ -110,8 +133,7 @@ class Zend_Validate_Int extends Zend_Validate_Abstract } else { try { - if (!Zend_Locale_Format::isInteger($value, array('locale' => 'en')) && - !Zend_Locale_Format::isInteger($value, array('locale' => $this->_locale))) { + if (!Zend_Locale_Format::isInteger($value, array('locale' => $this->_locale))) { $this->_error(self::NOT_INT); return false; } -- cgit v1.2.3