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

Source for file LC_Page_Admin_System_Parameter.php

Documentation is available at LC_Page_Admin_System_Parameter.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.  * パラメータ設定 のページクラス.
  29.  *
  30.  * @package Page
  31.  * @author LOCKON CO.,LTD.
  32.  * @version $Id$
  33.  */
  34.  
  35.     // {{{ properties
  36.  
  37.     /** 定数キーとなる配列 */
  38.     var $arrKeys;
  39.  
  40.     /** 定数コメントとなる配列 */
  41.     var $arrComments;
  42.  
  43.     /** 定数値となる配列 */
  44.     var $arrValues;
  45.  
  46.     // }}}
  47.     // {{{ functions
  48.  
  49.     /**
  50.      * Page を初期化する.
  51.      *
  52.      * @return void 
  53.      */
  54.     function init({
  55.         parent::init();
  56.         $this->tpl_mainpage = 'system/parameter.tpl';
  57.         $this->tpl_subnavi 'system/subnavi.tpl';
  58.         $this->tpl_subno 'parameter';
  59.         $this->tpl_mainno = 'system';
  60.     }
  61.  
  62.     /**
  63.      * Page のプロセス.
  64.      *
  65.      * @return void 
  66.      */
  67.     function process({
  68.         $objView new SC_AdminView();
  69.         $masterData new SC_DB_MasterData_Ex();
  70.  
  71.         // 認証可否の判定
  72.         SC_Utils_Ex::sfIsSuccess(new SC_Session());
  73.  
  74.         // キーの配列を生成
  75.         $this->arrKeys = $this->getParamKeys($masterData);
  76.  
  77.         if (isset($_POST["mode"]&& $_POST["mode"== "update"{
  78.  
  79.             // データの引き継ぎ
  80.             $this->arrForm $_POST;
  81.  
  82.             // エラーチェック
  83.             $this->arrErr $this->errorCheck();
  84.             // エラーの無い場合は update
  85.             if (empty($this->arrErr)) {
  86.                 $this->update();
  87.                 $this->tpl_onload = "window.alert('パラメータの設定が完了しました。');";
  88.             else {
  89.                 $this->arrValues = SC_Utils_Ex::getHash2Array($this->arrForm,
  90.                                                               $this->arrKeys);
  91.                 $this->tpl_onload = "window.alert('エラーが発生しました。入力内容をご確認下さい。');";
  92.             }
  93.  
  94.         }
  95.  
  96.         if (empty($this->arrErr)) {
  97.             $this->arrValues = SC_Utils_Ex::getHash2Array(
  98.                                        $masterData->getDBMasterData("mtb_constants"));
  99.         }
  100.  
  101.         // コメント, 値の配列を生成
  102.         $this->arrComments = SC_Utils_Ex::getHash2Array(
  103.                                      $masterData->getDBMasterData("mtb_constants",
  104.                                              array("id""remarks""rank")));
  105.  
  106.         $objView->assignobj($this);
  107.         $objView->display(MAIN_FRAME);
  108.     }
  109.  
  110.     /**
  111.      * デストラクタ.
  112.      *
  113.      * @return void 
  114.      */
  115.     function destroy({
  116.         parent::destroy();
  117.     }
  118.  
  119.     /**
  120.      * パラメータ情報を更新する.
  121.      *
  122.      * 画面の設定値で mtb_constants テーブルの値とキャッシュを更新する.
  123.      *
  124.      * @access private
  125.      * @return void 
  126.      */
  127.     function update({
  128.         $data array();
  129.         $masterData new SC_DB_MasterData_Ex();
  130.         foreach ($this->arrKeys as $key{
  131.             $data[$key$_POST[$key];
  132.         }
  133.  
  134.         // DBのデータを更新
  135.         $masterData->updateMasterData("mtb_constants"array()$data);
  136.  
  137.         // 更新したデータを取得
  138.         $mtb_constants $masterData->getDBMasterData("mtb_constants");
  139.  
  140.         // キャッシュを生成
  141.         $masterData->clearCache("mtb_constants");
  142.         $masterData->createCache("mtb_constants"$mtb_constantstrue,
  143.                                  array("id""remarks""rank"));
  144.     }
  145.  
  146.     /**
  147.      * エラーチェックを行う.
  148.      *
  149.      * @access private
  150.      * @return void 
  151.      */
  152.     function errorCheck({
  153.         $objErr new SC_CheckError($this->arrForm);
  154.         for ($i 0$i count($this->arrKeys)$i++{
  155.             $objErr->doFunc(array($this->arrKeys[$i],
  156.                                   $this->arrForm[$this->arrKeys[$i]]),
  157.                             array("EXIST_CHECK_REVERSE""EVAL_CHECK"));
  158.         }
  159.         return $objErr->arrErr;
  160.     }
  161.  
  162.     /**
  163.      * パラメータのキーを配列で返す.
  164.      *
  165.      * @access private
  166.      * @return array パラメータのキーの配列
  167.      */
  168.     function getParamKeys(&$masterData{
  169.         $keys array();
  170.         $i 0;
  171.         foreach ($masterData->getDBMasterData("mtb_constants"as $key => $val{
  172.             $keys[$i$key;
  173.             $i++;
  174.         }
  175.         return $keys;
  176.     }
  177. }
  178. ?>

Documentation generated on Fri, 24 Feb 2012 13:59:11 +0900 by Seasoft