source: branches/version-2_13-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Bloc.php @ 22857

Revision 22857, 8.8 KB checked in by Seasoft, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

  • 主に空白・空白行の調整。
  • 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
24require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
25
26/**
27 * ブロック編集 のページクラス.
28 *
29 * @package Page
30 * @author LOCKON CO.,LTD.
31 * @version $Id$
32 */
33class LC_Page_Admin_Design_Bloc extends LC_Page_Admin_Ex
34{
35    /**
36     * Page を初期化する.
37     *
38     * @return void
39     */
40    function init()
41    {
42        parent::init();
43        $this->tpl_mainpage = 'design/bloc.tpl';
44        $this->tpl_subno_edit = 'bloc';
45        $this->text_row = 13;
46        $this->tpl_subno = 'bloc';
47        $this->tpl_mainno = 'design';
48        $this->tpl_maintitle = 'デザイン管理';
49        $this->tpl_subtitle = 'ブロック設定';
50        $masterData = new SC_DB_MasterData_Ex();
51        $this->arrDeviceType = $masterData->getMasterData('mtb_device_type');
52    }
53
54    /**
55     * Page のプロセス.
56     *
57     * @return void
58     */
59    function process()
60    {
61        $this->action();
62        $this->sendResponse();
63    }
64
65    /**
66     * Page のアクション.
67     *
68     * @return void
69     */
70    function action()
71    {
72        $objFormParam = new SC_FormParam_Ex();
73        $this->lfInitParam($objFormParam);
74        $objFormParam->setParam($_REQUEST);
75        $objFormParam->convParam();
76        $this->arrErr = $objFormParam->checkError();
77        $is_error = (!SC_Utils_Ex::isBlank($this->arrErr));
78
79        $this->bloc_id = $objFormParam->getValue('bloc_id');
80        $this->device_type_id = $objFormParam->getValue('device_type_id', DEVICE_TYPE_PC);
81
82        $objBloc = new SC_Helper_Bloc_Ex($this->device_type_id);
83        $objLayout = new SC_Helper_PageLayout_Ex();
84
85        switch ($this->getMode()) {
86            // 登録/更新
87            case 'confirm':
88                if (!$is_error) {
89                    $this->arrErr = $this->lfCheckError($objFormParam, $this->arrErr, $objBloc);
90                    if (SC_Utils_Ex::isBlank($this->arrErr)) {
91                        $result = $this->doRegister($objFormParam, $objBloc);
92                        if ($result !== false) {
93                            $arrPram = array(
94                                'bloc_id' => $result,
95                                'device_type_id' => $this->device_type_id,
96                                'msg' => 'on',
97                            );
98
99                            SC_Response_Ex::reload($arrPram, true);
100                            SC_Response_Ex::actionExit();
101                        }
102                    }
103                }
104                break;
105
106            // 削除
107            case 'delete':
108                if (!$is_error) {
109                    if ($this->doDelete($objFormParam, $objBloc)) {
110                        $arrPram = array(
111                            'device_type_id' => $this->device_type_id,
112                            'msg' => 'on',
113                        );
114
115                        SC_Response_Ex::reload($arrPram, true);
116                        SC_Response_Ex::actionExit();
117                    }
118                }
119                break;
120
121            default:
122                if (isset($_GET['msg']) && $_GET['msg'] == 'on') {
123                    // 完了メッセージ
124                    $this->tpl_onload = "alert('登録が完了しました。');";
125                }
126                break;
127        }
128
129        if (!$is_error) {
130            // ブロック一覧を取得
131            $this->arrBlocList = $objBloc->getList();
132            // bloc_id が指定されている場合にはブロックデータの取得
133            if (!SC_Utils_Ex::isBlank($this->bloc_id)) {
134                $arrBloc = $this->getBlocTemplate($this->bloc_id, $objBloc);
135                $objFormParam->setParam($arrBloc);
136            }
137        } else {
138            // 画面にエラー表示しないため, ログ出力
139            GC_Utils_Ex::gfPrintLog('Error: ' . print_r($this->arrErr, true));
140        }
141        $this->tpl_subtitle = $this->arrDeviceType[$this->device_type_id] . '>' . $this->tpl_subtitle;
142        $this->arrForm = $objFormParam->getFormParamList();
143    }
144
145    /**
146     * デストラクタ.
147     *
148     * @return void
149     */
150    function destroy()
151    {
152        parent::destroy();
153    }
154
155    /**
156     * パラメーター情報の初期化
157     *
158     * @param object $objFormParam SC_FormParamインスタンス
159     * @return void
160     */
161    function lfInitParam(&$objFormParam)
162    {
163        $objFormParam->addParam('ブロックID', 'bloc_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
164        $objFormParam->addParam('端末種別ID', 'device_type_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
165        $objFormParam->addParam('ブロック名', 'bloc_name', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK'));
166        $objFormParam->addParam('ファイル名', 'filename', STEXT_LEN, 'a', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK'));
167        $objFormParam->addParam('ブロックデータ', 'bloc_html');
168    }
169
170    /**
171     * ブロックのテンプレートを取得する.
172     *
173     * @param integer $bloc_id ブロックID
174     * @param SC_Helper_Bloc_Ex $objBloc SC_Helper_Bloc_Ex インスタンス
175     * @return array ブロック情報の配列
176     */
177    function getBlocTemplate($bloc_id, SC_Helper_Bloc_Ex &$objBloc)
178    {
179        $arrBloc = $objBloc->get($bloc_id);
180
181        return $arrBloc;
182    }
183
184    /**
185     * 登録を実行する.
186     *
187     * ファイルの作成に失敗した場合は, エラーメッセージを出力し,
188     * データベースをロールバックする.
189     *
190     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
191     * @param SC_Helper_Bloc $objBloc SC_Helper_Bloc インスタンス
192     * @return integer|boolean 登録が成功した場合, 登録したブロックID;
193     *                         失敗した場合 false
194     */
195    function doRegister(&$objFormParam, SC_Helper_Bloc_Ex &$objBloc)
196    {
197        $arrParams = $objFormParam->getHashArray();
198        $result = $objBloc->save($arrParams);
199
200        if (!$result) {
201            $this->arrErr['err'] = '※ ブロックの書き込みに失敗しました<br />';
202        }
203
204        return $result;
205    }
206
207    /**
208     * 削除を実行する.
209     *
210     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
211     * @param SC_Helper_Bloc $objBloc SC_Helper_Bloc インスタンス
212     * @return boolean 登録が成功した場合 true; 失敗した場合 false
213     */
214    function doDelete(&$objFormParam, SC_Helper_Bloc_Ex &$objBloc)
215    {
216        $arrParams = $objFormParam->getHashArray();
217        $result = $objBloc->delete($arrParams['bloc_id']);
218
219        if (!$result) {
220            $this->arrErr['err'] = '※ ブロックの削除に失敗しました<br />';
221        }
222
223        return $result;
224    }
225
226    /**
227     * エラーチェックを行う.
228     *
229     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
230     * @return array エラーメッセージの配列
231     */
232    function lfCheckError(&$objFormParam, &$arrErr, SC_Helper_Bloc_Ex &$objBloc)
233    {
234        $arrParams = $objFormParam->getHashArray();
235        $objErr = new SC_CheckError_Ex($arrParams);
236        $objErr->arrErr =& $arrErr;
237        $objErr->doFunc(array('ブロック名', 'bloc_name', STEXT_LEN), array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK'));
238        $objErr->doFunc(array('ファイル名', 'filename', STEXT_LEN), array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK','FILE_NAME_CHECK_BY_NOUPLOAD'));
239
240        $where = 'filename = ?';
241        $arrValues = array($arrParams['filename']);
242
243        // 変更の場合は自ブロックを除外
244        if (!SC_Utils_Ex::isBlank($arrParams['bloc_id'])) {
245            $where .= ' AND bloc_id <> ?';
246            $arrValues[] = $arrParams['bloc_id'];
247        }
248        $arrBloc = $objBloc->getWhere($where, $arrValues);
249        if (!SC_Utils_Ex::isBlank($arrBloc)) {
250            $objErr->arrErr['filename'] = '※ 同じファイル名のデータが存在しています。別のファイル名を入力してください。<br />';
251        }
252
253        return $objErr->arrErr;
254    }
255}
Note: See TracBrowser for help on using the repository browser.