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

Revision 18734, 5.1 KB checked in by nanasess, 14 years ago (diff)

Copyright の更新(#601)

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