/**
  * バリデーションチェック
  *
  * @param string $key name属性
  * @param array $option
  * @return string エラーメッセージ
  */
 public function rule($key, array $options = array())
 {
     $value = $this->Data->get($key);
     $value = MWF_Functions::convert_eol($value);
     if (!MWF_Functions::is_empty($value)) {
         $defaults = array('min' => 0, 'max' => 0, 'message' => __('The number of characters is invalid.', MWF_Config::DOMAIN));
         $options = array_merge($defaults, $options);
         $length = mb_strlen($value, get_bloginfo('charset'));
         if (MWF_Functions::is_numeric($options['min'])) {
             if (MWF_Functions::is_numeric($options['max'])) {
                 if (!($options['min'] <= $length && $length <= $options['max'])) {
                     return $options['message'];
                 }
             } else {
                 if ($options['min'] > $length) {
                     return $options['message'];
                 }
             }
         } elseif (MWF_Functions::is_numeric($options['max'])) {
             if ($options['max'] < $length) {
                 return $options['message'];
             }
         }
     }
 }
Beispiel #2
0
 /**
  * バリデーションチェック
  *
  * @param string $key name属性
  * @param array $option
  * @return string エラーメッセージ
  */
 public function rule($key, array $options = array())
 {
     $value = $this->Data->get($key);
     if (!is_null($value) && MWF_Functions::is_empty($value)) {
         $defaults = array('message' => __('Please enter.', MWF_Config::DOMAIN));
         $options = array_merge($defaults, $options);
         return $options['message'];
     }
 }
 /**
  * rule
  * @param string $key name属性
  * @param array $option
  * @return string エラーメッセージ
  */
 public function rule($key, array $options = array())
 {
     $value = $this->Data->get($key);
     if (!is_null($value) && !MWF_Functions::is_empty($value)) {
         if (!preg_match('/^[ぁ-ゞ  ]*?[ぁ-ゞ]+?[ぁ-ゞ  ]*?$/u', $value)) {
             $defaults = array('message' => __('Please enter with a Japanese Hiragana.', MWF_Config::DOMAIN));
             $options = array_merge($defaults, $options);
             return $options['message'];
         }
     }
 }
Beispiel #4
0
 /**
  * バリデーションチェック
  *
  * @param string $key name属性
  * @param array $option
  * @return string エラーメッセージ
  */
 public function rule($key, array $options = array())
 {
     $value = $this->Data->get($key);
     if (!MWF_Functions::is_empty($value)) {
         $defaults = array('message' => __('This is not the format of a zip code.', MWF_Config::DOMAIN));
         $options = array_merge($defaults, $options);
         if (!preg_match('/^\\d{3}-\\d{4}$/', $value)) {
             return $options['message'];
         }
     }
 }
 /**
  * バリデーションチェック
  *
  * @param string $key name属性
  * @param array $option
  * @return string エラーメッセージ
  */
 public function rule($key, array $options = array())
 {
     $value = $this->Data->get($key);
     if (!MWF_Functions::is_empty($value)) {
         if (!preg_match('/^[A-Za-z]+$/', $value)) {
             $defaults = array('message' => __('Please enter with a half-width alphabetic character.', MWF_Config::DOMAIN));
             $options = array_merge($defaults, $options);
             return $options['message'];
         }
     }
 }
 /**
  * rule
  * @param string $key name属性
  * @param array $option
  * @return string エラーメッセージ
  */
 public function rule($key, array $options = array())
 {
     $value = $this->Data->get($key);
     if (!is_null($value) && !MWF_Functions::is_empty($value)) {
         if (!preg_match('/^[^@]+@([^@^\\.]+\\.)+[^@^\\.]+$/', $value)) {
             $defaults = array('message' => __('This is not the format of a mail address.', MWF_Config::DOMAIN));
             $options = array_merge($defaults, $options);
             return $options['message'];
         }
     }
 }
Beispiel #7
0
 /**
  * バリデーションチェック
  *
  * @param string $key name属性
  * @param array $option
  * @return string エラーメッセージ
  */
 public function rule($key, array $options = array())
 {
     $value = $this->Data->get($key);
     if (!MWF_Functions::is_empty($value)) {
         if (!preg_match('/^https{0,1}:\\/\\/[^\\/]+\\.[^\\.]+/', $value)) {
             $defaults = array('message' => __('This is not the format of a url.', MWF_Config::DOMAIN));
             $options = array_merge($defaults, $options);
             return $options['message'];
         }
     }
 }
 /**
  * rule
  * @param string $key name属性
  * @param array $option
  * @return string エラーメッセージ
  */
 public function rule($key, array $options = array())
 {
     $value = $this->Data->get($key);
     if (!is_null($value) && !MWF_Functions::is_empty($value)) {
         $defaults = array('options' => array(), 'message' => __('This value is invalid.', MWF_Config::DOMAIN));
         $options = array_merge($defaults, $options);
         if (!(is_array($options['options']) && in_array($value, $options['options']))) {
             return $options['message'];
         }
     }
 }
Beispiel #9
0
 /**
  * バリデーションチェック
  *
  * @param string $key name属性
  * @param array $option
  * @return string エラーメッセージ
  */
 public function rule($key, array $options = array())
 {
     $value = $this->Data->get($key);
     if (!MWF_Functions::is_empty($value)) {
         $defaults = array('target' => null, 'message' => __('This is not in agreement.', MWF_Config::DOMAIN));
         $options = array_merge($defaults, $options);
         $target_value = $this->Data->get($options['target']);
         if ((string) $value !== (string) $target_value) {
             return $options['message'];
         }
     }
 }
 /**
  * rule
  * @param string $key name属性
  * @param array $option
  * @return string エラーメッセージ
  */
 public function rule($key, array $options = array())
 {
     $value = $this->Data->get($key);
     if (!is_null($value) && !MWF_Functions::is_empty($value)) {
         $defaults = array('message' => __('This is not the format of a date.', MWF_Config::DOMAIN));
         $options = array_merge($defaults, $options);
         $timestamp = strtotime($value);
         $year = date('Y', $timestamp);
         $month = date('m', $timestamp);
         $day = date('d', $timestamp);
         $checkdate = checkdate($month, $day, $year);
         if (!$timestamp || !$checkdate || preg_match('/^[a-zA-Z]$/', $value) || preg_match('/^\\s+$/', $value)) {
             return $options['message'];
         }
     }
 }
 /**
  * rule
  * @param string $key name属性
  * @param array $option
  * @return string エラーメッセージ
  */
 public function rule($key, array $options = array())
 {
     $value = $this->Data->get($key);
     if (!is_null($value) && !MWF_Functions::is_empty($value)) {
         $defaults = array('types' => '', 'message' => __('This file is invalid.', MWF_Config::DOMAIN));
         $options = array_merge($defaults, $options);
         $_types = explode(',', $options['types']);
         foreach ($_types as $type) {
             $types[] = preg_quote(trim($type), '/');
         }
         $types = implode('|', MWF_Functions::array_clean($types));
         $pattern = '/\\.(' . $types . ')$/i';
         if (!preg_match($pattern, $value)) {
             return $options['message'];
         }
     }
 }
Beispiel #12
0
 /**
  * バリデーションチェック
  *
  * @param string $key name属性
  * @param array $option
  * @return string エラーメッセージ
  */
 public function rule($key, array $options = array())
 {
     $value = $this->Data->get($key);
     $value = (string) $value;
     if (!MWF_Functions::is_empty($value)) {
         $defaults = array('options' => array(), 'message' => __('This value is invalid.', MWF_Config::DOMAIN));
         $options = array_merge($defaults, $options);
         if (is_array($options['options'])) {
             foreach ($options['options'] as $option) {
                 $option = (string) $option;
                 if ($value === $option) {
                     return;
                 }
             }
         }
         return $options['message'];
     }
 }
Beispiel #13
0
 /**
  * id属性を返す
  *
  * @param string $id
  * @param string $suffix
  * @return string
  */
 protected function get_attr_id($id, $suffix = '')
 {
     if (!MWF_Functions::is_empty($id)) {
         if ($suffix) {
             $id .= '-' . $suffix;
         }
         return $id;
     }
 }