Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Validator / Sitemap / Lastmod.php
blob379824515f56649c0c7075420f9b4209aaf9d0ac
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Validator\Sitemap;
12 use Zend\Stdlib\ErrorHandler;
13 use Zend\Validator\AbstractValidator;
15 /**
16 * Validates whether a given value is valid as a sitemap <lastmod> value
18 * @link http://www.sitemaps.org/protocol.php Sitemaps XML format
20 class Lastmod extends AbstractValidator
22 /**
23 * Regular expression to use when validating
26 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])?$/';
28 /**
29 * Validation key for not valid
32 const NOT_VALID = 'sitemapLastmodNotValid';
33 const INVALID = 'sitemapLastmodInvalid';
35 /**
36 * Validation failure message template definitions
38 * @var array
40 protected $messageTemplates = array(
41 self::NOT_VALID => "The input is not a valid sitemap lastmod",
42 self::INVALID => "Invalid type given. String expected",
45 /**
46 * Validates if a string is valid as a sitemap lastmod
48 * @link http://www.sitemaps.org/protocol.php#lastmoddef <lastmod>
50 * @param string $value value to validate
51 * @return bool
53 public function isValid($value)
55 if (!is_string($value)) {
56 $this->error(self::INVALID);
57 return false;
60 $this->setValue($value);
61 ErrorHandler::start();
62 $result = preg_match(self::LASTMOD_REGEX, $value);
63 ErrorHandler::stop();
64 if ($result != 1) {
65 $this->error(self::NOT_VALID);
66 return false;
69 return true;