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

Revision 22567, 4.8 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
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
24// {{{ requires
25require_once 'LC_Page_Upgrade_Base.php';
26
27/**
28 * オーナーズストア購入商品一覧を返すページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Upgrade_ProductsList extends LC_Page_Upgrade_Base
35{
36
37    // }}}
38    // {{{ functions
39
40    /**
41     * Page を初期化する.
42     *
43     * @return void
44     */
45    function init()
46    {
47        parent::init();
48    }
49
50    /**
51     * Page のプロセス.
52     *
53     * @return void
54     */
55    function process($mode)
56    {
57        $objLog  = new LC_Upgrade_Helper_Log;
58        $objJson = new LC_Upgrade_Helper_Json;
59
60        $objLog->start($mode);
61
62        // 管理画面ログインチェック
63        $objLog->log('* admin auth start');
64        if ($this->isLoggedInAdminPage() !== true) {
65            $objJson->setError(OSTORE_E_C_ADMIN_AUTH);
66            $objJson->display();
67            $objLog->error(OSTORE_E_C_ADMIN_AUTH);
68            return;
69        }
70
71        // 認証キーの取得
72        $public_key = $this->getPublicKey();
73        $sha1_key = $this->createSeed();
74
75        $objLog->log('* public key check start');
76        if (empty($public_key)) {
77            $objJson->setError(OSTORE_E_C_NO_KEY);
78            $objJson->display();
79            $objLog->error(OSTORE_E_C_NO_KEY);
80            return;
81        }
82
83        // リクエストを開始
84        $objLog->log('* http request start');
85        $arrPostData = array(
86            'eccube_url' => HTTP_URL,
87            'public_key' => sha1($public_key . $sha1_key),
88            'sha1_key'   => $sha1_key,
89            'ver'        => ECCUBE_VERSION
90        );
91        $objReq = $this->request('products_list', $arrPostData);
92
93        // リクエストチェック
94        $objLog->log('* http request check start');
95        if (PEAR::isError($objReq)) {
96            $objJson->setError(OSTORE_E_C_HTTP_REQ);
97            $objJson->display();
98            $objLog->error(OSTORE_E_C_HTTP_REQ, $objReq);
99            return;
100        }
101
102        // レスポンスチェック
103        $objLog->log('* http response check start');
104        if ($objReq->getResponseCode() !== 200) {
105            $objJson->setError(OSTORE_E_C_HTTP_RESP);
106            $objJson->display();
107            $objLog->error(OSTORE_E_C_HTTP_RESP, $objReq);
108            return;
109        }
110
111        $body = $objReq->getResponseBody();
112        $objRet = $objJson->decode($body);
113
114        // JSONデータのチェック
115        $objLog->log('* json deta check start');
116        if (empty($objRet)) {
117            $objJson->setError(OSTORE_E_C_FAILED_JSON_PARSE);
118            $objJson->display();
119            $objLog->error(OSTORE_E_C_FAILED_JSON_PARSE, $objReq);
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            return;
149        } else {
150            // 配信サーバー側でエラーを補足
151            echo $body;
152            $objLog->error($objRet->errcode, $objReq);
153            return;
154        }
155    }
156
157    /**
158     * デストラクタ.
159     *
160     * @return void
161     */
162    function destroy()
163    {
164        parent::destroy();
165    }
166}
Note: See TracBrowser for help on using the repository browser.