~ubuntu-branches/ubuntu/utopic/zendframework/utopic

« back to all changes in this revision

Viewing changes to library/Zend/Validate/Sitemap/Lastmod.php

  • Committer: Bazaar Package Importer
  • Author(s): Frank Habermann
  • Date: 2010-04-28 20:10:00 UTC
  • mfrom: (1.3.1 upstream) (9.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100428201000-o347bj5qb5i3tpot
Tags: 1.10.4-1
new upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 * @subpackage Sitemap
18
18
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
19
19
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
20
 
 * @version    $Id: Lastmod.php 20358 2010-01-17 19:03:49Z thomas $
 
20
 * @version    $Id: Lastmod.php 21365 2010-03-07 09:38:41Z thomas $
21
21
 */
22
22
 
23
23
/**
48
48
     * Validation key for not valid
49
49
     *
50
50
     */
51
 
    const NOT_VALID = 'invalidSitemapLastmod';
 
51
    const NOT_VALID = 'sitemapLastmodNotValid';
 
52
    const INVALID   = 'sitemapLastmodInvalid';
52
53
 
53
54
    /**
54
55
     * Validation failure message template definitions
57
58
     */
58
59
    protected $_messageTemplates = array(
59
60
        self::NOT_VALID => "'%value%' is no valid sitemap lastmod",
 
61
        self::INVALID   => "Invalid type given, the value should be a string",
60
62
    );
61
63
 
62
64
    /**
69
71
     */
70
72
    public function isValid($value)
71
73
    {
 
74
        if (!is_string($value)) {
 
75
            $this->_error(self::INVALID);
 
76
            return false;
 
77
        }
 
78
 
72
79
        $this->_setValue($value);
73
 
 
74
 
        if (!is_string($value)) {
 
80
        $result = @preg_match(self::LASTMOD_REGEX, $value);
 
81
        if ($result != 1) {
 
82
            $this->_error(self::NOT_VALID);
75
83
            return false;
76
84
        }
77
85
 
78
 
        return @preg_match(self::LASTMOD_REGEX, $value) == 1;
 
86
        return true;
79
87
    }
80
88
}