Ejemplo n.º 1
0
 /**
  * 唯一のインスタンスに対して設定を行う
  * 
  * @static
  * @param  array    $opts
  */
 public static function setOptions($opts)
 {
     $instance = Teeple_Smarty4Maple::getInstance();
     foreach ($opts as $attr => $value) {
         if (array_key_exists($attr, $instance)) {
             $instance->{$attr} = $value;
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * エラーハンドリングを行ないます。
  * 
  * @param Exception $e 例外クラス
  */
 public static function handle($e)
 {
     // ロギング
     self::handleLogging($e);
     // エラーページを出力
     $display = $e->getMessage();
     $template = 'common/exception.html';
     $renderer = Teeple_Smarty4Maple::getInstance();
     $renderer->assign('display', $display);
     $renderer->assign('stack', $e->__toString());
     $result = $renderer->fetch($template);
     if ($result == "") {
         self::print_error($display);
     }
     print $result;
     return;
 }
Ejemplo n.º 3
0
 /**
  * Viewの処理を実行
  *
  **/
 public function postfilter()
 {
     if ($this->isCompleteResponse()) {
         $this->log->info("CompleteResponseフラグが立っているため、Viewは実行されませんでした。");
         return;
     }
     $view = $this->response->getView();
     $this->log->debug("view: {$view}");
     if ($view == "") {
         $view = Teeple_Util::getPathInfo();
     }
     if ($view != "") {
         $template = preg_replace("/^\\//", "", $view);
         if ($template == "") {
             throw new Teeple_Exception("テンプレートの指定が不正です。({$template})");
         }
         if (preg_match("/^location:/", $template)) {
             $url = preg_replace("/^location:/", "", $template);
             $url = trim($url);
             $this->response->setRedirect($url);
         } else {
             if (preg_match("/^redirect:/", $template)) {
                 $url = preg_replace("/^redirect:/", "", $template);
                 $url = trim($url);
                 $url = Teeple_Util::getAbsoluteUrlFromActionName($url, $this->request->isHttps());
                 $this->request->setFilterError(NULL);
                 // TODO 定数化
                 $this->session->setParameter("__REDIRECT_SCOPE_REQUEST", $this->request);
                 $this->response->setRedirect($url);
             } else {
                 $renderer = Teeple_Smarty4Maple::getInstance();
                 $action = $this->actionChain->getCurAction();
                 $renderer->setAction($action);
                 if (is_object($this->token)) {
                     $renderer->setToken($this->token);
                 }
                 if (is_object($this->session)) {
                     $renderer->setSession($this->session);
                 }
                 if (is_object($this->request)) {
                     $renderer->setRequest($this->request);
                 }
                 $renderer->setScriptName(Teeple_Util::getScriptName());
                 $result = $renderer->fetch($template);
                 if ($result == "") {
                     throw new Teeple_Exception("Viewのレンダリングに失敗しました。");
                 }
                 $this->response->setResult($result);
             }
         }
     }
     $contentDisposition = $this->response->getContentDisposition();
     $contentType = $this->response->getContentType();
     $result = $this->response->getResult();
     $redirect = $this->response->getRedirect();
     if ($redirect) {
         $this->redirect($redirect);
     } else {
         if ($contentDisposition != "") {
             header("Content-disposition: {$contentDisposition}");
         }
         if ($contentType != "") {
             header("Content-type: {$contentType}");
         }
         print $result;
     }
     return;
 }
Ejemplo n.º 4
0
 private function confirmPage($actionName)
 {
     list($className, $classfile, $templatefile) = $this->makeNames($actionName);
     $isClassfile = "新規作成";
     $isTemplatefile = "新規作成";
     if (@file_exists($classfile)) {
         $isClassfile = "存在します";
     }
     if (@file_exists($templatefile)) {
         $isTemplatefile = "存在します";
     }
     $renderer = Teeple_Smarty4Maple::getInstance();
     $renderer->assign('actionName', $actionName);
     $renderer->assign('classfile', $classfile);
     $renderer->assign('templatefile', $templatefile);
     $renderer->assign('isClassfile', $isClassfile);
     $renderer->assign('isTemplatefile', $isTemplatefile);
     $result = $renderer->fetch('devhelper/confirm.html');
     print $result;
     exit;
 }