/** * Page のレスポンス送信. * * @return void */ public function sendResponse() { // ループ防止に現在URLを格納 $location = ''; $netUrl = new Net_URL(); $location = $netUrl->getUrl(); // ログインされていなく、リダイレクト処理 if (empty($this->isLogin) && !preg_match('/^.*original.*/', $location)) { $this->objDisplay->response->sendRedirect('original'); } $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); // ローカルフックポイントを実行. $this->doLocalHookpointAfter($objPlugin); // HeadNaviにpluginテンプレートを追加する. $objPlugin->setHeadNaviBlocs($this->arrPageLayout['HeadNavi']); // スーパーフックポイントを実行. $objPlugin->doAction('LC_Page_process', array($this)); // ページクラス名をテンプレートに渡す $arrBacktrace = debug_backtrace(); if (strlen($this->tpl_page_class_name) === 0) { $this->tpl_page_class_name = preg_replace('/_Ex$/', '', $arrBacktrace[1]['class']); } $this->objDisplay->prepare($this); $this->objDisplay->addHeader('Vary', 'User-Agent'); $this->objDisplay->response->write(); }
/** * Page を初期化する. * * DBエラー発生時, エラーページを表示しようした際の DB 接続を防ぐため, * ここでは, parent::init() を行わない. * @return void */ function init() { $this->tpl_mainpage = 'error.tpl'; $this->tpl_title = t('c_Error_01'); // ディスプレイクラス生成 $this->objDisplay = new SC_Display_Ex(); // transformでフックしているばあいに, 再度エラーが発生するため, コールバックを無効化. $objHelperPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); $objHelperPlugin->arrRegistedPluginActions = array(); }
/** * クラスのオートローディング本体 * * LC_* には対応していない。 * @return void */ public static function autoload($class) { $arrClassNamePart = explode('_', $class); $is_ex = end($arrClassNamePart) === 'Ex'; $count = count($arrClassNamePart); $classpath = $is_ex ? CLASS_EX_REALDIR : CLASS_REALDIR; if (($arrClassNamePart[0] === 'GC' || $arrClassNamePart[0] === 'SC') && $arrClassNamePart[1] === 'Utils') { $classpath .= $is_ex ? 'util_extends/' : 'util/'; } elseif ($arrClassNamePart[0] === 'SC' && $is_ex === true && $count >= 4) { $arrClassNamePartTemp = $arrClassNamePart; // FIXME クラスファイルのディレクトリ命名が変。変な現状に合わせて強引な処理をしてる。 $arrClassNamePartTemp[1] = $arrClassNamePartTemp[1] . '_extends'; $classpath .= strtolower(implode('/', array_slice($arrClassNamePartTemp, 1, -2))) . '/'; } elseif ($arrClassNamePart[0] === 'SC' && $is_ex === false && $count >= 3) { $classpath .= strtolower(implode('/', array_slice($arrClassNamePart, 1, -1))) . '/'; } elseif ($arrClassNamePart[0] === 'SC') { // 処理なし } else { $classpath = ''; $class = str_replace('_', '/', $class); } $classpath .= "{$class}.php"; // プラグイン向けフックポイント // MEMO: プラグインのローダーがDB接続を必要とするため、SC_Queryがロードされた後のみ呼び出される。 // プラグイン情報のキャッシュ化が行われれば、全部にフックさせることを可能に? $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance(true); if (is_object($objPlugin)) { // 元の設定を一時保存 $plugin_class = $class; $plugin_classpath = $classpath; $objPlugin->doAction('loadClassFileChange', array(&$plugin_class, &$plugin_classpath)); // FIXME: トリッキーな処理で _Ex ファイルを無視しないようにする(無視するとユーザーカスタマイズで分かりにくい) // SC_XXXX_Ex がロードされる場合にextendsのchainを // SC_XXXX_Ex -> SC_XXXX から、 SC_XXXX_Ex -> $class (-> SC_XXXX) と変える。 // そうでない場合は、直接置き換えと想定して帰ってきたクラスをロードする if ($plugin_class !== $class) { if ($is_ex) { // Ex ファイルへのフックの場合のみチェイン変更する。 $exp = "/(class[ ]+{$class}[ ]+extends +)[a-zA-Z_\\-]+( *{)/"; $replace = '$1' . $plugin_class . '$2'; $base_class_str = file_get_contents($classpath); $base_class_str = str_replace(array('<?php', '?>'), '', $base_class_str); $base_class_str = preg_replace($exp, $replace, $base_class_str, 1); include $plugin_classpath; eval($base_class_str); return; } else { include $plugin_classpath; } } } include $classpath; }
/** * Page を初期化する. * LC_Page_Adminクラス内でエラーページを表示しようとした際に無限ループに陥るのを防ぐため, * ここでは, parent::init() を行わない.(フロントのエラー画面出力と同様の仕様) * * @return void */ public function init() { $this->template = LOGIN_FRAME; $this->tpl_mainpage = 'login_error.tpl'; $this->tpl_title = 'ログインエラー'; // ディスプレイクラス生成 $this->objDisplay = new SC_Display_Ex(); // transformでフックしているばあいに, 再度エラーが発生するため, コールバックを無効化. $objHelperPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); $objHelperPlugin->arrRegistedPluginActions = array(); // キャッシュから店舗情報取得(DBへの接続は行わない) $this->arrSiteInfo = SC_Helper_DB_Ex::sfGetBasisDataCache(false); }
/** * ページのレイアウト情報を取得し, 設定する. * * 現在の URL に応じたページのレイアウト情報を取得し, LC_Page インスタンスに * 設定する. * * @access public * @param LC_Page $objPage LC_Page インスタンス * @param boolean $preview プレビュー表示の場合 true * @param string $url ページのURL($_SERVER['SCRIPT_NAME'] の情報) * @param integer $device_type_id 端末種別ID * @return void */ public function sfGetPageLayout(&$objPage, $preview = false, $url = '', $device_type_id = DEVICE_TYPE_PC) { // URLを元にページ情報を取得 if ($preview === false) { $url = preg_replace('|^' . preg_quote(ROOT_URLPATH) . '|', '', $url); $arrPageData = $this->getPageProperties($device_type_id, null, 'url = ?', array($url)); // プレビューの場合は, プレビュー用のデータを取得 } else { $arrPageData = $this->getPageProperties($device_type_id, 0); } if (empty($arrPageData)) { trigger_error('ページ情報を取得できませんでした。', E_USER_WARNING); } $objPage->tpl_mainpage = $this->getTemplatePath($device_type_id) . $arrPageData[0]['filename'] . '.tpl'; if (!file_exists($objPage->tpl_mainpage)) { $msg = 'メイン部のテンプレートが存在しません。[' . $objPage->tpl_mainpage . ']'; trigger_error($msg, E_USER_WARNING); } $objPage->arrPageLayout =& $arrPageData[0]; if (strlen($objPage->arrPageLayout['author']) === 0) { $arrInfo = SC_Helper_DB_Ex::sfGetBasisData(); $objPage->arrPageLayout['author'] = $arrInfo['company_name']; } // ページタイトルを設定 if (SC_Utils_Ex::isBlank($objPage->tpl_title)) { $objPage->tpl_title = $objPage->arrPageLayout['page_name']; } // 該当ページのブロックを取得し, 配置する $masterData = new SC_DB_MasterData_Ex(); $arrTarget = $masterData->getMasterData('mtb_target'); $arrBlocs = $this->getBlocPositions($device_type_id, $objPage->arrPageLayout['page_id']); // 無効なプラグインのブロックを取り除く. $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance(); $arrBlocs = $objPlugin->getEnableBlocs($arrBlocs); // php_path, tpl_path が存在するものを, 各ターゲットに配置 foreach ($arrTarget as $target_id => $value) { foreach ($arrBlocs as $arrBloc) { if ($arrBloc['target_id'] != $target_id) { continue; } if (is_file($arrBloc['php_path']) || is_file($arrBloc['tpl_path'])) { $objPage->arrPageLayout[$arrTarget[$target_id]][] = $arrBloc; } else { $error = "ブロックが見つかりません\n" . 'tpl_path: ' . $arrBloc['tpl_path'] . "\n" . 'php_path: ' . $arrBloc['php_path']; trigger_error($error, E_USER_WARNING); } } } // カラム数を取得する $objPage->tpl_column_num = $this->getColumnNum($objPage->arrPageLayout); }
/** * コンストラクタ */ public function __construct() { $this->check_dir = IMAGE_SAVE_REALDIR; // SC_FormParamのフックポイント // TODO: debug_backtrace以外にいい方法があれば良いが、一旦これで $backtraces = debug_backtrace(); // 呼び出し元のクラスを取得 $class = $backtraces[1]['class']; $objPage = $backtraces[1]['object']; $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($objPage->plugin_activate_flg); if (is_object($objPlugin)) { $objPlugin->doAction('SC_FormParam_construct', array($class, $this)); } }
/** * Page を初期化する. * * @return void */ public function init() { // 開始時刻を設定する。 $this->timeStart = microtime(true); $this->tpl_authority = $_SESSION['authority']; // ディスプレイクラス生成 $this->objDisplay = new SC_Display_Ex(); $this->setTplMainpage($this->blocItems['tpl_path']); // トランザクショントークンの検証と生成 $this->setTokenTo(); // ローカルフックポイントを実行. $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); $this->doLocalHookpointBefore($objPlugin); }
/** * ページのレイアウト情報を取得し, 設定する. * * 現在の URL に応じたページのレイアウト情報を取得し, LC_Page インスタンスに * 設定する. * * @access public * @param LC_Page $objPage LC_Page インスタンス * @param boolean $preview プレビュー表示の場合 true * @param string $url ページのURL($_SERVER['SCRIPT_NAME'] の情報) * @param integer $device_type_id 端末種別ID * @return void */ function sfGetPageLayout(&$objPage, $preview = false, $url = '', $device_type_id = DEVICE_TYPE_PC) { // URLを元にページ情報を取得 if ($preview === false) { $url = preg_replace('|^' . preg_quote(ROOT_URLPATH) . '|', '', $url); $arrPageData = $this->getPageProperties($device_type_id, null, 'url = ?', array($url)); } else { $arrPageData = $this->getPageProperties($device_type_id, 0); } $objPage->tpl_mainpage = $this->getTemplatePath($device_type_id) . $arrPageData[0]['filename'] . '.tpl'; $objPage->arrPageLayout =& $arrPageData[0]; // ページタイトルを設定 if (SC_Utils_Ex::isBlank($objPage->tpl_title)) { $objPage->tpl_title = $objPage->arrPageLayout['page_name']; } // 該当ページのブロックを取得し, 配置する $masterData = new SC_DB_MasterData_Ex(); $arrTarget = $masterData->getMasterData('mtb_target'); $arrBlocs = $this->getBlocPositions($device_type_id, $objPage->arrPageLayout['page_id']); var_dump($arrTarget); var_dump($arrBlocs); // 無効なプラグインのブロックを取り除く. $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance(); $arrBlocs = $objPlugin->getEnableBlocs($arrBlocs); // php_path, tpl_path が存在するものを, 各ターゲットに配置 foreach ($arrTarget as $target_id => $value) { foreach ($arrBlocs as $arrBloc) { if ($arrBloc['target_id'] != $target_id) { continue; } if (is_file($arrBloc['php_path']) || is_file($arrBloc['tpl_path'])) { $objPage->arrPageLayout[$arrTarget[$target_id]][] = $arrBloc; } else { $error = "ブロックが見つかりません\n" . 'tpl_path: ' . $arrBloc['tpl_path'] . "\n" . 'php_path: ' . $arrBloc['php_path']; GC_Utils_Ex::gfPrintLog($error); } } } // カラム数を取得する $objPage->tpl_column_num = $this->getColumnNum($objPage->arrPageLayout); }
/** * Page のResponse. * * todo たいした処理でないのに異常に処理が重い * @return void */ function sendResponse() { // TODO sendResponseをオーバーライドしている為、afterフックポイントが実行されない.直接実行する.(#1790) $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); $objPlugin->doAction('LC_Page_Mypage_DownLoad_action_after', array($this)); $this->objDisplay->noAction(); // パラメーター取得 $customer_id = $_SESSION['customer']['customer_id']; $order_id = $_GET['order_id']; $product_id = $_GET['product_id']; $product_class_id = $_GET['product_class_id']; //DBから商品情報の読込 $arrForm = $this->lfGetRealFileName($customer_id, $order_id, $product_id, $product_class_id); //ファイル情報が無い場合はNG if ($arrForm['down_realfilename'] == '') { SC_Utils_Ex::sfDispSiteError(DOWNFILE_NOT_FOUND, '', true); } //ファイルそのものが無い場合もとりあえずNG $realpath = DOWN_SAVE_REALDIR . $arrForm['down_realfilename']; if (!file_exists($realpath)) { SC_Utils_Ex::sfDispSiteError(DOWNFILE_NOT_FOUND, '', true); } //ファイル名をエンコードする Safariの対策はUTF-8で様子を見る $encoding = 'Shift_JIS'; if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Safari')) { $encoding = 'UTF-8'; } $sdown_filename = mb_convert_encoding($arrForm['down_filename'], $encoding, 'auto'); // flushなどを利用しているので、現行のSC_Displayは利用できません。 // SC_DisplayやSC_Responseに大容量ファイルレスポンスが実装されたら移行可能だと思います。 // ダウンロード実行 モバイル端末はダウンロード方法が異なる if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { // キャリアがAUのモバイル端末はさらにダウンロード方法が異なる if (SC_MobileUserAgent::getCarrier() == 'ezweb') { // AUモバイル $this->lfMobileAuDownload($realpath, $sdown_filename); } else { // AU以外のモバイル $this->lfMobileDownload($realpath, $sdown_filename); } } else { // PC、スマフォ $this->lfDownload($realpath, $sdown_filename); } }
function process(&$lcpage) { //プラグインの名前を判別してページ内で有効なプラグインがあれば実行する $arrPluginList = SC_Helper_Plugin_Ex::load($lcpage); if (count($arrPluginList) > 0) { foreach ($arrPluginList as $key => $value) { $instance = new $value(); $instance->process($lcpage); } } return $lcpage; }
/** * アプリケーション内でリダイレクトする * * 内部で生成する URL の searchpart は、下記の順で上書きしていく。(後勝ち) * 1. 引数 $inheritQueryString が true の場合、$_SERVER['QUERY_STRING'] * 2. $location に含まれる searchpart * 3. 引数 $arrQueryString * @param string $location 「url-path」「現在のURLからのパス」「URL」のいずれか。「../」の解釈は行なわない。 * @param array $arrQueryString URL に付加する searchpart * @param bool $inheritQueryString 現在のリクエストの searchpart を継承するか * @param bool|null $useSsl true:HTTPSを強制, false:HTTPを強制, null:継承 * @return void * @static */ function sendRedirect($location, $arrQueryString = array(), $inheritQueryString = false, $useSsl = null) { // ローカルフックポイント処理 $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); $arrBacktrace = debug_backtrace(); if (is_object($arrBacktrace[0]['object']) && method_exists($arrBacktrace[0]['object'], 'getMode')) { $parent_class_name = get_parent_class($arrBacktrace[0]['object']); $objPlugin->doAction($parent_class_name . '_action_' . $arrBacktrace[0]['object']->getMode(), array($arrBacktrace[0]['object'])); $class_name = get_class($arrBacktrace[0]['object']); if ($class_name != $parent_class_name) { $objPlugin->doAction($class_name . '_action_' . $arrBacktrace[0]['object']->getMode(), array($this)); } } elseif (is_object($arrBacktrace[0]['object'])) { $pattern = '/^[a-zA-Z0-9_]+$/'; $mode = null; if (isset($_GET['mode']) && preg_match($pattern, $_GET['mode'])) { $mode = $_GET['mode']; } elseif (isset($_POST['mode']) && preg_match($pattern, $_POST['mode'])) { $mode = $_POST['mode']; } $parent_class_name = get_parent_class($arrBacktrace[0]['object']); $objPlugin->doAction($parent_class_name . '_action_' . $mode, array($arrBacktrace[0]['object'])); $class_name = get_class($arrBacktrace[0]['object']); if ($class_name != $parent_class_name) { $objPlugin->doAction($class_name . '_action_' . $mode, array($this)); } } // url-path → URL 変換 if ($location[0] === '/') { $netUrl = new Net_URL($location); $location = $netUrl->getUrl(); } // URL の場合 if (preg_match('/^https?:/', $location)) { $url = $location; if (is_bool($useSsl)) { if ($useSsl) { $pattern = '/^' . preg_quote(HTTP_URL, '/') . '(.*)/'; $replacement = HTTPS_URL . '\\1'; $url = preg_replace($pattern, $replacement, $url); } else { $pattern = '/^' . preg_quote(HTTPS_URL, '/') . '(.*)/'; $replacement = HTTP_URL . '\\1'; $url = preg_replace($pattern, $replacement, $url); } } } else { if (!is_bool($useSsl)) { $useSsl = SC_Utils_Ex::sfIsHTTPS(); } $netUrl = new Net_URL($useSsl ? HTTPS_URL : HTTP_URL); $netUrl->path = dirname($_SERVER['SCRIPT_NAME']) . '/' . $location; $url = $netUrl->getUrl(); } $pattern = '/^(' . preg_quote(HTTP_URL, '/') . '|' . preg_quote(HTTPS_URL, '/') . ')/'; // アプリケーション外へのリダイレクトは扱わない if (preg_match($pattern, $url) === 0) { trigger_error('', E_USER_ERROR); } $netUrl = new Net_URL($url); if ($inheritQueryString && !empty($_SERVER['QUERY_STRING'])) { $arrQueryStringBackup = $netUrl->querystring; // XXX メソッド名は add で始まるが、実際には置換を行う $netUrl->addRawQueryString($_SERVER['QUERY_STRING']); $netUrl->querystring = array_merge($netUrl->querystring, $arrQueryStringBackup); } $netUrl->querystring = array_merge($netUrl->querystring, $arrQueryString); $session = SC_SessionFactory_Ex::getInstance(); if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE || $session->useCookie() == false) { $netUrl->addQueryString(session_name(), session_id()); } $netUrl->addQueryString(TRANSACTION_ID_NAME, SC_Helper_Session_Ex::getToken()); $url = $netUrl->getURL(); header("Location: {$url}"); exit; }
/** * Page のAction. * * @return void */ function action() { // 会員クラス $objCustomer = new SC_Customer_Ex(); // パラメーター管理クラス $this->objFormParam = new SC_FormParam_Ex(); // パラメーター情報の初期化 $this->arrForm = $this->lfInitParam($this->objFormParam); // ファイル管理クラス $this->objUpFile = new SC_UploadFile_Ex(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR); // ファイル情報の初期化 $this->objUpFile = $this->lfInitFile($this->objUpFile); // プロダクトIDの正当性チェック $product_id = $this->lfCheckProductId($this->objFormParam->getValue('admin'), $this->objFormParam->getValue('product_id')); $this->mode = $this->getMode(); $objProduct = new SC_Product_Ex(); $objProduct->setProductsClassByProductIds(array($product_id)); // 規格1クラス名 $this->tpl_class_name1 = $objProduct->className1[$product_id]; // 規格2クラス名 $this->tpl_class_name2 = $objProduct->className2[$product_id]; // 規格1 $this->arrClassCat1 = $objProduct->classCats1[$product_id]; // 規格1が設定されている $this->tpl_classcat_find1 = $objProduct->classCat1_find[$product_id]; // 規格2が設定されている $this->tpl_classcat_find2 = $objProduct->classCat2_find[$product_id]; $this->tpl_stock_find = $objProduct->stock_find[$product_id]; $this->tpl_product_class_id = $objProduct->classCategories[$product_id]['__unselected']['__unselected']['product_class_id']; $this->tpl_product_type = $objProduct->classCategories[$product_id]['__unselected']['__unselected']['product_type']; // 在庫が無い場合は、OnLoadしない。(javascriptエラー防止) if ($this->tpl_stock_find) { // 規格選択セレクトボックスの作成 $this->js_lnOnload .= $this->lfMakeSelect(); } $this->tpl_javascript .= 'classCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories[$product_id]) . ';'; $this->tpl_javascript .= 'function lnOnLoad(){' . $this->js_lnOnload . '}'; $this->tpl_onload .= 'lnOnLoad();'; // モバイル用 規格選択セレクトボックスの作成 if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { $this->lfMakeSelectMobile($this, $product_id, $this->objFormParam->getValue('classcategory_id1')); } // 商品IDをFORM内に保持する $this->tpl_product_id = $product_id; switch ($this->mode) { case 'cart': $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $this->tpl_classcat_find1, $this->tpl_classcat_find2); if (count($this->arrErr) == 0) { $objCartSess = new SC_CartSession_Ex(); $product_class_id = $this->objFormParam->getValue('product_class_id'); $objCartSess->addProduct($product_class_id, $this->objFormParam->getValue('quantity')); SC_Response_Ex::sendRedirect(CART_URLPATH); SC_Response_Ex::actionExit(); } break; case 'add_favorite': // ログイン中のユーザが商品をお気に入りにいれる処理 if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) { $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam); if (count($this->arrErr) == 0) { if (!$this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'), $objCustomer->getValue('customer_id'))) { $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite', array($this)); SC_Response_Ex::actionExit(); } } } break; case 'add_favorite_sphone': // ログイン中のユーザが商品をお気に入りにいれる処理(スマートフォン用) if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) { $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam); if (count($this->arrErr) == 0) { if ($this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'), $objCustomer->getValue('customer_id'))) { $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite_sphone', array($this)); print 'true'; SC_Response_Ex::actionExit(); } } print 'error'; SC_Response_Ex::actionExit(); } break; case 'select': case 'select2': case 'selectItem': /** * モバイルの数量指定・規格選択の際に、 * $_SESSION['cart_referer_url'] を上書きさせないために、 * 何もせずbreakする。 */ break; default: // カート「戻るボタン」用に保持 $netURL = new Net_URL(); $_SESSION['cart_referer_url'] = $netURL->getURL(); break; } // モバイル用 ポストバック処理 if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { switch ($this->mode) { case 'select': // 規格1が設定されている場合 if ($this->tpl_classcat_find1) { // templateの変更 $this->tpl_mainpage = 'products/select_find1.tpl'; break; } // 数量の入力を行う $this->tpl_mainpage = 'products/select_item.tpl'; break; case 'select2': $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $this->tpl_classcat_find1, $this->tpl_classcat_find2); // 規格1が設定されていて、エラーを検出した場合 if ($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) { // templateの変更 $this->tpl_mainpage = 'products/select_find1.tpl'; break; } // 規格2が設定されている場合 if ($this->tpl_classcat_find2) { $this->arrErr = array(); $this->tpl_mainpage = 'products/select_find2.tpl'; break; } case 'selectItem': $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $this->tpl_classcat_find1, $this->tpl_classcat_find2); // 規格2が設定されていて、エラーを検出した場合 if ($this->tpl_classcat_find2 and $this->arrErr['classcategory_id2']) { // templateの変更 $this->tpl_mainpage = 'products/select_find2.tpl'; break; } $value1 = $this->objFormParam->getValue('classcategory_id1'); // 規格2が設定されている場合. if (SC_Utils_Ex::isBlank($this->objFormParam->getValue('classcategory_id2')) == false) { $value2 = '#' . $this->objFormParam->getValue('classcategory_id2'); } else { $value2 = '#0'; } if (strlen($value1) === 0) { $value1 = '__unselected'; } $this->tpl_product_class_id = $objProduct->classCategories[$product_id][$value1][$value2]['product_class_id']; // この段階では、数量の入力チェックエラーを出させない。 unset($this->arrErr['quantity']); // 数量の入力を行う $this->tpl_mainpage = 'products/select_item.tpl'; break; case 'cart': // この段階でエラーが出る場合は、数量の入力エラーのはず if (count($this->arrErr)) { // 数量の入力を行う $this->tpl_mainpage = 'products/select_item.tpl'; } break; default: $this->tpl_mainpage = 'products/detail.tpl'; break; } } // 商品詳細を取得 $this->arrProduct = $objProduct->getDetail($product_id); // サブタイトルを取得 $this->tpl_subtitle = $this->arrProduct['name']; // 関連カテゴリを取得 $this->arrRelativeCat = SC_Helper_DB_Ex::sfGetMultiCatTree($product_id); // 商品ステータスを取得 $this->productStatus = $objProduct->getProductStatus($product_id); // 画像ファイル指定がない場合の置換処理 $this->arrProduct['main_image'] = SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']); $this->subImageFlag = $this->lfSetFile($this->objUpFile, $this->arrProduct, $this->arrFile); //レビュー情報の取得 $this->arrReview = $this->lfGetReviewData($product_id); //関連商品情報表示 $this->arrRecommend = $this->lfPreGetRecommendProducts($product_id); // ログイン判定 if ($objCustomer->isLoginSuccess() === true) { //お気に入りボタン表示 $this->tpl_login = true; $this->is_favorite = SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($objCustomer->getValue('customer_id'), $product_id)); } }
/** * Add product to authenticated user's favorites. (for Smart phone) * * @param type $objCustomer * @return void */ function doAddFavoriteSphone($objCustomer) { // ログイン中のユーザが商品をお気に入りにいれる処理(スマートフォン用) if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) { $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam); if (count($this->arrErr) == 0) { if ($this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'), $objCustomer->getValue('customer_id'))) { $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite_sphone', array($this)); print 'true'; SC_Response_Ex::actionExit(); } } print 'error'; SC_Response_Ex::actionExit(); } }
/** * アップロードファイルのエラーチェック. * * @param string $plugin_code * @param string $plugin_dir * @return array エラー情報を格納した連想配列. * */ function lfCheckErrorUploadFile($plugin_code, $plugin_dir) { $arrErr = array(); // プラグイン重複チェック $plugins = SC_Helper_Plugin_Ex::getAllPlugin(); foreach ($plugins as $val) { if ($val['plugin_code'] == $plugin_code) { $arrErr['plugin_file'] = "※ 同名のプラグインがすでに登録されています。<br/>"; } } return $arrErr; }
/** * outputfilter用のフィルタ関数。プラグイン用のフックポイント処理を実行 * @param string $source ソース * @param Smarty_Compiler $smarty Smartyのコンパイラクラス * @return string $source ソース */ function outputfilter_transform($source, &$smarty) { if (!is_null($this->objPage)) { // フックポイントを実行. $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->objPage->plugin_activate_flg); $objPlugin->doAction('outputfilterTransform', array(&$source, $this->objPage, $smarty->_current_file)); } return $source; }
/** * アプリケーション内でリダイレクトする * * 内部で生成する URL の searchpart は、下記の順で上書きしていく。(後勝ち) * 1. 引数 $inheritQueryString が true の場合、$_SERVER['QUERY_STRING'] * 2. $location に含まれる searchpart * 3. 引数 $arrQueryString * * @param string $location * 「url-path」「現在のURLからのパス」「URL」のいずれか。「../」の解釈は行なわない。 * @param array $arrQueryString * URL に付加する searchpart * @param bool $inheritQueryString * 現在のリクエストの searchpart を継承するか * @param bool|null $useSsl * true:HTTPSを強制, false:HTTPを強制, null:継承 * @return void * @static * */ public function sendRedirect($location, $arrQueryString = array(), $inheritQueryString = false, $useSsl = null) { // ローカルフックポイント処理 $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); if (is_object($objPlugin)) { $arrBacktrace = debug_backtrace(); if (is_object($arrBacktrace[0]['object'])) { $pattern = '/^[a-zA-Z0-9_]+$/'; if (isset($_REQUEST['mode']) && preg_match($pattern, $_REQUEST['mode'])) { $mode = $_REQUEST['mode']; } $parent_class_name = get_parent_class($arrBacktrace[0]['object']); $class_name = get_class($arrBacktrace[0]['object']); } $objPlugin->doAction($parent_class_name . '_action_' . $mode, array($arrBacktrace[0]['object'])); if ($class_name != $parent_class_name) { $objPlugin->doAction($class_name . '_action_' . $mode, array($this)); } } // url-path → URL 変換 if ($location[0] === '/') { $netUrl = new Net_URL($location); $url = $netUrl->getUrl(); } elseif (strpos($location, HTTPS_URL) === 0 || strpos($location, HTTP_URL) === 0) { $url = $location; } else { $netUrl = new Net_URL(HTTP_URL); $netUrl->path = dirname($_SERVER['SCRIPT_NAME']) . '/' . $location; $url = $netUrl->getUrl(); } if (!is_bool($useSsl)) { $useSsl = SC_Utils_Ex::sfIsHTTPS(); } if ($useSsl) { $url = str_replace(HTTP_URL, HTTPS_URL, $url); } else { $url = str_replace(HTTPS_URL, HTTP_URL, $url); } // アプリケーション外へのリダイレクトは扱わない if (!SC_Utils_Ex::isAppInnerUrl($url)) { trigger_error('URL IS APP NOT INNER URL', E_USER_ERROR); } $netUrl = new Net_URL($url); if ($inheritQueryString && !empty($_SERVER['QUERY_STRING'])) { $arrQueryStringBackup = $netUrl->querystring; // XXX メソッド名は add で始まるが、実際には置換を行う $netUrl->addRawQueryString($_SERVER['QUERY_STRING']); $netUrl->querystring = array_merge($netUrl->querystring, $arrQueryStringBackup); } $netUrl->querystring = array_merge($netUrl->querystring, $arrQueryString); $session = SC_SessionFactory_Ex::getInstance(); if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE || $session->useCookie() == false) { $netUrl->addQueryString(session_name(), session_id()); } if (GC_Utils_Ex::isAdminFunction()) { // 管理画面またはmode指定時は付与 $netUrl->addQueryString(TRANSACTION_ID_NAME, SC_Helper_Session_Ex::getToken()); } $url = $netUrl->getURL(); header("Location: {$url}"); exit; }
/** * Page のレスポンス送信. * * @return void */ function sendResponse() { $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); // ローカルフックポイントを実行 $parent_class_name = get_parent_class($this); $objPlugin->doAction($parent_class_name . '_action_after', array($this)); $class_name = get_class($this); if ($class_name != $parent_class_name) { $objPlugin->doAction($class_name . '_action_after', array($this)); } // HeadNaviにpluginテンプレートを追加する. $objPlugin->setHeadNaviBlocs($this->arrPageLayout['HeadNavi']); // スーパーフックポイントを実行. $objPlugin->doAction('LC_Page_process', array($this)); $this->objDisplay->prepare($this, true); $this->objDisplay->response->write(); }
/** * ローカルフックポイントを生成し、実行します. * * @param SC_Helper_Plugin_Ex $objPlugin * @return void */ function doLocalHookpointAfter(SC_Helper_Plugin_Ex $objPlugin) { // ローカルフックポイントを実行 $parent_class_name = get_parent_class($this); if ($parent_class_name != 'LC_Page') { $objPlugin->doAction($parent_class_name . '_action_after', array($this)); } $class_name = get_class($this); if ($parent_class_name != 'LC_Page' && $class_name != $parent_class_name) { $objPlugin->doAction($class_name . '_action_after', array($this)); } }