/**
  * Page のアクション.
  *
  * @return void
  */
 function action()
 {
     $layout = new SC_Helper_PageLayout_Ex();
     $layout->sfGetPageLayout($this, false, $_SERVER['SCRIPT_NAME'], $this->objDisplay->detectDevice());
     $this->arrBreadcrumb[0][0] = array();
     switch ($this->arrPageLayout['url']) {
         case 'products/list.php':
             $category_id = $_GET['category_id'];
             if ($category_id) {
                 $this->arrBreadcrumb[0] = self::getBreadcrumbByCategoryId(intval($category_id));
             } else {
                 if ($_GET['mode'] == 'search') {
                     $this->current_name = '検索結果';
                 } else {
                     $this->current_name = '全商品';
                 }
             }
             break;
         case 'products/detail.php':
             $product_id = $_GET['product_id'];
             $this->arrBreadcrumb = SC_Helper_DB_Ex::sfGetMultiCatTree($product_id);
             $objProduct = new SC_Product_Ex();
             $arrProduct = $objProduct->getDetail($product_id);
             $this->current_name = $arrProduct['name'];
             break;
         case 'index.php':
             $this->current_name = '';
             break;
         default:
             $this->current_name = $this->arrPageLayout['page_name'];
             break;
     }
     $this->arrData = self::loadData();
 }
コード例 #2
0
 /**
  * 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();
     if ($_SESSION['customer']['email'] != "") {
         /*My own query*/
         $servername = "localhost";
         $username = "******";
         $password = "******";
         $dbname = "rise_up_shop";
         // Create connection
         $conn = new mysqli($servername, $username, $password, $dbname);
         // Check connection
         $sql = "update dtb_products SET view_count=view_count+1 WHERE product_id={$product_id}";
         mysqli_query($conn, $sql);
     }
     $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->doCart();
             break;
         case 'add_favorite':
             $this->doAddFavorite($objCustomer);
             break;
         case 'add_favorite_sphone':
             $this->doAddFavoriteSphone($objCustomer);
             break;
         case 'select':
         case 'select2':
         case 'selectItem':
             /**
              * モバイルの数量指定・規格選択の際に、
              * $_SESSION['cart_referer_url'] を上書きさせないために、
              * 何もせずbreakする。
              */
             break;
         default:
             $this->doDefault();
             break;
     }
     // モバイル用 ポストバック処理
     if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
         switch ($this->mode) {
             case 'select':
                 $this->doMobileSelect();
                 break;
             case 'select2':
                 $this->doMobileSelect2();
                 break;
             case 'selectItem':
                 $this->doMobileSelectItem();
                 break;
             case 'cart':
                 $this->doMobileCart();
                 break;
             default:
                 $this->doMobileDefault();
                 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));
     }
 }
 /**
  * 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));
     }
 }
コード例 #4
0
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     $objView = new SC_SiteView();
     $objCustomer = new SC_Customer();
     $objQuery = new SC_Query();
     $objDb = new SC_Helper_DB_Ex();
     // レイアウトデザインを取得
     $helper = new SC_Helper_PageLayout_Ex();
     $helper->sfGetPageLayout($this, false, "products/detail.php");
     // ログイン中のユーザが商品をお気に入りにいれる処理
     if ($objCustomer->isLoginSuccess() === true && strlen($_POST['mode']) > 0 && $_POST['mode'] == "add_favorite" && strlen($_POST['favorite_product_id']) > 0) {
         // 値の正当性チェック
         if (!SC_Utils_Ex::sfIsInt($_POST['favorite_product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $_POST['favorite_product_id'], "del_flg = 0 AND status = 1")) {
             SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
             exit;
         } else {
             $this->arrErr = $this->lfCheckError();
             if (count($this->arrErr) == 0) {
                 $customer_id = $objCustomer->getValue('customer_id');
                 $this->lfRegistFavoriteProduct($customer_id, $_POST['favorite_product_id']);
             }
         }
     }
     // パラメータ管理クラス
     $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($_GET['admin']) && $_GET['admin'] == 'on') {
         SC_Utils_Ex::sfIsSuccess(new SC_Session());
         $status = true;
         $where = "del_flg = 0";
     } else {
         $status = false;
         $where = "del_flg = 0 AND status = 1";
     }
     if (isset($_POST['mode']) && $_POST['mode'] != "") {
         $tmp_id = $_POST['product_id'];
     } else {
         $tmp_id = $_GET['product_id'];
     }
     // 値の正当性チェック
     if (!SC_Utils_Ex::sfIsInt($_GET['product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $tmp_id, $where)) {
         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->lfMakeSelect($tmp_id);
     // 商品IDをFORM内に保持する。
     $this->tpl_product_id = $tmp_id;
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     switch ($_POST['mode']) {
         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'];
                 if (!empty($_POST['gmo_oneclick'])) {
                     $objCartSess->delAllProducts();
                 }
                 // 規格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'));
                 if (!empty($_POST['gmo_oneclick'])) {
                     $objSiteSess = new SC_SiteSession();
                     $objSiteSess->setRegistFlag();
                     $objCartSess->saveCurrentCart($objSiteSess->getUniqId());
                     $this->sendRedirect($this->getLocation(URL_DIR . 'user_data/gmopg_oneclick_confirm.php', array(), true));
                     exit;
                 }
                 $this->sendRedirect($this->getLocation(URL_CART_TOP));
                 exit;
             }
             break;
         default:
             break;
     }
     $objQuery = new SC_Query();
     // DBから商品情報を取得する。
     $arrRet = $objQuery->select("*, (SELECT count(*) FROM dtb_customer_favorite_products WHERE product_id = alldtl.product_id AND customer_id = ?) AS favorite_count", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($objCustomer->getValue('customer_id'), $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'];
     }
     // サブタイトルを取得
     $arrCategory_id = $objDb->sfGetCategoryId($arrRet[0]['product_id'], '', $status);
     $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]);
     $this->tpl_subtitle = $arrFirstCat['name'];
     // 関連カテゴリを取得
     $this->arrRelativeCat = $objDb->sfGetMultiCatTree($tmp_id);
     // 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);
     // トラックバック情報の取得
     // トラックバック機能の稼働状況チェック
     if (SC_Utils_Ex::sfGetSiteControlFlg(SITE_CONTROL_TRACKBACK) != 1) {
         $this->arrTrackbackView = "OFF";
     } else {
         $this->arrTrackbackView = "ON";
         $this->arrTrackback = $this->lfGetTrackbackData($tmp_id);
     }
     $this->trackback_url = TRACKBACK_TO_URL . $tmp_id;
     // タイトルに商品名を入れる
     $this->tpl_title = "商品詳細 " . $this->arrProduct["name"];
     //オススメ商品情報表示
     $this->arrRecommend = $this->lfPreGetRecommendProducts($tmp_id);
     //この商品を買った人はこんな商品も買っています
     $this->arrRelateProducts = $this->lfGetRelateProducts($tmp_id);
     $this->lfConvertParam();
     $objView->assignobj($this);
     $objView->display(SITE_FRAME);
 }