Loc.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Validate
  17. * @subpackage Sitemap
  18. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /**
  22. * @see Zend_Validate_Abstract
  23. */
  24. require_once 'Zend/Validate/Abstract.php';
  25. /**
  26. * @see Zend_Uri
  27. */
  28. require_once 'Zend/Uri.php';
  29. /**
  30. * Validates whether a given value is valid as a sitemap <loc> value
  31. *
  32. * @link http://www.sitemaps.org/protocol.php Sitemaps XML format
  33. *
  34. * @category Zend
  35. * @package Zend_Validate
  36. * @subpackage Sitemap
  37. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  38. * @license http://framework.zend.com/license/new-bsd New BSD License
  39. */
  40. class Zend_Validate_Sitemap_Loc extends Zend_Validate_Abstract
  41. {
  42. /**
  43. * Validation key for not valid
  44. *
  45. */
  46. const NOT_VALID = 'invalidSitemapLoc';
  47. /**
  48. * Validation failure message template definitions
  49. *
  50. * @var array
  51. */
  52. protected $_messageTemplates = array(
  53. self::NOT_VALID => "'%value%' is not a valid sitemap location",
  54. );
  55. /**
  56. * Validates if a string is valid as a sitemap location
  57. *
  58. * @link http://www.sitemaps.org/protocol.php#locdef <loc>
  59. *
  60. * @param string $value value to validate
  61. * @return boolean
  62. */
  63. public function isValid($value)
  64. {
  65. $this->_setValue($value);
  66. if (!is_string($value)) {
  67. return false;
  68. }
  69. return Zend_Uri::check($value);
  70. }
  71. }