Changeset 20275


Ignore:
Timestamp:
2011/02/21 00:30:56 (13 years ago)
Author:
miningbrownie
Message:

#972 デザイン管理のヘッダー/フッター設定ページ完了
合わせて以下のバグ修正

  1. 登録できない

登録するボタンを押した際送信されるmodeがconfirmになっていたがactionの中ではregistとして扱われていた。

  1. 拡大した入力枠が元に戻る

拡大ボタンを押した後でも、header_rowとfooter_rowが空のまま送信されていた。

Location:
branches/version-2_5-dev/data
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/data/Smarty/templates/admin/design/header.tpl

    r20116 r20275  
    3232  <!--{* プレビューここから *}--> 
    3333  <!--{if $header_prev == "on"}--> 
    34   <dic id="design-header-preview"> 
     34  <div id="design-header-preview"> 
    3535    <!--{if $browser_type == 1}--> 
    3636      <div style="zoom:0.8"><!--{include file="`$smarty.const.USER_REALDIR`include/preview/header.tpl"}--></div> 
     
    5151    <textarea id="header-area" class="top" name="header" rows="<!--{$header_row}-->" wrap="off" style="width: 100%;"><!--{$header_data|smarty:nodefaults}--></textarea> 
    5252    <div class="btn"> 
    53       <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> 
     53      <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> 
    5454    </div> 
    5555 
     
    5757        <ul> 
    5858          <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> 
    59           <li><a class="btn-action" href="javascript:;" name='subm' onclick="fnFormModeSubmit('form_header','confirm','',''); return false;"><span class="btn-next">登録する</span></a></li> 
     59          <li><a class="btn-action" href="javascript:;" name='subm' onclick="fnFormModeSubmit('form_header','regist','',''); return false;"><span class="btn-next">登録する</span></a></li> 
    6060        </ul> 
    6161    </div> 
     
    8585    <textarea id="footer-area" class="top" name="footer" rows="<!--{$footer_row}-->" style="width: 100%;"><!--{$footer_data|smarty:nodefaults}--></textarea> 
    8686    <div class="btn"> 
    87       <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> 
     87      <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> 
    8888    </div> 
    8989 
     
    9191        <ul> 
    9292          <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> 
    93           <li><a class="btn-action" href="javascript:;" name='subm' onclick="fnFormModeSubmit('form_footer','confirm','',''); return false;"><span class="btn-next">登録する</span></a></li> 
     93          <li><a class="btn-action" href="javascript:;" name='subm' onclick="fnFormModeSubmit('form_footer','regist','',''); return false;"><span class="btn-next">登録する</span></a></li> 
    9494        </ul> 
    9595    </div> 
  • branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Header.php

    r20116 r20275  
    7575        SC_Utils_Ex::sfIsSuccess($objSess); 
    7676 
    77         $this->objLayout = new SC_Helper_PageLayout_Ex(); 
    78  
    7977        // 端末種別IDを取得 
    8078        if (isset($_REQUEST['device_type_id']) 
     
    8482            $device_type_id = DEVICE_TYPE_PC; 
    8583        } 
     84        $this->device_type_id = $device_type_id; 
    8685 
    87         $division = isset($_POST['division']) ? $_POST['division'] : ""; 
    88         $pre_DIR = USER_INC_REALDIR . 'preview/'; 
     86        // テンプレートのパス 
     87        $template_path = $this->lfGetTemplatePath($device_type_id); 
     88        $preview_template_path = $this->lfGetPreviewTemplatePath(); 
    8989 
    9090        // データ更新処理 
    91         if ($division != ''){ 
    92             // プレビュー用テンプレートに書き込み 
    93             $fp = fopen($pre_DIR.$division.'.tpl',"w"); // TODO 
    94             fwrite($fp, $_POST[$division]); 
    95             fclose($fp); 
     91        if (isset($_POST['division']) && $_POST['division'] != '') { 
     92            $division = $_POST['division']; 
     93            $content = $_POST[$division]; // TODO no checked? 
     94            // プレビュー用のテンプレートに書き込む 
     95            $preview_template = $preview_template_path.'/'.$division.'.tpl'; 
     96            $this->lfUpdateTemplate($preview_template, $content); 
    9697 
    97             // 登録時はプレビュー用テンプレートをコピーする 
    9898            switch ($this->getMode()) { 
    9999            case 'regist': 
    100                 copy($pre_DIR.$division.".tpl", $this->objLayout->getTemplatePath($device_type_id) . $division . ".tpl"); 
    101                 // 完了メッセージ(プレビュー時は表示しない) 
     100                // 正規のテンプレートに書き込む 
     101                $template = $template_path . '/' . $division . '.tpl'; 
     102                $this->lfUpdateTemplate($template, $content); 
    102103                $this->tpl_onload="alert('登録が完了しました。');"; 
    103  
    104                 // テキストエリアの幅を元に戻す(処理の統一のため) 
    105                 $_POST['header_row'] = ""; 
    106                 $_POST['footer_row'] = ""; 
    107104                break; 
    108105            case 'preview': 
    109106                if ($division == "header") $this->header_prev = "on"; 
    110107                if ($division == "footer") $this->footer_prev = "on"; 
     108                $this->header_row = isset($_POST['header_row']) ? $_POST['header_row'] : $this->header_row; 
     109                $this->footer_row = isset($_POST['footer_row']) ? $_POST['footer_row'] : $this->footer_row; 
    111110                break; 
    112111            default: 
     112                // なにもしない 
    113113                break; 
    114114            } 
    115             // ヘッダーファイルの読み込み(プレビューデータ) 
    116             $header_data = file_get_contents($pre_DIR . "header.tpl"); 
    117  
    118             // フッターファイルの読み込み(プレビューデータ) 
    119             $footer_data = file_get_contents($pre_DIR . "footer.tpl"); 
    120115        }else{ 
    121             // postでデータが渡されなければ新規読み込みと判断をし、プレビュー用データを正規のデータで上書きする 
    122             if (!is_dir($pre_DIR)) { 
    123                 mkdir($pre_DIR); 
    124             } 
    125  
    126             // ユーザーパスにテンプレートが存在しなければ, 
    127             // 指定テンプレートから読み込む 
    128             $header_tpl = $this->objLayout->getTemplatePath($device_type_id) . "header.tpl"; 
    129             $footer_tpl = $this->objLayout->getTemplatePath($device_type_id) . "footer.tpl"; 
    130  
    131             copy($header_tpl, $pre_DIR . "header.tpl"); 
    132             copy($footer_tpl, $pre_DIR . "footer.tpl"); 
    133  
    134             // ヘッダーファイルの読み込み 
    135             $header_data = file_get_contents($header_tpl); 
    136             // フッターファイルの読み込み 
    137             $footer_data = file_get_contents($footer_tpl); 
     116            // postでデータが渡されなければ新規読み込みと判断をし、 
     117            // プレビュー用テンプレートに正規のテンプレートをロードする 
     118            $templates = array( 
     119                'header.tpl', 
     120                'footer.tpl' 
     121            ); 
     122            $this->lfLoadPreviewTemplates($preview_template_path, $template_path, $templates); 
    138123        } 
    139124 
    140125        // テキストエリアに表示 
    141         $this->header_data = $header_data; 
    142         $this->footer_data = $footer_data; 
    143         $this->device_type_id = $device_type_id; 
    144  
    145         if (isset($_POST['header_row']) && $_POST['header_row'] != ''){ 
    146             $this->header_row = $_POST['header_row']; 
    147         } 
    148  
    149         if (isset($_POST['footer_row']) && $_POST['footer_row'] != ''){ 
    150             $this->footer_row = $_POST['footer_row']; 
    151         } 
     126        $this->header_data = file_get_contents($preview_template_path . '/header.tpl'); 
     127        $this->footer_data = file_get_contents($preview_template_path . '/footer.tpl'); 
    152128 
    153129        // ブラウザタイプ 
    154         $this->browser_type = 
    155             isset($_POST['browser_type']) ? $_POST['browser_type'] : ""; 
     130        $this->browser_type = isset($_POST['browser_type']) ? $_POST['browser_type'] : ""; 
     131    } 
     132 
     133    protected function lfLoadPreviewTemplates($preview_template_path, $template_path, $templates) { 
     134        if (!is_dir($preview_template_path)) { 
     135            mkdir($preview_template_path); 
     136        } 
     137        foreach($templates as $template) { 
     138            $source = $template_path . '/' . $template; 
     139            $dest = $preview_template_path . '/' . $template; 
     140            copy($source, $dest); 
     141        } 
     142    } 
     143 
     144    protected function lfUpdateTemplate($template, $content) { 
     145        $fp = fopen($template,"w"); 
     146        fwrite($fp, $content); 
     147        fclose($fp); 
     148    } 
     149 
     150    protected function lfGetTemplatePath($device_type_id) { 
     151        $objLayout = new SC_Helper_PageLayout_Ex(); 
     152        return $objLayout->getTemplatePath($device_type_id); 
     153    } 
     154 
     155    protected function lfGetPreviewTemplatePath() { 
     156        return USER_INC_REALDIR . 'preview'; 
    156157    } 
    157158 
     
    165166    } 
    166167} 
    167 ?> 
Note: See TracChangeset for help on using the changeset viewer.