| 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 |
|---|
| 25 | require_once(CLASS_PATH . "pages/LC_Page.php"); |
|---|
| 26 | |
|---|
| 27 | /** |
|---|
| 28 | * ヘッダ, フッタ編集 のページクラス. |
|---|
| 29 | * |
|---|
| 30 | * @package Page |
|---|
| 31 | * @author LOCKON CO.,LTD. |
|---|
| 32 | * @version $Id$ |
|---|
| 33 | */ |
|---|
| 34 | class LC_Page_Admin_Design_Header extends LC_Page { |
|---|
| 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 | $this->tpl_onload = 'comment_start(); comment_end();'; |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | /** |
|---|
| 57 | * Page のプロセス. |
|---|
| 58 | * |
|---|
| 59 | * @return void |
|---|
| 60 | */ |
|---|
| 61 | function process() { |
|---|
| 62 | $objView = new SC_AdminView(); |
|---|
| 63 | |
|---|
| 64 | // 認証可否の判定 |
|---|
| 65 | $objSess = new SC_Session(); |
|---|
| 66 | SC_Utils_Ex::sfIsSuccess($objSess); |
|---|
| 67 | |
|---|
| 68 | $division = isset($_POST['division']) ? $_POST['division'] : ""; |
|---|
| 69 | $pre_DIR = USER_INC_PATH . 'preview/'; |
|---|
| 70 | |
|---|
| 71 | // データ更新処理 |
|---|
| 72 | if ($division != ''){ |
|---|
| 73 | // プレビュー用テンプレートに書き込み |
|---|
| 74 | $fp = fopen($pre_DIR.$division.'.tpl',"w"); // TODO |
|---|
| 75 | fwrite($fp, $_POST[$division]); |
|---|
| 76 | fclose($fp); |
|---|
| 77 | |
|---|
| 78 | // 登録時はプレビュー用テンプレートをコピーする |
|---|
| 79 | if ($_POST['mode'] == 'confirm'){ |
|---|
| 80 | copy($pre_DIR.$division.".tpl", USER_PATH . USER_PACKAGE_DIR . TEMPLATE_NAME . "/" . $division . ".tpl"); |
|---|
| 81 | // 完了メッセージ(プレビュー時は表示しない) |
|---|
| 82 | $this->tpl_onload="alert('登録が完了しました。');"; |
|---|
| 83 | |
|---|
| 84 | // テキストエリアの幅を元に戻す(処理の統一のため) |
|---|
| 85 | $_POST['header_row'] = ""; |
|---|
| 86 | $_POST['footer_row'] = ""; |
|---|
| 87 | }else if ($_POST['mode'] == 'preview'){ |
|---|
| 88 | if ($division == "header") $this->header_prev = "on"; |
|---|
| 89 | if ($division == "footer") $this->footer_prev = "on"; |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | // ヘッダーファイルの読み込み(プレビューデータ) |
|---|
| 93 | $header_data = file_get_contents($pre_DIR . "header.tpl"); |
|---|
| 94 | |
|---|
| 95 | // フッターファイルの読み込み(プレビューデータ) |
|---|
| 96 | $footer_data = file_get_contents($pre_DIR . "footer.tpl"); |
|---|
| 97 | }else{ |
|---|
| 98 | // postでデータが渡されなければ新規読み込みと判断をし、プレビュー用データを正規のデータで上書きする |
|---|
| 99 | if (!is_dir($pre_DIR)) { |
|---|
| 100 | mkdir($pre_DIR); |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | // ユーザーパスにテンプレートが存在しなければ, |
|---|
| 104 | // 指定テンプレートから読み込む |
|---|
| 105 | $header_tpl = USER_PATH . USER_PACKAGE_DIR . TEMPLATE_NAME . "/" . "header.tpl"; |
|---|
| 106 | if (!is_file($header_tpl)) { |
|---|
| 107 | $header_tpl = TEMPLATE_DIR . "header.tpl"; |
|---|
| 108 | } |
|---|
| 109 | $footer_tpl = USER_PATH . USER_PACKAGE_DIR . TEMPLATE_NAME . "/" . "footer.tpl"; |
|---|
| 110 | if (!is_file($footer_tpl)) { |
|---|
| 111 | $footer_tpl = TEMPLATE_DIR . "footer.tpl"; |
|---|
| 112 | } |
|---|
| 113 | |
|---|
| 114 | copy($header_tpl, $pre_DIR . "header.tpl"); |
|---|
| 115 | copy($footer_tpl, $pre_DIR . "footer.tpl"); |
|---|
| 116 | |
|---|
| 117 | // ヘッダーファイルの読み込み |
|---|
| 118 | $header_data = file_get_contents($header_tpl); |
|---|
| 119 | // フッターファイルの読み込み |
|---|
| 120 | $footer_data = file_get_contents($footer_tpl); |
|---|
| 121 | } |
|---|
| 122 | |
|---|
| 123 | // テキストエリアに表示 |
|---|
| 124 | $this->header_data = $header_data; |
|---|
| 125 | $this->footer_data = $footer_data; |
|---|
| 126 | |
|---|
| 127 | if (isset($_POST['header_row']) && $_POST['header_row'] != ''){ |
|---|
| 128 | $this->header_row = $_POST['header_row']; |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | if (isset($_POST['footer_row']) && $_POST['footer_row'] != ''){ |
|---|
| 132 | $this->footer_row = $_POST['footer_row']; |
|---|
| 133 | } |
|---|
| 134 | |
|---|
| 135 | // ブラウザタイプ |
|---|
| 136 | $this->browser_type = |
|---|
| 137 | isset($_POST['browser_type']) ? $_POST['browser_type'] : ""; |
|---|
| 138 | |
|---|
| 139 | // 画面の表示 |
|---|
| 140 | $objView->assignobj($this); |
|---|
| 141 | $objView->display(MAIN_FRAME); |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | /** |
|---|
| 145 | * デストラクタ. |
|---|
| 146 | * |
|---|
| 147 | * @return void |
|---|
| 148 | */ |
|---|
| 149 | function destroy() { |
|---|
| 150 | parent::destroy(); |
|---|
| 151 | } |
|---|
| 152 | } |
|---|
| 153 | ?> |
|---|