Beispiel #1
0
 /**
  *  レンダラオブジェクトを取得する
  *
  *  @access protected
  *  @return object  Ethna_Renderer  レンダラオブジェクト
  */
 public function _getRenderer()
 {
     $c = $this->backend->getController();
     $renderer = $c->getRenderer();
     $form_array = $this->af->getArray();
     $app_array = $this->af->getAppArray();
     $app_ne_array = $this->af->getAppNEArray();
     $renderer->setPropByRef('form', $form_array);
     $renderer->setPropByRef('app', $app_array);
     $renderer->setPropByRef('app_ne', $app_ne_array);
     $message_list = Ethna_Util::escapeHtml($this->ae->getMessageList());
     $renderer->setPropByRef('errors', $message_list);
     if (isset($_SESSION)) {
         $tmp_session = Ethna_Util::escapeHtml($_SESSION);
         $renderer->setPropByRef('session', $tmp_session);
     }
     $renderer->setProp('script', htmlspecialchars(basename($_SERVER['SCRIPT_NAME']), ENT_QUOTES, $this->ctl->getClientEncoding()));
     $renderer->setProp('request_uri', isset($_SERVER['REQUEST_URI']) ? htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES, $this->ctl->getClientEncoding()) : '');
     $renderer->setProp('config', $this->config->get());
     return $renderer;
 }
Beispiel #2
0
 /**
  *  フォーム値検証のエラー処理を行う
  *
  *  @access public
  *  @param  string      $name   フォーム項目名
  *  @param  int         $code   エラーコード
  */
 public function handleError($name, $code)
 {
     $def = $this->getDef($name);
     // ユーザ定義エラーメッセージ
     $code_map = array(E_FORM_REQUIRED => 'required_error', E_FORM_WRONGTYPE_SCALAR => 'type_error', E_FORM_WRONGTYPE_ARRAY => 'type_error', E_FORM_WRONGTYPE_INT => 'type_error', E_FORM_WRONGTYPE_FLOAT => 'type_error', E_FORM_WRONGTYPE_DATETIME => 'type_error', E_FORM_WRONGTYPE_BOOLEAN => 'type_error', E_FORM_MIN_INT => 'min_error', E_FORM_MIN_FLOAT => 'min_error', E_FORM_MIN_DATETIME => 'min_error', E_FORM_MIN_FILE => 'min_error', E_FORM_MIN_STRING => 'min_error', E_FORM_MAX_INT => 'max_error', E_FORM_MAX_FLOAT => 'max_error', E_FORM_MAX_DATETIME => 'max_error', E_FORM_MAX_FILE => 'max_error', E_FORM_MAX_STRING => 'max_error', E_FORM_REGEXP => 'regexp_error');
     //   フォーム定義にエラーメッセージが定義されていれば
     //   それを使う
     if (array_key_exists($code_map[$code], $def)) {
         $this->ae->add($name, $def[$code_map[$code]], $code);
         return;
     }
     //   定義されていない場合は、内部のメッセージを使う
     if ($code == E_FORM_REQUIRED) {
         switch ($def['form_type']) {
             case FORM_TYPE_TEXT:
             case FORM_TYPE_PASSWORD:
             case FORM_TYPE_TEXTAREA:
             case FORM_TYPE_SUBMIT:
                 $message = _et('Please input {form}.');
                 break;
             case FORM_TYPE_SELECT:
             case FORM_TYPE_RADIO:
             case FORM_TYPE_CHECKBOX:
             case FORM_TYPE_FILE:
                 $message = _et('Please select {form}.');
                 break;
             default:
                 $message = _et('Please input {form}.');
                 break;
         }
     } else {
         if ($code == E_FORM_WRONGTYPE_SCALAR) {
             $message = _et('Please input scalar value to {form}.');
         } else {
             if ($code == E_FORM_WRONGTYPE_ARRAY) {
                 $message = _et('Please input array value to {form}.');
             } else {
                 if ($code == E_FORM_WRONGTYPE_INT) {
                     $message = _et('Please input integer value to {form}.');
                 } else {
                     if ($code == E_FORM_WRONGTYPE_FLOAT) {
                         $message = _et('Please input float value to {form}.');
                     } else {
                         if ($code == E_FORM_WRONGTYPE_DATETIME) {
                             $message = _et('Please input valid datetime to {form}.');
                         } else {
                             if ($code == E_FORM_WRONGTYPE_BOOLEAN) {
                                 $message = _et('You can input 0 or 1 to {form}.');
                             } else {
                                 if ($code == E_FORM_MIN_INT) {
                                     $this->ae->add($name, _et('Please input more than %d(int) to {form}.'), $code, $def['min']);
                                     return;
                                 } else {
                                     if ($code == E_FORM_MIN_FLOAT) {
                                         $this->ae->add($name, _et('Please input more than %f(float) to {form}.'), $code, $def['min']);
                                         return;
                                     } else {
                                         if ($code == E_FORM_MIN_DATETIME) {
                                             $this->ae->add($name, _et('Please input datetime value %s or later to {form}.'), $code, $def['min']);
                                             return;
                                         } else {
                                             if ($code == E_FORM_MIN_FILE) {
                                                 $this->ae->add($name, _et('Please specify file whose size is more than %d KB.'), $code, $def['min']);
                                                 return;
                                             } else {
                                                 if ($code == E_FORM_MIN_STRING) {
                                                     $this->ae->add($name, _et('Please input more than %d full-size (%d half-size) characters to {form}.'), $code, intval($def['min'] / 2), $def['min']);
                                                     return;
                                                 } else {
                                                     if ($code == E_FORM_MAX_INT) {
                                                         $this->ae->add($name, _et('Please input less than %d(int) to {form}.'), $code, $def['max']);
                                                         return;
                                                     } else {
                                                         if ($code == E_FORM_MAX_FLOAT) {
                                                             $this->ae->add($name, _et('Please input less than %f(float) to {form}.'), $code, $def['max']);
                                                             return;
                                                         } else {
                                                             if ($code == E_FORM_MAX_DATETIME) {
                                                                 $this->ae->add($name, _et('Please input datetime value before %s to {form}.'), $code, $def['max']);
                                                                 return;
                                                             } else {
                                                                 if ($code == E_FORM_MAX_FILE) {
                                                                     $this->ae->add($name, _et('Please specify file whose size is less than %d KB to {form}.'), $code, $def['max']);
                                                                     return;
                                                                 } else {
                                                                     if ($code == E_FORM_MAX_STRING) {
                                                                         $this->ae->add($name, _et('Please input less than %d full-size (%d half-size) characters to {form}.'), $code, intval($def['max'] / 2), $def['max']);
                                                                         return;
                                                                     } else {
                                                                         if ($code == E_FORM_REGEXP) {
                                                                             $message = _et('Please input {form} properly.');
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $this->ae->add($name, $message, $code);
 }