Page
[ class tree: Page ] [ index: Page ] [ all elements ]

Source for file LC_Page_Admin_OwnersStore_Settings.php

Documentation is available at LC_Page_Admin_OwnersStore_Settings.php

  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) 2000-2010 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(CLASS_PATH "pages/LC_Page.php");
  26.  
  27. /**
  28.  * EC-CUBEアプリケーション管理:アプリケーション設定 のページクラス.
  29.  *
  30.  * @package Page
  31.  * @author LOCKON CO.,LTD.
  32.  * @version $Id: LC_Page_Admin_OwnersStore_Settings.php 18734 2010-06-22 08:45:33Z nanasess $
  33.  */
  34.  
  35.     /** SC_FormParamのインスタンス */
  36.     var $objForm;
  37.  
  38.     /** リクエストパラメータを格納する連想配列 */
  39.     var $arrForm;
  40.  
  41.     /** バリデーションエラー情報を格納する連想配列 */
  42.     var $arrErr;
  43.  
  44.     // }}}
  45.     // {{{ functions
  46.  
  47.     /**
  48.      * Page を初期化する.
  49.      *
  50.      * @return void 
  51.      */
  52.     function init({
  53.         parent::init();
  54.  
  55.         $this->tpl_mainpage = 'ownersstore/settings.tpl';
  56.         $this->tpl_subnavi  'ownersstore/subnavi.tpl';
  57.         $this->tpl_mainno   = 'ownersstore';
  58.         $this->tpl_subno    'settings';
  59.         $this->tpl_subtitle '認証キー設定';
  60.     }
  61.  
  62.     /**
  63.      * Page のプロセス.
  64.      *
  65.      * @return void 
  66.      */
  67.     function process({
  68.  
  69.         // ログインチェック
  70.         SC_Utils::sfIsSuccess(new SC_Session());
  71.  
  72.         // トランザクションIDの取得
  73.         $this->transactionid = $this->getToken();
  74.  
  75.         // $_POST['mode']によってアクション振り分け
  76.         switch($this->getMode()) {
  77.         // 入力内容をDBへ登録する
  78.         case 'register':
  79.             $this->execRegisterMode();
  80.             break;
  81.         // 初回表示
  82.         default:
  83.             $this->execDefaultMode();
  84.         }
  85.  
  86.         // ページ出力
  87.         $objView new SC_AdminView();
  88.         $objView->assignObj($this);
  89.         $objView->display(MAIN_FRAME);
  90.     }
  91.  
  92.     /**
  93.      * デストラクタ.
  94.      *
  95.      * @return void 
  96.      */
  97.     function destroy({
  98.         parent::destroy();
  99.     }
  100.  
  101.     /**
  102.      * switchアクション振り分け用パラメータを取得する.
  103.      *
  104.      * @param void 
  105.      * @return string モード名
  106.      */
  107.     function getMode({
  108.         $mode '';
  109.         if ($_SERVER['REQUEST_METHOD'== 'GET'{
  110.             if (isset($_GET['mode'])) $mode $_GET['mode'];
  111.         elseif ($_SERVER['REQUEST_METHOD'== 'POST'{
  112.             if (isset($_POST['mode'])) $mode $_POST['mode'];
  113.         }
  114.         return $mode;
  115.     }
  116.  
  117.     /**
  118.      * registerアクションの実行.
  119.      * 入力内容をDBへ登録する.
  120.      *
  121.      * @param void 
  122.      * @return void 
  123.      */
  124.     function execRegisterMode({
  125.         if ($this->isValidToken(!== true{
  126.             SC_Utils_Ex::sfDispError('');
  127.         }
  128.         // パラメータオブジェクトの初期化
  129.         $this->initRegisterMode();
  130.         // POSTされたパラメータの検証
  131.         $arrErr $this->validateRegistermode();
  132.  
  133.         // エラー時の処理
  134.         if (!empty($arrErr)) {
  135.             $this->arrErr  = $arrErr;
  136.             $this->arrForm = $this->objForm->getHashArray();
  137.             $this->transactionid = $this->getToken();
  138.             return;
  139.         }
  140.  
  141.         // エラーがなければDBへ登録
  142.         $arrForm $this->objForm->getHashArray();
  143.         $this->registerOwnersStoreSettings($arrForm);
  144.  
  145.         $this->arrForm = $arrForm;
  146.  
  147.         $this->tpl_onload = "alert('登録しました。')";
  148.         $this->transactionid = $this->getToken();
  149.     }
  150.  
  151.     /**
  152.      * registerアクションの初期化.
  153.      * SC_FormParamを初期化しメンバ変数にセットする.
  154.      *
  155.      * @param void 
  156.      * @return void 
  157.      */
  158.     function initRegisterMode({
  159.         // 前後の空白を削除
  160.         if (isset($_POST['public_key'])) {
  161.             $_POST['public_key'trim($_POST['public_key']);
  162.         }
  163.  
  164.         $objForm new SC_FormParam();
  165.         $objForm->addParam('認証キー''public_key'LTEXT_LEN''array('EXIST_CHECK''ALNUM_CHECK''MAX_LENGTH_CHECK'));
  166.         $objForm->setParam($_POST);
  167.  
  168.         $this->objForm = $objForm;
  169.     }
  170.  
  171.     /**
  172.      * registerアクションのパラメータを検証する.
  173.      *
  174.      * @param void 
  175.      * @return array エラー情報を格納した連想配列
  176.      */
  177.     function validateRegistermode({
  178.         return $this->objForm->checkError();
  179.     }
  180.  
  181.     /**
  182.      * defaultアクションの実行.
  183.      * DBから登録内容を取得し表示する.
  184.      *
  185.      * @param void 
  186.      * @return void 
  187.      */
  188.     function execDefaultMode({
  189.         $this->arrForm = $this->getOwnersStoreSettings();
  190.     }
  191.  
  192.     /**
  193.      * DBへ入力内容を登録する.
  194.      *
  195.      * @param array $arrSettingsData オーナーズストア設定の連想配列
  196.      * @return void 
  197.      */
  198.     function registerOwnersStoreSettings($arrSettingsData{
  199.         $table 'dtb_ownersstore_settings';
  200.         $objQuery new SC_Query();
  201.         $count $objQuery->count($table);
  202.  
  203.         if ($count{
  204.             $objQuery->update($table$arrSettingsData);
  205.         else {
  206.             $objQuery->insert($table$arrSettingsData);
  207.         }
  208.     }
  209.  
  210.     /**
  211.      * DBから登録内容を取得する.
  212.      *
  213.      * @param void 
  214.      * @return array 
  215.      */
  216.     function getOwnersStoreSettings(){
  217.         $table   'dtb_ownersstore_settings';
  218.         $colmuns '*';
  219.  
  220.         $objQuery new SC_Query();
  221.         $arrRet $objQuery->select($colmuns$table);
  222.  
  223.         if (isset($arrRet[0])) return $arrRet[0];
  224.  
  225.         return array();
  226.     }
  227. }
  228. ?>

Documentation generated on Fri, 24 Feb 2012 13:58:57 +0900 by Seasoft