response = new SC_Response_Ex(); $this->autoSet = $autoGenerateHttpHeaders; if ($hasPrevURL) { $this->setPrevURL(); } } function setPrevURL(){ // TODO SC_SiteSession で実装した方が良さげ $objCartSess = new SC_CartSession(); $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); } /** * LC_Page のパラメータを, テンプレートに設定し, 出力の準備を行う. * * @param LC_Page $page LC_Page インスタンス * @param $is_admin boolean 管理画面を扱う場合 true */ function prepare($page, $is_admin = false){ if(!$this->deviceSeted || !is_null($this->view)){ $device = ($is_admin) ? DEVICE_TYPE_ADMIN : $this->detectDevice(); $this->setDevice($device); } $this->assignobj($page); $this->response->setResposeBody($this->view->getResponse($page->getTemplate())); } /** * リダイレクトを行う. * * SC_Response::sendRedirect() のラッパーです. */ function redirect($location){ $this->response->sendRedirect($location); } /** * リロードを行う. * * SC_Response::reload() のラッパーです. */ function reload($queryString = array(), $removeQueryString = false){ $this->response->reload($queryString, $removeQueryString); } function noAction(){ return; } /** * ヘッダを追加する. */ function addHeader($name, $value){ $this->response->addHeader($name, $value); } /** * デバイス毎の出力方法を自動で変更する、ファサード * Enter description here ... */ function setDevice($device = DEVICE_TYPE_PC){ switch ($device){ case DEVICE_TYPE_MOBILE: $this->response->setContentType("text/html"); $this->setView(new SC_MobileView()); break; case DEVICE_TYPE_SMARTPHONE: $this->setView(new SC_SmartphoneView()); break; case DEVICE_TYPE_PC: $this->setView(new SC_SiteView()); break; case DEVICE_TYPE_ADMIN: $this->setView(new SC_AdminView()); } $this->deviceSeted = true; } /** * SC_View インスタンスを設定する. */ function setView($view){ $this->view = $view; } /** * 機種を判別する。 * SC_Display::MOBILE = ガラケー = 1 * SC_Display::SMARTPHONE = スマホ = 2 * SC_Display::PC = PC = 10 * ※PHP4の為にconstは使っていません。 1がガラケーで、2がスマホで4がPCです。 * @return */ function detectDevice(){ $nu = new Net_UserAgent_Mobile(); $su = new SC_SmartphoneUserAgent(); $retDevice = 0; if($nu->isMobile()){ $retDevice = DEVICE_TYPE_MOBILE; }elseif ($su->isSmartphone()){ $retDevice = DEVICE_TYPE_SMARTPHONE; }else{ $retDevice = DEVICE_TYPE_PC; } if($this->autoSet){ $this->setDevice($retDevice); } return $retDevice; } function assign($val1,$val2){ $this->view->assign($val1, $val2); } function assignobj($obj){ $this->view->assignobj($obj); } function assignarray($array){ $this->view->assignarray($array); } }