Index: /branches/comu-ver2/data/Smarty/templates/default/admin/design/index.tpl
===================================================================
--- /branches/comu-ver2/data/Smarty/templates/default/admin/design/index.tpl	(revision 18189)
+++ /branches/comu-ver2/data/Smarty/templates/default/admin/design/index.tpl	(revision 18190)
@@ -51,4 +51,5 @@
                   <input type="hidden" class="target-id" name="target_id_<!--{$smarty.foreach.bloc_loop.iteration}-->" value="<!--{$item.target_id}-->" />
                   <input type="hidden" class="top" name="top_<!--{$smarty.foreach.bloc_loop.iteration}-->" value="<!--{$item.bloc_row}-->" />
+                  <label>(<input type="checkbox" class="anywhere" name="anywhere_<!--{$smarty.foreach.bloc_loop.iteration}-->" value="1" <!--{$item.anywhere_selected}-->  />全ページ)</label> 
                 </div>
                 <!--{assign var="firstflg" value=true}-->
@@ -72,4 +73,6 @@
                   <input type="hidden" class="target-id" name="target_id_<!--{$smarty.foreach.bloc_loop.iteration}-->" value="<!--{$item.target_id}-->" />
                   <input type="hidden" class="top" name="top_<!--{$smarty.foreach.bloc_loop.iteration}-->" value="<!--{$item.bloc_row}-->" />
+                     <label>(<input type="checkbox" class="anywhere" name="anywhere_<!--{$smarty.foreach.bloc_loop.iteration}-->" value="1" <!--{$item.anywhere_selected}-->  />全ページ)</label> 
+               
                 </div>
                 <!--{assign var="firstflg" value=true}-->
@@ -91,4 +94,6 @@
                   <input type="hidden" class="target-id" name="target_id_<!--{$smarty.foreach.bloc_loop.iteration}-->" value="<!--{$item.target_id}-->" />
                   <input type="hidden" class="top" name="top_<!--{$smarty.foreach.bloc_loop.iteration}-->" value="<!--{$item.bloc_row}-->" />
+                     <label>(<input type="checkbox" class="anywhere" name="anywhere_<!--{$smarty.foreach.bloc_loop.iteration}-->" value="1" <!--{$item.anywhere_selected}-->  />全ページ)</label> 
+               
                 </div>
                 <!--{assign var="firstflg" value=true}-->
@@ -110,4 +115,6 @@
                   <input type="hidden" class="target-id" name="target_id_<!--{$smarty.foreach.bloc_loop.iteration}-->" value="<!--{$item.target_id}-->" />
                   <input type="hidden" class="top" name="top_<!--{$smarty.foreach.bloc_loop.iteration}-->" value="<!--{$item.bloc_row}-->" />
+                     <label>(<input type="checkbox" class="anywhere" name="anywhere_<!--{$smarty.foreach.bloc_loop.iteration}-->" value="1" <!--{$item.anywhere_selected}-->  />全ページ)</label> 
+               
                 </div>
                 <!--{assign var="firstflg" value=true}-->
@@ -136,4 +143,6 @@
                   <input type="hidden" class="target-id" name="target_id_<!--{$smarty.foreach.bloc_loop.iteration}-->" value="<!--{$item.target_id}-->" />
                   <input type="hidden" class="top" name="top_<!--{$smarty.foreach.bloc_loop.iteration}-->" value="<!--{$item.bloc_row}-->" />
+                     <label>(<input type="checkbox" class="anywhere" name="anywhere_<!--{$smarty.foreach.bloc_loop.iteration}-->" value="1" <!--{$item.anywhere_selected}-->  />全ページ)</label> 
+               
                 </div>
                 <!--{assign var="firstflg" value=true}-->
@@ -157,4 +166,6 @@
                   <input type="hidden" class="target-id" name="target_id_<!--{$smarty.foreach.bloc_loop.iteration}-->" value="<!--{$item.target_id}-->" />
                   <input type="hidden" class="top" name="top_<!--{$smarty.foreach.bloc_loop.iteration}-->" value="<!--{$item.bloc_row}-->" />
+                     <label>(<input type="checkbox" class="anywhere" name="anywhere_<!--{$smarty.foreach.bloc_loop.iteration}-->" value="1" <!--{$item.anywhere_selected}-->  />全ページ)</label> 
+               
                 </div>
                 <!--{assign var="firstflg" value=true}-->
@@ -184,4 +195,6 @@
             <input type="hidden" class="target-id" name="target_id_<!--{$smarty.foreach.bloc_loop.iteration}-->" value="<!--{$item.target_id}-->" />
             <input type="hidden" class="top" name="top_<!--{$smarty.foreach.bloc_loop.iteration}-->" value="<!--{$item.bloc_row}-->" />
+               <label>(<input type="checkbox" class="anywhere" name="anywhere_<!--{$smarty.foreach.bloc_loop.iteration}-->" value="1" <!--{$item.anywhere_selected}-->  />全ページ)</label> 
+               
           </div>
           <!--{assign var="firstflg" value=true}-->
Index: /branches/comu-ver2/data/class/pages/admin/design/LC_Page_Admin_Design.php
===================================================================
--- /branches/comu-ver2/data/class/pages/admin/design/LC_Page_Admin_Design.php	(revision 18189)
+++ /branches/comu-ver2/data/class/pages/admin/design/LC_Page_Admin_Design.php	(revision 18190)
@@ -79,12 +79,15 @@
 
         // ブロック配置用データを取得
-        $sel   = ", pos.target_id, pos.bloc_id, pos.bloc_row ";
+        $sel   = ", pos.target_id, pos.bloc_id, pos.bloc_row ,pos.anywhere";
         $from  = ", dtb_blocposition AS pos";
         $where = " where ";
-        $where .= " lay.page_id = ? AND ";
-        $where .= "lay.page_id = pos.page_id AND exists (select bloc_id from dtb_bloc as blc where pos.bloc_id = blc.bloc_id) ORDER BY lay.page_id,pos.target_id, pos.bloc_row, pos.bloc_id ";
+        $where .= "( pos.anywhere = 1 OR (lay.page_id = ? AND ";
+        $where .= "lay.page_id = pos.page_id AND exists (select bloc_id from dtb_bloc as blc where pos.bloc_id = blc.bloc_id) )) ORDER BY lay.page_id,pos.target_id, pos.bloc_row, pos.bloc_id ";
+//        $where .= "((lay.page_id = ? AND ";
+//        $where .= "lay.page_id = pos.page_id AND exists (select bloc_id from dtb_bloc as blc where pos.bloc_id = blc.bloc_id) )) ORDER BY lay.page_id,pos.target_id, pos.bloc_row, pos.bloc_id ";
+        
         $arrData = array($page_id);
         $arrBlocPos = $this->lfgetLayoutData($sel, $from, $where, $arrData );
-
+                
         // データの存在チェックを行う
         $arrPageData = $objLayout->lfgetPageData("page_id = ?", array($page_id));
@@ -143,5 +146,7 @@
                 $arrUpdBlocData[$upd_cnt]['target_id']  = $arrTargetFlip[$_POST['target_id_'.$upd_cnt]];    // ターゲットID
                 $arrUpdBlocData[$upd_cnt]['top']        = $_POST['top_'.$upd_cnt];                          // TOP座標
+                $arrUpdBlocData[$upd_cnt]['anywhere']        = $_POST['anywhere_'.$upd_cnt];                     //全ページ適用か
                 $arrUpdBlocData[$upd_cnt]['update_url'] = $_SERVER['HTTP_REFERER'];                         // 更新URL
+                
             }
 
@@ -178,6 +183,7 @@
                 $ins_sql .= "   ,? ";           // ブロックの並び順序
                 $ins_sql .= "   ,(SELECT filename FROM dtb_bloc WHERE bloc_id = ?) ";           // ファイル名称
+                $ins_sql .= "   ,? ";           // 全ページフラグ
                 $ins_sql .= "   )  ";
-
+                
                 // insertデータ生成
                 $arrInsData = array($page_id,
@@ -185,6 +191,21 @@
                                     $arrUpdBlocData[$key]['id'],
                                     $arrUpdBlocData[$key]['bloc_row'],
-                                    $arrUpdBlocData[$key]['id']
+                                    $arrUpdBlocData[$key]['id'],
+                                    $arrUpdBlocData[$key]['anywhere']
                                     );
+                $count = $objDBConn->getOne("SELECT COUNT(*) FROM dtb_blocposition WHERE anywhere = 1 AND bloc_id = ?",array($arrUpdBlocData[$key]['id']));
+                                    
+               if($arrUpdBlocData[$key]['anywhere'] == 1){
+                   $count = $objDBConn->getOne("SELECT COUNT(*) FROM dtb_blocposition WHERE anywhere = 1 AND bloc_id = ?",array($arrUpdBlocData[$key]['id']));
+                   $objDBConn->getLastQuery();
+                   if($count != 0){
+                       continue;
+                   }else{
+                   }
+               }else{
+                   if($count > 0){
+                       $objDBConn->query("DELETE FROM dtb_blocposition WHERE anywhere = 1 AND bloc_id = ?",array($arrUpdBlocData[$key]['id']));
+                   }
+               }
                 // SQL実行
                 $arrRet = $objDBConn->query($ins_sql,$arrInsData);
@@ -228,13 +249,16 @@
                 $tpl_arrBloc = $this->lfSetBlocData($arrBloc, $val, $tpl_arrBloc, $cnt);
                 $cnt++;
-            }
-        }
-
+            }else{
+            }
+        }
+        
+                
         // 未使用のブロックデータを追加
         foreach($arrBloc as $key => $val){
             if (!$this->lfChkBloc($val, $tpl_arrBloc)) {
-                $val['target_id'] = 5;  // 未使用に追加する
+                $val['target_id'] = 7;  // 未使用に追加する
                 $tpl_arrBloc = $this->lfSetBlocData($arrBloc, $val, $tpl_arrBloc, $cnt);
                 $cnt++;
+            }else{
             }
         }
@@ -374,5 +398,8 @@
         $tpl_arrBloc[$cnt]['bloc_row'] =
             isset($val['bloc_row']) ? $val['bloc_row'] : "";
-
+        $tpl_arrBloc[$cnt]['anywhere'] = $val['anywhere'];
+        if($val['anywhere'] == 1){
+            $tpl_arrBloc[$cnt]['anywhere_selected'] = 'checked="checked"';
+        }
         foreach($arrBloc as $bloc_key => $bloc_val){
             if ($bloc_val['bloc_id'] == $val['bloc_id']) {
@@ -382,5 +409,5 @@
         }
         $tpl_arrBloc[$cnt]['name'] = $bloc_name;
-
+                
         return $tpl_arrBloc;
     }
@@ -400,5 +427,5 @@
             }
         }
-
+        
         // 配列に存在しなければFlaseを返す
         return false;
@@ -437,5 +464,5 @@
         $arrUpdData = array();          // 更新データ生成用
         $filename = $arrPageData[0]['filename'];
-
+        
         $arrPreData = $objLayout->lfgetPageData(" page_id = ? " , array("0"));
 
@@ -480,4 +507,5 @@
         $sql .= "     ,tpl_dir = ?";
         $sql .= "     ,filename = ?";
+        $sql .= "     ,anywhere = ?";
         $sql .= " where page_id = 0";
 
@@ -488,4 +516,5 @@
                             ,USER_DIR . "templates/" . TEMPLATE_NAME . "/"
                             ,$filename
+                           
                             );
 
Index: /branches/comu-ver2/data/class/helper/SC_Helper_PageLayout.php
===================================================================
--- /branches/comu-ver2/data/class/helper/SC_Helper_PageLayout.php	(revision 18189)
+++ /branches/comu-ver2/data/class/helper/SC_Helper_PageLayout.php	(revision 18190)
@@ -53,4 +53,5 @@
                 $url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
             }
+            
             $url2 = preg_replace('|^' . preg_quote(SITE_URL) . '|', '', $url);
             // URLを元にページデザインを取得
@@ -61,5 +62,5 @@
                 . TEMPLATE_NAME . "/" . $arrPageData[0]['filename'] . ".tpl";
         }
-        
+                
         foreach($arrPageData[0] as $key => $val) {
             $debug_message.= "arrPageData[$key]：" . $val . "\n";
@@ -124,4 +125,5 @@
      */
     function lfgetPageData($where = 'page_id <> 0', $where_vals = array()) {
+                
         $objQuery = new SC_Query;       // DB操作オブジェクト
         $arrRet = array();              // データ取得用
@@ -167,5 +169,5 @@
 
         // 取得するカラム
-        $col = "target_id, bloc_name, tpl_path, php_path";
+        $col = "target_id, bloc_name, tpl_path, php_path,anywhere";
         
         // 取得するテーブル
@@ -173,5 +175,5 @@
         
         // where文生成
-        $where = "page_id = ?";
+        $where = "anywhere = 1 OR page_id = ?";
         $where_vals[] = $page_id;
 
@@ -181,5 +183,5 @@
         // SQL実行
         $arrRet = $objQuery->select($col, $table, $where, $where_vals);
-                                            
+        
         // 結果を返す
         return $arrRet;
@@ -198,5 +200,5 @@
             foreach($arrNavi as $key => $val){
                 // 指定された箇所と同じデータだけを取得する
-                if ($target_id == $val['target_id']){
+                if ($target_id == $val['target_id'] ){
                     if ($val['php_path'] != '') {
                         $arrNavi[$key]['php_path'] = HTML_PATH . $val['php_path'];
Index: /branches/comu-ver2/html/install/sql/create_table_mysql.sql
===================================================================
--- /branches/comu-ver2/html/install/sql/create_table_mysql.sql	(revision 18069)
+++ /branches/comu-ver2/html/install/sql/create_table_mysql.sql	(revision 18190)
@@ -901,5 +901,6 @@
     bloc_id int,
     bloc_row int,
-    filename text
+    filename text,
+    anywhere int
 ) TYPE=InnoDB ;
 
Index: /branches/comu-ver2/html/install/sql/create_table_pgsql.sql
===================================================================
--- /branches/comu-ver2/html/install/sql/create_table_pgsql.sql	(revision 18023)
+++ /branches/comu-ver2/html/install/sql/create_table_pgsql.sql	(revision 18190)
@@ -929,5 +929,6 @@
     bloc_id int4,
     bloc_row int4,
-    filename text
+    filename text,
+    anywhere int2
 );
 
Index: /branches/comu-ver2/html/install/sql/insert_data.sql
===================================================================
--- /branches/comu-ver2/html/install/sql/insert_data.sql	(revision 18189)
+++ /branches/comu-ver2/html/install/sql/insert_data.sql	(revision 18190)
@@ -24,25 +24,25 @@
 update dtb_pagelayout set page_id = 0 where page_id = 5;
 
-INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename) VALUES (1,1,1,2,'category');
-INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename) VALUES (1,1,2,3,'guide');
-INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename) VALUES (1,1,3,1,'cart');
-INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename) VALUES (1,3,4,2,'search_products');
-INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename) VALUES (1,4,5,1,'news');
-INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename) VALUES (1,3,6,1,'login');
-INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename) VALUES (1,4,7,2,'best5');
-INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename) VALUES (2,1,1,2,'category');
-INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename) VALUES (2,1,2,3,'guide');
-INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename) VALUES (2,1,3,1,'cart');
-INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename) VALUES (2,7,4,0,'search_products');
-INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename) VALUES (2,7,5,0,'news');
-INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename) VALUES (2,7,6,0,'login');
-INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename) VALUES (2,7,7,0,'best5');
-INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename) VALUES (3,1,1,2,'category');
-INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename) VALUES (3,1,2,3,'guide');
-INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename) VALUES (3,1,3,1,'cart');
-INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename) VALUES (3,7,4,0,'search_products');
-INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename) VALUES (3,7,5,0,'news');
-INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename) VALUES (3,7,6,0,'login');
-INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename) VALUES (3,7,7,0,'best5');
+INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename,anywhere) VALUES (1,1,1,2,'category',0);
+INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename,anywhere) VALUES (1,1,2,3,'guide',0);
+INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename,anywhere) VALUES (1,1,3,1,'cart',0);
+INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename,anywhere) VALUES (1,3,4,2,'search_products',0);
+INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename,anywhere) VALUES (1,4,5,1,'news',0);
+INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename,anywhere) VALUES (1,3,6,1,'login',0);
+INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename,anywhere) VALUES (1,4,7,2,'best5',0);
+INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename,anywhere) VALUES (2,1,1,2,'category',0);
+INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename,anywhere) VALUES (2,1,2,3,'guide',0);
+INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename,anywhere) VALUES (2,1,3,1,'cart',0);
+INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename,anywhere) VALUES (2,7,4,0,'search_products',0);
+INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename,anywhere) VALUES (2,7,5,0,'news',0);
+INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename,anywhere) VALUES (2,7,6,0,'login',0);
+INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename,anywhere) VALUES (2,7,7,0,'best5',0);
+INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename,anywhere) VALUES (3,1,1,2,'category',0);
+INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename,anywhere) VALUES (3,1,2,3,'guide',0);
+INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename,anywhere) VALUES (3,1,3,1,'cart',0);
+INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename,anywhere) VALUES (3,7,4,0,'search_products',0);
+INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename,anywhere) VALUES (3,7,5,0,'news',0);
+INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename,anywhere) VALUES (3,7,6,0,'login',0);
+INSERT INTO dtb_blocposition (page_id,target_id,bloc_id,bloc_row,filename,anywhere) VALUES (3,7,7,0,'best5',0);
 
 INSERT INTO dtb_csv(csv_id,col,disp_name,rank,create_date,update_date) VALUES (1,'product_id','商品ID',1,now(),now());
