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

Revision 20560, 5.6 KB checked in by t_yuo, 13 years ago (diff)

#948 (コンテンツ管理>CSV出力設定、デザイン管理 サブタイトルが欲しい)

  • デザイン管理に対応しました。
  • 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-2010 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->tpl_subnavi  = 'design/subnavi.tpl';
48        $this->header_row = 13;
49        $this->footer_row = 13;
50        $this->tpl_subno = 'header';
51        $this->tpl_mainno = 'design';
52        $this->tpl_subtitle = 'ヘッダー/フッター設定';
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     * FIXME テンプレートの取得方法を要修正
71     *
72     * @return void
73     */
74    function action() {
75        // 端末種別IDを取得
76        if (isset($_REQUEST['device_type_id'])
77            && is_numeric($_REQUEST['device_type_id'])) {
78            $device_type_id = $_REQUEST['device_type_id'];
79        } else {
80            $device_type_id = DEVICE_TYPE_PC;
81        }
82        $this->device_type_id = $device_type_id;
83
84        //サブタイトルの追加
85        $this->tpl_subtitle .= ' - ' . $this->arrDeviceType[$device_type_id];
86
87        // テンプレートのパス
88        $template_path = $this->lfGetTemplatePath($device_type_id);
89        $preview_template_path = $this->lfGetPreviewTemplatePath();
90
91        // データ更新処理
92        if (isset($_POST['division']) && $_POST['division'] != '') {
93            $division = $_POST['division'];
94            $content = $_POST[$division]; // TODO no checked?
95            // プレビュー用のテンプレートに書き込む
96            $preview_template = $preview_template_path.'/'.$division.'.tpl';
97            $this->lfUpdateTemplate($preview_template, $content);
98
99            switch ($this->getMode()) {
100            case 'regist':
101                // 正規のテンプレートに書き込む
102                $template = $template_path . '/' . $division . '.tpl';
103                $this->lfUpdateTemplate($template, $content);
104                $this->tpl_onload="alert('登録が完了しました。');";
105                break;
106            case 'preview':
107                if ($division == 'header') $this->header_prev = 'on';
108                if ($division == 'footer') $this->footer_prev = 'on';
109                $this->header_row = isset($_POST['header_row']) ? $_POST['header_row'] : $this->header_row;
110                $this->footer_row = isset($_POST['footer_row']) ? $_POST['footer_row'] : $this->footer_row;
111                break;
112            default:
113                // なにもしない
114                break;
115            }
116        }else{
117            // postでデータが渡されなければ新規読み込みと判断をし、
118            // プレビュー用テンプレートに正規のテンプレートをロードする
119            $templates = array(
120                'header.tpl',
121                'footer.tpl'
122            );
123            $this->lfLoadPreviewTemplates($preview_template_path, $template_path, $templates);
124        }
125
126        // テキストエリアに表示
127        $this->header_data = file_get_contents($preview_template_path . '/header.tpl');
128        $this->footer_data = file_get_contents($preview_template_path . '/footer.tpl');
129
130        // ブラウザタイプ
131        $this->browser_type = isset($_POST['browser_type']) ? $_POST['browser_type'] : "";
132    }
133
134    protected function lfLoadPreviewTemplates($preview_template_path, $template_path, $templates) {
135        if (!is_dir($preview_template_path)) {
136            mkdir($preview_template_path);
137        }
138        foreach($templates as $template) {
139            $source = $template_path . '/' . $template;
140            $dest = $preview_template_path . '/' . $template;
141            copy($source, $dest);
142        }
143    }
144
145    protected function lfUpdateTemplate($template, $content) {
146        $fp = fopen($template,'w');
147        fwrite($fp, $content);
148        fclose($fp);
149    }
150
151    protected function lfGetTemplatePath($device_type_id) {
152        $objLayout = new SC_Helper_PageLayout_Ex();
153        return $objLayout->getTemplatePath($device_type_id);
154    }
155
156    protected function lfGetPreviewTemplatePath() {
157        return USER_INC_REALDIR . 'preview';
158    }
159
160    /**
161     * デストラクタ.
162     *
163     * @return void
164     */
165    function destroy() {
166        parent::destroy();
167    }
168}
Note: See TracBrowser for help on using the repository browser.