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