Beispiel #1
0
 protected function execute(&$obj, $fieldName)
 {
     if (Teeple_Util::isBlank($this->target)) {
         throw new Teeple_Exception("targetが指定されていません。");
     }
     // 初期化
     Teeple_Util::setProperty($obj, $this->target, "");
     $value = Teeple_Util::getProperty($obj, $fieldName);
     if (!is_array($value) || count($value) < 3) {
         return FALSE;
     }
     $y = $value['Year'];
     $m = $value['Month'];
     $d = $value['Day'];
     if ($y != "" && $m != "" && $d != "") {
         $h = isset($value['Hour']) ? $value['Hour'] : 0;
         $i = isset($value['Minute']) ? $value['Minute'] : 0;
         $s = isset($value['Second']) ? $value['Second'] : 0;
         if (!is_numeric($y) || !is_numeric($m) || !is_numeric($d) || !is_numeric($h) || !is_numeric($i) || !is_numeric($s)) {
             return FALSE;
         }
         $time = mktime($h, $i, $s, $m, $d, $y);
         if ($time !== FALSE) {
             $datestr = strftime($this->format, $time);
             Teeple_Util::setProperty($obj, $this->target, $datestr);
             return TRUE;
         }
     }
     return FALSE;
 }
Beispiel #2
0
 protected function execute($obj, $fieldName)
 {
     $value = $this->getTargetValue($obj, $fieldName);
     if (Teeple_Util::isBlank($value)) {
         return TRUE;
     }
     return is_numeric($value);
 }
Beispiel #3
0
 protected function execute($obj, $fieldName)
 {
     $value = $this->getTargetValue($obj, $fieldName);
     if (Teeple_Util::isBlank($value)) {
         return TRUE;
     }
     return preg_match('/^[+-]?[0-9]*$/', $value) && intval($value) < 128;
 }
Beispiel #4
0
 protected function execute($obj, $fieldName)
 {
     $value = $this->getTargetValue($obj, $fieldName);
     if (Teeple_Util::isBlank($value)) {
         return TRUE;
     }
     if (Teeple_Util::isBlank($this->maxlength) || !is_numeric($this->maxlength)) {
         throw new Teeple_Exception("maxlengthが正しくセットされていません。");
     }
     return $this->maxlength >= mb_strlen($value, INTERNAL_CODE);
 }
Beispiel #5
0
 protected function execute($obj, $fieldName)
 {
     $value = $this->getTargetValue($obj, $fieldName);
     if (Teeple_Util::isBlank($value)) {
         return TRUE;
     }
     if (Teeple_Util::isBlank($this->mask)) {
         throw new Teeple_Exception("maskが設定されていません。");
     }
     return preg_match($this->mask, $value);
 }
Beispiel #6
0
 protected function execute($obj, $fieldName)
 {
     $value = $this->getTargetValue($obj, $fieldName);
     if (Teeple_Util::isBlank($value)) {
         return TRUE;
     }
     // 比較対象のプロパティを取得
     if (Teeple_Util::isBlank($this->compareTo)) {
         throw new Teeple_Exception("compareToが設定されていません。");
     }
     $value2 = $this->getTargetValue($obj, $this->compareTo);
     return $value === $value2;
 }
Beispiel #7
0
 protected function execute($obj, $fieldName)
 {
     $value = $this->getTargetValue($obj, $fieldName);
     if (Teeple_Util::isBlank($value)) {
         return TRUE;
     }
     if (Teeple_Util::isBlank($this->minbytelength) || !is_numeric($this->minbytelength)) {
         throw new Teeple_Exception("minbytelengthが正しくセットされていません。");
     }
     if (!Teeple_Util::isBlank($this->charset)) {
         $value = mb_convert_encoding($value, $this->charset);
     }
     return $this->minbytelength <= strlen($value);
 }
Beispiel #8
0
 protected function execute($obj, $fieldName)
 {
     $value = $this->getTargetValue($obj, $fieldName);
     if (Teeple_Util::isBlank($value)) {
         return TRUE;
     }
     if (!@is_numeric($this->min) || !@is_numeric($this->max)) {
         throw new Teeple_Exception("min,maxを数値で指定してください。");
     }
     if (!is_numeric($value)) {
         return FALSE;
     }
     return $this->min <= $value && $value <= $this->max;
 }
Beispiel #9
0
 protected function execute($obj, $fieldName)
 {
     $value = $this->getTargetValue($obj, $fieldName);
     if (Teeple_Util::isBlank($value)) {
         return TRUE;
     }
     if (!Teeple_Util::isBlank($this->minlength) && $this->minlength > mb_strlen($value, INTERNAL_CODE)) {
         return FALSE;
     }
     if (!Teeple_Util::isBlank($this->maxlength) && $this->maxlength < mb_strlen($value, INTERNAL_CODE)) {
         return FALSE;
     }
     return TRUE;
 }
Beispiel #10
0
 protected function execute($obj, $fieldName)
 {
     $value = $this->getTargetValue($obj, $fieldName);
     if (Teeple_Util::isBlank($value)) {
         return TRUE;
     }
     $atom = "(?:[a-zA-Z0-9_!#\\\$\\%&'*+\\/=?\\^`{}~|\\-]+)";
     $dot_atom = "(?:{$atom}(?:\\.{$atom})*)";
     $quoted = '(?:"(?:\\\\[^\\r\\n]|[^\\\\"])*")';
     $local = "(?:{$dot_atom}|{$quoted})";
     $domain_lit = '(?:\\[(?:\\\\\\S|[\\x21-\\x5a\\x5e-\\x7e])*\\])';
     $domain = "(?:{$dot_atom}|{$domain_lit})";
     $addr_spec = "{$local}\\@{$domain}";
     return preg_match("/^{$addr_spec}\$/", $value);
 }
Beispiel #11
0
 protected function execute($obj, $fieldName)
 {
     $value = $this->getTargetValue($obj, $fieldName);
     if (Teeple_Util::isBlank($value)) {
         return TRUE;
     }
     if (Teeple_Util::isBlank($this->format)) {
         throw new Teeple_Exception("formatが設定されていません。");
     }
     $ar = strptime($value, $this->format);
     if ($ar === FALSE) {
         return FALSE;
     }
     return TRUE;
 }
Beispiel #12
0
 protected function execute($obj, $fieldName)
 {
     $value = $this->getTargetValue($obj, $fieldName);
     if (is_array($value)) {
         foreach ($value as $key => $val) {
             if (Teeple_Util::isBlank($val)) {
                 return FALSE;
             }
         }
     } else {
         if (Teeple_Util::isBlank($value)) {
             return FALSE;
         }
     }
     return TRUE;
 }
Beispiel #13
0
 protected function execute(&$obj, $fieldName)
 {
     $value = Teeple_Util::getProperty($obj, $fieldName);
     if (is_array($value)) {
         foreach ($value as $key => $val) {
             $value[$key] = $this->convertMethod($val);
         }
         Teeple_Util::setProperty($obj, $fieldName, $value);
     } else {
         if (!Teeple_Util::isBlank($value)) {
             $value = $this->convertMethod($value);
             Teeple_Util::setProperty($obj, $fieldName, $value);
         }
     }
     return TRUE;
 }
Beispiel #14
0
 protected function execute(&$obj, $fieldName)
 {
     if (Teeple_Util::isBlank($this->target)) {
         throw new Teeple_Exception("targetが指定されていません。");
     }
     $value = Teeple_Util::getProperty($obj, $fieldName);
     if (!is_array($value) || count($value) != 2) {
         return FALSE;
     }
     if ($value[0] != "" && $value[1] != "") {
         $newvalue = sprintf("%s@%s", $value[0], $value[1]);
         Teeple_Util::setProperty($obj, $this->target, $newvalue);
         return TRUE;
     }
     return FALSE;
 }
Beispiel #15
0
 protected function execute(&$obj, $fieldName)
 {
     if (Teeple_Util::isBlank($this->target)) {
         throw new Teeple_Exception("targetが指定されていません。");
     }
     $result = array();
     $value = Teeple_Util::getProperty($obj, $fieldName);
     if (Teeple_Util::isBlank($value)) {
         return FALSE;
     }
     list($y, $m, $d) = explode('-', $value);
     $result[0] = $y;
     $result[1] = $m;
     $result[2] = $d;
     Teeple_Util::setProperty($obj, $this->target, $result);
     return TRUE;
 }
Beispiel #16
0
 protected function execute(&$obj, $fieldName)
 {
     if (Teeple_Util::isBlank($this->target)) {
         throw new Teeple_Exception("targetが指定されていません。");
     }
     $value = Teeple_Util::getProperty($obj, $fieldName);
     if (!is_array($value)) {
         return FALSE;
     }
     // ブランクだったら結合しない
     $result = implode("", $value);
     if (!strlen($result)) {
         return FALSE;
     }
     $result = implode($this->sep, $value);
     Teeple_Util::setProperty($obj, $this->target, $result);
     return TRUE;
 }
Beispiel #17
0
 protected function execute(&$obj, $fieldName)
 {
     if (Teeple_Util::isBlank($this->target)) {
         throw new Teeple_Exception("targetが指定されていません。");
     }
     // 初期化
     Teeple_Util::setProperty($obj, $this->target, "");
     $value = Teeple_Util::getProperty($obj, $fieldName);
     if (!is_array($value) || count($value) != 3) {
         return FALSE;
     }
     if ($value[0] != "" && $value[1] != "" && $value[2] != "") {
         $time = mktime(0, 0, 0, $value[1], $value[2], $value[0]);
         if ($time !== FALSE) {
             $datestr = strftime($this->format, $time);
             Teeple_Util::setProperty($obj, $this->target, $datestr);
             return TRUE;
         }
     }
     return FALSE;
 }
Beispiel #18
0
 protected function execute($obj, $fieldName)
 {
     $value = $this->getTargetValue($obj, $fieldName);
     if (!is_array($value)) {
         throw new Teeple_Exception("対象となる値が配列ではありません。");
     }
     $year = $value['Year'];
     $month = $value['Month'];
     $day = $value['Day'];
     $hour = $value['Hour'];
     $minute = $value['Minute'];
     $second = isset($value['Second']) ? $second = $value['Second'] : '00';
     // 全部空だったらTRUE
     if (Teeple_Util::isBlank($year) && Teeple_Util::isBlank($month) && Teeple_Util::isBlank($day) && Teeple_Util::isBlank($hour) && Teeple_Util::isBlank($minute)) {
         return TRUE;
     }
     if ($year == "" || $month == "" || $day == "" || $hour == "" || $minute == "") {
         return FALSE;
     } else {
         if (!is_numeric($year) || !is_numeric($month) || !is_numeric($day) || !is_numeric($hour) || !is_numeric($minute)) {
             return FALSE;
         } else {
             if (checkdate($month, $day, $year)) {
                 if (0 > intval($hour) || 23 < intval($hour)) {
                     return FALSE;
                 }
                 if (0 > intval($minute) || 59 < intval($minute)) {
                     return FALSE;
                 }
                 if (0 > intval($second) || 59 < intval($second)) {
                     return FALSE;
                 }
                 return TRUE;
             } else {
                 return FALSE;
             }
         }
     }
     return TRUE;
 }
Beispiel #19
0
 protected function execute(&$obj, $fieldName)
 {
     if (Teeple_Util::isBlank($this->target)) {
         throw new Teeple_Exception("targetが指定されていません。");
     }
     $value = Teeple_Util::getProperty($obj, $fieldName);
     if (!is_array($value) || count($value) < 2) {
         return FALSE;
     }
     $h = $value['Hour'];
     $i = $value['Minute'];
     $s = isset($value['Second']) ? $value['Second'] : 0;
     if ($h != "" && $i != "") {
         $time = mktime($h, $i, $s);
         if ($time !== FALSE) {
             $datestr = strftime($this->format, $time);
             Teeple_Util::setProperty($obj, $this->target, $datestr);
             return TRUE;
         }
     }
     return FALSE;
 }
Beispiel #20
0
 protected function execute(&$obj, $fieldName)
 {
     if (Teeple_Util::isBlank($this->target)) {
         throw new Teeple_Exception("targetが指定されていません。");
     }
     $result = array();
     $value = Teeple_Util::getProperty($obj, $fieldName);
     list($day, $time) = explode(' ', $value);
     if (Teeple_Util::isBlank($day)) {
         return FALSE;
     }
     list($y, $m, $d) = explode('-', $day);
     $result['Year'] = $y;
     $result['Month'] = $m;
     $result['Day'] = $d;
     if (!Teeple_Util::isBlank($time)) {
         list($h, $i, $s) = explode(':', $time);
         $result['Hour'] = $h;
         $result['Minute'] = $i;
         $result['Second'] = $s;
     }
     Teeple_Util::setProperty($obj, $this->target, $result);
     return TRUE;
 }
Beispiel #21
0
 /**
  * HTTPSかどうか
  */
 public function isHttps()
 {
     return isset($_SERVER['HTTPS']) && !Teeple_Util::isBlank($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off';
 }
Beispiel #22
0
 /**
  * ラベル名を取得します。
  *
  * @param array $fieldConfig
  * @return string
  */
 private function getLabel(&$fieldConfig)
 {
     if (isset($fieldConfig['label']) && !Teeple_Util::isBlank($fieldConfig['label'])) {
         return $fieldConfig['label'];
     }
     $label = $this->resource->getResource('form.' . $fieldConfig['name']);
     if (Teeple_Util::isBlank($label)) {
         $label = $fieldConfig['name'];
     }
     return $label;
 }