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

Revision 19661, 5.0 KB checked in by nanasess, 13 years ago (diff)

source:branches/camp/camp-2_5-E のマージ

  • スマートフォン対応(#787)
  • プラグイン機能(#494)
  • Property svn:eol-style set to LF
  • Property svn:keywords set to "Id Revision Date"
  • 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-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
25require_once(CLASS_PATH . "pages/admin/LC_Page_Admin.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 {
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        $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        SC_Utils_Ex::sfIsSuccess(new SC_Session());
84
85        // キーの配列を生成
86        $this->arrKeys = $this->getParamKeys($masterData);
87
88        if (isset($_POST["mode"]) && $_POST["mode"] == "update") {
89
90            // データの引き継ぎ
91            $this->arrForm = $_POST;
92
93            // エラーチェック
94            $this->arrErr = $this->errorCheck();
95            // エラーの無い場合は update
96            if (empty($this->arrErr)) {
97                $this->update();
98                $this->tpl_onload = "window.alert('パラメータの設定が完了しました。');";
99            } else {
100                $this->arrValues = SC_Utils_Ex::getHash2Array($this->arrForm,
101                                                              $this->arrKeys);
102                $this->tpl_onload = "window.alert('エラーが発生しました。入力内容をご確認下さい。');";
103            }
104
105        }
106
107        if (empty($this->arrErr)) {
108            $this->arrValues = SC_Utils_Ex::getHash2Array(
109                                       $masterData->getDBMasterData("mtb_constants"));
110        }
111
112        // コメント, 値の配列を生成
113        $this->arrComments = SC_Utils_Ex::getHash2Array(
114                                     $masterData->getDBMasterData("mtb_constants",
115                                             array("id", "remarks", "rank")));
116
117    }
118
119    /**
120     * デストラクタ.
121     *
122     * @return void
123     */
124    function destroy() {
125        parent::destroy();
126    }
127
128    /**
129     * パラメータ情報を更新する.
130     *
131     * 画面の設定値で mtb_constants テーブルの値とキャッシュを更新する.
132     *
133     * @access private
134     * @return void
135     */
136    function update() {
137        $data = array();
138        $masterData = new SC_DB_MasterData_Ex();
139        foreach ($this->arrKeys as $key) {
140            $data[$key] = $_POST[$key];
141        }
142
143        // DBのデータを更新
144        $masterData->updateMasterData('mtb_constants', array(), $data);
145
146        // キャッシュを生成
147        $masterData->createCache('mtb_constants', array(), true, array('id', 'remarks'));
148    }
149
150    /**
151     * エラーチェックを行う.
152     *
153     * @access private
154     * @return void
155     */
156    function errorCheck() {
157        $objErr = new SC_CheckError($this->arrForm);
158        for ($i = 0; $i < count($this->arrKeys); $i++) {
159            $objErr->doFunc(array($this->arrKeys[$i],
160                                  $this->arrForm[$this->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}
182?>
Note: See TracBrowser for help on using the repository browser.