source: branches/version-2_13_0/data/class/pages/upgrade/LC_Page_Upgrade_ProductsList.php @ 23143

Revision 23143, 4.7 KB checked in by m_uehara, 7 years ago (diff)

#2348 r23140 をマージ

  • 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    public function init()
41    {
42        parent::init();
43    }
44
45    /**
46     * Page のプロセス.
47     *
48     * @return void
49     */
50    public 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
64            return;
65        }
66
67        // 認証キーの取得
68        $public_key = $this->getPublicKey();
69        $sha1_key = $this->createSeed();
70
71        $objLog->log('* public key check start');
72        if (empty($public_key)) {
73            $objJson->setError(OSTORE_E_C_NO_KEY);
74            $objJson->display();
75            $objLog->error(OSTORE_E_C_NO_KEY);
76
77            return;
78        }
79
80        // リクエストを開始
81        $objLog->log('* http request start');
82        $arrPostData = array(
83            'eccube_url' => HTTP_URL,
84            'public_key' => sha1($public_key . $sha1_key),
85            'sha1_key'   => $sha1_key,
86            'ver'        => ECCUBE_VERSION
87        );
88        $objReq = $this->request('products_list', $arrPostData);
89
90        // リクエストチェック
91        $objLog->log('* http request check start');
92        if (PEAR::isError($objReq)) {
93            $objJson->setError(OSTORE_E_C_HTTP_REQ);
94            $objJson->display();
95            $objLog->error(OSTORE_E_C_HTTP_REQ, $objReq);
96
97            return;
98        }
99
100        // レスポンスチェック
101        $objLog->log('* http response check start');
102        if ($objReq->getResponseCode() !== 200) {
103            $objJson->setError(OSTORE_E_C_HTTP_RESP);
104            $objJson->display();
105            $objLog->error(OSTORE_E_C_HTTP_RESP, $objReq);
106
107            return;
108        }
109
110        $body = $objReq->getResponseBody();
111        $objRet = $objJson->decode($body);
112
113        // JSONデータのチェック
114        $objLog->log('* json deta check start');
115        if (empty($objRet)) {
116            $objJson->setError(OSTORE_E_C_FAILED_JSON_PARSE);
117            $objJson->display();
118            $objLog->error(OSTORE_E_C_FAILED_JSON_PARSE, $objReq);
119
120            return;
121        }
122
123        // ステータスチェック
124        $objLog->log('* json status check start');
125        if ($objRet->status === OSTORE_STATUS_SUCCESS) {
126            $objLog->log('* get products list ok');
127
128            $arrProducts = array();
129
130            foreach ($objRet->data as $product) {
131                $arrProducts[] = get_object_vars($product);
132            }
133            $objView = new SC_AdminView_Ex();
134            $objView->assign('arrProducts', $arrProducts);
135
136            $template = 'ownersstore/products_list.tpl';
137
138            if (!$objView->_smarty->template_exists($template)) {
139                $objLog->log('* template not exist, use default template');
140                // デフォルトテンプレートを使用
141                $template = DATA_REALDIR . 'Smarty/templates/default/admin/' . $template;
142            }
143
144            $html = $objView->fetch('ownersstore/products_list.tpl');
145            $objJson->setSuccess(array(), $html);
146            $objJson->display();
147            $objLog->end();
148
149            return;
150        } else {
151            // 配信サーバー側でエラーを補足
152            echo $body;
153            $objLog->error($objRet->errcode, $objReq);
154
155            return;
156        }
157    }
158}
Note: See TracBrowser for help on using the repository browser.