source: branches/version-2_13_0/data/class/pages/admin/system/LC_Page_Admin_System_Parameter.php @ 23126

Revision 23126, 4.9 KB checked in by m_uehara, 11 years ago (diff)

#2348 r23116 - r23125 をマージ

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