| [ Index ] |
|
Code source de PRADO 3.0.6 |
1 <?php 2 /** 3 * TEmailAddressValidator class file 4 * 5 * @author Qiang Xue <qiang.xue@gmail.com> 6 * @link http://www.pradosoft.com/ 7 * @copyright Copyright © 2005 PradoSoft 8 * @license http://www.pradosoft.com/license/ 9 * @version $Id: TEmailAddressValidator.php 1397 2006-09-07 07:55:53Z wei $ 10 * @package System.Web.UI.WebControls 11 */ 12 13 /** 14 * Using TRegularExpressionValidator class 15 */ 16 Prado::using('System.Web.UI.WebControls.TRegularExpressionValidator'); 17 18 /** 19 * TEmailAddressValidator class 20 * 21 * TEmailAddressValidator validates whether the value of an associated 22 * input component is a valid email address. If {@link getCheckMXRecord CheckMXRecord} 23 * is true, it will check MX record for the email adress, provided 24 * checkdnsrr() is available in the installed PHP. 25 * 26 * @author Qiang Xue <qiang.xue@gmail.com> 27 * @version $Id: TEmailAddressValidator.php 1397 2006-09-07 07:55:53Z wei $ 28 * @package System.Web.UI.WebControls 29 * @since 3.0 30 */ 31 class TEmailAddressValidator extends TRegularExpressionValidator 32 { 33 /** 34 * Regular expression used to validate the email address 35 */ 36 const EMAIL_REGEXP="\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"; 37 38 /** 39 * Gets the name of the javascript class responsible for performing validation for this control. 40 * This method overrides the parent implementation. 41 * @return string the javascript class name 42 */ 43 protected function getClientClassName() 44 { 45 return 'Prado.WebUI.TEmailAddressValidator'; 46 } 47 48 /** 49 * @return string the regular expression that determines the pattern used to validate a field. 50 */ 51 public function getRegularExpression() 52 { 53 $regex=parent::getRegularExpression(); 54 return $regex===''?self::EMAIL_REGEXP:$regex; 55 } 56 57 /** 58 * Returns an array of javascript validator options. 59 * @return array javascript validator options. 60 */ 61 public function evaluateIsValid() 62 { 63 $valid=parent::evaluateIsValid(); 64 if($valid && $this->getCheckMXRecord() && function_exists('checkdnsrr')) 65 { 66 if(($value=$this->getValidationValue($this->getValidationTarget()))!=='') 67 { 68 if(($pos=strpos($value,'@'))!==false) 69 { 70 $domain=substr($value,$pos+1); 71 return $domain===''?false:checkdnsrr($domain,'MX'); 72 } 73 else 74 return false; 75 } 76 } 77 return $valid; 78 } 79 80 /** 81 * @return boolean whether to check MX record for the email address being validated. Defaults to true. 82 */ 83 public function getCheckMXRecord() 84 { 85 return $this->getViewState('CheckMXRecord',true); 86 } 87 88 /** 89 * @param boolean whether to check MX record for the email address being validated. 90 * Note, if {@link checkdnsrr} is not available, this check will not be performed. 91 */ 92 public function setCheckMXRecord($value) 93 { 94 $this->setViewState('CheckMXRecord',TPropertyValue::ensureBoolean($value),true); 95 } 96 } 97 98 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Feb 25 21:07:04 2007 | par Balluche grâce à PHPXref 0.7 |