Changeset 20857
- Timestamp:
- 2011/04/18 18:30:03 (12 years ago)
- bzr:base-revision:
- svn-v4:1e3b908f-19a9-db11-a64c-001125224ba8:branches/version-2_11-dev:20856
- bzr:committer:
- Kentaro Ohkouchi <ohkouchi@loop-az.jp>
- bzr:file-ids:
data/Smarty/templates/admin/design/bloc.tpl 15732@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2FSmarty%2Ftemplates%2Fdefault%2Fadmin%2Fdesign%2Fbloc.tpl
data/class/pages/admin/design/LC_Page_Admin_Design_Bloc.php 15687@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fadmin%2Fdesign%2FLC_Page_Admin_Design_Bloc.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-20110418092619-3m57hfeourllitfk- bzr:repository-uuid:
- 1e3b908f-19a9-db11-a64c-001125224ba8
- bzr:revision-id:
- ohkouchi@loop-az.jp-20110418092950-v2hq68b8pcbfrg4t
- bzr:revno:
- 3568
- bzr:revprop:branch-nick:
- branches/version-2_11-dev
- bzr:root:
- branches/version-2_11-dev
- bzr:text-revisions:
data/Smarty/templates/admin/design/bloc.tpl ohkouchi@loop-az.jp-20110418092619-3m57hfeourllitfk
data/class/pages/admin/design/LC_Page_Admin_Design_Bloc.php ohkouchi@loop-az.jp-20110418092619-3m57hfeourllitfk
data/class/pages/admin/design/LC_Page_Admin_Design_MainEdit.php ohkouchi@loop-az.jp-20110418092619-3m57hfeourllitfk- bzr:timestamp:
- 2011-04-18 18:29:50.394999981 +0900
- bzr:user-agent:
- bzr2.2.1+bzr-svn1.0.4
- svn:original-date:
- 2011-04-18T09:29:50.395000Z
- Location:
- branches/version-2_11-dev/data
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_11-dev/data/Smarty/templates/admin/design/bloc.tpl
r20853 r20857 28 28 <input type="hidden" name="device_type_id" value="<!--{$device_type_id|h}-->" /> 29 29 30 <div id="design" class="contents-main"> 30 31 <!--{if $arrErr.err != ""}--> 31 32 <div class="message"> … … 99 100 </table> 100 101 <!--{* ▲ブロック一覧 *}--> 101 102 </div> 102 103 </form> -
branches/version-2_11-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Bloc.php
r20853 r20857 24 24 // {{{ requires 25 25 require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php'; 26 require_once CLASS_EX_REALDIR . 'helper_extends/SC_Helper_FileManager_Ex.php'; 26 27 27 28 /** … … 78 79 $is_error = (!SC_Utils_Ex::isBlank($this->arrErr)); 79 80 80 $bloc_id = $objFormParam->getValue('bloc_id'); 81 $this->bloc_id = $bloc_id; 82 83 $device_type_id = $objFormParam->getValue('device_type_id', DEVICE_TYPE_PC); 84 $this->objLayout = new SC_Helper_PageLayout_Ex(); 81 $this->bloc_id = $objFormParam->getValue('bloc_id'); 82 $this->device_type_id = $objFormParam->getValue('device_type_id', DEVICE_TYPE_PC); 83 84 $objLayout = new SC_Helper_PageLayout_Ex(); 85 85 86 86 switch($this->getMode()) { 87 // 登録/更新 87 88 case 'confirm': 88 // エラーチェック 89 $this->arrErr = $this->lfErrorCheck($_POST); 90 91 // エラーがなければ更新処理を行う 92 if (count($this->arrErr) == 0) { 93 // DBへデータを更新する 94 $this->lfEntryBlocData($_POST, $device_type_id); 95 96 // 旧ファイルの削除 97 if (file_exists($tplPath)) { 98 unlink($tplPath); 89 if (!$is_error) { 90 $this->arrErr = $this->lfCheckError($objFormParam, $this->arrErr, $objLayout); 91 if (SC_Utils_Ex::isBlank($this->arrErr)) { 92 $result = $this->doRegister($objFormParam, $objLayout); 93 if ($result !== false) { 94 SC_Response_Ex::reload(array('bloc_id' => $result, 95 'device_type_id' => $this->device_type_id, 96 'msg' => 'on'), true); 97 exit; 98 } 99 99 } 100 101 // ファイル作成 102 $package_path = $this->objLayout->getTemplatePath($device_type_id) . BLOC_DIR; 103 $new_bloc_path = $package_path . $_POST['filename'] . ".tpl"; 104 // ディレクトリの作成 105 SC_Utils_Ex::sfMakeDir($new_bloc_path); 106 $fp = fopen($new_bloc_path,"w"); 107 if (!$fp) { 108 SC_Utils_Ex::sfDispException(); 100 } 101 break; 102 103 // 削除 104 case 'delete': 105 if (!$is_error) { 106 if ($this->doDelete($objFormParam, $objLayout)) { 107 SC_Response_Ex::reload(array('device_type_id' => $this->device_type_id, 108 'msg' => 'on'), true); 109 exit; 109 110 } 110 fwrite($fp, $_POST['bloc_html']); // FIXME いきなり POST はちょっと...111 fclose($fp);112 113 $arrBlocData = $this->lfGetBlocData($device_type_id, "filename = ?",114 array($_POST['filename']));115 116 $bloc_id = $arrBlocData[0]['bloc_id'];117 $arrQueryString = array(118 'bloc_id' => $bloc_id,119 'device_type_id' => $device_type_id,120 'msg' => 'on',121 );122 $this->objDisplay->reload($arrQueryString, true);123 exit;124 }else{125 // エラーがあれば入力時のデータを表示する126 $this->arrBlocData = $_POST;127 111 } 128 112 break; 129 case 'delete': 130 // DBへデータを更新する 131 $objQuery =& SC_Query_Ex::getSingletonInstance(); 132 $sql = ""; // データ更新SQL生成用 133 $ret = ""; // データ更新結果格納用 134 135 // bloc_id が空でない場合にはdeleteを実行 136 if ($bloc_id !== '') { 137 $objQuery->delete('dtb_bloc', 'bloc_id = ? AND device_type_id = ?', array($bloc_id, $device_type_id)); 138 139 // ページに配置されているデータも削除する 140 $objQuery->delete('dtb_blocposition', 'bloc_id = ? AND device_type_id = ?', array($bloc_id, $device_type_id)); 141 142 // ファイルの削除 143 if (file_exists($tplPath)) { 144 unlink($tplPath); 145 } 146 } 147 $this->objDisplay->reload(array("device_type_id" => $device_type_id), true); 148 exit; 149 break; 113 150 114 default: 151 115 if (isset($_GET['msg']) && $_GET['msg'] == 'on') { 152 116 // 完了メッセージ 153 $this->tpl_onload="alert('登録が完了しました。');"; 154 } 155 } 156 $this->device_type_id = $device_type_id; 117 $this->tpl_onload = "alert('登録が完了しました。');"; 118 } 119 } 157 120 158 121 if (!$is_error) { 159 122 // ブロック一覧を取得 160 $this->arrBlocList = $ this->objLayout->getBlocs($device_type_id);123 $this->arrBlocList = $objLayout->getBlocs($this->device_type_id); 161 124 // bloc_id が指定されている場合にはブロックデータの取得 162 125 if (!SC_Utils_Ex::isBlank($this->bloc_id)) { 163 $arrBloc = $this->getBlocTemplate($this->device_type_id, $this->bloc_id, $ this->objLayout);126 $arrBloc = $this->getBlocTemplate($this->device_type_id, $this->bloc_id, $objLayout); 164 127 $objFormParam->setParam($arrBloc); 165 128 } … … 217 180 218 181 /** 219 * ブロック情報を取得する. 220 * 221 * @param integer $device_type_id 端末種別ID 222 * @param string $where Where句文 223 * @param array $arrVal Where句の絞込条件値 224 * @return array ブロック情報 225 */ 226 function lfGetBlocData($device_type_id, $where = '', $arrVal = array()){ 182 * 登録を実行する. 183 * 184 * ファイルの作成に失敗した場合は, エラーメッセージを出力し, 185 * データベースをロールバックする. 186 * 187 * @param SC_FormParam $objFormParam SC_FormParam インスタンス 188 * @param SC_Helper_PageLayout $objLayout SC_Helper_PageLayout インスタンス 189 * @return integer|boolean 登録が成功した場合, 登録したブロックID; 190 * 失敗した場合 false 191 */ 192 function doRegister(&$objFormParam, &$objLayout) { 193 $arrParams = $objFormParam->getHashArray(); 194 227 195 $objQuery =& SC_Query_Ex::getSingletonInstance(); 228 $objQuery->setOrder("bloc_id"); 229 $sql_where = 'device_type_id = ?'; 230 $arrSql = array($device_type_id); 231 if (!empty($where)) { 232 $sql_where .= ' AND ' . $where; 233 $arrSql = array_merge($arrSql, $arrVal); 234 } 235 return $objQuery->select("*", "dtb_bloc", $sql_where, $arrSql); 236 } 237 238 /** 239 * ブロック情報を更新する. 240 * 241 * @param array $arrData 更新データ 242 * @param integer $device_type_id 端末種別ID 243 * @return integer 更新結果 244 */ 245 function lfEntryBlocData($arrData, $device_type_id){ 196 $objQuery->begin(); 197 198 // blod_id が空の場合は新規登録 199 $is_new = SC_Utils_Ex::isBlank($arrParams['bloc_id']); 200 $bloc_dir = $objLayout->getTemplatePath($arrParams['device_type_id']) . BLOC_DIR; 201 // 既存データの重複チェック 202 if (!$is_new) { 203 $arrExists = $objLayout->getBlocs($arrParams['device_type_id'], 'bloc_id = ?', array($arrParams['bloc_id'])); 204 205 // 既存のファイルが存在する場合は削除しておく 206 $exists_file = $bloc_dir . $arrExists[0]['filename'] . '.tpl'; 207 if (file_exists($exists_file)) { 208 unlink($exists_file); 209 } 210 } 211 212 $table = 'dtb_bloc'; 213 $arrValues = $objQuery->extractOnlyColsOf($table, $arrParams); 214 $arrValues['tpl_path'] = $arrParams['filename'] . '.tpl'; 215 $arrValues['update_date'] = 'now()'; 216 217 // 新規登録 218 if ($is_new || SC_Utils_Ex::isBlank($arrExists)) { 219 $objQuery->setOrder(''); 220 $arrValues['bloc_id'] = 1 + $objQuery->max('bloc_id', $table, 'device_type_id = ?', 221 array($arrValues['device_type_id'])); 222 $arrValues['create_date'] = 'now()'; 223 $objQuery->insert($table, $arrValues); 224 } 225 // 更新 226 else { 227 $objQuery->update($table, $arrValues, 'bloc_id = ? AND device_type_id = ?', 228 array($arrValues['bloc_id'], $arrValues['device_type_id'])); 229 } 230 231 $bloc_path = $bloc_dir . $arrValues['tpl_path']; 232 if (!SC_Helper_FileManager_Ex::sfWriteFile($bloc_path, $arrParams['bloc_html'])) { 233 $this->arrErr['err'] = '※ ブロックの書き込みに失敗しました<br />'; 234 $objQuery->rollback(); 235 return false; 236 } 237 238 $objQuery->commit(); 239 return $arrValues['bloc_id']; 240 } 241 242 /** 243 * 削除を実行する. 244 * 245 * @param SC_FormParam $objFormParam SC_FormParam インスタンス 246 * @param SC_Helper_PageLayout $objLayout SC_Helper_PageLayout インスタンス 247 * @return boolean 登録が成功した場合 true; 失敗した場合 false 248 */ 249 function doDelete(&$objFormParam, &$objLayout) { 250 $arrParams = $objFormParam->getHashArray(); 246 251 $objQuery =& SC_Query_Ex::getSingletonInstance(); 247 $sql = ""; // データ更新SQL生成用 248 $ret = ""; // データ更新結果格納用 249 $arrUpdData = array(); // 更新データ生成用 250 $arrChk = array(); // 排他チェック用 251 252 // 更新データ生成 253 $arrUpdData = array("bloc_name" => $arrData['bloc_name'], 254 "tpl_path" => $arrData['filename'] . '.tpl', 255 'filename' => $arrData['filename']); 256 257 // データが存在しているかチェックを行う 258 if($arrData['bloc_id'] !== ''){ 259 $arrChk = $this->lfGetBlocData($device_type_id, "bloc_id = ?", 260 array($arrData['bloc_id'])); 261 } 262 263 // bloc_id が空 若しくは データが存在していない場合にはINSERTを行う 264 if ($arrData['bloc_id'] === '' or !isset($arrChk[0])) { 265 // SQL生成 266 // FIXME device_type_id ごとの連番にする 267 $arrUpdData['bloc_id'] = $objQuery->nextVal('dtb_bloc_bloc_id'); 268 $arrUpdData['device_type_id'] = $device_type_id; 269 $arrUpdData['update_date'] = "now()"; 270 $ret = $objQuery->insert('dtb_bloc', $arrUpdData); 252 $objQuery->begin(); 253 254 $arrExists = $objLayout->getBlocs($arrParams['device_type_id'], 'bloc_id = ? AND deletable_flg = 1', 255 array($arrParams['bloc_id'])); 256 $is_error = false; 257 if (!SC_Utils_Ex::isBlank($arrExists)) { 258 $objQuery->delete('dtb_bloc', 'bloc_id = ? AND device_type_id = ?', 259 array($arrExists[0]['bloc_id'], $arrExists[0]['device_type_id'])); 260 $objQuery->delete('dtb_blocposition', 'bloc_id = ? AND device_type_id = ?', 261 array($arrExists[0]['bloc_id'], $arrExists[0]['device_type_id'])); 262 263 $bloc_dir = $objLayout->getTemplatePath($arrParams['device_type_id']) . BLOC_DIR; 264 $exists_file = $bloc_dir . $arrExists[0]['filename'] . '.tpl'; 265 266 // ファイルの削除 267 if (file_exists($exists_file)) { 268 if (!unlink($exists_file)) { 269 $is_error = true; 270 } 271 } 271 272 } else { 272 $ret = $objQuery->update('dtb_bloc', $arrUpdData, 'bloc_id = ? AND device_type_id = ?', 273 array($arrData['bloc_id'], $device_type_id)); 274 } 275 return $ret; 276 } 277 278 /** 279 * 入力項目のエラーチェックを行う. 280 * 281 * @param array $arrData 入力データ 282 * @return array エラー情報 283 */ 284 function lfErrorCheck($array) { 285 $objErr = new SC_CheckError_Ex($array); 286 273 $is_error = true; 274 } 275 276 if ($is_error) { 277 $this->arrErr['err'] = '※ ブロックの削除に失敗しました<br />'; 278 $objQuery->rollback(); 279 return false; 280 } 281 $objQuery->commit(); 282 return true; 283 } 284 285 /** 286 * エラーチェックを行う. 287 * 288 * @param SC_FormParam $objFormParam SC_FormParam インスタンス 289 * @return array エラーメッセージの配列 290 */ 291 function lfCheckError(&$objFormParam, &$arrErr, &$objLayout) { 292 $arrParams = $objFormParam->getHashArray(); 293 $objErr = new SC_CheckError_Ex($arrParams); 294 $objErr->arrErr =& $arrErr; 287 295 $objErr->doFunc(array("ブロック名", "bloc_name", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); 288 $objErr->doFunc(array("ファイル名", 'filename', STEXT_LEN), array("EXIST_CHECK", "NO_SPTAB", "MAX_LENGTH_CHECK","FILE_NAME_CHECK_BY_NOUPLOAD")); 289 290 // 同一のファイル名が存在している場合にはエラー 291 if(!isset($objErr->arrErr['filename']) && $array['filename'] !== ''){ 292 $arrChk = $this->lfGetBlocData($array['device_type_id'], "filename = ?", array($array['filename'])); 293 294 if (count($arrChk[0]) >= 1 && $arrChk[0]['bloc_id'] != $array['bloc_id']) { 295 $objErr->arrErr['filename'] = '※ 同じファイル名のデータが存在しています。別の名称を付けてください。'; 296 } 297 } 298 296 $objErr->doFunc(array('ファイル名', 'filename', STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK","FILE_NAME_CHECK_BY_NOUPLOAD")); 297 298 $where = 'filename = ?'; 299 $arrValues = array($arrParams['filename']); 300 301 // 変更の場合は自ブロックを除外 302 if (!SC_Utils_Ex::isBlank($arrParams['bloc_id'])) { 303 $where .= ' AND bloc_id <> ?'; 304 $arrValues[] = $arrParams['bloc_id']; 305 } 306 $arrBloc = $objLayout->getBlocs($arrParams['device_type_id'], $where, $arrValues); 307 if (!SC_Utils_Ex::isBlank($arrBloc)) { 308 $objErr->arrErr['filename'] = '※ 同じファイル名のデータが存在しています。別のファイル名を入力してください。<br />'; 309 } 299 310 return $objErr->arrErr; 300 311 } -
branches/version-2_11-dev/data/class/pages/admin/design/LC_Page_Admin_Design_MainEdit.php
r20847 r20857 83 83 84 84 switch ($this->getMode()) { 85 // 削除 85 86 case 'delete': 86 87 if (!$is_error) { … … 94 95 break; 95 96 97 // 登録/編集 96 98 case 'confirm': 97 99 if (!$is_error) { … … 107 109 } 108 110 } 111 break; 112 109 113 default: 110 114 if (isset($_GET['msg']) && $_GET['msg'] == 'on'){ … … 188 192 * 失敗した場合 false 189 193 */ 190 function doRegister( $objFormParam, &$objLayout) {194 function doRegister(&$objFormParam, &$objLayout) { 191 195 $filename = $objFormParam->getValue('filename'); 192 196 $arrParams['device_type_id'] = $objFormParam->getValue('device_type_id'); … … 275 279 } 276 280 277 $objQuery->update( 'dtb_pagelayout', $arrValues, 'page_id = ? AND device_type_id = ?',281 $objQuery->update($table, $arrValues, 'page_id = ? AND device_type_id = ?', 278 282 array($arrValues['page_id'], $arrValues['device_type_id'])); 279 283 }
Note: See TracChangeset
for help on using the changeset viewer.