Changeset 18212 for branches/comu-ver2/data/class/pages/admin
- Timestamp:
- 2009/07/19 23:31:46 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/comu-ver2/data/class/pages/admin/design/LC_Page_Admin_Design.php
r18211 r18212 34 34 class LC_Page_Admin_Design extends LC_Page { 35 35 36 // }}}37 // {{{ functions38 39 /**40 * Page を初期化する.41 *42 * @return void43 */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 void57 */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]; // ブロックID146 $arrUpdBlocData[$upd_cnt]['target_id'] = $arrTargetFlip[$_POST['target_id_'.$upd_cnt]]; // ターゲットID147 $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']; // 更新URL150 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; // ページID168 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 .= " ? "; // ページID181 $ins_sql .= " ,? "; // ターゲットID182 $ins_sql .= " ,? "; // ブロックID183 $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, 230 230 "msg" => "on"))); 231 exit;232 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 void231 exit; 232 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 294 */ 295 295 function destroy() {
Note: See TracChangeset
for help on using the changeset viewer.
