示例#1
0
文件: password.php 项目: Borvik/Munla
 /**
  * Creates a new password form element.
  * 
  * @param array $attributes The attributes that should be assigned to the password element.
  */
 public function __construct(array $attributes)
 {
     parent::__construct($attributes);
     $this->type = 'password';
     if (isset($this->attributes['value'])) {
         unset($this->attributes['value']);
     }
 }
示例#2
0
文件: url.php 项目: Borvik/Munla
 /**
  * Validates a url value.
  * 
  * @param string $value The value to validate.
  * 
  * @return bool|string Returns boolean TRUE upon successfull validation, and an error message string upon failure.
  */
 public function validate(&$value)
 {
     $return = parent::validate($value);
     if ($return !== true) {
         return $return;
     }
     if (isset($value) && strlen(trim($value)) > 0) {
         $valid = is::url($value, true);
         if (!is_array($valid)) {
             $msglbl = get::array_def($this->attributes, 'msglbl', get::array_def($this->attributes, 'name', $this->getId()));
             return sprintf('"%s" has an invalid url. Urls start with http/https/ftp followed by "://" and then the domain and path.', $msglbl);
         }
         $value = $valid;
     }
     return true;
 }
示例#3
0
文件: email.php 项目: Borvik/Munla
 /**
  * Validates a email value.
  * 
  * @param string $value The value to validate.
  * 
  * @return bool|string Returns boolean TRUE upon successfull validation, and an error message string upon failure.
  */
 public function validate(&$value)
 {
     $return = parent::validate($value);
     if ($return !== true) {
         return $return;
     }
     if (isset($value) && strlen(trim($value)) > 0) {
         $valid = is::email($value, get::array_def($this->attributes, 'multiple', false) == 'multiple');
         if (!is_object($valid) || !($valid instanceof emailAddressList || $valid instanceof emailAddress)) {
             $msglbl = get::array_def($this->attributes, 'msglbl', get::array_def($this->attributes, 'name', $this->getId()));
             return sprintf('"%s" has an invalid email address.', $msglbl);
         }
         $value = $valid;
     }
     return true;
 }
示例#4
0
文件: tel.php 项目: Borvik/Munla
 /**
  * Validates a telephone value.
  * 
  * @param string $value The value to validate.
  * 
  * @return bool|string Returns boolean TRUE upon successfull validation, and an error message string upon failure.
  */
 public function validate(&$value)
 {
     $return = parent::validate($value);
     if ($return !== true) {
         return $return;
     }
     $mode = get::array_def($this->attributes, 'validatemode', 'none');
     if (isset($value) && strlen(trim($value)) > 0 && $mode != 'none') {
         if (strtolower($mode) == 'us') {
             $return = false;
             if (preg_match('/^[\\(]?(\\d{0,3})[\\)]?[\\s]?[\\-]?(\\d{3})[\\s]?[\\-]?(\\d{4})([x\\s]{1,}(\\d*))?$/', trim($value), $matches)) {
                 $phoneNumber = '';
                 // we have a match, dump sub-patterns to $matches
                 $phone_number = $matches[0];
                 // original number
                 $area_code = $matches[1];
                 // 3-digit area code
                 $exchange = $matches[2];
                 // 3-digit exchange
                 $number = $matches[3];
                 // 4-digit number
                 $return = new phoneNumber();
                 $return->original = $matches[0];
                 if (isset($matches[1]) && strlen(trim($matches[1])) > 0) {
                     $return->areacode = trim($matches[1]);
                     $return->formatted .= '(' . $return->areacode . ') ';
                 }
                 $return->exchange = $matches[2];
                 $return->number = $matches[3];
                 $return->formatted .= $return->exchange . '-' . $return->number;
                 if (isset($matches[4]) && strlen(trim($matches[4])) > 0) {
                     $return->extension = trim($matches[5]);
                     $return->xformatted = $return->formatted . ' x' . $return->extension;
                 }
             }
             if ($return === false) {
                 $msglbl = get::array_def($this->attributes, 'msglbl', get::array_def($this->attributes, 'name', $this->getId()));
                 return sprintf('"%s" has an invalid phone format (###-#### with optional 3 digit area code, and/or extension).', $msglbl);
             }
             $value = $return;
         }
     }
     return true;
 }
示例#5
0
文件: search.php 项目: Borvik/Munla
 /**
  * Creates a new search form element.
  * 
  * @param array $attributes The attributes that should be assigned to the search element.
  */
 public function __construct(array $attributes)
 {
     parent::__construct($attributes);
     $this->type = 'search';
 }