Changeset 20830 for branches/version-2_11-dev/data/class/pages/admin/design/LC_Page_Admin_Design.php
- Timestamp:
- 2011/04/12 22:58:10 (13 years ago)
- bzr:base-revision:
- svn-v4:1e3b908f-19a9-db11-a64c-001125224ba8:branches/version-2_11-dev:20829
- bzr:committer:
- Kentaro Ohkouchi <ohkouchi@loop-az.jp>
- bzr:file-ids:
data/Smarty/templates/admin/design/index.tpl 15732@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2FSmarty%2Ftemplates%2Fdefault%2Fadmin%2Fdesign%2Findex.tpl
data/class/SC_FormParam.php 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2FSC_FormParam.php
data/class/helper/SC_Helper_PageLayout.php 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fhelper%2FSC_Helper_PageLayout.php
data/class/pages/admin/design/LC_Page_Admin_Design.php 15680@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fadmin%2Fdesign%2FLC_Page_Admin_Design.php
data/class/pages/admin/design/LC_Page_Admin_Design_MainEdit.php 15682@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fadmin%2Fdesign%2FLC_Page_Admin_Design_MainEdit.php- bzr:mapping-version:
- v4
- bzr:merge:
ohkouchi@loop-az.jp-20110412135550-rrkz5279jtmkd6rz- bzr:repository-uuid:
- 1e3b908f-19a9-db11-a64c-001125224ba8
- bzr:revision-id:
- ohkouchi@loop-az.jp-20110412135757-jzouuuwavr7z993z
- bzr:revno:
- 3541
- bzr:revprop:branch-nick:
- branches/version-2_11-dev
- bzr:root:
- branches/version-2_11-dev
- bzr:text-revisions:
data/Smarty/templates/admin/design/index.tpl ohkouchi@loop-az.jp-20110412135550-rrkz5279jtmkd6rz
data/class/SC_FormParam.php ohkouchi@loop-az.jp-20110412135550-rrkz5279jtmkd6rz
data/class/helper/SC_Helper_PageLayout.php ohkouchi@loop-az.jp-20110412135550-rrkz5279jtmkd6rz
data/class/pages/admin/design/LC_Page_Admin_Design.php ohkouchi@loop-az.jp-20110412135550-rrkz5279jtmkd6rz
data/class/pages/admin/design/LC_Page_Admin_Design_MainEdit.php ohkouchi@loop-az.jp-20110412135550-rrkz5279jtmkd6rz- bzr:timestamp:
- 2011-04-12 22:57:57.092000008 +0900
- bzr:user-agent:
- bzr2.2.1+bzr-svn1.0.4
- svn:original-date:
- 2011-04-12T13:57:57.092000Z
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_11-dev/data/class/pages/admin/design/LC_Page_Admin_Design.php
r20764 r20830 28 28 * デザイン管理 のページクラス. 29 29 * 30 * ターゲットID 0:未使用 1:レフトナビ 2:ライトナビ 3:イン画面上部 4:メイン画面下部 5:画面上部 6:画面下部 7:ヘッダより上 8:フッタより下 9:HEADタグ内 10:ヘッダ内部31 30 * @package Page 32 31 * @author LOCKON CO.,LTD. … … 68 67 * Page のアクション. 69 68 * 70 * TODO パラメータの数値チェック71 *72 69 * @return void 73 70 */ 74 71 function action() { 75 72 $objLayout = new SC_Helper_PageLayout_Ex(); 76 77 // ページIDを取得 78 if (isset($_REQUEST['page_id']) && is_numeric($_REQUEST['page_id'])) { 79 $page_id = $_REQUEST['page_id']; 80 } else { 81 $page_id = 1; // FIXME $_REQUEST['page_id'] を受け取れない不具合時に不正処理が行なわれる原因となった 82 } 83 // 端末種別IDを取得 84 if (isset($_REQUEST['device_type_id']) 85 && is_numeric($_REQUEST['device_type_id'])) { 86 $device_type_id = $_REQUEST['device_type_id']; 87 } else { 88 $device_type_id = DEVICE_TYPE_PC; 89 } 90 91 //サブタイトルの追加 92 $this->tpl_subtitle .= ' - ' . $this->arrDeviceType[$device_type_id]; 93 94 // 編集可能ページを取得 95 $this->arrEditPage = $objLayout->lfGetPageData("page_id <> 0 AND device_type_id = ?", array($device_type_id)); 96 97 // レイアウト情報を取得 98 $arrBlocPos = $objLayout->lfGetNaviData($page_id, $device_type_id); 99 100 // データの存在チェックを行う 101 $arrPageData = $objLayout->lfGetPageData("page_id = ? AND device_type_id = ?", array($page_id, $device_type_id)); 102 103 if (count($arrPageData) <= 0) { 104 $this->exists_page = 0; 105 }else{ 106 $this->exists_page = 1; 107 } 108 109 // メッセージ表示 110 if (isset($_GET['msg']) && $_GET['msg'] == 'on') { 111 $this->complate_msg="alert('登録が完了しました。');"; 112 } 113 114 // ブロックを取得 115 $objQuery = SC_Query_Ex::getSingletonInstance(); 116 $arrBloc = $objQuery->select("*", "dtb_bloc", "device_type_id = ?", array($device_type_id)); 73 $objFormParam = new SC_FormParam_Ex(); 74 $this->lfInitParam($objFormParam, intval($_REQUEST['bloc_cnt'])); 75 $objFormParam->setParam($_REQUEST); 76 77 $this->device_type_id = $objFormParam->getValue('device_type_id', DEVICE_TYPE_PC); 78 $this->page_id = $objFormParam->getValue('page_id', 1); 117 79 118 80 switch ($this->getMode()) { 119 81 // 新規ブロック作成 120 82 case 'new_bloc': 121 SC_Response_Ex::sendRedirect('bloc.php', array("device_type_id" => $ device_type_id));83 SC_Response_Ex::sendRedirect('bloc.php', array("device_type_id" => $this->device_type_id)); 122 84 exit; 123 85 break; … … 125 87 // 新規ページ作成 126 88 case 'new_page': 127 SC_Response_Ex::sendRedirect('main_edit.php', array("device_type_id" => $ device_type_id));89 SC_Response_Ex::sendRedirect('main_edit.php', array("device_type_id" => $this->device_type_id)); 128 90 exit; 129 91 break; 130 92 93 // プレビュー 94 case 'preview': 95 $this->placingBlocs($objFormParam, true); 96 $filename = $this->savePreviewData($this->page_id, $objLayout); 97 $_SESSION['preview'] = 'ON'; 98 SC_Response_Ex::sendRedirectFromUrlPath('preview/' . DIR_INDEX_PATH, array('filename' => $filename)); 99 exit; 100 101 // 編集実行 131 102 case 'confirm': 132 case 'preview': 133 //TODO 要リファクタリング(MODE if利用) 134 $page_id = $_POST['page_id']; 135 if ($this->getMode() == 'preview') { 136 $page_id = '0'; 137 } 138 139 // 更新用にデータを整える 140 $arrUpdBlocData = array(); 141 142 // delete実行 143 $arrRet = $objQuery->delete("dtb_blocposition", 144 "page_id = ? AND device_type_id = ?", 145 array($page_id, $device_type_id)); 146 147 $arrTargetFlip = array_flip($this->arrTarget); 148 149 // POSTのデータを使いやすいように修正 150 for ($upd_cnt = 1; $upd_cnt <= $_POST['bloc_cnt']; $upd_cnt++) { 151 if (!isset($_POST['id_'.$upd_cnt])) { 152 break; 153 } 154 155 // ブロック名称 156 $arrUpdBlocData[$upd_cnt]['name'] = $_POST['name_'.$upd_cnt]; 157 // ブロックID 158 $arrUpdBlocData[$upd_cnt]['id'] = $_POST['id_'.$upd_cnt]; 159 // ターゲットID 160 $arrUpdBlocData[$upd_cnt]['target_id'] = $arrTargetFlip[$_POST['target_id_'.$upd_cnt]]; 161 // TOP座標 162 $arrUpdBlocData[$upd_cnt]['top'] = $_POST['top_'.$upd_cnt]; 163 // 全ページ適用か 164 $arrUpdBlocData[$upd_cnt]['anywhere'] = $_POST['anywhere_'.$upd_cnt]; 165 // 更新URL 166 $arrUpdBlocData[$upd_cnt]['update_url'] = $_SERVER['HTTP_REFERER']; 167 } 168 169 // ブロックの順序を取得し、更新を行う 170 foreach ($arrUpdBlocData as $key => $val) { 171 if ($arrUpdBlocData[$key]['target_id'] == TARGET_ID_UNUSED) { 172 continue; 173 } 174 175 // ブロックの順序を取得 176 $arrUpdBlocData[$key]['bloc_row'] = $this->lfGetRowID($arrUpdBlocData, $val); 177 178 // insertデータ生成 179 $arrInsData = array('device_type_id' => $device_type_id, 180 'page_id' => $page_id, 181 'target_id' => $arrUpdBlocData[$key]['target_id'], 182 'bloc_id' => $arrUpdBlocData[$key]['id'], 183 'bloc_row' => $arrUpdBlocData[$key]['bloc_row'], 184 'anywhere' => $arrUpdBlocData[$key]['anywhere'] ? 1 : 0); 185 $count = $objQuery->getOne("SELECT COUNT(*) FROM dtb_blocposition WHERE anywhere = 1 AND bloc_id = ? AND device_type_id = ?", 186 array($arrUpdBlocData[$key]['id'], $device_type_id)); 187 188 if ($arrUpdBlocData[$key]['anywhere'] == 1) { 189 $count = $objQuery->getOne("SELECT COUNT(*) FROM dtb_blocposition WHERE anywhere = 1 AND bloc_id = ? AND device_type_id = ?", 190 array($arrUpdBlocData[$key]['id'], $device_type_id)); 191 if ($count != 0) { 192 continue; 193 } 194 } else { 195 if ($count > 0) { 196 $objQuery->query("DELETE FROM dtb_blocposition WHERE anywhere = 1 AND bloc_id = ? AND device_type_id = ?", 197 array($arrUpdBlocData[$key]['id'], $device_type_id)); 198 } 199 } 200 // SQL実行 201 $arrRet = $objQuery->insert("dtb_blocposition", $arrInsData); 202 } 203 204 // プレビュー処理 TODO 要リファクタリング(MODE if利用) 205 if ($this->getMode() == 'preview') { 206 $this->lfSetPreData($arrPageData, $objLayout); 207 208 $_SESSION['preview'] = 'ON'; 209 210 SC_Response_Ex::sendRedirectFromUrlPath('preview/' . DIR_INDEX_PATH, array('filename' => $arrPageData[0]['filename'])); 211 exit; 212 213 } else { 214 $arrQueryString = array("device_type_id" => $device_type_id, "page_id" => $page_id, 'msg' => 'on'); 215 SC_Response_Ex::reload($arrQueryString, true); 216 exit; 217 } 103 $this->placingBlocs($objFormParam); 104 $arrQueryString = array("device_type_id" => $this->device_type_id, "page_id" => $this->page_id, 'msg' => 'on'); 105 SC_Response_Ex::reload($arrQueryString, true); 106 exit; 107 218 108 break; 219 109 … … 221 111 case 'delete': 222 112 //ベースデータでなければファイルを削除 223 if ( !$objLayout->lfCheckBaseData($page_id, $device_type_id)) {224 $objLayout->lfDelPageData($ page_id, $device_type_id);225 SC_Response_Ex::reload(array('device_type_id' => $ device_type_id), true);113 if ($objLayout->isEditablePage($this->device_type_id, $this->page_id)) { 114 $objLayout->lfDelPageData($this->page_id, $this->device_type_id); 115 SC_Response_Ex::reload(array('device_type_id' => $this->device_type_id), true); 226 116 exit; 227 117 } … … 229 119 230 120 default: 231 } 232 233 // ブロック情報を画面配置用に編集 234 $tpl_arrBloc = array(); 235 $cnt = 0; 236 // 使用されているブロックデータを生成 237 foreach($arrBlocPos as $key => $val){ 238 if ($val['page_id'] == $page_id) { 239 $tpl_arrBloc = $this->lfSetBlocData($arrBloc, $val, $tpl_arrBloc, $cnt); 240 $cnt++; 241 } 242 } 243 // 未使用のブロックデータを追加 244 foreach($arrBloc as $key => $val){ 245 if (!$this->lfChkBloc($val, $tpl_arrBloc)) { 246 $val['target_id'] = TARGET_ID_UNUSED; // 未使用に追加する 247 $tpl_arrBloc = $this->lfSetBlocData($arrBloc, $val, $tpl_arrBloc, $cnt); 248 $cnt++; 249 } 250 } 251 252 $this->tpl_arrBloc = $tpl_arrBloc; 253 $this->bloc_cnt = count($tpl_arrBloc); 254 $this->page_id = $page_id; 255 $this->device_type_id = $device_type_id; 256 257 // ページ名称を取得 258 $arrPageData = $objLayout->lfGetPageData('page_id = ? AND device_type_id = ?', array($page_id, $device_type_id)); 259 $this->arrPageData = $arrPageData[0]; 260 261 global $GLOBAL_ERR; 262 $errCnt = 0; 263 if ($GLOBAL_ERR != "") { 264 $arrGlobalErr = explode("\n",$GLOBAL_ERR); 265 $errCnt = count($arrGlobalErr) - 8; 266 if ($errCnt < 0 ) { 267 $errCnt = 0; 268 } 269 } 270 $this->errCnt = $errCnt; 121 // 完了メッセージ表示 122 if (isset($_GET['msg']) && $_GET['msg'] == 'on') { 123 $this->tpl_onload="alert('登録が完了しました。');"; 124 } 125 } 126 127 $this->arrBlocs = $this->getLayout($this->device_type_id, $this->page_id, $objLayout); 128 $this->bloc_cnt = count($this->arrBlocs); 129 // 編集中のページ 130 $this->arrPageData = $objLayout->getPageProperties($this->device_type_id, $this->page_id); 131 // 編集可能ページ一覧 132 $this->arrEditPage = $objLayout->getPageProperties($this->device_type_id, null); 133 //サブタイトルを取得 134 $this->tpl_subtitle .= ' - ' . $this->arrDeviceType[$this->device_type_id]; 271 135 } 272 136 … … 281 145 282 146 /** 283 * ブロック情報の配列を生成する. 284 * 285 * @param array $arrBloc Bloc情報 286 * @param array $tpl_arrBloc データをセットする配列 287 * @param array $val DBから取得したブロック情報 147 * フォームパラメータの初期化を行う. 148 * 149 * @param SC_FormParam $objFormParam SC_FormParam インスタンス. 150 * @param integer $bloc_cnt ブロック数 151 * @return void 152 */ 153 function lfInitParam(&$objFormParam, $bloc_cnt = 0) { 154 $objFormParam->addParam("ページID", "page_id", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); 155 $objFormParam->addParam("端末種別ID", "device_type_id", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); 156 $objFormParam->addParam("ブロック数", "bloc_cnt", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); 157 158 for ($i = 1; $i <= $bloc_cnt; $i++) { 159 $objFormParam->addParam("ブロック名", "name_" . $i, STEXT_LEN, 'a', array("MAX_LENGTH_CHECK", "GRAPH_CHECK")); 160 $objFormParam->addParam("ブロックID", "id_" . $i, INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); 161 $objFormParam->addParam("ターゲットID", "target_id_" . $i, STEXT_LEN, 'a', array("MAX_LENGTH_CHECK", "ALNUM_CHECK")); 162 $objFormParam->addParam("TOP座標", "top_" . $i, INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); 163 $objFormParam->addParam("全ページ", "anywhere_" . $i, INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); 164 } 165 } 166 167 /** 168 * ブロックのレイアウト情報を取得する. 169 * 170 * @param integer $device_type_id 端末種別ID 171 * @param integer $page_id ページID 172 * @param SC_Helper_PageLayout $objLayout SC_Helper_PageLayout インスタンス 173 * @return array レイアウト情報の配列 174 */ 175 function getLayout($device_type_id, $page_id, &$objLayout) { 176 $arrResults = array(); 177 $i = 0; 178 179 // レイアウト済みのブロックデータを追加 180 $arrBlocPos = $objLayout->getBlocPositions($device_type_id, $page_id); 181 foreach($arrBlocPos as $arrBloc){ 182 $this->copyBloc($arrResults, $arrBloc, $i); 183 $i++; 184 } 185 186 // 未使用のブロックデータを追加 187 $arrBloc = $objLayout->getBlocs($device_type_id); 188 foreach($arrBloc as $arrBloc){ 189 if (!$this->existsBloc($arrBloc, $arrResults)) { 190 $arrBloc['target_id'] = TARGET_ID_UNUSED; 191 $this->copyBloc($arrResults, $arrBloc, $i); 192 $i++; 193 } 194 } 195 return $arrResults; 196 } 197 198 /** 199 * ブロック情報の配列をコピーする. 200 * 201 * @param array $arrDest コピー先ブロック情報 202 * @param array $arrFrom コピー元ブロック情報 288 203 * @param integer $cnt 配列番号 289 * @return array データをセットした配列 290 */ 291 function lfSetBlocData($arrBloc, $val, $tpl_arrBloc, $cnt) { 292 293 $tpl_arrBloc[$cnt]['target_id'] = $this->arrTarget[$val['target_id']]; 294 $tpl_arrBloc[$cnt]['bloc_id'] = $val['bloc_id']; 295 $tpl_arrBloc[$cnt]['bloc_row'] = 296 isset($val['bloc_row']) ? $val['bloc_row'] : ""; 297 $tpl_arrBloc[$cnt]['anywhere'] = $val['anywhere']; 298 if($val['anywhere'] == 1){ 299 $tpl_arrBloc[$cnt]['anywhere_selected'] = 'checked="checked"'; 300 } 301 foreach($arrBloc as $bloc_key => $bloc_val){ 302 if ($bloc_val['bloc_id'] == $val['bloc_id']) { 303 $bloc_name = $bloc_val['bloc_name']; 304 break; 305 } 306 } 307 $tpl_arrBloc[$cnt]['name'] = $bloc_name; 308 309 return $tpl_arrBloc; 310 } 311 312 /** 313 * ブロックIDが配列に追加されているかのチェックを行う. 314 * 315 * @param array $arrBloc Bloc情報 316 * @param array $arrChkData チェックを行うデータ配列 204 * @return void 205 */ 206 function copyBloc(&$arrDest, $arrFrom, $cnt) { 207 $arrDest[$cnt]['target_id'] = $this->arrTarget[$arrFrom['target_id']]; 208 $arrDest[$cnt]['bloc_id'] = $arrFrom['bloc_id']; 209 $arrDest[$cnt]['bloc_row'] = $arrFrom['bloc_row']; 210 $arrDest[$cnt]['anywhere'] = $arrFrom['anywhere']; 211 $arrDest[$cnt]['name'] = $arrFrom['bloc_name']; 212 } 213 214 /** 215 * ブロックIDがコピー先の配列に追加されているかのチェックを行う. 216 * 217 * @param array $arrBloc ブロックの配列 218 * @param array $arrToBlocs チェックを行うデータ配列 317 219 * @return bool 存在する場合 true 318 220 */ 319 function lfChkBloc($arrBloc, $arrChkData) { 320 foreach($arrChkData as $key => $val){ 321 if ($val['bloc_id'] === $arrBloc['bloc_id'] ) { 322 // 配列に存在すればTrueを返す 221 function existsBloc($arrBloc, $arrToBlocs) { 222 foreach($arrToBlocs as $arrToBloc){ 223 if ($arrBloc['bloc_id'] === $arrToBloc['bloc_id'] ) { 323 224 return true; 324 225 } 325 226 } 326 327 // 配列に存在しなければFlaseを返す328 227 return false; 329 228 } 330 229 331 230 /** 332 * ブロックIDが何番目に配置されているかを調べる.333 *334 * @param array $arrUpdData 更新情報335 * @param array $arrObj チェックを行うデータ配列336 * @return integer 順番337 */338 function lfGetRowID($arrUpdData, $arrObj){339 $no = 0; // カウント用(同じデータが必ず1件あるので、初期値は0)340 341 // 対象データが何番目に配置されているのかを取得する。342 foreach ($arrUpdData as $key => $val) {343 if ($val['target_id'] === $arrObj['target_id'] and $val['top'] <= $arrObj['top']){344 $no++;345 }346 }347 // 番号を返す348 return $no;349 }350 351 /**352 231 * プレビューするデータを DB に保存する. 353 232 * 354 * FIXME 355 * 356 * @param array $arrPageData ページ情報の配列 357 * @return void 358 */ 359 function lfSetPreData($arrPageData, &$objLayout){ 360 $objQuery = new SC_Query_Ex(); // DB操作オブジェクト 361 $sql = ""; // データ更新SQL生成用 362 $ret = ""; // データ更新結果格納用 363 $arrUpdData = array(); // 更新データ生成用 364 $filename = $arrPageData[0]['filename']; 365 366 $arrPreData = $objLayout->lfgetPageData(" page_id = ? " , array("0")); 367 368 // XXX tplファイルの削除 369 $del_tpl = USER_REALDIR . "templates/" . $filename . '.tpl'; 370 371 if (file_exists($del_tpl)){ 372 unlink($del_tpl); 373 } 374 375 // filename が空の場合にはMYページと判断 376 if($filename == ""){ 377 $tplfile = TEMPLATE_REALDIR . "mypage/index"; 378 $filename = 'mypage'; 379 } else { 380 $tplfile = TEMPLATE_REALDIR . $filename; 381 } 382 383 // プレビュー用tplファイルのコピー 384 $copyTo = USER_REALDIR . "templates/preview/" . TEMPLATE_NAME . "/" . $filename . ".tpl"; 385 386 if (!is_dir(dirname($copyTo))) { 387 mkdir(dirname($copyTo)); 388 } 389 390 copy($tplfile . ".tpl", $copyTo); 391 392 // 更新データの取得 393 $sql = "select page_id,page_name, header_chk, footer_chk from dtb_pagelayout where page_id = ? OR page_id = ANY (SELECT page_id FROM dtb_blocposition WHERE anywhere = 1)" ; 394 395 $ret = $objQuery->getAll($sql, array($arrPageData[0]['page_id'])); 396 397 // dbデータのコピー 398 $sql = " update dtb_pagelayout set "; 399 $sql .= " page_name = ?"; 400 $sql .= " ,header_chk = ?"; 401 $sql .= " ,footer_chk = ?"; 402 $sql .= " ,url = ?"; 403 $sql .= " ,filename = ?"; 404 // $sql .= " ,anywhere = ?"; 405 $sql .= " where page_id = 0"; 406 var_dump($ret); 407 echo("####<br/>\n\n".__LINE__ ." in file:".__FILE__."<br/>\n\n ####"); 408 409 $arrUpdData = array($ret[0]['page_id'] 410 ,$ret[0]['page_id'] 411 ,$ret[0]['page_id'] 412 ,USER_DIR . "templates/" . TEMPLATE_NAME . "/" 413 ,$filename 414 // ,$ret[0]['anywhere'] 415 416 ); 417 418 $objQuery->query($sql,$arrUpdData); 233 * @param integer $page_id プレビューを行うページID 234 * @param SC_Helper_PageLayout $objLayout SC_Helper_PageLayout インスタンス 235 * @return string プレビューを行う tpl_mainpage ファイル名 236 */ 237 function savePreviewData($page_id, &$objLayout){ 238 $arrPageData = $objLayout->getPageProperties(DEVICE_TYPE_PC, $page_id); 239 $objQuery =& SC_Query_Ex::getSingletonInstance(); 240 $arrPageData[0]['page_id'] = 0; 241 $objQuery->update('dtb_pagelayout', $arrPageData[0], 'page_id = 0 AND device_type_id = ?', array(DEVICE_TYPE_PC)); 242 return $arrPageData[0]['filename']; 243 } 244 245 /** 246 * ブロックを配置する. 247 * 248 * @param SC_FormParam $objFormParam SC_FormParam インスタンス 249 * @param boolean $is_preview プレビュー時の場合 true 250 * @return void 251 */ 252 function placingBlocs(&$objFormParam, $is_preview = false) { 253 $page_id = $is_preview ? 0 : $objFormParam->getValue('page_id'); 254 $device_type_id = $objFormParam->getValue('device_type_id'); 255 $bloc_cnt = $objFormParam->getValue('bloc_cnt'); 256 $objQuery =& SC_Query_Ex::getSingletonInstance(); 257 $objQuery->begin(); 258 $objQuery->delete("dtb_blocposition", "page_id = ? AND device_type_id = ?", 259 array($page_id, $device_type_id)); 260 $arrTargetFlip = array_flip($this->arrTarget); 261 var_dump($objFormParam->getHashArray()); 262 var_dump($_POST); 263 for ($i = 1; $i <= $bloc_cnt; $i++) { 264 // bloc_id が取得できない場合は INSERT しない 265 $id = $objFormParam->getValue('id_' . $i); 266 if (SC_Utils_Ex::isBlank($id)) { 267 continue; 268 } 269 // 未使用は INSERT しない 270 $arrParams['target_id'] = $arrTargetFlip[$objFormParam->getValue('target_id_' . $i)]; 271 if ($arrParams['target_id'] == TARGET_ID_UNUSED) { 272 continue; 273 } 274 275 // 他のページに anywhere が存在する場合は INSERT しない 276 $arrParams['anywhere'] = intval($objFormParam->getValue('anywhere_' . $i)); 277 if ($arrParams['anywhere'] == 1) { 278 $count = $objQuery->count('dtb_blocposition', 'anywhere = 1 AND bloc_id = ? AND device_type_id = ?', 279 array($id, $device_type_id)); 280 if ($count > 0) { 281 continue; 282 } 283 } 284 285 $arrParams['device_type_id'] = $device_type_id; 286 $arrParams['page_id'] = $page_id; 287 $arrParams['bloc_id'] = $id; 288 $arrParams['bloc_row'] = $objFormParam->getValue('top_' . $i); 289 290 $objQuery->insert("dtb_blocposition", $arrParams); 291 } 292 $objQuery->commit(); 419 293 } 420 294 }
Note: See TracChangeset
for help on using the changeset viewer.