예제 #1
0
 /**
  * コントローラーを実行します。
  *
  */
 public static function start()
 {
     $log = LoggerManager::getLogger(Teeple_Util::getPathInfo());
     $log->info("*** リクエストを開始します。");
     try {
         // コンテナの取得
         $container = Teeple_Container::getInstance();
         //$container->setup(WEBAPP_DIR .'/config/dicon.ini');
         // セッションを作成 TODO セッションのパラメータ制御
         $session = $container->getComponent("Teeple_Session");
         $session->start();
         // リダイレクトスコープのリクエスト復元
         $request = $session->getParameter("__REDIRECT_SCOPE_REQUEST");
         if (is_object($request)) {
             $request->setActionMethod("execute");
             $request->resetCompleteFlag();
             $request->isRedirect = TRUE;
             $container->register("Teeple_Request", $request);
             $session->removeParameter("__REDIRECT_SCOPE_REQUEST");
         }
         // controllerの実行
         $controller = $container->getComponent('Teeple_Controller');
         $controller->execute();
     } catch (Exception $e) {
         $txManager = $container->getComponent('Teeple_TransactionManager');
         $txManager->rollbackAll();
         Teeple_ErrorHandler::handle($e);
     }
     return;
 }
예제 #2
0
 /**
  * URIからAction名を特定します。
  *
  * @return string
  */
 public function makeActionName()
 {
     $path = Teeple_Util::getPathInfo();
     if ($path == NULL || strlen($path) == 0 || $path == '/') {
         return 'index';
     }
     if ($path[strlen($path) - 1] == '/') {
         $path .= "index.html";
     }
     $path = preg_replace('/^\\/?(.*)$/', '$1', $path);
     $path = preg_replace('/(\\..*)?$/', '', $path);
     $path = str_replace('/', '_', $path);
     return $path;
 }
예제 #3
0
파일: View.php 프로젝트: miztaka/teeple2
 /**
  * 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;
 }