@@ -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,7 +869,7 @@ 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 |
|
| 872 | + * @param string $originObject |
|
| 873 | 873 | * @return object |
| 874 | 874 | */ |
| 875 | 875 | function restoreTrash($originObject) |
@@ -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 Object(-1,'msg_invalid_request'); |
|
| 565 | + if (!$module_srl || !$name || !$eid) return new Object(-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 Object(-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 Object(-1,'msg_invalid_request'); |
|
| 603 | + if (!$module_srl || !$var_idx) return new Object(-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 Object(-1,'msg_invalid_request'); |
|
| 622 | + if (!$type || !$module_srl || !$var_idx) return new Object(-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 Object(-1,'msg_invalid_request'); |
|
| 626 | + if (!$module_info->module_srl) return new Object(-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 Object(-1,'msg_invalid_request'); |
|
| 630 | + if (!$extra_keys[$var_idx]) return new Object(-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 Object(-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 Object(-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 Object(-1, $output->getMessage()); |
|
| 887 | + if (!$output->toBool()) return new Object(-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); |