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
RevLine 
[15688]1<?php
2/*
[16582]3 * This file is part of EC-CUBE
4 *
[18701]5 * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
[15688]6 *
7 * http://www.lockon.co.jp/
[16582]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.
[15688]22 */
23
24// {{{ requires
[20534]25require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
[15688]26
27/**
28 * ヘッダ, フッタ編集 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
[20345]34class LC_Page_Admin_Design_Header extends LC_Page_Admin_Ex {
[15688]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;
[20538]50        $this->tpl_subno = 'header';
51        $this->tpl_mainno = 'design';
[19715]52        $this->tpl_subtitle = 'ヘッダー/フッター設定';
[20560]53        $masterData = new SC_DB_MasterData_Ex();
54        $this->arrDeviceType = $masterData->getMasterData('mtb_device_type');
[15688]55    }
56
57    /**
58     * Page のプロセス.
59     *
60     * @return void
61     */
62    function process() {
[19661]63        $this->action();
64        $this->sendResponse();
65    }
[15688]66
[19661]67    /**
68     * Page のアクション.
69     *
[19713]70     * FIXME テンプレートの取得方法を要修正
71     *
[19661]72     * @return void
73     */
74    function action() {
[19725]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        }
[20275]82        $this->device_type_id = $device_type_id;
[19725]83
[20560]84        //サブタイトルの追加
85        $this->tpl_subtitle .= ' - ' . $this->arrDeviceType[$device_type_id];
86
[20275]87        // テンプレートのパス
88        $template_path = $this->lfGetTemplatePath($device_type_id);
89        $preview_template_path = $this->lfGetPreviewTemplatePath();
[15688]90
91        // データ更新処理
[20275]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);
[15688]98
[20044]99            switch ($this->getMode()) {
100            case 'regist':
[20275]101                // 正規のテンプレートに書き込む
102                $template = $template_path . '/' . $division . '.tpl';
103                $this->lfUpdateTemplate($template, $content);
[15688]104                $this->tpl_onload="alert('登録が完了しました。');";
[20044]105                break;
106            case 'preview':
[20538]107                if ($division == 'header') $this->header_prev = 'on';
108                if ($division == 'footer') $this->footer_prev = 'on';
[20275]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;
[20044]111                break;
112            default:
[20275]113                // なにもしない
[20044]114                break;
[15688]115            }
116        }else{
[20275]117            // postでデータが渡されなければ新規読み込みと判断をし、
118            // プレビュー用テンプレートに正規のテンプレートをロードする
119            $templates = array(
120                'header.tpl',
121                'footer.tpl'
122            );
123            $this->lfLoadPreviewTemplates($preview_template_path, $template_path, $templates);
[15688]124        }
125
126        // テキストエリアに表示
[20275]127        $this->header_data = file_get_contents($preview_template_path . '/header.tpl');
128        $this->footer_data = file_get_contents($preview_template_path . '/footer.tpl');
[15688]129
[20275]130        // ブラウザタイプ
131        $this->browser_type = isset($_POST['browser_type']) ? $_POST['browser_type'] : "";
132    }
[15688]133
[20275]134    protected function lfLoadPreviewTemplates($preview_template_path, $template_path, $templates) {
135        if (!is_dir($preview_template_path)) {
136            mkdir($preview_template_path);
[15688]137        }
[20275]138        foreach($templates as $template) {
139            $source = $template_path . '/' . $template;
140            $dest = $preview_template_path . '/' . $template;
141            copy($source, $dest);
142        }
143    }
[15688]144
[20275]145    protected function lfUpdateTemplate($template, $content) {
[20538]146        $fp = fopen($template,'w');
[20275]147        fwrite($fp, $content);
148        fclose($fp);
[15688]149    }
150
[20275]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
[15688]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.