[Svn-src-all:881] [version-2_5-dev 19768] #748(モバイル/スマートフォンのデザイン管理)

Seasoft admin @ mail.ec-cube.net
2010年 12月 25日 (土) 20:58:13 JST


Subversion committed to /home/svn/open 19768
http://svn.ec-cube.net/open_trac/changeset/19768
┌────────────────────────────┐
│更新者 :  Seasoft                                      │
│更新日時:  2010-12-25 20:58:13 +0900 (土, 25 12月 2010)│
└────────────────────────────┘

Log:
--------------------------------------------------------
#748(モバイル/スマートフォンのデザイン管理)
  * プレビュー周り(荒削りです)
#874(テンプレートは /data/ 配下のみ保存する)

Changed:                      [U:修正,A:追加,D:削除]
--------------------------------------------------------
U   branches/version-2_5-dev/data/class/SC_View.php
U   branches/version-2_5-dev/data/class/helper/SC_Helper_PageLayout.php
U   branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Bloc.php
U   branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Header.php
U   branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_MainEdit.php
U   branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php

変更: branches/version-2_5-dev/data/class/SC_View.php
===================================================================
--- branches/version-2_5-dev/data/class/SC_View.php	2010-12-25 10:02:43 UTC (rev 19767)
+++ branches/version-2_5-dev/data/class/SC_View.php	2010-12-25 11:58:13 UTC (rev 19768)
@@ -181,19 +181,10 @@
         $this->assign("TPL_DIR", SC_Helper_PageLayout_Ex::getUserDir($device_type_id, true));
 
         // ヘッダとフッタを割り当て
-        $templatePath = SC_Helper_PageLayout_Ex::getTemplatePath($device_type_id, true);
+        $templatePath = SC_Helper_PageLayout_Ex::getTemplatePath($device_type_id);
         $header_tpl = $templatePath . "header.tpl";
         $footer_tpl = $templatePath . "footer.tpl";
 
-        // ユーザー作成のテンプレートが無ければ, 指定テンプレートを割り当て
-        $templatePath = SC_Helper_PageLayout_Ex::getTemplatePath($device_type_id);
-        if (!$this->_smarty->template_exists($header_tpl)) {
-            $header_tpl = $templatePath . "header.tpl";
-        }
-        if (!$this->_smarty->template_exists($footer_tpl)) {
-            $footer_tpl = $templatePath . "footer.tpl";
-        }
-
         $this->assign("header_tpl", $header_tpl);
         $this->assign("footer_tpl", $footer_tpl);
     }

変更: branches/version-2_5-dev/data/class/helper/SC_Helper_PageLayout.php
===================================================================
--- branches/version-2_5-dev/data/class/helper/SC_Helper_PageLayout.php	2010-12-25 10:02:43 UTC (rev 19767)
+++ branches/version-2_5-dev/data/class/helper/SC_Helper_PageLayout.php	2010-12-25 11:58:13 UTC (rev 19768)
@@ -57,26 +57,14 @@
         } else {
             // TODO
             $arrPageData = $this->lfGetPageData("device_type_id = ? AND page_id = 0", array($device_type_id));
-            $objPage->tpl_mainpage = $this->getTemplatePath($device_type_id, true) 
+            $objPage->tpl_mainpage = $this->getTemplatePath($device_type_id) 
                 . "preview/" . $arrPageData[0]['filename'] . ".tpl";
         }
 
         $arrPageLayout = $arrPageData[0];
 
-        // ユーザテンプレートのパスを取得
-        $user_tpl =  $this->getTemplatePath($device_type_id, true)
-            . $arrPageLayout['filename'] . ".tpl";
+        $objPage->tpl_mainpage = $this->getTemplatePath($device_type_id) . $arrPageLayout['filename'] . ".tpl";
 
-        // ユーザテンプレートの存在チェック
-        if (is_file($user_tpl)) {
-            $objPage->tpl_mainpage = $user_tpl;
-        }
-        // 存在しない場合は指定テンプレートを使用
-        else {
-            $objPage->tpl_mainpage = $this->getTemplatePath($device_type_id)
-                . $arrPageLayout['filename'] . ".tpl";
-        }
-
         // ページタイトルを設定
         if (!isset($objPage->tpl_title)) {
             $objPage->tpl_title = $arrPageLayout['page_name'];
@@ -150,12 +138,7 @@
                     if ($val['php_path'] != '') {
                         $arrNavi[$key]['php_path'] = HTML_PATH . $val['php_path'];
                     } else {
-                        $user_block_path = $this->getTemplatePath($device_type_id, true) .  "/" . $val['tpl_path'];
-                        if (is_file($user_block_path)) {
-                            $arrNavi[$key]['tpl_path'] = $user_block_path;
-                        } else {
-                            $arrNavi[$key]['tpl_path'] = $this->getTemplatePath($device_type_id) . $val['tpl_path'];
-                        }
+                        $arrNavi[$key]['tpl_path'] = $this->getTemplatePath($device_type_id) . $val['tpl_path'];
                     }
                     // phpから呼び出されるか、tplファイルが存在する場合
                     if ($val['php_path'] != '' || is_file($arrNavi[$key]['tpl_path'])) {

変更: branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Bloc.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Bloc.php	2010-12-25 10:02:43 UTC (rev 19767)
+++ branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Bloc.php	2010-12-25 11:58:13 UTC (rev 19768)
@@ -92,7 +92,7 @@
         }
 
         $this->objLayout = new SC_Helper_PageLayout_Ex();
-        $package_path = $this->objLayout->getTemplatePath($device_type_id, true);
+        $package_path = $this->objLayout->getTemplatePath($device_type_id);
 
         // ブロック一覧を取得
         $this->arrBlocList = $this->lfgetBlocData("device_type_id = ?", array($device_type_id));
@@ -102,15 +102,8 @@
             $arrBlocData = $this->lfGetBlocData("bloc_id = ? AND device_type_id = ?",
                                                 array($bloc_id, $device_type_id));
 
-            // ユーザー作成ブロックが存在する場合
-            if (is_file($package_path . $arrBlocData[0]['tpl_path'])) {
-                $arrBlocData[0]['tpl_path'] = $package_path . $arrBlocData[0]['tpl_path'];
+            $arrBlocData[0]['tpl_path'] = $this->objLayout->getTemplatePath($device_type_id) . $arrBlocData[0]['tpl_path'];
 
-            // 存在しない場合は指定テンプレートのブロックを取得
-            } else {
-                $arrBlocData[0]['tpl_path'] = $this->objLayout->getTemplatePath($device_type_id) . $arrBlocData[0]['tpl_path'];
-            }
-
             // テンプレートファイルの読み込み
             $arrBlocData[0]['tpl_data'] = file_get_contents($arrBlocData[0]['tpl_path']);
             $this->arrBlocData = $arrBlocData[0];

変更: 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	2010-12-25 10:02:43 UTC (rev 19767)
+++ branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Header.php	2010-12-25 11:58:13 UTC (rev 19768)
@@ -96,7 +96,7 @@
 
             // 登録時はプレビュー用テンプレートをコピーする
             if ($_POST['mode'] == 'confirm'){
-                copy($pre_DIR.$division.".tpl", $this->objLayout->getTemplatePath($device_type_id, true) . $division . ".tpl");
+                copy($pre_DIR.$division.".tpl", $this->objLayout->getTemplatePath($device_type_id) . $division . ".tpl");
                 // 完了メッセージ(プレビュー時は表示しない)
                 $this->tpl_onload="alert('登録が完了しました。');";
 
@@ -121,14 +121,8 @@
 
             // ユーザーパスにテンプレートが存在しなければ,
             // 指定テンプレートから読み込む
-            $header_tpl = $this->objLayout->getTemplatePath($device_type_id, true) . "header.tpl";
-            if (!is_file($header_tpl)) {
-                $header_tpl = $this->objLayout->getTemplatePath($device_type_id) . "header.tpl";
-            }
-            $footer_tpl = $this->objLayout->getTemplatePath($device_type_id, true) . "footer.tpl";
-            if (!is_file($footer_tpl)) {
-                $footer_tpl = $this->objLayout->getTemplatePath($device_type_id) . "footer.tpl";
-            }
+            $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");

変更: branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_MainEdit.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_MainEdit.php	2010-12-25 10:02:43 UTC (rev 19767)
+++ branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_MainEdit.php	2010-12-25 11:58:13 UTC (rev 19768)
@@ -156,19 +156,10 @@
             exit;
         }
 
-        // FIXME
-        // テンプレートファイルが存在していれば読み込む
-        $templatePath = $this->objLayout->getTemplatePath($device_type_id, true);
-        $tpl_file =  $templatePath . $arrPageData[0]['filename'] . ".tpl";
+        // テンプレートを読み込む
+        $templatePath = $this->objLayout->getTemplatePath($device_type_id);
+        $arrPageData[0]['tpl_data'] = file_get_contents($templatePath . $arrPageData[0]['filename'] . ".tpl");
 
-        if (file_exists($tpl_file)){
-            $arrPageData[0]['tpl_data'] = file_get_contents($tpl_file);
-        // 存在してなければ, 指定されたテンプレートのファイルを読み込む
-        } else {
-            $templatePath = $this->objLayout->getTemplatePath($device_type_id);
-            $arrPageData[0]['tpl_data'] = file_get_contents($templatePath . $arrPageData[0]['filename'] . ".tpl");
-        }
-
         // チェックボックスの値変更
         $arrPageData[0]['header_chk'] = SC_Utils_Ex::sfChangeCheckBox($arrPageData[0]['header_chk'], true);
         $arrPageData[0]['footer_chk'] = SC_Utils_Ex::sfChangeCheckBox($arrPageData[0]['footer_chk'], true);
@@ -182,69 +173,49 @@
     /**
      * プレビュー画面を表示する.
      *
-     * FIXME
-     *
-     * @param integer $page_id ページID
+     * @param integer $page_id_old 元のページID
      * @param integer $device_type_id 端末種別ID
      * @return void
      */
-    function lfPreviewPageData($page_id, $device_type_id) {
+    function lfPreviewPageData($page_id_old, $device_type_id) {
 
-        $page_id_old = $page_id;
         // プレビューの場合ページIDを0にセットする。
-        $page_id = "0";
-        $url = basename($_POST['url']);
-        
+        $page_id = '0';
+        $url = 'preview';
+
         $tmpPost = $_POST;
         $tmpPost['page_id'] = $page_id;
         $tmpPost['url'] = $url;
         $tmpPost['tpl_dir'] = USER_PATH . "templates/preview/";
-        
+
         $arrPreData = $this->objLayout->lfGetPageData("page_id = ? AND device_type_id = ?",
                                                       array($page_id, $device_type_id));
-        
-        // tplファイルの削除 (XXX: 処理の意図が不明。存在していると都合が悪いファイル?)
-        $del_tpl = USER_PATH . "templates/" . $arrPreData[0]['filename'] . '.tpl';
-        if (file_exists($del_tpl)){
-            unlink($del_tpl);
-        }
 
         // DBへデータを更新する
-        $this->lfEntryPageData($tmpPost);
+        $this->lfEntryPageData($tmpPost, $device_type_id);
 
         // TPLファイル作成
-        $preview_tpl = USER_PATH . "templates/preview/" . TEMPLATE_NAME . "/" . $url . '.tpl';
-        $this->lfCreateFile($preview_tpl, $_POST['tpl_data']);
+        $cre_tpl = $this->objLayout->getTemplatePath($device_type_id) . $url . '.tpl';
+        $this->lfCreateFile($cre_tpl, $_POST['tpl_data']);
         
         // blocposition を削除
         $objQuery = new SC_Query();		// DB操作オブジェクト
-        $sql = 'delete from dtb_blocposition where page_id = 0';
-        $ret = $objQuery->query($sql);
+        $ret = $objQuery->delete('dtb_blocposition', 'page_id = 0 AND device_type_id = ?', array($device_type_id));
 
         if ($page_id_old != "") {
             // 登録データを取得
-            $sql = "SELECT 0, target_id, bloc_id, bloc_row FROM dtb_blocposition WHERE page_id = ?";
-            $ret = $objQuery->getAll($sql,array($page_id_old));
+            $sql = 'SELECT target_id, bloc_id, bloc_row FROM dtb_blocposition WHERE page_id = ? AND device_type_id = ?';
+            $ret = $objQuery->getAll($sql, array($page_id_old, $device_type_id));
 
-            if (count($ret) > 0) {
-
-                // blocposition を複製
-                $sql = " insert into dtb_blocposition (";
-                $sql .= "     page_id,";
-                $sql .= "     target_id,";
-                $sql .= "     bloc_id,";
-                $sql .= "     bloc_row";
-                $sql .= "     )values(?, ?, ?, ?)";
-
-                // 取得件数文INSERT実行
-                foreach($ret as $key => $val){
-                    $ret = $objQuery->query($sql,$val);
-                }
+            // blocposition を複製
+            foreach($ret as $row){
+                $row['page_id'] = $page_id;
+                $row['device_type_id'] = $device_type_id;
+                $objQuery->insert('dtb_blocposition', $row);
             }
         }
         $_SESSION['preview'] = "ON";
         $this->objDisplay->redirect($this->getLocation(URL_DIR . "preview/" . DIR_INDEX_URL, array("filename" => $arrPageData[0]["filename"])));
-
     }
 
     /**
@@ -270,7 +241,7 @@
             }
 
             // TPLファイル作成
-            $cre_tpl = $this->objLayout->getTemplatePath($device_type_id, true) . basename($_POST['url']) . '.tpl';
+            $cre_tpl = $this->objLayout->getTemplatePath($device_type_id) . basename($_POST['url']) . '.tpl';
             $this->lfCreateFile($cre_tpl, $_POST['tpl_data']);
 
             $this->objDisplay->redirect($this->getLocation("./main_edit.php",
@@ -350,7 +321,7 @@
             } else {
                 $arrUpdData['php_dir'] .= '/';
             }
-            $arrUpdData['tpl_dir']      = substr($this->objLayout->getTemplatePath($devie_type_id, true), strlen(URL_DIR));
+            $arrUpdData['tpl_dir']      = substr($this->objLayout->getTemplatePath($devie_type_id), strlen(URL_DIR));
             $arrUpdData['filename']     = basename($arrData['url']); // 拡張子を付加しない
         }
 
@@ -435,7 +406,13 @@
 
         // ファイル作成
         $fp = fopen($path,"w");
-        fwrite($fp, $data); // FIXME いきなり POST はちょっと...
+        if ($fp === false) {
+            SC_Utils_Ex::sfDispException();
+        }
+        $ret = fwrite($fp, $data);
+        if ($ret === false) {
+            SC_Utils_Ex::sfDispException();
+        }
         fclose($fp);
     }
 

変更: branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php	2010-12-25 10:02:43 UTC (rev 19767)
+++ branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php	2010-12-25 11:58:13 UTC (rev 19768)
@@ -59,12 +59,7 @@
         if (substr($bloc_file, 0, 1) == '/') {
             $this->tpl_mainpage = $bloc_file;
         } else {
-            $user_bloc_path = SC_Helper_PageLayout_Ex::getTemplatePath($this->objDisplay->detectDevice(), true) . BLOC_DIR . $bloc_file;
-            if (is_file($user_bloc_path)) {
-                $this->tpl_mainpage = $user_bloc_path;
-            } else {
-                $this->tpl_mainpage = SC_Helper_PageLayout_Ex::getTemplatePath($this->objDisplay->detectDevice()) . BLOC_DIR . $bloc_file;
-            }
+            $this->tpl_mainpage = SC_Helper_PageLayout_Ex::getTemplatePath($this->objDisplay->detectDevice()) . BLOC_DIR . $bloc_file;
         }
 
         $this->setTemplate($this->tpl_mainpage);




Svn-src-all メーリングリストの案内