Ignore:
Timestamp:
2010/12/25 20:58:13 (16 years ago)
Author:
Seasoft
Message:

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

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

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

Location:
branches/version-2_5-dev/data/class/pages/admin/design
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Bloc.php

    r19737 r19768  
    9393 
    9494        $this->objLayout = new SC_Helper_PageLayout_Ex(); 
    95         $package_path = $this->objLayout->getTemplatePath($device_type_id, true); 
     95        $package_path = $this->objLayout->getTemplatePath($device_type_id); 
    9696 
    9797        // ブロック一覧を取得 
    … …  
    103103                                                array($bloc_id, $device_type_id)); 
    104104 
    105             // ユーザー作成ブロックが存在する場合 
    106             if (is_file($package_path . $arrBlocData[0]['tpl_path'])) { 
    107                 $arrBlocData[0]['tpl_path'] = $package_path . $arrBlocData[0]['tpl_path']; 
    108  
    109             // 存在しない場合は指定テンプレートのブロックを取得 
    110             } else { 
    111                 $arrBlocData[0]['tpl_path'] = $this->objLayout->getTemplatePath($device_type_id) . $arrBlocData[0]['tpl_path']; 
    112             } 
     105            $arrBlocData[0]['tpl_path'] = $this->objLayout->getTemplatePath($device_type_id) . $arrBlocData[0]['tpl_path']; 
    113106 
    114107            // テンプレートファイルの読み込み 
  • branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Header.php

    r19737 r19768  
    9797            // 登録時はプレビュー用テンプレートをコピーする 
    9898            if ($_POST['mode'] == 'confirm'){ 
    99                 copy($pre_DIR.$division.".tpl", $this->objLayout->getTemplatePath($device_type_id, true) . $division . ".tpl"); 
     99                copy($pre_DIR.$division.".tpl", $this->objLayout->getTemplatePath($device_type_id) . $division . ".tpl"); 
    100100                // 完了メッセージ(プレビュー時は表示しない) 
    101101                $this->tpl_onload="alert('登録が完了しました。');"; 
    … …  
    122122            // ユーザーパスにテンプレートが存在しなければ, 
    123123            // 指定テンプレートから読み込む 
    124             $header_tpl = $this->objLayout->getTemplatePath($device_type_id, true) . "header.tpl"; 
    125             if (!is_file($header_tpl)) { 
    126                 $header_tpl = $this->objLayout->getTemplatePath($device_type_id) . "header.tpl"; 
    127             } 
    128             $footer_tpl = $this->objLayout->getTemplatePath($device_type_id, true) . "footer.tpl"; 
    129             if (!is_file($footer_tpl)) { 
    130                 $footer_tpl = $this->objLayout->getTemplatePath($device_type_id) . "footer.tpl"; 
    131             } 
     124            $header_tpl = $this->objLayout->getTemplatePath($device_type_id) . "header.tpl"; 
     125            $footer_tpl = $this->objLayout->getTemplatePath($device_type_id) . "footer.tpl"; 
    132126 
    133127            copy($header_tpl, $pre_DIR . "header.tpl"); 
  • branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_MainEdit.php

    r19737 r19768  
    157157        } 
    158158 
    159         // FIXME 
    160         // テンプレートファイルが存在していれば読み込む 
    161         $templatePath = $this->objLayout->getTemplatePath($device_type_id, true); 
    162         $tpl_file =  $templatePath . $arrPageData[0]['filename'] . ".tpl"; 
    163  
    164         if (file_exists($tpl_file)){ 
    165             $arrPageData[0]['tpl_data'] = file_get_contents($tpl_file); 
    166         // 存在してなければ, 指定されたテンプレートのファイルを読み込む 
    167         } else { 
    168             $templatePath = $this->objLayout->getTemplatePath($device_type_id); 
    169             $arrPageData[0]['tpl_data'] = file_get_contents($templatePath . $arrPageData[0]['filename'] . ".tpl"); 
    170         } 
     159        // テンプレートを読み込む 
     160        $templatePath = $this->objLayout->getTemplatePath($device_type_id); 
     161        $arrPageData[0]['tpl_data'] = file_get_contents($templatePath . $arrPageData[0]['filename'] . ".tpl"); 
    171162 
    172163        // チェックボックスの値変更 
    … …  
    183174     * プレビュー画面を表示する. 
    184175     * 
    185      * FIXME 
    186      * 
    187      * @param integer $page_id ページID 
     176     * @param integer $page_id_old 元のページID 
    188177     * @param integer $device_type_id 端末種別ID 
    189178     * @return void 
    190179     */ 
    191     function lfPreviewPageData($page_id, $device_type_id) { 
    192  
    193         $page_id_old = $page_id; 
     180    function lfPreviewPageData($page_id_old, $device_type_id) { 
     181 
    194182        // プレビューの場合ページIDを0にセットする。 
    195         $page_id = "0"; 
    196         $url = basename($_POST['url']); 
    197          
     183        $page_id = '0'; 
     184        $url = 'preview'; 
     185 
    198186        $tmpPost = $_POST; 
    199187        $tmpPost['page_id'] = $page_id; 
    200188        $tmpPost['url'] = $url; 
    201189        $tmpPost['tpl_dir'] = USER_PATH . "templates/preview/"; 
    202          
     190 
    203191        $arrPreData = $this->objLayout->lfGetPageData("page_id = ? AND device_type_id = ?", 
    204192                                                      array($page_id, $device_type_id)); 
    205          
    206         // tplファイルの削除 (XXX: 処理の意図が不明。存在していると都合が悪いファイル?) 
    207         $del_tpl = USER_PATH . "templates/" . $arrPreData[0]['filename'] . '.tpl'; 
    208         if (file_exists($del_tpl)){ 
    209             unlink($del_tpl); 
    210         } 
    211193 
    212194        // DBへデータを更新する 
    213         $this->lfEntryPageData($tmpPost); 
     195        $this->lfEntryPageData($tmpPost, $device_type_id); 
    214196 
    215197        // TPLファイル作成 
    216         $preview_tpl = USER_PATH . "templates/preview/" . TEMPLATE_NAME . "/" . $url . '.tpl'; 
    217         $this->lfCreateFile($preview_tpl, $_POST['tpl_data']); 
     198        $cre_tpl = $this->objLayout->getTemplatePath($device_type_id) . $url . '.tpl'; 
     199        $this->lfCreateFile($cre_tpl, $_POST['tpl_data']); 
    218200         
    219201        // blocposition を削除 
    220202        $objQuery = new SC_Query();     // DB操作オブジェクト 
    221         $sql = 'delete from dtb_blocposition where page_id = 0'; 
    222         $ret = $objQuery->query($sql); 
     203        $ret = $objQuery->delete('dtb_blocposition', 'page_id = 0 AND device_type_id = ?', array($device_type_id)); 
    223204 
    224205        if ($page_id_old != "") { 
    225206            // 登録データを取得 
    226             $sql = "SELECT 0, target_id, bloc_id, bloc_row FROM dtb_blocposition WHERE page_id = ?"; 
    227             $ret = $objQuery->getAll($sql,array($page_id_old)); 
    228  
    229             if (count($ret) > 0) { 
    230  
    231                 // blocposition を複製 
    232                 $sql = " insert into dtb_blocposition ("; 
    233                 $sql .= "     page_id,"; 
    234                 $sql .= "     target_id,"; 
    235                 $sql .= "     bloc_id,"; 
    236                 $sql .= "     bloc_row"; 
    237                 $sql .= "     )values(?, ?, ?, ?)"; 
    238  
    239                 // 取得件数文INSERT実行 
    240                 foreach($ret as $key => $val){ 
    241                     $ret = $objQuery->query($sql,$val); 
    242                 } 
     207            $sql = 'SELECT target_id, bloc_id, bloc_row FROM dtb_blocposition WHERE page_id = ? AND device_type_id = ?'; 
     208            $ret = $objQuery->getAll($sql, array($page_id_old, $device_type_id)); 
     209 
     210            // blocposition を複製 
     211            foreach($ret as $row){ 
     212                $row['page_id'] = $page_id; 
     213                $row['device_type_id'] = $device_type_id; 
     214                $objQuery->insert('dtb_blocposition', $row); 
    243215            } 
    244216        } 
    245217        $_SESSION['preview'] = "ON"; 
    246218        $this->objDisplay->redirect($this->getLocation(URL_DIR . "preview/" . DIR_INDEX_URL, array("filename" => $arrPageData[0]["filename"]))); 
    247  
    248219    } 
    249220 
    … …  
    271242 
    272243            // TPLファイル作成 
    273             $cre_tpl = $this->objLayout->getTemplatePath($device_type_id, true) . basename($_POST['url']) . '.tpl'; 
     244            $cre_tpl = $this->objLayout->getTemplatePath($device_type_id) . basename($_POST['url']) . '.tpl'; 
    274245            $this->lfCreateFile($cre_tpl, $_POST['tpl_data']); 
    275246 
    … …  
    351322                $arrUpdData['php_dir'] .= '/'; 
    352323            } 
    353             $arrUpdData['tpl_dir']      = substr($this->objLayout->getTemplatePath($devie_type_id, true), strlen(URL_DIR)); 
     324            $arrUpdData['tpl_dir']      = substr($this->objLayout->getTemplatePath($devie_type_id), strlen(URL_DIR)); 
    354325            $arrUpdData['filename']     = basename($arrData['url']); // 拡張子を付加しない 
    355326        } 
    … …  
    436407        // ファイル作成 
    437408        $fp = fopen($path,"w"); 
    438         fwrite($fp, $data); // FIXME いきなり POST はちょっと... 
     409        if ($fp === false) { 
     410            SC_Utils_Ex::sfDispException(); 
     411        } 
     412        $ret = fwrite($fp, $data); 
     413        if ($ret === false) { 
     414            SC_Utils_Ex::sfDispException(); 
     415        } 
    439416        fclose($fp); 
    440417    } 
Note: See TracChangeset for help on using the changeset viewer.