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; }
protected function execute(&$obj, $fieldName) { $value = Teeple_Util::getProperty($obj, $fieldName); if (is_array($value)) { array_walk($value, 'trim'); } else { $value = trim($value); } Teeple_Util::setProperty($obj, $fieldName, $value); return TRUE; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
/** * Validation対象の値を取得します。 * * @param object $obj * @param string $fieldName */ protected function getTargetValue($obj, $fieldName) { return Teeple_Util::getProperty($obj, $fieldName); }