@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * Remove the selected docs from admin page |
| 24 | - * @return void |
|
| 24 | + * @return ModuleObject|null |
|
| 25 | 25 | */ |
| 26 | 26 | function procDocumentAdminDeleteChecked() |
| 27 | 27 | { |
@@ -869,8 +869,8 @@ discard block |
||
| 869 | 869 | /** |
| 870 | 870 | * Restore document from trash module, called by trash module |
| 871 | 871 | * This method is passived |
| 872 | - * @param object|array $originObject |
|
| 873 | - * @return object |
|
| 872 | + * @param string $originObject |
|
| 873 | + * @return BaseObject |
|
| 874 | 874 | */ |
| 875 | 875 | function restoreTrash($originObject) |
| 876 | 876 | { |
@@ -27,21 +27,21 @@ discard block |
||
| 27 | 27 | { |
| 28 | 28 | // error appears if no doc is selected |
| 29 | 29 | $cart = Context::get('cart'); |
| 30 | - if(!$cart) return $this->stop('msg_cart_is_null'); |
|
| 31 | - $document_srl_list= explode('|@|', $cart); |
|
| 30 | + if (!$cart) return $this->stop('msg_cart_is_null'); |
|
| 31 | + $document_srl_list = explode('|@|', $cart); |
|
| 32 | 32 | $document_count = count($document_srl_list); |
| 33 | - if(!$document_count) return $this->stop('msg_cart_is_null'); |
|
| 33 | + if (!$document_count) return $this->stop('msg_cart_is_null'); |
|
| 34 | 34 | // Delete a doc |
| 35 | 35 | $oDocumentController = getController('document'); |
| 36 | - for($i=0;$i<$document_count;$i++) |
|
| 36 | + for ($i = 0; $i < $document_count; $i++) |
|
| 37 | 37 | { |
| 38 | 38 | $document_srl = trim($document_srl_list[$i]); |
| 39 | - if(!$document_srl) continue; |
|
| 39 | + if (!$document_srl) continue; |
|
| 40 | 40 | |
| 41 | 41 | $oDocumentController->deleteDocument($document_srl, true); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - $this->setMessage(sprintf(Context::getLang('msg_checked_document_is_deleted'), $document_count) ); |
|
| 44 | + $this->setMessage(sprintf(Context::getLang('msg_checked_document_is_deleted'), $document_count)); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | function moveDocumentModule($document_srl_list, $module_srl, $category_srl) |
| 55 | 55 | { |
| 56 | - if(!count($document_srl_list)) return; |
|
| 56 | + if (!count($document_srl_list)) return; |
|
| 57 | 57 | |
| 58 | 58 | $oDocumentModel = getModel('document'); |
| 59 | 59 | $oDocumentController = getController('document'); |
@@ -62,22 +62,22 @@ discard block |
||
| 62 | 62 | $oDB->begin(); |
| 63 | 63 | |
| 64 | 64 | $triggerObj = new stdClass(); |
| 65 | - $triggerObj->document_srls = implode(',',$document_srl_list); |
|
| 65 | + $triggerObj->document_srls = implode(',', $document_srl_list); |
|
| 66 | 66 | $triggerObj->module_srl = $module_srl; |
| 67 | 67 | $triggerObj->category_srl = $category_srl; |
| 68 | 68 | // Call a trigger (before) |
| 69 | 69 | $output = ModuleHandler::triggerCall('document.moveDocumentModule', 'before', $triggerObj); |
| 70 | - if(!$output->toBool()) |
|
| 70 | + if (!$output->toBool()) |
|
| 71 | 71 | { |
| 72 | 72 | $oDB->rollback(); |
| 73 | 73 | return $output; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - for($i=count($document_srl_list)-1;$i>=0;$i--) |
|
| 76 | + for ($i = count($document_srl_list) - 1; $i >= 0; $i--) |
|
| 77 | 77 | { |
| 78 | 78 | $document_srl = $document_srl_list[$i]; |
| 79 | 79 | $oDocument = $oDocumentModel->getDocument($document_srl); |
| 80 | - if(!$oDocument->isExists()) continue; |
|
| 80 | + if (!$oDocument->isExists()) continue; |
|
| 81 | 81 | |
| 82 | 82 | $source_category_srl = $oDocument->get('category_srl'); |
| 83 | 83 | |
@@ -90,27 +90,27 @@ discard block |
||
| 90 | 90 | $obj->content = $output_ori->data->content; |
| 91 | 91 | |
| 92 | 92 | // Move the attached file if the target module is different |
| 93 | - if($module_srl != $obj->module_srl && $oDocument->hasUploadedFiles()) |
|
| 93 | + if ($module_srl != $obj->module_srl && $oDocument->hasUploadedFiles()) |
|
| 94 | 94 | { |
| 95 | 95 | $oFileController = getController('file'); |
| 96 | 96 | |
| 97 | 97 | $files = $oDocument->getUploadedFiles(); |
| 98 | 98 | $delete_file_srls = array(); |
| 99 | - if(is_array($files)) |
|
| 99 | + if (is_array($files)) |
|
| 100 | 100 | { |
| 101 | - foreach($files as $val) |
|
| 101 | + foreach ($files as $val) |
|
| 102 | 102 | { |
| 103 | 103 | $file_info = array(); |
| 104 | 104 | $file_info['tmp_name'] = $val->uploaded_filename; |
| 105 | 105 | $file_info['name'] = $val->source_filename; |
| 106 | 106 | $inserted_file = $oFileController->insertFile($file_info, $module_srl, $obj->document_srl, $val->download_count, true); |
| 107 | - if($inserted_file && $inserted_file->toBool()) |
|
| 107 | + if ($inserted_file && $inserted_file->toBool()) |
|
| 108 | 108 | { |
| 109 | 109 | // for image/video files |
| 110 | - if($val->direct_download == 'Y') |
|
| 110 | + if ($val->direct_download == 'Y') |
|
| 111 | 111 | { |
| 112 | - $source_filename = substr($val->uploaded_filename,2); |
|
| 113 | - $target_filename = substr($inserted_file->get('uploaded_filename'),2); |
|
| 112 | + $source_filename = substr($val->uploaded_filename, 2); |
|
| 113 | + $target_filename = substr($inserted_file->get('uploaded_filename'), 2); |
|
| 114 | 114 | $obj->content = str_replace($source_filename, $target_filename, $obj->content); |
| 115 | 115 | // For binary files |
| 116 | 116 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | $oFileController->setFilesValid($obj->document_srl); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - if($module_srl != $obj->module_srl) |
|
| 132 | + if ($module_srl != $obj->module_srl) |
|
| 133 | 133 | { |
| 134 | 134 | $oDocumentController->deleteDocumentAliasByDocument($obj->document_srl); |
| 135 | 135 | } |
@@ -137,48 +137,48 @@ discard block |
||
| 137 | 137 | $obj->module_srl = $module_srl; |
| 138 | 138 | $obj->category_srl = $category_srl; |
| 139 | 139 | $output = executeQuery('document.updateDocumentModule', $obj); |
| 140 | - if(!$output->toBool()) { |
|
| 140 | + if (!$output->toBool()) { |
|
| 141 | 141 | $oDB->rollback(); |
| 142 | 142 | return $output; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | //Move a module of the extra vars |
| 146 | 146 | $output = executeQuery('document.moveDocumentExtraVars', $obj); |
| 147 | - if(!$output->toBool()) { |
|
| 147 | + if (!$output->toBool()) { |
|
| 148 | 148 | $oDB->rollback(); |
| 149 | 149 | return $output; |
| 150 | 150 | } |
| 151 | 151 | // Set 0 if a new category doesn't exist after catergory change |
| 152 | - if($source_category_srl != $category_srl) |
|
| 152 | + if ($source_category_srl != $category_srl) |
|
| 153 | 153 | { |
| 154 | - if($source_category_srl) $oDocumentController->updateCategoryCount($oDocument->get('module_srl'), $source_category_srl); |
|
| 155 | - if($category_srl) $oDocumentController->updateCategoryCount($module_srl, $category_srl); |
|
| 154 | + if ($source_category_srl) $oDocumentController->updateCategoryCount($oDocument->get('module_srl'), $source_category_srl); |
|
| 155 | + if ($category_srl) $oDocumentController->updateCategoryCount($module_srl, $category_srl); |
|
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | $args = new stdClass(); |
| 160 | - $args->document_srls = implode(',',$document_srl_list); |
|
| 160 | + $args->document_srls = implode(',', $document_srl_list); |
|
| 161 | 161 | $args->module_srl = $module_srl; |
| 162 | 162 | // move the comment |
| 163 | 163 | $output = executeQuery('comment.updateCommentModule', $args); |
| 164 | - if(!$output->toBool()) |
|
| 164 | + if (!$output->toBool()) |
|
| 165 | 165 | { |
| 166 | 166 | $oDB->rollback(); |
| 167 | 167 | return $output; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | $output = executeQuery('comment.updateCommentListModule', $args); |
| 171 | - if(!$output->toBool()) |
|
| 171 | + if (!$output->toBool()) |
|
| 172 | 172 | { |
| 173 | 173 | $oDB->rollback(); |
| 174 | 174 | return $output; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | // move the trackback |
| 178 | - if(getClass('trackback')) |
|
| 178 | + if (getClass('trackback')) |
|
| 179 | 179 | { |
| 180 | 180 | $output = executeQuery('trackback.updateTrackbackModule', $args); |
| 181 | - if(!$output->toBool()) |
|
| 181 | + if (!$output->toBool()) |
|
| 182 | 182 | { |
| 183 | 183 | $oDB->rollback(); |
| 184 | 184 | return $output; |
@@ -187,14 +187,14 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | // Tags |
| 189 | 189 | $output = executeQuery('tag.updateTagModule', $args); |
| 190 | - if(!$output->toBool()) |
|
| 190 | + if (!$output->toBool()) |
|
| 191 | 191 | { |
| 192 | 192 | $oDB->rollback(); |
| 193 | 193 | return $output; |
| 194 | 194 | } |
| 195 | 195 | // Call a trigger (before) |
| 196 | 196 | $output = ModuleHandler::triggerCall('document.moveDocumentModule', 'after', $triggerObj); |
| 197 | - if(!$output->toBool()) |
|
| 197 | + if (!$output->toBool()) |
|
| 198 | 198 | { |
| 199 | 199 | $oDB->rollback(); |
| 200 | 200 | return $output; |
@@ -203,11 +203,11 @@ discard block |
||
| 203 | 203 | $oDB->commit(); |
| 204 | 204 | //remove from cache |
| 205 | 205 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 206 | - if($oCacheHandler->isSupport()) |
|
| 206 | + if ($oCacheHandler->isSupport()) |
|
| 207 | 207 | { |
| 208 | - foreach($document_srl_list as $document_srl) |
|
| 208 | + foreach ($document_srl_list as $document_srl) |
|
| 209 | 209 | { |
| 210 | - $cache_key_item = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
| 210 | + $cache_key_item = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
| 211 | 211 | $oCacheHandler->delete($cache_key_item); |
| 212 | 212 | } |
| 213 | 213 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | */ |
| 224 | 224 | function copyDocumentModule($document_srl_list, $module_srl, $category_srl) |
| 225 | 225 | { |
| 226 | - if(count($document_srl_list) < 1) return; |
|
| 226 | + if (count($document_srl_list) < 1) return; |
|
| 227 | 227 | |
| 228 | 228 | $oDocumentModel = getModel('document'); |
| 229 | 229 | $oDocumentController = getController('document'); |
@@ -234,12 +234,12 @@ discard block |
||
| 234 | 234 | $oDB->begin(); |
| 235 | 235 | |
| 236 | 236 | $triggerObj = new stdClass(); |
| 237 | - $triggerObj->document_srls = implode(',',$document_srl_list); |
|
| 237 | + $triggerObj->document_srls = implode(',', $document_srl_list); |
|
| 238 | 238 | $triggerObj->module_srl = $module_srl; |
| 239 | 239 | $triggerObj->category_srl = $category_srl; |
| 240 | 240 | // Call a trigger (before) |
| 241 | 241 | $output = ModuleHandler::triggerCall('document.copyDocumentModule', 'before', $triggerObj); |
| 242 | - if(!$output->toBool()) |
|
| 242 | + if (!$output->toBool()) |
|
| 243 | 243 | { |
| 244 | 244 | $oDB->rollback(); |
| 245 | 245 | return $output; |
@@ -247,11 +247,11 @@ discard block |
||
| 247 | 247 | |
| 248 | 248 | $extraVarsList = $oDocumentModel->getDocumentExtraVarsFromDB($document_srl_list); |
| 249 | 249 | $extraVarsListByDocumentSrl = array(); |
| 250 | - if(is_array($extraVarsList->data)) |
|
| 250 | + if (is_array($extraVarsList->data)) |
|
| 251 | 251 | { |
| 252 | - foreach($extraVarsList->data as $value) |
|
| 252 | + foreach ($extraVarsList->data as $value) |
|
| 253 | 253 | { |
| 254 | - if(!isset($extraVarsListByDocumentSrl[$value->document_srl])) |
|
| 254 | + if (!isset($extraVarsListByDocumentSrl[$value->document_srl])) |
|
| 255 | 255 | { |
| 256 | 256 | $extraVarsListByDocumentSrl[$value->document_srl] = array(); |
| 257 | 257 | } |
@@ -260,22 +260,22 @@ discard block |
||
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - for($i=count($document_srl_list)-1;$i>=0;$i--) |
|
| 263 | + for ($i = count($document_srl_list) - 1; $i >= 0; $i--) |
|
| 264 | 264 | { |
| 265 | 265 | $document_srl = $document_srl_list[$i]; |
| 266 | 266 | $oDocument = $oDocumentModel->getDocument($document_srl); |
| 267 | - if(!$oDocument->isExists()) continue; |
|
| 267 | + if (!$oDocument->isExists()) continue; |
|
| 268 | 268 | |
| 269 | 269 | $obj = $oDocument->getObjectVars(); |
| 270 | 270 | |
| 271 | 271 | $extraVars = $extraVarsListByDocumentSrl[$document_srl]; |
| 272 | - if($module_srl == $obj->module_srl) |
|
| 272 | + if ($module_srl == $obj->module_srl) |
|
| 273 | 273 | { |
| 274 | - if(is_array($extraVars)) |
|
| 274 | + if (is_array($extraVars)) |
|
| 275 | 275 | { |
| 276 | - foreach($extraVars as $extraItem) |
|
| 276 | + foreach ($extraVars as $extraItem) |
|
| 277 | 277 | { |
| 278 | - if($extraItem->var_idx >= 0) $obj->{'extra_vars'.$extraItem->var_idx} = $extraItem->value; |
|
| 278 | + if ($extraItem->var_idx >= 0) $obj->{'extra_vars'.$extraItem->var_idx} = $extraItem->value; |
|
| 279 | 279 | } |
| 280 | 280 | } |
| 281 | 281 | } |
@@ -287,10 +287,10 @@ discard block |
||
| 287 | 287 | $obj->trackback_count = 0; |
| 288 | 288 | |
| 289 | 289 | // Pre-register the attachment |
| 290 | - if($oDocument->hasUploadedFiles()) |
|
| 290 | + if ($oDocument->hasUploadedFiles()) |
|
| 291 | 291 | { |
| 292 | 292 | $files = $oDocument->getUploadedFiles(); |
| 293 | - foreach($files as $val) |
|
| 293 | + foreach ($files as $val) |
|
| 294 | 294 | { |
| 295 | 295 | $file_info = array(); |
| 296 | 296 | $file_info['tmp_name'] = $val->uploaded_filename; |
@@ -298,10 +298,10 @@ discard block |
||
| 298 | 298 | $oFileController = getController('file'); |
| 299 | 299 | $inserted_file = $oFileController->insertFile($file_info, $module_srl, $obj->document_srl, 0, true); |
| 300 | 300 | // if image/video files |
| 301 | - if($val->direct_download == 'Y') |
|
| 301 | + if ($val->direct_download == 'Y') |
|
| 302 | 302 | { |
| 303 | - $source_filename = substr($val->uploaded_filename,2); |
|
| 304 | - $target_filename = substr($inserted_file->get('uploaded_filename'),2); |
|
| 303 | + $source_filename = substr($val->uploaded_filename, 2); |
|
| 304 | + $target_filename = substr($inserted_file->get('uploaded_filename'), 2); |
|
| 305 | 305 | $obj->content = str_replace($source_filename, $target_filename, $obj->content); |
| 306 | 306 | // If binary file |
| 307 | 307 | } |
@@ -315,23 +315,23 @@ discard block |
||
| 315 | 315 | |
| 316 | 316 | // Write a post |
| 317 | 317 | $output = $oDocumentController->insertDocument($obj, true, true); |
| 318 | - if(!$output->toBool()) |
|
| 318 | + if (!$output->toBool()) |
|
| 319 | 319 | { |
| 320 | 320 | $oDB->rollback(); |
| 321 | 321 | return $output; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | // copy multi language contents |
| 325 | - if(is_array($extraVars)) |
|
| 325 | + if (is_array($extraVars)) |
|
| 326 | 326 | { |
| 327 | - foreach($extraVars as $value) |
|
| 327 | + foreach ($extraVars as $value) |
|
| 328 | 328 | { |
| 329 | - if($value->idx >= 0 && $value->lang_code == Context::getLangType()) |
|
| 329 | + if ($value->idx >= 0 && $value->lang_code == Context::getLangType()) |
|
| 330 | 330 | { |
| 331 | 331 | continue; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - if( $value->var_idx < 0 || ($module_srl == $value->module_srl && $value->var_idx >= 0) ) |
|
| 334 | + if ($value->var_idx < 0 || ($module_srl == $value->module_srl && $value->var_idx >= 0)) |
|
| 335 | 335 | { |
| 336 | 336 | $oDocumentController->insertDocumentExtraVar($value->module_srl, $obj->document_srl, $value->var_idx, $value->value, $value->eid, $value->lang_code); |
| 337 | 337 | } |
@@ -339,26 +339,26 @@ discard block |
||
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | // Move the comments |
| 342 | - if($oDocument->getCommentCount()) |
|
| 342 | + if ($oDocument->getCommentCount()) |
|
| 343 | 343 | { |
| 344 | 344 | $oCommentModel = getModel('comment'); |
| 345 | 345 | $comment_output = $oCommentModel->getCommentList($document_srl, 0, true, 99999999); |
| 346 | 346 | $comments = $comment_output->data; |
| 347 | - if(count($comments) > 0) |
|
| 347 | + if (count($comments) > 0) |
|
| 348 | 348 | { |
| 349 | 349 | $oCommentController = getController('comment'); |
| 350 | 350 | $success_count = 0; |
| 351 | 351 | $p_comment_srl = array(); |
| 352 | - foreach($comments as $comment_obj) |
|
| 352 | + foreach ($comments as $comment_obj) |
|
| 353 | 353 | { |
| 354 | 354 | $comment_srl = getNextSequence(); |
| 355 | 355 | $p_comment_srl[$comment_obj->comment_srl] = $comment_srl; |
| 356 | 356 | |
| 357 | 357 | // Pre-register the attachment |
| 358 | - if($comment_obj->uploaded_count) |
|
| 358 | + if ($comment_obj->uploaded_count) |
|
| 359 | 359 | { |
| 360 | 360 | $files = $oFileModel->getFiles($comment_obj->comment_srl, true); |
| 361 | - foreach($files as $val) |
|
| 361 | + foreach ($files as $val) |
|
| 362 | 362 | { |
| 363 | 363 | $file_info = array(); |
| 364 | 364 | $file_info['tmp_name'] = $val->uploaded_filename; |
@@ -366,10 +366,10 @@ discard block |
||
| 366 | 366 | $oFileController = getController('file'); |
| 367 | 367 | $inserted_file = $oFileController->insertFile($file_info, $module_srl, $comment_srl, 0, true); |
| 368 | 368 | // if image/video files |
| 369 | - if($val->direct_download == 'Y') |
|
| 369 | + if ($val->direct_download == 'Y') |
|
| 370 | 370 | { |
| 371 | - $source_filename = substr($val->uploaded_filename,2); |
|
| 372 | - $target_filename = substr($inserted_file->get('uploaded_filename'),2); |
|
| 371 | + $source_filename = substr($val->uploaded_filename, 2); |
|
| 372 | + $target_filename = substr($inserted_file->get('uploaded_filename'), 2); |
|
| 373 | 373 | $comment_obj->content = str_replace($source_filename, $target_filename, $comment_obj->content); |
| 374 | 374 | // If binary file |
| 375 | 375 | } |
@@ -385,10 +385,10 @@ discard block |
||
| 385 | 385 | $comment_obj->document_srl = $obj->document_srl; |
| 386 | 386 | $comment_obj->comment_srl = $comment_srl; |
| 387 | 387 | |
| 388 | - if($comment_obj->parent_srl) $comment_obj->parent_srl = $p_comment_srl[$comment_obj->parent_srl]; |
|
| 388 | + if ($comment_obj->parent_srl) $comment_obj->parent_srl = $p_comment_srl[$comment_obj->parent_srl]; |
|
| 389 | 389 | |
| 390 | 390 | $output = $oCommentController->insertComment($comment_obj, true); |
| 391 | - if($output->toBool()) $success_count ++; |
|
| 391 | + if ($output->toBool()) $success_count++; |
|
| 392 | 392 | } |
| 393 | 393 | $oDocumentController->updateCommentCount($obj->document_srl, $success_count, $comment_obj->nick_name, true); |
| 394 | 394 | } |
@@ -396,19 +396,19 @@ discard block |
||
| 396 | 396 | |
| 397 | 397 | // Move the trackbacks |
| 398 | 398 | $oTrackbackModel = getModel('trackback'); |
| 399 | - if($oTrackbackModel && $oDocument->getTrackbackCount()) |
|
| 399 | + if ($oTrackbackModel && $oDocument->getTrackbackCount()) |
|
| 400 | 400 | { |
| 401 | 401 | $trackbacks = $oTrackbackModel->getTrackbackList($oDocument->document_srl); |
| 402 | - if(count($trackbacks)) |
|
| 402 | + if (count($trackbacks)) |
|
| 403 | 403 | { |
| 404 | 404 | $success_count = 0; |
| 405 | - foreach($trackbacks as $trackback_obj) |
|
| 405 | + foreach ($trackbacks as $trackback_obj) |
|
| 406 | 406 | { |
| 407 | 407 | $trackback_obj->trackback_srl = getNextSequence(); |
| 408 | 408 | $trackback_obj->module_srl = $obj->module_srl; |
| 409 | 409 | $trackback_obj->document_srl = $obj->document_srl; |
| 410 | 410 | $output = executeQuery('trackback.insertTrackback', $trackback_obj); |
| 411 | - if($output->toBool()) $success_count++; |
|
| 411 | + if ($output->toBool()) $success_count++; |
|
| 412 | 412 | } |
| 413 | 413 | // Update the number of trackbacks |
| 414 | 414 | $oDocumentController->updateTrackbackCount($obj->document_srl, $success_count); |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | // Call a trigger (before) |
| 422 | 422 | $triggerObj->copied_srls = $copied_srls; |
| 423 | 423 | $output = ModuleHandler::triggerCall('document.copyDocumentModule', 'after', $triggerObj); |
| 424 | - if(!$output->toBool()) |
|
| 424 | + if (!$output->toBool()) |
|
| 425 | 425 | { |
| 426 | 426 | $oDB->rollback(); |
| 427 | 427 | return $output; |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | $document_list = $oDocumentModel->getDocumentList($args); |
| 449 | 449 | $documents = $document_list->data; |
| 450 | 450 | $output = executeQuery('document.deleteModuleDocument', $args); |
| 451 | - if(is_array($documents)) |
|
| 451 | + if (is_array($documents)) |
|
| 452 | 452 | { |
| 453 | 453 | foreach ($documents as $oDocument) |
| 454 | 454 | { |
@@ -457,13 +457,13 @@ discard block |
||
| 457 | 457 | } |
| 458 | 458 | //remove from cache |
| 459 | 459 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 460 | - if($oCacheHandler->isSupport()) |
|
| 460 | + if ($oCacheHandler->isSupport()) |
|
| 461 | 461 | { |
| 462 | - if(is_array($document_srl_list)) |
|
| 462 | + if (is_array($document_srl_list)) |
|
| 463 | 463 | { |
| 464 | - foreach($document_srl_list as $document_srl) |
|
| 464 | + foreach ($document_srl_list as $document_srl) |
|
| 465 | 465 | { |
| 466 | - $cache_key_item = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
| 466 | + $cache_key_item = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
| 467 | 467 | $oCacheHandler->delete($cache_key_item); |
| 468 | 468 | } |
| 469 | 469 | } |
@@ -482,8 +482,8 @@ discard block |
||
| 482 | 482 | $config = getModel('document')->getDocumentConfig(); |
| 483 | 483 | $config->icons = Context::get('icons'); |
| 484 | 484 | $config->micons = Context::get('micons'); |
| 485 | - $output = $oModuleController->insertModuleConfig('document',$config); |
|
| 486 | - if(!$output->toBool()) |
|
| 485 | + $output = $oModuleController->insertModuleConfig('document', $config); |
|
| 486 | + if (!$output->toBool()) |
|
| 487 | 487 | { |
| 488 | 488 | return $output; |
| 489 | 489 | } |
@@ -502,11 +502,11 @@ discard block |
||
| 502 | 502 | { |
| 503 | 503 | $document_srl = trim(Context::get('document_srl')); |
| 504 | 504 | |
| 505 | - if($document_srl) |
|
| 505 | + if ($document_srl) |
|
| 506 | 506 | { |
| 507 | 507 | $args->document_srl = $document_srl; |
| 508 | 508 | $output = executeQuery('document.deleteDeclaredDocuments', $args); |
| 509 | - if(!$output->toBool()) return $output; |
|
| 509 | + if (!$output->toBool()) return $output; |
|
| 510 | 510 | } |
| 511 | 511 | } |
| 512 | 512 | |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | */ |
| 517 | 517 | function procDocumentAdminDeleteAllThumbnail() |
| 518 | 518 | { |
| 519 | - $temp_cache_dir = './files/thumbnails_' . $_SERVER['REQUEST_TIME']; |
|
| 519 | + $temp_cache_dir = './files/thumbnails_'.$_SERVER['REQUEST_TIME']; |
|
| 520 | 520 | FileHandler::rename('./files/thumbnails', $temp_cache_dir); |
| 521 | 521 | FileHandler::makeDir('./files/thumbnails'); |
| 522 | 522 | |
@@ -532,12 +532,12 @@ discard block |
||
| 532 | 532 | function deleteThumbnailFile($path) |
| 533 | 533 | { |
| 534 | 534 | $directory = dir($path); |
| 535 | - while($entry = $directory->read()) { |
|
| 535 | + while ($entry = $directory->read()) { |
|
| 536 | 536 | if ($entry != "." && $entry != "..") { |
| 537 | 537 | if (is_dir($path."/".$entry)) { |
| 538 | 538 | $this->deleteThumbnailFile($path."/".$entry); |
| 539 | 539 | } else { |
| 540 | - if(!preg_match('/^thumbnail_([^\.]*)\.jpg$/i',$entry)) continue; |
|
| 540 | + if (!preg_match('/^thumbnail_([^\.]*)\.jpg$/i', $entry)) continue; |
|
| 541 | 541 | FileHandler::removeFile($path.'/'.$entry); |
| 542 | 542 | } |
| 543 | 543 | } |
@@ -562,13 +562,13 @@ discard block |
||
| 562 | 562 | $eid = Context::get('eid'); |
| 563 | 563 | $obj = new stdClass(); |
| 564 | 564 | |
| 565 | - if(!$module_srl || !$name || !$eid) return new BaseObject(-1,'msg_invalid_request'); |
|
| 565 | + if (!$module_srl || !$name || !$eid) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 566 | 566 | // set the max value if idx is not specified |
| 567 | - if(!$var_idx) |
|
| 567 | + if (!$var_idx) |
|
| 568 | 568 | { |
| 569 | 569 | $obj->module_srl = $module_srl; |
| 570 | 570 | $output = executeQuery('document.getDocumentMaxExtraKeyIdx', $obj); |
| 571 | - $var_idx = $output->data->var_idx+1; |
|
| 571 | + $var_idx = $output->data->var_idx + 1; |
|
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | // Check if the module name already exists |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | $obj->var_idx = $var_idx; |
| 577 | 577 | $obj->eid = $eid; |
| 578 | 578 | $output = executeQuery('document.isExistsExtraKey', $obj); |
| 579 | - if(!$output->toBool() || $output->data->count) |
|
| 579 | + if (!$output->toBool() || $output->data->count) |
|
| 580 | 580 | { |
| 581 | 581 | return new BaseObject(-1, 'msg_extra_name_exists'); |
| 582 | 582 | } |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | // insert or update |
| 585 | 585 | $oDocumentController = getController('document'); |
| 586 | 586 | $output = $oDocumentController->insertDocumentExtraKey($module_srl, $var_idx, $name, $type, $is_required, $search, $default, $desc, $eid); |
| 587 | - if(!$output->toBool()) return $output; |
|
| 587 | + if (!$output->toBool()) return $output; |
|
| 588 | 588 | |
| 589 | 589 | $this->setMessage('success_registed'); |
| 590 | 590 | |
@@ -600,11 +600,11 @@ discard block |
||
| 600 | 600 | { |
| 601 | 601 | $module_srl = Context::get('module_srl'); |
| 602 | 602 | $var_idx = Context::get('var_idx'); |
| 603 | - if(!$module_srl || !$var_idx) return new BaseObject(-1,'msg_invalid_request'); |
|
| 603 | + if (!$module_srl || !$var_idx) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 604 | 604 | |
| 605 | 605 | $oDocumentController = getController('document'); |
| 606 | 606 | $output = $oDocumentController->deleteDocumentExtraKeys($module_srl, $var_idx); |
| 607 | - if(!$output->toBool()) return $output; |
|
| 607 | + if (!$output->toBool()) return $output; |
|
| 608 | 608 | |
| 609 | 609 | $this->setMessage('success_deleted'); |
| 610 | 610 | } |
@@ -619,19 +619,19 @@ discard block |
||
| 619 | 619 | $module_srl = Context::get('module_srl'); |
| 620 | 620 | $var_idx = Context::get('var_idx'); |
| 621 | 621 | |
| 622 | - if(!$type || !$module_srl || !$var_idx) return new BaseObject(-1,'msg_invalid_request'); |
|
| 622 | + if (!$type || !$module_srl || !$var_idx) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 623 | 623 | |
| 624 | 624 | $oModuleModel = getModel('module'); |
| 625 | 625 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); |
| 626 | - if(!$module_info->module_srl) return new BaseObject(-1,'msg_invalid_request'); |
|
| 626 | + if (!$module_info->module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 627 | 627 | |
| 628 | 628 | $oDocumentModel = getModel('document'); |
| 629 | 629 | $extra_keys = $oDocumentModel->getExtraKeys($module_srl); |
| 630 | - if(!$extra_keys[$var_idx]) return new BaseObject(-1,'msg_invalid_request'); |
|
| 630 | + if (!$extra_keys[$var_idx]) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 631 | 631 | |
| 632 | - if($type == 'up') $new_idx = $var_idx-1; |
|
| 633 | - else $new_idx = $var_idx+1; |
|
| 634 | - if($new_idx<1) return new BaseObject(-1,'msg_invalid_request'); |
|
| 632 | + if ($type == 'up') $new_idx = $var_idx - 1; |
|
| 633 | + else $new_idx = $var_idx + 1; |
|
| 634 | + if ($new_idx < 1) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 635 | 635 | |
| 636 | 636 | $args = new stdClass(); |
| 637 | 637 | $args->module_srl = $module_srl; |
@@ -642,16 +642,16 @@ discard block |
||
| 642 | 642 | unset($args); |
| 643 | 643 | |
| 644 | 644 | // update immediately if there is no idx to change |
| 645 | - if(!$extra_keys[$new_idx]) |
|
| 645 | + if (!$extra_keys[$new_idx]) |
|
| 646 | 646 | { |
| 647 | 647 | $args = new stdClass(); |
| 648 | 648 | $args->module_srl = $module_srl; |
| 649 | 649 | $args->var_idx = $var_idx; |
| 650 | 650 | $args->new_idx = $new_idx; |
| 651 | 651 | $output = executeQuery('document.updateDocumentExtraKeyIdx', $args); |
| 652 | - if(!$output->toBool()) return $output; |
|
| 652 | + if (!$output->toBool()) return $output; |
|
| 653 | 653 | $output = executeQuery('document.updateDocumentExtraVarIdx', $args); |
| 654 | - if(!$output->toBool()) return $output; |
|
| 654 | + if (!$output->toBool()) return $output; |
|
| 655 | 655 | // replace if exists |
| 656 | 656 | } |
| 657 | 657 | else |
@@ -661,27 +661,27 @@ discard block |
||
| 661 | 661 | $args->var_idx = $new_idx; |
| 662 | 662 | $args->new_idx = -10000; |
| 663 | 663 | $output = executeQuery('document.updateDocumentExtraKeyIdx', $args); |
| 664 | - if(!$output->toBool()) return $output; |
|
| 664 | + if (!$output->toBool()) return $output; |
|
| 665 | 665 | $output = executeQuery('document.updateDocumentExtraVarIdx', $args); |
| 666 | - if(!$output->toBool()) return $output; |
|
| 666 | + if (!$output->toBool()) return $output; |
|
| 667 | 667 | |
| 668 | 668 | $args->var_idx = $var_idx; |
| 669 | 669 | $args->new_idx = $new_idx; |
| 670 | 670 | $output = executeQuery('document.updateDocumentExtraKeyIdx', $args); |
| 671 | - if(!$output->toBool()) return $output; |
|
| 671 | + if (!$output->toBool()) return $output; |
|
| 672 | 672 | $output = executeQuery('document.updateDocumentExtraVarIdx', $args); |
| 673 | - if(!$output->toBool()) return $output; |
|
| 673 | + if (!$output->toBool()) return $output; |
|
| 674 | 674 | |
| 675 | 675 | $args->var_idx = -10000; |
| 676 | 676 | $args->new_idx = $var_idx; |
| 677 | 677 | $output = executeQuery('document.updateDocumentExtraKeyIdx', $args); |
| 678 | - if(!$output->toBool()) return $output; |
|
| 678 | + if (!$output->toBool()) return $output; |
|
| 679 | 679 | $output = executeQuery('document.updateDocumentExtraVarIdx', $args); |
| 680 | - if(!$output->toBool()) return $output; |
|
| 680 | + if (!$output->toBool()) return $output; |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); |
| 684 | - if($oCacheHandler->isSupport()) |
|
| 684 | + if ($oCacheHandler->isSupport()) |
|
| 685 | 685 | { |
| 686 | 686 | $object_key = 'module_document_extra_keys:'.$module_srl; |
| 687 | 687 | $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
@@ -695,9 +695,9 @@ discard block |
||
| 695 | 695 | */ |
| 696 | 696 | function procDocumentAdminInsertAlias() |
| 697 | 697 | { |
| 698 | - $args = Context::gets('module_srl','document_srl', 'alias_title'); |
|
| 698 | + $args = Context::gets('module_srl', 'document_srl', 'alias_title'); |
|
| 699 | 699 | $alias_srl = Context::get('alias_srl'); |
| 700 | - if(!$alias_srl) |
|
| 700 | + if (!$alias_srl) |
|
| 701 | 701 | { |
| 702 | 702 | $args->alias_srl = getNextSequence(); |
| 703 | 703 | $query = "document.insertAlias"; |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | $oDocumentModel = getModel('document'); |
| 741 | 741 | $oDocumentController = getController('document'); |
| 742 | 742 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
| 743 | - if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted'); |
|
| 743 | + if (!$oDocument->isGranted()) return $this->stop('msg_not_permitted'); |
|
| 744 | 744 | |
| 745 | 745 | $oModuleModel = getModel('module'); |
| 746 | 746 | $module_info = $oModuleModel->getModuleInfoByDocumentSrl($document_srl); |
@@ -752,31 +752,31 @@ discard block |
||
| 752 | 752 | $oDocumentController->moveDocumentToTrash($args); |
| 753 | 753 | |
| 754 | 754 | $returnUrl = Context::get('success_return_url'); |
| 755 | - if(!$returnUrl) |
|
| 755 | + if (!$returnUrl) |
|
| 756 | 756 | { |
| 757 | 757 | $arrUrl = parse_url(Context::get('cur_url')); |
| 758 | 758 | $query = ""; |
| 759 | 759 | |
| 760 | - if($arrUrl['query']) |
|
| 760 | + if ($arrUrl['query']) |
|
| 761 | 761 | { |
| 762 | 762 | parse_str($arrUrl['query'], $arrQuery); |
| 763 | 763 | |
| 764 | 764 | // set query |
| 765 | - if(isset($arrQuery['document_srl'])) |
|
| 765 | + if (isset($arrQuery['document_srl'])) |
|
| 766 | 766 | unset($arrQuery['document_srl']); |
| 767 | 767 | |
| 768 | 768 | $searchArgs = new stdClass; |
| 769 | - foreach($arrQuery as $key=>$val) |
|
| 769 | + foreach ($arrQuery as $key=>$val) |
|
| 770 | 770 | { |
| 771 | 771 | $searchArgs->{$key} = $val; |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | - if(!isset($searchArgs->sort_index)) |
|
| 774 | + if (!isset($searchArgs->sort_index)) |
|
| 775 | 775 | $searchArgs->sort_index = $module_info->order_target; |
| 776 | 776 | |
| 777 | - foreach($module_info as $key=>$val) |
|
| 777 | + foreach ($module_info as $key=>$val) |
|
| 778 | 778 | { |
| 779 | - if(!isset($searchArgs->{$key})) |
|
| 779 | + if (!isset($searchArgs->{$key})) |
|
| 780 | 780 | $searchArgs->{$key} = $val; |
| 781 | 781 | } |
| 782 | 782 | |
@@ -784,20 +784,20 @@ discard block |
||
| 784 | 784 | $output = $oDocumentModel->getDocumentList($searchArgs, $module_info->except_notice, TRUE, array('document_srl')); |
| 785 | 785 | |
| 786 | 786 | $cur_page = 1; |
| 787 | - if(isset($arrQuery['page'])) { |
|
| 788 | - $cur_page = (int)$arrQuery['page']; |
|
| 787 | + if (isset($arrQuery['page'])) { |
|
| 788 | + $cur_page = (int) $arrQuery['page']; |
|
| 789 | 789 | } |
| 790 | 790 | |
| 791 | 791 | |
| 792 | - if($cur_page>1 && count($output->data) == 0) |
|
| 792 | + if ($cur_page > 1 && count($output->data) == 0) |
|
| 793 | 793 | $arrQuery['page'] = $cur_page - 1; |
| 794 | 794 | |
| 795 | 795 | $query = "?"; |
| 796 | - foreach($arrQuery as $key=>$val) |
|
| 796 | + foreach ($arrQuery as $key=>$val) |
|
| 797 | 797 | $query .= sprintf("%s=%s&", $key, $val); |
| 798 | 798 | $query = substr($query, 0, -1); |
| 799 | 799 | } |
| 800 | - $returnUrl = $arrUrl['path'] . $query; |
|
| 800 | + $returnUrl = $arrUrl['path'].$query; |
|
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | $this->add('redirect_url', $returnUrl); |
@@ -874,7 +874,7 @@ discard block |
||
| 874 | 874 | */ |
| 875 | 875 | function restoreTrash($originObject) |
| 876 | 876 | { |
| 877 | - if(is_array($originObject)) $originObject = (object)$originObject; |
|
| 877 | + if (is_array($originObject)) $originObject = (object) $originObject; |
|
| 878 | 878 | |
| 879 | 879 | $oDocumentController = getController('document'); |
| 880 | 880 | $oDocumentModel = getModel('document'); |
@@ -884,12 +884,12 @@ discard block |
||
| 884 | 884 | |
| 885 | 885 | //DB restore |
| 886 | 886 | $output = $oDocumentController->insertDocument($originObject, false, true, false); |
| 887 | - if(!$output->toBool()) return new BaseObject(-1, $output->getMessage()); |
|
| 887 | + if (!$output->toBool()) return new BaseObject(-1, $output->getMessage()); |
|
| 888 | 888 | |
| 889 | 889 | //FILE restore |
| 890 | 890 | $oDocument = $oDocumentModel->getDocument($originObject->document_srl); |
| 891 | 891 | // If the post was not temorarily saved, set the attachment's status to be valid |
| 892 | - if($oDocument->hasUploadedFiles() && $originObject->member_srl != $originObject->module_srl) |
|
| 892 | + if ($oDocument->hasUploadedFiles() && $originObject->member_srl != $originObject->module_srl) |
|
| 893 | 893 | { |
| 894 | 894 | $args = new stdClass(); |
| 895 | 895 | $args->upload_target_srl = $oDocument->document_srl; |
@@ -898,10 +898,10 @@ discard block |
||
| 898 | 898 | } |
| 899 | 899 | |
| 900 | 900 | // call a trigger (after) |
| 901 | - if($output->toBool()) |
|
| 901 | + if ($output->toBool()) |
|
| 902 | 902 | { |
| 903 | 903 | $trigger_output = ModuleHandler::triggerCall('document.restoreTrash', 'after', $originObject); |
| 904 | - if(!$trigger_output->toBool()) |
|
| 904 | + if (!$trigger_output->toBool()) |
|
| 905 | 905 | { |
| 906 | 906 | $oDB->rollback(); |
| 907 | 907 | return $trigger_output; |
@@ -922,7 +922,7 @@ discard block |
||
| 922 | 922 | function emptyTrash($originObject) |
| 923 | 923 | { |
| 924 | 924 | $originObject = unserialize($originObject); |
| 925 | - if(is_array($originObject)) $originObject = (object) $originObject; |
|
| 925 | + if (is_array($originObject)) $originObject = (object) $originObject; |
|
| 926 | 926 | |
| 927 | 927 | $oDocument = new documentItem(); |
| 928 | 928 | $oDocument->setAttribute($originObject); |
@@ -27,16 +27,22 @@ discard block |
||
| 27 | 27 | { |
| 28 | 28 | // error appears if no doc is selected |
| 29 | 29 | $cart = Context::get('cart'); |
| 30 | - if(!$cart) return $this->stop('msg_cart_is_null'); |
|
| 30 | + if(!$cart) { |
|
| 31 | + return $this->stop('msg_cart_is_null'); |
|
| 32 | + } |
|
| 31 | 33 | $document_srl_list= explode('|@|', $cart); |
| 32 | 34 | $document_count = count($document_srl_list); |
| 33 | - if(!$document_count) return $this->stop('msg_cart_is_null'); |
|
| 35 | + if(!$document_count) { |
|
| 36 | + return $this->stop('msg_cart_is_null'); |
|
| 37 | + } |
|
| 34 | 38 | // Delete a doc |
| 35 | 39 | $oDocumentController = getController('document'); |
| 36 | 40 | for($i=0;$i<$document_count;$i++) |
| 37 | 41 | { |
| 38 | 42 | $document_srl = trim($document_srl_list[$i]); |
| 39 | - if(!$document_srl) continue; |
|
| 43 | + if(!$document_srl) { |
|
| 44 | + continue; |
|
| 45 | + } |
|
| 40 | 46 | |
| 41 | 47 | $oDocumentController->deleteDocument($document_srl, true); |
| 42 | 48 | } |
@@ -53,7 +59,9 @@ discard block |
||
| 53 | 59 | */ |
| 54 | 60 | function moveDocumentModule($document_srl_list, $module_srl, $category_srl) |
| 55 | 61 | { |
| 56 | - if(!count($document_srl_list)) return; |
|
| 62 | + if(!count($document_srl_list)) { |
|
| 63 | + return; |
|
| 64 | + } |
|
| 57 | 65 | |
| 58 | 66 | $oDocumentModel = getModel('document'); |
| 59 | 67 | $oDocumentController = getController('document'); |
@@ -77,7 +85,9 @@ discard block |
||
| 77 | 85 | { |
| 78 | 86 | $document_srl = $document_srl_list[$i]; |
| 79 | 87 | $oDocument = $oDocumentModel->getDocument($document_srl); |
| 80 | - if(!$oDocument->isExists()) continue; |
|
| 88 | + if(!$oDocument->isExists()) { |
|
| 89 | + continue; |
|
| 90 | + } |
|
| 81 | 91 | |
| 82 | 92 | $source_category_srl = $oDocument->get('category_srl'); |
| 83 | 93 | |
@@ -113,8 +123,7 @@ discard block |
||
| 113 | 123 | $target_filename = substr($inserted_file->get('uploaded_filename'),2); |
| 114 | 124 | $obj->content = str_replace($source_filename, $target_filename, $obj->content); |
| 115 | 125 | // For binary files |
| 116 | - } |
|
| 117 | - else |
|
| 126 | + } else |
|
| 118 | 127 | { |
| 119 | 128 | $obj->content = str_replace('file_srl='.$val->file_srl, 'file_srl='.$inserted_file->get('file_srl'), $obj->content); |
| 120 | 129 | $obj->content = str_replace('sid='.$val->sid, 'sid='.$inserted_file->get('sid'), $obj->content); |
@@ -151,8 +160,12 @@ discard block |
||
| 151 | 160 | // Set 0 if a new category doesn't exist after catergory change |
| 152 | 161 | if($source_category_srl != $category_srl) |
| 153 | 162 | { |
| 154 | - if($source_category_srl) $oDocumentController->updateCategoryCount($oDocument->get('module_srl'), $source_category_srl); |
|
| 155 | - if($category_srl) $oDocumentController->updateCategoryCount($module_srl, $category_srl); |
|
| 163 | + if($source_category_srl) { |
|
| 164 | + $oDocumentController->updateCategoryCount($oDocument->get('module_srl'), $source_category_srl); |
|
| 165 | + } |
|
| 166 | + if($category_srl) { |
|
| 167 | + $oDocumentController->updateCategoryCount($module_srl, $category_srl); |
|
| 168 | + } |
|
| 156 | 169 | } |
| 157 | 170 | } |
| 158 | 171 | |
@@ -223,7 +236,9 @@ discard block |
||
| 223 | 236 | */ |
| 224 | 237 | function copyDocumentModule($document_srl_list, $module_srl, $category_srl) |
| 225 | 238 | { |
| 226 | - if(count($document_srl_list) < 1) return; |
|
| 239 | + if(count($document_srl_list) < 1) { |
|
| 240 | + return; |
|
| 241 | + } |
|
| 227 | 242 | |
| 228 | 243 | $oDocumentModel = getModel('document'); |
| 229 | 244 | $oDocumentController = getController('document'); |
@@ -264,7 +279,9 @@ discard block |
||
| 264 | 279 | { |
| 265 | 280 | $document_srl = $document_srl_list[$i]; |
| 266 | 281 | $oDocument = $oDocumentModel->getDocument($document_srl); |
| 267 | - if(!$oDocument->isExists()) continue; |
|
| 282 | + if(!$oDocument->isExists()) { |
|
| 283 | + continue; |
|
| 284 | + } |
|
| 268 | 285 | |
| 269 | 286 | $obj = $oDocument->getObjectVars(); |
| 270 | 287 | |
@@ -275,7 +292,9 @@ discard block |
||
| 275 | 292 | { |
| 276 | 293 | foreach($extraVars as $extraItem) |
| 277 | 294 | { |
| 278 | - if($extraItem->var_idx >= 0) $obj->{'extra_vars'.$extraItem->var_idx} = $extraItem->value; |
|
| 295 | + if($extraItem->var_idx >= 0) { |
|
| 296 | + $obj->{'extra_vars'.$extraItem->var_idx} = $extraItem->value; |
|
| 297 | + } |
|
| 279 | 298 | } |
| 280 | 299 | } |
| 281 | 300 | } |
@@ -304,8 +323,7 @@ discard block |
||
| 304 | 323 | $target_filename = substr($inserted_file->get('uploaded_filename'),2); |
| 305 | 324 | $obj->content = str_replace($source_filename, $target_filename, $obj->content); |
| 306 | 325 | // If binary file |
| 307 | - } |
|
| 308 | - else |
|
| 326 | + } else |
|
| 309 | 327 | { |
| 310 | 328 | $obj->content = str_replace('file_srl='.$val->file_srl, 'file_srl='.$inserted_file->get('file_srl'), $obj->content); |
| 311 | 329 | $obj->content = str_replace('sid='.$val->sid, 'sid='.$inserted_file->get('sid'), $obj->content); |
@@ -372,8 +390,7 @@ discard block |
||
| 372 | 390 | $target_filename = substr($inserted_file->get('uploaded_filename'),2); |
| 373 | 391 | $comment_obj->content = str_replace($source_filename, $target_filename, $comment_obj->content); |
| 374 | 392 | // If binary file |
| 375 | - } |
|
| 376 | - else |
|
| 393 | + } else |
|
| 377 | 394 | { |
| 378 | 395 | $comment_obj->content = str_replace('file_srl='.$val->file_srl, 'file_srl='.$inserted_file->get('file_srl'), $comment_obj->content); |
| 379 | 396 | $comment_obj->content = str_replace('sid='.$val->sid, 'sid='.$inserted_file->get('sid'), $comment_obj->content); |
@@ -385,10 +402,14 @@ discard block |
||
| 385 | 402 | $comment_obj->document_srl = $obj->document_srl; |
| 386 | 403 | $comment_obj->comment_srl = $comment_srl; |
| 387 | 404 | |
| 388 | - if($comment_obj->parent_srl) $comment_obj->parent_srl = $p_comment_srl[$comment_obj->parent_srl]; |
|
| 405 | + if($comment_obj->parent_srl) { |
|
| 406 | + $comment_obj->parent_srl = $p_comment_srl[$comment_obj->parent_srl]; |
|
| 407 | + } |
|
| 389 | 408 | |
| 390 | 409 | $output = $oCommentController->insertComment($comment_obj, true); |
| 391 | - if($output->toBool()) $success_count ++; |
|
| 410 | + if($output->toBool()) { |
|
| 411 | + $success_count ++; |
|
| 412 | + } |
|
| 392 | 413 | } |
| 393 | 414 | $oDocumentController->updateCommentCount($obj->document_srl, $success_count, $comment_obj->nick_name, true); |
| 394 | 415 | } |
@@ -408,7 +429,9 @@ discard block |
||
| 408 | 429 | $trackback_obj->module_srl = $obj->module_srl; |
| 409 | 430 | $trackback_obj->document_srl = $obj->document_srl; |
| 410 | 431 | $output = executeQuery('trackback.insertTrackback', $trackback_obj); |
| 411 | - if($output->toBool()) $success_count++; |
|
| 432 | + if($output->toBool()) { |
|
| 433 | + $success_count++; |
|
| 434 | + } |
|
| 412 | 435 | } |
| 413 | 436 | // Update the number of trackbacks |
| 414 | 437 | $oDocumentController->updateTrackbackCount($obj->document_srl, $success_count); |
@@ -506,7 +529,9 @@ discard block |
||
| 506 | 529 | { |
| 507 | 530 | $args->document_srl = $document_srl; |
| 508 | 531 | $output = executeQuery('document.deleteDeclaredDocuments', $args); |
| 509 | - if(!$output->toBool()) return $output; |
|
| 532 | + if(!$output->toBool()) { |
|
| 533 | + return $output; |
|
| 534 | + } |
|
| 510 | 535 | } |
| 511 | 536 | } |
| 512 | 537 | |
@@ -537,7 +562,9 @@ discard block |
||
| 537 | 562 | if (is_dir($path."/".$entry)) { |
| 538 | 563 | $this->deleteThumbnailFile($path."/".$entry); |
| 539 | 564 | } else { |
| 540 | - if(!preg_match('/^thumbnail_([^\.]*)\.jpg$/i',$entry)) continue; |
|
| 565 | + if(!preg_match('/^thumbnail_([^\.]*)\.jpg$/i',$entry)) { |
|
| 566 | + continue; |
|
| 567 | + } |
|
| 541 | 568 | FileHandler::removeFile($path.'/'.$entry); |
| 542 | 569 | } |
| 543 | 570 | } |
@@ -562,7 +589,9 @@ discard block |
||
| 562 | 589 | $eid = Context::get('eid'); |
| 563 | 590 | $obj = new stdClass(); |
| 564 | 591 | |
| 565 | - if(!$module_srl || !$name || !$eid) return new BaseObject(-1,'msg_invalid_request'); |
|
| 592 | + if(!$module_srl || !$name || !$eid) { |
|
| 593 | + return new BaseObject(-1,'msg_invalid_request'); |
|
| 594 | + } |
|
| 566 | 595 | // set the max value if idx is not specified |
| 567 | 596 | if(!$var_idx) |
| 568 | 597 | { |
@@ -584,7 +613,9 @@ discard block |
||
| 584 | 613 | // insert or update |
| 585 | 614 | $oDocumentController = getController('document'); |
| 586 | 615 | $output = $oDocumentController->insertDocumentExtraKey($module_srl, $var_idx, $name, $type, $is_required, $search, $default, $desc, $eid); |
| 587 | - if(!$output->toBool()) return $output; |
|
| 616 | + if(!$output->toBool()) { |
|
| 617 | + return $output; |
|
| 618 | + } |
|
| 588 | 619 | |
| 589 | 620 | $this->setMessage('success_registed'); |
| 590 | 621 | |
@@ -600,11 +631,15 @@ discard block |
||
| 600 | 631 | { |
| 601 | 632 | $module_srl = Context::get('module_srl'); |
| 602 | 633 | $var_idx = Context::get('var_idx'); |
| 603 | - if(!$module_srl || !$var_idx) return new BaseObject(-1,'msg_invalid_request'); |
|
| 634 | + if(!$module_srl || !$var_idx) { |
|
| 635 | + return new BaseObject(-1,'msg_invalid_request'); |
|
| 636 | + } |
|
| 604 | 637 | |
| 605 | 638 | $oDocumentController = getController('document'); |
| 606 | 639 | $output = $oDocumentController->deleteDocumentExtraKeys($module_srl, $var_idx); |
| 607 | - if(!$output->toBool()) return $output; |
|
| 640 | + if(!$output->toBool()) { |
|
| 641 | + return $output; |
|
| 642 | + } |
|
| 608 | 643 | |
| 609 | 644 | $this->setMessage('success_deleted'); |
| 610 | 645 | } |
@@ -619,26 +654,41 @@ discard block |
||
| 619 | 654 | $module_srl = Context::get('module_srl'); |
| 620 | 655 | $var_idx = Context::get('var_idx'); |
| 621 | 656 | |
| 622 | - if(!$type || !$module_srl || !$var_idx) return new BaseObject(-1,'msg_invalid_request'); |
|
| 657 | + if(!$type || !$module_srl || !$var_idx) { |
|
| 658 | + return new BaseObject(-1,'msg_invalid_request'); |
|
| 659 | + } |
|
| 623 | 660 | |
| 624 | 661 | $oModuleModel = getModel('module'); |
| 625 | 662 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); |
| 626 | - if(!$module_info->module_srl) return new BaseObject(-1,'msg_invalid_request'); |
|
| 663 | + if(!$module_info->module_srl) { |
|
| 664 | + return new BaseObject(-1,'msg_invalid_request'); |
|
| 665 | + } |
|
| 627 | 666 | |
| 628 | 667 | $oDocumentModel = getModel('document'); |
| 629 | 668 | $extra_keys = $oDocumentModel->getExtraKeys($module_srl); |
| 630 | - if(!$extra_keys[$var_idx]) return new BaseObject(-1,'msg_invalid_request'); |
|
| 669 | + if(!$extra_keys[$var_idx]) { |
|
| 670 | + return new BaseObject(-1,'msg_invalid_request'); |
|
| 671 | + } |
|
| 631 | 672 | |
| 632 | - if($type == 'up') $new_idx = $var_idx-1; |
|
| 633 | - else $new_idx = $var_idx+1; |
|
| 634 | - if($new_idx<1) return new BaseObject(-1,'msg_invalid_request'); |
|
| 673 | + if($type == 'up') { |
|
| 674 | + $new_idx = $var_idx-1; |
|
| 675 | + } else { |
|
| 676 | + $new_idx = $var_idx+1; |
|
| 677 | + } |
|
| 678 | + if($new_idx<1) { |
|
| 679 | + return new BaseObject(-1,'msg_invalid_request'); |
|
| 680 | + } |
|
| 635 | 681 | |
| 636 | 682 | $args = new stdClass(); |
| 637 | 683 | $args->module_srl = $module_srl; |
| 638 | 684 | $args->var_idx = $new_idx; |
| 639 | 685 | $output = executeQuery('document.getDocumentExtraKeys', $args); |
| 640 | - if (!$output->toBool()) return $output; |
|
| 641 | - if (!$output->data) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 686 | + if (!$output->toBool()) { |
|
| 687 | + return $output; |
|
| 688 | + } |
|
| 689 | + if (!$output->data) { |
|
| 690 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
| 691 | + } |
|
| 642 | 692 | unset($args); |
| 643 | 693 | |
| 644 | 694 | // update immediately if there is no idx to change |
@@ -649,35 +699,50 @@ discard block |
||
| 649 | 699 | $args->var_idx = $var_idx; |
| 650 | 700 | $args->new_idx = $new_idx; |
| 651 | 701 | $output = executeQuery('document.updateDocumentExtraKeyIdx', $args); |
| 652 | - if(!$output->toBool()) return $output; |
|
| 702 | + if(!$output->toBool()) { |
|
| 703 | + return $output; |
|
| 704 | + } |
|
| 653 | 705 | $output = executeQuery('document.updateDocumentExtraVarIdx', $args); |
| 654 | - if(!$output->toBool()) return $output; |
|
| 706 | + if(!$output->toBool()) { |
|
| 707 | + return $output; |
|
| 708 | + } |
|
| 655 | 709 | // replace if exists |
| 656 | - } |
|
| 657 | - else |
|
| 710 | + } else |
|
| 658 | 711 | { |
| 659 | 712 | $args = new stdClass(); |
| 660 | 713 | $args->module_srl = $module_srl; |
| 661 | 714 | $args->var_idx = $new_idx; |
| 662 | 715 | $args->new_idx = -10000; |
| 663 | 716 | $output = executeQuery('document.updateDocumentExtraKeyIdx', $args); |
| 664 | - if(!$output->toBool()) return $output; |
|
| 717 | + if(!$output->toBool()) { |
|
| 718 | + return $output; |
|
| 719 | + } |
|
| 665 | 720 | $output = executeQuery('document.updateDocumentExtraVarIdx', $args); |
| 666 | - if(!$output->toBool()) return $output; |
|
| 721 | + if(!$output->toBool()) { |
|
| 722 | + return $output; |
|
| 723 | + } |
|
| 667 | 724 | |
| 668 | 725 | $args->var_idx = $var_idx; |
| 669 | 726 | $args->new_idx = $new_idx; |
| 670 | 727 | $output = executeQuery('document.updateDocumentExtraKeyIdx', $args); |
| 671 | - if(!$output->toBool()) return $output; |
|
| 728 | + if(!$output->toBool()) { |
|
| 729 | + return $output; |
|
| 730 | + } |
|
| 672 | 731 | $output = executeQuery('document.updateDocumentExtraVarIdx', $args); |
| 673 | - if(!$output->toBool()) return $output; |
|
| 732 | + if(!$output->toBool()) { |
|
| 733 | + return $output; |
|
| 734 | + } |
|
| 674 | 735 | |
| 675 | 736 | $args->var_idx = -10000; |
| 676 | 737 | $args->new_idx = $var_idx; |
| 677 | 738 | $output = executeQuery('document.updateDocumentExtraKeyIdx', $args); |
| 678 | - if(!$output->toBool()) return $output; |
|
| 739 | + if(!$output->toBool()) { |
|
| 740 | + return $output; |
|
| 741 | + } |
|
| 679 | 742 | $output = executeQuery('document.updateDocumentExtraVarIdx', $args); |
| 680 | - if(!$output->toBool()) return $output; |
|
| 743 | + if(!$output->toBool()) { |
|
| 744 | + return $output; |
|
| 745 | + } |
|
| 681 | 746 | } |
| 682 | 747 | |
| 683 | 748 | $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); |
@@ -701,8 +766,7 @@ discard block |
||
| 701 | 766 | { |
| 702 | 767 | $args->alias_srl = getNextSequence(); |
| 703 | 768 | $query = "document.insertAlias"; |
| 704 | - } |
|
| 705 | - else |
|
| 769 | + } else |
|
| 706 | 770 | { |
| 707 | 771 | $args->alias_srl = $alias_srl; |
| 708 | 772 | $query = "document.updateAlias"; |
@@ -740,7 +804,9 @@ discard block |
||
| 740 | 804 | $oDocumentModel = getModel('document'); |
| 741 | 805 | $oDocumentController = getController('document'); |
| 742 | 806 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
| 743 | - if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted'); |
|
| 807 | + if(!$oDocument->isGranted()) { |
|
| 808 | + return $this->stop('msg_not_permitted'); |
|
| 809 | + } |
|
| 744 | 810 | |
| 745 | 811 | $oModuleModel = getModel('module'); |
| 746 | 812 | $module_info = $oModuleModel->getModuleInfoByDocumentSrl($document_srl); |
@@ -762,8 +828,9 @@ discard block |
||
| 762 | 828 | parse_str($arrUrl['query'], $arrQuery); |
| 763 | 829 | |
| 764 | 830 | // set query |
| 765 | - if(isset($arrQuery['document_srl'])) |
|
| 766 | - unset($arrQuery['document_srl']); |
|
| 831 | + if(isset($arrQuery['document_srl'])) { |
|
| 832 | + unset($arrQuery['document_srl']); |
|
| 833 | + } |
|
| 767 | 834 | |
| 768 | 835 | $searchArgs = new stdClass; |
| 769 | 836 | foreach($arrQuery as $key=>$val) |
@@ -771,13 +838,15 @@ discard block |
||
| 771 | 838 | $searchArgs->{$key} = $val; |
| 772 | 839 | } |
| 773 | 840 | |
| 774 | - if(!isset($searchArgs->sort_index)) |
|
| 775 | - $searchArgs->sort_index = $module_info->order_target; |
|
| 841 | + if(!isset($searchArgs->sort_index)) { |
|
| 842 | + $searchArgs->sort_index = $module_info->order_target; |
|
| 843 | + } |
|
| 776 | 844 | |
| 777 | 845 | foreach($module_info as $key=>$val) |
| 778 | 846 | { |
| 779 | - if(!isset($searchArgs->{$key})) |
|
| 780 | - $searchArgs->{$key} = $val; |
|
| 847 | + if(!isset($searchArgs->{$key})) { |
|
| 848 | + $searchArgs->{$key} = $val; |
|
| 849 | + } |
|
| 781 | 850 | } |
| 782 | 851 | |
| 783 | 852 | $oDocumentModel = getModel('document'); |
@@ -789,12 +858,14 @@ discard block |
||
| 789 | 858 | } |
| 790 | 859 | |
| 791 | 860 | |
| 792 | - if($cur_page>1 && count($output->data) == 0) |
|
| 793 | - $arrQuery['page'] = $cur_page - 1; |
|
| 861 | + if($cur_page>1 && count($output->data) == 0) { |
|
| 862 | + $arrQuery['page'] = $cur_page - 1; |
|
| 863 | + } |
|
| 794 | 864 | |
| 795 | 865 | $query = "?"; |
| 796 | - foreach($arrQuery as $key=>$val) |
|
| 797 | - $query .= sprintf("%s=%s&", $key, $val); |
|
| 866 | + foreach($arrQuery as $key=>$val) { |
|
| 867 | + $query .= sprintf("%s=%s&", $key, $val); |
|
| 868 | + } |
|
| 798 | 869 | $query = substr($query, 0, -1); |
| 799 | 870 | } |
| 800 | 871 | $returnUrl = $arrUrl['path'] . $query; |
@@ -874,7 +945,9 @@ discard block |
||
| 874 | 945 | */ |
| 875 | 946 | function restoreTrash($originObject) |
| 876 | 947 | { |
| 877 | - if(is_array($originObject)) $originObject = (object)$originObject; |
|
| 948 | + if(is_array($originObject)) { |
|
| 949 | + $originObject = (object)$originObject; |
|
| 950 | + } |
|
| 878 | 951 | |
| 879 | 952 | $oDocumentController = getController('document'); |
| 880 | 953 | $oDocumentModel = getModel('document'); |
@@ -884,7 +957,9 @@ discard block |
||
| 884 | 957 | |
| 885 | 958 | //DB restore |
| 886 | 959 | $output = $oDocumentController->insertDocument($originObject, false, true, false); |
| 887 | - if(!$output->toBool()) return new BaseObject(-1, $output->getMessage()); |
|
| 960 | + if(!$output->toBool()) { |
|
| 961 | + return new BaseObject(-1, $output->getMessage()); |
|
| 962 | + } |
|
| 888 | 963 | |
| 889 | 964 | //FILE restore |
| 890 | 965 | $oDocument = $oDocumentModel->getDocument($originObject->document_srl); |
@@ -922,7 +997,9 @@ discard block |
||
| 922 | 997 | function emptyTrash($originObject) |
| 923 | 998 | { |
| 924 | 999 | $originObject = unserialize($originObject); |
| 925 | - if(is_array($originObject)) $originObject = (object) $originObject; |
|
| 1000 | + if(is_array($originObject)) { |
|
| 1001 | + $originObject = (object) $originObject; |
|
| 1002 | + } |
|
| 926 | 1003 | |
| 927 | 1004 | $oDocument = new documentItem(); |
| 928 | 1005 | $oDocument->setAttribute($originObject); |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | |
| 717 | 717 | /** |
| 718 | 718 | * Move the doc into the trash |
| 719 | - * @param object $obj |
|
| 719 | + * @param stdClass $obj |
|
| 720 | 720 | * @return object |
| 721 | 721 | */ |
| 722 | 722 | function moveDocumentToTrash($obj) |
@@ -1811,7 +1811,7 @@ discard block |
||
| 1811 | 1811 | * Occasionally the xml file is not generated after menu is configued on the admin page \n |
| 1812 | 1812 | * The administrator can manually update the file in this case \n |
| 1813 | 1813 | * Although the issue is not currently reproduced, it is unnecessay to remove. |
| 1814 | - * @return void |
|
| 1814 | + * @return BaseObject|null |
|
| 1815 | 1815 | */ |
| 1816 | 1816 | function procDocumentMakeXmlFile() |
| 1817 | 1817 | { |
@@ -24,19 +24,27 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | function procDocumentVoteUp() |
| 26 | 26 | { |
| 27 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 27 | + if(!Context::get('is_logged')) { |
|
| 28 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
| 29 | + } |
|
| 28 | 30 | |
| 29 | 31 | $document_srl = Context::get('target_srl'); |
| 30 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 32 | + if(!$document_srl) { |
|
| 33 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
| 34 | + } |
|
| 31 | 35 | |
| 32 | 36 | $oDocumentModel = getModel('document'); |
| 33 | 37 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
| 34 | 38 | $module_srl = $oDocument->get('module_srl'); |
| 35 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 39 | + if(!$module_srl) { |
|
| 40 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
| 41 | + } |
|
| 36 | 42 | |
| 37 | 43 | $oModuleModel = getModel('module'); |
| 38 | 44 | $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
| 39 | - if($document_config->use_vote_up=='N') return new BaseObject(-1, 'msg_invalid_request'); |
|
| 45 | + if($document_config->use_vote_up=='N') { |
|
| 46 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
| 47 | + } |
|
| 40 | 48 | |
| 41 | 49 | $point = 1; |
| 42 | 50 | $output = $this->updateVotedCount($document_srl, $point); |
@@ -69,19 +77,27 @@ discard block |
||
| 69 | 77 | */ |
| 70 | 78 | function procDocumentVoteDown() |
| 71 | 79 | { |
| 72 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 80 | + if(!Context::get('is_logged')) { |
|
| 81 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
| 82 | + } |
|
| 73 | 83 | |
| 74 | 84 | $document_srl = Context::get('target_srl'); |
| 75 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 85 | + if(!$document_srl) { |
|
| 86 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
| 87 | + } |
|
| 76 | 88 | |
| 77 | 89 | $oDocumentModel = getModel('document'); |
| 78 | 90 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
| 79 | 91 | $module_srl = $oDocument->get('module_srl'); |
| 80 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 92 | + if(!$module_srl) { |
|
| 93 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
| 94 | + } |
|
| 81 | 95 | |
| 82 | 96 | $oModuleModel = getModel('module'); |
| 83 | 97 | $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
| 84 | - if($document_config->use_vote_down=='N') return new BaseObject(-1, 'msg_invalid_request'); |
|
| 98 | + if($document_config->use_vote_down=='N') { |
|
| 99 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
| 100 | + } |
|
| 85 | 101 | |
| 86 | 102 | $point = -1; |
| 87 | 103 | $output = $this->updateVotedCount($document_srl, $point); |
@@ -95,10 +111,14 @@ discard block |
||
| 95 | 111 | */ |
| 96 | 112 | function procDocumentDeclare() |
| 97 | 113 | { |
| 98 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 114 | + if(!Context::get('is_logged')) { |
|
| 115 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
| 116 | + } |
|
| 99 | 117 | |
| 100 | 118 | $document_srl = Context::get('target_srl'); |
| 101 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 119 | + if(!$document_srl) { |
|
| 120 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
| 121 | + } |
|
| 102 | 122 | |
| 103 | 123 | return $this->declaredDocument($document_srl); |
| 104 | 124 | } |
@@ -140,7 +160,9 @@ discard block |
||
| 140 | 160 | $args->history_srl = $history_srl; |
| 141 | 161 | $args->module_srl = $module_srl; |
| 142 | 162 | $args->document_srl = $document_srl; |
| 143 | - if(!$args->history_srl && !$args->module_srl && !$args->document_srl) return; |
|
| 163 | + if(!$args->history_srl && !$args->module_srl && !$args->document_srl) { |
|
| 164 | + return; |
|
| 165 | + } |
|
| 144 | 166 | executeQuery("document.deleteHistory", $args); |
| 145 | 167 | } |
| 146 | 168 | |
@@ -152,15 +174,21 @@ discard block |
||
| 152 | 174 | function triggerDeleteModuleDocuments(&$obj) |
| 153 | 175 | { |
| 154 | 176 | $module_srl = $obj->module_srl; |
| 155 | - if(!$module_srl) return new BaseObject(); |
|
| 177 | + if(!$module_srl) { |
|
| 178 | + return new BaseObject(); |
|
| 179 | + } |
|
| 156 | 180 | // Delete the document |
| 157 | 181 | $oDocumentAdminController = getAdminController('document'); |
| 158 | 182 | $output = $oDocumentAdminController->deleteModuleDocument($module_srl); |
| 159 | - if(!$output->toBool()) return $output; |
|
| 183 | + if(!$output->toBool()) { |
|
| 184 | + return $output; |
|
| 185 | + } |
|
| 160 | 186 | // Delete the category |
| 161 | 187 | $oDocumentController = getController('document'); |
| 162 | 188 | $output = $oDocumentController->deleteModuleCategory($module_srl); |
| 163 | - if(!$output->toBool()) return $output; |
|
| 189 | + if(!$output->toBool()) { |
|
| 190 | + return $output; |
|
| 191 | + } |
|
| 164 | 192 | // Delete extra key and variable, because module deleted |
| 165 | 193 | $this->deleteDocumentExtraKeys($module_srl); |
| 166 | 194 | |
@@ -202,10 +230,18 @@ discard block |
||
| 202 | 230 | $oDB = &DB::getInstance(); |
| 203 | 231 | $oDB->begin(); |
| 204 | 232 | // List variables |
| 205 | - if($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
| 206 | - if(!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
| 207 | - if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
| 208 | - if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N'; |
|
| 233 | + if($obj->comment_status) { |
|
| 234 | + $obj->commentStatus = $obj->comment_status; |
|
| 235 | + } |
|
| 236 | + if(!$obj->commentStatus) { |
|
| 237 | + $obj->commentStatus = 'DENY'; |
|
| 238 | + } |
|
| 239 | + if($obj->commentStatus == 'DENY') { |
|
| 240 | + $this->_checkCommentStatusForOldVersion($obj); |
|
| 241 | + } |
|
| 242 | + if($obj->allow_trackback!='Y') { |
|
| 243 | + $obj->allow_trackback = 'N'; |
|
| 244 | + } |
|
| 209 | 245 | if($obj->homepage) |
| 210 | 246 | { |
| 211 | 247 | $obj->homepage = removeHackTag($obj->homepage); |
@@ -215,9 +251,15 @@ discard block |
||
| 215 | 251 | } |
| 216 | 252 | } |
| 217 | 253 | |
| 218 | - if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
| 219 | - if(!$obj->email_address) $obj->email_address = ''; |
|
| 220 | - if(!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
| 254 | + if($obj->notify_message != 'Y') { |
|
| 255 | + $obj->notify_message = 'N'; |
|
| 256 | + } |
|
| 257 | + if(!$obj->email_address) { |
|
| 258 | + $obj->email_address = ''; |
|
| 259 | + } |
|
| 260 | + if(!$isRestore) { |
|
| 261 | + $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
| 262 | + } |
|
| 221 | 263 | |
| 222 | 264 | // can modify regdate only manager |
| 223 | 265 | $grant = Context::get('grant'); |
@@ -227,7 +269,9 @@ discard block |
||
| 227 | 269 | } |
| 228 | 270 | |
| 229 | 271 | // Serialize the $extra_vars, check the extra_vars type, because duplicate serialized avoid |
| 230 | - if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
| 272 | + if(!is_string($obj->extra_vars)) { |
|
| 273 | + $obj->extra_vars = serialize($obj->extra_vars); |
|
| 274 | + } |
|
| 231 | 275 | // Remove the columns for automatic saving |
| 232 | 276 | unset($obj->_saved_doc_srl); |
| 233 | 277 | unset($obj->_saved_doc_title); |
@@ -235,10 +279,15 @@ discard block |
||
| 235 | 279 | unset($obj->_saved_doc_message); |
| 236 | 280 | // Call a trigger (before) |
| 237 | 281 | $output = ModuleHandler::triggerCall('document.insertDocument', 'before', $obj); |
| 238 | - if(!$output->toBool()) return $output; |
|
| 282 | + if(!$output->toBool()) { |
|
| 283 | + return $output; |
|
| 284 | + } |
|
| 239 | 285 | // Register it if no given document_srl exists |
| 240 | - if(!$obj->document_srl) $obj->document_srl = getNextSequence(); |
|
| 241 | - elseif(!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) return new BaseObject(-1, 'msg_not_permitted'); |
|
| 286 | + if(!$obj->document_srl) { |
|
| 287 | + $obj->document_srl = getNextSequence(); |
|
| 288 | + } elseif(!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) { |
|
| 289 | + return new BaseObject(-1, 'msg_not_permitted'); |
|
| 290 | + } |
|
| 242 | 291 | |
| 243 | 292 | $oDocumentModel = getModel('document'); |
| 244 | 293 | // Set to 0 if the category_srl doesn't exist |
@@ -249,12 +298,19 @@ discard block |
||
| 249 | 298 | { |
| 250 | 299 | return new BaseObject(-1, 'msg_not_permitted'); |
| 251 | 300 | } |
| 252 | - if(count($category_list) > 0 && !$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
| 301 | + if(count($category_list) > 0 && !$category_list[$obj->category_srl]) { |
|
| 302 | + $obj->category_srl = 0; |
|
| 303 | + } |
|
| 253 | 304 | } |
| 254 | 305 | // Set the read counts and update order. |
| 255 | - if(!$obj->readed_count) $obj->readed_count = 0; |
|
| 256 | - if($isLatest) $obj->update_order = $obj->list_order = $obj->document_srl * -1; |
|
| 257 | - else $obj->update_order = $obj->list_order; |
|
| 306 | + if(!$obj->readed_count) { |
|
| 307 | + $obj->readed_count = 0; |
|
| 308 | + } |
|
| 309 | + if($isLatest) { |
|
| 310 | + $obj->update_order = $obj->list_order = $obj->document_srl * -1; |
|
| 311 | + } else { |
|
| 312 | + $obj->update_order = $obj->list_order; |
|
| 313 | + } |
|
| 258 | 314 | // Check the status of password hash for manually inserting. Apply hashing for otherwise. |
| 259 | 315 | if($obj->password && !$obj->password_is_hashed) |
| 260 | 316 | { |
@@ -276,9 +332,13 @@ discard block |
||
| 276 | 332 | // If the tile is empty, extract string from the contents. |
| 277 | 333 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 278 | 334 | settype($obj->title, "string"); |
| 279 | - if($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...'); |
|
| 335 | + if($obj->title == '') { |
|
| 336 | + $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...'); |
|
| 337 | + } |
|
| 280 | 338 | // If no tile extracted from the contents, leave it untitled. |
| 281 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
| 339 | + if($obj->title == '') { |
|
| 340 | + $obj->title = 'Untitled'; |
|
| 341 | + } |
|
| 282 | 342 | // Remove XE's own tags from the contents. |
| 283 | 343 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
| 284 | 344 | if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
@@ -290,13 +350,19 @@ discard block |
||
| 290 | 350 | $obj->content = nl2br($obj->content); |
| 291 | 351 | } |
| 292 | 352 | // Remove iframe and script if not a top adminisrator in the session. |
| 293 | - if($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content); |
|
| 353 | + if($logged_info->is_admin != 'Y') { |
|
| 354 | + $obj->content = removeHackTag($obj->content); |
|
| 355 | + } |
|
| 294 | 356 | // An error appears if both log-in info and user name don't exist. |
| 295 | - if(!$logged_info->member_srl && !$obj->nick_name) return new BaseObject(-1,'msg_invalid_request'); |
|
| 357 | + if(!$logged_info->member_srl && !$obj->nick_name) { |
|
| 358 | + return new BaseObject(-1,'msg_invalid_request'); |
|
| 359 | + } |
|
| 296 | 360 | |
| 297 | 361 | $obj->lang_code = Context::getLangType(); |
| 298 | 362 | // Insert data into the DB |
| 299 | - if(!$obj->status) $this->_checkDocumentStatusForOldVersion($obj); |
|
| 363 | + if(!$obj->status) { |
|
| 364 | + $this->_checkDocumentStatusForOldVersion($obj); |
|
| 365 | + } |
|
| 300 | 366 | $output = executeQuery('document.insertDocument', $obj); |
| 301 | 367 | if(!$output->toBool()) |
| 302 | 368 | { |
@@ -313,19 +379,25 @@ discard block |
||
| 313 | 379 | if(isset($obj->{'extra_vars'.$idx})) |
| 314 | 380 | { |
| 315 | 381 | $tmp = $obj->{'extra_vars'.$idx}; |
| 316 | - if(is_array($tmp)) |
|
| 317 | - $value = implode('|@|', $tmp); |
|
| 318 | - else |
|
| 319 | - $value = trim($tmp); |
|
| 382 | + if(is_array($tmp)) { |
|
| 383 | + $value = implode('|@|', $tmp); |
|
| 384 | + } else { |
|
| 385 | + $value = trim($tmp); |
|
| 386 | + } |
|
| 387 | + } else if(isset($obj->{$extra_item->name})) { |
|
| 388 | + $value = trim($obj->{$extra_item->name}); |
|
| 389 | + } |
|
| 390 | + if($value == NULL) { |
|
| 391 | + continue; |
|
| 320 | 392 | } |
| 321 | - else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
| 322 | - if($value == NULL) continue; |
|
| 323 | 393 | |
| 324 | 394 | $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); |
| 325 | 395 | } |
| 326 | 396 | } |
| 327 | 397 | // Update the category if the category_srl exists. |
| 328 | - if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
| 398 | + if($obj->category_srl) { |
|
| 399 | + $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
| 400 | + } |
|
| 329 | 401 | // Call a trigger (after) |
| 330 | 402 | if($output->toBool()) |
| 331 | 403 | { |
@@ -367,27 +439,39 @@ discard block |
||
| 367 | 439 | return new BaseObject(-1, 'msg_invalid_request'); |
| 368 | 440 | } |
| 369 | 441 | |
| 370 | - if(!$source_obj->document_srl || !$obj->document_srl) return new BaseObject(-1,'msg_invalied_request'); |
|
| 371 | - if(!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET'; |
|
| 372 | - if(!$obj->status) $obj->status = 'PUBLIC'; |
|
| 442 | + if(!$source_obj->document_srl || !$obj->document_srl) { |
|
| 443 | + return new BaseObject(-1,'msg_invalied_request'); |
|
| 444 | + } |
|
| 445 | + if(!$obj->status && $obj->is_secret == 'Y') { |
|
| 446 | + $obj->status = 'SECRET'; |
|
| 447 | + } |
|
| 448 | + if(!$obj->status) { |
|
| 449 | + $obj->status = 'PUBLIC'; |
|
| 450 | + } |
|
| 373 | 451 | |
| 374 | 452 | // Call a trigger (before) |
| 375 | 453 | $output = ModuleHandler::triggerCall('document.updateDocument', 'before', $obj); |
| 376 | - if(!$output->toBool()) return $output; |
|
| 454 | + if(!$output->toBool()) { |
|
| 455 | + return $output; |
|
| 456 | + } |
|
| 377 | 457 | |
| 378 | 458 | // begin transaction |
| 379 | 459 | $oDB = &DB::getInstance(); |
| 380 | 460 | $oDB->begin(); |
| 381 | 461 | |
| 382 | 462 | $oModuleModel = getModel('module'); |
| 383 | - if(!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl'); |
|
| 463 | + if(!$obj->module_srl) { |
|
| 464 | + $obj->module_srl = $source_obj->get('module_srl'); |
|
| 465 | + } |
|
| 384 | 466 | $module_srl = $obj->module_srl; |
| 385 | 467 | $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
| 386 | 468 | if(!$document_config) |
| 387 | 469 | { |
| 388 | 470 | $document_config = new stdClass(); |
| 389 | 471 | } |
| 390 | - if(!isset($document_config->use_history)) $document_config->use_history = 'N'; |
|
| 472 | + if(!isset($document_config->use_history)) { |
|
| 473 | + $document_config->use_history = 'N'; |
|
| 474 | + } |
|
| 391 | 475 | $bUseHistory = $document_config->use_history == 'Y' || $document_config->use_history == 'Trace'; |
| 392 | 476 | |
| 393 | 477 | if($bUseHistory) |
@@ -396,22 +480,31 @@ discard block |
||
| 396 | 480 | $args->history_srl = getNextSequence(); |
| 397 | 481 | $args->document_srl = $obj->document_srl; |
| 398 | 482 | $args->module_srl = $module_srl; |
| 399 | - if($document_config->use_history == 'Y') $args->content = $source_obj->get('content'); |
|
| 483 | + if($document_config->use_history == 'Y') { |
|
| 484 | + $args->content = $source_obj->get('content'); |
|
| 485 | + } |
|
| 400 | 486 | $args->nick_name = $source_obj->get('nick_name'); |
| 401 | 487 | $args->member_srl = $source_obj->get('member_srl'); |
| 402 | 488 | $args->regdate = $source_obj->get('last_update'); |
| 403 | 489 | $args->ipaddress = $source_obj->get('ipaddress'); |
| 404 | 490 | $output = executeQuery("document.insertHistory", $args); |
| 405 | - } |
|
| 406 | - else |
|
| 491 | + } else |
|
| 407 | 492 | { |
| 408 | 493 | $obj->ipaddress = $source_obj->get('ipaddress'); |
| 409 | 494 | } |
| 410 | 495 | // List variables |
| 411 | - if($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
| 412 | - if(!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
| 413 | - if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
| 414 | - if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N'; |
|
| 496 | + if($obj->comment_status) { |
|
| 497 | + $obj->commentStatus = $obj->comment_status; |
|
| 498 | + } |
|
| 499 | + if(!$obj->commentStatus) { |
|
| 500 | + $obj->commentStatus = 'DENY'; |
|
| 501 | + } |
|
| 502 | + if($obj->commentStatus == 'DENY') { |
|
| 503 | + $this->_checkCommentStatusForOldVersion($obj); |
|
| 504 | + } |
|
| 505 | + if($obj->allow_trackback!='Y') { |
|
| 506 | + $obj->allow_trackback = 'N'; |
|
| 507 | + } |
|
| 415 | 508 | if($obj->homepage) |
| 416 | 509 | { |
| 417 | 510 | $obj->homepage = removeHackTag($obj->homepage); |
@@ -421,7 +514,9 @@ discard block |
||
| 421 | 514 | } |
| 422 | 515 | } |
| 423 | 516 | |
| 424 | - if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
| 517 | + if($obj->notify_message != 'Y') { |
|
| 518 | + $obj->notify_message = 'N'; |
|
| 519 | + } |
|
| 425 | 520 | |
| 426 | 521 | // can modify regdate only manager |
| 427 | 522 | $grant = Context::get('grant'); |
@@ -431,7 +526,9 @@ discard block |
||
| 431 | 526 | } |
| 432 | 527 | |
| 433 | 528 | // Serialize the $extra_vars |
| 434 | - if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
| 529 | + if(!is_string($obj->extra_vars)) { |
|
| 530 | + $obj->extra_vars = serialize($obj->extra_vars); |
|
| 531 | + } |
|
| 435 | 532 | // Remove the columns for automatic saving |
| 436 | 533 | unset($obj->_saved_doc_srl); |
| 437 | 534 | unset($obj->_saved_doc_title); |
@@ -443,7 +540,9 @@ discard block |
||
| 443 | 540 | if($source_obj->get('category_srl')!=$obj->category_srl) |
| 444 | 541 | { |
| 445 | 542 | $category_list = $oDocumentModel->getCategoryList($obj->module_srl); |
| 446 | - if(!$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
| 543 | + if(!$category_list[$obj->category_srl]) { |
|
| 544 | + $obj->category_srl = 0; |
|
| 545 | + } |
|
| 447 | 546 | } |
| 448 | 547 | // Change the update order |
| 449 | 548 | $obj->update_order = getNextSequence() * -1; |
@@ -478,9 +577,13 @@ discard block |
||
| 478 | 577 | // If the tile is empty, extract string from the contents. |
| 479 | 578 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 480 | 579 | settype($obj->title, "string"); |
| 481 | - if($obj->title == '') $obj->title = cut_str(strip_tags($obj->content),20,'...'); |
|
| 580 | + if($obj->title == '') { |
|
| 581 | + $obj->title = cut_str(strip_tags($obj->content),20,'...'); |
|
| 582 | + } |
|
| 482 | 583 | // If no tile extracted from the contents, leave it untitled. |
| 483 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
| 584 | + if($obj->title == '') { |
|
| 585 | + $obj->title = 'Untitled'; |
|
| 586 | + } |
|
| 484 | 587 | // Remove XE's own tags from the contents. |
| 485 | 588 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
| 486 | 589 | if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
@@ -500,8 +603,7 @@ discard block |
||
| 500 | 603 | $lang_code_args->document_srl = $source_obj->get('document_srl'); |
| 501 | 604 | $lang_code_args->lang_code = Context::getLangType(); |
| 502 | 605 | $output = executeQuery('document.updateDocumentsLangCode', $lang_code_args); |
| 503 | - } |
|
| 504 | - else |
|
| 606 | + } else |
|
| 505 | 607 | { |
| 506 | 608 | $extra_content = new stdClass; |
| 507 | 609 | $extra_content->title = $obj->title; |
@@ -520,7 +622,9 @@ discard block |
||
| 520 | 622 | $obj->content = removeHackTag($obj->content); |
| 521 | 623 | } |
| 522 | 624 | // if temporary document, regdate is now setting |
| 523 | - if($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis'); |
|
| 625 | + if($source_obj->get('status') == $this->getConfigStatus('temp')) { |
|
| 626 | + $obj->regdate = date('YmdHis'); |
|
| 627 | + } |
|
| 524 | 628 | |
| 525 | 629 | // Insert data into the DB |
| 526 | 630 | $output = executeQuery('document.updateDocument', $obj); |
@@ -543,25 +647,37 @@ discard block |
||
| 543 | 647 | if(isset($obj->{'extra_vars'.$idx})) |
| 544 | 648 | { |
| 545 | 649 | $tmp = $obj->{'extra_vars'.$idx}; |
| 546 | - if(is_array($tmp)) |
|
| 547 | - $value = implode('|@|', $tmp); |
|
| 548 | - else |
|
| 549 | - $value = trim($tmp); |
|
| 650 | + if(is_array($tmp)) { |
|
| 651 | + $value = implode('|@|', $tmp); |
|
| 652 | + } else { |
|
| 653 | + $value = trim($tmp); |
|
| 654 | + } |
|
| 655 | + } else if(isset($obj->{$extra_item->name})) { |
|
| 656 | + $value = trim($obj->{$extra_item->name}); |
|
| 657 | + } |
|
| 658 | + if($value == NULL) { |
|
| 659 | + continue; |
|
| 550 | 660 | } |
| 551 | - else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
| 552 | - if($value == NULL) continue; |
|
| 553 | 661 | $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); |
| 554 | 662 | } |
| 555 | 663 | } |
| 556 | 664 | // Inert extra vars for multi-language support of title and contents. |
| 557 | - if($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType()); |
|
| 558 | - if($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType()); |
|
| 665 | + if($extra_content->title) { |
|
| 666 | + $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType()); |
|
| 667 | + } |
|
| 668 | + if($extra_content->content) { |
|
| 669 | + $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType()); |
|
| 670 | + } |
|
| 559 | 671 | } |
| 560 | 672 | // Update the category if the category_srl exists. |
| 561 | 673 | if($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl) |
| 562 | 674 | { |
| 563 | - if($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
| 564 | - if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
| 675 | + if($source_obj->get('category_srl') != $obj->category_srl) { |
|
| 676 | + $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
| 677 | + } |
|
| 678 | + if($obj->category_srl) { |
|
| 679 | + $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
| 680 | + } |
|
| 565 | 681 | } |
| 566 | 682 | // Call a trigger (after) |
| 567 | 683 | if($output->toBool()) |
@@ -606,7 +722,9 @@ discard block |
||
| 606 | 722 | $trigger_obj = new stdClass(); |
| 607 | 723 | $trigger_obj->document_srl = $document_srl; |
| 608 | 724 | $output = ModuleHandler::triggerCall('document.deleteDocument', 'before', $trigger_obj); |
| 609 | - if(!$output->toBool()) return $output; |
|
| 725 | + if(!$output->toBool()) { |
|
| 726 | + return $output; |
|
| 727 | + } |
|
| 610 | 728 | |
| 611 | 729 | // begin transaction |
| 612 | 730 | $oDB = &DB::getInstance(); |
@@ -618,12 +736,17 @@ discard block |
||
| 618 | 736 | $oDocumentModel = getModel('document'); |
| 619 | 737 | // Check if the documnet exists |
| 620 | 738 | $oDocument = $oDocumentModel->getDocument($document_srl, $is_admin); |
| 739 | + } else if($isEmptyTrash && $oDocument == null) { |
|
| 740 | + return new BaseObject(-1, 'document is not exists'); |
|
| 621 | 741 | } |
| 622 | - else if($isEmptyTrash && $oDocument == null) return new BaseObject(-1, 'document is not exists'); |
|
| 623 | 742 | |
| 624 | - if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new BaseObject(-1, 'msg_invalid_document'); |
|
| 743 | + if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) { |
|
| 744 | + return new BaseObject(-1, 'msg_invalid_document'); |
|
| 745 | + } |
|
| 625 | 746 | // Check if a permossion is granted |
| 626 | - if(!$oDocument->isGranted()) return new BaseObject(-1, 'msg_not_permitted'); |
|
| 747 | + if(!$oDocument->isGranted()) { |
|
| 748 | + return new BaseObject(-1, 'msg_not_permitted'); |
|
| 749 | + } |
|
| 627 | 750 | |
| 628 | 751 | //if empty trash, document already deleted, therefore document not delete |
| 629 | 752 | $args = new stdClass(); |
@@ -643,7 +766,9 @@ discard block |
||
| 643 | 766 | |
| 644 | 767 | $this->deleteDocumentHistory(null, $document_srl, null); |
| 645 | 768 | // Update category information if the category_srl exists. |
| 646 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
| 769 | + if($oDocument->get('category_srl')) { |
|
| 770 | + $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
| 771 | + } |
|
| 647 | 772 | // Delete a declared list |
| 648 | 773 | executeQuery('document.deleteDeclared', $args); |
| 649 | 774 | // Delete extra variable |
@@ -723,8 +848,11 @@ discard block |
||
| 723 | 848 | { |
| 724 | 849 | $trash_args = new stdClass(); |
| 725 | 850 | // Get trash_srl if a given trash_srl doesn't exist |
| 726 | - if(!$obj->trash_srl) $trash_args->trash_srl = getNextSequence(); |
|
| 727 | - else $trash_args->trash_srl = $obj->trash_srl; |
|
| 851 | + if(!$obj->trash_srl) { |
|
| 852 | + $trash_args->trash_srl = getNextSequence(); |
|
| 853 | + } else { |
|
| 854 | + $trash_args->trash_srl = $obj->trash_srl; |
|
| 855 | + } |
|
| 728 | 856 | // Get its module_srl which the document belongs to |
| 729 | 857 | $oDocumentModel = getModel('document'); |
| 730 | 858 | $oDocument = $oDocumentModel->getDocument($obj->document_srl); |
@@ -732,7 +860,9 @@ discard block |
||
| 732 | 860 | $trash_args->module_srl = $oDocument->get('module_srl'); |
| 733 | 861 | $obj->module_srl = $oDocument->get('module_srl'); |
| 734 | 862 | // Cannot throw data from the trash to the trash |
| 735 | - if($trash_args->module_srl == 0) return false; |
|
| 863 | + if($trash_args->module_srl == 0) { |
|
| 864 | + return false; |
|
| 865 | + } |
|
| 736 | 866 | // Data setting |
| 737 | 867 | $trash_args->document_srl = $obj->document_srl; |
| 738 | 868 | $trash_args->description = $obj->description; |
@@ -793,7 +923,9 @@ discard block |
||
| 793 | 923 | }*/ |
| 794 | 924 | |
| 795 | 925 | // update category |
| 796 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
| 926 | + if($oDocument->get('category_srl')) { |
|
| 927 | + $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
| 928 | + } |
|
| 797 | 929 | |
| 798 | 930 | // remove thumbnails |
| 799 | 931 | FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3))); |
@@ -838,7 +970,9 @@ discard block |
||
| 838 | 970 | function updateReadedCount(&$oDocument) |
| 839 | 971 | { |
| 840 | 972 | // Pass if Crawler access |
| 841 | - if(isCrawler()) return false; |
|
| 973 | + if(isCrawler()) { |
|
| 974 | + return false; |
|
| 975 | + } |
|
| 842 | 976 | |
| 843 | 977 | $document_srl = $oDocument->document_srl; |
| 844 | 978 | $member_srl = $oDocument->get('member_srl'); |
@@ -846,10 +980,14 @@ discard block |
||
| 846 | 980 | |
| 847 | 981 | // Call a trigger when the read count is updated (before) |
| 848 | 982 | $trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'before', $oDocument); |
| 849 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
| 983 | + if(!$trigger_output->toBool()) { |
|
| 984 | + return $trigger_output; |
|
| 985 | + } |
|
| 850 | 986 | |
| 851 | 987 | // Pass if read count is increaded on the session information |
| 852 | - if($_SESSION['readed_document'][$document_srl]) return false; |
|
| 988 | + if($_SESSION['readed_document'][$document_srl]) { |
|
| 989 | + return false; |
|
| 990 | + } |
|
| 853 | 991 | |
| 854 | 992 | // Pass if the author's IP address is as same as visitor's. |
| 855 | 993 | if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
@@ -914,7 +1052,9 @@ discard block |
||
| 914 | 1052 | */ |
| 915 | 1053 | function insertDocumentExtraKey($module_srl, $var_idx, $var_name, $var_type, $var_is_required = 'N', $var_search = 'N', $var_default = '', $var_desc = '', $eid) |
| 916 | 1054 | { |
| 917 | - if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new BaseObject(-1,'msg_invalid_request'); |
|
| 1055 | + if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) { |
|
| 1056 | + return new BaseObject(-1,'msg_invalid_request'); |
|
| 1057 | + } |
|
| 918 | 1058 | |
| 919 | 1059 | $obj = new stdClass(); |
| 920 | 1060 | $obj->module_srl = $module_srl; |
@@ -931,8 +1071,7 @@ discard block |
||
| 931 | 1071 | if(!$output->data) |
| 932 | 1072 | { |
| 933 | 1073 | $output = executeQuery('document.insertDocumentExtraKey', $obj); |
| 934 | - } |
|
| 935 | - else |
|
| 1074 | + } else |
|
| 936 | 1075 | { |
| 937 | 1076 | $output = executeQuery('document.updateDocumentExtraKey', $obj); |
| 938 | 1077 | // Update the extra var(eid) |
@@ -958,10 +1097,14 @@ discard block |
||
| 958 | 1097 | */ |
| 959 | 1098 | function deleteDocumentExtraKeys($module_srl, $var_idx = null) |
| 960 | 1099 | { |
| 961 | - if(!$module_srl) return new BaseObject(-1,'msg_invalid_request'); |
|
| 1100 | + if(!$module_srl) { |
|
| 1101 | + return new BaseObject(-1,'msg_invalid_request'); |
|
| 1102 | + } |
|
| 962 | 1103 | $obj = new stdClass(); |
| 963 | 1104 | $obj->module_srl = $module_srl; |
| 964 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
| 1105 | + if(!is_null($var_idx)) { |
|
| 1106 | + $obj->var_idx = $var_idx; |
|
| 1107 | + } |
|
| 965 | 1108 | |
| 966 | 1109 | $oDB = DB::getInstance(); |
| 967 | 1110 | $oDB->begin(); |
@@ -1025,8 +1168,12 @@ discard block |
||
| 1025 | 1168 | */ |
| 1026 | 1169 | function insertDocumentExtraVar($module_srl, $document_srl, $var_idx, $value, $eid = null, $lang_code = '') |
| 1027 | 1170 | { |
| 1028 | - if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new BaseObject(-1,'msg_invalid_request'); |
|
| 1029 | - if(!$lang_code) $lang_code = Context::getLangType(); |
|
| 1171 | + if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) { |
|
| 1172 | + return new BaseObject(-1,'msg_invalid_request'); |
|
| 1173 | + } |
|
| 1174 | + if(!$lang_code) { |
|
| 1175 | + $lang_code = Context::getLangType(); |
|
| 1176 | + } |
|
| 1030 | 1177 | |
| 1031 | 1178 | $obj = new stdClass; |
| 1032 | 1179 | $obj->module_srl = $module_srl; |
@@ -1052,10 +1199,18 @@ discard block |
||
| 1052 | 1199 | { |
| 1053 | 1200 | $obj = new stdClass(); |
| 1054 | 1201 | $obj->module_srl = $module_srl; |
| 1055 | - if(!is_null($document_srl)) $obj->document_srl = $document_srl; |
|
| 1056 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
| 1057 | - if(!is_null($lang_code)) $obj->lang_code = $lang_code; |
|
| 1058 | - if(!is_null($eid)) $obj->eid = $eid; |
|
| 1202 | + if(!is_null($document_srl)) { |
|
| 1203 | + $obj->document_srl = $document_srl; |
|
| 1204 | + } |
|
| 1205 | + if(!is_null($var_idx)) { |
|
| 1206 | + $obj->var_idx = $var_idx; |
|
| 1207 | + } |
|
| 1208 | + if(!is_null($lang_code)) { |
|
| 1209 | + $obj->lang_code = $lang_code; |
|
| 1210 | + } |
|
| 1211 | + if(!is_null($eid)) { |
|
| 1212 | + $obj->eid = $eid; |
|
| 1213 | + } |
|
| 1059 | 1214 | $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
| 1060 | 1215 | return $output; |
| 1061 | 1216 | } |
@@ -1069,8 +1224,11 @@ discard block |
||
| 1069 | 1224 | */ |
| 1070 | 1225 | function updateVotedCount($document_srl, $point = 1) |
| 1071 | 1226 | { |
| 1072 | - if($point > 0) $failed_voted = 'failed_voted'; |
|
| 1073 | - else $failed_voted = 'failed_blamed'; |
|
| 1227 | + if($point > 0) { |
|
| 1228 | + $failed_voted = 'failed_voted'; |
|
| 1229 | + } else { |
|
| 1230 | + $failed_voted = 'failed_blamed'; |
|
| 1231 | + } |
|
| 1074 | 1232 | // Return fail if session already has information about votes |
| 1075 | 1233 | if($_SESSION['voted_document'][$document_srl]) |
| 1076 | 1234 | { |
@@ -1106,8 +1264,7 @@ discard block |
||
| 1106 | 1264 | if($member_srl) |
| 1107 | 1265 | { |
| 1108 | 1266 | $args->member_srl = $member_srl; |
| 1109 | - } |
|
| 1110 | - else |
|
| 1267 | + } else |
|
| 1111 | 1268 | { |
| 1112 | 1269 | $args->ipaddress = $_SERVER['REMOTE_ADDR']; |
| 1113 | 1270 | } |
@@ -1129,17 +1286,20 @@ discard block |
||
| 1129 | 1286 | { |
| 1130 | 1287 | $args->blamed_count = $oDocument->get('blamed_count') + $point; |
| 1131 | 1288 | $output = executeQuery('document.updateBlamedCount', $args); |
| 1132 | - } |
|
| 1133 | - else |
|
| 1289 | + } else |
|
| 1134 | 1290 | { |
| 1135 | 1291 | $args->voted_count = $oDocument->get('voted_count') + $point; |
| 1136 | 1292 | $output = executeQuery('document.updateVotedCount', $args); |
| 1137 | 1293 | } |
| 1138 | - if(!$output->toBool()) return $output; |
|
| 1294 | + if(!$output->toBool()) { |
|
| 1295 | + return $output; |
|
| 1296 | + } |
|
| 1139 | 1297 | // Leave logs |
| 1140 | 1298 | $args->point = $point; |
| 1141 | 1299 | $output = executeQuery('document.insertDocumentVotedLog', $args); |
| 1142 | - if(!$output->toBool()) return $output; |
|
| 1300 | + if(!$output->toBool()) { |
|
| 1301 | + return $output; |
|
| 1302 | + } |
|
| 1143 | 1303 | |
| 1144 | 1304 | $obj = new stdClass; |
| 1145 | 1305 | $obj->member_srl = $oDocument->get('member_srl'); |
@@ -1175,8 +1335,7 @@ discard block |
||
| 1175 | 1335 | { |
| 1176 | 1336 | $output->setMessage('success_voted'); |
| 1177 | 1337 | $output->add('voted_count', $obj->after_point); |
| 1178 | - } |
|
| 1179 | - else |
|
| 1338 | + } else |
|
| 1180 | 1339 | { |
| 1181 | 1340 | $output->setMessage('success_blamed'); |
| 1182 | 1341 | $output->add('blamed_count', $obj->after_point); |
@@ -1193,13 +1352,17 @@ discard block |
||
| 1193 | 1352 | function declaredDocument($document_srl) |
| 1194 | 1353 | { |
| 1195 | 1354 | // Fail if session information already has a reported document |
| 1196 | - if($_SESSION['declared_document'][$document_srl]) return new BaseObject(-1, 'failed_declared'); |
|
| 1355 | + if($_SESSION['declared_document'][$document_srl]) { |
|
| 1356 | + return new BaseObject(-1, 'failed_declared'); |
|
| 1357 | + } |
|
| 1197 | 1358 | |
| 1198 | 1359 | // Check if previously reported |
| 1199 | 1360 | $args = new stdClass(); |
| 1200 | 1361 | $args->document_srl = $document_srl; |
| 1201 | 1362 | $output = executeQuery('document.getDeclaredDocument', $args); |
| 1202 | - if(!$output->toBool()) return $output; |
|
| 1363 | + if(!$output->toBool()) { |
|
| 1364 | + return $output; |
|
| 1365 | + } |
|
| 1203 | 1366 | |
| 1204 | 1367 | $declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0; |
| 1205 | 1368 | |
@@ -1243,8 +1406,7 @@ discard block |
||
| 1243 | 1406 | if($member_srl) |
| 1244 | 1407 | { |
| 1245 | 1408 | $args->member_srl = $member_srl; |
| 1246 | - } |
|
| 1247 | - else |
|
| 1409 | + } else |
|
| 1248 | 1410 | { |
| 1249 | 1411 | $args->ipaddress = $_SERVER['REMOTE_ADDR']; |
| 1250 | 1412 | } |
@@ -1264,9 +1426,14 @@ discard block |
||
| 1264 | 1426 | $oDB->begin(); |
| 1265 | 1427 | |
| 1266 | 1428 | // Add the declared document |
| 1267 | - if($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args); |
|
| 1268 | - else $output = executeQuery('document.insertDeclaredDocument', $args); |
|
| 1269 | - if(!$output->toBool()) return $output; |
|
| 1429 | + if($declared_count > 0) { |
|
| 1430 | + $output = executeQuery('document.updateDeclaredDocument', $args); |
|
| 1431 | + } else { |
|
| 1432 | + $output = executeQuery('document.insertDeclaredDocument', $args); |
|
| 1433 | + } |
|
| 1434 | + if(!$output->toBool()) { |
|
| 1435 | + return $output; |
|
| 1436 | + } |
|
| 1270 | 1437 | // Leave logs |
| 1271 | 1438 | $output = executeQuery('document.insertDocumentDeclaredLog', $args); |
| 1272 | 1439 | if(!$output->toBool()) |
@@ -1365,9 +1532,10 @@ discard block |
||
| 1365 | 1532 | $parent_category = $oDocumentModel->getCategory($obj->parent_srl); |
| 1366 | 1533 | $obj->list_order = $parent_category->list_order; |
| 1367 | 1534 | $this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order+1); |
| 1368 | - if(!$obj->category_srl) $obj->category_srl = getNextSequence(); |
|
| 1369 | - } |
|
| 1370 | - else |
|
| 1535 | + if(!$obj->category_srl) { |
|
| 1536 | + $obj->category_srl = getNextSequence(); |
|
| 1537 | + } |
|
| 1538 | + } else |
|
| 1371 | 1539 | { |
| 1372 | 1540 | $obj->list_order = $obj->category_srl = getNextSequence(); |
| 1373 | 1541 | } |
@@ -1407,13 +1575,17 @@ discard block |
||
| 1407 | 1575 | { |
| 1408 | 1576 | // Create a document model object |
| 1409 | 1577 | $oDocumentModel = getModel('document'); |
| 1410 | - if(!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl); |
|
| 1578 | + if(!$document_count) { |
|
| 1579 | + $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl); |
|
| 1580 | + } |
|
| 1411 | 1581 | |
| 1412 | 1582 | $args = new stdClass; |
| 1413 | 1583 | $args->category_srl = $category_srl; |
| 1414 | 1584 | $args->document_count = $document_count; |
| 1415 | 1585 | $output = executeQuery('document.updateCategoryCount', $args); |
| 1416 | - if($output->toBool()) $this->makeCategoryFile($module_srl); |
|
| 1586 | + if($output->toBool()) { |
|
| 1587 | + $this->makeCategoryFile($module_srl); |
|
| 1588 | + } |
|
| 1417 | 1589 | |
| 1418 | 1590 | return $output; |
| 1419 | 1591 | } |
@@ -1426,7 +1598,9 @@ discard block |
||
| 1426 | 1598 | function updateCategory($obj) |
| 1427 | 1599 | { |
| 1428 | 1600 | $output = executeQuery('document.updateCategory', $obj); |
| 1429 | - if($output->toBool()) $this->makeCategoryFile($obj->module_srl); |
|
| 1601 | + if($output->toBool()) { |
|
| 1602 | + $this->makeCategoryFile($obj->module_srl); |
|
| 1603 | + } |
|
| 1430 | 1604 | return $output; |
| 1431 | 1605 | } |
| 1432 | 1606 | |
@@ -1443,11 +1617,17 @@ discard block |
||
| 1443 | 1617 | $category_info = $oDocumentModel->getCategory($category_srl); |
| 1444 | 1618 | // Display an error that the category cannot be deleted if it has a child |
| 1445 | 1619 | $output = executeQuery('document.getChildCategoryCount', $args); |
| 1446 | - if(!$output->toBool()) return $output; |
|
| 1447 | - if($output->data->count>0) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
| 1620 | + if(!$output->toBool()) { |
|
| 1621 | + return $output; |
|
| 1622 | + } |
|
| 1623 | + if($output->data->count>0) { |
|
| 1624 | + return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
| 1625 | + } |
|
| 1448 | 1626 | // Delete a category information |
| 1449 | 1627 | $output = executeQuery('document.deleteCategory', $args); |
| 1450 | - if(!$output->toBool()) return $output; |
|
| 1628 | + if(!$output->toBool()) { |
|
| 1629 | + return $output; |
|
| 1630 | + } |
|
| 1451 | 1631 | |
| 1452 | 1632 | $this->makeCategoryFile($category_info->module_srl); |
| 1453 | 1633 | // remvove cache |
@@ -1462,8 +1642,9 @@ discard block |
||
| 1462 | 1642 | $args->page = ++$page; |
| 1463 | 1643 | $output = executeQuery('document.getDocumentList', $args, array('document_srl')); |
| 1464 | 1644 | |
| 1465 | - if($output->data == array()) |
|
| 1466 | - break; |
|
| 1645 | + if($output->data == array()) { |
|
| 1646 | + break; |
|
| 1647 | + } |
|
| 1467 | 1648 | |
| 1468 | 1649 | foreach($output->data as $val) |
| 1469 | 1650 | { |
@@ -1515,18 +1696,26 @@ discard block |
||
| 1515 | 1696 | // Seek a full list of categories |
| 1516 | 1697 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
| 1517 | 1698 | $category_srl_list = array_keys($category_list); |
| 1518 | - if(count($category_srl_list)<2) return new BaseObject(); |
|
| 1699 | + if(count($category_srl_list)<2) { |
|
| 1700 | + return new BaseObject(); |
|
| 1701 | + } |
|
| 1519 | 1702 | |
| 1520 | 1703 | $prev_category = NULL; |
| 1521 | 1704 | foreach($category_list as $key => $val) |
| 1522 | 1705 | { |
| 1523 | - if($key==$category_srl) break; |
|
| 1706 | + if($key==$category_srl) { |
|
| 1707 | + break; |
|
| 1708 | + } |
|
| 1524 | 1709 | $prev_category = $val; |
| 1525 | 1710 | } |
| 1526 | 1711 | // Return if the previous category doesn't exist |
| 1527 | - if(!$prev_category) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
| 1712 | + if(!$prev_category) { |
|
| 1713 | + return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
| 1714 | + } |
|
| 1528 | 1715 | // Return if the selected category is the top level |
| 1529 | - if($category_srl_list[0]==$category_srl) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
| 1716 | + if($category_srl_list[0]==$category_srl) { |
|
| 1717 | + return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
| 1718 | + } |
|
| 1530 | 1719 | // Information of the selected category |
| 1531 | 1720 | $cur_args = new stdClass; |
| 1532 | 1721 | $cur_args->category_srl = $category_srl; |
@@ -1562,15 +1751,21 @@ discard block |
||
| 1562 | 1751 | // Seek a full list of categories |
| 1563 | 1752 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
| 1564 | 1753 | $category_srl_list = array_keys($category_list); |
| 1565 | - if(count($category_srl_list)<2) return new BaseObject(); |
|
| 1754 | + if(count($category_srl_list)<2) { |
|
| 1755 | + return new BaseObject(); |
|
| 1756 | + } |
|
| 1566 | 1757 | |
| 1567 | 1758 | for($i=0;$i<count($category_srl_list);$i++) |
| 1568 | 1759 | { |
| 1569 | - if($category_srl_list[$i]==$category_srl) break; |
|
| 1760 | + if($category_srl_list[$i]==$category_srl) { |
|
| 1761 | + break; |
|
| 1762 | + } |
|
| 1570 | 1763 | } |
| 1571 | 1764 | |
| 1572 | 1765 | $next_category_srl = $category_srl_list[$i+1]; |
| 1573 | - if(!$category_list[$next_category_srl]) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
| 1766 | + if(!$category_list[$next_category_srl]) { |
|
| 1767 | + return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
| 1768 | + } |
|
| 1574 | 1769 | $next_category = $category_list[$next_category_srl]; |
| 1575 | 1770 | // Information of the selected category |
| 1576 | 1771 | $cur_args = new stdClass; |
@@ -1597,7 +1792,9 @@ discard block |
||
| 1597 | 1792 | { |
| 1598 | 1793 | $oDocumentModel = getModel('document'); |
| 1599 | 1794 | $extra_keys = $oDocumentModel->getExtraKeys($module_srl); |
| 1600 | - if(!count($extra_keys)) return; |
|
| 1795 | + if(!count($extra_keys)) { |
|
| 1796 | + return; |
|
| 1797 | + } |
|
| 1601 | 1798 | |
| 1602 | 1799 | $js_code = array(); |
| 1603 | 1800 | $js_code[] = '<script>//<![CDATA['; |
@@ -1616,7 +1813,9 @@ discard block |
||
| 1616 | 1813 | } |
| 1617 | 1814 | $name = str_ireplace(array('<script', '</script'), array('<scr" + "ipt', '</scr" + "ipt'), $val->name); |
| 1618 | 1815 | $js_code[] = sprintf('validator.cast("ADD_MESSAGE", ["extra_vars%s","%s"]);', $idx, $name); |
| 1619 | - if($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
| 1816 | + if($val->is_required == 'Y') { |
|
| 1817 | + $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
| 1818 | + } |
|
| 1620 | 1819 | } |
| 1621 | 1820 | |
| 1622 | 1821 | $js_code[] = '})(jQuery);'; |
@@ -1634,7 +1833,9 @@ discard block |
||
| 1634 | 1833 | function procDocumentInsertCategory($args = null) |
| 1635 | 1834 | { |
| 1636 | 1835 | // List variables |
| 1637 | - if(!$args) $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid'); |
|
| 1836 | + if(!$args) { |
|
| 1837 | + $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid'); |
|
| 1838 | + } |
|
| 1638 | 1839 | $args->title = $args->category_title; |
| 1639 | 1840 | $args->description = $args->category_description; |
| 1640 | 1841 | $args->color = $args->category_color; |
@@ -1650,11 +1851,18 @@ discard block |
||
| 1650 | 1851 | $columnList = array('module_srl', 'module'); |
| 1651 | 1852 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
| 1652 | 1853 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1653 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
| 1854 | + if(!$grant->manager) { |
|
| 1855 | + return new BaseObject(-1,'msg_not_permitted'); |
|
| 1856 | + } |
|
| 1654 | 1857 | |
| 1655 | - if($args->expand !="Y") $args->expand = "N"; |
|
| 1656 | - if(!is_array($args->group_srls)) $args->group_srls = str_replace('|@|',',',$args->group_srls); |
|
| 1657 | - else $args->group_srls = implode(',', $args->group_srls); |
|
| 1858 | + if($args->expand !="Y") { |
|
| 1859 | + $args->expand = "N"; |
|
| 1860 | + } |
|
| 1861 | + if(!is_array($args->group_srls)) { |
|
| 1862 | + $args->group_srls = str_replace('|@|',',',$args->group_srls); |
|
| 1863 | + } else { |
|
| 1864 | + $args->group_srls = implode(',', $args->group_srls); |
|
| 1865 | + } |
|
| 1658 | 1866 | $args->parent_srl = (int)$args->parent_srl; |
| 1659 | 1867 | |
| 1660 | 1868 | $oDocumentModel = getModel('document'); |
@@ -1665,7 +1873,9 @@ discard block |
||
| 1665 | 1873 | if($args->category_srl) |
| 1666 | 1874 | { |
| 1667 | 1875 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
| 1668 | - if($category_info->category_srl != $args->category_srl) $args->category_srl = null; |
|
| 1876 | + if($category_info->category_srl != $args->category_srl) { |
|
| 1877 | + $args->category_srl = null; |
|
| 1878 | + } |
|
| 1669 | 1879 | } |
| 1670 | 1880 | // Update if exists |
| 1671 | 1881 | if($args->category_srl) |
@@ -1677,8 +1887,7 @@ discard block |
||
| 1677 | 1887 | return $output; |
| 1678 | 1888 | } |
| 1679 | 1889 | // Insert if not exist |
| 1680 | - } |
|
| 1681 | - else |
|
| 1890 | + } else |
|
| 1682 | 1891 | { |
| 1683 | 1892 | $output = $this->insertCategory($args); |
| 1684 | 1893 | if(!$output->toBool()) |
@@ -1720,7 +1929,9 @@ discard block |
||
| 1720 | 1929 | $columnList = array('module_srl', 'module'); |
| 1721 | 1930 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($source_category->module_srl, $columnList); |
| 1722 | 1931 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1723 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
| 1932 | + if(!$grant->manager) { |
|
| 1933 | + return new BaseObject(-1,'msg_not_permitted'); |
|
| 1934 | + } |
|
| 1724 | 1935 | |
| 1725 | 1936 | // First child of the parent_category_srl |
| 1726 | 1937 | $source_args = new stdClass; |
@@ -1733,30 +1944,39 @@ discard block |
||
| 1733 | 1944 | $args->parent_srl = $parent_category_srl; |
| 1734 | 1945 | $output = executeQuery('document.getChildCategoryMinListOrder', $args); |
| 1735 | 1946 | |
| 1736 | - if(!$output->toBool()) return $output; |
|
| 1947 | + if(!$output->toBool()) { |
|
| 1948 | + return $output; |
|
| 1949 | + } |
|
| 1737 | 1950 | $args->list_order = (int)$output->data->list_order; |
| 1738 | - if(!$args->list_order) $args->list_order = 0; |
|
| 1951 | + if(!$args->list_order) { |
|
| 1952 | + $args->list_order = 0; |
|
| 1953 | + } |
|
| 1739 | 1954 | $args->list_order--; |
| 1740 | 1955 | |
| 1741 | 1956 | $source_args->category_srl = $source_category_srl; |
| 1742 | 1957 | $source_args->parent_srl = $parent_category_srl; |
| 1743 | 1958 | $source_args->list_order = $args->list_order; |
| 1744 | 1959 | $output = $this->updateCategory($source_args); |
| 1745 | - if(!$output->toBool()) return $output; |
|
| 1960 | + if(!$output->toBool()) { |
|
| 1961 | + return $output; |
|
| 1962 | + } |
|
| 1746 | 1963 | // Sibling of the $target_category_srl |
| 1747 | - } |
|
| 1748 | - else if($target_category_srl > 0) |
|
| 1964 | + } else if($target_category_srl > 0) |
|
| 1749 | 1965 | { |
| 1750 | 1966 | $target_category = $oDocumentModel->getCategory($target_category_srl); |
| 1751 | 1967 | // Move all siblings of the $target_category down |
| 1752 | 1968 | $output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order+1); |
| 1753 | - if(!$output->toBool()) return $output; |
|
| 1969 | + if(!$output->toBool()) { |
|
| 1970 | + return $output; |
|
| 1971 | + } |
|
| 1754 | 1972 | |
| 1755 | 1973 | $source_args->category_srl = $source_category_srl; |
| 1756 | 1974 | $source_args->parent_srl = $target_category->parent_srl; |
| 1757 | 1975 | $source_args->list_order = $target_category->list_order+1; |
| 1758 | 1976 | $output = $this->updateCategory($source_args); |
| 1759 | - if(!$output->toBool()) return $output; |
|
| 1977 | + if(!$output->toBool()) { |
|
| 1978 | + return $output; |
|
| 1979 | + } |
|
| 1760 | 1980 | } |
| 1761 | 1981 | // Re-generate the xml file |
| 1762 | 1982 | $xml_file = $this->makeCategoryFile($source_category->module_srl); |
@@ -1781,14 +2001,20 @@ discard block |
||
| 1781 | 2001 | $columnList = array('module_srl', 'module'); |
| 1782 | 2002 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
| 1783 | 2003 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1784 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
| 2004 | + if(!$grant->manager) { |
|
| 2005 | + return new BaseObject(-1,'msg_not_permitted'); |
|
| 2006 | + } |
|
| 1785 | 2007 | |
| 1786 | 2008 | $oDocumentModel = getModel('document'); |
| 1787 | 2009 | // Get original information |
| 1788 | 2010 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
| 1789 | - if($category_info->parent_srl) $parent_srl = $category_info->parent_srl; |
|
| 2011 | + if($category_info->parent_srl) { |
|
| 2012 | + $parent_srl = $category_info->parent_srl; |
|
| 2013 | + } |
|
| 1790 | 2014 | // Display an error that the category cannot be deleted if it has a child node |
| 1791 | - if($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
| 2015 | + if($oDocumentModel->getCategoryChlidCount($args->category_srl)) { |
|
| 2016 | + return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
| 2017 | + } |
|
| 1792 | 2018 | // Remove from the DB |
| 1793 | 2019 | $output = $this->deleteCategory($args->category_srl); |
| 1794 | 2020 | if(!$output->toBool()) |
@@ -1822,7 +2048,9 @@ discard block |
||
| 1822 | 2048 | $columnList = array('module_srl', 'module'); |
| 1823 | 2049 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
| 1824 | 2050 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1825 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
| 2051 | + if(!$grant->manager) { |
|
| 2052 | + return new BaseObject(-1,'msg_not_permitted'); |
|
| 2053 | + } |
|
| 1826 | 2054 | |
| 1827 | 2055 | $xml_file = $this->makeCategoryFile($module_srl); |
| 1828 | 2056 | // Set return value |
@@ -1837,14 +2065,18 @@ discard block |
||
| 1837 | 2065 | function makeCategoryFile($module_srl) |
| 1838 | 2066 | { |
| 1839 | 2067 | // Return if there is no information you need for creating a cache file |
| 1840 | - if(!$module_srl) return false; |
|
| 2068 | + if(!$module_srl) { |
|
| 2069 | + return false; |
|
| 2070 | + } |
|
| 1841 | 2071 | // Get module information (to obtain mid) |
| 1842 | 2072 | $oModuleModel = getModel('module'); |
| 1843 | 2073 | $columnList = array('module_srl', 'mid', 'site_srl'); |
| 1844 | 2074 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
| 1845 | 2075 | $mid = $module_info->mid; |
| 1846 | 2076 | |
| 1847 | - if(!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category'); |
|
| 2077 | + if(!is_dir('./files/cache/document_category')) { |
|
| 2078 | + FileHandler::makeDir('./files/cache/document_category'); |
|
| 2079 | + } |
|
| 1848 | 2080 | // Cache file's name |
| 1849 | 2081 | $xml_file = sprintf("./files/cache/document_category/%s.xml.php", $module_srl); |
| 1850 | 2082 | $php_file = sprintf("./files/cache/document_category/%s.php", $module_srl); |
@@ -1856,13 +2088,17 @@ discard block |
||
| 1856 | 2088 | |
| 1857 | 2089 | $category_list = $output->data; |
| 1858 | 2090 | |
| 1859 | - if(!is_array($category_list)) $category_list = array($category_list); |
|
| 2091 | + if(!is_array($category_list)) { |
|
| 2092 | + $category_list = array($category_list); |
|
| 2093 | + } |
|
| 1860 | 2094 | |
| 1861 | 2095 | $category_count = count($category_list); |
| 1862 | 2096 | for($i=0;$i<$category_count;$i++) |
| 1863 | 2097 | { |
| 1864 | 2098 | $category_srl = $category_list[$i]->category_srl; |
| 1865 | - if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = ''; |
|
| 2099 | + if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) { |
|
| 2100 | + $category_list[$i]->group_srls = ''; |
|
| 2101 | + } |
|
| 1866 | 2102 | $list[$category_srl] = $category_list[$i]; |
| 1867 | 2103 | } |
| 1868 | 2104 | // Create the xml file without node data if no data is obtained |
@@ -1874,7 +2110,9 @@ discard block |
||
| 1874 | 2110 | return $xml_file; |
| 1875 | 2111 | } |
| 1876 | 2112 | // Change to an array if only a single data is obtained |
| 1877 | - if(!is_array($list)) $list = array($list); |
|
| 2113 | + if(!is_array($list)) { |
|
| 2114 | + $list = array($list); |
|
| 2115 | + } |
|
| 1878 | 2116 | // Create a tree for loop |
| 1879 | 2117 | foreach($list as $category_srl => $node) |
| 1880 | 2118 | { |
@@ -1953,13 +2191,17 @@ discard block |
||
| 1953 | 2191 | */ |
| 1954 | 2192 | function getXmlTree($source_node, $tree, $site_srl, &$xml_header_buff) |
| 1955 | 2193 | { |
| 1956 | - if(!$source_node) return; |
|
| 2194 | + if(!$source_node) { |
|
| 2195 | + return; |
|
| 2196 | + } |
|
| 1957 | 2197 | |
| 1958 | 2198 | foreach($source_node as $category_srl => $node) |
| 1959 | 2199 | { |
| 1960 | 2200 | $child_buff = ""; |
| 1961 | 2201 | // Get data of the child nodes |
| 1962 | - if($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
| 2202 | + if($category_srl && $tree[$category_srl]) { |
|
| 2203 | + $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
| 2204 | + } |
|
| 1963 | 2205 | // List variables |
| 1964 | 2206 | $expand = $node->expand; |
| 1965 | 2207 | $group_srls = $node->group_srls; |
@@ -1969,8 +2211,11 @@ discard block |
||
| 1969 | 2211 | $color = $node->color; |
| 1970 | 2212 | $description = $node->description; |
| 1971 | 2213 | // If node->group_srls value exists |
| 1972 | - if($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls); |
|
| 1973 | - else $group_check_code = "true"; |
|
| 2214 | + if($group_srls) { |
|
| 2215 | + $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls); |
|
| 2216 | + } else { |
|
| 2217 | + $group_check_code = "true"; |
|
| 2218 | + } |
|
| 1974 | 2219 | |
| 1975 | 2220 | $title = $node->title; |
| 1976 | 2221 | $oModuleAdminModel = getAdminModel('module'); |
@@ -2010,8 +2255,11 @@ discard block |
||
| 2010 | 2255 | $node->document_count |
| 2011 | 2256 | ); |
| 2012 | 2257 | |
| 2013 | - if($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
| 2014 | - else $buff .= sprintf('<node %s />', $attribute); |
|
| 2258 | + if($child_buff) { |
|
| 2259 | + $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
| 2260 | + } else { |
|
| 2261 | + $buff .= sprintf('<node %s />', $attribute); |
|
| 2262 | + } |
|
| 2015 | 2263 | } |
| 2016 | 2264 | return $buff; |
| 2017 | 2265 | } |
@@ -2030,7 +2278,9 @@ discard block |
||
| 2030 | 2278 | function getPhpCacheCode($source_node, $tree, $site_srl, &$php_header_buff) |
| 2031 | 2279 | { |
| 2032 | 2280 | $output = array("buff"=>"", "category_srl_list"=>array()); |
| 2033 | - if(!$source_node) return $output; |
|
| 2281 | + if(!$source_node) { |
|
| 2282 | + return $output; |
|
| 2283 | + } |
|
| 2034 | 2284 | |
| 2035 | 2285 | // Set to an arraty for looping and then generate php script codes to be included |
| 2036 | 2286 | foreach($source_node as $category_srl => $node) |
@@ -2129,7 +2379,9 @@ discard block |
||
| 2129 | 2379 | function addDocumentPopupMenu($url, $str, $icon = '', $target = 'self') |
| 2130 | 2380 | { |
| 2131 | 2381 | $document_popup_menu_list = Context::get('document_popup_menu_list'); |
| 2132 | - if(!is_array($document_popup_menu_list)) $document_popup_menu_list = array(); |
|
| 2382 | + if(!is_array($document_popup_menu_list)) { |
|
| 2383 | + $document_popup_menu_list = array(); |
|
| 2384 | + } |
|
| 2133 | 2385 | |
| 2134 | 2386 | $obj = new stdClass(); |
| 2135 | 2387 | $obj->url = $url; |
@@ -2147,7 +2399,9 @@ discard block |
||
| 2147 | 2399 | */ |
| 2148 | 2400 | function procDocumentAddCart() |
| 2149 | 2401 | { |
| 2150 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
| 2402 | + if(!Context::get('is_logged')) { |
|
| 2403 | + return new BaseObject(-1, 'msg_not_permitted'); |
|
| 2404 | + } |
|
| 2151 | 2405 | |
| 2152 | 2406 | // Get document_srl |
| 2153 | 2407 | $srls = explode(',',Context::get('srls')); |
@@ -2155,11 +2409,15 @@ discard block |
||
| 2155 | 2409 | { |
| 2156 | 2410 | $srl = trim($srls[$i]); |
| 2157 | 2411 | |
| 2158 | - if(!$srl) continue; |
|
| 2412 | + if(!$srl) { |
|
| 2413 | + continue; |
|
| 2414 | + } |
|
| 2159 | 2415 | |
| 2160 | 2416 | $document_srls[] = $srl; |
| 2161 | 2417 | } |
| 2162 | - if(!count($document_srls)) return; |
|
| 2418 | + if(!count($document_srls)) { |
|
| 2419 | + return; |
|
| 2420 | + } |
|
| 2163 | 2421 | |
| 2164 | 2422 | // Get module_srl of the documents |
| 2165 | 2423 | $args = new stdClass; |
@@ -2167,14 +2425,18 @@ discard block |
||
| 2167 | 2425 | $args->document_srls = implode(',',$document_srls); |
| 2168 | 2426 | $args->order_type = 'asc'; |
| 2169 | 2427 | $output = executeQueryArray('document.getDocuments', $args); |
| 2170 | - if(!$output->data) return new BaseObject(); |
|
| 2428 | + if(!$output->data) { |
|
| 2429 | + return new BaseObject(); |
|
| 2430 | + } |
|
| 2171 | 2431 | |
| 2172 | 2432 | unset($document_srls); |
| 2173 | 2433 | foreach($output->data as $key => $val) |
| 2174 | 2434 | { |
| 2175 | 2435 | $document_srls[$val->module_srl][] = $val->document_srl; |
| 2176 | 2436 | } |
| 2177 | - if(!$document_srls || !count($document_srls)) return new BaseObject(); |
|
| 2437 | + if(!$document_srls || !count($document_srls)) { |
|
| 2438 | + return new BaseObject(); |
|
| 2439 | + } |
|
| 2178 | 2440 | |
| 2179 | 2441 | // Check if each of module administrators exists. Top-level administator will have a permission to modify every document of all modules.(Even to modify temporarily saved or trashed documents) |
| 2180 | 2442 | $oModuleModel = getModel('module'); |
@@ -2199,7 +2461,9 @@ discard block |
||
| 2199 | 2461 | } |
| 2200 | 2462 | } |
| 2201 | 2463 | } |
| 2202 | - if(!count($document_srls)) return new BaseObject(); |
|
| 2464 | + if(!count($document_srls)) { |
|
| 2465 | + return new BaseObject(); |
|
| 2466 | + } |
|
| 2203 | 2467 | |
| 2204 | 2468 | foreach($document_srls as $module_srl => $documents) |
| 2205 | 2469 | { |
@@ -2207,9 +2471,14 @@ discard block |
||
| 2207 | 2471 | for($i=0;$i<$cnt;$i++) |
| 2208 | 2472 | { |
| 2209 | 2473 | $document_srl = (int)trim($documents[$i]); |
| 2210 | - if(!$document_srls) continue; |
|
| 2211 | - if($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]); |
|
| 2212 | - else $_SESSION['document_management'][$document_srl] = true; |
|
| 2474 | + if(!$document_srls) { |
|
| 2475 | + continue; |
|
| 2476 | + } |
|
| 2477 | + if($_SESSION['document_management'][$document_srl]) { |
|
| 2478 | + unset($_SESSION['document_management'][$document_srl]); |
|
| 2479 | + } else { |
|
| 2480 | + $_SESSION['document_management'][$document_srl] = true; |
|
| 2481 | + } |
|
| 2213 | 2482 | } |
| 2214 | 2483 | } |
| 2215 | 2484 | } |
@@ -2221,7 +2490,9 @@ discard block |
||
| 2221 | 2490 | function procDocumentManageCheckedDocument() |
| 2222 | 2491 | { |
| 2223 | 2492 | @set_time_limit(0); |
| 2224 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
| 2493 | + if(!Context::get('is_logged')) { |
|
| 2494 | + return new BaseObject(-1,'msg_not_permitted'); |
|
| 2495 | + } |
|
| 2225 | 2496 | |
| 2226 | 2497 | if(!checkCSRF()) |
| 2227 | 2498 | { |
@@ -2231,14 +2502,21 @@ discard block |
||
| 2231 | 2502 | $type = Context::get('type'); |
| 2232 | 2503 | $target_module = Context::get('target_module'); |
| 2233 | 2504 | $module_srl = Context::get('module_srl'); |
| 2234 | - if($target_module && !$module_srl) $module_srl = $target_module; |
|
| 2505 | + if($target_module && !$module_srl) { |
|
| 2506 | + $module_srl = $target_module; |
|
| 2507 | + } |
|
| 2235 | 2508 | $category_srl = Context::get('target_category'); |
| 2236 | 2509 | $message_content = Context::get('message_content'); |
| 2237 | - if($message_content) $message_content = nl2br($message_content); |
|
| 2510 | + if($message_content) { |
|
| 2511 | + $message_content = nl2br($message_content); |
|
| 2512 | + } |
|
| 2238 | 2513 | |
| 2239 | 2514 | $cart = Context::get('cart'); |
| 2240 | - if(!is_array($cart)) $document_srl_list = explode('|@|', $cart); |
|
| 2241 | - else $document_srl_list = $cart; |
|
| 2515 | + if(!is_array($cart)) { |
|
| 2516 | + $document_srl_list = explode('|@|', $cart); |
|
| 2517 | + } else { |
|
| 2518 | + $document_srl_list = $cart; |
|
| 2519 | + } |
|
| 2242 | 2520 | |
| 2243 | 2521 | $document_srl_count = count($document_srl_list); |
| 2244 | 2522 | |
@@ -2248,7 +2526,9 @@ discard block |
||
| 2248 | 2526 | { |
| 2249 | 2527 | $oDocument = $oDocumentModel->getDocument($document_srl); |
| 2250 | 2528 | $document_items[] = $oDocument; |
| 2251 | - if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted'); |
|
| 2529 | + if(!$oDocument->isGranted()) { |
|
| 2530 | + return $this->stop('msg_not_permitted'); |
|
| 2531 | + } |
|
| 2252 | 2532 | } |
| 2253 | 2533 | |
| 2254 | 2534 | // Send a message |
@@ -2264,10 +2544,15 @@ discard block |
||
| 2264 | 2544 | |
| 2265 | 2545 | foreach($document_items as $oDocument) |
| 2266 | 2546 | { |
| 2267 | - if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) continue; |
|
| 2547 | + if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) { |
|
| 2548 | + continue; |
|
| 2549 | + } |
|
| 2268 | 2550 | |
| 2269 | - if($type=='move') $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
| 2270 | - else $purl = ""; |
|
| 2551 | + if($type=='move') { |
|
| 2552 | + $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
| 2553 | + } else { |
|
| 2554 | + $purl = ""; |
|
| 2555 | + } |
|
| 2271 | 2556 | $content = sprintf("<div>%s</div><hr />%s<div style=\"font-weight:bold\">%s</div>%s",$message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false)); |
| 2272 | 2557 | |
| 2273 | 2558 | $oCommunicationController->sendMessage($sender_member_srl, $oDocument->get('member_srl'), $title, $content, false); |
@@ -2280,24 +2565,30 @@ discard block |
||
| 2280 | 2565 | $oDocumentAdminController = getAdminController('document'); |
| 2281 | 2566 | if($type == 'move') |
| 2282 | 2567 | { |
| 2283 | - if(!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
| 2568 | + if(!$module_srl) { |
|
| 2569 | + return new BaseObject(-1, 'fail_to_move'); |
|
| 2570 | + } |
|
| 2284 | 2571 | |
| 2285 | 2572 | $output = $oDocumentAdminController->moveDocumentModule($document_srl_list, $module_srl, $category_srl); |
| 2286 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
| 2573 | + if(!$output->toBool()) { |
|
| 2574 | + return new BaseObject(-1, 'fail_to_move'); |
|
| 2575 | + } |
|
| 2287 | 2576 | |
| 2288 | 2577 | $msg_code = 'success_moved'; |
| 2289 | 2578 | |
| 2290 | - } |
|
| 2291 | - else if($type == 'copy') |
|
| 2579 | + } else if($type == 'copy') |
|
| 2292 | 2580 | { |
| 2293 | - if(!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
| 2581 | + if(!$module_srl) { |
|
| 2582 | + return new BaseObject(-1, 'fail_to_move'); |
|
| 2583 | + } |
|
| 2294 | 2584 | |
| 2295 | 2585 | $output = $oDocumentAdminController->copyDocumentModule($document_srl_list, $module_srl, $category_srl); |
| 2296 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
| 2586 | + if(!$output->toBool()) { |
|
| 2587 | + return new BaseObject(-1, 'fail_to_move'); |
|
| 2588 | + } |
|
| 2297 | 2589 | |
| 2298 | 2590 | $msg_code = 'success_copied'; |
| 2299 | - } |
|
| 2300 | - else if($type =='delete') |
|
| 2591 | + } else if($type =='delete') |
|
| 2301 | 2592 | { |
| 2302 | 2593 | $oDB = &DB::getInstance(); |
| 2303 | 2594 | $oDB->begin(); |
@@ -2305,12 +2596,13 @@ discard block |
||
| 2305 | 2596 | { |
| 2306 | 2597 | $document_srl = $document_srl_list[$i]; |
| 2307 | 2598 | $output = $this->deleteDocument($document_srl, true); |
| 2308 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_delete'); |
|
| 2599 | + if(!$output->toBool()) { |
|
| 2600 | + return new BaseObject(-1, 'fail_to_delete'); |
|
| 2601 | + } |
|
| 2309 | 2602 | } |
| 2310 | 2603 | $oDB->commit(); |
| 2311 | 2604 | $msg_code = 'success_deleted'; |
| 2312 | - } |
|
| 2313 | - else if($type == 'trash') |
|
| 2605 | + } else if($type == 'trash') |
|
| 2314 | 2606 | { |
| 2315 | 2607 | $args = new stdClass(); |
| 2316 | 2608 | $args->description = $message_content; |
@@ -2320,12 +2612,13 @@ discard block |
||
| 2320 | 2612 | for($i=0;$i<$document_srl_count;$i++) { |
| 2321 | 2613 | $args->document_srl = $document_srl_list[$i]; |
| 2322 | 2614 | $output = $this->moveDocumentToTrash($args); |
| 2323 | - if(!$output || !$output->toBool()) return new BaseObject(-1, 'fail_to_trash'); |
|
| 2615 | + if(!$output || !$output->toBool()) { |
|
| 2616 | + return new BaseObject(-1, 'fail_to_trash'); |
|
| 2617 | + } |
|
| 2324 | 2618 | } |
| 2325 | 2619 | $oDB->commit(); |
| 2326 | 2620 | $msg_code = 'success_trashed'; |
| 2327 | - } |
|
| 2328 | - else if($type == 'cancelDeclare') |
|
| 2621 | + } else if($type == 'cancelDeclare') |
|
| 2329 | 2622 | { |
| 2330 | 2623 | $args->document_srl = $document_srl_list; |
| 2331 | 2624 | $output = executeQuery('document.deleteDeclaredDocuments', $args); |
@@ -2347,18 +2640,27 @@ discard block |
||
| 2347 | 2640 | function procDocumentInsertModuleConfig() |
| 2348 | 2641 | { |
| 2349 | 2642 | $module_srl = Context::get('target_module_srl'); |
| 2350 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
| 2351 | - else $module_srl = array($module_srl); |
|
| 2643 | + if(preg_match('/^([0-9,]+)$/',$module_srl)) { |
|
| 2644 | + $module_srl = explode(',',$module_srl); |
|
| 2645 | + } else { |
|
| 2646 | + $module_srl = array($module_srl); |
|
| 2647 | + } |
|
| 2352 | 2648 | |
| 2353 | 2649 | $document_config = new stdClass(); |
| 2354 | 2650 | $document_config->use_history = Context::get('use_history'); |
| 2355 | - if(!$document_config->use_history) $document_config->use_history = 'N'; |
|
| 2651 | + if(!$document_config->use_history) { |
|
| 2652 | + $document_config->use_history = 'N'; |
|
| 2653 | + } |
|
| 2356 | 2654 | |
| 2357 | 2655 | $document_config->use_vote_up = Context::get('use_vote_up'); |
| 2358 | - if(!$document_config->use_vote_up) $document_config->use_vote_up = 'Y'; |
|
| 2656 | + if(!$document_config->use_vote_up) { |
|
| 2657 | + $document_config->use_vote_up = 'Y'; |
|
| 2658 | + } |
|
| 2359 | 2659 | |
| 2360 | 2660 | $document_config->use_vote_down = Context::get('use_vote_down'); |
| 2361 | - if(!$document_config->use_vote_down) $document_config->use_vote_down = 'Y'; |
|
| 2661 | + if(!$document_config->use_vote_down) { |
|
| 2662 | + $document_config->use_vote_down = 'Y'; |
|
| 2663 | + } |
|
| 2362 | 2664 | |
| 2363 | 2665 | $document_config->use_status = Context::get('use_status'); |
| 2364 | 2666 | |
@@ -2366,7 +2668,9 @@ discard block |
||
| 2366 | 2668 | for($i=0;$i<count($module_srl);$i++) |
| 2367 | 2669 | { |
| 2368 | 2670 | $srl = trim($module_srl[$i]); |
| 2369 | - if(!$srl) continue; |
|
| 2671 | + if(!$srl) { |
|
| 2672 | + continue; |
|
| 2673 | + } |
|
| 2370 | 2674 | $output = $oModuleController->insertModulePartConfig('document',$srl,$document_config); |
| 2371 | 2675 | } |
| 2372 | 2676 | $this->setError(-1); |
@@ -2383,7 +2687,9 @@ discard block |
||
| 2383 | 2687 | function procDocumentTempSave() |
| 2384 | 2688 | { |
| 2385 | 2689 | // Check login information |
| 2386 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_logged'); |
|
| 2690 | + if(!Context::get('is_logged')) { |
|
| 2691 | + return new BaseObject(-1, 'msg_not_logged'); |
|
| 2692 | + } |
|
| 2387 | 2693 | $module_info = Context::get('module_info'); |
| 2388 | 2694 | $logged_info = Context::get('logged_info'); |
| 2389 | 2695 | |
@@ -2421,8 +2727,7 @@ discard block |
||
| 2421 | 2727 | $output = $oDocumentController->updateDocument($oDocument, $obj); |
| 2422 | 2728 | $msg_code = 'success_updated'; |
| 2423 | 2729 | // Otherwise, get a new |
| 2424 | - } |
|
| 2425 | - else |
|
| 2730 | + } else |
|
| 2426 | 2731 | { |
| 2427 | 2732 | $output = $oDocumentController->insertDocument($obj); |
| 2428 | 2733 | $msg_code = 'success_registed'; |
@@ -2448,17 +2753,20 @@ discard block |
||
| 2448 | 2753 | */ |
| 2449 | 2754 | function procDocumentGetList() |
| 2450 | 2755 | { |
| 2451 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
| 2756 | + if(!Context::get('is_logged')) { |
|
| 2757 | + return new BaseObject(-1,'msg_not_permitted'); |
|
| 2758 | + } |
|
| 2452 | 2759 | $documentSrls = Context::get('document_srls'); |
| 2453 | - if($documentSrls) $documentSrlList = explode(',', $documentSrls); |
|
| 2760 | + if($documentSrls) { |
|
| 2761 | + $documentSrlList = explode(',', $documentSrls); |
|
| 2762 | + } |
|
| 2454 | 2763 | |
| 2455 | 2764 | if(count($documentSrlList) > 0) |
| 2456 | 2765 | { |
| 2457 | 2766 | $oDocumentModel = getModel('document'); |
| 2458 | 2767 | $columnList = array('document_srl', 'title', 'nick_name', 'status'); |
| 2459 | 2768 | $documentList = $oDocumentModel->getDocuments($documentSrlList, $this->grant->is_admin, false, $columnList); |
| 2460 | - } |
|
| 2461 | - else |
|
| 2769 | + } else |
|
| 2462 | 2770 | { |
| 2463 | 2771 | global $lang; |
| 2464 | 2772 | $documentList = array(); |
@@ -2476,11 +2784,18 @@ discard block |
||
| 2476 | 2784 | */ |
| 2477 | 2785 | function _checkCommentStatusForOldVersion(&$obj) |
| 2478 | 2786 | { |
| 2479 | - if(!isset($obj->allow_comment)) $obj->allow_comment = 'N'; |
|
| 2480 | - if(!isset($obj->lock_comment)) $obj->lock_comment = 'N'; |
|
| 2787 | + if(!isset($obj->allow_comment)) { |
|
| 2788 | + $obj->allow_comment = 'N'; |
|
| 2789 | + } |
|
| 2790 | + if(!isset($obj->lock_comment)) { |
|
| 2791 | + $obj->lock_comment = 'N'; |
|
| 2792 | + } |
|
| 2481 | 2793 | |
| 2482 | - if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW'; |
|
| 2483 | - else $obj->commentStatus = 'DENY'; |
|
| 2794 | + if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') { |
|
| 2795 | + $obj->commentStatus = 'ALLOW'; |
|
| 2796 | + } else { |
|
| 2797 | + $obj->commentStatus = 'DENY'; |
|
| 2798 | + } |
|
| 2484 | 2799 | } |
| 2485 | 2800 | |
| 2486 | 2801 | /** |
@@ -2490,8 +2805,12 @@ discard block |
||
| 2490 | 2805 | */ |
| 2491 | 2806 | function _checkDocumentStatusForOldVersion(&$obj) |
| 2492 | 2807 | { |
| 2493 | - if(!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret'); |
|
| 2494 | - if(!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public'); |
|
| 2808 | + if(!$obj->status && $obj->is_secret == 'Y') { |
|
| 2809 | + $obj->status = $this->getConfigStatus('secret'); |
|
| 2810 | + } |
|
| 2811 | + if(!$obj->status && $obj->is_secret != 'Y') { |
|
| 2812 | + $obj->status = $this->getConfigStatus('public'); |
|
| 2813 | + } |
|
| 2495 | 2814 | } |
| 2496 | 2815 | |
| 2497 | 2816 | public function updateUploaedCount($documentSrlList) |
@@ -24,19 +24,19 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | function procDocumentVoteUp() |
| 26 | 26 | { |
| 27 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 27 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 28 | 28 | |
| 29 | 29 | $document_srl = Context::get('target_srl'); |
| 30 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 30 | + if (!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 31 | 31 | |
| 32 | 32 | $oDocumentModel = getModel('document'); |
| 33 | 33 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
| 34 | 34 | $module_srl = $oDocument->get('module_srl'); |
| 35 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 35 | + if (!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 36 | 36 | |
| 37 | 37 | $oModuleModel = getModel('module'); |
| 38 | - $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
|
| 39 | - if($document_config->use_vote_up=='N') return new BaseObject(-1, 'msg_invalid_request'); |
|
| 38 | + $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
|
| 39 | + if ($document_config->use_vote_up == 'N') return new BaseObject(-1, 'msg_invalid_request'); |
|
| 40 | 40 | |
| 41 | 41 | $point = 1; |
| 42 | 42 | $output = $this->updateVotedCount($document_srl, $point); |
@@ -69,19 +69,19 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | function procDocumentVoteDown() |
| 71 | 71 | { |
| 72 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 72 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 73 | 73 | |
| 74 | 74 | $document_srl = Context::get('target_srl'); |
| 75 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 75 | + if (!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 76 | 76 | |
| 77 | 77 | $oDocumentModel = getModel('document'); |
| 78 | 78 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
| 79 | 79 | $module_srl = $oDocument->get('module_srl'); |
| 80 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 80 | + if (!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 81 | 81 | |
| 82 | 82 | $oModuleModel = getModel('module'); |
| 83 | - $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
|
| 84 | - if($document_config->use_vote_down=='N') return new BaseObject(-1, 'msg_invalid_request'); |
|
| 83 | + $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
|
| 84 | + if ($document_config->use_vote_down == 'N') return new BaseObject(-1, 'msg_invalid_request'); |
|
| 85 | 85 | |
| 86 | 86 | $point = -1; |
| 87 | 87 | $output = $this->updateVotedCount($document_srl, $point); |
@@ -95,10 +95,10 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | function procDocumentDeclare() |
| 97 | 97 | { |
| 98 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 98 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 99 | 99 | |
| 100 | 100 | $document_srl = Context::get('target_srl'); |
| 101 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 101 | + if (!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 102 | 102 | |
| 103 | 103 | return $this->declaredDocument($document_srl); |
| 104 | 104 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $args->history_srl = $history_srl; |
| 141 | 141 | $args->module_srl = $module_srl; |
| 142 | 142 | $args->document_srl = $document_srl; |
| 143 | - if(!$args->history_srl && !$args->module_srl && !$args->document_srl) return; |
|
| 143 | + if (!$args->history_srl && !$args->module_srl && !$args->document_srl) return; |
|
| 144 | 144 | executeQuery("document.deleteHistory", $args); |
| 145 | 145 | } |
| 146 | 146 | |
@@ -152,15 +152,15 @@ discard block |
||
| 152 | 152 | function triggerDeleteModuleDocuments(&$obj) |
| 153 | 153 | { |
| 154 | 154 | $module_srl = $obj->module_srl; |
| 155 | - if(!$module_srl) return new BaseObject(); |
|
| 155 | + if (!$module_srl) return new BaseObject(); |
|
| 156 | 156 | // Delete the document |
| 157 | 157 | $oDocumentAdminController = getAdminController('document'); |
| 158 | 158 | $output = $oDocumentAdminController->deleteModuleDocument($module_srl); |
| 159 | - if(!$output->toBool()) return $output; |
|
| 159 | + if (!$output->toBool()) return $output; |
|
| 160 | 160 | // Delete the category |
| 161 | 161 | $oDocumentController = getController('document'); |
| 162 | 162 | $output = $oDocumentController->deleteModuleCategory($module_srl); |
| 163 | - if(!$output->toBool()) return $output; |
|
| 163 | + if (!$output->toBool()) return $output; |
|
| 164 | 164 | // Delete extra key and variable, because module deleted |
| 165 | 165 | $this->deleteDocumentExtraKeys($module_srl); |
| 166 | 166 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | function insertDocument($obj, $manual_inserted = false, $isRestore = false, $isLatest = true) |
| 195 | 195 | { |
| 196 | - if(!$manual_inserted && !checkCSRF()) |
|
| 196 | + if (!$manual_inserted && !checkCSRF()) |
|
| 197 | 197 | { |
| 198 | 198 | return new BaseObject(-1, 'msg_invalid_request'); |
| 199 | 199 | } |
@@ -202,32 +202,32 @@ discard block |
||
| 202 | 202 | $oDB = &DB::getInstance(); |
| 203 | 203 | $oDB->begin(); |
| 204 | 204 | // List variables |
| 205 | - if($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
| 206 | - if(!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
| 207 | - if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
| 208 | - if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N'; |
|
| 209 | - if($obj->homepage) |
|
| 205 | + if ($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
| 206 | + if (!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
| 207 | + if ($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
| 208 | + if ($obj->allow_trackback != 'Y') $obj->allow_trackback = 'N'; |
|
| 209 | + if ($obj->homepage) |
|
| 210 | 210 | { |
| 211 | 211 | $obj->homepage = removeHackTag($obj->homepage); |
| 212 | - if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage)) |
|
| 212 | + if (!preg_match('/^[a-z]+:\/\//i', $obj->homepage)) |
|
| 213 | 213 | { |
| 214 | 214 | $obj->homepage = 'http://'.$obj->homepage; |
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
| 219 | - if(!$obj->email_address) $obj->email_address = ''; |
|
| 220 | - if(!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
| 218 | + if ($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
| 219 | + if (!$obj->email_address) $obj->email_address = ''; |
|
| 220 | + if (!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
| 221 | 221 | |
| 222 | 222 | // can modify regdate only manager |
| 223 | 223 | $grant = Context::get('grant'); |
| 224 | - if(!$grant->manager) |
|
| 224 | + if (!$grant->manager) |
|
| 225 | 225 | { |
| 226 | 226 | unset($obj->regdate); |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | // Serialize the $extra_vars, check the extra_vars type, because duplicate serialized avoid |
| 230 | - if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
| 230 | + if (!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
| 231 | 231 | // Remove the columns for automatic saving |
| 232 | 232 | unset($obj->_saved_doc_srl); |
| 233 | 233 | unset($obj->_saved_doc_title); |
@@ -235,34 +235,34 @@ discard block |
||
| 235 | 235 | unset($obj->_saved_doc_message); |
| 236 | 236 | // Call a trigger (before) |
| 237 | 237 | $output = ModuleHandler::triggerCall('document.insertDocument', 'before', $obj); |
| 238 | - if(!$output->toBool()) return $output; |
|
| 238 | + if (!$output->toBool()) return $output; |
|
| 239 | 239 | // Register it if no given document_srl exists |
| 240 | - if(!$obj->document_srl) $obj->document_srl = getNextSequence(); |
|
| 241 | - elseif(!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) return new BaseObject(-1, 'msg_not_permitted'); |
|
| 240 | + if (!$obj->document_srl) $obj->document_srl = getNextSequence(); |
|
| 241 | + elseif (!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) return new BaseObject(-1, 'msg_not_permitted'); |
|
| 242 | 242 | |
| 243 | 243 | $oDocumentModel = getModel('document'); |
| 244 | 244 | // Set to 0 if the category_srl doesn't exist |
| 245 | - if($obj->category_srl) |
|
| 245 | + if ($obj->category_srl) |
|
| 246 | 246 | { |
| 247 | 247 | $category_list = $oDocumentModel->getCategoryList($obj->module_srl); |
| 248 | - if(count($category_list) > 0 && !$category_list[$obj->category_srl]->grant) |
|
| 248 | + if (count($category_list) > 0 && !$category_list[$obj->category_srl]->grant) |
|
| 249 | 249 | { |
| 250 | 250 | return new BaseObject(-1, 'msg_not_permitted'); |
| 251 | 251 | } |
| 252 | - if(count($category_list) > 0 && !$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
| 252 | + if (count($category_list) > 0 && !$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
| 253 | 253 | } |
| 254 | 254 | // Set the read counts and update order. |
| 255 | - if(!$obj->readed_count) $obj->readed_count = 0; |
|
| 256 | - if($isLatest) $obj->update_order = $obj->list_order = $obj->document_srl * -1; |
|
| 255 | + if (!$obj->readed_count) $obj->readed_count = 0; |
|
| 256 | + if ($isLatest) $obj->update_order = $obj->list_order = $obj->document_srl * -1; |
|
| 257 | 257 | else $obj->update_order = $obj->list_order; |
| 258 | 258 | // Check the status of password hash for manually inserting. Apply hashing for otherwise. |
| 259 | - if($obj->password && !$obj->password_is_hashed) |
|
| 259 | + if ($obj->password && !$obj->password_is_hashed) |
|
| 260 | 260 | { |
| 261 | 261 | $obj->password = getModel('member')->hashPassword($obj->password); |
| 262 | 262 | } |
| 263 | 263 | // Insert member's information only if the member is logged-in and not manually registered. |
| 264 | 264 | $logged_info = Context::get('logged_info'); |
| 265 | - if(Context::get('is_logged') && !$manual_inserted && !$isRestore) |
|
| 265 | + if (Context::get('is_logged') && !$manual_inserted && !$isRestore) |
|
| 266 | 266 | { |
| 267 | 267 | $obj->member_srl = $logged_info->member_srl; |
| 268 | 268 | |
@@ -276,61 +276,61 @@ discard block |
||
| 276 | 276 | // If the tile is empty, extract string from the contents. |
| 277 | 277 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 278 | 278 | settype($obj->title, "string"); |
| 279 | - if($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...'); |
|
| 279 | + if ($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))), 20, '...'); |
|
| 280 | 280 | // If no tile extracted from the contents, leave it untitled. |
| 281 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
| 281 | + if ($obj->title == '') $obj->title = 'Untitled'; |
|
| 282 | 282 | // Remove XE's own tags from the contents. |
| 283 | 283 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
| 284 | - if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
|
| 284 | + if (Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
|
| 285 | 285 | { |
| 286 | - if($obj->use_html != 'Y') |
|
| 286 | + if ($obj->use_html != 'Y') |
|
| 287 | 287 | { |
| 288 | 288 | $obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 289 | 289 | } |
| 290 | 290 | $obj->content = nl2br($obj->content); |
| 291 | 291 | } |
| 292 | 292 | // Remove iframe and script if not a top adminisrator in the session. |
| 293 | - if($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content); |
|
| 293 | + if ($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content); |
|
| 294 | 294 | // An error appears if both log-in info and user name don't exist. |
| 295 | - if(!$logged_info->member_srl && !$obj->nick_name) return new BaseObject(-1,'msg_invalid_request'); |
|
| 295 | + if (!$logged_info->member_srl && !$obj->nick_name) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 296 | 296 | |
| 297 | 297 | $obj->lang_code = Context::getLangType(); |
| 298 | 298 | // Insert data into the DB |
| 299 | - if(!$obj->status) $this->_checkDocumentStatusForOldVersion($obj); |
|
| 299 | + if (!$obj->status) $this->_checkDocumentStatusForOldVersion($obj); |
|
| 300 | 300 | $output = executeQuery('document.insertDocument', $obj); |
| 301 | - if(!$output->toBool()) |
|
| 301 | + if (!$output->toBool()) |
|
| 302 | 302 | { |
| 303 | 303 | $oDB->rollback(); |
| 304 | 304 | return $output; |
| 305 | 305 | } |
| 306 | 306 | // Insert extra variables if the document successfully inserted. |
| 307 | 307 | $extra_keys = $oDocumentModel->getExtraKeys($obj->module_srl); |
| 308 | - if(count($extra_keys)) |
|
| 308 | + if (count($extra_keys)) |
|
| 309 | 309 | { |
| 310 | - foreach($extra_keys as $idx => $extra_item) |
|
| 310 | + foreach ($extra_keys as $idx => $extra_item) |
|
| 311 | 311 | { |
| 312 | 312 | $value = NULL; |
| 313 | - if(isset($obj->{'extra_vars'.$idx})) |
|
| 313 | + if (isset($obj->{'extra_vars'.$idx})) |
|
| 314 | 314 | { |
| 315 | 315 | $tmp = $obj->{'extra_vars'.$idx}; |
| 316 | - if(is_array($tmp)) |
|
| 316 | + if (is_array($tmp)) |
|
| 317 | 317 | $value = implode('|@|', $tmp); |
| 318 | 318 | else |
| 319 | 319 | $value = trim($tmp); |
| 320 | 320 | } |
| 321 | - else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
| 322 | - if($value == NULL) continue; |
|
| 321 | + else if (isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
| 322 | + if ($value == NULL) continue; |
|
| 323 | 323 | |
| 324 | 324 | $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); |
| 325 | 325 | } |
| 326 | 326 | } |
| 327 | 327 | // Update the category if the category_srl exists. |
| 328 | - if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
| 328 | + if ($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
| 329 | 329 | // Call a trigger (after) |
| 330 | - if($output->toBool()) |
|
| 330 | + if ($output->toBool()) |
|
| 331 | 331 | { |
| 332 | 332 | $trigger_output = ModuleHandler::triggerCall('document.insertDocument', 'after', $obj); |
| 333 | - if(!$trigger_output->toBool()) |
|
| 333 | + if (!$trigger_output->toBool()) |
|
| 334 | 334 | { |
| 335 | 335 | $oDB->rollback(); |
| 336 | 336 | return $trigger_output; |
@@ -341,12 +341,12 @@ discard block |
||
| 341 | 341 | $oDB->commit(); |
| 342 | 342 | |
| 343 | 343 | // return |
| 344 | - if(!$manual_inserted) |
|
| 344 | + if (!$manual_inserted) |
|
| 345 | 345 | { |
| 346 | 346 | $this->addGrant($obj->document_srl); |
| 347 | 347 | } |
| 348 | - $output->add('document_srl',$obj->document_srl); |
|
| 349 | - $output->add('category_srl',$obj->category_srl); |
|
| 348 | + $output->add('document_srl', $obj->document_srl); |
|
| 349 | + $output->add('category_srl', $obj->category_srl); |
|
| 350 | 350 | |
| 351 | 351 | return $output; |
| 352 | 352 | } |
@@ -362,41 +362,41 @@ discard block |
||
| 362 | 362 | { |
| 363 | 363 | $logged_info = Context::get('logged_info'); |
| 364 | 364 | |
| 365 | - if(!$manual_updated && !checkCSRF()) |
|
| 365 | + if (!$manual_updated && !checkCSRF()) |
|
| 366 | 366 | { |
| 367 | 367 | return new BaseObject(-1, 'msg_invalid_request'); |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | - if(!$source_obj->document_srl || !$obj->document_srl) return new BaseObject(-1,'msg_invalied_request'); |
|
| 371 | - if(!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET'; |
|
| 372 | - if(!$obj->status) $obj->status = 'PUBLIC'; |
|
| 370 | + if (!$source_obj->document_srl || !$obj->document_srl) return new BaseObject(-1, 'msg_invalied_request'); |
|
| 371 | + if (!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET'; |
|
| 372 | + if (!$obj->status) $obj->status = 'PUBLIC'; |
|
| 373 | 373 | |
| 374 | 374 | // Call a trigger (before) |
| 375 | 375 | $output = ModuleHandler::triggerCall('document.updateDocument', 'before', $obj); |
| 376 | - if(!$output->toBool()) return $output; |
|
| 376 | + if (!$output->toBool()) return $output; |
|
| 377 | 377 | |
| 378 | 378 | // begin transaction |
| 379 | 379 | $oDB = &DB::getInstance(); |
| 380 | 380 | $oDB->begin(); |
| 381 | 381 | |
| 382 | 382 | $oModuleModel = getModel('module'); |
| 383 | - if(!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl'); |
|
| 383 | + if (!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl'); |
|
| 384 | 384 | $module_srl = $obj->module_srl; |
| 385 | 385 | $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
| 386 | - if(!$document_config) |
|
| 386 | + if (!$document_config) |
|
| 387 | 387 | { |
| 388 | 388 | $document_config = new stdClass(); |
| 389 | 389 | } |
| 390 | - if(!isset($document_config->use_history)) $document_config->use_history = 'N'; |
|
| 390 | + if (!isset($document_config->use_history)) $document_config->use_history = 'N'; |
|
| 391 | 391 | $bUseHistory = $document_config->use_history == 'Y' || $document_config->use_history == 'Trace'; |
| 392 | 392 | |
| 393 | - if($bUseHistory) |
|
| 393 | + if ($bUseHistory) |
|
| 394 | 394 | { |
| 395 | 395 | $args = new stdClass; |
| 396 | 396 | $args->history_srl = getNextSequence(); |
| 397 | 397 | $args->document_srl = $obj->document_srl; |
| 398 | 398 | $args->module_srl = $module_srl; |
| 399 | - if($document_config->use_history == 'Y') $args->content = $source_obj->get('content'); |
|
| 399 | + if ($document_config->use_history == 'Y') $args->content = $source_obj->get('content'); |
|
| 400 | 400 | $args->nick_name = $source_obj->get('nick_name'); |
| 401 | 401 | $args->member_srl = $source_obj->get('member_srl'); |
| 402 | 402 | $args->regdate = $source_obj->get('last_update'); |
@@ -408,30 +408,30 @@ discard block |
||
| 408 | 408 | $obj->ipaddress = $source_obj->get('ipaddress'); |
| 409 | 409 | } |
| 410 | 410 | // List variables |
| 411 | - if($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
| 412 | - if(!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
| 413 | - if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
| 414 | - if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N'; |
|
| 415 | - if($obj->homepage) |
|
| 411 | + if ($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
| 412 | + if (!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
| 413 | + if ($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
| 414 | + if ($obj->allow_trackback != 'Y') $obj->allow_trackback = 'N'; |
|
| 415 | + if ($obj->homepage) |
|
| 416 | 416 | { |
| 417 | 417 | $obj->homepage = removeHackTag($obj->homepage); |
| 418 | - if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage)) |
|
| 418 | + if (!preg_match('/^[a-z]+:\/\//i', $obj->homepage)) |
|
| 419 | 419 | { |
| 420 | 420 | $obj->homepage = 'http://'.$obj->homepage; |
| 421 | 421 | } |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | - if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
| 424 | + if ($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
| 425 | 425 | |
| 426 | 426 | // can modify regdate only manager |
| 427 | 427 | $grant = Context::get('grant'); |
| 428 | - if(!$grant->manager) |
|
| 428 | + if (!$grant->manager) |
|
| 429 | 429 | { |
| 430 | 430 | unset($obj->regdate); |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | // Serialize the $extra_vars |
| 434 | - if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
| 434 | + if (!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
| 435 | 435 | // Remove the columns for automatic saving |
| 436 | 436 | unset($obj->_saved_doc_srl); |
| 437 | 437 | unset($obj->_saved_doc_title); |
@@ -440,23 +440,23 @@ discard block |
||
| 440 | 440 | |
| 441 | 441 | $oDocumentModel = getModel('document'); |
| 442 | 442 | // Set the category_srl to 0 if the changed category is not exsiting. |
| 443 | - if($source_obj->get('category_srl')!=$obj->category_srl) |
|
| 443 | + if ($source_obj->get('category_srl') != $obj->category_srl) |
|
| 444 | 444 | { |
| 445 | 445 | $category_list = $oDocumentModel->getCategoryList($obj->module_srl); |
| 446 | - if(!$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
| 446 | + if (!$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
| 447 | 447 | } |
| 448 | 448 | // Change the update order |
| 449 | 449 | $obj->update_order = getNextSequence() * -1; |
| 450 | 450 | // Hash the password if it exists |
| 451 | - if($obj->password) |
|
| 451 | + if ($obj->password) |
|
| 452 | 452 | { |
| 453 | 453 | $obj->password = getModel('member')->hashPassword($obj->password); |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | // If an author is identical to the modifier or history is used, use the logged-in user's information. |
| 457 | - if(Context::get('is_logged') && !$manual_updated) |
|
| 457 | + if (Context::get('is_logged') && !$manual_updated) |
|
| 458 | 458 | { |
| 459 | - if($source_obj->get('member_srl')==$logged_info->member_srl) |
|
| 459 | + if ($source_obj->get('member_srl') == $logged_info->member_srl) |
|
| 460 | 460 | { |
| 461 | 461 | $obj->member_srl = $logged_info->member_srl; |
| 462 | 462 | $obj->user_name = htmlspecialchars_decode($logged_info->user_name); |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | // For the document written by logged-in user however no nick_name exists |
| 470 | - if($source_obj->get('member_srl')&& !$obj->nick_name) |
|
| 470 | + if ($source_obj->get('member_srl') && !$obj->nick_name) |
|
| 471 | 471 | { |
| 472 | 472 | $obj->member_srl = $source_obj->get('member_srl'); |
| 473 | 473 | $obj->user_name = $source_obj->get('user_name'); |
@@ -478,24 +478,24 @@ discard block |
||
| 478 | 478 | // If the tile is empty, extract string from the contents. |
| 479 | 479 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 480 | 480 | settype($obj->title, "string"); |
| 481 | - if($obj->title == '') $obj->title = cut_str(strip_tags($obj->content),20,'...'); |
|
| 481 | + if ($obj->title == '') $obj->title = cut_str(strip_tags($obj->content), 20, '...'); |
|
| 482 | 482 | // If no tile extracted from the contents, leave it untitled. |
| 483 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
| 483 | + if ($obj->title == '') $obj->title = 'Untitled'; |
|
| 484 | 484 | // Remove XE's own tags from the contents. |
| 485 | 485 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
| 486 | - if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
|
| 486 | + if (Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
|
| 487 | 487 | { |
| 488 | - if($obj->use_html != 'Y') |
|
| 488 | + if ($obj->use_html != 'Y') |
|
| 489 | 489 | { |
| 490 | 490 | $obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 491 | 491 | } |
| 492 | 492 | $obj->content = nl2br($obj->content); |
| 493 | 493 | } |
| 494 | 494 | // Change not extra vars but language code of the original document if document's lang_code is different from author's setting. |
| 495 | - if($source_obj->get('lang_code') != Context::getLangType()) |
|
| 495 | + if ($source_obj->get('lang_code') != Context::getLangType()) |
|
| 496 | 496 | { |
| 497 | 497 | // Change not extra vars but language code of the original document if document's lang_code doesn't exist. |
| 498 | - if(!$source_obj->get('lang_code')) |
|
| 498 | + if (!$source_obj->get('lang_code')) |
|
| 499 | 499 | { |
| 500 | 500 | $lang_code_args->document_srl = $source_obj->get('document_srl'); |
| 501 | 501 | $lang_code_args->lang_code = Context::getLangType(); |
@@ -515,59 +515,59 @@ discard block |
||
| 515 | 515 | } |
| 516 | 516 | } |
| 517 | 517 | // Remove iframe and script if not a top adminisrator in the session. |
| 518 | - if($logged_info->is_admin != 'Y') |
|
| 518 | + if ($logged_info->is_admin != 'Y') |
|
| 519 | 519 | { |
| 520 | 520 | $obj->content = removeHackTag($obj->content); |
| 521 | 521 | } |
| 522 | 522 | // if temporary document, regdate is now setting |
| 523 | - if($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis'); |
|
| 523 | + if ($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis'); |
|
| 524 | 524 | |
| 525 | 525 | // Insert data into the DB |
| 526 | 526 | $output = executeQuery('document.updateDocument', $obj); |
| 527 | - if(!$output->toBool()) |
|
| 527 | + if (!$output->toBool()) |
|
| 528 | 528 | { |
| 529 | 529 | $oDB->rollback(); |
| 530 | 530 | return $output; |
| 531 | 531 | } |
| 532 | 532 | // Remove all extra variables |
| 533 | - if(Context::get('act')!='procFileDelete') |
|
| 533 | + if (Context::get('act') != 'procFileDelete') |
|
| 534 | 534 | { |
| 535 | 535 | $this->deleteDocumentExtraVars($source_obj->get('module_srl'), $obj->document_srl, null, Context::getLangType()); |
| 536 | 536 | // Insert extra variables if the document successfully inserted. |
| 537 | 537 | $extra_keys = $oDocumentModel->getExtraKeys($obj->module_srl); |
| 538 | - if(count($extra_keys)) |
|
| 538 | + if (count($extra_keys)) |
|
| 539 | 539 | { |
| 540 | - foreach($extra_keys as $idx => $extra_item) |
|
| 540 | + foreach ($extra_keys as $idx => $extra_item) |
|
| 541 | 541 | { |
| 542 | 542 | $value = NULL; |
| 543 | - if(isset($obj->{'extra_vars'.$idx})) |
|
| 543 | + if (isset($obj->{'extra_vars'.$idx})) |
|
| 544 | 544 | { |
| 545 | 545 | $tmp = $obj->{'extra_vars'.$idx}; |
| 546 | - if(is_array($tmp)) |
|
| 546 | + if (is_array($tmp)) |
|
| 547 | 547 | $value = implode('|@|', $tmp); |
| 548 | 548 | else |
| 549 | 549 | $value = trim($tmp); |
| 550 | 550 | } |
| 551 | - else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
| 552 | - if($value == NULL) continue; |
|
| 551 | + else if (isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
| 552 | + if ($value == NULL) continue; |
|
| 553 | 553 | $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); |
| 554 | 554 | } |
| 555 | 555 | } |
| 556 | 556 | // Inert extra vars for multi-language support of title and contents. |
| 557 | - if($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType()); |
|
| 558 | - if($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType()); |
|
| 557 | + if ($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType()); |
|
| 558 | + if ($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType()); |
|
| 559 | 559 | } |
| 560 | 560 | // Update the category if the category_srl exists. |
| 561 | - if($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl) |
|
| 561 | + if ($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl) |
|
| 562 | 562 | { |
| 563 | - if($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
| 564 | - if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
| 563 | + if ($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
| 564 | + if ($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
| 565 | 565 | } |
| 566 | 566 | // Call a trigger (after) |
| 567 | - if($output->toBool()) |
|
| 567 | + if ($output->toBool()) |
|
| 568 | 568 | { |
| 569 | 569 | $trigger_output = ModuleHandler::triggerCall('document.updateDocument', 'after', $obj); |
| 570 | - if(!$trigger_output->toBool()) |
|
| 570 | + if (!$trigger_output->toBool()) |
|
| 571 | 571 | { |
| 572 | 572 | $oDB->rollback(); |
| 573 | 573 | return $trigger_output; |
@@ -577,15 +577,15 @@ discard block |
||
| 577 | 577 | // commit |
| 578 | 578 | $oDB->commit(); |
| 579 | 579 | // Remove the thumbnail file |
| 580 | - FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3))); |
|
| 580 | + FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3))); |
|
| 581 | 581 | |
| 582 | - $output->add('document_srl',$obj->document_srl); |
|
| 582 | + $output->add('document_srl', $obj->document_srl); |
|
| 583 | 583 | //remove from cache |
| 584 | 584 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 585 | - if($oCacheHandler->isSupport()) |
|
| 585 | + if ($oCacheHandler->isSupport()) |
|
| 586 | 586 | { |
| 587 | 587 | //remove document item from cache |
| 588 | - $cache_key = 'document_item:'. getNumberingPath($obj->document_srl) . $obj->document_srl; |
|
| 588 | + $cache_key = 'document_item:'.getNumberingPath($obj->document_srl).$obj->document_srl; |
|
| 589 | 589 | $oCacheHandler->delete($cache_key); |
| 590 | 590 | } |
| 591 | 591 | |
@@ -606,33 +606,33 @@ discard block |
||
| 606 | 606 | $trigger_obj = new stdClass(); |
| 607 | 607 | $trigger_obj->document_srl = $document_srl; |
| 608 | 608 | $output = ModuleHandler::triggerCall('document.deleteDocument', 'before', $trigger_obj); |
| 609 | - if(!$output->toBool()) return $output; |
|
| 609 | + if (!$output->toBool()) return $output; |
|
| 610 | 610 | |
| 611 | 611 | // begin transaction |
| 612 | 612 | $oDB = &DB::getInstance(); |
| 613 | 613 | $oDB->begin(); |
| 614 | 614 | |
| 615 | - if(!$isEmptyTrash) |
|
| 615 | + if (!$isEmptyTrash) |
|
| 616 | 616 | { |
| 617 | 617 | // get model object of the document |
| 618 | 618 | $oDocumentModel = getModel('document'); |
| 619 | 619 | // Check if the documnet exists |
| 620 | 620 | $oDocument = $oDocumentModel->getDocument($document_srl, $is_admin); |
| 621 | 621 | } |
| 622 | - else if($isEmptyTrash && $oDocument == null) return new BaseObject(-1, 'document is not exists'); |
|
| 622 | + else if ($isEmptyTrash && $oDocument == null) return new BaseObject(-1, 'document is not exists'); |
|
| 623 | 623 | |
| 624 | - if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new BaseObject(-1, 'msg_invalid_document'); |
|
| 624 | + if (!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new BaseObject(-1, 'msg_invalid_document'); |
|
| 625 | 625 | // Check if a permossion is granted |
| 626 | - if(!$oDocument->isGranted()) return new BaseObject(-1, 'msg_not_permitted'); |
|
| 626 | + if (!$oDocument->isGranted()) return new BaseObject(-1, 'msg_not_permitted'); |
|
| 627 | 627 | |
| 628 | 628 | //if empty trash, document already deleted, therefore document not delete |
| 629 | 629 | $args = new stdClass(); |
| 630 | 630 | $args->document_srl = $document_srl; |
| 631 | - if(!$isEmptyTrash) |
|
| 631 | + if (!$isEmptyTrash) |
|
| 632 | 632 | { |
| 633 | 633 | // Delete the document |
| 634 | 634 | $output = executeQuery('document.deleteDocument', $args); |
| 635 | - if(!$output->toBool()) |
|
| 635 | + if (!$output->toBool()) |
|
| 636 | 636 | { |
| 637 | 637 | $oDB->rollback(); |
| 638 | 638 | return $output; |
@@ -643,7 +643,7 @@ discard block |
||
| 643 | 643 | |
| 644 | 644 | $this->deleteDocumentHistory(null, $document_srl, null); |
| 645 | 645 | // Update category information if the category_srl exists. |
| 646 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
| 646 | + if ($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl')); |
|
| 647 | 647 | // Delete a declared list |
| 648 | 648 | executeQuery('document.deleteDeclared', $args); |
| 649 | 649 | // Delete extra variable |
@@ -651,11 +651,11 @@ discard block |
||
| 651 | 651 | |
| 652 | 652 | //this |
| 653 | 653 | // Call a trigger (after) |
| 654 | - if($output->toBool()) |
|
| 654 | + if ($output->toBool()) |
|
| 655 | 655 | { |
| 656 | 656 | $trigger_obj = $oDocument->getObjectVars(); |
| 657 | 657 | $trigger_output = ModuleHandler::triggerCall('document.deleteDocument', 'after', $trigger_obj); |
| 658 | - if(!$trigger_output->toBool()) |
|
| 658 | + if (!$trigger_output->toBool()) |
|
| 659 | 659 | { |
| 660 | 660 | $oDB->rollback(); |
| 661 | 661 | return $trigger_output; |
@@ -667,16 +667,16 @@ discard block |
||
| 667 | 667 | $this->_deleteDocumentVotedLog($args); |
| 668 | 668 | |
| 669 | 669 | // Remove the thumbnail file |
| 670 | - FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($document_srl, 3))); |
|
| 670 | + FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($document_srl, 3))); |
|
| 671 | 671 | |
| 672 | 672 | // commit |
| 673 | 673 | $oDB->commit(); |
| 674 | 674 | |
| 675 | 675 | //remove from cache |
| 676 | 676 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 677 | - if($oCacheHandler->isSupport()) |
|
| 677 | + if ($oCacheHandler->isSupport()) |
|
| 678 | 678 | { |
| 679 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
| 679 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
| 680 | 680 | $oCacheHandler->delete($cache_key); |
| 681 | 681 | } |
| 682 | 682 | |
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | { |
| 724 | 724 | $trash_args = new stdClass(); |
| 725 | 725 | // Get trash_srl if a given trash_srl doesn't exist |
| 726 | - if(!$obj->trash_srl) $trash_args->trash_srl = getNextSequence(); |
|
| 726 | + if (!$obj->trash_srl) $trash_args->trash_srl = getNextSequence(); |
|
| 727 | 727 | else $trash_args->trash_srl = $obj->trash_srl; |
| 728 | 728 | // Get its module_srl which the document belongs to |
| 729 | 729 | $oDocumentModel = getModel('document'); |
@@ -732,12 +732,12 @@ discard block |
||
| 732 | 732 | $trash_args->module_srl = $oDocument->get('module_srl'); |
| 733 | 733 | $obj->module_srl = $oDocument->get('module_srl'); |
| 734 | 734 | // Cannot throw data from the trash to the trash |
| 735 | - if($trash_args->module_srl == 0) return false; |
|
| 735 | + if ($trash_args->module_srl == 0) return false; |
|
| 736 | 736 | // Data setting |
| 737 | 737 | $trash_args->document_srl = $obj->document_srl; |
| 738 | 738 | $trash_args->description = $obj->description; |
| 739 | 739 | // Insert member's information only if the member is logged-in and not manually registered. |
| 740 | - if(Context::get('is_logged')&&!$manual_inserted) |
|
| 740 | + if (Context::get('is_logged') && !$manual_inserted) |
|
| 741 | 741 | { |
| 742 | 742 | $logged_info = Context::get('logged_info'); |
| 743 | 743 | $trash_args->member_srl = $logged_info->member_srl; |
@@ -773,14 +773,14 @@ discard block |
||
| 773 | 773 | |
| 774 | 774 | $oTrashAdminController = getAdminController('trash'); |
| 775 | 775 | $output = $oTrashAdminController->insertTrash($oTrashVO); |
| 776 | - if(!$output->toBool()) |
|
| 776 | + if (!$output->toBool()) |
|
| 777 | 777 | { |
| 778 | 778 | $oDB->rollback(); |
| 779 | 779 | return $output; |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | $output = executeQuery('document.deleteDocument', $trash_args); |
| 783 | - if(!$output->toBool()) |
|
| 783 | + if (!$output->toBool()) |
|
| 784 | 784 | { |
| 785 | 785 | $oDB->rollback(); |
| 786 | 786 | return $output; |
@@ -793,12 +793,12 @@ discard block |
||
| 793 | 793 | }*/ |
| 794 | 794 | |
| 795 | 795 | // update category |
| 796 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
| 796 | + if ($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl')); |
|
| 797 | 797 | |
| 798 | 798 | // remove thumbnails |
| 799 | - FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3))); |
|
| 799 | + FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3))); |
|
| 800 | 800 | // Set the attachment to be invalid state |
| 801 | - if($oDocument->hasUploadedFiles()) |
|
| 801 | + if ($oDocument->hasUploadedFiles()) |
|
| 802 | 802 | { |
| 803 | 803 | $args = new stdClass(); |
| 804 | 804 | $args->upload_target_srl = $oDocument->document_srl; |
@@ -806,10 +806,10 @@ discard block |
||
| 806 | 806 | executeQuery('file.updateFileValid', $args); |
| 807 | 807 | } |
| 808 | 808 | // Call a trigger (after) |
| 809 | - if($output->toBool()) |
|
| 809 | + if ($output->toBool()) |
|
| 810 | 810 | { |
| 811 | 811 | $trigger_output = ModuleHandler::triggerCall('document.moveDocumentToTrash', 'after', $obj); |
| 812 | - if(!$trigger_output->toBool()) |
|
| 812 | + if (!$trigger_output->toBool()) |
|
| 813 | 813 | { |
| 814 | 814 | $oDB->rollback(); |
| 815 | 815 | return $trigger_output; |
@@ -821,9 +821,9 @@ discard block |
||
| 821 | 821 | |
| 822 | 822 | // Clear cache |
| 823 | 823 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 824 | - if($oCacheHandler->isSupport()) |
|
| 824 | + if ($oCacheHandler->isSupport()) |
|
| 825 | 825 | { |
| 826 | - $cache_key = 'document_item:'. getNumberingPath($oDocument->document_srl) . $oDocument->document_srl; |
|
| 826 | + $cache_key = 'document_item:'.getNumberingPath($oDocument->document_srl).$oDocument->document_srl; |
|
| 827 | 827 | $oCacheHandler->delete($cache_key); |
| 828 | 828 | } |
| 829 | 829 | |
@@ -838,7 +838,7 @@ discard block |
||
| 838 | 838 | function updateReadedCount(&$oDocument) |
| 839 | 839 | { |
| 840 | 840 | // Pass if Crawler access |
| 841 | - if(isCrawler()) return false; |
|
| 841 | + if (isCrawler()) return false; |
|
| 842 | 842 | |
| 843 | 843 | $document_srl = $oDocument->document_srl; |
| 844 | 844 | $member_srl = $oDocument->get('member_srl'); |
@@ -846,19 +846,19 @@ discard block |
||
| 846 | 846 | |
| 847 | 847 | // Call a trigger when the read count is updated (before) |
| 848 | 848 | $trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'before', $oDocument); |
| 849 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
| 849 | + if (!$trigger_output->toBool()) return $trigger_output; |
|
| 850 | 850 | |
| 851 | 851 | // Pass if read count is increaded on the session information |
| 852 | - if($_SESSION['readed_document'][$document_srl]) return false; |
|
| 852 | + if ($_SESSION['readed_document'][$document_srl]) return false; |
|
| 853 | 853 | |
| 854 | 854 | // Pass if the author's IP address is as same as visitor's. |
| 855 | - if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
| 855 | + if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
| 856 | 856 | { |
| 857 | 857 | $_SESSION['readed_document'][$document_srl] = true; |
| 858 | 858 | return false; |
| 859 | 859 | } |
| 860 | 860 | // Pass ater registering sesscion if the author is a member and has same information as the currently logged-in user. |
| 861 | - if($member_srl && $logged_info->member_srl == $member_srl) |
|
| 861 | + if ($member_srl && $logged_info->member_srl == $member_srl) |
|
| 862 | 862 | { |
| 863 | 863 | $_SESSION['readed_document'][$document_srl] = true; |
| 864 | 864 | return false; |
@@ -874,7 +874,7 @@ discard block |
||
| 874 | 874 | |
| 875 | 875 | // Call a trigger when the read count is updated (after) |
| 876 | 876 | $trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'after', $oDocument); |
| 877 | - if(!$trigger_output->toBool()) |
|
| 877 | + if (!$trigger_output->toBool()) |
|
| 878 | 878 | { |
| 879 | 879 | $oDB->rollback(); |
| 880 | 880 | return $trigger_output; |
@@ -883,15 +883,15 @@ discard block |
||
| 883 | 883 | $oDB->commit(); |
| 884 | 884 | |
| 885 | 885 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 886 | - if($oCacheHandler->isSupport()) |
|
| 886 | + if ($oCacheHandler->isSupport()) |
|
| 887 | 887 | { |
| 888 | 888 | //remove document item from cache |
| 889 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
| 889 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
| 890 | 890 | $oCacheHandler->delete($cache_key); |
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | // Register session |
| 894 | - if(!$_SESSION['banned_document'][$document_srl]) |
|
| 894 | + if (!$_SESSION['banned_document'][$document_srl]) |
|
| 895 | 895 | { |
| 896 | 896 | $_SESSION['readed_document'][$document_srl] = true; |
| 897 | 897 | } |
@@ -914,21 +914,21 @@ discard block |
||
| 914 | 914 | */ |
| 915 | 915 | function insertDocumentExtraKey($module_srl, $var_idx, $var_name, $var_type, $var_is_required = 'N', $var_search = 'N', $var_default = '', $var_desc = '', $eid) |
| 916 | 916 | { |
| 917 | - if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new BaseObject(-1,'msg_invalid_request'); |
|
| 917 | + if (!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 918 | 918 | |
| 919 | 919 | $obj = new stdClass(); |
| 920 | 920 | $obj->module_srl = $module_srl; |
| 921 | 921 | $obj->var_idx = $var_idx; |
| 922 | 922 | $obj->var_name = $var_name; |
| 923 | 923 | $obj->var_type = $var_type; |
| 924 | - $obj->var_is_required = $var_is_required=='Y'?'Y':'N'; |
|
| 925 | - $obj->var_search = $var_search=='Y'?'Y':'N'; |
|
| 924 | + $obj->var_is_required = $var_is_required == 'Y' ? 'Y' : 'N'; |
|
| 925 | + $obj->var_search = $var_search == 'Y' ? 'Y' : 'N'; |
|
| 926 | 926 | $obj->var_default = $var_default; |
| 927 | 927 | $obj->var_desc = $var_desc; |
| 928 | 928 | $obj->eid = $eid; |
| 929 | 929 | |
| 930 | 930 | $output = executeQuery('document.getDocumentExtraKeys', $obj); |
| 931 | - if(!$output->data) |
|
| 931 | + if (!$output->data) |
|
| 932 | 932 | { |
| 933 | 933 | $output = executeQuery('document.insertDocumentExtraKey', $obj); |
| 934 | 934 | } |
@@ -940,7 +940,7 @@ discard block |
||
| 940 | 940 | } |
| 941 | 941 | |
| 942 | 942 | $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); |
| 943 | - if($oCacheHandler->isSupport()) |
|
| 943 | + if ($oCacheHandler->isSupport()) |
|
| 944 | 944 | { |
| 945 | 945 | $object_key = 'module_document_extra_keys:'.$module_srl; |
| 946 | 946 | $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
@@ -958,42 +958,42 @@ discard block |
||
| 958 | 958 | */ |
| 959 | 959 | function deleteDocumentExtraKeys($module_srl, $var_idx = null) |
| 960 | 960 | { |
| 961 | - if(!$module_srl) return new BaseObject(-1,'msg_invalid_request'); |
|
| 961 | + if (!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 962 | 962 | $obj = new stdClass(); |
| 963 | 963 | $obj->module_srl = $module_srl; |
| 964 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
| 964 | + if (!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
| 965 | 965 | |
| 966 | 966 | $oDB = DB::getInstance(); |
| 967 | 967 | $oDB->begin(); |
| 968 | 968 | |
| 969 | 969 | $output = $oDB->executeQuery('document.deleteDocumentExtraKeys', $obj); |
| 970 | - if(!$output->toBool()) |
|
| 970 | + if (!$output->toBool()) |
|
| 971 | 971 | { |
| 972 | 972 | $oDB->rollback(); |
| 973 | 973 | return $output; |
| 974 | 974 | } |
| 975 | 975 | |
| 976 | - if($var_idx != NULL) |
|
| 976 | + if ($var_idx != NULL) |
|
| 977 | 977 | { |
| 978 | 978 | $output = $oDB->executeQuery('document.updateDocumentExtraKeyIdxOrder', $obj); |
| 979 | - if(!$output->toBool()) |
|
| 979 | + if (!$output->toBool()) |
|
| 980 | 980 | { |
| 981 | 981 | $oDB->rollback(); |
| 982 | 982 | return $output; |
| 983 | 983 | } |
| 984 | 984 | } |
| 985 | 985 | |
| 986 | - $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
|
| 987 | - if(!$output->toBool()) |
|
| 986 | + $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
|
| 987 | + if (!$output->toBool()) |
|
| 988 | 988 | { |
| 989 | 989 | $oDB->rollback(); |
| 990 | 990 | return $output; |
| 991 | 991 | } |
| 992 | 992 | |
| 993 | - if($var_idx != NULL) |
|
| 993 | + if ($var_idx != NULL) |
|
| 994 | 994 | { |
| 995 | 995 | $output = $oDB->executeQuery('document.updateDocumentExtraVarIdxOrder', $obj); |
| 996 | - if(!$output->toBool()) |
|
| 996 | + if (!$output->toBool()) |
|
| 997 | 997 | { |
| 998 | 998 | $oDB->rollback(); |
| 999 | 999 | return $output; |
@@ -1003,7 +1003,7 @@ discard block |
||
| 1003 | 1003 | $oDB->commit(); |
| 1004 | 1004 | |
| 1005 | 1005 | $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); |
| 1006 | - if($oCacheHandler->isSupport()) |
|
| 1006 | + if ($oCacheHandler->isSupport()) |
|
| 1007 | 1007 | { |
| 1008 | 1008 | $object_key = 'module_document_extra_keys:'.$module_srl; |
| 1009 | 1009 | $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
@@ -1025,8 +1025,8 @@ discard block |
||
| 1025 | 1025 | */ |
| 1026 | 1026 | function insertDocumentExtraVar($module_srl, $document_srl, $var_idx, $value, $eid = null, $lang_code = '') |
| 1027 | 1027 | { |
| 1028 | - if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new BaseObject(-1,'msg_invalid_request'); |
|
| 1029 | - if(!$lang_code) $lang_code = Context::getLangType(); |
|
| 1028 | + if (!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 1029 | + if (!$lang_code) $lang_code = Context::getLangType(); |
|
| 1030 | 1030 | |
| 1031 | 1031 | $obj = new stdClass; |
| 1032 | 1032 | $obj->module_srl = $module_srl; |
@@ -1052,10 +1052,10 @@ discard block |
||
| 1052 | 1052 | { |
| 1053 | 1053 | $obj = new stdClass(); |
| 1054 | 1054 | $obj->module_srl = $module_srl; |
| 1055 | - if(!is_null($document_srl)) $obj->document_srl = $document_srl; |
|
| 1056 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
| 1057 | - if(!is_null($lang_code)) $obj->lang_code = $lang_code; |
|
| 1058 | - if(!is_null($eid)) $obj->eid = $eid; |
|
| 1055 | + if (!is_null($document_srl)) $obj->document_srl = $document_srl; |
|
| 1056 | + if (!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
| 1057 | + if (!is_null($lang_code)) $obj->lang_code = $lang_code; |
|
| 1058 | + if (!is_null($eid)) $obj->eid = $eid; |
|
| 1059 | 1059 | $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
| 1060 | 1060 | return $output; |
| 1061 | 1061 | } |
@@ -1069,10 +1069,10 @@ discard block |
||
| 1069 | 1069 | */ |
| 1070 | 1070 | function updateVotedCount($document_srl, $point = 1) |
| 1071 | 1071 | { |
| 1072 | - if($point > 0) $failed_voted = 'failed_voted'; |
|
| 1072 | + if ($point > 0) $failed_voted = 'failed_voted'; |
|
| 1073 | 1073 | else $failed_voted = 'failed_blamed'; |
| 1074 | 1074 | // Return fail if session already has information about votes |
| 1075 | - if($_SESSION['voted_document'][$document_srl]) |
|
| 1075 | + if ($_SESSION['voted_document'][$document_srl]) |
|
| 1076 | 1076 | { |
| 1077 | 1077 | return new BaseObject(-1, $failed_voted); |
| 1078 | 1078 | } |
@@ -1080,7 +1080,7 @@ discard block |
||
| 1080 | 1080 | $oDocumentModel = getModel('document'); |
| 1081 | 1081 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
| 1082 | 1082 | // Pass if the author's IP address is as same as visitor's. |
| 1083 | - if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
| 1083 | + if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
| 1084 | 1084 | { |
| 1085 | 1085 | $_SESSION['voted_document'][$document_srl] = true; |
| 1086 | 1086 | return new BaseObject(-1, $failed_voted); |
@@ -1091,10 +1091,10 @@ discard block |
||
| 1091 | 1091 | $member_srl = $oMemberModel->getLoggedMemberSrl(); |
| 1092 | 1092 | |
| 1093 | 1093 | // Check if document's author is a member. |
| 1094 | - if($oDocument->get('member_srl')) |
|
| 1094 | + if ($oDocument->get('member_srl')) |
|
| 1095 | 1095 | { |
| 1096 | 1096 | // Pass after registering a session if author's information is same as the currently logged-in user's. |
| 1097 | - if($member_srl && $member_srl == abs($oDocument->get('member_srl'))) |
|
| 1097 | + if ($member_srl && $member_srl == abs($oDocument->get('member_srl'))) |
|
| 1098 | 1098 | { |
| 1099 | 1099 | $_SESSION['voted_document'][$document_srl] = true; |
| 1100 | 1100 | return new BaseObject(-1, $failed_voted); |
@@ -1103,7 +1103,7 @@ discard block |
||
| 1103 | 1103 | |
| 1104 | 1104 | // Use member_srl for logged-in members and IP address for non-members. |
| 1105 | 1105 | $args = new stdClass; |
| 1106 | - if($member_srl) |
|
| 1106 | + if ($member_srl) |
|
| 1107 | 1107 | { |
| 1108 | 1108 | $args->member_srl = $member_srl; |
| 1109 | 1109 | } |
@@ -1114,7 +1114,7 @@ discard block |
||
| 1114 | 1114 | $args->document_srl = $document_srl; |
| 1115 | 1115 | $output = executeQuery('document.getDocumentVotedLogInfo', $args); |
| 1116 | 1116 | // Pass after registering a session if log information has vote-up logs |
| 1117 | - if($output->data->count) |
|
| 1117 | + if ($output->data->count) |
|
| 1118 | 1118 | { |
| 1119 | 1119 | $_SESSION['voted_document'][$document_srl] = true; |
| 1120 | 1120 | return new BaseObject(-1, $failed_voted); |
@@ -1125,7 +1125,7 @@ discard block |
||
| 1125 | 1125 | $oDB->begin(); |
| 1126 | 1126 | |
| 1127 | 1127 | // Update the voted count |
| 1128 | - if($point < 0) |
|
| 1128 | + if ($point < 0) |
|
| 1129 | 1129 | { |
| 1130 | 1130 | $args->blamed_count = $oDocument->get('blamed_count') + $point; |
| 1131 | 1131 | $output = executeQuery('document.updateBlamedCount', $args); |
@@ -1135,11 +1135,11 @@ discard block |
||
| 1135 | 1135 | $args->voted_count = $oDocument->get('voted_count') + $point; |
| 1136 | 1136 | $output = executeQuery('document.updateVotedCount', $args); |
| 1137 | 1137 | } |
| 1138 | - if(!$output->toBool()) return $output; |
|
| 1138 | + if (!$output->toBool()) return $output; |
|
| 1139 | 1139 | // Leave logs |
| 1140 | 1140 | $args->point = $point; |
| 1141 | 1141 | $output = executeQuery('document.insertDocumentVotedLog', $args); |
| 1142 | - if(!$output->toBool()) return $output; |
|
| 1142 | + if (!$output->toBool()) return $output; |
|
| 1143 | 1143 | |
| 1144 | 1144 | $obj = new stdClass; |
| 1145 | 1145 | $obj->member_srl = $oDocument->get('member_srl'); |
@@ -1150,7 +1150,7 @@ discard block |
||
| 1150 | 1150 | $obj->before_point = ($point < 0) ? $oDocument->get('blamed_count') : $oDocument->get('voted_count'); |
| 1151 | 1151 | $obj->after_point = ($point < 0) ? $args->blamed_count : $args->voted_count; |
| 1152 | 1152 | $trigger_output = ModuleHandler::triggerCall('document.updateVotedCount', 'after', $obj); |
| 1153 | - if(!$trigger_output->toBool()) |
|
| 1153 | + if (!$trigger_output->toBool()) |
|
| 1154 | 1154 | { |
| 1155 | 1155 | $oDB->rollback(); |
| 1156 | 1156 | return $trigger_output; |
@@ -1159,10 +1159,10 @@ discard block |
||
| 1159 | 1159 | $oDB->commit(); |
| 1160 | 1160 | |
| 1161 | 1161 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 1162 | - if($oCacheHandler->isSupport()) |
|
| 1162 | + if ($oCacheHandler->isSupport()) |
|
| 1163 | 1163 | { |
| 1164 | 1164 | //remove document item from cache |
| 1165 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
| 1165 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
| 1166 | 1166 | $oCacheHandler->delete($cache_key); |
| 1167 | 1167 | } |
| 1168 | 1168 | |
@@ -1171,7 +1171,7 @@ discard block |
||
| 1171 | 1171 | |
| 1172 | 1172 | // Return result |
| 1173 | 1173 | $output = new BaseObject(); |
| 1174 | - if($point > 0) |
|
| 1174 | + if ($point > 0) |
|
| 1175 | 1175 | { |
| 1176 | 1176 | $output->setMessage('success_voted'); |
| 1177 | 1177 | $output->add('voted_count', $obj->after_point); |
@@ -1193,13 +1193,13 @@ discard block |
||
| 1193 | 1193 | function declaredDocument($document_srl) |
| 1194 | 1194 | { |
| 1195 | 1195 | // Fail if session information already has a reported document |
| 1196 | - if($_SESSION['declared_document'][$document_srl]) return new BaseObject(-1, 'failed_declared'); |
|
| 1196 | + if ($_SESSION['declared_document'][$document_srl]) return new BaseObject(-1, 'failed_declared'); |
|
| 1197 | 1197 | |
| 1198 | 1198 | // Check if previously reported |
| 1199 | 1199 | $args = new stdClass(); |
| 1200 | 1200 | $args->document_srl = $document_srl; |
| 1201 | 1201 | $output = executeQuery('document.getDeclaredDocument', $args); |
| 1202 | - if(!$output->toBool()) return $output; |
|
| 1202 | + if (!$output->toBool()) return $output; |
|
| 1203 | 1203 | |
| 1204 | 1204 | $declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0; |
| 1205 | 1205 | |
@@ -1209,7 +1209,7 @@ discard block |
||
| 1209 | 1209 | |
| 1210 | 1210 | // Call a trigger (before) |
| 1211 | 1211 | $trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'before', $trigger_obj); |
| 1212 | - if(!$trigger_output->toBool()) |
|
| 1212 | + if (!$trigger_output->toBool()) |
|
| 1213 | 1213 | { |
| 1214 | 1214 | return $trigger_output; |
| 1215 | 1215 | } |
@@ -1219,19 +1219,19 @@ discard block |
||
| 1219 | 1219 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
| 1220 | 1220 | |
| 1221 | 1221 | // Pass if the author's IP address is as same as visitor's. |
| 1222 | - if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) { |
|
| 1222 | + if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) { |
|
| 1223 | 1223 | $_SESSION['declared_document'][$document_srl] = true; |
| 1224 | 1224 | return new BaseObject(-1, 'failed_declared'); |
| 1225 | 1225 | } |
| 1226 | 1226 | |
| 1227 | 1227 | // Check if document's author is a member. |
| 1228 | - if($oDocument->get('member_srl')) |
|
| 1228 | + if ($oDocument->get('member_srl')) |
|
| 1229 | 1229 | { |
| 1230 | 1230 | // Create a member model object |
| 1231 | 1231 | $oMemberModel = getModel('member'); |
| 1232 | 1232 | $member_srl = $oMemberModel->getLoggedMemberSrl(); |
| 1233 | 1233 | // Pass after registering a session if author's information is same as the currently logged-in user's. |
| 1234 | - if($member_srl && $member_srl == abs($oDocument->get('member_srl'))) |
|
| 1234 | + if ($member_srl && $member_srl == abs($oDocument->get('member_srl'))) |
|
| 1235 | 1235 | { |
| 1236 | 1236 | $_SESSION['declared_document'][$document_srl] = true; |
| 1237 | 1237 | return new BaseObject(-1, 'failed_declared'); |
@@ -1240,7 +1240,7 @@ discard block |
||
| 1240 | 1240 | |
| 1241 | 1241 | // Use member_srl for logged-in members and IP address for non-members. |
| 1242 | 1242 | $args = new stdClass; |
| 1243 | - if($member_srl) |
|
| 1243 | + if ($member_srl) |
|
| 1244 | 1244 | { |
| 1245 | 1245 | $args->member_srl = $member_srl; |
| 1246 | 1246 | } |
@@ -1253,7 +1253,7 @@ discard block |
||
| 1253 | 1253 | $output = executeQuery('document.getDocumentDeclaredLogInfo', $args); |
| 1254 | 1254 | |
| 1255 | 1255 | // Pass after registering a sesson if reported/declared documents are in the logs. |
| 1256 | - if($output->data->count) |
|
| 1256 | + if ($output->data->count) |
|
| 1257 | 1257 | { |
| 1258 | 1258 | $_SESSION['declared_document'][$document_srl] = true; |
| 1259 | 1259 | return new BaseObject(-1, 'failed_declared'); |
@@ -1264,23 +1264,23 @@ discard block |
||
| 1264 | 1264 | $oDB->begin(); |
| 1265 | 1265 | |
| 1266 | 1266 | // Add the declared document |
| 1267 | - if($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args); |
|
| 1267 | + if ($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args); |
|
| 1268 | 1268 | else $output = executeQuery('document.insertDeclaredDocument', $args); |
| 1269 | - if(!$output->toBool()) return $output; |
|
| 1269 | + if (!$output->toBool()) return $output; |
|
| 1270 | 1270 | // Leave logs |
| 1271 | 1271 | $output = executeQuery('document.insertDocumentDeclaredLog', $args); |
| 1272 | - if(!$output->toBool()) |
|
| 1272 | + if (!$output->toBool()) |
|
| 1273 | 1273 | { |
| 1274 | 1274 | $oDB->rollback(); |
| 1275 | 1275 | return $output; |
| 1276 | 1276 | } |
| 1277 | 1277 | |
| 1278 | - $this->add('declared_count', $declared_count+1); |
|
| 1278 | + $this->add('declared_count', $declared_count + 1); |
|
| 1279 | 1279 | |
| 1280 | 1280 | // Call a trigger (after) |
| 1281 | 1281 | $trigger_obj->declared_count = $declared_count + 1; |
| 1282 | 1282 | $trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'after', $trigger_obj); |
| 1283 | - if(!$trigger_output->toBool()) |
|
| 1283 | + if (!$trigger_output->toBool()) |
|
| 1284 | 1284 | { |
| 1285 | 1285 | $oDB->rollback(); |
| 1286 | 1286 | return $trigger_output; |
@@ -1310,16 +1310,16 @@ discard block |
||
| 1310 | 1310 | $args->document_srl = $document_srl; |
| 1311 | 1311 | $args->comment_count = $comment_count; |
| 1312 | 1312 | |
| 1313 | - if($comment_inserted) |
|
| 1313 | + if ($comment_inserted) |
|
| 1314 | 1314 | { |
| 1315 | - $args->update_order = -1*getNextSequence(); |
|
| 1315 | + $args->update_order = -1 * getNextSequence(); |
|
| 1316 | 1316 | $args->last_updater = $last_updater; |
| 1317 | 1317 | |
| 1318 | 1318 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 1319 | - if($oCacheHandler->isSupport()) |
|
| 1319 | + if ($oCacheHandler->isSupport()) |
|
| 1320 | 1320 | { |
| 1321 | 1321 | //remove document item from cache |
| 1322 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
| 1322 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
| 1323 | 1323 | $oCacheHandler->delete($cache_key); |
| 1324 | 1324 | } |
| 1325 | 1325 | } |
@@ -1340,10 +1340,10 @@ discard block |
||
| 1340 | 1340 | $args->trackback_count = $trackback_count; |
| 1341 | 1341 | |
| 1342 | 1342 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 1343 | - if($oCacheHandler->isSupport()) |
|
| 1343 | + if ($oCacheHandler->isSupport()) |
|
| 1344 | 1344 | { |
| 1345 | 1345 | //remove document item from cache |
| 1346 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
| 1346 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
| 1347 | 1347 | $oCacheHandler->delete($cache_key); |
| 1348 | 1348 | } |
| 1349 | 1349 | |
@@ -1358,14 +1358,14 @@ discard block |
||
| 1358 | 1358 | function insertCategory($obj) |
| 1359 | 1359 | { |
| 1360 | 1360 | // Sort the order to display if a child category is added |
| 1361 | - if($obj->parent_srl) |
|
| 1361 | + if ($obj->parent_srl) |
|
| 1362 | 1362 | { |
| 1363 | 1363 | // Get its parent category |
| 1364 | 1364 | $oDocumentModel = getModel('document'); |
| 1365 | 1365 | $parent_category = $oDocumentModel->getCategory($obj->parent_srl); |
| 1366 | 1366 | $obj->list_order = $parent_category->list_order; |
| 1367 | - $this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order+1); |
|
| 1368 | - if(!$obj->category_srl) $obj->category_srl = getNextSequence(); |
|
| 1367 | + $this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order + 1); |
|
| 1368 | + if (!$obj->category_srl) $obj->category_srl = getNextSequence(); |
|
| 1369 | 1369 | } |
| 1370 | 1370 | else |
| 1371 | 1371 | { |
@@ -1373,7 +1373,7 @@ discard block |
||
| 1373 | 1373 | } |
| 1374 | 1374 | |
| 1375 | 1375 | $output = executeQuery('document.insertCategory', $obj); |
| 1376 | - if($output->toBool()) |
|
| 1376 | + if ($output->toBool()) |
|
| 1377 | 1377 | { |
| 1378 | 1378 | $output->add('category_srl', $obj->category_srl); |
| 1379 | 1379 | $this->makeCategoryFile($obj->module_srl); |
@@ -1407,13 +1407,13 @@ discard block |
||
| 1407 | 1407 | { |
| 1408 | 1408 | // Create a document model object |
| 1409 | 1409 | $oDocumentModel = getModel('document'); |
| 1410 | - if(!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl); |
|
| 1410 | + if (!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl, $category_srl); |
|
| 1411 | 1411 | |
| 1412 | 1412 | $args = new stdClass; |
| 1413 | 1413 | $args->category_srl = $category_srl; |
| 1414 | 1414 | $args->document_count = $document_count; |
| 1415 | 1415 | $output = executeQuery('document.updateCategoryCount', $args); |
| 1416 | - if($output->toBool()) $this->makeCategoryFile($module_srl); |
|
| 1416 | + if ($output->toBool()) $this->makeCategoryFile($module_srl); |
|
| 1417 | 1417 | |
| 1418 | 1418 | return $output; |
| 1419 | 1419 | } |
@@ -1426,7 +1426,7 @@ discard block |
||
| 1426 | 1426 | function updateCategory($obj) |
| 1427 | 1427 | { |
| 1428 | 1428 | $output = executeQuery('document.updateCategory', $obj); |
| 1429 | - if($output->toBool()) $this->makeCategoryFile($obj->module_srl); |
|
| 1429 | + if ($output->toBool()) $this->makeCategoryFile($obj->module_srl); |
|
| 1430 | 1430 | return $output; |
| 1431 | 1431 | } |
| 1432 | 1432 | |
@@ -1443,32 +1443,32 @@ discard block |
||
| 1443 | 1443 | $category_info = $oDocumentModel->getCategory($category_srl); |
| 1444 | 1444 | // Display an error that the category cannot be deleted if it has a child |
| 1445 | 1445 | $output = executeQuery('document.getChildCategoryCount', $args); |
| 1446 | - if(!$output->toBool()) return $output; |
|
| 1447 | - if($output->data->count>0) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
| 1446 | + if (!$output->toBool()) return $output; |
|
| 1447 | + if ($output->data->count > 0) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
| 1448 | 1448 | // Delete a category information |
| 1449 | 1449 | $output = executeQuery('document.deleteCategory', $args); |
| 1450 | - if(!$output->toBool()) return $output; |
|
| 1450 | + if (!$output->toBool()) return $output; |
|
| 1451 | 1451 | |
| 1452 | 1452 | $this->makeCategoryFile($category_info->module_srl); |
| 1453 | 1453 | // remvove cache |
| 1454 | 1454 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 1455 | - if($oCacheHandler->isSupport()) |
|
| 1455 | + if ($oCacheHandler->isSupport()) |
|
| 1456 | 1456 | { |
| 1457 | 1457 | $page = 0; |
| 1458 | - while(true) { |
|
| 1458 | + while (true) { |
|
| 1459 | 1459 | $args = new stdClass(); |
| 1460 | 1460 | $args->category_srl = $category_srl; |
| 1461 | 1461 | $args->list_count = 100; |
| 1462 | 1462 | $args->page = ++$page; |
| 1463 | 1463 | $output = executeQuery('document.getDocumentList', $args, array('document_srl')); |
| 1464 | 1464 | |
| 1465 | - if($output->data == array()) |
|
| 1465 | + if ($output->data == array()) |
|
| 1466 | 1466 | break; |
| 1467 | 1467 | |
| 1468 | - foreach($output->data as $val) |
|
| 1468 | + foreach ($output->data as $val) |
|
| 1469 | 1469 | { |
| 1470 | 1470 | //remove document item from cache |
| 1471 | - $cache_key = 'document_item:'. getNumberingPath($val->document_srl) . $val->document_srl; |
|
| 1471 | + $cache_key = 'document_item:'.getNumberingPath($val->document_srl).$val->document_srl; |
|
| 1472 | 1472 | $oCacheHandler->delete($cache_key); |
| 1473 | 1473 | } |
| 1474 | 1474 | } |
@@ -1515,18 +1515,18 @@ discard block |
||
| 1515 | 1515 | // Seek a full list of categories |
| 1516 | 1516 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
| 1517 | 1517 | $category_srl_list = array_keys($category_list); |
| 1518 | - if(count($category_srl_list)<2) return new BaseObject(); |
|
| 1518 | + if (count($category_srl_list) < 2) return new BaseObject(); |
|
| 1519 | 1519 | |
| 1520 | 1520 | $prev_category = NULL; |
| 1521 | - foreach($category_list as $key => $val) |
|
| 1521 | + foreach ($category_list as $key => $val) |
|
| 1522 | 1522 | { |
| 1523 | - if($key==$category_srl) break; |
|
| 1523 | + if ($key == $category_srl) break; |
|
| 1524 | 1524 | $prev_category = $val; |
| 1525 | 1525 | } |
| 1526 | 1526 | // Return if the previous category doesn't exist |
| 1527 | - if(!$prev_category) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
| 1527 | + if (!$prev_category) return new BaseObject(-1, Context::getLang('msg_category_not_moved')); |
|
| 1528 | 1528 | // Return if the selected category is the top level |
| 1529 | - if($category_srl_list[0]==$category_srl) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
| 1529 | + if ($category_srl_list[0] == $category_srl) return new BaseObject(-1, Context::getLang('msg_category_not_moved')); |
|
| 1530 | 1530 | // Information of the selected category |
| 1531 | 1531 | $cur_args = new stdClass; |
| 1532 | 1532 | $cur_args->category_srl = $category_srl; |
@@ -1562,15 +1562,15 @@ discard block |
||
| 1562 | 1562 | // Seek a full list of categories |
| 1563 | 1563 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
| 1564 | 1564 | $category_srl_list = array_keys($category_list); |
| 1565 | - if(count($category_srl_list)<2) return new BaseObject(); |
|
| 1565 | + if (count($category_srl_list) < 2) return new BaseObject(); |
|
| 1566 | 1566 | |
| 1567 | - for($i=0;$i<count($category_srl_list);$i++) |
|
| 1567 | + for ($i = 0; $i < count($category_srl_list); $i++) |
|
| 1568 | 1568 | { |
| 1569 | - if($category_srl_list[$i]==$category_srl) break; |
|
| 1569 | + if ($category_srl_list[$i] == $category_srl) break; |
|
| 1570 | 1570 | } |
| 1571 | 1571 | |
| 1572 | - $next_category_srl = $category_srl_list[$i+1]; |
|
| 1573 | - if(!$category_list[$next_category_srl]) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
| 1572 | + $next_category_srl = $category_srl_list[$i + 1]; |
|
| 1573 | + if (!$category_list[$next_category_srl]) return new BaseObject(-1, Context::getLang('msg_category_not_moved')); |
|
| 1574 | 1574 | $next_category = $category_list[$next_category_srl]; |
| 1575 | 1575 | // Information of the selected category |
| 1576 | 1576 | $cur_args = new stdClass; |
@@ -1597,7 +1597,7 @@ discard block |
||
| 1597 | 1597 | { |
| 1598 | 1598 | $oDocumentModel = getModel('document'); |
| 1599 | 1599 | $extra_keys = $oDocumentModel->getExtraKeys($module_srl); |
| 1600 | - if(!count($extra_keys)) return; |
|
| 1600 | + if (!count($extra_keys)) return; |
|
| 1601 | 1601 | |
| 1602 | 1602 | $js_code = array(); |
| 1603 | 1603 | $js_code[] = '<script>//<![CDATA['; |
@@ -1607,16 +1607,16 @@ discard block |
||
| 1607 | 1607 | |
| 1608 | 1608 | $logged_info = Context::get('logged_info'); |
| 1609 | 1609 | |
| 1610 | - foreach($extra_keys as $idx => $val) |
|
| 1610 | + foreach ($extra_keys as $idx => $val) |
|
| 1611 | 1611 | { |
| 1612 | 1612 | $idx = $val->idx; |
| 1613 | - if($val->type == 'kr_zip') |
|
| 1613 | + if ($val->type == 'kr_zip') |
|
| 1614 | 1614 | { |
| 1615 | 1615 | $idx .= '[]'; |
| 1616 | 1616 | } |
| 1617 | 1617 | $name = str_ireplace(array('<script', '</script'), array('<scr" + "ipt', '</scr" + "ipt'), $val->name); |
| 1618 | 1618 | $js_code[] = sprintf('validator.cast("ADD_MESSAGE", ["extra_vars%s","%s"]);', $idx, $name); |
| 1619 | - if($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
| 1619 | + if ($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
| 1620 | 1620 | } |
| 1621 | 1621 | |
| 1622 | 1622 | $js_code[] = '})(jQuery);'; |
@@ -1634,12 +1634,12 @@ discard block |
||
| 1634 | 1634 | function procDocumentInsertCategory($args = null) |
| 1635 | 1635 | { |
| 1636 | 1636 | // List variables |
| 1637 | - if(!$args) $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid'); |
|
| 1637 | + if (!$args) $args = Context::gets('module_srl', 'category_srl', 'parent_srl', 'category_title', 'category_description', 'expand', 'group_srls', 'category_color', 'mid'); |
|
| 1638 | 1638 | $args->title = $args->category_title; |
| 1639 | 1639 | $args->description = $args->category_description; |
| 1640 | 1640 | $args->color = $args->category_color; |
| 1641 | 1641 | |
| 1642 | - if(!$args->module_srl && $args->mid) |
|
| 1642 | + if (!$args->module_srl && $args->mid) |
|
| 1643 | 1643 | { |
| 1644 | 1644 | $mid = $args->mid; |
| 1645 | 1645 | unset($args->mid); |
@@ -1650,28 +1650,28 @@ discard block |
||
| 1650 | 1650 | $columnList = array('module_srl', 'module'); |
| 1651 | 1651 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
| 1652 | 1652 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1653 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
| 1653 | + if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted'); |
|
| 1654 | 1654 | |
| 1655 | - if($args->expand !="Y") $args->expand = "N"; |
|
| 1656 | - if(!is_array($args->group_srls)) $args->group_srls = str_replace('|@|',',',$args->group_srls); |
|
| 1655 | + if ($args->expand != "Y") $args->expand = "N"; |
|
| 1656 | + if (!is_array($args->group_srls)) $args->group_srls = str_replace('|@|', ',', $args->group_srls); |
|
| 1657 | 1657 | else $args->group_srls = implode(',', $args->group_srls); |
| 1658 | - $args->parent_srl = (int)$args->parent_srl; |
|
| 1658 | + $args->parent_srl = (int) $args->parent_srl; |
|
| 1659 | 1659 | |
| 1660 | 1660 | $oDocumentModel = getModel('document'); |
| 1661 | 1661 | |
| 1662 | 1662 | $oDB = &DB::getInstance(); |
| 1663 | 1663 | $oDB->begin(); |
| 1664 | 1664 | // Check if already exists |
| 1665 | - if($args->category_srl) |
|
| 1665 | + if ($args->category_srl) |
|
| 1666 | 1666 | { |
| 1667 | 1667 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
| 1668 | - if($category_info->category_srl != $args->category_srl) $args->category_srl = null; |
|
| 1668 | + if ($category_info->category_srl != $args->category_srl) $args->category_srl = null; |
|
| 1669 | 1669 | } |
| 1670 | 1670 | // Update if exists |
| 1671 | - if($args->category_srl) |
|
| 1671 | + if ($args->category_srl) |
|
| 1672 | 1672 | { |
| 1673 | 1673 | $output = $this->updateCategory($args); |
| 1674 | - if(!$output->toBool()) |
|
| 1674 | + if (!$output->toBool()) |
|
| 1675 | 1675 | { |
| 1676 | 1676 | $oDB->rollback(); |
| 1677 | 1677 | return $output; |
@@ -1681,7 +1681,7 @@ discard block |
||
| 1681 | 1681 | else |
| 1682 | 1682 | { |
| 1683 | 1683 | $output = $this->insertCategory($args); |
| 1684 | - if(!$output->toBool()) |
|
| 1684 | + if (!$output->toBool()) |
|
| 1685 | 1685 | { |
| 1686 | 1686 | $oDB->rollback(); |
| 1687 | 1687 | return $output; |
@@ -1720,11 +1720,11 @@ discard block |
||
| 1720 | 1720 | $columnList = array('module_srl', 'module'); |
| 1721 | 1721 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($source_category->module_srl, $columnList); |
| 1722 | 1722 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1723 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
| 1723 | + if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted'); |
|
| 1724 | 1724 | |
| 1725 | 1725 | // First child of the parent_category_srl |
| 1726 | 1726 | $source_args = new stdClass; |
| 1727 | - if($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0)) |
|
| 1727 | + if ($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0)) |
|
| 1728 | 1728 | { |
| 1729 | 1729 | $parent_category = $oDocumentModel->getCategory($parent_category_srl); |
| 1730 | 1730 | |
@@ -1733,30 +1733,30 @@ discard block |
||
| 1733 | 1733 | $args->parent_srl = $parent_category_srl; |
| 1734 | 1734 | $output = executeQuery('document.getChildCategoryMinListOrder', $args); |
| 1735 | 1735 | |
| 1736 | - if(!$output->toBool()) return $output; |
|
| 1737 | - $args->list_order = (int)$output->data->list_order; |
|
| 1738 | - if(!$args->list_order) $args->list_order = 0; |
|
| 1736 | + if (!$output->toBool()) return $output; |
|
| 1737 | + $args->list_order = (int) $output->data->list_order; |
|
| 1738 | + if (!$args->list_order) $args->list_order = 0; |
|
| 1739 | 1739 | $args->list_order--; |
| 1740 | 1740 | |
| 1741 | 1741 | $source_args->category_srl = $source_category_srl; |
| 1742 | 1742 | $source_args->parent_srl = $parent_category_srl; |
| 1743 | 1743 | $source_args->list_order = $args->list_order; |
| 1744 | 1744 | $output = $this->updateCategory($source_args); |
| 1745 | - if(!$output->toBool()) return $output; |
|
| 1745 | + if (!$output->toBool()) return $output; |
|
| 1746 | 1746 | // Sibling of the $target_category_srl |
| 1747 | 1747 | } |
| 1748 | - else if($target_category_srl > 0) |
|
| 1748 | + else if ($target_category_srl > 0) |
|
| 1749 | 1749 | { |
| 1750 | 1750 | $target_category = $oDocumentModel->getCategory($target_category_srl); |
| 1751 | 1751 | // Move all siblings of the $target_category down |
| 1752 | - $output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order+1); |
|
| 1753 | - if(!$output->toBool()) return $output; |
|
| 1752 | + $output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order + 1); |
|
| 1753 | + if (!$output->toBool()) return $output; |
|
| 1754 | 1754 | |
| 1755 | 1755 | $source_args->category_srl = $source_category_srl; |
| 1756 | 1756 | $source_args->parent_srl = $target_category->parent_srl; |
| 1757 | - $source_args->list_order = $target_category->list_order+1; |
|
| 1757 | + $source_args->list_order = $target_category->list_order + 1; |
|
| 1758 | 1758 | $output = $this->updateCategory($source_args); |
| 1759 | - if(!$output->toBool()) return $output; |
|
| 1759 | + if (!$output->toBool()) return $output; |
|
| 1760 | 1760 | } |
| 1761 | 1761 | // Re-generate the xml file |
| 1762 | 1762 | $xml_file = $this->makeCategoryFile($source_category->module_srl); |
@@ -1772,7 +1772,7 @@ discard block |
||
| 1772 | 1772 | function procDocumentDeleteCategory() |
| 1773 | 1773 | { |
| 1774 | 1774 | // List variables |
| 1775 | - $args = Context::gets('module_srl','category_srl'); |
|
| 1775 | + $args = Context::gets('module_srl', 'category_srl'); |
|
| 1776 | 1776 | |
| 1777 | 1777 | $oDB = &DB::getInstance(); |
| 1778 | 1778 | $oDB->begin(); |
@@ -1781,17 +1781,17 @@ discard block |
||
| 1781 | 1781 | $columnList = array('module_srl', 'module'); |
| 1782 | 1782 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
| 1783 | 1783 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1784 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
| 1784 | + if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted'); |
|
| 1785 | 1785 | |
| 1786 | 1786 | $oDocumentModel = getModel('document'); |
| 1787 | 1787 | // Get original information |
| 1788 | 1788 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
| 1789 | - if($category_info->parent_srl) $parent_srl = $category_info->parent_srl; |
|
| 1789 | + if ($category_info->parent_srl) $parent_srl = $category_info->parent_srl; |
|
| 1790 | 1790 | // Display an error that the category cannot be deleted if it has a child node |
| 1791 | - if($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
| 1791 | + if ($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
| 1792 | 1792 | // Remove from the DB |
| 1793 | 1793 | $output = $this->deleteCategory($args->category_srl); |
| 1794 | - if(!$output->toBool()) |
|
| 1794 | + if (!$output->toBool()) |
|
| 1795 | 1795 | { |
| 1796 | 1796 | $oDB->rollback(); |
| 1797 | 1797 | return $output; |
@@ -1822,11 +1822,11 @@ discard block |
||
| 1822 | 1822 | $columnList = array('module_srl', 'module'); |
| 1823 | 1823 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
| 1824 | 1824 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1825 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
| 1825 | + if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted'); |
|
| 1826 | 1826 | |
| 1827 | 1827 | $xml_file = $this->makeCategoryFile($module_srl); |
| 1828 | 1828 | // Set return value |
| 1829 | - $this->add('xml_file',$xml_file); |
|
| 1829 | + $this->add('xml_file', $xml_file); |
|
| 1830 | 1830 | } |
| 1831 | 1831 | |
| 1832 | 1832 | /** |
@@ -1837,14 +1837,14 @@ discard block |
||
| 1837 | 1837 | function makeCategoryFile($module_srl) |
| 1838 | 1838 | { |
| 1839 | 1839 | // Return if there is no information you need for creating a cache file |
| 1840 | - if(!$module_srl) return false; |
|
| 1840 | + if (!$module_srl) return false; |
|
| 1841 | 1841 | // Get module information (to obtain mid) |
| 1842 | 1842 | $oModuleModel = getModel('module'); |
| 1843 | 1843 | $columnList = array('module_srl', 'mid', 'site_srl'); |
| 1844 | 1844 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
| 1845 | 1845 | $mid = $module_info->mid; |
| 1846 | 1846 | |
| 1847 | - if(!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category'); |
|
| 1847 | + if (!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category'); |
|
| 1848 | 1848 | // Cache file's name |
| 1849 | 1849 | $xml_file = sprintf("./files/cache/document_category/%s.xml.php", $module_srl); |
| 1850 | 1850 | $php_file = sprintf("./files/cache/document_category/%s.php", $module_srl); |
@@ -1856,17 +1856,17 @@ discard block |
||
| 1856 | 1856 | |
| 1857 | 1857 | $category_list = $output->data; |
| 1858 | 1858 | |
| 1859 | - if(!is_array($category_list)) $category_list = array($category_list); |
|
| 1859 | + if (!is_array($category_list)) $category_list = array($category_list); |
|
| 1860 | 1860 | |
| 1861 | 1861 | $category_count = count($category_list); |
| 1862 | - for($i=0;$i<$category_count;$i++) |
|
| 1862 | + for ($i = 0; $i < $category_count; $i++) |
|
| 1863 | 1863 | { |
| 1864 | 1864 | $category_srl = $category_list[$i]->category_srl; |
| 1865 | - if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = ''; |
|
| 1865 | + if (!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = ''; |
|
| 1866 | 1866 | $list[$category_srl] = $category_list[$i]; |
| 1867 | 1867 | } |
| 1868 | 1868 | // Create the xml file without node data if no data is obtained |
| 1869 | - if(!$list) |
|
| 1869 | + if (!$list) |
|
| 1870 | 1870 | { |
| 1871 | 1871 | $xml_buff = "<root />"; |
| 1872 | 1872 | FileHandler::writeFile($xml_file, $xml_buff); |
@@ -1874,12 +1874,12 @@ discard block |
||
| 1874 | 1874 | return $xml_file; |
| 1875 | 1875 | } |
| 1876 | 1876 | // Change to an array if only a single data is obtained |
| 1877 | - if(!is_array($list)) $list = array($list); |
|
| 1877 | + if (!is_array($list)) $list = array($list); |
|
| 1878 | 1878 | // Create a tree for loop |
| 1879 | - foreach($list as $category_srl => $node) |
|
| 1879 | + foreach ($list as $category_srl => $node) |
|
| 1880 | 1880 | { |
| 1881 | 1881 | $node->mid = $mid; |
| 1882 | - $parent_srl = (int)$node->parent_srl; |
|
| 1882 | + $parent_srl = (int) $node->parent_srl; |
|
| 1883 | 1883 | $tree[$parent_srl][$category_srl] = $node; |
| 1884 | 1884 | } |
| 1885 | 1885 | // A common header to set permissions and groups of the cache file |
@@ -1953,13 +1953,13 @@ discard block |
||
| 1953 | 1953 | */ |
| 1954 | 1954 | function getXmlTree($source_node, $tree, $site_srl, &$xml_header_buff) |
| 1955 | 1955 | { |
| 1956 | - if(!$source_node) return; |
|
| 1956 | + if (!$source_node) return; |
|
| 1957 | 1957 | |
| 1958 | - foreach($source_node as $category_srl => $node) |
|
| 1958 | + foreach ($source_node as $category_srl => $node) |
|
| 1959 | 1959 | { |
| 1960 | 1960 | $child_buff = ""; |
| 1961 | 1961 | // Get data of the child nodes |
| 1962 | - if($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
| 1962 | + if ($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
| 1963 | 1963 | // List variables |
| 1964 | 1964 | $expand = $node->expand; |
| 1965 | 1965 | $group_srls = $node->group_srls; |
@@ -1969,27 +1969,27 @@ discard block |
||
| 1969 | 1969 | $color = $node->color; |
| 1970 | 1970 | $description = $node->description; |
| 1971 | 1971 | // If node->group_srls value exists |
| 1972 | - if($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls); |
|
| 1972 | + if ($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))', $group_srls); |
|
| 1973 | 1973 | else $group_check_code = "true"; |
| 1974 | 1974 | |
| 1975 | 1975 | $title = $node->title; |
| 1976 | 1976 | $oModuleAdminModel = getAdminModel('module'); |
| 1977 | 1977 | |
| 1978 | 1978 | $langs = $oModuleAdminModel->getLangCode($site_srl, $title); |
| 1979 | - if(count($langs)) |
|
| 1979 | + if (count($langs)) |
|
| 1980 | 1980 | { |
| 1981 | - foreach($langs as $key => $val) |
|
| 1981 | + foreach ($langs as $key => $val) |
|
| 1982 | 1982 | { |
| 1983 | - $xml_header_buff .= sprintf('$_titles[%d]["%s"] = %s; ', $category_srl, $key, var_export(str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)), true)); |
|
| 1983 | + $xml_header_buff .= sprintf('$_titles[%d]["%s"] = %s; ', $category_srl, $key, var_export(str_replace('"', '\\"', htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)), true)); |
|
| 1984 | 1984 | } |
| 1985 | 1985 | } |
| 1986 | 1986 | |
| 1987 | 1987 | $langx = $oModuleAdminModel->getLangCode($site_srl, $description); |
| 1988 | - if(count($langx)) |
|
| 1988 | + if (count($langx)) |
|
| 1989 | 1989 | { |
| 1990 | - foreach($langx as $key => $val) |
|
| 1990 | + foreach ($langx as $key => $val) |
|
| 1991 | 1991 | { |
| 1992 | - $xml_header_buff .= sprintf('$_descriptions[%d]["%s"] = %s; ', $category_srl, $key, var_export(str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)), true)); |
|
| 1992 | + $xml_header_buff .= sprintf('$_descriptions[%d]["%s"] = %s; ', $category_srl, $key, var_export(str_replace('"', '\\"', htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)), true)); |
|
| 1993 | 1993 | } |
| 1994 | 1994 | } |
| 1995 | 1995 | |
@@ -2002,7 +2002,7 @@ discard block |
||
| 2002 | 2002 | $category_srl, |
| 2003 | 2003 | $group_check_code, |
| 2004 | 2004 | $category_srl, |
| 2005 | - var_export(getUrl('','mid',$node->mid,'category',$category_srl), true), |
|
| 2005 | + var_export(getUrl('', 'mid', $node->mid, 'category', $category_srl), true), |
|
| 2006 | 2006 | var_export($expand, true), |
| 2007 | 2007 | var_export($color, true), |
| 2008 | 2008 | $group_check_code, |
@@ -2010,8 +2010,8 @@ discard block |
||
| 2010 | 2010 | $node->document_count |
| 2011 | 2011 | ); |
| 2012 | 2012 | |
| 2013 | - if($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
| 2014 | - else $buff .= sprintf('<node %s />', $attribute); |
|
| 2013 | + if ($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
| 2014 | + else $buff .= sprintf('<node %s />', $attribute); |
|
| 2015 | 2015 | } |
| 2016 | 2016 | return $buff; |
| 2017 | 2017 | } |
@@ -2030,13 +2030,13 @@ discard block |
||
| 2030 | 2030 | function getPhpCacheCode($source_node, $tree, $site_srl, &$php_header_buff) |
| 2031 | 2031 | { |
| 2032 | 2032 | $output = array("buff"=>"", "category_srl_list"=>array()); |
| 2033 | - if(!$source_node) return $output; |
|
| 2033 | + if (!$source_node) return $output; |
|
| 2034 | 2034 | |
| 2035 | 2035 | // Set to an arraty for looping and then generate php script codes to be included |
| 2036 | - foreach($source_node as $category_srl => $node) |
|
| 2036 | + foreach ($source_node as $category_srl => $node) |
|
| 2037 | 2037 | { |
| 2038 | 2038 | // Get data from child nodes first if exist. |
| 2039 | - if($category_srl && $tree[$category_srl]){ |
|
| 2039 | + if ($category_srl && $tree[$category_srl]) { |
|
| 2040 | 2040 | $child_output = $this->getPhpCacheCode($tree[$category_srl], $tree, $site_srl, $php_header_buff); |
| 2041 | 2041 | } else { |
| 2042 | 2042 | $child_output = array("buff"=>"", "category_srl_list"=>array()); |
@@ -2047,14 +2047,14 @@ discard block |
||
| 2047 | 2047 | $output['category_srl_list'] = array_merge($output['category_srl_list'], $child_output['category_srl_list']); |
| 2048 | 2048 | |
| 2049 | 2049 | // If node->group_srls value exists |
| 2050 | - if($node->group_srls) { |
|
| 2051 | - $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$node->group_srls); |
|
| 2050 | + if ($node->group_srls) { |
|
| 2051 | + $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))', $node->group_srls); |
|
| 2052 | 2052 | } else { |
| 2053 | 2053 | $group_check_code = "true"; |
| 2054 | 2054 | } |
| 2055 | 2055 | |
| 2056 | 2056 | // List variables |
| 2057 | - $selected = '"' . implode('","', $child_output['category_srl_list']) . '"'; |
|
| 2057 | + $selected = '"'.implode('","', $child_output['category_srl_list']).'"'; |
|
| 2058 | 2058 | $child_buff = $child_output['buff']; |
| 2059 | 2059 | $expand = $node->expand; |
| 2060 | 2060 | |
@@ -2063,32 +2063,32 @@ discard block |
||
| 2063 | 2063 | $oModuleAdminModel = getAdminModel('module'); |
| 2064 | 2064 | $langs = $oModuleAdminModel->getLangCode($site_srl, $title); |
| 2065 | 2065 | |
| 2066 | - if(count($langs)) |
|
| 2066 | + if (count($langs)) |
|
| 2067 | 2067 | { |
| 2068 | - foreach($langs as $key => $val) |
|
| 2068 | + foreach ($langs as $key => $val) |
|
| 2069 | 2069 | { |
| 2070 | 2070 | $val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 2071 | 2071 | $php_header_buff .= sprintf( |
| 2072 | 2072 | '$_titles[%d]["%s"] = %s; ', |
| 2073 | 2073 | $category_srl, |
| 2074 | 2074 | $key, |
| 2075 | - var_export(str_replace('"','\\"', $val), true) |
|
| 2075 | + var_export(str_replace('"', '\\"', $val), true) |
|
| 2076 | 2076 | ); |
| 2077 | 2077 | } |
| 2078 | 2078 | } |
| 2079 | 2079 | |
| 2080 | 2080 | $langx = $oModuleAdminModel->getLangCode($site_srl, $description); |
| 2081 | 2081 | |
| 2082 | - if(count($langx)) |
|
| 2082 | + if (count($langx)) |
|
| 2083 | 2083 | { |
| 2084 | - foreach($langx as $key => $val) |
|
| 2084 | + foreach ($langx as $key => $val) |
|
| 2085 | 2085 | { |
| 2086 | 2086 | $val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 2087 | 2087 | $php_header_buff .= sprintf( |
| 2088 | 2088 | '$_descriptions[%d]["%s"] = %s; ', |
| 2089 | 2089 | $category_srl, |
| 2090 | 2090 | $key, |
| 2091 | - var_export(str_replace('"','\\"', $val), true) |
|
| 2091 | + var_export(str_replace('"', '\\"', $val), true) |
|
| 2092 | 2092 | ); |
| 2093 | 2093 | } |
| 2094 | 2094 | } |
@@ -2112,7 +2112,7 @@ discard block |
||
| 2112 | 2112 | ); |
| 2113 | 2113 | |
| 2114 | 2114 | // Generate buff data |
| 2115 | - $output['buff'] .= sprintf('%s=>array(%s),', $node->category_srl, $attribute); |
|
| 2115 | + $output['buff'] .= sprintf('%s=>array(%s),', $node->category_srl, $attribute); |
|
| 2116 | 2116 | } |
| 2117 | 2117 | |
| 2118 | 2118 | return $output; |
@@ -2129,7 +2129,7 @@ discard block |
||
| 2129 | 2129 | function addDocumentPopupMenu($url, $str, $icon = '', $target = 'self') |
| 2130 | 2130 | { |
| 2131 | 2131 | $document_popup_menu_list = Context::get('document_popup_menu_list'); |
| 2132 | - if(!is_array($document_popup_menu_list)) $document_popup_menu_list = array(); |
|
| 2132 | + if (!is_array($document_popup_menu_list)) $document_popup_menu_list = array(); |
|
| 2133 | 2133 | |
| 2134 | 2134 | $obj = new stdClass(); |
| 2135 | 2135 | $obj->url = $url; |
@@ -2147,68 +2147,68 @@ discard block |
||
| 2147 | 2147 | */ |
| 2148 | 2148 | function procDocumentAddCart() |
| 2149 | 2149 | { |
| 2150 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
| 2150 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
| 2151 | 2151 | |
| 2152 | 2152 | // Get document_srl |
| 2153 | - $srls = explode(',',Context::get('srls')); |
|
| 2154 | - for($i = 0; $i < count($srls); $i++) |
|
| 2153 | + $srls = explode(',', Context::get('srls')); |
|
| 2154 | + for ($i = 0; $i < count($srls); $i++) |
|
| 2155 | 2155 | { |
| 2156 | 2156 | $srl = trim($srls[$i]); |
| 2157 | 2157 | |
| 2158 | - if(!$srl) continue; |
|
| 2158 | + if (!$srl) continue; |
|
| 2159 | 2159 | |
| 2160 | 2160 | $document_srls[] = $srl; |
| 2161 | 2161 | } |
| 2162 | - if(!count($document_srls)) return; |
|
| 2162 | + if (!count($document_srls)) return; |
|
| 2163 | 2163 | |
| 2164 | 2164 | // Get module_srl of the documents |
| 2165 | 2165 | $args = new stdClass; |
| 2166 | 2166 | $args->list_count = count($document_srls); |
| 2167 | - $args->document_srls = implode(',',$document_srls); |
|
| 2167 | + $args->document_srls = implode(',', $document_srls); |
|
| 2168 | 2168 | $args->order_type = 'asc'; |
| 2169 | 2169 | $output = executeQueryArray('document.getDocuments', $args); |
| 2170 | - if(!$output->data) return new BaseObject(); |
|
| 2170 | + if (!$output->data) return new BaseObject(); |
|
| 2171 | 2171 | |
| 2172 | 2172 | unset($document_srls); |
| 2173 | - foreach($output->data as $key => $val) |
|
| 2173 | + foreach ($output->data as $key => $val) |
|
| 2174 | 2174 | { |
| 2175 | 2175 | $document_srls[$val->module_srl][] = $val->document_srl; |
| 2176 | 2176 | } |
| 2177 | - if(!$document_srls || !count($document_srls)) return new BaseObject(); |
|
| 2177 | + if (!$document_srls || !count($document_srls)) return new BaseObject(); |
|
| 2178 | 2178 | |
| 2179 | 2179 | // Check if each of module administrators exists. Top-level administator will have a permission to modify every document of all modules.(Even to modify temporarily saved or trashed documents) |
| 2180 | 2180 | $oModuleModel = getModel('module'); |
| 2181 | 2181 | $module_srls = array_keys($document_srls); |
| 2182 | - for($i=0;$i<count($module_srls);$i++) |
|
| 2182 | + for ($i = 0; $i < count($module_srls); $i++) |
|
| 2183 | 2183 | { |
| 2184 | 2184 | $module_srl = $module_srls[$i]; |
| 2185 | 2185 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); |
| 2186 | 2186 | $logged_info = Context::get('logged_info'); |
| 2187 | - if($logged_info->is_admin != 'Y') |
|
| 2187 | + if ($logged_info->is_admin != 'Y') |
|
| 2188 | 2188 | { |
| 2189 | - if(!$module_info) |
|
| 2189 | + if (!$module_info) |
|
| 2190 | 2190 | { |
| 2191 | 2191 | unset($document_srls[$module_srl]); |
| 2192 | 2192 | continue; |
| 2193 | 2193 | } |
| 2194 | 2194 | $grant = $oModuleModel->getGrant($module_info, $logged_info); |
| 2195 | - if(!$grant->manager) |
|
| 2195 | + if (!$grant->manager) |
|
| 2196 | 2196 | { |
| 2197 | 2197 | unset($document_srls[$module_srl]); |
| 2198 | 2198 | continue; |
| 2199 | 2199 | } |
| 2200 | 2200 | } |
| 2201 | 2201 | } |
| 2202 | - if(!count($document_srls)) return new BaseObject(); |
|
| 2202 | + if (!count($document_srls)) return new BaseObject(); |
|
| 2203 | 2203 | |
| 2204 | - foreach($document_srls as $module_srl => $documents) |
|
| 2204 | + foreach ($document_srls as $module_srl => $documents) |
|
| 2205 | 2205 | { |
| 2206 | 2206 | $cnt = count($documents); |
| 2207 | - for($i=0;$i<$cnt;$i++) |
|
| 2207 | + for ($i = 0; $i < $cnt; $i++) |
|
| 2208 | 2208 | { |
| 2209 | - $document_srl = (int)trim($documents[$i]); |
|
| 2210 | - if(!$document_srls) continue; |
|
| 2211 | - if($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]); |
|
| 2209 | + $document_srl = (int) trim($documents[$i]); |
|
| 2210 | + if (!$document_srls) continue; |
|
| 2211 | + if ($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]); |
|
| 2212 | 2212 | else $_SESSION['document_management'][$document_srl] = true; |
| 2213 | 2213 | } |
| 2214 | 2214 | } |
@@ -2221,9 +2221,9 @@ discard block |
||
| 2221 | 2221 | function procDocumentManageCheckedDocument() |
| 2222 | 2222 | { |
| 2223 | 2223 | @set_time_limit(0); |
| 2224 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
| 2224 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
| 2225 | 2225 | |
| 2226 | - if(!checkCSRF()) |
|
| 2226 | + if (!checkCSRF()) |
|
| 2227 | 2227 | { |
| 2228 | 2228 | return new BaseObject(-1, 'msg_invalid_request'); |
| 2229 | 2229 | } |
@@ -2231,44 +2231,44 @@ discard block |
||
| 2231 | 2231 | $type = Context::get('type'); |
| 2232 | 2232 | $target_module = Context::get('target_module'); |
| 2233 | 2233 | $module_srl = Context::get('module_srl'); |
| 2234 | - if($target_module && !$module_srl) $module_srl = $target_module; |
|
| 2234 | + if ($target_module && !$module_srl) $module_srl = $target_module; |
|
| 2235 | 2235 | $category_srl = Context::get('target_category'); |
| 2236 | 2236 | $message_content = Context::get('message_content'); |
| 2237 | - if($message_content) $message_content = nl2br($message_content); |
|
| 2237 | + if ($message_content) $message_content = nl2br($message_content); |
|
| 2238 | 2238 | |
| 2239 | 2239 | $cart = Context::get('cart'); |
| 2240 | - if(!is_array($cart)) $document_srl_list = explode('|@|', $cart); |
|
| 2240 | + if (!is_array($cart)) $document_srl_list = explode('|@|', $cart); |
|
| 2241 | 2241 | else $document_srl_list = $cart; |
| 2242 | 2242 | |
| 2243 | 2243 | $document_srl_count = count($document_srl_list); |
| 2244 | 2244 | |
| 2245 | 2245 | $oDocumentModel = getModel('document'); |
| 2246 | 2246 | $document_items = array(); |
| 2247 | - foreach($document_srl_list as $document_srl) |
|
| 2247 | + foreach ($document_srl_list as $document_srl) |
|
| 2248 | 2248 | { |
| 2249 | 2249 | $oDocument = $oDocumentModel->getDocument($document_srl); |
| 2250 | 2250 | $document_items[] = $oDocument; |
| 2251 | - if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted'); |
|
| 2251 | + if (!$oDocument->isGranted()) return $this->stop('msg_not_permitted'); |
|
| 2252 | 2252 | } |
| 2253 | 2253 | |
| 2254 | 2254 | // Send a message |
| 2255 | - if($message_content) |
|
| 2255 | + if ($message_content) |
|
| 2256 | 2256 | { |
| 2257 | 2257 | |
| 2258 | 2258 | $oCommunicationController = getController('communication'); |
| 2259 | 2259 | |
| 2260 | 2260 | $logged_info = Context::get('logged_info'); |
| 2261 | 2261 | |
| 2262 | - $title = cut_str($message_content,10,'...'); |
|
| 2262 | + $title = cut_str($message_content, 10, '...'); |
|
| 2263 | 2263 | $sender_member_srl = $logged_info->member_srl; |
| 2264 | 2264 | |
| 2265 | - foreach($document_items as $oDocument) |
|
| 2265 | + foreach ($document_items as $oDocument) |
|
| 2266 | 2266 | { |
| 2267 | - if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) continue; |
|
| 2267 | + if (!$oDocument->get('member_srl') || $oDocument->get('member_srl') == $sender_member_srl) continue; |
|
| 2268 | 2268 | |
| 2269 | - if($type=='move') $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
| 2269 | + if ($type == 'move') $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
| 2270 | 2270 | else $purl = ""; |
| 2271 | - $content = sprintf("<div>%s</div><hr />%s<div style=\"font-weight:bold\">%s</div>%s",$message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false)); |
|
| 2271 | + $content = sprintf("<div>%s</div><hr />%s<div style=\"font-weight:bold\">%s</div>%s", $message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false)); |
|
| 2272 | 2272 | |
| 2273 | 2273 | $oCommunicationController->sendMessage($sender_member_srl, $oDocument->get('member_srl'), $title, $content, false); |
| 2274 | 2274 | } |
@@ -2278,54 +2278,54 @@ discard block |
||
| 2278 | 2278 | $oSpamController->setAvoidLog(); |
| 2279 | 2279 | |
| 2280 | 2280 | $oDocumentAdminController = getAdminController('document'); |
| 2281 | - if($type == 'move') |
|
| 2281 | + if ($type == 'move') |
|
| 2282 | 2282 | { |
| 2283 | - if(!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
| 2283 | + if (!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
| 2284 | 2284 | |
| 2285 | 2285 | $output = $oDocumentAdminController->moveDocumentModule($document_srl_list, $module_srl, $category_srl); |
| 2286 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
| 2286 | + if (!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
| 2287 | 2287 | |
| 2288 | 2288 | $msg_code = 'success_moved'; |
| 2289 | 2289 | |
| 2290 | 2290 | } |
| 2291 | - else if($type == 'copy') |
|
| 2291 | + else if ($type == 'copy') |
|
| 2292 | 2292 | { |
| 2293 | - if(!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
| 2293 | + if (!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
| 2294 | 2294 | |
| 2295 | 2295 | $output = $oDocumentAdminController->copyDocumentModule($document_srl_list, $module_srl, $category_srl); |
| 2296 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
| 2296 | + if (!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
| 2297 | 2297 | |
| 2298 | 2298 | $msg_code = 'success_copied'; |
| 2299 | 2299 | } |
| 2300 | - else if($type =='delete') |
|
| 2300 | + else if ($type == 'delete') |
|
| 2301 | 2301 | { |
| 2302 | 2302 | $oDB = &DB::getInstance(); |
| 2303 | 2303 | $oDB->begin(); |
| 2304 | - for($i=0;$i<$document_srl_count;$i++) |
|
| 2304 | + for ($i = 0; $i < $document_srl_count; $i++) |
|
| 2305 | 2305 | { |
| 2306 | 2306 | $document_srl = $document_srl_list[$i]; |
| 2307 | 2307 | $output = $this->deleteDocument($document_srl, true); |
| 2308 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_delete'); |
|
| 2308 | + if (!$output->toBool()) return new BaseObject(-1, 'fail_to_delete'); |
|
| 2309 | 2309 | } |
| 2310 | 2310 | $oDB->commit(); |
| 2311 | 2311 | $msg_code = 'success_deleted'; |
| 2312 | 2312 | } |
| 2313 | - else if($type == 'trash') |
|
| 2313 | + else if ($type == 'trash') |
|
| 2314 | 2314 | { |
| 2315 | 2315 | $args = new stdClass(); |
| 2316 | 2316 | $args->description = $message_content; |
| 2317 | 2317 | |
| 2318 | 2318 | $oDB = &DB::getInstance(); |
| 2319 | 2319 | $oDB->begin(); |
| 2320 | - for($i=0;$i<$document_srl_count;$i++) { |
|
| 2320 | + for ($i = 0; $i < $document_srl_count; $i++) { |
|
| 2321 | 2321 | $args->document_srl = $document_srl_list[$i]; |
| 2322 | 2322 | $output = $this->moveDocumentToTrash($args); |
| 2323 | - if(!$output || !$output->toBool()) return new BaseObject(-1, 'fail_to_trash'); |
|
| 2323 | + if (!$output || !$output->toBool()) return new BaseObject(-1, 'fail_to_trash'); |
|
| 2324 | 2324 | } |
| 2325 | 2325 | $oDB->commit(); |
| 2326 | 2326 | $msg_code = 'success_trashed'; |
| 2327 | 2327 | } |
| 2328 | - else if($type == 'cancelDeclare') |
|
| 2328 | + else if ($type == 'cancelDeclare') |
|
| 2329 | 2329 | { |
| 2330 | 2330 | $args->document_srl = $document_srl_list; |
| 2331 | 2331 | $output = executeQuery('document.deleteDeclaredDocuments', $args); |
@@ -2347,27 +2347,27 @@ discard block |
||
| 2347 | 2347 | function procDocumentInsertModuleConfig() |
| 2348 | 2348 | { |
| 2349 | 2349 | $module_srl = Context::get('target_module_srl'); |
| 2350 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
| 2350 | + if (preg_match('/^([0-9,]+)$/', $module_srl)) $module_srl = explode(',', $module_srl); |
|
| 2351 | 2351 | else $module_srl = array($module_srl); |
| 2352 | 2352 | |
| 2353 | 2353 | $document_config = new stdClass(); |
| 2354 | 2354 | $document_config->use_history = Context::get('use_history'); |
| 2355 | - if(!$document_config->use_history) $document_config->use_history = 'N'; |
|
| 2355 | + if (!$document_config->use_history) $document_config->use_history = 'N'; |
|
| 2356 | 2356 | |
| 2357 | 2357 | $document_config->use_vote_up = Context::get('use_vote_up'); |
| 2358 | - if(!$document_config->use_vote_up) $document_config->use_vote_up = 'Y'; |
|
| 2358 | + if (!$document_config->use_vote_up) $document_config->use_vote_up = 'Y'; |
|
| 2359 | 2359 | |
| 2360 | 2360 | $document_config->use_vote_down = Context::get('use_vote_down'); |
| 2361 | - if(!$document_config->use_vote_down) $document_config->use_vote_down = 'Y'; |
|
| 2361 | + if (!$document_config->use_vote_down) $document_config->use_vote_down = 'Y'; |
|
| 2362 | 2362 | |
| 2363 | 2363 | $document_config->use_status = Context::get('use_status'); |
| 2364 | 2364 | |
| 2365 | 2365 | $oModuleController = getController('module'); |
| 2366 | - for($i=0;$i<count($module_srl);$i++) |
|
| 2366 | + for ($i = 0; $i < count($module_srl); $i++) |
|
| 2367 | 2367 | { |
| 2368 | 2368 | $srl = trim($module_srl[$i]); |
| 2369 | - if(!$srl) continue; |
|
| 2370 | - $output = $oModuleController->insertModulePartConfig('document',$srl,$document_config); |
|
| 2369 | + if (!$srl) continue; |
|
| 2370 | + $output = $oModuleController->insertModulePartConfig('document', $srl, $document_config); |
|
| 2371 | 2371 | } |
| 2372 | 2372 | $this->setError(-1); |
| 2373 | 2373 | $this->setMessage('success_updated', 'info'); |
@@ -2383,7 +2383,7 @@ discard block |
||
| 2383 | 2383 | function procDocumentTempSave() |
| 2384 | 2384 | { |
| 2385 | 2385 | // Check login information |
| 2386 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_logged'); |
|
| 2386 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_logged'); |
|
| 2387 | 2387 | $module_info = Context::get('module_info'); |
| 2388 | 2388 | $logged_info = Context::get('logged_info'); |
| 2389 | 2389 | |
@@ -2395,7 +2395,7 @@ discard block |
||
| 2395 | 2395 | unset($obj->is_notice); |
| 2396 | 2396 | |
| 2397 | 2397 | // Extract from beginning part of contents in the guestbook |
| 2398 | - if(!$obj->title) |
|
| 2398 | + if (!$obj->title) |
|
| 2399 | 2399 | { |
| 2400 | 2400 | $obj->title = cut_str(strip_tags($obj->content), 20, '...'); |
| 2401 | 2401 | } |
@@ -2406,13 +2406,13 @@ discard block |
||
| 2406 | 2406 | $oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager); |
| 2407 | 2407 | |
| 2408 | 2408 | // Update if already exists |
| 2409 | - if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl) |
|
| 2409 | + if ($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl) |
|
| 2410 | 2410 | { |
| 2411 | - if($oDocument->get('module_srl') != $obj->module_srl) |
|
| 2411 | + if ($oDocument->get('module_srl') != $obj->module_srl) |
|
| 2412 | 2412 | { |
| 2413 | 2413 | return new BaseObject(-1, 'msg_invalid_request'); |
| 2414 | 2414 | } |
| 2415 | - if(!$oDocument->isGranted()) |
|
| 2415 | + if (!$oDocument->isGranted()) |
|
| 2416 | 2416 | { |
| 2417 | 2417 | return new BaseObject(-1, 'msg_invalid_request'); |
| 2418 | 2418 | } |
@@ -2430,7 +2430,7 @@ discard block |
||
| 2430 | 2430 | $oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager); |
| 2431 | 2431 | } |
| 2432 | 2432 | // Set the attachment to be invalid state |
| 2433 | - if($oDocument->hasUploadedFiles()) |
|
| 2433 | + if ($oDocument->hasUploadedFiles()) |
|
| 2434 | 2434 | { |
| 2435 | 2435 | $args = new stdClass; |
| 2436 | 2436 | $args->upload_target_srl = $oDocument->document_srl; |
@@ -2448,11 +2448,11 @@ discard block |
||
| 2448 | 2448 | */ |
| 2449 | 2449 | function procDocumentGetList() |
| 2450 | 2450 | { |
| 2451 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
| 2451 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
| 2452 | 2452 | $documentSrls = Context::get('document_srls'); |
| 2453 | - if($documentSrls) $documentSrlList = explode(',', $documentSrls); |
|
| 2453 | + if ($documentSrls) $documentSrlList = explode(',', $documentSrls); |
|
| 2454 | 2454 | |
| 2455 | - if(count($documentSrlList) > 0) |
|
| 2455 | + if (count($documentSrlList) > 0) |
|
| 2456 | 2456 | { |
| 2457 | 2457 | $oDocumentModel = getModel('document'); |
| 2458 | 2458 | $columnList = array('document_srl', 'title', 'nick_name', 'status'); |
@@ -2476,10 +2476,10 @@ discard block |
||
| 2476 | 2476 | */ |
| 2477 | 2477 | function _checkCommentStatusForOldVersion(&$obj) |
| 2478 | 2478 | { |
| 2479 | - if(!isset($obj->allow_comment)) $obj->allow_comment = 'N'; |
|
| 2480 | - if(!isset($obj->lock_comment)) $obj->lock_comment = 'N'; |
|
| 2479 | + if (!isset($obj->allow_comment)) $obj->allow_comment = 'N'; |
|
| 2480 | + if (!isset($obj->lock_comment)) $obj->lock_comment = 'N'; |
|
| 2481 | 2481 | |
| 2482 | - if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW'; |
|
| 2482 | + if ($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW'; |
|
| 2483 | 2483 | else $obj->commentStatus = 'DENY'; |
| 2484 | 2484 | } |
| 2485 | 2485 | |
@@ -2490,8 +2490,8 @@ discard block |
||
| 2490 | 2490 | */ |
| 2491 | 2491 | function _checkDocumentStatusForOldVersion(&$obj) |
| 2492 | 2492 | { |
| 2493 | - if(!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret'); |
|
| 2494 | - if(!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public'); |
|
| 2493 | + if (!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret'); |
|
| 2494 | + if (!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public'); |
|
| 2495 | 2495 | } |
| 2496 | 2496 | |
| 2497 | 2497 | public function updateUploaedCount($documentSrlList) |
@@ -2499,10 +2499,10 @@ discard block |
||
| 2499 | 2499 | $oDocumentModel = getModel('document'); |
| 2500 | 2500 | $oFileModel = getModel('file'); |
| 2501 | 2501 | |
| 2502 | - if(is_array($documentSrlList)) |
|
| 2502 | + if (is_array($documentSrlList)) |
|
| 2503 | 2503 | { |
| 2504 | 2504 | $documentSrlList = array_unique($documentSrlList); |
| 2505 | - foreach($documentSrlList AS $key => $documentSrl) |
|
| 2505 | + foreach ($documentSrlList AS $key => $documentSrl) |
|
| 2506 | 2506 | { |
| 2507 | 2507 | $fileCount = $oFileModel->getFilesCount($documentSrl); |
| 2508 | 2508 | $args = new stdClass(); |
@@ -2523,14 +2523,14 @@ discard block |
||
| 2523 | 2523 | $oDocumentModel = getModel('document'); |
| 2524 | 2524 | $documentExtraKeys = $oDocumentModel->getExtraKeys($obj->originModuleSrl); |
| 2525 | 2525 | |
| 2526 | - if(is_array($documentExtraKeys) && is_array($obj->moduleSrlList)) |
|
| 2526 | + if (is_array($documentExtraKeys) && is_array($obj->moduleSrlList)) |
|
| 2527 | 2527 | { |
| 2528 | - $oDocumentController=getController('document'); |
|
| 2529 | - foreach($obj->moduleSrlList AS $key=>$value) |
|
| 2528 | + $oDocumentController = getController('document'); |
|
| 2529 | + foreach ($obj->moduleSrlList AS $key=>$value) |
|
| 2530 | 2530 | { |
| 2531 | - foreach($documentExtraKeys AS $extraItem) |
|
| 2531 | + foreach ($documentExtraKeys AS $extraItem) |
|
| 2532 | 2532 | { |
| 2533 | - $oDocumentController->insertDocumentExtraKey($value, $extraItem->idx, $extraItem->name, $extraItem->type, $extraItem->is_required , $extraItem->search , $extraItem->default , $extraItem->desc, $extraItem->eid) ; |
|
| 2533 | + $oDocumentController->insertDocumentExtraKey($value, $extraItem->idx, $extraItem->name, $extraItem->type, $extraItem->is_required, $extraItem->search, $extraItem->default, $extraItem->desc, $extraItem->eid); |
|
| 2534 | 2534 | } |
| 2535 | 2535 | } |
| 2536 | 2536 | } |
@@ -2542,9 +2542,9 @@ discard block |
||
| 2542 | 2542 | $documentConfig = $oModuleModel->getModulePartConfig('document', $obj->originModuleSrl); |
| 2543 | 2543 | |
| 2544 | 2544 | $oModuleController = getController('module'); |
| 2545 | - if(is_array($obj->moduleSrlList)) |
|
| 2545 | + if (is_array($obj->moduleSrlList)) |
|
| 2546 | 2546 | { |
| 2547 | - foreach($obj->moduleSrlList AS $key=>$moduleSrl) |
|
| 2547 | + foreach ($obj->moduleSrlList AS $key=>$moduleSrl) |
|
| 2548 | 2548 | { |
| 2549 | 2549 | $oModuleController->insertModulePartConfig('document', $moduleSrl, $documentConfig); |
| 2550 | 2550 | } |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | /** |
| 497 | 497 | * Show pop-up menu of the selected posts |
| 498 | 498 | * Printing, scrap, recommendations and negative, reported the Add Features |
| 499 | - * @return void |
|
| 499 | + * @return BaseObject|null |
|
| 500 | 500 | */ |
| 501 | 501 | function getDocumentMenu() |
| 502 | 502 | { |
@@ -1266,7 +1266,7 @@ discard block |
||
| 1266 | 1266 | * Setting sort index |
| 1267 | 1267 | * @param object $obj |
| 1268 | 1268 | * @param bool $load_extra_vars |
| 1269 | - * @return object |
|
| 1269 | + * @return stdClass |
|
| 1270 | 1270 | */ |
| 1271 | 1271 | function _setSortIndex($obj, $load_extra_vars) |
| 1272 | 1272 | { |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | function getDocumentExtraVarsFromDB($documentSrls) |
| 39 | 39 | { |
| 40 | - if(!is_array($documentSrls) || count($documentSrls) == 0) |
|
| 40 | + if (!is_array($documentSrls) || count($documentSrls) == 0) |
|
| 41 | 41 | { |
| 42 | 42 | return new BaseObject(-1, 'msg_invalid_request'); |
| 43 | 43 | } |
@@ -58,52 +58,52 @@ discard block |
||
| 58 | 58 | $_document_list = &$GLOBALS['XE_DOCUMENT_LIST']; |
| 59 | 59 | |
| 60 | 60 | // XE XE_DOCUMENT_LIST all documents that the object referred to the global variable settings |
| 61 | - if(count($_document_list) <= 0) return; |
|
| 61 | + if (count($_document_list) <= 0) return; |
|
| 62 | 62 | |
| 63 | 63 | // Find all called the document object variable has been set extension |
| 64 | 64 | $document_srls = array(); |
| 65 | - foreach($_document_list as $key => $val) |
|
| 65 | + foreach ($_document_list as $key => $val) |
|
| 66 | 66 | { |
| 67 | - if(!$val->document_srl || $checked_documents[$val->document_srl]) continue; |
|
| 67 | + if (!$val->document_srl || $checked_documents[$val->document_srl]) continue; |
|
| 68 | 68 | $checked_documents[$val->document_srl] = true; |
| 69 | 69 | $document_srls[] = $val->document_srl; |
| 70 | 70 | } |
| 71 | 71 | // If the document number, return detected |
| 72 | - if(!count($document_srls)) return; |
|
| 72 | + if (!count($document_srls)) return; |
|
| 73 | 73 | // Expand variables mijijeongdoen article about a current visitor to the extension of the language code, the search variable |
| 74 | 74 | //$obj->document_srl = implode(',',$document_srls); |
| 75 | 75 | $output = $this->getDocumentExtraVarsFromDB($document_srls); |
| 76 | - if($output->toBool() && $output->data) |
|
| 76 | + if ($output->toBool() && $output->data) |
|
| 77 | 77 | { |
| 78 | - foreach($output->data as $key => $val) |
|
| 78 | + foreach ($output->data as $key => $val) |
|
| 79 | 79 | { |
| 80 | - if(!isset($val->value)) continue; |
|
| 81 | - if(!$extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0]) $extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0] = trim($val->value); |
|
| 80 | + if (!isset($val->value)) continue; |
|
| 81 | + if (!$extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0]) $extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0] = trim($val->value); |
|
| 82 | 82 | $extra_vars[$val->document_srl][$val->var_idx][$val->lang_code] = trim($val->value); |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | $user_lang_code = Context::getLangType(); |
| 87 | - for($i=0,$c=count($document_srls);$i<$c;$i++) |
|
| 87 | + for ($i = 0, $c = count($document_srls); $i < $c; $i++) |
|
| 88 | 88 | { |
| 89 | 89 | $document_srl = $document_srls[$i]; |
| 90 | 90 | unset($vars); |
| 91 | 91 | |
| 92 | - if(!$_document_list[$document_srl] || !is_object($_document_list[$document_srl]) || !$_document_list[$document_srl]->isExists()) continue; |
|
| 92 | + if (!$_document_list[$document_srl] || !is_object($_document_list[$document_srl]) || !$_document_list[$document_srl]->isExists()) continue; |
|
| 93 | 93 | $module_srl = $_document_list[$document_srl]->get('module_srl'); |
| 94 | 94 | $extra_keys = $this->getExtraKeys($module_srl); |
| 95 | 95 | $vars = $extra_vars[$document_srl]; |
| 96 | 96 | $document_lang_code = $_document_list[$document_srl]->get('lang_code'); |
| 97 | 97 | // Expand the variable processing |
| 98 | - if(count($extra_keys)) |
|
| 98 | + if (count($extra_keys)) |
|
| 99 | 99 | { |
| 100 | - foreach($extra_keys as $idx => $key) |
|
| 100 | + foreach ($extra_keys as $idx => $key) |
|
| 101 | 101 | { |
| 102 | 102 | $extra_keys[$idx] = clone($key); |
| 103 | 103 | $val = $vars[$idx]; |
| 104 | - if(isset($val[$user_lang_code])) $v = $val[$user_lang_code]; |
|
| 105 | - else if(isset($val[$document_lang_code])) $v = $val[$document_lang_code]; |
|
| 106 | - else if(isset($val[0])) $v = $val[0]; |
|
| 104 | + if (isset($val[$user_lang_code])) $v = $val[$user_lang_code]; |
|
| 105 | + else if (isset($val[$document_lang_code])) $v = $val[$document_lang_code]; |
|
| 106 | + else if (isset($val[0])) $v = $val[0]; |
|
| 107 | 107 | else $v = null; |
| 108 | 108 | $extra_keys[$idx]->value = $v; |
| 109 | 109 | } |
@@ -113,11 +113,11 @@ discard block |
||
| 113 | 113 | $evars = new ExtraVar($module_srl); |
| 114 | 114 | $evars->setExtraVarKeys($extra_keys); |
| 115 | 115 | // Title Processing |
| 116 | - if($vars[-1][$user_lang_code]) $_document_list[$document_srl]->add('title',$vars[-1][$user_lang_code]); |
|
| 116 | + if ($vars[-1][$user_lang_code]) $_document_list[$document_srl]->add('title', $vars[-1][$user_lang_code]); |
|
| 117 | 117 | // Information processing |
| 118 | - if($vars[-2][$user_lang_code]) $_document_list[$document_srl]->add('content',$vars[-2][$user_lang_code]); |
|
| 118 | + if ($vars[-2][$user_lang_code]) $_document_list[$document_srl]->add('content', $vars[-2][$user_lang_code]); |
|
| 119 | 119 | |
| 120 | - if($vars[-1][$user_lang_code] || $vars[-2][$user_lang_code]) |
|
| 120 | + if ($vars[-1][$user_lang_code] || $vars[-2][$user_lang_code]) |
|
| 121 | 121 | { |
| 122 | 122 | unset($checked_documents[$document_srl]); |
| 123 | 123 | } |
@@ -134,17 +134,17 @@ discard block |
||
| 134 | 134 | * @param array $columnList |
| 135 | 135 | * @return documentItem |
| 136 | 136 | */ |
| 137 | - function getDocument($document_srl=0, $is_admin = false, $load_extra_vars=true, $columnList = array()) |
|
| 137 | + function getDocument($document_srl = 0, $is_admin = false, $load_extra_vars = true, $columnList = array()) |
|
| 138 | 138 | { |
| 139 | - if(!$document_srl) return new documentItem(); |
|
| 139 | + if (!$document_srl) return new documentItem(); |
|
| 140 | 140 | |
| 141 | - if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
| 141 | + if (!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
| 142 | 142 | { |
| 143 | 143 | $oDocument = new documentItem($document_srl, $load_extra_vars, $columnList); |
| 144 | 144 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
| 145 | - if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
| 145 | + if ($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
| 146 | 146 | } |
| 147 | - if($is_admin) $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->setGrant(); |
|
| 147 | + if ($is_admin) $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->setGrant(); |
|
| 148 | 148 | |
| 149 | 149 | return $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
| 150 | 150 | } |
@@ -157,12 +157,12 @@ discard block |
||
| 157 | 157 | * @param array $columnList |
| 158 | 158 | * @return array value type is documentItem |
| 159 | 159 | */ |
| 160 | - function getDocuments($document_srls, $is_admin = false, $load_extra_vars=true, $columnList = array()) |
|
| 160 | + function getDocuments($document_srls, $is_admin = false, $load_extra_vars = true, $columnList = array()) |
|
| 161 | 161 | { |
| 162 | - if(is_array($document_srls)) |
|
| 162 | + if (is_array($document_srls)) |
|
| 163 | 163 | { |
| 164 | 164 | $list_count = count($document_srls); |
| 165 | - $document_srls = implode(',',$document_srls); |
|
| 165 | + $document_srls = implode(',', $document_srls); |
|
| 166 | 166 | } |
| 167 | 167 | else |
| 168 | 168 | { |
@@ -175,33 +175,33 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | $output = executeQuery('document.getDocuments', $args, $columnList); |
| 177 | 177 | $document_list = $output->data; |
| 178 | - if(!$document_list) return; |
|
| 179 | - if(!is_array($document_list)) $document_list = array($document_list); |
|
| 178 | + if (!$document_list) return; |
|
| 179 | + if (!is_array($document_list)) $document_list = array($document_list); |
|
| 180 | 180 | |
| 181 | 181 | $document_count = count($document_list); |
| 182 | - foreach($document_list as $key => $attribute) |
|
| 182 | + foreach ($document_list as $key => $attribute) |
|
| 183 | 183 | { |
| 184 | 184 | $document_srl = $attribute->document_srl; |
| 185 | - if(!$document_srl) continue; |
|
| 185 | + if (!$document_srl) continue; |
|
| 186 | 186 | |
| 187 | - if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
| 187 | + if (!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
| 188 | 188 | { |
| 189 | 189 | $oDocument = null; |
| 190 | 190 | $oDocument = new documentItem(); |
| 191 | 191 | $oDocument->setAttribute($attribute, false); |
| 192 | - if($is_admin) $oDocument->setGrant(); |
|
| 192 | + if ($is_admin) $oDocument->setGrant(); |
|
| 193 | 193 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | $result[$attribute->document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
| 199 | + if ($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
| 200 | 200 | |
| 201 | 201 | $output = null; |
| 202 | - if(count($result)) |
|
| 202 | + if (count($result)) |
|
| 203 | 203 | { |
| 204 | - foreach($result as $document_srl => $val) |
|
| 204 | + foreach ($result as $document_srl => $val) |
|
| 205 | 205 | { |
| 206 | 206 | $output[$document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
| 207 | 207 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | * @param array $columnList |
| 219 | 219 | * @return BaseObject |
| 220 | 220 | */ |
| 221 | - function getDocumentList($obj, $except_notice = false, $load_extra_vars=true, $columnList = array()) |
|
| 221 | + function getDocumentList($obj, $except_notice = false, $load_extra_vars = true, $columnList = array()) |
|
| 222 | 222 | { |
| 223 | 223 | $sort_check = $this->_setSortIndex($obj, $load_extra_vars); |
| 224 | 224 | $obj->sort_index = $sort_check->sort_index; |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | // Call trigger (before) |
| 229 | 229 | // This trigger can be used to set an alternative output using a different search method |
| 230 | 230 | $output = ModuleHandler::triggerCall('document.getDocumentList', 'before', $obj); |
| 231 | - if($output instanceof BaseObject && !$output->toBool()) |
|
| 231 | + if ($output instanceof BaseObject && !$output->toBool()) |
|
| 232 | 232 | { |
| 233 | 233 | return $output; |
| 234 | 234 | } |
@@ -245,10 +245,10 @@ discard block |
||
| 245 | 245 | $output = $obj->use_alternate_output; |
| 246 | 246 | unset($obj->use_alternate_output); |
| 247 | 247 | } |
| 248 | - elseif ($sort_check->isExtraVars && substr_count($obj->search_target,'extra_vars')) |
|
| 248 | + elseif ($sort_check->isExtraVars && substr_count($obj->search_target, 'extra_vars')) |
|
| 249 | 249 | { |
| 250 | 250 | $query_id = 'document.getDocumentListWithinExtraVarsExtraSort'; |
| 251 | - $args->sort_index = str_replace('documents.','',$args->sort_index); |
|
| 251 | + $args->sort_index = str_replace('documents.', '', $args->sort_index); |
|
| 252 | 252 | $output = executeQueryArray($query_id, $args); |
| 253 | 253 | } |
| 254 | 254 | elseif ($sort_check->isExtraVars) |
@@ -260,16 +260,16 @@ discard block |
||
| 260 | 260 | // document.getDocumentList query execution |
| 261 | 261 | // Query_id if you have a group by clause getDocumentListWithinTag getDocumentListWithinComment or used again to perform the query because |
| 262 | 262 | $groupByQuery = array('document.getDocumentListWithinComment' => 1, 'document.getDocumentListWithinTag' => 1, 'document.getDocumentListWithinExtraVars' => 1); |
| 263 | - if(isset($groupByQuery[$query_id])) |
|
| 263 | + if (isset($groupByQuery[$query_id])) |
|
| 264 | 264 | { |
| 265 | 265 | $group_args = clone($args); |
| 266 | 266 | $group_args->sort_index = 'documents.'.$args->sort_index; |
| 267 | 267 | $output = executeQueryArray($query_id, $group_args); |
| 268 | - if(!$output->toBool()||!count($output->data)) return $output; |
|
| 268 | + if (!$output->toBool() || !count($output->data)) return $output; |
|
| 269 | 269 | |
| 270 | - foreach($output->data as $key => $val) |
|
| 270 | + foreach ($output->data as $key => $val) |
|
| 271 | 271 | { |
| 272 | - if($val->document_srl) $target_srls[] = $val->document_srl; |
|
| 272 | + if ($val->document_srl) $target_srls[] = $val->document_srl; |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | $page_navigation = $output->page_navigation; |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | $virtual_number = $keys[0]; |
| 278 | 278 | |
| 279 | 279 | $target_args = new stdClass(); |
| 280 | - $target_args->document_srls = implode(',',$target_srls); |
|
| 280 | + $target_args->document_srls = implode(',', $target_srls); |
|
| 281 | 281 | $target_args->list_order = $args->sort_index; |
| 282 | 282 | $target_args->order_type = $args->order_type; |
| 283 | 283 | $target_args->list_count = $args->list_count; |
@@ -294,35 +294,35 @@ discard block |
||
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | // Return if no result or an error occurs |
| 297 | - if(!$output->toBool()||!count($output->data)) return $output; |
|
| 297 | + if (!$output->toBool() || !count($output->data)) return $output; |
|
| 298 | 298 | $idx = 0; |
| 299 | 299 | $data = $output->data; |
| 300 | 300 | unset($output->data); |
| 301 | 301 | |
| 302 | - if(!isset($virtual_number)) |
|
| 302 | + if (!isset($virtual_number)) |
|
| 303 | 303 | { |
| 304 | 304 | $keys = array_keys($data); |
| 305 | 305 | $virtual_number = $keys[0]; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - if($except_notice) |
|
| 308 | + if ($except_notice) |
|
| 309 | 309 | { |
| 310 | - foreach($data as $key => $attribute) |
|
| 310 | + foreach ($data as $key => $attribute) |
|
| 311 | 311 | { |
| 312 | - if($attribute->is_notice == 'Y') $virtual_number --; |
|
| 312 | + if ($attribute->is_notice == 'Y') $virtual_number--; |
|
| 313 | 313 | } |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - foreach($data as $key => $attribute) |
|
| 316 | + foreach ($data as $key => $attribute) |
|
| 317 | 317 | { |
| 318 | - if($except_notice && $attribute->is_notice == 'Y') continue; |
|
| 318 | + if ($except_notice && $attribute->is_notice == 'Y') continue; |
|
| 319 | 319 | $document_srl = $attribute->document_srl; |
| 320 | - if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
| 320 | + if (!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
| 321 | 321 | { |
| 322 | 322 | $oDocument = null; |
| 323 | 323 | $oDocument = new documentItem(); |
| 324 | 324 | $oDocument->setAttribute($attribute, false); |
| 325 | - if($is_admin) $oDocument->setGrant(); |
|
| 325 | + if ($is_admin) $oDocument->setGrant(); |
|
| 326 | 326 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
| 327 | 327 | } |
| 328 | 328 | |
@@ -330,11 +330,11 @@ discard block |
||
| 330 | 330 | $virtual_number--; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
| 333 | + if ($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
| 334 | 334 | |
| 335 | - if(count($output->data)) |
|
| 335 | + if (count($output->data)) |
|
| 336 | 336 | { |
| 337 | - foreach($output->data as $number => $document) |
|
| 337 | + foreach ($output->data as $number => $document) |
|
| 338 | 338 | { |
| 339 | 339 | $output->data[$number] = $GLOBALS['XE_DOCUMENT_LIST'][$document->document_srl]; |
| 340 | 340 | } |
@@ -356,16 +356,16 @@ discard block |
||
| 356 | 356 | { |
| 357 | 357 | $args = new stdClass(); |
| 358 | 358 | $args->module_srl = $obj->module_srl; |
| 359 | - $args->category_srl= $obj->category_srl; |
|
| 359 | + $args->category_srl = $obj->category_srl; |
|
| 360 | 360 | $output = executeQueryArray('document.getNoticeList', $args, $columnList); |
| 361 | - if(!$output->toBool()||!$output->data) return; |
|
| 361 | + if (!$output->toBool() || !$output->data) return; |
|
| 362 | 362 | |
| 363 | - foreach($output->data as $key => $val) |
|
| 363 | + foreach ($output->data as $key => $val) |
|
| 364 | 364 | { |
| 365 | 365 | $document_srl = $val->document_srl; |
| 366 | - if(!$document_srl) continue; |
|
| 366 | + if (!$document_srl) continue; |
|
| 367 | 367 | |
| 368 | - if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
| 368 | + if (!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
| 369 | 369 | { |
| 370 | 370 | $oDocument = null; |
| 371 | 371 | $oDocument = new documentItem(); |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | } |
| 377 | 377 | $this->setToAllDocumentExtraVars(); |
| 378 | 378 | |
| 379 | - foreach($result->data as $document_srl => $val) |
|
| 379 | + foreach ($result->data as $document_srl => $val) |
|
| 380 | 380 | { |
| 381 | 381 | $result->data[$document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
| 382 | 382 | } |
@@ -392,20 +392,20 @@ discard block |
||
| 392 | 392 | */ |
| 393 | 393 | function getExtraKeys($module_srl) |
| 394 | 394 | { |
| 395 | - if(!isset($GLOBALS['XE_EXTRA_KEYS'][$module_srl])) |
|
| 395 | + if (!isset($GLOBALS['XE_EXTRA_KEYS'][$module_srl])) |
|
| 396 | 396 | { |
| 397 | 397 | $keys = false; |
| 398 | 398 | $oCacheHandler = CacheHandler::getInstance('object', null, true); |
| 399 | - if($oCacheHandler->isSupport()) |
|
| 399 | + if ($oCacheHandler->isSupport()) |
|
| 400 | 400 | { |
| 401 | - $object_key = 'module_document_extra_keys:' . $module_srl; |
|
| 401 | + $object_key = 'module_document_extra_keys:'.$module_srl; |
|
| 402 | 402 | $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
| 403 | 403 | $keys = $oCacheHandler->get($cache_key); |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | $oExtraVar = ExtraVar::getInstance($module_srl); |
| 407 | 407 | |
| 408 | - if($keys === false) |
|
| 408 | + if ($keys === false) |
|
| 409 | 409 | { |
| 410 | 410 | $obj = new stdClass(); |
| 411 | 411 | $obj->module_srl = $module_srl; |
@@ -415,13 +415,13 @@ discard block |
||
| 415 | 415 | |
| 416 | 416 | // correcting index order |
| 417 | 417 | $isFixed = FALSE; |
| 418 | - if(is_array($output->data)) |
|
| 418 | + if (is_array($output->data)) |
|
| 419 | 419 | { |
| 420 | 420 | $prevIdx = 0; |
| 421 | - foreach($output->data as $no => $value) |
|
| 421 | + foreach ($output->data as $no => $value) |
|
| 422 | 422 | { |
| 423 | 423 | // case first |
| 424 | - if($prevIdx == 0 && $value->idx != 1) |
|
| 424 | + if ($prevIdx == 0 && $value->idx != 1) |
|
| 425 | 425 | { |
| 426 | 426 | $args = new stdClass(); |
| 427 | 427 | $args->module_srl = $module_srl; |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | // case others |
| 438 | - if($prevIdx > 0 && $prevIdx + 1 != $value->idx) |
|
| 438 | + if ($prevIdx > 0 && $prevIdx + 1 != $value->idx) |
|
| 439 | 439 | { |
| 440 | 440 | $args = new stdClass(); |
| 441 | 441 | $args->module_srl = $module_srl; |
@@ -452,16 +452,16 @@ discard block |
||
| 452 | 452 | } |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - if($isFixed) |
|
| 455 | + if ($isFixed) |
|
| 456 | 456 | { |
| 457 | 457 | $output = executeQueryArray('document.getDocumentExtraKeys', $obj); |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | $oExtraVar->setExtraVarKeys($output->data); |
| 461 | 461 | $keys = $oExtraVar->getExtraVars(); |
| 462 | - if(!$keys) $keys = array(); |
|
| 462 | + if (!$keys) $keys = array(); |
|
| 463 | 463 | |
| 464 | - if($oCacheHandler->isSupport()) |
|
| 464 | + if ($oCacheHandler->isSupport()) |
|
| 465 | 465 | { |
| 466 | 466 | $oCacheHandler->put($cache_key, $keys); |
| 467 | 467 | } |
@@ -482,14 +482,14 @@ discard block |
||
| 482 | 482 | */ |
| 483 | 483 | function getExtraVars($module_srl, $document_srl) |
| 484 | 484 | { |
| 485 | - if(!isset($GLOBALS['XE_EXTRA_VARS'][$document_srl])) |
|
| 485 | + if (!isset($GLOBALS['XE_EXTRA_VARS'][$document_srl])) |
|
| 486 | 486 | { |
| 487 | 487 | // Extended to extract the values of variables set |
| 488 | 488 | $oDocument = $this->getDocument($document_srl, false); |
| 489 | 489 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
| 490 | 490 | $this->setToAllDocumentExtraVars(); |
| 491 | 491 | } |
| 492 | - if(is_array($GLOBALS['XE_EXTRA_VARS'][$document_srl])) ksort($GLOBALS['XE_EXTRA_VARS'][$document_srl]); |
|
| 492 | + if (is_array($GLOBALS['XE_EXTRA_VARS'][$document_srl])) ksort($GLOBALS['XE_EXTRA_VARS'][$document_srl]); |
|
| 493 | 493 | return $GLOBALS['XE_EXTRA_VARS'][$document_srl]; |
| 494 | 494 | } |
| 495 | 495 | |
@@ -512,71 +512,71 @@ discard block |
||
| 512 | 512 | |
| 513 | 513 | $oDocumentController = getController('document'); |
| 514 | 514 | // Members must be a possible feature |
| 515 | - if($logged_info->member_srl) |
|
| 515 | + if ($logged_info->member_srl) |
|
| 516 | 516 | { |
| 517 | 517 | $oDocumentModel = getModel('document'); |
| 518 | 518 | $columnList = array('document_srl', 'module_srl', 'member_srl', 'ipaddress'); |
| 519 | 519 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList); |
| 520 | 520 | $module_srl = $oDocument->get('module_srl'); |
| 521 | 521 | $member_srl = $oDocument->get('member_srl'); |
| 522 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 522 | + if (!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 523 | 523 | |
| 524 | 524 | $oModuleModel = getModel('module'); |
| 525 | - $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
|
| 526 | - if($document_config->use_vote_up!='N' && $member_srl!=$logged_info->member_srl) |
|
| 525 | + $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
|
| 526 | + if ($document_config->use_vote_up != 'N' && $member_srl != $logged_info->member_srl) |
|
| 527 | 527 | { |
| 528 | 528 | // Add a Referral Button |
| 529 | 529 | $url = sprintf("doCallModuleAction('document','procDocumentVoteUp','%s')", $document_srl); |
| 530 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_vote','','javascript'); |
|
| 530 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_vote', '', 'javascript'); |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | - if($document_config->use_vote_down!='N' && $member_srl!=$logged_info->member_srl) |
|
| 533 | + if ($document_config->use_vote_down != 'N' && $member_srl != $logged_info->member_srl) |
|
| 534 | 534 | { |
| 535 | 535 | // Add button to negative |
| 536 | - $url= sprintf("doCallModuleAction('document','procDocumentVoteDown','%s')", $document_srl); |
|
| 537 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_vote_down','','javascript'); |
|
| 536 | + $url = sprintf("doCallModuleAction('document','procDocumentVoteDown','%s')", $document_srl); |
|
| 537 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_vote_down', '', 'javascript'); |
|
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | // Adding Report |
| 541 | 541 | $url = sprintf("doCallModuleAction('document','procDocumentDeclare','%s')", $document_srl); |
| 542 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_declare','','javascript'); |
|
| 542 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_declare', '', 'javascript'); |
|
| 543 | 543 | |
| 544 | 544 | // Add Bookmark button |
| 545 | 545 | $url = sprintf("doCallModuleAction('member','procMemberScrapDocument','%s')", $document_srl); |
| 546 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_scrap','','javascript'); |
|
| 546 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_scrap', '', 'javascript'); |
|
| 547 | 547 | } |
| 548 | 548 | // Add print button |
| 549 | - $url = getUrl('','module','document','act','dispDocumentPrint','document_srl',$document_srl); |
|
| 550 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_print','','printDocument'); |
|
| 549 | + $url = getUrl('', 'module', 'document', 'act', 'dispDocumentPrint', 'document_srl', $document_srl); |
|
| 550 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_print', '', 'printDocument'); |
|
| 551 | 551 | // Call a trigger (after) |
| 552 | 552 | ModuleHandler::triggerCall('document.getDocumentMenu', 'after', $menu_list); |
| 553 | - if($this->grant->manager) |
|
| 553 | + if ($this->grant->manager) |
|
| 554 | 554 | { |
| 555 | 555 | $str_confirm = Context::getLang('confirm_move'); |
| 556 | 556 | $url = sprintf("if(!confirm('%s')) return; var params = new Array(); params['document_srl']='%s'; params['mid']=current_mid;params['cur_url']=current_url; exec_xml('document', 'procDocumentAdminMoveToTrash', params)", $str_confirm, $document_srl); |
| 557 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_trash','','javascript'); |
|
| 557 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_trash', '', 'javascript'); |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | // If you are managing to find posts by ip |
| 561 | - if($logged_info->is_admin == 'Y') |
|
| 561 | + if ($logged_info->is_admin == 'Y') |
|
| 562 | 562 | { |
| 563 | 563 | $oDocumentModel = getModel('document'); |
| 564 | - $oDocument = $oDocumentModel->getDocument($document_srl); //before setting document recycle |
|
| 564 | + $oDocument = $oDocumentModel->getDocument($document_srl); //before setting document recycle |
|
| 565 | 565 | |
| 566 | - if($oDocument->isExists()) |
|
| 566 | + if ($oDocument->isExists()) |
|
| 567 | 567 | { |
| 568 | 568 | // Find a post equivalent to ip address |
| 569 | - $url = getUrl('','module','admin','act','dispDocumentAdminList','search_target','ipaddress','search_keyword',$oDocument->getIpAddress()); |
|
| 570 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_search_by_ipaddress',$icon_path,'TraceByIpaddress'); |
|
| 569 | + $url = getUrl('', 'module', 'admin', 'act', 'dispDocumentAdminList', 'search_target', 'ipaddress', 'search_keyword', $oDocument->getIpAddress()); |
|
| 570 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_search_by_ipaddress', $icon_path, 'TraceByIpaddress'); |
|
| 571 | 571 | |
| 572 | 572 | $url = sprintf("var params = new Array(); params['ipaddress_list']='%s'; exec_xml('spamfilter', 'procSpamfilterAdminInsertDeniedIP', params, completeCallModuleAction)", $oDocument->getIpAddress()); |
| 573 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_add_ip_to_spamfilter','','javascript'); |
|
| 573 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_add_ip_to_spamfilter', '', 'javascript'); |
|
| 574 | 574 | } |
| 575 | 575 | } |
| 576 | 576 | // Changing the language of pop-up menu |
| 577 | 577 | $menus = Context::get('document_popup_menu_list'); |
| 578 | 578 | $menus_count = count($menus); |
| 579 | - for($i=0;$i<$menus_count;$i++) |
|
| 579 | + for ($i = 0; $i < $menus_count; $i++) |
|
| 580 | 580 | { |
| 581 | 581 | $menus[$i]->str = Context::getLang($menus[$i]->str); |
| 582 | 582 | } |
@@ -592,13 +592,13 @@ discard block |
||
| 592 | 592 | */ |
| 593 | 593 | function getDocumentCount($module_srl, $search_obj = NULL) |
| 594 | 594 | { |
| 595 | - if(is_null($search_obj)) $search_obj = new stdClass(); |
|
| 595 | + if (is_null($search_obj)) $search_obj = new stdClass(); |
|
| 596 | 596 | $search_obj->module_srl = $module_srl; |
| 597 | 597 | |
| 598 | 598 | $output = executeQuery('document.getDocumentCount', $search_obj); |
| 599 | 599 | // Return total number of |
| 600 | 600 | $total_count = $output->data->count; |
| 601 | - return (int)$total_count; |
|
| 601 | + return (int) $total_count; |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | /** |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | function getDocumentCountByGroupStatus($search_obj = NULL) |
| 610 | 610 | { |
| 611 | 611 | $output = executeQuery('document.getDocumentCountByGroupStatus', $search_obj); |
| 612 | - if(!$output->toBool()) return array(); |
|
| 612 | + if (!$output->toBool()) return array(); |
|
| 613 | 613 | |
| 614 | 614 | return $output->data; |
| 615 | 615 | } |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | $output = executeQuery('document.getDocumentExtraVarsCount', $args); |
| 629 | 629 | // Return total number of |
| 630 | 630 | $total_count = $output->data->count; |
| 631 | - return (int)$total_count; |
|
| 631 | + return (int) $total_count; |
|
| 632 | 632 | } |
| 633 | 633 | |
| 634 | 634 | /** |
@@ -645,29 +645,29 @@ discard block |
||
| 645 | 645 | |
| 646 | 646 | $this->_setSearchOption($opt, $args, $query_id, $use_division); |
| 647 | 647 | |
| 648 | - if($sort_check->isExtraVars) |
|
| 648 | + if ($sort_check->isExtraVars) |
|
| 649 | 649 | { |
| 650 | 650 | return 1; |
| 651 | 651 | } |
| 652 | 652 | else |
| 653 | 653 | { |
| 654 | - if($sort_check->sort_index === 'list_order' || $sort_check->sort_index === 'update_order') |
|
| 654 | + if ($sort_check->sort_index === 'list_order' || $sort_check->sort_index === 'update_order') |
|
| 655 | 655 | { |
| 656 | - if($args->order_type === 'desc') |
|
| 656 | + if ($args->order_type === 'desc') |
|
| 657 | 657 | { |
| 658 | - $args->{'rev_' . $sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
|
| 658 | + $args->{'rev_'.$sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
|
| 659 | 659 | } |
| 660 | 660 | else |
| 661 | 661 | { |
| 662 | 662 | $args->{$sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
| 663 | 663 | } |
| 664 | 664 | } |
| 665 | - elseif($sort_check->sort_index === 'regdate') |
|
| 665 | + elseif ($sort_check->sort_index === 'regdate') |
|
| 666 | 666 | { |
| 667 | 667 | |
| 668 | - if($args->order_type === 'asc') |
|
| 668 | + if ($args->order_type === 'asc') |
|
| 669 | 669 | { |
| 670 | - $args->{'rev_' . $sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
|
| 670 | + $args->{'rev_'.$sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
|
| 671 | 671 | } |
| 672 | 672 | else |
| 673 | 673 | { |
@@ -682,9 +682,9 @@ discard block |
||
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | // Guhanhu total number of the article search page |
| 685 | - $output = executeQuery($query_id . 'Page', $args); |
|
| 685 | + $output = executeQuery($query_id.'Page', $args); |
|
| 686 | 686 | $count = $output->data->count; |
| 687 | - $page = (int)(($count-1)/$opt->list_count)+1; |
|
| 687 | + $page = (int) (($count - 1) / $opt->list_count) + 1; |
|
| 688 | 688 | return $page; |
| 689 | 689 | } |
| 690 | 690 | |
@@ -696,16 +696,16 @@ discard block |
||
| 696 | 696 | */ |
| 697 | 697 | function getCategory($category_srl, $columnList = array()) |
| 698 | 698 | { |
| 699 | - $args =new stdClass(); |
|
| 699 | + $args = new stdClass(); |
|
| 700 | 700 | $args->category_srl = $category_srl; |
| 701 | 701 | $output = executeQuery('document.getCategory', $args, $columnList); |
| 702 | 702 | |
| 703 | 703 | $node = $output->data; |
| 704 | - if(!$node) return; |
|
| 704 | + if (!$node) return; |
|
| 705 | 705 | |
| 706 | - if($node->group_srls) |
|
| 706 | + if ($node->group_srls) |
|
| 707 | 707 | { |
| 708 | - $group_srls = explode(',',$node->group_srls); |
|
| 708 | + $group_srls = explode(',', $node->group_srls); |
|
| 709 | 709 | unset($node->group_srls); |
| 710 | 710 | $node->group_srls = $group_srls; |
| 711 | 711 | } |
@@ -726,8 +726,8 @@ discard block |
||
| 726 | 726 | { |
| 727 | 727 | $args = new stdClass(); |
| 728 | 728 | $args->category_srl = $category_srl; |
| 729 | - $output = executeQuery('document.getChildCategoryCount',$args); |
|
| 730 | - if($output->data->count > 0) return true; |
|
| 729 | + $output = executeQuery('document.getChildCategoryCount', $args); |
|
| 730 | + if ($output->data->count > 0) return true; |
|
| 731 | 731 | return false; |
| 732 | 732 | } |
| 733 | 733 | |
@@ -743,10 +743,10 @@ discard block |
||
| 743 | 743 | // Category of the target module file swollen |
| 744 | 744 | $filename = sprintf("%sfiles/cache/document_category/%s.php", _XE_PATH_, $module_srl); |
| 745 | 745 | // If the target file to the cache file regeneration category |
| 746 | - if(!file_exists($filename)) |
|
| 746 | + if (!file_exists($filename)) |
|
| 747 | 747 | { |
| 748 | 748 | $oDocumentController = getController('document'); |
| 749 | - if(!$oDocumentController->makeCategoryFile($module_srl)) return array(); |
|
| 749 | + if (!$oDocumentController->makeCategoryFile($module_srl)) return array(); |
|
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | include($filename); |
@@ -766,10 +766,10 @@ discard block |
||
| 766 | 766 | */ |
| 767 | 767 | function _arrangeCategory(&$document_category, $list, $depth) |
| 768 | 768 | { |
| 769 | - if(!count($list)) return; |
|
| 769 | + if (!count($list)) return; |
|
| 770 | 770 | $idx = 0; |
| 771 | 771 | $list_order = array(); |
| 772 | - foreach($list as $key => $val) |
|
| 772 | + foreach ($list as $key => $val) |
|
| 773 | 773 | { |
| 774 | 774 | $obj = new stdClass; |
| 775 | 775 | $obj->mid = $val['mid']; |
@@ -778,7 +778,7 @@ discard block |
||
| 778 | 778 | $obj->parent_srl = $val['parent_srl']; |
| 779 | 779 | $obj->title = $obj->text = $val['text']; |
| 780 | 780 | $obj->description = $val['description']; |
| 781 | - $obj->expand = $val['expand']=='Y'?true:false; |
|
| 781 | + $obj->expand = $val['expand'] == 'Y' ?true:false; |
|
| 782 | 782 | $obj->color = $val['color']; |
| 783 | 783 | $obj->document_count = $val['document_count']; |
| 784 | 784 | $obj->depth = $depth; |
@@ -786,26 +786,26 @@ discard block |
||
| 786 | 786 | $obj->childs = array(); |
| 787 | 787 | $obj->grant = $val['grant']; |
| 788 | 788 | |
| 789 | - if(Context::get('mid') == $obj->mid && Context::get('category') == $obj->category_srl) $selected = true; |
|
| 789 | + if (Context::get('mid') == $obj->mid && Context::get('category') == $obj->category_srl) $selected = true; |
|
| 790 | 790 | else $selected = false; |
| 791 | 791 | |
| 792 | 792 | $obj->selected = $selected; |
| 793 | 793 | |
| 794 | 794 | $list_order[$idx++] = $obj->category_srl; |
| 795 | 795 | // If you have a parent category of child nodes apply data |
| 796 | - if($obj->parent_srl) |
|
| 796 | + if ($obj->parent_srl) |
|
| 797 | 797 | { |
| 798 | 798 | $parent_srl = $obj->parent_srl; |
| 799 | 799 | $document_count = $obj->document_count; |
| 800 | 800 | $expand = $obj->expand; |
| 801 | - if($selected) $expand = true; |
|
| 801 | + if ($selected) $expand = true; |
|
| 802 | 802 | |
| 803 | - while($parent_srl) |
|
| 803 | + while ($parent_srl) |
|
| 804 | 804 | { |
| 805 | 805 | $document_category[$parent_srl]->document_count += $document_count; |
| 806 | 806 | $document_category[$parent_srl]->childs[] = $obj->category_srl; |
| 807 | 807 | $document_category[$parent_srl]->child_count = count($document_category[$parent_srl]->childs); |
| 808 | - if($expand) $document_category[$parent_srl]->expand = $expand; |
|
| 808 | + if ($expand) $document_category[$parent_srl]->expand = $expand; |
|
| 809 | 809 | |
| 810 | 810 | $parent_srl = $document_category[$parent_srl]->parent_srl; |
| 811 | 811 | } |
@@ -813,10 +813,10 @@ discard block |
||
| 813 | 813 | |
| 814 | 814 | $document_category[$key] = $obj; |
| 815 | 815 | |
| 816 | - if(count($val['list'])) $this->_arrangeCategory($document_category, $val['list'], $depth+1); |
|
| 816 | + if (count($val['list'])) $this->_arrangeCategory($document_category, $val['list'], $depth + 1); |
|
| 817 | 817 | } |
| 818 | 818 | $document_category[$list_order[0]]->first = true; |
| 819 | - $document_category[$list_order[count($list_order)-1]]->last = true; |
|
| 819 | + $document_category[$list_order[count($list_order) - 1]]->last = true; |
|
| 820 | 820 | } |
| 821 | 821 | |
| 822 | 822 | /** |
@@ -831,7 +831,7 @@ discard block |
||
| 831 | 831 | $args->module_srl = $module_srl; |
| 832 | 832 | $args->category_srl = $category_srl; |
| 833 | 833 | $output = executeQuery('document.getCategoryDocumentCount', $args); |
| 834 | - return (int)$output->data->count; |
|
| 834 | + return (int) $output->data->count; |
|
| 835 | 835 | } |
| 836 | 836 | |
| 837 | 837 | /** |
@@ -841,8 +841,8 @@ discard block |
||
| 841 | 841 | */ |
| 842 | 842 | function getCategoryXmlFile($module_srl) |
| 843 | 843 | { |
| 844 | - $xml_file = sprintf('files/cache/document_category/%s.xml.php',$module_srl); |
|
| 845 | - if(!file_exists($xml_file)) |
|
| 844 | + $xml_file = sprintf('files/cache/document_category/%s.xml.php', $module_srl); |
|
| 845 | + if (!file_exists($xml_file)) |
|
| 846 | 846 | { |
| 847 | 847 | $oDocumentController = getController('document'); |
| 848 | 848 | $oDocumentController->makeCategoryFile($module_srl); |
@@ -857,8 +857,8 @@ discard block |
||
| 857 | 857 | */ |
| 858 | 858 | function getCategoryPhpFile($module_srl) |
| 859 | 859 | { |
| 860 | - $php_file = sprintf('files/cache/document_category/%s.php',$module_srl); |
|
| 861 | - if(!file_exists($php_file)) |
|
| 860 | + $php_file = sprintf('files/cache/document_category/%s.php', $module_srl); |
|
| 861 | + if (!file_exists($php_file)) |
|
| 862 | 862 | { |
| 863 | 863 | $oDocumentController = getController('document'); |
| 864 | 864 | $oDocumentController->makeCategoryFile($module_srl); |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | */ |
| 874 | 874 | function getMonthlyArchivedList($obj) |
| 875 | 875 | { |
| 876 | - if($obj->mid) |
|
| 876 | + if ($obj->mid) |
|
| 877 | 877 | { |
| 878 | 878 | $oModuleModel = getModel('module'); |
| 879 | 879 | $obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid); |
@@ -881,13 +881,13 @@ discard block |
||
| 881 | 881 | } |
| 882 | 882 | // Module_srl passed the array may be a check whether the array |
| 883 | 883 | $args = new stdClass; |
| 884 | - if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
| 884 | + if (is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
| 885 | 885 | else $args->module_srl = $obj->module_srl; |
| 886 | 886 | |
| 887 | 887 | $output = executeQuery('document.getMonthlyArchivedList', $args); |
| 888 | - if(!$output->toBool()||!$output->data) return $output; |
|
| 888 | + if (!$output->toBool() || !$output->data) return $output; |
|
| 889 | 889 | |
| 890 | - if(!is_array($output->data)) $output->data = array($output->data); |
|
| 890 | + if (!is_array($output->data)) $output->data = array($output->data); |
|
| 891 | 891 | |
| 892 | 892 | return $output; |
| 893 | 893 | } |
@@ -899,7 +899,7 @@ discard block |
||
| 899 | 899 | */ |
| 900 | 900 | function getDailyArchivedList($obj) |
| 901 | 901 | { |
| 902 | - if($obj->mid) |
|
| 902 | + if ($obj->mid) |
|
| 903 | 903 | { |
| 904 | 904 | $oModuleModel = getModel('module'); |
| 905 | 905 | $obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid); |
@@ -907,14 +907,14 @@ discard block |
||
| 907 | 907 | } |
| 908 | 908 | // Module_srl passed the array may be a check whether the array |
| 909 | 909 | $args = new stdClass; |
| 910 | - if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
| 910 | + if (is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
| 911 | 911 | else $args->module_srl = $obj->module_srl; |
| 912 | 912 | $args->regdate = $obj->regdate; |
| 913 | 913 | |
| 914 | 914 | $output = executeQuery('document.getDailyArchivedList', $args); |
| 915 | - if(!$output->toBool()) return $output; |
|
| 915 | + if (!$output->toBool()) return $output; |
|
| 916 | 916 | |
| 917 | - if(!is_array($output->data)) $output->data = array($output->data); |
|
| 917 | + if (!is_array($output->data)) $output->data = array($output->data); |
|
| 918 | 918 | |
| 919 | 919 | return $output; |
| 920 | 920 | } |
@@ -925,17 +925,17 @@ discard block |
||
| 925 | 925 | */ |
| 926 | 926 | function getDocumentCategories() |
| 927 | 927 | { |
| 928 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
| 928 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
| 929 | 929 | $module_srl = Context::get('module_srl'); |
| 930 | - $categories= $this->getCategoryList($module_srl); |
|
| 930 | + $categories = $this->getCategoryList($module_srl); |
|
| 931 | 931 | $lang = Context::get('lang'); |
| 932 | 932 | // No additional category |
| 933 | 933 | $output = "0,0,{$lang->none_category}\n"; |
| 934 | - if($categories) |
|
| 934 | + if ($categories) |
|
| 935 | 935 | { |
| 936 | - foreach($categories as $category_srl => $category) |
|
| 936 | + foreach ($categories as $category_srl => $category) |
|
| 937 | 937 | { |
| 938 | - $output .= sprintf("%d,%d,%s\n",$category_srl, $category->depth,$category->title); |
|
| 938 | + $output .= sprintf("%d,%d,%s\n", $category_srl, $category->depth, $category->title); |
|
| 939 | 939 | } |
| 940 | 940 | } |
| 941 | 941 | $this->add('categories', $output); |
@@ -947,7 +947,7 @@ discard block |
||
| 947 | 947 | */ |
| 948 | 948 | function getDocumentConfig() |
| 949 | 949 | { |
| 950 | - if($this->documentConfig === NULL) |
|
| 950 | + if ($this->documentConfig === NULL) |
|
| 951 | 951 | { |
| 952 | 952 | $oModuleModel = getModel('module'); |
| 953 | 953 | $config = $oModuleModel->getModuleConfig('document'); |
@@ -1020,11 +1020,11 @@ discard block |
||
| 1020 | 1020 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); |
| 1021 | 1021 | // Check permissions |
| 1022 | 1022 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1023 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
| 1023 | + if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted'); |
|
| 1024 | 1024 | |
| 1025 | 1025 | $category_srl = Context::get('category_srl'); |
| 1026 | 1026 | $category_info = $this->getCategory($category_srl); |
| 1027 | - if(!$category_info) |
|
| 1027 | + if (!$category_info) |
|
| 1028 | 1028 | { |
| 1029 | 1029 | return new BaseObject(-1, 'msg_invalid_request'); |
| 1030 | 1030 | } |
@@ -1040,14 +1040,14 @@ discard block |
||
| 1040 | 1040 | */ |
| 1041 | 1041 | function getDocumentSrlByAlias($mid, $alias) |
| 1042 | 1042 | { |
| 1043 | - if(!$mid || !$alias) return null; |
|
| 1043 | + if (!$mid || !$alias) return null; |
|
| 1044 | 1044 | $site_module_info = Context::get('site_module_info'); |
| 1045 | 1045 | $args = new stdClass; |
| 1046 | 1046 | $args->mid = $mid; |
| 1047 | 1047 | $args->alias_title = $alias; |
| 1048 | 1048 | $args->site_srl = $site_module_info->site_srl; |
| 1049 | 1049 | $output = executeQuery('document.getDocumentSrlByAlias', $args); |
| 1050 | - if(!$output->data) return null; |
|
| 1050 | + if (!$output->data) return null; |
|
| 1051 | 1051 | else return $output->data->document_srl; |
| 1052 | 1052 | } |
| 1053 | 1053 | |
@@ -1059,15 +1059,15 @@ discard block |
||
| 1059 | 1059 | */ |
| 1060 | 1060 | function getDocumentSrlByTitle($module_srl, $title) |
| 1061 | 1061 | { |
| 1062 | - if(!$module_srl || !$title) return null; |
|
| 1062 | + if (!$module_srl || !$title) return null; |
|
| 1063 | 1063 | $args = new stdClass; |
| 1064 | 1064 | $args->module_srl = $module_srl; |
| 1065 | 1065 | $args->title = $title; |
| 1066 | 1066 | $output = executeQuery('document.getDocumentSrlByTitle', $args); |
| 1067 | - if(!$output->data) return null; |
|
| 1067 | + if (!$output->data) return null; |
|
| 1068 | 1068 | else |
| 1069 | 1069 | { |
| 1070 | - if(is_array($output->data)) return $output->data[0]->document_srl; |
|
| 1070 | + if (is_array($output->data)) return $output->data[0]->document_srl; |
|
| 1071 | 1071 | return $output->data->document_srl; |
| 1072 | 1072 | } |
| 1073 | 1073 | } |
@@ -1079,12 +1079,12 @@ discard block |
||
| 1079 | 1079 | */ |
| 1080 | 1080 | function getAlias($document_srl) |
| 1081 | 1081 | { |
| 1082 | - if(!$document_srl) return null; |
|
| 1082 | + if (!$document_srl) return null; |
|
| 1083 | 1083 | $args = new stdClass; |
| 1084 | 1084 | $args->document_srl = $document_srl; |
| 1085 | 1085 | $output = executeQueryArray('document.getAliases', $args); |
| 1086 | 1086 | |
| 1087 | - if(!$output->data) return null; |
|
| 1087 | + if (!$output->data) return null; |
|
| 1088 | 1088 | else return $output->data[0]->alias_title; |
| 1089 | 1089 | } |
| 1090 | 1090 | |
@@ -1127,32 +1127,32 @@ discard block |
||
| 1127 | 1127 | { |
| 1128 | 1128 | // Variable check |
| 1129 | 1129 | $args = new stdClass; |
| 1130 | - $args->category_srl = $obj->category_srl?$obj->category_srl:null; |
|
| 1130 | + $args->category_srl = $obj->category_srl ? $obj->category_srl : null; |
|
| 1131 | 1131 | $args->sort_index = $obj->sort_index; |
| 1132 | - $args->order_type = $obj->order_type?$obj->order_type:'desc'; |
|
| 1133 | - $args->page = $obj->page?$obj->page:1; |
|
| 1134 | - $args->list_count = $obj->list_count?$obj->list_count:20; |
|
| 1135 | - $args->page_count = $obj->page_count?$obj->page_count:10; |
|
| 1132 | + $args->order_type = $obj->order_type ? $obj->order_type : 'desc'; |
|
| 1133 | + $args->page = $obj->page ? $obj->page : 1; |
|
| 1134 | + $args->list_count = $obj->list_count ? $obj->list_count : 20; |
|
| 1135 | + $args->page_count = $obj->page_count ? $obj->page_count : 10; |
|
| 1136 | 1136 | // Search options |
| 1137 | 1137 | $search_target = $obj->search_target; |
| 1138 | 1138 | $search_keyword = $obj->search_keyword; |
| 1139 | - if($search_target && $search_keyword) |
|
| 1139 | + if ($search_target && $search_keyword) |
|
| 1140 | 1140 | { |
| 1141 | - switch($search_target) |
|
| 1141 | + switch ($search_target) |
|
| 1142 | 1142 | { |
| 1143 | 1143 | case 'title' : |
| 1144 | 1144 | case 'content' : |
| 1145 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1145 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
| 1146 | 1146 | $args->{"s_".$search_target} = $search_keyword; |
| 1147 | 1147 | $use_division = true; |
| 1148 | 1148 | break; |
| 1149 | 1149 | case 'title_content' : |
| 1150 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1150 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
| 1151 | 1151 | $args->s_title = $search_keyword; |
| 1152 | 1152 | $args->s_content = $search_keyword; |
| 1153 | 1153 | break; |
| 1154 | 1154 | case 'user_id' : |
| 1155 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1155 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
| 1156 | 1156 | $args->s_user_id = $search_keyword; |
| 1157 | 1157 | $args->sort_index = 'documents.'.$args->sort_index; |
| 1158 | 1158 | break; |
@@ -1160,13 +1160,13 @@ discard block |
||
| 1160 | 1160 | case 'nick_name' : |
| 1161 | 1161 | case 'email_address' : |
| 1162 | 1162 | case 'homepage' : |
| 1163 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1163 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
| 1164 | 1164 | $args->{"s_".$search_target} = $search_keyword; |
| 1165 | 1165 | break; |
| 1166 | 1166 | case 'is_notice' : |
| 1167 | 1167 | case 'is_secret' : |
| 1168 | - if($search_keyword=='N') $args->statusList = array($this->getConfigStatus('public')); |
|
| 1169 | - elseif($search_keyword=='Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
| 1168 | + if ($search_keyword == 'N') $args->statusList = array($this->getConfigStatus('public')); |
|
| 1169 | + elseif ($search_keyword == 'Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
| 1170 | 1170 | break; |
| 1171 | 1171 | case 'member_srl' : |
| 1172 | 1172 | case 'readed_count' : |
@@ -1175,7 +1175,7 @@ discard block |
||
| 1175 | 1175 | case 'comment_count' : |
| 1176 | 1176 | case 'trackback_count' : |
| 1177 | 1177 | case 'uploaded_count' : |
| 1178 | - $args->{"s_".$search_target} = (int)$search_keyword; |
|
| 1178 | + $args->{"s_".$search_target} = (int) $search_keyword; |
|
| 1179 | 1179 | break; |
| 1180 | 1180 | case 'regdate' : |
| 1181 | 1181 | case 'last_update' : |
@@ -1187,9 +1187,9 @@ discard block |
||
| 1187 | 1187 | } |
| 1188 | 1188 | |
| 1189 | 1189 | $output = executeQueryArray('document.getTrashList', $args); |
| 1190 | - if($output->data) |
|
| 1190 | + if ($output->data) |
|
| 1191 | 1191 | { |
| 1192 | - foreach($output->data as $key => $attribute) |
|
| 1192 | + foreach ($output->data as $key => $attribute) |
|
| 1193 | 1193 | { |
| 1194 | 1194 | $oDocument = null; |
| 1195 | 1195 | $oDocument = new documentItem(); |
@@ -1208,46 +1208,46 @@ discard block |
||
| 1208 | 1208 | { |
| 1209 | 1209 | $args = new stdClass; |
| 1210 | 1210 | $document_srl = Context::get('document_srl'); |
| 1211 | - if(!$document_srl) return new BaseObject(-1,'msg_invalid_request'); |
|
| 1211 | + if (!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 1212 | 1212 | |
| 1213 | 1213 | $point = Context::get('point'); |
| 1214 | - if($point != -1) $point = 1; |
|
| 1214 | + if ($point != -1) $point = 1; |
|
| 1215 | 1215 | |
| 1216 | 1216 | $oDocumentModel = getModel('document'); |
| 1217 | 1217 | $columnList = array('document_srl', 'module_srl'); |
| 1218 | 1218 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList); |
| 1219 | 1219 | $module_srl = $oDocument->get('module_srl'); |
| 1220 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 1220 | + if (!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 1221 | 1221 | |
| 1222 | 1222 | $oModuleModel = getModel('module'); |
| 1223 | - $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
|
| 1224 | - if($point == -1) |
|
| 1223 | + $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
|
| 1224 | + if ($point == -1) |
|
| 1225 | 1225 | { |
| 1226 | - if($document_config->use_vote_down!='S') return new BaseObject(-1, 'msg_invalid_request'); |
|
| 1226 | + if ($document_config->use_vote_down != 'S') return new BaseObject(-1, 'msg_invalid_request'); |
|
| 1227 | 1227 | $args->below_point = 0; |
| 1228 | 1228 | } |
| 1229 | 1229 | else |
| 1230 | 1230 | { |
| 1231 | - if($document_config->use_vote_up!='S') return new BaseObject(-1, 'msg_invalid_request'); |
|
| 1231 | + if ($document_config->use_vote_up != 'S') return new BaseObject(-1, 'msg_invalid_request'); |
|
| 1232 | 1232 | $args->more_point = 0; |
| 1233 | 1233 | } |
| 1234 | 1234 | |
| 1235 | 1235 | $args->document_srl = $document_srl; |
| 1236 | 1236 | |
| 1237 | - $output = executeQueryArray('document.getVotedMemberList',$args); |
|
| 1238 | - if(!$output->toBool()) return $output; |
|
| 1237 | + $output = executeQueryArray('document.getVotedMemberList', $args); |
|
| 1238 | + if (!$output->toBool()) return $output; |
|
| 1239 | 1239 | |
| 1240 | 1240 | $oMemberModel = getModel('member'); |
| 1241 | - if($output->data) |
|
| 1241 | + if ($output->data) |
|
| 1242 | 1242 | { |
| 1243 | - foreach($output->data as $k => $d) |
|
| 1243 | + foreach ($output->data as $k => $d) |
|
| 1244 | 1244 | { |
| 1245 | 1245 | $profile_image = $oMemberModel->getProfileImage($d->member_srl); |
| 1246 | 1246 | $output->data[$k]->src = $profile_image->src; |
| 1247 | 1247 | } |
| 1248 | 1248 | } |
| 1249 | 1249 | |
| 1250 | - $this->add('voted_member_list',$output->data); |
|
| 1250 | + $this->add('voted_member_list', $output->data); |
|
| 1251 | 1251 | } |
| 1252 | 1252 | |
| 1253 | 1253 | /** |
@@ -1257,7 +1257,7 @@ discard block |
||
| 1257 | 1257 | function getStatusNameList() |
| 1258 | 1258 | { |
| 1259 | 1259 | global $lang; |
| 1260 | - if(!isset($lang->status_name_list)) |
|
| 1260 | + if (!isset($lang->status_name_list)) |
|
| 1261 | 1261 | return array_flip($this->getStatusList()); |
| 1262 | 1262 | else return $lang->status_name_list; |
| 1263 | 1263 | } |
@@ -1272,7 +1272,7 @@ discard block |
||
| 1272 | 1272 | { |
| 1273 | 1273 | $sortIndex = $obj->sort_index; |
| 1274 | 1274 | $isExtraVars = false; |
| 1275 | - if(!in_array($sortIndex, array('list_order','regdate','last_update','update_order','readed_count','voted_count','blamed_count','comment_count','trackback_count','uploaded_count','title','category_srl'))) |
|
| 1275 | + if (!in_array($sortIndex, array('list_order', 'regdate', 'last_update', 'update_order', 'readed_count', 'voted_count', 'blamed_count', 'comment_count', 'trackback_count', 'uploaded_count', 'title', 'category_srl'))) |
|
| 1276 | 1276 | { |
| 1277 | 1277 | // get module_srl extra_vars list |
| 1278 | 1278 | if ($load_extra_vars) |
@@ -1287,11 +1287,11 @@ discard block |
||
| 1287 | 1287 | else |
| 1288 | 1288 | { |
| 1289 | 1289 | $check_array = array(); |
| 1290 | - foreach($extra_output->data as $val) |
|
| 1290 | + foreach ($extra_output->data as $val) |
|
| 1291 | 1291 | { |
| 1292 | 1292 | $check_array[] = $val->eid; |
| 1293 | 1293 | } |
| 1294 | - if(!in_array($sortIndex, $check_array)) $sortIndex = 'list_order'; |
|
| 1294 | + if (!in_array($sortIndex, $check_array)) $sortIndex = 'list_order'; |
|
| 1295 | 1295 | else $isExtraVars = true; |
| 1296 | 1296 | } |
| 1297 | 1297 | } |
@@ -1319,13 +1319,13 @@ discard block |
||
| 1319 | 1319 | { |
| 1320 | 1320 | // Variable check |
| 1321 | 1321 | $args = new stdClass(); |
| 1322 | - $args->category_srl = $searchOpt->category_srl?$searchOpt->category_srl:null; |
|
| 1322 | + $args->category_srl = $searchOpt->category_srl ? $searchOpt->category_srl : null; |
|
| 1323 | 1323 | $args->order_type = $searchOpt->order_type; |
| 1324 | - $args->page = $searchOpt->page?$searchOpt->page:1; |
|
| 1325 | - $args->list_count = $searchOpt->list_count?$searchOpt->list_count:20; |
|
| 1326 | - $args->page_count = $searchOpt->page_count?$searchOpt->page_count:10; |
|
| 1327 | - $args->start_date = $searchOpt->start_date?$searchOpt->start_date:null; |
|
| 1328 | - $args->end_date = $searchOpt->end_date?$searchOpt->end_date:null; |
|
| 1324 | + $args->page = $searchOpt->page ? $searchOpt->page : 1; |
|
| 1325 | + $args->list_count = $searchOpt->list_count ? $searchOpt->list_count : 20; |
|
| 1326 | + $args->page_count = $searchOpt->page_count ? $searchOpt->page_count : 10; |
|
| 1327 | + $args->start_date = $searchOpt->start_date ? $searchOpt->start_date : null; |
|
| 1328 | + $args->end_date = $searchOpt->end_date ? $searchOpt->end_date : null; |
|
| 1329 | 1329 | $args->member_srl = $searchOpt->member_srl; |
| 1330 | 1330 | |
| 1331 | 1331 | $logged_info = Context::get('logged_info'); |
@@ -1334,10 +1334,10 @@ discard block |
||
| 1334 | 1334 | |
| 1335 | 1335 | // Check the target and sequence alignment |
| 1336 | 1336 | $orderType = array('desc' => 1, 'asc' => 1); |
| 1337 | - if(!isset($orderType[$args->order_type])) $args->order_type = 'asc'; |
|
| 1337 | + if (!isset($orderType[$args->order_type])) $args->order_type = 'asc'; |
|
| 1338 | 1338 | |
| 1339 | 1339 | // If that came across mid module_srl instead of a direct module_srl guhaejum |
| 1340 | - if($searchOpt->mid) |
|
| 1340 | + if ($searchOpt->mid) |
|
| 1341 | 1341 | { |
| 1342 | 1342 | $oModuleModel = getModel('module'); |
| 1343 | 1343 | $args->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid); |
@@ -1345,30 +1345,30 @@ discard block |
||
| 1345 | 1345 | } |
| 1346 | 1346 | |
| 1347 | 1347 | // Module_srl passed the array may be a check whether the array |
| 1348 | - if(is_array($searchOpt->module_srl)) $args->module_srl = implode(',', $searchOpt->module_srl); |
|
| 1348 | + if (is_array($searchOpt->module_srl)) $args->module_srl = implode(',', $searchOpt->module_srl); |
|
| 1349 | 1349 | else $args->module_srl = $searchOpt->module_srl; |
| 1350 | 1350 | |
| 1351 | 1351 | // Except for the test module_srl |
| 1352 | - if(is_array($searchOpt->exclude_module_srl)) $args->exclude_module_srl = implode(',', $searchOpt->exclude_module_srl); |
|
| 1352 | + if (is_array($searchOpt->exclude_module_srl)) $args->exclude_module_srl = implode(',', $searchOpt->exclude_module_srl); |
|
| 1353 | 1353 | else $args->exclude_module_srl = $searchOpt->exclude_module_srl; |
| 1354 | 1354 | |
| 1355 | 1355 | // only admin document list, temp document showing |
| 1356 | - if($searchOpt->statusList) $args->statusList = $searchOpt->statusList; |
|
| 1356 | + if ($searchOpt->statusList) $args->statusList = $searchOpt->statusList; |
|
| 1357 | 1357 | else |
| 1358 | 1358 | { |
| 1359 | - if($logged_info->is_admin == 'Y' && !$searchOpt->module_srl) |
|
| 1359 | + if ($logged_info->is_admin == 'Y' && !$searchOpt->module_srl) |
|
| 1360 | 1360 | $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public'), $this->getConfigStatus('temp')); |
| 1361 | 1361 | else |
| 1362 | 1362 | $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public')); |
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | 1365 | // Category is selected, further sub-categories until all conditions |
| 1366 | - if($args->category_srl) |
|
| 1366 | + if ($args->category_srl) |
|
| 1367 | 1367 | { |
| 1368 | 1368 | $category_list = $this->getCategoryList($args->module_srl); |
| 1369 | 1369 | $category_info = $category_list[$args->category_srl]; |
| 1370 | 1370 | $category_info->childs[] = $args->category_srl; |
| 1371 | - $args->category_srl = implode(',',$category_info->childs); |
|
| 1371 | + $args->category_srl = implode(',', $category_info->childs); |
|
| 1372 | 1372 | } |
| 1373 | 1373 | |
| 1374 | 1374 | // Used to specify the default query id (based on several search options to query id modified) |
@@ -1381,24 +1381,24 @@ discard block |
||
| 1381 | 1381 | $search_target = $searchOpt->search_target; |
| 1382 | 1382 | $search_keyword = $searchOpt->search_keyword; |
| 1383 | 1383 | |
| 1384 | - if($search_target && $search_keyword) |
|
| 1384 | + if ($search_target && $search_keyword) |
|
| 1385 | 1385 | { |
| 1386 | - switch($search_target) |
|
| 1386 | + switch ($search_target) |
|
| 1387 | 1387 | { |
| 1388 | 1388 | case 'title' : |
| 1389 | 1389 | case 'content' : |
| 1390 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1390 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
| 1391 | 1391 | $args->{"s_".$search_target} = $search_keyword; |
| 1392 | 1392 | $use_division = true; |
| 1393 | 1393 | break; |
| 1394 | 1394 | case 'title_content' : |
| 1395 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1395 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
| 1396 | 1396 | $args->s_title = $search_keyword; |
| 1397 | 1397 | $args->s_content = $search_keyword; |
| 1398 | 1398 | $use_division = true; |
| 1399 | 1399 | break; |
| 1400 | 1400 | case 'user_id' : |
| 1401 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1401 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
| 1402 | 1402 | $args->s_user_id = $search_keyword; |
| 1403 | 1403 | $args->sort_index = 'documents.'.$args->sort_index; |
| 1404 | 1404 | break; |
@@ -1406,18 +1406,18 @@ discard block |
||
| 1406 | 1406 | case 'nick_name' : |
| 1407 | 1407 | case 'email_address' : |
| 1408 | 1408 | case 'homepage' : |
| 1409 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1409 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
| 1410 | 1410 | $args->{"s_".$search_target} = $search_keyword; |
| 1411 | 1411 | break; |
| 1412 | 1412 | case 'is_notice' : |
| 1413 | - if($search_keyword=='N') $args->{"s_".$search_target} = 'N'; |
|
| 1414 | - elseif($search_keyword=='Y') $args->{"s_".$search_target} = 'Y'; |
|
| 1413 | + if ($search_keyword == 'N') $args->{"s_".$search_target} = 'N'; |
|
| 1414 | + elseif ($search_keyword == 'Y') $args->{"s_".$search_target} = 'Y'; |
|
| 1415 | 1415 | else $args->{"s_".$search_target} = ''; |
| 1416 | 1416 | break; |
| 1417 | 1417 | case 'is_secret' : |
| 1418 | - if($search_keyword=='N') $args->statusList = array($this->getConfigStatus('public')); |
|
| 1419 | - elseif($search_keyword=='Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
| 1420 | - elseif($search_keyword=='temp') $args->statusList = array($this->getConfigStatus('temp')); |
|
| 1418 | + if ($search_keyword == 'N') $args->statusList = array($this->getConfigStatus('public')); |
|
| 1419 | + elseif ($search_keyword == 'Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
| 1420 | + elseif ($search_keyword == 'temp') $args->statusList = array($this->getConfigStatus('temp')); |
|
| 1421 | 1421 | break; |
| 1422 | 1422 | case 'member_srl' : |
| 1423 | 1423 | case 'readed_count' : |
@@ -1425,10 +1425,10 @@ discard block |
||
| 1425 | 1425 | case 'comment_count' : |
| 1426 | 1426 | case 'trackback_count' : |
| 1427 | 1427 | case 'uploaded_count' : |
| 1428 | - $args->{"s_".$search_target} = (int)$search_keyword; |
|
| 1428 | + $args->{"s_".$search_target} = (int) $search_keyword; |
|
| 1429 | 1429 | break; |
| 1430 | 1430 | case 'blamed_count' : |
| 1431 | - $args->{"s_".$search_target} = (int)$search_keyword * -1; |
|
| 1431 | + $args->{"s_".$search_target} = (int) $search_keyword * -1; |
|
| 1432 | 1432 | break; |
| 1433 | 1433 | case 'regdate' : |
| 1434 | 1434 | case 'last_update' : |
@@ -1441,7 +1441,7 @@ discard block |
||
| 1441 | 1441 | $use_division = true; |
| 1442 | 1442 | break; |
| 1443 | 1443 | case 'tag' : |
| 1444 | - $args->s_tags = str_replace(' ','%',$search_keyword); |
|
| 1444 | + $args->s_tags = str_replace(' ', '%', $search_keyword); |
|
| 1445 | 1445 | $query_id = 'document.getDocumentListWithinTag'; |
| 1446 | 1446 | break; |
| 1447 | 1447 | case 'extra_vars': |
@@ -1449,9 +1449,9 @@ discard block |
||
| 1449 | 1449 | $query_id = 'document.getDocumentListWithinExtraVars'; |
| 1450 | 1450 | break; |
| 1451 | 1451 | default : |
| 1452 | - if(strpos($search_target,'extra_vars')!==false) { |
|
| 1452 | + if (strpos($search_target, 'extra_vars') !== false) { |
|
| 1453 | 1453 | $args->var_idx = substr($search_target, strlen('extra_vars')); |
| 1454 | - $args->var_value = str_replace(' ','%',$search_keyword); |
|
| 1454 | + $args->var_value = str_replace(' ', '%', $search_keyword); |
|
| 1455 | 1455 | $args->sort_index = 'documents.'.$args->sort_index; |
| 1456 | 1456 | $query_id = 'document.getDocumentListWithExtraVars'; |
| 1457 | 1457 | } |
@@ -1468,18 +1468,18 @@ discard block |
||
| 1468 | 1468 | /** |
| 1469 | 1469 | * list_order asc sort of division that can be used only when |
| 1470 | 1470 | */ |
| 1471 | - if($args->sort_index != 'list_order' || $args->order_type != 'asc') $use_division = false; |
|
| 1471 | + if ($args->sort_index != 'list_order' || $args->order_type != 'asc') $use_division = false; |
|
| 1472 | 1472 | |
| 1473 | 1473 | /** |
| 1474 | 1474 | * If it is true, use_division changed to use the document division |
| 1475 | 1475 | */ |
| 1476 | - if($use_division) |
|
| 1476 | + if ($use_division) |
|
| 1477 | 1477 | { |
| 1478 | 1478 | // Division begins |
| 1479 | - $division = (int)Context::get('division'); |
|
| 1479 | + $division = (int) Context::get('division'); |
|
| 1480 | 1480 | |
| 1481 | 1481 | // order by list_order and (module_srl===0 or module_srl may count), therefore case table full scan |
| 1482 | - if($args->sort_index == 'list_order' && ($args->exclude_module_srl === '0' || count(explode(',', $args->module_srl)) > 5)) |
|
| 1482 | + if ($args->sort_index == 'list_order' && ($args->exclude_module_srl === '0' || count(explode(',', $args->module_srl)) > 5)) |
|
| 1483 | 1483 | { |
| 1484 | 1484 | $listSqlID = 'document.getDocumentListUseIndex'; |
| 1485 | 1485 | $divisionSqlID = 'document.getDocumentDivisionUseIndex'; |
@@ -1491,7 +1491,7 @@ discard block |
||
| 1491 | 1491 | } |
| 1492 | 1492 | |
| 1493 | 1493 | // If you do not value the best division top |
| 1494 | - if(!$division) |
|
| 1494 | + if (!$division) |
|
| 1495 | 1495 | { |
| 1496 | 1496 | $division_args = new stdClass(); |
| 1497 | 1497 | $division_args->module_srl = $args->module_srl; |
@@ -1502,7 +1502,7 @@ discard block |
||
| 1502 | 1502 | $division_args->statusList = $args->statusList; |
| 1503 | 1503 | |
| 1504 | 1504 | $output = executeQuery($divisionSqlID, $division_args, array('list_order')); |
| 1505 | - if($output->data) |
|
| 1505 | + if ($output->data) |
|
| 1506 | 1506 | { |
| 1507 | 1507 | $item = array_pop($output->data); |
| 1508 | 1508 | $division = $item->list_order; |
@@ -1511,10 +1511,10 @@ discard block |
||
| 1511 | 1511 | } |
| 1512 | 1512 | |
| 1513 | 1513 | // The last division |
| 1514 | - $last_division = (int)Context::get('last_division'); |
|
| 1514 | + $last_division = (int) Context::get('last_division'); |
|
| 1515 | 1515 | |
| 1516 | 1516 | // Division after division from the 5000 value of the specified Wanted |
| 1517 | - if(!$last_division) |
|
| 1517 | + if (!$last_division) |
|
| 1518 | 1518 | { |
| 1519 | 1519 | $last_division_args = new stdClass(); |
| 1520 | 1520 | $last_division_args->module_srl = $args->module_srl; |
@@ -1526,7 +1526,7 @@ discard block |
||
| 1526 | 1526 | $last_division_args->page = 5001; |
| 1527 | 1527 | |
| 1528 | 1528 | $output = executeQuery($divisionSqlID, $last_division_args, array('list_order')); |
| 1529 | - if($output->data) |
|
| 1529 | + if ($output->data) |
|
| 1530 | 1530 | { |
| 1531 | 1531 | $item = array_pop($output->data); |
| 1532 | 1532 | $last_division = $item->list_order; |
@@ -1534,14 +1534,14 @@ discard block |
||
| 1534 | 1534 | } |
| 1535 | 1535 | |
| 1536 | 1536 | // Make sure that after last_division article |
| 1537 | - if($last_division) |
|
| 1537 | + if ($last_division) |
|
| 1538 | 1538 | { |
| 1539 | 1539 | $last_division_args = new stdClass(); |
| 1540 | 1540 | $last_division_args->module_srl = $args->module_srl; |
| 1541 | 1541 | $last_division_args->exclude_module_srl = $args->exclude_module_srl; |
| 1542 | 1542 | $last_division_args->list_order = $last_division; |
| 1543 | 1543 | $output = executeQuery('document.getDocumentDivisionCount', $last_division_args); |
| 1544 | - if($output->data->count<1) $last_division = null; |
|
| 1544 | + if ($output->data->count < 1) $last_division = null; |
|
| 1545 | 1545 | } |
| 1546 | 1546 | |
| 1547 | 1547 | $args->division = $division; |
@@ -1574,7 +1574,7 @@ discard block |
||
| 1574 | 1574 | * @param int $count |
| 1575 | 1575 | * @return object |
| 1576 | 1576 | */ |
| 1577 | - function getDocumentListByMemberSrl($member_srl, $columnList = array(), $page = 0, $is_admin = FALSE, $count = 0 ) |
|
| 1577 | + function getDocumentListByMemberSrl($member_srl, $columnList = array(), $page = 0, $is_admin = FALSE, $count = 0) |
|
| 1578 | 1578 | { |
| 1579 | 1579 | $args = new stdClass(); |
| 1580 | 1580 | $args->member_srl = $member_srl; |
@@ -1582,8 +1582,8 @@ discard block |
||
| 1582 | 1582 | $output = executeQuery('document.getDocumentListByMemberSrl', $args, $columnList); |
| 1583 | 1583 | $document_list = $output->data; |
| 1584 | 1584 | |
| 1585 | - if(!$document_list) return array(); |
|
| 1586 | - if(!is_array($document_list)) $document_list = array($document_list); |
|
| 1585 | + if (!$document_list) return array(); |
|
| 1586 | + if (!is_array($document_list)) $document_list = array($document_list); |
|
| 1587 | 1587 | |
| 1588 | 1588 | return $document_list; |
| 1589 | 1589 | } |
@@ -1595,7 +1595,7 @@ discard block |
||
| 1595 | 1595 | function getDocumentExtraImagePath() |
| 1596 | 1596 | { |
| 1597 | 1597 | $documentConfig = getModel('document')->getDocumentConfig(); |
| 1598 | - if(Mobile::isFromMobilePhone()) |
|
| 1598 | + if (Mobile::isFromMobilePhone()) |
|
| 1599 | 1599 | { |
| 1600 | 1600 | $iconSkin = $documentConfig->micons; |
| 1601 | 1601 | } |
@@ -1603,7 +1603,7 @@ discard block |
||
| 1603 | 1603 | { |
| 1604 | 1604 | $iconSkin = $documentConfig->icons; |
| 1605 | 1605 | } |
| 1606 | - $path = sprintf('%s%s',getUrl(), "modules/document/tpl/icons/$iconSkin/"); |
|
| 1606 | + $path = sprintf('%s%s', getUrl(), "modules/document/tpl/icons/$iconSkin/"); |
|
| 1607 | 1607 | |
| 1608 | 1608 | return $path; |
| 1609 | 1609 | } |
@@ -58,18 +58,24 @@ discard block |
||
| 58 | 58 | $_document_list = &$GLOBALS['XE_DOCUMENT_LIST']; |
| 59 | 59 | |
| 60 | 60 | // XE XE_DOCUMENT_LIST all documents that the object referred to the global variable settings |
| 61 | - if(count($_document_list) <= 0) return; |
|
| 61 | + if(count($_document_list) <= 0) { |
|
| 62 | + return; |
|
| 63 | + } |
|
| 62 | 64 | |
| 63 | 65 | // Find all called the document object variable has been set extension |
| 64 | 66 | $document_srls = array(); |
| 65 | 67 | foreach($_document_list as $key => $val) |
| 66 | 68 | { |
| 67 | - if(!$val->document_srl || $checked_documents[$val->document_srl]) continue; |
|
| 69 | + if(!$val->document_srl || $checked_documents[$val->document_srl]) { |
|
| 70 | + continue; |
|
| 71 | + } |
|
| 68 | 72 | $checked_documents[$val->document_srl] = true; |
| 69 | 73 | $document_srls[] = $val->document_srl; |
| 70 | 74 | } |
| 71 | 75 | // If the document number, return detected |
| 72 | - if(!count($document_srls)) return; |
|
| 76 | + if(!count($document_srls)) { |
|
| 77 | + return; |
|
| 78 | + } |
|
| 73 | 79 | // Expand variables mijijeongdoen article about a current visitor to the extension of the language code, the search variable |
| 74 | 80 | //$obj->document_srl = implode(',',$document_srls); |
| 75 | 81 | $output = $this->getDocumentExtraVarsFromDB($document_srls); |
@@ -77,8 +83,12 @@ discard block |
||
| 77 | 83 | { |
| 78 | 84 | foreach($output->data as $key => $val) |
| 79 | 85 | { |
| 80 | - if(!isset($val->value)) continue; |
|
| 81 | - if(!$extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0]) $extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0] = trim($val->value); |
|
| 86 | + if(!isset($val->value)) { |
|
| 87 | + continue; |
|
| 88 | + } |
|
| 89 | + if(!$extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0]) { |
|
| 90 | + $extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0] = trim($val->value); |
|
| 91 | + } |
|
| 82 | 92 | $extra_vars[$val->document_srl][$val->var_idx][$val->lang_code] = trim($val->value); |
| 83 | 93 | } |
| 84 | 94 | } |
@@ -89,7 +99,9 @@ discard block |
||
| 89 | 99 | $document_srl = $document_srls[$i]; |
| 90 | 100 | unset($vars); |
| 91 | 101 | |
| 92 | - if(!$_document_list[$document_srl] || !is_object($_document_list[$document_srl]) || !$_document_list[$document_srl]->isExists()) continue; |
|
| 102 | + if(!$_document_list[$document_srl] || !is_object($_document_list[$document_srl]) || !$_document_list[$document_srl]->isExists()) { |
|
| 103 | + continue; |
|
| 104 | + } |
|
| 93 | 105 | $module_srl = $_document_list[$document_srl]->get('module_srl'); |
| 94 | 106 | $extra_keys = $this->getExtraKeys($module_srl); |
| 95 | 107 | $vars = $extra_vars[$document_srl]; |
@@ -101,10 +113,15 @@ discard block |
||
| 101 | 113 | { |
| 102 | 114 | $extra_keys[$idx] = clone($key); |
| 103 | 115 | $val = $vars[$idx]; |
| 104 | - if(isset($val[$user_lang_code])) $v = $val[$user_lang_code]; |
|
| 105 | - else if(isset($val[$document_lang_code])) $v = $val[$document_lang_code]; |
|
| 106 | - else if(isset($val[0])) $v = $val[0]; |
|
| 107 | - else $v = null; |
|
| 116 | + if(isset($val[$user_lang_code])) { |
|
| 117 | + $v = $val[$user_lang_code]; |
|
| 118 | + } else if(isset($val[$document_lang_code])) { |
|
| 119 | + $v = $val[$document_lang_code]; |
|
| 120 | + } else if(isset($val[0])) { |
|
| 121 | + $v = $val[0]; |
|
| 122 | + } else { |
|
| 123 | + $v = null; |
|
| 124 | + } |
|
| 108 | 125 | $extra_keys[$idx]->value = $v; |
| 109 | 126 | } |
| 110 | 127 | } |
@@ -113,9 +130,13 @@ discard block |
||
| 113 | 130 | $evars = new ExtraVar($module_srl); |
| 114 | 131 | $evars->setExtraVarKeys($extra_keys); |
| 115 | 132 | // Title Processing |
| 116 | - if($vars[-1][$user_lang_code]) $_document_list[$document_srl]->add('title',$vars[-1][$user_lang_code]); |
|
| 133 | + if($vars[-1][$user_lang_code]) { |
|
| 134 | + $_document_list[$document_srl]->add('title',$vars[-1][$user_lang_code]); |
|
| 135 | + } |
|
| 117 | 136 | // Information processing |
| 118 | - if($vars[-2][$user_lang_code]) $_document_list[$document_srl]->add('content',$vars[-2][$user_lang_code]); |
|
| 137 | + if($vars[-2][$user_lang_code]) { |
|
| 138 | + $_document_list[$document_srl]->add('content',$vars[-2][$user_lang_code]); |
|
| 139 | + } |
|
| 119 | 140 | |
| 120 | 141 | if($vars[-1][$user_lang_code] || $vars[-2][$user_lang_code]) |
| 121 | 142 | { |
@@ -136,15 +157,21 @@ discard block |
||
| 136 | 157 | */ |
| 137 | 158 | function getDocument($document_srl=0, $is_admin = false, $load_extra_vars=true, $columnList = array()) |
| 138 | 159 | { |
| 139 | - if(!$document_srl) return new documentItem(); |
|
| 160 | + if(!$document_srl) { |
|
| 161 | + return new documentItem(); |
|
| 162 | + } |
|
| 140 | 163 | |
| 141 | 164 | if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
| 142 | 165 | { |
| 143 | 166 | $oDocument = new documentItem($document_srl, $load_extra_vars, $columnList); |
| 144 | 167 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
| 145 | - if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
| 168 | + if($load_extra_vars) { |
|
| 169 | + $this->setToAllDocumentExtraVars(); |
|
| 170 | + } |
|
| 171 | + } |
|
| 172 | + if($is_admin) { |
|
| 173 | + $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->setGrant(); |
|
| 146 | 174 | } |
| 147 | - if($is_admin) $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->setGrant(); |
|
| 148 | 175 | |
| 149 | 176 | return $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
| 150 | 177 | } |
@@ -163,8 +190,7 @@ discard block |
||
| 163 | 190 | { |
| 164 | 191 | $list_count = count($document_srls); |
| 165 | 192 | $document_srls = implode(',',$document_srls); |
| 166 | - } |
|
| 167 | - else |
|
| 193 | + } else |
|
| 168 | 194 | { |
| 169 | 195 | $list_count = 1; |
| 170 | 196 | } |
@@ -175,28 +201,38 @@ discard block |
||
| 175 | 201 | |
| 176 | 202 | $output = executeQuery('document.getDocuments', $args, $columnList); |
| 177 | 203 | $document_list = $output->data; |
| 178 | - if(!$document_list) return; |
|
| 179 | - if(!is_array($document_list)) $document_list = array($document_list); |
|
| 204 | + if(!$document_list) { |
|
| 205 | + return; |
|
| 206 | + } |
|
| 207 | + if(!is_array($document_list)) { |
|
| 208 | + $document_list = array($document_list); |
|
| 209 | + } |
|
| 180 | 210 | |
| 181 | 211 | $document_count = count($document_list); |
| 182 | 212 | foreach($document_list as $key => $attribute) |
| 183 | 213 | { |
| 184 | 214 | $document_srl = $attribute->document_srl; |
| 185 | - if(!$document_srl) continue; |
|
| 215 | + if(!$document_srl) { |
|
| 216 | + continue; |
|
| 217 | + } |
|
| 186 | 218 | |
| 187 | 219 | if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
| 188 | 220 | { |
| 189 | 221 | $oDocument = null; |
| 190 | 222 | $oDocument = new documentItem(); |
| 191 | 223 | $oDocument->setAttribute($attribute, false); |
| 192 | - if($is_admin) $oDocument->setGrant(); |
|
| 224 | + if($is_admin) { |
|
| 225 | + $oDocument->setGrant(); |
|
| 226 | + } |
|
| 193 | 227 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
| 194 | 228 | } |
| 195 | 229 | |
| 196 | 230 | $result[$attribute->document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
| 197 | 231 | } |
| 198 | 232 | |
| 199 | - if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
| 233 | + if($load_extra_vars) { |
|
| 234 | + $this->setToAllDocumentExtraVars(); |
|
| 235 | + } |
|
| 200 | 236 | |
| 201 | 237 | $output = null; |
| 202 | 238 | if(count($result)) |
@@ -244,18 +280,15 @@ discard block |
||
| 244 | 280 | { |
| 245 | 281 | $output = $obj->use_alternate_output; |
| 246 | 282 | unset($obj->use_alternate_output); |
| 247 | - } |
|
| 248 | - elseif ($sort_check->isExtraVars && substr_count($obj->search_target,'extra_vars')) |
|
| 283 | + } elseif ($sort_check->isExtraVars && substr_count($obj->search_target,'extra_vars')) |
|
| 249 | 284 | { |
| 250 | 285 | $query_id = 'document.getDocumentListWithinExtraVarsExtraSort'; |
| 251 | 286 | $args->sort_index = str_replace('documents.','',$args->sort_index); |
| 252 | 287 | $output = executeQueryArray($query_id, $args); |
| 253 | - } |
|
| 254 | - elseif ($sort_check->isExtraVars) |
|
| 288 | + } elseif ($sort_check->isExtraVars) |
|
| 255 | 289 | { |
| 256 | 290 | $output = executeQueryArray($query_id, $args); |
| 257 | - } |
|
| 258 | - else |
|
| 291 | + } else |
|
| 259 | 292 | { |
| 260 | 293 | // document.getDocumentList query execution |
| 261 | 294 | // Query_id if you have a group by clause getDocumentListWithinTag getDocumentListWithinComment or used again to perform the query because |
@@ -265,11 +298,15 @@ discard block |
||
| 265 | 298 | $group_args = clone($args); |
| 266 | 299 | $group_args->sort_index = 'documents.'.$args->sort_index; |
| 267 | 300 | $output = executeQueryArray($query_id, $group_args); |
| 268 | - if(!$output->toBool()||!count($output->data)) return $output; |
|
| 301 | + if(!$output->toBool()||!count($output->data)) { |
|
| 302 | + return $output; |
|
| 303 | + } |
|
| 269 | 304 | |
| 270 | 305 | foreach($output->data as $key => $val) |
| 271 | 306 | { |
| 272 | - if($val->document_srl) $target_srls[] = $val->document_srl; |
|
| 307 | + if($val->document_srl) { |
|
| 308 | + $target_srls[] = $val->document_srl; |
|
| 309 | + } |
|
| 273 | 310 | } |
| 274 | 311 | |
| 275 | 312 | $page_navigation = $output->page_navigation; |
@@ -287,14 +324,15 @@ discard block |
||
| 287 | 324 | $output->total_count = $page_navigation->total_count; |
| 288 | 325 | $output->total_page = $page_navigation->total_page; |
| 289 | 326 | $output->page = $page_navigation->cur_page; |
| 290 | - } |
|
| 291 | - else |
|
| 327 | + } else |
|
| 292 | 328 | { |
| 293 | 329 | $output = executeQueryArray($query_id, $args, $columnList); |
| 294 | 330 | } |
| 295 | 331 | } |
| 296 | 332 | // Return if no result or an error occurs |
| 297 | - if(!$output->toBool()||!count($output->data)) return $output; |
|
| 333 | + if(!$output->toBool()||!count($output->data)) { |
|
| 334 | + return $output; |
|
| 335 | + } |
|
| 298 | 336 | $idx = 0; |
| 299 | 337 | $data = $output->data; |
| 300 | 338 | unset($output->data); |
@@ -309,20 +347,26 @@ discard block |
||
| 309 | 347 | { |
| 310 | 348 | foreach($data as $key => $attribute) |
| 311 | 349 | { |
| 312 | - if($attribute->is_notice == 'Y') $virtual_number --; |
|
| 350 | + if($attribute->is_notice == 'Y') { |
|
| 351 | + $virtual_number --; |
|
| 352 | + } |
|
| 313 | 353 | } |
| 314 | 354 | } |
| 315 | 355 | |
| 316 | 356 | foreach($data as $key => $attribute) |
| 317 | 357 | { |
| 318 | - if($except_notice && $attribute->is_notice == 'Y') continue; |
|
| 358 | + if($except_notice && $attribute->is_notice == 'Y') { |
|
| 359 | + continue; |
|
| 360 | + } |
|
| 319 | 361 | $document_srl = $attribute->document_srl; |
| 320 | 362 | if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
| 321 | 363 | { |
| 322 | 364 | $oDocument = null; |
| 323 | 365 | $oDocument = new documentItem(); |
| 324 | 366 | $oDocument->setAttribute($attribute, false); |
| 325 | - if($is_admin) $oDocument->setGrant(); |
|
| 367 | + if($is_admin) { |
|
| 368 | + $oDocument->setGrant(); |
|
| 369 | + } |
|
| 326 | 370 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
| 327 | 371 | } |
| 328 | 372 | |
@@ -330,7 +374,9 @@ discard block |
||
| 330 | 374 | $virtual_number--; |
| 331 | 375 | } |
| 332 | 376 | |
| 333 | - if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
| 377 | + if($load_extra_vars) { |
|
| 378 | + $this->setToAllDocumentExtraVars(); |
|
| 379 | + } |
|
| 334 | 380 | |
| 335 | 381 | if(count($output->data)) |
| 336 | 382 | { |
@@ -358,12 +404,16 @@ discard block |
||
| 358 | 404 | $args->module_srl = $obj->module_srl; |
| 359 | 405 | $args->category_srl= $obj->category_srl; |
| 360 | 406 | $output = executeQueryArray('document.getNoticeList', $args, $columnList); |
| 361 | - if(!$output->toBool()||!$output->data) return; |
|
| 407 | + if(!$output->toBool()||!$output->data) { |
|
| 408 | + return; |
|
| 409 | + } |
|
| 362 | 410 | |
| 363 | 411 | foreach($output->data as $key => $val) |
| 364 | 412 | { |
| 365 | 413 | $document_srl = $val->document_srl; |
| 366 | - if(!$document_srl) continue; |
|
| 414 | + if(!$document_srl) { |
|
| 415 | + continue; |
|
| 416 | + } |
|
| 367 | 417 | |
| 368 | 418 | if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
| 369 | 419 | { |
@@ -459,7 +509,9 @@ discard block |
||
| 459 | 509 | |
| 460 | 510 | $oExtraVar->setExtraVarKeys($output->data); |
| 461 | 511 | $keys = $oExtraVar->getExtraVars(); |
| 462 | - if(!$keys) $keys = array(); |
|
| 512 | + if(!$keys) { |
|
| 513 | + $keys = array(); |
|
| 514 | + } |
|
| 463 | 515 | |
| 464 | 516 | if($oCacheHandler->isSupport()) |
| 465 | 517 | { |
@@ -489,7 +541,9 @@ discard block |
||
| 489 | 541 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
| 490 | 542 | $this->setToAllDocumentExtraVars(); |
| 491 | 543 | } |
| 492 | - if(is_array($GLOBALS['XE_EXTRA_VARS'][$document_srl])) ksort($GLOBALS['XE_EXTRA_VARS'][$document_srl]); |
|
| 544 | + if(is_array($GLOBALS['XE_EXTRA_VARS'][$document_srl])) { |
|
| 545 | + ksort($GLOBALS['XE_EXTRA_VARS'][$document_srl]); |
|
| 546 | + } |
|
| 493 | 547 | return $GLOBALS['XE_EXTRA_VARS'][$document_srl]; |
| 494 | 548 | } |
| 495 | 549 | |
@@ -519,7 +573,9 @@ discard block |
||
| 519 | 573 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList); |
| 520 | 574 | $module_srl = $oDocument->get('module_srl'); |
| 521 | 575 | $member_srl = $oDocument->get('member_srl'); |
| 522 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 576 | + if(!$module_srl) { |
|
| 577 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
| 578 | + } |
|
| 523 | 579 | |
| 524 | 580 | $oModuleModel = getModel('module'); |
| 525 | 581 | $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
@@ -592,7 +648,9 @@ discard block |
||
| 592 | 648 | */ |
| 593 | 649 | function getDocumentCount($module_srl, $search_obj = NULL) |
| 594 | 650 | { |
| 595 | - if(is_null($search_obj)) $search_obj = new stdClass(); |
|
| 651 | + if(is_null($search_obj)) { |
|
| 652 | + $search_obj = new stdClass(); |
|
| 653 | + } |
|
| 596 | 654 | $search_obj->module_srl = $module_srl; |
| 597 | 655 | |
| 598 | 656 | $output = executeQuery('document.getDocumentCount', $search_obj); |
@@ -609,7 +667,9 @@ discard block |
||
| 609 | 667 | function getDocumentCountByGroupStatus($search_obj = NULL) |
| 610 | 668 | { |
| 611 | 669 | $output = executeQuery('document.getDocumentCountByGroupStatus', $search_obj); |
| 612 | - if(!$output->toBool()) return array(); |
|
| 670 | + if(!$output->toBool()) { |
|
| 671 | + return array(); |
|
| 672 | + } |
|
| 613 | 673 | |
| 614 | 674 | return $output->data; |
| 615 | 675 | } |
@@ -648,34 +708,29 @@ discard block |
||
| 648 | 708 | if($sort_check->isExtraVars) |
| 649 | 709 | { |
| 650 | 710 | return 1; |
| 651 | - } |
|
| 652 | - else |
|
| 711 | + } else |
|
| 653 | 712 | { |
| 654 | 713 | if($sort_check->sort_index === 'list_order' || $sort_check->sort_index === 'update_order') |
| 655 | 714 | { |
| 656 | 715 | if($args->order_type === 'desc') |
| 657 | 716 | { |
| 658 | 717 | $args->{'rev_' . $sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
| 659 | - } |
|
| 660 | - else |
|
| 718 | + } else |
|
| 661 | 719 | { |
| 662 | 720 | $args->{$sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
| 663 | 721 | } |
| 664 | - } |
|
| 665 | - elseif($sort_check->sort_index === 'regdate') |
|
| 722 | + } elseif($sort_check->sort_index === 'regdate') |
|
| 666 | 723 | { |
| 667 | 724 | |
| 668 | 725 | if($args->order_type === 'asc') |
| 669 | 726 | { |
| 670 | 727 | $args->{'rev_' . $sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
| 671 | - } |
|
| 672 | - else |
|
| 728 | + } else |
|
| 673 | 729 | { |
| 674 | 730 | $args->{$sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
| 675 | 731 | } |
| 676 | 732 | |
| 677 | - } |
|
| 678 | - else |
|
| 733 | + } else |
|
| 679 | 734 | { |
| 680 | 735 | return 1; |
| 681 | 736 | } |
@@ -701,15 +756,16 @@ discard block |
||
| 701 | 756 | $output = executeQuery('document.getCategory', $args, $columnList); |
| 702 | 757 | |
| 703 | 758 | $node = $output->data; |
| 704 | - if(!$node) return; |
|
| 759 | + if(!$node) { |
|
| 760 | + return; |
|
| 761 | + } |
|
| 705 | 762 | |
| 706 | 763 | if($node->group_srls) |
| 707 | 764 | { |
| 708 | 765 | $group_srls = explode(',',$node->group_srls); |
| 709 | 766 | unset($node->group_srls); |
| 710 | 767 | $node->group_srls = $group_srls; |
| 711 | - } |
|
| 712 | - else |
|
| 768 | + } else |
|
| 713 | 769 | { |
| 714 | 770 | unset($node->group_srls); |
| 715 | 771 | $node->group_srls = array(); |
@@ -727,7 +783,9 @@ discard block |
||
| 727 | 783 | $args = new stdClass(); |
| 728 | 784 | $args->category_srl = $category_srl; |
| 729 | 785 | $output = executeQuery('document.getChildCategoryCount',$args); |
| 730 | - if($output->data->count > 0) return true; |
|
| 786 | + if($output->data->count > 0) { |
|
| 787 | + return true; |
|
| 788 | + } |
|
| 731 | 789 | return false; |
| 732 | 790 | } |
| 733 | 791 | |
@@ -746,7 +804,9 @@ discard block |
||
| 746 | 804 | if(!file_exists($filename)) |
| 747 | 805 | { |
| 748 | 806 | $oDocumentController = getController('document'); |
| 749 | - if(!$oDocumentController->makeCategoryFile($module_srl)) return array(); |
|
| 807 | + if(!$oDocumentController->makeCategoryFile($module_srl)) { |
|
| 808 | + return array(); |
|
| 809 | + } |
|
| 750 | 810 | } |
| 751 | 811 | |
| 752 | 812 | include($filename); |
@@ -766,7 +826,9 @@ discard block |
||
| 766 | 826 | */ |
| 767 | 827 | function _arrangeCategory(&$document_category, $list, $depth) |
| 768 | 828 | { |
| 769 | - if(!count($list)) return; |
|
| 829 | + if(!count($list)) { |
|
| 830 | + return; |
|
| 831 | + } |
|
| 770 | 832 | $idx = 0; |
| 771 | 833 | $list_order = array(); |
| 772 | 834 | foreach($list as $key => $val) |
@@ -786,8 +848,11 @@ discard block |
||
| 786 | 848 | $obj->childs = array(); |
| 787 | 849 | $obj->grant = $val['grant']; |
| 788 | 850 | |
| 789 | - if(Context::get('mid') == $obj->mid && Context::get('category') == $obj->category_srl) $selected = true; |
|
| 790 | - else $selected = false; |
|
| 851 | + if(Context::get('mid') == $obj->mid && Context::get('category') == $obj->category_srl) { |
|
| 852 | + $selected = true; |
|
| 853 | + } else { |
|
| 854 | + $selected = false; |
|
| 855 | + } |
|
| 791 | 856 | |
| 792 | 857 | $obj->selected = $selected; |
| 793 | 858 | |
@@ -798,14 +863,18 @@ discard block |
||
| 798 | 863 | $parent_srl = $obj->parent_srl; |
| 799 | 864 | $document_count = $obj->document_count; |
| 800 | 865 | $expand = $obj->expand; |
| 801 | - if($selected) $expand = true; |
|
| 866 | + if($selected) { |
|
| 867 | + $expand = true; |
|
| 868 | + } |
|
| 802 | 869 | |
| 803 | 870 | while($parent_srl) |
| 804 | 871 | { |
| 805 | 872 | $document_category[$parent_srl]->document_count += $document_count; |
| 806 | 873 | $document_category[$parent_srl]->childs[] = $obj->category_srl; |
| 807 | 874 | $document_category[$parent_srl]->child_count = count($document_category[$parent_srl]->childs); |
| 808 | - if($expand) $document_category[$parent_srl]->expand = $expand; |
|
| 875 | + if($expand) { |
|
| 876 | + $document_category[$parent_srl]->expand = $expand; |
|
| 877 | + } |
|
| 809 | 878 | |
| 810 | 879 | $parent_srl = $document_category[$parent_srl]->parent_srl; |
| 811 | 880 | } |
@@ -813,7 +882,9 @@ discard block |
||
| 813 | 882 | |
| 814 | 883 | $document_category[$key] = $obj; |
| 815 | 884 | |
| 816 | - if(count($val['list'])) $this->_arrangeCategory($document_category, $val['list'], $depth+1); |
|
| 885 | + if(count($val['list'])) { |
|
| 886 | + $this->_arrangeCategory($document_category, $val['list'], $depth+1); |
|
| 887 | + } |
|
| 817 | 888 | } |
| 818 | 889 | $document_category[$list_order[0]]->first = true; |
| 819 | 890 | $document_category[$list_order[count($list_order)-1]]->last = true; |
@@ -881,13 +952,20 @@ discard block |
||
| 881 | 952 | } |
| 882 | 953 | // Module_srl passed the array may be a check whether the array |
| 883 | 954 | $args = new stdClass; |
| 884 | - if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
| 885 | - else $args->module_srl = $obj->module_srl; |
|
| 955 | + if(is_array($obj->module_srl)) { |
|
| 956 | + $args->module_srl = implode(',', $obj->module_srl); |
|
| 957 | + } else { |
|
| 958 | + $args->module_srl = $obj->module_srl; |
|
| 959 | + } |
|
| 886 | 960 | |
| 887 | 961 | $output = executeQuery('document.getMonthlyArchivedList', $args); |
| 888 | - if(!$output->toBool()||!$output->data) return $output; |
|
| 962 | + if(!$output->toBool()||!$output->data) { |
|
| 963 | + return $output; |
|
| 964 | + } |
|
| 889 | 965 | |
| 890 | - if(!is_array($output->data)) $output->data = array($output->data); |
|
| 966 | + if(!is_array($output->data)) { |
|
| 967 | + $output->data = array($output->data); |
|
| 968 | + } |
|
| 891 | 969 | |
| 892 | 970 | return $output; |
| 893 | 971 | } |
@@ -907,14 +985,21 @@ discard block |
||
| 907 | 985 | } |
| 908 | 986 | // Module_srl passed the array may be a check whether the array |
| 909 | 987 | $args = new stdClass; |
| 910 | - if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
| 911 | - else $args->module_srl = $obj->module_srl; |
|
| 988 | + if(is_array($obj->module_srl)) { |
|
| 989 | + $args->module_srl = implode(',', $obj->module_srl); |
|
| 990 | + } else { |
|
| 991 | + $args->module_srl = $obj->module_srl; |
|
| 992 | + } |
|
| 912 | 993 | $args->regdate = $obj->regdate; |
| 913 | 994 | |
| 914 | 995 | $output = executeQuery('document.getDailyArchivedList', $args); |
| 915 | - if(!$output->toBool()) return $output; |
|
| 996 | + if(!$output->toBool()) { |
|
| 997 | + return $output; |
|
| 998 | + } |
|
| 916 | 999 | |
| 917 | - if(!is_array($output->data)) $output->data = array($output->data); |
|
| 1000 | + if(!is_array($output->data)) { |
|
| 1001 | + $output->data = array($output->data); |
|
| 1002 | + } |
|
| 918 | 1003 | |
| 919 | 1004 | return $output; |
| 920 | 1005 | } |
@@ -925,7 +1010,9 @@ discard block |
||
| 925 | 1010 | */ |
| 926 | 1011 | function getDocumentCategories() |
| 927 | 1012 | { |
| 928 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
| 1013 | + if(!Context::get('is_logged')) { |
|
| 1014 | + return new BaseObject(-1,'msg_not_permitted'); |
|
| 1015 | + } |
|
| 929 | 1016 | $module_srl = Context::get('module_srl'); |
| 930 | 1017 | $categories= $this->getCategoryList($module_srl); |
| 931 | 1018 | $lang = Context::get('lang'); |
@@ -1020,7 +1107,9 @@ discard block |
||
| 1020 | 1107 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); |
| 1021 | 1108 | // Check permissions |
| 1022 | 1109 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1023 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
| 1110 | + if(!$grant->manager) { |
|
| 1111 | + return new BaseObject(-1,'msg_not_permitted'); |
|
| 1112 | + } |
|
| 1024 | 1113 | |
| 1025 | 1114 | $category_srl = Context::get('category_srl'); |
| 1026 | 1115 | $category_info = $this->getCategory($category_srl); |
@@ -1040,15 +1129,20 @@ discard block |
||
| 1040 | 1129 | */ |
| 1041 | 1130 | function getDocumentSrlByAlias($mid, $alias) |
| 1042 | 1131 | { |
| 1043 | - if(!$mid || !$alias) return null; |
|
| 1132 | + if(!$mid || !$alias) { |
|
| 1133 | + return null; |
|
| 1134 | + } |
|
| 1044 | 1135 | $site_module_info = Context::get('site_module_info'); |
| 1045 | 1136 | $args = new stdClass; |
| 1046 | 1137 | $args->mid = $mid; |
| 1047 | 1138 | $args->alias_title = $alias; |
| 1048 | 1139 | $args->site_srl = $site_module_info->site_srl; |
| 1049 | 1140 | $output = executeQuery('document.getDocumentSrlByAlias', $args); |
| 1050 | - if(!$output->data) return null; |
|
| 1051 | - else return $output->data->document_srl; |
|
| 1141 | + if(!$output->data) { |
|
| 1142 | + return null; |
|
| 1143 | + } else { |
|
| 1144 | + return $output->data->document_srl; |
|
| 1145 | + } |
|
| 1052 | 1146 | } |
| 1053 | 1147 | |
| 1054 | 1148 | /** |
@@ -1059,15 +1153,20 @@ discard block |
||
| 1059 | 1153 | */ |
| 1060 | 1154 | function getDocumentSrlByTitle($module_srl, $title) |
| 1061 | 1155 | { |
| 1062 | - if(!$module_srl || !$title) return null; |
|
| 1156 | + if(!$module_srl || !$title) { |
|
| 1157 | + return null; |
|
| 1158 | + } |
|
| 1063 | 1159 | $args = new stdClass; |
| 1064 | 1160 | $args->module_srl = $module_srl; |
| 1065 | 1161 | $args->title = $title; |
| 1066 | 1162 | $output = executeQuery('document.getDocumentSrlByTitle', $args); |
| 1067 | - if(!$output->data) return null; |
|
| 1068 | - else |
|
| 1163 | + if(!$output->data) { |
|
| 1164 | + return null; |
|
| 1165 | + } else |
|
| 1069 | 1166 | { |
| 1070 | - if(is_array($output->data)) return $output->data[0]->document_srl; |
|
| 1167 | + if(is_array($output->data)) { |
|
| 1168 | + return $output->data[0]->document_srl; |
|
| 1169 | + } |
|
| 1071 | 1170 | return $output->data->document_srl; |
| 1072 | 1171 | } |
| 1073 | 1172 | } |
@@ -1079,13 +1178,18 @@ discard block |
||
| 1079 | 1178 | */ |
| 1080 | 1179 | function getAlias($document_srl) |
| 1081 | 1180 | { |
| 1082 | - if(!$document_srl) return null; |
|
| 1181 | + if(!$document_srl) { |
|
| 1182 | + return null; |
|
| 1183 | + } |
|
| 1083 | 1184 | $args = new stdClass; |
| 1084 | 1185 | $args->document_srl = $document_srl; |
| 1085 | 1186 | $output = executeQueryArray('document.getAliases', $args); |
| 1086 | 1187 | |
| 1087 | - if(!$output->data) return null; |
|
| 1088 | - else return $output->data[0]->alias_title; |
|
| 1188 | + if(!$output->data) { |
|
| 1189 | + return null; |
|
| 1190 | + } else { |
|
| 1191 | + return $output->data[0]->alias_title; |
|
| 1192 | + } |
|
| 1089 | 1193 | } |
| 1090 | 1194 | |
| 1091 | 1195 | /** |
@@ -1142,17 +1246,23 @@ discard block |
||
| 1142 | 1246 | { |
| 1143 | 1247 | case 'title' : |
| 1144 | 1248 | case 'content' : |
| 1145 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1249 | + if($search_keyword) { |
|
| 1250 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1251 | + } |
|
| 1146 | 1252 | $args->{"s_".$search_target} = $search_keyword; |
| 1147 | 1253 | $use_division = true; |
| 1148 | 1254 | break; |
| 1149 | 1255 | case 'title_content' : |
| 1150 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1256 | + if($search_keyword) { |
|
| 1257 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1258 | + } |
|
| 1151 | 1259 | $args->s_title = $search_keyword; |
| 1152 | 1260 | $args->s_content = $search_keyword; |
| 1153 | 1261 | break; |
| 1154 | 1262 | case 'user_id' : |
| 1155 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1263 | + if($search_keyword) { |
|
| 1264 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1265 | + } |
|
| 1156 | 1266 | $args->s_user_id = $search_keyword; |
| 1157 | 1267 | $args->sort_index = 'documents.'.$args->sort_index; |
| 1158 | 1268 | break; |
@@ -1160,13 +1270,18 @@ discard block |
||
| 1160 | 1270 | case 'nick_name' : |
| 1161 | 1271 | case 'email_address' : |
| 1162 | 1272 | case 'homepage' : |
| 1163 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1273 | + if($search_keyword) { |
|
| 1274 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1275 | + } |
|
| 1164 | 1276 | $args->{"s_".$search_target} = $search_keyword; |
| 1165 | 1277 | break; |
| 1166 | 1278 | case 'is_notice' : |
| 1167 | 1279 | case 'is_secret' : |
| 1168 | - if($search_keyword=='N') $args->statusList = array($this->getConfigStatus('public')); |
|
| 1169 | - elseif($search_keyword=='Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
| 1280 | + if($search_keyword=='N') { |
|
| 1281 | + $args->statusList = array($this->getConfigStatus('public')); |
|
| 1282 | + } elseif($search_keyword=='Y') { |
|
| 1283 | + $args->statusList = array($this->getConfigStatus('secret')); |
|
| 1284 | + } |
|
| 1170 | 1285 | break; |
| 1171 | 1286 | case 'member_srl' : |
| 1172 | 1287 | case 'readed_count' : |
@@ -1208,34 +1323,45 @@ discard block |
||
| 1208 | 1323 | { |
| 1209 | 1324 | $args = new stdClass; |
| 1210 | 1325 | $document_srl = Context::get('document_srl'); |
| 1211 | - if(!$document_srl) return new BaseObject(-1,'msg_invalid_request'); |
|
| 1326 | + if(!$document_srl) { |
|
| 1327 | + return new BaseObject(-1,'msg_invalid_request'); |
|
| 1328 | + } |
|
| 1212 | 1329 | |
| 1213 | 1330 | $point = Context::get('point'); |
| 1214 | - if($point != -1) $point = 1; |
|
| 1331 | + if($point != -1) { |
|
| 1332 | + $point = 1; |
|
| 1333 | + } |
|
| 1215 | 1334 | |
| 1216 | 1335 | $oDocumentModel = getModel('document'); |
| 1217 | 1336 | $columnList = array('document_srl', 'module_srl'); |
| 1218 | 1337 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList); |
| 1219 | 1338 | $module_srl = $oDocument->get('module_srl'); |
| 1220 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 1339 | + if(!$module_srl) { |
|
| 1340 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
| 1341 | + } |
|
| 1221 | 1342 | |
| 1222 | 1343 | $oModuleModel = getModel('module'); |
| 1223 | 1344 | $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
| 1224 | 1345 | if($point == -1) |
| 1225 | 1346 | { |
| 1226 | - if($document_config->use_vote_down!='S') return new BaseObject(-1, 'msg_invalid_request'); |
|
| 1347 | + if($document_config->use_vote_down!='S') { |
|
| 1348 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
| 1349 | + } |
|
| 1227 | 1350 | $args->below_point = 0; |
| 1228 | - } |
|
| 1229 | - else |
|
| 1351 | + } else |
|
| 1230 | 1352 | { |
| 1231 | - if($document_config->use_vote_up!='S') return new BaseObject(-1, 'msg_invalid_request'); |
|
| 1353 | + if($document_config->use_vote_up!='S') { |
|
| 1354 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
| 1355 | + } |
|
| 1232 | 1356 | $args->more_point = 0; |
| 1233 | 1357 | } |
| 1234 | 1358 | |
| 1235 | 1359 | $args->document_srl = $document_srl; |
| 1236 | 1360 | |
| 1237 | 1361 | $output = executeQueryArray('document.getVotedMemberList',$args); |
| 1238 | - if(!$output->toBool()) return $output; |
|
| 1362 | + if(!$output->toBool()) { |
|
| 1363 | + return $output; |
|
| 1364 | + } |
|
| 1239 | 1365 | |
| 1240 | 1366 | $oMemberModel = getModel('member'); |
| 1241 | 1367 | if($output->data) |
@@ -1257,9 +1383,11 @@ discard block |
||
| 1257 | 1383 | function getStatusNameList() |
| 1258 | 1384 | { |
| 1259 | 1385 | global $lang; |
| 1260 | - if(!isset($lang->status_name_list)) |
|
| 1261 | - return array_flip($this->getStatusList()); |
|
| 1262 | - else return $lang->status_name_list; |
|
| 1386 | + if(!isset($lang->status_name_list)) { |
|
| 1387 | + return array_flip($this->getStatusList()); |
|
| 1388 | + } else { |
|
| 1389 | + return $lang->status_name_list; |
|
| 1390 | + } |
|
| 1263 | 1391 | } |
| 1264 | 1392 | |
| 1265 | 1393 | /** |
@@ -1283,20 +1411,22 @@ discard block |
||
| 1283 | 1411 | if (!$extra_output->data || !$extra_output->toBool()) |
| 1284 | 1412 | { |
| 1285 | 1413 | $sortIndex = 'list_order'; |
| 1286 | - } |
|
| 1287 | - else |
|
| 1414 | + } else |
|
| 1288 | 1415 | { |
| 1289 | 1416 | $check_array = array(); |
| 1290 | 1417 | foreach($extra_output->data as $val) |
| 1291 | 1418 | { |
| 1292 | 1419 | $check_array[] = $val->eid; |
| 1293 | 1420 | } |
| 1294 | - if(!in_array($sortIndex, $check_array)) $sortIndex = 'list_order'; |
|
| 1295 | - else $isExtraVars = true; |
|
| 1421 | + if(!in_array($sortIndex, $check_array)) { |
|
| 1422 | + $sortIndex = 'list_order'; |
|
| 1423 | + } else { |
|
| 1424 | + $isExtraVars = true; |
|
| 1425 | + } |
|
| 1296 | 1426 | } |
| 1427 | + } else { |
|
| 1428 | + $sortIndex = 'list_order'; |
|
| 1297 | 1429 | } |
| 1298 | - else |
|
| 1299 | - $sortIndex = 'list_order'; |
|
| 1300 | 1430 | } |
| 1301 | 1431 | $returnObj = new stdClass(); |
| 1302 | 1432 | $returnObj->sort_index = $sortIndex; |
@@ -1334,7 +1464,9 @@ discard block |
||
| 1334 | 1464 | |
| 1335 | 1465 | // Check the target and sequence alignment |
| 1336 | 1466 | $orderType = array('desc' => 1, 'asc' => 1); |
| 1337 | - if(!isset($orderType[$args->order_type])) $args->order_type = 'asc'; |
|
| 1467 | + if(!isset($orderType[$args->order_type])) { |
|
| 1468 | + $args->order_type = 'asc'; |
|
| 1469 | + } |
|
| 1338 | 1470 | |
| 1339 | 1471 | // If that came across mid module_srl instead of a direct module_srl guhaejum |
| 1340 | 1472 | if($searchOpt->mid) |
@@ -1345,21 +1477,29 @@ discard block |
||
| 1345 | 1477 | } |
| 1346 | 1478 | |
| 1347 | 1479 | // Module_srl passed the array may be a check whether the array |
| 1348 | - if(is_array($searchOpt->module_srl)) $args->module_srl = implode(',', $searchOpt->module_srl); |
|
| 1349 | - else $args->module_srl = $searchOpt->module_srl; |
|
| 1480 | + if(is_array($searchOpt->module_srl)) { |
|
| 1481 | + $args->module_srl = implode(',', $searchOpt->module_srl); |
|
| 1482 | + } else { |
|
| 1483 | + $args->module_srl = $searchOpt->module_srl; |
|
| 1484 | + } |
|
| 1350 | 1485 | |
| 1351 | 1486 | // Except for the test module_srl |
| 1352 | - if(is_array($searchOpt->exclude_module_srl)) $args->exclude_module_srl = implode(',', $searchOpt->exclude_module_srl); |
|
| 1353 | - else $args->exclude_module_srl = $searchOpt->exclude_module_srl; |
|
| 1487 | + if(is_array($searchOpt->exclude_module_srl)) { |
|
| 1488 | + $args->exclude_module_srl = implode(',', $searchOpt->exclude_module_srl); |
|
| 1489 | + } else { |
|
| 1490 | + $args->exclude_module_srl = $searchOpt->exclude_module_srl; |
|
| 1491 | + } |
|
| 1354 | 1492 | |
| 1355 | 1493 | // only admin document list, temp document showing |
| 1356 | - if($searchOpt->statusList) $args->statusList = $searchOpt->statusList; |
|
| 1357 | - else |
|
| 1494 | + if($searchOpt->statusList) { |
|
| 1495 | + $args->statusList = $searchOpt->statusList; |
|
| 1496 | + } else |
|
| 1358 | 1497 | { |
| 1359 | - if($logged_info->is_admin == 'Y' && !$searchOpt->module_srl) |
|
| 1360 | - $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public'), $this->getConfigStatus('temp')); |
|
| 1361 | - else |
|
| 1362 | - $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public')); |
|
| 1498 | + if($logged_info->is_admin == 'Y' && !$searchOpt->module_srl) { |
|
| 1499 | + $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public'), $this->getConfigStatus('temp')); |
|
| 1500 | + } else { |
|
| 1501 | + $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public')); |
|
| 1502 | + } |
|
| 1363 | 1503 | } |
| 1364 | 1504 | |
| 1365 | 1505 | // Category is selected, further sub-categories until all conditions |
@@ -1387,18 +1527,24 @@ discard block |
||
| 1387 | 1527 | { |
| 1388 | 1528 | case 'title' : |
| 1389 | 1529 | case 'content' : |
| 1390 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1530 | + if($search_keyword) { |
|
| 1531 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1532 | + } |
|
| 1391 | 1533 | $args->{"s_".$search_target} = $search_keyword; |
| 1392 | 1534 | $use_division = true; |
| 1393 | 1535 | break; |
| 1394 | 1536 | case 'title_content' : |
| 1395 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1537 | + if($search_keyword) { |
|
| 1538 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1539 | + } |
|
| 1396 | 1540 | $args->s_title = $search_keyword; |
| 1397 | 1541 | $args->s_content = $search_keyword; |
| 1398 | 1542 | $use_division = true; |
| 1399 | 1543 | break; |
| 1400 | 1544 | case 'user_id' : |
| 1401 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1545 | + if($search_keyword) { |
|
| 1546 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1547 | + } |
|
| 1402 | 1548 | $args->s_user_id = $search_keyword; |
| 1403 | 1549 | $args->sort_index = 'documents.'.$args->sort_index; |
| 1404 | 1550 | break; |
@@ -1406,18 +1552,28 @@ discard block |
||
| 1406 | 1552 | case 'nick_name' : |
| 1407 | 1553 | case 'email_address' : |
| 1408 | 1554 | case 'homepage' : |
| 1409 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1555 | + if($search_keyword) { |
|
| 1556 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1557 | + } |
|
| 1410 | 1558 | $args->{"s_".$search_target} = $search_keyword; |
| 1411 | 1559 | break; |
| 1412 | 1560 | case 'is_notice' : |
| 1413 | - if($search_keyword=='N') $args->{"s_".$search_target} = 'N'; |
|
| 1414 | - elseif($search_keyword=='Y') $args->{"s_".$search_target} = 'Y'; |
|
| 1415 | - else $args->{"s_".$search_target} = ''; |
|
| 1561 | + if($search_keyword=='N') { |
|
| 1562 | + $args->{"s_".$search_target} = 'N'; |
|
| 1563 | + } elseif($search_keyword=='Y') { |
|
| 1564 | + $args->{"s_".$search_target} = 'Y'; |
|
| 1565 | + } else { |
|
| 1566 | + $args->{"s_".$search_target} = ''; |
|
| 1567 | + } |
|
| 1416 | 1568 | break; |
| 1417 | 1569 | case 'is_secret' : |
| 1418 | - if($search_keyword=='N') $args->statusList = array($this->getConfigStatus('public')); |
|
| 1419 | - elseif($search_keyword=='Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
| 1420 | - elseif($search_keyword=='temp') $args->statusList = array($this->getConfigStatus('temp')); |
|
| 1570 | + if($search_keyword=='N') { |
|
| 1571 | + $args->statusList = array($this->getConfigStatus('public')); |
|
| 1572 | + } elseif($search_keyword=='Y') { |
|
| 1573 | + $args->statusList = array($this->getConfigStatus('secret')); |
|
| 1574 | + } elseif($search_keyword=='temp') { |
|
| 1575 | + $args->statusList = array($this->getConfigStatus('temp')); |
|
| 1576 | + } |
|
| 1421 | 1577 | break; |
| 1422 | 1578 | case 'member_srl' : |
| 1423 | 1579 | case 'readed_count' : |
@@ -1462,13 +1618,14 @@ discard block |
||
| 1462 | 1618 | if ($searchOpt->isExtraVars) |
| 1463 | 1619 | { |
| 1464 | 1620 | $query_id = 'document.getDocumentListExtraSort'; |
| 1465 | - } |
|
| 1466 | - else |
|
| 1621 | + } else |
|
| 1467 | 1622 | { |
| 1468 | 1623 | /** |
| 1469 | 1624 | * list_order asc sort of division that can be used only when |
| 1470 | 1625 | */ |
| 1471 | - if($args->sort_index != 'list_order' || $args->order_type != 'asc') $use_division = false; |
|
| 1626 | + if($args->sort_index != 'list_order' || $args->order_type != 'asc') { |
|
| 1627 | + $use_division = false; |
|
| 1628 | + } |
|
| 1472 | 1629 | |
| 1473 | 1630 | /** |
| 1474 | 1631 | * If it is true, use_division changed to use the document division |
@@ -1483,8 +1640,7 @@ discard block |
||
| 1483 | 1640 | { |
| 1484 | 1641 | $listSqlID = 'document.getDocumentListUseIndex'; |
| 1485 | 1642 | $divisionSqlID = 'document.getDocumentDivisionUseIndex'; |
| 1486 | - } |
|
| 1487 | - else |
|
| 1643 | + } else |
|
| 1488 | 1644 | { |
| 1489 | 1645 | $listSqlID = 'document.getDocumentList'; |
| 1490 | 1646 | $divisionSqlID = 'document.getDocumentDivision'; |
@@ -1541,7 +1697,9 @@ discard block |
||
| 1541 | 1697 | $last_division_args->exclude_module_srl = $args->exclude_module_srl; |
| 1542 | 1698 | $last_division_args->list_order = $last_division; |
| 1543 | 1699 | $output = executeQuery('document.getDocumentDivisionCount', $last_division_args); |
| 1544 | - if($output->data->count<1) $last_division = null; |
|
| 1700 | + if($output->data->count<1) { |
|
| 1701 | + $last_division = null; |
|
| 1702 | + } |
|
| 1545 | 1703 | } |
| 1546 | 1704 | |
| 1547 | 1705 | $args->division = $division; |
@@ -1582,8 +1740,12 @@ discard block |
||
| 1582 | 1740 | $output = executeQuery('document.getDocumentListByMemberSrl', $args, $columnList); |
| 1583 | 1741 | $document_list = $output->data; |
| 1584 | 1742 | |
| 1585 | - if(!$document_list) return array(); |
|
| 1586 | - if(!is_array($document_list)) $document_list = array($document_list); |
|
| 1743 | + if(!$document_list) { |
|
| 1744 | + return array(); |
|
| 1745 | + } |
|
| 1746 | + if(!is_array($document_list)) { |
|
| 1747 | + $document_list = array($document_list); |
|
| 1748 | + } |
|
| 1587 | 1749 | |
| 1588 | 1750 | return $document_list; |
| 1589 | 1751 | } |
@@ -1598,8 +1760,7 @@ discard block |
||
| 1598 | 1760 | if(Mobile::isFromMobilePhone()) |
| 1599 | 1761 | { |
| 1600 | 1762 | $iconSkin = $documentConfig->micons; |
| 1601 | - } |
|
| 1602 | - else |
|
| 1763 | + } else |
|
| 1603 | 1764 | { |
| 1604 | 1765 | $iconSkin = $documentConfig->icons; |
| 1605 | 1766 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * Preview |
| 55 | - * @return void |
|
| 55 | + * @return BaseObject|null |
|
| 56 | 56 | */ |
| 57 | 57 | function dispDocumentPreview() |
| 58 | 58 | { |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | /** |
| 157 | 157 | * Document temp saved list |
| 158 | - * @return void |
|
| 158 | + * @return ModuleObject|null |
|
| 159 | 159 | */ |
| 160 | 160 | function dispTempSavedList() |
| 161 | 161 | { |
@@ -36,16 +36,16 @@ discard block |
||
| 36 | 36 | $oDocumentModel = getModel('document'); |
| 37 | 37 | // Creates an object for displaying the selected document |
| 38 | 38 | $oDocument = $oDocumentModel->getDocument($document_srl, $this->grant->manager); |
| 39 | - if(!$oDocument->isExists()) return new BaseObject(-1,'msg_invalid_request'); |
|
| 39 | + if (!$oDocument->isExists()) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 40 | 40 | // Check permissions |
| 41 | - if(!$oDocument->isAccessible()) return new BaseObject(-1,'msg_not_permitted'); |
|
| 41 | + if (!$oDocument->isAccessible()) return new BaseObject(-1, 'msg_not_permitted'); |
|
| 42 | 42 | // Information setting module |
| 43 | 43 | //Context::set('module_info', $module_info); //module_info not use in UI |
| 44 | 44 | // Browser title settings |
| 45 | 45 | Context::setBrowserTitle($oDocument->getTitleText()); |
| 46 | 46 | Context::set('oDocument', $oDocument); |
| 47 | 47 | |
| 48 | - Context::set('layout','none'); |
|
| 48 | + Context::set('layout', 'none'); |
|
| 49 | 49 | $this->setTemplatePath($this->module_path.'tpl'); |
| 50 | 50 | $this->setTemplateFile('print_page'); |
| 51 | 51 | } |
@@ -56,12 +56,12 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | function dispDocumentPreview() |
| 58 | 58 | { |
| 59 | - if(!checkCSRF()) |
|
| 59 | + if (!checkCSRF()) |
|
| 60 | 60 | { |
| 61 | 61 | return new BaseObject(-1, 'msg_invalid_request'); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - if(Context::get('logged_info')->is_admin != 'Y') |
|
| 64 | + if (Context::get('logged_info')->is_admin != 'Y') |
|
| 65 | 65 | { |
| 66 | 66 | Context::set('content', removeHackTag(Context::get('content'))); |
| 67 | 67 | } |
@@ -78,19 +78,19 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | function dispDocumentManageDocument() |
| 80 | 80 | { |
| 81 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
| 81 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
| 82 | 82 | // Taken from a list of selected sessions |
| 83 | 83 | $flag_list = $_SESSION['document_management']; |
| 84 | - if(count($flag_list)) |
|
| 84 | + if (count($flag_list)) |
|
| 85 | 85 | { |
| 86 | - foreach($flag_list as $key => $val) |
|
| 86 | + foreach ($flag_list as $key => $val) |
|
| 87 | 87 | { |
| 88 | - if(!is_bool($val)) continue; |
|
| 88 | + if (!is_bool($val)) continue; |
|
| 89 | 89 | $document_srl_list[] = $key; |
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - if(count($document_srl_list)) |
|
| 93 | + if (count($document_srl_list)) |
|
| 94 | 94 | { |
| 95 | 95 | $oDocumentModel = getModel('document'); |
| 96 | 96 | $document_list = $oDocumentModel->getDocuments($document_srl_list, $this->grant->is_admin); |
@@ -99,13 +99,13 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | $oModuleModel = getModel('module'); |
| 101 | 101 | // The combination of module categories list and the list of modules |
| 102 | - if(count($module_list)>1) Context::set('module_list', $module_categories); |
|
| 102 | + if (count($module_list) > 1) Context::set('module_list', $module_categories); |
|
| 103 | 103 | |
| 104 | - $module_srl=Context::get('module_srl'); |
|
| 105 | - Context::set('module_srl',$module_srl); |
|
| 104 | + $module_srl = Context::get('module_srl'); |
|
| 105 | + Context::set('module_srl', $module_srl); |
|
| 106 | 106 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); |
| 107 | - Context::set('mid',$module_info->mid); |
|
| 108 | - Context::set('browser_title',$module_info->browser_title); |
|
| 107 | + Context::set('mid', $module_info->mid); |
|
| 108 | + Context::set('browser_title', $module_info->browser_title); |
|
| 109 | 109 | |
| 110 | 110 | // Select Pop-up layout |
| 111 | 111 | $this->setLayoutPath('./common/tpl'); |
@@ -126,24 +126,24 @@ discard block |
||
| 126 | 126 | $current_module_srl = Context::get('module_srl'); |
| 127 | 127 | $current_module_srls = Context::get('module_srls'); |
| 128 | 128 | |
| 129 | - if(!$current_module_srl && !$current_module_srls) |
|
| 129 | + if (!$current_module_srl && !$current_module_srls) |
|
| 130 | 130 | { |
| 131 | 131 | // Get information of the current module |
| 132 | 132 | $current_module_info = Context::get('current_module_info'); |
| 133 | 133 | $current_module_srl = $current_module_info->module_srl; |
| 134 | - if(!$current_module_srl) return new BaseObject(); |
|
| 134 | + if (!$current_module_srl) return new BaseObject(); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | $oModuleModel = getModel('module'); |
| 138 | - if($current_module_srl) |
|
| 138 | + if ($current_module_srl) |
|
| 139 | 139 | { |
| 140 | 140 | $document_config = $oModuleModel->getModulePartConfig('document', $current_module_srl); |
| 141 | 141 | } |
| 142 | - if(!$document_config) |
|
| 142 | + if (!$document_config) |
|
| 143 | 143 | { |
| 144 | 144 | $document_config = new stdClass(); |
| 145 | 145 | } |
| 146 | - if(!isset($document_config->use_history)) $document_config->use_history = 'N'; |
|
| 146 | + if (!isset($document_config->use_history)) $document_config->use_history = 'N'; |
|
| 147 | 147 | Context::set('document_config', $document_config); |
| 148 | 148 | |
| 149 | 149 | $oTemplate = &TemplateHandler::getInstance(); |
@@ -163,13 +163,13 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | $oMemberModel = getModel('member'); |
| 165 | 165 | // A message appears if the user is not logged-in |
| 166 | - if(!$oMemberModel->isLogged()) return $this->stop('msg_not_logged'); |
|
| 166 | + if (!$oMemberModel->isLogged()) return $this->stop('msg_not_logged'); |
|
| 167 | 167 | // Get the saved document (module_srl is set to member_srl instead) |
| 168 | 168 | $logged_info = Context::get('logged_info'); |
| 169 | 169 | $args = new stdClass(); |
| 170 | 170 | $args->member_srl = $logged_info->member_srl; |
| 171 | 171 | $args->statusList = array($this->getConfigStatus('temp')); |
| 172 | - $args->page = (int)Context::get('page'); |
|
| 172 | + $args->page = (int) Context::get('page'); |
|
| 173 | 173 | $args->list_count = 10; |
| 174 | 174 | |
| 175 | 175 | $oDocumentModel = getModel('document'); |
@@ -36,9 +36,13 @@ discard block |
||
| 36 | 36 | $oDocumentModel = getModel('document'); |
| 37 | 37 | // Creates an object for displaying the selected document |
| 38 | 38 | $oDocument = $oDocumentModel->getDocument($document_srl, $this->grant->manager); |
| 39 | - if(!$oDocument->isExists()) return new BaseObject(-1,'msg_invalid_request'); |
|
| 39 | + if(!$oDocument->isExists()) { |
|
| 40 | + return new BaseObject(-1,'msg_invalid_request'); |
|
| 41 | + } |
|
| 40 | 42 | // Check permissions |
| 41 | - if(!$oDocument->isAccessible()) return new BaseObject(-1,'msg_not_permitted'); |
|
| 43 | + if(!$oDocument->isAccessible()) { |
|
| 44 | + return new BaseObject(-1,'msg_not_permitted'); |
|
| 45 | + } |
|
| 42 | 46 | // Information setting module |
| 43 | 47 | //Context::set('module_info', $module_info); //module_info not use in UI |
| 44 | 48 | // Browser title settings |
@@ -78,14 +82,18 @@ discard block |
||
| 78 | 82 | */ |
| 79 | 83 | function dispDocumentManageDocument() |
| 80 | 84 | { |
| 81 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
| 85 | + if(!Context::get('is_logged')) { |
|
| 86 | + return new BaseObject(-1,'msg_not_permitted'); |
|
| 87 | + } |
|
| 82 | 88 | // Taken from a list of selected sessions |
| 83 | 89 | $flag_list = $_SESSION['document_management']; |
| 84 | 90 | if(count($flag_list)) |
| 85 | 91 | { |
| 86 | 92 | foreach($flag_list as $key => $val) |
| 87 | 93 | { |
| 88 | - if(!is_bool($val)) continue; |
|
| 94 | + if(!is_bool($val)) { |
|
| 95 | + continue; |
|
| 96 | + } |
|
| 89 | 97 | $document_srl_list[] = $key; |
| 90 | 98 | } |
| 91 | 99 | } |
@@ -99,7 +107,9 @@ discard block |
||
| 99 | 107 | |
| 100 | 108 | $oModuleModel = getModel('module'); |
| 101 | 109 | // The combination of module categories list and the list of modules |
| 102 | - if(count($module_list)>1) Context::set('module_list', $module_categories); |
|
| 110 | + if(count($module_list)>1) { |
|
| 111 | + Context::set('module_list', $module_categories); |
|
| 112 | + } |
|
| 103 | 113 | |
| 104 | 114 | $module_srl=Context::get('module_srl'); |
| 105 | 115 | Context::set('module_srl',$module_srl); |
@@ -131,7 +141,9 @@ discard block |
||
| 131 | 141 | // Get information of the current module |
| 132 | 142 | $current_module_info = Context::get('current_module_info'); |
| 133 | 143 | $current_module_srl = $current_module_info->module_srl; |
| 134 | - if(!$current_module_srl) return new BaseObject(); |
|
| 144 | + if(!$current_module_srl) { |
|
| 145 | + return new BaseObject(); |
|
| 146 | + } |
|
| 135 | 147 | } |
| 136 | 148 | |
| 137 | 149 | $oModuleModel = getModel('module'); |
@@ -143,7 +155,9 @@ discard block |
||
| 143 | 155 | { |
| 144 | 156 | $document_config = new stdClass(); |
| 145 | 157 | } |
| 146 | - if(!isset($document_config->use_history)) $document_config->use_history = 'N'; |
|
| 158 | + if(!isset($document_config->use_history)) { |
|
| 159 | + $document_config->use_history = 'N'; |
|
| 160 | + } |
|
| 147 | 161 | Context::set('document_config', $document_config); |
| 148 | 162 | |
| 149 | 163 | $oTemplate = &TemplateHandler::getInstance(); |
@@ -163,7 +177,9 @@ discard block |
||
| 163 | 177 | |
| 164 | 178 | $oMemberModel = getModel('member'); |
| 165 | 179 | // A message appears if the user is not logged-in |
| 166 | - if(!$oMemberModel->isLogged()) return $this->stop('msg_not_logged'); |
|
| 180 | + if(!$oMemberModel->isLogged()) { |
|
| 181 | + return $this->stop('msg_not_logged'); |
|
| 182 | + } |
|
| 167 | 183 | // Get the saved document (module_srl is set to member_srl instead) |
| 168 | 184 | $logged_info = Context::get('logged_info'); |
| 169 | 185 | $args = new stdClass(); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | /** |
| 57 | 57 | * Delete selected files from the administrator page |
| 58 | 58 | * |
| 59 | - * @return BaseObject |
|
| 59 | + * @return ModuleObject|null |
|
| 60 | 60 | */ |
| 61 | 61 | function procFileAdminDeleteChecked() |
| 62 | 62 | { |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | /** |
| 111 | 111 | * Add file information for each module |
| 112 | 112 | * |
| 113 | - * @return void |
|
| 113 | + * @return BaseObject|null |
|
| 114 | 114 | */ |
| 115 | 115 | function procFileAdminInsertModuleConfig() |
| 116 | 116 | { |
@@ -26,29 +26,29 @@ discard block |
||
| 26 | 26 | $args = new stdClass(); |
| 27 | 27 | $args->module_srl = $module_srl; |
| 28 | 28 | $columnList = array('file_srl', 'uploaded_filename'); |
| 29 | - $output = executeQueryArray('file.getModuleFiles',$args, $columnList); |
|
| 30 | - if(!$output) return $output; |
|
| 29 | + $output = executeQueryArray('file.getModuleFiles', $args, $columnList); |
|
| 30 | + if (!$output) return $output; |
|
| 31 | 31 | $files = $output->data; |
| 32 | 32 | // Remove from the DB |
| 33 | 33 | $args->module_srl = $module_srl; |
| 34 | 34 | $output = executeQuery('file.deleteModuleFiles', $args); |
| 35 | - if(!$output->toBool()) return $output; |
|
| 35 | + if (!$output->toBool()) return $output; |
|
| 36 | 36 | // Remove the file |
| 37 | - FileHandler::removeDir( sprintf("./files/attach/images/%s/", $module_srl) ) ; |
|
| 38 | - FileHandler::removeDir( sprintf("./files/attach/binaries/%s/", $module_srl) ); |
|
| 37 | + FileHandler::removeDir(sprintf("./files/attach/images/%s/", $module_srl)); |
|
| 38 | + FileHandler::removeDir(sprintf("./files/attach/binaries/%s/", $module_srl)); |
|
| 39 | 39 | // Remove the file list obtained from the DB |
| 40 | 40 | $path = array(); |
| 41 | 41 | $cnt = count($files); |
| 42 | - for($i=0;$i<$cnt;$i++) |
|
| 42 | + for ($i = 0; $i < $cnt; $i++) |
|
| 43 | 43 | { |
| 44 | 44 | $uploaded_filename = $files[$i]->uploaded_filename; |
| 45 | 45 | FileHandler::removeFile($uploaded_filename); |
| 46 | 46 | |
| 47 | 47 | $path_info = pathinfo($uploaded_filename); |
| 48 | - if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
| 48 | + if (!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
| 49 | 49 | } |
| 50 | 50 | // Remove a file directory of the document |
| 51 | - for($i=0;$i<count($path);$i++) FileHandler::removeBlankDir($path[$i]); |
|
| 51 | + for ($i = 0; $i < count($path); $i++) FileHandler::removeBlankDir($path[$i]); |
|
| 52 | 52 | |
| 53 | 53 | return $output; |
| 54 | 54 | } |
@@ -62,23 +62,23 @@ discard block |
||
| 62 | 62 | { |
| 63 | 63 | // An error appears if no document is selected |
| 64 | 64 | $cart = Context::get('cart'); |
| 65 | - if(!$cart) return $this->stop('msg_file_cart_is_null'); |
|
| 66 | - if(!is_array($cart)) $file_srl_list= explode('|@|', $cart); |
|
| 65 | + if (!$cart) return $this->stop('msg_file_cart_is_null'); |
|
| 66 | + if (!is_array($cart)) $file_srl_list = explode('|@|', $cart); |
|
| 67 | 67 | else $file_srl_list = $cart; |
| 68 | 68 | $file_count = count($file_srl_list); |
| 69 | - if(!$file_count) return $this->stop('msg_file_cart_is_null'); |
|
| 69 | + if (!$file_count) return $this->stop('msg_file_cart_is_null'); |
|
| 70 | 70 | |
| 71 | 71 | $oFileController = getController('file'); |
| 72 | 72 | // Delete the post |
| 73 | - for($i=0;$i<$file_count;$i++) |
|
| 73 | + for ($i = 0; $i < $file_count; $i++) |
|
| 74 | 74 | { |
| 75 | 75 | $file_srl = trim($file_srl_list[$i]); |
| 76 | - if(!$file_srl) continue; |
|
| 76 | + if (!$file_srl) continue; |
|
| 77 | 77 | |
| 78 | 78 | $oFileController->deleteFile($file_srl); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - $this->setMessage( sprintf(Context::getLang('msg_checked_file_is_deleted'), $file_count) ); |
|
| 81 | + $this->setMessage(sprintf(Context::getLang('msg_checked_file_is_deleted'), $file_count)); |
|
| 82 | 82 | |
| 83 | 83 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispFileAdminList'); |
| 84 | 84 | $this->setRedirectUrl($returnUrl); |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | $config->allow_outlink_site = Context::get('allow_outlink_site'); |
| 102 | 102 | // Create module Controller object |
| 103 | 103 | $oModuleController = getController('module'); |
| 104 | - $output = $oModuleController->insertModuleConfig('file',$config); |
|
| 104 | + $output = $oModuleController->insertModuleConfig('file', $config); |
|
| 105 | 105 | |
| 106 | 106 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispFileAdminConfig'); |
| 107 | 107 | return $this->setRedirectUrl($returnUrl, $output); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | // Get variables |
| 118 | 118 | $module_srl = Context::get('target_module_srl'); |
| 119 | 119 | // In order to configure multiple modules at once |
| 120 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
| 120 | + if (preg_match('/^([0-9,]+)$/', $module_srl)) $module_srl = explode(',', $module_srl); |
|
| 121 | 121 | else $module_srl = array($module_srl); |
| 122 | 122 | |
| 123 | 123 | $download_grant = Context::get('download_grant'); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | $file_config->allowed_attach_size = Context::get('allowed_attach_size'); |
| 131 | 131 | $file_config->allowed_filetypes = str_replace(' ', '', Context::get('allowed_filetypes')); |
| 132 | 132 | |
| 133 | - if(!is_array($download_grant)) $file_config->download_grant = explode('|@|',$download_grant); |
|
| 133 | + if (!is_array($download_grant)) $file_config->download_grant = explode('|@|', $download_grant); |
|
| 134 | 134 | else $file_config->download_grant = $download_grant; |
| 135 | 135 | |
| 136 | 136 | //관리자가 허용한 첨부파일의 사이즈가 php.ini의 값보다 큰지 확인하기 - by ovclas |
@@ -140,15 +140,15 @@ discard block |
||
| 140 | 140 | $iniUploadMaxSize = FileHandler::returnbytes(ini_get('upload_max_filesize')); |
| 141 | 141 | $iniMinSzie = min($iniPostMaxSize, $iniUploadMaxSize); |
| 142 | 142 | |
| 143 | - if($userFileAllowSize > $iniMinSzie || $userAttachAllowSize > $iniMinSzie) |
|
| 143 | + if ($userFileAllowSize > $iniMinSzie || $userAttachAllowSize > $iniMinSzie) |
|
| 144 | 144 | return new BaseObject(-1, 'input size over than config in php.ini'); |
| 145 | 145 | |
| 146 | 146 | $oModuleController = getController('module'); |
| 147 | - for($i=0;$i<count($module_srl);$i++) |
|
| 147 | + for ($i = 0; $i < count($module_srl); $i++) |
|
| 148 | 148 | { |
| 149 | 149 | $srl = trim($module_srl[$i]); |
| 150 | - if(!$srl) continue; |
|
| 151 | - $oModuleController->insertModulePartConfig('file',$srl,$file_config); |
|
| 150 | + if (!$srl) continue; |
|
| 151 | + $oModuleController->insertModulePartConfig('file', $srl, $file_config); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | $this->setError(-1); |
@@ -165,16 +165,16 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | function procFileAdminAddCart() |
| 167 | 167 | { |
| 168 | - $file_srl = (int)Context::get('file_srl'); |
|
| 168 | + $file_srl = (int) Context::get('file_srl'); |
|
| 169 | 169 | //$fileSrlList = array(500, 502); |
| 170 | 170 | |
| 171 | 171 | $oFileModel = getModel('file'); |
| 172 | 172 | $output = $oFileModel->getFile($file_srl); |
| 173 | 173 | //$output = $oFileModel->getFile($fileSrlList); |
| 174 | 174 | |
| 175 | - if($output->file_srl) |
|
| 175 | + if ($output->file_srl) |
|
| 176 | 176 | { |
| 177 | - if($_SESSION['file_management'][$output->file_srl]) unset($_SESSION['file_management'][$output->file_srl]); |
|
| 177 | + if ($_SESSION['file_management'][$output->file_srl]) unset($_SESSION['file_management'][$output->file_srl]); |
|
| 178 | 178 | else $_SESSION['file_management'][$output->file_srl] = true; |
| 179 | 179 | } |
| 180 | 180 | } |
@@ -27,12 +27,16 @@ discard block |
||
| 27 | 27 | $args->module_srl = $module_srl; |
| 28 | 28 | $columnList = array('file_srl', 'uploaded_filename'); |
| 29 | 29 | $output = executeQueryArray('file.getModuleFiles',$args, $columnList); |
| 30 | - if(!$output) return $output; |
|
| 30 | + if(!$output) { |
|
| 31 | + return $output; |
|
| 32 | + } |
|
| 31 | 33 | $files = $output->data; |
| 32 | 34 | // Remove from the DB |
| 33 | 35 | $args->module_srl = $module_srl; |
| 34 | 36 | $output = executeQuery('file.deleteModuleFiles', $args); |
| 35 | - if(!$output->toBool()) return $output; |
|
| 37 | + if(!$output->toBool()) { |
|
| 38 | + return $output; |
|
| 39 | + } |
|
| 36 | 40 | // Remove the file |
| 37 | 41 | FileHandler::removeDir( sprintf("./files/attach/images/%s/", $module_srl) ) ; |
| 38 | 42 | FileHandler::removeDir( sprintf("./files/attach/binaries/%s/", $module_srl) ); |
@@ -45,10 +49,14 @@ discard block |
||
| 45 | 49 | FileHandler::removeFile($uploaded_filename); |
| 46 | 50 | |
| 47 | 51 | $path_info = pathinfo($uploaded_filename); |
| 48 | - if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
| 52 | + if(!in_array($path_info['dirname'], $path)) { |
|
| 53 | + $path[] = $path_info['dirname']; |
|
| 54 | + } |
|
| 49 | 55 | } |
| 50 | 56 | // Remove a file directory of the document |
| 51 | - for($i=0;$i<count($path);$i++) FileHandler::removeBlankDir($path[$i]); |
|
| 57 | + for($i=0;$i<count($path);$i++) { |
|
| 58 | + FileHandler::removeBlankDir($path[$i]); |
|
| 59 | + } |
|
| 52 | 60 | |
| 53 | 61 | return $output; |
| 54 | 62 | } |
@@ -62,18 +70,27 @@ discard block |
||
| 62 | 70 | { |
| 63 | 71 | // An error appears if no document is selected |
| 64 | 72 | $cart = Context::get('cart'); |
| 65 | - if(!$cart) return $this->stop('msg_file_cart_is_null'); |
|
| 66 | - if(!is_array($cart)) $file_srl_list= explode('|@|', $cart); |
|
| 67 | - else $file_srl_list = $cart; |
|
| 73 | + if(!$cart) { |
|
| 74 | + return $this->stop('msg_file_cart_is_null'); |
|
| 75 | + } |
|
| 76 | + if(!is_array($cart)) { |
|
| 77 | + $file_srl_list= explode('|@|', $cart); |
|
| 78 | + } else { |
|
| 79 | + $file_srl_list = $cart; |
|
| 80 | + } |
|
| 68 | 81 | $file_count = count($file_srl_list); |
| 69 | - if(!$file_count) return $this->stop('msg_file_cart_is_null'); |
|
| 82 | + if(!$file_count) { |
|
| 83 | + return $this->stop('msg_file_cart_is_null'); |
|
| 84 | + } |
|
| 70 | 85 | |
| 71 | 86 | $oFileController = getController('file'); |
| 72 | 87 | // Delete the post |
| 73 | 88 | for($i=0;$i<$file_count;$i++) |
| 74 | 89 | { |
| 75 | 90 | $file_srl = trim($file_srl_list[$i]); |
| 76 | - if(!$file_srl) continue; |
|
| 91 | + if(!$file_srl) { |
|
| 92 | + continue; |
|
| 93 | + } |
|
| 77 | 94 | |
| 78 | 95 | $oFileController->deleteFile($file_srl); |
| 79 | 96 | } |
@@ -117,8 +134,11 @@ discard block |
||
| 117 | 134 | // Get variables |
| 118 | 135 | $module_srl = Context::get('target_module_srl'); |
| 119 | 136 | // In order to configure multiple modules at once |
| 120 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
| 121 | - else $module_srl = array($module_srl); |
|
| 137 | + if(preg_match('/^([0-9,]+)$/',$module_srl)) { |
|
| 138 | + $module_srl = explode(',',$module_srl); |
|
| 139 | + } else { |
|
| 140 | + $module_srl = array($module_srl); |
|
| 141 | + } |
|
| 122 | 142 | |
| 123 | 143 | $download_grant = Context::get('download_grant'); |
| 124 | 144 | |
@@ -130,8 +150,11 @@ discard block |
||
| 130 | 150 | $file_config->allowed_attach_size = Context::get('allowed_attach_size'); |
| 131 | 151 | $file_config->allowed_filetypes = str_replace(' ', '', Context::get('allowed_filetypes')); |
| 132 | 152 | |
| 133 | - if(!is_array($download_grant)) $file_config->download_grant = explode('|@|',$download_grant); |
|
| 134 | - else $file_config->download_grant = $download_grant; |
|
| 153 | + if(!is_array($download_grant)) { |
|
| 154 | + $file_config->download_grant = explode('|@|',$download_grant); |
|
| 155 | + } else { |
|
| 156 | + $file_config->download_grant = $download_grant; |
|
| 157 | + } |
|
| 135 | 158 | |
| 136 | 159 | //관리자가 허용한 첨부파일의 사이즈가 php.ini의 값보다 큰지 확인하기 - by ovclas |
| 137 | 160 | $userFileAllowSize = FileHandler::returnbytes($file_config->allowed_filesize.'M'); |
@@ -140,14 +163,17 @@ discard block |
||
| 140 | 163 | $iniUploadMaxSize = FileHandler::returnbytes(ini_get('upload_max_filesize')); |
| 141 | 164 | $iniMinSzie = min($iniPostMaxSize, $iniUploadMaxSize); |
| 142 | 165 | |
| 143 | - if($userFileAllowSize > $iniMinSzie || $userAttachAllowSize > $iniMinSzie) |
|
| 144 | - return new BaseObject(-1, 'input size over than config in php.ini'); |
|
| 166 | + if($userFileAllowSize > $iniMinSzie || $userAttachAllowSize > $iniMinSzie) { |
|
| 167 | + return new BaseObject(-1, 'input size over than config in php.ini'); |
|
| 168 | + } |
|
| 145 | 169 | |
| 146 | 170 | $oModuleController = getController('module'); |
| 147 | 171 | for($i=0;$i<count($module_srl);$i++) |
| 148 | 172 | { |
| 149 | 173 | $srl = trim($module_srl[$i]); |
| 150 | - if(!$srl) continue; |
|
| 174 | + if(!$srl) { |
|
| 175 | + continue; |
|
| 176 | + } |
|
| 151 | 177 | $oModuleController->insertModulePartConfig('file',$srl,$file_config); |
| 152 | 178 | } |
| 153 | 179 | |
@@ -174,8 +200,11 @@ discard block |
||
| 174 | 200 | |
| 175 | 201 | if($output->file_srl) |
| 176 | 202 | { |
| 177 | - if($_SESSION['file_management'][$output->file_srl]) unset($_SESSION['file_management'][$output->file_srl]); |
|
| 178 | - else $_SESSION['file_management'][$output->file_srl] = true; |
|
| 203 | + if($_SESSION['file_management'][$output->file_srl]) { |
|
| 204 | + unset($_SESSION['file_management'][$output->file_srl]); |
|
| 205 | + } else { |
|
| 206 | + $_SESSION['file_management'][$output->file_srl] = true; |
|
| 207 | + } |
|
| 179 | 208 | } |
| 180 | 209 | } |
| 181 | 210 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * It is used when a file list of the upload_target_srl is requested for creating/updating a document. |
| 21 | 21 | * Attempt to replace with sever-side session if upload_target_srl is not yet determined |
| 22 | 22 | * |
| 23 | - * @return void |
|
| 23 | + * @return BaseObject|null |
|
| 24 | 24 | */ |
| 25 | 25 | function getFileList() |
| 26 | 26 | { |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * Get file configurations |
| 147 | 147 | * |
| 148 | 148 | * @param int $module_srl If set this, returns specific module's configuration. Otherwise returns global configuration. |
| 149 | - * @return object Returns configuration. |
|
| 149 | + * @return stdClass Returns configuration. |
|
| 150 | 150 | */ |
| 151 | 151 | function getFileConfig($module_srl = null) |
| 152 | 152 | { |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | /** |
| 277 | 277 | * Return configurations of the attachement (it automatically checks if an administrator is) |
| 278 | 278 | * |
| 279 | - * @return object Returns a file configuration of current module. If user is admin, returns PHP's max file size and allow all file types. |
|
| 279 | + * @return stdClass Returns a file configuration of current module. If user is admin, returns PHP's max file size and allow all file types. |
|
| 280 | 280 | */ |
| 281 | 281 | function getUploadConfig() |
| 282 | 282 | { |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | * Return file configuration of the module |
| 331 | 331 | * |
| 332 | 332 | * @param int $module_srl The sequence of module to get configuration |
| 333 | - * @return object |
|
| 333 | + * @return stdClass |
|
| 334 | 334 | */ |
| 335 | 335 | function getFileModuleConfig($module_srl) |
| 336 | 336 | { |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | $mid = Context::get('mid'); |
| 30 | 30 | $editor_sequence = Context::get('editor_sequence'); |
| 31 | 31 | $upload_target_srl = Context::get('upload_target_srl'); |
| 32 | - if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
| 32 | + if (!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
| 33 | 33 | |
| 34 | - if($upload_target_srl) |
|
| 34 | + if ($upload_target_srl) |
|
| 35 | 35 | { |
| 36 | 36 | $oDocumentModel = getModel('document'); |
| 37 | 37 | $oCommentModel = getModel('comment'); |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | $oDocument = $oDocumentModel->getDocument($upload_target_srl); |
| 41 | 41 | |
| 42 | 42 | // comment 권한 확인 |
| 43 | - if(!$oDocument->isExists()) |
|
| 43 | + if (!$oDocument->isExists()) |
|
| 44 | 44 | { |
| 45 | 45 | $oComment = $oCommentModel->getComment($upload_target_srl); |
| 46 | - if($oComment->isExists() && $oComment->isSecret() && !$oComment->isGranted()) |
|
| 46 | + if ($oComment->isExists() && $oComment->isSecret() && !$oComment->isGranted()) |
|
| 47 | 47 | { |
| 48 | 48 | return new BaseObject(-1, 'msg_not_permitted'); |
| 49 | 49 | } |
@@ -52,34 +52,34 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // document 권한 확인 |
| 55 | - if($oDocument->isExists() && $oDocument->isSecret() && !$oDocument->isGranted()) |
|
| 55 | + if ($oDocument->isExists() && $oDocument->isSecret() && !$oDocument->isGranted()) |
|
| 56 | 56 | { |
| 57 | 57 | return new BaseObject(-1, 'msg_not_permitted'); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // 모듈 권한 확인 |
| 61 | - if($oDocument->isExists()) |
|
| 61 | + if ($oDocument->isExists()) |
|
| 62 | 62 | { |
| 63 | 63 | $grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($oDocument->get('module_srl')), $logged_info); |
| 64 | - if(!$grant->access) |
|
| 64 | + if (!$grant->access) |
|
| 65 | 65 | { |
| 66 | 66 | return new BaseObject(-1, 'msg_not_permitted'); |
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | $tmp_files = $this->getFiles($upload_target_srl); |
| 71 | - if(!$tmp_files) $tmp_files = array(); |
|
| 71 | + if (!$tmp_files) $tmp_files = array(); |
|
| 72 | 72 | |
| 73 | - foreach($tmp_files as $file_info) |
|
| 73 | + foreach ($tmp_files as $file_info) |
|
| 74 | 74 | { |
| 75 | - if(!$file_info->file_srl) continue; |
|
| 75 | + if (!$file_info->file_srl) continue; |
|
| 76 | 76 | |
| 77 | 77 | $obj = new stdClass; |
| 78 | 78 | $obj->file_srl = $file_info->file_srl; |
| 79 | 79 | $obj->source_filename = $file_info->source_filename; |
| 80 | 80 | $obj->file_size = $file_info->file_size; |
| 81 | 81 | $obj->disp_file_size = FileHandler::filesize($file_info->file_size); |
| 82 | - if($file_info->direct_download=='N') $obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid, $file_info->module_srl); |
|
| 82 | + if ($file_info->direct_download == 'N') $obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid, $file_info->module_srl); |
|
| 83 | 83 | else $obj->download_url = str_replace('./', '', $file_info->uploaded_filename); |
| 84 | 84 | $obj->direct_download = $file_info->direct_download; |
| 85 | 85 | $obj->cover_image = ($file_info->cover_image === 'Y') ? true : false; |
@@ -99,17 +99,17 @@ discard block |
||
| 99 | 99 | //$config = $oModuleModel->getModuleInfoByMid($mid); //perhaps config varialbles not used |
| 100 | 100 | |
| 101 | 101 | $file_config = $this->getUploadConfig(); |
| 102 | - $left_size = $file_config->allowed_attach_size*1024*1024 - $attached_size; |
|
| 102 | + $left_size = $file_config->allowed_attach_size * 1024 * 1024 - $attached_size; |
|
| 103 | 103 | // Settings of required information |
| 104 | 104 | $attached_size = FileHandler::filesize($attached_size); |
| 105 | - $allowed_attach_size = FileHandler::filesize($file_config->allowed_attach_size*1024*1024); |
|
| 106 | - $allowed_filesize = FileHandler::filesize($file_config->allowed_filesize*1024*1024); |
|
| 105 | + $allowed_attach_size = FileHandler::filesize($file_config->allowed_attach_size * 1024 * 1024); |
|
| 106 | + $allowed_filesize = FileHandler::filesize($file_config->allowed_filesize * 1024 * 1024); |
|
| 107 | 107 | $allowed_filetypes = $file_config->allowed_filetypes; |
| 108 | - $this->add("files",$files); |
|
| 109 | - $this->add("editor_sequence",$editor_sequence); |
|
| 110 | - $this->add("upload_target_srl",$upload_target_srl); |
|
| 111 | - $this->add("upload_status",$upload_status); |
|
| 112 | - $this->add("left_size",$left_size); |
|
| 108 | + $this->add("files", $files); |
|
| 109 | + $this->add("editor_sequence", $editor_sequence); |
|
| 110 | + $this->add("upload_target_srl", $upload_target_srl); |
|
| 111 | + $this->add("upload_status", $upload_status); |
|
| 112 | + $this->add("left_size", $left_size); |
|
| 113 | 113 | $this->add('attached_size', $attached_size); |
| 114 | 114 | $this->add('allowed_attach_size', $allowed_attach_size); |
| 115 | 115 | $this->add('allowed_filesize', $allowed_filesize); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | $args = new stdClass(); |
| 128 | 128 | $args->upload_target_srl = $upload_target_srl; |
| 129 | 129 | $output = executeQuery('file.getFilesCount', $args); |
| 130 | - return (int)$output->data->count; |
|
| 130 | + return (int) $output->data->count; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @param string $sid |
| 138 | 138 | * @return string Returns a url |
| 139 | 139 | */ |
| 140 | - function getDownloadUrl($file_srl, $sid, $module_srl="") |
|
| 140 | + function getDownloadUrl($file_srl, $sid, $module_srl = "") |
|
| 141 | 141 | { |
| 142 | 142 | return sprintf('?module=%s&act=%s&file_srl=%s&sid=%s&module_srl=%s', 'file', 'procFileDownload', $file_srl, $sid, $module_srl); |
| 143 | 143 | } |
@@ -155,12 +155,12 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | $file_module_config = $oModuleModel->getModuleConfig('file'); |
| 157 | 157 | |
| 158 | - if($module_srl) $file_config = $oModuleModel->getModulePartConfig('file',$module_srl); |
|
| 159 | - if(!$file_config) $file_config = $file_module_config; |
|
| 158 | + if ($module_srl) $file_config = $oModuleModel->getModulePartConfig('file', $module_srl); |
|
| 159 | + if (!$file_config) $file_config = $file_module_config; |
|
| 160 | 160 | |
| 161 | 161 | $config = new stdClass(); |
| 162 | 162 | |
| 163 | - if($file_config) |
|
| 163 | + if ($file_config) |
|
| 164 | 164 | { |
| 165 | 165 | $config->allowed_filesize = $file_config->allowed_filesize; |
| 166 | 166 | $config->allowed_attach_size = $file_config->allowed_attach_size; |
@@ -171,31 +171,31 @@ discard block |
||
| 171 | 171 | $config->allow_outlink_format = $file_config->allow_outlink_format; |
| 172 | 172 | } |
| 173 | 173 | // Property for all files comes first than each property |
| 174 | - if(!$config->allowed_filesize) $config->allowed_filesize = $file_module_config->allowed_filesize; |
|
| 175 | - if(!$config->allowed_attach_size) $config->allowed_attach_size = $file_module_config->allowed_attach_size; |
|
| 176 | - if(!$config->allowed_filetypes) $config->allowed_filetypes = $file_module_config->allowed_filetypes; |
|
| 177 | - if(!$config->allow_outlink) $config->allow_outlink = $file_module_config->allow_outlink; |
|
| 178 | - if(!$config->allow_outlink_site) $config->allow_outlink_site = $file_module_config->allow_outlink_site; |
|
| 179 | - if(!$config->allow_outlink_format) $config->allow_outlink_format = $file_module_config->allow_outlink_format; |
|
| 180 | - if(!$config->download_grant) $config->download_grant = $file_module_config->download_grant; |
|
| 174 | + if (!$config->allowed_filesize) $config->allowed_filesize = $file_module_config->allowed_filesize; |
|
| 175 | + if (!$config->allowed_attach_size) $config->allowed_attach_size = $file_module_config->allowed_attach_size; |
|
| 176 | + if (!$config->allowed_filetypes) $config->allowed_filetypes = $file_module_config->allowed_filetypes; |
|
| 177 | + if (!$config->allow_outlink) $config->allow_outlink = $file_module_config->allow_outlink; |
|
| 178 | + if (!$config->allow_outlink_site) $config->allow_outlink_site = $file_module_config->allow_outlink_site; |
|
| 179 | + if (!$config->allow_outlink_format) $config->allow_outlink_format = $file_module_config->allow_outlink_format; |
|
| 180 | + if (!$config->download_grant) $config->download_grant = $file_module_config->download_grant; |
|
| 181 | 181 | // Default setting if not exists |
| 182 | - if(!$config->allowed_filesize) $config->allowed_filesize = '2'; |
|
| 183 | - if(!$config->allowed_attach_size) $config->allowed_attach_size = '3'; |
|
| 184 | - if(!$config->allowed_filetypes) $config->allowed_filetypes = '*.*'; |
|
| 185 | - if(!$config->allow_outlink) $config->allow_outlink = 'Y'; |
|
| 186 | - if(!$config->download_grant) $config->download_grant = array(); |
|
| 182 | + if (!$config->allowed_filesize) $config->allowed_filesize = '2'; |
|
| 183 | + if (!$config->allowed_attach_size) $config->allowed_attach_size = '3'; |
|
| 184 | + if (!$config->allowed_filetypes) $config->allowed_filetypes = '*.*'; |
|
| 185 | + if (!$config->allow_outlink) $config->allow_outlink = 'Y'; |
|
| 186 | + if (!$config->download_grant) $config->download_grant = array(); |
|
| 187 | 187 | |
| 188 | 188 | $size = ini_get('upload_max_filesize'); |
| 189 | 189 | $unit = strtolower($size[strlen($size) - 1]); |
| 190 | - $size = (float)$size; |
|
| 191 | - if($unit == 'g') $size *= 1024; |
|
| 192 | - if($unit == 'k') $size /= 1024; |
|
| 190 | + $size = (float) $size; |
|
| 191 | + if ($unit == 'g') $size *= 1024; |
|
| 192 | + if ($unit == 'k') $size /= 1024; |
|
| 193 | 193 | |
| 194 | - if($config->allowed_filesize > $size) |
|
| 194 | + if ($config->allowed_filesize > $size) |
|
| 195 | 195 | { |
| 196 | 196 | $config->allowed_filesize = $size; |
| 197 | 197 | } |
| 198 | - if($config->allowed_attach_size > $size) |
|
| 198 | + if ($config->allowed_attach_size > $size) |
|
| 199 | 199 | { |
| 200 | 200 | $config->allowed_attach_size = $size; |
| 201 | 201 | } |
@@ -215,10 +215,10 @@ discard block |
||
| 215 | 215 | $args = new stdClass(); |
| 216 | 216 | $args->file_srl = $file_srl; |
| 217 | 217 | $output = executeQueryArray('file.getFile', $args, $columnList); |
| 218 | - if(!$output->toBool()) return $output; |
|
| 218 | + if (!$output->toBool()) return $output; |
|
| 219 | 219 | |
| 220 | 220 | // old version compatibility |
| 221 | - if(count($output->data) == 1) |
|
| 221 | + if (count($output->data) == 1) |
|
| 222 | 222 | { |
| 223 | 223 | $file = $output->data[0]; |
| 224 | 224 | $file->download_url = $this->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl); |
@@ -229,9 +229,9 @@ discard block |
||
| 229 | 229 | { |
| 230 | 230 | $fileList = array(); |
| 231 | 231 | |
| 232 | - if(is_array($output->data)) |
|
| 232 | + if (is_array($output->data)) |
|
| 233 | 233 | { |
| 234 | - foreach($output->data as $key=>$value) |
|
| 234 | + foreach ($output->data as $key=>$value) |
|
| 235 | 235 | { |
| 236 | 236 | $file = $value; |
| 237 | 237 | $file->download_url = $this->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl); |
@@ -255,13 +255,13 @@ discard block |
||
| 255 | 255 | $args = new stdClass(); |
| 256 | 256 | $args->upload_target_srl = $upload_target_srl; |
| 257 | 257 | $args->sort_index = $sortIndex; |
| 258 | - if($ckValid) $args->isvalid = 'Y'; |
|
| 258 | + if ($ckValid) $args->isvalid = 'Y'; |
|
| 259 | 259 | $output = executeQueryArray('file.getFiles', $args, $columnList); |
| 260 | - if(!$output->data) return; |
|
| 260 | + if (!$output->data) return; |
|
| 261 | 261 | |
| 262 | 262 | $file_list = $output->data; |
| 263 | 263 | |
| 264 | - if($file_list && !is_array($file_list)) $file_list = array($file_list); |
|
| 264 | + if ($file_list && !is_array($file_list)) $file_list = array($file_list); |
|
| 265 | 265 | |
| 266 | 266 | foreach ($file_list as &$file) |
| 267 | 267 | { |
@@ -284,14 +284,14 @@ discard block |
||
| 284 | 284 | |
| 285 | 285 | $module_srl = Context::get('module_srl'); |
| 286 | 286 | // Get the current module if module_srl doesn't exist |
| 287 | - if(!$module_srl) |
|
| 287 | + if (!$module_srl) |
|
| 288 | 288 | { |
| 289 | 289 | $current_module_info = Context::get('current_module_info'); |
| 290 | 290 | $module_srl = $current_module_info->module_srl; |
| 291 | 291 | } |
| 292 | 292 | $file_config = $this->getFileConfig($module_srl); |
| 293 | 293 | |
| 294 | - if($logged_info->is_admin == 'Y') |
|
| 294 | + if ($logged_info->is_admin == 'Y') |
|
| 295 | 295 | { |
| 296 | 296 | $iniPostMaxSize = FileHandler::returnbytes(ini_get('post_max_size')); |
| 297 | 297 | $iniUploadMaxSize = FileHandler::returnbytes(ini_get('upload_max_filesize')); |
@@ -317,9 +317,9 @@ discard block |
||
| 317 | 317 | '%s : %s/ %s<br /> %s : %s (%s : %s)', |
| 318 | 318 | Context::getLang('allowed_attach_size'), |
| 319 | 319 | FileHandler::filesize($attached_size), |
| 320 | - FileHandler::filesize($file_config->allowed_attach_size*1024*1024), |
|
| 320 | + FileHandler::filesize($file_config->allowed_attach_size * 1024 * 1024), |
|
| 321 | 321 | Context::getLang('allowed_filesize'), |
| 322 | - FileHandler::filesize($file_config->allowed_filesize*1024*1024), |
|
| 322 | + FileHandler::filesize($file_config->allowed_filesize * 1024 * 1024), |
|
| 323 | 323 | Context::getLang('allowed_filetypes'), |
| 324 | 324 | $file_config->allowed_filetypes |
| 325 | 325 | ); |
@@ -346,9 +346,9 @@ discard block |
||
| 346 | 346 | */ |
| 347 | 347 | function getFileGrant($file_info, $member_info) |
| 348 | 348 | { |
| 349 | - if(!$file_info) return null; |
|
| 349 | + if (!$file_info) return null; |
|
| 350 | 350 | |
| 351 | - if($_SESSION['__XE_UPLOADING_FILES_INFO__'][$file_info->file_srl]) |
|
| 351 | + if ($_SESSION['__XE_UPLOADING_FILES_INFO__'][$file_info->file_srl]) |
|
| 352 | 352 | { |
| 353 | 353 | $file_grant->is_deletable = true; |
| 354 | 354 | return $file_grant; |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | |
| 360 | 360 | $oDocumentModel = getModel('document'); |
| 361 | 361 | $oDocument = $oDocumentModel->getDocument($file_info->upload_target_srl); |
| 362 | - if($oDocument->isExists()) $document_grant = $oDocument->isGranted(); |
|
| 362 | + if ($oDocument->isExists()) $document_grant = $oDocument->isGranted(); |
|
| 363 | 363 | |
| 364 | 364 | $file_grant->is_deletable = ($document_grant || $member_info->is_admin == 'Y' || $member_info->member_srl == $file_info->member_srl || $grant->manager); |
| 365 | 365 | |
@@ -276,7 +276,7 @@ |
||
| 276 | 276 | |
| 277 | 277 | /** |
| 278 | 278 | * Migrate data after completing xml file extraction |
| 279 | - * @return void |
|
| 279 | + * @return BaseObject|null |
|
| 280 | 280 | */ |
| 281 | 281 | function procImporterAdminImport() |
| 282 | 282 | { |
@@ -43,19 +43,19 @@ discard block |
||
| 43 | 43 | $filename = Context::get('filename'); |
| 44 | 44 | $isExists = 'false'; |
| 45 | 45 | |
| 46 | - if(strncasecmp('http://', $filename, 7) === 0) |
|
| 46 | + if (strncasecmp('http://', $filename, 7) === 0) |
|
| 47 | 47 | { |
| 48 | - if(ini_get('allow_url_fopen')) |
|
| 48 | + if (ini_get('allow_url_fopen')) |
|
| 49 | 49 | { |
| 50 | 50 | $fp = @fopen($filename, "r"); |
| 51 | - if($fp) |
|
| 51 | + if ($fp) |
|
| 52 | 52 | { |
| 53 | 53 | $str = fgets($fp, 100); |
| 54 | - if(strlen($str) > 0) |
|
| 54 | + if (strlen($str) > 0) |
|
| 55 | 55 | { |
| 56 | 56 | $isExists = 'true'; |
| 57 | 57 | $type = 'XML'; |
| 58 | - if(stristr($str, 'tattertools')) $type = 'TTXML'; |
|
| 58 | + if (stristr($str, 'tattertools')) $type = 'TTXML'; |
|
| 59 | 59 | |
| 60 | 60 | $this->add('type', $type); |
| 61 | 61 | } |
@@ -72,16 +72,16 @@ discard block |
||
| 72 | 72 | { |
| 73 | 73 | $realPath = FileHandler::getRealPath($filename); |
| 74 | 74 | |
| 75 | - if(file_exists($realPath) && is_file($realPath)) $isExists = 'true'; |
|
| 75 | + if (file_exists($realPath) && is_file($realPath)) $isExists = 'true'; |
|
| 76 | 76 | $this->add('exists', $isExists); |
| 77 | 77 | |
| 78 | - if($isExists == 'true') |
|
| 78 | + if ($isExists == 'true') |
|
| 79 | 79 | { |
| 80 | 80 | $type = 'XML'; |
| 81 | 81 | |
| 82 | 82 | $fp = fopen($realPath, "r"); |
| 83 | 83 | $str = fgets($fp, 100); |
| 84 | - if(stristr($str, 'tattertools')) $type = 'TTXML'; |
|
| 84 | + if (stristr($str, 'tattertools')) $type = 'TTXML'; |
|
| 85 | 85 | fclose($fp); |
| 86 | 86 | |
| 87 | 87 | $this->add('type', $type); |
@@ -107,16 +107,16 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | /* DBMS가 CUBRID인 경우 MySQL과 동일한 방법으로는 문서 및 댓글에 대한 사용자 정보를 동기화 할 수 없으므로 예외 처리 합니다. |
| 109 | 109 | CUBRID를 사용하지 않는 경우에만 보편적인 기존 질의문을 사용합니다. */ |
| 110 | - $db_info = Context::getDBInfo (); |
|
| 111 | - if($db_info->db_type != "cubrid") |
|
| 110 | + $db_info = Context::getDBInfo(); |
|
| 111 | + if ($db_info->db_type != "cubrid") |
|
| 112 | 112 | { |
| 113 | 113 | $output = executeQuery('importer.updateDocumentSync'.$postFix); |
| 114 | 114 | $output = executeQuery('importer.updateCommentSync'.$postFix); |
| 115 | 115 | } |
| 116 | 116 | else |
| 117 | 117 | { |
| 118 | - $output = executeQueryArray ('importer.getDocumentMemberSrlWithUserID'.$postFix); |
|
| 119 | - if(is_array ($output->data) && count ($output->data)) |
|
| 118 | + $output = executeQueryArray('importer.getDocumentMemberSrlWithUserID'.$postFix); |
|
| 119 | + if (is_array($output->data) && count($output->data)) |
|
| 120 | 120 | { |
| 121 | 121 | $success_count = 0; |
| 122 | 122 | $error_count = 0; |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | { |
| 126 | 126 | $args->user_id = $val->user_id; |
| 127 | 127 | $args->member_srl = $val->member_srl; |
| 128 | - $tmp = executeQuery ('importer.updateDocumentSyncForCUBRID'.$postFix, $args); |
|
| 129 | - if($tmp->toBool () === true) |
|
| 128 | + $tmp = executeQuery('importer.updateDocumentSyncForCUBRID'.$postFix, $args); |
|
| 129 | + if ($tmp->toBool() === true) |
|
| 130 | 130 | { |
| 131 | 131 | $success_count++; |
| 132 | 132 | } |
@@ -138,8 +138,8 @@ discard block |
||
| 138 | 138 | } |
| 139 | 139 | } // documents section |
| 140 | 140 | |
| 141 | - $output = executeQueryArray ('importer.getCommentMemberSrlWithUserID'.$postFix); |
|
| 142 | - if(is_array ($output->data) && count ($output->data)) |
|
| 141 | + $output = executeQueryArray('importer.getCommentMemberSrlWithUserID'.$postFix); |
|
| 142 | + if (is_array($output->data) && count($output->data)) |
|
| 143 | 143 | { |
| 144 | 144 | $success_count = 0; |
| 145 | 145 | $error_count = 0; |
@@ -148,8 +148,8 @@ discard block |
||
| 148 | 148 | { |
| 149 | 149 | $args->user_id = $val->user_id; |
| 150 | 150 | $args->member_srl = $val->member_srl; |
| 151 | - $tmp = executeQuery ('importer.updateCommentSyncForCUBRID'.$postFix, $args); |
|
| 152 | - if($tmp->toBool () === true) |
|
| 151 | + $tmp = executeQuery('importer.updateCommentSyncForCUBRID'.$postFix, $args); |
|
| 152 | + if ($tmp->toBool() === true) |
|
| 153 | 153 | { |
| 154 | 154 | $success_count++; |
| 155 | 155 | } |
@@ -178,15 +178,15 @@ discard block |
||
| 178 | 178 | // Extract and cache information from the xml file |
| 179 | 179 | $oExtract = new extract(); |
| 180 | 180 | |
| 181 | - switch($type) |
|
| 181 | + switch ($type) |
|
| 182 | 182 | { |
| 183 | 183 | case 'member' : |
| 184 | - $output = $oExtract->set($xml_file,'<members ', '</members>', '<member>', '</member>'); |
|
| 185 | - if($output->toBool()) $oExtract->saveItems(); |
|
| 184 | + $output = $oExtract->set($xml_file, '<members ', '</members>', '<member>', '</member>'); |
|
| 185 | + if ($output->toBool()) $oExtract->saveItems(); |
|
| 186 | 186 | break; |
| 187 | 187 | case 'message' : |
| 188 | - $output = $oExtract->set($xml_file,'<messages ', '</messages>', '<message>','</message>'); |
|
| 189 | - if($output->toBool()) $oExtract->saveItems(); |
|
| 188 | + $output = $oExtract->set($xml_file, '<messages ', '</messages>', '<message>', '</message>'); |
|
| 189 | + if ($output->toBool()) $oExtract->saveItems(); |
|
| 190 | 190 | break; |
| 191 | 191 | case 'ttxml' : |
| 192 | 192 | // Category information |
@@ -199,12 +199,12 @@ discard block |
||
| 199 | 199 | while (!feof($oExtract->fd)) |
| 200 | 200 | { |
| 201 | 201 | $str = fgets($oExtract->fd, 1024); |
| 202 | - if(strstr($str, '<category>')) |
|
| 202 | + if (strstr($str, '<category>')) |
|
| 203 | 203 | { |
| 204 | 204 | $started = true; |
| 205 | 205 | $str = strstr($str, '<category>'); |
| 206 | 206 | } |
| 207 | - if(substr($str,0,strlen('<post ')) == '<post ') break; |
|
| 207 | + if (substr($str, 0, strlen('<post ')) == '<post ') break; |
|
| 208 | 208 | if ($started) $buff .= $str; |
| 209 | 209 | } |
| 210 | 210 | $buff = '<categories>'.$buff.'</categories>'; |
@@ -214,22 +214,22 @@ discard block |
||
| 214 | 214 | |
| 215 | 215 | // Guestbook information |
| 216 | 216 | $output = $oExtract->set($xml_file, '', '', '', ''); |
| 217 | - if($output->toBool()) |
|
| 217 | + if ($output->toBool()) |
|
| 218 | 218 | { |
| 219 | 219 | $started = false; |
| 220 | 220 | $buff = ''; |
| 221 | 221 | while (!feof($oExtract->fd)) |
| 222 | 222 | { |
| 223 | 223 | $str = fgets($oExtract->fd, 1024); |
| 224 | - if(strstr($str, '<guestbook>')) |
|
| 224 | + if (strstr($str, '<guestbook>')) |
|
| 225 | 225 | { |
| 226 | 226 | $started = true; |
| 227 | 227 | $str = strstr($str, '<guestbook>'); |
| 228 | 228 | } |
| 229 | - if($started) |
|
| 229 | + if ($started) |
|
| 230 | 230 | { |
| 231 | 231 | $pos = strpos($str, '</guestbook>'); |
| 232 | - if($pos !== false) |
|
| 232 | + if ($pos !== false) |
|
| 233 | 233 | { |
| 234 | 234 | $buff .= substr($str, 0, $pos + strlen('</guestbook>')); |
| 235 | 235 | break; |
@@ -241,37 +241,37 @@ discard block |
||
| 241 | 241 | $guestbook_filename = sprintf('%s/%s', $oExtract->cache_path, 'guestbook.xml'); |
| 242 | 242 | FileHandler::writeFile($guestbook_filename, $buff); |
| 243 | 243 | // Individual items |
| 244 | - $output = $oExtract->set($xml_file,'<blog', '</blog>', '<post ', '</post>'); |
|
| 245 | - if($output->toBool()) $oExtract->saveItems(); |
|
| 244 | + $output = $oExtract->set($xml_file, '<blog', '</blog>', '<post ', '</post>'); |
|
| 245 | + if ($output->toBool()) $oExtract->saveItems(); |
|
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | break; |
| 249 | 249 | default : |
| 250 | 250 | // First get category information |
| 251 | - $output = $oExtract->set($xml_file,'<categories>', '</categories>', '<category','</category>'); |
|
| 252 | - if($output->toBool()) |
|
| 251 | + $output = $oExtract->set($xml_file, '<categories>', '</categories>', '<category', '</category>'); |
|
| 252 | + if ($output->toBool()) |
|
| 253 | 253 | { |
| 254 | 254 | $oExtract->mergeItems('category.xml'); |
| 255 | 255 | // Get each item |
| 256 | - $output = $oExtract->set($xml_file,'<posts ', '</posts>', '<post>', '</post>'); |
|
| 257 | - if($output->toBool()) $oExtract->saveItems(); |
|
| 256 | + $output = $oExtract->set($xml_file, '<posts ', '</posts>', '<post>', '</post>'); |
|
| 257 | + if ($output->toBool()) $oExtract->saveItems(); |
|
| 258 | 258 | } |
| 259 | 259 | break; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - if(!$output->toBool()) |
|
| 262 | + if (!$output->toBool()) |
|
| 263 | 263 | { |
| 264 | - $this->add('error',0); |
|
| 265 | - $this->add('status',-1); |
|
| 264 | + $this->add('error', 0); |
|
| 265 | + $this->add('status', -1); |
|
| 266 | 266 | $this->setMessage($output->getMessage()); |
| 267 | 267 | return; |
| 268 | 268 | } |
| 269 | 269 | // Notify that all data completely extracted |
| 270 | - $this->add('type',$type); |
|
| 271 | - $this->add('total',$oExtract->getTotalCount()); |
|
| 272 | - $this->add('cur',0); |
|
| 270 | + $this->add('type', $type); |
|
| 271 | + $this->add('total', $oExtract->getTotalCount()); |
|
| 272 | + $this->add('cur', 0); |
|
| 273 | 273 | $this->add('key', $oExtract->getKey()); |
| 274 | - $this->add('status',0); |
|
| 274 | + $this->add('status', 0); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -291,19 +291,19 @@ discard block |
||
| 291 | 291 | $this->unit_count = Context::get('unit_count'); |
| 292 | 292 | // Check if an index file exists |
| 293 | 293 | $index_file = './files/cache/importer/'.$key.'/index'; |
| 294 | - if(!file_exists($index_file)) return new BaseObject(-1, 'msg_invalid_xml_file'); |
|
| 294 | + if (!file_exists($index_file)) return new BaseObject(-1, 'msg_invalid_xml_file'); |
|
| 295 | 295 | |
| 296 | - switch($type) |
|
| 296 | + switch ($type) |
|
| 297 | 297 | { |
| 298 | 298 | case 'ttxml' : |
| 299 | - if(!$target_module) return new BaseObject(-1,'msg_invalid_request'); |
|
| 299 | + if (!$target_module) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 300 | 300 | |
| 301 | 301 | $oModuleModel = getModel('module'); |
| 302 | 302 | $columnList = array('module_srl', 'module'); |
| 303 | 303 | $target_module_info = $oModuleModel->getModuleInfoByModuleSrl($target_module, $columnList); |
| 304 | 304 | |
| 305 | - $ttimporter = FileHandler::exists(_XE_PATH_ . 'modules/importer/ttimport.class.php'); |
|
| 306 | - if($ttimporter) require_once($ttimporter); |
|
| 305 | + $ttimporter = FileHandler::exists(_XE_PATH_.'modules/importer/ttimport.class.php'); |
|
| 306 | + if ($ttimporter) require_once($ttimporter); |
|
| 307 | 307 | |
| 308 | 308 | $oTT = new ttimport(); |
| 309 | 309 | $cur = $oTT->importModule($key, $cur, $index_file, $this->unit_count, $target_module, $guestbook_target_module, $user_id, $target_module_info->module); |
@@ -316,23 +316,23 @@ discard block |
||
| 316 | 316 | break; |
| 317 | 317 | case 'module' : |
| 318 | 318 | // Check if the target module exists |
| 319 | - if(!$target_module) return new BaseObject(-1,'msg_invalid_request'); |
|
| 319 | + if (!$target_module) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 320 | 320 | $cur = $this->importModule($key, $cur, $index_file, $target_module); |
| 321 | 321 | break; |
| 322 | 322 | } |
| 323 | 323 | // Notify that all data completely extracted |
| 324 | - $this->add('type',$type); |
|
| 325 | - $this->add('total',$total); |
|
| 326 | - $this->add('cur',$cur); |
|
| 324 | + $this->add('type', $type); |
|
| 325 | + $this->add('total', $total); |
|
| 326 | + $this->add('cur', $cur); |
|
| 327 | 327 | $this->add('key', $key); |
| 328 | 328 | $this->add('target_module', $target_module); |
| 329 | 329 | // When completing, success message appears and remove the cache files |
| 330 | - if($total <= $cur) |
|
| 330 | + if ($total <= $cur) |
|
| 331 | 331 | { |
| 332 | - $this->setMessage( sprintf(Context::getLang('msg_import_finished'), $cur, $total) ); |
|
| 332 | + $this->setMessage(sprintf(Context::getLang('msg_import_finished'), $cur, $total)); |
|
| 333 | 333 | FileHandler::removeDir('./files/cache/importer/'.$key); |
| 334 | 334 | } |
| 335 | - else $this->setMessage( sprintf(Context::getLang('msg_importing'), $total, $cur) ); |
|
| 335 | + else $this->setMessage(sprintf(Context::getLang('msg_importing'), $total, $cur)); |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | /** |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | */ |
| 345 | 345 | function importMember($key, $cur, $index_file) |
| 346 | 346 | { |
| 347 | - if(!$cur) $cur = 0; |
|
| 347 | + if (!$cur) $cur = 0; |
|
| 348 | 348 | // Create the xmlParser object |
| 349 | 349 | $oXmlParser = new XmlParser(); |
| 350 | 350 | // Create objects for importing member information |
@@ -357,30 +357,30 @@ discard block |
||
| 357 | 357 | $oModuleModel = getModel('module'); |
| 358 | 358 | $member_config = $oModuleModel->getModuleConfig('member'); |
| 359 | 359 | // Open an index file |
| 360 | - $f = fopen($index_file,"r"); |
|
| 360 | + $f = fopen($index_file, "r"); |
|
| 361 | 361 | // Pass if already read |
| 362 | - for($i=0;$i<$cur;$i++) fgets($f, 1024); |
|
| 362 | + for ($i = 0; $i < $cur; $i++) fgets($f, 1024); |
|
| 363 | 363 | // Read by each line until the condition meets |
| 364 | - for($idx=$cur;$idx<$cur+$this->unit_count;$idx++) |
|
| 364 | + for ($idx = $cur; $idx < $cur + $this->unit_count; $idx++) |
|
| 365 | 365 | { |
| 366 | - if(feof($f)) break; |
|
| 366 | + if (feof($f)) break; |
|
| 367 | 367 | // Find a given location |
| 368 | 368 | $target_file = trim(fgets($f, 1024)); |
| 369 | 369 | // Load and parse the file |
| 370 | 370 | $xmlObj = $oXmlParser->loadXmlFile($target_file); |
| 371 | 371 | FileHandler::removeFile($target_file); |
| 372 | - if(!$xmlObj) continue; |
|
| 372 | + if (!$xmlObj) continue; |
|
| 373 | 373 | // List Objects |
| 374 | 374 | $obj = new stdClass(); |
| 375 | 375 | $obj->user_id = base64_decode($xmlObj->member->user_id->body); |
| 376 | 376 | $obj->password = base64_decode($xmlObj->member->password->body); |
| 377 | 377 | $obj->user_name = base64_decode($xmlObj->member->user_name->body); |
| 378 | 378 | $obj->nick_name = base64_decode($xmlObj->member->nick_name->body); |
| 379 | - if(!$obj->user_name) $obj->user_name = $obj->nick_name; |
|
| 379 | + if (!$obj->user_name) $obj->user_name = $obj->nick_name; |
|
| 380 | 380 | $obj->email = base64_decode($xmlObj->member->email->body); |
| 381 | 381 | $obj->homepage = base64_decode($xmlObj->member->homepage->body); |
| 382 | 382 | $obj->blog = base64_decode($xmlObj->member->blog->body); |
| 383 | - $obj->birthday = substr(base64_decode($xmlObj->member->birthday->body),0,8); |
|
| 383 | + $obj->birthday = substr(base64_decode($xmlObj->member->birthday->body), 0, 8); |
|
| 384 | 384 | $obj->allow_mailing = base64_decode($xmlObj->member->allow_mailing->body); |
| 385 | 385 | $obj->point = base64_decode($xmlObj->member->point->body); |
| 386 | 386 | $obj->image_nickname = base64_decode($xmlObj->member->image_nickname->buff->body); |
@@ -390,26 +390,26 @@ discard block |
||
| 390 | 390 | $obj->regdate = base64_decode($xmlObj->member->regdate->body); |
| 391 | 391 | $obj->last_login = base64_decode($xmlObj->member->last_login->body); |
| 392 | 392 | |
| 393 | - if($xmlObj->member->extra_vars) |
|
| 393 | + if ($xmlObj->member->extra_vars) |
|
| 394 | 394 | { |
| 395 | - foreach($xmlObj->member->extra_vars as $key => $val) |
|
| 395 | + foreach ($xmlObj->member->extra_vars as $key => $val) |
|
| 396 | 396 | { |
| 397 | - if(in_array($key, array('node_name','attrs','body'))) continue; |
|
| 397 | + if (in_array($key, array('node_name', 'attrs', 'body'))) continue; |
|
| 398 | 398 | $obj->extra_vars->{$key} = base64_decode($val->body); |
| 399 | 399 | } |
| 400 | 400 | } |
| 401 | 401 | // Create url for homepage and blog |
| 402 | - if($obj->homepage && strncasecmp('http://', $obj->homepage, 7) !== 0 && strncasecmp('https://', $obj->homepage, 8) !== 0) $obj->homepage = 'http://'.$obj->homepage; |
|
| 402 | + if ($obj->homepage && strncasecmp('http://', $obj->homepage, 7) !== 0 && strncasecmp('https://', $obj->homepage, 8) !== 0) $obj->homepage = 'http://'.$obj->homepage; |
|
| 403 | 403 | // email address column |
| 404 | 404 | $obj->email_address = $obj->email; |
| 405 | 405 | list($obj->email_id, $obj->email_host) = explode('@', $obj->email); |
| 406 | 406 | // Set the mailing option |
| 407 | - if($obj->allow_mailing!='Y') $obj->allow_mailing = 'N'; |
|
| 407 | + if ($obj->allow_mailing != 'Y') $obj->allow_mailing = 'N'; |
|
| 408 | 408 | // Set the message option |
| 409 | 409 | $obj->allow_message = 'Y'; |
| 410 | - if(!in_array($obj->allow_message, array('Y','N','F'))) $obj->allow_message= 'Y'; |
|
| 410 | + if (!in_array($obj->allow_message, array('Y', 'N', 'F'))) $obj->allow_message = 'Y'; |
|
| 411 | 411 | // Get member-join date if the last login time is not found |
| 412 | - if(!$obj->last_login) $obj->last_login = $obj->regdate; |
|
| 412 | + if (!$obj->last_login) $obj->last_login = $obj->regdate; |
|
| 413 | 413 | // Get a member_srl |
| 414 | 414 | $obj->member_srl = getNextSequence(); |
| 415 | 415 | $obj->list_order = -1 * $obj->member_srl; |
@@ -421,63 +421,63 @@ discard block |
||
| 421 | 421 | $nick_args = new stdClass; |
| 422 | 422 | $nick_args->nick_name = $obj->nick_name; |
| 423 | 423 | $nick_output = executeQuery('member.getMemberSrl', $nick_args); |
| 424 | - if(!$nick_output->toBool()) $obj->nick_name .= '_'.$obj->member_srl; |
|
| 424 | + if (!$nick_output->toBool()) $obj->nick_name .= '_'.$obj->member_srl; |
|
| 425 | 425 | // Add a member |
| 426 | 426 | $output = executeQuery('member.insertMember', $obj); |
| 427 | 427 | |
| 428 | - if($output->toBool() && !($obj->password)) |
|
| 428 | + if ($output->toBool() && !($obj->password)) |
|
| 429 | 429 | { |
| 430 | 430 | // Send a mail telling the user to reset his password. |
| 431 | 431 | $oMail = new Mail(); |
| 432 | - $oMail->setTitle("Password update for your " . getFullSiteUrl() . " account"); |
|
| 433 | - $webmaster_name = $member_config->webmaster_name?$member_config->webmaster_name:'Webmaster'; |
|
| 432 | + $oMail->setTitle("Password update for your ".getFullSiteUrl()." account"); |
|
| 433 | + $webmaster_name = $member_config->webmaster_name ? $member_config->webmaster_name : 'Webmaster'; |
|
| 434 | 434 | $oMail->setContent("Dear $obj->user_name, <br /><br /> |
| 435 | 435 | We recently migrated our phpBB forum to XpressEngine. Since you password was encrypted we could not migrate it too, so please reset it by following this link: |
| 436 | - <a href='" . getFullSiteUrl() . "/?act=dispMemberFindAccount' >" . getFullSiteUrl() . "?act=dispMemberFindAccount</a>. You need to enter you email address and hit the 'Find account' button. You will then receive an email with a new, generated password that you can change after login. <br /><br /> |
|
| 436 | + <a href='".getFullSiteUrl()."/?act=dispMemberFindAccount' >".getFullSiteUrl()."?act=dispMemberFindAccount</a>. You need to enter you email address and hit the 'Find account' button. You will then receive an email with a new, generated password that you can change after login. <br /><br /> |
|
| 437 | 437 | |
| 438 | 438 | Thank you for your understanding,<br /> |
| 439 | 439 | {$webmaster_name}" |
| 440 | 440 | ); |
| 441 | 441 | $oMail->setSender($webmaster_name, $member_config->webmaster_email); |
| 442 | - $oMail->setReceiptor( $obj->user_name, $obj->email); |
|
| 442 | + $oMail->setReceiptor($obj->user_name, $obj->email); |
|
| 443 | 443 | $oMail->send(); |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | // add group join/image name-mark-signiture and so on if a new member successfully added |
| 447 | - if($output->toBool()) |
|
| 447 | + if ($output->toBool()) |
|
| 448 | 448 | { |
| 449 | 449 | // Join to the default group |
| 450 | 450 | $obj->group_srl = $default_group_srl; |
| 451 | - executeQuery('member.addMemberToGroup',$obj); |
|
| 451 | + executeQuery('member.addMemberToGroup', $obj); |
|
| 452 | 452 | // Image name |
| 453 | - if($obj->image_nickname) |
|
| 453 | + if ($obj->image_nickname) |
|
| 454 | 454 | { |
| 455 | 455 | $target_path = sprintf('files/member_extra_info/image_name/%s/', getNumberingPath($obj->member_srl)); |
| 456 | 456 | $target_filename = sprintf('%s%d.gif', $target_path, $obj->member_srl); |
| 457 | 457 | FileHandler::writeFile($target_filename, $obj->image_nickname); |
| 458 | 458 | } |
| 459 | 459 | // Image mark |
| 460 | - if($obj->image_mark && file_exists($obj->image_mark)) |
|
| 460 | + if ($obj->image_mark && file_exists($obj->image_mark)) |
|
| 461 | 461 | { |
| 462 | 462 | $target_path = sprintf('files/member_extra_info/image_mark/%s/', getNumberingPath($obj->member_srl)); |
| 463 | 463 | $target_filename = sprintf('%s%d.gif', $target_path, $obj->member_srl); |
| 464 | 464 | FileHandler::writeFile($target_filename, $obj->image_mark); |
| 465 | 465 | } |
| 466 | 466 | // Profile image |
| 467 | - if($obj->profile_image) |
|
| 467 | + if ($obj->profile_image) |
|
| 468 | 468 | { |
| 469 | 469 | $target_path = sprintf('files/member_extra_info/profile_image/%s/', getNumberingPath($obj->member_srl)); |
| 470 | 470 | $target_filename = sprintf('%s%d.gif', $target_path, $obj->member_srl); |
| 471 | 471 | FileHandler::writeFile($target_filename, $obj->profile_image); |
| 472 | 472 | } |
| 473 | 473 | // Signiture |
| 474 | - if($obj->signature) |
|
| 474 | + if ($obj->signature) |
|
| 475 | 475 | { |
| 476 | 476 | $signature = removeHackTag($obj->signature); |
| 477 | 477 | $signature_buff = sprintf('<?php if(!defined("__XE__")) exit();?>%s', $signature); |
| 478 | 478 | |
| 479 | 479 | $target_path = sprintf('files/member_extra_info/signature/%s/', getNumberingPath($obj->member_srl)); |
| 480 | - if(!is_dir($target_path)) FileHandler::makeDir($target_path); |
|
| 480 | + if (!is_dir($target_path)) FileHandler::makeDir($target_path); |
|
| 481 | 481 | $target_filename = sprintf('%s%d.signature.php', $target_path, $obj->member_srl); |
| 482 | 482 | |
| 483 | 483 | FileHandler::writeFile($target_filename, $signature_buff); |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | |
| 488 | 488 | fclose($f); |
| 489 | 489 | |
| 490 | - return $idx-1; |
|
| 490 | + return $idx - 1; |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | /** |
@@ -499,58 +499,58 @@ discard block |
||
| 499 | 499 | */ |
| 500 | 500 | function importMessage($key, $cur, $index_file) |
| 501 | 501 | { |
| 502 | - if(!$cur) $cur = 0; |
|
| 502 | + if (!$cur) $cur = 0; |
|
| 503 | 503 | // Create the xmlParser object |
| 504 | 504 | $oXmlParser = new XmlParser(); |
| 505 | 505 | // Open an index file |
| 506 | - $f = fopen($index_file,"r"); |
|
| 506 | + $f = fopen($index_file, "r"); |
|
| 507 | 507 | // Pass if already read |
| 508 | - for($i=0;$i<$cur;$i++) fgets($f, 1024); |
|
| 508 | + for ($i = 0; $i < $cur; $i++) fgets($f, 1024); |
|
| 509 | 509 | // Read each line until the condition meets |
| 510 | - for($idx=$cur;$idx<$cur+$this->unit_count;$idx++) |
|
| 510 | + for ($idx = $cur; $idx < $cur + $this->unit_count; $idx++) |
|
| 511 | 511 | { |
| 512 | - if(feof($f)) break; |
|
| 512 | + if (feof($f)) break; |
|
| 513 | 513 | // Find a location |
| 514 | 514 | $target_file = trim(fgets($f, 1024)); |
| 515 | 515 | // Load and parse the file |
| 516 | 516 | $xmlObj = $oXmlParser->loadXmlFile($target_file); |
| 517 | 517 | FileHandler::removeFile($target_file); |
| 518 | - if(!$xmlObj) continue; |
|
| 518 | + if (!$xmlObj) continue; |
|
| 519 | 519 | // List objects |
| 520 | 520 | $obj = null; |
| 521 | 521 | $obj->receiver = base64_decode($xmlObj->message->receiver->body); |
| 522 | 522 | $obj->sender = base64_decode($xmlObj->message->sender->body); |
| 523 | 523 | $obj->title = base64_decode($xmlObj->message->title->body); |
| 524 | 524 | $obj->content = base64_decode($xmlObj->message->content->body); |
| 525 | - $obj->readed = base64_decode($xmlObj->message->readed->body)=='Y'?'Y':'N'; |
|
| 525 | + $obj->readed = base64_decode($xmlObj->message->readed->body) == 'Y' ? 'Y' : 'N'; |
|
| 526 | 526 | $obj->regdate = base64_decode($xmlObj->message->regdate->body); |
| 527 | 527 | $obj->readed_date = base64_decode($xmlObj->message->readed_date->body); |
| 528 | 528 | // Get member_srl of sender/recipient (If not exists, pass) |
| 529 | - if(!$obj->sender) continue; |
|
| 529 | + if (!$obj->sender) continue; |
|
| 530 | 530 | $sender_args->user_id = $obj->sender; |
| 531 | - $sender_output = executeQuery('member.getMemberInfo',$sender_args); |
|
| 531 | + $sender_output = executeQuery('member.getMemberInfo', $sender_args); |
|
| 532 | 532 | $sender_srl = $sender_output->data->member_srl; |
| 533 | - if(!$sender_srl) |
|
| 533 | + if (!$sender_srl) |
|
| 534 | 534 | { |
| 535 | 535 | unset($sender_args); |
| 536 | 536 | $sender_args->email_address = $obj->sender; |
| 537 | - $sender_output = executeQuery('member.getMemberInfoByEmailAddress',$sender_args); |
|
| 537 | + $sender_output = executeQuery('member.getMemberInfoByEmailAddress', $sender_args); |
|
| 538 | 538 | $sender_srl = $sender_output->data->member_srl; |
| 539 | 539 | } |
| 540 | - if(!$sender_srl) continue; |
|
| 540 | + if (!$sender_srl) continue; |
|
| 541 | 541 | |
| 542 | 542 | $receiver_args->user_id = $obj->receiver; |
| 543 | - if(!$obj->receiver) continue; |
|
| 544 | - $receiver_output = executeQuery('member.getMemberInfo',$receiver_args); |
|
| 543 | + if (!$obj->receiver) continue; |
|
| 544 | + $receiver_output = executeQuery('member.getMemberInfo', $receiver_args); |
|
| 545 | 545 | $receiver_srl = $receiver_output->data->member_srl; |
| 546 | - if(!$receiver_srl) |
|
| 546 | + if (!$receiver_srl) |
|
| 547 | 547 | { |
| 548 | 548 | unset($receiver_args); |
| 549 | 549 | $receiver_args->email_address = $obj->receiver; |
| 550 | - $receiver_output = executeQuery('member.getMemberInfoByEmailAddress',$receiver_args); |
|
| 550 | + $receiver_output = executeQuery('member.getMemberInfoByEmailAddress', $receiver_args); |
|
| 551 | 551 | $receiver_srl = $receiver_output->data->member_srl; |
| 552 | 552 | } |
| 553 | - if(!$receiver_srl) continue; |
|
| 553 | + if (!$receiver_srl) continue; |
|
| 554 | 554 | // Message to save into sender's message box |
| 555 | 555 | $sender_args->sender_srl = $sender_srl; |
| 556 | 556 | $sender_args->receiver_srl = $receiver_srl; |
@@ -565,13 +565,13 @@ discard block |
||
| 565 | 565 | $sender_args->list_order = $sender_args->message_srl * -1; |
| 566 | 566 | |
| 567 | 567 | $output = executeQuery('communication.sendMessage', $sender_args); |
| 568 | - if($output->toBool()) |
|
| 568 | + if ($output->toBool()) |
|
| 569 | 569 | { |
| 570 | 570 | // Message to save into recipient's massage box |
| 571 | 571 | $receiver_args->message_srl = $sender_args->related_srl; |
| 572 | - $receiver_args->list_order = $sender_args->related_srl*-1; |
|
| 572 | + $receiver_args->list_order = $sender_args->related_srl * -1; |
|
| 573 | 573 | $receiver_args->sender_srl = $sender_srl; |
| 574 | - if(!$receiver_args->sender_srl) $receiver_args->sender_srl = $receiver_srl; |
|
| 574 | + if (!$receiver_args->sender_srl) $receiver_args->sender_srl = $receiver_srl; |
|
| 575 | 575 | $receiver_args->receiver_srl = $receiver_srl; |
| 576 | 576 | $receiver_args->message_type = 'R'; |
| 577 | 577 | $receiver_args->title = $obj->title; |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | |
| 586 | 586 | fclose($f); |
| 587 | 587 | |
| 588 | - return $idx-1; |
|
| 588 | + return $idx - 1; |
|
| 589 | 589 | } |
| 590 | 590 | |
| 591 | 591 | /** |
@@ -605,10 +605,10 @@ discard block |
||
| 605 | 605 | $oDocumentModel = getModel('document'); |
| 606 | 606 | $category_list = $category_titles = array(); |
| 607 | 607 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
| 608 | - if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
| 608 | + if (count($category_list)) foreach ($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
| 609 | 609 | // Extract category information |
| 610 | 610 | $category_file = preg_replace('/index$/i', 'category.xml', $index_file); |
| 611 | - if(file_exists($category_file)) |
|
| 611 | + if (file_exists($category_file)) |
|
| 612 | 612 | { |
| 613 | 613 | $buff = FileHandler::readFile($category_file); |
| 614 | 614 | |
@@ -616,14 +616,14 @@ discard block |
||
| 616 | 616 | $xmlDoc = $this->oXmlParser->loadXmlFile($category_file); |
| 617 | 617 | |
| 618 | 618 | $categories = $xmlDoc->items->category; |
| 619 | - if($categories) |
|
| 619 | + if ($categories) |
|
| 620 | 620 | { |
| 621 | - if(!is_array($categories)) $categories = array($categories); |
|
| 621 | + if (!is_array($categories)) $categories = array($categories); |
|
| 622 | 622 | $match_sequence = array(); |
| 623 | - foreach($categories as $k => $v) |
|
| 623 | + foreach ($categories as $k => $v) |
|
| 624 | 624 | { |
| 625 | 625 | $category = trim(base64_decode($v->body)); |
| 626 | - if(!$category || $category_titles[$category]) continue; |
|
| 626 | + if (!$category || $category_titles[$category]) continue; |
|
| 627 | 627 | |
| 628 | 628 | $sequence = $v->attrs->sequence; |
| 629 | 629 | $parent = $v->attrs->parent; |
@@ -631,10 +631,10 @@ discard block |
||
| 631 | 631 | $obj = null; |
| 632 | 632 | $obj->title = $category; |
| 633 | 633 | $obj->module_srl = $module_srl; |
| 634 | - if($parent) $obj->parent_srl = $match_sequence[$parent]; |
|
| 634 | + if ($parent) $obj->parent_srl = $match_sequence[$parent]; |
|
| 635 | 635 | |
| 636 | 636 | $output = $oDocumentController->insertCategory($obj); |
| 637 | - if($output->toBool()) $match_sequence[$sequence] = $output->get('category_srl'); |
|
| 637 | + if ($output->toBool()) $match_sequence[$sequence] = $output->get('category_srl'); |
|
| 638 | 638 | } |
| 639 | 639 | $oDocumentController = getController('document'); |
| 640 | 640 | $oDocumentController->makeCategoryFile($module_srl); |
@@ -644,31 +644,31 @@ discard block |
||
| 644 | 644 | |
| 645 | 645 | $category_list = $category_titles = array(); |
| 646 | 646 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
| 647 | - if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
| 647 | + if (count($category_list)) foreach ($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
| 648 | 648 | |
| 649 | 649 | $ek_args->module_srl = $module_srl; |
| 650 | 650 | $output = executeQueryArray('document.getDocumentExtraKeys', $ek_args); |
| 651 | - if($output->data) |
|
| 651 | + if ($output->data) |
|
| 652 | 652 | { |
| 653 | - foreach($output->data as $key => $val) $extra_keys[$val->eid] = true; |
|
| 653 | + foreach ($output->data as $key => $val) $extra_keys[$val->eid] = true; |
|
| 654 | 654 | } |
| 655 | 655 | |
| 656 | - if(!$cur) $cur = 0; |
|
| 656 | + if (!$cur) $cur = 0; |
|
| 657 | 657 | // Open an index file |
| 658 | - $f = fopen($index_file,"r"); |
|
| 658 | + $f = fopen($index_file, "r"); |
|
| 659 | 659 | // Pass if already read |
| 660 | - for($i=0;$i<$cur;$i++) fgets($f, 1024); |
|
| 660 | + for ($i = 0; $i < $cur; $i++) fgets($f, 1024); |
|
| 661 | 661 | // Read each line until the condition meets |
| 662 | - for($idx=$cur;$idx<$cur+$this->unit_count;$idx++) |
|
| 662 | + for ($idx = $cur; $idx < $cur + $this->unit_count; $idx++) |
|
| 663 | 663 | { |
| 664 | - if(feof($f)) break; |
|
| 664 | + if (feof($f)) break; |
|
| 665 | 665 | // Find a location |
| 666 | 666 | $target_file = trim(fgets($f, 1024)); |
| 667 | 667 | |
| 668 | - if(!file_exists($target_file)) continue; |
|
| 668 | + if (!file_exists($target_file)) continue; |
|
| 669 | 669 | // Importing data from now on |
| 670 | - $fp = fopen($target_file,"r"); |
|
| 671 | - if(!$fp) continue; |
|
| 670 | + $fp = fopen($target_file, "r"); |
|
| 671 | + if (!$fp) continue; |
|
| 672 | 672 | |
| 673 | 673 | $obj = new stdClass; |
| 674 | 674 | $obj->module_srl = $module_srl; |
@@ -680,51 +680,51 @@ discard block |
||
| 680 | 680 | $started = false; |
| 681 | 681 | $buff = array(); |
| 682 | 682 | // Start from the body data |
| 683 | - while(!feof($fp)) |
|
| 683 | + while (!feof($fp)) |
|
| 684 | 684 | { |
| 685 | 685 | $str = fgets($fp, 1024); |
| 686 | 686 | // Prepare an item |
| 687 | - if(trim($str) == '<post>') |
|
| 687 | + if (trim($str) == '<post>') |
|
| 688 | 688 | { |
| 689 | 689 | $started = true; |
| 690 | 690 | // Trackback inserted |
| 691 | 691 | } |
| 692 | - else if(substr($str,0,11) == '<trackbacks') |
|
| 692 | + else if (substr($str, 0, 11) == '<trackbacks') |
|
| 693 | 693 | { |
| 694 | 694 | $obj->trackback_count = $this->importTrackbacks($fp, $module_srl, $obj->document_srl); |
| 695 | 695 | continue; |
| 696 | 696 | // Comments inserted |
| 697 | 697 | } |
| 698 | - else if(substr($str,0,9) == '<comments') |
|
| 698 | + else if (substr($str, 0, 9) == '<comments') |
|
| 699 | 699 | { |
| 700 | 700 | $obj->comment_count = $this->importComments($fp, $module_srl, $obj->document_srl); |
| 701 | 701 | continue; |
| 702 | 702 | // Attachment inserted |
| 703 | 703 | } |
| 704 | - else if(substr($str,0,9) == '<attaches') |
|
| 704 | + else if (substr($str, 0, 9) == '<attaches') |
|
| 705 | 705 | { |
| 706 | 706 | $obj->uploaded_count = $this->importAttaches($fp, $module_srl, $obj->document_srl, $files); |
| 707 | 707 | continue; |
| 708 | 708 | // When starting extra variabls |
| 709 | 709 | } |
| 710 | - elseif(trim($str) == '<extra_vars>') |
|
| 710 | + elseif (trim($str) == '<extra_vars>') |
|
| 711 | 711 | { |
| 712 | 712 | $extra_vars = $this->importExtraVars($fp); |
| 713 | 713 | continue; |
| 714 | 714 | } |
| 715 | 715 | |
| 716 | - if($started) $buff[] = $str; |
|
| 716 | + if ($started) $buff[] = $str; |
|
| 717 | 717 | } |
| 718 | 718 | |
| 719 | 719 | $xmlDoc = $this->oXmlParser->parse(implode('', $buff)); |
| 720 | 720 | |
| 721 | 721 | $category = base64_decode($xmlDoc->post->category->body); |
| 722 | - if($category_titles[$category]) $obj->category_srl = $category_titles[$category]; |
|
| 722 | + if ($category_titles[$category]) $obj->category_srl = $category_titles[$category]; |
|
| 723 | 723 | |
| 724 | 724 | $obj->member_srl = 0; |
| 725 | 725 | |
| 726 | - $obj->is_notice = base64_decode($xmlDoc->post->is_notice->body)=='Y'?'Y':'N'; |
|
| 727 | - $obj->status = base64_decode($xmlDoc->post->is_secret->body)=='Y'?$oDocumentModel->getConfigStatus('secret'):$oDocumentModel->getConfigStatus('public'); |
|
| 726 | + $obj->is_notice = base64_decode($xmlDoc->post->is_notice->body) == 'Y' ? 'Y' : 'N'; |
|
| 727 | + $obj->status = base64_decode($xmlDoc->post->is_secret->body) == 'Y' ? $oDocumentModel->getConfigStatus('secret') : $oDocumentModel->getConfigStatus('public'); |
|
| 728 | 728 | $obj->title = base64_decode($xmlDoc->post->title->body); |
| 729 | 729 | $obj->content = base64_decode($xmlDoc->post->content->body); |
| 730 | 730 | $obj->readed_count = base64_decode($xmlDoc->post->readed_count->body); |
@@ -733,39 +733,39 @@ discard block |
||
| 733 | 733 | $obj->password = base64_decode($xmlDoc->post->password->body); |
| 734 | 734 | $obj->user_name = base64_decode($xmlDoc->post->user_name->body); |
| 735 | 735 | $obj->nick_name = base64_decode($xmlDoc->post->nick_name->body); |
| 736 | - if(!$obj->user_name) $obj->user_name = $obj->nick_name; |
|
| 736 | + if (!$obj->user_name) $obj->user_name = $obj->nick_name; |
|
| 737 | 737 | $obj->user_id = base64_decode($xmlDoc->post->user_id->body); |
| 738 | 738 | $obj->email_address = base64_decode($xmlDoc->post->email->body); |
| 739 | 739 | $obj->homepage = base64_decode($xmlDoc->post->homepage->body); |
| 740 | - if($obj->homepage && strncasecmp('http://', $obj->homepage, 7) !== 0 && strncasecmp('https://', $obj->homepage, 8) !== 0) $obj->homepage = 'http://'.$obj->homepage; |
|
| 740 | + if ($obj->homepage && strncasecmp('http://', $obj->homepage, 7) !== 0 && strncasecmp('https://', $obj->homepage, 8) !== 0) $obj->homepage = 'http://'.$obj->homepage; |
|
| 741 | 741 | $obj->tags = base64_decode($xmlDoc->post->tags->body); |
| 742 | 742 | $obj->regdate = base64_decode($xmlDoc->post->regdate->body); |
| 743 | 743 | $obj->last_update = base64_decode($xmlDoc->post->update->body); |
| 744 | 744 | $obj->last_updater = base64_decode($xmlDoc->post->last_updater->body); |
| 745 | - if(!$obj->last_update) $obj->last_update = $obj->regdate; |
|
| 745 | + if (!$obj->last_update) $obj->last_update = $obj->regdate; |
|
| 746 | 746 | $obj->ipaddress = base64_decode($xmlDoc->post->ipaddress->body); |
| 747 | - $obj->list_order = $obj->update_order = $obj->document_srl*-1; |
|
| 748 | - $obj->commentStatus = base64_decode($xmlDoc->post->allow_comment->body)!='N'?'ALLOW':'DENY'; |
|
| 749 | - $obj->allow_trackback = base64_decode($xmlDoc->post->allow_trackback->body)!='N'?'Y':'N'; |
|
| 747 | + $obj->list_order = $obj->update_order = $obj->document_srl * -1; |
|
| 748 | + $obj->commentStatus = base64_decode($xmlDoc->post->allow_comment->body) != 'N' ? 'ALLOW' : 'DENY'; |
|
| 749 | + $obj->allow_trackback = base64_decode($xmlDoc->post->allow_trackback->body) != 'N' ? 'Y' : 'N'; |
|
| 750 | 750 | $obj->notify_message = base64_decode($xmlDoc->post->is_notice->body); |
| 751 | 751 | // Change content information (attachment) |
| 752 | - if(count($files)) |
|
| 752 | + if (count($files)) |
|
| 753 | 753 | { |
| 754 | - foreach($files as $key => $val) |
|
| 754 | + foreach ($files as $key => $val) |
|
| 755 | 755 | { |
| 756 | - $obj->content = preg_replace('/(src|href)\=(["\']?)'.preg_quote($key).'(["\']?)/i','$1="'.$val.'"',$obj->content); |
|
| 757 | - $obj->content = preg_replace('/(["\']?).\/files\/(.+)\/'.preg_quote($key).'([^"\']+)(["\']?)/i','"'.$val.'"',$obj->content); |
|
| 758 | - $obj->content = preg_replace('/(["\']?)files\/(.+)\/'.preg_quote($key).'([^"\']+)(["\']?)/i','"'.$val.'"',$obj->content); |
|
| 756 | + $obj->content = preg_replace('/(src|href)\=(["\']?)'.preg_quote($key).'(["\']?)/i', '$1="'.$val.'"', $obj->content); |
|
| 757 | + $obj->content = preg_replace('/(["\']?).\/files\/(.+)\/'.preg_quote($key).'([^"\']+)(["\']?)/i', '"'.$val.'"', $obj->content); |
|
| 758 | + $obj->content = preg_replace('/(["\']?)files\/(.+)\/'.preg_quote($key).'([^"\']+)(["\']?)/i', '"'.$val.'"', $obj->content); |
|
| 759 | 759 | } |
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | $output = executeQuery('document.insertDocument', $obj); |
| 763 | 763 | |
| 764 | - if($output->toBool() && $obj->tags) |
|
| 764 | + if ($output->toBool() && $obj->tags) |
|
| 765 | 765 | { |
| 766 | - $tag_list = explode(',',$obj->tags); |
|
| 766 | + $tag_list = explode(',', $obj->tags); |
|
| 767 | 767 | $tag_count = count($tag_list); |
| 768 | - for($i=0;$i<$tag_count;$i++) |
|
| 768 | + for ($i = 0; $i < $tag_count; $i++) |
|
| 769 | 769 | { |
| 770 | 770 | $args = new stdClass; |
| 771 | 771 | $args->tag_srl = getNextSequence(); |
@@ -773,17 +773,17 @@ discard block |
||
| 773 | 773 | $args->document_srl = $obj->document_srl; |
| 774 | 774 | $args->tag = trim($tag_list[$i]); |
| 775 | 775 | $args->regdate = $obj->regdate; |
| 776 | - if(!$args->tag) continue; |
|
| 776 | + if (!$args->tag) continue; |
|
| 777 | 777 | $output = executeQuery('tag.insertTag', $args); |
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | } |
| 781 | 781 | // Add extra variables |
| 782 | - if(count($extra_vars)) |
|
| 782 | + if (count($extra_vars)) |
|
| 783 | 783 | { |
| 784 | - foreach($extra_vars as $key => $val) |
|
| 784 | + foreach ($extra_vars as $key => $val) |
|
| 785 | 785 | { |
| 786 | - if(!$val->value) continue; |
|
| 786 | + if (!$val->value) continue; |
|
| 787 | 787 | unset($e_args); |
| 788 | 788 | $e_args->module_srl = $module_srl; |
| 789 | 789 | $e_args->document_srl = $obj->document_srl; |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | $e_args->lang_code = $val->lang_code; |
| 793 | 793 | $e_args->eid = $val->eid; |
| 794 | 794 | // Create a key for extra vars if not exists (except vars for title and content) |
| 795 | - if(!preg_match('/^(title|content)_(.+)$/i',$e_args->eid) && !$extra_keys[$e_args->eid]) |
|
| 795 | + if (!preg_match('/^(title|content)_(.+)$/i', $e_args->eid) && !$extra_keys[$e_args->eid]) |
|
| 796 | 796 | { |
| 797 | 797 | unset($ek_args); |
| 798 | 798 | $ek_args->module_srl = $module_srl; |
@@ -816,9 +816,9 @@ discard block |
||
| 816 | 816 | |
| 817 | 817 | fclose($f); |
| 818 | 818 | // Sync category counts |
| 819 | - if(count($category_list)) foreach($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl); |
|
| 819 | + if (count($category_list)) foreach ($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl); |
|
| 820 | 820 | |
| 821 | - return $idx-1; |
|
| 821 | + return $idx - 1; |
|
| 822 | 822 | } |
| 823 | 823 | |
| 824 | 824 | /** |
@@ -834,17 +834,17 @@ discard block |
||
| 834 | 834 | $buff = null; |
| 835 | 835 | $cnt = 0; |
| 836 | 836 | |
| 837 | - while(!feof($fp)) |
|
| 837 | + while (!feof($fp)) |
|
| 838 | 838 | { |
| 839 | 839 | $str = fgets($fp, 1024); |
| 840 | 840 | // If </trackbacks> is, break |
| 841 | - if(trim($str) == '</trackbacks>') break; |
|
| 841 | + if (trim($str) == '</trackbacks>') break; |
|
| 842 | 842 | // If <trackback>, start importing |
| 843 | - if(trim($str) == '<trackback>') $started = true; |
|
| 843 | + if (trim($str) == '<trackback>') $started = true; |
|
| 844 | 844 | |
| 845 | - if($started) $buff .= $str; |
|
| 845 | + if ($started) $buff .= $str; |
|
| 846 | 846 | // If </trackback>, insert to the DB |
| 847 | - if(trim($str) == '</trackback>') |
|
| 847 | + if (trim($str) == '</trackback>') |
|
| 848 | 848 | { |
| 849 | 849 | $xmlDoc = $this->oXmlParser->parse($buff); |
| 850 | 850 | |
@@ -858,9 +858,9 @@ discard block |
||
| 858 | 858 | $obj->excerpt = base64_decode($xmlDoc->trackback->excerpt->body); |
| 859 | 859 | $obj->regdate = base64_decode($xmlDoc->trackback->regdate->body); |
| 860 | 860 | $obj->ipaddress = base64_decode($xmlDoc->trackback->ipaddress->body); |
| 861 | - $obj->list_order = -1*$obj->trackback_srl; |
|
| 861 | + $obj->list_order = -1 * $obj->trackback_srl; |
|
| 862 | 862 | $output = executeQuery('trackback.insertTrackback', $obj); |
| 863 | - if($output->toBool()) $cnt++; |
|
| 863 | + if ($output->toBool()) $cnt++; |
|
| 864 | 864 | |
| 865 | 865 | $buff = null; |
| 866 | 866 | $started = false; |
@@ -884,13 +884,13 @@ discard block |
||
| 884 | 884 | |
| 885 | 885 | $sequences = array(); |
| 886 | 886 | |
| 887 | - while(!feof($fp)) |
|
| 887 | + while (!feof($fp)) |
|
| 888 | 888 | { |
| 889 | 889 | $str = fgets($fp, 1024); |
| 890 | 890 | // If </comments> is, break |
| 891 | - if(trim($str) == '</comments>') break; |
|
| 891 | + if (trim($str) == '</comments>') break; |
|
| 892 | 892 | // If <comment> is, start importing |
| 893 | - if(trim($str) == '<comment>') |
|
| 893 | + if (trim($str) == '<comment>') |
|
| 894 | 894 | { |
| 895 | 895 | $started = true; |
| 896 | 896 | $obj = new stdClass; |
@@ -898,15 +898,15 @@ discard block |
||
| 898 | 898 | $files = array(); |
| 899 | 899 | } |
| 900 | 900 | // If <attaches is, start importing attachments |
| 901 | - if(substr($str,0,9) == '<attaches') |
|
| 901 | + if (substr($str, 0, 9) == '<attaches') |
|
| 902 | 902 | { |
| 903 | 903 | $obj->uploaded_count = $this->importAttaches($fp, $module_srl, $obj->comment_srl, $files); |
| 904 | 904 | continue; |
| 905 | 905 | } |
| 906 | 906 | |
| 907 | - if($started) $buff .= $str; |
|
| 907 | + if ($started) $buff .= $str; |
|
| 908 | 908 | // If </comment> is, insert to the DB |
| 909 | - if(trim($str) == '</comment>') |
|
| 909 | + if (trim($str) == '</comment>') |
|
| 910 | 910 | { |
| 911 | 911 | $xmlDoc = $this->oXmlParser->parse($buff); |
| 912 | 912 | |
@@ -916,35 +916,35 @@ discard block |
||
| 916 | 916 | |
| 917 | 917 | $obj->module_srl = $module_srl; |
| 918 | 918 | |
| 919 | - if($parent) $obj->parent_srl = $sequences[$parent]; |
|
| 919 | + if ($parent) $obj->parent_srl = $sequences[$parent]; |
|
| 920 | 920 | else $obj->parent_srl = 0; |
| 921 | 921 | |
| 922 | 922 | $obj->document_srl = $document_srl; |
| 923 | - $obj->is_secret = base64_decode($xmlDoc->comment->is_secret->body)=='Y'?'Y':'N'; |
|
| 924 | - $obj->notify_message = base64_decode($xmlDoc->comment->notify_message->body)=='Y'?'Y':'N'; |
|
| 923 | + $obj->is_secret = base64_decode($xmlDoc->comment->is_secret->body) == 'Y' ? 'Y' : 'N'; |
|
| 924 | + $obj->notify_message = base64_decode($xmlDoc->comment->notify_message->body) == 'Y' ? 'Y' : 'N'; |
|
| 925 | 925 | $obj->content = base64_decode($xmlDoc->comment->content->body); |
| 926 | 926 | $obj->voted_count = base64_decode($xmlDoc->comment->voted_count->body); |
| 927 | 927 | $obj->blamed_count = base64_decode($xmlDoc->comment->blamed_count->body); |
| 928 | 928 | $obj->password = base64_decode($xmlDoc->comment->password->body); |
| 929 | - $obj->user_name =base64_decode($xmlDoc->comment->user_name->body); |
|
| 929 | + $obj->user_name = base64_decode($xmlDoc->comment->user_name->body); |
|
| 930 | 930 | $obj->nick_name = base64_decode($xmlDoc->comment->nick_name->body); |
| 931 | - if(!$obj->user_name) $obj->user_name = $obj->nick_name; |
|
| 931 | + if (!$obj->user_name) $obj->user_name = $obj->nick_name; |
|
| 932 | 932 | $obj->user_id = base64_decode($xmlDoc->comment->user_id->body); |
| 933 | 933 | $obj->member_srl = 0; |
| 934 | 934 | $obj->email_address = base64_decode($xmlDoc->comment->email->body); |
| 935 | 935 | $obj->homepage = base64_decode($xmlDoc->comment->homepage->body); |
| 936 | 936 | $obj->regdate = base64_decode($xmlDoc->comment->regdate->body); |
| 937 | 937 | $obj->last_update = base64_decode($xmlDoc->comment->update->body); |
| 938 | - if(!$obj->last_update) $obj->last_update = $obj->regdate; |
|
| 938 | + if (!$obj->last_update) $obj->last_update = $obj->regdate; |
|
| 939 | 939 | $obj->ipaddress = base64_decode($xmlDoc->comment->ipaddress->body); |
| 940 | - $obj->status = base64_decode($xmlDoc->comment->status->body)==''?'1':base64_decode($xmlDoc->comment->status->body); |
|
| 941 | - $obj->list_order = $obj->comment_srl*-1; |
|
| 940 | + $obj->status = base64_decode($xmlDoc->comment->status->body) == '' ? '1' : base64_decode($xmlDoc->comment->status->body); |
|
| 941 | + $obj->list_order = $obj->comment_srl * -1; |
|
| 942 | 942 | // Change content information (attachment) |
| 943 | - if(count($files)) |
|
| 943 | + if (count($files)) |
|
| 944 | 944 | { |
| 945 | - foreach($files as $key => $val) |
|
| 945 | + foreach ($files as $key => $val) |
|
| 946 | 946 | { |
| 947 | - $obj->content = preg_replace('/(src|href)\=(["\']?)'.preg_quote($key).'(["\']?)/i','$1="'.$val.'"',$obj->content); |
|
| 947 | + $obj->content = preg_replace('/(src|href)\=(["\']?)'.preg_quote($key).'(["\']?)/i', '$1="'.$val.'"', $obj->content); |
|
| 948 | 948 | } |
| 949 | 949 | } |
| 950 | 950 | // Comment list first |
@@ -954,7 +954,7 @@ discard block |
||
| 954 | 954 | $list_args->module_srl = $obj->module_srl; |
| 955 | 955 | $list_args->regdate = $obj->regdate; |
| 956 | 956 | // Set data directly if parent comment doesn't exist |
| 957 | - if(!$obj->parent_srl) |
|
| 957 | + if (!$obj->parent_srl) |
|
| 958 | 958 | { |
| 959 | 959 | $list_args->head = $list_args->arrange = $obj->comment_srl; |
| 960 | 960 | $list_args->depth = 0; |
@@ -966,25 +966,25 @@ discard block |
||
| 966 | 966 | $parent_args->comment_srl = $obj->parent_srl; |
| 967 | 967 | $parent_output = executeQuery('comment.getCommentListItem', $parent_args); |
| 968 | 968 | // Return if parent comment doesn't exist |
| 969 | - if(!$parent_output->toBool() || !$parent_output->data) continue; |
|
| 969 | + if (!$parent_output->toBool() || !$parent_output->data) continue; |
|
| 970 | 970 | $parent = $parent_output->data; |
| 971 | 971 | |
| 972 | 972 | $list_args->head = $parent->head; |
| 973 | - $list_args->depth = $parent->depth+1; |
|
| 974 | - if($list_args->depth<2) $list_args->arrange = $obj->comment_srl; |
|
| 973 | + $list_args->depth = $parent->depth + 1; |
|
| 974 | + if ($list_args->depth < 2) $list_args->arrange = $obj->comment_srl; |
|
| 975 | 975 | else |
| 976 | 976 | { |
| 977 | 977 | $list_args->arrange = $parent->arrange; |
| 978 | 978 | $output = executeQuery('comment.updateCommentListArrange', $list_args); |
| 979 | - if(!$output->toBool()) return $output; |
|
| 979 | + if (!$output->toBool()) return $output; |
|
| 980 | 980 | } |
| 981 | 981 | } |
| 982 | 982 | |
| 983 | 983 | $output = executeQuery('comment.insertCommentList', $list_args); |
| 984 | - if($output->toBool()) |
|
| 984 | + if ($output->toBool()) |
|
| 985 | 985 | { |
| 986 | 986 | $output = executeQuery('comment.insertComment', $obj); |
| 987 | - if($output->toBool()) $cnt++; |
|
| 987 | + if ($output->toBool()) $cnt++; |
|
| 988 | 988 | } |
| 989 | 989 | |
| 990 | 990 | $buff = null; |
@@ -1010,13 +1010,13 @@ discard block |
||
| 1010 | 1010 | $buff = null; |
| 1011 | 1011 | |
| 1012 | 1012 | $file_obj = new stdClass; |
| 1013 | - while(!feof($fp)) |
|
| 1013 | + while (!feof($fp)) |
|
| 1014 | 1014 | { |
| 1015 | 1015 | $str = trim(fgets($fp, 1024)); |
| 1016 | 1016 | // If it ends with </attaches>, break |
| 1017 | - if(trim($str) == '</attaches>') break; |
|
| 1017 | + if (trim($str) == '</attaches>') break; |
|
| 1018 | 1018 | // If it starts with <attach>, collect attachments |
| 1019 | - if(trim($str) == '<attach>') |
|
| 1019 | + if (trim($str) == '<attach>') |
|
| 1020 | 1020 | { |
| 1021 | 1021 | $file_obj->file_srl = getNextSequence(); |
| 1022 | 1022 | $file_obj->upload_target_srl = $upload_target_srl; |
@@ -1026,26 +1026,26 @@ discard block |
||
| 1026 | 1026 | $buff = null; |
| 1027 | 1027 | // If it starts with <file>, handle the attachement in xml file |
| 1028 | 1028 | } |
| 1029 | - else if(trim($str) == '<file>') |
|
| 1029 | + else if (trim($str) == '<file>') |
|
| 1030 | 1030 | { |
| 1031 | 1031 | $file_obj->file = $this->saveTemporaryFile($fp); |
| 1032 | 1032 | continue; |
| 1033 | 1033 | } |
| 1034 | 1034 | |
| 1035 | - if($started) $buff .= $str; |
|
| 1035 | + if ($started) $buff .= $str; |
|
| 1036 | 1036 | // If it ends with </attach>, handle attachements |
| 1037 | - if(trim($str) == '</attach>') |
|
| 1037 | + if (trim($str) == '</attach>') |
|
| 1038 | 1038 | { |
| 1039 | 1039 | $xmlDoc = $this->oXmlParser->parse($buff.$str); |
| 1040 | 1040 | |
| 1041 | 1041 | $file_obj->source_filename = base64_decode($xmlDoc->attach->filename->body); |
| 1042 | 1042 | $file_obj->download_count = base64_decode($xmlDoc->attach->download_count->body); |
| 1043 | 1043 | |
| 1044 | - if(!$file_obj->file) |
|
| 1044 | + if (!$file_obj->file) |
|
| 1045 | 1045 | { |
| 1046 | 1046 | $url = base64_decode($xmlDoc->attach->url->body); |
| 1047 | 1047 | $path = base64_decode($xmlDoc->attach->path->body); |
| 1048 | - if($path && file_exists($path)) $file_obj->file = $path; |
|
| 1048 | + if ($path && file_exists($path)) $file_obj->file = $path; |
|
| 1049 | 1049 | else |
| 1050 | 1050 | { |
| 1051 | 1051 | $file_obj->file = $this->getTmpFilename(); |
@@ -1053,11 +1053,11 @@ discard block |
||
| 1053 | 1053 | } |
| 1054 | 1054 | } |
| 1055 | 1055 | |
| 1056 | - if(file_exists($file_obj->file)) |
|
| 1056 | + if (file_exists($file_obj->file)) |
|
| 1057 | 1057 | { |
| 1058 | 1058 | $random = new Password(); |
| 1059 | 1059 | // Set upload path by checking if the attachement is an image or other kind of file |
| 1060 | - if(preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_obj->source_filename)) |
|
| 1060 | + if (preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_obj->source_filename)) |
|
| 1061 | 1061 | { |
| 1062 | 1062 | // Immediately remove the direct file if it has any kind of extensions for hacking |
| 1063 | 1063 | $file_obj->source_filename = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x', $file_obj->source_filename); |
@@ -1065,14 +1065,14 @@ discard block |
||
| 1065 | 1065 | |
| 1066 | 1066 | $path = sprintf("./files/attach/images/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3)); |
| 1067 | 1067 | |
| 1068 | - $ext = substr(strrchr($file_obj->source_filename,'.'),1); |
|
| 1068 | + $ext = substr(strrchr($file_obj->source_filename, '.'), 1); |
|
| 1069 | 1069 | $_filename = $random->createSecureSalt(32, 'hex').'.'.$ext; |
| 1070 | 1070 | $filename = $path.$_filename; |
| 1071 | 1071 | |
| 1072 | 1072 | $idx = 1; |
| 1073 | - while(file_exists($filename)) |
|
| 1073 | + while (file_exists($filename)) |
|
| 1074 | 1074 | { |
| 1075 | - $filename = $path.preg_replace('/\.([a-z0-9]+)$/i','_'.$idx.'.$1', $_filename); |
|
| 1075 | + $filename = $path.preg_replace('/\.([a-z0-9]+)$/i', '_'.$idx.'.$1', $_filename); |
|
| 1076 | 1076 | $idx++; |
| 1077 | 1077 | } |
| 1078 | 1078 | |
@@ -1080,14 +1080,14 @@ discard block |
||
| 1080 | 1080 | } |
| 1081 | 1081 | else |
| 1082 | 1082 | { |
| 1083 | - $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3)); |
|
| 1083 | + $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3)); |
|
| 1084 | 1084 | $filename = $path.$random->createSecureSalt(32, 'hex'); |
| 1085 | 1085 | $file_obj->direct_download = 'N'; |
| 1086 | 1086 | } |
| 1087 | 1087 | // Create a directory |
| 1088 | - if(!FileHandler::makeDir($path)) continue; |
|
| 1088 | + if (!FileHandler::makeDir($path)) continue; |
|
| 1089 | 1089 | |
| 1090 | - if(strncmp('./files/cache/importer/', $file_obj->file, 23) === 0) |
|
| 1090 | + if (strncmp('./files/cache/importer/', $file_obj->file, 23) === 0) |
|
| 1091 | 1091 | { |
| 1092 | 1092 | FileHandler::rename($file_obj->file, $filename); |
| 1093 | 1093 | } |
@@ -1098,7 +1098,7 @@ discard block |
||
| 1098 | 1098 | |
| 1099 | 1099 | // Insert the file to the DB |
| 1100 | 1100 | unset($file_obj->file); |
| 1101 | - if(file_exists($filename)) |
|
| 1101 | + if (file_exists($filename)) |
|
| 1102 | 1102 | { |
| 1103 | 1103 | $file_obj->uploaded_filename = $filename; |
| 1104 | 1104 | $file_obj->file_size = filesize($filename); |
@@ -1108,13 +1108,13 @@ discard block |
||
| 1108 | 1108 | $file_obj->isvalid = 'Y'; |
| 1109 | 1109 | $output = executeQuery('file.insertFile', $file_obj); |
| 1110 | 1110 | |
| 1111 | - if($output->toBool()) |
|
| 1111 | + if ($output->toBool()) |
|
| 1112 | 1112 | { |
| 1113 | 1113 | $uploaded_count++; |
| 1114 | 1114 | $tmp_obj = null; |
| 1115 | 1115 | $tmp_obj->source_filename = $file_obj->source_filename; |
| 1116 | - if($file_obj->direct_download == 'Y') $files[$file_obj->source_filename] = $file_obj->uploaded_filename; |
|
| 1117 | - else $files[$file_obj->source_filename] = getUrl('','module','file','act','procFileDownload','file_srl',$file_obj->file_srl,'sid',$file_obj->sid); |
|
| 1116 | + if ($file_obj->direct_download == 'Y') $files[$file_obj->source_filename] = $file_obj->uploaded_filename; |
|
| 1117 | + else $files[$file_obj->source_filename] = getUrl('', 'module', 'file', 'act', 'procFileDownload', 'file_srl', $file_obj->file_srl, 'sid', $file_obj->sid); |
|
| 1118 | 1118 | } |
| 1119 | 1119 | } |
| 1120 | 1120 | } |
@@ -1131,8 +1131,8 @@ discard block |
||
| 1131 | 1131 | { |
| 1132 | 1132 | $path = "./files/cache/importer"; |
| 1133 | 1133 | FileHandler::makeDir($path); |
| 1134 | - $filename = sprintf("%s/%d", $path, rand(11111111,99999999)); |
|
| 1135 | - if(file_exists($filename)) $filename .= rand(111,999); |
|
| 1134 | + $filename = sprintf("%s/%d", $path, rand(11111111, 99999999)); |
|
| 1135 | + if (file_exists($filename)) $filename .= rand(111, 999); |
|
| 1136 | 1136 | return $filename; |
| 1137 | 1137 | } |
| 1138 | 1138 | |
@@ -1147,14 +1147,14 @@ discard block |
||
| 1147 | 1147 | $f = fopen($temp_filename, "w"); |
| 1148 | 1148 | |
| 1149 | 1149 | $buff = ''; |
| 1150 | - while(!feof($fp)) |
|
| 1150 | + while (!feof($fp)) |
|
| 1151 | 1151 | { |
| 1152 | 1152 | $str = trim(fgets($fp, 1024)); |
| 1153 | - if(trim($str) == '</file>') break; |
|
| 1153 | + if (trim($str) == '</file>') break; |
|
| 1154 | 1154 | |
| 1155 | 1155 | $buff .= $str; |
| 1156 | 1156 | |
| 1157 | - if(substr($buff,-7)=='</buff>') |
|
| 1157 | + if (substr($buff, -7) == '</buff>') |
|
| 1158 | 1158 | { |
| 1159 | 1159 | fwrite($f, base64_decode(substr($buff, 6, -7))); |
| 1160 | 1160 | $buff = ''; |
@@ -1173,23 +1173,23 @@ discard block |
||
| 1173 | 1173 | function importExtraVars($fp) |
| 1174 | 1174 | { |
| 1175 | 1175 | $buff = null; |
| 1176 | - while(!feof($fp)) |
|
| 1176 | + while (!feof($fp)) |
|
| 1177 | 1177 | { |
| 1178 | 1178 | $buff .= $str = trim(fgets($fp, 1024)); |
| 1179 | - if(trim($str) == '</extra_vars>') break; |
|
| 1179 | + if (trim($str) == '</extra_vars>') break; |
|
| 1180 | 1180 | } |
| 1181 | - if(!$buff) return array(); |
|
| 1181 | + if (!$buff) return array(); |
|
| 1182 | 1182 | |
| 1183 | 1183 | $buff = '<extra_vars>'.$buff; |
| 1184 | 1184 | $oXmlParser = new XmlParser(); |
| 1185 | 1185 | $xmlDoc = $this->oXmlParser->parse($buff); |
| 1186 | - if(!count($xmlDoc->extra_vars->key)) return array(); |
|
| 1186 | + if (!count($xmlDoc->extra_vars->key)) return array(); |
|
| 1187 | 1187 | |
| 1188 | 1188 | $index = 1; |
| 1189 | - foreach($xmlDoc->extra_vars->key as $k => $v) |
|
| 1189 | + foreach ($xmlDoc->extra_vars->key as $k => $v) |
|
| 1190 | 1190 | { |
| 1191 | 1191 | unset($vobj); |
| 1192 | - if($v->var_idx) |
|
| 1192 | + if ($v->var_idx) |
|
| 1193 | 1193 | { |
| 1194 | 1194 | $vobj->var_idx = base64_decode($v->var_idx->body); |
| 1195 | 1195 | $vobj->lang_code = base64_decode($v->lang_code->body); |
@@ -1197,7 +1197,7 @@ discard block |
||
| 1197 | 1197 | $vobj->eid = base64_decode($v->eid->body); |
| 1198 | 1198 | |
| 1199 | 1199 | } |
| 1200 | - else if($v->body) |
|
| 1200 | + else if ($v->body) |
|
| 1201 | 1201 | { |
| 1202 | 1202 | $vobj->var_idx = $index; |
| 1203 | 1203 | $vobj->lang_code = Context::getLangType(); |
@@ -55,24 +55,29 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | $isExists = 'true'; |
| 57 | 57 | $type = 'XML'; |
| 58 | - if(stristr($str, 'tattertools')) $type = 'TTXML'; |
|
| 58 | + if(stristr($str, 'tattertools')) { |
|
| 59 | + $type = 'TTXML'; |
|
| 60 | + } |
|
| 59 | 61 | |
| 60 | 62 | $this->add('type', $type); |
| 61 | 63 | } |
| 62 | 64 | fclose($fp); |
| 63 | 65 | $resultMessage = $lang->found_xml_file; |
| 66 | + } else { |
|
| 67 | + $resultMessage = $lang->cannot_url_file; |
|
| 64 | 68 | } |
| 65 | - else $resultMessage = $lang->cannot_url_file; |
|
| 69 | + } else { |
|
| 70 | + $resultMessage = $lang->cannot_allow_fopen_in_phpini; |
|
| 66 | 71 | } |
| 67 | - else $resultMessage = $lang->cannot_allow_fopen_in_phpini; |
|
| 68 | 72 | |
| 69 | 73 | $this->add('exists', $isExists); |
| 70 | - } |
|
| 71 | - else |
|
| 74 | + } else |
|
| 72 | 75 | { |
| 73 | 76 | $realPath = FileHandler::getRealPath($filename); |
| 74 | 77 | |
| 75 | - if(file_exists($realPath) && is_file($realPath)) $isExists = 'true'; |
|
| 78 | + if(file_exists($realPath) && is_file($realPath)) { |
|
| 79 | + $isExists = 'true'; |
|
| 80 | + } |
|
| 76 | 81 | $this->add('exists', $isExists); |
| 77 | 82 | |
| 78 | 83 | if($isExists == 'true') |
@@ -81,13 +86,16 @@ discard block |
||
| 81 | 86 | |
| 82 | 87 | $fp = fopen($realPath, "r"); |
| 83 | 88 | $str = fgets($fp, 100); |
| 84 | - if(stristr($str, 'tattertools')) $type = 'TTXML'; |
|
| 89 | + if(stristr($str, 'tattertools')) { |
|
| 90 | + $type = 'TTXML'; |
|
| 91 | + } |
|
| 85 | 92 | fclose($fp); |
| 86 | 93 | |
| 87 | 94 | $this->add('type', $type); |
| 88 | 95 | $resultMessage = $lang->found_xml_file; |
| 96 | + } else { |
|
| 97 | + $resultMessage = $lang->not_found_xml_file; |
|
| 89 | 98 | } |
| 90 | - else $resultMessage = $lang->not_found_xml_file; |
|
| 91 | 99 | } |
| 92 | 100 | $this->add('result_message', $resultMessage); |
| 93 | 101 | } |
@@ -112,8 +120,7 @@ discard block |
||
| 112 | 120 | { |
| 113 | 121 | $output = executeQuery('importer.updateDocumentSync'.$postFix); |
| 114 | 122 | $output = executeQuery('importer.updateCommentSync'.$postFix); |
| 115 | - } |
|
| 116 | - else |
|
| 123 | + } else |
|
| 117 | 124 | { |
| 118 | 125 | $output = executeQueryArray ('importer.getDocumentMemberSrlWithUserID'.$postFix); |
| 119 | 126 | if(is_array ($output->data) && count ($output->data)) |
@@ -129,8 +136,7 @@ discard block |
||
| 129 | 136 | if($tmp->toBool () === true) |
| 130 | 137 | { |
| 131 | 138 | $success_count++; |
| 132 | - } |
|
| 133 | - else |
|
| 139 | + } else |
|
| 134 | 140 | { |
| 135 | 141 | $error_count++; |
| 136 | 142 | } |
@@ -152,8 +158,7 @@ discard block |
||
| 152 | 158 | if($tmp->toBool () === true) |
| 153 | 159 | { |
| 154 | 160 | $success_count++; |
| 155 | - } |
|
| 156 | - else |
|
| 161 | + } else |
|
| 157 | 162 | { |
| 158 | 163 | $error_count++; |
| 159 | 164 | } |
@@ -182,11 +187,15 @@ discard block |
||
| 182 | 187 | { |
| 183 | 188 | case 'member' : |
| 184 | 189 | $output = $oExtract->set($xml_file,'<members ', '</members>', '<member>', '</member>'); |
| 185 | - if($output->toBool()) $oExtract->saveItems(); |
|
| 190 | + if($output->toBool()) { |
|
| 191 | + $oExtract->saveItems(); |
|
| 192 | + } |
|
| 186 | 193 | break; |
| 187 | 194 | case 'message' : |
| 188 | 195 | $output = $oExtract->set($xml_file,'<messages ', '</messages>', '<message>','</message>'); |
| 189 | - if($output->toBool()) $oExtract->saveItems(); |
|
| 196 | + if($output->toBool()) { |
|
| 197 | + $oExtract->saveItems(); |
|
| 198 | + } |
|
| 190 | 199 | break; |
| 191 | 200 | case 'ttxml' : |
| 192 | 201 | // Category information |
@@ -204,8 +213,12 @@ discard block |
||
| 204 | 213 | $started = true; |
| 205 | 214 | $str = strstr($str, '<category>'); |
| 206 | 215 | } |
| 207 | - if(substr($str,0,strlen('<post ')) == '<post ') break; |
|
| 208 | - if ($started) $buff .= $str; |
|
| 216 | + if(substr($str,0,strlen('<post ')) == '<post ') { |
|
| 217 | + break; |
|
| 218 | + } |
|
| 219 | + if ($started) { |
|
| 220 | + $buff .= $str; |
|
| 221 | + } |
|
| 209 | 222 | } |
| 210 | 223 | $buff = '<categories>'.$buff.'</categories>'; |
| 211 | 224 | $oExtract->closeFile(); |
@@ -242,7 +255,9 @@ discard block |
||
| 242 | 255 | FileHandler::writeFile($guestbook_filename, $buff); |
| 243 | 256 | // Individual items |
| 244 | 257 | $output = $oExtract->set($xml_file,'<blog', '</blog>', '<post ', '</post>'); |
| 245 | - if($output->toBool()) $oExtract->saveItems(); |
|
| 258 | + if($output->toBool()) { |
|
| 259 | + $oExtract->saveItems(); |
|
| 260 | + } |
|
| 246 | 261 | } |
| 247 | 262 | } |
| 248 | 263 | break; |
@@ -254,7 +269,9 @@ discard block |
||
| 254 | 269 | $oExtract->mergeItems('category.xml'); |
| 255 | 270 | // Get each item |
| 256 | 271 | $output = $oExtract->set($xml_file,'<posts ', '</posts>', '<post>', '</post>'); |
| 257 | - if($output->toBool()) $oExtract->saveItems(); |
|
| 272 | + if($output->toBool()) { |
|
| 273 | + $oExtract->saveItems(); |
|
| 274 | + } |
|
| 258 | 275 | } |
| 259 | 276 | break; |
| 260 | 277 | } |
@@ -291,19 +308,25 @@ discard block |
||
| 291 | 308 | $this->unit_count = Context::get('unit_count'); |
| 292 | 309 | // Check if an index file exists |
| 293 | 310 | $index_file = './files/cache/importer/'.$key.'/index'; |
| 294 | - if(!file_exists($index_file)) return new BaseObject(-1, 'msg_invalid_xml_file'); |
|
| 311 | + if(!file_exists($index_file)) { |
|
| 312 | + return new BaseObject(-1, 'msg_invalid_xml_file'); |
|
| 313 | + } |
|
| 295 | 314 | |
| 296 | 315 | switch($type) |
| 297 | 316 | { |
| 298 | 317 | case 'ttxml' : |
| 299 | - if(!$target_module) return new BaseObject(-1,'msg_invalid_request'); |
|
| 318 | + if(!$target_module) { |
|
| 319 | + return new BaseObject(-1,'msg_invalid_request'); |
|
| 320 | + } |
|
| 300 | 321 | |
| 301 | 322 | $oModuleModel = getModel('module'); |
| 302 | 323 | $columnList = array('module_srl', 'module'); |
| 303 | 324 | $target_module_info = $oModuleModel->getModuleInfoByModuleSrl($target_module, $columnList); |
| 304 | 325 | |
| 305 | 326 | $ttimporter = FileHandler::exists(_XE_PATH_ . 'modules/importer/ttimport.class.php'); |
| 306 | - if($ttimporter) require_once($ttimporter); |
|
| 327 | + if($ttimporter) { |
|
| 328 | + require_once($ttimporter); |
|
| 329 | + } |
|
| 307 | 330 | |
| 308 | 331 | $oTT = new ttimport(); |
| 309 | 332 | $cur = $oTT->importModule($key, $cur, $index_file, $this->unit_count, $target_module, $guestbook_target_module, $user_id, $target_module_info->module); |
@@ -316,7 +339,9 @@ discard block |
||
| 316 | 339 | break; |
| 317 | 340 | case 'module' : |
| 318 | 341 | // Check if the target module exists |
| 319 | - if(!$target_module) return new BaseObject(-1,'msg_invalid_request'); |
|
| 342 | + if(!$target_module) { |
|
| 343 | + return new BaseObject(-1,'msg_invalid_request'); |
|
| 344 | + } |
|
| 320 | 345 | $cur = $this->importModule($key, $cur, $index_file, $target_module); |
| 321 | 346 | break; |
| 322 | 347 | } |
@@ -331,8 +356,9 @@ discard block |
||
| 331 | 356 | { |
| 332 | 357 | $this->setMessage( sprintf(Context::getLang('msg_import_finished'), $cur, $total) ); |
| 333 | 358 | FileHandler::removeDir('./files/cache/importer/'.$key); |
| 359 | + } else { |
|
| 360 | + $this->setMessage( sprintf(Context::getLang('msg_importing'), $total, $cur) ); |
|
| 334 | 361 | } |
| 335 | - else $this->setMessage( sprintf(Context::getLang('msg_importing'), $total, $cur) ); |
|
| 336 | 362 | } |
| 337 | 363 | |
| 338 | 364 | /** |
@@ -344,7 +370,9 @@ discard block |
||
| 344 | 370 | */ |
| 345 | 371 | function importMember($key, $cur, $index_file) |
| 346 | 372 | { |
| 347 | - if(!$cur) $cur = 0; |
|
| 373 | + if(!$cur) { |
|
| 374 | + $cur = 0; |
|
| 375 | + } |
|
| 348 | 376 | // Create the xmlParser object |
| 349 | 377 | $oXmlParser = new XmlParser(); |
| 350 | 378 | // Create objects for importing member information |
@@ -359,24 +387,32 @@ discard block |
||
| 359 | 387 | // Open an index file |
| 360 | 388 | $f = fopen($index_file,"r"); |
| 361 | 389 | // Pass if already read |
| 362 | - for($i=0;$i<$cur;$i++) fgets($f, 1024); |
|
| 390 | + for($i=0;$i<$cur;$i++) { |
|
| 391 | + fgets($f, 1024); |
|
| 392 | + } |
|
| 363 | 393 | // Read by each line until the condition meets |
| 364 | 394 | for($idx=$cur;$idx<$cur+$this->unit_count;$idx++) |
| 365 | 395 | { |
| 366 | - if(feof($f)) break; |
|
| 396 | + if(feof($f)) { |
|
| 397 | + break; |
|
| 398 | + } |
|
| 367 | 399 | // Find a given location |
| 368 | 400 | $target_file = trim(fgets($f, 1024)); |
| 369 | 401 | // Load and parse the file |
| 370 | 402 | $xmlObj = $oXmlParser->loadXmlFile($target_file); |
| 371 | 403 | FileHandler::removeFile($target_file); |
| 372 | - if(!$xmlObj) continue; |
|
| 404 | + if(!$xmlObj) { |
|
| 405 | + continue; |
|
| 406 | + } |
|
| 373 | 407 | // List Objects |
| 374 | 408 | $obj = new stdClass(); |
| 375 | 409 | $obj->user_id = base64_decode($xmlObj->member->user_id->body); |
| 376 | 410 | $obj->password = base64_decode($xmlObj->member->password->body); |
| 377 | 411 | $obj->user_name = base64_decode($xmlObj->member->user_name->body); |
| 378 | 412 | $obj->nick_name = base64_decode($xmlObj->member->nick_name->body); |
| 379 | - if(!$obj->user_name) $obj->user_name = $obj->nick_name; |
|
| 413 | + if(!$obj->user_name) { |
|
| 414 | + $obj->user_name = $obj->nick_name; |
|
| 415 | + } |
|
| 380 | 416 | $obj->email = base64_decode($xmlObj->member->email->body); |
| 381 | 417 | $obj->homepage = base64_decode($xmlObj->member->homepage->body); |
| 382 | 418 | $obj->blog = base64_decode($xmlObj->member->blog->body); |
@@ -394,22 +430,32 @@ discard block |
||
| 394 | 430 | { |
| 395 | 431 | foreach($xmlObj->member->extra_vars as $key => $val) |
| 396 | 432 | { |
| 397 | - if(in_array($key, array('node_name','attrs','body'))) continue; |
|
| 433 | + if(in_array($key, array('node_name','attrs','body'))) { |
|
| 434 | + continue; |
|
| 435 | + } |
|
| 398 | 436 | $obj->extra_vars->{$key} = base64_decode($val->body); |
| 399 | 437 | } |
| 400 | 438 | } |
| 401 | 439 | // Create url for homepage and blog |
| 402 | - if($obj->homepage && strncasecmp('http://', $obj->homepage, 7) !== 0 && strncasecmp('https://', $obj->homepage, 8) !== 0) $obj->homepage = 'http://'.$obj->homepage; |
|
| 440 | + if($obj->homepage && strncasecmp('http://', $obj->homepage, 7) !== 0 && strncasecmp('https://', $obj->homepage, 8) !== 0) { |
|
| 441 | + $obj->homepage = 'http://'.$obj->homepage; |
|
| 442 | + } |
|
| 403 | 443 | // email address column |
| 404 | 444 | $obj->email_address = $obj->email; |
| 405 | 445 | list($obj->email_id, $obj->email_host) = explode('@', $obj->email); |
| 406 | 446 | // Set the mailing option |
| 407 | - if($obj->allow_mailing!='Y') $obj->allow_mailing = 'N'; |
|
| 447 | + if($obj->allow_mailing!='Y') { |
|
| 448 | + $obj->allow_mailing = 'N'; |
|
| 449 | + } |
|
| 408 | 450 | // Set the message option |
| 409 | 451 | $obj->allow_message = 'Y'; |
| 410 | - if(!in_array($obj->allow_message, array('Y','N','F'))) $obj->allow_message= 'Y'; |
|
| 452 | + if(!in_array($obj->allow_message, array('Y','N','F'))) { |
|
| 453 | + $obj->allow_message= 'Y'; |
|
| 454 | + } |
|
| 411 | 455 | // Get member-join date if the last login time is not found |
| 412 | - if(!$obj->last_login) $obj->last_login = $obj->regdate; |
|
| 456 | + if(!$obj->last_login) { |
|
| 457 | + $obj->last_login = $obj->regdate; |
|
| 458 | + } |
|
| 413 | 459 | // Get a member_srl |
| 414 | 460 | $obj->member_srl = getNextSequence(); |
| 415 | 461 | $obj->list_order = -1 * $obj->member_srl; |
@@ -421,7 +467,9 @@ discard block |
||
| 421 | 467 | $nick_args = new stdClass; |
| 422 | 468 | $nick_args->nick_name = $obj->nick_name; |
| 423 | 469 | $nick_output = executeQuery('member.getMemberSrl', $nick_args); |
| 424 | - if(!$nick_output->toBool()) $obj->nick_name .= '_'.$obj->member_srl; |
|
| 470 | + if(!$nick_output->toBool()) { |
|
| 471 | + $obj->nick_name .= '_'.$obj->member_srl; |
|
| 472 | + } |
|
| 425 | 473 | // Add a member |
| 426 | 474 | $output = executeQuery('member.insertMember', $obj); |
| 427 | 475 | |
@@ -477,7 +525,9 @@ discard block |
||
| 477 | 525 | $signature_buff = sprintf('<?php if(!defined("__XE__")) exit();?>%s', $signature); |
| 478 | 526 | |
| 479 | 527 | $target_path = sprintf('files/member_extra_info/signature/%s/', getNumberingPath($obj->member_srl)); |
| 480 | - if(!is_dir($target_path)) FileHandler::makeDir($target_path); |
|
| 528 | + if(!is_dir($target_path)) { |
|
| 529 | + FileHandler::makeDir($target_path); |
|
| 530 | + } |
|
| 481 | 531 | $target_filename = sprintf('%s%d.signature.php', $target_path, $obj->member_srl); |
| 482 | 532 | |
| 483 | 533 | FileHandler::writeFile($target_filename, $signature_buff); |
@@ -499,23 +549,31 @@ discard block |
||
| 499 | 549 | */ |
| 500 | 550 | function importMessage($key, $cur, $index_file) |
| 501 | 551 | { |
| 502 | - if(!$cur) $cur = 0; |
|
| 552 | + if(!$cur) { |
|
| 553 | + $cur = 0; |
|
| 554 | + } |
|
| 503 | 555 | // Create the xmlParser object |
| 504 | 556 | $oXmlParser = new XmlParser(); |
| 505 | 557 | // Open an index file |
| 506 | 558 | $f = fopen($index_file,"r"); |
| 507 | 559 | // Pass if already read |
| 508 | - for($i=0;$i<$cur;$i++) fgets($f, 1024); |
|
| 560 | + for($i=0;$i<$cur;$i++) { |
|
| 561 | + fgets($f, 1024); |
|
| 562 | + } |
|
| 509 | 563 | // Read each line until the condition meets |
| 510 | 564 | for($idx=$cur;$idx<$cur+$this->unit_count;$idx++) |
| 511 | 565 | { |
| 512 | - if(feof($f)) break; |
|
| 566 | + if(feof($f)) { |
|
| 567 | + break; |
|
| 568 | + } |
|
| 513 | 569 | // Find a location |
| 514 | 570 | $target_file = trim(fgets($f, 1024)); |
| 515 | 571 | // Load and parse the file |
| 516 | 572 | $xmlObj = $oXmlParser->loadXmlFile($target_file); |
| 517 | 573 | FileHandler::removeFile($target_file); |
| 518 | - if(!$xmlObj) continue; |
|
| 574 | + if(!$xmlObj) { |
|
| 575 | + continue; |
|
| 576 | + } |
|
| 519 | 577 | // List objects |
| 520 | 578 | $obj = null; |
| 521 | 579 | $obj->receiver = base64_decode($xmlObj->message->receiver->body); |
@@ -526,7 +584,9 @@ discard block |
||
| 526 | 584 | $obj->regdate = base64_decode($xmlObj->message->regdate->body); |
| 527 | 585 | $obj->readed_date = base64_decode($xmlObj->message->readed_date->body); |
| 528 | 586 | // Get member_srl of sender/recipient (If not exists, pass) |
| 529 | - if(!$obj->sender) continue; |
|
| 587 | + if(!$obj->sender) { |
|
| 588 | + continue; |
|
| 589 | + } |
|
| 530 | 590 | $sender_args->user_id = $obj->sender; |
| 531 | 591 | $sender_output = executeQuery('member.getMemberInfo',$sender_args); |
| 532 | 592 | $sender_srl = $sender_output->data->member_srl; |
@@ -537,10 +597,14 @@ discard block |
||
| 537 | 597 | $sender_output = executeQuery('member.getMemberInfoByEmailAddress',$sender_args); |
| 538 | 598 | $sender_srl = $sender_output->data->member_srl; |
| 539 | 599 | } |
| 540 | - if(!$sender_srl) continue; |
|
| 600 | + if(!$sender_srl) { |
|
| 601 | + continue; |
|
| 602 | + } |
|
| 541 | 603 | |
| 542 | 604 | $receiver_args->user_id = $obj->receiver; |
| 543 | - if(!$obj->receiver) continue; |
|
| 605 | + if(!$obj->receiver) { |
|
| 606 | + continue; |
|
| 607 | + } |
|
| 544 | 608 | $receiver_output = executeQuery('member.getMemberInfo',$receiver_args); |
| 545 | 609 | $receiver_srl = $receiver_output->data->member_srl; |
| 546 | 610 | if(!$receiver_srl) |
@@ -550,7 +614,9 @@ discard block |
||
| 550 | 614 | $receiver_output = executeQuery('member.getMemberInfoByEmailAddress',$receiver_args); |
| 551 | 615 | $receiver_srl = $receiver_output->data->member_srl; |
| 552 | 616 | } |
| 553 | - if(!$receiver_srl) continue; |
|
| 617 | + if(!$receiver_srl) { |
|
| 618 | + continue; |
|
| 619 | + } |
|
| 554 | 620 | // Message to save into sender's message box |
| 555 | 621 | $sender_args->sender_srl = $sender_srl; |
| 556 | 622 | $sender_args->receiver_srl = $receiver_srl; |
@@ -571,7 +637,9 @@ discard block |
||
| 571 | 637 | $receiver_args->message_srl = $sender_args->related_srl; |
| 572 | 638 | $receiver_args->list_order = $sender_args->related_srl*-1; |
| 573 | 639 | $receiver_args->sender_srl = $sender_srl; |
| 574 | - if(!$receiver_args->sender_srl) $receiver_args->sender_srl = $receiver_srl; |
|
| 640 | + if(!$receiver_args->sender_srl) { |
|
| 641 | + $receiver_args->sender_srl = $receiver_srl; |
|
| 642 | + } |
|
| 575 | 643 | $receiver_args->receiver_srl = $receiver_srl; |
| 576 | 644 | $receiver_args->message_type = 'R'; |
| 577 | 645 | $receiver_args->title = $obj->title; |
@@ -605,7 +673,9 @@ discard block |
||
| 605 | 673 | $oDocumentModel = getModel('document'); |
| 606 | 674 | $category_list = $category_titles = array(); |
| 607 | 675 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
| 608 | - if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
| 676 | + if(count($category_list)) { |
|
| 677 | + foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
| 678 | + } |
|
| 609 | 679 | // Extract category information |
| 610 | 680 | $category_file = preg_replace('/index$/i', 'category.xml', $index_file); |
| 611 | 681 | if(file_exists($category_file)) |
@@ -618,12 +688,16 @@ discard block |
||
| 618 | 688 | $categories = $xmlDoc->items->category; |
| 619 | 689 | if($categories) |
| 620 | 690 | { |
| 621 | - if(!is_array($categories)) $categories = array($categories); |
|
| 691 | + if(!is_array($categories)) { |
|
| 692 | + $categories = array($categories); |
|
| 693 | + } |
|
| 622 | 694 | $match_sequence = array(); |
| 623 | 695 | foreach($categories as $k => $v) |
| 624 | 696 | { |
| 625 | 697 | $category = trim(base64_decode($v->body)); |
| 626 | - if(!$category || $category_titles[$category]) continue; |
|
| 698 | + if(!$category || $category_titles[$category]) { |
|
| 699 | + continue; |
|
| 700 | + } |
|
| 627 | 701 | |
| 628 | 702 | $sequence = $v->attrs->sequence; |
| 629 | 703 | $parent = $v->attrs->parent; |
@@ -631,10 +705,14 @@ discard block |
||
| 631 | 705 | $obj = null; |
| 632 | 706 | $obj->title = $category; |
| 633 | 707 | $obj->module_srl = $module_srl; |
| 634 | - if($parent) $obj->parent_srl = $match_sequence[$parent]; |
|
| 708 | + if($parent) { |
|
| 709 | + $obj->parent_srl = $match_sequence[$parent]; |
|
| 710 | + } |
|
| 635 | 711 | |
| 636 | 712 | $output = $oDocumentController->insertCategory($obj); |
| 637 | - if($output->toBool()) $match_sequence[$sequence] = $output->get('category_srl'); |
|
| 713 | + if($output->toBool()) { |
|
| 714 | + $match_sequence[$sequence] = $output->get('category_srl'); |
|
| 715 | + } |
|
| 638 | 716 | } |
| 639 | 717 | $oDocumentController = getController('document'); |
| 640 | 718 | $oDocumentController->makeCategoryFile($module_srl); |
@@ -644,31 +722,45 @@ discard block |
||
| 644 | 722 | |
| 645 | 723 | $category_list = $category_titles = array(); |
| 646 | 724 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
| 647 | - if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
| 725 | + if(count($category_list)) { |
|
| 726 | + foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
| 727 | + } |
|
| 648 | 728 | |
| 649 | 729 | $ek_args->module_srl = $module_srl; |
| 650 | 730 | $output = executeQueryArray('document.getDocumentExtraKeys', $ek_args); |
| 651 | 731 | if($output->data) |
| 652 | 732 | { |
| 653 | - foreach($output->data as $key => $val) $extra_keys[$val->eid] = true; |
|
| 733 | + foreach($output->data as $key => $val) { |
|
| 734 | + $extra_keys[$val->eid] = true; |
|
| 735 | + } |
|
| 654 | 736 | } |
| 655 | 737 | |
| 656 | - if(!$cur) $cur = 0; |
|
| 738 | + if(!$cur) { |
|
| 739 | + $cur = 0; |
|
| 740 | + } |
|
| 657 | 741 | // Open an index file |
| 658 | 742 | $f = fopen($index_file,"r"); |
| 659 | 743 | // Pass if already read |
| 660 | - for($i=0;$i<$cur;$i++) fgets($f, 1024); |
|
| 744 | + for($i=0;$i<$cur;$i++) { |
|
| 745 | + fgets($f, 1024); |
|
| 746 | + } |
|
| 661 | 747 | // Read each line until the condition meets |
| 662 | 748 | for($idx=$cur;$idx<$cur+$this->unit_count;$idx++) |
| 663 | 749 | { |
| 664 | - if(feof($f)) break; |
|
| 750 | + if(feof($f)) { |
|
| 751 | + break; |
|
| 752 | + } |
|
| 665 | 753 | // Find a location |
| 666 | 754 | $target_file = trim(fgets($f, 1024)); |
| 667 | 755 | |
| 668 | - if(!file_exists($target_file)) continue; |
|
| 756 | + if(!file_exists($target_file)) { |
|
| 757 | + continue; |
|
| 758 | + } |
|
| 669 | 759 | // Importing data from now on |
| 670 | 760 | $fp = fopen($target_file,"r"); |
| 671 | - if(!$fp) continue; |
|
| 761 | + if(!$fp) { |
|
| 762 | + continue; |
|
| 763 | + } |
|
| 672 | 764 | |
| 673 | 765 | $obj = new stdClass; |
| 674 | 766 | $obj->module_srl = $module_srl; |
@@ -688,38 +780,38 @@ discard block |
||
| 688 | 780 | { |
| 689 | 781 | $started = true; |
| 690 | 782 | // Trackback inserted |
| 691 | - } |
|
| 692 | - else if(substr($str,0,11) == '<trackbacks') |
|
| 783 | + } else if(substr($str,0,11) == '<trackbacks') |
|
| 693 | 784 | { |
| 694 | 785 | $obj->trackback_count = $this->importTrackbacks($fp, $module_srl, $obj->document_srl); |
| 695 | 786 | continue; |
| 696 | 787 | // Comments inserted |
| 697 | - } |
|
| 698 | - else if(substr($str,0,9) == '<comments') |
|
| 788 | + } else if(substr($str,0,9) == '<comments') |
|
| 699 | 789 | { |
| 700 | 790 | $obj->comment_count = $this->importComments($fp, $module_srl, $obj->document_srl); |
| 701 | 791 | continue; |
| 702 | 792 | // Attachment inserted |
| 703 | - } |
|
| 704 | - else if(substr($str,0,9) == '<attaches') |
|
| 793 | + } else if(substr($str,0,9) == '<attaches') |
|
| 705 | 794 | { |
| 706 | 795 | $obj->uploaded_count = $this->importAttaches($fp, $module_srl, $obj->document_srl, $files); |
| 707 | 796 | continue; |
| 708 | 797 | // When starting extra variabls |
| 709 | - } |
|
| 710 | - elseif(trim($str) == '<extra_vars>') |
|
| 798 | + } elseif(trim($str) == '<extra_vars>') |
|
| 711 | 799 | { |
| 712 | 800 | $extra_vars = $this->importExtraVars($fp); |
| 713 | 801 | continue; |
| 714 | 802 | } |
| 715 | 803 | |
| 716 | - if($started) $buff[] = $str; |
|
| 804 | + if($started) { |
|
| 805 | + $buff[] = $str; |
|
| 806 | + } |
|
| 717 | 807 | } |
| 718 | 808 | |
| 719 | 809 | $xmlDoc = $this->oXmlParser->parse(implode('', $buff)); |
| 720 | 810 | |
| 721 | 811 | $category = base64_decode($xmlDoc->post->category->body); |
| 722 | - if($category_titles[$category]) $obj->category_srl = $category_titles[$category]; |
|
| 812 | + if($category_titles[$category]) { |
|
| 813 | + $obj->category_srl = $category_titles[$category]; |
|
| 814 | + } |
|
| 723 | 815 | |
| 724 | 816 | $obj->member_srl = 0; |
| 725 | 817 | |
@@ -733,16 +825,22 @@ discard block |
||
| 733 | 825 | $obj->password = base64_decode($xmlDoc->post->password->body); |
| 734 | 826 | $obj->user_name = base64_decode($xmlDoc->post->user_name->body); |
| 735 | 827 | $obj->nick_name = base64_decode($xmlDoc->post->nick_name->body); |
| 736 | - if(!$obj->user_name) $obj->user_name = $obj->nick_name; |
|
| 828 | + if(!$obj->user_name) { |
|
| 829 | + $obj->user_name = $obj->nick_name; |
|
| 830 | + } |
|
| 737 | 831 | $obj->user_id = base64_decode($xmlDoc->post->user_id->body); |
| 738 | 832 | $obj->email_address = base64_decode($xmlDoc->post->email->body); |
| 739 | 833 | $obj->homepage = base64_decode($xmlDoc->post->homepage->body); |
| 740 | - if($obj->homepage && strncasecmp('http://', $obj->homepage, 7) !== 0 && strncasecmp('https://', $obj->homepage, 8) !== 0) $obj->homepage = 'http://'.$obj->homepage; |
|
| 834 | + if($obj->homepage && strncasecmp('http://', $obj->homepage, 7) !== 0 && strncasecmp('https://', $obj->homepage, 8) !== 0) { |
|
| 835 | + $obj->homepage = 'http://'.$obj->homepage; |
|
| 836 | + } |
|
| 741 | 837 | $obj->tags = base64_decode($xmlDoc->post->tags->body); |
| 742 | 838 | $obj->regdate = base64_decode($xmlDoc->post->regdate->body); |
| 743 | 839 | $obj->last_update = base64_decode($xmlDoc->post->update->body); |
| 744 | 840 | $obj->last_updater = base64_decode($xmlDoc->post->last_updater->body); |
| 745 | - if(!$obj->last_update) $obj->last_update = $obj->regdate; |
|
| 841 | + if(!$obj->last_update) { |
|
| 842 | + $obj->last_update = $obj->regdate; |
|
| 843 | + } |
|
| 746 | 844 | $obj->ipaddress = base64_decode($xmlDoc->post->ipaddress->body); |
| 747 | 845 | $obj->list_order = $obj->update_order = $obj->document_srl*-1; |
| 748 | 846 | $obj->commentStatus = base64_decode($xmlDoc->post->allow_comment->body)!='N'?'ALLOW':'DENY'; |
@@ -773,7 +871,9 @@ discard block |
||
| 773 | 871 | $args->document_srl = $obj->document_srl; |
| 774 | 872 | $args->tag = trim($tag_list[$i]); |
| 775 | 873 | $args->regdate = $obj->regdate; |
| 776 | - if(!$args->tag) continue; |
|
| 874 | + if(!$args->tag) { |
|
| 875 | + continue; |
|
| 876 | + } |
|
| 777 | 877 | $output = executeQuery('tag.insertTag', $args); |
| 778 | 878 | } |
| 779 | 879 | |
@@ -783,7 +883,9 @@ discard block |
||
| 783 | 883 | { |
| 784 | 884 | foreach($extra_vars as $key => $val) |
| 785 | 885 | { |
| 786 | - if(!$val->value) continue; |
|
| 886 | + if(!$val->value) { |
|
| 887 | + continue; |
|
| 888 | + } |
|
| 787 | 889 | unset($e_args); |
| 788 | 890 | $e_args->module_srl = $module_srl; |
| 789 | 891 | $e_args->document_srl = $obj->document_srl; |
@@ -816,7 +918,9 @@ discard block |
||
| 816 | 918 | |
| 817 | 919 | fclose($f); |
| 818 | 920 | // Sync category counts |
| 819 | - if(count($category_list)) foreach($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl); |
|
| 921 | + if(count($category_list)) { |
|
| 922 | + foreach($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl); |
|
| 923 | + } |
|
| 820 | 924 | |
| 821 | 925 | return $idx-1; |
| 822 | 926 | } |
@@ -838,11 +942,17 @@ discard block |
||
| 838 | 942 | { |
| 839 | 943 | $str = fgets($fp, 1024); |
| 840 | 944 | // If </trackbacks> is, break |
| 841 | - if(trim($str) == '</trackbacks>') break; |
|
| 945 | + if(trim($str) == '</trackbacks>') { |
|
| 946 | + break; |
|
| 947 | + } |
|
| 842 | 948 | // If <trackback>, start importing |
| 843 | - if(trim($str) == '<trackback>') $started = true; |
|
| 949 | + if(trim($str) == '<trackback>') { |
|
| 950 | + $started = true; |
|
| 951 | + } |
|
| 844 | 952 | |
| 845 | - if($started) $buff .= $str; |
|
| 953 | + if($started) { |
|
| 954 | + $buff .= $str; |
|
| 955 | + } |
|
| 846 | 956 | // If </trackback>, insert to the DB |
| 847 | 957 | if(trim($str) == '</trackback>') |
| 848 | 958 | { |
@@ -860,7 +970,9 @@ discard block |
||
| 860 | 970 | $obj->ipaddress = base64_decode($xmlDoc->trackback->ipaddress->body); |
| 861 | 971 | $obj->list_order = -1*$obj->trackback_srl; |
| 862 | 972 | $output = executeQuery('trackback.insertTrackback', $obj); |
| 863 | - if($output->toBool()) $cnt++; |
|
| 973 | + if($output->toBool()) { |
|
| 974 | + $cnt++; |
|
| 975 | + } |
|
| 864 | 976 | |
| 865 | 977 | $buff = null; |
| 866 | 978 | $started = false; |
@@ -888,7 +1000,9 @@ discard block |
||
| 888 | 1000 | { |
| 889 | 1001 | $str = fgets($fp, 1024); |
| 890 | 1002 | // If </comments> is, break |
| 891 | - if(trim($str) == '</comments>') break; |
|
| 1003 | + if(trim($str) == '</comments>') { |
|
| 1004 | + break; |
|
| 1005 | + } |
|
| 892 | 1006 | // If <comment> is, start importing |
| 893 | 1007 | if(trim($str) == '<comment>') |
| 894 | 1008 | { |
@@ -904,7 +1018,9 @@ discard block |
||
| 904 | 1018 | continue; |
| 905 | 1019 | } |
| 906 | 1020 | |
| 907 | - if($started) $buff .= $str; |
|
| 1021 | + if($started) { |
|
| 1022 | + $buff .= $str; |
|
| 1023 | + } |
|
| 908 | 1024 | // If </comment> is, insert to the DB |
| 909 | 1025 | if(trim($str) == '</comment>') |
| 910 | 1026 | { |
@@ -916,8 +1032,11 @@ discard block |
||
| 916 | 1032 | |
| 917 | 1033 | $obj->module_srl = $module_srl; |
| 918 | 1034 | |
| 919 | - if($parent) $obj->parent_srl = $sequences[$parent]; |
|
| 920 | - else $obj->parent_srl = 0; |
|
| 1035 | + if($parent) { |
|
| 1036 | + $obj->parent_srl = $sequences[$parent]; |
|
| 1037 | + } else { |
|
| 1038 | + $obj->parent_srl = 0; |
|
| 1039 | + } |
|
| 921 | 1040 | |
| 922 | 1041 | $obj->document_srl = $document_srl; |
| 923 | 1042 | $obj->is_secret = base64_decode($xmlDoc->comment->is_secret->body)=='Y'?'Y':'N'; |
@@ -928,14 +1047,18 @@ discard block |
||
| 928 | 1047 | $obj->password = base64_decode($xmlDoc->comment->password->body); |
| 929 | 1048 | $obj->user_name =base64_decode($xmlDoc->comment->user_name->body); |
| 930 | 1049 | $obj->nick_name = base64_decode($xmlDoc->comment->nick_name->body); |
| 931 | - if(!$obj->user_name) $obj->user_name = $obj->nick_name; |
|
| 1050 | + if(!$obj->user_name) { |
|
| 1051 | + $obj->user_name = $obj->nick_name; |
|
| 1052 | + } |
|
| 932 | 1053 | $obj->user_id = base64_decode($xmlDoc->comment->user_id->body); |
| 933 | 1054 | $obj->member_srl = 0; |
| 934 | 1055 | $obj->email_address = base64_decode($xmlDoc->comment->email->body); |
| 935 | 1056 | $obj->homepage = base64_decode($xmlDoc->comment->homepage->body); |
| 936 | 1057 | $obj->regdate = base64_decode($xmlDoc->comment->regdate->body); |
| 937 | 1058 | $obj->last_update = base64_decode($xmlDoc->comment->update->body); |
| 938 | - if(!$obj->last_update) $obj->last_update = $obj->regdate; |
|
| 1059 | + if(!$obj->last_update) { |
|
| 1060 | + $obj->last_update = $obj->regdate; |
|
| 1061 | + } |
|
| 939 | 1062 | $obj->ipaddress = base64_decode($xmlDoc->comment->ipaddress->body); |
| 940 | 1063 | $obj->status = base64_decode($xmlDoc->comment->status->body)==''?'1':base64_decode($xmlDoc->comment->status->body); |
| 941 | 1064 | $obj->list_order = $obj->comment_srl*-1; |
@@ -959,24 +1082,28 @@ discard block |
||
| 959 | 1082 | $list_args->head = $list_args->arrange = $obj->comment_srl; |
| 960 | 1083 | $list_args->depth = 0; |
| 961 | 1084 | // Get parent_srl if parent comment exists |
| 962 | - } |
|
| 963 | - else |
|
| 1085 | + } else |
|
| 964 | 1086 | { |
| 965 | 1087 | // Get parent comment infomation |
| 966 | 1088 | $parent_args->comment_srl = $obj->parent_srl; |
| 967 | 1089 | $parent_output = executeQuery('comment.getCommentListItem', $parent_args); |
| 968 | 1090 | // Return if parent comment doesn't exist |
| 969 | - if(!$parent_output->toBool() || !$parent_output->data) continue; |
|
| 1091 | + if(!$parent_output->toBool() || !$parent_output->data) { |
|
| 1092 | + continue; |
|
| 1093 | + } |
|
| 970 | 1094 | $parent = $parent_output->data; |
| 971 | 1095 | |
| 972 | 1096 | $list_args->head = $parent->head; |
| 973 | 1097 | $list_args->depth = $parent->depth+1; |
| 974 | - if($list_args->depth<2) $list_args->arrange = $obj->comment_srl; |
|
| 975 | - else |
|
| 1098 | + if($list_args->depth<2) { |
|
| 1099 | + $list_args->arrange = $obj->comment_srl; |
|
| 1100 | + } else |
|
| 976 | 1101 | { |
| 977 | 1102 | $list_args->arrange = $parent->arrange; |
| 978 | 1103 | $output = executeQuery('comment.updateCommentListArrange', $list_args); |
| 979 | - if(!$output->toBool()) return $output; |
|
| 1104 | + if(!$output->toBool()) { |
|
| 1105 | + return $output; |
|
| 1106 | + } |
|
| 980 | 1107 | } |
| 981 | 1108 | } |
| 982 | 1109 | |
@@ -984,7 +1111,9 @@ discard block |
||
| 984 | 1111 | if($output->toBool()) |
| 985 | 1112 | { |
| 986 | 1113 | $output = executeQuery('comment.insertComment', $obj); |
| 987 | - if($output->toBool()) $cnt++; |
|
| 1114 | + if($output->toBool()) { |
|
| 1115 | + $cnt++; |
|
| 1116 | + } |
|
| 988 | 1117 | } |
| 989 | 1118 | |
| 990 | 1119 | $buff = null; |
@@ -1014,7 +1143,9 @@ discard block |
||
| 1014 | 1143 | { |
| 1015 | 1144 | $str = trim(fgets($fp, 1024)); |
| 1016 | 1145 | // If it ends with </attaches>, break |
| 1017 | - if(trim($str) == '</attaches>') break; |
|
| 1146 | + if(trim($str) == '</attaches>') { |
|
| 1147 | + break; |
|
| 1148 | + } |
|
| 1018 | 1149 | // If it starts with <attach>, collect attachments |
| 1019 | 1150 | if(trim($str) == '<attach>') |
| 1020 | 1151 | { |
@@ -1025,14 +1156,15 @@ discard block |
||
| 1025 | 1156 | $started = true; |
| 1026 | 1157 | $buff = null; |
| 1027 | 1158 | // If it starts with <file>, handle the attachement in xml file |
| 1028 | - } |
|
| 1029 | - else if(trim($str) == '<file>') |
|
| 1159 | + } else if(trim($str) == '<file>') |
|
| 1030 | 1160 | { |
| 1031 | 1161 | $file_obj->file = $this->saveTemporaryFile($fp); |
| 1032 | 1162 | continue; |
| 1033 | 1163 | } |
| 1034 | 1164 | |
| 1035 | - if($started) $buff .= $str; |
|
| 1165 | + if($started) { |
|
| 1166 | + $buff .= $str; |
|
| 1167 | + } |
|
| 1036 | 1168 | // If it ends with </attach>, handle attachements |
| 1037 | 1169 | if(trim($str) == '</attach>') |
| 1038 | 1170 | { |
@@ -1045,8 +1177,9 @@ discard block |
||
| 1045 | 1177 | { |
| 1046 | 1178 | $url = base64_decode($xmlDoc->attach->url->body); |
| 1047 | 1179 | $path = base64_decode($xmlDoc->attach->path->body); |
| 1048 | - if($path && file_exists($path)) $file_obj->file = $path; |
|
| 1049 | - else |
|
| 1180 | + if($path && file_exists($path)) { |
|
| 1181 | + $file_obj->file = $path; |
|
| 1182 | + } else |
|
| 1050 | 1183 | { |
| 1051 | 1184 | $file_obj->file = $this->getTmpFilename(); |
| 1052 | 1185 | FileHandler::getRemoteFile($url, $file_obj->file); |
@@ -1077,21 +1210,21 @@ discard block |
||
| 1077 | 1210 | } |
| 1078 | 1211 | |
| 1079 | 1212 | $file_obj->direct_download = 'Y'; |
| 1080 | - } |
|
| 1081 | - else |
|
| 1213 | + } else |
|
| 1082 | 1214 | { |
| 1083 | 1215 | $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3)); |
| 1084 | 1216 | $filename = $path.$random->createSecureSalt(32, 'hex'); |
| 1085 | 1217 | $file_obj->direct_download = 'N'; |
| 1086 | 1218 | } |
| 1087 | 1219 | // Create a directory |
| 1088 | - if(!FileHandler::makeDir($path)) continue; |
|
| 1220 | + if(!FileHandler::makeDir($path)) { |
|
| 1221 | + continue; |
|
| 1222 | + } |
|
| 1089 | 1223 | |
| 1090 | 1224 | if(strncmp('./files/cache/importer/', $file_obj->file, 23) === 0) |
| 1091 | 1225 | { |
| 1092 | 1226 | FileHandler::rename($file_obj->file, $filename); |
| 1093 | - } |
|
| 1094 | - else |
|
| 1227 | + } else |
|
| 1095 | 1228 | { |
| 1096 | 1229 | copy($file_obj->file, $filename); |
| 1097 | 1230 | } |
@@ -1113,8 +1246,11 @@ discard block |
||
| 1113 | 1246 | $uploaded_count++; |
| 1114 | 1247 | $tmp_obj = null; |
| 1115 | 1248 | $tmp_obj->source_filename = $file_obj->source_filename; |
| 1116 | - if($file_obj->direct_download == 'Y') $files[$file_obj->source_filename] = $file_obj->uploaded_filename; |
|
| 1117 | - else $files[$file_obj->source_filename] = getUrl('','module','file','act','procFileDownload','file_srl',$file_obj->file_srl,'sid',$file_obj->sid); |
|
| 1249 | + if($file_obj->direct_download == 'Y') { |
|
| 1250 | + $files[$file_obj->source_filename] = $file_obj->uploaded_filename; |
|
| 1251 | + } else { |
|
| 1252 | + $files[$file_obj->source_filename] = getUrl('','module','file','act','procFileDownload','file_srl',$file_obj->file_srl,'sid',$file_obj->sid); |
|
| 1253 | + } |
|
| 1118 | 1254 | } |
| 1119 | 1255 | } |
| 1120 | 1256 | } |
@@ -1132,7 +1268,9 @@ discard block |
||
| 1132 | 1268 | $path = "./files/cache/importer"; |
| 1133 | 1269 | FileHandler::makeDir($path); |
| 1134 | 1270 | $filename = sprintf("%s/%d", $path, rand(11111111,99999999)); |
| 1135 | - if(file_exists($filename)) $filename .= rand(111,999); |
|
| 1271 | + if(file_exists($filename)) { |
|
| 1272 | + $filename .= rand(111,999); |
|
| 1273 | + } |
|
| 1136 | 1274 | return $filename; |
| 1137 | 1275 | } |
| 1138 | 1276 | |
@@ -1150,7 +1288,9 @@ discard block |
||
| 1150 | 1288 | while(!feof($fp)) |
| 1151 | 1289 | { |
| 1152 | 1290 | $str = trim(fgets($fp, 1024)); |
| 1153 | - if(trim($str) == '</file>') break; |
|
| 1291 | + if(trim($str) == '</file>') { |
|
| 1292 | + break; |
|
| 1293 | + } |
|
| 1154 | 1294 | |
| 1155 | 1295 | $buff .= $str; |
| 1156 | 1296 | |
@@ -1176,14 +1316,20 @@ discard block |
||
| 1176 | 1316 | while(!feof($fp)) |
| 1177 | 1317 | { |
| 1178 | 1318 | $buff .= $str = trim(fgets($fp, 1024)); |
| 1179 | - if(trim($str) == '</extra_vars>') break; |
|
| 1319 | + if(trim($str) == '</extra_vars>') { |
|
| 1320 | + break; |
|
| 1321 | + } |
|
| 1322 | + } |
|
| 1323 | + if(!$buff) { |
|
| 1324 | + return array(); |
|
| 1180 | 1325 | } |
| 1181 | - if(!$buff) return array(); |
|
| 1182 | 1326 | |
| 1183 | 1327 | $buff = '<extra_vars>'.$buff; |
| 1184 | 1328 | $oXmlParser = new XmlParser(); |
| 1185 | 1329 | $xmlDoc = $this->oXmlParser->parse($buff); |
| 1186 | - if(!count($xmlDoc->extra_vars->key)) return array(); |
|
| 1330 | + if(!count($xmlDoc->extra_vars->key)) { |
|
| 1331 | + return array(); |
|
| 1332 | + } |
|
| 1187 | 1333 | |
| 1188 | 1334 | $index = 1; |
| 1189 | 1335 | foreach($xmlDoc->extra_vars->key as $k => $v) |
@@ -1196,8 +1342,7 @@ discard block |
||
| 1196 | 1342 | $vobj->value = base64_decode($v->value->body); |
| 1197 | 1343 | $vobj->eid = base64_decode($v->eid->body); |
| 1198 | 1344 | |
| 1199 | - } |
|
| 1200 | - else if($v->body) |
|
| 1345 | + } else if($v->body) |
|
| 1201 | 1346 | { |
| 1202 | 1347 | $vobj->var_idx = $index; |
| 1203 | 1348 | $vobj->lang_code = Context::getLangType(); |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | /** |
| 421 | 421 | * insert image into user layout |
| 422 | 422 | * @param int $layout_srl |
| 423 | - * @param object $source file data |
|
| 423 | + * @param string $source file data |
|
| 424 | 424 | * @return boolean (true : success, false : fail) |
| 425 | 425 | */ |
| 426 | 426 | function insertUserLayoutImage($layout_srl,$source) |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | /** |
| 545 | 545 | * Add the widget code for faceoff into user layout file |
| 546 | 546 | * @param int $layout_srl |
| 547 | - * @param object $arg |
|
| 547 | + * @param null|stdClass $arg |
|
| 548 | 548 | * @param string $content |
| 549 | 549 | * @return string |
| 550 | 550 | */ |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | |
| 587 | 587 | /** |
| 588 | 588 | * export user layout |
| 589 | - * @return void |
|
| 589 | + * @return BaseObject|null |
|
| 590 | 590 | */ |
| 591 | 591 | function procLayoutAdminUserLayoutExport() |
| 592 | 592 | { |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | /** |
| 683 | 683 | * faceoff import |
| 684 | 684 | * @deprecated |
| 685 | - * @return void |
|
| 685 | + * @return ModuleObject|null |
|
| 686 | 686 | */ |
| 687 | 687 | function procLayoutAdminUserLayoutImport() |
| 688 | 688 | { |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | |
| 710 | 710 | /** |
| 711 | 711 | * layout copy |
| 712 | - * @return void |
|
| 712 | + * @return BaseObject|null |
|
| 713 | 713 | */ |
| 714 | 714 | function procLayoutAdminCopyLayout() |
| 715 | 715 | { |
@@ -843,7 +843,7 @@ discard block |
||
| 843 | 843 | /** |
| 844 | 844 | * Layout file copy |
| 845 | 845 | * @param $sourceLayoutSrl origin layout number |
| 846 | - * @param $targetLayoutSrl origin layout number |
|
| 846 | + * @param integer $targetLayoutSrl origin layout number |
|
| 847 | 847 | * @return void |
| 848 | 848 | */ |
| 849 | 849 | function _copyLayoutFile($sourceLayoutSrl, $targetLayoutSrl) |
@@ -23,20 +23,20 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | function procLayoutAdminInsert() |
| 25 | 25 | { |
| 26 | - if(Context::get('layout') == 'faceoff') return $this->stop('not supported'); |
|
| 26 | + if (Context::get('layout') == 'faceoff') return $this->stop('not supported'); |
|
| 27 | 27 | |
| 28 | 28 | // Get information to create a layout |
| 29 | 29 | $site_module_info = Context::get('site_module_info'); |
| 30 | - $args->site_srl = (int)$site_module_info->site_srl; |
|
| 30 | + $args->site_srl = (int) $site_module_info->site_srl; |
|
| 31 | 31 | $args->layout_srl = getNextSequence(); |
| 32 | 32 | $args->layout = Context::get('layout'); |
| 33 | 33 | $args->title = Context::get('title'); |
| 34 | 34 | $args->layout_type = Context::get('_layout_type'); |
| 35 | - if(!$args->layout_type) $args->layout_type = "P"; |
|
| 35 | + if (!$args->layout_type) $args->layout_type = "P"; |
|
| 36 | 36 | |
| 37 | 37 | // Insert into the DB |
| 38 | 38 | $output = $this->insertLayout($args); |
| 39 | - if(!$output->toBool()) return $output; |
|
| 39 | + if (!$output->toBool()) return $output; |
|
| 40 | 40 | |
| 41 | 41 | // initiate if it is faceoff layout |
| 42 | 42 | $this->initLayout($args->layout_srl, $args->layout); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | { |
| 71 | 71 | $oLayoutModel = getModel('layout'); |
| 72 | 72 | // Import a sample layout if it is faceoff |
| 73 | - if($oLayoutModel->useDefaultLayout($layout_name)) |
|
| 73 | + if ($oLayoutModel->useDefaultLayout($layout_name)) |
|
| 74 | 74 | { |
| 75 | 75 | $this->importLayout($layout_srl, $this->module_path.'tpl/faceOff_sample.tar'); |
| 76 | 76 | // Remove a directory |
@@ -101,25 +101,25 @@ discard block |
||
| 101 | 101 | $is_sitemap = $extra_vars->is_sitemap; |
| 102 | 102 | unset($extra_vars->is_sitemap); |
| 103 | 103 | |
| 104 | - $args = Context::gets('layout_srl','title'); |
|
| 104 | + $args = Context::gets('layout_srl', 'title'); |
|
| 105 | 105 | // Get layout information |
| 106 | 106 | $oLayoutModel = getModel('layout'); |
| 107 | 107 | $oMenuAdminModel = getAdminModel('menu'); |
| 108 | 108 | $layout_info = $oLayoutModel->getLayout($args->layout_srl); |
| 109 | 109 | |
| 110 | - if($layout_info->menu) |
|
| 110 | + if ($layout_info->menu) |
|
| 111 | 111 | { |
| 112 | 112 | $menus = get_object_vars($layout_info->menu); |
| 113 | 113 | } |
| 114 | - if(count($menus)) |
|
| 114 | + if (count($menus)) |
|
| 115 | 115 | { |
| 116 | - foreach($menus as $menu_id => $val) |
|
| 116 | + foreach ($menus as $menu_id => $val) |
|
| 117 | 117 | { |
| 118 | 118 | $menu_srl = Context::get($menu_id); |
| 119 | - if(!$menu_srl) continue; |
|
| 119 | + if (!$menu_srl) continue; |
|
| 120 | 120 | |
| 121 | 121 | // if menu is -1, get default menu in site |
| 122 | - if($menu_srl == -1) |
|
| 122 | + if ($menu_srl == -1) |
|
| 123 | 123 | { |
| 124 | 124 | $oModuleModel = getModel('module'); |
| 125 | 125 | $start_module = $oModuleModel->getSiteInfo(0, $columnList); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | $tmpArgs->url = $start_module->mid; |
| 128 | 128 | $tmpArgs->site_srl = 0; |
| 129 | 129 | $output = executeQuery('menu.getMenuItemByUrl', $tmpArgs); |
| 130 | - if(!$output->toBool()) |
|
| 130 | + if (!$output->toBool()) |
|
| 131 | 131 | { |
| 132 | 132 | return new BaseObject(-1, 'fail_to_update'); |
| 133 | 133 | } |
@@ -143,31 +143,31 @@ discard block |
||
| 143 | 143 | $apply_layout = Context::get('apply_layout'); |
| 144 | 144 | $apply_mobile_view = Context::get('apply_mobile_view'); |
| 145 | 145 | |
| 146 | - if($apply_layout=='Y' || $apply_mobile_view=='Y') |
|
| 146 | + if ($apply_layout == 'Y' || $apply_mobile_view == 'Y') |
|
| 147 | 147 | { |
| 148 | 148 | $menu_args = new stdClass(); |
| 149 | 149 | $menu_args->menu_srl = $menu_srl; |
| 150 | 150 | $menu_args->site_srl = $layout_info->site_srl; |
| 151 | 151 | $output = executeQueryArray('layout.getLayoutModules', $menu_args); |
| 152 | - if($output->data) |
|
| 152 | + if ($output->data) |
|
| 153 | 153 | { |
| 154 | 154 | $modules = array(); |
| 155 | - for($i=0;$i<count($output->data);$i++) |
|
| 155 | + for ($i = 0; $i < count($output->data); $i++) |
|
| 156 | 156 | { |
| 157 | 157 | $modules[] = $output->data[$i]->module_srl; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - if(count($modules)) |
|
| 160 | + if (count($modules)) |
|
| 161 | 161 | { |
| 162 | 162 | $update_args = new stdClass(); |
| 163 | - $update_args->module_srls = implode(',',$modules); |
|
| 164 | - if($apply_layout == "Y") |
|
| 163 | + $update_args->module_srls = implode(',', $modules); |
|
| 164 | + if ($apply_layout == "Y") |
|
| 165 | 165 | { |
| 166 | 166 | $update_args->layout_srl = $args->layout_srl; |
| 167 | 167 | } |
| 168 | - if($layout_info->layout_type == "M") |
|
| 168 | + if ($layout_info->layout_type == "M") |
|
| 169 | 169 | { |
| 170 | - if(Context::get('apply_mobile_view') == "Y") |
|
| 170 | + if (Context::get('apply_mobile_view') == "Y") |
|
| 171 | 171 | { |
| 172 | 172 | $update_args->use_mobile = "Y"; |
| 173 | 173 | } |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | $oCacheHandler = CacheHandler::getInstance('object', null, true); |
| 182 | - if($oCacheHandler->isSupport()) |
|
| 182 | + if ($oCacheHandler->isSupport()) |
|
| 183 | 183 | { |
| 184 | 184 | $oCacheHandler->invalidateGroupKey('site_and_module'); |
| 185 | 185 | } |
@@ -191,21 +191,21 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | $tmpDir = sprintf('./files/attach/images/%s/tmp', $args->layout_srl); |
| 193 | 193 | // Separately handle if a type of extra_vars is an image |
| 194 | - if($layout_info->extra_var) |
|
| 194 | + if ($layout_info->extra_var) |
|
| 195 | 195 | { |
| 196 | - foreach($layout_info->extra_var as $name => $vars) |
|
| 196 | + foreach ($layout_info->extra_var as $name => $vars) |
|
| 197 | 197 | { |
| 198 | - if($vars->type!='image') continue; |
|
| 198 | + if ($vars->type != 'image') continue; |
|
| 199 | 199 | |
| 200 | 200 | $fileName = $extra_vars->{$name}; |
| 201 | - if($vars->value == $fileName) |
|
| 201 | + if ($vars->value == $fileName) |
|
| 202 | 202 | { |
| 203 | 203 | continue; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | FileHandler::removeFile($vars->value); |
| 207 | 207 | |
| 208 | - if(!$fileName) |
|
| 208 | + if (!$fileName) |
|
| 209 | 209 | { |
| 210 | 210 | continue; |
| 211 | 211 | } |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | $pathInfo = pathinfo($fileName); |
| 214 | 214 | $tmpFileName = sprintf('%s/tmp/%s', $pathInfo['dirname'], $pathInfo['basename']); |
| 215 | 215 | |
| 216 | - if(!FileHandler::moveFile($tmpFileName, $fileName)) |
|
| 216 | + if (!FileHandler::moveFile($tmpFileName, $fileName)) |
|
| 217 | 217 | { |
| 218 | 218 | unset($extra_vars->{$name}); |
| 219 | 219 | } |
@@ -225,21 +225,21 @@ discard block |
||
| 225 | 225 | $oModuleController = getController('module'); |
| 226 | 226 | $layout_config = new stdClass(); |
| 227 | 227 | $layout_config->header_script = Context::get('header_script'); |
| 228 | - $oModuleController->insertModulePartConfig('layout',$args->layout_srl,$layout_config); |
|
| 228 | + $oModuleController->insertModulePartConfig('layout', $args->layout_srl, $layout_config); |
|
| 229 | 229 | // Save a title of the menu |
| 230 | 230 | $extra_vars->menu_name_list = $menu_name_list; |
| 231 | 231 | // Variable setting for DB insert |
| 232 | 232 | $args->extra_vars = serialize($extra_vars); |
| 233 | 233 | |
| 234 | 234 | $output = $this->updateLayout($args); |
| 235 | - if(!$output->toBool()) |
|
| 235 | + if (!$output->toBool()) |
|
| 236 | 236 | { |
| 237 | 237 | return $output; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | FileHandler::removeDir($tmpDir); |
| 241 | 241 | |
| 242 | - if(!$is_sitemap) |
|
| 242 | + if (!$is_sitemap) |
|
| 243 | 243 | { |
| 244 | 244 | return $this->setRedirectUrl(Context::get('error_return_url'), $output); |
| 245 | 245 | } |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | function updateLayout($args) { |
| 260 | 260 | $output = executeQuery('layout.updateLayout', $args); |
| 261 | - if($output->toBool()) |
|
| 261 | + if ($output->toBool()) |
|
| 262 | 262 | { |
| 263 | 263 | $oLayoutModel = getModel('layout'); |
| 264 | 264 | $cache_file = $oLayoutModel->getUserLayoutCache($args->layout_srl, Context::getLangType()); |
@@ -289,13 +289,13 @@ discard block |
||
| 289 | 289 | { |
| 290 | 290 | $oLayoutModel = getModel('layout'); |
| 291 | 291 | |
| 292 | - if($force) |
|
| 292 | + if ($force) |
|
| 293 | 293 | { |
| 294 | 294 | $layoutInfo = $oLayoutModel->getLayout($layout_srl); |
| 295 | - if($layoutInfo) |
|
| 295 | + if ($layoutInfo) |
|
| 296 | 296 | { |
| 297 | 297 | $layoutList = $oLayoutModel->getLayoutInstanceList($layoutInfo->site_srl, $layoutInfo->layout_type, $layoutInfo->layout, array('layout_srl', 'layout')); |
| 298 | - if(count($layoutList) <= 1) |
|
| 298 | + if (count($layoutList) <= 1) |
|
| 299 | 299 | { |
| 300 | 300 | // uninstall package |
| 301 | 301 | $path = $layoutInfo->path; |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | $packageSrl = $oAutoinstallModel->getPackageSrlByPath($path); |
| 305 | 305 | $oAutoinstallAdminController = getAdminController('autoinstall'); |
| 306 | 306 | |
| 307 | - if($packageSrl) |
|
| 307 | + if ($packageSrl) |
|
| 308 | 308 | { |
| 309 | 309 | $output = $oAutoinstallAdminController->uninstallPackageByPackageSrl($packageSrl); |
| 310 | 310 | } |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | $output = $oAutoinstallAdminController->uninstallPackageByPath($path); |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - if(!$output->toBool()) |
|
| 316 | + if (!$output->toBool()) |
|
| 317 | 317 | { |
| 318 | 318 | return new BaseObject(-1, $output->message); |
| 319 | 319 | } |
@@ -331,9 +331,9 @@ discard block |
||
| 331 | 331 | $args->layout_srl = $layout_srl; |
| 332 | 332 | $output = executeQuery("layout.deleteLayout", $args); |
| 333 | 333 | |
| 334 | - if(!$output->toBool()) return $output; |
|
| 334 | + if (!$output->toBool()) return $output; |
|
| 335 | 335 | |
| 336 | - return new BaseObject(0,'success_deleted'); |
|
| 336 | + return new BaseObject(0, 'success_deleted'); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | /** |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | $code_css = Context::get('code_css'); |
| 354 | 354 | $is_post = ($_SERVER['REQUEST_METHOD'] == 'POST'); |
| 355 | 355 | |
| 356 | - if(!$layout_srl || !$code || !$is_post) |
|
| 356 | + if (!$layout_srl || !$code || !$is_post) |
|
| 357 | 357 | { |
| 358 | 358 | return new BaseObject(-1, 'msg_invalid_request'); |
| 359 | 359 | } |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | function procLayoutAdminCodeReset() |
| 377 | 377 | { |
| 378 | 378 | $layout_srl = Context::get('layout_srl'); |
| 379 | - if(!$layout_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 379 | + if (!$layout_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 380 | 380 | |
| 381 | 381 | // delete user layout file |
| 382 | 382 | $oLayoutModel = getModel('layout'); |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | $info = $oLayoutModel->getLayout($layout_srl); |
| 387 | 387 | |
| 388 | 388 | // if face off delete, tmp file |
| 389 | - if($oLayoutModel->useDefaultLayout($info->layout)) |
|
| 389 | + if ($oLayoutModel->useDefaultLayout($info->layout)) |
|
| 390 | 390 | { |
| 391 | 391 | $this->deleteUserLayoutTempFile($layout_srl); |
| 392 | 392 | $faceoff_css = $oLayoutModel->getUserLayoutFaceOffCss($layout_srl); |
@@ -404,11 +404,11 @@ discard block |
||
| 404 | 404 | */ |
| 405 | 405 | function procLayoutAdminUserImageUpload() |
| 406 | 406 | { |
| 407 | - if(!Context::isUploaded()) exit(); |
|
| 407 | + if (!Context::isUploaded()) exit(); |
|
| 408 | 408 | |
| 409 | 409 | $image = Context::get('user_layout_image'); |
| 410 | 410 | $layout_srl = Context::get('layout_srl'); |
| 411 | - if(!is_uploaded_file($image['tmp_name'])) exit(); |
|
| 411 | + if (!is_uploaded_file($image['tmp_name'])) exit(); |
|
| 412 | 412 | |
| 413 | 413 | $this->insertUserLayoutImage($layout_srl, $image); |
| 414 | 414 | $this->setTemplatePath($this->module_path.'tpl'); |
@@ -423,24 +423,24 @@ discard block |
||
| 423 | 423 | * @param object $source file data |
| 424 | 424 | * @return boolean (true : success, false : fail) |
| 425 | 425 | */ |
| 426 | - function insertUserLayoutImage($layout_srl,$source) |
|
| 426 | + function insertUserLayoutImage($layout_srl, $source) |
|
| 427 | 427 | { |
| 428 | 428 | $oLayoutModel = getModel('layout'); |
| 429 | 429 | $path = $oLayoutModel->getUserLayoutImagePath($layout_srl); |
| 430 | - if(!is_dir($path)) FileHandler::makeDir($path); |
|
| 430 | + if (!is_dir($path)) FileHandler::makeDir($path); |
|
| 431 | 431 | |
| 432 | 432 | $filename = strtolower($source['name']); |
| 433 | - if($filename != urlencode($filename)) |
|
| 433 | + if ($filename != urlencode($filename)) |
|
| 434 | 434 | { |
| 435 | - $ext = substr(strrchr($filename,'.'),1); |
|
| 435 | + $ext = substr(strrchr($filename, '.'), 1); |
|
| 436 | 436 | $filename = sprintf('%s.%s', md5($filename), $ext); |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | // Check uploaded file |
| 440 | - if(!checkUploadedFile($source['tmp_name'])) return false; |
|
| 440 | + if (!checkUploadedFile($source['tmp_name'])) return false; |
|
| 441 | 441 | |
| 442 | - if(file_exists($path .'/'. $filename)) @unlink($path . $filename); |
|
| 443 | - if(!move_uploaded_file($source['tmp_name'], $path . $filename )) return false; |
|
| 442 | + if (file_exists($path.'/'.$filename)) @unlink($path.$filename); |
|
| 443 | + if (!move_uploaded_file($source['tmp_name'], $path.$filename)) return false; |
|
| 444 | 444 | return true; |
| 445 | 445 | } |
| 446 | 446 | |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | { |
| 453 | 453 | $filename = Context::get('filename'); |
| 454 | 454 | $layout_srl = Context::get('layout_srl'); |
| 455 | - $this->removeUserLayoutImage($layout_srl,$filename); |
|
| 455 | + $this->removeUserLayoutImage($layout_srl, $filename); |
|
| 456 | 456 | $this->setMessage('success_deleted'); |
| 457 | 457 | $this->setRedirectUrl(Context::get('error_return_url')); |
| 458 | 458 | } |
@@ -463,11 +463,11 @@ discard block |
||
| 463 | 463 | * @param string $filename |
| 464 | 464 | * @return void |
| 465 | 465 | */ |
| 466 | - function removeUserLayoutImage($layout_srl,$filename) |
|
| 466 | + function removeUserLayoutImage($layout_srl, $filename) |
|
| 467 | 467 | { |
| 468 | 468 | $oLayoutModel = getModel('layout'); |
| 469 | 469 | $path = $oLayoutModel->getUserLayoutImagePath($layout_srl); |
| 470 | - @unlink($path . $filename); |
|
| 470 | + @unlink($path.$filename); |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | // deprecated |
@@ -482,19 +482,19 @@ discard block |
||
| 482 | 482 | $oModuleModel = getModel('module'); |
| 483 | 483 | |
| 484 | 484 | $mid = Context::get('mid'); |
| 485 | - if(!$mid) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 485 | + if (!$mid) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 486 | 486 | |
| 487 | 487 | $site_module_info = Context::get('site_module_info'); |
| 488 | 488 | $columnList = array('layout_srl'); |
| 489 | 489 | $module_info = $oModuleModel->getModuleInfoByMid($mid, $site_module_info->site_srl, $columnList); |
| 490 | 490 | $layout_srl = $module_info->layout_srl; |
| 491 | - if(!$layout_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 491 | + if (!$layout_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 492 | 492 | |
| 493 | 493 | $oLayoutModel = getModel('layout'); |
| 494 | 494 | |
| 495 | 495 | // save tmp? |
| 496 | 496 | $temp = Context::get('saveTemp'); |
| 497 | - if($temp =='Y') |
|
| 497 | + if ($temp == 'Y') |
|
| 498 | 498 | { |
| 499 | 499 | $oLayoutModel->setUseUserLayoutTemp(); |
| 500 | 500 | } |
@@ -504,28 +504,28 @@ discard block |
||
| 504 | 504 | $this->deleteUserLayoutTempFile($layout_srl); |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | - $this->add('saveTemp',$temp); |
|
| 507 | + $this->add('saveTemp', $temp); |
|
| 508 | 508 | |
| 509 | 509 | // write user layout |
| 510 | - $extension_obj = Context::gets('e1','e2','neck','knee'); |
|
| 510 | + $extension_obj = Context::gets('e1', 'e2', 'neck', 'knee'); |
|
| 511 | 511 | |
| 512 | 512 | $file = $oLayoutModel->getUserLayoutHtml($layout_srl); |
| 513 | 513 | $content = FileHandler::readFile($file); |
| 514 | - $content = $this->addExtension($layout_srl,$extension_obj,$content); |
|
| 515 | - FileHandler::writeFile($file,$content); |
|
| 514 | + $content = $this->addExtension($layout_srl, $extension_obj, $content); |
|
| 515 | + FileHandler::writeFile($file, $content); |
|
| 516 | 516 | |
| 517 | 517 | // write faceoff.css |
| 518 | 518 | $css = stripslashes(Context::get('css')); |
| 519 | 519 | |
| 520 | 520 | $css_file = $oLayoutModel->getUserLayoutFaceOffCss($layout_srl); |
| 521 | - FileHandler::writeFile($css_file,$css); |
|
| 521 | + FileHandler::writeFile($css_file, $css); |
|
| 522 | 522 | |
| 523 | 523 | // write ini |
| 524 | - $obj = Context::gets('type','align','column'); |
|
| 525 | - $obj = (array)$obj; |
|
| 524 | + $obj = Context::gets('type', 'align', 'column'); |
|
| 525 | + $obj = (array) $obj; |
|
| 526 | 526 | $src = $oLayoutModel->getUserLayoutIniConfig($layout_srl); |
| 527 | - foreach($obj as $key => $val) $src[$key] = $val; |
|
| 528 | - $this->insertUserLayoutValue($layout_srl,$src); |
|
| 527 | + foreach ($obj as $key => $val) $src[$key] = $val; |
|
| 528 | + $this->insertUserLayoutValue($layout_srl, $src); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | /** |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | * @param object $arr layout ini |
| 535 | 535 | * @return void |
| 536 | 536 | */ |
| 537 | - function insertUserLayoutValue($layout_srl,$arr) |
|
| 537 | + function insertUserLayoutValue($layout_srl, $arr) |
|
| 538 | 538 | { |
| 539 | 539 | $oLayoutModel = getModel('layout'); |
| 540 | 540 | $file = $oLayoutModel->getUserLayoutIni($layout_srl); |
@@ -548,24 +548,24 @@ discard block |
||
| 548 | 548 | * @param string $content |
| 549 | 549 | * @return string |
| 550 | 550 | */ |
| 551 | - function addExtension($layout_srl,$arg,$content) |
|
| 551 | + function addExtension($layout_srl, $arg, $content) |
|
| 552 | 552 | { |
| 553 | 553 | $oLayoutModel = getModel('layout'); |
| 554 | 554 | $reg = '/(<\!\-\- start\-e1 \-\->)(.*)(<\!\-\- end\-e1 \-\->)/i'; |
| 555 | - $extension_content = '\1' .stripslashes($arg->e1) . '\3'; |
|
| 556 | - $content = preg_replace($reg,$extension_content,$content); |
|
| 555 | + $extension_content = '\1'.stripslashes($arg->e1).'\3'; |
|
| 556 | + $content = preg_replace($reg, $extension_content, $content); |
|
| 557 | 557 | |
| 558 | 558 | $reg = '/(<\!\-\- start\-e2 \-\->)(.*)(<\!\-\- end\-e2 \-\->)/i'; |
| 559 | - $extension_content = '\1' .stripslashes($arg->e2) . '\3'; |
|
| 560 | - $content = preg_replace($reg,$extension_content,$content); |
|
| 559 | + $extension_content = '\1'.stripslashes($arg->e2).'\3'; |
|
| 560 | + $content = preg_replace($reg, $extension_content, $content); |
|
| 561 | 561 | |
| 562 | 562 | $reg = '/(<\!\-\- start\-neck \-\->)(.*)(<\!\-\- end\-neck \-\->)/i'; |
| 563 | - $extension_content = '\1' .stripslashes($arg->neck) . '\3'; |
|
| 564 | - $content = preg_replace($reg,$extension_content,$content); |
|
| 563 | + $extension_content = '\1'.stripslashes($arg->neck).'\3'; |
|
| 564 | + $content = preg_replace($reg, $extension_content, $content); |
|
| 565 | 565 | |
| 566 | 566 | $reg = '/(<\!\-\- start\-knee \-\->)(.*)(<\!\-\- end\-knee \-\->)/i'; |
| 567 | - $extension_content = '\1' .stripslashes($arg->knee) . '\3'; |
|
| 568 | - $content = preg_replace($reg,$extension_content,$content); |
|
| 567 | + $extension_content = '\1'.stripslashes($arg->knee).'\3'; |
|
| 568 | + $content = preg_replace($reg, $extension_content, $content); |
|
| 569 | 569 | return $content; |
| 570 | 570 | } |
| 571 | 571 | |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | { |
| 579 | 579 | $oLayoutModel = getModel('layout'); |
| 580 | 580 | $file_list = $oLayoutModel->getUserLayoutTempFileList($layout_srl); |
| 581 | - foreach($file_list as $key => $file) |
|
| 581 | + foreach ($file_list as $key => $file) |
|
| 582 | 582 | { |
| 583 | 583 | FileHandler::removeFile($file); |
| 584 | 584 | } |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | function procLayoutAdminUserLayoutExport() |
| 592 | 592 | { |
| 593 | 593 | $layout_srl = Context::get('layout_srl'); |
| 594 | - if(!$layout_srl) return new BaseObject('-1','msg_invalid_request'); |
|
| 594 | + if (!$layout_srl) return new BaseObject('-1', 'msg_invalid_request'); |
|
| 595 | 595 | |
| 596 | 596 | require_once(_XE_PATH_.'libs/tar.class.php'); |
| 597 | 597 | $oLayoutModel = getModel('layout'); |
@@ -606,30 +606,30 @@ discard block |
||
| 606 | 606 | $file_list = $oLayoutModel->getUserLayoutFileList($layout_srl); |
| 607 | 607 | unset($file_list[2]); |
| 608 | 608 | |
| 609 | - foreach($file_list as $file) |
|
| 609 | + foreach ($file_list as $file) |
|
| 610 | 610 | { |
| 611 | - if(strncasecmp('images', $file, 6) === 0) continue; |
|
| 611 | + if (strncasecmp('images', $file, 6) === 0) continue; |
|
| 612 | 612 | |
| 613 | 613 | // replace path |
| 614 | - $file = $target_path . $file; |
|
| 614 | + $file = $target_path.$file; |
|
| 615 | 615 | $content = FileHandler::readFile($file); |
| 616 | - $pattern = '/(http:\/\/[^ ]+)?(\.\/)?' . str_replace('/', '\/', (str_replace('./', '', $file_path))) . '/'; |
|
| 617 | - if(basename($file) == 'faceoff.css' || basename($file) == 'layout.css') |
|
| 616 | + $pattern = '/(http:\/\/[^ ]+)?(\.\/)?'.str_replace('/', '\/', (str_replace('./', '', $file_path))).'/'; |
|
| 617 | + if (basename($file) == 'faceoff.css' || basename($file) == 'layout.css') |
|
| 618 | 618 | $content = preg_replace($pattern, '../', $content); |
| 619 | 619 | else |
| 620 | 620 | $content = preg_replace($pattern, './', $content); |
| 621 | 621 | |
| 622 | 622 | // replace ini config |
| 623 | - foreach($ini_config as $key => $value) |
|
| 623 | + foreach ($ini_config as $key => $value) |
|
| 624 | 624 | { |
| 625 | - $content = str_replace('{$layout_info->faceoff_ini_config[\'' . $key . '\']}', $value, $content); |
|
| 625 | + $content = str_replace('{$layout_info->faceoff_ini_config[\''.$key.'\']}', $value, $content); |
|
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | FileHandler::writeFile($file, $content); |
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | // make info.xml |
| 632 | - $info_file = $target_path . 'conf/info.xml'; |
|
| 632 | + $info_file = $target_path.'conf/info.xml'; |
|
| 633 | 633 | FileHandler::copyFile('./modules/layout/faceoff/conf/info.xml', $info_file); |
| 634 | 634 | $content = FileHandler::readFile($info_file); |
| 635 | 635 | $content = str_replace('type="faceoff"', '', $content); |
@@ -637,19 +637,19 @@ discard block |
||
| 637 | 637 | $file_list[] = 'conf/info.xml'; |
| 638 | 638 | |
| 639 | 639 | // make css file |
| 640 | - $css_file = $target_path . 'css/layout.css'; |
|
| 640 | + $css_file = $target_path.'css/layout.css'; |
|
| 641 | 641 | FileHandler::copyFile('./modules/layout/faceoff/css/layout.css', $css_file); |
| 642 | 642 | $content = FileHandler::readFile('./modules/layout/tpl/css/widget.css'); |
| 643 | - FileHandler::writeFile($css_file, "\n" . $content, 'a'); |
|
| 644 | - $content = FileHandler::readFile($target_path . 'faceoff.css'); |
|
| 645 | - FileHandler::writeFile($css_file, "\n" . $content, 'a'); |
|
| 646 | - $content = FileHandler::readFile($target_path . 'layout.css'); |
|
| 647 | - FileHandler::writeFile($css_file, "\n" . $content, 'a'); |
|
| 643 | + FileHandler::writeFile($css_file, "\n".$content, 'a'); |
|
| 644 | + $content = FileHandler::readFile($target_path.'faceoff.css'); |
|
| 645 | + FileHandler::writeFile($css_file, "\n".$content, 'a'); |
|
| 646 | + $content = FileHandler::readFile($target_path.'layout.css'); |
|
| 647 | + FileHandler::writeFile($css_file, "\n".$content, 'a'); |
|
| 648 | 648 | |
| 649 | 649 | // css load |
| 650 | - $content = FileHandler::readFile($target_path . 'layout.html'); |
|
| 651 | - $content = "<load target=\"css/layout.css\" />\n" . $content; |
|
| 652 | - FileHandler::writeFile($target_path . 'layout.html', $content); |
|
| 650 | + $content = FileHandler::readFile($target_path.'layout.html'); |
|
| 651 | + $content = "<load target=\"css/layout.css\" />\n".$content; |
|
| 652 | + FileHandler::writeFile($target_path.'layout.html', $content); |
|
| 653 | 653 | unset($file_list[3]); |
| 654 | 654 | unset($file_list[1]); |
| 655 | 655 | $file_list[] = 'css/layout.css'; |
@@ -658,16 +658,16 @@ discard block |
||
| 658 | 658 | $tar = new tar(); |
| 659 | 659 | $user_layout_path = FileHandler::getRealPath($oLayoutModel->getUserLayoutPath(0)); |
| 660 | 660 | chdir($user_layout_path); |
| 661 | - foreach($file_list as $key => $file) $tar->addFile($file); |
|
| 661 | + foreach ($file_list as $key => $file) $tar->addFile($file); |
|
| 662 | 662 | |
| 663 | 663 | $stream = $tar->toTarStream(); |
| 664 | - $filename = 'faceoff_' . date('YmdHis') . '.tar'; |
|
| 664 | + $filename = 'faceoff_'.date('YmdHis').'.tar'; |
|
| 665 | 665 | header("Cache-Control: "); |
| 666 | 666 | header("Pragma: "); |
| 667 | 667 | header("Content-Type: application/x-compressed"); |
| 668 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
| 668 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
| 669 | 669 | // header("Content-Length: " .strlen($stream)); ?? why?? |
| 670 | - header('Content-Disposition: attachment; filename="'. $filename .'"'); |
|
| 670 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
| 671 | 671 | header("Content-Transfer-Encoding: binary\n"); |
| 672 | 672 | echo $stream; |
| 673 | 673 | // Close Context and then exit |
@@ -689,18 +689,18 @@ discard block |
||
| 689 | 689 | return $this->stop('not supported'); |
| 690 | 690 | |
| 691 | 691 | // check upload |
| 692 | - if(!Context::isUploaded()) exit(); |
|
| 692 | + if (!Context::isUploaded()) exit(); |
|
| 693 | 693 | $file = Context::get('file'); |
| 694 | - if(!is_uploaded_file($file['tmp_name']) || !checkUploadedFile($file['tmp_name'])) exit(); |
|
| 694 | + if (!is_uploaded_file($file['tmp_name']) || !checkUploadedFile($file['tmp_name'])) exit(); |
|
| 695 | 695 | |
| 696 | - if(substr_compare($file['name'], '.tar', -4) !== 0) exit(); |
|
| 696 | + if (substr_compare($file['name'], '.tar', -4) !== 0) exit(); |
|
| 697 | 697 | |
| 698 | 698 | $layout_srl = Context::get('layout_srl'); |
| 699 | - if(!$layout_srl) exit(); |
|
| 699 | + if (!$layout_srl) exit(); |
|
| 700 | 700 | |
| 701 | 701 | $oLayoutModel = getModel('layout'); |
| 702 | 702 | $user_layout_path = FileHandler::getRealPath($oLayoutModel->getUserLayoutPath($layout_srl)); |
| 703 | - if(!move_uploaded_file($file['tmp_name'], $user_layout_path . 'faceoff.tar')) exit(); |
|
| 703 | + if (!move_uploaded_file($file['tmp_name'], $user_layout_path.'faceoff.tar')) exit(); |
|
| 704 | 704 | |
| 705 | 705 | $this->importLayout($layout_srl, $user_layout_path.'faceoff.tar'); |
| 706 | 706 | |
@@ -714,12 +714,12 @@ discard block |
||
| 714 | 714 | function procLayoutAdminCopyLayout() |
| 715 | 715 | { |
| 716 | 716 | $sourceArgs = Context::getRequestVars(); |
| 717 | - if($sourceArgs->layout == 'faceoff') |
|
| 717 | + if ($sourceArgs->layout == 'faceoff') |
|
| 718 | 718 | { |
| 719 | 719 | return $this->stop('not supported'); |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | - if(!$sourceArgs->layout_srl) |
|
| 722 | + if (!$sourceArgs->layout_srl) |
|
| 723 | 723 | { |
| 724 | 724 | return $this->stop('msg_empty_origin_layout'); |
| 725 | 725 | } |
@@ -727,12 +727,12 @@ discard block |
||
| 727 | 727 | $oLayoutModel = getModel('layout'); |
| 728 | 728 | $layout = $oLayoutModel->getLayout($sourceArgs->layout_srl); |
| 729 | 729 | |
| 730 | - if(!$sourceArgs->title) |
|
| 730 | + if (!$sourceArgs->title) |
|
| 731 | 731 | { |
| 732 | 732 | $sourceArgs->title = array($layout->title.'_'.$this->_makeRandomMid()); |
| 733 | 733 | } |
| 734 | 734 | |
| 735 | - if(!is_array($sourceArgs->title) || count($sourceArgs->title) == 0) |
|
| 735 | + if (!is_array($sourceArgs->title) || count($sourceArgs->title) == 0) |
|
| 736 | 736 | { |
| 737 | 737 | return $this->stop('msg_empty_target_layout'); |
| 738 | 738 | } |
@@ -742,11 +742,11 @@ discard block |
||
| 742 | 742 | $args->extra_vars = $output->extra_vars; |
| 743 | 743 | $extra_vars = unserialize($args->extra_vars); |
| 744 | 744 | |
| 745 | - if($layout->extra_var_count) { |
|
| 745 | + if ($layout->extra_var_count) { |
|
| 746 | 746 | $reg = "/^.\/files\/attach\/images\/([0-9]+)\/(.*)/"; |
| 747 | - if($extra_vars) foreach($extra_vars as $key => $val) { |
|
| 748 | - if($layout->extra_var->{$key}->type == 'image') { |
|
| 749 | - if(!preg_match($reg,$val,$matches)) continue; |
|
| 747 | + if ($extra_vars) foreach ($extra_vars as $key => $val) { |
|
| 748 | + if ($layout->extra_var->{$key}->type == 'image') { |
|
| 749 | + if (!preg_match($reg, $val, $matches)) continue; |
|
| 750 | 750 | $image_list[$key]->filename = $matches[2]; |
| 751 | 751 | $image_list[$key]->old_file = $val; |
| 752 | 752 | } |
@@ -758,19 +758,19 @@ discard block |
||
| 758 | 758 | $layout_config->header_script = $extra_vars->header_script; |
| 759 | 759 | |
| 760 | 760 | // Get information to create a layout |
| 761 | - $args->site_srl = (int)$layout->site_srl; |
|
| 761 | + $args->site_srl = (int) $layout->site_srl; |
|
| 762 | 762 | $args->layout = $layout->layout; |
| 763 | 763 | $args->layout_type = $layout->layout_type; |
| 764 | - if(!$args->layout_type) $args->layout_type = "P"; |
|
| 764 | + if (!$args->layout_type) $args->layout_type = "P"; |
|
| 765 | 765 | |
| 766 | 766 | $oDB = &DB::getInstance(); |
| 767 | 767 | $oDB->begin(); |
| 768 | 768 | |
| 769 | - if(is_array($sourceArgs->title)) |
|
| 769 | + if (is_array($sourceArgs->title)) |
|
| 770 | 770 | { |
| 771 | - foreach($sourceArgs->title AS $key=>$value) |
|
| 771 | + foreach ($sourceArgs->title AS $key=>$value) |
|
| 772 | 772 | { |
| 773 | - if(!trim($value)) |
|
| 773 | + if (!trim($value)) |
|
| 774 | 774 | { |
| 775 | 775 | continue; |
| 776 | 776 | } |
@@ -778,9 +778,9 @@ discard block |
||
| 778 | 778 | $args->layout_srl = getNextSequence(); |
| 779 | 779 | $args->title = $value; |
| 780 | 780 | |
| 781 | - if(is_array($image_list)) { |
|
| 782 | - foreach($image_list as $key=>$val) { |
|
| 783 | - $new_file = sprintf("./files/attach/images/%s/%s", $args->layout_srl,$val->filename); |
|
| 781 | + if (is_array($image_list)) { |
|
| 782 | + foreach ($image_list as $key=>$val) { |
|
| 783 | + $new_file = sprintf("./files/attach/images/%s/%s", $args->layout_srl, $val->filename); |
|
| 784 | 784 | FileHandler::copyFile($val->old_file, $new_file); |
| 785 | 785 | $extra_vars->{$key} = $new_file; |
| 786 | 786 | } |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | |
| 793 | 793 | // Insert into the DB |
| 794 | 794 | $output = $this->insertLayout($args); |
| 795 | - if(!$output->toBool()) |
|
| 795 | + if (!$output->toBool()) |
|
| 796 | 796 | { |
| 797 | 797 | $oDB->rollback(); |
| 798 | 798 | return $output; |
@@ -815,7 +815,7 @@ discard block |
||
| 815 | 815 | $oDB->commit(); |
| 816 | 816 | |
| 817 | 817 | $this->setMessage('success_registed'); |
| 818 | - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) { |
|
| 818 | + if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) { |
|
| 819 | 819 | global $lang; |
| 820 | 820 | htmlHeader(); |
| 821 | 821 | alertScript($lang->success_registed); |
@@ -831,9 +831,9 @@ discard block |
||
| 831 | 831 | { |
| 832 | 832 | $time = $_SERVER['REQUEST_TIME']; |
| 833 | 833 | $randomString = ""; |
| 834 | - for($i=0;$i<4;$i++) |
|
| 834 | + for ($i = 0; $i < 4; $i++) |
|
| 835 | 835 | { |
| 836 | - $doc = rand()%26+65; |
|
| 836 | + $doc = rand() % 26 + 65; |
|
| 837 | 837 | $randomString .= chr($doc); |
| 838 | 838 | } |
| 839 | 839 | |
@@ -857,12 +857,12 @@ discard block |
||
| 857 | 857 | FileHandler::makeDir($targetImagePath); |
| 858 | 858 | |
| 859 | 859 | $sourceFileList = $oLayoutModel->getUserLayoutFileList($sourceLayoutSrl); |
| 860 | - foreach($sourceFileList as $key => $file) |
|
| 860 | + foreach ($sourceFileList as $key => $file) |
|
| 861 | 861 | { |
| 862 | - if(is_readable($sourceLayoutPath.$file)) |
|
| 862 | + if (is_readable($sourceLayoutPath.$file)) |
|
| 863 | 863 | { |
| 864 | 864 | FileHandler::copyFile($sourceLayoutPath.$file, $targetLayoutPath.$file); |
| 865 | - if($file == 'layout.html' || $file == 'layout.css') |
|
| 865 | + if ($file == 'layout.html' || $file == 'layout.css') |
|
| 866 | 866 | { |
| 867 | 867 | $this->_changeFilepathInSource($targetLayoutPath.$file, $sourceImagePath, $targetImagePath); |
| 868 | 868 | } |
@@ -893,9 +893,9 @@ discard block |
||
| 893 | 893 | $oLayoutModel = getModel('layout'); |
| 894 | 894 | $user_layout_path = FileHandler::getRealPath($oLayoutModel->getUserLayoutPath($layout_srl)); |
| 895 | 895 | $file_list = $oLayoutModel->getUserLayoutFileList($layout_srl); |
| 896 | - foreach($file_list as $key => $file) |
|
| 896 | + foreach ($file_list as $key => $file) |
|
| 897 | 897 | { |
| 898 | - FileHandler::removeFile($user_layout_path . $file); |
|
| 898 | + FileHandler::removeFile($user_layout_path.$file); |
|
| 899 | 899 | } |
| 900 | 900 | |
| 901 | 901 | require_once(_XE_PATH_.'libs/tar.class.php'); |
@@ -904,12 +904,12 @@ discard block |
||
| 904 | 904 | $tar = new tar(); |
| 905 | 905 | $tar->openTAR($source_file); |
| 906 | 906 | // If layout.ini file does not exist |
| 907 | - if(!$tar->getFile('layout.ini')) return; |
|
| 907 | + if (!$tar->getFile('layout.ini')) return; |
|
| 908 | 908 | |
| 909 | - $replace_path = getNumberingPath($layout_srl,3); |
|
| 910 | - foreach($tar->files as $key => $info) |
|
| 909 | + $replace_path = getNumberingPath($layout_srl, 3); |
|
| 910 | + foreach ($tar->files as $key => $info) |
|
| 911 | 911 | { |
| 912 | - FileHandler::writeFile($user_layout_path . $info['name'],str_replace('__LAYOUT_PATH__',$replace_path,$info['file'])); |
|
| 912 | + FileHandler::writeFile($user_layout_path.$info['name'], str_replace('__LAYOUT_PATH__', $replace_path, $info['file'])); |
|
| 913 | 913 | } |
| 914 | 914 | // Remove uploaded file |
| 915 | 915 | FileHandler::removeFile($source_file); |
@@ -927,32 +927,32 @@ discard block |
||
| 927 | 927 | $this->setTemplatePath($this->module_path.'tpl'); |
| 928 | 928 | $this->setTemplateFile("after_upload_config_image.html"); |
| 929 | 929 | |
| 930 | - if(!$img['tmp_name'] || !is_uploaded_file($img['tmp_name']) || !checkUploadedFile($img['tmp_name'])) |
|
| 930 | + if (!$img['tmp_name'] || !is_uploaded_file($img['tmp_name']) || !checkUploadedFile($img['tmp_name'])) |
|
| 931 | 931 | { |
| 932 | 932 | Context::set('msg', Context::getLang('upload failed')); |
| 933 | 933 | return; |
| 934 | 934 | } |
| 935 | 935 | |
| 936 | - if(!preg_match('/\.(jpg|jpeg|gif|png)$/i', $img['name'])) |
|
| 936 | + if (!preg_match('/\.(jpg|jpeg|gif|png)$/i', $img['name'])) |
|
| 937 | 937 | { |
| 938 | 938 | Context::set('msg', Context::getLang('msg_layout_image_target')); |
| 939 | 939 | return; |
| 940 | 940 | } |
| 941 | 941 | |
| 942 | 942 | $path = sprintf('./files/attach/images/%s/', $layoutSrl); |
| 943 | - $tmpPath = $path . 'tmp/'; |
|
| 944 | - if(!FileHandler::makeDir($tmpPath)) |
|
| 943 | + $tmpPath = $path.'tmp/'; |
|
| 944 | + if (!FileHandler::makeDir($tmpPath)) |
|
| 945 | 945 | { |
| 946 | 946 | Context::set('msg', Context::getLang('make directory failed')); |
| 947 | 947 | return; |
| 948 | 948 | } |
| 949 | 949 | |
| 950 | - $ext = substr(strrchr($img['name'],'.'),1); |
|
| 951 | - $_fileName = md5(crypt(rand(1000000,900000), rand(0,100))).'.'.$ext; |
|
| 952 | - $fileName = $path . $_fileName; |
|
| 953 | - $tmpFileName = $tmpPath . $_fileName; |
|
| 950 | + $ext = substr(strrchr($img['name'], '.'), 1); |
|
| 951 | + $_fileName = md5(crypt(rand(1000000, 900000), rand(0, 100))).'.'.$ext; |
|
| 952 | + $fileName = $path.$_fileName; |
|
| 953 | + $tmpFileName = $tmpPath.$_fileName; |
|
| 954 | 954 | |
| 955 | - if(!move_uploaded_file($img['tmp_name'], $tmpFileName)) |
|
| 955 | + if (!move_uploaded_file($img['tmp_name'], $tmpFileName)) |
|
| 956 | 956 | { |
| 957 | 957 | Context::set('msg', Context::getLang('move file failed')); |
| 958 | 958 | return; |
@@ -977,9 +977,9 @@ discard block |
||
| 977 | 977 | $oModel = getModel('layout'); |
| 978 | 978 | $layoutInfo = $oModel->getLayout($layoutSrl); |
| 979 | 979 | |
| 980 | - if($layoutInfo->extra_var_count) |
|
| 980 | + if ($layoutInfo->extra_var_count) |
|
| 981 | 981 | { |
| 982 | - foreach($layoutInfo->extra_var as $varId => $val) |
|
| 982 | + foreach ($layoutInfo->extra_var as $varId => $val) |
|
| 983 | 983 | { |
| 984 | 984 | $newLayoutInfo->{$varId} = $val->value; |
| 985 | 985 | } |
@@ -990,7 +990,7 @@ discard block |
||
| 990 | 990 | $args->layout_srl = $layoutSrl; |
| 991 | 991 | $args->extra_vars = serialize($newLayoutInfo); |
| 992 | 992 | $output = $this->updateLayout($args); |
| 993 | - if(!$output->toBool()) |
|
| 993 | + if (!$output->toBool()) |
|
| 994 | 994 | { |
| 995 | 995 | Context::set('msg', Context::getLang($output->getMessage())); |
| 996 | 996 | return $output; |
@@ -23,7 +23,9 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | function procLayoutAdminInsert() |
| 25 | 25 | { |
| 26 | - if(Context::get('layout') == 'faceoff') return $this->stop('not supported'); |
|
| 26 | + if(Context::get('layout') == 'faceoff') { |
|
| 27 | + return $this->stop('not supported'); |
|
| 28 | + } |
|
| 27 | 29 | |
| 28 | 30 | // Get information to create a layout |
| 29 | 31 | $site_module_info = Context::get('site_module_info'); |
@@ -32,11 +34,15 @@ discard block |
||
| 32 | 34 | $args->layout = Context::get('layout'); |
| 33 | 35 | $args->title = Context::get('title'); |
| 34 | 36 | $args->layout_type = Context::get('_layout_type'); |
| 35 | - if(!$args->layout_type) $args->layout_type = "P"; |
|
| 37 | + if(!$args->layout_type) { |
|
| 38 | + $args->layout_type = "P"; |
|
| 39 | + } |
|
| 36 | 40 | |
| 37 | 41 | // Insert into the DB |
| 38 | 42 | $output = $this->insertLayout($args); |
| 39 | - if(!$output->toBool()) return $output; |
|
| 43 | + if(!$output->toBool()) { |
|
| 44 | + return $output; |
|
| 45 | + } |
|
| 40 | 46 | |
| 41 | 47 | // initiate if it is faceoff layout |
| 42 | 48 | $this->initLayout($args->layout_srl, $args->layout); |
@@ -44,7 +50,9 @@ discard block |
||
| 44 | 50 | // update layout info |
| 45 | 51 | Context::set('layout_srl', $args->layout_srl); |
| 46 | 52 | $output = $this->procLayoutAdminUpdate(); |
| 47 | - if (!$output->toBool()) return $output; |
|
| 53 | + if (!$output->toBool()) { |
|
| 54 | + return $output; |
|
| 55 | + } |
|
| 48 | 56 | |
| 49 | 57 | return $this->setRedirectUrl(Context::get('success_return_url'), $output); |
| 50 | 58 | } |
@@ -74,8 +82,7 @@ discard block |
||
| 74 | 82 | { |
| 75 | 83 | $this->importLayout($layout_srl, $this->module_path.'tpl/faceOff_sample.tar'); |
| 76 | 84 | // Remove a directory |
| 77 | - } |
|
| 78 | - else |
|
| 85 | + } else |
|
| 79 | 86 | { |
| 80 | 87 | FileHandler::removeDir($oLayoutModel->getUserLayoutPath($layout_srl)); |
| 81 | 88 | } |
@@ -116,7 +123,9 @@ discard block |
||
| 116 | 123 | foreach($menus as $menu_id => $val) |
| 117 | 124 | { |
| 118 | 125 | $menu_srl = Context::get($menu_id); |
| 119 | - if(!$menu_srl) continue; |
|
| 126 | + if(!$menu_srl) { |
|
| 127 | + continue; |
|
| 128 | + } |
|
| 120 | 129 | |
| 121 | 130 | // if menu is -1, get default menu in site |
| 122 | 131 | if($menu_srl == -1) |
@@ -172,8 +181,7 @@ discard block |
||
| 172 | 181 | $update_args->use_mobile = "Y"; |
| 173 | 182 | } |
| 174 | 183 | $output = executeQuery('layout.updateModuleMLayout', $update_args); |
| 175 | - } |
|
| 176 | - else |
|
| 184 | + } else |
|
| 177 | 185 | { |
| 178 | 186 | $output = executeQuery('layout.updateModuleLayout', $update_args); |
| 179 | 187 | } |
@@ -195,7 +203,9 @@ discard block |
||
| 195 | 203 | { |
| 196 | 204 | foreach($layout_info->extra_var as $name => $vars) |
| 197 | 205 | { |
| 198 | - if($vars->type!='image') continue; |
|
| 206 | + if($vars->type!='image') { |
|
| 207 | + continue; |
|
| 208 | + } |
|
| 199 | 209 | |
| 200 | 210 | $fileName = $extra_vars->{$name}; |
| 201 | 211 | if($vars->value == $fileName) |
@@ -242,8 +252,7 @@ discard block |
||
| 242 | 252 | if(!$is_sitemap) |
| 243 | 253 | { |
| 244 | 254 | return $this->setRedirectUrl(Context::get('error_return_url'), $output); |
| 245 | - } |
|
| 246 | - else |
|
| 255 | + } else |
|
| 247 | 256 | { |
| 248 | 257 | $context = Context::getInstance(); |
| 249 | 258 | $context->setRequestMethod('JSON'); |
@@ -307,8 +316,7 @@ discard block |
||
| 307 | 316 | if($packageSrl) |
| 308 | 317 | { |
| 309 | 318 | $output = $oAutoinstallAdminController->uninstallPackageByPackageSrl($packageSrl); |
| 310 | - } |
|
| 311 | - else |
|
| 319 | + } else |
|
| 312 | 320 | { |
| 313 | 321 | $output = $oAutoinstallAdminController->uninstallPackageByPath($path); |
| 314 | 322 | } |
@@ -331,7 +339,9 @@ discard block |
||
| 331 | 339 | $args->layout_srl = $layout_srl; |
| 332 | 340 | $output = executeQuery("layout.deleteLayout", $args); |
| 333 | 341 | |
| 334 | - if(!$output->toBool()) return $output; |
|
| 342 | + if(!$output->toBool()) { |
|
| 343 | + return $output; |
|
| 344 | + } |
|
| 335 | 345 | |
| 336 | 346 | return new BaseObject(0,'success_deleted'); |
| 337 | 347 | } |
@@ -376,7 +386,9 @@ discard block |
||
| 376 | 386 | function procLayoutAdminCodeReset() |
| 377 | 387 | { |
| 378 | 388 | $layout_srl = Context::get('layout_srl'); |
| 379 | - if(!$layout_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 389 | + if(!$layout_srl) { |
|
| 390 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
| 391 | + } |
|
| 380 | 392 | |
| 381 | 393 | // delete user layout file |
| 382 | 394 | $oLayoutModel = getModel('layout'); |
@@ -404,11 +416,15 @@ discard block |
||
| 404 | 416 | */ |
| 405 | 417 | function procLayoutAdminUserImageUpload() |
| 406 | 418 | { |
| 407 | - if(!Context::isUploaded()) exit(); |
|
| 419 | + if(!Context::isUploaded()) { |
|
| 420 | + exit(); |
|
| 421 | + } |
|
| 408 | 422 | |
| 409 | 423 | $image = Context::get('user_layout_image'); |
| 410 | 424 | $layout_srl = Context::get('layout_srl'); |
| 411 | - if(!is_uploaded_file($image['tmp_name'])) exit(); |
|
| 425 | + if(!is_uploaded_file($image['tmp_name'])) { |
|
| 426 | + exit(); |
|
| 427 | + } |
|
| 412 | 428 | |
| 413 | 429 | $this->insertUserLayoutImage($layout_srl, $image); |
| 414 | 430 | $this->setTemplatePath($this->module_path.'tpl'); |
@@ -427,7 +443,9 @@ discard block |
||
| 427 | 443 | { |
| 428 | 444 | $oLayoutModel = getModel('layout'); |
| 429 | 445 | $path = $oLayoutModel->getUserLayoutImagePath($layout_srl); |
| 430 | - if(!is_dir($path)) FileHandler::makeDir($path); |
|
| 446 | + if(!is_dir($path)) { |
|
| 447 | + FileHandler::makeDir($path); |
|
| 448 | + } |
|
| 431 | 449 | |
| 432 | 450 | $filename = strtolower($source['name']); |
| 433 | 451 | if($filename != urlencode($filename)) |
@@ -437,10 +455,16 @@ discard block |
||
| 437 | 455 | } |
| 438 | 456 | |
| 439 | 457 | // Check uploaded file |
| 440 | - if(!checkUploadedFile($source['tmp_name'])) return false; |
|
| 458 | + if(!checkUploadedFile($source['tmp_name'])) { |
|
| 459 | + return false; |
|
| 460 | + } |
|
| 441 | 461 | |
| 442 | - if(file_exists($path .'/'. $filename)) @unlink($path . $filename); |
|
| 443 | - if(!move_uploaded_file($source['tmp_name'], $path . $filename )) return false; |
|
| 462 | + if(file_exists($path .'/'. $filename)) { |
|
| 463 | + @unlink($path . $filename); |
|
| 464 | + } |
|
| 465 | + if(!move_uploaded_file($source['tmp_name'], $path . $filename )) { |
|
| 466 | + return false; |
|
| 467 | + } |
|
| 444 | 468 | return true; |
| 445 | 469 | } |
| 446 | 470 | |
@@ -482,13 +506,17 @@ discard block |
||
| 482 | 506 | $oModuleModel = getModel('module'); |
| 483 | 507 | |
| 484 | 508 | $mid = Context::get('mid'); |
| 485 | - if(!$mid) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 509 | + if(!$mid) { |
|
| 510 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
| 511 | + } |
|
| 486 | 512 | |
| 487 | 513 | $site_module_info = Context::get('site_module_info'); |
| 488 | 514 | $columnList = array('layout_srl'); |
| 489 | 515 | $module_info = $oModuleModel->getModuleInfoByMid($mid, $site_module_info->site_srl, $columnList); |
| 490 | 516 | $layout_srl = $module_info->layout_srl; |
| 491 | - if(!$layout_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 517 | + if(!$layout_srl) { |
|
| 518 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
| 519 | + } |
|
| 492 | 520 | |
| 493 | 521 | $oLayoutModel = getModel('layout'); |
| 494 | 522 | |
@@ -497,8 +525,7 @@ discard block |
||
| 497 | 525 | if($temp =='Y') |
| 498 | 526 | { |
| 499 | 527 | $oLayoutModel->setUseUserLayoutTemp(); |
| 500 | - } |
|
| 501 | - else |
|
| 528 | + } else |
|
| 502 | 529 | { |
| 503 | 530 | // delete temp files |
| 504 | 531 | $this->deleteUserLayoutTempFile($layout_srl); |
@@ -524,7 +551,9 @@ discard block |
||
| 524 | 551 | $obj = Context::gets('type','align','column'); |
| 525 | 552 | $obj = (array)$obj; |
| 526 | 553 | $src = $oLayoutModel->getUserLayoutIniConfig($layout_srl); |
| 527 | - foreach($obj as $key => $val) $src[$key] = $val; |
|
| 554 | + foreach($obj as $key => $val) { |
|
| 555 | + $src[$key] = $val; |
|
| 556 | + } |
|
| 528 | 557 | $this->insertUserLayoutValue($layout_srl,$src); |
| 529 | 558 | } |
| 530 | 559 | |
@@ -591,7 +620,9 @@ discard block |
||
| 591 | 620 | function procLayoutAdminUserLayoutExport() |
| 592 | 621 | { |
| 593 | 622 | $layout_srl = Context::get('layout_srl'); |
| 594 | - if(!$layout_srl) return new BaseObject('-1','msg_invalid_request'); |
|
| 623 | + if(!$layout_srl) { |
|
| 624 | + return new BaseObject('-1','msg_invalid_request'); |
|
| 625 | + } |
|
| 595 | 626 | |
| 596 | 627 | require_once(_XE_PATH_.'libs/tar.class.php'); |
| 597 | 628 | $oLayoutModel = getModel('layout'); |
@@ -608,16 +639,19 @@ discard block |
||
| 608 | 639 | |
| 609 | 640 | foreach($file_list as $file) |
| 610 | 641 | { |
| 611 | - if(strncasecmp('images', $file, 6) === 0) continue; |
|
| 642 | + if(strncasecmp('images', $file, 6) === 0) { |
|
| 643 | + continue; |
|
| 644 | + } |
|
| 612 | 645 | |
| 613 | 646 | // replace path |
| 614 | 647 | $file = $target_path . $file; |
| 615 | 648 | $content = FileHandler::readFile($file); |
| 616 | 649 | $pattern = '/(http:\/\/[^ ]+)?(\.\/)?' . str_replace('/', '\/', (str_replace('./', '', $file_path))) . '/'; |
| 617 | - if(basename($file) == 'faceoff.css' || basename($file) == 'layout.css') |
|
| 618 | - $content = preg_replace($pattern, '../', $content); |
|
| 619 | - else |
|
| 620 | - $content = preg_replace($pattern, './', $content); |
|
| 650 | + if(basename($file) == 'faceoff.css' || basename($file) == 'layout.css') { |
|
| 651 | + $content = preg_replace($pattern, '../', $content); |
|
| 652 | + } else { |
|
| 653 | + $content = preg_replace($pattern, './', $content); |
|
| 654 | + } |
|
| 621 | 655 | |
| 622 | 656 | // replace ini config |
| 623 | 657 | foreach($ini_config as $key => $value) |
@@ -658,7 +692,9 @@ discard block |
||
| 658 | 692 | $tar = new tar(); |
| 659 | 693 | $user_layout_path = FileHandler::getRealPath($oLayoutModel->getUserLayoutPath(0)); |
| 660 | 694 | chdir($user_layout_path); |
| 661 | - foreach($file_list as $key => $file) $tar->addFile($file); |
|
| 695 | + foreach($file_list as $key => $file) { |
|
| 696 | + $tar->addFile($file); |
|
| 697 | + } |
|
| 662 | 698 | |
| 663 | 699 | $stream = $tar->toTarStream(); |
| 664 | 700 | $filename = 'faceoff_' . date('YmdHis') . '.tar'; |
@@ -689,18 +725,28 @@ discard block |
||
| 689 | 725 | return $this->stop('not supported'); |
| 690 | 726 | |
| 691 | 727 | // check upload |
| 692 | - if(!Context::isUploaded()) exit(); |
|
| 728 | + if(!Context::isUploaded()) { |
|
| 729 | + exit(); |
|
| 730 | + } |
|
| 693 | 731 | $file = Context::get('file'); |
| 694 | - if(!is_uploaded_file($file['tmp_name']) || !checkUploadedFile($file['tmp_name'])) exit(); |
|
| 732 | + if(!is_uploaded_file($file['tmp_name']) || !checkUploadedFile($file['tmp_name'])) { |
|
| 733 | + exit(); |
|
| 734 | + } |
|
| 695 | 735 | |
| 696 | - if(substr_compare($file['name'], '.tar', -4) !== 0) exit(); |
|
| 736 | + if(substr_compare($file['name'], '.tar', -4) !== 0) { |
|
| 737 | + exit(); |
|
| 738 | + } |
|
| 697 | 739 | |
| 698 | 740 | $layout_srl = Context::get('layout_srl'); |
| 699 | - if(!$layout_srl) exit(); |
|
| 741 | + if(!$layout_srl) { |
|
| 742 | + exit(); |
|
| 743 | + } |
|
| 700 | 744 | |
| 701 | 745 | $oLayoutModel = getModel('layout'); |
| 702 | 746 | $user_layout_path = FileHandler::getRealPath($oLayoutModel->getUserLayoutPath($layout_srl)); |
| 703 | - if(!move_uploaded_file($file['tmp_name'], $user_layout_path . 'faceoff.tar')) exit(); |
|
| 747 | + if(!move_uploaded_file($file['tmp_name'], $user_layout_path . 'faceoff.tar')) { |
|
| 748 | + exit(); |
|
| 749 | + } |
|
| 704 | 750 | |
| 705 | 751 | $this->importLayout($layout_srl, $user_layout_path.'faceoff.tar'); |
| 706 | 752 | |
@@ -744,9 +790,11 @@ discard block |
||
| 744 | 790 | |
| 745 | 791 | if($layout->extra_var_count) { |
| 746 | 792 | $reg = "/^.\/files\/attach\/images\/([0-9]+)\/(.*)/"; |
| 747 | - if($extra_vars) foreach($extra_vars as $key => $val) { |
|
| 793 | + if($extra_vars) { |
|
| 794 | + foreach($extra_vars as $key => $val) { |
|
| 748 | 795 | if($layout->extra_var->{$key}->type == 'image') { |
| 749 | 796 | if(!preg_match($reg,$val,$matches)) continue; |
| 797 | + } |
|
| 750 | 798 | $image_list[$key]->filename = $matches[2]; |
| 751 | 799 | $image_list[$key]->old_file = $val; |
| 752 | 800 | } |
@@ -761,7 +809,9 @@ discard block |
||
| 761 | 809 | $args->site_srl = (int)$layout->site_srl; |
| 762 | 810 | $args->layout = $layout->layout; |
| 763 | 811 | $args->layout_type = $layout->layout_type; |
| 764 | - if(!$args->layout_type) $args->layout_type = "P"; |
|
| 812 | + if(!$args->layout_type) { |
|
| 813 | + $args->layout_type = "P"; |
|
| 814 | + } |
|
| 765 | 815 | |
| 766 | 816 | $oDB = &DB::getInstance(); |
| 767 | 817 | $oDB->begin(); |
@@ -904,7 +954,9 @@ discard block |
||
| 904 | 954 | $tar = new tar(); |
| 905 | 955 | $tar->openTAR($source_file); |
| 906 | 956 | // If layout.ini file does not exist |
| 907 | - if(!$tar->getFile('layout.ini')) return; |
|
| 957 | + if(!$tar->getFile('layout.ini')) { |
|
| 958 | + return; |
|
| 959 | + } |
|
| 908 | 960 | |
| 909 | 961 | $replace_path = getNumberingPath($layout_srl,3); |
| 910 | 962 | foreach($tar->files as $key => $info) |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | /** |
| 134 | 134 | * Display list of pc layout instance |
| 135 | - * @return void|BaseObject (void : success, BaseObject : fail) |
|
| 135 | + * @return ModuleObject|null (void : success, BaseObject : fail) |
|
| 136 | 136 | */ |
| 137 | 137 | function dispLayoutAdminInstanceList() |
| 138 | 138 | { |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | /** |
| 162 | 162 | * Layout setting page |
| 163 | 163 | * Once select a layout with empty value in the DB, then adjust values |
| 164 | - * @return void|BaseObject (void : success, BaseObject : fail) |
|
| 164 | + * @return ModuleObject|null (void : success, BaseObject : fail) |
|
| 165 | 165 | */ |
| 166 | 166 | function dispLayoutAdminInsert() |
| 167 | 167 | { |
@@ -28,20 +28,20 @@ discard block |
||
| 28 | 28 | // Set a layout list |
| 29 | 29 | $oLayoutModel = getModel('layout'); |
| 30 | 30 | $layout_list = $oLayoutModel->getDownloadedLayoutList($type, true); |
| 31 | - if(!is_array($layout_list)) |
|
| 31 | + if (!is_array($layout_list)) |
|
| 32 | 32 | { |
| 33 | 33 | $layout_list = array(); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if($type == 'P') |
|
| 36 | + if ($type == 'P') |
|
| 37 | 37 | { |
| 38 | 38 | // get Theme layout |
| 39 | 39 | $oAdminModel = getAdminModel('admin'); |
| 40 | 40 | $themeList = $oAdminModel->getThemeList(); |
| 41 | 41 | $themeLayoutList = array(); |
| 42 | - foreach($themeList as $themeInfo) |
|
| 42 | + foreach ($themeList as $themeInfo) |
|
| 43 | 43 | { |
| 44 | - if(strpos($themeInfo->layout_info->name, '.') === false) continue; |
|
| 44 | + if (strpos($themeInfo->layout_info->name, '.') === false) continue; |
|
| 45 | 45 | $themeLayoutList[] = $oLayoutModel->getLayoutInfo($themeInfo->layout_info->name, null, 'P'); |
| 46 | 46 | } |
| 47 | 47 | $layout_list = array_merge($layout_list, $themeLayoutList); |
@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | //Security |
| 61 | 61 | $security = new Security(); |
| 62 | - $security->encodeHTML('layout_list..layout','layout_list..title'); |
|
| 62 | + $security->encodeHTML('layout_list..layout', 'layout_list..title'); |
|
| 63 | 63 | |
| 64 | - foreach($layout_list as $no => $layout_info) |
|
| 64 | + foreach ($layout_list as $no => $layout_info) |
|
| 65 | 65 | { |
| 66 | 66 | $layout_list[$no]->description = nl2br(trim($layout_info->description)); |
| 67 | 67 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | $type = Context::get('type'); |
| 78 | 78 | |
| 79 | - if(!in_array($type, array('P', 'M'))) $type = 'P'; |
|
| 79 | + if (!in_array($type, array('P', 'M'))) $type = 'P'; |
|
| 80 | 80 | |
| 81 | 81 | $oLayoutModel = getModel('layout'); |
| 82 | 82 | |
@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | $_layout_list = $oLayoutModel->getLayoutInstanceList(0, $type, null, $columnList); |
| 90 | 90 | |
| 91 | 91 | $layout_list = array(); |
| 92 | - foreach($_layout_list as $item) |
|
| 92 | + foreach ($_layout_list as $item) |
|
| 93 | 93 | { |
| 94 | - if(!$layout_list[$item->layout]) |
|
| 94 | + if (!$layout_list[$item->layout]) |
|
| 95 | 95 | { |
| 96 | 96 | $layout_list[$item->layout] = array(); |
| 97 | 97 | $layout_info = $oLayoutModel->getLayoutInfo($item->layout, null, $type); |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $aTitle = strtolower($a['title']); |
| 123 | 123 | $bTitle = strtolower($b['title']); |
| 124 | 124 | |
| 125 | - if($aTitle == $bTitle) |
|
| 125 | + if ($aTitle == $bTitle) |
|
| 126 | 126 | { |
| 127 | 127 | return 0; |
| 128 | 128 | } |
@@ -139,12 +139,12 @@ discard block |
||
| 139 | 139 | $type = Context::get('type'); |
| 140 | 140 | $layout = Context::get('layout'); |
| 141 | 141 | |
| 142 | - if(!in_array($type, array('P', 'M'))) $type = 'P'; |
|
| 143 | - if(!$layout) return $this->stop('msg_invalid_request'); |
|
| 142 | + if (!in_array($type, array('P', 'M'))) $type = 'P'; |
|
| 143 | + if (!$layout) return $this->stop('msg_invalid_request'); |
|
| 144 | 144 | |
| 145 | 145 | $oLayoutModel = getModel('layout'); |
| 146 | 146 | $layout_info = $oLayoutModel->getLayoutInfo($layout, null, $type); |
| 147 | - if(!$layout_info) return $this->stop('msg_invalid_request'); |
|
| 147 | + if (!$layout_info) return $this->stop('msg_invalid_request'); |
|
| 148 | 148 | |
| 149 | 149 | Context::set('layout_info', $layout_info); |
| 150 | 150 | |
@@ -167,18 +167,18 @@ discard block |
||
| 167 | 167 | { |
| 168 | 168 | $oModel = getModel('layout'); |
| 169 | 169 | $type = Context::get('type'); |
| 170 | - if(!in_array($type, array('P', 'M'))) $type = 'P'; |
|
| 170 | + if (!in_array($type, array('P', 'M'))) $type = 'P'; |
|
| 171 | 171 | |
| 172 | 172 | //Security |
| 173 | 173 | $security = new Security(); |
| 174 | - $security->encodeHTML('layout_list..layout','layout_list..title'); |
|
| 174 | + $security->encodeHTML('layout_list..layout', 'layout_list..title'); |
|
| 175 | 175 | |
| 176 | 176 | // Get layout info |
| 177 | 177 | $layout = Context::get('layout'); |
| 178 | - if($layout == 'faceoff') return $this->stop('not supported'); |
|
| 178 | + if ($layout == 'faceoff') return $this->stop('not supported'); |
|
| 179 | 179 | |
| 180 | 180 | $layout_info = $oModel->getLayoutInfo($layout, null, $type); |
| 181 | - if(!$layout_info) return $this->stop('msg_invalid_request'); |
|
| 181 | + if (!$layout_info) return $this->stop('msg_invalid_request'); |
|
| 182 | 182 | |
| 183 | 183 | // get Menu list |
| 184 | 184 | $oMenuAdminModel = getAdminModel('menu'); |
@@ -192,10 +192,10 @@ discard block |
||
| 192 | 192 | $layout_info = $security->encodeHTML('.', 'author..', 'extra_var..', 'extra_var....'); |
| 193 | 193 | |
| 194 | 194 | $layout_info->description = nl2br(trim($layout_info->description)); |
| 195 | - if(!is_object($layout_info->extra_var)) $layout_info->extra_var = new StdClass(); |
|
| 196 | - foreach($layout_info->extra_var as $var_name => $val) |
|
| 195 | + if (!is_object($layout_info->extra_var)) $layout_info->extra_var = new StdClass(); |
|
| 196 | + foreach ($layout_info->extra_var as $var_name => $val) |
|
| 197 | 197 | { |
| 198 | - if(isset($layout_info->{$var_name}->description)) |
|
| 198 | + if (isset($layout_info->{$var_name}->description)) |
|
| 199 | 199 | $layout_info->{$var_name}->description = nl2br(trim($val->description)); |
| 200 | 200 | } |
| 201 | 201 | Context::set('selected_layout', $layout_info); |
@@ -234,24 +234,24 @@ discard block |
||
| 234 | 234 | $oLayoutModel = getModel('layout'); |
| 235 | 235 | $layout_info = $oLayoutModel->getLayout($layout_srl); |
| 236 | 236 | // Error appears if there is no layout information is registered |
| 237 | - if(!$layout_info) return $this->dispLayoutAdminInstalledList(); |
|
| 237 | + if (!$layout_info) return $this->dispLayoutAdminInstalledList(); |
|
| 238 | 238 | |
| 239 | 239 | // Get Layout Code |
| 240 | - if($oLayoutModel->useDefaultLayout($layout_info->layout_srl)) |
|
| 240 | + if ($oLayoutModel->useDefaultLayout($layout_info->layout_srl)) |
|
| 241 | 241 | { |
| 242 | - $layout_file = $oLayoutModel->getDefaultLayoutHtml($layout_info->layout); |
|
| 243 | - $layout_css_file = $oLayoutModel->getDefaultLayoutCss($layout_info->layout); |
|
| 242 | + $layout_file = $oLayoutModel->getDefaultLayoutHtml($layout_info->layout); |
|
| 243 | + $layout_css_file = $oLayoutModel->getDefaultLayoutCss($layout_info->layout); |
|
| 244 | 244 | } |
| 245 | 245 | else |
| 246 | 246 | { |
| 247 | 247 | $layout_file = $oLayoutModel->getUserLayoutHtml($layout_info->layout_srl); |
| 248 | 248 | $layout_css_file = $oLayoutModel->getUserLayoutCss($layout_info->layout_srl); |
| 249 | 249 | |
| 250 | - if(!file_exists($layout_file)) $layout_file = $layout_info->path . 'layout.html'; |
|
| 251 | - if(!file_exists($layout_css_file)) $layout_css_file = $layout_info->path . 'layout.css'; |
|
| 250 | + if (!file_exists($layout_file)) $layout_file = $layout_info->path.'layout.html'; |
|
| 251 | + if (!file_exists($layout_css_file)) $layout_css_file = $layout_info->path.'layout.css'; |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - if(file_exists($layout_css_file)) |
|
| 254 | + if (file_exists($layout_css_file)) |
|
| 255 | 255 | { |
| 256 | 256 | $layout_code_css = FileHandler::readFile($layout_css_file); |
| 257 | 257 | Context::set('layout_code_css', $layout_code_css); |
@@ -295,30 +295,30 @@ discard block |
||
| 295 | 295 | $layout_srl = Context::get('layout_srl'); |
| 296 | 296 | $code = Context::get('code'); |
| 297 | 297 | $code_css = Context::get('code_css'); |
| 298 | - if(!$layout_srl || !$code) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 298 | + if (!$layout_srl || !$code) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 299 | 299 | // Get the layout information |
| 300 | 300 | $oLayoutModel = getModel('layout'); |
| 301 | 301 | $layout_info = $oLayoutModel->getLayout($layout_srl); |
| 302 | - if(!$layout_info) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 302 | + if (!$layout_info) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 303 | 303 | // Separately handle the layout if its type is faceoff |
| 304 | - if($layout_info && $layout_info->type == 'faceoff') $oLayoutModel->doActivateFaceOff($layout_info); |
|
| 304 | + if ($layout_info && $layout_info->type == 'faceoff') $oLayoutModel->doActivateFaceOff($layout_info); |
|
| 305 | 305 | // Apply CSS directly |
| 306 | 306 | Context::addHtmlHeader("<style type=\"text/css\" charset=\"UTF-8\">".$code_css."</style>"); |
| 307 | 307 | // Set names and values of extra_vars to $layout_info |
| 308 | - if($layout_info->extra_var_count) |
|
| 308 | + if ($layout_info->extra_var_count) |
|
| 309 | 309 | { |
| 310 | - foreach($layout_info->extra_var as $var_id => $val) |
|
| 310 | + foreach ($layout_info->extra_var as $var_id => $val) |
|
| 311 | 311 | { |
| 312 | 312 | $layout_info->{$var_id} = $val->value; |
| 313 | 313 | } |
| 314 | 314 | } |
| 315 | 315 | // menu in layout information becomes an argument for Context:: set |
| 316 | - if($layout_info->menu_count) |
|
| 316 | + if ($layout_info->menu_count) |
|
| 317 | 317 | { |
| 318 | - foreach($layout_info->menu as $menu_id => $menu) |
|
| 318 | + foreach ($layout_info->menu as $menu_id => $menu) |
|
| 319 | 319 | { |
| 320 | 320 | $menu->php_file = FileHandler::getRealPath($menu->php_file); |
| 321 | - if(FileHandler::exists($menu->php_file)) include($menu->php_file); |
|
| 321 | + if (FileHandler::exists($menu->php_file)) include($menu->php_file); |
|
| 322 | 322 | Context::set($menu_id, $menu); |
| 323 | 323 | } |
| 324 | 324 | } |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | $layout_file = 'layout'; |
| 337 | 337 | |
| 338 | 338 | $layout_tpl = $oTemplate->compile($layout_path, $layout_file, $edited_layout_file); |
| 339 | - Context::set('layout','none'); |
|
| 339 | + Context::set('layout', 'none'); |
|
| 340 | 340 | // Convert widgets and others |
| 341 | 341 | $oContext = &Context::getInstance(); |
| 342 | 342 | Context::set('layout_tpl', $layout_tpl); |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | // Remove the remaining tmp files because of temporarily saving |
| 360 | 360 | // This part needs to be modified |
| 361 | 361 | $delete_tmp = Context::get('delete_tmp'); |
| 362 | - if($delete_tmp =='Y') |
|
| 362 | + if ($delete_tmp == 'Y') |
|
| 363 | 363 | { |
| 364 | 364 | $oLayoutAdminController = getAdminController('layout'); |
| 365 | 365 | $oLayoutAdminController->deleteUserLayoutTempFile($layout_srl); |
@@ -373,24 +373,24 @@ discard block |
||
| 373 | 373 | |
| 374 | 374 | $css = FileHandler::readFile($faceoffcss); |
| 375 | 375 | $match = null; |
| 376 | - preg_match_all('/([^\{]+)\{([^\}]*)\}/is',$css,$match); |
|
| 377 | - for($i=0,$c=count($match[1]);$i<$c;$i++) |
|
| 376 | + preg_match_all('/([^\{]+)\{([^\}]*)\}/is', $css, $match); |
|
| 377 | + for ($i = 0, $c = count($match[1]); $i < $c; $i++) |
|
| 378 | 378 | { |
| 379 | 379 | $name = trim($match[1][$i]); |
| 380 | 380 | $css = trim($match[2][$i]); |
| 381 | - if(!$css) continue; |
|
| 382 | - $css = str_replace('./images/',Context::getRequestUri().$oLayoutModel->getUserLayoutImagePath($layout_srl),$css); |
|
| 383 | - $style[] .= sprintf('"%s":"%s"',$name,$css); |
|
| 381 | + if (!$css) continue; |
|
| 382 | + $css = str_replace('./images/', Context::getRequestUri().$oLayoutModel->getUserLayoutImagePath($layout_srl), $css); |
|
| 383 | + $style[] .= sprintf('"%s":"%s"', $name, $css); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - if(count($style)) |
|
| 386 | + if (count($style)) |
|
| 387 | 387 | { |
| 388 | - $script = '<script type="text/javascript"> var faceOffStyle = {'.implode(',',$style).'}; </script>'; |
|
| 388 | + $script = '<script type="text/javascript"> var faceOffStyle = {'.implode(',', $style).'}; </script>'; |
|
| 389 | 389 | Context::addHtmlHeader($script); |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | $oTemplate = &TemplateHandler::getInstance(); |
| 393 | - Context::set('content', $oTemplate->compile($this->module_path.'tpl','about_faceoff')); |
|
| 393 | + Context::set('content', $oTemplate->compile($this->module_path.'tpl', 'about_faceoff')); |
|
| 394 | 394 | // Change widget codes in Javascript mode |
| 395 | 395 | $oWidgetController = getController('widget'); |
| 396 | 396 | $oWidgetController->setWidgetCodeInJavascriptMode(); |
@@ -41,7 +41,9 @@ discard block |
||
| 41 | 41 | $themeLayoutList = array(); |
| 42 | 42 | foreach($themeList as $themeInfo) |
| 43 | 43 | { |
| 44 | - if(strpos($themeInfo->layout_info->name, '.') === false) continue; |
|
| 44 | + if(strpos($themeInfo->layout_info->name, '.') === false) { |
|
| 45 | + continue; |
|
| 46 | + } |
|
| 45 | 47 | $themeLayoutList[] = $oLayoutModel->getLayoutInfo($themeInfo->layout_info->name, null, 'P'); |
| 46 | 48 | } |
| 47 | 49 | $layout_list = array_merge($layout_list, $themeLayoutList); |
@@ -76,7 +78,9 @@ discard block |
||
| 76 | 78 | { |
| 77 | 79 | $type = Context::get('type'); |
| 78 | 80 | |
| 79 | - if(!in_array($type, array('P', 'M'))) $type = 'P'; |
|
| 81 | + if(!in_array($type, array('P', 'M'))) { |
|
| 82 | + $type = 'P'; |
|
| 83 | + } |
|
| 80 | 84 | |
| 81 | 85 | $oLayoutModel = getModel('layout'); |
| 82 | 86 | |
@@ -139,12 +143,18 @@ discard block |
||
| 139 | 143 | $type = Context::get('type'); |
| 140 | 144 | $layout = Context::get('layout'); |
| 141 | 145 | |
| 142 | - if(!in_array($type, array('P', 'M'))) $type = 'P'; |
|
| 143 | - if(!$layout) return $this->stop('msg_invalid_request'); |
|
| 146 | + if(!in_array($type, array('P', 'M'))) { |
|
| 147 | + $type = 'P'; |
|
| 148 | + } |
|
| 149 | + if(!$layout) { |
|
| 150 | + return $this->stop('msg_invalid_request'); |
|
| 151 | + } |
|
| 144 | 152 | |
| 145 | 153 | $oLayoutModel = getModel('layout'); |
| 146 | 154 | $layout_info = $oLayoutModel->getLayoutInfo($layout, null, $type); |
| 147 | - if(!$layout_info) return $this->stop('msg_invalid_request'); |
|
| 155 | + if(!$layout_info) { |
|
| 156 | + return $this->stop('msg_invalid_request'); |
|
| 157 | + } |
|
| 148 | 158 | |
| 149 | 159 | Context::set('layout_info', $layout_info); |
| 150 | 160 | |
@@ -167,7 +177,9 @@ discard block |
||
| 167 | 177 | { |
| 168 | 178 | $oModel = getModel('layout'); |
| 169 | 179 | $type = Context::get('type'); |
| 170 | - if(!in_array($type, array('P', 'M'))) $type = 'P'; |
|
| 180 | + if(!in_array($type, array('P', 'M'))) { |
|
| 181 | + $type = 'P'; |
|
| 182 | + } |
|
| 171 | 183 | |
| 172 | 184 | //Security |
| 173 | 185 | $security = new Security(); |
@@ -175,10 +187,14 @@ discard block |
||
| 175 | 187 | |
| 176 | 188 | // Get layout info |
| 177 | 189 | $layout = Context::get('layout'); |
| 178 | - if($layout == 'faceoff') return $this->stop('not supported'); |
|
| 190 | + if($layout == 'faceoff') { |
|
| 191 | + return $this->stop('not supported'); |
|
| 192 | + } |
|
| 179 | 193 | |
| 180 | 194 | $layout_info = $oModel->getLayoutInfo($layout, null, $type); |
| 181 | - if(!$layout_info) return $this->stop('msg_invalid_request'); |
|
| 195 | + if(!$layout_info) { |
|
| 196 | + return $this->stop('msg_invalid_request'); |
|
| 197 | + } |
|
| 182 | 198 | |
| 183 | 199 | // get Menu list |
| 184 | 200 | $oMenuAdminModel = getAdminModel('menu'); |
@@ -192,11 +208,14 @@ discard block |
||
| 192 | 208 | $layout_info = $security->encodeHTML('.', 'author..', 'extra_var..', 'extra_var....'); |
| 193 | 209 | |
| 194 | 210 | $layout_info->description = nl2br(trim($layout_info->description)); |
| 195 | - if(!is_object($layout_info->extra_var)) $layout_info->extra_var = new StdClass(); |
|
| 211 | + if(!is_object($layout_info->extra_var)) { |
|
| 212 | + $layout_info->extra_var = new StdClass(); |
|
| 213 | + } |
|
| 196 | 214 | foreach($layout_info->extra_var as $var_name => $val) |
| 197 | 215 | { |
| 198 | - if(isset($layout_info->{$var_name}->description)) |
|
| 199 | - $layout_info->{$var_name}->description = nl2br(trim($val->description)); |
|
| 216 | + if(isset($layout_info->{$var_name}->description)) { |
|
| 217 | + $layout_info->{$var_name}->description = nl2br(trim($val->description)); |
|
| 218 | + } |
|
| 200 | 219 | } |
| 201 | 220 | Context::set('selected_layout', $layout_info); |
| 202 | 221 | |
@@ -234,21 +253,26 @@ discard block |
||
| 234 | 253 | $oLayoutModel = getModel('layout'); |
| 235 | 254 | $layout_info = $oLayoutModel->getLayout($layout_srl); |
| 236 | 255 | // Error appears if there is no layout information is registered |
| 237 | - if(!$layout_info) return $this->dispLayoutAdminInstalledList(); |
|
| 256 | + if(!$layout_info) { |
|
| 257 | + return $this->dispLayoutAdminInstalledList(); |
|
| 258 | + } |
|
| 238 | 259 | |
| 239 | 260 | // Get Layout Code |
| 240 | 261 | if($oLayoutModel->useDefaultLayout($layout_info->layout_srl)) |
| 241 | 262 | { |
| 242 | 263 | $layout_file = $oLayoutModel->getDefaultLayoutHtml($layout_info->layout); |
| 243 | 264 | $layout_css_file = $oLayoutModel->getDefaultLayoutCss($layout_info->layout); |
| 244 | - } |
|
| 245 | - else |
|
| 265 | + } else |
|
| 246 | 266 | { |
| 247 | 267 | $layout_file = $oLayoutModel->getUserLayoutHtml($layout_info->layout_srl); |
| 248 | 268 | $layout_css_file = $oLayoutModel->getUserLayoutCss($layout_info->layout_srl); |
| 249 | 269 | |
| 250 | - if(!file_exists($layout_file)) $layout_file = $layout_info->path . 'layout.html'; |
|
| 251 | - if(!file_exists($layout_css_file)) $layout_css_file = $layout_info->path . 'layout.css'; |
|
| 270 | + if(!file_exists($layout_file)) { |
|
| 271 | + $layout_file = $layout_info->path . 'layout.html'; |
|
| 272 | + } |
|
| 273 | + if(!file_exists($layout_css_file)) { |
|
| 274 | + $layout_css_file = $layout_info->path . 'layout.css'; |
|
| 275 | + } |
|
| 252 | 276 | } |
| 253 | 277 | |
| 254 | 278 | if(file_exists($layout_css_file)) |
@@ -295,13 +319,19 @@ discard block |
||
| 295 | 319 | $layout_srl = Context::get('layout_srl'); |
| 296 | 320 | $code = Context::get('code'); |
| 297 | 321 | $code_css = Context::get('code_css'); |
| 298 | - if(!$layout_srl || !$code) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 322 | + if(!$layout_srl || !$code) { |
|
| 323 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
| 324 | + } |
|
| 299 | 325 | // Get the layout information |
| 300 | 326 | $oLayoutModel = getModel('layout'); |
| 301 | 327 | $layout_info = $oLayoutModel->getLayout($layout_srl); |
| 302 | - if(!$layout_info) return new BaseObject(-1, 'msg_invalid_request'); |
|
| 328 | + if(!$layout_info) { |
|
| 329 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
| 330 | + } |
|
| 303 | 331 | // Separately handle the layout if its type is faceoff |
| 304 | - if($layout_info && $layout_info->type == 'faceoff') $oLayoutModel->doActivateFaceOff($layout_info); |
|
| 332 | + if($layout_info && $layout_info->type == 'faceoff') { |
|
| 333 | + $oLayoutModel->doActivateFaceOff($layout_info); |
|
| 334 | + } |
|
| 305 | 335 | // Apply CSS directly |
| 306 | 336 | Context::addHtmlHeader("<style type=\"text/css\" charset=\"UTF-8\">".$code_css."</style>"); |
| 307 | 337 | // Set names and values of extra_vars to $layout_info |
@@ -318,7 +348,9 @@ discard block |
||
| 318 | 348 | foreach($layout_info->menu as $menu_id => $menu) |
| 319 | 349 | { |
| 320 | 350 | $menu->php_file = FileHandler::getRealPath($menu->php_file); |
| 321 | - if(FileHandler::exists($menu->php_file)) include($menu->php_file); |
|
| 351 | + if(FileHandler::exists($menu->php_file)) { |
|
| 352 | + include($menu->php_file); |
|
| 353 | + } |
|
| 322 | 354 | Context::set($menu_id, $menu); |
| 323 | 355 | } |
| 324 | 356 | } |
@@ -378,7 +410,9 @@ discard block |
||
| 378 | 410 | { |
| 379 | 411 | $name = trim($match[1][$i]); |
| 380 | 412 | $css = trim($match[2][$i]); |
| 381 | - if(!$css) continue; |
|
| 413 | + if(!$css) { |
|
| 414 | + continue; |
|
| 415 | + } |
|
| 382 | 416 | $css = str_replace('./images/',Context::getRequestUri().$oLayoutModel->getUserLayoutImagePath($layout_srl),$css); |
| 383 | 417 | $style[] .= sprintf('"%s":"%s"',$name,$css); |
| 384 | 418 | } |