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

Revision 19768, 5.4 KB checked in by Seasoft, 13 years ago (diff)

#748(モバイル/スマートフォンのデザイン管理)

  • プレビュー周り(荒削りです)

#874(テンプレートは /data/ 配下のみ保存する)

  • Property svn:eol-style set to LF
  • Property svn:keywords set to "Id Revision Date"
  • 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_PATH . "pages/admin/LC_Page_Admin.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 {
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    }
54
55    /**
56     * Page のプロセス.
57     *
58     * @return void
59     */
60    function process() {
61        $this->action();
62        $this->sendResponse();
63    }
64
65    /**
66     * Page のアクション.
67     *
68     * FIXME テンプレートの取得方法を要修正
69     *
70     * @return void
71     */
72    function action() {
73        // 認証可否の判定
74        $objSess = new SC_Session();
75        SC_Utils_Ex::sfIsSuccess($objSess);
76
77        $this->objLayout = new SC_Helper_PageLayout_Ex();
78
79        // 端末種別IDを取得
80        if (isset($_REQUEST['device_type_id'])
81            && is_numeric($_REQUEST['device_type_id'])) {
82            $device_type_id = $_REQUEST['device_type_id'];
83        } else {
84            $device_type_id = DEVICE_TYPE_PC;
85        }
86
87        $division = isset($_POST['division']) ? $_POST['division'] : "";
88        $pre_DIR = USER_INC_PATH . 'preview/';
89
90        // データ更新処理
91        if ($division != ''){
92            // プレビュー用テンプレートに書き込み
93            $fp = fopen($pre_DIR.$division.'.tpl',"w"); // TODO
94            fwrite($fp, $_POST[$division]);
95            fclose($fp);
96
97            // 登録時はプレビュー用テンプレートをコピーする
98            if ($_POST['mode'] == 'confirm'){
99                copy($pre_DIR.$division.".tpl", $this->objLayout->getTemplatePath($device_type_id) . $division . ".tpl");
100                // 完了メッセージ(プレビュー時は表示しない)
101                $this->tpl_onload="alert('登録が完了しました。');";
102
103                // テキストエリアの幅を元に戻す(処理の統一のため)
104                $_POST['header_row'] = "";
105                $_POST['footer_row'] = "";
106            }else if ($_POST['mode'] == 'preview'){
107                if ($division == "header") $this->header_prev = "on";
108                if ($division == "footer") $this->footer_prev = "on";
109            }
110
111            // ヘッダーファイルの読み込み(プレビューデータ)
112            $header_data = file_get_contents($pre_DIR . "header.tpl");
113
114            // フッターファイルの読み込み(プレビューデータ)
115            $footer_data = file_get_contents($pre_DIR . "footer.tpl");
116        }else{
117            // postでデータが渡されなければ新規読み込みと判断をし、プレビュー用データを正規のデータで上書きする
118            if (!is_dir($pre_DIR)) {
119                mkdir($pre_DIR);
120            }
121
122            // ユーザーパスにテンプレートが存在しなければ,
123            // 指定テンプレートから読み込む
124            $header_tpl = $this->objLayout->getTemplatePath($device_type_id) . "header.tpl";
125            $footer_tpl = $this->objLayout->getTemplatePath($device_type_id) . "footer.tpl";
126
127            copy($header_tpl, $pre_DIR . "header.tpl");
128            copy($footer_tpl, $pre_DIR . "footer.tpl");
129
130            // ヘッダーファイルの読み込み
131            $header_data = file_get_contents($header_tpl);
132            // フッターファイルの読み込み
133            $footer_data = file_get_contents($footer_tpl);
134        }
135
136        // テキストエリアに表示
137        $this->header_data = $header_data;
138        $this->footer_data = $footer_data;
139        $this->device_type_id = $device_type_id;
140
141        if (isset($_POST['header_row']) && $_POST['header_row'] != ''){
142            $this->header_row = $_POST['header_row'];
143        }
144
145        if (isset($_POST['footer_row']) && $_POST['footer_row'] != ''){
146            $this->footer_row = $_POST['footer_row'];
147        }
148
149        // ブラウザタイプ
150        $this->browser_type =
151            isset($_POST['browser_type']) ? $_POST['browser_type'] : "";
152    }
153
154    /**
155     * デストラクタ.
156     *
157     * @return void
158     */
159    function destroy() {
160        parent::destroy();
161    }
162}
163?>
Note: See TracBrowser for help on using the repository browser.