| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 lmb_require('limb/validation/src/rule/lmbDomainRule.class.php'); 10 11 /** 12 * Checks that field value is a valid Url. 13 * @package validation 14 * @version $Id: lmbUrlRule.class.php 5945 2007-06-06 08:31:43Z pachanga $ 15 */ 16 class lmbUrlRule extends lmbDomainRule 17 { 18 /** 19 * @var array List of allowable schemes e.g. array('http', 'ftp'); 20 */ 21 protected $allowable_schemes = array(); 22 23 /** 24 * Constructor. 25 * @param string Field name 26 * @param array List of allowable schemes 27 */ 28 function __construct($field_name, $allowable_schemes = array(), $custom_error = '') 29 { 30 parent :: __construct($field_name, $custom_error); 31 32 $this->allowable_schemes = $allowable_schemes ? $allowable_schemes : array(); 33 } 34 35 function check($value) 36 { 37 $url = @parse_url($value); 38 if (isset($url['scheme']) && isset($url['host']) && 39 ($url['scheme'] == 'http' || $url['scheme'] == 'ftp')) 40 { 41 parent::check($url['host']); 42 } 43 44 if (!sizeof($this->allowable_schemes)) 45 return; 46 47 if (!isset($url['scheme'])) 48 { 49 $this->error('Please specify a scheme for {Field}.'); 50 return; 51 } 52 53 if (!in_array($url['scheme'], $this->allowable_schemes)) 54 $this->error('{Field} may not use {scheme}.', array('scheme' => $url['scheme'])); 55 } 56 } 57 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Dec 2 03:54:09 2008 | Cross-referenced by PHPXref 0.7 |