Source for file LC_Page_Upgrade_ProductsList.php

Documentation is available at LC_Page_Upgrade_ProductsList.php

  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) 2000-2007 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
  25. require_once 'LC_Page_Upgrade_Base.php';
  26.  
  27. /**
  28.  * オーナーズストア購入商品一覧を返すページクラス.
  29.  *
  30.  * @package Page
  31.  * @author LOCKON CO.,LTD.
  32.  * @version $Id: LC_Page_Upgrade_ProductsList.php 16856 2007-12-02 05:10:18Z adachi $
  33.  */
  34.  
  35.     // }}}
  36.     // {{{ functions
  37.  
  38.     /**
  39.      * Page を初期化する.
  40.      *
  41.      * @return void 
  42.      */
  43.     function init({
  44.         parent::init();
  45.     }
  46.  
  47.     /**
  48.      * Page のプロセス.
  49.      *
  50.      * @return void 
  51.      */
  52.     function process($mode{
  53.         $objLog  new LC_Upgrade_Helper_Log;
  54.         $objJson new LC_Upgrade_Helper_Json;
  55.  
  56.         $objLog->start($mode);
  57.  
  58.         // 管理画面ログインチェック
  59.         $objLog->log('* admin auth start');
  60.         if ($this->isLoggedInAdminPage(!== true{
  61.             $objJson->setError(OSTORE_E_C_ADMIN_AUTH);
  62.             $objJson->display();
  63.             $objLog->error(OSTORE_E_C_ADMIN_AUTH);
  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.             return;
  77.         }
  78.  
  79.         // リクエストを開始
  80.         $objLog->log('* http request start');
  81.         $arrPostData array(
  82.             'eccube_url' => SITE_URL,
  83.             'public_key' => sha1($public_key $sha1_key),
  84.             'sha1_key'   => $sha1_key
  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();
  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_PATH '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.  
  152.     /**
  153.      * デストラクタ.
  154.      *
  155.      * @return void 
  156.      */
  157.     function destroy({
  158.         parent::destroy();
  159.     }
  160. }
  161. ?>

Documentation generated on Tue, 28 Apr 2009 18:13:04 +0900 by phpDocumentor 1.4.2