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

Revision 23140, 4.7 KB checked in by m_uehara, 11 years ago (diff)

#2348 r23128 - r23137 をマージ

  • 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        $response = $objReq->send();
90
91        // リクエストチェック
92        $objLog->log('* http request check start');
93        if (PEAR::isError($objReq)) {
94            $objJson->setError(OSTORE_E_C_HTTP_REQ);
95            $objJson->display();
96            $objLog->error(OSTORE_E_C_HTTP_REQ, $objReq);
97
98            return;
99        }
100
101        // レスポンスチェック
102        $objLog->log('* http response check start');
103
104        if ( $response->getStatus() !== 200) {
105            $objJson->setError(OSTORE_E_C_HTTP_RESP);
106            $objJson->display();
107            $objLog->error(OSTORE_E_C_HTTP_RESP, $objReq);
108
109            return;
110        }
111
112        $body = $response->getBody();
113        $objRet = $objJson->decode($body);
114
115        // JSONデータのチェック
116        $objLog->log('* json deta check start');
117        if (empty($objRet)) {
118            $objJson->setError(OSTORE_E_C_FAILED_JSON_PARSE);
119            $objJson->display();
120            $objLog->error(OSTORE_E_C_FAILED_JSON_PARSE, $objReq);
121
122            return;
123        }
124
125        // ステータスチェック
126        $objLog->log('* json status check start');
127        if ($objRet->status === OSTORE_STATUS_SUCCESS) {
128            $objLog->log('* get products list ok');
129
130            $arrProducts = array();
131
132            foreach ($objRet->data as $product) {
133                $arrProducts[] = get_object_vars($product);
134            }
135            $objView = new SC_AdminView_Ex();
136            $objView->assign('arrProducts', $arrProducts);
137
138            $template = 'ownersstore/products_list.tpl';
139
140            if (!$objView->_smarty->template_exists($template)) {
141                $objLog->log('* template not exist, use default template');
142                // デフォルトテンプレートを使用
143                $template = DATA_REALDIR . 'Smarty/templates/default/admin/' . $template;
144            }
145
146            $html = $objView->fetch('ownersstore/products_list.tpl');
147            $objJson->setSuccess(array(), $html);
148            $objJson->display();
149            $objLog->end();
150
151            return;
152        } else {
153            // 配信サーバー側でエラーを補足
154            echo $body;
155            $objLog->error($objRet->errcode, $objReq);
156
157            return;
158        }
159    }
160}
Note: See TracBrowser for help on using the repository browser.