source: branches/version-2_5-dev/data/class/pages/admin/ownersstore/LC_Page_Admin_OwnersStore_Settings.php @ 20764

Revision 20764, 5.2 KB checked in by nanasess, 13 years ago (diff)

#601 (コピーライトの更新)

  • 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-2011 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_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
26
27/**
28 * EC-CUBEアプリケーション管理:アプリケーション設定 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_OwnersStore_Settings extends LC_Page_Admin_Ex {
35
36    /** SC_FormParamのインスタンス */
37    var $objForm;
38
39    /** リクエストパラメータを格納する連想配列 */
40    var $arrForm;
41
42    /** バリデーションエラー情報を格納する連想配列 */
43    var $arrErr;
44
45    // }}}
46    // {{{ functions
47
48    /**
49     * Page を初期化する.
50     *
51     * @return void
52     */
53    function init() {
54        parent::init();
55
56        $this->tpl_mainpage = 'ownersstore/settings.tpl';
57        $this->tpl_mainno   = 'ownersstore';
58        $this->tpl_subno    = 'settings';
59        $this->tpl_subtitle = '認証キー設定';
60        $this->httpCacheControl('nocache');
61    }
62
63    /**
64     * Page のプロセス.
65     *
66     * @return void
67     */
68    function process() {
69        $this->action();
70        $this->sendResponse();
71    }
72
73    /**
74     * Page のアクション.
75     *
76     * @return void
77     */
78    function action() {
79        switch($this->getMode()) {
80        // 入力内容をDBへ登録する
81        case 'register':
82            $this->execRegisterMode();
83            break;
84        // 初回表示
85        default:
86            $this->execDefaultMode();
87        }
88    }
89
90    /**
91     * デストラクタ.
92     *
93     * @return void
94     */
95    function destroy() {
96        parent::destroy();
97    }
98
99    /**
100     * registerアクションの実行.
101     * 入力内容をDBへ登録する.
102     *
103     * @param void
104     * @return void
105     */
106    function execRegisterMode() {
107        // パラメータオブジェクトの初期化
108        $this->initRegisterMode();
109        // POSTされたパラメータの検証
110        $arrErr = $this->validateRegistermode();
111
112        // エラー時の処理
113        if (!empty($arrErr)) {
114            $this->arrErr  = $arrErr;
115            $this->arrForm = $this->objForm->getHashArray();
116            return;
117        }
118
119        // エラーがなければDBへ登録
120        $arrForm = $this->objForm->getHashArray();
121        $this->registerOwnersStoreSettings($arrForm);
122
123        $this->arrForm = $arrForm;
124
125        $this->tpl_onload = "alert('登録しました。')";
126    }
127
128    /**
129     * registerアクションの初期化.
130     * SC_FormParamを初期化しメンバ変数にセットする.
131     *
132     * @param void
133     * @return void
134     */
135    function initRegisterMode() {
136        // 前後の空白を削除
137        if (isset($_POST['public_key'])) {
138            $_POST['public_key'] = trim($_POST['public_key']);
139        }
140
141        $objForm = new SC_FormParam_Ex();
142        $objForm->addParam('認証キー', 'public_key', LTEXT_LEN, '', array('EXIST_CHECK', 'ALNUM_CHECK', 'MAX_LENGTH_CHECK'));
143        $objForm->setParam($_POST);
144
145        $this->objForm = $objForm;
146    }
147
148    /**
149     * registerアクションのパラメータを検証する.
150     *
151     * @param void
152     * @return array エラー情報を格納した連想配列
153     */
154    function validateRegistermode() {
155        return $this->objForm->checkError();
156    }
157
158    /**
159     * defaultアクションの実行.
160     * DBから登録内容を取得し表示する.
161     *
162     * @param void
163     * @return void
164     */
165    function execDefaultMode() {
166        $this->arrForm = $this->getOwnersStoreSettings();
167    }
168
169    /**
170     * DBへ入力内容を登録する.
171     *
172     * @param array $arrSettingsData オーナーズストア設定の連想配列
173     * @return void
174     */
175    function registerOwnersStoreSettings($arrSettingsData) {
176        $table = 'dtb_ownersstore_settings';
177        $objQuery = new SC_Query_Ex();
178        $count = $objQuery->count($table);
179
180        if ($count) {
181            $objQuery->update($table, $arrSettingsData);
182        } else {
183            $objQuery->insert($table, $arrSettingsData);
184        }
185    }
186
187    /**
188     * DBから登録内容を取得する.
189     *
190     * @param void
191     * @return array
192     */
193    function getOwnersStoreSettings(){
194        $table   = 'dtb_ownersstore_settings';
195        $colmuns = '*';
196
197        $objQuery = new SC_Query_Ex();
198        $arrRet = $objQuery->select($colmuns, $table);
199
200        if (isset($arrRet[0])) return $arrRet[0];
201
202        return array();
203    }
204}
205?>
Note: See TracBrowser for help on using the repository browser.