[Svn-src-all:1385] [version-2_5-dev 20275] #972 デザイン管理のヘッダー/フッター設定ページ完了
miningbrownie
admin @ mail.ec-cube.net
2011年 2月 21日 (月) 00:30:56 JST
Subversion committed to /home/svn/open 20275
http://svn.ec-cube.net/open_trac/changeset/20275
┌────────────────────────────┐
│更新者 : miningbrownie │
│更新日時: 2011-02-21 00:30:56 +0900 (月, 21 2月 2011)│
└────────────────────────────┘
Log:
--------------------------------------------------------
#972 デザイン管理のヘッダー/フッター設定ページ完了
合わせて以下のバグ修正
1. 登録できない
登録するボタンを押した際送信されるmodeがconfirmになっていたがactionの中ではregistとして扱われていた。
2. 拡大した入力枠が元に戻る
拡大ボタンを押した後でも、header_rowとfooter_rowが空のまま送信されていた。
Changed: [U:修正,A:追加,D:削除]
--------------------------------------------------------
U branches/version-2_5-dev/data/Smarty/templates/admin/design/header.tpl
U branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Header.php
変更: branches/version-2_5-dev/data/Smarty/templates/admin/design/header.tpl
===================================================================
--- branches/version-2_5-dev/data/Smarty/templates/admin/design/header.tpl 2011-02-20 13:48:14 UTC (rev 20274)
+++ branches/version-2_5-dev/data/Smarty/templates/admin/design/header.tpl 2011-02-20 15:30:56 UTC (rev 20275)
@@ -31,7 +31,7 @@
<h2>ヘッダー編集</h2>
<!--{* プレビューここから *}-->
<!--{if $header_prev == "on"}-->
- <dic id="design-header-preview">
+ <div id="design-header-preview">
<!--{if $browser_type == 1}-->
<div style="zoom:0.8"><!--{include file="`$smarty.const.USER_REALDIR`include/preview/header.tpl"}--></div>
<!--{else}-->
@@ -50,13 +50,13 @@
<textarea id="header-area" class="top" name="header" rows="<!--{$header_row}-->" wrap="off" style="width: 100%;"><!--{$header_data|smarty:nodefaults}--></textarea>
<div class="btn">
- <a id="header-area-resize-btn" class="btn-normal" href="javascript:;" onclick="ChangeSize('#header-area-resize-btn', '#header-area', 50, 13); return false;"><span>拡大</span></a>
+ <a id="header-area-resize-btn" class="btn-normal" href="javascript:;" onclick="ChangeSize('#header-area-resize-btn', '#header-area', 50, 13); $('input[name=header_row]').val($('#header-area').attr('rows'));return false;"><span>拡大</span></a>
</div>
<div class="btn-area">
<ul>
<li><a class="btn-action" href="javascript:;" name='preview' onclick="lfnSetBrowser('form_header', 'browser_type'); fnFormModeSubmit('form_header','preview','',''); return false;"><span class="btn-prev">プレビュー</span></a></li>
- <li><a class="btn-action" href="javascript:;" name='subm' onclick="fnFormModeSubmit('form_header','confirm','',''); return false;"><span class="btn-next">登録する</span></a></li>
+ <li><a class="btn-action" href="javascript:;" name='subm' onclick="fnFormModeSubmit('form_header','regist','',''); return false;"><span class="btn-next">登録する</span></a></li>
</ul>
</div>
@@ -84,13 +84,13 @@
<textarea id="footer-area" class="top" name="footer" rows="<!--{$footer_row}-->" style="width: 100%;"><!--{$footer_data|smarty:nodefaults}--></textarea>
<div class="btn">
- <a id="footer-area-resize-btn" class="btn-normal" href="javascript:;" onclick="ChangeSize('#footer-area-resize-btn', '#footer-area', 50, 13); return false;"><span>拡大</span></a>
+ <a id="footer-area-resize-btn" class="btn-normal" href="javascript:;" onclick="ChangeSize('#footer-area-resize-btn', '#footer-area', 50, 13); $('input[name=footer_row]').val($('#footer-area').attr('rows'));return false;"><span>拡大</span></a>
</div>
<div class="btn-area">
<ul>
<li><a class="btn-action" href="javascript:;" name='preview' onclick="lfnSetBrowser('form_footer', 'browser_type'); fnFormModeSubmit('form_footer','preview','',''); return false;"><span class="btn-prev">プレビュー</span></a></li>
- <li><a class="btn-action" href="javascript:;" name='subm' onclick="fnFormModeSubmit('form_footer','confirm','',''); return false;"><span class="btn-next">登録する</span></a></li>
+ <li><a class="btn-action" href="javascript:;" name='subm' onclick="fnFormModeSubmit('form_footer','regist','',''); return false;"><span class="btn-next">登録する</span></a></li>
</ul>
</div>
変更: branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Header.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Header.php 2011-02-20 13:48:14 UTC (rev 20274)
+++ branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Header.php 2011-02-20 15:30:56 UTC (rev 20275)
@@ -74,8 +74,6 @@
$objSess = new SC_Session();
SC_Utils_Ex::sfIsSuccess($objSess);
- $this->objLayout = new SC_Helper_PageLayout_Ex();
-
// 端末種別IDを取得
if (isset($_REQUEST['device_type_id'])
&& is_numeric($_REQUEST['device_type_id'])) {
@@ -83,78 +81,81 @@
} else {
$device_type_id = DEVICE_TYPE_PC;
}
+ $this->device_type_id = $device_type_id;
- $division = isset($_POST['division']) ? $_POST['division'] : "";
- $pre_DIR = USER_INC_REALDIR . 'preview/';
+ // テンプレートのパス
+ $template_path = $this->lfGetTemplatePath($device_type_id);
+ $preview_template_path = $this->lfGetPreviewTemplatePath();
// データ更新処理
- if ($division != ''){
- // プレビュー用テンプレートに書き込み
- $fp = fopen($pre_DIR.$division.'.tpl',"w"); // TODO
- fwrite($fp, $_POST[$division]);
- fclose($fp);
+ if (isset($_POST['division']) && $_POST['division'] != '') {
+ $division = $_POST['division'];
+ $content = $_POST[$division]; // TODO no checked?
+ // プレビュー用のテンプレートに書き込む
+ $preview_template = $preview_template_path.'/'.$division.'.tpl';
+ $this->lfUpdateTemplate($preview_template, $content);
- // 登録時はプレビュー用テンプレートをコピーする
switch ($this->getMode()) {
case 'regist':
- copy($pre_DIR.$division.".tpl", $this->objLayout->getTemplatePath($device_type_id) . $division . ".tpl");
- // 完了メッセージ(プレビュー時は表示しない)
+ // 正規のテンプレートに書き込む
+ $template = $template_path . '/' . $division . '.tpl';
+ $this->lfUpdateTemplate($template, $content);
$this->tpl_onload="alert('登録が完了しました。');";
-
- // テキストエリアの幅を元に戻す(処理の統一のため)
- $_POST['header_row'] = "";
- $_POST['footer_row'] = "";
break;
case 'preview':
if ($division == "header") $this->header_prev = "on";
if ($division == "footer") $this->footer_prev = "on";
+ $this->header_row = isset($_POST['header_row']) ? $_POST['header_row'] : $this->header_row;
+ $this->footer_row = isset($_POST['footer_row']) ? $_POST['footer_row'] : $this->footer_row;
break;
default:
+ // なにもしない
break;
}
- // ヘッダーファイルの読み込み(プレビューデータ)
- $header_data = file_get_contents($pre_DIR . "header.tpl");
-
- // フッターファイルの読み込み(プレビューデータ)
- $footer_data = file_get_contents($pre_DIR . "footer.tpl");
}else{
- // postでデータが渡されなければ新規読み込みと判断をし、プレビュー用データを正規のデータで上書きする
- if (!is_dir($pre_DIR)) {
- mkdir($pre_DIR);
- }
-
- // ユーザーパスにテンプレートが存在しなければ,
- // 指定テンプレートから読み込む
- $header_tpl = $this->objLayout->getTemplatePath($device_type_id) . "header.tpl";
- $footer_tpl = $this->objLayout->getTemplatePath($device_type_id) . "footer.tpl";
-
- copy($header_tpl, $pre_DIR . "header.tpl");
- copy($footer_tpl, $pre_DIR . "footer.tpl");
-
- // ヘッダーファイルの読み込み
- $header_data = file_get_contents($header_tpl);
- // フッターファイルの読み込み
- $footer_data = file_get_contents($footer_tpl);
+ // postでデータが渡されなければ新規読み込みと判断をし、
+ // プレビュー用テンプレートに正規のテンプレートをロードする
+ $templates = array(
+ 'header.tpl',
+ 'footer.tpl'
+ );
+ $this->lfLoadPreviewTemplates($preview_template_path, $template_path, $templates);
}
// テキストエリアに表示
- $this->header_data = $header_data;
- $this->footer_data = $footer_data;
- $this->device_type_id = $device_type_id;
+ $this->header_data = file_get_contents($preview_template_path . '/header.tpl');
+ $this->footer_data = file_get_contents($preview_template_path . '/footer.tpl');
- if (isset($_POST['header_row']) && $_POST['header_row'] != ''){
- $this->header_row = $_POST['header_row'];
- }
+ // ブラウザタイプ
+ $this->browser_type = isset($_POST['browser_type']) ? $_POST['browser_type'] : "";
+ }
- if (isset($_POST['footer_row']) && $_POST['footer_row'] != ''){
- $this->footer_row = $_POST['footer_row'];
+ protected function lfLoadPreviewTemplates($preview_template_path, $template_path, $templates) {
+ if (!is_dir($preview_template_path)) {
+ mkdir($preview_template_path);
}
+ foreach($templates as $template) {
+ $source = $template_path . '/' . $template;
+ $dest = $preview_template_path . '/' . $template;
+ copy($source, $dest);
+ }
+ }
- // ブラウザタイプ
- $this->browser_type =
- isset($_POST['browser_type']) ? $_POST['browser_type'] : "";
+ protected function lfUpdateTemplate($template, $content) {
+ $fp = fopen($template,"w");
+ fwrite($fp, $content);
+ fclose($fp);
}
+ protected function lfGetTemplatePath($device_type_id) {
+ $objLayout = new SC_Helper_PageLayout_Ex();
+ return $objLayout->getTemplatePath($device_type_id);
+ }
+
+ protected function lfGetPreviewTemplatePath() {
+ return USER_INC_REALDIR . 'preview';
+ }
+
/**
* デストラクタ.
*
@@ -164,4 +165,3 @@
parent::destroy();
}
}
-?>
Svn-src-all メーリングリストの案内