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

Revision 22567, 5.4 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

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