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

Revision 22100, 6.3 KB checked in by pineray, 11 years ago (diff)

#163 (テキスト出力多言語対応)

グローバル化に伴い、不要となった SC_I18n を削除.

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