Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'libs/Zend/Validate/Sitemap/Lastmod.php')
-rw-r--r--libs/Zend/Validate/Sitemap/Lastmod.php29
1 files changed, 18 insertions, 11 deletions
diff --git a/libs/Zend/Validate/Sitemap/Lastmod.php b/libs/Zend/Validate/Sitemap/Lastmod.php
index 4f01d1a781..aa2266ecd9 100644
--- a/libs/Zend/Validate/Sitemap/Lastmod.php
+++ b/libs/Zend/Validate/Sitemap/Lastmod.php
@@ -15,15 +15,15 @@
* @category Zend
* @package Zend_Validate
* @subpackage Sitemap
- * @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: Lastmod.php 16971 2009-07-22 18:05:45Z mikaelkael $
+ * @version $Id: Lastmod.php 21365 2010-03-07 09:38:41Z thomas $
*/
/**
* @see Zend_Validate_Abstract
*/
-require_once 'Zend/Validate/Abstract.php';
+// require_once 'Zend/Validate/Abstract.php';
/**
* Validates whether a given value is valid as a sitemap <lastmod> value
@@ -33,7 +33,7 @@ require_once 'Zend/Validate/Abstract.php';
* @category Zend
* @package Zend_Validate
* @subpackage Sitemap
- * @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_Sitemap_Lastmod extends Zend_Validate_Abstract
@@ -42,13 +42,14 @@ class Zend_Validate_Sitemap_Lastmod extends Zend_Validate_Abstract
* Regular expression to use when validating
*
*/
- const LASTMOD_REGEX = '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])(T([0-1][0-9]|2[0-3])(:[0-5][0-9]){2}(\\+|-)([0-1][0-9]|2[0-3]):[0-5][0-9])?$/m';
+ const LASTMOD_REGEX = '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])(T([0-1][0-9]|2[0-3])(:[0-5][0-9])(:[0-5][0-9])?(\\+|-)([0-1][0-9]|2[0-3]):[0-5][0-9])?$/';
/**
* Validation key for not valid
*
*/
- const NOT_VALID = 'invalidSitemapLastmod';
+ const NOT_VALID = 'sitemapLastmodNotValid';
+ const INVALID = 'sitemapLastmodInvalid';
/**
* Validation failure message template definitions
@@ -56,7 +57,8 @@ class Zend_Validate_Sitemap_Lastmod extends Zend_Validate_Abstract
* @var array
*/
protected $_messageTemplates = array(
- self::NOT_VALID => "'%value%' is not a valid sitemap lastmod",
+ self::NOT_VALID => "'%value%' is no valid sitemap lastmod",
+ self::INVALID => "Invalid type given, the value should be a string",
);
/**
@@ -69,13 +71,18 @@ class Zend_Validate_Sitemap_Lastmod extends Zend_Validate_Abstract
*/
public function isValid($value)
{
- $this->_setValue($value);
-
if (!is_string($value)) {
+ $this->_error(self::INVALID);
return false;
}
- return @preg_match(self::LASTMOD_REGEX, $value) == 1;
- }
+ $this->_setValue($value);
+ $result = @preg_match(self::LASTMOD_REGEX, $value);
+ if ($result != 1) {
+ $this->_error(self::NOT_VALID);
+ return false;
+ }
+ return true;
+ }
}