source: branches/version-2_12-dev/data/class/pages/admin/system/LC_Page_Admin_System_Parameter.php @ 21689

Revision 21689, 5.5 KB checked in by h_yoshimoto, 12 years ago (diff)

#1692 インスタンスを呼び出す処理を統一

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