Changeset 18201 for branches


Ignore:
Timestamp:
2009/07/18 14:53:54 (15 years ago)
Author:
miningbrownie
Message:

http://svn.ec-cube.net/open_trac/ticket/518 この件を修正しました。SC_Helper_PageLayoutでの順番が間違えていたのと、insert_data.sqlでのそのスペースの名前の付け方に揺らぎがありました。

Location:
branches/comu-ver2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/comu-ver2/data/class/helper/SC_Helper_PageLayout.php

    r18194 r18201  
    106106        $arrPageLayout['TopNavi'] = $this->lfGetNavi($arrNavi,5); //上部 
    107107        $arrPageLayout['BottomNavi'] = $this->lfGetNavi($arrNavi,6); //下部 
    108         $arrPageLayout['HeaderTopNavi'] = $this->lfGetNavi($arrNavi,7); //上部 
    109         $arrPageLayout['FooterBottomNavi'] = $this->lfGetNavi($arrNavi,8); //下 
    110         $arrPageLayout['HeadNavi'] = $this->lfGetNavi($arrNavi,9); //上 
     108        $arrPageLayout['HeadNavi'] = $this->lfGetNavi($arrNavi,7); //上部 
     109        $arrPageLayout['HeaderTopNavi'] = $this->lfGetNavi($arrNavi,8); //上 
     110        $arrPageLayout['FooterBottomNavi'] = $this->lfGetNavi($arrNavi,9); //下 
    111111         
    112112         
  • branches/comu-ver2/data/class/pages/admin/design/LC_Page_Admin_Design.php

    r18194 r18201  
    3434class LC_Page_Admin_Design extends LC_Page { 
    3535 
    36     // }}} 
    37     // {{{ functions 
    38  
    39     /** 
    40     * Page を初期化する. 
    41     * 
    42     * @return void 
    43     */ 
    44     function init() { 
    45         parent::init(); 
    46         $this->tpl_mainpage = 'design/index.tpl'; 
    47         $this->tpl_subnavi = 'design/subnavi.tpl'; 
    48         $this->tpl_subno = "layout"; 
    49         $this->tpl_mainno = "design"; 
    50         $this->tpl_subtitle = 'レイアウト編集'; 
    51     } 
    52  
    53     /** 
    54     * Page のプロセス. 
    55     * 
    56     * @return void 
    57     */ 
    58     function process() { 
    59  
    60         $objView = new SC_AdminView(); 
    61         $objSess = new SC_Session(); 
    62         $objLayout = new SC_Helper_PageLayout_Ex(); 
    63  
    64         // 認証可否の判定 
    65         $objSess = new SC_Session(); 
    66         SC_Utils_Ex::sfIsSuccess($objSess); 
    67  
    68         // ページIDを取得 
    69         if (isset($_GET['page_id'])) { 
    70             $page_id = $_GET['page_id']; 
    71         }else if (isset($_POST['page_id'])){ 
    72             $page_id = $_POST['page_id']; 
    73         }else{ 
    74             $page_id = 1; 
    75         } 
    76  
    77         // 編集可能ページを取得 
    78         $this->arrEditPage = $objLayout->lfgetPageData(); 
    79  
    80         // ブロック配置用データを取得 
    81         $sel   = ", pos.target_id, pos.bloc_id, pos.bloc_row ,pos.anywhere"; 
    82         $from  = ", dtb_blocposition AS pos"; 
    83         $where = " where "; 
    84         $where .= "( pos.anywhere = 1 OR (lay.page_id = ? AND "; 
    85         $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 "; 
    86 //        $where .= "((lay.page_id = ? AND "; 
    87 //        $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 "; 
    88          
    89         $arrData = array($page_id); 
    90         $arrBlocPos = $this->lfgetLayoutData($sel, $from, $where, $arrData ); 
    91                  
    92         // データの存在チェックを行う 
    93         $arrPageData = $objLayout->lfgetPageData("page_id = ?", array($page_id)); 
    94         if (count($arrPageData) <= 0) { 
    95             $exists_page = 0; 
    96         }else{ 
    97             $exists_page = 1; 
    98         } 
    99         $this->exists_page = $exists_page; 
    100  
    101         // メッセージ表示 
    102         if (isset($_GET['msg']) && $_GET['msg'] == "on") { 
    103             $this->complate_msg="alert('登録が完了しました。');"; 
    104         } 
    105  
    106         // ブロックを取得 
    107         $arrBloc = $this->lfgetBlocData(); 
    108  
    109         if (!isset($_POST['mode'])) $_POST['mode'] = ""; 
    110  
    111         // 新規ブロック作成 
    112         if ($_POST['mode'] == 'new_bloc') { 
    113             $this->sendRedirect($this->getLocation("./bloc.php")); 
    114             exit; 
    115         } 
    116  
    117         // 新規ページ作成 
    118         if ($_POST['mode'] == 'new_page') { 
    119             $this->sendRedirect($this->getLocation("./main_edit.php")); 
    120             exit; 
    121         } 
    122  
    123         // データ登録処理 
    124         if ($_POST['mode'] == 'confirm' or $_POST['mode'] == 'preview') { 
    125             $page_id = $_POST['page_id']; 
    126             if ($_POST['mode'] == 'preview') { 
    127                 $page_id = '0'; 
    128             } 
    129             $masterData = new SC_DB_MasterData_Ex(); 
    130             $arrTarget = $masterData->getMasterData("mtb_target"); 
    131  
    132             // 更新用にデータを整える 
    133             $arrUpdBlocData = array(); 
    134             $arrTargetFlip = array_flip($arrTarget); 
    135  
    136             $upd_cnt = 1; 
    137             $arrUpdData[$upd_cnt]['page_id'] = $page_id; 
    138  
    139             // POSTのデータを使いやすいように修正 
    140             for($upd_cnt = 1; $upd_cnt <= $_POST['bloc_cnt']; $upd_cnt++){ 
    141                 if (!isset($_POST['id_'.$upd_cnt])) { 
    142                     break; 
    143                 } 
    144                 $arrUpdBlocData[$upd_cnt]['name']       = $_POST['name_'.$upd_cnt];                         // ブロック名称 
    145                 $arrUpdBlocData[$upd_cnt]['id']         = $_POST['id_'.$upd_cnt];                           // ブロックID 
    146                 $arrUpdBlocData[$upd_cnt]['target_id']  = $arrTargetFlip[$_POST['target_id_'.$upd_cnt]];    // ターゲットID 
    147                 $arrUpdBlocData[$upd_cnt]['top']        = $_POST['top_'.$upd_cnt];                          // TOP座標 
    148                 $arrUpdBlocData[$upd_cnt]['anywhere']        = $_POST['anywhere_'.$upd_cnt];                     //全ページ適用か 
    149                 $arrUpdBlocData[$upd_cnt]['update_url'] = $_SERVER['HTTP_REFERER'];                         // 更新URL 
    150                  
    151             } 
    152  
    153             // データの更新を行う 
    154             $objDBConn = new SC_DbConn;     // DB操作オブジェクト 
    155             $arrRet = array();              // データ取得用 
    156  
    157             // delete実行 
    158             $del_sql = ""; 
    159             $del_sql .= "DELETE FROM dtb_blocposition WHERE page_id = ? "; 
    160             $arrRet = $objDBConn->query($del_sql,array($page_id)); 
    161  
    162             // ブロックの順序を取得し、更新を行う 
    163             foreach($arrUpdBlocData as $key => $val){ 
    164                 // ブロックの順序を取得 
    165                 $bloc_row = $this->lfGetRowID($arrUpdBlocData, $val); 
    166                 $arrUpdBlocData[$key]['bloc_row'] = $bloc_row; 
    167                 $arrUpdBlocData[$key]['page_id']    =  $page_id;    // ページID 
    168  
    169                 /* 
    170                 ターゲットID 1:レフトナビ 2:ライトナビ 3:イン画面上部 4:メイン画面下部  5:画面上部 6:画面下部 7:ヘッダより上 8:フッタより下 9:HEADタグ内 10:欄外 
    171                 */ 
    172                 if ($arrUpdBlocData[$key]['target_id'] == 10) { 
    173                     $arrUpdBlocData[$key]['bloc_row'] = "0"; 
    174                 } 
    175  
    176                 // insert文生成 
    177                 $ins_sql = ""; 
    178                 $ins_sql .= "INSERT INTO dtb_blocposition "; 
    179                 $ins_sql .= " values ( "; 
    180                 $ins_sql .= "   ?  ";           // ページID 
    181                 $ins_sql .= "   ,? ";           // ターゲットID 
    182                 $ins_sql .= "   ,? ";           // ブロックID 
    183                 $ins_sql .= "   ,? ";           // ブロックの並び順序 
    184                 $ins_sql .= "   ,(SELECT filename FROM dtb_bloc WHERE bloc_id = ?) ";           // ファイル名称 
    185                 $ins_sql .= "   ,? ";           // 全ページフラグ 
    186                 $ins_sql .= "   )  "; 
    187                  
    188                 // insertデータ生成 
    189                 $arrInsData = array($page_id, 
    190                                     $arrUpdBlocData[$key]['target_id'], 
    191                                     $arrUpdBlocData[$key]['id'], 
    192                                     $arrUpdBlocData[$key]['bloc_row'], 
    193                                     $arrUpdBlocData[$key]['id'], 
    194                                     $arrUpdBlocData[$key]['anywhere'] 
    195                                     ); 
    196                 $count = $objDBConn->getOne("SELECT COUNT(*) FROM dtb_blocposition WHERE anywhere = 1 AND bloc_id = ?",array($arrUpdBlocData[$key]['id'])); 
    197                                      
    198                if($arrUpdBlocData[$key]['anywhere'] == 1){ 
    199                    $count = $objDBConn->getOne("SELECT COUNT(*) FROM dtb_blocposition WHERE anywhere = 1 AND bloc_id = ?",array($arrUpdBlocData[$key]['id'])); 
    200                    $objDBConn->getLastQuery(); 
    201                    if($count != 0){ 
    202                        continue; 
    203                    }else{ 
    204                    } 
    205                }else{ 
    206                    if($count > 0){ 
    207                        $objDBConn->query("DELETE FROM dtb_blocposition WHERE anywhere = 1 AND bloc_id = ?",array($arrUpdBlocData[$key]['id'])); 
    208                    } 
    209                } 
    210                 // SQL実行 
    211                 $arrRet = $objDBConn->query($ins_sql,$arrInsData); 
    212             } 
    213  
    214             // プレビュー処理 
    215             if ($_POST['mode'] == 'preview') { 
    216                 if ($page_id === "") { 
    217                     $this->sendRedirect($this->getLocation(DIR_INDEX_URL)); 
    218                     exit; 
    219                 } 
    220                 $this->lfSetPreData($arrPageData, $objLayout); 
    221  
    222                 $_SESSION['preview'] = "ON"; 
    223  
    224                 $this->sendRedirect($this->getLocation(URL_DIR . "preview/" . DIR_INDEX_URL, array("filename" => $arrPageData[0]["filename"]))); 
    225                 exit; 
    226  
    227             }else{ 
    228                 $this->sendRedirect($this->getLocation(DIR_INDEX_URL, 
    229                                             array("page_id" => $page_id, 
     36    // }}} 
     37    // {{{ functions 
     38 
     39    /** 
     40    * Page を初期化する. 
     41    * 
     42    * @return void 
     43    */ 
     44    function init() { 
     45        parent::init(); 
     46        $this->tpl_mainpage = 'design/index.tpl'; 
     47        $this->tpl_subnavi = 'design/subnavi.tpl'; 
     48        $this->tpl_subno = "layout"; 
     49        $this->tpl_mainno = "design"; 
     50        $this->tpl_subtitle = 'レイアウト編集'; 
     51    } 
     52 
     53    /** 
     54    * Page のプロセス. 
     55    * 
     56    * @return void 
     57    */ 
     58    function process() { 
     59 
     60        $objView = new SC_AdminView(); 
     61        $objSess = new SC_Session(); 
     62        $objLayout = new SC_Helper_PageLayout_Ex(); 
     63 
     64        // 認証可否の判定 
     65        $objSess = new SC_Session(); 
     66        SC_Utils_Ex::sfIsSuccess($objSess); 
     67 
     68        // ページIDを取得 
     69        if (isset($_GET['page_id'])) { 
     70            $page_id = $_GET['page_id']; 
     71        }else if (isset($_POST['page_id'])){ 
     72            $page_id = $_POST['page_id']; 
     73        }else{ 
     74            $page_id = 1; 
     75        } 
     76 
     77        // 編集可能ページを取得 
     78        $this->arrEditPage = $objLayout->lfgetPageData(); 
     79 
     80        // ブロック配置用データを取得 
     81        $sel   = ", pos.target_id, pos.bloc_id, pos.bloc_row ,pos.anywhere"; 
     82        $from  = ", dtb_blocposition AS pos"; 
     83        $where = " where "; 
     84        $where .= "( pos.anywhere = 1 OR (lay.page_id = ? AND "; 
     85        $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 "; 
     86        //        $where .= "((lay.page_id = ? AND "; 
     87        //        $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 "; 
     88 
     89        $arrData = array($page_id); 
     90        $arrBlocPos = $this->lfgetLayoutData($sel, $from, $where, $arrData ); 
     91 
     92        // データの存在チェックを行う 
     93        $arrPageData = $objLayout->lfgetPageData("page_id = ?", array($page_id)); 
     94        if (count($arrPageData) <= 0) { 
     95            $exists_page = 0; 
     96        }else{ 
     97            $exists_page = 1; 
     98        } 
     99        $this->exists_page = $exists_page; 
     100 
     101        // メッセージ表示 
     102        if (isset($_GET['msg']) && $_GET['msg'] == "on") { 
     103            $this->complate_msg="alert('登録が完了しました。');"; 
     104        } 
     105 
     106        // ブロックを取得 
     107        $arrBloc = $this->lfgetBlocData(); 
     108 
     109        if (!isset($_POST['mode'])) $_POST['mode'] = ""; 
     110 
     111        // 新規ブロック作成 
     112        if ($_POST['mode'] == 'new_bloc') { 
     113            $this->sendRedirect($this->getLocation("./bloc.php")); 
     114            exit; 
     115        } 
     116 
     117        // 新規ページ作成 
     118        if ($_POST['mode'] == 'new_page') { 
     119            $this->sendRedirect($this->getLocation("./main_edit.php")); 
     120            exit; 
     121        } 
     122 
     123        // データ登録処理 
     124        if ($_POST['mode'] == 'confirm' or $_POST['mode'] == 'preview') { 
     125            $page_id = $_POST['page_id']; 
     126            if ($_POST['mode'] == 'preview') { 
     127                $page_id = '0'; 
     128            } 
     129            $masterData = new SC_DB_MasterData_Ex(); 
     130            $arrTarget = $masterData->getMasterData("mtb_target"); 
     131 
     132            // 更新用にデータを整える 
     133            $arrUpdBlocData = array(); 
     134            $arrTargetFlip = array_flip($arrTarget); 
     135 
     136            $upd_cnt = 1; 
     137            $arrUpdData[$upd_cnt]['page_id'] = $page_id; 
     138 
     139            // POSTのデータを使いやすいように修正 
     140            for($upd_cnt = 1; $upd_cnt <= $_POST['bloc_cnt']; $upd_cnt++){ 
     141                if (!isset($_POST['id_'.$upd_cnt])) { 
     142                    break; 
     143                } 
     144                $arrUpdBlocData[$upd_cnt]['name']       = $_POST['name_'.$upd_cnt];                         // ブロック名称 
     145                $arrUpdBlocData[$upd_cnt]['id']         = $_POST['id_'.$upd_cnt];                           // ブロックID 
     146                $arrUpdBlocData[$upd_cnt]['target_id']  = $arrTargetFlip[$_POST['target_id_'.$upd_cnt]];    // ターゲットID 
     147                $arrUpdBlocData[$upd_cnt]['top']        = $_POST['top_'.$upd_cnt];                          // TOP座標 
     148                $arrUpdBlocData[$upd_cnt]['anywhere']        = $_POST['anywhere_'.$upd_cnt];                     //全ページ適用か 
     149                $arrUpdBlocData[$upd_cnt]['update_url'] = $_SERVER['HTTP_REFERER'];                         // 更新URL 
     150 
     151            } 
     152 
     153            // データの更新を行う 
     154            $objDBConn = new SC_DbConn;     // DB操作オブジェクト 
     155            $arrRet = array();              // データ取得用 
     156 
     157            // delete実行 
     158            $del_sql = ""; 
     159            $del_sql .= "DELETE FROM dtb_blocposition WHERE page_id = ? "; 
     160            $arrRet = $objDBConn->query($del_sql,array($page_id)); 
     161 
     162            // ブロックの順序を取得し、更新を行う 
     163            foreach($arrUpdBlocData as $key => $val){ 
     164                // ブロックの順序を取得 
     165                $bloc_row = $this->lfGetRowID($arrUpdBlocData, $val); 
     166                $arrUpdBlocData[$key]['bloc_row'] = $bloc_row; 
     167                $arrUpdBlocData[$key]['page_id']    =  $page_id;    // ページID 
     168 
     169                /* 
     170                ターゲットID 1:レフトナビ 2:ライトナビ 3:イン画面上部 4:メイン画面下部  5:画面上部 6:画面下部 7:ヘッダより上 8:フッタより下 9:HEADタグ内 10:欄外 
     171                */ 
     172                if ($arrUpdBlocData[$key]['target_id'] == 10) { 
     173                    $arrUpdBlocData[$key]['bloc_row'] = "0"; 
     174                } 
     175 
     176                // insert文生成 
     177                $ins_sql = ""; 
     178                $ins_sql .= "INSERT INTO dtb_blocposition "; 
     179                $ins_sql .= " values ( "; 
     180                $ins_sql .= "   ?  ";           // ページID 
     181                $ins_sql .= "   ,? ";           // ターゲットID 
     182                $ins_sql .= "   ,? ";           // ブロックID 
     183                $ins_sql .= "   ,? ";           // ブロックの並び順序 
     184                $ins_sql .= "   ,(SELECT filename FROM dtb_bloc WHERE bloc_id = ?) ";           // ファイル名称 
     185                $ins_sql .= "   ,? ";           // 全ページフラグ 
     186                $ins_sql .= "   )  "; 
     187 
     188                // insertデータ生成 
     189                $arrInsData = array($page_id, 
     190                $arrUpdBlocData[$key]['target_id'], 
     191                $arrUpdBlocData[$key]['id'], 
     192                $arrUpdBlocData[$key]['bloc_row'], 
     193                $arrUpdBlocData[$key]['id'], 
     194                $arrUpdBlocData[$key]['anywhere'] 
     195                ); 
     196                $count = $objDBConn->getOne("SELECT COUNT(*) FROM dtb_blocposition WHERE anywhere = 1 AND bloc_id = ?",array($arrUpdBlocData[$key]['id'])); 
     197 
     198                if($arrUpdBlocData[$key]['anywhere'] == 1){ 
     199                    $count = $objDBConn->getOne("SELECT COUNT(*) FROM dtb_blocposition WHERE anywhere = 1 AND bloc_id = ?",array($arrUpdBlocData[$key]['id'])); 
     200                    $objDBConn->getLastQuery(); 
     201                    if($count != 0){ 
     202                        continue; 
     203                    }else{ 
     204                    } 
     205                }else{ 
     206                    if($count > 0){ 
     207                        $objDBConn->query("DELETE FROM dtb_blocposition WHERE anywhere = 1 AND bloc_id = ?",array($arrUpdBlocData[$key]['id'])); 
     208                    } 
     209                } 
     210                // SQL実行 
     211                $arrRet = $objDBConn->query($ins_sql,$arrInsData); 
     212            } 
     213 
     214            // プレビュー処理 
     215            if ($_POST['mode'] == 'preview') { 
     216                if ($page_id === "") { 
     217                    $this->sendRedirect($this->getLocation(DIR_INDEX_URL)); 
     218                    exit; 
     219                } 
     220                $this->lfSetPreData($arrPageData, $objLayout); 
     221 
     222                $_SESSION['preview'] = "ON"; 
     223 
     224                $this->sendRedirect($this->getLocation(URL_DIR . "preview/" . DIR_INDEX_URL, array("filename" => $arrPageData[0]["filename"]))); 
     225                exit; 
     226 
     227            }else{ 
     228                $this->sendRedirect($this->getLocation(DIR_INDEX_URL, 
     229                array("page_id" => $page_id, 
    230230                                                  "msg" => "on"))); 
    231231                exit; 
    232232 
    233             } 
    234         } 
    235  
    236         // データ削除処理 ベースデータでなければファイルを削除 
    237         if ($_POST['mode'] == 'delete' and  !$objLayout->lfCheckBaseData($page_id)) { 
    238             $objLayout->lfDelPageData($page_id); 
    239             $this->sendRedirect($this->getLocation(DIR_INDEX_URL)); 
    240             exit; 
    241         } 
    242  
    243         // ブロック情報を画面配置用に編集 
    244         $tpl_arrBloc = array(); 
    245         $cnt = 0; 
    246         // 使用されているブロックデータを生成 
    247         foreach($arrBlocPos as $key => $val){ 
    248             if ($val['page_id'] == $page_id) { 
    249                 $tpl_arrBloc = $this->lfSetBlocData($arrBloc, $val, $tpl_arrBloc, $cnt); 
    250                 $cnt++; 
    251             }else{ 
    252             } 
    253         } 
    254          
    255                  
    256         // 未使用のブロックデータを追加 
    257         foreach($arrBloc as $key => $val){ 
    258             if (!$this->lfChkBloc($val, $tpl_arrBloc)) { 
    259                 $val['target_id'] = 7;  // 未使用に追加する 
    260                 $tpl_arrBloc = $this->lfSetBlocData($arrBloc, $val, $tpl_arrBloc, $cnt); 
    261                 $cnt++; 
    262             }else{ 
    263             } 
    264         } 
    265  
    266         $this->tpl_arrBloc = $tpl_arrBloc; 
    267         $this->bloc_cnt = count($tpl_arrBloc); 
    268         $this->page_id = $page_id; 
    269  
    270         // ページ名称を取得 
    271         $arrPageData = $objLayout->lfgetPageData(' page_id = ?', array($page_id)); 
    272         $this->arrPageData = $arrPageData[0]; 
    273  
    274         global $GLOBAL_ERR; 
    275         $errCnt = 0; 
    276         if ($GLOBAL_ERR != "") { 
    277             $arrGlobalErr = explode("\n",$GLOBAL_ERR); 
    278             $errCnt = count($arrGlobalErr) - 8; 
    279             if ($errCnt < 0 ) { 
    280                 $errCnt = 0; 
    281             } 
    282         } 
    283         $this->errCnt = $errCnt; 
    284  
    285         // 画面の表示 
    286         $objView->assignobj($this); 
    287         $objView->display(MAIN_FRAME); 
    288  
    289     } 
    290     /** 
    291      * デストラクタ. 
    292      * 
    293      * @return void 
    294      */ 
    295     function destroy() { 
    296         parent::destroy(); 
    297     } 
    298  
    299     /** 
    300      * 編集可能なページ情報を取得する. 
    301      * 
    302      * @param string $sel Select句文 
    303      * @param string $where Where句文 
    304      * @param array $arrVa Where句の絞込条件値 
    305      * @return array ページレイアウト情報の配列 
    306      */ 
    307     function lfgetLayoutData($sel = '' , $from = '', $where = '', $arrVal = ''){ 
    308         $objDBConn = new SC_DbConn;     // DB操作オブジェクト 
    309         $sql = "";                      // データ取得SQL生成用 
    310         $arrRet = array();              // データ取得用 
    311  
    312         // SQL生成 
    313  
    314         $sql = ""; 
    315         $sql .= " select "; 
    316         $sql .= "     lay.page_id "; 
    317         $sql .= "     ,lay.page_name "; 
    318         $sql .= "     ,lay.url "; 
    319         $sql .= "     ,lay.author "; 
    320         $sql .= "     ,lay.description "; 
    321         $sql .= "     ,lay.keyword "; 
    322         $sql .= "     ,lay.update_url "; 
    323         $sql .= "     ,lay.create_date "; 
    324         $sql .= "     ,lay.update_date "; 
    325  
    326         // Select句の指定があれば追加 
    327         if ($sel != '') { 
    328             $sql .= $sel; 
    329         } 
    330  
    331         $sql .= " from dtb_pagelayout AS lay "; 
    332         // From句の指定があれば追加 
    333         if ($from != '') { 
    334             $sql .= $from; 
    335         } 
    336  
    337         // where句の指定があれば追加 
    338         if ($where != '') { 
    339             $sql .= $where; 
    340         }else{ 
    341             $sql .= " ORDER BY lay.page_id "; 
    342         } 
    343  
    344         $arrRet = $objDBConn->getAll($sql, $arrVal); 
    345  
    346         return $arrRet; 
    347     } 
    348  
    349     /** 
    350      * ブロック情報を取得する. 
    351      * 
    352      * @param string $where Where句文 
    353      * @param array $arrVal Where句の絞込条件値 
    354      * @return array ブロック情報の配列 
    355      */ 
    356     function lfgetBlocData($where = '', $arrVal = ''){ 
    357         $objDBConn = new SC_DbConn;     // DB操作オブジェクト 
    358         $sql = "";                      // データ取得SQL生成用 
    359         $arrRet = array();              // データ取得用 
    360  
    361         // SQL生成 
    362         $sql = ""; 
    363         $sql .= " SELECT "; 
    364         $sql .= "   bloc_id"; 
    365         $sql .= "   ,bloc_name"; 
    366         $sql .= "   ,tpl_path"; 
    367         $sql .= "   ,filename"; 
    368         $sql .= "   ,update_date"; 
    369         $sql .= " FROM "; 
    370         $sql .= "   dtb_bloc"; 
    371  
    372         // where句の指定があれば追加 
    373         if ($where != '') { 
    374             $sql .= " WHERE " . $where; 
    375         } 
    376  
    377         $sql .= " ORDER BY  bloc_id"; 
    378  
    379         $arrRet = $objDBConn->getAll($sql, $arrVal); 
    380  
    381         return $arrRet; 
    382     } 
    383  
    384     /** 
    385      * ブロック情報の配列を生成する. 
    386      * 
    387      * @param array $arrBloc Bloc情報 
    388      * @param array $tpl_arrBloc データをセットする配列 
    389      * @param integer $cnt 配列番号 
    390      * @return array データをセットした配列 
    391      */ 
    392     function lfSetBlocData($arrBloc, $val, $tpl_arrBloc, $cnt) { 
    393         $masterData = new SC_DB_MasterData_Ex(); 
    394         $arrTarget = $masterData->getMasterData("mtb_target"); 
    395  
    396         $tpl_arrBloc[$cnt]['target_id'] = $arrTarget[$val['target_id']]; 
    397         $tpl_arrBloc[$cnt]['bloc_id'] = $val['bloc_id']; 
    398         $tpl_arrBloc[$cnt]['bloc_row'] = 
    399             isset($val['bloc_row']) ? $val['bloc_row'] : ""; 
    400         $tpl_arrBloc[$cnt]['anywhere'] = $val['anywhere']; 
    401         if($val['anywhere'] == 1){ 
    402             $tpl_arrBloc[$cnt]['anywhere_selected'] = 'checked="checked"'; 
    403         } 
    404         foreach($arrBloc as $bloc_key => $bloc_val){ 
    405             if ($bloc_val['bloc_id'] == $val['bloc_id']) { 
    406                 $bloc_name = $bloc_val['bloc_name']; 
    407                 break; 
    408             } 
    409         } 
    410         $tpl_arrBloc[$cnt]['name'] = $bloc_name; 
    411                  
    412         return $tpl_arrBloc; 
    413     } 
    414  
    415     /** 
    416      * ブロックIDが配列に追加されているかのチェックを行う. 
    417      * 
    418      * @param array $arrBloc Bloc情報 
    419      * @param array $arrChkData チェックを行うデータ配列 
    420      * @return bool 存在する場合 true 
    421      */ 
    422     function lfChkBloc($arrBloc, $arrChkData) { 
    423         foreach($arrChkData as $key => $val){ 
    424             if ($val['bloc_id'] === $arrBloc['bloc_id'] ) { 
    425                 // 配列に存在すればTrueを返す 
    426                 return true; 
    427             } 
    428         } 
    429          
    430         // 配列に存在しなければFlaseを返す 
    431         return false; 
    432     } 
    433  
    434     /** 
    435      * ブロックIDが何番目に配置されているかを調べる. 
    436      * 
    437      * @param array $arrUpdData 更新情報 
    438      * @param array $arrObj チェックを行うデータ配列 
    439      * @return integer 順番 
    440      */ 
    441     function lfGetRowID($arrUpdData, $arrObj){ 
    442         $no = 0; // カウント用(同じデータが必ず1件あるので、初期値は0) 
    443  
    444         // 対象データが何番目に配置されているのかを取得する。 
    445         foreach ($arrUpdData as $key => $val) { 
    446             if ($val['target_id'] === $arrObj['target_id'] and $val['top'] <= $arrObj['top']){ 
    447                 $no++; 
    448             } 
    449         } 
    450         // 番号を返す 
    451         return $no; 
    452     } 
    453  
    454     /** 
    455      * プレビューするデータを DB に保存する. 
    456      * 
    457      * @param array $arrPageData ページ情報の配列 
    458      * @return void 
    459      */ 
    460     function lfSetPreData($arrPageData, &$objLayout){ 
    461         $objDBConn = new SC_DbConn;     // DB操作オブジェクト 
    462         $sql = "";                      // データ更新SQL生成用 
    463         $ret = "";                      // データ更新結果格納用 
    464         $arrUpdData = array();          // 更新データ生成用 
    465         $filename = $arrPageData[0]['filename']; 
    466          
    467         $arrPreData = $objLayout->lfgetPageData(" page_id = ? " , array("0")); 
    468  
    469         // XXX tplファイルの削除 
    470         $del_tpl = USER_PATH . "templates/" . $filename . '.tpl'; 
    471  
    472         if (file_exists($del_tpl)){ 
    473             unlink($del_tpl); 
    474         } 
    475  
    476         // filename が空の場合にはMYページと判断 
    477         if($filename == ""){ 
    478             $tplfile = TEMPLATE_DIR . "mypage/index"; 
    479             $filename = 'mypage'; 
    480         } else { 
    481             if (file_exists(TEMPLATE_FTP_DIR . $filename . ".tpl")) { 
    482                 $tplfile = TEMPLATE_FTP_DIR . $filename; 
    483             } else { 
    484                 $tplfile = TEMPLATE_DIR . $filename; 
    485             } 
    486         } 
    487  
    488         // プレビュー用tplファイルのコピー 
    489         $copyTo = USER_PATH . "templates/preview/" . TEMPLATE_NAME . "/" . $filename . ".tpl"; 
    490  
    491         if (!is_dir(dirname($copyTo))) { 
    492             mkdir(dirname($copyTo)); 
    493         } 
    494  
    495         copy($tplfile . ".tpl", $copyTo); 
    496  
    497         // 更新データの取得 
    498         $sql = "select page_name, header_chk, footer_chk from dtb_pagelayout where page_id = ?"; 
    499         $ret = $objDBConn->getAll($sql, array($arrPageData[0]['page_id'])); 
    500  
    501         // dbデータのコピー 
    502         $sql = " update dtb_pagelayout set "; 
    503         $sql .= "     page_name = ?"; 
    504         $sql .= "     ,header_chk = ?"; 
    505         $sql .= "     ,footer_chk = ?"; 
    506         $sql .= "     ,url = ?"; 
    507         $sql .= "     ,tpl_dir = ?"; 
    508         $sql .= "     ,filename = ?"; 
    509         $sql .= "     ,anywhere = ?"; 
    510         $sql .= " where page_id = 0"; 
    511  
    512         $arrUpdData = array($ret[0]['page_id'] 
    513                             ,$ret[0]['page_id'] 
    514                             ,$ret[0]['page_id'] 
    515                             ,USER_DIR . "templates/" . TEMPLATE_NAME . "/" 
    516                             ,USER_DIR . "templates/" . TEMPLATE_NAME . "/" 
    517                             ,$filename 
    518                             
    519                             ); 
    520  
    521         $objDBConn->query($sql,$arrUpdData); 
    522     } 
     233            } 
     234        } 
     235 
     236        // データ削除処理 ベースデータでなければファイルを削除 
     237        if ($_POST['mode'] == 'delete' and  !$objLayout->lfCheckBaseData($page_id)) { 
     238            $objLayout->lfDelPageData($page_id); 
     239            $this->sendRedirect($this->getLocation(DIR_INDEX_URL)); 
     240            exit; 
     241        } 
     242 
     243        // ブロック情報を画面配置用に編集 
     244        $tpl_arrBloc = array(); 
     245        $cnt = 0; 
     246        // 使用されているブロックデータを生成 
     247        foreach($arrBlocPos as $key => $val){ 
     248            if ($val['page_id'] == $page_id) { 
     249                $tpl_arrBloc = $this->lfSetBlocData($arrBloc, $val, $tpl_arrBloc, $cnt); 
     250                $cnt++; 
     251            }else{ 
     252            } 
     253        } 
     254 
     255 
     256        // 未使用のブロックデータを追加 
     257        foreach($arrBloc as $key => $val){ 
     258            if (!$this->lfChkBloc($val, $tpl_arrBloc)) { 
     259                $val['target_id'] = 10;  // 未使用に追加する 
     260                $tpl_arrBloc = $this->lfSetBlocData($arrBloc, $val, $tpl_arrBloc, $cnt); 
     261                $cnt++; 
     262            }else{ 
     263            } 
     264        } 
     265 
     266        $this->tpl_arrBloc = $tpl_arrBloc; 
     267        $this->bloc_cnt = count($tpl_arrBloc); 
     268        $this->page_id = $page_id; 
     269 
     270        // ページ名称を取得 
     271        $arrPageData = $objLayout->lfgetPageData(' page_id = ?', array($page_id)); 
     272        $this->arrPageData = $arrPageData[0]; 
     273 
     274        global $GLOBAL_ERR; 
     275        $errCnt = 0; 
     276        if ($GLOBAL_ERR != "") { 
     277            $arrGlobalErr = explode("\n",$GLOBAL_ERR); 
     278            $errCnt = count($arrGlobalErr) - 8; 
     279            if ($errCnt < 0 ) { 
     280                $errCnt = 0; 
     281            } 
     282        } 
     283        $this->errCnt = $errCnt; 
     284 
     285        // 画面の表示 
     286        $objView->assignobj($this); 
     287        $objView->display(MAIN_FRAME); 
     288 
     289    } 
     290    /** 
     291     * デストラクタ. 
     292     * 
     293     * @return void 
     294     */ 
     295    function destroy() { 
     296        parent::destroy(); 
     297    } 
     298 
     299    /** 
     300     * 編集可能なページ情報を取得する. 
     301     * 
     302     * @param string $sel Select句文 
     303     * @param string $where Where句文 
     304     * @param array $arrVa Where句の絞込条件値 
     305     * @return array ページレイアウト情報の配列 
     306     */ 
     307    function lfgetLayoutData($sel = '' , $from = '', $where = '', $arrVal = ''){ 
     308        $objDBConn = new SC_DbConn;     // DB操作オブジェクト 
     309        $sql = "";                      // データ取得SQL生成用 
     310        $arrRet = array();              // データ取得用 
     311 
     312        // SQL生成 
     313 
     314        $sql = ""; 
     315        $sql .= " select "; 
     316        $sql .= "     lay.page_id "; 
     317        $sql .= "     ,lay.page_name "; 
     318        $sql .= "     ,lay.url "; 
     319        $sql .= "     ,lay.author "; 
     320        $sql .= "     ,lay.description "; 
     321        $sql .= "     ,lay.keyword "; 
     322        $sql .= "     ,lay.update_url "; 
     323        $sql .= "     ,lay.create_date "; 
     324        $sql .= "     ,lay.update_date "; 
     325 
     326        // Select句の指定があれば追加 
     327        if ($sel != '') { 
     328            $sql .= $sel; 
     329        } 
     330 
     331        $sql .= " from dtb_pagelayout AS lay "; 
     332        // From句の指定があれば追加 
     333        if ($from != '') { 
     334            $sql .= $from; 
     335        } 
     336 
     337        // where句の指定があれば追加 
     338        if ($where != '') { 
     339            $sql .= $where; 
     340        }else{ 
     341            $sql .= " ORDER BY lay.page_id "; 
     342        } 
     343 
     344        $arrRet = $objDBConn->getAll($sql, $arrVal); 
     345 
     346        return $arrRet; 
     347    } 
     348 
     349    /** 
     350     * ブロック情報を取得する. 
     351     * 
     352     * @param string $where Where句文 
     353     * @param array $arrVal Where句の絞込条件値 
     354     * @return array ブロック情報の配列 
     355     */ 
     356    function lfgetBlocData($where = '', $arrVal = ''){ 
     357        $objDBConn = new SC_DbConn;     // DB操作オブジェクト 
     358        $sql = "";                      // データ取得SQL生成用 
     359        $arrRet = array();              // データ取得用 
     360 
     361        // SQL生成 
     362        $sql = ""; 
     363        $sql .= " SELECT "; 
     364        $sql .= "   bloc_id"; 
     365        $sql .= "   ,bloc_name"; 
     366        $sql .= "   ,tpl_path"; 
     367        $sql .= "   ,filename"; 
     368        $sql .= "   ,update_date"; 
     369        $sql .= " FROM "; 
     370        $sql .= "   dtb_bloc"; 
     371 
     372        // where句の指定があれば追加 
     373        if ($where != '') { 
     374            $sql .= " WHERE " . $where; 
     375        } 
     376 
     377        $sql .= " ORDER BY  bloc_id"; 
     378 
     379        $arrRet = $objDBConn->getAll($sql, $arrVal); 
     380 
     381        return $arrRet; 
     382    } 
     383 
     384    /** 
     385     * ブロック情報の配列を生成する. 
     386     * 
     387     * @param array $arrBloc Bloc情報 
     388     * @param array $tpl_arrBloc データをセットする配列 
     389     * @param integer $cnt 配列番号 
     390     * @return array データをセットした配列 
     391     */ 
     392    function lfSetBlocData($arrBloc, $val, $tpl_arrBloc, $cnt) { 
     393        $masterData = new SC_DB_MasterData_Ex(); 
     394        $arrTarget = $masterData->getMasterData("mtb_target"); 
     395 
     396        $tpl_arrBloc[$cnt]['target_id'] = $arrTarget[$val['target_id']]; 
     397        $tpl_arrBloc[$cnt]['bloc_id'] = $val['bloc_id']; 
     398        $tpl_arrBloc[$cnt]['bloc_row'] = 
     399        isset($val['bloc_row']) ? $val['bloc_row'] : ""; 
     400        $tpl_arrBloc[$cnt]['anywhere'] = $val['anywhere']; 
     401        if($val['anywhere'] == 1){ 
     402            $tpl_arrBloc[$cnt]['anywhere_selected'] = 'checked="checked"'; 
     403        } 
     404        foreach($arrBloc as $bloc_key => $bloc_val){ 
     405            if ($bloc_val['bloc_id'] == $val['bloc_id']) { 
     406                $bloc_name = $bloc_val['bloc_name']; 
     407                break; 
     408            } 
     409        } 
     410        $tpl_arrBloc[$cnt]['name'] = $bloc_name; 
     411 
     412        return $tpl_arrBloc; 
     413    } 
     414 
     415    /** 
     416     * ブロックIDが配列に追加されているかのチェックを行う. 
     417     * 
     418     * @param array $arrBloc Bloc情報 
     419     * @param array $arrChkData チェックを行うデータ配列 
     420     * @return bool 存在する場合 true 
     421     */ 
     422    function lfChkBloc($arrBloc, $arrChkData) { 
     423        foreach($arrChkData as $key => $val){ 
     424            if ($val['bloc_id'] === $arrBloc['bloc_id'] ) { 
     425                // 配列に存在すればTrueを返す 
     426                return true; 
     427            } 
     428        } 
     429 
     430        // 配列に存在しなければFlaseを返す 
     431        return false; 
     432    } 
     433 
     434    /** 
     435     * ブロックIDが何番目に配置されているかを調べる. 
     436     * 
     437     * @param array $arrUpdData 更新情報 
     438     * @param array $arrObj チェックを行うデータ配列 
     439     * @return integer 順番 
     440     */ 
     441    function lfGetRowID($arrUpdData, $arrObj){ 
     442        $no = 0; // カウント用(同じデータが必ず1件あるので、初期値は0) 
     443 
     444        // 対象データが何番目に配置されているのかを取得する。 
     445        foreach ($arrUpdData as $key => $val) { 
     446            if ($val['target_id'] === $arrObj['target_id'] and $val['top'] <= $arrObj['top']){ 
     447                $no++; 
     448            } 
     449        } 
     450        // 番号を返す 
     451        return $no; 
     452    } 
     453 
     454    /** 
     455     * プレビューするデータを DB に保存する. 
     456     * 
     457     * @param array $arrPageData ページ情報の配列 
     458     * @return void 
     459     */ 
     460    function lfSetPreData($arrPageData, &$objLayout){ 
     461        $objDBConn = new SC_DbConn;     // DB操作オブジェクト 
     462        $sql = "";                      // データ更新SQL生成用 
     463        $ret = "";                      // データ更新結果格納用 
     464        $arrUpdData = array();          // 更新データ生成用 
     465        $filename = $arrPageData[0]['filename']; 
     466 
     467        $arrPreData = $objLayout->lfgetPageData(" page_id = ? " , array("0")); 
     468 
     469        // XXX tplファイルの削除 
     470        $del_tpl = USER_PATH . "templates/" . $filename . '.tpl'; 
     471 
     472        if (file_exists($del_tpl)){ 
     473            unlink($del_tpl); 
     474        } 
     475 
     476        // filename が空の場合にはMYページと判断 
     477        if($filename == ""){ 
     478            $tplfile = TEMPLATE_DIR . "mypage/index"; 
     479            $filename = 'mypage'; 
     480        } else { 
     481            if (file_exists(TEMPLATE_FTP_DIR . $filename . ".tpl")) { 
     482                $tplfile = TEMPLATE_FTP_DIR . $filename; 
     483            } else { 
     484                $tplfile = TEMPLATE_DIR . $filename; 
     485            } 
     486        } 
     487 
     488        // プレビュー用tplファイルのコピー 
     489        $copyTo = USER_PATH . "templates/preview/" . TEMPLATE_NAME . "/" . $filename . ".tpl"; 
     490 
     491        if (!is_dir(dirname($copyTo))) { 
     492            mkdir(dirname($copyTo)); 
     493        } 
     494 
     495        copy($tplfile . ".tpl", $copyTo); 
     496 
     497        // 更新データの取得 
     498        $sql = "select page_id,page_name, header_chk, footer_chk from dtb_pagelayout where page_id = ? OR page_id = (SELECT page_id FROM dtb_blocposition WHERE anywhere = 1)" ; 
     499        echo("####<br/>\n\n".__LINE__ ." in file:".__FILE__."<br/>\n\n ####"); 
     500         
     501        $ret = $objDBConn->getAll($sql, array($arrPageData[0]['page_id'])); 
     502        $objDBConn->getLastQuery(); 
     503                echo("####<br/>\n\n".__LINE__ ." in file:".__FILE__."<br/>\n\n ####"); 
     504 
     505        // dbデータのコピー 
     506        $sql = " update dtb_pagelayout set "; 
     507        $sql .= "     page_name = ?"; 
     508        $sql .= "     ,header_chk = ?"; 
     509        $sql .= "     ,footer_chk = ?"; 
     510        $sql .= "     ,url = ?"; 
     511        $sql .= "     ,tpl_dir = ?"; 
     512        $sql .= "     ,filename = ?"; 
     513//      $sql .= "     ,anywhere = ?"; 
     514        $sql .= " where page_id = 0"; 
     515        var_dump($ret); 
     516                echo("####<br/>\n\n".__LINE__ ." in file:".__FILE__."<br/>\n\n ####"); 
     517 
     518        $arrUpdData = array($ret[0]['page_id'] 
     519        ,$ret[0]['page_id'] 
     520        ,$ret[0]['page_id'] 
     521        ,USER_DIR . "templates/" . TEMPLATE_NAME . "/" 
     522        ,USER_DIR . "templates/" . TEMPLATE_NAME . "/" 
     523        ,$filename 
     524//      ,$ret[0]['anywhere'] 
     525          
     526        ); 
     527        var_dump($arrUpdData); 
     528                echo("####<br/>\n\n".__LINE__ ." in file:".__FILE__."<br/>\n\n ####"); 
     529 
     530        $objDBConn->query($sql,$arrUpdData); 
     531    } 
    523532} 
    524533?> 
  • branches/comu-ver2/html/install/sql/insert_data.sql

    r18194 r18201  
    747747INSERT INTO mtb_target VALUES ('5', 'TopNavi',4); 
    748748INSERT INTO mtb_target VALUES ('6', 'BottomNavi',5); 
    749 INSERT INTO mtb_target VALUES ('7', 'MainFoot',6); 
    750 INSERT INTO mtb_target VALUES ('8', 'TopNavi',7); 
    751 INSERT INTO mtb_target VALUES ('9', 'BottomNavi',8); 
     749INSERT INTO mtb_target VALUES ('7', 'HeadNavi',6); 
     750INSERT INTO mtb_target VALUES ('8', 'HeaderTopNavi',7); 
     751INSERT INTO mtb_target VALUES ('9', 'FooterBottomNavi',8); 
    752752INSERT INTO mtb_target VALUES ('10', 'Unused',9); 
    753753INSERT INTO mtb_review_deny_url VALUES ('0', 'http://',0); 
Note: See TracChangeset for help on using the changeset viewer.