Changeset 22610
- Timestamp:
- 2013/03/06 23:09:54 (11 years ago)
- Location:
- branches/version-2_12-dev/data
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/class/helper/SC_Helper_PageLayout.php
r22567 r22610 138 138 function getBlocs($device_type_id = DEVICE_TYPE_PC, $where = '', $arrParams = array(), $has_realpath = true) 139 139 { 140 $objQuery =& SC_Query_Ex::getSingletonInstance(); 141 $where = 'device_type_id = ? ' . (SC_Utils_Ex::isBlank($where) ? $where : 'AND ' . $where); 142 $arrParams = array_merge(array($device_type_id), $arrParams); 143 $objQuery->setOrder('bloc_id'); 144 $arrBlocs = $objQuery->select('*', 'dtb_bloc', $where, $arrParams); 140 $objBloc = new SC_Helper_Bloc_Ex($device_type_id); 141 $arrBlocs = $objBloc->getWhere($where, $arrParams); 145 142 if ($has_realpath) { 146 143 $this->setBlocPathTo($device_type_id, $arrBlocs); -
branches/version-2_12-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Bloc.php
r22567 r22610 86 86 $this->device_type_id = $objFormParam->getValue('device_type_id', DEVICE_TYPE_PC); 87 87 88 $objBloc = new SC_Helper_Bloc_Ex($this->device_type_id); 88 89 $objLayout = new SC_Helper_PageLayout_Ex(); 89 90 … … 92 93 case 'confirm': 93 94 if (!$is_error) { 94 $this->arrErr = $this->lfCheckError($objFormParam, $this->arrErr, $obj Layout);95 $this->arrErr = $this->lfCheckError($objFormParam, $this->arrErr, $objBloc); 95 96 if (SC_Utils_Ex::isBlank($this->arrErr)) { 96 $result = $this->doRegister($objFormParam, $obj Layout);97 $result = $this->doRegister($objFormParam, $objBloc); 97 98 if ($result !== false) { 98 99 $arrPram = array( … … 112 113 case 'delete': 113 114 if (!$is_error) { 114 if ($this->doDelete($objFormParam, $obj Layout)) {115 if ($this->doDelete($objFormParam, $objBloc)) { 115 116 $arrPram = array( 116 117 'device_type_id' => $this->device_type_id, … … 134 135 if (!$is_error) { 135 136 // ブロック一覧を取得 136 $this->arrBlocList = $obj Layout->getBlocs($this->device_type_id);137 $this->arrBlocList = $objBloc->getList(); 137 138 // bloc_id が指定されている場合にはブロックデータの取得 138 139 if (!SC_Utils_Ex::isBlank($this->bloc_id)) { 139 $arrBloc = $this->getBlocTemplate($this-> device_type_id, $this->bloc_id, $objLayout);140 $arrBloc = $this->getBlocTemplate($this->bloc_id, $objBloc); 140 141 $objFormParam->setParam($arrBloc); 141 142 } … … 177 178 * ブロックのテンプレートを取得する. 178 179 * 179 * @param integer $device_type_id 端末種別ID180 180 * @param integer $bloc_id ブロックID 181 * @param SC_Helper_ PageLayout $objLayout SC_Helper_PageLayoutインスタンス181 * @param SC_Helper_Bloc_Ex $objBloc SC_Helper_Bloc_Ex インスタンス 182 182 * @return array ブロック情報の配列 183 183 */ 184 function getBlocTemplate($device_type_id, $bloc_id, &$objLayout) 185 { 186 $arrBloc = $objLayout->getBlocs($device_type_id, 'bloc_id = ?', array($bloc_id)); 187 if (SC_Utils_Ex::isAbsoluteRealPath($arrBloc[0]['tpl_path'])) { 188 $tpl_path = $arrBloc[0]['tpl_path']; 189 } else { 190 $tpl_path = SC_Helper_PageLayout_Ex::getTemplatePath($device_type_id) . BLOC_DIR . $arrBloc[0]['tpl_path']; 191 } 192 if (file_exists($tpl_path)) { 193 $arrBloc[0]['bloc_html'] = file_get_contents($tpl_path); 194 } 195 return $arrBloc[0]; 184 function getBlocTemplate($bloc_id, SC_Helper_Bloc_Ex &$objBloc) 185 { 186 $arrBloc = $objBloc->get($bloc_id); 187 return $arrBloc; 196 188 } 197 189 … … 203 195 * 204 196 * @param SC_FormParam $objFormParam SC_FormParam インスタンス 205 * @param SC_Helper_ PageLayout $objLayout SC_Helper_PageLayoutインスタンス197 * @param SC_Helper_Bloc $objBloc SC_Helper_Bloc インスタンス 206 198 * @return integer|boolean 登録が成功した場合, 登録したブロックID; 207 199 * 失敗した場合 false 208 200 */ 209 function doRegister(&$objFormParam, &$objLayout)201 function doRegister(&$objFormParam, SC_Helper_Bloc_Ex &$objBloc) 210 202 { 211 203 $arrParams = $objFormParam->getHashArray(); 212 213 $objQuery =& SC_Query_Ex::getSingletonInstance(); 214 $objQuery->begin(); 215 216 // blod_id が空の場合は新規登録 217 $is_new = SC_Utils_Ex::isBlank($arrParams['bloc_id']); 218 $bloc_dir = $objLayout->getTemplatePath($arrParams['device_type_id']) . BLOC_DIR; 219 // 既存データの重複チェック 220 if (!$is_new) { 221 $arrExists = $objLayout->getBlocs($arrParams['device_type_id'], 'bloc_id = ?', array($arrParams['bloc_id'])); 222 223 // 既存のファイルが存在する場合は削除しておく 224 $exists_file = $bloc_dir . $arrExists[0]['filename'] . '.tpl'; 225 if (file_exists($exists_file)) { 226 unlink($exists_file); 227 } 228 } 229 230 $table = 'dtb_bloc'; 231 $arrValues = $objQuery->extractOnlyColsOf($table, $arrParams); 232 $arrValues['tpl_path'] = $arrParams['filename'] . '.tpl'; 233 $arrValues['update_date'] = 'CURRENT_TIMESTAMP'; 234 235 // 新規登録 236 if ($is_new || SC_Utils_Ex::isBlank($arrExists)) { 237 $objQuery->setOrder(''); 238 $arrValues['bloc_id'] = 1 + $objQuery->max('bloc_id', $table, 'device_type_id = ?', 239 array($arrValues['device_type_id'])); 240 $arrValues['create_date'] = 'CURRENT_TIMESTAMP'; 241 $objQuery->insert($table, $arrValues); 242 } 243 // 更新 244 else { 245 $objQuery->update($table, $arrValues, 'bloc_id = ? AND device_type_id = ?', 246 array($arrValues['bloc_id'], $arrValues['device_type_id'])); 247 } 248 249 $bloc_path = $bloc_dir . $arrValues['tpl_path']; 250 if (!SC_Helper_FileManager_Ex::sfWriteFile($bloc_path, $arrParams['bloc_html'])) { 204 $result = $objBloc->save($arrParams); 205 206 if (!$result) { 251 207 $this->arrErr['err'] = '※ ブロックの書き込みに失敗しました<br />'; 252 $objQuery->rollback(); 253 return false; 254 } 255 256 $objQuery->commit(); 257 return $arrValues['bloc_id']; 208 } 209 210 return $result; 258 211 } 259 212 … … 262 215 * 263 216 * @param SC_FormParam $objFormParam SC_FormParam インスタンス 264 * @param SC_Helper_ PageLayout $objLayout SC_Helper_PageLayoutインスタンス217 * @param SC_Helper_Bloc $objBloc SC_Helper_Bloc インスタンス 265 218 * @return boolean 登録が成功した場合 true; 失敗した場合 false 266 219 */ 267 function doDelete(&$objFormParam, &$objLayout)220 function doDelete(&$objFormParam, SC_Helper_Bloc_Ex &$objBloc) 268 221 { 269 222 $arrParams = $objFormParam->getHashArray(); 270 $objQuery =& SC_Query_Ex::getSingletonInstance(); 271 $objQuery->begin(); 272 273 $arrExists = $objLayout->getBlocs($arrParams['device_type_id'], 'bloc_id = ? AND deletable_flg = 1', 274 array($arrParams['bloc_id'])); 275 $is_error = false; 276 if (!SC_Utils_Ex::isBlank($arrExists)) { 277 $objQuery->delete('dtb_bloc', 'bloc_id = ? AND device_type_id = ?', 278 array($arrExists[0]['bloc_id'], $arrExists[0]['device_type_id'])); 279 $objQuery->delete('dtb_blocposition', 'bloc_id = ? AND device_type_id = ?', 280 array($arrExists[0]['bloc_id'], $arrExists[0]['device_type_id'])); 281 282 $bloc_dir = $objLayout->getTemplatePath($arrParams['device_type_id']) . BLOC_DIR; 283 $exists_file = $bloc_dir . $arrExists[0]['filename'] . '.tpl'; 284 285 // ファイルの削除 286 if (file_exists($exists_file)) { 287 if (!unlink($exists_file)) { 288 $is_error = true; 289 } 290 } 291 } else { 292 $is_error = true; 293 } 294 295 if ($is_error) { 223 $result = $objBloc->delete($arrParams['bloc_id']); 224 225 if (!$result) { 296 226 $this->arrErr['err'] = '※ ブロックの削除に失敗しました<br />'; 297 $objQuery->rollback(); 298 return false; 299 } 300 $objQuery->commit(); 301 return true; 227 } 228 229 return $result; 302 230 } 303 231 … … 308 236 * @return array エラーメッセージの配列 309 237 */ 310 function lfCheckError(&$objFormParam, &$arrErr, &$objLayout)238 function lfCheckError(&$objFormParam, &$arrErr, SC_Helper_Bloc_Ex &$objBloc) 311 239 { 312 240 $arrParams = $objFormParam->getHashArray(); … … 324 252 $arrValues[] = $arrParams['bloc_id']; 325 253 } 326 $arrBloc = $obj Layout->getBlocs($arrParams['device_type_id'],$where, $arrValues);254 $arrBloc = $objBloc->getWhere($where, $arrValues); 327 255 if (!SC_Utils_Ex::isBlank($arrBloc)) { 328 256 $objErr->arrErr['filename'] = '※ 同じファイル名のデータが存在しています。別のファイル名を入力してください。<br />';
Note: See TracChangeset
for help on using the changeset viewer.