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

Revision 22926, 4.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
Line 
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 'LC_Page_Upgrade_Base.php';
25
26/**
27 * オーナーズストア購入商品一覧を返すページクラス.
28 *
29 * @package Page
30 * @author LOCKON CO.,LTD.
31 * @version $Id$
32 */
33class LC_Page_Upgrade_ProductsList extends LC_Page_Upgrade_Base
34{
35    /**
36     * Page を初期化する.
37     *
38     * @return void
39     */
40    function init()
41    {
42        parent::init();
43    }
44
45    /**
46     * Page のプロセス.
47     *
48     * @return void
49     */
50    function process($mode)
51    {
52        $objLog  = new LC_Upgrade_Helper_Log;
53        $objJson = new LC_Upgrade_Helper_Json;
54
55        $objLog->start($mode);
56
57        // 管理画面ログインチェック
58        $objLog->log('* admin auth start');
59        if ($this->isLoggedInAdminPage() !== true) {
60            $objJson->setError(OSTORE_E_C_ADMIN_AUTH);
61            $objJson->display();
62            $objLog->error(OSTORE_E_C_ADMIN_AUTH);
63            return;
64        }
65
66        // 認証キーの取得
67        $public_key = $this->getPublicKey();
68        $sha1_key = $this->createSeed();
69
70        $objLog->log('* public key check start');
71        if (empty($public_key)) {
72            $objJson->setError(OSTORE_E_C_NO_KEY);
73            $objJson->display();
74            $objLog->error(OSTORE_E_C_NO_KEY);
75            return;
76        }
77
78        // リクエストを開始
79        $objLog->log('* http request start');
80        $arrPostData = array(
81            'eccube_url' => HTTP_URL,
82            'public_key' => sha1($public_key . $sha1_key),
83            'sha1_key'   => $sha1_key,
84            'ver'        => ECCUBE_VERSION
85        );
86        $objReq = $this->request('products_list', $arrPostData);
87
88        // リクエストチェック
89        $objLog->log('* http request check start');
90        if (PEAR::isError($objReq)) {
91            $objJson->setError(OSTORE_E_C_HTTP_REQ);
92            $objJson->display();
93            $objLog->error(OSTORE_E_C_HTTP_REQ, $objReq);
94            return;
95        }
96
97        // レスポンスチェック
98        $objLog->log('* http response check start');
99        if ($objReq->getResponseCode() !== 200) {
100            $objJson->setError(OSTORE_E_C_HTTP_RESP);
101            $objJson->display();
102            $objLog->error(OSTORE_E_C_HTTP_RESP, $objReq);
103            return;
104        }
105
106        $body = $objReq->getResponseBody();
107        $objRet = $objJson->decode($body);
108
109        // JSONデータのチェック
110        $objLog->log('* json deta check start');
111        if (empty($objRet)) {
112            $objJson->setError(OSTORE_E_C_FAILED_JSON_PARSE);
113            $objJson->display();
114            $objLog->error(OSTORE_E_C_FAILED_JSON_PARSE, $objReq);
115            return;
116        }
117
118        // ステータスチェック
119        $objLog->log('* json status check start');
120        if ($objRet->status === OSTORE_STATUS_SUCCESS) {
121            $objLog->log('* get products list ok');
122
123            $arrProducts = array();
124
125            foreach ($objRet->data as $product) {
126                $arrProducts[] = get_object_vars($product);
127            }
128            $objView = new SC_AdminView_Ex();
129            $objView->assign('arrProducts', $arrProducts);
130
131            $template = 'ownersstore/products_list.tpl';
132
133            if (!$objView->_smarty->template_exists($template)) {
134                $objLog->log('* template not exist, use default template');
135                // デフォルトテンプレートを使用
136                $template = DATA_REALDIR . 'Smarty/templates/default/admin/' . $template;
137            }
138
139            $html = $objView->fetch('ownersstore/products_list.tpl');
140            $objJson->setSuccess(array(), $html);
141            $objJson->display();
142            $objLog->end();
143            return;
144        } else {
145            // 配信サーバー側でエラーを補足
146            echo $body;
147            $objLog->error($objRet->errcode, $objReq);
148            return;
149        }
150    }
151}
Note: See TracBrowser for help on using the repository browser.