[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
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 [email protected] so we can send you a copy immediately. 14 * 15 * @category Zend 16 * @package Zend_Validate 17 * @subpackage Sitemap 18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 19 * @license http://framework.zend.com/license/new-bsd New BSD License 20 * @version $Id$ 21 */ 22 23 /** 24 * @see Zend_Validate_Abstract 25 */ 26 require_once 'Zend/Validate/Abstract.php'; 27 28 /** 29 * Validates whether a given value is valid as a sitemap <priority> value 30 * 31 * @link http://www.sitemaps.org/protocol.php Sitemaps XML format 32 * 33 * @category Zend 34 * @package Zend_Validate 35 * @subpackage Sitemap 36 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 37 * @license http://framework.zend.com/license/new-bsd New BSD License 38 */ 39 class Zend_Validate_Sitemap_Priority extends Zend_Validate_Abstract 40 { 41 /** 42 * Validation key for not valid 43 * 44 */ 45 const NOT_VALID = 'sitemapPriorityNotValid'; 46 const INVALID = 'sitemapPriorityInvalid'; 47 48 /** 49 * Validation failure message template definitions 50 * 51 * @var array 52 */ 53 protected $_messageTemplates = array( 54 self::NOT_VALID => "'%value%' is no valid sitemap priority", 55 self::INVALID => "Invalid type given, the value should be a integer, a float or a numeric string", 56 ); 57 58 /** 59 * Validates if a string is valid as a sitemap priority 60 * 61 * @link http://www.sitemaps.org/protocol.php#prioritydef <priority> 62 * 63 * @param string $value value to validate 64 * @return boolean 65 */ 66 public function isValid($value) 67 { 68 if (!is_numeric($value)) { 69 $this->_error(self::INVALID); 70 return false; 71 } 72 73 $this->_setValue($value); 74 $value = (float) $value; 75 if ($value < 0 || $value > 1) { 76 $this->_error(self::NOT_VALID); 77 return false; 78 } 79 80 return true; 81 } 82 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |