Warning: Can't use blame annotator:
svn blame failed on branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_Detail.php: バイナリファイル 'file:///home/svn/open/branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_Detail.php' に対しては blame で各行の最終変更者を計算できません 195004

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

Revision 22926, 24.7 KB checked in by Seasoft, 11 years ago (diff)

#2287 (環境によりデストラクタが正しく動作しないケースがある)
#2288 (リクエスト単位で実行されるべきログ出力がブロックにも適用されている)
#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

  • 不明確な仕様にコメントを残した。
  • 親デストラクタを呼ぶだけの記述は可読性が悪くなると考え削除した。(上述のチケットで OS の仕様に依存したデストラクタとなるため、敢えてアプリケーション側で記述しておく意義は薄れたという認識のもと。)
  • 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
RevLine 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2013 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    var $arrSTATUS;
40
41    /** 商品ステータス画像 */
42    var $arrSTATUS_IMAGE;
43
44    /** 発送予定日 */
45    var $arrDELIVERYDATE;
46
47    /** おすすめレベル */
48    var $arrRECOMMEND;
49
50    /** フォームパラメーター */
51    var $objFormParam;
52
53    /** アップロードファイル */
54    var $objUpFile;
55
56    /** モード */
57    var $mode;
58
59    /**
60     * Page を初期化する.
61     *
62     * @return void
63     */
64    function init()
65    {
66        parent::init();
67        $masterData = new SC_DB_MasterData_Ex();
68        $this->arrSTATUS = $masterData->getMasterData('mtb_status');
69        $this->arrSTATUS_IMAGE = $masterData->getMasterData('mtb_status_image');
70        $this->arrDELIVERYDATE = $masterData->getMasterData('mtb_delivery_date');
71        $this->arrRECOMMEND = $masterData->getMasterData('mtb_recommend');
72
73        // POST に限定する mode
74        $this->arrLimitPostMode[] = 'cart';
75        $this->arrLimitPostMode[] = 'add_favorite';
76        $this->arrLimitPostMode[] = 'add_favorite_sphone';
77        $this->arrLimitPostMode[] = 'select';
78        $this->arrLimitPostMode[] = 'select2';
79        $this->arrLimitPostMode[] = 'selectItem';
80    }
81
82    /**
83     * Page のプロセス.
84     *
85     * @return void
86     */
87    function process()
88    {
89        parent::process();
90        $this->action();
91        $this->sendResponse();
92    }
93
94    /**
95     * Page のAction.
96     *
97     * @return void
98     */
99    function action()
100    {
101        // 会員クラス
102        $objCustomer = new SC_Customer_Ex();
103
104        // パラメーター管理クラス
105        $this->objFormParam = new SC_FormParam_Ex();
106        // パラメーター情報の初期化
107        $this->arrForm = $this->lfInitParam($this->objFormParam);
108        // ファイル管理クラス
109        $this->objUpFile = new SC_UploadFile_Ex(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR);
110        // ファイル情報の初期化
111        $this->objUpFile = $this->lfInitFile($this->objUpFile);
112
113        // プロダクトIDの正当性チェック
114        $product_id = $this->lfCheckProductId($this->objFormParam->getValue('admin'),$this->objFormParam->getValue('product_id'));
115        $this->mode = $this->getMode();
116
117        $objProduct = new SC_Product_Ex();
118        $objProduct->setProductsClassByProductIds(array($product_id));
119
120        // 規格1クラス名
121        $this->tpl_class_name1 = $objProduct->className1[$product_id];
122
123        // 規格2クラス名
124        $this->tpl_class_name2 = $objProduct->className2[$product_id];
125
126        // 規格1
127        $this->arrClassCat1 = $objProduct->classCats1[$product_id];
128
129        // 規格1が設定されている
130        $this->tpl_classcat_find1 = $objProduct->classCat1_find[$product_id];
131        // 規格2が設定されている
132        $this->tpl_classcat_find2 = $objProduct->classCat2_find[$product_id];
133
134        $this->tpl_stock_find = $objProduct->stock_find[$product_id];
135        $this->tpl_product_class_id = $objProduct->classCategories[$product_id]['__unselected']['__unselected']['product_class_id'];
136        $this->tpl_product_type = $objProduct->classCategories[$product_id]['__unselected']['__unselected']['product_type'];
137
138        // 在庫が無い場合は、OnLoadしない。(javascriptエラー防止)
139        if ($this->tpl_stock_find) {
140            // 規格選択セレクトボックスの作成
141            $this->js_lnOnload .= $this->lfMakeSelect();
142        }
143
144        $this->tpl_javascript .= 'classCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories[$product_id]) . ';';
145        $this->tpl_javascript .= 'function lnOnLoad()
146        {' . $this->js_lnOnload . '}';
147        $this->tpl_onload .= 'lnOnLoad();';
148
149        // モバイル用 規格選択セレクトボックスの作成
150        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
151            $this->lfMakeSelectMobile($this, $product_id,$this->objFormParam->getValue('classcategory_id1'));
152        }
153
154        // 商品IDをFORM内に保持する
155        $this->tpl_product_id = $product_id;
156
157        switch ($this->mode) {
158            case 'cart':
159                $this->doCart();
160                break;
161
162            case 'add_favorite':
163                $this->doAddFavorite($objCustomer);
164                break;
165
166            case 'add_favorite_sphone':
167                $this->doAddFavoriteSphone($objCustomer);
168                break;
169
170            case 'select':
171            case 'select2':
172            case 'selectItem':
173                /**
174                 * モバイルの数量指定・規格選択の際に、
175                 * $_SESSION['cart_referer_url'] を上書きさせないために、
176                 * 何もせずbreakする。
177                 */
178                break;
179
180            default:
181                $this->doDefault();
182                break;
183        }
184
185        // モバイル用 ポストバック処理
186        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
187            switch ($this->mode) {
188                case 'select':
189                    $this->doMobileSelect();
190                    break;
191
192                case 'select2':
193                    $this->doMobileSelect2();
194                    break;
195
196                case 'selectItem':
197                    $this->doMobileSelectItem();
198                    break;
199
200                case 'cart':
201                    $this->doMobileCart();
202                    break;
203
204                default:
205                    $this->doMobileDefault();
206                    break;
207            }
208        }
209
210        // 商品詳細を取得
211        $this->arrProduct = $objProduct->getDetail($product_id);
212
213        // サブタイトルを取得
214        $this->tpl_subtitle = $this->arrProduct['name'];
215
216        // 関連カテゴリを取得
217        $this->arrRelativeCat = SC_Helper_DB_Ex::sfGetMultiCatTree($product_id);
218
219        // 商品ステータスを取得
220        $this->productStatus = $objProduct->getProductStatus($product_id);
221
222        // 画像ファイル指定がない場合の置換処理
223        $this->arrProduct['main_image']
224            = SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']);
225
226        $this->subImageFlag = $this->lfSetFile($this->objUpFile,$this->arrProduct,$this->arrFile);
227        //レビュー情報の取得
228        $this->arrReview = $this->lfGetReviewData($product_id);
229
230        //関連商品情報表示
231        $this->arrRecommend = $this->lfPreGetRecommendProducts($product_id);
232
233        // ログイン判定
234        if ($objCustomer->isLoginSuccess() === true) {
235            //お気に入りボタン表示
236            $this->tpl_login = true;
237            $this->is_favorite = SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($objCustomer->getValue('customer_id'), $product_id));
238        }
239    }
240
241    /* プロダクトIDの正当性チェック */
242    function lfCheckProductId($admin_mode,$product_id)
243    {
244        // 管理機能からの確認の場合は、非公開の商品も表示する。
245        if (isset($admin_mode) && $admin_mode == 'on') {
246            SC_Utils_Ex::sfIsSuccess(new SC_Session_Ex());
247            $status = true;
248            $where = 'del_flg = 0';
249        } else {
250            $status = false;
251            $where = 'del_flg = 0 AND status = 1';
252        }
253
254        if (!SC_Utils_Ex::sfIsInt($product_id)
255            || SC_Utils_Ex::sfIsZeroFilling($product_id)
256            || !SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', (array)$product_id, $where)
257        ) {
258                SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
259        }
260
261        return $product_id;
262    }
263
264    /* ファイル情報の初期化 */
265    function lfInitFile($objUpFile)
266    {
267        $objUpFile->addFile('詳細-メイン画像', 'main_image', array('jpg'), IMAGE_SIZE);
268        for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
269            $objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg'), IMAGE_SIZE);
270        }
271
272        return $objUpFile;
273    }
274
275    /* 規格選択セレクトボックスの作成 */
276    function lfMakeSelect()
277    {
278        return 'fnSetClassCategories('
279            . 'document.form1, '
280            . SC_Utils_Ex::jsonEncode($this->objFormParam->getValue('classcategory_id2'))
281            . '); ';
282    }
283
284    /* 規格選択セレクトボックスの作成(モバイル) */
285    function lfMakeSelectMobile(&$objPage, $product_id,$request_classcategory_id1)
286    {
287        $classcat_find1 = false;
288        $classcat_find2 = false;
289
290        // 規格名一覧
291        $arrClassName = SC_Helper_DB_Ex::sfGetIDValueList('dtb_class', 'class_id', 'name');
292        // 規格分類名一覧
293        $arrClassCatName = SC_Helper_DB_Ex::sfGetIDValueList('dtb_classcategory', 'classcategory_id', 'name');
294        // 商品規格情報の取得
295        $arrProductsClass = $this->lfGetProductsClass($product_id);
296
297        // 規格1クラス名の取得
298        $objPage->tpl_class_name1 = $arrClassName[$arrProductsClass[0]['class_id1']];
299        // 規格2クラス名の取得
300        $objPage->tpl_class_name2 = $arrClassName[$arrProductsClass[0]['class_id2']];
301
302        // すべての組み合わせ数
303        $count = count($arrProductsClass);
304
305        $classcat_id1 = '';
306
307        $arrSele1 = array();
308        $arrSele2 = array();
309
310        for ($i = 0; $i < $count; $i++) {
311            // 在庫のチェック
312            if ($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
313                continue;
314            }
315
316            // 規格1のセレクトボックス用
317            if ($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']) {
318                $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
319                $arrSele1[$classcat_id1] = $arrClassCatName[$classcat_id1];
320            }
321
322            // 規格2のセレクトボックス用
323            if ($arrProductsClass[$i]['classcategory_id1'] == $request_classcategory_id1 and $classcat_id2 != $arrProductsClass[$i]['classcategory_id2']) {
324                $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
325                $arrSele2[$classcat_id2] = $arrClassCatName[$classcat_id2];
326            }
327        }
328
329        // 規格1
330        $objPage->arrClassCat1 = $arrSele1;
331        $objPage->arrClassCat2 = $arrSele2;
332
333        // 規格1が設定されている
334        if (isset($arrProductsClass[0]['classcategory_id1']) && $arrProductsClass[0]['classcategory_id1'] != '0') {
335            $classcat_find1 = true;
336        }
337
338        // 規格2が設定されている
339        if (isset($arrProductsClass[0]['classcategory_id2']) && $arrProductsClass[0]['classcategory_id2'] != '0') {
340            $classcat_find2 = true;
341        }
342
343        $objPage->tpl_classcat_find1 = $classcat_find1;
344        $objPage->tpl_classcat_find2 = $classcat_find2;
345    }
346
347    /* パラメーター情報の初期化 */
348    function lfInitParam(&$objFormParam)
349    {
350        $objFormParam->addParam('規格1', 'classcategory_id1', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
351        $objFormParam->addParam('規格2', 'classcategory_id2', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
352        $objFormParam->addParam('数量', 'quantity', INT_LEN, 'n', array('EXIST_CHECK', 'ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
353        $objFormParam->addParam('管理者ログイン', 'admin', INT_LEN, 'a', array('ALNUM_CHECK','MAX_LENGTH_CHECK'));
354        $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('EXIST_CHECK', 'ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
355        $objFormParam->addParam('お気に入り商品ID', 'favorite_product_id', INT_LEN, 'n', array('ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
356        $objFormParam->addParam('商品規格ID', 'product_class_id', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
357        // 値の取得
358        $objFormParam->setParam($_REQUEST);
359        // 入力値の変換
360        $objFormParam->convParam();
361        // 入力情報を渡す
362        return $objFormParam->getFormParamList();
363    }
364
365    /* 商品規格情報の取得 */
366    function lfGetProductsClass($product_id)
367    {
368        $objProduct = new SC_Product_Ex();
369
370        return $objProduct->getProductsClassFullByProductId($product_id);
371    }
372
373    /* 登録済み関連商品の読み込み */
374    function lfPreGetRecommendProducts($product_id)
375    {
376        $objProduct = new SC_Product_Ex();
377        $objQuery =& SC_Query_Ex::getSingletonInstance();
378
379        $objQuery->setOrder('rank DESC');
380        $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));
381
382        $arrRecommendProductId = array();
383        foreach ($arrRecommendData as $recommend) {
384            $arrRecommendProductId[] = $recommend['recommend_product_id'];
385        }
386
387        $objQuery =& SC_Query_Ex::getSingletonInstance();
388        $arrProducts = $objProduct->getListByProductIds($objQuery, $arrRecommendProductId);
389
390        $arrRecommend = array();
391        foreach ($arrRecommendData as $key => $arrRow) {
392            $arrRecommendData[$key] = array_merge($arrRow, $arrProducts[$arrRow['recommend_product_id']]);
393        }
394
395        return $arrRecommendData;
396    }
397
398    /* 入力内容のチェック */
399    function lfCheckError($mode,&$objFormParam,$tpl_classcat_find1 = null ,$tpl_classcat_find2 = null)
400    {
401        switch ($mode) {
402        case 'add_favorite_sphone':
403        case 'add_favorite':
404            $objCustomer = new SC_Customer_Ex();
405            $objErr = new SC_CheckError_Ex();
406            $customer_id = $objCustomer->getValue('customer_id');
407            if (SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id))) {
408                $objErr->arrErr['add_favorite'.$favorite_product_id] = '※ この商品は既にお気に入りに追加されています。<br />';
409            }
410            break;
411        default:
412            // 入力データを渡す。
413            $arrRet =  $objFormParam->getHashArray();
414            $objErr = new SC_CheckError_Ex($arrRet);
415            $objErr->arrErr = $objFormParam->checkError();
416
417            // 複数項目チェック
418            if ($tpl_classcat_find1) {
419                $objErr->doFunc(array('規格1', 'classcategory_id1'), array('EXIST_CHECK'));
420            }
421            if ($tpl_classcat_find2) {
422                $objErr->doFunc(array('規格2', 'classcategory_id2'), array('EXIST_CHECK'));
423            }
424            break;
425        }
426
427        return $objErr->arrErr;
428    }
429
430    //商品ごとのレビュー情報を取得する
431    function lfGetReviewData($id)
432    {
433        $objQuery =& SC_Query_Ex::getSingletonInstance();
434        //商品ごとのレビュー情報を取得する
435        $col = 'create_date, reviewer_url, reviewer_name, recommend_level, title, comment';
436        $from = 'dtb_review';
437        $where = 'del_flg = 0 AND status = 1 AND product_id = ?';
438        $objQuery->setOrder('create_date DESC');
439        $objQuery->setLimit(REVIEW_REGIST_MAX);
440        $arrWhereVal = array($id);
441        $arrReview = $objQuery->select($col, $from, $where, $arrWhereVal);
442
443        return $arrReview;
444    }
445
446    /*
447     * ファイルの情報をセットする
448     * @return $subImageFlag
449     */
450    function lfSetFile($objUpFile,$arrProduct,&$arrFile)
451    {
452        // DBからのデータを引き継ぐ
453        $objUpFile->setDBFileList($arrProduct);
454        // ファイル表示用配列を渡す
455        $arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH, true);
456
457        // サブ画像の有無を判定
458        $subImageFlag = false;
459        for ($i = 1; $i <= PRODUCTSUB_MAX; $i++) {
460            if ($arrFile['sub_image' . $i]['filepath'] != '') {
461                $subImageFlag = true;
462            }
463        }
464
465        return $subImageFlag;
466    }
467
468    /*
469     * お気に入り商品登録
470     * @return void
471     */
472    function lfRegistFavoriteProduct($favorite_product_id,$customer_id)
473    {
474        // ログイン中のユーザが商品をお気に入りにいれる処理
475        if (!SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', $favorite_product_id, 'del_flg = 0 AND status = 1')) {
476            SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
477            return false;
478        } else {
479            $objQuery =& SC_Query_Ex::getSingletonInstance();
480            $exists = $objQuery->exists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id));
481
482            if (!$exists) {
483                $sqlval['customer_id'] = $customer_id;
484                $sqlval['product_id'] = $favorite_product_id;
485                $sqlval['update_date'] = 'CURRENT_TIMESTAMP';
486                $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
487
488                $objQuery->begin();
489                $objQuery->insert('dtb_customer_favorite_products', $sqlval);
490                $objQuery->commit();
491            }
492            // お気に入りに登録したことを示すフラグ
493            $this->just_added_favorite = true;
494            return true;
495        }
496    }
497
498    /**
499     * Add product(s) into the cart.
500     *
501     * @return void
502     */
503    function doCart()
504    {
505        $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam,
506                                            $this->tpl_classcat_find1,
507                                            $this->tpl_classcat_find2);
508        if (count($this->arrErr) == 0) {
509            $objCartSess = new SC_CartSession_Ex();
510            $product_class_id = $this->objFormParam->getValue('product_class_id');
511
512            $objCartSess->addProduct($product_class_id, $this->objFormParam->getValue('quantity'));
513
514            // 開いているカテゴリーツリーを維持するためのパラメーター
515            $arrQueryString = array(
516                'product_id' => $this->objFormParam->getValue('product_id'),
517            );
518
519            SC_Response_Ex::sendRedirect(CART_URLPATH, $arrQueryString);
520            SC_Response_Ex::actionExit();
521        }
522    }
523
524    /**
525     * Add product to authenticated user's favorites.
526     *
527     * @param type $objCustomer
528     * @return void
529     */
530    function doAddFavorite(&$objCustomer)
531    {
532        // ログイン中のユーザが商品をお気に入りにいれる処理
533        if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) {
534            $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam);
535            if (count($this->arrErr) == 0) {
536                if (!$this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'),$objCustomer->getValue('customer_id'))) {
537                    $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
538                    $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite', array($this));
539
540                    SC_Response_Ex::actionExit();
541                }
542            }
543        }
544    }
545
546    /**
547     * Add product to authenticated user's favorites. (for Smart phone)
548     *
549     * @param type $objCustomer
550     * @return void
551     */
552    function doAddFavoriteSphone($objCustomer)
553    {
554        // ログイン中のユーザが商品をお気に入りにいれる処理(スマートフォン用)
555        if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) {
556            $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam);
557            if (count($this->arrErr) == 0) {
558                if ($this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'),$objCustomer->getValue('customer_id'))) {
559                    $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
560                    $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite_sphone', array($this));
561
562                    print 'true';
563                    SC_Response_Ex::actionExit();
564                }
565            }
566            print 'error';
567            SC_Response_Ex::actionExit();
568        }
569    }
570
571    /**
572     *
573     *
574     * @return void
575     */
576    function doDefault()
577    {
578        // カート「戻るボタン」用に保持
579        $netURL = new Net_URL();
580        $_SESSION['cart_referer_url'] = $netURL->getURL();
581    }
582
583    /**
584     *
585     * @return void
586     */
587    function doMobileSelect()
588    {
589        // 規格1が設定されている場合
590        if ($this->tpl_classcat_find1) {
591            // templateの変更
592            $this->tpl_mainpage = 'products/select_find1.tpl';
593            return;
594        }
595
596        // 数量の入力を行う
597        $this->tpl_mainpage = 'products/select_item.tpl';
598    }
599
600    /**
601     *
602     * @return type
603     */
604    function doMobileSelect2()
605    {
606        $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam,$this->tpl_classcat_find1,$this->tpl_classcat_find2);
607
608        // 規格1が設定されていて、エラーを検出した場合
609        if ($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) {
610            // templateの変更
611            $this->tpl_mainpage = 'products/select_find1.tpl';
612            return;
613        }
614
615        // 規格2が設定されている場合
616        if ($this->tpl_classcat_find2) {
617            $this->arrErr = array();
618
619            $this->tpl_mainpage = 'products/select_find2.tpl';
620            return;
621        }
622
623        $this->doMobileSelectItem();
624    }
625
626    /**
627     *
628     * @return void
629     */
630    function doMobileSelectItem()
631    {
632        $objProduct = new SC_Product_Ex();
633
634        $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $this->tpl_classcat_find1, $this->tpl_classcat_find2);
635
636        // この段階では、商品規格ID・数量の入力チェックエラーを出させない。
637        // FIXME: エラーチェックの定義で mode で定義を分岐する方が良いように感じる
638        unset($this->arrErr['product_class_id']);
639        unset($this->arrErr['quantity']);
640
641        // 規格2が設定されていて、エラーを検出した場合
642        if ($this->tpl_classcat_find2 and !empty($this->arrErr)) {
643            // templateの変更
644            $this->tpl_mainpage = 'products/select_find2.tpl';
645            return;
646        }
647
648        $product_id = $this->objFormParam->getValue('product_id');
649
650        $value1 = $this->objFormParam->getValue('classcategory_id1');
651        if (strlen($value1) === 0) {
652            $value1 = '__unselected';
653        }
654
655        // 規格2が設定されている場合.
656        if (SC_Utils_Ex::isBlank($this->objFormParam->getValue('classcategory_id2')) == false){
657            $value2 = '#' . $this->objFormParam->getValue('classcategory_id2');
658        } else {
659            $value2 = '#0';
660        }
661
662        $objProduct->setProductsClassByProductIds(array($product_id));
663        $this->tpl_product_class_id = $objProduct->classCategories[$product_id][$value1][$value2]['product_class_id'];
664
665        // 数量の入力を行う
666        $this->tpl_mainpage = 'products/select_item.tpl';
667    }
668
669    /**
670     *
671     * @return void
672     */
673    function doMobileCart()
674    {
675        // この段階でエラーが出る場合は、数量の入力エラーのはず
676        if (count($this->arrErr)) {
677            // 数量の入力を行う
678            $this->tpl_mainpage = 'products/select_item.tpl';
679        }
680    }
681
682    /**
683     *
684     * @return void
685     */
686    function doMobileDefault()
687    {
688        $this->tpl_mainpage = 'products/detail.tpl';
689    }
690}
Note: See TracBrowser for help on using the repository browser.