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

Revision 22567, 6.3 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_Design_Header extends LC_Page_Admin_Ex
35{
36
37    // }}}
38    // {{{ functions
39
40    /**
41     * Page を初期化する.
42     *
43     * @return void
44     */
45    function init()
46    {
47        parent::init();
48        $this->tpl_mainpage = 'design/header.tpl';
49        $this->header_row = 13;
50        $this->footer_row = 13;
51        $this->tpl_subno = 'header';
52        $this->tpl_mainno = 'design';
53        $this->tpl_maintitle = 'デザイン管理';
54        $this->tpl_subtitle = 'ヘッダー/フッター設定';
55        $masterData = new SC_DB_MasterData_Ex();
56        $this->arrDeviceType = $masterData->getMasterData('mtb_device_type');
57    }
58
59    /**
60     * Page のプロセス.
61     *
62     * @return void
63     */
64    function process()
65    {
66        $this->action();
67        $this->sendResponse();
68    }
69
70    /**
71     * Page のアクション.
72     *
73     * @return void
74     */
75    function action()
76    {
77
78        $objFormParam = new SC_FormParam_Ex();
79        $this->lfInitParam($objFormParam);
80        $objFormParam->setParam($_REQUEST);
81        $objFormParam->convParam();
82        $this->arrErr = $objFormParam->checkError();
83        $is_error = (!SC_Utils_Ex::isBlank($this->arrErr));
84
85        $this->device_type_id = $objFormParam->getValue('device_type_id', DEVICE_TYPE_PC);
86
87        switch ($this->getMode()) {
88            // 登録
89            case 'regist':
90                $this->arrErr = $this->lfCheckError($objFormParam, $this->arrErr);
91                if (SC_Utils_Ex::isBlank($this->arrErr)) {
92                    if ($this->doRegister($objFormParam)) {
93                        $this->tpl_onload = "alert('登録が完了しました。');";
94                    }
95                }
96                break;
97
98            default:
99                break;
100        }
101
102        if (!$is_error) {
103            // テキストエリアに表示
104            $header_path = $this->getTemplatePath($this->device_type_id, 'header');
105            $footer_path = $this->getTemplatePath($this->device_type_id, 'footer');
106            if ($header_path === false || $footer_path === false) {
107                $this->arrErr['err'] = '※ ファイルの取得に失敗しました<br />';
108            } else {
109                $this->header_data = file_get_contents($header_path);
110                $this->footer_data = file_get_contents($footer_path);
111            }
112        } else {
113            // 画面にエラー表示しないため, ログ出力
114            GC_Utils_Ex::gfPrintLog('Error: ' . print_r($this->arrErr, true));
115        }
116
117        //サブタイトルの追加
118        $this->tpl_subtitle = $this->arrDeviceType[$this->device_type_id] . '>' . $this->tpl_subtitle;
119
120    }
121
122    /**
123     * デストラクタ.
124     *
125     * @return void
126     */
127    function destroy()
128    {
129        parent::destroy();
130    }
131
132    /**
133     * パラメーター情報の初期化
134     *
135     * @param object $objFormParam SC_FormParamインスタンス
136     * @return void
137     */
138    function lfInitParam(&$objFormParam)
139    {
140        $objFormParam->addParam('端末種別ID', 'device_type_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
141        $objFormParam->addParam('division', 'division', STEXT_LEN, 'a', array('MAX_LENGTH_CHECK'));
142        $objFormParam->addParam('ヘッダデータ', 'header');
143        $objFormParam->addParam('フッタデータ', 'footer');
144    }
145
146    /**
147     * エラーチェックを行う.
148     *
149     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
150     * @return array エラーメッセージの配列
151     */
152    function lfCheckError(&$objFormParam, &$arrErr)
153    {
154        $arrParams = $objFormParam->getHashArray();
155        $objErr = new SC_CheckError_Ex($arrParams);
156        $objErr->arrErr =& $arrErr;
157        $objErr->doFunc(array('division', 'division', STEXT_LEN), array('EXIST_CHECK'));
158        return $objErr->arrErr;
159    }
160
161    /**
162     * 登録を実行する.
163     *
164     * ファイルの作成に失敗した場合は, エラーメッセージを出力する.
165     *
166     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
167     * @return integer|boolean 登録が成功した場合 true; 失敗した場合 false
168     */
169    function doRegister(&$objFormParam)
170    {
171        $division = $objFormParam->getValue('division');
172        $contents = $objFormParam->getValue($division);
173        $tpl_path = $this->getTemplatePath($objFormParam->getValue('device_type_id'), $division);
174        if ($tpl_path === false
175            || !SC_Helper_FileManager_Ex::sfWriteFile($tpl_path, $contents)) {
176            $this->arrErr['err'] = '※ ファイルの書き込みに失敗しました<br />';
177            return false;
178        }
179        return true;
180    }
181
182    /**
183     * テンプレートパスを取得する.
184     *
185     * @param integer $device_type_id 端末種別ID
186     * @param string $division 'header' or 'footer'
187     * @return string|boolean 成功した場合, テンプレートのパス; 失敗した場合 false
188     */
189    function getTemplatePath($device_type_id, $division)
190    {
191        $tpl_path = SC_Helper_PageLayout_Ex::getTemplatePath($device_type_id) . '/' . $division . '.tpl';
192        if (file_exists($tpl_path)) {
193            return $tpl_path;
194        } else {
195            return false;
196        }
197    }
198}
Note: See TracBrowser for help on using the repository browser.