Changeset 15705
- Timestamp:
- 2007/09/14 12:29:24 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/feature-templates/html/admin/design/index.php
r17 r15705 8 8 require_once(DATA_PATH . "include/page_layout.inc"); 9 9 10 // ǧ¾ÚȽÄê 11 sfIsSuccess(new SC_Session()); 12 10 13 class LC_Page { 11 12 13 14 15 16 17 $this->tpl_subno = "layout"; 18 19 20 14 var $arrForm; 15 var $arrHidden; 16 17 function LC_Page() { 18 $this->tpl_mainpage = 'design/index.tpl'; 19 $this->tpl_subnavi = 'design/subnavi.tpl'; 20 $this->tpl_subno = "layout"; 21 $this->tpl_mainno = "design"; 22 $this->tpl_subtitle = '¥ì¥¤¥¢¥¦¥ÈÊÔ½¸'; 23 } 21 24 } 22 25 23 26 $objPage = new LC_Page(); 24 27 $objView = new SC_AdminView(); 25 $objSess = new SC_Session();26 28 27 29 // ¥Ú¡¼¥¸ID¤ò¼èÆÀ 28 30 if (isset($_GET['page_id'])) { 29 31 $page_id = $_GET['page_id']; 30 32 }else if ($_POST['page_id']){ 31 33 $page_id = $_POST['page_id']; 32 34 }else{ 33 35 $page_id = 1; 34 36 } 35 37 … … 49 51 $arrPageData = lfgetPageData("page_id = ?", array($page_id)); 50 52 if (count($arrPageData) <= 0) { 51 53 $exists_page = 0; 52 54 }else{ 53 55 $exists_page = 1; 54 56 } 55 57 $objPage->exists_page = $exists_page; … … 57 59 // ¥á¥Ã¥»¡¼¥¸É½¼¨ 58 60 if ($_GET['msg'] == "on") { 59 61 $objPage->complate_msg="alert('ÅÐÏ¿¤¬´°Î»¤·¤Þ¤·¤¿¡£');"; 60 62 } 61 63 … … 65 67 // ¿·µ¬¥Ö¥í¥Ã¥¯ºîÀ® 66 68 if ($_POST['mode'] == 'new_bloc') { 67 69 header("location: ./bloc.php"); 68 70 } 69 71 70 72 // ¿·µ¬¥Ú¡¼¥¸ºîÀ® 71 73 if ($_POST['mode'] == 'new_page') { 72 74 header("location: ./main_edit.php"); 73 75 } 74 76 75 77 // ¥Ç¡¼¥¿ÅÐÏ¿½èÍý 76 78 if ($_POST['mode'] == 'confirm' or $_POST['mode'] == 'preview') { 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 $arrUpdBlocData[$upd_cnt]['id'] = $_POST['id_'.$upd_cnt]; // ¥Ö¥í¥Ã¥¯ID 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 79 80 $arrPageData = array(); 81 if ($_POST['mode'] == 'preview') { 82 $arrPageData = lfgetPageData(" page_id = ? " , array($page_id)); 83 $page_id = "0"; 84 $_POST['page_id'] = "0"; 85 } 86 87 // ¹¹¿·ÍѤ˥ǡ¼¥¿¤òÀ°¤¨¤ë 88 $arrUpdBlocData = array(); 89 $arrTargetFlip = array_flip($arrTarget); 90 91 $upd_cnt = 1; 92 $arrUpdData[$upd_cnt]['page_id'] = $_POST['page_id']; 93 94 // POST¤Î¥Ç¡¼¥¿¤ò»È¤¤¤ä¤¹¤¤¤è¤¦¤Ë½¤Àµ 95 for($upd_cnt = 1; $upd_cnt <= $_POST['bloc_cnt']; $upd_cnt++){ 96 if (!isset($_POST['id_'.$upd_cnt])) { 97 break; 98 } 99 $arrUpdBlocData[$upd_cnt]['name'] = $_POST['name_'.$upd_cnt]; // ¥Ö¥í¥Ã¥¯Ì¾¾Î 100 $arrUpdBlocData[$upd_cnt]['id'] = $_POST['id_'.$upd_cnt]; // ¥Ö¥í¥Ã¥¯ID 101 $arrUpdBlocData[$upd_cnt]['target_id'] = $arrTargetFlip[$_POST['target_id_'.$upd_cnt]]; // ¥¿¡¼¥²¥Ã¥ÈID 102 $arrUpdBlocData[$upd_cnt]['top'] = $_POST['top_'.$upd_cnt]; // TOPºÂɸ 103 $arrUpdBlocData[$upd_cnt]['update_url'] = $_SERVER['HTTP_REFERER']; // ¹¹¿·URL 104 } 105 106 // ¥Ç¡¼¥¿¤Î¹¹¿·¤ò¹Ô¤¦ 107 $objDBConn = new SC_DbConn; // DBÁàºî¥ª¥Ö¥¸¥§¥¯¥È 108 $arrRet = array(); // ¥Ç¡¼¥¿¼èÆÀÍÑ 109 110 // delete¼Â¹Ô 111 $del_sql = ""; 112 $del_sql .= "DELETE FROM dtb_blocposition WHERE page_id = ? "; 113 $arrRet = $objDBConn->query($del_sql,array($page_id)); 114 115 // ¥Ö¥í¥Ã¥¯¤Î½ç½ø¤ò¼èÆÀ¤·¡¢¹¹¿·¤ò¹Ô¤¦ 116 foreach($arrUpdBlocData as $key => $val){ 117 // ¥Ö¥í¥Ã¥¯¤Î½ç½ø¤ò¼èÆÀ 118 $bloc_row = lfGetRowID($arrUpdBlocData, $val); 119 $arrUpdBlocData[$key]['bloc_row'] = $bloc_row; 120 $arrUpdBlocData[$key]['page_id'] = $_POST['page_id']; // ¥Ú¡¼¥¸ID 121 122 if ($arrUpdBlocData[$key]['target_id'] == 5) { 123 $arrUpdBlocData[$key]['bloc_row'] = "0"; 124 } 125 126 // insertʸÀ¸À® 127 $ins_sql = ""; 128 $ins_sql .= "INSERT INTO dtb_blocposition "; 129 $ins_sql .= " values ( "; 130 $ins_sql .= " ? "; // ¥Ú¡¼¥¸ID 131 $ins_sql .= " ,? "; // ¥¿¡¼¥²¥Ã¥ÈID 132 $ins_sql .= " ,? "; // ¥Ö¥í¥Ã¥¯ID 133 $ins_sql .= " ,? "; // ¥Ö¥í¥Ã¥¯¤Îʤӽç½ø 134 $ins_sql .= " ,(SELECT filename FROM dtb_bloc WHERE bloc_id = ?) "; // ¥Õ¥¡¥¤¥ë̾¾Î 135 $ins_sql .= " ) "; 136 137 // insert¥Ç¡¼¥¿À¸À® 138 $arrInsData = array($page_id, 139 $arrUpdBlocData[$key]['target_id'], 140 $arrUpdBlocData[$key]['id'], 141 $arrUpdBlocData[$key]['bloc_row'], 142 $arrUpdBlocData[$key]['id'] 143 ); 144 // SQL¼Â¹Ô 145 $arrRet = $objDBConn->query($ins_sql,$arrInsData); 146 } 147 148 // ¥×¥ì¥Ó¥å¡¼½èÍý 149 if ($_POST['mode'] == 'preview') { 150 if ($page_id === "") { 151 header("location: ./index.php"); 152 } 153 lfSetPreData($arrPageData); 154 155 $_SESSION['preview'] = "ON"; 156 header("Location: ". URL_DIR . "preview/index.php"); 157 }else{ 158 header("Location: ./index.php?page_id=$page_id&msg=on"); 159 } 158 160 } 159 161 160 162 // ¥Ç¡¼¥¿ºï½ü½èÍý ¥Ù¡¼¥¹¥Ç¡¼¥¿¤Ç¤Ê¤±¤ì¤Ð¥Õ¥¡¥¤¥ë¤òºï½ü 161 163 if ($_POST['mode'] == 'delete' and !lfCheckBaseData($page_id)) { 162 164 lfDelPageData($page_id); 163 165 } 164 166 … … 168 170 // »ÈÍѤµ¤ì¤Æ¤¤¤ë¥Ö¥í¥Ã¥¯¥Ç¡¼¥¿¤òÀ¸À® 169 171 foreach($arrBlocPos as $key => $val){ 170 171 172 173 172 if ($val['page_id'] == $page_id) { 173 $tpl_arrBloc = lfSetBlocData($arrBloc, $val, $tpl_arrBloc, $cnt); 174 $cnt++; 175 } 174 176 } 175 177 176 178 // ̤»ÈÍѤΥ֥í¥Ã¥¯¥Ç¡¼¥¿¤òÄɲà 177 179 foreach($arrBloc as $key => $val){ 178 179 180 181 182 180 if (!lfChkBloc($val, $tpl_arrBloc)) { 181 $val['target_id'] = 5; // ̤»ÈÍѤËÄɲ乤ë 182 $tpl_arrBloc = lfSetBlocData($arrBloc, $val, $tpl_arrBloc, $cnt); 183 $cnt++; 184 } 183 185 } 184 186 … … 191 193 $objPage->arrPageData = $arrPageData[0]; 192 194 193 // ǧ¾Ú²ÄÈݤÎȽÄê194 $objSess = new SC_Session();195 sfIsSuccess($objSess);196 197 195 global $GLOBAL_ERR; 198 196 $errCnt = 0; 199 197 if ($GLOBAL_ERR != "") { 200 201 202 203 204 198 $arrGlobalErr = explode("\n",$GLOBAL_ERR); 199 $errCnt = count($arrGlobalErr) - 8; 200 if ($errCnt < 0 ) { 201 $errCnt = 0; 202 } 205 203 } 206 204 $objPage->errCnt = $errCnt; … … 221 219 **************************************************************************************************************/ 222 220 function lfgetLayoutData($sel = '' , $from = '', $where = '', $arrVal = ''){ 223 224 225 226 227 228 229 230 $sql .= " select "; 231 232 233 234 235 236 237 238 239 240 241 // Select¶ç¤Î»ØÄ꤬¤¢¤ì¤ÐÄɲà 242 243 244 245 246 247 // From¶ç¤Î»ØÄ꤬¤¢¤ì¤ÐÄɲà 248 249 250 251 252 // where¶ç¤Î»ØÄ꤬¤¢¤ì¤ÐÄɲà 253 254 255 256 257 258 259 260 261 221 $objDBConn = new SC_DbConn; // DBÁàºî¥ª¥Ö¥¸¥§¥¯¥È 222 $sql = ""; // ¥Ç¡¼¥¿¼èÆÀSQLÀ¸À®ÍÑ 223 $arrRet = array(); // ¥Ç¡¼¥¿¼èÆÀÍÑ 224 225 // SQLÀ¸À® 226 227 $sql = ""; 228 $sql .= " select "; 229 $sql .= " lay.page_id "; 230 $sql .= " ,lay.page_name "; 231 $sql .= " ,lay.url "; 232 $sql .= " ,lay.author "; 233 $sql .= " ,lay.description "; 234 $sql .= " ,lay.keyword "; 235 $sql .= " ,lay.update_url "; 236 $sql .= " ,lay.create_date "; 237 $sql .= " ,lay.update_date "; 238 239 // Select¶ç¤Î»ØÄ꤬¤¢¤ì¤ÐÄɲà 240 if ($sel != '') { 241 $sql .= $sel; 242 } 243 244 $sql .= " from dtb_pagelayout AS lay "; 245 // From¶ç¤Î»ØÄ꤬¤¢¤ì¤ÐÄɲà 246 if ($from != '') { 247 $sql .= $from; 248 } 249 250 // where¶ç¤Î»ØÄ꤬¤¢¤ì¤ÐÄɲà 251 if ($where != '') { 252 $sql .= $where; 253 }else{ 254 $sql .= " ORDER BY lay.page_id "; 255 } 256 257 $arrRet = $objDBConn->getAll($sql, $arrVal); 258 259 return $arrRet; 262 260 } 263 261 … … 270 268 **************************************************************************************************************/ 271 269 function lfgetBlocData($where = '', $arrVal = ''){ 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 // where¶ç¤Î»ØÄ꤬¤¢¤ì¤ÐÄɲà 288 289 290 291 292 293 294 295 296 270 $objDBConn = new SC_DbConn; // DBÁàºî¥ª¥Ö¥¸¥§¥¯¥È 271 $sql = ""; // ¥Ç¡¼¥¿¼èÆÀSQLÀ¸À®ÍÑ 272 $arrRet = array(); // ¥Ç¡¼¥¿¼èÆÀÍÑ 273 274 // SQLÀ¸À® 275 $sql = ""; 276 $sql .= " SELECT "; 277 $sql .= " bloc_id"; 278 $sql .= " ,bloc_name"; 279 $sql .= " ,tpl_path"; 280 $sql .= " ,filename"; 281 $sql .= " ,update_date"; 282 $sql .= " FROM "; 283 $sql .= " dtb_bloc"; 284 285 // where¶ç¤Î»ØÄ꤬¤¢¤ì¤ÐÄɲà 286 if ($where != '') { 287 $sql .= " WHERE " . $where; 288 } 289 290 $sql .= " ORDER BY bloc_id"; 291 292 $arrRet = $objDBConn->getAll($sql, $arrVal); 293 294 return $arrRet; 297 295 } 298 296 … … 306 304 **************************************************************************************************************/ 307 305 function lfSetBlocData($arrBloc, $val, $tpl_arrBloc, $cnt) { 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 306 global $arrTarget; 307 308 $tpl_arrBloc[$cnt]['target_id'] = $arrTarget[$val['target_id']]; 309 $tpl_arrBloc[$cnt]['bloc_id'] = $val['bloc_id']; 310 $tpl_arrBloc[$cnt]['bloc_row'] = $val['bloc_row']; 311 312 foreach($arrBloc as $bloc_key => $bloc_val){ 313 if ($bloc_val['bloc_id'] == $val['bloc_id']) { 314 $bloc_name = $bloc_val['bloc_name']; 315 break; 316 } 317 } 318 $tpl_arrBloc[$cnt]['name'] = $bloc_name; 319 320 return $tpl_arrBloc; 323 321 } 324 322 … … 332 330 **************************************************************************************************************/ 333 331 function lfChkBloc($arrBloc, $arrChkData) { 334 335 336 337 338 339 340 341 342 332 foreach($arrChkData as $key => $val){ 333 if ($val['bloc_id'] === $arrBloc['bloc_id'] ) { 334 // ÇÛÎó¤Ë¸ºß¤¹¤ì¤ÐTrue¤òÊÖ¤¹ 335 return true; 336 } 337 } 338 339 // ÇÛÎó¤Ë¸ºß¤·¤Ê¤±¤ì¤ÐFlase¤òÊÖ¤¹ 340 return false; 343 341 } 344 342 … … 351 349 **************************************************************************************************************/ 352 350 function lfGetRowID($arrUpdData, $arrObj){ 353 354 355 356 357 358 359 360 361 362 351 $no = 0; // ¥«¥¦¥ó¥ÈÍÑ¡ÊƱ¤¸¥Ç¡¼¥¿¤¬É¬¤º1·ï¤¢¤ë¤Î¤Ç¡¢½é´üÃͤÏ0¡Ë 352 353 // Âоݥǡ¼¥¿¤¬²¿ÈÖÌܤËÇÛÃÖ¤µ¤ì¤Æ¤¤¤ë¤Î¤«¤ò¼èÆÀ¤¹¤ë¡£ 354 foreach ($arrUpdData as $key => $val) { 355 if ($val['target_id'] === $arrObj['target_id'] and $val['top'] <= $arrObj['top']){ 356 $no++; 357 } 358 } 359 // ÈÖ¹æ¤òÊÖ¤¹ 360 return $no; 363 361 } 364 362 … … 371 369 **************************************************************************************************************/ 372 370 function lfSetPreData($arrPageData){ 373 374 375 376 377 378 379 380 381 382 383 384 unlink($del_tpl); 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 } 371 $objDBConn = new SC_DbConn; // DBÁàºî¥ª¥Ö¥¸¥§¥¯¥È 372 $sql = ""; // ¥Ç¡¼¥¿¹¹¿·SQLÀ¸À®ÍÑ 373 $ret = ""; // ¥Ç¡¼¥¿¹¹¿··ë²Ì³ÊǼÍÑ 374 $arrUpdData = array(); // ¹¹¿·¥Ç¡¼¥¿À¸À®ÍÑ 375 $filename = uniqid(""); 376 377 $arrPreData = lfgetPageData(" page_id = ? " , array("0")); 378 379 // tpl¥Õ¥¡¥¤¥ë¤Îºï½ü 380 $del_tpl = USER_PATH . "templates/" . $arrPreData[0]['filename'] . '.tpl'; 381 if (file_exists($del_tpl)){ 382 unlink($del_tpl); 383 } 384 385 // ¥×¥ì¥Ó¥å¡¼ÍÑtpl¥Õ¥¡¥¤¥ë¤Î¥³¥Ô¡¼ 386 $tplfile = $arrPageData[0]['tpl_dir'] . $arrPageData[0]['filename']; 387 388 if($tplfile == ""){ 389 // tpl¥Õ¥¡¥¤¥ë¤¬¶õ¤Î¾ì¹ç¤Ë¤ÏMY¥Ú¡¼¥¸¤ÈȽÃÇ 390 $tplfile = "user_data/templates/mypage/index"; 391 } 392 copy(HTML_PATH . $tplfile . ".tpl", USER_PATH . "templates/" . $filename . ".tpl"); 393 394 // ¹¹¿·¥Ç¡¼¥¿¤Î¼èÆÀ 395 $sql = "select page_name, header_chk, footer_chk from dtb_pagelayout where page_id = ?"; 396 $ret = $objDBConn->getAll($sql, array($arrPageData[0]['page_id'])); 397 398 // db¥Ç¡¼¥¿¤Î¥³¥Ô¡¼ 399 $sql = " update dtb_pagelayout set "; 400 $sql .= " page_name = ?"; 401 $sql .= " ,header_chk = ?"; 402 $sql .= " ,footer_chk = ?"; 403 $sql .= " ,url = ?"; 404 $sql .= " ,tpl_dir = ?"; 405 $sql .= " ,filename = ?"; 406 $sql .= " where page_id = 0"; 407 408 $arrUpdData = array($ret[0]['page_id'] 409 ,$ret[0]['page_id'] 410 ,$ret[0]['page_id'] 411 ,USER_DIR."templates/" 412 ,USER_DIR."templates/" 413 ,$filename 414 ); 415 416 $objDBConn->query($sql,$arrUpdData); 417 }
Note: See TracChangeset
for help on using the changeset viewer.