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

Revision 23605, 6.2 KB checked in by kimoto, 10 years ago (diff)

#2448 typo修正・ソース整形・ソースコメントの改善 for 2.13.3

Scrutinizer Auto-Fixes

This patch was automatically generated as part of the following inspection:
 https://scrutinizer-ci.com/g/nobuhiko/EC-CUBE/inspections/d8722894-69a6-4b1b-898d-43618035c60d

Enabled analysis tools:

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