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

source: branches/version-2_12-dev/data/class/pages/cart/LC_Page_Cart.php @ 22567

Revision 22567, 9.2 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

  • 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
24// {{{ requires
25require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
26
27/**
28 * カート のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Cart extends LC_Page_Ex
35{
36
37    // {{{ properties
38
39    /** 商品規格情報の配列 */
40    var $arrData;
41
42    /** 動作モード */
43    var $mode;
44
45    /** メッセージ */
46    public $tpl_message = '';
47
48    // }}}
49    // {{{ functions
50
51    /**
52     * Page を初期化する.
53     *
54     * @return void
55     */
56    function init()
57    {
58        parent::init();
59        $this->tpl_title = '現在のカゴの中';
60        $masterData = new SC_DB_MasterData_Ex();
61        $this->arrProductType = $masterData->getMasterData('mtb_product_type');
62
63    }
64
65    /**
66     * Page のプロセス.
67     *
68     * @return void
69     */
70    function process()
71    {
72        parent::process();
73        $this->action();
74        $this->sendResponse();
75    }
76
77    /**
78     * Page のアクション.
79     *
80     * @return void
81     */
82    function action()
83    {
84
85        $objCartSess = new SC_CartSession_Ex();
86        $objSiteSess = new SC_SiteSession_Ex();
87        $objCustomer = new SC_Customer_Ex();
88
89        $objFormParam = $this->lfInitParam($_REQUEST);
90        $this->mode = $this->getMode();
91
92        $this->cartKeys = $objCartSess->getKeys();
93        foreach ($this->cartKeys as $key) {
94            // 商品購入中にカート内容が変更された。
95            if ($objCartSess->getCancelPurchase($key)) {
96                $this->tpl_message .= "商品購入中にカート内容が変更されましたので、お手数ですが購入手続きをやり直して下さい。\n";
97            }
98        }
99
100        $cart_no = $objFormParam->getValue('cart_no');
101        $cartKey = $objFormParam->getValue('cartKey');
102
103        switch ($this->mode) {
104            case 'confirm':
105                // カート内情報の取得
106                $cartList = $objCartSess->getCartList($cartKey);
107                // カート商品が1件以上存在する場合
108                if (count($cartList) > 0) {
109                    // カートを購入モードに設定
110                    $this->lfSetCurrentCart($objSiteSess, $objCartSess, $cartKey);
111
112
113                    // 購入ページへ
114                    SC_Response_Ex::sendRedirect(SHOPPING_URL);
115                    SC_Response_Ex::actionExit();
116                }
117                break;
118            case 'up'://1個追加
119                $objCartSess->upQuantity($cart_no, $cartKey);
120
121
122                SC_Response_Ex::reload(array('category_id' => $objFormParam->getValue('category_id')), true);
123                SC_Response_Ex::actionExit();
124                break;
125            case 'down'://1個減らす
126                $objCartSess->downQuantity($cart_no, $cartKey);
127
128
129                SC_Response_Ex::reload(array('category_id' => $objFormParam->getValue('category_id')), true);
130                SC_Response_Ex::actionExit();
131                break;
132            case 'setQuantity'://数量変更
133                $objCartSess->setQuantity($objFormParam->getValue('quantity'), $cart_no, $cartKey);
134
135
136                SC_Response_Ex::reload(array('category_id' => $objFormParam->getValue('category_id')), true);
137                SC_Response_Ex::actionExit();
138                break;
139            case 'delete'://カートから削除
140                $objCartSess->delProduct($cart_no, $cartKey);
141
142
143                SC_Response_Ex::reload(array('category_id' => $objFormParam->getValue('category_id')), true);
144                SC_Response_Ex::actionExit();
145                break;
146            default:
147                break;
148        }
149        $this->arrInfo = SC_Helper_DB_Ex::sfGetBasisData();
150        $totalIncTax = 0;
151        foreach ($this->cartKeys as $key) {
152            // カート集計処理
153            $this->tpl_message .= $objCartSess->checkProducts($key);
154            $this->tpl_total_inctax[$key] = $objCartSess->getAllProductsTotal($key);
155            $totalIncTax += $this->tpl_total_inctax[$key];
156            $this->tpl_total_tax[$key] = $objCartSess->getAllProductsTax($key);
157            // ポイント合計
158            $this->tpl_total_point[$key] = $objCartSess->getAllProductsPoint($key);
159
160            $this->arrData[$key] = $objCartSess->calculate($key, $objCustomer);
161
162            // 送料無料チェック
163            $this->arrData[$key]['is_deliv_free'] = $objCartSess->isDelivFree($key);
164
165            // 送料無料までの金額を計算
166            $this->tpl_deliv_free[$key] = $this->arrInfo['free_rule'] - $this->tpl_total_inctax[$key];
167        }
168
169        //商品の合計金額をセット
170        $this->tpl_all_total_inctax = $totalIncTax;
171
172        $this->tpl_category_id = $objFormParam->getValue('category_id');
173
174        // ログイン判定
175        if ($objCustomer->isLoginSuccess(true)) {
176            $this->tpl_login = true;
177            $this->tpl_user_point = $objCustomer->getValue('point');
178            $this->tpl_name = $objCustomer->getValue('name01');
179        }
180
181        // 前頁のURLを取得
182        // TODO: SC_CartSession::setPrevURL()利用不可。
183        $this->lfGetCartPrevUrl($_SESSION,$_SERVER['HTTP_REFERER']);
184        $this->tpl_prev_url = (isset($_SESSION['cart_prev_url'])) ? $_SESSION['cart_prev_url'] : '';
185
186        // すべてのカートの内容を取得する
187        $this->cartItems = $objCartSess->getAllCartList();
188
189
190    }
191
192    /**
193     * デストラクタ.
194     *
195     * @return void
196     */
197    function destroy()
198    {
199        parent::destroy();
200    }
201
202    /**
203     * ユーザ入力値の処理
204     *
205     * @return object
206     */
207    function lfInitParam($arrRequest)
208    {
209        $objFormParam = new SC_FormParam_Ex();
210        $objFormParam->addParam('カートキー', 'cartKey', INT_LEN, 'n', array('NUM_CHECK','MAX_LENGTH_CHECK'));
211        $objFormParam->addParam('カートナンバー', 'cart_no', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
212        // PC版での値引き継ぎ用
213        $objFormParam->addParam('カテゴリID', 'category_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
214        // スマートフォン版での数量変更用
215        $objFormParam->addParam('数量', 'quantity', INT_LEN, 'n', array('EXIST_CHECK', 'ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
216        // 値の取得
217        $objFormParam->setParam($arrRequest);
218        // 入力値の変換
219        $objFormParam->convParam();
220        return $objFormParam;
221    }
222
223    /**
224     * order_temp_id の更新
225     *
226     * @return
227     */
228    function lfUpdateOrderTempid($pre_uniqid,$uniqid)
229    {
230        $sqlval['order_temp_id'] = $uniqid;
231        $where = 'order_temp_id = ?';
232        $objQuery =& SC_Query_Ex::getSingletonInstance();
233        $res = $objQuery->update('dtb_order_temp', $sqlval, $where, array($pre_uniqid));
234        if ($res != 1) {
235            return false;
236        }
237        return true;
238    }
239
240    /**
241     * 前頁のURLを取得
242     *
243     * @return void
244     */
245    function lfGetCartPrevUrl(&$session,$referer)
246    {
247        if (!preg_match('/cart/', $referer)) {
248            if (!empty($session['cart_referer_url'])) {
249                $session['cart_prev_url'] = $session['cart_referer_url'];
250                unset($session['cart_referer_url']);
251            } else {
252                if (preg_match('/entry/', $referer)) {
253                    $session['cart_prev_url'] = HTTPS_URL . 'entry/kiyaku.php';
254                } else {
255                    $session['cart_prev_url'] = $referer;
256                }
257            }
258        }
259        // 妥当性チェック
260        if (!SC_Utils_Ex::sfIsInternalDomain($session['cart_prev_url'])) {
261            $session['cart_prev_url'] = '';
262        }
263    }
264
265    /**
266     * カートを購入モードに設定
267     *
268     * @return void
269     */
270    function lfSetCurrentCart(&$objSiteSess, &$objCartSess, $cartKey)
271    {
272        // 正常に登録されたことを記録しておく
273        $objSiteSess->setRegistFlag();
274        $pre_uniqid = $objSiteSess->getUniqId();
275        // 注文一時IDの発行
276        $objSiteSess->setUniqId();
277        $uniqid = $objSiteSess->getUniqId();
278        // エラーリトライなどで既にuniqidが存在する場合は、設定を引き継ぐ
279        if ($pre_uniqid != '') {
280            $this->lfUpdateOrderTempid($pre_uniqid,$uniqid);
281        }
282        // カートを購入モードに設定
283        $objCartSess->registerKey($cartKey);
284        $objCartSess->saveCurrentCart($uniqid, $cartKey);
285    }
286}
Note: See TracBrowser for help on using the repository browser.