source: branches/feature-module-update/data/class/pages/admin/app/LC_Page_Admin_App_Settings.php @ 15631

Revision 15631, 5.1 KB checked in by adachi, 17 years ago (diff)

ECCUBEアプリ用管理ページを新規作成, 仮コミット

  • 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 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7
8// {{{ requires
9require_once(CLASS_PATH . "pages/LC_Page.php");
10
11/**
12 * EC-CUBEアプリケーション管理:アプリケーション設定 のページクラス.
13 *
14 * @package Page
15 * @author LOCKON CO.,LTD.
16 * @version $Id$
17 */
18class LC_Page_Admin_App_Settings extends LC_Page {
19
20    /** SC_FormParamのインスタンス */
21    var $objForm;
22
23    /** リクエストパラメータを格納する連想配列 */
24    var $arrForm;
25
26    /** バリデーションエラー情報を格納する連想配列 */
27    var $arrErr;
28
29    // }}}
30    // {{{ functions
31
32    /**
33     * Page を初期化する.
34     *
35     * @return void
36     */
37    function init() {
38        parent::init();
39
40        $this->tpl_mainpage = 'app/settings.tpl';
41        $this->tpl_subnavi  = 'app/subnavi.tpl';
42        $this->tpl_mainno   = 'app';
43        $this->tpl_subno    = 'settings';
44        $this->tpl_subtitle = 'アプリケーション設定';
45    }
46
47    /**
48     * Page のプロセス.
49     *
50     * @return void
51     */
52    function process() {
53
54        // ログインチェック
55        SC_Utils::sfIsSuccess(new SC_Session());
56
57        // トランザクションIDの取得
58        $this->transactionid = $this->getToken();
59
60        // $_POST['mode']によってアクション振り分け
61        switch($this->getMode()) {
62        // 入力内容をDBへ登録する
63        case 'register':
64            $this->execRegisterMode();
65            break;
66        // 初回表示
67        default:
68            $this->execDefaultMode();
69        }
70
71        // ページ出力
72        $objView = new SC_AdminView();
73        $objView->assignObj($this);
74        $objView->display(MAIN_FRAME);
75    }
76
77    /**
78     * デストラクタ.
79     *
80     * @return void
81     */
82    function destroy() {
83        parent::destroy();
84    }
85
86    /**
87     * switchアクション振り分け用パラメータを取得する.
88     *
89     * @param void
90     * @return string モード名
91     */
92    function getMode() {
93        $mode = '';
94        if ($_SERVER['REQUEST_METHOD'] == 'GET') {
95            if (isset($_GET['mode'])) $mode = $_GET['mode'];
96        } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') {
97            if (isset($_POST['mode'])) $mode = $_POST['mode'];
98        }
99        return $mode;
100    }
101
102    /**
103     * registerアクションの実行.
104     * 入力内容をDBへ登録する.
105     *
106     * @param void
107     * @return void
108     */
109    function execRegisterMode() {
110        if ($this->isValidToken() !== true) {
111            SC_Utils_Ex::sfDispError('');
112        }
113        // パラメータオブジェクトの初期化
114        $this->initRegisterMode();
115        // POSTされたパラメータの検証
116        $arrErr = $this->validateRegistermode();
117
118        // エラー時の処理
119        if (!empty($arrErr)) {
120            $this->arrErr  = $arrErr;
121            $this->arrForm = $this->objForm->getHashArray();
122            $this->transactionid = $this->getToken();
123            return;
124        }
125
126        // エラーがなければDBへ登録
127        $arrForm = $this->objForm->getHashArray();
128        $this->registerAppSettings($arrForm);
129
130        $this->arrForm = $arrForm;
131
132        $this->tpl_onload = "alert('登録しました。')";
133        $this->transactionid = $this->getToken();
134    }
135
136    /**
137     * registerアクションの初期化.
138     * SC_FormParamを初期化しメンバ変数にセットする.
139     *
140     * @param void
141     * @return void
142     */
143    function initRegisterMode() {
144        // 前後の空白を削除
145        if (isset($_POST['public_key'])) {
146            $_POST['public_key'] = trim($_POST['public_key']);
147        }
148
149        $objForm = new SC_FormParam();
150        $objForm->addParam('認証キー', 'public_key', MTEXT_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        return $this->objForm->checkError();
164    }
165
166    /**
167     * defaultアクションの実行.
168     * DBから登録内容を取得し表示する.
169     *
170     * @param void
171     * @return void
172     */
173    function execDefaultMode() {
174        // $this->arrForm = $this->getAppSettings();
175    }
176
177    /**
178     * DBへ入力内容を登録する.
179     *
180     * @param array $arrSettingsData アプリケーション設定の連想配列
181     * @return void
182     */
183    function registerAppSettings($arrSettingsData) {
184
185    }
186
187    /**
188     * DBから登録内容を取得する.
189     *
190     * @param void
191     * @return array
192     */
193    function getAppSettings(){
194        $table   = 'dtb_application_settings';
195        $colmuns = '*';
196        $where   = 'app_id = 1';
197
198        $objQuery = new SC_Query();
199        $arrRet = $objQuery->select($colmuns, $table, $where);
200
201        if (isset($arrRet[0])) return $arrRet[0];
202
203        return array();
204    }
205}
206?>
Note: See TracBrowser for help on using the repository browser.