Index: branches/version-2_5-dev/data/Smarty/templates/admin/design/main_edit.tpl
===================================================================
--- branches/version-2_5-dev/data/Smarty/templates/admin/design/main_edit.tpl	(revision 19719)
+++ branches/version-2_5-dev/data/Smarty/templates/admin/design/main_edit.tpl	(revision 19722)
@@ -48,4 +48,5 @@
 <input type="hidden" name="mode" value="" />
 <input type="hidden" name="page_id" value="<!--{$page_id}-->" />
+<input type="hidden" name="device_type_id" value="<!--{$device_type_id|escape}-->" />
 
   <!--{if $arrErr.page_id_err != ""}-->
Index: branches/version-2_5-dev/data/Smarty/templates/admin/design/template.tpl
===================================================================
--- branches/version-2_5-dev/data/Smarty/templates/admin/design/template.tpl	(revision 19715)
+++ branches/version-2_5-dev/data/Smarty/templates/admin/design/template.tpl	(revision 19722)
@@ -39,4 +39,5 @@
 <input type="hidden" name="template_code_temp" value="" />
 <input type="hidden" name="uniqid" value="<!--{$uniqid}-->" />
+<input type="hidden" name="device_type_id" value="<!--{$device_type_id|escape}-->" />
 <div id="design" class="contents-main">
   <p style="margin-bottom: 20px">
Index: branches/version-2_5-dev/data/Smarty/templates/admin/design/up_down.tpl
===================================================================
--- branches/version-2_5-dev/data/Smarty/templates/admin/design/up_down.tpl	(revision 19715)
+++ branches/version-2_5-dev/data/Smarty/templates/admin/design/up_down.tpl	(revision 19722)
@@ -38,4 +38,5 @@
 <input type="hidden" name="mode" value="" />
 <input type="hidden" name="uniqid" value="<!--{$uniqid}-->" />
+<input type="hidden" name="device_type_id" value="<!--{$device_type_id|escape}-->" />
 <div id="disign" class="contents-main">
   <p class="remark">
Index: branches/version-2_5-dev/data/Smarty/templates/admin/design/bloc.tpl
===================================================================
--- branches/version-2_5-dev/data/Smarty/templates/admin/design/bloc.tpl	(revision 19719)
+++ branches/version-2_5-dev/data/Smarty/templates/admin/design/bloc.tpl	(revision 19722)
@@ -25,4 +25,6 @@
 <input type="hidden" name="mode" value="" />
 <input type="hidden" name="bloc_id" value="<!--{$bloc_id}-->" />
+<input type="hidden" name="device_type_id" value="<!--{$device_type_id|escape}-->" />
+
   <!--{* ▼ブロック設定ここから *}-->
 
Index: branches/version-2_5-dev/data/Smarty/templates/admin/design/index.tpl
===================================================================
--- branches/version-2_5-dev/data/Smarty/templates/admin/design/index.tpl	(revision 19715)
+++ branches/version-2_5-dev/data/Smarty/templates/admin/design/index.tpl	(revision 19722)
@@ -21,4 +21,6 @@
 <input type="hidden" name="page_id" value="<!--{$page_id}-->" />
 <input type="hidden" name="bloc_cnt" value="<!--{$bloc_cnt}-->" />
+<input type="hidden" name="device_type_id" value="<!--{$device_type_id|escape}-->" />
+
 <div id="design" class="contents-main">
     <!--{* ▼レイアウトここから *}-->
Index: branches/version-2_5-dev/data/Smarty/templates/admin/design/css.tpl
===================================================================
--- branches/version-2_5-dev/data/Smarty/templates/admin/design/css.tpl	(revision 19719)
+++ branches/version-2_5-dev/data/Smarty/templates/admin/design/css.tpl	(revision 19722)
@@ -26,4 +26,5 @@
 <input type="hidden" name="area_row" value="<!--{$area_row}-->" />
 <input type="hidden" name="old_css_name" value="<!--{$old_css_name}-->" />
+<input type="hidden" name="device_type_id" value="<!--{$device_type_id|escape}-->" />
 <div id="design" class="contents-main">
 
Index: branches/version-2_5-dev/data/Smarty/templates/admin/design/header.tpl
===================================================================
--- branches/version-2_5-dev/data/Smarty/templates/admin/design/header.tpl	(revision 19719)
+++ branches/version-2_5-dev/data/Smarty/templates/admin/design/header.tpl	(revision 19722)
@@ -47,4 +47,6 @@
   <input type="hidden" name="header_row" value="<!--{$header_row}-->" />
   <input type="hidden" name="browser_type" value="" />
+  <input type="hidden" name="device_type_id" value="<!--{$device_type_id|escape}-->" />
+
     <textarea name="header" rows="<!--{$header_row}-->" wrap="off" style="width: 100%;"><!--{$header_data|smarty:nodefaults}--></textarea>
     <div class="btn">
@@ -75,4 +77,6 @@
   <input type="hidden" name="footer_row" value=<!--{$footer_row}--> />
   <input type="hidden" name="browser_type" value="" />
+  <input type="hidden" name="device_type_id" value="<!--{$device_type_id|escape}-->" />
+
     <textarea name="footer" rows="<!--{$footer_row}-->" style="width: 100%;"><!--{$footer_data|smarty:nodefaults}--></textarea>
     <div class="btn">
Index: branches/version-2_5-dev/data/class/helper/SC_Helper_PageLayout.php
===================================================================
--- branches/version-2_5-dev/data/class/helper/SC_Helper_PageLayout.php	(revision 19713)
+++ branches/version-2_5-dev/data/class/helper/SC_Helper_PageLayout.php	(revision 19722)
@@ -64,19 +64,16 @@
         $arrPageLayout = $arrPageData[0];
 
-        // tpl_mainpageの設定なし、又はトップページの場合
-        if (!isset($objPage->tpl_mainpage) || $url == "index.php") {
-            // ユーザテンプレートのパスを取得
-            $user_tpl =  $this->getTemplatePath($device_type_id, true)
+        // ユーザテンプレートのパスを取得
+        $user_tpl =  $this->getTemplatePath($device_type_id, true)
+            . $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 (is_file($user_tpl)) {
-                $objPage->tpl_mainpage = $user_tpl;
-            }
-            // 存在しない場合は指定テンプレートを使用
-            else {
-                $objPage->tpl_mainpage = $this->getTemplatePath($device_type_id)
-                    . $arrPageLayout['filename'] . ".tpl";
-            }
         }
 
@@ -268,4 +265,5 @@
         case DEVICE_TYPE_MOBILE:
             $dir = MOBILE_TEMPLATE_DIR;
+            $userPath = HTML_PATH . MOBILE_DIR . USER_DIR;
             $templateName = MOBILE_TEMPLATE_NAME;
             break;
@@ -273,4 +271,5 @@
         case DEVICE_TYPE_SMARTPHONE:
             $dir = SMARTPHONE_TEMPLATE_DIR;
+            $userPath = HTML_PATH . SMARTPHONE_DIR . USER_DIR;
             $templateName = SMARTPHONE_TEMPLATE_NAME;
             break;
@@ -279,10 +278,57 @@
         default:
             $dir = TEMPLATE_DIR;
+            $userPath = USER_PATH;
             $templateName = TEMPLATE_NAME;
         }
         if ($isUser) {
-            $dir = USER_TEMPLATE_DIR . $templateName . "/";
+            $dir = $userPath . USER_PACKAGE_DIR . $templateName . "/";
         }
         return $dir;
+    }
+
+    /**
+     * user_data の絶対パスを返す.
+     *
+     * @param integer $device_type_id 端末種別ID
+     * @return string 端末に応じた user_data の絶対パス
+     */
+    function getUserPath($device_type_id = DEVICE_TYPE_PC) {
+        switch ($device_type_id) {
+        case DEVICE_TYPE_MOBILE:
+            return HTML_PATH . MOBILE_DIR . USER_DIR;
+            break;
+
+        case DEVICE_TYPE_SMARTPHONE:
+            return HTML_PATH . SMARTPHONE_DIR . USER_DIR;
+            break;
+
+        case DEVICE_TYPE_PC:
+        default:
+        }
+        return USER_PATH;
+    }
+
+    /**
+     * DocumentRoot から user_data のパスを取得する.
+     *
+     * @param integer $device_type_id 端末種別ID
+     * @return string 端末に応じた DocumentRoot から user_data までのパス
+     */
+    function getUserDir($device_type_id = DEVICE_TYPE_PC) {
+        switch ($device_type_id) {
+        case DEVICE_TYPE_MOBILE:
+            $userDir = URL_DIR . MOBILE_DIR . USER_DIR;
+            $templateName = MOBILE_TEMPLATE_NAME;
+            break;
+
+        case DEVICE_TYPE_SMARTPHONE:
+            $userDir = URL_DIR . SMARTPHONE_DIR . USER_DIR;
+            break;
+
+        case DEVICE_TYPE_PC:
+        default:
+            $userDir = URL_DIR . USER_DIR;
+        }
+        return $userDir;
     }
 }
Index: branches/version-2_5-dev/data/class/pages/LC_Page_Index.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/LC_Page_Index.php	(revision 19713)
+++ branches/version-2_5-dev/data/class/pages/LC_Page_Index.php	(revision 19722)
@@ -44,6 +44,4 @@
     function init() {
         parent::init();
-        $this->tpl_mainpage = 'top.tpl';
-        $this->tpl_column_num = 3;
     }
 
Index: branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_CSS.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_CSS.php	(revision 19715)
+++ branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_CSS.php	(revision 19722)
@@ -125,4 +125,5 @@
         // ファイルリストを取得
         $this->arrCSSList = $this->lfGetCSSList($css_dir);
+        $this->device_type_id = $device_type_id;
     }
 
Index: 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	(revision 19715)
+++ branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Header.php	(revision 19722)
@@ -133,4 +133,5 @@
         $this->header_data = $header_data;
         $this->footer_data = $footer_data;
+        $this->device_type_id = $device_type_id;
 
         if (isset($_POST['header_row']) && $_POST['header_row'] != ''){
Index: 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	(revision 19715)
+++ branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_MainEdit.php	(revision 19722)
@@ -94,5 +94,5 @@
 
         // ページ一覧を取得
-        $this->arrPageList = $this->objLayout->lfgetPageData("page_id <> 0 AND device_type_id = ?",
+        $this->arrPageList = $this->objLayout->lfGetPageData("page_id <> 0 AND device_type_id = ?",
                                                              array($device_type_id));
 
@@ -104,5 +104,5 @@
         // page_id が指定されている場合にはテンプレートデータの取得
         if (is_numeric($page_id) and $page_id != '') {
-            $this->lfGetPageData($page_id, $device_type_id, $objView);
+            $this->arrPageData = $this->lfGetPageData($page_id, $device_type_id, $objView);
         }
 
@@ -111,11 +111,11 @@
         switch ($_POST['mode']) {
             case 'preview':
-                $this->lfPreviewPageData($page_id);
+                $this->lfPreviewPageData($page_id, $device_type_id);
                 exit;
                 break;
 
         case 'delete':
-            if (!$this->objLayout->lfCheckBaseData($page_id)) {
-                $this->lfDeletePageData($page_id);
+            if (!$this->objLayout->lfCheckBaseData($page_id, $device_type_id)) {
+                $this->lfDeletePageData($page_id, $device_type_id);
                 exit;
             }
@@ -123,7 +123,8 @@
 
         case 'confirm':
-            $this->lfConfirmPageData($page_id);
+            $this->lfConfirmPageData($page_id, $device_type_id);
         default:
         }
+        $this->device_type_id = $device_type_id;
     }
 
@@ -148,4 +149,5 @@
         $arrPageData = $this->objLayout->lfGetPageData("page_id = ? AND device_type_id = ?",
                                                        array($page_id, $device_type_id));
+        
 
         if (strlen($arrPageData[0]['filename']) == 0) {
@@ -159,10 +161,13 @@
         // FIXME
         // テンプレートファイルが存在していれば読み込む
-        $tpl_file =  USER_TEMPLATE_PATH . "/" . TEMPLATE_NAME . "/" . $arrPageData[0]['filename'] . ".tpl";
+        $templatePath = $this->objLayout->getTemplatePath($device_type_id, true);
+        $tpl_file =  $templatePath . $arrPageData[0]['filename'] . ".tpl";
+        $this->p($tpl_file);
         if (file_exists($tpl_file)){
             $arrPageData[0]['tpl_data'] = file_get_contents($tpl_file);
         // 存在してなければ, 指定されたテンプレートのファイルを読み込む
         } else {
-            $arrPageData[0]['tpl_data'] = file_get_contents(TEMPLATE_DIR . $arrPageData[0]['filename'] . ".tpl");
+            $templatePath = $this->objLayout->getTemplatePath($device_type_id);
+            $arrPageData[0]['tpl_data'] = file_get_contents($templatePath . $arrPageData[0]['filename'] . ".tpl");
         }
 
@@ -174,9 +179,11 @@
         $arrPageData[0]['directory'] = str_replace(USER_DIR, '', $arrPageData[0]['php_dir']);
 
-        $this->arrPageData = $arrPageData[0];
+        return $arrPageData[0];
     }
 
     /**
      * プレビュー画面を表示する.
+     *
+     * FIXME
      *
      * @param integer $page_id ページID
@@ -257,17 +264,18 @@
         if (count($this->arrErr) == 0) {
             // DBへデータを更新する
-            $this->lfEntryPageData($_POST);
+            $page_id = $this->lfEntryPageData($_POST, $device_type_id);
 
             // ベースデータでなければファイルを削除し、PHPファイルを作成する
             if (!$this->objLayout->lfCheckBaseData($page_id, $device_type_id)) {
                 // PHPファイル作成
-                $this->lfCreatePHPFile($_POST['url']);
+                $this->lfCreatePHPFile($_POST['url'], $device_type_id);
             }
 
             // FIXME
             // TPLファイル作成
-            $cre_tpl = USER_TEMPLATE_PATH . "/" . TEMPLATE_NAME . "/" . basename($_POST['url']) . '.tpl';
+            $cre_tpl = $this->objLayout->getTemplatePath($device_type_id, true) . basename($_POST['url']) . '.tpl';
             $this->lfCreateFile($cre_tpl, $_POST['tpl_data']);
 
+            /*
             // 新規作成の場合、
             if ($page_id == '') {
@@ -276,4 +284,5 @@
                 $page_id = $arrPageData[0]['page_id'];
             }
+            */
             $this->objDisplay->redirect($this->getLocation("./main_edit.php",
                                     array("page_id" => $page_id,
@@ -302,9 +311,9 @@
 
         // 更新データの変換
-        $sqlval = $this->lfGetUpdData($arrData);
+        $sqlval = $this->lfGetUpdData($arrData, $device_type_id);
 
         // データが存在しているかチェックを行う
         if($arrData['page_id'] !== ''){
-            $arrChk = $this->objLayout->lfgetPageData("page_id = ? AND device_type_id = ?",
+            $arrChk = $this->objLayout->lfGetPageData("page_id = ? AND device_type_id = ?",
                                                       array($arrData['page_id'], $device_type_id));
         }
@@ -317,4 +326,5 @@
             $sqlval['create_date'] = 'now()';
             $objQuery->insert('dtb_pagelayout', $sqlval);
+            $page_id = $sqlval['page_id'];
         }
         // データが存在してる場合にはアップデートを行う
@@ -322,5 +332,7 @@
             $objQuery->update('dtb_pagelayout', $sqlval, 'page_id = ? AND device_type_id = ?',
                               array($arrData['page_id'], $device_type_id));
-        }
+            $page_id = $arrData['page_id'];
+        }
+        return $page_id;
     }
 
@@ -331,5 +343,5 @@
      * @return array 更新データ
      */
-    function lfGetUpdData($arrData){
+    function lfGetUpdData($arrData, $device_type_id) {
         $arrUpdData = array(
             'header_chk'    => SC_Utils_Ex::sfChangeCheckBox($arrData['header_chk']),   // ヘッダー使用
@@ -340,7 +352,7 @@
 
         // ベースデータの場合には変更しない。
-        if (!$this->objLayout->lfCheckBaseData($arrData['page_id'])) {
+        if (!$this->objLayout->lfCheckBaseData($arrData['page_id'], $device_type_id)) {
             $arrUpdData['page_name']    = $arrData['page_name'] ;
-            $arrUpdData['url']          = USER_DIR . $arrData['url'] . '.php';
+            $arrUpdData['url']          = $this->objLayout->getUserDir($device_type_id) . $arrData['url'] . '.php';
             $arrUpdData['php_dir']      = dirname($arrUpdData['url']);
             if ($arrUpdData['php_dir'] == '.') {
@@ -349,5 +361,5 @@
                 $arrUpdData['php_dir'] .= '/';
             }
-            $arrUpdData['tpl_dir']      = substr(TPL_DIR, strlen(URL_DIR));
+            $arrUpdData['tpl_dir']      = substr($this->objLayout->getTemplatePath($devie_type_id, true), strlen(URL_DIR));
             $arrUpdData['filename']     = basename($arrData['url']); // 拡張子を付加しない
         }
@@ -443,7 +455,7 @@
      * @return void
      */
-    function lfCreatePHPFile($url){
-
-        $path = USER_PATH . $url . ".php";
+    function lfCreatePHPFile($url, $device_type_id){
+
+        $path = $this->objLayout->getUserPath($device_type_id) . $url . ".php";
 
         // カスタマイズを考慮し、上書きしない。(#831)
Index: branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Template.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Template.php	(revision 19713)
+++ branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Template.php	(revision 19722)
@@ -189,4 +189,5 @@
 		    $this->templates = $this->lfGetAllTemplates();
 		    $this->now_template = TEMPLATE_NAME;
+            $this->device_type_id = $device_type_id;
     }
 
Index: branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Up_Down.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Up_Down.php	(revision 19715)
+++ branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Up_Down.php	(revision 19722)
@@ -119,4 +119,5 @@
 		        break;
 		    }
+            $this->device_type_id = $device_type_id;
     }
 
Index: 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	(revision 19719)
+++ branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Bloc.php	(revision 19722)
@@ -219,4 +219,5 @@
             break;
         }
+        $this->device_type_id = $device_type_id;
     }
 
Index: branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design.php	(revision 19719)
+++ branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design.php	(revision 19722)
@@ -260,4 +260,5 @@
         $this->bloc_cnt = count($tpl_arrBloc);
         $this->page_id = $page_id;
+        $this->device_type_id = $device_type_id;
 
         // ページ名称を取得
