source: branches/comu-ver2/data/class/pages/admin/system/LC_Page_Admin_System_Parameter.php @ 17571

Revision 17571, 5.2 KB checked in by Seasoft, 16 years ago (diff)

merge 17267

  • 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-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
25require_once(CLASS_PATH . "pages/LC_Page.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 {
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        $mtb_constants = $masterData->getDBMasterData("mtb_constants");
141
142        // キャッシュを生成
143        $masterData->clearCache("mtb_constants");
144        $masterData->createCache("mtb_constants", $mtb_constants, true,
145                                 array("id", "remarks", "rank"));
146    }
147
148    /**
149     * エラーチェックを行う.
150     *
151     * @access private
152     * @return void
153     */
154    function errorCheck() {
155        $objErr = new SC_CheckError($this->arrForm);
156        for ($i = 0; $i < count($this->arrKeys); $i++) {
157            $objErr->doFunc(array($this->arrKeys[$i],
158                                  $this->arrForm[$this->arrKeys[$i]]),
159                            array("EXIST_CHECK_REVERSE", "EVAL_CHECK"));
160        }
161        return $objErr->arrErr;
162    }
163
164    /**
165     * パラメータのキーを配列で返す.
166     *
167     * @access private
168     * @return array パラメータのキーの配列
169     */
170    function getParamKeys(&$masterData) {
171        $keys = array();
172        $i = 0;
173        foreach ($masterData->getDBMasterData("mtb_constants") as $key => $val) {
174            $keys[$i] = $key;
175            $i++;
176        }
177        return $keys;
178    }
179}
180?>
Note: See TracBrowser for help on using the repository browser.