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 |
---|
25 | require_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 | */ |
---|
34 | class 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 | $masterData = new SC_DB_MasterData_Ex(); |
---|
81 | |
---|
82 | // キーの配列を生成 |
---|
83 | $this->arrKeys = $this->getParamKeys($masterData); |
---|
84 | |
---|
85 | switch ($this->getMode()) { |
---|
86 | case 'update': |
---|
87 | // データの引き継ぎ |
---|
88 | $this->arrForm = $_POST; |
---|
89 | |
---|
90 | // エラーチェック |
---|
91 | $this->arrErr = $this->errorCheck($this->arrKeys, $this->arrForm); |
---|
92 | // エラーの無い場合は update |
---|
93 | if (empty($this->arrErr)) { |
---|
94 | $this->update($this->arrKeys, $this->arrForm); |
---|
95 | $this->tpl_onload = "window.alert('パラメーターの設定が完了しました。');"; |
---|
96 | } else { |
---|
97 | $this->arrValues = SC_Utils_Ex::getHash2Array($this->arrForm, |
---|
98 | $this->arrKeys); |
---|
99 | $this->tpl_onload = "window.alert('エラーが発生しました。入力内容をご確認下さい。');"; |
---|
100 | } |
---|
101 | break; |
---|
102 | default: |
---|
103 | break; |
---|
104 | } |
---|
105 | |
---|
106 | if (empty($this->arrErr)) { |
---|
107 | $this->arrValues = SC_Utils_Ex::getHash2Array( |
---|
108 | $masterData->getDBMasterData('mtb_constants')); |
---|
109 | } |
---|
110 | |
---|
111 | // コメント, 値の配列を生成 |
---|
112 | $this->arrComments = SC_Utils_Ex::getHash2Array( |
---|
113 | $masterData->getDBMasterData('mtb_constants', |
---|
114 | array('id', 'remarks', 'rank'))); |
---|
115 | |
---|
116 | } |
---|
117 | |
---|
118 | /** |
---|
119 | * デストラクタ. |
---|
120 | * |
---|
121 | * @return void |
---|
122 | */ |
---|
123 | function destroy() { |
---|
124 | parent::destroy(); |
---|
125 | } |
---|
126 | |
---|
127 | /** |
---|
128 | * パラメーター情報を更新する. |
---|
129 | * |
---|
130 | * 画面の設定値で mtb_constants テーブルの値とキャッシュを更新する. |
---|
131 | * |
---|
132 | * @access private |
---|
133 | * @return void |
---|
134 | */ |
---|
135 | function update(&$arrKeys, &$arrForm) { |
---|
136 | $data = array(); |
---|
137 | $masterData = new SC_DB_MasterData_Ex(); |
---|
138 | foreach ($arrKeys as $key) { |
---|
139 | $data[$key] = $arrForm[$key]; |
---|
140 | } |
---|
141 | |
---|
142 | // DBのデータを更新 |
---|
143 | $masterData->updateMasterData('mtb_constants', array(), $data); |
---|
144 | |
---|
145 | // キャッシュを生成 |
---|
146 | $masterData->createCache('mtb_constants', array(), true, array('id', 'remarks')); |
---|
147 | } |
---|
148 | |
---|
149 | /** |
---|
150 | * エラーチェックを行う. |
---|
151 | * |
---|
152 | * @access private |
---|
153 | * @param array $arrForm $_POST 値 |
---|
154 | * @return void |
---|
155 | */ |
---|
156 | function errorCheck(&$arrKeys, &$arrForm) { |
---|
157 | $objErr = new SC_CheckError_Ex($arrForm); |
---|
158 | for ($i = 0; $i < count($arrKeys); $i++) { |
---|
159 | $objErr->doFunc(array($arrKeys[$i], |
---|
160 | $arrForm[$arrKeys[$i]]), |
---|
161 | array('EXIST_CHECK_REVERSE', 'EVAL_CHECK')); |
---|
162 | } |
---|
163 | return $objErr->arrErr; |
---|
164 | } |
---|
165 | |
---|
166 | /** |
---|
167 | * パラメーターのキーを配列で返す. |
---|
168 | * |
---|
169 | * @access private |
---|
170 | * @return array パラメーターのキーの配列 |
---|
171 | */ |
---|
172 | function getParamKeys(&$masterData) { |
---|
173 | $keys = array(); |
---|
174 | $i = 0; |
---|
175 | foreach ($masterData->getDBMasterData('mtb_constants') as $key => $val) { |
---|
176 | $keys[$i] = $key; |
---|
177 | $i++; |
---|
178 | } |
---|
179 | return $keys; |
---|
180 | } |
---|
181 | } |
---|