コード例 #1
0
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     global $objCampaignSess;
     $objView = new SC_SiteView(false);
     $objQuery = new SC_Query();
     $objCampaignSess = new SC_CampaignSession();
     // ディレクトリ名を取得
     $dir_name = dirname($_SERVER['PHP_SELF']);
     $arrDir = split('/', $dir_name);
     $dir_name = $arrDir[count($arrDir) - 1];
     /* セッションにキャンペーンデータを書き込む */
     // キャンペーンからの遷移という情報を保持
     $objCampaignSess->setIsCampaign();
     // キャンペーンIDを保持
     $campaign_id = $objQuery->get("dtb_campaign", "campaign_id", "directory_name = ? AND del_flg = 0", array($dir_name));
     $objCampaignSess->setCampaignId($campaign_id);
     // キャンペーンディレクトリ名を保持
     $objCampaignSess->setCampaignDir($dir_name);
     // カートに入れないページの場合のページ(申込のみページ)へリダイレクト
     $cart_flg = $objQuery->get("dtb_campaign", "cart_flg", "campaign_id = ?", array($campaign_id));
     if (!$cart_flg) {
         $this->sendRedirect($this->getLocation(CAMPAIGN_URL . "{$dir_name}/application.php"));
         exit;
     }
     // キャンペーンが開催中かをチェック
     if ($this->lfCheckActive($dir_name, $objQuery)) {
         $status = CAMPAIGN_TEMPLATE_ACTIVE;
     } else {
         $status = CAMPAIGN_TEMPLATE_END;
     }
     if ($_GET['init'] != "") {
         $this->tpl_init = 'false';
         $this->lfDispProductsList($_GET['ids'], $objQuery);
     } else {
         $this->tpl_init = 'true';
     }
     switch ($_POST['mode']) {
         case 'cart':
             $this->arrErr = $this->lfCheckError($_POST['product_id']);
             if (count($this->arrErr) == 0) {
                 $objCartSess = new SC_CartSession();
                 $classcategory_id = "classcategory_id" . $_POST['product_id'];
                 $classcategory_id1 = $_POST[$classcategory_id . '_1'];
                 $classcategory_id2 = $_POST[$classcategory_id . '_2'];
                 $quantity = "quantity" . $_POST['product_id'];
                 // 規格1が設定されていない場合
                 if (!$this->tpl_classcat_find1[$_POST['product_id']]) {
                     $classcategory_id1 = '0';
                 }
                 // 規格2が設定されていない場合
                 if (!$this->tpl_classcat_find2[$_POST['product_id']]) {
                     $classcategory_id2 = '0';
                 }
                 $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
                 $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity], $campaign_id);
                 $this->sendRedirect($this->getLocation(URL_CART_TOP));
                 exit;
             }
             break;
         default:
             break;
     }
     // 入力情報を渡す
     $this->arrForm = $_POST;
     $this->tpl_dir_name = CAMPAIGN_TEMPLATE_PATH . $dir_name . "/" . $status;
     //---- ページ表示
     $objView->assignobj($this);
     $objView->display($this->tpl_mainpage);
 }
コード例 #2
0
 /**
  * Page のプロセス(モバイル).
  *
  * FIXME 要リファクタリング
  *
  * @return void
  */
 function mobileProcess()
 {
     $objView = new SC_MobileView();
     $objCustomer = new SC_Customer();
     $objQuery = new SC_Query();
     $objDb = new SC_Helper_DB_Ex();
     // パラメータ管理クラス
     $this->objFormParam = new SC_FormParam();
     // パラメータ情報の初期化
     $this->lfInitParam();
     // POST値の取得
     $this->objFormParam->setParam($_POST);
     // ファイル管理クラス
     $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR);
     // ファイル情報の初期化
     $this->lfInitFile();
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     if (!empty($_POST['mode'])) {
         $tmp_id = $_POST['product_id'];
     } else {
         $tmp_id = $_GET['product_id'];
     }
     // 値の正当性チェック
     if (!SC_Utils_Ex::sfIsInt($tmp_id) || !$objDb->sfIsRecord("dtb_products", "product_id", $tmp_id, 'del_flg = 0 AND status = 1')) {
         SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
     }
     // ログイン判定
     if ($objCustomer->isLoginSuccess(true)) {
         //お気に入りボタン表示
         $this->tpl_login = true;
         /* 閲覧ログ機能は現在未使用
         
                        $table = "dtb_customer_reading";
                        $where = "customer_id = ? ";
                        $arrval[] = $objCustomer->getValue('customer_id');
                        //顧客の閲覧商品数
                        $rpcnt = $objQuery->count($table, $where, $arrval);
         
                        //閲覧数が設定数以下
                        if ($rpcnt < CUSTOMER_READING_MAX){
                        //閲覧履歴に新規追加
                        lfRegistReadingData($tmp_id, $objCustomer->getValue('customer_id'));
                        } else {
                        //閲覧履歴の中で一番古いものを削除して新規追加
                        $oldsql = "SELECT MIN(update_date) FROM ".$table." WHERE customer_id = ?";
                        $old = $objQuery->getone($oldsql, array($objCustomer->getValue("customer_id")));
                        $where = "customer_id = ? AND update_date = ? ";
                        $arrval = array($objCustomer->getValue("customer_id"), $old);
                        //削除
                        $objQuery->delete($table, $where, $arrval);
                        //追加
                        lfRegistReadingData($tmp_id, $objCustomer->getValue('customer_id'));
                        }
                     */
     }
     // 規格選択セレクトボックスの作成
     $this->lfMakeSelectMobile($this, $tmp_id);
     // 商品IDをFORM内に保持する。
     $this->tpl_product_id = $tmp_id;
     switch ($_POST['mode']) {
         case 'select':
             // 規格1が設定されている場合
             if ($this->tpl_classcat_find1) {
                 // templateの変更
                 $this->tpl_mainpage = "products/select_find1.tpl";
                 break;
             }
         case 'select2':
             $this->arrErr = $this->lfCheckError();
             // 規格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();
             // 規格1が設定されている場合
             if ($this->tpl_classcat_find2 and $this->arrErr['classcategory_id2']) {
                 // templateの変更
                 $this->tpl_mainpage = "products/select_find2.tpl";
                 break;
             }
             // 商品数の選択を行う
             $this->tpl_mainpage = "products/select_item.tpl";
             break;
         case 'cart':
             // 入力値の変換
             $this->objFormParam->convParam();
             $this->arrErr = $this->lfCheckError();
             if (count($this->arrErr) == 0) {
                 $objCartSess = new SC_CartSession();
                 $classcategory_id1 = $_POST['classcategory_id1'];
                 $classcategory_id2 = $_POST['classcategory_id2'];
                 // 規格1が設定されていない場合
                 if (!$this->tpl_classcat_find1) {
                     $classcategory_id1 = '0';
                 }
                 // 規格2が設定されていない場合
                 if (!$this->tpl_classcat_find2) {
                     $classcategory_id2 = '0';
                 }
                 $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
                 $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $this->objFormParam->getValue('quantity'));
                 $this->sendRedirect($this->getLocation(MOBILE_URL_CART_TOP), true);
                 exit;
             }
             break;
         default:
             break;
     }
     $objQuery = new SC_Query();
     // DBから商品情報を取得する。
     $arrRet = $objQuery->select("*", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($tmp_id));
     $this->arrProduct = $arrRet[0];
     // 商品コードの取得
     $code_sql = "SELECT product_code FROM dtb_products_class AS prdcls WHERE prdcls.product_id = ? GROUP BY product_code ORDER BY product_code";
     $arrProductCode = $objQuery->getall($code_sql, array($tmp_id));
     $arrProductCode = SC_Utils_Ex::sfswaparray($arrProductCode);
     $this->arrProductCode = $arrProductCode["product_code"];
     // 購入制限数を取得
     if ($this->arrProduct['sale_unlimited'] == 1 || $this->arrProduct['sale_limit'] > SALE_LIMIT_MAX) {
         $this->tpl_sale_limit = SALE_LIMIT_MAX;
     } else {
         $this->tpl_sale_limit = $this->arrProduct['sale_limit'];
     }
     // サブタイトルを取得
     $arrFirstCat = $objDb->sfGetFirstCat($arrRet[0]['category_id']);
     $tpl_subtitle = $arrFirstCat['name'];
     $this->tpl_subtitle = $tpl_subtitle;
     // DBからのデータを引き継ぐ
     $this->objUpFile->setDBFileList($this->arrProduct);
     // ファイル表示用配列を渡す
     $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL, true);
     // 支払方法の取得
     $this->arrPayment = $this->lfGetPayment();
     // 入力情報を渡す
     $this->arrForm = $this->objFormParam->getFormParamList();
     //レビュー情報の取得
     $this->arrReview = $this->lfGetReviewData($tmp_id);
     // タイトルに商品名を入れる
     $this->tpl_title = "商品詳細 " . $this->arrProduct["name"];
     //オススメ商品情報表示
     $this->arrRecommend = $this->lfPreGetRecommendProducts($tmp_id);
     //この商品を買った人はこんな商品も買っています
     $this->arrRelateProducts = $this->lfGetRelateProducts($tmp_id);
     $objView->assignobj($this);
     $objView->display(SITE_FRAME);
 }
コード例 #3
0
ファイル: SC_View.php プロジェクト: khrisna/eccubedrm
 function SC_SiteView($cart = true)
 {
     parent::SC_View();
     $this->_smarty->template_dir = TEMPLATE_DIR;
     $this->_smarty->compile_dir = COMPILE_DIR;
     $this->initpath();
     // PHP5ではsessionをスタートする前にヘッダー情報を送信していると警告が出るため、先にセッションをスタートするように変更
     SC_Utils_Ex::sfDomainSessionStart();
     if ($cart) {
         $include_dir = realpath(dirname(__FILE__));
         require_once $include_dir . "/SC_CartSession.php";
         $objCartSess = new SC_CartSession();
         $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
     }
 }
コード例 #4
0
 /**
  * Page のプロセス(モバイル).
  *
  * FIXME スパゲッティ...
  *
  * @return void
  */
 function mobileProcess()
 {
     $objView = new SC_MobileView();
     $conn = new SC_DBConn();
     $objDb = new SC_Helper_DB_Ex();
     //表示件数の選択
     if (isset($_REQUEST['disp_number']) && SC_Utils_Ex::sfIsInt($_REQUEST['disp_number'])) {
         $this->disp_number = $_REQUEST['disp_number'];
     } else {
         //最小表示件数を選択
         $this->disp_number = current(array_keys($this->arrPRODUCTLISTMAX));
     }
     //表示順序の保存
     $this->orderby = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : "";
     // GETのカテゴリIDを元に正しいカテゴリIDを取得する。
     $arrCategory_id = $objDb->sfGetCategoryId("", $_GET['category_id']);
     // タイトル編集
     $tpl_subtitle = "";
     $tpl_search_mode = false;
     if (!isset($_GET['mode'])) {
         $_GET['mode'] = "";
     }
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     if (!isset($_GET['name'])) {
         $_GET['name'] = "";
     }
     if (!isset($_REQUEST['orderby'])) {
         $_REQUEST['orderby'] = "";
     }
     if (empty($arrCategory_id)) {
         $arrCategory_id = array("0");
     }
     if ($_GET['mode'] == 'search') {
         $tpl_subtitle = "検索結果";
         $tpl_search_mode = true;
     } elseif (empty($arrCategory_id)) {
         $tpl_subtitle = "全商品";
     } else {
         $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]);
         $tpl_subtitle = $arrFirstCat['name'];
     }
     $objQuery = new SC_Query();
     $count = $objQuery->count("dtb_best_products", "category_id = ?", $arrCategory_id);
     // 以下の条件でBEST商品を表示する
     // ・BEST最大数の商品が登録されている。
     // ・カテゴリIDがルートIDである。
     // ・検索モードでない。
     if ($count >= BEST_MIN && $this->lfIsRootCategory($arrCategory_id[0]) && $_GET['mode'] != 'search') {
         // 商品TOPの表示処理
         $this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $arrCategory_id[0]);
         $this->BEST_ROOP_MAX = ceil((BEST_MAX - 1) / 2);
     } else {
         if ($_GET['mode'] == 'search' && strlen($_GET['category_id']) == 0) {
             // 検索時にcategory_idがGETに存在しない場合は、仮に埋めたIDを空白に戻す
             $arrCategory_id = array("");
         }
         // 商品一覧の表示処理
         $this->lfDispProductsList($arrCategory_id[0], $_GET['name'], $this->disp_number, $_REQUEST['orderby']);
         // 検索条件を画面に表示
         // カテゴリー検索条件
         if (strlen($_GET['category_id']) == 0) {
             $arrSearch['category'] = "指定なし";
         } else {
             $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?", array($category_id));
             $arrSearch['category'] = $arrCat;
         }
         // 商品名検索条件
         if ($_GET['name'] === "") {
             $arrSearch['name'] = "指定なし";
         } else {
             $arrSearch['name'] = $_GET['name'];
         }
     }
     if ($_POST['mode'] == "cart" && $_POST['product_id'] != "") {
         // 値の正当性チェック
         if (!SC_Utils_Ex::sfIsInt($_POST['product_id']) || !SC_Utils_Ex::sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) {
             SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND, "", false, "", true);
         } else {
             // 入力値の変換
             $this->arrErr = $this->lfCheckError($_POST['product_id']);
             if (count($this->arrErr) == 0) {
                 $objCartSess = new SC_CartSession();
                 $classcategory_id = "classcategory_id" . $_POST['product_id'];
                 $classcategory_id1 = $_POST[$classcategory_id . '_1'];
                 $classcategory_id2 = $_POST[$classcategory_id . '_2'];
                 $quantity = "quantity" . $_POST['product_id'];
                 // 規格1が設定されていない場合
                 if (!$this->tpl_classcat_find1[$_POST['product_id']]) {
                     $classcategory_id1 = '0';
                 }
                 // 規格2が設定されていない場合
                 if (!$this->tpl_classcat_find2[$_POST['product_id']]) {
                     $classcategory_id2 = '0';
                 }
                 $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
                 $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity]);
                 $this->sendRedirect(MOBILE_URL_CART_TOP, array(session_name() => session_id()));
                 exit;
             }
         }
     }
     // ページ送り機能用のURLを作成する。
     $objURL = new Net_URL($_SERVER['PHP_SELF']);
     foreach ($_REQUEST as $key => $value) {
         if ($key == session_name() || $key == 'pageno') {
             continue;
         }
         $objURL->addQueryString($key, mb_convert_encoding($value, 'SJIS', CHAR_CODE));
     }
     if ($this->objNavi->now_page > 1) {
         $objURL->addQueryString('pageno', $this->objNavi->now_page - 1);
         $this->tpl_previous_page = $objURL->path . '?' . $objURL->getQueryString();
     }
     if ($this->objNavi->now_page < $this->objNavi->max_page) {
         $objURL->addQueryString('pageno', $this->objNavi->now_page + 1);
         $this->tpl_next_page = $objURL->path . '?' . $objURL->getQueryString();
     }
     $this->tpl_subtitle = $tpl_subtitle;
     $this->tpl_search_mode = $tpl_search_mode;
     // 支払方法の取得
     $this->arrPayment = $this->lfGetPayment();
     // 入力情報を渡す
     $this->arrForm = $_POST;
     $this->category_id = $arrCategory_id[0];
     $this->arrSearch = $arrSearch;
     $this->tpl_mainpage = MOBILE_TEMPLATE_DIR . "products/list.tpl";
     $objView->assignobj($this);
     $objView->display(SITE_FRAME);
 }