source: branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_Detail.php @ 23605

Revision 23605, 27.1 KB checked in by kimoto, 10 years ago (diff)

#2448 typo修正・ソース整形・ソースコメントの改善 for 2.13.3

Scrutinizer Auto-Fixes

This patch was automatically generated as part of the following inspection:
 https://scrutinizer-ci.com/g/nobuhiko/EC-CUBE/inspections/d8722894-69a6-4b1b-898d-43618035c60d

Enabled analysis tools:

  • PHP Analyzer
  • PHP PDepend
  • PHP Similarity Analyzer
  • PHP Change Tracking Analyzer
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2014 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
25
26if (file_exists(MODULE_REALDIR . 'mdl_gmopg/inc/function.php')) {
27    require_once MODULE_REALDIR . 'mdl_gmopg/inc/function.php';
28}
29/**
30 * 商品詳細 のページクラス.
31 *
32 * @package Page
33 * @author LOCKON CO.,LTD.
34 * @version $Id:LC_Page_Products_Detail.php 15532 2007-08-31 14:39:46Z nanasess $
35 */
36class LC_Page_Products_Detail extends LC_Page_Ex
37{
38    /** 商品ステータス */
39    public $arrSTATUS;
40
41    /** 商品ステータス画像 */
42    public $arrSTATUS_IMAGE;
43
44    /** 発送予定日 */
45    public $arrDELIVERYDATE;
46
47    /** おすすめレベル */
48    public $arrRECOMMEND;
49
50    /** @var SC_FormParam フォームパラメーター */
51    public $objFormParam;
52
53    /** @var SC_UploadFile アップロードファイル */
54    public $objUpFile;
55
56    /** @var string モード */
57    public $mode;
58
59    /** @var array 商品情報 */
60    public $arrProduct;
61
62    /** @var string 規格1クラス名 */
63    public $tpl_class_name1;
64
65    /** @var string 規格2クラス名 */
66    public $tpl_class_name2;
67
68    /** @var bool 在庫があるかどうか */
69    public $tpl_stock_find;
70
71    /** @var array 規格1の規格分類 */
72    public $arrClassCat1;
73
74    /** @var bool 規格1が設定されている */
75    public $tpl_classcat_find1;
76
77    /** @var bool 規格2が設定されている */
78    public $tpl_classcat_find2;
79
80    /** @var int デフォルトの商品規格ID */
81    public $tpl_product_class_id;
82
83    /** @var int デフォルトの商品タイプ */
84    public $tpl_product_type;
85
86    /** @var string ページ表示時に実行するJavaScript */
87    public $js_lnOnload;
88
89    /** @var int 商品ID */
90    public $tpl_product_id;
91
92    /** @var array フォーム情報 */
93    public $arrForm;
94
95    /** @var string サブタイトル */
96    public $tpl_subtitle;
97
98    /** @var array 関連カテゴリー */
99    public $arrRelativeCat;
100
101    /** @var array 商品ステータス(アイコン) */
102    public $productStatus;
103
104    /** @var bool サブ画像が存在するか */
105    public $subImageFlag;
106
107    /** @var array レビュー情報 */
108    public $arrReview;
109
110    /** @var array 関連商品情報 */
111    public $arrRecommend;
112
113    /** @var array ファイル情報 */
114    public $arrFile;
115
116    /** @var bool ログイン状態かどうか */
117    public $tpl_login;
118
119    /** @var bool お気に入りに登録済みか */
120    public $is_favorite;
121
122    /** @var bool お気に入りに登録したことを示すフラグ */
123    public $just_added_favorite;
124
125    /** @var array エラー情報 */
126    public $arrErr;
127
128    /**
129     * Page を初期化する.
130     *
131     * @return void
132     */
133    public function init()
134    {
135        parent::init();
136        $masterData = new SC_DB_MasterData_Ex();
137        $this->arrSTATUS = $masterData->getMasterData('mtb_status');
138        $this->arrSTATUS_IMAGE = $masterData->getMasterData('mtb_status_image');
139        $this->arrDELIVERYDATE = $masterData->getMasterData('mtb_delivery_date');
140        $this->arrRECOMMEND = $masterData->getMasterData('mtb_recommend');
141
142        // POST に限定する mode
143        $this->arrLimitPostMode[] = 'cart';
144        $this->arrLimitPostMode[] = 'add_favorite';
145        $this->arrLimitPostMode[] = 'add_favorite_sphone';
146        $this->arrLimitPostMode[] = 'select';
147        $this->arrLimitPostMode[] = 'select2';
148        $this->arrLimitPostMode[] = 'selectItem';
149    }
150
151    /**
152     * Page のプロセス.
153     *
154     * @return void
155     */
156    public function process()
157    {
158        parent::process();
159        $this->action();
160        $this->sendResponse();
161    }
162
163    /**
164     * Page のAction.
165     *
166     * @return void
167     */
168    public function action()
169    {
170        //決済処理中ステータスのロールバック
171        $objPurchase = new SC_Helper_Purchase_Ex();
172        $objPurchase->cancelPendingOrder(PENDING_ORDER_CANCEL_FLAG);
173
174        // 会員クラス
175        $objCustomer = new SC_Customer_Ex();
176
177        // パラメーター管理クラス
178        $this->objFormParam = new SC_FormParam_Ex();
179        // パラメーター情報の初期化
180        $this->arrForm = $this->lfInitParam($this->objFormParam);
181        // ファイル管理クラス
182        $this->objUpFile = new SC_UploadFile_Ex(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR);
183        // ファイル情報の初期化
184        $this->objUpFile = $this->lfInitFile($this->objUpFile);
185        $this->mode = $this->getMode();
186
187        $objProduct = new SC_Product_Ex();
188
189        // プロダクトIDの正当性チェック
190        $product_id = $this->lfCheckProductId($this->objFormParam->getValue('admin'), $this->objFormParam->getValue('product_id'), $objProduct);
191
192        $objProduct->setProductsClassByProductIds(array($product_id));
193
194        // 規格1クラス名
195        $this->tpl_class_name1 = $objProduct->className1[$product_id];
196
197        // 規格2クラス名
198        $this->tpl_class_name2 = $objProduct->className2[$product_id];
199
200        // 規格1
201        $this->arrClassCat1 = $objProduct->classCats1[$product_id];
202
203        // 規格1が設定されている
204        $this->tpl_classcat_find1 = $objProduct->classCat1_find[$product_id];
205        // 規格2が設定されている
206        $this->tpl_classcat_find2 = $objProduct->classCat2_find[$product_id];
207
208        $this->tpl_stock_find = $objProduct->stock_find[$product_id];
209        $this->tpl_product_class_id = $objProduct->classCategories[$product_id]['__unselected']['__unselected']['product_class_id'];
210        $this->tpl_product_type = $objProduct->classCategories[$product_id]['__unselected']['__unselected']['product_type'];
211
212        // 在庫が無い場合は、OnLoadしない。(javascriptエラー防止)
213        if ($this->tpl_stock_find) {
214            // 規格選択セレクトボックスの作成
215            $this->js_lnOnload .= $this->lfMakeSelect();
216        }
217
218        $this->tpl_javascript .= 'eccube.classCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories[$product_id]) . ';';
219        $this->tpl_javascript .= 'function lnOnLoad()
220        {' . $this->js_lnOnload . '}';
221        $this->tpl_onload .= 'lnOnLoad();';
222
223        // モバイル用 規格選択セレクトボックスの作成
224        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
225            $this->lfMakeSelectMobile($this, $product_id, $this->objFormParam->getValue('classcategory_id1'));
226        }
227
228        // 商品IDをFORM内に保持する
229        $this->tpl_product_id = $product_id;
230
231        switch ($this->mode) {
232            case 'cart':
233                $this->doCart();
234                break;
235
236            case 'add_favorite':
237                $this->doAddFavorite($objCustomer);
238                break;
239
240            case 'add_favorite_sphone':
241                $this->doAddFavoriteSphone($objCustomer);
242                break;
243
244            case 'select':
245            case 'select2':
246            case 'selectItem':
247                /**
248                 * モバイルの数量指定・規格選択の際に、
249                 * $_SESSION['cart_referer_url'] を上書きさせないために、
250                 * 何もせずbreakする。
251                 */
252                break;
253
254            default:
255                $this->doDefault();
256                break;
257        }
258
259        // モバイル用 ポストバック処理
260        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
261            switch ($this->mode) {
262                case 'select':
263                    $this->doMobileSelect();
264                    break;
265
266                case 'select2':
267                    $this->doMobileSelect2();
268                    break;
269
270                case 'selectItem':
271                    $this->doMobileSelectItem();
272                    break;
273
274                case 'cart':
275                    $this->doMobileCart();
276                    break;
277
278                default:
279                    $this->doMobileDefault();
280                    break;
281            }
282        }
283
284        // 商品詳細を取得
285        $this->arrProduct = $objProduct->getDetail($product_id);
286
287        // サブタイトルを取得
288        $this->tpl_subtitle = $this->arrProduct['name'];
289
290        // 関連カテゴリを取得
291        $arrCategory_id = $objProduct->getCategoryIds($product_id);
292        $objCategory = new SC_Helper_Category_Ex();
293        $this->arrRelativeCat = array();
294        foreach ($arrCategory_id as $category_id) {
295            $this->arrRelativeCat[] = $objCategory->getTreeTrail($category_id, false);
296        }
297
298        // 商品ステータスを取得
299        $this->productStatus = $objProduct->getProductStatus($product_id);
300
301        // 画像ファイル指定がない場合の置換処理
302        $this->arrProduct['main_image']
303            = SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']);
304
305        $this->subImageFlag = $this->lfSetFile($this->objUpFile, $this->arrProduct, $this->arrFile);
306        //レビュー情報の取得
307        $objReview = new SC_Helper_Review_Ex();
308        $this->arrReview = $objReview->getListByProductId($product_id);
309
310        //関連商品情報表示
311        $this->arrRecommend = $this->lfPreGetRecommendProducts($product_id);
312
313        // ログイン判定
314        if ($objCustomer->isLoginSuccess() === true) {
315            //お気に入りボタン表示
316            $this->tpl_login = true;
317            $this->is_favorite = SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($objCustomer->getValue('customer_id'), $product_id));
318        }
319    }
320
321    /**
322     * プロダクトIDの正当性チェック
323     *
324     * @param string $admin_mode
325     * @param int $product_id
326     * @param SC_Product $objProduct
327     * @return integer
328     */
329    public function lfCheckProductId($admin_mode, $product_id, SC_Product $objProduct)
330    {
331        // 管理機能からの確認の場合は、非公開の商品も表示する。
332        if (isset($admin_mode) && $admin_mode == 'on' && SC_Utils_Ex::sfIsSuccess(new SC_Session_Ex(), false)) {
333            $include_hidden = true;
334        } else {
335            $include_hidden = false;
336        }
337
338        if (!$objProduct->isValidProductId($product_id, $include_hidden)) {
339                SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
340        }
341
342        return $product_id;
343    }
344
345    /**
346     * ファイル情報の初期化
347     *
348     * @param SC_UploadFile $objUpFile
349     * @return SC_UploadFile
350     */
351    public function lfInitFile(SC_UploadFile $objUpFile)
352    {
353        $objUpFile->addFile('詳細-メイン画像', 'main_image', array('jpg'), IMAGE_SIZE);
354        for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
355            $objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg'), IMAGE_SIZE);
356        }
357
358        return $objUpFile;
359    }
360
361    /* 規格選択セレクトボックスの作成 */
362    public function lfMakeSelect()
363    {
364        return 'fnSetClassCategories('
365            . 'document.form1, '
366            . SC_Utils_Ex::jsonEncode($this->objFormParam->getValue('classcategory_id2'))
367            . '); ';
368    }
369
370    /* 規格選択セレクトボックスの作成(モバイル) */
371
372    /**
373     * @param LC_Page_Products_Detail $objPage
374     * @param integer $product_id
375     */
376    public function lfMakeSelectMobile(&$objPage, $product_id, $request_classcategory_id1)
377    {
378        $classcat_find1 = false;
379        $classcat_find2 = false;
380
381        // 規格名一覧
382        $arrClassName = SC_Helper_DB_Ex::sfGetIDValueList('dtb_class', 'class_id', 'name');
383        // 規格分類名一覧
384        $arrClassCatName = SC_Helper_DB_Ex::sfGetIDValueList('dtb_classcategory', 'classcategory_id', 'name');
385        // 商品規格情報の取得
386        $arrProductsClass = $this->lfGetProductsClass($product_id);
387
388        // 規格1クラス名の取得
389        $objPage->tpl_class_name1 = $arrClassName[$arrProductsClass[0]['class_id1']];
390        // 規格2クラス名の取得
391        $objPage->tpl_class_name2 = $arrClassName[$arrProductsClass[0]['class_id2']];
392
393        // 全ての組み合わせ数
394        $count = count($arrProductsClass);
395
396        $classcat_id1 = '';
397        $classcat_id2 = '';
398
399        $arrSele1 = array();
400        $arrSele2 = array();
401
402        for ($i = 0; $i < $count; $i++) {
403            // 在庫のチェック
404            if ($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
405                continue;
406            }
407
408            // 規格1のセレクトボックス用
409            if ($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']) {
410                $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
411                $arrSele1[$classcat_id1] = $arrClassCatName[$classcat_id1];
412            }
413
414            // 規格2のセレクトボックス用
415            if ($arrProductsClass[$i]['classcategory_id1'] == $request_classcategory_id1 and $classcat_id2 != $arrProductsClass[$i]['classcategory_id2']) {
416                $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
417                $arrSele2[$classcat_id2] = $arrClassCatName[$classcat_id2];
418            }
419        }
420
421        // 規格1
422        $objPage->arrClassCat1 = $arrSele1;
423        $objPage->arrClassCat2 = $arrSele2;
424
425        // 規格1が設定されている
426        if (isset($arrProductsClass[0]['classcategory_id1']) && $arrProductsClass[0]['classcategory_id1'] != '0') {
427            $classcat_find1 = true;
428        }
429
430        // 規格2が設定されている
431        if (isset($arrProductsClass[0]['classcategory_id2']) && $arrProductsClass[0]['classcategory_id2'] != '0') {
432            $classcat_find2 = true;
433        }
434
435        $objPage->tpl_classcat_find1 = $classcat_find1;
436        $objPage->tpl_classcat_find2 = $classcat_find2;
437    }
438
439    /**
440     * パラメーター情報の初期化
441     *
442     * @param SC_FormParam $objFormParam
443     * @return array
444     */
445    public function lfInitParam(SC_FormParam &$objFormParam)
446    {
447        $objFormParam->addParam('規格1', 'classcategory_id1', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
448        $objFormParam->addParam('規格2', 'classcategory_id2', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
449        $objFormParam->addParam('数量', 'quantity', INT_LEN, 'n', array('EXIST_CHECK', 'ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
450        $objFormParam->addParam('管理者ログイン', 'admin', INT_LEN, 'a', array('ALNUM_CHECK', 'MAX_LENGTH_CHECK'));
451        $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('EXIST_CHECK', 'ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
452        $objFormParam->addParam('お気に入り商品ID', 'favorite_product_id', INT_LEN, 'n', array('ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
453        $objFormParam->addParam('商品規格ID', 'product_class_id', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
454        // 値の取得
455        $objFormParam->setParam($_REQUEST);
456        // 入力値の変換
457        $objFormParam->convParam();
458        // 入力情報を渡す
459        return $objFormParam->getFormParamList();
460    }
461
462    /* 商品規格情報の取得 */
463    public function lfGetProductsClass($product_id)
464    {
465        $objProduct = new SC_Product_Ex();
466
467        return $objProduct->getProductsClassFullByProductId($product_id);
468    }
469
470    /* 登録済み関連商品の読み込み */
471
472    /**
473     * @param integer $product_id
474     */
475    public function lfPreGetRecommendProducts($product_id)
476    {
477        $objProduct = new SC_Product_Ex();
478        $objQuery =& SC_Query_Ex::getSingletonInstance();
479
480        $objQuery->setOrder('rank DESC');
481        $arrRecommendData = $objQuery->select('recommend_product_id, comment', 'dtb_recommend_products as t1 left join dtb_products as t2 on t1.recommend_product_id = t2.product_id', 't1.product_id = ? and t2.del_flg = 0 and t2.status = 1', array($product_id));
482
483        $recommendProductIds = array();
484        foreach ($arrRecommendData as $recommend) {
485            $recommendProductIds[] = $recommend['recommend_product_id'];
486        }
487
488        $objQuery =& SC_Query_Ex::getSingletonInstance();
489        $arrProducts = $objProduct->getListByProductIds($objQuery, $recommendProductIds);
490
491        foreach ($arrRecommendData as $key => $arrRow) {
492            $arrRecommendData[$key] = array_merge($arrRow, $arrProducts[$arrRow['recommend_product_id']]);
493        }
494
495        return $arrRecommendData;
496    }
497
498    /* 入力内容のチェック */
499
500    /**
501     * @param string $mode
502     * @param boolean $tpl_classcat_find1
503     * @param boolean $tpl_classcat_find2
504     */
505    public function lfCheckError($mode, SC_FormParam &$objFormParam, $tpl_classcat_find1 = null, $tpl_classcat_find2 = null)
506    {
507        switch ($mode) {
508        case 'add_favorite_sphone':
509        case 'add_favorite':
510            $objCustomer = new SC_Customer_Ex();
511            $objErr = new SC_CheckError_Ex();
512            $customer_id = $objCustomer->getValue('customer_id');
513            $favorite_product_id = $objFormParam->getValue('favorite_product_id');
514            if (SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id))) {
515                $objErr->arrErr['add_favorite'.$favorite_product_id] = '※ この商品は既にお気に入りに追加されています。<br />';
516            }
517            break;
518        default:
519            // 入力データを渡す。
520            $arrRet =  $objFormParam->getHashArray();
521            $objErr = new SC_CheckError_Ex($arrRet);
522            $objErr->arrErr = $objFormParam->checkError();
523
524            // 複数項目チェック
525            if ($tpl_classcat_find1) {
526                $objErr->doFunc(array('規格1', 'classcategory_id1'), array('EXIST_CHECK'));
527            }
528            if ($tpl_classcat_find2) {
529                $objErr->doFunc(array('規格2', 'classcategory_id2'), array('EXIST_CHECK'));
530            }
531            break;
532        }
533
534        return $objErr->arrErr;
535    }
536
537    /**
538     * ファイルの情報をセットする
539     *
540     * @param SC_UploadFile $objUpFile
541     * @param array $arrProduct
542     * @param array $arrFile
543     * @return bool
544     */
545    public function lfSetFile(SC_UploadFile $objUpFile, $arrProduct, &$arrFile)
546    {
547        // DBからのデータを引き継ぐ
548        $objUpFile->setDBFileList($arrProduct);
549        // ファイル表示用配列を渡す
550        $arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH, true);
551
552        // サブ画像の有無を判定
553        $subImageFlag = false;
554        for ($i = 1; $i <= PRODUCTSUB_MAX; $i++) {
555            if ($arrFile['sub_image' . $i]['filepath'] != '') {
556                $subImageFlag = true;
557            }
558        }
559
560        return $subImageFlag;
561    }
562
563    /*
564     * お気に入り商品登録
565     * @return void
566     */
567    public function lfRegistFavoriteProduct($favorite_product_id, $customer_id)
568    {
569        // ログイン中のユーザが商品をお気に入りにいれる処理
570        if (!SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', $favorite_product_id, 'del_flg = 0 AND status = 1')) {
571            SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
572
573            return false;
574        } else {
575            $objQuery =& SC_Query_Ex::getSingletonInstance();
576            $exists = $objQuery->exists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id));
577
578            if (!$exists) {
579                $sqlval['customer_id'] = $customer_id;
580                $sqlval['product_id'] = $favorite_product_id;
581                $sqlval['update_date'] = 'CURRENT_TIMESTAMP';
582                $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
583
584                $objQuery->begin();
585                $objQuery->insert('dtb_customer_favorite_products', $sqlval);
586                $objQuery->commit();
587            }
588            // お気に入りに登録したことを示すフラグ
589            $this->just_added_favorite = true;
590
591            return true;
592        }
593    }
594
595    /**
596     * Add product(s) into the cart.
597     *
598     * @return void
599     */
600    public function doCart()
601    {
602        $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam,
603                                            $this->tpl_classcat_find1,
604                                            $this->tpl_classcat_find2);
605        if (count($this->arrErr) == 0) {
606            $objCartSess = new SC_CartSession_Ex();
607            $product_class_id = $this->objFormParam->getValue('product_class_id');
608
609            $objCartSess->addProduct($product_class_id, $this->objFormParam->getValue('quantity'));
610
611            // 開いているカテゴリーツリーを維持するためのパラメーター
612            $arrQueryString = array(
613                'product_id' => $this->objFormParam->getValue('product_id'),
614            );
615
616            SC_Response_Ex::sendRedirect(CART_URL, $arrQueryString);
617            SC_Response_Ex::actionExit();
618        }
619    }
620
621    /**
622     * Add product to authenticated user's favorites.
623     *
624     * @param  SC_Customer $objCustomer
625     * @return void
626     */
627    public function doAddFavorite(SC_Customer &$objCustomer)
628    {
629        // ログイン中のユーザが商品をお気に入りにいれる処理
630        if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) {
631            $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam);
632            if (count($this->arrErr) == 0) {
633                if (!$this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'), $objCustomer->getValue('customer_id'))) {
634                    SC_Response_Ex::actionExit();
635                }
636                $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
637                $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite', array($this));
638            }
639        }
640    }
641
642    /**
643     * Add product to authenticated user's favorites. (for Smart phone)
644     *
645     * @param  SC_Customer $objCustomer
646     * @return void
647     */
648    public function doAddFavoriteSphone(SC_Customer $objCustomer)
649    {
650        // ログイン中のユーザが商品をお気に入りにいれる処理(スマートフォン用)
651        if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) {
652            $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam);
653            if (count($this->arrErr) == 0) {
654                if ($this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'), $objCustomer->getValue('customer_id'))) {
655                    $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
656                    $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite_sphone', array($this));
657                    print 'true';
658                    SC_Response_Ex::actionExit();
659                }
660            }
661            print 'error';
662            SC_Response_Ex::actionExit();
663        }
664    }
665
666    /**
667     *
668     *
669     * @return void
670     */
671    public function doDefault()
672    {
673        // カート「戻るボタン」用に保持
674        $netURL = new Net_URL();
675        $_SESSION['cart_referer_url'] = $netURL->getURL();
676    }
677
678    /**
679     *
680     * @return void
681     */
682    public function doMobileSelect()
683    {
684        // 規格1が設定されている場合
685        if ($this->tpl_classcat_find1) {
686            // templateの変更
687            $this->tpl_mainpage = 'products/select_find1.tpl';
688
689            return;
690        }
691
692        // 数量の入力を行う
693        $this->tpl_mainpage = 'products/select_item.tpl';
694    }
695
696    /**
697     *
698     * @return void
699     */
700    public function doMobileSelect2()
701    {
702        $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $this->tpl_classcat_find1, $this->tpl_classcat_find2);
703
704        // 規格1が設定されていて、エラーを検出した場合
705        if ($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) {
706            // templateの変更
707            $this->tpl_mainpage = 'products/select_find1.tpl';
708
709            return;
710        }
711
712        // 規格2が設定されている場合
713        if ($this->tpl_classcat_find2) {
714            $this->arrErr = array();
715
716            $this->tpl_mainpage = 'products/select_find2.tpl';
717
718            return;
719        }
720
721        $this->doMobileSelectItem();
722    }
723
724    /**
725     *
726     * @return void
727     */
728    public function doMobileSelectItem()
729    {
730        $objProduct = new SC_Product_Ex();
731
732        $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $this->tpl_classcat_find1, $this->tpl_classcat_find2);
733
734        // この段階では、商品規格ID・数量の入力チェックエラーを出させない。
735        // FIXME: エラーチェックの定義で mode で定義を分岐する方が良いように感じる
736        unset($this->arrErr['product_class_id']);
737        unset($this->arrErr['quantity']);
738
739        // 規格2が設定されていて、エラーを検出した場合
740        if ($this->tpl_classcat_find2 and !empty($this->arrErr)) {
741            // templateの変更
742            $this->tpl_mainpage = 'products/select_find2.tpl';
743
744            return;
745        }
746
747        $product_id = $this->objFormParam->getValue('product_id');
748
749        $value1 = $this->objFormParam->getValue('classcategory_id1');
750        if (strlen($value1) === 0) {
751            $value1 = '__unselected';
752        }
753
754        // 規格2が設定されている場合.
755        if (SC_Utils_Ex::isBlank($this->objFormParam->getValue('classcategory_id2')) == false) {
756            $value2 = '#' . $this->objFormParam->getValue('classcategory_id2');
757        } else {
758            $value2 = '#0';
759        }
760
761        $objProduct->setProductsClassByProductIds(array($product_id));
762        $this->tpl_product_class_id = $objProduct->classCategories[$product_id][$value1][$value2]['product_class_id'];
763
764        // 数量の入力を行う
765        $this->tpl_mainpage = 'products/select_item.tpl';
766    }
767
768    /**
769     *
770     * @return void
771     */
772    public function doMobileCart()
773    {
774        // この段階でエラーが出る場合は、数量の入力エラーのはず
775        if (count($this->arrErr)) {
776            // 数量の入力を行う
777            $this->tpl_mainpage = 'products/select_item.tpl';
778        }
779    }
780
781    /**
782     *
783     * @return void
784     */
785    public function doMobileDefault()
786    {
787        $this->tpl_mainpage = 'products/detail.tpl';
788    }
789}
Note: See TracBrowser for help on using the repository browser.