@@ -279,6 +279,9 @@ discard block |
||
279 | 279 | $this->setRedirectUrl($returnUrl); |
280 | 280 | } |
281 | 281 | |
282 | + /** |
|
283 | + * @param string $message_content |
|
284 | + */ |
|
282 | 285 | private function _sendMessageForComment($message_content, $comment_srl_list) |
283 | 286 | { |
284 | 287 | $oCommunicationController = getController('communication'); |
@@ -308,6 +311,9 @@ discard block |
||
308 | 311 | |
309 | 312 | /** |
310 | 313 | * comment move to trash |
314 | + * @param ModuleObject $oCommentController |
|
315 | + * @param DB $oDB |
|
316 | + * @param string $message_content |
|
311 | 317 | * @return void|object |
312 | 318 | */ |
313 | 319 | function _moveCommentToTrash($commentSrlList, &$oCommentController, &$oDB, $message_content = NULL) |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | |
134 | 134 | //mail to author of thread - START |
135 | 135 | /** |
136 | - * @todo Removed code send email to document author. |
|
137 | - */ |
|
136 | + * @todo Removed code send email to document author. |
|
137 | + */ |
|
138 | 138 | /* |
139 | 139 | if($document_author_email != $comment->email_address && $logged_info->email_address != $document_author_email) |
140 | 140 | { |
@@ -341,10 +341,10 @@ discard block |
||
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
344 | - * @fn procCommentAdminMoveToTrash |
|
345 | - * @brief move a comment to trash |
|
346 | - * @see commentModel::getCommentMenu |
|
347 | - */ |
|
344 | + * @fn procCommentAdminMoveToTrash |
|
345 | + * @brief move a comment to trash |
|
346 | + * @see commentModel::getCommentMenu |
|
347 | + */ |
|
348 | 348 | function procCommentAdminMoveToTrash() |
349 | 349 | { |
350 | 350 | $oDB = DB::getInstance(); |
@@ -32,8 +32,7 @@ discard block |
||
32 | 32 | if(!is_array($cart)) |
33 | 33 | { |
34 | 34 | $comment_srl_list = explode('|@|', $cart); |
35 | - } |
|
36 | - else |
|
35 | + } else |
|
37 | 36 | { |
38 | 37 | $comment_srl_list = $cart; |
39 | 38 | } |
@@ -61,8 +60,7 @@ discard block |
||
61 | 60 | if(!is_array($cart)) |
62 | 61 | { |
63 | 62 | $comment_srl_list = explode('|@|', $cart); |
64 | - } |
|
65 | - else |
|
63 | + } else |
|
66 | 64 | { |
67 | 65 | $comment_srl_list = $cart; |
68 | 66 | } |
@@ -74,8 +72,7 @@ discard block |
||
74 | 72 | if(!$output->toBool()) |
75 | 73 | { |
76 | 74 | return $output; |
77 | - } |
|
78 | - else |
|
75 | + } else |
|
79 | 76 | { |
80 | 77 | //update comment count for document |
81 | 78 | $updated_documents_arr = array(); |
@@ -202,8 +199,7 @@ discard block |
||
202 | 199 | if(!is_array($cart)) |
203 | 200 | { |
204 | 201 | $comment_srl_list = explode('|@|', $cart); |
205 | - } |
|
206 | - else |
|
202 | + } else |
|
207 | 203 | { |
208 | 204 | $comment_srl_list = $cart; |
209 | 205 | } |
@@ -262,8 +258,7 @@ discard block |
||
262 | 258 | if($isTrash == 'true') |
263 | 259 | { |
264 | 260 | $msgCode = 'success_trashed'; |
265 | - } |
|
266 | - else |
|
261 | + } else |
|
267 | 262 | { |
268 | 263 | $msgCode = 'success_deleted'; |
269 | 264 | } |
@@ -355,7 +350,9 @@ discard block |
||
355 | 350 | $oCommentController = getController('comment'); |
356 | 351 | $oComment = $oCommentModel->getComment($comment_srl, false); |
357 | 352 | |
358 | - if(!$oComment->isGranted()) return $this->stop('msg_not_permitted'); |
|
353 | + if(!$oComment->isGranted()) { |
|
354 | + return $this->stop('msg_not_permitted'); |
|
355 | + } |
|
359 | 356 | |
360 | 357 | $message_content = ""; |
361 | 358 | $this->_moveCommentToTrash(array($comment_srl), $oCommentController, $oDB, $message_content); |
@@ -410,8 +407,7 @@ discard block |
||
410 | 407 | if($_SESSION['comment_management'][$key]) |
411 | 408 | { |
412 | 409 | unset($_SESSION['comment_management'][$key]); |
413 | - } |
|
414 | - else |
|
410 | + } else |
|
415 | 411 | { |
416 | 412 | $_SESSION['comment_management'][$key] = TRUE; |
417 | 413 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | // Error display if none is selected |
31 | 31 | $cart = Context::get('cart'); |
32 | - if(!is_array($cart)) |
|
32 | + if (!is_array($cart)) |
|
33 | 33 | { |
34 | 34 | $comment_srl_list = explode('|@|', $cart); |
35 | 35 | } |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | |
55 | 55 | // Error display if none is selected |
56 | 56 | $cart = Context::get('cart'); |
57 | - if(!$cart) |
|
57 | + if (!$cart) |
|
58 | 58 | { |
59 | 59 | return $this->stop('msg_cart_is_null'); |
60 | 60 | } |
61 | - if(!is_array($cart)) |
|
61 | + if (!is_array($cart)) |
|
62 | 62 | { |
63 | 63 | $comment_srl_list = explode('|@|', $cart); |
64 | 64 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $args->status = $will_publish; |
72 | 72 | $args->comment_srls_list = $comment_srl_list; |
73 | 73 | $output = executeQuery('comment.updatePublishedStatus', $args); |
74 | - if(!$output->toBool()) |
|
74 | + if (!$output->toBool()) |
|
75 | 75 | { |
76 | 76 | return $output; |
77 | 77 | } |
@@ -90,16 +90,16 @@ discard block |
||
90 | 90 | //$oMemberModule = getModel("member"); |
91 | 91 | //$logged_info = $oMemberModule->getMemberInfoByMemberSrl($logged_member_srl); |
92 | 92 | $new_status = ($will_publish) ? "published" : "unpublished"; |
93 | - foreach($comment_srl_list as $comment_srl) |
|
93 | + foreach ($comment_srl_list as $comment_srl) |
|
94 | 94 | { |
95 | 95 | // check if comment already exists |
96 | 96 | $comment = $oCommentModel->getComment($comment_srl); |
97 | - if($comment->comment_srl != $comment_srl) |
|
97 | + if ($comment->comment_srl != $comment_srl) |
|
98 | 98 | { |
99 | 99 | return new BaseObject(-1, 'msg_invalid_request'); |
100 | 100 | } |
101 | 101 | $document_srl = $comment->document_srl; |
102 | - if(!in_array($document_srl, $updated_documents_arr)) |
|
102 | + if (!in_array($document_srl, $updated_documents_arr)) |
|
103 | 103 | { |
104 | 104 | $updated_documents_arr[] = $document_srl; |
105 | 105 | // update the number of comments |
@@ -117,13 +117,13 @@ discard block |
||
117 | 117 | // send email to comment's author, all admins and thread(document) subscribers - START |
118 | 118 | // ------------------------------------------------------- |
119 | 119 | $oMail = new Mail(); |
120 | - $mail_title = "[XE - " . $module_info->mid . "] comment(s) status changed to " . $new_status . " on document: \"" . $oDocument->getTitleText() . "\""; |
|
120 | + $mail_title = "[XE - ".$module_info->mid."] comment(s) status changed to ".$new_status." on document: \"".$oDocument->getTitleText()."\""; |
|
121 | 121 | $oMail->setTitle($mail_title); |
122 | 122 | $mail_content = " |
123 | - The comment #" . $comment_srl . " on document \"" . $oDocument->getTitleText() . "\" has been " . $new_status . " by admin of <strong><i>" . strtoupper($module_info->mid) . "</i></strong> module. |
|
123 | + The comment #" . $comment_srl." on document \"".$oDocument->getTitleText()."\" has been ".$new_status." by admin of <strong><i>".strtoupper($module_info->mid)."</i></strong> module. |
|
124 | 124 | <br /> |
125 | 125 | <br />Comment content: |
126 | - " . $comment->content . " |
|
126 | + " . $comment->content." |
|
127 | 127 | <br /> |
128 | 128 | "; |
129 | 129 | $oMail->setContent($mail_content); |
@@ -145,17 +145,17 @@ discard block |
||
145 | 145 | */ |
146 | 146 | //mail to author of thread - STOP |
147 | 147 | //mail to all emails set for administrators - START |
148 | - if($module_info->admin_mail) |
|
148 | + if ($module_info->admin_mail) |
|
149 | 149 | { |
150 | 150 | $target_mail = explode(',', $module_info->admin_mail); |
151 | - for($i = 0; $i < count($target_mail); $i++) |
|
151 | + for ($i = 0; $i < count($target_mail); $i++) |
|
152 | 152 | { |
153 | 153 | $email_address = trim($target_mail[$i]); |
154 | - if(!$email_address) |
|
154 | + if (!$email_address) |
|
155 | 155 | { |
156 | 156 | continue; |
157 | 157 | } |
158 | - if($author_email != $email_address) |
|
158 | + if ($author_email != $email_address) |
|
159 | 159 | { |
160 | 160 | $oMail->setReceiptor($email_address, $email_address); |
161 | 161 | $oMail->send(); |
@@ -173,12 +173,12 @@ discard block |
||
173 | 173 | |
174 | 174 | // for message send - start |
175 | 175 | $message_content = Context::get('message_content'); |
176 | - if($message_content) |
|
176 | + if ($message_content) |
|
177 | 177 | { |
178 | 178 | $message_content = nl2br($message_content); |
179 | 179 | } |
180 | 180 | |
181 | - if($message_content) |
|
181 | + if ($message_content) |
|
182 | 182 | { |
183 | 183 | $this->_sendMessageForComment($message_content, $comment_srl_list); |
184 | 184 | } |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | |
196 | 196 | // Error display if none is selected |
197 | 197 | $cart = Context::get('cart'); |
198 | - if(!$cart) |
|
198 | + if (!$cart) |
|
199 | 199 | { |
200 | 200 | return $this->stop('msg_cart_is_null'); |
201 | 201 | } |
202 | - if(!is_array($cart)) |
|
202 | + if (!is_array($cart)) |
|
203 | 203 | { |
204 | 204 | $comment_srl_list = explode('|@|', $cart); |
205 | 205 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $comment_srl_list = $cart; |
209 | 209 | } |
210 | 210 | $comment_count = count($comment_srl_list); |
211 | - if(!$comment_count) |
|
211 | + if (!$comment_count) |
|
212 | 212 | { |
213 | 213 | return $this->stop('msg_cart_is_null'); |
214 | 214 | } |
@@ -220,34 +220,34 @@ discard block |
||
220 | 220 | |
221 | 221 | // for message send - start |
222 | 222 | $message_content = Context::get('message_content'); |
223 | - if($message_content) |
|
223 | + if ($message_content) |
|
224 | 224 | { |
225 | 225 | $message_content = nl2br($message_content); |
226 | 226 | } |
227 | 227 | |
228 | - if($message_content) |
|
228 | + if ($message_content) |
|
229 | 229 | { |
230 | 230 | $this->_sendMessageForComment($message_content, $comment_srl_list); |
231 | 231 | } |
232 | 232 | // for message send - end |
233 | 233 | // comment into trash |
234 | - if($isTrash == 'true') |
|
234 | + if ($isTrash == 'true') |
|
235 | 235 | { |
236 | 236 | $this->_moveCommentToTrash($comment_srl_list, $oCommentController, $oDB, $message_content); |
237 | 237 | } |
238 | 238 | |
239 | 239 | $deleted_count = 0; |
240 | 240 | // Delete the comment posting |
241 | - for($i = 0; $i < $comment_count; $i++) |
|
241 | + for ($i = 0; $i < $comment_count; $i++) |
|
242 | 242 | { |
243 | 243 | $comment_srl = trim($comment_srl_list[$i]); |
244 | - if(!$comment_srl) |
|
244 | + if (!$comment_srl) |
|
245 | 245 | { |
246 | 246 | continue; |
247 | 247 | } |
248 | 248 | |
249 | 249 | $output = $oCommentController->deleteComment($comment_srl, TRUE, $isTrash); |
250 | - if(!$output->toBool()) |
|
250 | + if (!$output->toBool()) |
|
251 | 251 | { |
252 | 252 | $oDB->rollback(); |
253 | 253 | return $output; |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | $oDB->commit(); |
260 | 260 | |
261 | 261 | $msgCode = ''; |
262 | - if($isTrash == 'true') |
|
262 | + if ($isTrash == 'true') |
|
263 | 263 | { |
264 | 264 | $msgCode = 'success_trashed'; |
265 | 265 | } |
@@ -290,12 +290,12 @@ discard block |
||
290 | 290 | $sender_member_srl = $logged_info->member_srl; |
291 | 291 | |
292 | 292 | $comment_count = count($comment_srl_list); |
293 | - for($i = 0; $i < $comment_count; $i++) |
|
293 | + for ($i = 0; $i < $comment_count; $i++) |
|
294 | 294 | { |
295 | 295 | $comment_srl = $comment_srl_list[$i]; |
296 | 296 | $oComment = $oCommentModel->getComment($comment_srl, TRUE); |
297 | 297 | |
298 | - if(!$oComment->get('member_srl') || $oComment->get('member_srl') == $sender_member_srl) |
|
298 | + if (!$oComment->get('member_srl') || $oComment->get('member_srl') == $sender_member_srl) |
|
299 | 299 | { |
300 | 300 | continue; |
301 | 301 | } |
@@ -312,16 +312,16 @@ discard block |
||
312 | 312 | */ |
313 | 313 | function _moveCommentToTrash($commentSrlList, &$oCommentController, &$oDB, $message_content = NULL) |
314 | 314 | { |
315 | - require_once(_XE_PATH_ . 'modules/trash/model/TrashVO.php'); |
|
315 | + require_once(_XE_PATH_.'modules/trash/model/TrashVO.php'); |
|
316 | 316 | |
317 | - if(is_array($commentSrlList)) |
|
317 | + if (is_array($commentSrlList)) |
|
318 | 318 | { |
319 | 319 | $logged_info = Context::get('logged_info'); |
320 | 320 | $oCommentModel = getModel('comment'); |
321 | 321 | $commentItemList = $oCommentModel->getComments($commentSrlList); |
322 | 322 | $oTrashAdminController = getAdminController('trash'); |
323 | 323 | |
324 | - foreach($commentItemList AS $key => $oComment) |
|
324 | + foreach ($commentItemList AS $key => $oComment) |
|
325 | 325 | { |
326 | 326 | $oTrashVO = new TrashVO(); |
327 | 327 | $oTrashVO->setTrashSrl(getNextSequence()); |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | $oTrashVO->setDescription($message_content); |
332 | 332 | |
333 | 333 | $output = $oTrashAdminController->insertTrash($oTrashVO); |
334 | - if(!$output->toBool()) |
|
334 | + if (!$output->toBool()) |
|
335 | 335 | { |
336 | 336 | $oDB->rollback(); |
337 | 337 | return $output; |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | $oCommentController = getController('comment'); |
356 | 356 | $oComment = $oCommentModel->getComment($comment_srl, false); |
357 | 357 | |
358 | - if(!$oComment->isGranted()) return $this->stop('msg_not_permitted'); |
|
358 | + if (!$oComment->isGranted()) return $this->stop('msg_not_permitted'); |
|
359 | 359 | |
360 | 360 | $message_content = ""; |
361 | 361 | $this->_moveCommentToTrash(array($comment_srl), $oCommentController, $oDB, $message_content); |
@@ -377,12 +377,12 @@ discard block |
||
377 | 377 | { |
378 | 378 | $comment_srl = trim(Context::get('comment_srl')); |
379 | 379 | |
380 | - if($comment_srl) |
|
380 | + if ($comment_srl) |
|
381 | 381 | { |
382 | 382 | $args = new stdClass(); |
383 | 383 | $args->comment_srl = $comment_srl; |
384 | 384 | $output = executeQuery('comment.deleteDeclaredComments', $args); |
385 | - if(!$output->toBool()) |
|
385 | + if (!$output->toBool()) |
|
386 | 386 | { |
387 | 387 | return $output; |
388 | 388 | } |
@@ -403,11 +403,11 @@ discard block |
||
403 | 403 | |
404 | 404 | $output = $oCommentModel->getComments($commentSrlList); |
405 | 405 | |
406 | - if(is_array($output)) |
|
406 | + if (is_array($output)) |
|
407 | 407 | { |
408 | - foreach($output AS $key => $value) |
|
408 | + foreach ($output AS $key => $value) |
|
409 | 409 | { |
410 | - if($_SESSION['comment_management'][$key]) |
|
410 | + if ($_SESSION['comment_management'][$key]) |
|
411 | 411 | { |
412 | 412 | unset($_SESSION['comment_management'][$key]); |
413 | 413 | } |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | $args = new stdClass(); |
429 | 429 | $args->module_srl = $module_srl; |
430 | 430 | $output = executeQuery('comment.deleteModuleComments', $args); |
431 | - if(!$output->toBool()) |
|
431 | + if (!$output->toBool()) |
|
432 | 432 | { |
433 | 433 | return $output; |
434 | 434 | } |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | |
438 | 438 | //remove from cache |
439 | 439 | $oCacheHandler = CacheHandler::getInstance('object'); |
440 | - if($oCacheHandler->isSupport()) |
|
440 | + if ($oCacheHandler->isSupport()) |
|
441 | 441 | { |
442 | 442 | // Invalidate newest comments. Per document cache is invalidated inside document admin controller. |
443 | 443 | $oCacheHandler->invalidateGroupKey('newestCommentsList'); |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | */ |
453 | 453 | function restoreTrash($originObject) |
454 | 454 | { |
455 | - if(is_array($originObject)) |
|
455 | + if (is_array($originObject)) |
|
456 | 456 | { |
457 | 457 | $originObject = (object) $originObject; |
458 | 458 | } |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | function emptyTrash($originObject) |
486 | 486 | { |
487 | 487 | $originObject = unserialize($originObject); |
488 | - if(is_array($originObject)) |
|
488 | + if (is_array($originObject)) |
|
489 | 489 | { |
490 | 490 | $originObject = (object) $originObject; |
491 | 491 | } |
@@ -101,7 +101,6 @@ |
||
101 | 101 | |
102 | 102 | /** |
103 | 103 | * @brief check member's grant |
104 | - * @param object $member_info |
|
105 | 104 | * @param array $arrGrant |
106 | 105 | * @return boolean |
107 | 106 | */ |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | - * @brief get grant array for insert to database. table module_config's config field |
|
65 | - * @param string $default |
|
66 | - * @param array $group |
|
67 | - * @return array |
|
68 | - */ |
|
64 | + * @brief get grant array for insert to database. table module_config's config field |
|
65 | + * @param string $default |
|
66 | + * @param array $group |
|
67 | + * @return array |
|
68 | + */ |
|
69 | 69 | function getGrantArray($default, $group) |
70 | 70 | { |
71 | 71 | $grant = array(); |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
103 | - * @brief check member's grant |
|
104 | - * @param object $member_info |
|
105 | - * @param array $arrGrant |
|
106 | - * @return boolean |
|
107 | - */ |
|
103 | + * @brief check member's grant |
|
104 | + * @param object $member_info |
|
105 | + * @param array $arrGrant |
|
106 | + * @return boolean |
|
107 | + */ |
|
108 | 108 | function checkGrant($arrGrant) |
109 | 109 | { |
110 | 110 | if(!$arrGrant) |
@@ -27,32 +27,32 @@ discard block |
||
27 | 27 | $oModuleModel = getModel('module'); |
28 | 28 | $communication_config = $oModuleModel->getModuleConfig('communication'); |
29 | 29 | |
30 | - if(!is_object($communication_config)) |
|
30 | + if (!is_object($communication_config)) |
|
31 | 31 | { |
32 | 32 | $communication_config = new stdClass(); |
33 | 33 | } |
34 | 34 | |
35 | - if(!$communication_config->skin) |
|
35 | + if (!$communication_config->skin) |
|
36 | 36 | { |
37 | 37 | $communication_config->skin = 'default'; |
38 | 38 | } |
39 | 39 | |
40 | - if(!$communication_config->colorset) |
|
40 | + if (!$communication_config->colorset) |
|
41 | 41 | { |
42 | 42 | $communication_config->colorset = 'white'; |
43 | 43 | } |
44 | 44 | |
45 | - if(!$communication_config->editor_skin) |
|
45 | + if (!$communication_config->editor_skin) |
|
46 | 46 | { |
47 | 47 | $communication_config->editor_skin = 'ckeditor'; |
48 | 48 | } |
49 | 49 | |
50 | - if(!$communication_config->mskin) |
|
50 | + if (!$communication_config->mskin) |
|
51 | 51 | { |
52 | 52 | $communication_config->mskin = 'default'; |
53 | 53 | } |
54 | 54 | |
55 | - if(!$communication_config->grant_write) |
|
55 | + if (!$communication_config->grant_write) |
|
56 | 56 | { |
57 | 57 | $communication_config->grant_write = array('default_grant'=>'member'); |
58 | 58 | } |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | function getGrantArray($default, $group) |
70 | 70 | { |
71 | 71 | $grant = array(); |
72 | - if($default!="") |
|
72 | + if ($default != "") |
|
73 | 73 | { |
74 | - switch($default) |
|
74 | + switch ($default) |
|
75 | 75 | { |
76 | 76 | case "-2": |
77 | 77 | $grant = array("default_grant"=>"site"); |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | break; |
85 | 85 | } |
86 | 86 | } |
87 | - else if(is_array($group)) |
|
87 | + else if (is_array($group)) |
|
88 | 88 | { |
89 | 89 | $oMemberModel = getModel('member'); |
90 | 90 | $group_list = $oMemberModel->getGroups($this->site_srl); |
91 | 91 | |
92 | 92 | $group_grant = array(); |
93 | - foreach($group as $group_srl) |
|
93 | + foreach ($group as $group_srl) |
|
94 | 94 | { |
95 | 95 | $group_grant[$group_srl] = $group_list[$group_srl]->title; |
96 | 96 | } |
@@ -107,37 +107,37 @@ discard block |
||
107 | 107 | */ |
108 | 108 | function checkGrant($arrGrant) |
109 | 109 | { |
110 | - if(!$arrGrant) |
|
110 | + if (!$arrGrant) |
|
111 | 111 | return false; |
112 | 112 | |
113 | 113 | $logged_info = Context::get('logged_info'); |
114 | - if(!$logged_info) |
|
114 | + if (!$logged_info) |
|
115 | 115 | return false; |
116 | 116 | |
117 | - if($logged_info->is_admin == "Y") |
|
117 | + if ($logged_info->is_admin == "Y") |
|
118 | 118 | return true; |
119 | 119 | |
120 | - if($arrGrant['default_grant']) |
|
120 | + if ($arrGrant['default_grant']) |
|
121 | 121 | { |
122 | - if($arrGrant['default_grant'] == "member" && $logged_info) |
|
122 | + if ($arrGrant['default_grant'] == "member" && $logged_info) |
|
123 | 123 | return true; |
124 | 124 | |
125 | - if($arrGrant['default_grant'] == "site" && $this->site_srl == $logged_info->site_srl) |
|
125 | + if ($arrGrant['default_grant'] == "site" && $this->site_srl == $logged_info->site_srl) |
|
126 | 126 | return true; |
127 | 127 | |
128 | - if($arrGrant['default_grant'] == "manager" && $logged_info->is_admin == "Y") |
|
128 | + if ($arrGrant['default_grant'] == "manager" && $logged_info->is_admin == "Y") |
|
129 | 129 | return true; |
130 | 130 | } |
131 | 131 | |
132 | - if($arrGrant['group_grant']) |
|
132 | + if ($arrGrant['group_grant']) |
|
133 | 133 | { |
134 | 134 | $group_grant = $arrGrant['group_grant']; |
135 | - if(!is_array($group_grant)) |
|
135 | + if (!is_array($group_grant)) |
|
136 | 136 | return false; |
137 | 137 | |
138 | - foreach($logged_info->group_list as $group_srl=>$title) |
|
138 | + foreach ($logged_info->group_list as $group_srl=>$title) |
|
139 | 139 | { |
140 | - if(isset($group_grant[$group_srl])&&$group_grant[$group_srl]==$title) |
|
140 | + if (isset($group_grant[$group_srl]) && $group_grant[$group_srl] == $title) |
|
141 | 141 | return true; |
142 | 142 | } |
143 | 143 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $output = executeQuery('communication.getMessage', $args, $columnList); |
163 | 163 | |
164 | 164 | $message = $output->data; |
165 | - if(!$message) |
|
165 | + if (!$message) |
|
166 | 166 | { |
167 | 167 | return; |
168 | 168 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | // get recipient's information if it is a sent message |
171 | 171 | $oMemberModel = getModel('member'); |
172 | 172 | |
173 | - if($message->sender_srl == $logged_info->member_srl && $message->message_type == 'S') |
|
173 | + if ($message->sender_srl == $logged_info->member_srl && $message->message_type == 'S') |
|
174 | 174 | { |
175 | 175 | $member_info = $oMemberModel->getMemberInfoByMemberSrl($message->receiver_srl); |
176 | 176 | } |
@@ -180,22 +180,22 @@ discard block |
||
180 | 180 | $member_info = $oMemberModel->getMemberInfoByMemberSrl($message->sender_srl); |
181 | 181 | } |
182 | 182 | |
183 | - if($member_info) |
|
183 | + if ($member_info) |
|
184 | 184 | { |
185 | - foreach($member_info as $key => $val) |
|
185 | + foreach ($member_info as $key => $val) |
|
186 | 186 | { |
187 | - if($key === 'title') continue; |
|
188 | - if($key === 'content') continue; |
|
189 | - if($key === 'sender_srl') continue; |
|
190 | - if($key === 'password') continue; |
|
191 | - if($key === 'regdate') continue; |
|
187 | + if ($key === 'title') continue; |
|
188 | + if ($key === 'content') continue; |
|
189 | + if ($key === 'sender_srl') continue; |
|
190 | + if ($key === 'password') continue; |
|
191 | + if ($key === 'regdate') continue; |
|
192 | 192 | |
193 | 193 | $message->{$key} = $val; |
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | 197 | // change the status if is a received and not yet read message |
198 | - if($message->message_type == 'R' && $message->readed != 'Y') |
|
198 | + if ($message->message_type == 'R' && $message->readed != 'Y') |
|
199 | 199 | { |
200 | 200 | $oCommunicationController = getController('communication'); |
201 | 201 | $oCommunicationController->setMessageReaded($message_srl); |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | $args->readed = 'N'; |
219 | 219 | |
220 | 220 | $output = executeQuery('communication.getNewMessage', $args, $columnList); |
221 | - if(!count($output->data)) |
|
221 | + if (!count($output->data)) |
|
222 | 222 | { |
223 | 223 | return; |
224 | 224 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | $logged_info = Context::get('logged_info'); |
243 | 243 | $args = new stdClass(); |
244 | 244 | |
245 | - switch($message_type) |
|
245 | + switch ($message_type) |
|
246 | 246 | { |
247 | 247 | case 'R' : |
248 | 248 | $args->member_srl = $logged_info->member_srl; |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | $output = executeQueryArray('communication.getFriendGroups', $args); |
348 | 348 | |
349 | 349 | $group_list = $output->data; |
350 | - if(!$group_list) |
|
350 | + if (!$group_list) |
|
351 | 351 | { |
352 | 352 | return; |
353 | 353 | } |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | |
371 | 371 | $output = executeQuery('communication.isAddedFriend', $args); |
372 | 372 | |
373 | - if($output->data->count) |
|
373 | + if ($output->data->count) |
|
374 | 374 | { |
375 | 375 | return TRUE; |
376 | 376 | } |
@@ -83,8 +83,7 @@ discard block |
||
83 | 83 | $grant = array("default_grant"=>"member"); |
84 | 84 | break; |
85 | 85 | } |
86 | - } |
|
87 | - else if(is_array($group)) |
|
86 | + } else if(is_array($group)) |
|
88 | 87 | { |
89 | 88 | $oMemberModel = getModel('member'); |
90 | 89 | $group_list = $oMemberModel->getGroups($this->site_srl); |
@@ -107,38 +106,46 @@ discard block |
||
107 | 106 | */ |
108 | 107 | function checkGrant($arrGrant) |
109 | 108 | { |
110 | - if(!$arrGrant) |
|
111 | - return false; |
|
109 | + if(!$arrGrant) { |
|
110 | + return false; |
|
111 | + } |
|
112 | 112 | |
113 | 113 | $logged_info = Context::get('logged_info'); |
114 | - if(!$logged_info) |
|
115 | - return false; |
|
114 | + if(!$logged_info) { |
|
115 | + return false; |
|
116 | + } |
|
116 | 117 | |
117 | - if($logged_info->is_admin == "Y") |
|
118 | - return true; |
|
118 | + if($logged_info->is_admin == "Y") { |
|
119 | + return true; |
|
120 | + } |
|
119 | 121 | |
120 | 122 | if($arrGrant['default_grant']) |
121 | 123 | { |
122 | - if($arrGrant['default_grant'] == "member" && $logged_info) |
|
123 | - return true; |
|
124 | + if($arrGrant['default_grant'] == "member" && $logged_info) { |
|
125 | + return true; |
|
126 | + } |
|
124 | 127 | |
125 | - if($arrGrant['default_grant'] == "site" && $this->site_srl == $logged_info->site_srl) |
|
126 | - return true; |
|
128 | + if($arrGrant['default_grant'] == "site" && $this->site_srl == $logged_info->site_srl) { |
|
129 | + return true; |
|
130 | + } |
|
127 | 131 | |
128 | - if($arrGrant['default_grant'] == "manager" && $logged_info->is_admin == "Y") |
|
129 | - return true; |
|
132 | + if($arrGrant['default_grant'] == "manager" && $logged_info->is_admin == "Y") { |
|
133 | + return true; |
|
134 | + } |
|
130 | 135 | } |
131 | 136 | |
132 | 137 | if($arrGrant['group_grant']) |
133 | 138 | { |
134 | 139 | $group_grant = $arrGrant['group_grant']; |
135 | - if(!is_array($group_grant)) |
|
136 | - return false; |
|
140 | + if(!is_array($group_grant)) { |
|
141 | + return false; |
|
142 | + } |
|
137 | 143 | |
138 | 144 | foreach($logged_info->group_list as $group_srl=>$title) |
139 | 145 | { |
140 | - if(isset($group_grant[$group_srl])&&$group_grant[$group_srl]==$title) |
|
141 | - return true; |
|
146 | + if(isset($group_grant[$group_srl])&&$group_grant[$group_srl]==$title) { |
|
147 | + return true; |
|
148 | + } |
|
142 | 149 | } |
143 | 150 | |
144 | 151 | } |
@@ -184,11 +191,21 @@ discard block |
||
184 | 191 | { |
185 | 192 | foreach($member_info as $key => $val) |
186 | 193 | { |
187 | - if($key === 'title') continue; |
|
188 | - if($key === 'content') continue; |
|
189 | - if($key === 'sender_srl') continue; |
|
190 | - if($key === 'password') continue; |
|
191 | - if($key === 'regdate') continue; |
|
194 | + if($key === 'title') { |
|
195 | + continue; |
|
196 | + } |
|
197 | + if($key === 'content') { |
|
198 | + continue; |
|
199 | + } |
|
200 | + if($key === 'sender_srl') { |
|
201 | + continue; |
|
202 | + } |
|
203 | + if($key === 'password') { |
|
204 | + continue; |
|
205 | + } |
|
206 | + if($key === 'regdate') { |
|
207 | + continue; |
|
208 | + } |
|
192 | 209 | |
193 | 210 | $message->{$key} = $val; |
194 | 211 | } |
@@ -351,6 +351,7 @@ |
||
351 | 351 | |
352 | 352 | /** |
353 | 353 | * Return status by key |
354 | + * @param string $key |
|
354 | 355 | * @return string |
355 | 356 | */ |
356 | 357 | function getConfigStatus($key) |
@@ -70,68 +70,126 @@ discard block |
||
70 | 70 | if($oModuleModel->needUpdate($version_update_id)) |
71 | 71 | { |
72 | 72 | // 2007. 7. 25: Add a column(notify_message) for notification |
73 | - if(!$oDB->isColumnExists("documents","notify_message")) return true; |
|
73 | + if(!$oDB->isColumnExists("documents","notify_message")) { |
|
74 | + return true; |
|
75 | + } |
|
74 | 76 | |
75 | 77 | // 2007. 8. 23: create a clustered index in the document table |
76 | - if(!$oDB->isIndexExists("documents","idx_module_list_order")) return true; |
|
77 | - if(!$oDB->isIndexExists("documents","idx_module_update_order")) return true; |
|
78 | - if(!$oDB->isIndexExists("documents","idx_module_readed_count")) return true; |
|
79 | - if(!$oDB->isIndexExists("documents","idx_module_voted_count")) return true; |
|
78 | + if(!$oDB->isIndexExists("documents","idx_module_list_order")) { |
|
79 | + return true; |
|
80 | + } |
|
81 | + if(!$oDB->isIndexExists("documents","idx_module_update_order")) { |
|
82 | + return true; |
|
83 | + } |
|
84 | + if(!$oDB->isIndexExists("documents","idx_module_readed_count")) { |
|
85 | + return true; |
|
86 | + } |
|
87 | + if(!$oDB->isIndexExists("documents","idx_module_voted_count")) { |
|
88 | + return true; |
|
89 | + } |
|
80 | 90 | // 2007. 10. 17 Add a trigger to delete all posts together when the module is deleted |
81 | - if(!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) return true; |
|
91 | + if(!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) { |
|
92 | + return true; |
|
93 | + } |
|
82 | 94 | // 2007. 10. 25 add parent_srl, expand to the document category |
83 | - if(!$oDB->isColumnExists("document_categories","parent_srl")) return true; |
|
84 | - if(!$oDB->isColumnExists("document_categories","expand")) return true; |
|
85 | - if(!$oDB->isColumnExists("document_categories","group_srls")) return true; |
|
95 | + if(!$oDB->isColumnExists("document_categories","parent_srl")) { |
|
96 | + return true; |
|
97 | + } |
|
98 | + if(!$oDB->isColumnExists("document_categories","expand")) { |
|
99 | + return true; |
|
100 | + } |
|
101 | + if(!$oDB->isColumnExists("document_categories","group_srls")) { |
|
102 | + return true; |
|
103 | + } |
|
86 | 104 | // 2007. 11. 20 create a composite index on the columns(module_srl + is_notice) |
87 | - if(!$oDB->isIndexExists("documents","idx_module_notice")) return true; |
|
105 | + if(!$oDB->isIndexExists("documents","idx_module_notice")) { |
|
106 | + return true; |
|
107 | + } |
|
88 | 108 | // 2008. 02. 18 create a composite index on the columns(module_srl + document_srl) (checked by Manian)) |
89 | - if(!$oDB->isIndexExists("documents","idx_module_document_srl")) return true; |
|
109 | + if(!$oDB->isIndexExists("documents","idx_module_document_srl")) { |
|
110 | + return true; |
|
111 | + } |
|
90 | 112 | |
91 | 113 | // 2007. 12. 03: Add if the colume(extra_vars) doesn't exist |
92 | - if(!$oDB->isColumnExists("documents","extra_vars")) return true; |
|
114 | + if(!$oDB->isColumnExists("documents","extra_vars")) { |
|
115 | + return true; |
|
116 | + } |
|
93 | 117 | // 2008. 04. 23 Add a column(blamed_count) |
94 | - if(!$oDB->isColumnExists("documents", "blamed_count")) return true; |
|
95 | - if(!$oDB->isIndexExists("documents","idx_module_blamed_count")) return true; |
|
96 | - if(!$oDB->isColumnExists("document_voted_log", "point")) return true; |
|
118 | + if(!$oDB->isColumnExists("documents", "blamed_count")) { |
|
119 | + return true; |
|
120 | + } |
|
121 | + if(!$oDB->isIndexExists("documents","idx_module_blamed_count")) { |
|
122 | + return true; |
|
123 | + } |
|
124 | + if(!$oDB->isColumnExists("document_voted_log", "point")) { |
|
125 | + return true; |
|
126 | + } |
|
97 | 127 | // 2008-12-15 Add a column(color) |
98 | - if(!$oDB->isColumnExists("document_categories", "color")) return true; |
|
128 | + if(!$oDB->isColumnExists("document_categories", "color")) { |
|
129 | + return true; |
|
130 | + } |
|
99 | 131 | |
100 | 132 | /** |
101 | 133 | * 2009. 01. 29: Add a column(lang_code) if not exist in the document_extra_vars table |
102 | 134 | */ |
103 | - if(!$oDB->isColumnExists("document_extra_vars","lang_code")) return true; |
|
135 | + if(!$oDB->isColumnExists("document_extra_vars","lang_code")) { |
|
136 | + return true; |
|
137 | + } |
|
104 | 138 | |
105 | - if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) return true; |
|
139 | + if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) { |
|
140 | + return true; |
|
141 | + } |
|
106 | 142 | // 2009. 03. 09 Add a column(lang_code) to the documnets table |
107 | - if(!$oDB->isColumnExists("documents","lang_code")) return true; |
|
143 | + if(!$oDB->isColumnExists("documents","lang_code")) { |
|
144 | + return true; |
|
145 | + } |
|
108 | 146 | // 2009. 03. 11 check the index in the document_extra_vars table |
109 | - if(!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars")) return true; |
|
147 | + if(!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars")) { |
|
148 | + return true; |
|
149 | + } |
|
110 | 150 | |
111 | 151 | // 2009. 03. 19: Add a column(eid) if not exist in the table |
112 | - if(!$oDB->isColumnExists("document_extra_keys","eid")) return true; |
|
113 | - if(!$oDB->isColumnExists("document_extra_vars","eid")) return true; |
|
152 | + if(!$oDB->isColumnExists("document_extra_keys","eid")) { |
|
153 | + return true; |
|
154 | + } |
|
155 | + if(!$oDB->isColumnExists("document_extra_vars","eid")) { |
|
156 | + return true; |
|
157 | + } |
|
114 | 158 | |
115 | 159 | // 2011. 03. 30 Cubrid index Check the index in the document_extra_vars table |
116 | - if(!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order")) return true; |
|
160 | + if(!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order")) { |
|
161 | + return true; |
|
162 | + } |
|
117 | 163 | |
118 | 164 | //2011. 04. 07 adding description column to document categories |
119 | - if(!$oDB->isColumnExists("document_categories","description")) return true; |
|
165 | + if(!$oDB->isColumnExists("document_categories","description")) { |
|
166 | + return true; |
|
167 | + } |
|
120 | 168 | |
121 | 169 | //2011. 05. 23 adding status column to document |
122 | - if(!$oDB->isColumnExists('documents', 'status')) return true; |
|
170 | + if(!$oDB->isColumnExists('documents', 'status')) { |
|
171 | + return true; |
|
172 | + } |
|
123 | 173 | |
124 | 174 | //2011. 06. 07 check comment status update |
125 | - if($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment')) return true; |
|
175 | + if($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment')) { |
|
176 | + return true; |
|
177 | + } |
|
126 | 178 | |
127 | 179 | // 2011. 10. 25 status index check |
128 | - if(!$oDB->isIndexExists("documents", "idx_module_status")) return true; |
|
180 | + if(!$oDB->isIndexExists("documents", "idx_module_status")) { |
|
181 | + return true; |
|
182 | + } |
|
129 | 183 | |
130 | 184 | // 2012. 02. 27 Add a trigger to copy extra keys when the module is copied |
131 | - if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) return true; |
|
185 | + if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) { |
|
186 | + return true; |
|
187 | + } |
|
132 | 188 | |
133 | 189 | // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied |
134 | - if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after')) return true; |
|
190 | + if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after')) { |
|
191 | + return true; |
|
192 | + } |
|
135 | 193 | |
136 | 194 | $oModuleController->insertUpdatedLog($version_update_id); |
137 | 195 | } |
@@ -178,20 +236,33 @@ discard block |
||
178 | 236 | $oDB->addIndex("documents","idx_module_voted_count", array("module_srl","voted_count")); |
179 | 237 | } |
180 | 238 | // 2007. 10. 17 Add a trigger to delete all posts together when the module is deleted |
181 | - if(!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) |
|
182 | - $oModuleController->insertTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after'); |
|
239 | + if(!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) { |
|
240 | + $oModuleController->insertTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after'); |
|
241 | + } |
|
183 | 242 | // 2007. 10. 25 add columns(parent_srl, expand) |
184 | - if(!$oDB->isColumnExists("document_categories","parent_srl")) $oDB->addColumn('document_categories',"parent_srl","number",12,0); |
|
185 | - if(!$oDB->isColumnExists("document_categories","expand")) $oDB->addColumn('document_categories',"expand","char",1,"N"); |
|
186 | - if(!$oDB->isColumnExists("document_categories","group_srls")) $oDB->addColumn('document_categories',"group_srls","text"); |
|
243 | + if(!$oDB->isColumnExists("document_categories","parent_srl")) { |
|
244 | + $oDB->addColumn('document_categories',"parent_srl","number",12,0); |
|
245 | + } |
|
246 | + if(!$oDB->isColumnExists("document_categories","expand")) { |
|
247 | + $oDB->addColumn('document_categories',"expand","char",1,"N"); |
|
248 | + } |
|
249 | + if(!$oDB->isColumnExists("document_categories","group_srls")) { |
|
250 | + $oDB->addColumn('document_categories',"group_srls","text"); |
|
251 | + } |
|
187 | 252 | // 2007. 11. 20 create a composite index on the columns(module_srl + is_notice) |
188 | - if(!$oDB->isIndexExists("documents","idx_module_notice")) $oDB->addIndex("documents","idx_module_notice", array("module_srl","is_notice")); |
|
253 | + if(!$oDB->isIndexExists("documents","idx_module_notice")) { |
|
254 | + $oDB->addIndex("documents","idx_module_notice", array("module_srl","is_notice")); |
|
255 | + } |
|
189 | 256 | |
190 | 257 | // 2007. 12. 03: Add if the colume(extra_vars) doesn't exist |
191 | - if(!$oDB->isColumnExists("documents","extra_vars")) $oDB->addColumn('documents','extra_vars','text'); |
|
258 | + if(!$oDB->isColumnExists("documents","extra_vars")) { |
|
259 | + $oDB->addColumn('documents','extra_vars','text'); |
|
260 | + } |
|
192 | 261 | |
193 | 262 | // 2008. 02. 18 create a composite index on the columns(module_srl + document_srl) (checked by Manian)) |
194 | - if(!$oDB->isIndexExists("documents","idx_module_document_srl")) $oDB->addIndex("documents","idx_module_document_srl", array("module_srl","document_srl")); |
|
263 | + if(!$oDB->isIndexExists("documents","idx_module_document_srl")) { |
|
264 | + $oDB->addIndex("documents","idx_module_document_srl", array("module_srl","document_srl")); |
|
265 | + } |
|
195 | 266 | // 2008. 04. 23 Add a column(blamed count) |
196 | 267 | if(!$oDB->isColumnExists("documents", "blamed_count")) |
197 | 268 | { |
@@ -204,18 +275,24 @@ discard block |
||
204 | 275 | $oDB->addIndex('documents', 'idx_module_blamed_count', array('module_srl', 'blamed_count')); |
205 | 276 | } |
206 | 277 | |
207 | - if(!$oDB->isColumnExists("document_voted_log", "point")) |
|
208 | - $oDB->addColumn('document_voted_log', 'point', 'number', 11, 0, true); |
|
278 | + if(!$oDB->isColumnExists("document_voted_log", "point")) { |
|
279 | + $oDB->addColumn('document_voted_log', 'point', 'number', 11, 0, true); |
|
280 | + } |
|
209 | 281 | |
210 | 282 | |
211 | - if(!$oDB->isColumnExists("document_categories","color")) $oDB->addColumn('document_categories',"color","char",7); |
|
283 | + if(!$oDB->isColumnExists("document_categories","color")) { |
|
284 | + $oDB->addColumn('document_categories',"color","char",7); |
|
285 | + } |
|
212 | 286 | |
213 | 287 | // 2009. 01. 29: Add a column(lang_code) if not exist in the document_extra_vars table |
214 | - if(!$oDB->isColumnExists("document_extra_vars","lang_code")) $oDB->addColumn('document_extra_vars',"lang_code","varchar",10); |
|
288 | + if(!$oDB->isColumnExists("document_extra_vars","lang_code")) { |
|
289 | + $oDB->addColumn('document_extra_vars',"lang_code","varchar",10); |
|
290 | + } |
|
215 | 291 | |
216 | 292 | // 2009. 01. 29 Added a trigger for additional setup |
217 | - if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) |
|
218 | - $oModuleController->insertTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before'); |
|
293 | + if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) { |
|
294 | + $oModuleController->insertTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before'); |
|
295 | + } |
|
219 | 296 | // 2009. 03. 09 Add a column(lang_code) to the documnets table |
220 | 297 | if(!$oDB->isColumnExists("documents","lang_code")) |
221 | 298 | { |
@@ -276,7 +353,9 @@ discard block |
||
276 | 353 | } |
277 | 354 | |
278 | 355 | //2011. 04. 07 adding description column to document categories |
279 | - if(!$oDB->isColumnExists("document_categories","description")) $oDB->addColumn('document_categories',"description","varchar",200,0); |
|
356 | + if(!$oDB->isColumnExists("document_categories","description")) { |
|
357 | + $oDB->addColumn('document_categories',"description","varchar",200,0); |
|
358 | + } |
|
280 | 359 | |
281 | 360 | //2011. 05. 23 adding status column to document |
282 | 361 | if(!$oDB->isColumnExists('documents', 'status')) |
@@ -287,8 +366,9 @@ discard block |
||
287 | 366 | } |
288 | 367 | |
289 | 368 | // 2011. 09. 08 drop column document is_secret |
290 | - if($oDB->isColumnExists('documents', 'status') && $oDB->isColumnExists('documents', 'is_secret')) |
|
291 | - $oDB->dropColumn('documents', 'is_secret'); |
|
369 | + if($oDB->isColumnExists('documents', 'status') && $oDB->isColumnExists('documents', 'is_secret')) { |
|
370 | + $oDB->dropColumn('documents', 'is_secret'); |
|
371 | + } |
|
292 | 372 | |
293 | 373 | //2011. 06. 07 merge column, allow_comment and lock_comment |
294 | 374 | if($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment')) |
@@ -313,14 +393,17 @@ discard block |
||
313 | 393 | $output = executeQuery('document.updateDocumentCommentStatus', $args); |
314 | 394 | } |
315 | 395 | |
316 | - if($oDB->isColumnExists('documents', 'allow_comment') && $oDB->isColumnExists('documents', 'comment_status')) |
|
317 | - $oDB->dropColumn('documents', 'allow_comment'); |
|
396 | + if($oDB->isColumnExists('documents', 'allow_comment') && $oDB->isColumnExists('documents', 'comment_status')) { |
|
397 | + $oDB->dropColumn('documents', 'allow_comment'); |
|
398 | + } |
|
318 | 399 | |
319 | - if($oDB->isColumnExists('documents', 'lock_comment') && $oDB->isColumnExists('documents', 'comment_status')) |
|
320 | - $oDB->dropColumn('documents', 'lock_comment'); |
|
400 | + if($oDB->isColumnExists('documents', 'lock_comment') && $oDB->isColumnExists('documents', 'comment_status')) { |
|
401 | + $oDB->dropColumn('documents', 'lock_comment'); |
|
402 | + } |
|
321 | 403 | |
322 | - if(!$oDB->isIndexExists("documents", "idx_module_status")) |
|
323 | - $oDB->addIndex("documents", "idx_module_status", array("module_srl","status")); |
|
404 | + if(!$oDB->isIndexExists("documents", "idx_module_status")) { |
|
405 | + $oDB->addIndex("documents", "idx_module_status", array("module_srl","status")); |
|
406 | + } |
|
324 | 407 | |
325 | 408 | // 2012. 02. 27 Add a trigger to copy extra keys when the module is copied |
326 | 409 | if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) |
@@ -376,8 +459,11 @@ discard block |
||
376 | 459 | */ |
377 | 460 | function getConfigStatus($key) |
378 | 461 | { |
379 | - if(array_key_exists(strtolower($key), $this->statusList)) return $this->statusList[$key]; |
|
380 | - else $this->getDefaultStatus(); |
|
462 | + if(array_key_exists(strtolower($key), $this->statusList)) { |
|
463 | + return $this->statusList[$key]; |
|
464 | + } else { |
|
465 | + $this->getDefaultStatus(); |
|
466 | + } |
|
381 | 467 | } |
382 | 468 | } |
383 | 469 | /* End of file document.class.php */ |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * Search option to use in admin page |
18 | 18 | * @var array |
19 | 19 | */ |
20 | - var $search_option = array('title','content','title_content','user_name',); // /< Search options |
|
20 | + var $search_option = array('title', 'content', 'title_content', 'user_name',); // /< Search options |
|
21 | 21 | /** |
22 | 22 | * Status list |
23 | 23 | * @var array |
@@ -34,22 +34,22 @@ discard block |
||
34 | 34 | $oModuleController = getController('module'); |
35 | 35 | |
36 | 36 | $oDB = &DB::getInstance(); |
37 | - $oDB->addIndex("documents","idx_module_list_order", array("module_srl","list_order")); |
|
38 | - $oDB->addIndex("documents","idx_module_update_order", array("module_srl","update_order")); |
|
39 | - $oDB->addIndex("documents","idx_module_readed_count", array("module_srl","readed_count")); |
|
40 | - $oDB->addIndex("documents","idx_module_voted_count", array("module_srl","voted_count")); |
|
41 | - $oDB->addIndex("documents","idx_module_notice", array("module_srl","is_notice")); |
|
42 | - $oDB->addIndex("documents","idx_module_document_srl", array("module_srl","document_srl")); |
|
43 | - $oDB->addIndex("documents","idx_module_blamed_count", array("module_srl","blamed_count")); |
|
44 | - $oDB->addIndex("document_aliases", "idx_module_title", array("module_srl","alias_title"), true); |
|
45 | - $oDB->addIndex("document_extra_vars", "unique_extra_vars", array("module_srl","document_srl","var_idx","lang_code"), true); |
|
37 | + $oDB->addIndex("documents", "idx_module_list_order", array("module_srl", "list_order")); |
|
38 | + $oDB->addIndex("documents", "idx_module_update_order", array("module_srl", "update_order")); |
|
39 | + $oDB->addIndex("documents", "idx_module_readed_count", array("module_srl", "readed_count")); |
|
40 | + $oDB->addIndex("documents", "idx_module_voted_count", array("module_srl", "voted_count")); |
|
41 | + $oDB->addIndex("documents", "idx_module_notice", array("module_srl", "is_notice")); |
|
42 | + $oDB->addIndex("documents", "idx_module_document_srl", array("module_srl", "document_srl")); |
|
43 | + $oDB->addIndex("documents", "idx_module_blamed_count", array("module_srl", "blamed_count")); |
|
44 | + $oDB->addIndex("document_aliases", "idx_module_title", array("module_srl", "alias_title"), true); |
|
45 | + $oDB->addIndex("document_extra_vars", "unique_extra_vars", array("module_srl", "document_srl", "var_idx", "lang_code"), true); |
|
46 | 46 | // 2007. 10. 17 Add a trigger to delete all posts together when the module is deleted |
47 | 47 | $oModuleController->insertTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after'); |
48 | 48 | |
49 | 49 | // 2009. 01. 29 Added a trigger for additional setup |
50 | 50 | $oModuleController->insertTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before'); |
51 | 51 | |
52 | - if(!is_dir('./files/cache/tmp')) |
|
52 | + if (!is_dir('./files/cache/tmp')) |
|
53 | 53 | { |
54 | 54 | FileHandler::makeDir('./files/cache/tmp'); |
55 | 55 | } |
@@ -67,71 +67,71 @@ discard block |
||
67 | 67 | $oModuleModel = getModel('module'); |
68 | 68 | $oModuleController = getController('module'); |
69 | 69 | $version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated')); |
70 | - if($oModuleModel->needUpdate($version_update_id)) |
|
70 | + if ($oModuleModel->needUpdate($version_update_id)) |
|
71 | 71 | { |
72 | 72 | // 2007. 7. 25: Add a column(notify_message) for notification |
73 | - if(!$oDB->isColumnExists("documents","notify_message")) return true; |
|
73 | + if (!$oDB->isColumnExists("documents", "notify_message")) return true; |
|
74 | 74 | |
75 | 75 | // 2007. 8. 23: create a clustered index in the document table |
76 | - if(!$oDB->isIndexExists("documents","idx_module_list_order")) return true; |
|
77 | - if(!$oDB->isIndexExists("documents","idx_module_update_order")) return true; |
|
78 | - if(!$oDB->isIndexExists("documents","idx_module_readed_count")) return true; |
|
79 | - if(!$oDB->isIndexExists("documents","idx_module_voted_count")) return true; |
|
76 | + if (!$oDB->isIndexExists("documents", "idx_module_list_order")) return true; |
|
77 | + if (!$oDB->isIndexExists("documents", "idx_module_update_order")) return true; |
|
78 | + if (!$oDB->isIndexExists("documents", "idx_module_readed_count")) return true; |
|
79 | + if (!$oDB->isIndexExists("documents", "idx_module_voted_count")) return true; |
|
80 | 80 | // 2007. 10. 17 Add a trigger to delete all posts together when the module is deleted |
81 | - if(!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) return true; |
|
81 | + if (!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) return true; |
|
82 | 82 | // 2007. 10. 25 add parent_srl, expand to the document category |
83 | - if(!$oDB->isColumnExists("document_categories","parent_srl")) return true; |
|
84 | - if(!$oDB->isColumnExists("document_categories","expand")) return true; |
|
85 | - if(!$oDB->isColumnExists("document_categories","group_srls")) return true; |
|
83 | + if (!$oDB->isColumnExists("document_categories", "parent_srl")) return true; |
|
84 | + if (!$oDB->isColumnExists("document_categories", "expand")) return true; |
|
85 | + if (!$oDB->isColumnExists("document_categories", "group_srls")) return true; |
|
86 | 86 | // 2007. 11. 20 create a composite index on the columns(module_srl + is_notice) |
87 | - if(!$oDB->isIndexExists("documents","idx_module_notice")) return true; |
|
87 | + if (!$oDB->isIndexExists("documents", "idx_module_notice")) return true; |
|
88 | 88 | // 2008. 02. 18 create a composite index on the columns(module_srl + document_srl) (checked by Manian)) |
89 | - if(!$oDB->isIndexExists("documents","idx_module_document_srl")) return true; |
|
89 | + if (!$oDB->isIndexExists("documents", "idx_module_document_srl")) return true; |
|
90 | 90 | |
91 | 91 | // 2007. 12. 03: Add if the colume(extra_vars) doesn't exist |
92 | - if(!$oDB->isColumnExists("documents","extra_vars")) return true; |
|
92 | + if (!$oDB->isColumnExists("documents", "extra_vars")) return true; |
|
93 | 93 | // 2008. 04. 23 Add a column(blamed_count) |
94 | - if(!$oDB->isColumnExists("documents", "blamed_count")) return true; |
|
95 | - if(!$oDB->isIndexExists("documents","idx_module_blamed_count")) return true; |
|
96 | - if(!$oDB->isColumnExists("document_voted_log", "point")) return true; |
|
94 | + if (!$oDB->isColumnExists("documents", "blamed_count")) return true; |
|
95 | + if (!$oDB->isIndexExists("documents", "idx_module_blamed_count")) return true; |
|
96 | + if (!$oDB->isColumnExists("document_voted_log", "point")) return true; |
|
97 | 97 | // 2008-12-15 Add a column(color) |
98 | - if(!$oDB->isColumnExists("document_categories", "color")) return true; |
|
98 | + if (!$oDB->isColumnExists("document_categories", "color")) return true; |
|
99 | 99 | |
100 | 100 | /** |
101 | 101 | * 2009. 01. 29: Add a column(lang_code) if not exist in the document_extra_vars table |
102 | 102 | */ |
103 | - if(!$oDB->isColumnExists("document_extra_vars","lang_code")) return true; |
|
103 | + if (!$oDB->isColumnExists("document_extra_vars", "lang_code")) return true; |
|
104 | 104 | |
105 | - if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) return true; |
|
105 | + if (!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) return true; |
|
106 | 106 | // 2009. 03. 09 Add a column(lang_code) to the documnets table |
107 | - if(!$oDB->isColumnExists("documents","lang_code")) return true; |
|
107 | + if (!$oDB->isColumnExists("documents", "lang_code")) return true; |
|
108 | 108 | // 2009. 03. 11 check the index in the document_extra_vars table |
109 | - if(!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars")) return true; |
|
109 | + if (!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars")) return true; |
|
110 | 110 | |
111 | 111 | // 2009. 03. 19: Add a column(eid) if not exist in the table |
112 | - if(!$oDB->isColumnExists("document_extra_keys","eid")) return true; |
|
113 | - if(!$oDB->isColumnExists("document_extra_vars","eid")) return true; |
|
112 | + if (!$oDB->isColumnExists("document_extra_keys", "eid")) return true; |
|
113 | + if (!$oDB->isColumnExists("document_extra_vars", "eid")) return true; |
|
114 | 114 | |
115 | 115 | // 2011. 03. 30 Cubrid index Check the index in the document_extra_vars table |
116 | - if(!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order")) return true; |
|
116 | + if (!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order")) return true; |
|
117 | 117 | |
118 | 118 | //2011. 04. 07 adding description column to document categories |
119 | - if(!$oDB->isColumnExists("document_categories","description")) return true; |
|
119 | + if (!$oDB->isColumnExists("document_categories", "description")) return true; |
|
120 | 120 | |
121 | 121 | //2011. 05. 23 adding status column to document |
122 | - if(!$oDB->isColumnExists('documents', 'status')) return true; |
|
122 | + if (!$oDB->isColumnExists('documents', 'status')) return true; |
|
123 | 123 | |
124 | 124 | //2011. 06. 07 check comment status update |
125 | - if($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment')) return true; |
|
125 | + if ($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment')) return true; |
|
126 | 126 | |
127 | 127 | // 2011. 10. 25 status index check |
128 | - if(!$oDB->isIndexExists("documents", "idx_module_status")) return true; |
|
128 | + if (!$oDB->isIndexExists("documents", "idx_module_status")) return true; |
|
129 | 129 | |
130 | 130 | // 2012. 02. 27 Add a trigger to copy extra keys when the module is copied |
131 | - if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) return true; |
|
131 | + if (!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) return true; |
|
132 | 132 | |
133 | 133 | // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied |
134 | - if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after')) return true; |
|
134 | + if (!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after')) return true; |
|
135 | 135 | |
136 | 136 | $oModuleController->insertUpdatedLog($version_update_id); |
137 | 137 | } |
@@ -149,101 +149,101 @@ discard block |
||
149 | 149 | $oModuleModel = getModel('module'); |
150 | 150 | $oModuleController = getController('module'); |
151 | 151 | $version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated')); |
152 | - if($oModuleModel->needUpdate($version_update_id)) |
|
152 | + if ($oModuleModel->needUpdate($version_update_id)) |
|
153 | 153 | { |
154 | 154 | // 2007. 7. 25: Add a column(notify_message) for notification |
155 | - if(!$oDB->isColumnExists("documents","notify_message")) |
|
155 | + if (!$oDB->isColumnExists("documents", "notify_message")) |
|
156 | 156 | { |
157 | - $oDB->addColumn('documents',"notify_message","char",1); |
|
157 | + $oDB->addColumn('documents', "notify_message", "char", 1); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | // 2007. 8. 23: create a clustered index in the document table |
161 | - if(!$oDB->isIndexExists("documents","idx_module_list_order")) |
|
161 | + if (!$oDB->isIndexExists("documents", "idx_module_list_order")) |
|
162 | 162 | { |
163 | - $oDB->addIndex("documents","idx_module_list_order", array("module_srl","list_order")); |
|
163 | + $oDB->addIndex("documents", "idx_module_list_order", array("module_srl", "list_order")); |
|
164 | 164 | } |
165 | 165 | |
166 | - if(!$oDB->isIndexExists("documents","idx_module_update_order")) |
|
166 | + if (!$oDB->isIndexExists("documents", "idx_module_update_order")) |
|
167 | 167 | { |
168 | - $oDB->addIndex("documents","idx_module_update_order", array("module_srl","update_order")); |
|
168 | + $oDB->addIndex("documents", "idx_module_update_order", array("module_srl", "update_order")); |
|
169 | 169 | } |
170 | 170 | |
171 | - if(!$oDB->isIndexExists("documents","idx_module_readed_count")) |
|
171 | + if (!$oDB->isIndexExists("documents", "idx_module_readed_count")) |
|
172 | 172 | { |
173 | - $oDB->addIndex("documents","idx_module_readed_count", array("module_srl","readed_count")); |
|
173 | + $oDB->addIndex("documents", "idx_module_readed_count", array("module_srl", "readed_count")); |
|
174 | 174 | } |
175 | 175 | |
176 | - if(!$oDB->isIndexExists("documents","idx_module_voted_count")) |
|
176 | + if (!$oDB->isIndexExists("documents", "idx_module_voted_count")) |
|
177 | 177 | { |
178 | - $oDB->addIndex("documents","idx_module_voted_count", array("module_srl","voted_count")); |
|
178 | + $oDB->addIndex("documents", "idx_module_voted_count", array("module_srl", "voted_count")); |
|
179 | 179 | } |
180 | 180 | // 2007. 10. 17 Add a trigger to delete all posts together when the module is deleted |
181 | - if(!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) |
|
181 | + if (!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) |
|
182 | 182 | $oModuleController->insertTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after'); |
183 | 183 | // 2007. 10. 25 add columns(parent_srl, expand) |
184 | - if(!$oDB->isColumnExists("document_categories","parent_srl")) $oDB->addColumn('document_categories',"parent_srl","number",12,0); |
|
185 | - if(!$oDB->isColumnExists("document_categories","expand")) $oDB->addColumn('document_categories',"expand","char",1,"N"); |
|
186 | - if(!$oDB->isColumnExists("document_categories","group_srls")) $oDB->addColumn('document_categories',"group_srls","text"); |
|
184 | + if (!$oDB->isColumnExists("document_categories", "parent_srl")) $oDB->addColumn('document_categories', "parent_srl", "number", 12, 0); |
|
185 | + if (!$oDB->isColumnExists("document_categories", "expand")) $oDB->addColumn('document_categories', "expand", "char", 1, "N"); |
|
186 | + if (!$oDB->isColumnExists("document_categories", "group_srls")) $oDB->addColumn('document_categories', "group_srls", "text"); |
|
187 | 187 | // 2007. 11. 20 create a composite index on the columns(module_srl + is_notice) |
188 | - if(!$oDB->isIndexExists("documents","idx_module_notice")) $oDB->addIndex("documents","idx_module_notice", array("module_srl","is_notice")); |
|
188 | + if (!$oDB->isIndexExists("documents", "idx_module_notice")) $oDB->addIndex("documents", "idx_module_notice", array("module_srl", "is_notice")); |
|
189 | 189 | |
190 | 190 | // 2007. 12. 03: Add if the colume(extra_vars) doesn't exist |
191 | - if(!$oDB->isColumnExists("documents","extra_vars")) $oDB->addColumn('documents','extra_vars','text'); |
|
191 | + if (!$oDB->isColumnExists("documents", "extra_vars")) $oDB->addColumn('documents', 'extra_vars', 'text'); |
|
192 | 192 | |
193 | 193 | // 2008. 02. 18 create a composite index on the columns(module_srl + document_srl) (checked by Manian)) |
194 | - if(!$oDB->isIndexExists("documents","idx_module_document_srl")) $oDB->addIndex("documents","idx_module_document_srl", array("module_srl","document_srl")); |
|
194 | + if (!$oDB->isIndexExists("documents", "idx_module_document_srl")) $oDB->addIndex("documents", "idx_module_document_srl", array("module_srl", "document_srl")); |
|
195 | 195 | // 2008. 04. 23 Add a column(blamed count) |
196 | - if(!$oDB->isColumnExists("documents", "blamed_count")) |
|
196 | + if (!$oDB->isColumnExists("documents", "blamed_count")) |
|
197 | 197 | { |
198 | 198 | $oDB->addColumn('documents', 'blamed_count', 'number', 11, 0, true); |
199 | 199 | $oDB->addIndex('documents', 'idx_blamed_count', array('blamed_count')); |
200 | 200 | } |
201 | 201 | |
202 | - if(!$oDB->isIndexExists("documents","idx_module_blamed_count")) |
|
202 | + if (!$oDB->isIndexExists("documents", "idx_module_blamed_count")) |
|
203 | 203 | { |
204 | 204 | $oDB->addIndex('documents', 'idx_module_blamed_count', array('module_srl', 'blamed_count')); |
205 | 205 | } |
206 | 206 | |
207 | - if(!$oDB->isColumnExists("document_voted_log", "point")) |
|
207 | + if (!$oDB->isColumnExists("document_voted_log", "point")) |
|
208 | 208 | $oDB->addColumn('document_voted_log', 'point', 'number', 11, 0, true); |
209 | 209 | |
210 | 210 | |
211 | - if(!$oDB->isColumnExists("document_categories","color")) $oDB->addColumn('document_categories',"color","char",7); |
|
211 | + if (!$oDB->isColumnExists("document_categories", "color")) $oDB->addColumn('document_categories', "color", "char", 7); |
|
212 | 212 | |
213 | 213 | // 2009. 01. 29: Add a column(lang_code) if not exist in the document_extra_vars table |
214 | - if(!$oDB->isColumnExists("document_extra_vars","lang_code")) $oDB->addColumn('document_extra_vars',"lang_code","varchar",10); |
|
214 | + if (!$oDB->isColumnExists("document_extra_vars", "lang_code")) $oDB->addColumn('document_extra_vars', "lang_code", "varchar", 10); |
|
215 | 215 | |
216 | 216 | // 2009. 01. 29 Added a trigger for additional setup |
217 | - if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) |
|
217 | + if (!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) |
|
218 | 218 | $oModuleController->insertTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before'); |
219 | 219 | // 2009. 03. 09 Add a column(lang_code) to the documnets table |
220 | - if(!$oDB->isColumnExists("documents","lang_code")) |
|
220 | + if (!$oDB->isColumnExists("documents", "lang_code")) |
|
221 | 221 | { |
222 | 222 | $db_info = Context::getDBInfo(); |
223 | - $oDB->addColumn('documents',"lang_code","varchar",10, $db_info->lang_code); |
|
223 | + $oDB->addColumn('documents', "lang_code", "varchar", 10, $db_info->lang_code); |
|
224 | 224 | $obj->lang_code = $db_info->lang_type; |
225 | 225 | executeQuery('document.updateDocumentsLangCode', $obj); |
226 | 226 | } |
227 | 227 | // 2009. 03. 11 Check the index in the document_extra_vars table |
228 | - if(!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars")) |
|
228 | + if (!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars")) |
|
229 | 229 | { |
230 | - $oDB->addIndex("document_extra_vars", "unique_extra_vars", array("module_srl","document_srl","var_idx","lang_code"), true); |
|
230 | + $oDB->addIndex("document_extra_vars", "unique_extra_vars", array("module_srl", "document_srl", "var_idx", "lang_code"), true); |
|
231 | 231 | } |
232 | 232 | |
233 | - if($oDB->isIndexExists("document_extra_vars", "unique_module_vars")) |
|
233 | + if ($oDB->isIndexExists("document_extra_vars", "unique_module_vars")) |
|
234 | 234 | { |
235 | 235 | $oDB->dropIndex("document_extra_vars", "unique_module_vars", true); |
236 | 236 | } |
237 | 237 | |
238 | 238 | // 2009. 03. 19: Add a column(eid) |
239 | 239 | // 2009. 04. 12: Fixed the issue(#17922959) that changes another column values when adding eid column |
240 | - if(!$oDB->isColumnExists("document_extra_keys","eid")) |
|
240 | + if (!$oDB->isColumnExists("document_extra_keys", "eid")) |
|
241 | 241 | { |
242 | - $oDB->addColumn("document_extra_keys","eid","varchar",40); |
|
242 | + $oDB->addColumn("document_extra_keys", "eid", "varchar", 40); |
|
243 | 243 | |
244 | 244 | $output = executeQuery('document.getGroupsExtraKeys', $obj); |
245 | - if($output->toBool() && $output->data && count($output->data)) { |
|
246 | - foreach($output->data as $extra_keys) { |
|
245 | + if ($output->toBool() && $output->data && count($output->data)) { |
|
246 | + foreach ($output->data as $extra_keys) { |
|
247 | 247 | $args->module_srl = $extra_keys->module_srl; |
248 | 248 | $args->var_idx = $extra_keys->idx; |
249 | 249 | $args->new_eid = "extra_vars".$extra_keys->idx; |
@@ -252,14 +252,14 @@ discard block |
||
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
255 | - if(!$oDB->isColumnExists("document_extra_vars","eid")) |
|
255 | + if (!$oDB->isColumnExists("document_extra_vars", "eid")) |
|
256 | 256 | { |
257 | - $oDB->addColumn("document_extra_vars","eid","varchar",40); |
|
257 | + $oDB->addColumn("document_extra_vars", "eid", "varchar", 40); |
|
258 | 258 | $obj->var_idx = '-1,-2'; |
259 | 259 | $output = executeQuery('document.getGroupsExtraVars', $obj); |
260 | - if($output->toBool() && $output->data && count($output->data)) |
|
260 | + if ($output->toBool() && $output->data && count($output->data)) |
|
261 | 261 | { |
262 | - foreach($output->data as $extra_vars) |
|
262 | + foreach ($output->data as $extra_vars) |
|
263 | 263 | { |
264 | 264 | $args->module_srl = $extra_vars->module_srl; |
265 | 265 | $args->var_idx = $extra_vars->idx; |
@@ -270,16 +270,16 @@ discard block |
||
270 | 270 | } |
271 | 271 | |
272 | 272 | // 2011. 03. 30 Cubrid index Check the index in the document_extra_vars table |
273 | - if(!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order")) |
|
273 | + if (!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order")) |
|
274 | 274 | { |
275 | - $oDB->addIndex("document_extra_vars", "idx_document_list_order", array("document_srl","module_srl","var_idx"), false); |
|
275 | + $oDB->addIndex("document_extra_vars", "idx_document_list_order", array("document_srl", "module_srl", "var_idx"), false); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | //2011. 04. 07 adding description column to document categories |
279 | - if(!$oDB->isColumnExists("document_categories","description")) $oDB->addColumn('document_categories',"description","varchar",200,0); |
|
279 | + if (!$oDB->isColumnExists("document_categories", "description")) $oDB->addColumn('document_categories', "description", "varchar", 200, 0); |
|
280 | 280 | |
281 | 281 | //2011. 05. 23 adding status column to document |
282 | - if(!$oDB->isColumnExists('documents', 'status')) |
|
282 | + if (!$oDB->isColumnExists('documents', 'status')) |
|
283 | 283 | { |
284 | 284 | $oDB->addColumn('documents', 'status', 'varchar', 20, 'PUBLIC'); |
285 | 285 | $args->is_secret = 'Y'; |
@@ -287,11 +287,11 @@ discard block |
||
287 | 287 | } |
288 | 288 | |
289 | 289 | // 2011. 09. 08 drop column document is_secret |
290 | - if($oDB->isColumnExists('documents', 'status') && $oDB->isColumnExists('documents', 'is_secret')) |
|
290 | + if ($oDB->isColumnExists('documents', 'status') && $oDB->isColumnExists('documents', 'is_secret')) |
|
291 | 291 | $oDB->dropColumn('documents', 'is_secret'); |
292 | 292 | |
293 | 293 | //2011. 06. 07 merge column, allow_comment and lock_comment |
294 | - if($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment')) |
|
294 | + if ($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment')) |
|
295 | 295 | { |
296 | 296 | $oDB->addColumn('documents', 'comment_status', 'varchar', 20, 'ALLOW'); |
297 | 297 | |
@@ -313,23 +313,23 @@ discard block |
||
313 | 313 | $output = executeQuery('document.updateDocumentCommentStatus', $args); |
314 | 314 | } |
315 | 315 | |
316 | - if($oDB->isColumnExists('documents', 'allow_comment') && $oDB->isColumnExists('documents', 'comment_status')) |
|
316 | + if ($oDB->isColumnExists('documents', 'allow_comment') && $oDB->isColumnExists('documents', 'comment_status')) |
|
317 | 317 | $oDB->dropColumn('documents', 'allow_comment'); |
318 | 318 | |
319 | - if($oDB->isColumnExists('documents', 'lock_comment') && $oDB->isColumnExists('documents', 'comment_status')) |
|
319 | + if ($oDB->isColumnExists('documents', 'lock_comment') && $oDB->isColumnExists('documents', 'comment_status')) |
|
320 | 320 | $oDB->dropColumn('documents', 'lock_comment'); |
321 | 321 | |
322 | - if(!$oDB->isIndexExists("documents", "idx_module_status")) |
|
323 | - $oDB->addIndex("documents", "idx_module_status", array("module_srl","status")); |
|
322 | + if (!$oDB->isIndexExists("documents", "idx_module_status")) |
|
323 | + $oDB->addIndex("documents", "idx_module_status", array("module_srl", "status")); |
|
324 | 324 | |
325 | 325 | // 2012. 02. 27 Add a trigger to copy extra keys when the module is copied |
326 | - if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) |
|
326 | + if (!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) |
|
327 | 327 | { |
328 | 328 | $oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after'); |
329 | 329 | } |
330 | 330 | |
331 | 331 | // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied |
332 | - if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after')) |
|
332 | + if (!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after')) |
|
333 | 333 | { |
334 | 334 | $oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after'); |
335 | 335 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | $oModuleController->insertUpdatedLog($version_update_id); |
338 | 338 | } |
339 | 339 | |
340 | - return new BaseObject(0,'success_updated'); |
|
340 | + return new BaseObject(0, 'success_updated'); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | */ |
347 | 347 | function recompileCache() |
348 | 348 | { |
349 | - if(!is_dir('./files/cache/tmp')) |
|
349 | + if (!is_dir('./files/cache/tmp')) |
|
350 | 350 | { |
351 | 351 | FileHandler::makeDir('./files/cache/tmp'); |
352 | 352 | } |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | */ |
377 | 377 | function getConfigStatus($key) |
378 | 378 | { |
379 | - if(array_key_exists(strtolower($key), $this->statusList)) return $this->statusList[$key]; |
|
379 | + if (array_key_exists(strtolower($key), $this->statusList)) return $this->statusList[$key]; |
|
380 | 380 | else $this->getDefaultStatus(); |
381 | 381 | } |
382 | 382 | } |
@@ -1106,8 +1106,7 @@ |
||
1106 | 1106 | |
1107 | 1107 | /** |
1108 | 1108 | * Check accessible by document status |
1109 | - * @param array $matches |
|
1110 | - * @return mixed |
|
1109 | + * @return boolean |
|
1111 | 1110 | */ |
1112 | 1111 | function _checkAccessibleFromStatus() |
1113 | 1112 | { |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | function _loadFromDB($load_extra_vars = true) |
81 | 81 | { |
82 | - if(!$this->document_srl) return; |
|
82 | + if (!$this->document_srl) return; |
|
83 | 83 | |
84 | 84 | $document_item = false; |
85 | 85 | $cache_put = false; |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | |
89 | 89 | // cache controll |
90 | 90 | $oCacheHandler = CacheHandler::getInstance('object'); |
91 | - if($oCacheHandler->isSupport()) |
|
91 | + if ($oCacheHandler->isSupport()) |
|
92 | 92 | { |
93 | - $cache_key = 'document_item:' . getNumberingPath($this->document_srl) . $this->document_srl; |
|
93 | + $cache_key = 'document_item:'.getNumberingPath($this->document_srl).$this->document_srl; |
|
94 | 94 | $document_item = $oCacheHandler->get($cache_key); |
95 | - if($document_item !== false) |
|
95 | + if ($document_item !== false) |
|
96 | 96 | { |
97 | 97 | $columnList = array('readed_count', 'voted_count', 'blamed_count', 'comment_count', 'trackback_count'); |
98 | 98 | } |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | $args->document_srl = $this->document_srl; |
103 | 103 | $output = executeQuery('document.getDocument', $args, $columnList); |
104 | 104 | |
105 | - if($document_item === false) |
|
105 | + if ($document_item === false) |
|
106 | 106 | { |
107 | 107 | $document_item = $output->data; |
108 | 108 | |
109 | 109 | //insert in cache |
110 | - if($document_item && $oCacheHandler->isSupport()) |
|
110 | + if ($document_item && $oCacheHandler->isSupport()) |
|
111 | 111 | { |
112 | 112 | $oCacheHandler->put($cache_key, $document_item); |
113 | 113 | } |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | $this->setAttribute($document_item, $load_extra_vars); |
125 | 125 | } |
126 | 126 | |
127 | - function setAttribute($attribute, $load_extra_vars=true) |
|
127 | + function setAttribute($attribute, $load_extra_vars = true) |
|
128 | 128 | { |
129 | - if(!$attribute->document_srl) |
|
129 | + if (!$attribute->document_srl) |
|
130 | 130 | { |
131 | 131 | $this->document_srl = null; |
132 | 132 | return; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $this->adds($attribute); |
137 | 137 | |
138 | 138 | // Tags |
139 | - if($this->get('tags')) |
|
139 | + if ($this->get('tags')) |
|
140 | 140 | { |
141 | 141 | $tag_list = explode(',', $this->get('tags')); |
142 | 142 | $tag_list = array_map('trim', $tag_list); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | } |
145 | 145 | |
146 | 146 | $oDocumentModel = getModel('document'); |
147 | - if($load_extra_vars) |
|
147 | + if ($load_extra_vars) |
|
148 | 148 | { |
149 | 149 | $GLOBALS['XE_DOCUMENT_LIST'][$attribute->document_srl] = $this; |
150 | 150 | $oDocumentModel->setToAllDocumentExtraVars(); |
@@ -159,23 +159,23 @@ discard block |
||
159 | 159 | |
160 | 160 | function isGranted() |
161 | 161 | { |
162 | - if($_SESSION['own_document'][$this->document_srl]) return $this->grant_cache = true; |
|
162 | + if ($_SESSION['own_document'][$this->document_srl]) return $this->grant_cache = true; |
|
163 | 163 | |
164 | - if($this->grant_cache !== null) |
|
164 | + if ($this->grant_cache !== null) |
|
165 | 165 | { |
166 | 166 | return $this->grant_cache; |
167 | 167 | } |
168 | 168 | |
169 | - if(!Context::get('is_logged')) return $this->grant_cache = false; |
|
169 | + if (!Context::get('is_logged')) return $this->grant_cache = false; |
|
170 | 170 | |
171 | 171 | $logged_info = Context::get('logged_info'); |
172 | - if($logged_info->is_admin == 'Y') return $this->grant_cache = true; |
|
172 | + if ($logged_info->is_admin == 'Y') return $this->grant_cache = true; |
|
173 | 173 | |
174 | 174 | $oModuleModel = getModel('module'); |
175 | 175 | $grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($this->get('module_srl')), $logged_info); |
176 | - if($grant->manager) return $this->grant_cache = true; |
|
176 | + if ($grant->manager) return $this->grant_cache = true; |
|
177 | 177 | |
178 | - if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl')*-1 == $logged_info->member_srl)) return $this->grant_cache = true; |
|
178 | + if ($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl') * -1 == $logged_info->member_srl)) return $this->grant_cache = true; |
|
179 | 179 | |
180 | 180 | return $this->grant_cache = false; |
181 | 181 | } |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | |
189 | 189 | function isAccessible() |
190 | 190 | { |
191 | - return $_SESSION['accessible'][$this->document_srl]==true?true:false; |
|
191 | + return $_SESSION['accessible'][$this->document_srl] == true ?true:false; |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | function allowComment() |
195 | 195 | { |
196 | 196 | // init write, document is not exists. so allow comment status is true |
197 | - if(!$this->isExists()) return true; |
|
197 | + if (!$this->isExists()) return true; |
|
198 | 198 | |
199 | 199 | return $this->get('comment_status') == 'ALLOW' ? true : false; |
200 | 200 | } |
@@ -202,11 +202,11 @@ discard block |
||
202 | 202 | function allowTrackback() |
203 | 203 | { |
204 | 204 | static $allow_trackback_status = null; |
205 | - if(is_null($allow_trackback_status)) |
|
205 | + if (is_null($allow_trackback_status)) |
|
206 | 206 | { |
207 | 207 | |
208 | 208 | // Check the tarckback module exist |
209 | - if(!getClass('trackback')) |
|
209 | + if (!getClass('trackback')) |
|
210 | 210 | { |
211 | 211 | $allow_trackback_status = false; |
212 | 212 | } |
@@ -216,20 +216,20 @@ discard block |
||
216 | 216 | $oModuleModel = getModel('module'); |
217 | 217 | $trackback_config = $oModuleModel->getModuleConfig('trackback'); |
218 | 218 | |
219 | - if(!$trackback_config) |
|
219 | + if (!$trackback_config) |
|
220 | 220 | { |
221 | 221 | $trackback_config = new stdClass(); |
222 | 222 | } |
223 | 223 | |
224 | - if(!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y'; |
|
225 | - if($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false; |
|
224 | + if (!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y'; |
|
225 | + if ($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false; |
|
226 | 226 | else |
227 | 227 | { |
228 | 228 | $module_srl = $this->get('module_srl'); |
229 | 229 | // Check settings of each module |
230 | 230 | $module_config = $oModuleModel->getModulePartConfig('trackback', $module_srl); |
231 | - if($module_config->enable_trackback == 'N') $allow_trackback_status = false; |
|
232 | - else if($this->get('allow_trackback')=='Y' || !$this->isExists()) $allow_trackback_status = true; |
|
231 | + if ($module_config->enable_trackback == 'N') $allow_trackback_status = false; |
|
232 | + else if ($this->get('allow_trackback') == 'Y' || !$this->isExists()) $allow_trackback_status = true; |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | } |
@@ -238,14 +238,14 @@ discard block |
||
238 | 238 | |
239 | 239 | function isLocked() |
240 | 240 | { |
241 | - if(!$this->isExists()) return false; |
|
241 | + if (!$this->isExists()) return false; |
|
242 | 242 | |
243 | 243 | return $this->get('comment_status') == 'ALLOW' ? false : true; |
244 | 244 | } |
245 | 245 | |
246 | 246 | function isEditable() |
247 | 247 | { |
248 | - if($this->isGranted() || !$this->get('member_srl')) return true; |
|
248 | + if ($this->isGranted() || !$this->get('member_srl')) return true; |
|
249 | 249 | return false; |
250 | 250 | } |
251 | 251 | |
@@ -262,13 +262,13 @@ discard block |
||
262 | 262 | |
263 | 263 | function useNotify() |
264 | 264 | { |
265 | - return $this->get('notify_message')=='Y' ? true : false; |
|
265 | + return $this->get('notify_message') == 'Y' ? true : false; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | function doCart() |
269 | 269 | { |
270 | - if(!$this->document_srl) return false; |
|
271 | - if($this->isCarted()) $this->removeCart(); |
|
270 | + if (!$this->document_srl) return false; |
|
271 | + if ($this->isCarted()) $this->removeCart(); |
|
272 | 272 | else $this->addCart(); |
273 | 273 | } |
274 | 274 | |
@@ -295,18 +295,18 @@ discard block |
||
295 | 295 | */ |
296 | 296 | function notify($type, $content) |
297 | 297 | { |
298 | - if(!$this->document_srl) return; |
|
298 | + if (!$this->document_srl) return; |
|
299 | 299 | // return if it is not useNotify |
300 | - if(!$this->useNotify()) return; |
|
300 | + if (!$this->useNotify()) return; |
|
301 | 301 | // Pass if an author is not a logged-in user |
302 | - if(!$this->get('member_srl')) return; |
|
302 | + if (!$this->get('member_srl')) return; |
|
303 | 303 | // Return if the currently logged-in user is an author |
304 | 304 | $logged_info = Context::get('logged_info'); |
305 | - if($logged_info->member_srl == $this->get('member_srl')) return; |
|
305 | + if ($logged_info->member_srl == $this->get('member_srl')) return; |
|
306 | 306 | // List variables |
307 | - if($type) $title = "[".$type."] "; |
|
307 | + if ($type) $title = "[".$type."] "; |
|
308 | 308 | $title .= cut_str(strip_tags($content), 10, '...'); |
309 | - $content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>',$content, getFullUrl('','document_srl',$this->document_srl), getFullUrl('','document_srl',$this->document_srl)); |
|
309 | + $content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>', $content, getFullUrl('', 'document_srl', $this->document_srl), getFullUrl('', 'document_srl', $this->document_srl)); |
|
310 | 310 | $receiver_srl = $this->get('member_srl'); |
311 | 311 | $sender_member_srl = $logged_info->member_srl; |
312 | 312 | // Send a message |
@@ -321,26 +321,26 @@ discard block |
||
321 | 321 | |
322 | 322 | function getIpAddress() |
323 | 323 | { |
324 | - if($this->isGranted()) |
|
324 | + if ($this->isGranted()) |
|
325 | 325 | { |
326 | 326 | return $this->get('ipaddress'); |
327 | 327 | } |
328 | 328 | |
329 | - return '*' . strstr($this->get('ipaddress'), '.'); |
|
329 | + return '*'.strstr($this->get('ipaddress'), '.'); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | function isExistsHomepage() |
333 | 333 | { |
334 | - if(trim($this->get('homepage'))) return true; |
|
334 | + if (trim($this->get('homepage'))) return true; |
|
335 | 335 | return false; |
336 | 336 | } |
337 | 337 | |
338 | 338 | function getHomepageUrl() |
339 | 339 | { |
340 | 340 | $url = trim($this->get('homepage')); |
341 | - if(!$url) return; |
|
341 | + if (!$url) return; |
|
342 | 342 | |
343 | - if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) $url = 'http://' . $url; |
|
343 | + if (strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) $url = 'http://'.$url; |
|
344 | 344 | |
345 | 345 | return $url; |
346 | 346 | } |
@@ -370,52 +370,52 @@ discard block |
||
370 | 370 | return htmlspecialchars($this->get('last_updater'), ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
371 | 371 | } |
372 | 372 | |
373 | - function getTitleText($cut_size = 0, $tail='...') |
|
373 | + function getTitleText($cut_size = 0, $tail = '...') |
|
374 | 374 | { |
375 | - if(!$this->document_srl) return; |
|
375 | + if (!$this->document_srl) return; |
|
376 | 376 | |
377 | - if($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail); |
|
377 | + if ($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail); |
|
378 | 378 | else $title = $this->get('title'); |
379 | 379 | |
380 | 380 | return $title; |
381 | 381 | } |
382 | 382 | |
383 | - function getTitle($cut_size = 0, $tail='...') |
|
383 | + function getTitle($cut_size = 0, $tail = '...') |
|
384 | 384 | { |
385 | - if(!$this->document_srl) return; |
|
385 | + if (!$this->document_srl) return; |
|
386 | 386 | |
387 | 387 | $title = $this->getTitleText($cut_size, $tail); |
388 | 388 | |
389 | 389 | $attrs = array(); |
390 | 390 | $this->add('title_color', trim($this->get('title_color'))); |
391 | - if($this->get('title_bold')=='Y') $attrs[] = "font-weight:bold;"; |
|
392 | - if($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color'); |
|
391 | + if ($this->get('title_bold') == 'Y') $attrs[] = "font-weight:bold;"; |
|
392 | + if ($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color'); |
|
393 | 393 | |
394 | - if(count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
394 | + if (count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';', $attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
395 | 395 | else return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
396 | 396 | } |
397 | 397 | |
398 | 398 | function getContentText($strlen = 0) |
399 | 399 | { |
400 | - if(!$this->document_srl) return; |
|
400 | + if (!$this->document_srl) return; |
|
401 | 401 | |
402 | - if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
402 | + if ($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
403 | 403 | |
404 | 404 | $result = $this->_checkAccessibleFromStatus(); |
405 | - if($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
405 | + if ($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
406 | 406 | |
407 | 407 | $content = $this->get('content'); |
408 | 408 | $content = preg_replace_callback('/<(object|param|embed)[^>]*/is', array($this, '_checkAllowScriptAccess'), $content); |
409 | 409 | $content = preg_replace_callback('/<object[^>]*>/is', array($this, '_addAllowScriptAccess'), $content); |
410 | 410 | |
411 | - if($strlen) return cut_str(strip_tags($content),$strlen,'...'); |
|
411 | + if ($strlen) return cut_str(strip_tags($content), $strlen, '...'); |
|
412 | 412 | |
413 | 413 | return htmlspecialchars($content); |
414 | 414 | } |
415 | 415 | |
416 | 416 | function _addAllowScriptAccess($m) |
417 | 417 | { |
418 | - if($this->allowscriptaccessList[$this->allowscriptaccessKey] == 1) |
|
418 | + if ($this->allowscriptaccessList[$this->allowscriptaccessKey] == 1) |
|
419 | 419 | { |
420 | 420 | $m[0] = $m[0].'<param name="allowscriptaccess" value="never"></param>'; |
421 | 421 | } |
@@ -425,26 +425,26 @@ discard block |
||
425 | 425 | |
426 | 426 | function _checkAllowScriptAccess($m) |
427 | 427 | { |
428 | - if($m[1] == 'object') |
|
428 | + if ($m[1] == 'object') |
|
429 | 429 | { |
430 | 430 | $this->allowscriptaccessList[] = 1; |
431 | 431 | } |
432 | 432 | |
433 | - if($m[1] == 'param') |
|
433 | + if ($m[1] == 'param') |
|
434 | 434 | { |
435 | - if(stripos($m[0], 'allowscriptaccess')) |
|
435 | + if (stripos($m[0], 'allowscriptaccess')) |
|
436 | 436 | { |
437 | 437 | $m[0] = '<param name="allowscriptaccess" value="never"'; |
438 | - if(substr($m[0], -1) == '/') |
|
438 | + if (substr($m[0], -1) == '/') |
|
439 | 439 | { |
440 | 440 | $m[0] .= '/'; |
441 | 441 | } |
442 | - $this->allowscriptaccessList[count($this->allowscriptaccessList)-1]--; |
|
442 | + $this->allowscriptaccessList[count($this->allowscriptaccessList) - 1]--; |
|
443 | 443 | } |
444 | 444 | } |
445 | - else if($m[1] == 'embed') |
|
445 | + else if ($m[1] == 'embed') |
|
446 | 446 | { |
447 | - if(stripos($m[0], 'allowscriptaccess')) |
|
447 | + if (stripos($m[0], 'allowscriptaccess')) |
|
448 | 448 | { |
449 | 449 | $m[0] = preg_replace('/always|samedomain/i', 'never', $m[0]); |
450 | 450 | } |
@@ -458,24 +458,24 @@ discard block |
||
458 | 458 | |
459 | 459 | function getContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true, $stripEmbedTagException = false) |
460 | 460 | { |
461 | - if(!$this->document_srl) return; |
|
461 | + if (!$this->document_srl) return; |
|
462 | 462 | |
463 | - if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
463 | + if ($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
464 | 464 | |
465 | 465 | $result = $this->_checkAccessibleFromStatus(); |
466 | - if($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
466 | + if ($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
467 | 467 | |
468 | 468 | $content = $this->get('content'); |
469 | - if(!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl')); |
|
469 | + if (!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl')); |
|
470 | 470 | |
471 | 471 | // Define a link if using a rewrite module |
472 | 472 | $oContext = &Context::getInstance(); |
473 | - if($oContext->allow_rewrite) |
|
473 | + if ($oContext->allow_rewrite) |
|
474 | 474 | { |
475 | - $content = preg_replace('/<a([ \t]+)href=("|\')\.\/\?/i',"<a href=\\2". Context::getRequestUri() ."?", $content); |
|
475 | + $content = preg_replace('/<a([ \t]+)href=("|\')\.\/\?/i', "<a href=\\2".Context::getRequestUri()."?", $content); |
|
476 | 476 | } |
477 | 477 | // To display a pop-up menu |
478 | - if($add_popup_menu) |
|
478 | + if ($add_popup_menu) |
|
479 | 479 | { |
480 | 480 | $content = sprintf( |
481 | 481 | '%s<div class="document_popup_menu"><a href="#popup_menu_area" class="document_%d" onclick="return false">%s</a></div>', |
@@ -484,10 +484,10 @@ discard block |
||
484 | 484 | ); |
485 | 485 | } |
486 | 486 | // If additional content information is set |
487 | - if($add_content_info) |
|
487 | + if ($add_content_info) |
|
488 | 488 | { |
489 | 489 | $memberSrl = $this->get('member_srl'); |
490 | - if($memberSrl < 0) |
|
490 | + if ($memberSrl < 0) |
|
491 | 491 | { |
492 | 492 | $memberSrl = 0; |
493 | 493 | } |
@@ -503,12 +503,12 @@ discard block |
||
503 | 503 | } |
504 | 504 | else |
505 | 505 | { |
506 | - if($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content); |
|
506 | + if ($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content); |
|
507 | 507 | } |
508 | 508 | // Change the image path to a valid absolute path if resource_realpath is true |
509 | - if($resource_realpath) |
|
509 | + if ($resource_realpath) |
|
510 | 510 | { |
511 | - $content = preg_replace_callback('/<img([^>]+)>/i',array($this,'replaceResourceRealPath'), $content); |
|
511 | + $content = preg_replace_callback('/<img([^>]+)>/i', array($this, 'replaceResourceRealPath'), $content); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | return $content; |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | $content = trim(cut_str($content, $str_size, $tail)); |
558 | 558 | |
559 | 559 | // Replace back < , <, " |
560 | - $content = str_replace(array('<', '>', '"'),array('<', '>', '"'), $content); |
|
560 | + $content = str_replace(array('<', '>', '"'), array('<', '>', '"'), $content); |
|
561 | 561 | |
562 | 562 | return $content; |
563 | 563 | } |
@@ -570,13 +570,13 @@ discard block |
||
570 | 570 | function getRegdateTime() |
571 | 571 | { |
572 | 572 | $regdate = $this->get('regdate'); |
573 | - $year = substr($regdate,0,4); |
|
574 | - $month = substr($regdate,4,2); |
|
575 | - $day = substr($regdate,6,2); |
|
576 | - $hour = substr($regdate,8,2); |
|
577 | - $min = substr($regdate,10,2); |
|
578 | - $sec = substr($regdate,12,2); |
|
579 | - return mktime($hour,$min,$sec,$month,$day,$year); |
|
573 | + $year = substr($regdate, 0, 4); |
|
574 | + $month = substr($regdate, 4, 2); |
|
575 | + $day = substr($regdate, 6, 2); |
|
576 | + $hour = substr($regdate, 8, 2); |
|
577 | + $min = substr($regdate, 10, 2); |
|
578 | + $sec = substr($regdate, 12, 2); |
|
579 | + return mktime($hour, $min, $sec, $month, $day, $year); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | function getRegdateGM() |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | |
587 | 587 | function getRegdateDT() |
588 | 588 | { |
589 | - return $this->getRegdate('Y-m-d').'T'.$this->getRegdate('H:i:s').substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3,2); |
|
589 | + return $this->getRegdate('Y-m-d').'T'.$this->getRegdate('H:i:s').substr($GLOBALS['_time_zone'], 0, 3).':'.substr($GLOBALS['_time_zone'], 3, 2); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | function getUpdate($format = 'Y.m.d H:i:s') |
@@ -596,13 +596,13 @@ discard block |
||
596 | 596 | |
597 | 597 | function getUpdateTime() |
598 | 598 | { |
599 | - $year = substr($this->get('last_update'),0,4); |
|
600 | - $month = substr($this->get('last_update'),4,2); |
|
601 | - $day = substr($this->get('last_update'),6,2); |
|
602 | - $hour = substr($this->get('last_update'),8,2); |
|
603 | - $min = substr($this->get('last_update'),10,2); |
|
604 | - $sec = substr($this->get('last_update'),12,2); |
|
605 | - return mktime($hour,$min,$sec,$month,$day,$year); |
|
599 | + $year = substr($this->get('last_update'), 0, 4); |
|
600 | + $month = substr($this->get('last_update'), 4, 2); |
|
601 | + $day = substr($this->get('last_update'), 6, 2); |
|
602 | + $hour = substr($this->get('last_update'), 8, 2); |
|
603 | + $min = substr($this->get('last_update'), 10, 2); |
|
604 | + $sec = substr($this->get('last_update'), 12, 2); |
|
605 | + return mktime($hour, $min, $sec, $month, $day, $year); |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | function getUpdateGM() |
@@ -612,21 +612,21 @@ discard block |
||
612 | 612 | |
613 | 613 | function getUpdateDT() |
614 | 614 | { |
615 | - return $this->getUpdate('Y-m-d').'T'.$this->getUpdate('H:i:s').substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3,2); |
|
615 | + return $this->getUpdate('Y-m-d').'T'.$this->getUpdate('H:i:s').substr($GLOBALS['_time_zone'], 0, 3).':'.substr($GLOBALS['_time_zone'], 3, 2); |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | function getPermanentUrl() |
619 | 619 | { |
620 | - return getFullUrl('','mid', $this->getDocumentMid('document_srl'), 'document_srl', $this->get('document_srl')); |
|
620 | + return getFullUrl('', 'mid', $this->getDocumentMid('document_srl'), 'document_srl', $this->get('document_srl')); |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | function getTrackbackUrl() |
624 | 624 | { |
625 | - if(!$this->document_srl) return; |
|
625 | + if (!$this->document_srl) return; |
|
626 | 626 | |
627 | 627 | // Generate a key to prevent spams |
628 | 628 | $oTrackbackModel = getModel('trackback'); |
629 | - if($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid()); |
|
629 | + if ($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid()); |
|
630 | 630 | } |
631 | 631 | |
632 | 632 | /** |
@@ -636,24 +636,24 @@ discard block |
||
636 | 636 | function updateReadedCount() |
637 | 637 | { |
638 | 638 | $oDocumentController = getController('document'); |
639 | - if($oDocumentController->updateReadedCount($this)) |
|
639 | + if ($oDocumentController->updateReadedCount($this)) |
|
640 | 640 | { |
641 | 641 | $readed_count = $this->get('readed_count'); |
642 | - $this->add('readed_count', $readed_count+1); |
|
642 | + $this->add('readed_count', $readed_count + 1); |
|
643 | 643 | } |
644 | 644 | } |
645 | 645 | |
646 | 646 | function isExtraVarsExists() |
647 | 647 | { |
648 | - if(!$this->get('module_srl')) return false; |
|
648 | + if (!$this->get('module_srl')) return false; |
|
649 | 649 | $oDocumentModel = getModel('document'); |
650 | 650 | $extra_keys = $oDocumentModel->getExtraKeys($this->get('module_srl')); |
651 | - return count($extra_keys)?true:false; |
|
651 | + return count($extra_keys) ?true:false; |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | function getExtraVars() |
655 | 655 | { |
656 | - if(!$this->get('module_srl') || !$this->document_srl) return null; |
|
656 | + if (!$this->get('module_srl') || !$this->document_srl) return null; |
|
657 | 657 | |
658 | 658 | $oDocumentModel = getModel('document'); |
659 | 659 | return $oDocumentModel->getExtraVars($this->get('module_srl'), $this->document_srl); |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | function getExtraValue($idx) |
663 | 663 | { |
664 | 664 | $extra_vars = $this->getExtraVars(); |
665 | - if(is_array($extra_vars) && array_key_exists($idx,$extra_vars)) |
|
665 | + if (is_array($extra_vars) && array_key_exists($idx, $extra_vars)) |
|
666 | 666 | { |
667 | 667 | return $extra_vars[$idx]->getValue(); |
668 | 668 | } |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | function getExtraValueHTML($idx) |
676 | 676 | { |
677 | 677 | $extra_vars = $this->getExtraVars(); |
678 | - if(is_array($extra_vars) && array_key_exists($idx,$extra_vars)) |
|
678 | + if (is_array($extra_vars) && array_key_exists($idx, $extra_vars)) |
|
679 | 679 | { |
680 | 680 | return $extra_vars[$idx]->getValueHTML(); |
681 | 681 | } |
@@ -689,16 +689,16 @@ discard block |
||
689 | 689 | { |
690 | 690 | $extra_vars = $this->getExtraVars(); |
691 | 691 | |
692 | - if($extra_vars) |
|
692 | + if ($extra_vars) |
|
693 | 693 | { |
694 | 694 | // Handle extra variable(eid) |
695 | - foreach($extra_vars as $idx => $key) |
|
695 | + foreach ($extra_vars as $idx => $key) |
|
696 | 696 | { |
697 | 697 | $extra_eid[$key->eid] = $key; |
698 | 698 | } |
699 | 699 | } |
700 | 700 | |
701 | - if(is_array($extra_eid) && array_key_exists($eid,$extra_eid)) |
|
701 | + if (is_array($extra_eid) && array_key_exists($eid, $extra_eid)) |
|
702 | 702 | { |
703 | 703 | return $extra_eid[$eid]->getValue(); |
704 | 704 | } |
@@ -712,12 +712,12 @@ discard block |
||
712 | 712 | { |
713 | 713 | $extra_vars = $this->getExtraVars(); |
714 | 714 | // Handle extra variable(eid) |
715 | - foreach($extra_vars as $idx => $key) |
|
715 | + foreach ($extra_vars as $idx => $key) |
|
716 | 716 | { |
717 | 717 | $extra_eid[$key->eid] = $key; |
718 | 718 | } |
719 | 719 | |
720 | - if(is_array($extra_eid) && array_key_exists($eid,$extra_eid)) |
|
720 | + if (is_array($extra_eid) && array_key_exists($eid, $extra_eid)) |
|
721 | 721 | { |
722 | 722 | return $extra_eid[$eid]->getValueHTML(); |
723 | 723 | } |
@@ -741,13 +741,13 @@ discard block |
||
741 | 741 | |
742 | 742 | function getComments() |
743 | 743 | { |
744 | - if(!$this->getCommentCount()) return; |
|
745 | - if(!$this->isGranted() && $this->isSecret()) return; |
|
744 | + if (!$this->getCommentCount()) return; |
|
745 | + if (!$this->isGranted() && $this->isSecret()) return; |
|
746 | 746 | // cpage is a number of comment pages |
747 | 747 | $cpageStr = sprintf('%d_cpage', $this->document_srl); |
748 | 748 | $cpage = Context::get($cpageStr); |
749 | 749 | |
750 | - if(!$cpage) |
|
750 | + if (!$cpage) |
|
751 | 751 | { |
752 | 752 | $cpage = Context::get('cpage'); |
753 | 753 | } |
@@ -755,19 +755,19 @@ discard block |
||
755 | 755 | // Get a list of comments |
756 | 756 | $oCommentModel = getModel('comment'); |
757 | 757 | $output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin); |
758 | - if(!$output->toBool() || !count($output->data)) return; |
|
758 | + if (!$output->toBool() || !count($output->data)) return; |
|
759 | 759 | // Create commentItem object from a comment list |
760 | 760 | // If admin priviledge is granted on parent posts, you can read its child posts. |
761 | 761 | $accessible = array(); |
762 | 762 | $comment_list = array(); |
763 | - foreach($output->data as $key => $val) |
|
763 | + foreach ($output->data as $key => $val) |
|
764 | 764 | { |
765 | 765 | $oCommentItem = new commentItem(); |
766 | 766 | $oCommentItem->setAttribute($val); |
767 | 767 | // If permission is granted to the post, you can access it temporarily |
768 | - if($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true; |
|
768 | + if ($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true; |
|
769 | 769 | // If the comment is set to private and it belongs child post, it is allowable to read the comment for who has a admin privilege on its parent post |
770 | - if($val->parent_srl>0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl]===true) |
|
770 | + if ($val->parent_srl > 0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl] === true) |
|
771 | 771 | { |
772 | 772 | $oCommentItem->setAccessible(); |
773 | 773 | } |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | // Variable setting to be displayed on the skin |
777 | 777 | Context::set($cpageStr, $output->page_navigation->cur_page); |
778 | 778 | Context::set('cpage', $output->page_navigation->cur_page); |
779 | - if($output->total_page>1) $this->comment_page_navigation = $output->page_navigation; |
|
779 | + if ($output->total_page > 1) $this->comment_page_navigation = $output->page_navigation; |
|
780 | 780 | |
781 | 781 | return $comment_list; |
782 | 782 | } |
@@ -788,9 +788,9 @@ discard block |
||
788 | 788 | |
789 | 789 | function getTrackbacks() |
790 | 790 | { |
791 | - if(!$this->document_srl) return; |
|
791 | + if (!$this->document_srl) return; |
|
792 | 792 | |
793 | - if(!$this->allowTrackback() || !$this->get('trackback_count')) return; |
|
793 | + if (!$this->allowTrackback() || !$this->get('trackback_count')) return; |
|
794 | 794 | |
795 | 795 | $oTrackbackModel = getModel('trackback'); |
796 | 796 | return $oTrackbackModel->getTrackbackList($this->document_srl, $is_admin); |
@@ -798,47 +798,47 @@ discard block |
||
798 | 798 | |
799 | 799 | function thumbnailExists($width = 80, $height = 0, $type = '') |
800 | 800 | { |
801 | - if(!$this->document_srl) return false; |
|
802 | - if(!$this->getThumbnail($width, $height, $type)) return false; |
|
801 | + if (!$this->document_srl) return false; |
|
802 | + if (!$this->getThumbnail($width, $height, $type)) return false; |
|
803 | 803 | return true; |
804 | 804 | } |
805 | 805 | |
806 | 806 | function getThumbnail($width = 80, $height = 0, $thumbnail_type = '') |
807 | 807 | { |
808 | 808 | // Return false if the document doesn't exist |
809 | - if(!$this->document_srl) return; |
|
809 | + if (!$this->document_srl) return; |
|
810 | 810 | |
811 | - if($this->isSecret() && !$this->isGranted()) |
|
811 | + if ($this->isSecret() && !$this->isGranted()) |
|
812 | 812 | { |
813 | 813 | return; |
814 | 814 | } |
815 | 815 | |
816 | 816 | // If not specify its height, create a square |
817 | - if(!$height) $height = $width; |
|
817 | + if (!$height) $height = $width; |
|
818 | 818 | |
819 | 819 | // Return false if neither attachement nor image files in the document |
820 | 820 | $content = $this->get('content'); |
821 | - if(!$this->get('uploaded_count')) |
|
821 | + if (!$this->get('uploaded_count')) |
|
822 | 822 | { |
823 | - if(!$content) |
|
823 | + if (!$content) |
|
824 | 824 | { |
825 | 825 | $args = new stdClass(); |
826 | 826 | $args->document_srl = $this->document_srl; |
827 | 827 | $output = executeQuery('document.getDocument', $args, array('content')); |
828 | - if($output->toBool() && $output->data) |
|
828 | + if ($output->toBool() && $output->data) |
|
829 | 829 | { |
830 | 830 | $content = $output->data->content; |
831 | 831 | $this->add('content', $content); |
832 | 832 | } |
833 | 833 | } |
834 | 834 | |
835 | - if(!preg_match("!<img!is", $content)) return; |
|
835 | + if (!preg_match("!<img!is", $content)) return; |
|
836 | 836 | } |
837 | 837 | // Get thumbnai_type information from document module's configuration |
838 | - if(!in_array($thumbnail_type, array('crop','ratio'))) |
|
838 | + if (!in_array($thumbnail_type, array('crop', 'ratio'))) |
|
839 | 839 | { |
840 | 840 | $config = $GLOBALS['__document_config__']; |
841 | - if(!$config) |
|
841 | + if (!$config) |
|
842 | 842 | { |
843 | 843 | $oDocumentModel = getModel('document'); |
844 | 844 | $config = $oDocumentModel->getDocumentConfig(); |
@@ -848,15 +848,15 @@ discard block |
||
848 | 848 | } |
849 | 849 | |
850 | 850 | // Define thumbnail information |
851 | - $thumbnail_path = sprintf('files/thumbnails/%s',getNumberingPath($this->document_srl, 3)); |
|
851 | + $thumbnail_path = sprintf('files/thumbnails/%s', getNumberingPath($this->document_srl, 3)); |
|
852 | 852 | $thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type); |
853 | 853 | $thumbnail_lockfile = sprintf('%s%dx%d.%s.lock', $thumbnail_path, $width, $height, $thumbnail_type); |
854 | 854 | $thumbnail_url = Context::getRequestUri().$thumbnail_file; |
855 | 855 | |
856 | 856 | // Return false if thumbnail file exists and its size is 0. Otherwise, return its path |
857 | - if(file_exists($thumbnail_file) || file_exists($thumbnail_lockfile)) |
|
857 | + if (file_exists($thumbnail_file) || file_exists($thumbnail_lockfile)) |
|
858 | 858 | { |
859 | - if(filesize($thumbnail_file) < 1) |
|
859 | + if (filesize($thumbnail_file) < 1) |
|
860 | 860 | { |
861 | 861 | return FALSE; |
862 | 862 | } |
@@ -874,64 +874,64 @@ discard block |
||
874 | 874 | $is_tmp_file = false; |
875 | 875 | |
876 | 876 | // Find an iamge file among attached files if exists |
877 | - if($this->hasUploadedFiles()) |
|
877 | + if ($this->hasUploadedFiles()) |
|
878 | 878 | { |
879 | 879 | $file_list = $this->getUploadedFiles(); |
880 | 880 | |
881 | 881 | $first_image = null; |
882 | - foreach($file_list as $file) |
|
882 | + foreach ($file_list as $file) |
|
883 | 883 | { |
884 | - if($file->direct_download !== 'Y') continue; |
|
884 | + if ($file->direct_download !== 'Y') continue; |
|
885 | 885 | |
886 | - if($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
|
886 | + if ($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
|
887 | 887 | { |
888 | 888 | $source_file = $file->uploaded_filename; |
889 | 889 | break; |
890 | 890 | } |
891 | 891 | |
892 | - if($first_image) continue; |
|
892 | + if ($first_image) continue; |
|
893 | 893 | |
894 | - if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
|
894 | + if (preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
|
895 | 895 | { |
896 | - if(file_exists($file->uploaded_filename)) |
|
896 | + if (file_exists($file->uploaded_filename)) |
|
897 | 897 | { |
898 | 898 | $first_image = $file->uploaded_filename; |
899 | 899 | } |
900 | 900 | } |
901 | 901 | } |
902 | 902 | |
903 | - if(!$source_file && $first_image) |
|
903 | + if (!$source_file && $first_image) |
|
904 | 904 | { |
905 | 905 | $source_file = $first_image; |
906 | 906 | } |
907 | 907 | } |
908 | 908 | // If not exists, file an image file from the content |
909 | 909 | $is_tmp_file = false; |
910 | - if(!$source_file) |
|
910 | + if (!$source_file) |
|
911 | 911 | { |
912 | 912 | $random = new Password(); |
913 | 913 | |
914 | 914 | preg_match_all("!<img[^>]*src=(?:\"|\')([^\"\']*?)(?:\"|\')!is", $content, $matches, PREG_SET_ORDER); |
915 | 915 | |
916 | - foreach($matches as $target_image) |
|
916 | + foreach ($matches as $target_image) |
|
917 | 917 | { |
918 | 918 | $target_src = trim($target_image[1]); |
919 | - if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
919 | + if (preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
920 | 920 | |
921 | - if(!preg_match('/^(http|https):\/\//i',$target_src)) |
|
921 | + if (!preg_match('/^(http|https):\/\//i', $target_src)) |
|
922 | 922 | { |
923 | 923 | $target_src = Context::getRequestUri().$target_src; |
924 | 924 | } |
925 | 925 | |
926 | 926 | $target_src = htmlspecialchars_decode($target_src); |
927 | 927 | |
928 | - $tmp_file = _XE_PATH_ . 'files/cache/tmp/' . $random->createSecureSalt(32, 'hex'); |
|
928 | + $tmp_file = _XE_PATH_.'files/cache/tmp/'.$random->createSecureSalt(32, 'hex'); |
|
929 | 929 | FileHandler::getRemoteFile($target_src, $tmp_file); |
930 | - if(!file_exists($tmp_file)) continue; |
|
930 | + if (!file_exists($tmp_file)) continue; |
|
931 | 931 | |
932 | 932 | $imageinfo = getimagesize($tmp_file); |
933 | 933 | list($_w, $_h) = $imageinfo; |
934 | - if($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) { |
|
934 | + if ($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) { |
|
935 | 935 | FileHandler::removeFile($tmp_file); |
936 | 936 | continue; |
937 | 937 | } |
@@ -942,13 +942,13 @@ discard block |
||
942 | 942 | } |
943 | 943 | } |
944 | 944 | |
945 | - if($source_file) |
|
945 | + if ($source_file) |
|
946 | 946 | { |
947 | 947 | $output_file = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, 'jpg', $thumbnail_type); |
948 | 948 | } |
949 | 949 | |
950 | 950 | // Remove source file if it was temporary |
951 | - if($is_tmp_file) |
|
951 | + if ($is_tmp_file) |
|
952 | 952 | { |
953 | 953 | FileHandler::removeFile($source_file); |
954 | 954 | } |
@@ -957,14 +957,14 @@ discard block |
||
957 | 957 | FileHandler::removeFile($thumbnail_lockfile); |
958 | 958 | |
959 | 959 | // Return the thumbnail path if it was successfully generated |
960 | - if($output_file) |
|
960 | + if ($output_file) |
|
961 | 961 | { |
962 | 962 | return $thumbnail_url; |
963 | 963 | } |
964 | 964 | // Create an empty file if thumbnail generation failed |
965 | 965 | else |
966 | 966 | { |
967 | - FileHandler::writeFile($thumbnail_file, '','w'); |
|
967 | + FileHandler::writeFile($thumbnail_file, '', 'w'); |
|
968 | 968 | } |
969 | 969 | |
970 | 970 | return; |
@@ -978,21 +978,21 @@ discard block |
||
978 | 978 | */ |
979 | 979 | function getExtraImages($time_interval = 43200) |
980 | 980 | { |
981 | - if(!$this->document_srl) return; |
|
981 | + if (!$this->document_srl) return; |
|
982 | 982 | // variables for icon list |
983 | 983 | $buffs = array(); |
984 | 984 | |
985 | 985 | $check_files = false; |
986 | 986 | |
987 | 987 | // Check if secret post is |
988 | - if($this->isSecret()) $buffs[] = "secret"; |
|
988 | + if ($this->isSecret()) $buffs[] = "secret"; |
|
989 | 989 | |
990 | 990 | // Set the latest time |
991 | - $time_check = date("YmdHis", $_SERVER['REQUEST_TIME']-$time_interval); |
|
991 | + $time_check = date("YmdHis", $_SERVER['REQUEST_TIME'] - $time_interval); |
|
992 | 992 | |
993 | 993 | // Check new post |
994 | - if($this->get('regdate')>$time_check) $buffs[] = "new"; |
|
995 | - else if($this->get('last_update')>$time_check) $buffs[] = "update"; |
|
994 | + if ($this->get('regdate') > $time_check) $buffs[] = "new"; |
|
995 | + else if ($this->get('last_update') > $time_check) $buffs[] = "update"; |
|
996 | 996 | |
997 | 997 | /* |
998 | 998 | $content = $this->get('content'); |
@@ -1015,14 +1015,14 @@ discard block |
||
1015 | 1015 | */ |
1016 | 1016 | |
1017 | 1017 | // Check the attachment |
1018 | - if($this->hasUploadedFiles()) $buffs[] = "file"; |
|
1018 | + if ($this->hasUploadedFiles()) $buffs[] = "file"; |
|
1019 | 1019 | |
1020 | 1020 | return $buffs; |
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | function getStatus() |
1024 | 1024 | { |
1025 | - if(!$this->get('status')) return $this->getDefaultStatus(); |
|
1025 | + if (!$this->get('status')) return $this->getDefaultStatus(); |
|
1026 | 1026 | return $this->get('status'); |
1027 | 1027 | } |
1028 | 1028 | |
@@ -1033,11 +1033,11 @@ discard block |
||
1033 | 1033 | */ |
1034 | 1034 | function printExtraImages($time_check = 43200) |
1035 | 1035 | { |
1036 | - if(!$this->document_srl) return; |
|
1036 | + if (!$this->document_srl) return; |
|
1037 | 1037 | |
1038 | 1038 | $oDocumentModel = getModel('document'); |
1039 | 1039 | $documentConfig = $oDocumentModel->getDocumentConfig(); |
1040 | - if(Mobile::isFromMobilePhone()) |
|
1040 | + if (Mobile::isFromMobilePhone()) |
|
1041 | 1041 | { |
1042 | 1042 | $iconSkin = $documentConfig->micons; |
1043 | 1043 | } |
@@ -1045,13 +1045,13 @@ discard block |
||
1045 | 1045 | { |
1046 | 1046 | $iconSkin = $documentConfig->icons; |
1047 | 1047 | } |
1048 | - $path = sprintf('%s%s',getUrl(), "modules/document/tpl/icons/$iconSkin/"); |
|
1048 | + $path = sprintf('%s%s', getUrl(), "modules/document/tpl/icons/$iconSkin/"); |
|
1049 | 1049 | |
1050 | 1050 | $buffs = $this->getExtraImages($time_check); |
1051 | - if(!count($buffs)) return; |
|
1051 | + if (!count($buffs)) return; |
|
1052 | 1052 | |
1053 | 1053 | $buff = array(); |
1054 | - foreach($buffs as $key => $val) |
|
1054 | + foreach ($buffs as $key => $val) |
|
1055 | 1055 | { |
1056 | 1056 | $buff[] = sprintf('<img src="%s%s.gif" alt="%s" title="%s" style="margin-right:2px;" />', $path, $val, $val, $val); |
1057 | 1057 | } |
@@ -1060,20 +1060,20 @@ discard block |
||
1060 | 1060 | |
1061 | 1061 | function hasUploadedFiles() |
1062 | 1062 | { |
1063 | - if(!$this->document_srl) return; |
|
1063 | + if (!$this->document_srl) return; |
|
1064 | 1064 | |
1065 | - if($this->isSecret() && !$this->isGranted()) return false; |
|
1066 | - return $this->get('uploaded_count')? true : false; |
|
1065 | + if ($this->isSecret() && !$this->isGranted()) return false; |
|
1066 | + return $this->get('uploaded_count') ? true : false; |
|
1067 | 1067 | } |
1068 | 1068 | |
1069 | 1069 | function getUploadedFiles($sortIndex = 'file_srl') |
1070 | 1070 | { |
1071 | - if(!$this->document_srl) return; |
|
1071 | + if (!$this->document_srl) return; |
|
1072 | 1072 | |
1073 | - if($this->isSecret() && !$this->isGranted()) return; |
|
1074 | - if(!$this->get('uploaded_count')) return; |
|
1073 | + if ($this->isSecret() && !$this->isGranted()) return; |
|
1074 | + if (!$this->get('uploaded_count')) return; |
|
1075 | 1075 | |
1076 | - if(!$this->uploadedFiles[$sortIndex]) |
|
1076 | + if (!$this->uploadedFiles[$sortIndex]) |
|
1077 | 1077 | { |
1078 | 1078 | $oFileModel = getModel('file'); |
1079 | 1079 | $this->uploadedFiles[$sortIndex] = $oFileModel->getFiles($this->document_srl, array(), $sortIndex, true); |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | function getEditor() |
1090 | 1090 | { |
1091 | 1091 | $module_srl = $this->get('module_srl'); |
1092 | - if(!$module_srl) $module_srl = Context::get('module_srl'); |
|
1092 | + if (!$module_srl) $module_srl = Context::get('module_srl'); |
|
1093 | 1093 | |
1094 | 1094 | $oEditorModel = getModel('editor'); |
1095 | 1095 | return $oEditorModel->getModuleEditor('document', $module_srl, $this->document_srl, 'document_srl', 'content'); |
@@ -1104,7 +1104,7 @@ discard block |
||
1104 | 1104 | { |
1105 | 1105 | // Return false if not authorized, if a secret document, if the document is set not to allow any comment |
1106 | 1106 | if (!$this->allowComment()) return false; |
1107 | - if(!$this->isGranted() && $this->isSecret()) return false; |
|
1107 | + if (!$this->isGranted() && $this->isSecret()) return false; |
|
1108 | 1108 | |
1109 | 1109 | return true; |
1110 | 1110 | } |
@@ -1115,7 +1115,7 @@ discard block |
||
1115 | 1115 | */ |
1116 | 1116 | function getCommentEditor() |
1117 | 1117 | { |
1118 | - if(!$this->isEnableComment()) return; |
|
1118 | + if (!$this->isEnableComment()) return; |
|
1119 | 1119 | |
1120 | 1120 | $oEditorModel = getModel('editor'); |
1121 | 1121 | return $oEditorModel->getModuleEditor('comment', $this->get('module_srl'), $comment_srl, 'comment_srl', 'content'); |
@@ -1127,10 +1127,10 @@ discard block |
||
1127 | 1127 | */ |
1128 | 1128 | function getProfileImage() |
1129 | 1129 | { |
1130 | - if(!$this->isExists() || !$this->get('member_srl')) return; |
|
1130 | + if (!$this->isExists() || !$this->get('member_srl')) return; |
|
1131 | 1131 | $oMemberModel = getModel('member'); |
1132 | 1132 | $profile_info = $oMemberModel->getProfileImage($this->get('member_srl')); |
1133 | - if(!$profile_info) return; |
|
1133 | + if (!$profile_info) return; |
|
1134 | 1134 | |
1135 | 1135 | return $profile_info->src; |
1136 | 1136 | } |
@@ -1142,21 +1142,21 @@ discard block |
||
1142 | 1142 | function getSignature() |
1143 | 1143 | { |
1144 | 1144 | // Pass if a document doesn't exist |
1145 | - if(!$this->isExists() || !$this->get('member_srl')) return; |
|
1145 | + if (!$this->isExists() || !$this->get('member_srl')) return; |
|
1146 | 1146 | // Get signature information |
1147 | 1147 | $oMemberModel = getModel('member'); |
1148 | 1148 | $signature = $oMemberModel->getSignature($this->get('member_srl')); |
1149 | 1149 | // Check if a maximum height of signiture is set in the member module |
1150 | - if(!isset($GLOBALS['__member_signature_max_height'])) |
|
1150 | + if (!isset($GLOBALS['__member_signature_max_height'])) |
|
1151 | 1151 | { |
1152 | 1152 | $oModuleModel = getModel('module'); |
1153 | 1153 | $member_config = $oModuleModel->getModuleConfig('member'); |
1154 | 1154 | $GLOBALS['__member_signature_max_height'] = $member_config->signature_max_height; |
1155 | 1155 | } |
1156 | - if($signature) |
|
1156 | + if ($signature) |
|
1157 | 1157 | { |
1158 | 1158 | $max_signature_height = $GLOBALS['__member_signature_max_height']; |
1159 | - if($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature); |
|
1159 | + if ($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature); |
|
1160 | 1160 | } |
1161 | 1161 | |
1162 | 1162 | return $signature; |
@@ -1169,7 +1169,7 @@ discard block |
||
1169 | 1169 | */ |
1170 | 1170 | function replaceResourceRealPath($matches) |
1171 | 1171 | { |
1172 | - return preg_replace('/src=(["\']?)files/i','src=$1'.Context::getRequestUri().'files', $matches[0]); |
|
1172 | + return preg_replace('/src=(["\']?)files/i', 'src=$1'.Context::getRequestUri().'files', $matches[0]); |
|
1173 | 1173 | } |
1174 | 1174 | |
1175 | 1175 | /** |
@@ -1180,19 +1180,19 @@ discard block |
||
1180 | 1180 | function _checkAccessibleFromStatus() |
1181 | 1181 | { |
1182 | 1182 | $logged_info = Context::get('logged_info'); |
1183 | - if($logged_info->is_admin == 'Y') return true; |
|
1183 | + if ($logged_info->is_admin == 'Y') return true; |
|
1184 | 1184 | |
1185 | 1185 | $status = $this->get('status'); |
1186 | - if(empty($status)) return false; |
|
1186 | + if (empty($status)) return false; |
|
1187 | 1187 | |
1188 | 1188 | $oDocumentModel = getModel('document'); |
1189 | 1189 | $configStatusList = $oDocumentModel->getStatusList(); |
1190 | 1190 | |
1191 | - if($status == $configStatusList['public'] || $status == $configStatusList['publish']) |
|
1191 | + if ($status == $configStatusList['public'] || $status == $configStatusList['publish']) |
|
1192 | 1192 | return true; |
1193 | - else if($status == $configStatusList['private'] || $status == $configStatusList['secret']) |
|
1193 | + else if ($status == $configStatusList['private'] || $status == $configStatusList['secret']) |
|
1194 | 1194 | { |
1195 | - if($this->get('member_srl') == $logged_info->member_srl) |
|
1195 | + if ($this->get('member_srl') == $logged_info->member_srl) |
|
1196 | 1196 | return true; |
1197 | 1197 | } |
1198 | 1198 | return false; |
@@ -79,7 +79,9 @@ discard block |
||
79 | 79 | */ |
80 | 80 | function _loadFromDB($load_extra_vars = true) |
81 | 81 | { |
82 | - if(!$this->document_srl) return; |
|
82 | + if(!$this->document_srl) { |
|
83 | + return; |
|
84 | + } |
|
83 | 85 | |
84 | 86 | $document_item = false; |
85 | 87 | $cache_put = false; |
@@ -111,8 +113,7 @@ discard block |
||
111 | 113 | { |
112 | 114 | $oCacheHandler->put($cache_key, $document_item); |
113 | 115 | } |
114 | - } |
|
115 | - else |
|
116 | + } else |
|
116 | 117 | { |
117 | 118 | $document_item->readed_count = $output->data->readed_count; |
118 | 119 | $document_item->voted_count = $output->data->voted_count; |
@@ -159,23 +160,33 @@ discard block |
||
159 | 160 | |
160 | 161 | function isGranted() |
161 | 162 | { |
162 | - if($_SESSION['own_document'][$this->document_srl]) return $this->grant_cache = true; |
|
163 | + if($_SESSION['own_document'][$this->document_srl]) { |
|
164 | + return $this->grant_cache = true; |
|
165 | + } |
|
163 | 166 | |
164 | 167 | if($this->grant_cache !== null) |
165 | 168 | { |
166 | 169 | return $this->grant_cache; |
167 | 170 | } |
168 | 171 | |
169 | - if(!Context::get('is_logged')) return $this->grant_cache = false; |
|
172 | + if(!Context::get('is_logged')) { |
|
173 | + return $this->grant_cache = false; |
|
174 | + } |
|
170 | 175 | |
171 | 176 | $logged_info = Context::get('logged_info'); |
172 | - if($logged_info->is_admin == 'Y') return $this->grant_cache = true; |
|
177 | + if($logged_info->is_admin == 'Y') { |
|
178 | + return $this->grant_cache = true; |
|
179 | + } |
|
173 | 180 | |
174 | 181 | $oModuleModel = getModel('module'); |
175 | 182 | $grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($this->get('module_srl')), $logged_info); |
176 | - if($grant->manager) return $this->grant_cache = true; |
|
183 | + if($grant->manager) { |
|
184 | + return $this->grant_cache = true; |
|
185 | + } |
|
177 | 186 | |
178 | - if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl')*-1 == $logged_info->member_srl)) return $this->grant_cache = true; |
|
187 | + if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl')*-1 == $logged_info->member_srl)) { |
|
188 | + return $this->grant_cache = true; |
|
189 | + } |
|
179 | 190 | |
180 | 191 | return $this->grant_cache = false; |
181 | 192 | } |
@@ -194,7 +205,9 @@ discard block |
||
194 | 205 | function allowComment() |
195 | 206 | { |
196 | 207 | // init write, document is not exists. so allow comment status is true |
197 | - if(!$this->isExists()) return true; |
|
208 | + if(!$this->isExists()) { |
|
209 | + return true; |
|
210 | + } |
|
198 | 211 | |
199 | 212 | return $this->get('comment_status') == 'ALLOW' ? true : false; |
200 | 213 | } |
@@ -209,8 +222,7 @@ discard block |
||
209 | 222 | if(!getClass('trackback')) |
210 | 223 | { |
211 | 224 | $allow_trackback_status = false; |
212 | - } |
|
213 | - else |
|
225 | + } else |
|
214 | 226 | { |
215 | 227 | // If the trackback module is configured to be disabled, do not allow. Otherwise, check the setting of each module. |
216 | 228 | $oModuleModel = getModel('module'); |
@@ -221,15 +233,21 @@ discard block |
||
221 | 233 | $trackback_config = new stdClass(); |
222 | 234 | } |
223 | 235 | |
224 | - if(!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y'; |
|
225 | - if($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false; |
|
226 | - else |
|
236 | + if(!isset($trackback_config->enable_trackback)) { |
|
237 | + $trackback_config->enable_trackback = 'Y'; |
|
238 | + } |
|
239 | + if($trackback_config->enable_trackback != 'Y') { |
|
240 | + $allow_trackback_status = false; |
|
241 | + } else |
|
227 | 242 | { |
228 | 243 | $module_srl = $this->get('module_srl'); |
229 | 244 | // Check settings of each module |
230 | 245 | $module_config = $oModuleModel->getModulePartConfig('trackback', $module_srl); |
231 | - if($module_config->enable_trackback == 'N') $allow_trackback_status = false; |
|
232 | - else if($this->get('allow_trackback')=='Y' || !$this->isExists()) $allow_trackback_status = true; |
|
246 | + if($module_config->enable_trackback == 'N') { |
|
247 | + $allow_trackback_status = false; |
|
248 | + } else if($this->get('allow_trackback')=='Y' || !$this->isExists()) { |
|
249 | + $allow_trackback_status = true; |
|
250 | + } |
|
233 | 251 | } |
234 | 252 | } |
235 | 253 | } |
@@ -238,14 +256,18 @@ discard block |
||
238 | 256 | |
239 | 257 | function isLocked() |
240 | 258 | { |
241 | - if(!$this->isExists()) return false; |
|
259 | + if(!$this->isExists()) { |
|
260 | + return false; |
|
261 | + } |
|
242 | 262 | |
243 | 263 | return $this->get('comment_status') == 'ALLOW' ? false : true; |
244 | 264 | } |
245 | 265 | |
246 | 266 | function isEditable() |
247 | 267 | { |
248 | - if($this->isGranted() || !$this->get('member_srl')) return true; |
|
268 | + if($this->isGranted() || !$this->get('member_srl')) { |
|
269 | + return true; |
|
270 | + } |
|
249 | 271 | return false; |
250 | 272 | } |
251 | 273 | |
@@ -267,9 +289,14 @@ discard block |
||
267 | 289 | |
268 | 290 | function doCart() |
269 | 291 | { |
270 | - if(!$this->document_srl) return false; |
|
271 | - if($this->isCarted()) $this->removeCart(); |
|
272 | - else $this->addCart(); |
|
292 | + if(!$this->document_srl) { |
|
293 | + return false; |
|
294 | + } |
|
295 | + if($this->isCarted()) { |
|
296 | + $this->removeCart(); |
|
297 | + } else { |
|
298 | + $this->addCart(); |
|
299 | + } |
|
273 | 300 | } |
274 | 301 | |
275 | 302 | function addCart() |
@@ -295,16 +322,26 @@ discard block |
||
295 | 322 | */ |
296 | 323 | function notify($type, $content) |
297 | 324 | { |
298 | - if(!$this->document_srl) return; |
|
325 | + if(!$this->document_srl) { |
|
326 | + return; |
|
327 | + } |
|
299 | 328 | // return if it is not useNotify |
300 | - if(!$this->useNotify()) return; |
|
329 | + if(!$this->useNotify()) { |
|
330 | + return; |
|
331 | + } |
|
301 | 332 | // Pass if an author is not a logged-in user |
302 | - if(!$this->get('member_srl')) return; |
|
333 | + if(!$this->get('member_srl')) { |
|
334 | + return; |
|
335 | + } |
|
303 | 336 | // Return if the currently logged-in user is an author |
304 | 337 | $logged_info = Context::get('logged_info'); |
305 | - if($logged_info->member_srl == $this->get('member_srl')) return; |
|
338 | + if($logged_info->member_srl == $this->get('member_srl')) { |
|
339 | + return; |
|
340 | + } |
|
306 | 341 | // List variables |
307 | - if($type) $title = "[".$type."] "; |
|
342 | + if($type) { |
|
343 | + $title = "[".$type."] "; |
|
344 | + } |
|
308 | 345 | $title .= cut_str(strip_tags($content), 10, '...'); |
309 | 346 | $content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>',$content, getFullUrl('','document_srl',$this->document_srl), getFullUrl('','document_srl',$this->document_srl)); |
310 | 347 | $receiver_srl = $this->get('member_srl'); |
@@ -331,16 +368,22 @@ discard block |
||
331 | 368 | |
332 | 369 | function isExistsHomepage() |
333 | 370 | { |
334 | - if(trim($this->get('homepage'))) return true; |
|
371 | + if(trim($this->get('homepage'))) { |
|
372 | + return true; |
|
373 | + } |
|
335 | 374 | return false; |
336 | 375 | } |
337 | 376 | |
338 | 377 | function getHomepageUrl() |
339 | 378 | { |
340 | 379 | $url = trim($this->get('homepage')); |
341 | - if(!$url) return; |
|
380 | + if(!$url) { |
|
381 | + return; |
|
382 | + } |
|
342 | 383 | |
343 | - if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) $url = 'http://' . $url; |
|
384 | + if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) { |
|
385 | + $url = 'http://' . $url; |
|
386 | + } |
|
344 | 387 | |
345 | 388 | return $url; |
346 | 389 | } |
@@ -372,43 +415,65 @@ discard block |
||
372 | 415 | |
373 | 416 | function getTitleText($cut_size = 0, $tail='...') |
374 | 417 | { |
375 | - if(!$this->document_srl) return; |
|
418 | + if(!$this->document_srl) { |
|
419 | + return; |
|
420 | + } |
|
376 | 421 | |
377 | - if($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail); |
|
378 | - else $title = $this->get('title'); |
|
422 | + if($cut_size) { |
|
423 | + $title = cut_str($this->get('title'), $cut_size, $tail); |
|
424 | + } else { |
|
425 | + $title = $this->get('title'); |
|
426 | + } |
|
379 | 427 | |
380 | 428 | return $title; |
381 | 429 | } |
382 | 430 | |
383 | 431 | function getTitle($cut_size = 0, $tail='...') |
384 | 432 | { |
385 | - if(!$this->document_srl) return; |
|
433 | + if(!$this->document_srl) { |
|
434 | + return; |
|
435 | + } |
|
386 | 436 | |
387 | 437 | $title = $this->getTitleText($cut_size, $tail); |
388 | 438 | |
389 | 439 | $attrs = array(); |
390 | 440 | $this->add('title_color', trim($this->get('title_color'))); |
391 | - if($this->get('title_bold')=='Y') $attrs[] = "font-weight:bold;"; |
|
392 | - if($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color'); |
|
441 | + if($this->get('title_bold')=='Y') { |
|
442 | + $attrs[] = "font-weight:bold;"; |
|
443 | + } |
|
444 | + if($this->get('title_color') && $this->get('title_color') != 'N') { |
|
445 | + $attrs[] = "color:#".$this->get('title_color'); |
|
446 | + } |
|
393 | 447 | |
394 | - if(count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
395 | - else return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
|
448 | + if(count($attrs)) { |
|
449 | + return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
450 | + } else { |
|
451 | + return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
|
452 | + } |
|
396 | 453 | } |
397 | 454 | |
398 | 455 | function getContentText($strlen = 0) |
399 | 456 | { |
400 | - if(!$this->document_srl) return; |
|
457 | + if(!$this->document_srl) { |
|
458 | + return; |
|
459 | + } |
|
401 | 460 | |
402 | - if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
461 | + if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) { |
|
462 | + return Context::getLang('msg_is_secret'); |
|
463 | + } |
|
403 | 464 | |
404 | 465 | $result = $this->_checkAccessibleFromStatus(); |
405 | - if($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
466 | + if($result) { |
|
467 | + $_SESSION['accessible'][$this->document_srl] = true; |
|
468 | + } |
|
406 | 469 | |
407 | 470 | $content = $this->get('content'); |
408 | 471 | $content = preg_replace_callback('/<(object|param|embed)[^>]*/is', array($this, '_checkAllowScriptAccess'), $content); |
409 | 472 | $content = preg_replace_callback('/<object[^>]*>/is', array($this, '_addAllowScriptAccess'), $content); |
410 | 473 | |
411 | - if($strlen) return cut_str(strip_tags($content),$strlen,'...'); |
|
474 | + if($strlen) { |
|
475 | + return cut_str(strip_tags($content),$strlen,'...'); |
|
476 | + } |
|
412 | 477 | |
413 | 478 | return htmlspecialchars($content); |
414 | 479 | } |
@@ -441,14 +506,12 @@ discard block |
||
441 | 506 | } |
442 | 507 | $this->allowscriptaccessList[count($this->allowscriptaccessList)-1]--; |
443 | 508 | } |
444 | - } |
|
445 | - else if($m[1] == 'embed') |
|
509 | + } else if($m[1] == 'embed') |
|
446 | 510 | { |
447 | 511 | if(stripos($m[0], 'allowscriptaccess')) |
448 | 512 | { |
449 | 513 | $m[0] = preg_replace('/always|samedomain/i', 'never', $m[0]); |
450 | - } |
|
451 | - else |
|
514 | + } else |
|
452 | 515 | { |
453 | 516 | $m[0] = preg_replace('/\<embed/i', '<embed allowscriptaccess="never"', $m[0]); |
454 | 517 | } |
@@ -458,15 +521,23 @@ discard block |
||
458 | 521 | |
459 | 522 | function getContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true, $stripEmbedTagException = false) |
460 | 523 | { |
461 | - if(!$this->document_srl) return; |
|
524 | + if(!$this->document_srl) { |
|
525 | + return; |
|
526 | + } |
|
462 | 527 | |
463 | - if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
528 | + if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) { |
|
529 | + return Context::getLang('msg_is_secret'); |
|
530 | + } |
|
464 | 531 | |
465 | 532 | $result = $this->_checkAccessibleFromStatus(); |
466 | - if($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
533 | + if($result) { |
|
534 | + $_SESSION['accessible'][$this->document_srl] = true; |
|
535 | + } |
|
467 | 536 | |
468 | 537 | $content = $this->get('content'); |
469 | - if(!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl')); |
|
538 | + if(!$stripEmbedTagException) { |
|
539 | + stripEmbedTagForAdmin($content, $this->get('member_srl')); |
|
540 | + } |
|
470 | 541 | |
471 | 542 | // Define a link if using a rewrite module |
472 | 543 | $oContext = &Context::getInstance(); |
@@ -500,10 +571,11 @@ discard block |
||
500 | 571 | $this->document_srl, $memberSrl |
501 | 572 | ); |
502 | 573 | // Add xe_content class although accessing content is not required |
503 | - } |
|
504 | - else |
|
574 | + } else |
|
505 | 575 | { |
506 | - if($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content); |
|
576 | + if($add_xe_content_class) { |
|
577 | + $content = sprintf('<div class="xe_content">%s</div>', $content); |
|
578 | + } |
|
507 | 579 | } |
508 | 580 | // Change the image path to a valid absolute path if resource_realpath is true |
509 | 581 | if($resource_realpath) |
@@ -622,11 +694,15 @@ discard block |
||
622 | 694 | |
623 | 695 | function getTrackbackUrl() |
624 | 696 | { |
625 | - if(!$this->document_srl) return; |
|
697 | + if(!$this->document_srl) { |
|
698 | + return; |
|
699 | + } |
|
626 | 700 | |
627 | 701 | // Generate a key to prevent spams |
628 | 702 | $oTrackbackModel = getModel('trackback'); |
629 | - if($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid()); |
|
703 | + if($oTrackbackModel) { |
|
704 | + return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid()); |
|
705 | + } |
|
630 | 706 | } |
631 | 707 | |
632 | 708 | /** |
@@ -645,7 +721,9 @@ discard block |
||
645 | 721 | |
646 | 722 | function isExtraVarsExists() |
647 | 723 | { |
648 | - if(!$this->get('module_srl')) return false; |
|
724 | + if(!$this->get('module_srl')) { |
|
725 | + return false; |
|
726 | + } |
|
649 | 727 | $oDocumentModel = getModel('document'); |
650 | 728 | $extra_keys = $oDocumentModel->getExtraKeys($this->get('module_srl')); |
651 | 729 | return count($extra_keys)?true:false; |
@@ -653,7 +731,9 @@ discard block |
||
653 | 731 | |
654 | 732 | function getExtraVars() |
655 | 733 | { |
656 | - if(!$this->get('module_srl') || !$this->document_srl) return null; |
|
734 | + if(!$this->get('module_srl') || !$this->document_srl) { |
|
735 | + return null; |
|
736 | + } |
|
657 | 737 | |
658 | 738 | $oDocumentModel = getModel('document'); |
659 | 739 | return $oDocumentModel->getExtraVars($this->get('module_srl'), $this->document_srl); |
@@ -665,8 +745,7 @@ discard block |
||
665 | 745 | if(is_array($extra_vars) && array_key_exists($idx,$extra_vars)) |
666 | 746 | { |
667 | 747 | return $extra_vars[$idx]->getValue(); |
668 | - } |
|
669 | - else |
|
748 | + } else |
|
670 | 749 | { |
671 | 750 | return ''; |
672 | 751 | } |
@@ -678,8 +757,7 @@ discard block |
||
678 | 757 | if(is_array($extra_vars) && array_key_exists($idx,$extra_vars)) |
679 | 758 | { |
680 | 759 | return $extra_vars[$idx]->getValueHTML(); |
681 | - } |
|
682 | - else |
|
760 | + } else |
|
683 | 761 | { |
684 | 762 | return ''; |
685 | 763 | } |
@@ -701,8 +779,7 @@ discard block |
||
701 | 779 | if(is_array($extra_eid) && array_key_exists($eid,$extra_eid)) |
702 | 780 | { |
703 | 781 | return $extra_eid[$eid]->getValue(); |
704 | - } |
|
705 | - else |
|
782 | + } else |
|
706 | 783 | { |
707 | 784 | return ''; |
708 | 785 | } |
@@ -720,8 +797,7 @@ discard block |
||
720 | 797 | if(is_array($extra_eid) && array_key_exists($eid,$extra_eid)) |
721 | 798 | { |
722 | 799 | return $extra_eid[$eid]->getValueHTML(); |
723 | - } |
|
724 | - else |
|
800 | + } else |
|
725 | 801 | { |
726 | 802 | return ''; |
727 | 803 | } |
@@ -741,8 +817,12 @@ discard block |
||
741 | 817 | |
742 | 818 | function getComments() |
743 | 819 | { |
744 | - if(!$this->getCommentCount()) return; |
|
745 | - if(!$this->isGranted() && $this->isSecret()) return; |
|
820 | + if(!$this->getCommentCount()) { |
|
821 | + return; |
|
822 | + } |
|
823 | + if(!$this->isGranted() && $this->isSecret()) { |
|
824 | + return; |
|
825 | + } |
|
746 | 826 | // cpage is a number of comment pages |
747 | 827 | $cpageStr = sprintf('%d_cpage', $this->document_srl); |
748 | 828 | $cpage = Context::get($cpageStr); |
@@ -755,7 +835,9 @@ discard block |
||
755 | 835 | // Get a list of comments |
756 | 836 | $oCommentModel = getModel('comment'); |
757 | 837 | $output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin); |
758 | - if(!$output->toBool() || !count($output->data)) return; |
|
838 | + if(!$output->toBool() || !count($output->data)) { |
|
839 | + return; |
|
840 | + } |
|
759 | 841 | // Create commentItem object from a comment list |
760 | 842 | // If admin priviledge is granted on parent posts, you can read its child posts. |
761 | 843 | $accessible = array(); |
@@ -765,7 +847,9 @@ discard block |
||
765 | 847 | $oCommentItem = new commentItem(); |
766 | 848 | $oCommentItem->setAttribute($val); |
767 | 849 | // If permission is granted to the post, you can access it temporarily |
768 | - if($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true; |
|
850 | + if($oCommentItem->isGranted()) { |
|
851 | + $accessible[$val->comment_srl] = true; |
|
852 | + } |
|
769 | 853 | // If the comment is set to private and it belongs child post, it is allowable to read the comment for who has a admin privilege on its parent post |
770 | 854 | if($val->parent_srl>0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl]===true) |
771 | 855 | { |
@@ -776,7 +860,9 @@ discard block |
||
776 | 860 | // Variable setting to be displayed on the skin |
777 | 861 | Context::set($cpageStr, $output->page_navigation->cur_page); |
778 | 862 | Context::set('cpage', $output->page_navigation->cur_page); |
779 | - if($output->total_page>1) $this->comment_page_navigation = $output->page_navigation; |
|
863 | + if($output->total_page>1) { |
|
864 | + $this->comment_page_navigation = $output->page_navigation; |
|
865 | + } |
|
780 | 866 | |
781 | 867 | return $comment_list; |
782 | 868 | } |
@@ -788,9 +874,13 @@ discard block |
||
788 | 874 | |
789 | 875 | function getTrackbacks() |
790 | 876 | { |
791 | - if(!$this->document_srl) return; |
|
877 | + if(!$this->document_srl) { |
|
878 | + return; |
|
879 | + } |
|
792 | 880 | |
793 | - if(!$this->allowTrackback() || !$this->get('trackback_count')) return; |
|
881 | + if(!$this->allowTrackback() || !$this->get('trackback_count')) { |
|
882 | + return; |
|
883 | + } |
|
794 | 884 | |
795 | 885 | $oTrackbackModel = getModel('trackback'); |
796 | 886 | return $oTrackbackModel->getTrackbackList($this->document_srl, $is_admin); |
@@ -798,15 +888,21 @@ discard block |
||
798 | 888 | |
799 | 889 | function thumbnailExists($width = 80, $height = 0, $type = '') |
800 | 890 | { |
801 | - if(!$this->document_srl) return false; |
|
802 | - if(!$this->getThumbnail($width, $height, $type)) return false; |
|
891 | + if(!$this->document_srl) { |
|
892 | + return false; |
|
893 | + } |
|
894 | + if(!$this->getThumbnail($width, $height, $type)) { |
|
895 | + return false; |
|
896 | + } |
|
803 | 897 | return true; |
804 | 898 | } |
805 | 899 | |
806 | 900 | function getThumbnail($width = 80, $height = 0, $thumbnail_type = '') |
807 | 901 | { |
808 | 902 | // Return false if the document doesn't exist |
809 | - if(!$this->document_srl) return; |
|
903 | + if(!$this->document_srl) { |
|
904 | + return; |
|
905 | + } |
|
810 | 906 | |
811 | 907 | if($this->isSecret() && !$this->isGranted()) |
812 | 908 | { |
@@ -814,7 +910,9 @@ discard block |
||
814 | 910 | } |
815 | 911 | |
816 | 912 | // If not specify its height, create a square |
817 | - if(!$height) $height = $width; |
|
913 | + if(!$height) { |
|
914 | + $height = $width; |
|
915 | + } |
|
818 | 916 | |
819 | 917 | // Return false if neither attachement nor image files in the document |
820 | 918 | $content = $this->get('content'); |
@@ -832,7 +930,9 @@ discard block |
||
832 | 930 | } |
833 | 931 | } |
834 | 932 | |
835 | - if(!preg_match("!<img!is", $content)) return; |
|
933 | + if(!preg_match("!<img!is", $content)) { |
|
934 | + return; |
|
935 | + } |
|
836 | 936 | } |
837 | 937 | // Get thumbnai_type information from document module's configuration |
838 | 938 | if(!in_array($thumbnail_type, array('crop','ratio'))) |
@@ -859,8 +959,7 @@ discard block |
||
859 | 959 | if(filesize($thumbnail_file) < 1) |
860 | 960 | { |
861 | 961 | return FALSE; |
862 | - } |
|
863 | - else |
|
962 | + } else |
|
864 | 963 | { |
865 | 964 | return $thumbnail_url; |
866 | 965 | } |
@@ -881,7 +980,9 @@ discard block |
||
881 | 980 | $first_image = null; |
882 | 981 | foreach($file_list as $file) |
883 | 982 | { |
884 | - if($file->direct_download !== 'Y') continue; |
|
983 | + if($file->direct_download !== 'Y') { |
|
984 | + continue; |
|
985 | + } |
|
885 | 986 | |
886 | 987 | if($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
887 | 988 | { |
@@ -889,7 +990,9 @@ discard block |
||
889 | 990 | break; |
890 | 991 | } |
891 | 992 | |
892 | - if($first_image) continue; |
|
993 | + if($first_image) { |
|
994 | + continue; |
|
995 | + } |
|
893 | 996 | |
894 | 997 | if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
895 | 998 | { |
@@ -916,7 +1019,9 @@ discard block |
||
916 | 1019 | foreach($matches as $target_image) |
917 | 1020 | { |
918 | 1021 | $target_src = trim($target_image[1]); |
919 | - if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
1022 | + if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) { |
|
1023 | + continue; |
|
1024 | + } |
|
920 | 1025 | |
921 | 1026 | if(!preg_match('/^(http|https):\/\//i',$target_src)) |
922 | 1027 | { |
@@ -927,7 +1032,9 @@ discard block |
||
927 | 1032 | |
928 | 1033 | $tmp_file = _XE_PATH_ . 'files/cache/tmp/' . $random->createSecureSalt(32, 'hex'); |
929 | 1034 | FileHandler::getRemoteFile($target_src, $tmp_file); |
930 | - if(!file_exists($tmp_file)) continue; |
|
1035 | + if(!file_exists($tmp_file)) { |
|
1036 | + continue; |
|
1037 | + } |
|
931 | 1038 | |
932 | 1039 | $imageinfo = getimagesize($tmp_file); |
933 | 1040 | list($_w, $_h) = $imageinfo; |
@@ -978,21 +1085,28 @@ discard block |
||
978 | 1085 | */ |
979 | 1086 | function getExtraImages($time_interval = 43200) |
980 | 1087 | { |
981 | - if(!$this->document_srl) return; |
|
1088 | + if(!$this->document_srl) { |
|
1089 | + return; |
|
1090 | + } |
|
982 | 1091 | // variables for icon list |
983 | 1092 | $buffs = array(); |
984 | 1093 | |
985 | 1094 | $check_files = false; |
986 | 1095 | |
987 | 1096 | // Check if secret post is |
988 | - if($this->isSecret()) $buffs[] = "secret"; |
|
1097 | + if($this->isSecret()) { |
|
1098 | + $buffs[] = "secret"; |
|
1099 | + } |
|
989 | 1100 | |
990 | 1101 | // Set the latest time |
991 | 1102 | $time_check = date("YmdHis", $_SERVER['REQUEST_TIME']-$time_interval); |
992 | 1103 | |
993 | 1104 | // Check new post |
994 | - if($this->get('regdate')>$time_check) $buffs[] = "new"; |
|
995 | - else if($this->get('last_update')>$time_check) $buffs[] = "update"; |
|
1105 | + if($this->get('regdate')>$time_check) { |
|
1106 | + $buffs[] = "new"; |
|
1107 | + } else if($this->get('last_update')>$time_check) { |
|
1108 | + $buffs[] = "update"; |
|
1109 | + } |
|
996 | 1110 | |
997 | 1111 | /* |
998 | 1112 | $content = $this->get('content'); |
@@ -1015,14 +1129,18 @@ discard block |
||
1015 | 1129 | */ |
1016 | 1130 | |
1017 | 1131 | // Check the attachment |
1018 | - if($this->hasUploadedFiles()) $buffs[] = "file"; |
|
1132 | + if($this->hasUploadedFiles()) { |
|
1133 | + $buffs[] = "file"; |
|
1134 | + } |
|
1019 | 1135 | |
1020 | 1136 | return $buffs; |
1021 | 1137 | } |
1022 | 1138 | |
1023 | 1139 | function getStatus() |
1024 | 1140 | { |
1025 | - if(!$this->get('status')) return $this->getDefaultStatus(); |
|
1141 | + if(!$this->get('status')) { |
|
1142 | + return $this->getDefaultStatus(); |
|
1143 | + } |
|
1026 | 1144 | return $this->get('status'); |
1027 | 1145 | } |
1028 | 1146 | |
@@ -1033,22 +1151,25 @@ discard block |
||
1033 | 1151 | */ |
1034 | 1152 | function printExtraImages($time_check = 43200) |
1035 | 1153 | { |
1036 | - if(!$this->document_srl) return; |
|
1154 | + if(!$this->document_srl) { |
|
1155 | + return; |
|
1156 | + } |
|
1037 | 1157 | |
1038 | 1158 | $oDocumentModel = getModel('document'); |
1039 | 1159 | $documentConfig = $oDocumentModel->getDocumentConfig(); |
1040 | 1160 | if(Mobile::isFromMobilePhone()) |
1041 | 1161 | { |
1042 | 1162 | $iconSkin = $documentConfig->micons; |
1043 | - } |
|
1044 | - else |
|
1163 | + } else |
|
1045 | 1164 | { |
1046 | 1165 | $iconSkin = $documentConfig->icons; |
1047 | 1166 | } |
1048 | 1167 | $path = sprintf('%s%s',getUrl(), "modules/document/tpl/icons/$iconSkin/"); |
1049 | 1168 | |
1050 | 1169 | $buffs = $this->getExtraImages($time_check); |
1051 | - if(!count($buffs)) return; |
|
1170 | + if(!count($buffs)) { |
|
1171 | + return; |
|
1172 | + } |
|
1052 | 1173 | |
1053 | 1174 | $buff = array(); |
1054 | 1175 | foreach($buffs as $key => $val) |
@@ -1060,18 +1181,28 @@ discard block |
||
1060 | 1181 | |
1061 | 1182 | function hasUploadedFiles() |
1062 | 1183 | { |
1063 | - if(!$this->document_srl) return; |
|
1184 | + if(!$this->document_srl) { |
|
1185 | + return; |
|
1186 | + } |
|
1064 | 1187 | |
1065 | - if($this->isSecret() && !$this->isGranted()) return false; |
|
1188 | + if($this->isSecret() && !$this->isGranted()) { |
|
1189 | + return false; |
|
1190 | + } |
|
1066 | 1191 | return $this->get('uploaded_count')? true : false; |
1067 | 1192 | } |
1068 | 1193 | |
1069 | 1194 | function getUploadedFiles($sortIndex = 'file_srl') |
1070 | 1195 | { |
1071 | - if(!$this->document_srl) return; |
|
1196 | + if(!$this->document_srl) { |
|
1197 | + return; |
|
1198 | + } |
|
1072 | 1199 | |
1073 | - if($this->isSecret() && !$this->isGranted()) return; |
|
1074 | - if(!$this->get('uploaded_count')) return; |
|
1200 | + if($this->isSecret() && !$this->isGranted()) { |
|
1201 | + return; |
|
1202 | + } |
|
1203 | + if(!$this->get('uploaded_count')) { |
|
1204 | + return; |
|
1205 | + } |
|
1075 | 1206 | |
1076 | 1207 | if(!$this->uploadedFiles[$sortIndex]) |
1077 | 1208 | { |
@@ -1089,7 +1220,9 @@ discard block |
||
1089 | 1220 | function getEditor() |
1090 | 1221 | { |
1091 | 1222 | $module_srl = $this->get('module_srl'); |
1092 | - if(!$module_srl) $module_srl = Context::get('module_srl'); |
|
1223 | + if(!$module_srl) { |
|
1224 | + $module_srl = Context::get('module_srl'); |
|
1225 | + } |
|
1093 | 1226 | |
1094 | 1227 | $oEditorModel = getModel('editor'); |
1095 | 1228 | return $oEditorModel->getModuleEditor('document', $module_srl, $this->document_srl, 'document_srl', 'content'); |
@@ -1103,8 +1236,12 @@ discard block |
||
1103 | 1236 | function isEnableComment() |
1104 | 1237 | { |
1105 | 1238 | // Return false if not authorized, if a secret document, if the document is set not to allow any comment |
1106 | - if (!$this->allowComment()) return false; |
|
1107 | - if(!$this->isGranted() && $this->isSecret()) return false; |
|
1239 | + if (!$this->allowComment()) { |
|
1240 | + return false; |
|
1241 | + } |
|
1242 | + if(!$this->isGranted() && $this->isSecret()) { |
|
1243 | + return false; |
|
1244 | + } |
|
1108 | 1245 | |
1109 | 1246 | return true; |
1110 | 1247 | } |
@@ -1115,7 +1252,9 @@ discard block |
||
1115 | 1252 | */ |
1116 | 1253 | function getCommentEditor() |
1117 | 1254 | { |
1118 | - if(!$this->isEnableComment()) return; |
|
1255 | + if(!$this->isEnableComment()) { |
|
1256 | + return; |
|
1257 | + } |
|
1119 | 1258 | |
1120 | 1259 | $oEditorModel = getModel('editor'); |
1121 | 1260 | return $oEditorModel->getModuleEditor('comment', $this->get('module_srl'), $comment_srl, 'comment_srl', 'content'); |
@@ -1127,10 +1266,14 @@ discard block |
||
1127 | 1266 | */ |
1128 | 1267 | function getProfileImage() |
1129 | 1268 | { |
1130 | - if(!$this->isExists() || !$this->get('member_srl')) return; |
|
1269 | + if(!$this->isExists() || !$this->get('member_srl')) { |
|
1270 | + return; |
|
1271 | + } |
|
1131 | 1272 | $oMemberModel = getModel('member'); |
1132 | 1273 | $profile_info = $oMemberModel->getProfileImage($this->get('member_srl')); |
1133 | - if(!$profile_info) return; |
|
1274 | + if(!$profile_info) { |
|
1275 | + return; |
|
1276 | + } |
|
1134 | 1277 | |
1135 | 1278 | return $profile_info->src; |
1136 | 1279 | } |
@@ -1142,7 +1285,9 @@ discard block |
||
1142 | 1285 | function getSignature() |
1143 | 1286 | { |
1144 | 1287 | // Pass if a document doesn't exist |
1145 | - if(!$this->isExists() || !$this->get('member_srl')) return; |
|
1288 | + if(!$this->isExists() || !$this->get('member_srl')) { |
|
1289 | + return; |
|
1290 | + } |
|
1146 | 1291 | // Get signature information |
1147 | 1292 | $oMemberModel = getModel('member'); |
1148 | 1293 | $signature = $oMemberModel->getSignature($this->get('member_srl')); |
@@ -1156,7 +1301,9 @@ discard block |
||
1156 | 1301 | if($signature) |
1157 | 1302 | { |
1158 | 1303 | $max_signature_height = $GLOBALS['__member_signature_max_height']; |
1159 | - if($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature); |
|
1304 | + if($max_signature_height) { |
|
1305 | + $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature); |
|
1306 | + } |
|
1160 | 1307 | } |
1161 | 1308 | |
1162 | 1309 | return $signature; |
@@ -1180,20 +1327,25 @@ discard block |
||
1180 | 1327 | function _checkAccessibleFromStatus() |
1181 | 1328 | { |
1182 | 1329 | $logged_info = Context::get('logged_info'); |
1183 | - if($logged_info->is_admin == 'Y') return true; |
|
1330 | + if($logged_info->is_admin == 'Y') { |
|
1331 | + return true; |
|
1332 | + } |
|
1184 | 1333 | |
1185 | 1334 | $status = $this->get('status'); |
1186 | - if(empty($status)) return false; |
|
1335 | + if(empty($status)) { |
|
1336 | + return false; |
|
1337 | + } |
|
1187 | 1338 | |
1188 | 1339 | $oDocumentModel = getModel('document'); |
1189 | 1340 | $configStatusList = $oDocumentModel->getStatusList(); |
1190 | 1341 | |
1191 | - if($status == $configStatusList['public'] || $status == $configStatusList['publish']) |
|
1192 | - return true; |
|
1193 | - else if($status == $configStatusList['private'] || $status == $configStatusList['secret']) |
|
1342 | + if($status == $configStatusList['public'] || $status == $configStatusList['publish']) { |
|
1343 | + return true; |
|
1344 | + } else if($status == $configStatusList['private'] || $status == $configStatusList['secret']) |
|
1194 | 1345 | { |
1195 | - if($this->get('member_srl') == $logged_info->member_srl) |
|
1196 | - return true; |
|
1346 | + if($this->get('member_srl') == $logged_info->member_srl) { |
|
1347 | + return true; |
|
1348 | + } |
|
1197 | 1349 | } |
1198 | 1350 | return false; |
1199 | 1351 | } |
@@ -238,6 +238,7 @@ |
||
238 | 238 | |
239 | 239 | /** |
240 | 240 | * @brief AutoSave |
241 | + * @param stdClass $args |
|
241 | 242 | */ |
242 | 243 | function doSaveDoc($args) |
243 | 244 | { |
@@ -47,28 +47,28 @@ discard block |
||
47 | 47 | { |
48 | 48 | $component = Context::get('component'); |
49 | 49 | $method = Context::get('method'); |
50 | - if(!$component) return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
50 | + if (!$component) return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
51 | 51 | |
52 | 52 | $oEditorModel = getModel('editor'); |
53 | 53 | $oComponent = &$oEditorModel->getComponentObject($component); |
54 | - if(!$oComponent->toBool()) return $oComponent; |
|
54 | + if (!$oComponent->toBool()) return $oComponent; |
|
55 | 55 | |
56 | - if(!method_exists($oComponent, $method)) return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
56 | + if (!method_exists($oComponent, $method)) return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
57 | 57 | |
58 | 58 | //$output = call_user_method($method, $oComponent); |
59 | 59 | //$output = call_user_func(array($oComponent, $method)); |
60 | - if(method_exists($oComponent, $method)) $output = $oComponent->{$method}(); |
|
61 | - else return new BaseObject(-1,sprintf('%s method is not exists', $method)); |
|
60 | + if (method_exists($oComponent, $method)) $output = $oComponent->{$method}(); |
|
61 | + else return new BaseObject(-1, sprintf('%s method is not exists', $method)); |
|
62 | 62 | |
63 | - if((is_a($output, 'BaseObject') || is_subclass_of($output, 'BaseObject')) && !$output->toBool()) return $output; |
|
63 | + if ((is_a($output, 'BaseObject') || is_subclass_of($output, 'BaseObject')) && !$output->toBool()) return $output; |
|
64 | 64 | |
65 | 65 | $this->setError($oComponent->getError()); |
66 | 66 | $this->setMessage($oComponent->getMessage()); |
67 | 67 | |
68 | 68 | $vars = $oComponent->getVariables(); |
69 | - if(count($vars)) |
|
69 | + if (count($vars)) |
|
70 | 70 | { |
71 | - foreach($vars as $key => $val) |
|
71 | + foreach ($vars as $key => $val) |
|
72 | 72 | { |
73 | 73 | $this->add($key, $val); |
74 | 74 | } |
@@ -86,18 +86,18 @@ discard block |
||
86 | 86 | $module_srl = array(); |
87 | 87 | $oModuleModel = getModel('module'); |
88 | 88 | |
89 | - foreach($target_module_srl as $srl) |
|
89 | + foreach ($target_module_srl as $srl) |
|
90 | 90 | { |
91 | - if(!$srl) continue; |
|
91 | + if (!$srl) continue; |
|
92 | 92 | |
93 | 93 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($srl); |
94 | - if(!$module_info->module_srl) |
|
94 | + if (!$module_info->module_srl) |
|
95 | 95 | { |
96 | 96 | return new BaseObject(-1, 'msg_invalid_request'); |
97 | 97 | } |
98 | 98 | |
99 | 99 | $module_grant = $oModuleModel->getGrant($module_info, $logged_info); |
100 | - if(!$module_grant->manager) |
|
100 | + if (!$module_grant->manager) |
|
101 | 101 | { |
102 | 102 | return new BaseObject(-1, 'msg_not_permitted'); |
103 | 103 | } |
@@ -111,32 +111,32 @@ discard block |
||
111 | 111 | $editor_config->content_style = Context::get('content_style'); |
112 | 112 | $editor_config->comment_content_style = Context::get('comment_content_style'); |
113 | 113 | $editor_config->content_font = Context::get('content_font'); |
114 | - if($editor_config->content_font) |
|
114 | + if ($editor_config->content_font) |
|
115 | 115 | { |
116 | 116 | $font_list = array(); |
117 | - $fonts = explode(',',$editor_config->content_font); |
|
118 | - for($i=0,$c=count($fonts);$i<$c;$i++) |
|
117 | + $fonts = explode(',', $editor_config->content_font); |
|
118 | + for ($i = 0, $c = count($fonts); $i < $c; $i++) |
|
119 | 119 | { |
120 | - $font = trim(str_replace(array('"','\''),'',$fonts[$i])); |
|
121 | - if(!$font) continue; |
|
120 | + $font = trim(str_replace(array('"', '\''), '', $fonts[$i])); |
|
121 | + if (!$font) continue; |
|
122 | 122 | $font_list[] = $font; |
123 | 123 | } |
124 | - if(count($font_list)) $editor_config->content_font = '"'.implode('","',$font_list).'"'; |
|
124 | + if (count($font_list)) $editor_config->content_font = '"'.implode('","', $font_list).'"'; |
|
125 | 125 | } |
126 | 126 | $editor_config->content_font_size = Context::get('content_font_size'); |
127 | 127 | $editor_config->sel_editor_colorset = Context::get('sel_editor_colorset'); |
128 | 128 | $editor_config->sel_comment_editor_colorset = Context::get('sel_comment_editor_colorset'); |
129 | 129 | |
130 | - $grants = array('enable_html_grant','enable_comment_html_grant','upload_file_grant','comment_upload_file_grant','enable_default_component_grant','enable_comment_default_component_grant','enable_component_grant','enable_comment_component_grant'); |
|
130 | + $grants = array('enable_html_grant', 'enable_comment_html_grant', 'upload_file_grant', 'comment_upload_file_grant', 'enable_default_component_grant', 'enable_comment_default_component_grant', 'enable_component_grant', 'enable_comment_component_grant'); |
|
131 | 131 | |
132 | - foreach($grants as $key) |
|
132 | + foreach ($grants as $key) |
|
133 | 133 | { |
134 | 134 | $grant = Context::get($key); |
135 | - if(!$grant) |
|
135 | + if (!$grant) |
|
136 | 136 | { |
137 | 137 | $editor_config->{$key} = array(); |
138 | 138 | } |
139 | - else if(is_array($grant)) |
|
139 | + else if (is_array($grant)) |
|
140 | 140 | { |
141 | 141 | $editor_config->{$key} = $grant; |
142 | 142 | } |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | - $editor_config->editor_height = (int)Context::get('editor_height'); |
|
150 | - $editor_config->comment_editor_height = (int)Context::get('comment_editor_height'); |
|
149 | + $editor_config->editor_height = (int) Context::get('editor_height'); |
|
150 | + $editor_config->comment_editor_height = (int) Context::get('comment_editor_height'); |
|
151 | 151 | $editor_config->enable_autosave = Context::get('enable_autosave'); |
152 | - if($editor_config->enable_autosave != 'Y') $editor_config->enable_autosave = 'N'; |
|
152 | + if ($editor_config->enable_autosave != 'Y') $editor_config->enable_autosave = 'N'; |
|
153 | 153 | |
154 | 154 | $oModuleController = getController('module'); |
155 | - foreach($module_srl as $srl) |
|
155 | + foreach ($module_srl as $srl) |
|
156 | 156 | { |
157 | 157 | $oModuleController->insertModulePartConfig('editor', $srl, $editor_config); |
158 | 158 | } |
@@ -169,31 +169,31 @@ discard block |
||
169 | 169 | */ |
170 | 170 | function triggerEditorComponentCompile(&$content) |
171 | 171 | { |
172 | - if(Context::getResponseMethod()!='HTML') return new BaseObject(); |
|
172 | + if (Context::getResponseMethod() != 'HTML') return new BaseObject(); |
|
173 | 173 | |
174 | 174 | $module_info = Context::get('module_info'); |
175 | 175 | $module_srl = $module_info->module_srl; |
176 | - if($module_srl) |
|
176 | + if ($module_srl) |
|
177 | 177 | { |
178 | 178 | $oEditorModel = getModel('editor'); |
179 | 179 | $editor_config = $oEditorModel->getEditorConfig($module_srl); |
180 | 180 | $content_style = $editor_config->content_style; |
181 | - if($content_style) |
|
181 | + if ($content_style) |
|
182 | 182 | { |
183 | - $path = _XE_PATH_ . 'modules/editor/styles/'.$content_style.'/'; |
|
184 | - if(is_dir($path) && file_exists($path . 'style.ini')) |
|
183 | + $path = _XE_PATH_.'modules/editor/styles/'.$content_style.'/'; |
|
184 | + if (is_dir($path) && file_exists($path.'style.ini')) |
|
185 | 185 | { |
186 | 186 | $ini = file($path.'style.ini'); |
187 | - for($i = 0, $c = count($ini); $i < $c; $i++) |
|
187 | + for ($i = 0, $c = count($ini); $i < $c; $i++) |
|
188 | 188 | { |
189 | 189 | $file = trim($ini[$i]); |
190 | - if(!$file) continue; |
|
190 | + if (!$file) continue; |
|
191 | 191 | |
192 | - if(substr_compare($file, '.css', -4) === 0) |
|
192 | + if (substr_compare($file, '.css', -4) === 0) |
|
193 | 193 | { |
194 | 194 | Context::addCSSFile('./modules/editor/styles/'.$content_style.'/'.$file, false); |
195 | 195 | } |
196 | - elseif(substr_compare($file, '.js', -3) === 0) |
|
196 | + elseif (substr_compare($file, '.js', -3) === 0) |
|
197 | 197 | { |
198 | 198 | Context::addJsFile('./modules/editor/styles/'.$content_style.'/'.$file, false); |
199 | 199 | } |
@@ -202,12 +202,12 @@ discard block |
||
202 | 202 | } |
203 | 203 | $content_font = $editor_config->content_font; |
204 | 204 | $content_font_size = $editor_config->content_font_size; |
205 | - if($content_font || $content_font_size) |
|
205 | + if ($content_font || $content_font_size) |
|
206 | 206 | { |
207 | 207 | $buff = array(); |
208 | 208 | $buff[] = '<style> .xe_content { '; |
209 | - if($content_font) $buff[] = 'font-family:'.$content_font.';'; |
|
210 | - if($content_font_size) $buff[] = 'font-size:'.$content_font_size.';'; |
|
209 | + if ($content_font) $buff[] = 'font-family:'.$content_font.';'; |
|
210 | + if ($content_font_size) $buff[] = 'font-size:'.$content_font_size.';'; |
|
211 | 211 | $buff[] = ' }</style>'; |
212 | 212 | Context::addHtmlHeader(implode('', $buff)); |
213 | 213 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | */ |
223 | 223 | function transComponent($content) |
224 | 224 | { |
225 | - $content = preg_replace_callback('!<(?:(div)|img)([^>]*)editor_component=([^>]*)>(?(1)(.*?)</div>)!is', array($this,'transEditorComponent'), $content); |
|
225 | + $content = preg_replace_callback('!<(?:(div)|img)([^>]*)editor_component=([^>]*)>(?(1)(.*?)</div>)!is', array($this, 'transEditorComponent'), $content); |
|
226 | 226 | return $content; |
227 | 227 | } |
228 | 228 | |
@@ -237,19 +237,19 @@ discard block |
||
237 | 237 | |
238 | 238 | $xml_obj = new stdClass; |
239 | 239 | $xml_obj->attrs = new stdClass; |
240 | - for($i=0,$c=count($m[0]);$i<$c;$i++) |
|
240 | + for ($i = 0, $c = count($m[0]); $i < $c; $i++) |
|
241 | 241 | { |
242 | - if(!isset($xml_obj->attrs)) $xml_obj->attrs = new stdClass; |
|
242 | + if (!isset($xml_obj->attrs)) $xml_obj->attrs = new stdClass; |
|
243 | 243 | $xml_obj->attrs->{$m[1][$i]} = $m[2][$i]; |
244 | 244 | } |
245 | 245 | $xml_obj->body = $match[4]; |
246 | 246 | |
247 | - if(!$xml_obj->attrs->editor_component) return $match[0]; |
|
247 | + if (!$xml_obj->attrs->editor_component) return $match[0]; |
|
248 | 248 | |
249 | 249 | // Get converted codes by using component::transHTML() |
250 | 250 | $oEditorModel = getModel('editor'); |
251 | 251 | $oComponent = &$oEditorModel->getComponentObject($xml_obj->attrs->editor_component, 0); |
252 | - if(!is_object($oComponent)||!method_exists($oComponent, 'transHTML')) return $match[0]; |
|
252 | + if (!is_object($oComponent) || !method_exists($oComponent, 'transHTML')) return $match[0]; |
|
253 | 253 | |
254 | 254 | return $oComponent->transHTML($xml_obj); |
255 | 255 | } |
@@ -259,8 +259,8 @@ discard block |
||
259 | 259 | */ |
260 | 260 | function doSaveDoc($args) |
261 | 261 | { |
262 | - if(!$args->document_srl) $args->document_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
263 | - if(Context::get('is_logged')) |
|
262 | + if (!$args->document_srl) $args->document_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
263 | + if (Context::get('is_logged')) |
|
264 | 264 | { |
265 | 265 | $logged_info = Context::get('logged_info'); |
266 | 266 | $args->member_srl = $logged_info->member_srl; |
@@ -271,11 +271,11 @@ discard block |
||
271 | 271 | } |
272 | 272 | |
273 | 273 | // Get the current module if module_srl doesn't exist |
274 | - if(!$args->module_srl) |
|
274 | + if (!$args->module_srl) |
|
275 | 275 | { |
276 | 276 | $args->module_srl = Context::get('module_srl'); |
277 | 277 | } |
278 | - if(!$args->module_srl) |
|
278 | + if (!$args->module_srl) |
|
279 | 279 | { |
280 | 280 | $current_module_info = Context::get('current_module_info'); |
281 | 281 | $args->module_srl = $current_module_info->module_srl; |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | function deleteSavedDoc($mode = false) |
322 | 322 | { |
323 | 323 | $args = new stdClass(); |
324 | - if(Context::get('is_logged')) |
|
324 | + if (Context::get('is_logged')) |
|
325 | 325 | { |
326 | 326 | $logged_info = Context::get('logged_info'); |
327 | 327 | $args->member_srl = $logged_info->member_srl; |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | } |
333 | 333 | $args->module_srl = Context::get('module_srl'); |
334 | 334 | // Get the current module if module_srl doesn't exist |
335 | - if(!$args->module_srl) |
|
335 | + if (!$args->module_srl) |
|
336 | 336 | { |
337 | 337 | $current_module_info = Context::get('current_module_info'); |
338 | 338 | $args->module_srl = $current_module_info->module_srl; |
@@ -340,13 +340,13 @@ discard block |
||
340 | 340 | // Check if the auto-saved document already exists |
341 | 341 | $output = executeQuery('editor.getSavedDocument', $args); |
342 | 342 | $saved_doc = $output->data; |
343 | - if(!$saved_doc) return; |
|
343 | + if (!$saved_doc) return; |
|
344 | 344 | |
345 | 345 | $oDocumentModel = getModel('document'); |
346 | 346 | $oSaved = $oDocumentModel->getDocument($saved_doc->document_srl); |
347 | - if(!$oSaved->isExists()) |
|
347 | + if (!$oSaved->isExists()) |
|
348 | 348 | { |
349 | - if($mode) |
|
349 | + if ($mode) |
|
350 | 350 | { |
351 | 351 | $output = executeQuery('editor.getSavedDocument', $args); |
352 | 352 | $output = ModuleHandler::triggerCall('editor.deleteSavedDoc', 'after', $saved_doc); |
@@ -374,9 +374,9 @@ discard block |
||
374 | 374 | $oEditorModel = getModel('editor'); |
375 | 375 | $args = new stdClass; |
376 | 376 | |
377 | - if($filter_enabled) $args->enabled = "Y"; |
|
377 | + if ($filter_enabled) $args->enabled = "Y"; |
|
378 | 378 | |
379 | - if($site_srl) |
|
379 | + if ($site_srl) |
|
380 | 380 | { |
381 | 381 | $args->site_srl = $site_srl; |
382 | 382 | $output = executeQuery('editor.getSiteComponentList', $args); |
@@ -389,10 +389,10 @@ discard block |
||
389 | 389 | |
390 | 390 | // Get information about log-in status and its group |
391 | 391 | $is_logged = Context::get('is_logged'); |
392 | - if($is_logged) |
|
392 | + if ($is_logged) |
|
393 | 393 | { |
394 | 394 | $logged_info = Context::get('logged_info'); |
395 | - if($logged_info->group_list && is_array($logged_info->group_list)) |
|
395 | + if ($logged_info->group_list && is_array($logged_info->group_list)) |
|
396 | 396 | { |
397 | 397 | $group_list = array_keys($logged_info->group_list); |
398 | 398 | } |
@@ -400,30 +400,30 @@ discard block |
||
400 | 400 | } |
401 | 401 | |
402 | 402 | // Get xml information for looping DB list |
403 | - if(!is_array($db_list)) $db_list = array($db_list); |
|
403 | + if (!is_array($db_list)) $db_list = array($db_list); |
|
404 | 404 | $component_list = new stdClass(); |
405 | - foreach($db_list as $component) |
|
405 | + foreach ($db_list as $component) |
|
406 | 406 | { |
407 | - if(in_array($component->component_name, array('colorpicker_text','colorpicker_bg'))) continue; |
|
407 | + if (in_array($component->component_name, array('colorpicker_text', 'colorpicker_bg'))) continue; |
|
408 | 408 | |
409 | 409 | $component_name = $component->component_name; |
410 | - if(!$component_name) continue; |
|
410 | + if (!$component_name) continue; |
|
411 | 411 | |
412 | - if(!in_array($component_name, $downloaded_list)) continue; |
|
412 | + if (!in_array($component_name, $downloaded_list)) continue; |
|
413 | 413 | |
414 | 414 | unset($xml_info); |
415 | 415 | $xml_info = $oEditorModel->getComponentXmlInfo($component_name); |
416 | 416 | $xml_info->enabled = $component->enabled; |
417 | 417 | |
418 | - if($component->extra_vars) |
|
418 | + if ($component->extra_vars) |
|
419 | 419 | { |
420 | 420 | $extra_vars = unserialize($component->extra_vars); |
421 | - if($extra_vars->target_group) |
|
421 | + if ($extra_vars->target_group) |
|
422 | 422 | { |
423 | 423 | $xml_info->target_group = $extra_vars->target_group; |
424 | 424 | } |
425 | 425 | |
426 | - if($extra_vars->mid_list && count($extra_vars->mid_list)) |
|
426 | + if ($extra_vars->mid_list && count($extra_vars->mid_list)) |
|
427 | 427 | { |
428 | 428 | $xml_info->mid_list = $extra_vars->mid_list; |
429 | 429 | } |
@@ -450,9 +450,9 @@ discard block |
||
450 | 450 | if(!in_array(Context::get('mid'), $extra_vars->mid_list)) continue; |
451 | 451 | }*/ |
452 | 452 | // Check the configuration of the editor component |
453 | - if($xml_info->extra_vars) |
|
453 | + if ($xml_info->extra_vars) |
|
454 | 454 | { |
455 | - foreach($xml_info->extra_vars as $key => $val) |
|
455 | + foreach ($xml_info->extra_vars as $key => $val) |
|
456 | 456 | { |
457 | 457 | $xml_info->extra_vars->{$key}->value = $extra_vars->{$key}; |
458 | 458 | } |
@@ -463,25 +463,25 @@ discard block |
||
463 | 463 | // Get buttons, icons, images |
464 | 464 | $icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/icon.gif'; |
465 | 465 | $component_icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/component_icon.gif'; |
466 | - if(file_exists($icon_file)) $component_list->{$component_name}->icon = true; |
|
467 | - if(file_exists($component_icon_file)) $component_list->{$component_name}->component_icon = true; |
|
466 | + if (file_exists($icon_file)) $component_list->{$component_name}->icon = true; |
|
467 | + if (file_exists($component_icon_file)) $component_list->{$component_name}->component_icon = true; |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | // Return if it checks enabled only |
471 | - if($filter_enabled) |
|
471 | + if ($filter_enabled) |
|
472 | 472 | { |
473 | 473 | $cache_file = $oEditorModel->getCacheFile($filter_enabled, $site_srl); |
474 | - $buff = sprintf('<?php if(!defined("__XE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"','\\"',serialize($component_list))); |
|
474 | + $buff = sprintf('<?php if(!defined("__XE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"', '\\"', serialize($component_list))); |
|
475 | 475 | FileHandler::writeFile($cache_file, $buff); |
476 | 476 | return $component_list; |
477 | 477 | } |
478 | 478 | |
479 | 479 | // Get xml_info of downloaded list |
480 | - foreach($downloaded_list as $component_name) |
|
480 | + foreach ($downloaded_list as $component_name) |
|
481 | 481 | { |
482 | - if(in_array($component_name, array('colorpicker_text','colorpicker_bg'))) continue; |
|
482 | + if (in_array($component_name, array('colorpicker_text', 'colorpicker_bg'))) continue; |
|
483 | 483 | // Pass if configured |
484 | - if($component_list->{$component_name}) continue; |
|
484 | + if ($component_list->{$component_name}) continue; |
|
485 | 485 | // Insert data into the DB |
486 | 486 | $oEditorController = getAdminController('editor'); |
487 | 487 | $oEditorController->insertComponent($component_name, false, $site_srl); |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | } |
495 | 495 | |
496 | 496 | $cache_file = $oEditorModel->getCacheFile($filter_enabled, $site_srl); |
497 | - $buff = sprintf('<?php if(!defined("__XE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"','\\"',serialize($component_list))); |
|
497 | + $buff = sprintf('<?php if(!defined("__XE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"', '\\"', serialize($component_list))); |
|
498 | 498 | FileHandler::writeFile($cache_file, $buff); |
499 | 499 | |
500 | 500 | return $component_list; |
@@ -516,9 +516,9 @@ discard block |
||
516 | 516 | $editorConfig = $oModuleModel->getModulePartConfig('editor', $obj->originModuleSrl); |
517 | 517 | |
518 | 518 | $oModuleController = getController('module'); |
519 | - if(is_array($obj->moduleSrlList)) |
|
519 | + if (is_array($obj->moduleSrlList)) |
|
520 | 520 | { |
521 | - foreach($obj->moduleSrlList AS $key=>$moduleSrl) |
|
521 | + foreach ($obj->moduleSrlList AS $key=>$moduleSrl) |
|
522 | 522 | { |
523 | 523 | $oModuleController->insertModulePartConfig('editor', $moduleSrl, $editorConfig); |
524 | 524 | } |
@@ -47,20 +47,31 @@ discard block |
||
47 | 47 | { |
48 | 48 | $component = Context::get('component'); |
49 | 49 | $method = Context::get('method'); |
50 | - if(!$component) return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
50 | + if(!$component) { |
|
51 | + return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
52 | + } |
|
51 | 53 | |
52 | 54 | $oEditorModel = getModel('editor'); |
53 | 55 | $oComponent = &$oEditorModel->getComponentObject($component); |
54 | - if(!$oComponent->toBool()) return $oComponent; |
|
56 | + if(!$oComponent->toBool()) { |
|
57 | + return $oComponent; |
|
58 | + } |
|
55 | 59 | |
56 | - if(!method_exists($oComponent, $method)) return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
60 | + if(!method_exists($oComponent, $method)) { |
|
61 | + return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
62 | + } |
|
57 | 63 | |
58 | 64 | //$output = call_user_method($method, $oComponent); |
59 | 65 | //$output = call_user_func(array($oComponent, $method)); |
60 | - if(method_exists($oComponent, $method)) $output = $oComponent->{$method}(); |
|
61 | - else return new BaseObject(-1,sprintf('%s method is not exists', $method)); |
|
66 | + if(method_exists($oComponent, $method)) { |
|
67 | + $output = $oComponent->{$method}(); |
|
68 | + } else { |
|
69 | + return new BaseObject(-1,sprintf('%s method is not exists', $method)); |
|
70 | + } |
|
62 | 71 | |
63 | - if((is_a($output, 'BaseObject') || is_subclass_of($output, 'BaseObject')) && !$output->toBool()) return $output; |
|
72 | + if((is_a($output, 'BaseObject') || is_subclass_of($output, 'BaseObject')) && !$output->toBool()) { |
|
73 | + return $output; |
|
74 | + } |
|
64 | 75 | |
65 | 76 | $this->setError($oComponent->getError()); |
66 | 77 | $this->setMessage($oComponent->getMessage()); |
@@ -88,7 +99,9 @@ discard block |
||
88 | 99 | |
89 | 100 | foreach($target_module_srl as $srl) |
90 | 101 | { |
91 | - if(!$srl) continue; |
|
102 | + if(!$srl) { |
|
103 | + continue; |
|
104 | + } |
|
92 | 105 | |
93 | 106 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($srl); |
94 | 107 | if(!$module_info->module_srl) |
@@ -118,10 +131,14 @@ discard block |
||
118 | 131 | for($i=0,$c=count($fonts);$i<$c;$i++) |
119 | 132 | { |
120 | 133 | $font = trim(str_replace(array('"','\''),'',$fonts[$i])); |
121 | - if(!$font) continue; |
|
134 | + if(!$font) { |
|
135 | + continue; |
|
136 | + } |
|
122 | 137 | $font_list[] = $font; |
123 | 138 | } |
124 | - if(count($font_list)) $editor_config->content_font = '"'.implode('","',$font_list).'"'; |
|
139 | + if(count($font_list)) { |
|
140 | + $editor_config->content_font = '"'.implode('","',$font_list).'"'; |
|
141 | + } |
|
125 | 142 | } |
126 | 143 | $editor_config->content_font_size = Context::get('content_font_size'); |
127 | 144 | $editor_config->sel_editor_colorset = Context::get('sel_editor_colorset'); |
@@ -135,12 +152,10 @@ discard block |
||
135 | 152 | if(!$grant) |
136 | 153 | { |
137 | 154 | $editor_config->{$key} = array(); |
138 | - } |
|
139 | - else if(is_array($grant)) |
|
155 | + } else if(is_array($grant)) |
|
140 | 156 | { |
141 | 157 | $editor_config->{$key} = $grant; |
142 | - } |
|
143 | - else |
|
158 | + } else |
|
144 | 159 | { |
145 | 160 | $editor_config->{$key} = explode('|@|', $grant); |
146 | 161 | } |
@@ -149,7 +164,9 @@ discard block |
||
149 | 164 | $editor_config->editor_height = (int)Context::get('editor_height'); |
150 | 165 | $editor_config->comment_editor_height = (int)Context::get('comment_editor_height'); |
151 | 166 | $editor_config->enable_autosave = Context::get('enable_autosave'); |
152 | - if($editor_config->enable_autosave != 'Y') $editor_config->enable_autosave = 'N'; |
|
167 | + if($editor_config->enable_autosave != 'Y') { |
|
168 | + $editor_config->enable_autosave = 'N'; |
|
169 | + } |
|
153 | 170 | |
154 | 171 | $oModuleController = getController('module'); |
155 | 172 | foreach($module_srl as $srl) |
@@ -169,7 +186,9 @@ discard block |
||
169 | 186 | */ |
170 | 187 | function triggerEditorComponentCompile(&$content) |
171 | 188 | { |
172 | - if(Context::getResponseMethod()!='HTML') return new BaseObject(); |
|
189 | + if(Context::getResponseMethod()!='HTML') { |
|
190 | + return new BaseObject(); |
|
191 | + } |
|
173 | 192 | |
174 | 193 | $module_info = Context::get('module_info'); |
175 | 194 | $module_srl = $module_info->module_srl; |
@@ -187,13 +206,14 @@ discard block |
||
187 | 206 | for($i = 0, $c = count($ini); $i < $c; $i++) |
188 | 207 | { |
189 | 208 | $file = trim($ini[$i]); |
190 | - if(!$file) continue; |
|
209 | + if(!$file) { |
|
210 | + continue; |
|
211 | + } |
|
191 | 212 | |
192 | 213 | if(substr_compare($file, '.css', -4) === 0) |
193 | 214 | { |
194 | 215 | Context::addCSSFile('./modules/editor/styles/'.$content_style.'/'.$file, false); |
195 | - } |
|
196 | - elseif(substr_compare($file, '.js', -3) === 0) |
|
216 | + } elseif(substr_compare($file, '.js', -3) === 0) |
|
197 | 217 | { |
198 | 218 | Context::addJsFile('./modules/editor/styles/'.$content_style.'/'.$file, false); |
199 | 219 | } |
@@ -206,8 +226,12 @@ discard block |
||
206 | 226 | { |
207 | 227 | $buff = array(); |
208 | 228 | $buff[] = '<style> .xe_content { '; |
209 | - if($content_font) $buff[] = 'font-family:'.$content_font.';'; |
|
210 | - if($content_font_size) $buff[] = 'font-size:'.$content_font_size.';'; |
|
229 | + if($content_font) { |
|
230 | + $buff[] = 'font-family:'.$content_font.';'; |
|
231 | + } |
|
232 | + if($content_font_size) { |
|
233 | + $buff[] = 'font-size:'.$content_font_size.';'; |
|
234 | + } |
|
211 | 235 | $buff[] = ' }</style>'; |
212 | 236 | Context::addHtmlHeader(implode('', $buff)); |
213 | 237 | } |
@@ -239,17 +263,23 @@ discard block |
||
239 | 263 | $xml_obj->attrs = new stdClass; |
240 | 264 | for($i=0,$c=count($m[0]);$i<$c;$i++) |
241 | 265 | { |
242 | - if(!isset($xml_obj->attrs)) $xml_obj->attrs = new stdClass; |
|
266 | + if(!isset($xml_obj->attrs)) { |
|
267 | + $xml_obj->attrs = new stdClass; |
|
268 | + } |
|
243 | 269 | $xml_obj->attrs->{$m[1][$i]} = $m[2][$i]; |
244 | 270 | } |
245 | 271 | $xml_obj->body = $match[4]; |
246 | 272 | |
247 | - if(!$xml_obj->attrs->editor_component) return $match[0]; |
|
273 | + if(!$xml_obj->attrs->editor_component) { |
|
274 | + return $match[0]; |
|
275 | + } |
|
248 | 276 | |
249 | 277 | // Get converted codes by using component::transHTML() |
250 | 278 | $oEditorModel = getModel('editor'); |
251 | 279 | $oComponent = &$oEditorModel->getComponentObject($xml_obj->attrs->editor_component, 0); |
252 | - if(!is_object($oComponent)||!method_exists($oComponent, 'transHTML')) return $match[0]; |
|
280 | + if(!is_object($oComponent)||!method_exists($oComponent, 'transHTML')) { |
|
281 | + return $match[0]; |
|
282 | + } |
|
253 | 283 | |
254 | 284 | return $oComponent->transHTML($xml_obj); |
255 | 285 | } |
@@ -259,13 +289,14 @@ discard block |
||
259 | 289 | */ |
260 | 290 | function doSaveDoc($args) |
261 | 291 | { |
262 | - if(!$args->document_srl) $args->document_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
292 | + if(!$args->document_srl) { |
|
293 | + $args->document_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
294 | + } |
|
263 | 295 | if(Context::get('is_logged')) |
264 | 296 | { |
265 | 297 | $logged_info = Context::get('logged_info'); |
266 | 298 | $args->member_srl = $logged_info->member_srl; |
267 | - } |
|
268 | - else |
|
299 | + } else |
|
269 | 300 | { |
270 | 301 | $args->ipaddress = $_SERVER['REMOTE_ADDR']; |
271 | 302 | } |
@@ -325,8 +356,7 @@ discard block |
||
325 | 356 | { |
326 | 357 | $logged_info = Context::get('logged_info'); |
327 | 358 | $args->member_srl = $logged_info->member_srl; |
328 | - } |
|
329 | - else |
|
359 | + } else |
|
330 | 360 | { |
331 | 361 | $args->ipaddress = $_SERVER['REMOTE_ADDR']; |
332 | 362 | } |
@@ -340,7 +370,9 @@ discard block |
||
340 | 370 | // Check if the auto-saved document already exists |
341 | 371 | $output = executeQuery('editor.getSavedDocument', $args); |
342 | 372 | $saved_doc = $output->data; |
343 | - if(!$saved_doc) return; |
|
373 | + if(!$saved_doc) { |
|
374 | + return; |
|
375 | + } |
|
344 | 376 | |
345 | 377 | $oDocumentModel = getModel('document'); |
346 | 378 | $oSaved = $oDocumentModel->getDocument($saved_doc->document_srl); |
@@ -374,14 +406,17 @@ discard block |
||
374 | 406 | $oEditorModel = getModel('editor'); |
375 | 407 | $args = new stdClass; |
376 | 408 | |
377 | - if($filter_enabled) $args->enabled = "Y"; |
|
409 | + if($filter_enabled) { |
|
410 | + $args->enabled = "Y"; |
|
411 | + } |
|
378 | 412 | |
379 | 413 | if($site_srl) |
380 | 414 | { |
381 | 415 | $args->site_srl = $site_srl; |
382 | 416 | $output = executeQuery('editor.getSiteComponentList', $args); |
417 | + } else { |
|
418 | + $output = executeQuery('editor.getComponentList', $args); |
|
383 | 419 | } |
384 | - else $output = executeQuery('editor.getComponentList', $args); |
|
385 | 420 | $db_list = $output->data; |
386 | 421 | |
387 | 422 | // Get a list of files |
@@ -395,21 +430,30 @@ discard block |
||
395 | 430 | if($logged_info->group_list && is_array($logged_info->group_list)) |
396 | 431 | { |
397 | 432 | $group_list = array_keys($logged_info->group_list); |
433 | + } else { |
|
434 | + $group_list = array(); |
|
398 | 435 | } |
399 | - else $group_list = array(); |
|
400 | 436 | } |
401 | 437 | |
402 | 438 | // Get xml information for looping DB list |
403 | - if(!is_array($db_list)) $db_list = array($db_list); |
|
439 | + if(!is_array($db_list)) { |
|
440 | + $db_list = array($db_list); |
|
441 | + } |
|
404 | 442 | $component_list = new stdClass(); |
405 | 443 | foreach($db_list as $component) |
406 | 444 | { |
407 | - if(in_array($component->component_name, array('colorpicker_text','colorpicker_bg'))) continue; |
|
445 | + if(in_array($component->component_name, array('colorpicker_text','colorpicker_bg'))) { |
|
446 | + continue; |
|
447 | + } |
|
408 | 448 | |
409 | 449 | $component_name = $component->component_name; |
410 | - if(!$component_name) continue; |
|
450 | + if(!$component_name) { |
|
451 | + continue; |
|
452 | + } |
|
411 | 453 | |
412 | - if(!in_array($component_name, $downloaded_list)) continue; |
|
454 | + if(!in_array($component_name, $downloaded_list)) { |
|
455 | + continue; |
|
456 | + } |
|
413 | 457 | |
414 | 458 | unset($xml_info); |
415 | 459 | $xml_info = $oEditorModel->getComponentXmlInfo($component_name); |
@@ -463,8 +507,12 @@ discard block |
||
463 | 507 | // Get buttons, icons, images |
464 | 508 | $icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/icon.gif'; |
465 | 509 | $component_icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/component_icon.gif'; |
466 | - if(file_exists($icon_file)) $component_list->{$component_name}->icon = true; |
|
467 | - if(file_exists($component_icon_file)) $component_list->{$component_name}->component_icon = true; |
|
510 | + if(file_exists($icon_file)) { |
|
511 | + $component_list->{$component_name}->icon = true; |
|
512 | + } |
|
513 | + if(file_exists($component_icon_file)) { |
|
514 | + $component_list->{$component_name}->component_icon = true; |
|
515 | + } |
|
468 | 516 | } |
469 | 517 | |
470 | 518 | // Return if it checks enabled only |
@@ -479,9 +527,13 @@ discard block |
||
479 | 527 | // Get xml_info of downloaded list |
480 | 528 | foreach($downloaded_list as $component_name) |
481 | 529 | { |
482 | - if(in_array($component_name, array('colorpicker_text','colorpicker_bg'))) continue; |
|
530 | + if(in_array($component_name, array('colorpicker_text','colorpicker_bg'))) { |
|
531 | + continue; |
|
532 | + } |
|
483 | 533 | // Pass if configured |
484 | - if($component_list->{$component_name}) continue; |
|
534 | + if($component_list->{$component_name}) { |
|
535 | + continue; |
|
536 | + } |
|
485 | 537 | // Insert data into the DB |
486 | 538 | $oEditorController = getAdminController('editor'); |
487 | 539 | $oEditorController->insertComponent($component_name, false, $site_srl); |
@@ -144,7 +144,7 @@ |
||
144 | 144 | * Make search parameters from object(private) |
145 | 145 | * |
146 | 146 | * @param object $obj Original searach options |
147 | - * @param object $args Result searach options |
|
147 | + * @param stdClass $args Result searach options |
|
148 | 148 | * @return void |
149 | 149 | */ |
150 | 150 | function _makeSearchParam(&$obj, &$args) |
@@ -68,28 +68,28 @@ discard block |
||
68 | 68 | $this->_makeSearchParam($obj, $args); |
69 | 69 | |
70 | 70 | // Set valid/invalid state |
71 | - if($obj->isvalid == 'Y') $args->isvalid = 'Y'; |
|
72 | - elseif($obj->isvalid == 'N') $args->isvalid = 'N'; |
|
71 | + if ($obj->isvalid == 'Y') $args->isvalid = 'Y'; |
|
72 | + elseif ($obj->isvalid == 'N') $args->isvalid = 'N'; |
|
73 | 73 | // Set multimedia/common file |
74 | - if($obj->direct_download == 'Y') $args->direct_download = 'Y'; |
|
75 | - elseif($obj->direct_download == 'N') $args->direct_download= 'N'; |
|
74 | + if ($obj->direct_download == 'Y') $args->direct_download = 'Y'; |
|
75 | + elseif ($obj->direct_download == 'N') $args->direct_download = 'N'; |
|
76 | 76 | // Set variables |
77 | 77 | $args->sort_index = $obj->sort_index; |
78 | - $args->page = $obj->page?$obj->page:1; |
|
79 | - $args->list_count = $obj->list_count?$obj->list_count:20; |
|
80 | - $args->page_count = $obj->page_count?$obj->page_count:10; |
|
78 | + $args->page = $obj->page ? $obj->page : 1; |
|
79 | + $args->list_count = $obj->list_count ? $obj->list_count : 20; |
|
80 | + $args->page_count = $obj->page_count ? $obj->page_count : 10; |
|
81 | 81 | $args->s_module_srl = $obj->module_srl; |
82 | 82 | $args->exclude_module_srl = $obj->exclude_module_srl; |
83 | 83 | // Execute the file.getFileList query |
84 | 84 | $output = executeQuery('file.getFileList', $args, $columnList); |
85 | 85 | // Return if no result or an error occurs |
86 | - if(!$output->toBool()||!count($output->data)) return $output; |
|
86 | + if (!$output->toBool() || !count($output->data)) return $output; |
|
87 | 87 | |
88 | 88 | $oFileModel = getModel('file'); |
89 | 89 | |
90 | - foreach($output->data as $key => $file) |
|
90 | + foreach ($output->data as $key => $file) |
|
91 | 91 | { |
92 | - if($_SESSION['file_management'][$file->file_srl]) $file->isCarted = true; |
|
92 | + if ($_SESSION['file_management'][$file->file_srl]) $file->isCarted = true; |
|
93 | 93 | else $file->isCarted = false; |
94 | 94 | |
95 | 95 | $file->download_url = $oFileModel->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl); |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | */ |
133 | 133 | function getFilesCountByDate($date = '') |
134 | 134 | { |
135 | - if($date) $args->regDate = date('Ymd', strtotime($date)); |
|
135 | + if ($date) $args->regDate = date('Ymd', strtotime($date)); |
|
136 | 136 | |
137 | 137 | $output = executeQuery('file.getFilesCount', $args); |
138 | - if(!$output->toBool()) return 0; |
|
138 | + if (!$output->toBool()) return 0; |
|
139 | 139 | |
140 | 140 | return $output->data->count; |
141 | 141 | } |
@@ -150,31 +150,31 @@ discard block |
||
150 | 150 | function _makeSearchParam(&$obj, &$args) |
151 | 151 | { |
152 | 152 | // Search options |
153 | - $search_target = $obj->search_target?$obj->search_target:trim(Context::get('search_target')); |
|
154 | - $search_keyword = $obj->search_keyword?$obj->search_keyword:trim(Context::get('search_keyword')); |
|
153 | + $search_target = $obj->search_target ? $obj->search_target : trim(Context::get('search_target')); |
|
154 | + $search_keyword = $obj->search_keyword ? $obj->search_keyword : trim(Context::get('search_keyword')); |
|
155 | 155 | |
156 | - if($search_target && $search_keyword) |
|
156 | + if ($search_target && $search_keyword) |
|
157 | 157 | { |
158 | - switch($search_target) |
|
158 | + switch ($search_target) |
|
159 | 159 | { |
160 | 160 | case 'filename' : |
161 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
161 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
162 | 162 | $args->s_filename = $search_keyword; |
163 | 163 | break; |
164 | 164 | case 'filesize_more' : |
165 | - $args->s_filesize_more = (int)$search_keyword; |
|
165 | + $args->s_filesize_more = (int) $search_keyword; |
|
166 | 166 | break; |
167 | 167 | case 'filesize_mega_more' : |
168 | - $args->s_filesize_more = (int)$search_keyword * 1024 * 1024; |
|
168 | + $args->s_filesize_more = (int) $search_keyword * 1024 * 1024; |
|
169 | 169 | break; |
170 | 170 | case 'filesize_less' : |
171 | - $args->s_filesize_less = (int)$search_keyword; |
|
171 | + $args->s_filesize_less = (int) $search_keyword; |
|
172 | 172 | break; |
173 | 173 | case 'filesize_mega_less' : |
174 | - $args->s_filesize_less = (int)$search_keyword * 1024 * 1024; |
|
174 | + $args->s_filesize_less = (int) $search_keyword * 1024 * 1024; |
|
175 | 175 | break; |
176 | 176 | case 'download_count' : |
177 | - $args->s_download_count = (int)$search_keyword; |
|
177 | + $args->s_download_count = (int) $search_keyword; |
|
178 | 178 | break; |
179 | 179 | case 'regdate' : |
180 | 180 | $args->s_regdate = $search_keyword; |
@@ -68,11 +68,17 @@ discard block |
||
68 | 68 | $this->_makeSearchParam($obj, $args); |
69 | 69 | |
70 | 70 | // Set valid/invalid state |
71 | - if($obj->isvalid == 'Y') $args->isvalid = 'Y'; |
|
72 | - elseif($obj->isvalid == 'N') $args->isvalid = 'N'; |
|
71 | + if($obj->isvalid == 'Y') { |
|
72 | + $args->isvalid = 'Y'; |
|
73 | + } elseif($obj->isvalid == 'N') { |
|
74 | + $args->isvalid = 'N'; |
|
75 | + } |
|
73 | 76 | // Set multimedia/common file |
74 | - if($obj->direct_download == 'Y') $args->direct_download = 'Y'; |
|
75 | - elseif($obj->direct_download == 'N') $args->direct_download= 'N'; |
|
77 | + if($obj->direct_download == 'Y') { |
|
78 | + $args->direct_download = 'Y'; |
|
79 | + } elseif($obj->direct_download == 'N') { |
|
80 | + $args->direct_download= 'N'; |
|
81 | + } |
|
76 | 82 | // Set variables |
77 | 83 | $args->sort_index = $obj->sort_index; |
78 | 84 | $args->page = $obj->page?$obj->page:1; |
@@ -83,14 +89,19 @@ discard block |
||
83 | 89 | // Execute the file.getFileList query |
84 | 90 | $output = executeQuery('file.getFileList', $args, $columnList); |
85 | 91 | // Return if no result or an error occurs |
86 | - if(!$output->toBool()||!count($output->data)) return $output; |
|
92 | + if(!$output->toBool()||!count($output->data)) { |
|
93 | + return $output; |
|
94 | + } |
|
87 | 95 | |
88 | 96 | $oFileModel = getModel('file'); |
89 | 97 | |
90 | 98 | foreach($output->data as $key => $file) |
91 | 99 | { |
92 | - if($_SESSION['file_management'][$file->file_srl]) $file->isCarted = true; |
|
93 | - else $file->isCarted = false; |
|
100 | + if($_SESSION['file_management'][$file->file_srl]) { |
|
101 | + $file->isCarted = true; |
|
102 | + } else { |
|
103 | + $file->isCarted = false; |
|
104 | + } |
|
94 | 105 | |
95 | 106 | $file->download_url = $oFileModel->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl); |
96 | 107 | $output->data[$key] = $file; |
@@ -132,10 +143,14 @@ discard block |
||
132 | 143 | */ |
133 | 144 | function getFilesCountByDate($date = '') |
134 | 145 | { |
135 | - if($date) $args->regDate = date('Ymd', strtotime($date)); |
|
146 | + if($date) { |
|
147 | + $args->regDate = date('Ymd', strtotime($date)); |
|
148 | + } |
|
136 | 149 | |
137 | 150 | $output = executeQuery('file.getFilesCount', $args); |
138 | - if(!$output->toBool()) return 0; |
|
151 | + if(!$output->toBool()) { |
|
152 | + return 0; |
|
153 | + } |
|
139 | 154 | |
140 | 155 | return $output->data->count; |
141 | 156 | } |
@@ -158,7 +173,9 @@ discard block |
||
158 | 173 | switch($search_target) |
159 | 174 | { |
160 | 175 | case 'filename' : |
161 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
176 | + if($search_keyword) { |
|
177 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
178 | + } |
|
162 | 179 | $args->s_filename = $search_keyword; |
163 | 180 | break; |
164 | 181 | case 'filesize_more' : |
@@ -216,6 +216,7 @@ discard block |
||
216 | 216 | |
217 | 217 | /** |
218 | 218 | * Merge item |
219 | + * @param string $filename |
|
219 | 220 | * @return void |
220 | 221 | */ |
221 | 222 | function mergeItems($filename) |
@@ -310,6 +311,11 @@ discard block |
||
310 | 311 | return $this->key; |
311 | 312 | } |
312 | 313 | |
314 | + /** |
|
315 | + * @param string $str |
|
316 | + * |
|
317 | + * @return string |
|
318 | + */ |
|
313 | 319 | function _addTagCRTail($str) { |
314 | 320 | $str = preg_replace('/<\/([^>]*)></i', "</$1>\r\n<", $str); |
315 | 321 | return $str; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $this->filename = $filename; |
100 | 100 | |
101 | 101 | $this->startTag = $startTag; |
102 | - if($endTag) $this->endTag = $endTag; |
|
102 | + if ($endTag) $this->endTag = $endTag; |
|
103 | 103 | $this->itemStartTag = $itemTag; |
104 | 104 | $this->itemEndTag = $itemEndTag; |
105 | 105 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $this->cache_path = './files/cache/importer/'.$this->key; |
109 | 109 | $this->cache_index_file = $this->cache_path.'/index'; |
110 | 110 | |
111 | - if(!is_dir($this->cache_path)) FileHandler::makeDir($this->cache_path); |
|
111 | + if (!is_dir($this->cache_path)) FileHandler::makeDir($this->cache_path); |
|
112 | 112 | |
113 | 113 | return $this->openFile(); |
114 | 114 | } |
@@ -120,55 +120,55 @@ discard block |
||
120 | 120 | function openFile() |
121 | 121 | { |
122 | 122 | FileHandler::removeFile($this->cache_index_file); |
123 | - $this->index_fd = fopen($this->cache_index_file,"a"); |
|
123 | + $this->index_fd = fopen($this->cache_index_file, "a"); |
|
124 | 124 | // If local file |
125 | - if(strncasecmp('http://', $this->filename, 7) !== 0) |
|
125 | + if (strncasecmp('http://', $this->filename, 7) !== 0) |
|
126 | 126 | { |
127 | - if(!file_exists($this->filename)) return new BaseObject(-1,'msg_no_xml_file'); |
|
128 | - $this->fd = fopen($this->filename,"r"); |
|
127 | + if (!file_exists($this->filename)) return new BaseObject(-1, 'msg_no_xml_file'); |
|
128 | + $this->fd = fopen($this->filename, "r"); |
|
129 | 129 | // If remote file |
130 | 130 | } |
131 | 131 | else |
132 | 132 | { |
133 | 133 | $url_info = parse_url($this->filename); |
134 | - if(!$url_info['port']) $url_info['port'] = 80; |
|
135 | - if(!$url_info['path']) $url_info['path'] = '/'; |
|
134 | + if (!$url_info['port']) $url_info['port'] = 80; |
|
135 | + if (!$url_info['path']) $url_info['path'] = '/'; |
|
136 | 136 | |
137 | 137 | $this->fd = @fsockopen($url_info['host'], $url_info['port']); |
138 | - if(!$this->fd) return new BaseObject(-1,'msg_no_xml_file'); |
|
138 | + if (!$this->fd) return new BaseObject(-1, 'msg_no_xml_file'); |
|
139 | 139 | // If the file name contains Korean, do urlencode(iconv required) |
140 | 140 | $path = $url_info['path']; |
141 | - if(preg_match('/[\xEA-\xED][\x80-\xFF]{2}/', $path)&&function_exists('iconv')) |
|
141 | + if (preg_match('/[\xEA-\xED][\x80-\xFF]{2}/', $path) && function_exists('iconv')) |
|
142 | 142 | { |
143 | - $path_list = explode('/',$path); |
|
143 | + $path_list = explode('/', $path); |
|
144 | 144 | $cnt = count($path_list); |
145 | - $filename = $path_list[$cnt-1]; |
|
146 | - $filename = urlencode(iconv("UTF-8","EUC-KR",$filename)); |
|
147 | - $path_list[$cnt-1] = $filename; |
|
148 | - $path = implode('/',$path_list); |
|
145 | + $filename = $path_list[$cnt - 1]; |
|
146 | + $filename = urlencode(iconv("UTF-8", "EUC-KR", $filename)); |
|
147 | + $path_list[$cnt - 1] = $filename; |
|
148 | + $path = implode('/', $path_list); |
|
149 | 149 | $url_info['path'] = $path; |
150 | 150 | } |
151 | 151 | |
152 | 152 | $header = sprintf("GET %s?%s HTTP/1.0\r\nHost: %s\r\nReferer: %s://%s\r\nConnection: Close\r\n\r\n", $url_info['path'], $url_info['query'], $url_info['host'], $url_info['scheme'], $url_info['host']); |
153 | 153 | @fwrite($this->fd, $header); |
154 | 154 | $buff = ''; |
155 | - while(!feof($this->fd)) |
|
155 | + while (!feof($this->fd)) |
|
156 | 156 | { |
157 | 157 | $buff .= $str = fgets($this->fd, 1024); |
158 | - if(!trim($str)) break; |
|
158 | + if (!trim($str)) break; |
|
159 | 159 | } |
160 | - if(preg_match('/404 Not Found/i',$buff)) return new BaseObject(-1,'msg_no_xml_file'); |
|
160 | + if (preg_match('/404 Not Found/i', $buff)) return new BaseObject(-1, 'msg_no_xml_file'); |
|
161 | 161 | } |
162 | 162 | |
163 | - if($this->startTag) |
|
163 | + if ($this->startTag) |
|
164 | 164 | { |
165 | - while(!feof($this->fd)) |
|
165 | + while (!feof($this->fd)) |
|
166 | 166 | { |
167 | 167 | $str = fgets($this->fd, 1024); |
168 | 168 | $pos = strpos($str, $this->startTag); |
169 | - if($pos !== false) |
|
169 | + if ($pos !== false) |
|
170 | 170 | { |
171 | - $this->buff = substr($this->buff, $pos+strlen($this->startTag)); |
|
171 | + $this->buff = substr($this->buff, $pos + strlen($this->startTag)); |
|
172 | 172 | $this->isStarted = true; |
173 | 173 | $this->isFinished = false; |
174 | 174 | break; |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | { |
209 | 209 | FileHandler::removeDir($this->cache_path.$this->key); |
210 | 210 | $this->index = 0; |
211 | - while(!$this->isFinished()) |
|
211 | + while (!$this->isFinished()) |
|
212 | 212 | { |
213 | 213 | $this->getItem(); |
214 | 214 | } |
@@ -224,14 +224,14 @@ discard block |
||
224 | 224 | |
225 | 225 | $filename = sprintf('%s/%s', $this->cache_path, $filename); |
226 | 226 | |
227 | - $index_fd = fopen($this->cache_index_file,"r"); |
|
228 | - $fd = fopen($filename,'w'); |
|
227 | + $index_fd = fopen($this->cache_index_file, "r"); |
|
228 | + $fd = fopen($filename, 'w'); |
|
229 | 229 | |
230 | 230 | fwrite($fd, '<items>'); |
231 | - while(!feof($index_fd)) |
|
231 | + while (!feof($index_fd)) |
|
232 | 232 | { |
233 | - $target_file = trim(fgets($index_fd,1024)); |
|
234 | - if(!file_exists($target_file)) continue; |
|
233 | + $target_file = trim(fgets($index_fd, 1024)); |
|
234 | + if (!file_exists($target_file)) continue; |
|
235 | 235 | $buff = FileHandler::readFile($target_file); |
236 | 236 | fwrite($fd, FileHandler::readFile($target_file)); |
237 | 237 | |
@@ -247,21 +247,21 @@ discard block |
||
247 | 247 | */ |
248 | 248 | function getItem() |
249 | 249 | { |
250 | - if($this->isFinished()) return; |
|
250 | + if ($this->isFinished()) return; |
|
251 | 251 | |
252 | - while(!feof($this->fd)) |
|
252 | + while (!feof($this->fd)) |
|
253 | 253 | { |
254 | 254 | $startPos = strpos($this->buff, $this->itemStartTag); |
255 | - if($startPos !== false) |
|
255 | + if ($startPos !== false) |
|
256 | 256 | { |
257 | 257 | $this->buff = substr($this->buff, $startPos); |
258 | - $this->buff = preg_replace("/\>/",">\r\n",$this->buff,1); |
|
258 | + $this->buff = preg_replace("/\>/", ">\r\n", $this->buff, 1); |
|
259 | 259 | break; |
260 | 260 | } |
261 | - elseif($this->endTag) |
|
261 | + elseif ($this->endTag) |
|
262 | 262 | { |
263 | 263 | $endPos = strpos($this->buff, $this->endTag); |
264 | - if($endPos !== false) |
|
264 | + if ($endPos !== false) |
|
265 | 265 | { |
266 | 266 | $this->closeFile(); |
267 | 267 | return; |
@@ -271,21 +271,21 @@ discard block |
||
271 | 271 | } |
272 | 272 | |
273 | 273 | $startPos = strpos($this->buff, $this->itemStartTag); |
274 | - if($startPos === false) |
|
274 | + if ($startPos === false) |
|
275 | 275 | { |
276 | 276 | $this->closeFile(); |
277 | 277 | return; |
278 | 278 | } |
279 | 279 | |
280 | - $filename = sprintf('%s/%s.xml',$this->cache_path, $this->index++); |
|
280 | + $filename = sprintf('%s/%s.xml', $this->cache_path, $this->index++); |
|
281 | 281 | fwrite($this->index_fd, $filename."\r\n"); |
282 | 282 | |
283 | - $fd = fopen($filename,'w'); |
|
283 | + $fd = fopen($filename, 'w'); |
|
284 | 284 | |
285 | - while(!feof($this->fd)) |
|
285 | + while (!feof($this->fd)) |
|
286 | 286 | { |
287 | 287 | $endPos = strpos($this->buff, $this->itemEndTag); |
288 | - if($endPos !== false) |
|
288 | + if ($endPos !== false) |
|
289 | 289 | { |
290 | 290 | $endPos += strlen($this->itemEndTag); |
291 | 291 | $buff = substr($this->buff, 0, $endPos); |
@@ -99,7 +99,9 @@ discard block |
||
99 | 99 | $this->filename = $filename; |
100 | 100 | |
101 | 101 | $this->startTag = $startTag; |
102 | - if($endTag) $this->endTag = $endTag; |
|
102 | + if($endTag) { |
|
103 | + $this->endTag = $endTag; |
|
104 | + } |
|
103 | 105 | $this->itemStartTag = $itemTag; |
104 | 106 | $this->itemEndTag = $itemEndTag; |
105 | 107 | |
@@ -108,7 +110,9 @@ discard block |
||
108 | 110 | $this->cache_path = './files/cache/importer/'.$this->key; |
109 | 111 | $this->cache_index_file = $this->cache_path.'/index'; |
110 | 112 | |
111 | - if(!is_dir($this->cache_path)) FileHandler::makeDir($this->cache_path); |
|
113 | + if(!is_dir($this->cache_path)) { |
|
114 | + FileHandler::makeDir($this->cache_path); |
|
115 | + } |
|
112 | 116 | |
113 | 117 | return $this->openFile(); |
114 | 118 | } |
@@ -124,18 +128,25 @@ discard block |
||
124 | 128 | // If local file |
125 | 129 | if(strncasecmp('http://', $this->filename, 7) !== 0) |
126 | 130 | { |
127 | - if(!file_exists($this->filename)) return new BaseObject(-1,'msg_no_xml_file'); |
|
131 | + if(!file_exists($this->filename)) { |
|
132 | + return new BaseObject(-1,'msg_no_xml_file'); |
|
133 | + } |
|
128 | 134 | $this->fd = fopen($this->filename,"r"); |
129 | 135 | // If remote file |
130 | - } |
|
131 | - else |
|
136 | + } else |
|
132 | 137 | { |
133 | 138 | $url_info = parse_url($this->filename); |
134 | - if(!$url_info['port']) $url_info['port'] = 80; |
|
135 | - if(!$url_info['path']) $url_info['path'] = '/'; |
|
139 | + if(!$url_info['port']) { |
|
140 | + $url_info['port'] = 80; |
|
141 | + } |
|
142 | + if(!$url_info['path']) { |
|
143 | + $url_info['path'] = '/'; |
|
144 | + } |
|
136 | 145 | |
137 | 146 | $this->fd = @fsockopen($url_info['host'], $url_info['port']); |
138 | - if(!$this->fd) return new BaseObject(-1,'msg_no_xml_file'); |
|
147 | + if(!$this->fd) { |
|
148 | + return new BaseObject(-1,'msg_no_xml_file'); |
|
149 | + } |
|
139 | 150 | // If the file name contains Korean, do urlencode(iconv required) |
140 | 151 | $path = $url_info['path']; |
141 | 152 | if(preg_match('/[\xEA-\xED][\x80-\xFF]{2}/', $path)&&function_exists('iconv')) |
@@ -155,9 +166,13 @@ discard block |
||
155 | 166 | while(!feof($this->fd)) |
156 | 167 | { |
157 | 168 | $buff .= $str = fgets($this->fd, 1024); |
158 | - if(!trim($str)) break; |
|
169 | + if(!trim($str)) { |
|
170 | + break; |
|
171 | + } |
|
172 | + } |
|
173 | + if(preg_match('/404 Not Found/i',$buff)) { |
|
174 | + return new BaseObject(-1,'msg_no_xml_file'); |
|
159 | 175 | } |
160 | - if(preg_match('/404 Not Found/i',$buff)) return new BaseObject(-1,'msg_no_xml_file'); |
|
161 | 176 | } |
162 | 177 | |
163 | 178 | if($this->startTag) |
@@ -174,8 +189,7 @@ discard block |
||
174 | 189 | break; |
175 | 190 | } |
176 | 191 | } |
177 | - } |
|
178 | - else |
|
192 | + } else |
|
179 | 193 | { |
180 | 194 | $this->isStarted = true; |
181 | 195 | $this->isFinished = false; |
@@ -231,7 +245,9 @@ discard block |
||
231 | 245 | while(!feof($index_fd)) |
232 | 246 | { |
233 | 247 | $target_file = trim(fgets($index_fd,1024)); |
234 | - if(!file_exists($target_file)) continue; |
|
248 | + if(!file_exists($target_file)) { |
|
249 | + continue; |
|
250 | + } |
|
235 | 251 | $buff = FileHandler::readFile($target_file); |
236 | 252 | fwrite($fd, FileHandler::readFile($target_file)); |
237 | 253 | |
@@ -247,7 +263,9 @@ discard block |
||
247 | 263 | */ |
248 | 264 | function getItem() |
249 | 265 | { |
250 | - if($this->isFinished()) return; |
|
266 | + if($this->isFinished()) { |
|
267 | + return; |
|
268 | + } |
|
251 | 269 | |
252 | 270 | while(!feof($this->fd)) |
253 | 271 | { |
@@ -257,8 +275,7 @@ discard block |
||
257 | 275 | $this->buff = substr($this->buff, $startPos); |
258 | 276 | $this->buff = preg_replace("/\>/",">\r\n",$this->buff,1); |
259 | 277 | break; |
260 | - } |
|
261 | - elseif($this->endTag) |
|
278 | + } elseif($this->endTag) |
|
262 | 279 | { |
263 | 280 | $endPos = strpos($this->buff, $this->endTag); |
264 | 281 | if($endPos !== false) |
@@ -450,7 +450,7 @@ |
||
450 | 450 | * @param int $upload_target_srl |
451 | 451 | * @param array $files |
452 | 452 | * @param string $buff |
453 | - * @return bool |
|
453 | + * @return null|boolean |
|
454 | 454 | */ |
455 | 455 | function importAttaches($fp, $module_srl, $upload_target_srl, &$files, $buff) |
456 | 456 | { |
@@ -40,7 +40,9 @@ discard block |
||
40 | 40 | $oDocumentModel = getModel('document'); |
41 | 41 | $category_list = $category_titles = array(); |
42 | 42 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
43 | - if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
43 | + if(count($category_list)) { |
|
44 | + foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
45 | + } |
|
44 | 46 | // First handle categorty information |
45 | 47 | $category_file = preg_replace('/index$/i', 'category.xml', $index_file); |
46 | 48 | if(file_exists($category_file)) |
@@ -58,15 +60,21 @@ discard block |
||
58 | 60 | foreach($categories as $k => $v) |
59 | 61 | { |
60 | 62 | $category = $v->name; |
61 | - if(!$category || $category_titles[$category]) continue; |
|
63 | + if(!$category || $category_titles[$category]) { |
|
64 | + continue; |
|
65 | + } |
|
62 | 66 | |
63 | 67 | $obj = null; |
64 | 68 | $obj->title = $category; |
65 | 69 | $obj->module_srl = $module_srl; |
66 | - if($v->parent) $obj->parent_srl = $match_sequence[$v->parent]; |
|
70 | + if($v->parent) { |
|
71 | + $obj->parent_srl = $match_sequence[$v->parent]; |
|
72 | + } |
|
67 | 73 | $output = $oDocumentController->insertCategory($obj); |
68 | 74 | |
69 | - if($output->toBool()) $match_sequence[$v->sequence] = $category_titles[$category] = $output->get('category_srl'); |
|
75 | + if($output->toBool()) { |
|
76 | + $match_sequence[$v->sequence] = $category_titles[$category] = $output->get('category_srl'); |
|
77 | + } |
|
70 | 78 | } |
71 | 79 | $oDocumentController->makeCategoryFile($module_srl); |
72 | 80 | } |
@@ -74,28 +82,40 @@ discard block |
||
74 | 82 | } |
75 | 83 | $category_list = $category_titles = array(); |
76 | 84 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
77 | - if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
85 | + if(count($category_list)) { |
|
86 | + foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
87 | + } |
|
78 | 88 | // Get administrator information |
79 | 89 | $oMemberModel = getModel('member'); |
80 | 90 | $member_info = $oMemberModel->getMemberInfoByUserID($user_id); |
81 | 91 | $author_xml_id = 0; |
82 | 92 | |
83 | - if(!$cur) $cur = 0; |
|
93 | + if(!$cur) { |
|
94 | + $cur = 0; |
|
95 | + } |
|
84 | 96 | // Open an index file |
85 | 97 | $f = fopen($index_file,"r"); |
86 | 98 | // Pass if already read |
87 | - for($i=0;$i<$cur;$i++) fgets($f, 1024); |
|
99 | + for($i=0;$i<$cur;$i++) { |
|
100 | + fgets($f, 1024); |
|
101 | + } |
|
88 | 102 | // Read each line until the codition meets |
89 | 103 | for($idx=$cur;$idx<$cur+$unit_count;$idx++) |
90 | 104 | { |
91 | - if(feof($f)) break; |
|
105 | + if(feof($f)) { |
|
106 | + break; |
|
107 | + } |
|
92 | 108 | // Find a location |
93 | 109 | $target_file = trim(fgets($f, 1024)); |
94 | 110 | |
95 | - if(!file_exists($target_file)) continue; |
|
111 | + if(!file_exists($target_file)) { |
|
112 | + continue; |
|
113 | + } |
|
96 | 114 | // Start importing data |
97 | 115 | $fp = fopen($target_file,"r"); |
98 | - if(!$fp) continue; |
|
116 | + if(!$fp) { |
|
117 | + continue; |
|
118 | + } |
|
99 | 119 | |
100 | 120 | $obj = null; |
101 | 121 | $obj->module_srl = $module_srl; |
@@ -116,14 +136,17 @@ discard block |
||
116 | 136 | $started = true; |
117 | 137 | continue; |
118 | 138 | // Import the attachment |
119 | - } |
|
120 | - else if(substr($str,0,12) == '<attachment ') |
|
139 | + } else if(substr($str,0,12) == '<attachment ') |
|
121 | 140 | { |
122 | - if($this->importAttaches($fp, $module_srl, $obj->document_srl, $files, $str)) $obj->uploaded_count++; |
|
141 | + if($this->importAttaches($fp, $module_srl, $obj->document_srl, $files, $str)) { |
|
142 | + $obj->uploaded_count++; |
|
143 | + } |
|
123 | 144 | continue; |
124 | 145 | } |
125 | 146 | |
126 | - if($started) $buff .= $str; |
|
147 | + if($started) { |
|
148 | + $buff .= $str; |
|
149 | + } |
|
127 | 150 | } |
128 | 151 | |
129 | 152 | $xmlDoc = $this->oXmlParser->parse('<post>'.$buff); |
@@ -134,7 +157,9 @@ discard block |
||
134 | 157 | { |
135 | 158 | $tmp_arr = explode('/',$xmlDoc->post->category->body); |
136 | 159 | $category = trim($tmp_arr[count($tmp_arr)-1]); |
137 | - if($category_titles[$category]) $obj->category_srl = $category_titles[$category]; |
|
160 | + if($category_titles[$category]) { |
|
161 | + $obj->category_srl = $category_titles[$category]; |
|
162 | + } |
|
138 | 163 | } |
139 | 164 | |
140 | 165 | $obj->is_notice = 'N'; |
@@ -148,15 +173,21 @@ discard block |
||
148 | 173 | //$obj->allow_trackback = $xmlDoc->post->acceptTrackback->body=='1'?'Y':'N'; |
149 | 174 | $obj->regdate = date("YmdHis",$xmlDoc->post->published->body); |
150 | 175 | $obj->last_update = date("YmdHis", $xmlDoc->post->modified->body); |
151 | - if(!$obj->last_update) $obj->last_update = $obj->regdate; |
|
176 | + if(!$obj->last_update) { |
|
177 | + $obj->last_update = $obj->regdate; |
|
178 | + } |
|
152 | 179 | |
153 | 180 | $tag = null; |
154 | 181 | $tmp_tags = null; |
155 | 182 | $tag = $xmlDoc->post->tag; |
156 | 183 | if($tag) |
157 | 184 | { |
158 | - if(!is_array($tag)) $tag = array($tag); |
|
159 | - foreach($tag as $key => $val) $tmp_tags[] = $val->body; |
|
185 | + if(!is_array($tag)) { |
|
186 | + $tag = array($tag); |
|
187 | + } |
|
188 | + foreach($tag as $key => $val) { |
|
189 | + $tmp_tags[] = $val->body; |
|
190 | + } |
|
160 | 191 | $obj->tags = implode(',',$tmp_tags); |
161 | 192 | } |
162 | 193 | |
@@ -192,7 +223,9 @@ discard block |
||
192 | 223 | if($xmlDoc->post->trackback) |
193 | 224 | { |
194 | 225 | $trackbacks = $xmlDoc->post->trackback; |
195 | - if(!is_array($trackbacks)) $trackbacks = array($trackbacks); |
|
226 | + if(!is_array($trackbacks)) { |
|
227 | + $trackbacks = array($trackbacks); |
|
228 | + } |
|
196 | 229 | if(count($trackbacks)) |
197 | 230 | { |
198 | 231 | foreach($trackbacks as $key => $val) |
@@ -209,7 +242,9 @@ discard block |
||
209 | 242 | $tobj->ipaddress = $val->ip->body; |
210 | 243 | $tobj->list_order = -1*$tobj->trackback_srl; |
211 | 244 | $output = executeQuery('trackback.insertTrackback', $tobj); |
212 | - if($output->toBool()) $obj->trackback_count++; |
|
245 | + if($output->toBool()) { |
|
246 | + $obj->trackback_count++; |
|
247 | + } |
|
213 | 248 | } |
214 | 249 | } |
215 | 250 | } |
@@ -218,21 +253,29 @@ discard block |
||
218 | 253 | if($xmlDoc->post->comment) |
219 | 254 | { |
220 | 255 | $comment = $xmlDoc->post->comment; |
221 | - if(!is_array($comment)) $comment = array($comment); |
|
256 | + if(!is_array($comment)) { |
|
257 | + $comment = array($comment); |
|
258 | + } |
|
222 | 259 | foreach($comment as $key => $val) |
223 | 260 | { |
224 | 261 | $parent_srl = $this->insertComment($val, $module_srl, $obj->document_srl, $member_info, 0, $author_xml_id); |
225 | - if($parent_srl === false) continue; |
|
262 | + if($parent_srl === false) { |
|
263 | + continue; |
|
264 | + } |
|
226 | 265 | |
227 | 266 | $obj->comment_count++; |
228 | 267 | if($val->comment) |
229 | 268 | { |
230 | 269 | $child_comment = $val->comment; |
231 | - if(!is_array($child_comment)) $child_comment = array($child_comment); |
|
270 | + if(!is_array($child_comment)) { |
|
271 | + $child_comment = array($child_comment); |
|
272 | + } |
|
232 | 273 | foreach($child_comment as $k => $v) |
233 | 274 | { |
234 | 275 | $result = $this->insertComment($v, $module_srl, $obj->document_srl, $member_info, $parent_srl, $author_xml_id); |
235 | - if($result !== false) $obj->comment_count++; |
|
276 | + if($result !== false) { |
|
277 | + $obj->comment_count++; |
|
278 | + } |
|
236 | 279 | } |
237 | 280 | } |
238 | 281 | } |
@@ -270,7 +313,9 @@ discard block |
||
270 | 313 | $args->document_srl = $obj->document_srl; |
271 | 314 | $args->tag = trim($tag_list[$i]); |
272 | 315 | $args->regdate = $obj->regdate; |
273 | - if(!$args->tag) continue; |
|
316 | + if(!$args->tag) { |
|
317 | + continue; |
|
318 | + } |
|
274 | 319 | $output = executeQuery('tag.insertTag', $args); |
275 | 320 | } |
276 | 321 | } |
@@ -282,7 +327,9 @@ discard block |
||
282 | 327 | |
283 | 328 | fclose($f); |
284 | 329 | |
285 | - if(count($category_list)) foreach($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl); |
|
330 | + if(count($category_list)) { |
|
331 | + foreach($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl); |
|
332 | + } |
|
286 | 333 | // Guestbook information |
287 | 334 | $guestbook_file = preg_replace('/index$/i', 'guestbook.xml', $index_file); |
288 | 335 | if(file_exists($guestbook_file)) |
@@ -293,7 +340,9 @@ discard block |
||
293 | 340 | if($guestbook_module_srl && $xmlDoc->guestbook->comment) |
294 | 341 | { |
295 | 342 | $comment = $xmlDoc->guestbook->comment; |
296 | - if(!is_array($comment)) $comment = array($comment); |
|
343 | + if(!is_array($comment)) { |
|
344 | + $comment = array($comment); |
|
345 | + } |
|
297 | 346 | |
298 | 347 | if($module_name =='textyle') |
299 | 348 | { |
@@ -304,7 +353,9 @@ discard block |
||
304 | 353 | if($val->comment) |
305 | 354 | { |
306 | 355 | $child_comment = $val->comment; |
307 | - if(!is_array($child_comment)) $child_comment = array($child_comment); |
|
356 | + if(!is_array($child_comment)) { |
|
357 | + $child_comment = array($child_comment); |
|
358 | + } |
|
308 | 359 | foreach($child_comment as $k => $v) |
309 | 360 | { |
310 | 361 | $result = $this->insertTextyleGuestbookItem($v, $module_srl, $member_info,0,$textyle_guestbook_srl,$author_xml_id); |
@@ -313,8 +364,7 @@ discard block |
||
313 | 364 | |
314 | 365 | $result = $this->insertTextyleGuestbookItem($val, $module_srl, $member_info,$textyle_guestbook_srl,0,$author_xml_id); |
315 | 366 | } |
316 | - } |
|
317 | - else |
|
367 | + } else |
|
318 | 368 | { |
319 | 369 | foreach($comment as $key => $val) |
320 | 370 | { |
@@ -328,13 +378,17 @@ discard block |
||
328 | 378 | |
329 | 379 | // Extract a title form the bocy |
330 | 380 | $obj->title = cut_str(strip_tags($obj->content),20,'...'); |
331 | - if ($obj->title == '') $obj->title = 'Untitled'; |
|
381 | + if ($obj->title == '') { |
|
382 | + $obj->title = 'Untitled'; |
|
383 | + } |
|
332 | 384 | |
333 | 385 | $obj->commentStatus = 'ALLOW'; |
334 | 386 | $obj->allow_trackback = 'N'; |
335 | 387 | $obj->regdate = date("YmdHis",$val->written->body); |
336 | 388 | $obj->last_update = date("YmdHis", $val->written->body); |
337 | - if(!$obj->last_update) $obj->last_update = $obj->regdate; |
|
389 | + if(!$obj->last_update) { |
|
390 | + $obj->last_update = $obj->regdate; |
|
391 | + } |
|
338 | 392 | $obj->tags = ''; |
339 | 393 | $obj->readed_count = 0; |
340 | 394 | $obj->voted_count = 0; |
@@ -347,8 +401,7 @@ discard block |
||
347 | 401 | $obj->member_srl = $member_info->member_srl; |
348 | 402 | $obj->email_address = $member_info->email_address; |
349 | 403 | $obj->homepage = $member_info->homepage; |
350 | - } |
|
351 | - else |
|
404 | + } else |
|
352 | 405 | { |
353 | 406 | $obj->password = $val->password->body; |
354 | 407 | $obj->nick_name = $val->commenter->name->body; |
@@ -364,11 +417,15 @@ discard block |
||
364 | 417 | if($val->comment) |
365 | 418 | { |
366 | 419 | $child_comment = $val->comment; |
367 | - if(!is_array($child_comment)) $child_comment = array($child_comment); |
|
420 | + if(!is_array($child_comment)) { |
|
421 | + $child_comment = array($child_comment); |
|
422 | + } |
|
368 | 423 | foreach($child_comment as $k => $v) |
369 | 424 | { |
370 | 425 | $result = $this->insertComment($v, $module_srl, $obj->document_srl, $member_info, 0,$author_xml_id); |
371 | - if($result !== false) $obj->comment_count++; |
|
426 | + if($result !== false) { |
|
427 | + $obj->comment_count++; |
|
428 | + } |
|
372 | 429 | } |
373 | 430 | } |
374 | 431 | |
@@ -399,8 +456,7 @@ discard block |
||
399 | 456 | if($textyle_guestbook_srl>0) |
400 | 457 | { |
401 | 458 | $tobj->textyle_guestbook_srl = $textyle_guestbook_srl; |
402 | - } |
|
403 | - else |
|
459 | + } else |
|
404 | 460 | { |
405 | 461 | $tobj->textyle_guestbook_srl = getNextSequence(); |
406 | 462 | } |
@@ -416,8 +472,7 @@ discard block |
||
416 | 472 | $tobj->member_srl = $member_info->member_srl; |
417 | 473 | $tobj->homepage = $member_info->homepage; |
418 | 474 | $tobj->email_address = $member_info->email_address; |
419 | - } |
|
420 | - else |
|
475 | + } else |
|
421 | 476 | { |
422 | 477 | $tobj->password = $val->password->body; |
423 | 478 | $tobj->nick_name = $val->commenter->name->body; |
@@ -431,15 +486,16 @@ discard block |
||
431 | 486 | { |
432 | 487 | $tobj->parent_srl = $parent_srl; |
433 | 488 | $tobj->list_order = $tobj->parent_srl * -1; |
434 | - } |
|
435 | - else |
|
489 | + } else |
|
436 | 490 | { |
437 | 491 | $tobj->list_order = $tobj->textyle_guestbook_srl*-1; |
438 | 492 | } |
439 | 493 | |
440 | 494 | $output = executeQuery('textyle.insertTextyleGuestbook', $tobj); |
441 | 495 | |
442 | - if($output->toBool()) return $tobj->textyle_guestbook_srl; |
|
496 | + if($output->toBool()) { |
|
497 | + return $tobj->textyle_guestbook_srl; |
|
498 | + } |
|
443 | 499 | return false; |
444 | 500 | } |
445 | 501 | |
@@ -465,7 +521,9 @@ discard block |
||
465 | 521 | { |
466 | 522 | $str = fgets($fp, 1024); |
467 | 523 | // If it ends with </attaches>, break |
468 | - if(trim($str) == '</attachment>') break; |
|
524 | + if(trim($str) == '</attachment>') { |
|
525 | + break; |
|
526 | + } |
|
469 | 527 | // If it starts with <file>, handle the attachement in the xml file |
470 | 528 | if(substr($str, 0, 9)=='<content>') |
471 | 529 | { |
@@ -475,7 +533,9 @@ discard block |
||
475 | 533 | |
476 | 534 | $buff .= $str; |
477 | 535 | } |
478 | - if(!file_exists($file_obj->file)) return false; |
|
536 | + if(!file_exists($file_obj->file)) { |
|
537 | + return false; |
|
538 | + } |
|
479 | 539 | |
480 | 540 | $buff .= '</attachment>'; |
481 | 541 | |
@@ -490,15 +550,16 @@ discard block |
||
490 | 550 | $path = sprintf("./files/attach/images/%s/%s", $module_srl,getNumberingPath($upload_target_srl,3)); |
491 | 551 | $filename = $path.$file_obj->source_filename; |
492 | 552 | $file_obj->direct_download = 'Y'; |
493 | - } |
|
494 | - else |
|
553 | + } else |
|
495 | 554 | { |
496 | 555 | $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3)); |
497 | 556 | $filename = $path.md5(crypt(rand(1000000,900000), rand(0,100))); |
498 | 557 | $file_obj->direct_download = 'N'; |
499 | 558 | } |
500 | 559 | // Create a directory |
501 | - if(!FileHandler::makeDir($path)) return; |
|
560 | + if(!FileHandler::makeDir($path)) { |
|
561 | + return; |
|
562 | + } |
|
502 | 563 | |
503 | 564 | FileHandler::rename($file_obj->file, $filename); |
504 | 565 | // Insert to the DB |
@@ -515,8 +576,11 @@ discard block |
||
515 | 576 | { |
516 | 577 | $uploaded_count++; |
517 | 578 | $tmp_obj = null; |
518 | - if($file_obj->direct_download == 'Y') $files[$name]->url = $file_obj->uploaded_filename; |
|
519 | - else $files[$name]->url = getUrl('','module','file','act','procFileDownload','file_srl',$file_obj->file_srl,'sid',$file_obj->sid); |
|
579 | + if($file_obj->direct_download == 'Y') { |
|
580 | + $files[$name]->url = $file_obj->uploaded_filename; |
|
581 | + } else { |
|
582 | + $files[$name]->url = getUrl('','module','file','act','procFileDownload','file_srl',$file_obj->file_srl,'sid',$file_obj->sid); |
|
583 | + } |
|
520 | 584 | $files[$name]->direct_download = $file_obj->direct_download; |
521 | 585 | $files[$name]->source_filename = $file_obj->source_filename; |
522 | 586 | return true; |
@@ -532,9 +596,13 @@ discard block |
||
532 | 596 | function getTmpFilename() |
533 | 597 | { |
534 | 598 | $path = "./files/cache/importer"; |
535 | - if(!is_dir($path)) FileHandler::makeDir($path); |
|
599 | + if(!is_dir($path)) { |
|
600 | + FileHandler::makeDir($path); |
|
601 | + } |
|
536 | 602 | $filename = sprintf("%s/%d", $path, rand(11111111,99999999)); |
537 | - if(file_exists($filename)) $filename .= rand(111,999); |
|
603 | + if(file_exists($filename)) { |
|
604 | + $filename .= rand(111,999); |
|
605 | + } |
|
538 | 606 | return $filename; |
539 | 607 | } |
540 | 608 | |
@@ -553,7 +621,9 @@ discard block |
||
553 | 621 | { |
554 | 622 | $str = trim(fgets($fp, 1024)); |
555 | 623 | $buff .= $str; |
556 | - if(substr($str, -10) == '</content>') break; |
|
624 | + if(substr($str, -10) == '</content>') { |
|
625 | + break; |
|
626 | + } |
|
557 | 627 | } |
558 | 628 | |
559 | 629 | $buff = substr($buff, 0, -10); |
@@ -572,7 +642,9 @@ discard block |
||
572 | 642 | function _replaceTTAttach($matches) |
573 | 643 | { |
574 | 644 | $name = $matches[2]; |
575 | - if(!$name) return $matches[0]; |
|
645 | + if(!$name) { |
|
646 | + return $matches[0]; |
|
647 | + } |
|
576 | 648 | |
577 | 649 | $obj = $this->files[$name]; |
578 | 650 | // If multimedia file is, |
@@ -583,14 +655,12 @@ discard block |
||
583 | 655 | { |
584 | 656 | return sprintf('<img editor_component="image_link" src="%s" alt="%s" />', $obj->url, str_replace('"','\\"',$matches[4])); |
585 | 657 | // If other multimedia file but image is, |
586 | - } |
|
587 | - else |
|
658 | + } else |
|
588 | 659 | { |
589 | 660 | return sprintf('<img src="./common/img/blank.gif" editor_component="multimedia_link" multimedia_src="%s" width="400" height="320" style="display:block;width:400px;height:320px;border:2px dotted #4371B9;background:url(./modules/editor/components/multimedia_link/tpl/multimedia_link_component.gif) no-repeat center;" auto_start="false" alt="" />', $obj->url); |
590 | 661 | } |
591 | 662 | // If binary file is |
592 | - } |
|
593 | - else |
|
663 | + } else |
|
594 | 664 | { |
595 | 665 | return sprintf('<a href="%s">%s</a>', $obj->url, $obj->source_filename); |
596 | 666 | } |
@@ -603,7 +673,9 @@ discard block |
||
603 | 673 | function _replaceTTMovie($matches) |
604 | 674 | { |
605 | 675 | $key = $matches[1]; |
606 | - if(!$key) return $matches[0]; |
|
676 | + if(!$key) { |
|
677 | + return $matches[0]; |
|
678 | + } |
|
607 | 679 | |
608 | 680 | return |
609 | 681 | '<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="402">'. |
@@ -645,8 +717,7 @@ discard block |
||
645 | 717 | $tobj->member_srl = $member_info->member_srl; |
646 | 718 | $tobj->homepage = $member_info->homepage; |
647 | 719 | $tobj->email_address = $member_info->email_address; |
648 | - } |
|
649 | - else |
|
720 | + } else |
|
650 | 721 | { |
651 | 722 | $tobj->password = $val->password->body; |
652 | 723 | $tobj->nick_name = $val->commenter->name->body; |
@@ -670,24 +741,28 @@ discard block |
||
670 | 741 | $list_args->head = $list_args->arrange = $tobj->comment_srl; |
671 | 742 | $list_args->depth = 0; |
672 | 743 | // Get parent_srl if parent comment exists |
673 | - } |
|
674 | - else |
|
744 | + } else |
|
675 | 745 | { |
676 | 746 | // Get parent_srl |
677 | 747 | $parent_args->comment_srl = $tobj->parent_srl; |
678 | 748 | $parent_output = executeQuery('comment.getCommentListItem', $parent_args); |
679 | 749 | // Return if parent comment doesn't exist |
680 | - if(!$parent_output->toBool() || !$parent_output->data) return false; |
|
750 | + if(!$parent_output->toBool() || !$parent_output->data) { |
|
751 | + return false; |
|
752 | + } |
|
681 | 753 | $parent = $parent_output->data; |
682 | 754 | |
683 | 755 | $list_args->head = $parent->head; |
684 | 756 | $list_args->depth = $parent->depth+1; |
685 | - if($list_args->depth<2) $list_args->arrange = $tobj->comment_srl; |
|
686 | - else |
|
757 | + if($list_args->depth<2) { |
|
758 | + $list_args->arrange = $tobj->comment_srl; |
|
759 | + } else |
|
687 | 760 | { |
688 | 761 | $list_args->arrange = $parent->arrange; |
689 | 762 | $output = executeQuery('comment.updateCommentListArrange', $list_args); |
690 | - if(!$output->toBool()) return $output; |
|
763 | + if(!$output->toBool()) { |
|
764 | + return $output; |
|
765 | + } |
|
691 | 766 | } |
692 | 767 | } |
693 | 768 | |
@@ -695,7 +770,9 @@ discard block |
||
695 | 770 | if($output->toBool()) |
696 | 771 | { |
697 | 772 | $output = executeQuery('comment.insertComment', $tobj); |
698 | - if($output->toBool()) return $tobj->comment_srl; |
|
773 | + if($output->toBool()) { |
|
774 | + return $tobj->comment_srl; |
|
775 | + } |
|
699 | 776 | } |
700 | 777 | return false; |
701 | 778 | } |
@@ -710,9 +787,14 @@ discard block |
||
710 | 787 | */ |
711 | 788 | function arrangeCategory($obj, &$category, &$idx, $parent = 0) |
712 | 789 | { |
713 | - if(!$obj->category) return; |
|
714 | - if(!is_array($obj->category)) $c = array($obj->category); |
|
715 | - else $c = $obj->category; |
|
790 | + if(!$obj->category) { |
|
791 | + return; |
|
792 | + } |
|
793 | + if(!is_array($obj->category)) { |
|
794 | + $c = array($obj->category); |
|
795 | + } else { |
|
796 | + $c = $obj->category; |
|
797 | + } |
|
716 | 798 | foreach($c as $val) |
717 | 799 | { |
718 | 800 | $idx++; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param string $module_name |
32 | 32 | * @return int |
33 | 33 | */ |
34 | - function importModule($key, $cur, $index_file, $unit_count, $module_srl, $guestbook_module_srl, $user_id, $module_name=null) |
|
34 | + function importModule($key, $cur, $index_file, $unit_count, $module_srl, $guestbook_module_srl, $user_id, $module_name = null) |
|
35 | 35 | { |
36 | 36 | // Pre-create the objects needed |
37 | 37 | $this->oXmlParser = new XmlParser(); |
@@ -40,33 +40,33 @@ discard block |
||
40 | 40 | $oDocumentModel = getModel('document'); |
41 | 41 | $category_list = $category_titles = array(); |
42 | 42 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
43 | - if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
43 | + if (count($category_list)) foreach ($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
44 | 44 | // First handle categorty information |
45 | 45 | $category_file = preg_replace('/index$/i', 'category.xml', $index_file); |
46 | - if(file_exists($category_file)) |
|
46 | + if (file_exists($category_file)) |
|
47 | 47 | { |
48 | 48 | // Create the xmlParser object |
49 | 49 | $xmlDoc = $this->oXmlParser->loadXmlFile($category_file); |
50 | 50 | // List category information |
51 | - if($xmlDoc->categories->category) |
|
51 | + if ($xmlDoc->categories->category) |
|
52 | 52 | { |
53 | 53 | $categories = array(); |
54 | 54 | $idx = 0; |
55 | 55 | $this->arrangeCategory($xmlDoc->categories, $categories, $idx, 0); |
56 | 56 | |
57 | 57 | $match_sequence = array(); |
58 | - foreach($categories as $k => $v) |
|
58 | + foreach ($categories as $k => $v) |
|
59 | 59 | { |
60 | 60 | $category = $v->name; |
61 | - if(!$category || $category_titles[$category]) continue; |
|
61 | + if (!$category || $category_titles[$category]) continue; |
|
62 | 62 | |
63 | 63 | $obj = null; |
64 | 64 | $obj->title = $category; |
65 | 65 | $obj->module_srl = $module_srl; |
66 | - if($v->parent) $obj->parent_srl = $match_sequence[$v->parent]; |
|
66 | + if ($v->parent) $obj->parent_srl = $match_sequence[$v->parent]; |
|
67 | 67 | $output = $oDocumentController->insertCategory($obj); |
68 | 68 | |
69 | - if($output->toBool()) $match_sequence[$v->sequence] = $category_titles[$category] = $output->get('category_srl'); |
|
69 | + if ($output->toBool()) $match_sequence[$v->sequence] = $category_titles[$category] = $output->get('category_srl'); |
|
70 | 70 | } |
71 | 71 | $oDocumentController->makeCategoryFile($module_srl); |
72 | 72 | } |
@@ -74,28 +74,28 @@ discard block |
||
74 | 74 | } |
75 | 75 | $category_list = $category_titles = array(); |
76 | 76 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
77 | - if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
77 | + if (count($category_list)) foreach ($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
78 | 78 | // Get administrator information |
79 | 79 | $oMemberModel = getModel('member'); |
80 | 80 | $member_info = $oMemberModel->getMemberInfoByUserID($user_id); |
81 | 81 | $author_xml_id = 0; |
82 | 82 | |
83 | - if(!$cur) $cur = 0; |
|
83 | + if (!$cur) $cur = 0; |
|
84 | 84 | // Open an index file |
85 | - $f = fopen($index_file,"r"); |
|
85 | + $f = fopen($index_file, "r"); |
|
86 | 86 | // Pass if already read |
87 | - for($i=0;$i<$cur;$i++) fgets($f, 1024); |
|
87 | + for ($i = 0; $i < $cur; $i++) fgets($f, 1024); |
|
88 | 88 | // Read each line until the codition meets |
89 | - for($idx=$cur;$idx<$cur+$unit_count;$idx++) |
|
89 | + for ($idx = $cur; $idx < $cur + $unit_count; $idx++) |
|
90 | 90 | { |
91 | - if(feof($f)) break; |
|
91 | + if (feof($f)) break; |
|
92 | 92 | // Find a location |
93 | 93 | $target_file = trim(fgets($f, 1024)); |
94 | 94 | |
95 | - if(!file_exists($target_file)) continue; |
|
95 | + if (!file_exists($target_file)) continue; |
|
96 | 96 | // Start importing data |
97 | - $fp = fopen($target_file,"r"); |
|
98 | - if(!$fp) continue; |
|
97 | + $fp = fopen($target_file, "r"); |
|
98 | + if (!$fp) continue; |
|
99 | 99 | |
100 | 100 | $obj = null; |
101 | 101 | $obj->module_srl = $module_srl; |
@@ -107,57 +107,57 @@ discard block |
||
107 | 107 | $started = false; |
108 | 108 | $buff = null; |
109 | 109 | // Start importing from the body data |
110 | - while(!feof($fp)) |
|
110 | + while (!feof($fp)) |
|
111 | 111 | { |
112 | 112 | $str = fgets($fp, 1024); |
113 | 113 | // Prepare an item |
114 | - if(substr($str,0,5) == '<post') |
|
114 | + if (substr($str, 0, 5) == '<post') |
|
115 | 115 | { |
116 | 116 | $started = true; |
117 | 117 | continue; |
118 | 118 | // Import the attachment |
119 | 119 | } |
120 | - else if(substr($str,0,12) == '<attachment ') |
|
120 | + else if (substr($str, 0, 12) == '<attachment ') |
|
121 | 121 | { |
122 | - if($this->importAttaches($fp, $module_srl, $obj->document_srl, $files, $str)) $obj->uploaded_count++; |
|
122 | + if ($this->importAttaches($fp, $module_srl, $obj->document_srl, $files, $str)) $obj->uploaded_count++; |
|
123 | 123 | continue; |
124 | 124 | } |
125 | 125 | |
126 | - if($started) $buff .= $str; |
|
126 | + if ($started) $buff .= $str; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | $xmlDoc = $this->oXmlParser->parse('<post>'.$buff); |
130 | 130 | |
131 | 131 | $author_xml_id = $xmlDoc->post->author->body; |
132 | 132 | |
133 | - if($xmlDoc->post->category->body) |
|
133 | + if ($xmlDoc->post->category->body) |
|
134 | 134 | { |
135 | - $tmp_arr = explode('/',$xmlDoc->post->category->body); |
|
136 | - $category = trim($tmp_arr[count($tmp_arr)-1]); |
|
137 | - if($category_titles[$category]) $obj->category_srl = $category_titles[$category]; |
|
135 | + $tmp_arr = explode('/', $xmlDoc->post->category->body); |
|
136 | + $category = trim($tmp_arr[count($tmp_arr) - 1]); |
|
137 | + if ($category_titles[$category]) $obj->category_srl = $category_titles[$category]; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | $obj->is_notice = 'N'; |
141 | - $obj->status = in_array($xmlDoc->post->visibility->body, array('public','syndicated'))?$oDocumentModel->getConfigStatus('public'):$oDocumentModel->getConfigStatus('secret'); |
|
141 | + $obj->status = in_array($xmlDoc->post->visibility->body, array('public', 'syndicated')) ? $oDocumentModel->getConfigStatus('public') : $oDocumentModel->getConfigStatus('secret'); |
|
142 | 142 | $obj->title = $xmlDoc->post->title->body; |
143 | 143 | $obj->content = $xmlDoc->post->content->body; |
144 | 144 | $obj->password = md5($xmlDoc->post->password->body); |
145 | - $obj->commentStatus = $xmlDoc->post->acceptcomment->body=='1'?'ALLOW':'DENY'; |
|
146 | - $obj->allow_trackback = $xmlDoc->post->accepttrackback->body=='1'?'Y':'N'; |
|
145 | + $obj->commentStatus = $xmlDoc->post->acceptcomment->body == '1' ? 'ALLOW' : 'DENY'; |
|
146 | + $obj->allow_trackback = $xmlDoc->post->accepttrackback->body == '1' ? 'Y' : 'N'; |
|
147 | 147 | //$obj->allow_comment = $xmlDoc->post->acceptComment->body=='1'?'Y':'N'; |
148 | 148 | //$obj->allow_trackback = $xmlDoc->post->acceptTrackback->body=='1'?'Y':'N'; |
149 | - $obj->regdate = date("YmdHis",$xmlDoc->post->published->body); |
|
149 | + $obj->regdate = date("YmdHis", $xmlDoc->post->published->body); |
|
150 | 150 | $obj->last_update = date("YmdHis", $xmlDoc->post->modified->body); |
151 | - if(!$obj->last_update) $obj->last_update = $obj->regdate; |
|
151 | + if (!$obj->last_update) $obj->last_update = $obj->regdate; |
|
152 | 152 | |
153 | 153 | $tag = null; |
154 | 154 | $tmp_tags = null; |
155 | 155 | $tag = $xmlDoc->post->tag; |
156 | - if($tag) |
|
156 | + if ($tag) |
|
157 | 157 | { |
158 | - if(!is_array($tag)) $tag = array($tag); |
|
159 | - foreach($tag as $key => $val) $tmp_tags[] = $val->body; |
|
160 | - $obj->tags = implode(',',$tmp_tags); |
|
158 | + if (!is_array($tag)) $tag = array($tag); |
|
159 | + foreach ($tag as $key => $val) $tmp_tags[] = $val->body; |
|
160 | + $obj->tags = implode(',', $tmp_tags); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | $obj->readed_count = 0; |
@@ -169,33 +169,33 @@ discard block |
||
169 | 169 | $obj->email_address = $member_info->email_address; |
170 | 170 | $obj->homepage = $member_info->homepage; |
171 | 171 | $obj->ipaddress = $_REMOTE['SERVER_ADDR']; |
172 | - $obj->list_order = $obj->update_order = $obj->document_srl*-1; |
|
172 | + $obj->list_order = $obj->update_order = $obj->document_srl * -1; |
|
173 | 173 | $obj->notify_message = 'N'; |
174 | 174 | // Change content information (attachment) |
175 | - $obj->content = str_replace('[##_ATTACH_PATH_##]/','',$obj->content); |
|
176 | - if(count($files)) |
|
175 | + $obj->content = str_replace('[##_ATTACH_PATH_##]/', '', $obj->content); |
|
176 | + if (count($files)) |
|
177 | 177 | { |
178 | - foreach($files as $key => $val) { |
|
179 | - $obj->content = preg_replace('/(src|href)\=(["\']?)'.preg_quote($key).'(["\']?)/i','$1="'.$val->url.'"',$obj->content); |
|
178 | + foreach ($files as $key => $val) { |
|
179 | + $obj->content = preg_replace('/(src|href)\=(["\']?)'.preg_quote($key).'(["\']?)/i', '$1="'.$val->url.'"', $obj->content); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
183 | 183 | $obj->content = preg_replace_callback('!\[##_Movie\|([^\|]*)\|(.*?)_##\]!is', array($this, '_replaceTTMovie'), $obj->content); |
184 | 184 | |
185 | - if(count($files)) |
|
185 | + if (count($files)) |
|
186 | 186 | { |
187 | 187 | $this->files = $files; |
188 | 188 | $obj->content = preg_replace_callback('!\[##_([a-z0-9]+)\|([^\|]*)\|([^\|]*)\|(.*?)_##\]!is', array($this, '_replaceTTAttach'), $obj->content); |
189 | 189 | } |
190 | 190 | // Trackback inserted |
191 | 191 | $obj->trackback_count = 0; |
192 | - if($xmlDoc->post->trackback) |
|
192 | + if ($xmlDoc->post->trackback) |
|
193 | 193 | { |
194 | 194 | $trackbacks = $xmlDoc->post->trackback; |
195 | - if(!is_array($trackbacks)) $trackbacks = array($trackbacks); |
|
196 | - if(count($trackbacks)) |
|
195 | + if (!is_array($trackbacks)) $trackbacks = array($trackbacks); |
|
196 | + if (count($trackbacks)) |
|
197 | 197 | { |
198 | - foreach($trackbacks as $key => $val) |
|
198 | + foreach ($trackbacks as $key => $val) |
|
199 | 199 | { |
200 | 200 | $tobj = null; |
201 | 201 | $tobj->trackback_srl = getNextSequence(); |
@@ -205,40 +205,40 @@ discard block |
||
205 | 205 | $tobj->title = $val->title->body; |
206 | 206 | $tobj->blog_name = $val->site->body; |
207 | 207 | $tobj->excerpt = $val->excerpt->body; |
208 | - $tobj->regdate = date("YmdHis",$val->received->body); |
|
208 | + $tobj->regdate = date("YmdHis", $val->received->body); |
|
209 | 209 | $tobj->ipaddress = $val->ip->body; |
210 | - $tobj->list_order = -1*$tobj->trackback_srl; |
|
210 | + $tobj->list_order = -1 * $tobj->trackback_srl; |
|
211 | 211 | $output = executeQuery('trackback.insertTrackback', $tobj); |
212 | - if($output->toBool()) $obj->trackback_count++; |
|
212 | + if ($output->toBool()) $obj->trackback_count++; |
|
213 | 213 | } |
214 | 214 | } |
215 | 215 | } |
216 | 216 | // Comment |
217 | 217 | $obj->comment_count = 0; |
218 | - if($xmlDoc->post->comment) |
|
218 | + if ($xmlDoc->post->comment) |
|
219 | 219 | { |
220 | 220 | $comment = $xmlDoc->post->comment; |
221 | - if(!is_array($comment)) $comment = array($comment); |
|
222 | - foreach($comment as $key => $val) |
|
221 | + if (!is_array($comment)) $comment = array($comment); |
|
222 | + foreach ($comment as $key => $val) |
|
223 | 223 | { |
224 | 224 | $parent_srl = $this->insertComment($val, $module_srl, $obj->document_srl, $member_info, 0, $author_xml_id); |
225 | - if($parent_srl === false) continue; |
|
225 | + if ($parent_srl === false) continue; |
|
226 | 226 | |
227 | 227 | $obj->comment_count++; |
228 | - if($val->comment) |
|
228 | + if ($val->comment) |
|
229 | 229 | { |
230 | 230 | $child_comment = $val->comment; |
231 | - if(!is_array($child_comment)) $child_comment = array($child_comment); |
|
232 | - foreach($child_comment as $k => $v) |
|
231 | + if (!is_array($child_comment)) $child_comment = array($child_comment); |
|
232 | + foreach ($child_comment as $k => $v) |
|
233 | 233 | { |
234 | 234 | $result = $this->insertComment($v, $module_srl, $obj->document_srl, $member_info, $parent_srl, $author_xml_id); |
235 | - if($result !== false) $obj->comment_count++; |
|
235 | + if ($result !== false) $obj->comment_count++; |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | } |
239 | 239 | } |
240 | 240 | |
241 | - if($module_name == 'textyle') |
|
241 | + if ($module_name == 'textyle') |
|
242 | 242 | { |
243 | 243 | $args->document_srl = $obj->document_srl; |
244 | 244 | $args->module_srl = $obj->module_srl; |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | // Visibility value of published state |
248 | 248 | $status_published = array('public', 'syndicated'); |
249 | 249 | // Save state if not published |
250 | - if(!in_array($xmlDoc->post->visibility->body, $status_published)) |
|
250 | + if (!in_array($xmlDoc->post->visibility->body, $status_published)) |
|
251 | 251 | { |
252 | 252 | $obj->module_srl = $member_info->member_srl; |
253 | 253 | } |
@@ -255,14 +255,14 @@ discard block |
||
255 | 255 | // Document |
256 | 256 | $output = executeQuery('document.insertDocument', $obj); |
257 | 257 | |
258 | - if($output->toBool()) |
|
258 | + if ($output->toBool()) |
|
259 | 259 | { |
260 | 260 | // Tags |
261 | - if($obj->tags) |
|
261 | + if ($obj->tags) |
|
262 | 262 | { |
263 | - $tag_list = explode(',',$obj->tags); |
|
263 | + $tag_list = explode(',', $obj->tags); |
|
264 | 264 | $tag_count = count($tag_list); |
265 | - for($i=0;$i<$tag_count;$i++) |
|
265 | + for ($i = 0; $i < $tag_count; $i++) |
|
266 | 266 | { |
267 | 267 | $args = new stdClass; |
268 | 268 | $args->tag_srl = getNextSequence(); |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | $args->document_srl = $obj->document_srl; |
271 | 271 | $args->tag = trim($tag_list[$i]); |
272 | 272 | $args->regdate = $obj->regdate; |
273 | - if(!$args->tag) continue; |
|
273 | + if (!$args->tag) continue; |
|
274 | 274 | $output = executeQuery('tag.insertTag', $args); |
275 | 275 | } |
276 | 276 | } |
@@ -282,63 +282,63 @@ discard block |
||
282 | 282 | |
283 | 283 | fclose($f); |
284 | 284 | |
285 | - if(count($category_list)) foreach($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl); |
|
285 | + if (count($category_list)) foreach ($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl); |
|
286 | 286 | // Guestbook information |
287 | 287 | $guestbook_file = preg_replace('/index$/i', 'guestbook.xml', $index_file); |
288 | - if(file_exists($guestbook_file)) |
|
288 | + if (file_exists($guestbook_file)) |
|
289 | 289 | { |
290 | 290 | // Create the xmlParser object |
291 | 291 | $xmlDoc = $this->oXmlParser->loadXmlFile($guestbook_file); |
292 | 292 | // Handle guest book information |
293 | - if($guestbook_module_srl && $xmlDoc->guestbook->comment) |
|
293 | + if ($guestbook_module_srl && $xmlDoc->guestbook->comment) |
|
294 | 294 | { |
295 | 295 | $comment = $xmlDoc->guestbook->comment; |
296 | - if(!is_array($comment)) $comment = array($comment); |
|
296 | + if (!is_array($comment)) $comment = array($comment); |
|
297 | 297 | |
298 | - if($module_name =='textyle') |
|
298 | + if ($module_name == 'textyle') |
|
299 | 299 | { |
300 | - foreach($comment as $key => $val) |
|
300 | + foreach ($comment as $key => $val) |
|
301 | 301 | { |
302 | - $textyle_guestbook_srl = getNextSequence(); |
|
302 | + $textyle_guestbook_srl = getNextSequence(); |
|
303 | 303 | |
304 | - if($val->comment) |
|
304 | + if ($val->comment) |
|
305 | 305 | { |
306 | 306 | $child_comment = $val->comment; |
307 | - if(!is_array($child_comment)) $child_comment = array($child_comment); |
|
308 | - foreach($child_comment as $k => $v) |
|
307 | + if (!is_array($child_comment)) $child_comment = array($child_comment); |
|
308 | + foreach ($child_comment as $k => $v) |
|
309 | 309 | { |
310 | - $result = $this->insertTextyleGuestbookItem($v, $module_srl, $member_info,0,$textyle_guestbook_srl,$author_xml_id); |
|
310 | + $result = $this->insertTextyleGuestbookItem($v, $module_srl, $member_info, 0, $textyle_guestbook_srl, $author_xml_id); |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | - $result = $this->insertTextyleGuestbookItem($val, $module_srl, $member_info,$textyle_guestbook_srl,0,$author_xml_id); |
|
314 | + $result = $this->insertTextyleGuestbookItem($val, $module_srl, $member_info, $textyle_guestbook_srl, 0, $author_xml_id); |
|
315 | 315 | } |
316 | 316 | } |
317 | 317 | else |
318 | 318 | { |
319 | - foreach($comment as $key => $val) |
|
319 | + foreach ($comment as $key => $val) |
|
320 | 320 | { |
321 | 321 | $obj = null; |
322 | 322 | $obj->module_srl = $guestbook_module_srl; |
323 | 323 | $obj->document_srl = getNextSequence(); |
324 | 324 | $obj->uploaded_count = 0; |
325 | 325 | $obj->is_notice = 'N'; |
326 | - $obj->status = $val->secret->body=='1'?$oDocumentModel->getConfigStatus('secret'):$oDocumentModel->getConfigStatus('public'); |
|
326 | + $obj->status = $val->secret->body == '1' ? $oDocumentModel->getConfigStatus('secret') : $oDocumentModel->getConfigStatus('public'); |
|
327 | 327 | $obj->content = nl2br($val->content->body); |
328 | 328 | |
329 | 329 | // Extract a title form the bocy |
330 | - $obj->title = cut_str(strip_tags($obj->content),20,'...'); |
|
330 | + $obj->title = cut_str(strip_tags($obj->content), 20, '...'); |
|
331 | 331 | if ($obj->title == '') $obj->title = 'Untitled'; |
332 | 332 | |
333 | 333 | $obj->commentStatus = 'ALLOW'; |
334 | 334 | $obj->allow_trackback = 'N'; |
335 | - $obj->regdate = date("YmdHis",$val->written->body); |
|
335 | + $obj->regdate = date("YmdHis", $val->written->body); |
|
336 | 336 | $obj->last_update = date("YmdHis", $val->written->body); |
337 | - if(!$obj->last_update) $obj->last_update = $obj->regdate; |
|
337 | + if (!$obj->last_update) $obj->last_update = $obj->regdate; |
|
338 | 338 | $obj->tags = ''; |
339 | 339 | $obj->readed_count = 0; |
340 | 340 | $obj->voted_count = 0; |
341 | - if($author_xml_id && $val->commenter->attrs->id == $author_xml_id) |
|
341 | + if ($author_xml_id && $val->commenter->attrs->id == $author_xml_id) |
|
342 | 342 | { |
343 | 343 | $obj->password = ''; |
344 | 344 | $obj->nick_name = $member_info->nick_name; |
@@ -356,19 +356,19 @@ discard block |
||
356 | 356 | $homepage = $val->commenter->homepage->body; |
357 | 357 | } |
358 | 358 | $obj->ipaddress = $val->commenter->ip->body; |
359 | - $obj->list_order = $obj->update_order = $obj->document_srl*-1; |
|
359 | + $obj->list_order = $obj->update_order = $obj->document_srl * -1; |
|
360 | 360 | $obj->notify_message = 'N'; |
361 | 361 | $obj->trackback_count = 0; |
362 | 362 | |
363 | 363 | $obj->comment_count = 0; |
364 | - if($val->comment) |
|
364 | + if ($val->comment) |
|
365 | 365 | { |
366 | 366 | $child_comment = $val->comment; |
367 | - if(!is_array($child_comment)) $child_comment = array($child_comment); |
|
368 | - foreach($child_comment as $k => $v) |
|
367 | + if (!is_array($child_comment)) $child_comment = array($child_comment); |
|
368 | + foreach ($child_comment as $k => $v) |
|
369 | 369 | { |
370 | - $result = $this->insertComment($v, $module_srl, $obj->document_srl, $member_info, 0,$author_xml_id); |
|
371 | - if($result !== false) $obj->comment_count++; |
|
370 | + $result = $this->insertComment($v, $module_srl, $obj->document_srl, $member_info, 0, $author_xml_id); |
|
371 | + if ($result !== false) $obj->comment_count++; |
|
372 | 372 | } |
373 | 373 | } |
374 | 374 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | FileHandler::removeFile($guestbook_file); |
381 | 381 | } |
382 | 382 | |
383 | - return $idx-1; |
|
383 | + return $idx - 1; |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
@@ -393,10 +393,10 @@ discard block |
||
393 | 393 | * @param int $author_xml_id |
394 | 394 | * @return int|bool |
395 | 395 | */ |
396 | - function insertTextyleGuestbookItem($val, $module_srl, $member_info, $textyle_guestbook_srl,$parent_srl = 0, $author_xml_id=null) |
|
396 | + function insertTextyleGuestbookItem($val, $module_srl, $member_info, $textyle_guestbook_srl, $parent_srl = 0, $author_xml_id = null) |
|
397 | 397 | { |
398 | 398 | $tobj = null; |
399 | - if($textyle_guestbook_srl>0) |
|
399 | + if ($textyle_guestbook_srl > 0) |
|
400 | 400 | { |
401 | 401 | $tobj->textyle_guestbook_srl = $textyle_guestbook_srl; |
402 | 402 | } |
@@ -405,9 +405,9 @@ discard block |
||
405 | 405 | $tobj->textyle_guestbook_srl = getNextSequence(); |
406 | 406 | } |
407 | 407 | $tobj->module_srl = $module_srl; |
408 | - $tobj->is_secret = $val->secret->body=='1'?1:-1; |
|
408 | + $tobj->is_secret = $val->secret->body == '1' ? 1 : -1; |
|
409 | 409 | $tobj->content = nl2br($val->content->body); |
410 | - if($author_xml_id && $val->commenter->attrs->id == $author_xml_id) |
|
410 | + if ($author_xml_id && $val->commenter->attrs->id == $author_xml_id) |
|
411 | 411 | { |
412 | 412 | $tobj->password = ''; |
413 | 413 | $tobj->nick_name = $member_info->nick_name; |
@@ -424,22 +424,22 @@ discard block |
||
424 | 424 | $tobj->homepage = $val->commenter->homepage->body; |
425 | 425 | $tobj->member_srl = 0; |
426 | 426 | } |
427 | - $tobj->last_update = $tobj->regdate = date("YmdHis",$val->written->body); |
|
427 | + $tobj->last_update = $tobj->regdate = date("YmdHis", $val->written->body); |
|
428 | 428 | $tobj->ipaddress = $val->commenter->ip->body; |
429 | 429 | |
430 | - if($parent_srl>0) |
|
430 | + if ($parent_srl > 0) |
|
431 | 431 | { |
432 | 432 | $tobj->parent_srl = $parent_srl; |
433 | 433 | $tobj->list_order = $tobj->parent_srl * -1; |
434 | 434 | } |
435 | 435 | else |
436 | 436 | { |
437 | - $tobj->list_order = $tobj->textyle_guestbook_srl*-1; |
|
437 | + $tobj->list_order = $tobj->textyle_guestbook_srl * -1; |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | $output = executeQuery('textyle.insertTextyleGuestbook', $tobj); |
441 | 441 | |
442 | - if($output->toBool()) return $tobj->textyle_guestbook_srl; |
|
442 | + if ($output->toBool()) return $tobj->textyle_guestbook_srl; |
|
443 | 443 | return false; |
444 | 444 | } |
445 | 445 | |
@@ -456,18 +456,18 @@ discard block |
||
456 | 456 | { |
457 | 457 | $uploaded_count = 0; |
458 | 458 | |
459 | - $file_obj = null; |
|
459 | + $file_obj = null; |
|
460 | 460 | $file_obj->file_srl = getNextSequence(); |
461 | 461 | $file_obj->upload_target_srl = $upload_target_srl; |
462 | 462 | $file_obj->module_srl = $module_srl; |
463 | 463 | |
464 | - while(!feof($fp)) |
|
464 | + while (!feof($fp)) |
|
465 | 465 | { |
466 | 466 | $str = fgets($fp, 1024); |
467 | 467 | // If it ends with </attaches>, break |
468 | - if(trim($str) == '</attachment>') break; |
|
468 | + if (trim($str) == '</attachment>') break; |
|
469 | 469 | // If it starts with <file>, handle the attachement in the xml file |
470 | - if(substr($str, 0, 9)=='<content>') |
|
470 | + if (substr($str, 0, 9) == '<content>') |
|
471 | 471 | { |
472 | 472 | $file_obj->file = $this->saveTemporaryFile($fp, $str); |
473 | 473 | continue; |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | |
476 | 476 | $buff .= $str; |
477 | 477 | } |
478 | - if(!file_exists($file_obj->file)) return false; |
|
478 | + if (!file_exists($file_obj->file)) return false; |
|
479 | 479 | |
480 | 480 | $buff .= '</attachment>'; |
481 | 481 | |
@@ -485,20 +485,20 @@ discard block |
||
485 | 485 | $file_obj->download_count = $xmlDoc->attachment->downloads->body; |
486 | 486 | $name = $xmlDoc->attachment->name->body; |
487 | 487 | // Set upload path by checking if the attachement is an image or other kind of file |
488 | - if(preg_match("/\.(asf|asf|asx|avi|flv|gif|jpeg|jpg|m4a|m4v|mid|midi|moov|mov|mp1|mp2|mp3|mp4|mpeg|mpg|ogg|png|qt|ra|ram|rm|rmm|wav|webm|webp|wma|wmv)$/i", $file_obj->source_filename)) |
|
488 | + if (preg_match("/\.(asf|asf|asx|avi|flv|gif|jpeg|jpg|m4a|m4v|mid|midi|moov|mov|mp1|mp2|mp3|mp4|mpeg|mpg|ogg|png|qt|ra|ram|rm|rmm|wav|webm|webp|wma|wmv)$/i", $file_obj->source_filename)) |
|
489 | 489 | { |
490 | - $path = sprintf("./files/attach/images/%s/%s", $module_srl,getNumberingPath($upload_target_srl,3)); |
|
490 | + $path = sprintf("./files/attach/images/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3)); |
|
491 | 491 | $filename = $path.$file_obj->source_filename; |
492 | 492 | $file_obj->direct_download = 'Y'; |
493 | 493 | } |
494 | 494 | else |
495 | 495 | { |
496 | - $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3)); |
|
497 | - $filename = $path.md5(crypt(rand(1000000,900000), rand(0,100))); |
|
496 | + $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3)); |
|
497 | + $filename = $path.md5(crypt(rand(1000000, 900000), rand(0, 100))); |
|
498 | 498 | $file_obj->direct_download = 'N'; |
499 | 499 | } |
500 | 500 | // Create a directory |
501 | - if(!FileHandler::makeDir($path)) return; |
|
501 | + if (!FileHandler::makeDir($path)) return; |
|
502 | 502 | |
503 | 503 | FileHandler::rename($file_obj->file, $filename); |
504 | 504 | // Insert to the DB |
@@ -507,16 +507,16 @@ discard block |
||
507 | 507 | $file_obj->file_size = filesize($filename); |
508 | 508 | $file_obj->comment = NULL; |
509 | 509 | $file_obj->member_srl = 0; |
510 | - $file_obj->sid = md5(rand(rand(1111111,4444444),rand(4444445,9999999))); |
|
510 | + $file_obj->sid = md5(rand(rand(1111111, 4444444), rand(4444445, 9999999))); |
|
511 | 511 | $file_obj->isvalid = 'Y'; |
512 | 512 | $output = executeQuery('file.insertFile', $file_obj); |
513 | 513 | |
514 | - if($output->toBool()) |
|
514 | + if ($output->toBool()) |
|
515 | 515 | { |
516 | 516 | $uploaded_count++; |
517 | 517 | $tmp_obj = null; |
518 | - if($file_obj->direct_download == 'Y') $files[$name]->url = $file_obj->uploaded_filename; |
|
519 | - else $files[$name]->url = getUrl('','module','file','act','procFileDownload','file_srl',$file_obj->file_srl,'sid',$file_obj->sid); |
|
518 | + if ($file_obj->direct_download == 'Y') $files[$name]->url = $file_obj->uploaded_filename; |
|
519 | + else $files[$name]->url = getUrl('', 'module', 'file', 'act', 'procFileDownload', 'file_srl', $file_obj->file_srl, 'sid', $file_obj->sid); |
|
520 | 520 | $files[$name]->direct_download = $file_obj->direct_download; |
521 | 521 | $files[$name]->source_filename = $file_obj->source_filename; |
522 | 522 | return true; |
@@ -532,9 +532,9 @@ discard block |
||
532 | 532 | function getTmpFilename() |
533 | 533 | { |
534 | 534 | $path = "./files/cache/importer"; |
535 | - if(!is_dir($path)) FileHandler::makeDir($path); |
|
536 | - $filename = sprintf("%s/%d", $path, rand(11111111,99999999)); |
|
537 | - if(file_exists($filename)) $filename .= rand(111,999); |
|
535 | + if (!is_dir($path)) FileHandler::makeDir($path); |
|
536 | + $filename = sprintf("%s/%d", $path, rand(11111111, 99999999)); |
|
537 | + if (file_exists($filename)) $filename .= rand(111, 999); |
|
538 | 538 | return $filename; |
539 | 539 | } |
540 | 540 | |
@@ -549,11 +549,11 @@ discard block |
||
549 | 549 | $temp_filename = $this->getTmpFilename(); |
550 | 550 | $buff = substr($buff, 9); |
551 | 551 | |
552 | - while(!feof($fp)) |
|
552 | + while (!feof($fp)) |
|
553 | 553 | { |
554 | 554 | $str = trim(fgets($fp, 1024)); |
555 | 555 | $buff .= $str; |
556 | - if(substr($str, -10) == '</content>') break; |
|
556 | + if (substr($str, -10) == '</content>') break; |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | $buff = substr($buff, 0, -10); |
@@ -572,16 +572,16 @@ discard block |
||
572 | 572 | function _replaceTTAttach($matches) |
573 | 573 | { |
574 | 574 | $name = $matches[2]; |
575 | - if(!$name) return $matches[0]; |
|
575 | + if (!$name) return $matches[0]; |
|
576 | 576 | |
577 | 577 | $obj = $this->files[$name]; |
578 | 578 | // If multimedia file is, |
579 | - if($obj->direct_download == 'Y') |
|
579 | + if ($obj->direct_download == 'Y') |
|
580 | 580 | { |
581 | 581 | // If image file is |
582 | - if(preg_match('/\.(jpg|gif|jpeg|png)$/i', $obj->source_filename)) |
|
582 | + if (preg_match('/\.(jpg|gif|jpeg|png)$/i', $obj->source_filename)) |
|
583 | 583 | { |
584 | - return sprintf('<img editor_component="image_link" src="%s" alt="%s" />', $obj->url, str_replace('"','\\"',$matches[4])); |
|
584 | + return sprintf('<img editor_component="image_link" src="%s" alt="%s" />', $obj->url, str_replace('"', '\\"', $matches[4])); |
|
585 | 585 | // If other multimedia file but image is, |
586 | 586 | } |
587 | 587 | else |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | function _replaceTTMovie($matches) |
604 | 604 | { |
605 | 605 | $key = $matches[1]; |
606 | - if(!$key) return $matches[0]; |
|
606 | + if (!$key) return $matches[0]; |
|
607 | 607 | |
608 | 608 | return |
609 | 609 | '<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="402">'. |
@@ -631,12 +631,12 @@ discard block |
||
631 | 631 | $tobj->comment_srl = getNextSequence(); |
632 | 632 | $tobj->module_srl = $module_srl; |
633 | 633 | $tobj->document_srl = $document_srl; |
634 | - $tobj->is_secret = $val->secret->body=='1'?'Y':'N'; |
|
634 | + $tobj->is_secret = $val->secret->body == '1' ? 'Y' : 'N'; |
|
635 | 635 | $tobj->notify_message = 'N'; |
636 | 636 | $tobj->content = nl2br($val->content->body); |
637 | 637 | $tobj->voted_count = 0; |
638 | 638 | $tobj->status = 1; |
639 | - if($author_xml_id && $val->commenter->attrs->id == $author_xml_id) |
|
639 | + if ($author_xml_id && $val->commenter->attrs->id == $author_xml_id) |
|
640 | 640 | { |
641 | 641 | $tobj->password = ''; |
642 | 642 | $tobj->nick_name = $member_info->nick_name; |
@@ -653,9 +653,9 @@ discard block |
||
653 | 653 | $tobj->homepage = $val->commenter->homepage->body; |
654 | 654 | $tobj->member_srl = 0; |
655 | 655 | } |
656 | - $tobj->last_update = $tobj->regdate = date("YmdHis",$val->written->body); |
|
656 | + $tobj->last_update = $tobj->regdate = date("YmdHis", $val->written->body); |
|
657 | 657 | $tobj->ipaddress = $val->commenter->ip->body; |
658 | - $tobj->list_order = $tobj->comment_srl*-1; |
|
658 | + $tobj->list_order = $tobj->comment_srl * -1; |
|
659 | 659 | $tobj->sequence = $sequence; |
660 | 660 | $tobj->parent_srl = $parent_srl; |
661 | 661 | // Comment list first |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | $list_args->module_srl = $tobj->module_srl; |
666 | 666 | $list_args->regdate = $tobj->regdate; |
667 | 667 | // Set data directly if parent comment doesn't exist |
668 | - if(!$tobj->parent_srl) |
|
668 | + if (!$tobj->parent_srl) |
|
669 | 669 | { |
670 | 670 | $list_args->head = $list_args->arrange = $tobj->comment_srl; |
671 | 671 | $list_args->depth = 0; |
@@ -677,25 +677,25 @@ discard block |
||
677 | 677 | $parent_args->comment_srl = $tobj->parent_srl; |
678 | 678 | $parent_output = executeQuery('comment.getCommentListItem', $parent_args); |
679 | 679 | // Return if parent comment doesn't exist |
680 | - if(!$parent_output->toBool() || !$parent_output->data) return false; |
|
680 | + if (!$parent_output->toBool() || !$parent_output->data) return false; |
|
681 | 681 | $parent = $parent_output->data; |
682 | 682 | |
683 | 683 | $list_args->head = $parent->head; |
684 | - $list_args->depth = $parent->depth+1; |
|
685 | - if($list_args->depth<2) $list_args->arrange = $tobj->comment_srl; |
|
684 | + $list_args->depth = $parent->depth + 1; |
|
685 | + if ($list_args->depth < 2) $list_args->arrange = $tobj->comment_srl; |
|
686 | 686 | else |
687 | 687 | { |
688 | 688 | $list_args->arrange = $parent->arrange; |
689 | 689 | $output = executeQuery('comment.updateCommentListArrange', $list_args); |
690 | - if(!$output->toBool()) return $output; |
|
690 | + if (!$output->toBool()) return $output; |
|
691 | 691 | } |
692 | 692 | } |
693 | 693 | |
694 | 694 | $output = executeQuery('comment.insertCommentList', $list_args); |
695 | - if($output->toBool()) |
|
695 | + if ($output->toBool()) |
|
696 | 696 | { |
697 | 697 | $output = executeQuery('comment.insertComment', $tobj); |
698 | - if($output->toBool()) return $tobj->comment_srl; |
|
698 | + if ($output->toBool()) return $tobj->comment_srl; |
|
699 | 699 | } |
700 | 700 | return false; |
701 | 701 | } |
@@ -710,10 +710,10 @@ discard block |
||
710 | 710 | */ |
711 | 711 | function arrangeCategory($obj, &$category, &$idx, $parent = 0) |
712 | 712 | { |
713 | - if(!$obj->category) return; |
|
714 | - if(!is_array($obj->category)) $c = array($obj->category); |
|
713 | + if (!$obj->category) return; |
|
714 | + if (!is_array($obj->category)) $c = array($obj->category); |
|
715 | 715 | else $c = $obj->category; |
716 | - foreach($c as $val) |
|
716 | + foreach ($c as $val) |
|
717 | 717 | { |
718 | 718 | $idx++; |
719 | 719 | $priority = $val->priority->body; |
@@ -545,6 +545,7 @@ discard block |
||
545 | 545 | |
546 | 546 | /** |
547 | 547 | * @brief Install an each module |
548 | + * @param string $module_path |
|
548 | 549 | */ |
549 | 550 | function installModule($module, $module_path) |
550 | 551 | { |
@@ -614,6 +615,7 @@ discard block |
||
614 | 615 | /** |
615 | 616 | * @brief Create etc config file |
616 | 617 | * Create the config file when all settings are completed |
618 | + * @param stdClass $config_info |
|
617 | 619 | */ |
618 | 620 | function makeEtcConfigFile($config_info) |
619 | 621 | { |
@@ -413,7 +413,7 @@ |
||
413 | 413 | * make a file to files/config and check url approach by ".htaccess" rules |
414 | 414 | * |
415 | 415 | * @return bool |
416 | - */ |
|
416 | + */ |
|
417 | 417 | function checkRewriteUsable() { |
418 | 418 | $checkString = "isApproached"; |
419 | 419 | $checkFilePath = 'files/config/tmpRewriteCheck.txt'; |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | function init() |
18 | 18 | { |
19 | 19 | // Error occurs if already installed |
20 | - if($this->act !== 'procInstallLicenseAggrement' && Context::isInstalled()) |
|
20 | + if ($this->act !== 'procInstallLicenseAggrement' && Context::isInstalled()) |
|
21 | 21 | { |
22 | 22 | $this->stop('msg_already_installed'); |
23 | 23 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | function _procDBSetting() |
87 | 87 | { |
88 | 88 | // Get DB-related variables |
89 | - $con_string = Context::gets('db_type','db_port','db_hostname','db_userid','db_password','db_database','db_table_prefix'); |
|
89 | + $con_string = Context::gets('db_type', 'db_port', 'db_hostname', 'db_userid', 'db_password', 'db_database', 'db_table_prefix'); |
|
90 | 90 | |
91 | 91 | $db_info = new stdClass(); |
92 | 92 | $db_info->master_db = get_object_vars($con_string); |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | // Check if available to connect to the DB |
102 | 102 | $oDB = &DB::getInstance(); |
103 | 103 | $output = $oDB->getError(); |
104 | - if(!$output->toBool()) return $output; |
|
105 | - if(!$oDB->isConnected()) return $oDB->getError(); |
|
104 | + if (!$output->toBool()) return $output; |
|
105 | + if (!$oDB->isConnected()) return $oDB->getError(); |
|
106 | 106 | |
107 | 107 | // Create a db temp config file |
108 | - if(!$this->makeDBConfigFile()) return new BaseObject(-1, 'msg_install_failed'); |
|
108 | + if (!$this->makeDBConfigFile()) return new BaseObject(-1, 'msg_install_failed'); |
|
109 | 109 | |
110 | - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
|
110 | + if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) |
|
111 | 111 | { |
112 | 112 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'act', 'dispInstallConfigForm'); |
113 | 113 | header('location:'.$returnUrl); |
@@ -121,13 +121,13 @@ discard block |
||
121 | 121 | function procConfigSetting() |
122 | 122 | { |
123 | 123 | // Get variables |
124 | - $config_info = Context::gets('use_rewrite','time_zone'); |
|
125 | - if($config_info->use_rewrite!='Y') $config_info->use_rewrite = 'N'; |
|
124 | + $config_info = Context::gets('use_rewrite', 'time_zone'); |
|
125 | + if ($config_info->use_rewrite != 'Y') $config_info->use_rewrite = 'N'; |
|
126 | 126 | |
127 | 127 | // Create a db temp config file |
128 | - if(!$this->makeEtcConfigFile($config_info)) return new BaseObject(-1, 'msg_install_failed'); |
|
128 | + if (!$this->makeEtcConfigFile($config_info)) return new BaseObject(-1, 'msg_install_failed'); |
|
129 | 129 | |
130 | - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
|
130 | + if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) |
|
131 | 131 | { |
132 | 132 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'act', 'dispInstallManagerForm'); |
133 | 133 | header('location:'.$returnUrl); |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | function procInstall() |
142 | 142 | { |
143 | 143 | // Check if it is already installed |
144 | - if(Context::isInstalled()) return new BaseObject(-1, 'msg_already_installed'); |
|
144 | + if (Context::isInstalled()) return new BaseObject(-1, 'msg_already_installed'); |
|
145 | 145 | |
146 | 146 | Context::loadLang('modules/member/lang'); |
147 | 147 | $oMemberModel = getModel('member'); |
148 | 148 | $vars = Context::getRequestVars(); |
149 | 149 | |
150 | - if(!$oMemberModel->checkPasswordStrength($vars->password, 'high')) |
|
150 | + if (!$oMemberModel->checkPasswordStrength($vars->password, 'high')) |
|
151 | 151 | { |
152 | 152 | Context::loadLang('modules/member/lang'); |
153 | 153 | $message = Context::getLang('about_password_strength'); |
@@ -160,15 +160,15 @@ discard block |
||
160 | 160 | Context::set('logged_info', $logged_info); |
161 | 161 | |
162 | 162 | // check install config |
163 | - if(Context::get('install_config')) |
|
163 | + if (Context::get('install_config')) |
|
164 | 164 | { |
165 | 165 | $db_info = $this->_makeDbInfoByInstallConfig(); |
166 | 166 | } |
167 | 167 | // install by default XE UI |
168 | 168 | else |
169 | 169 | { |
170 | - if(FileHandler::exists($this->db_tmp_config_file)) include $this->db_tmp_config_file; |
|
171 | - if(FileHandler::exists($this->etc_tmp_config_file)) include $this->etc_tmp_config_file; |
|
170 | + if (FileHandler::exists($this->db_tmp_config_file)) include $this->db_tmp_config_file; |
|
171 | + if (FileHandler::exists($this->etc_tmp_config_file)) include $this->etc_tmp_config_file; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // Set DB type and information |
@@ -176,30 +176,30 @@ discard block |
||
176 | 176 | // Create DB Instance |
177 | 177 | $oDB = &DB::getInstance(); |
178 | 178 | // Check if available to connect to the DB |
179 | - if(!$oDB->isConnected()) return $oDB->getError(); |
|
179 | + if (!$oDB->isConnected()) return $oDB->getError(); |
|
180 | 180 | |
181 | 181 | // Install all the modules |
182 | 182 | try { |
183 | 183 | $oDB->begin(); |
184 | 184 | $this->installDownloadedModule(); |
185 | 185 | $oDB->commit(); |
186 | - } catch(Exception $e) { |
|
186 | + } catch (Exception $e) { |
|
187 | 187 | $oDB->rollback(); |
188 | 188 | return new BaseObject(-1, $e->getMessage()); |
189 | 189 | } |
190 | 190 | |
191 | 191 | // Create a config file |
192 | - if(!$this->makeConfigFile()) return new BaseObject(-1, 'msg_install_failed'); |
|
192 | + if (!$this->makeConfigFile()) return new BaseObject(-1, 'msg_install_failed'); |
|
193 | 193 | |
194 | 194 | // load script |
195 | - $scripts = FileHandler::readDir(_XE_PATH_ . 'modules/install/script', '/(\.php)$/'); |
|
196 | - if(count($scripts)>0) |
|
195 | + $scripts = FileHandler::readDir(_XE_PATH_.'modules/install/script', '/(\.php)$/'); |
|
196 | + if (count($scripts) > 0) |
|
197 | 197 | { |
198 | 198 | sort($scripts); |
199 | - foreach($scripts as $script) |
|
199 | + foreach ($scripts as $script) |
|
200 | 200 | { |
201 | 201 | $script_path = FileHandler::getRealPath('./modules/install/script/'); |
202 | - $output = include($script_path . $script); |
|
202 | + $output = include($script_path.$script); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | |
213 | 213 | unset($_SESSION['use_rewrite']); |
214 | 214 | |
215 | - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
|
215 | + if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) |
|
216 | 216 | { |
217 | 217 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl(''); |
218 | 218 | header('location:'.$returnUrl); |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | $db_info->use_rewrite = Context::get('use_rewrite'); |
243 | 243 | $db_info->time_zone = Context::get('time_zone'); |
244 | 244 | |
245 | - if($_SERVER['HTTPS'] == 'on') |
|
245 | + if ($_SERVER['HTTPS'] == 'on') |
|
246 | 246 | { |
247 | 247 | $https_port = (Context::get('https_port')) ? Context::get('https_port') : $_SERVER['SERVER_PORT']; |
248 | 248 | $https_port = (!$https_port != 443) ? $https_port : null; |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | $http_port = (Context::get('http_port')) ? Context::get('http_port') : $_SERVER['SERVER_PORT']; |
253 | 253 | $http_port = (!$http_port != 80) ? $http_port : null; |
254 | 254 | } |
255 | - if($http_port) $db_info->http_port = $http_port; |
|
256 | - if($https_port) $db_info->https_port = $https_port; |
|
255 | + if ($http_port) $db_info->http_port = $http_port; |
|
256 | + if ($https_port) $db_info->https_port = $https_port; |
|
257 | 257 | |
258 | 258 | return $db_info; |
259 | 259 | } |
@@ -263,57 +263,57 @@ discard block |
||
263 | 263 | */ |
264 | 264 | function procInstallFTP() |
265 | 265 | { |
266 | - if(Context::isInstalled()) return new BaseObject(-1, 'msg_already_installed'); |
|
267 | - $ftp_info = Context::gets('ftp_host', 'ftp_user','ftp_password','ftp_port','ftp_root_path'); |
|
268 | - $ftp_info->ftp_port = (int)$ftp_info->ftp_port; |
|
269 | - if(!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
270 | - if(!$ftp_info->ftp_host) $ftp_info->ftp_host = '127.0.0.1'; |
|
271 | - if(!$ftp_info->ftp_root_path) $ftp_info->ftp_root_path = '/'; |
|
266 | + if (Context::isInstalled()) return new BaseObject(-1, 'msg_already_installed'); |
|
267 | + $ftp_info = Context::gets('ftp_host', 'ftp_user', 'ftp_password', 'ftp_port', 'ftp_root_path'); |
|
268 | + $ftp_info->ftp_port = (int) $ftp_info->ftp_port; |
|
269 | + if (!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
270 | + if (!$ftp_info->ftp_host) $ftp_info->ftp_host = '127.0.0.1'; |
|
271 | + if (!$ftp_info->ftp_root_path) $ftp_info->ftp_root_path = '/'; |
|
272 | 272 | |
273 | 273 | $buff = array('<?php if(!defined("__XE__")) exit();'); |
274 | 274 | $buff[] = "\$ftp_info = new stdClass();"; |
275 | - foreach($ftp_info as $key => $val) |
|
275 | + foreach ($ftp_info as $key => $val) |
|
276 | 276 | { |
277 | - $buff[] = sprintf("\$ftp_info->%s='%s';", $key, str_replace("'","\\'",$val)); |
|
277 | + $buff[] = sprintf("\$ftp_info->%s='%s';", $key, str_replace("'", "\\'", $val)); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | // If safe_mode |
281 | - if(ini_get('safe_mode')) |
|
281 | + if (ini_get('safe_mode')) |
|
282 | 282 | { |
283 | - if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new BaseObject(-1,'msg_safe_mode_ftp_needed'); |
|
283 | + if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new BaseObject(-1, 'msg_safe_mode_ftp_needed'); |
|
284 | 284 | |
285 | 285 | require_once(_XE_PATH_.'libs/ftp.class.php'); |
286 | 286 | $oFtp = new ftp(); |
287 | - if(!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) return new BaseObject(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'host')); |
|
287 | + if (!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) return new BaseObject(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'host')); |
|
288 | 288 | |
289 | - if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
289 | + if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
290 | 290 | { |
291 | 291 | $oFtp->ftp_quit(); |
292 | - return new BaseObject(-1,'msg_ftp_invalid_auth_info'); |
|
292 | + return new BaseObject(-1, 'msg_ftp_invalid_auth_info'); |
|
293 | 293 | } |
294 | 294 | |
295 | - if(!is_dir(_XE_PATH_.'files') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path.'files')) |
|
295 | + if (!is_dir(_XE_PATH_.'files') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path.'files')) |
|
296 | 296 | { |
297 | 297 | $oFtp->ftp_quit(); |
298 | - return new BaseObject(-1,'msg_ftp_mkdir_fail'); |
|
298 | + return new BaseObject(-1, 'msg_ftp_mkdir_fail'); |
|
299 | 299 | } |
300 | 300 | |
301 | - if(!$oFtp->ftp_site("CHMOD 777 ".$ftp_info->ftp_root_path.'files')) |
|
301 | + if (!$oFtp->ftp_site("CHMOD 777 ".$ftp_info->ftp_root_path.'files')) |
|
302 | 302 | { |
303 | 303 | $oFtp->ftp_quit(); |
304 | - return new BaseObject(-1,'msg_ftp_chmod_fail'); |
|
304 | + return new BaseObject(-1, 'msg_ftp_chmod_fail'); |
|
305 | 305 | } |
306 | 306 | |
307 | - if(!is_dir(_XE_PATH_.'files/config') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path.'files/config')) |
|
307 | + if (!is_dir(_XE_PATH_.'files/config') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path.'files/config')) |
|
308 | 308 | { |
309 | 309 | $oFtp->ftp_quit(); |
310 | - return new BaseObject(-1,'msg_ftp_mkdir_fail'); |
|
310 | + return new BaseObject(-1, 'msg_ftp_mkdir_fail'); |
|
311 | 311 | } |
312 | 312 | |
313 | - if(!$oFtp->ftp_site("CHMOD 777 ".$ftp_info->ftp_root_path.'files/config')) |
|
313 | + if (!$oFtp->ftp_site("CHMOD 777 ".$ftp_info->ftp_root_path.'files/config')) |
|
314 | 314 | { |
315 | 315 | $oFtp->ftp_quit(); |
316 | - return new BaseObject(-1,'msg_ftp_chmod_fail'); |
|
316 | + return new BaseObject(-1, 'msg_ftp_chmod_fail'); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | $oFtp->ftp_quit(); |
@@ -324,31 +324,31 @@ discard block |
||
324 | 324 | |
325 | 325 | function procInstallCheckFtp() |
326 | 326 | { |
327 | - $ftp_info = Context::gets('ftp_user','ftp_password','ftp_port','sftp'); |
|
328 | - $ftp_info->ftp_port = (int)$ftp_info->ftp_port; |
|
329 | - if(!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
330 | - if(!$ftp_info->sftp) $ftp_info->sftp = 'N'; |
|
327 | + $ftp_info = Context::gets('ftp_user', 'ftp_password', 'ftp_port', 'sftp'); |
|
328 | + $ftp_info->ftp_port = (int) $ftp_info->ftp_port; |
|
329 | + if (!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
330 | + if (!$ftp_info->sftp) $ftp_info->sftp = 'N'; |
|
331 | 331 | |
332 | - if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new BaseObject(-1,'msg_safe_mode_ftp_needed'); |
|
332 | + if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new BaseObject(-1, 'msg_safe_mode_ftp_needed'); |
|
333 | 333 | |
334 | - if($ftp_info->sftp == 'Y') |
|
334 | + if ($ftp_info->sftp == 'Y') |
|
335 | 335 | { |
336 | 336 | $connection = ssh2_connect('localhost', $ftp_info->ftp_port); |
337 | - if(!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
337 | + if (!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
338 | 338 | { |
339 | - return new BaseObject(-1,'msg_ftp_invalid_auth_info'); |
|
339 | + return new BaseObject(-1, 'msg_ftp_invalid_auth_info'); |
|
340 | 340 | } |
341 | 341 | } |
342 | 342 | else |
343 | 343 | { |
344 | 344 | require_once(_XE_PATH_.'libs/ftp.class.php'); |
345 | 345 | $oFtp = new ftp(); |
346 | - if(!$oFtp->ftp_connect('127.0.0.1', $ftp_info->ftp_port)) return new BaseObject(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'localhost')); |
|
346 | + if (!$oFtp->ftp_connect('127.0.0.1', $ftp_info->ftp_port)) return new BaseObject(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'localhost')); |
|
347 | 347 | |
348 | - if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
348 | + if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
349 | 349 | { |
350 | 350 | $oFtp->ftp_quit(); |
351 | - return new BaseObject(-1,'msg_ftp_invalid_auth_info'); |
|
351 | + return new BaseObject(-1, 'msg_ftp_invalid_auth_info'); |
|
352 | 352 | } |
353 | 353 | $oFtp->ftp_quit(); |
354 | 354 | } |
@@ -365,36 +365,36 @@ discard block |
||
365 | 365 | $checklist = array(); |
366 | 366 | // 0. check your version of php (5.2.4 or higher) |
367 | 367 | $checklist['php_version'] = true; |
368 | - if(version_compare(PHP_VERSION, __XE_MIN_PHP_VERSION__, '<')) |
|
368 | + if (version_compare(PHP_VERSION, __XE_MIN_PHP_VERSION__, '<')) |
|
369 | 369 | { |
370 | 370 | $checklist['php_version'] = false; |
371 | 371 | } |
372 | 372 | |
373 | - if(version_compare(PHP_VERSION, __XE_RECOMMEND_PHP_VERSION__, '<')) |
|
373 | + if (version_compare(PHP_VERSION, __XE_RECOMMEND_PHP_VERSION__, '<')) |
|
374 | 374 | { |
375 | 375 | Context::set('phpversion_warning', true); |
376 | 376 | } |
377 | 377 | |
378 | 378 | // 1. Check permission |
379 | - if(is_writable('./')||is_writable('./files')) $checklist['permission'] = true; |
|
379 | + if (is_writable('./') || is_writable('./files')) $checklist['permission'] = true; |
|
380 | 380 | else $checklist['permission'] = false; |
381 | 381 | // 2. Check if xml_parser_create exists |
382 | - if(function_exists('xml_parser_create')) $checklist['xml'] = true; |
|
382 | + if (function_exists('xml_parser_create')) $checklist['xml'] = true; |
|
383 | 383 | else $checklist['xml'] = false; |
384 | 384 | // 3. Check if ini_get (session.auto_start) == 1 |
385 | - if(ini_get('session.auto_start')!=1) $checklist['session'] = true; |
|
385 | + if (ini_get('session.auto_start') != 1) $checklist['session'] = true; |
|
386 | 386 | else $checklist['session'] = false; |
387 | 387 | // 4. Check if iconv exists |
388 | - if(function_exists('iconv')) $checklist['iconv'] = true; |
|
388 | + if (function_exists('iconv')) $checklist['iconv'] = true; |
|
389 | 389 | else $checklist['iconv'] = false; |
390 | 390 | // 5. Check gd(imagecreatefromgif function) |
391 | - if(function_exists('imagecreatefromgif')) $checklist['gd'] = true; |
|
391 | + if (function_exists('imagecreatefromgif')) $checklist['gd'] = true; |
|
392 | 392 | else $checklist['gd'] = false; |
393 | 393 | // 6. Check DB |
394 | - if(DB::getEnableList()) $checklist['db'] = true; |
|
394 | + if (DB::getEnableList()) $checklist['db'] = true; |
|
395 | 395 | else $checklist['db'] = false; |
396 | 396 | |
397 | - if(!$checklist['php_version'] || !$checklist['permission'] || !$checklist['xml'] || !$checklist['session'] || !$checklist['db']) $install_enable = false; |
|
397 | + if (!$checklist['php_version'] || !$checklist['permission'] || !$checklist['xml'] || !$checklist['session'] || !$checklist['db']) $install_enable = false; |
|
398 | 398 | else $install_enable = true; |
399 | 399 | |
400 | 400 | // Save the checked result to the Context |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | |
415 | 415 | $license_agreement = ($vars->license_agreement == 'Y') ? true : false; |
416 | 416 | |
417 | - if($license_agreement) |
|
417 | + if ($license_agreement) |
|
418 | 418 | { |
419 | 419 | $currentTime = $_SERVER['REQUEST_TIME']; |
420 | 420 | FileHandler::writeFile($this->flagLicenseAgreement, $currentTime); |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | return new BaseObject(-1, 'msg_must_accept_license_agreement'); |
426 | 426 | } |
427 | 427 | |
428 | - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
|
428 | + if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) |
|
429 | 429 | { |
430 | 430 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'act', 'dispInstallCheckEnv'); |
431 | 431 | $this->setRedirectUrl($returnUrl); |
@@ -448,25 +448,25 @@ discard block |
||
448 | 448 | $hostname = $_SERVER['SERVER_NAME']; |
449 | 449 | $port = $_SERVER['SERVER_PORT']; |
450 | 450 | $str_port = ''; |
451 | - if($port) |
|
451 | + if ($port) |
|
452 | 452 | { |
453 | - $str_port = ':' . $port; |
|
453 | + $str_port = ':'.$port; |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | $tmpPath = $_SERVER['DOCUMENT_ROOT']; |
457 | 457 | |
458 | 458 | //if DIRECTORY_SEPARATOR is not /(IIS) |
459 | - if(DIRECTORY_SEPARATOR !== '/') |
|
459 | + if (DIRECTORY_SEPARATOR !== '/') |
|
460 | 460 | { |
461 | 461 | //change to slash for compare |
462 | 462 | $tmpPath = str_replace(DIRECTORY_SEPARATOR, '/', $_SERVER['DOCUMENT_ROOT']); |
463 | 463 | } |
464 | 464 | |
465 | - $query = "/JUST/CHECK/REWRITE/" . $checkFilePath; |
|
465 | + $query = "/JUST/CHECK/REWRITE/".$checkFilePath; |
|
466 | 466 | $currentPath = str_replace($tmpPath, "", _XE_PATH_); |
467 | - if($currentPath != "") |
|
467 | + if ($currentPath != "") |
|
468 | 468 | { |
469 | - $query = $currentPath . $query; |
|
469 | + $query = $currentPath.$query; |
|
470 | 470 | } |
471 | 471 | $requestUrl = sprintf('%s://%s%s%s', $scheme, $hostname, $str_port, $query); |
472 | 472 | $requestConfig = array(); |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | './files/cache/template_compiled', |
492 | 492 | ); |
493 | 493 | |
494 | - foreach($directory_list as $dir) |
|
494 | + foreach ($directory_list as $dir) |
|
495 | 495 | { |
496 | 496 | FileHandler::makeDir($dir); |
497 | 497 | } |
@@ -507,57 +507,57 @@ discard block |
||
507 | 507 | $oModuleModel = getModel('module'); |
508 | 508 | // Create a table ny finding schemas/*.xml file in each module |
509 | 509 | $module_list = FileHandler::readDir('./modules/', NULL, false, true); |
510 | - foreach($module_list as $module_path) |
|
510 | + foreach ($module_list as $module_path) |
|
511 | 511 | { |
512 | 512 | // Get module name |
513 | - $tmp_arr = explode('/',$module_path); |
|
514 | - $module = $tmp_arr[count($tmp_arr)-1]; |
|
513 | + $tmp_arr = explode('/', $module_path); |
|
514 | + $module = $tmp_arr[count($tmp_arr) - 1]; |
|
515 | 515 | |
516 | 516 | $xml_info = $oModuleModel->getModuleInfoXml($module); |
517 | - if(!$xml_info) continue; |
|
517 | + if (!$xml_info) continue; |
|
518 | 518 | $modules[$xml_info->category][] = $module; |
519 | 519 | } |
520 | 520 | // Install "module" module in advance |
521 | - $this->installModule('module','./modules/module'); |
|
521 | + $this->installModule('module', './modules/module'); |
|
522 | 522 | $oModule = getClass('module'); |
523 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
523 | + if ($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
524 | 524 | // Determine the order of module installation depending on category |
525 | - $install_step = array('system','content','member'); |
|
525 | + $install_step = array('system', 'content', 'member'); |
|
526 | 526 | // Install all the remaining modules |
527 | - foreach($install_step as $category) |
|
527 | + foreach ($install_step as $category) |
|
528 | 528 | { |
529 | - if(count($modules[$category])) |
|
529 | + if (count($modules[$category])) |
|
530 | 530 | { |
531 | - foreach($modules[$category] as $module) |
|
531 | + foreach ($modules[$category] as $module) |
|
532 | 532 | { |
533 | - if($module == 'module') continue; |
|
533 | + if ($module == 'module') continue; |
|
534 | 534 | $this->installModule($module, sprintf('./modules/%s', $module)); |
535 | 535 | |
536 | 536 | $oModule = getClass($module); |
537 | - if(is_object($oModule) && method_exists($oModule, 'checkUpdate')) |
|
537 | + if (is_object($oModule) && method_exists($oModule, 'checkUpdate')) |
|
538 | 538 | { |
539 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
539 | + if ($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
540 | 540 | } |
541 | 541 | } |
542 | 542 | unset($modules[$category]); |
543 | 543 | } |
544 | 544 | } |
545 | 545 | // Install all the remaining modules |
546 | - if(count($modules)) |
|
546 | + if (count($modules)) |
|
547 | 547 | { |
548 | - foreach($modules as $category => $module_list) |
|
548 | + foreach ($modules as $category => $module_list) |
|
549 | 549 | { |
550 | - if(count($module_list)) |
|
550 | + if (count($module_list)) |
|
551 | 551 | { |
552 | - foreach($module_list as $module) |
|
552 | + foreach ($module_list as $module) |
|
553 | 553 | { |
554 | - if($module == 'module') continue; |
|
554 | + if ($module == 'module') continue; |
|
555 | 555 | $this->installModule($module, sprintf('./modules/%s', $module)); |
556 | 556 | |
557 | 557 | $oModule = getClass($module); |
558 | - if($oModule && method_exists($oModule, 'checkUpdate') && method_exists($oModule, 'moduleUpdate')) |
|
558 | + if ($oModule && method_exists($oModule, 'checkUpdate') && method_exists($oModule, 'moduleUpdate')) |
|
559 | 559 | { |
560 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
560 | + if ($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
561 | 561 | } |
562 | 562 | } |
563 | 563 | } |
@@ -579,31 +579,31 @@ discard block |
||
579 | 579 | $schema_files = FileHandler::readDir($schema_dir, NULL, false, true); |
580 | 580 | |
581 | 581 | $file_cnt = count($schema_files); |
582 | - for($i=0;$i<$file_cnt;$i++) |
|
582 | + for ($i = 0; $i < $file_cnt; $i++) |
|
583 | 583 | { |
584 | 584 | $file = trim($schema_files[$i]); |
585 | - if(!$file || substr($file,-4)!='.xml') continue; |
|
585 | + if (!$file || substr($file, -4) != '.xml') continue; |
|
586 | 586 | $output = $oDB->createTableByXmlFile($file); |
587 | - if($output === false) |
|
587 | + if ($output === false) |
|
588 | 588 | throw new Exception('msg_create_table_failed'); |
589 | 589 | } |
590 | 590 | // Create a table and module instance and then execute install() method |
591 | 591 | unset($oModule); |
592 | 592 | $oModule = getClass($module); |
593 | - if(method_exists($oModule, 'moduleInstall')) $oModule->moduleInstall(); |
|
593 | + if (method_exists($oModule, 'moduleInstall')) $oModule->moduleInstall(); |
|
594 | 594 | return new BaseObject(); |
595 | 595 | } |
596 | 596 | |
597 | 597 | function _getDBConfigFileContents($db_info) |
598 | 598 | { |
599 | - if(substr($db_info->master_db['db_table_prefix'], -1) != '_') |
|
599 | + if (substr($db_info->master_db['db_table_prefix'], -1) != '_') |
|
600 | 600 | { |
601 | 601 | $db_info->master_db['db_table_prefix'] .= '_'; |
602 | 602 | } |
603 | 603 | |
604 | - foreach($db_info->slave_db as &$slave) |
|
604 | + foreach ($db_info->slave_db as &$slave) |
|
605 | 605 | { |
606 | - if(substr($slave['db_table_prefix'], -1) != '_') |
|
606 | + if (substr($slave['db_table_prefix'], -1) != '_') |
|
607 | 607 | { |
608 | 608 | $slave['db_table_prefix'] .= '_'; |
609 | 609 | } |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | |
612 | 612 | $buff = array(); |
613 | 613 | $buff[] = '<?php if(!defined("__XE__")) exit();'; |
614 | - $buff[] = '$db_info = (object)' . var_export(get_object_vars($db_info), TRUE) . ';'; |
|
614 | + $buff[] = '$db_info = (object)'.var_export(get_object_vars($db_info), TRUE).';'; |
|
615 | 615 | |
616 | 616 | return implode(PHP_EOL, $buff); |
617 | 617 | } |
@@ -625,13 +625,13 @@ discard block |
||
625 | 625 | $db_tmp_config_file = $this->db_tmp_config_file; |
626 | 626 | |
627 | 627 | $db_info = Context::getDBInfo(); |
628 | - if(!$db_info) return; |
|
628 | + if (!$db_info) return; |
|
629 | 629 | |
630 | 630 | $buff = $this->_getDBConfigFileContents($db_info); |
631 | 631 | |
632 | 632 | FileHandler::writeFile($db_tmp_config_file, $buff); |
633 | 633 | |
634 | - if(@file_exists($db_tmp_config_file)) return true; |
|
634 | + if (@file_exists($db_tmp_config_file)) return true; |
|
635 | 635 | return false; |
636 | 636 | } |
637 | 637 | |
@@ -644,14 +644,14 @@ discard block |
||
644 | 644 | $etc_tmp_config_file = $this->etc_tmp_config_file; |
645 | 645 | |
646 | 646 | $buff = '<?php if(!defined("__XE__")) exit();'."\n"; |
647 | - foreach($config_info as $key => $val) |
|
647 | + foreach ($config_info as $key => $val) |
|
648 | 648 | { |
649 | - $buff .= sprintf("\$db_info->%s = '%s';\n", $key, str_replace("'","\\'",$val)); |
|
649 | + $buff .= sprintf("\$db_info->%s = '%s';\n", $key, str_replace("'", "\\'", $val)); |
|
650 | 650 | } |
651 | 651 | |
652 | 652 | FileHandler::writeFile($etc_tmp_config_file, $buff); |
653 | 653 | |
654 | - if(@file_exists($etc_tmp_config_file)) return true; |
|
654 | + if (@file_exists($etc_tmp_config_file)) return true; |
|
655 | 655 | return false; |
656 | 656 | } |
657 | 657 | |
@@ -666,13 +666,13 @@ discard block |
||
666 | 666 | //if(file_exists($config_file)) return; |
667 | 667 | |
668 | 668 | $db_info = Context::getDBInfo(); |
669 | - if(!$db_info) return; |
|
669 | + if (!$db_info) return; |
|
670 | 670 | |
671 | 671 | $buff = $this->_getDBConfigFileContents($db_info); |
672 | 672 | |
673 | 673 | FileHandler::writeFile($config_file, $buff); |
674 | 674 | |
675 | - if(@file_exists($config_file)) |
|
675 | + if (@file_exists($config_file)) |
|
676 | 676 | { |
677 | 677 | FileHandler::removeFile($this->db_tmp_config_file); |
678 | 678 | FileHandler::removeFile($this->etc_tmp_config_file); |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | function installByConfig($install_config_file) |
688 | 688 | { |
689 | 689 | include $install_config_file; |
690 | - if(!is_array($auto_config)) return false; |
|
690 | + if (!is_array($auto_config)) return false; |
|
691 | 691 | |
692 | 692 | $auto_config['module'] = 'install'; |
693 | 693 | $auto_config['act'] = 'procInstall'; |
@@ -695,22 +695,22 @@ discard block |
||
695 | 695 | $fstr = "<%s><![CDATA[%s]]></%s>\r\n"; |
696 | 696 | $fheader = "POST %s HTTP/1.1\r\nHost: %s\r\nContent-Type: application/xml\r\nContent-Length: %s\r\n\r\n%s\r\n"; |
697 | 697 | $body = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<methodCall>\r\n<params>\r\n"; |
698 | - foreach($auto_config as $k => $v) |
|
698 | + foreach ($auto_config as $k => $v) |
|
699 | 699 | { |
700 | - if(!in_array($k,array('host','port','path'))) $body .= sprintf($fstr,$k,$v,$k); |
|
700 | + if (!in_array($k, array('host', 'port', 'path'))) $body .= sprintf($fstr, $k, $v, $k); |
|
701 | 701 | } |
702 | 702 | $body .= "</params>\r\n</methodCall>"; |
703 | 703 | |
704 | - $header = sprintf($fheader,$auto_config['path'],$auto_config['host'],strlen($body),$body); |
|
704 | + $header = sprintf($fheader, $auto_config['path'], $auto_config['host'], strlen($body), $body); |
|
705 | 705 | $fp = @fsockopen($auto_config['host'], $auto_config['port'], $errno, $errstr, 5); |
706 | 706 | |
707 | - if($fp) |
|
707 | + if ($fp) |
|
708 | 708 | { |
709 | 709 | fputs($fp, $header); |
710 | - while(!feof($fp)) |
|
710 | + while (!feof($fp)) |
|
711 | 711 | { |
712 | 712 | $line = trim(fgets($fp, 4096)); |
713 | - if(strncmp('<error>', $line, 7) === 0) |
|
713 | + if (strncmp('<error>', $line, 7) === 0) |
|
714 | 714 | { |
715 | 715 | fclose($fp); |
716 | 716 | return false; |
@@ -101,11 +101,17 @@ discard block |
||
101 | 101 | // Check if available to connect to the DB |
102 | 102 | $oDB = &DB::getInstance(); |
103 | 103 | $output = $oDB->getError(); |
104 | - if(!$output->toBool()) return $output; |
|
105 | - if(!$oDB->isConnected()) return $oDB->getError(); |
|
104 | + if(!$output->toBool()) { |
|
105 | + return $output; |
|
106 | + } |
|
107 | + if(!$oDB->isConnected()) { |
|
108 | + return $oDB->getError(); |
|
109 | + } |
|
106 | 110 | |
107 | 111 | // Create a db temp config file |
108 | - if(!$this->makeDBConfigFile()) return new BaseObject(-1, 'msg_install_failed'); |
|
112 | + if(!$this->makeDBConfigFile()) { |
|
113 | + return new BaseObject(-1, 'msg_install_failed'); |
|
114 | + } |
|
109 | 115 | |
110 | 116 | if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
111 | 117 | { |
@@ -122,10 +128,14 @@ discard block |
||
122 | 128 | { |
123 | 129 | // Get variables |
124 | 130 | $config_info = Context::gets('use_rewrite','time_zone'); |
125 | - if($config_info->use_rewrite!='Y') $config_info->use_rewrite = 'N'; |
|
131 | + if($config_info->use_rewrite!='Y') { |
|
132 | + $config_info->use_rewrite = 'N'; |
|
133 | + } |
|
126 | 134 | |
127 | 135 | // Create a db temp config file |
128 | - if(!$this->makeEtcConfigFile($config_info)) return new BaseObject(-1, 'msg_install_failed'); |
|
136 | + if(!$this->makeEtcConfigFile($config_info)) { |
|
137 | + return new BaseObject(-1, 'msg_install_failed'); |
|
138 | + } |
|
129 | 139 | |
130 | 140 | if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
131 | 141 | { |
@@ -141,7 +151,9 @@ discard block |
||
141 | 151 | function procInstall() |
142 | 152 | { |
143 | 153 | // Check if it is already installed |
144 | - if(Context::isInstalled()) return new BaseObject(-1, 'msg_already_installed'); |
|
154 | + if(Context::isInstalled()) { |
|
155 | + return new BaseObject(-1, 'msg_already_installed'); |
|
156 | + } |
|
145 | 157 | |
146 | 158 | Context::loadLang('modules/member/lang'); |
147 | 159 | $oMemberModel = getModel('member'); |
@@ -167,8 +179,12 @@ discard block |
||
167 | 179 | // install by default XE UI |
168 | 180 | else |
169 | 181 | { |
170 | - if(FileHandler::exists($this->db_tmp_config_file)) include $this->db_tmp_config_file; |
|
171 | - if(FileHandler::exists($this->etc_tmp_config_file)) include $this->etc_tmp_config_file; |
|
182 | + if(FileHandler::exists($this->db_tmp_config_file)) { |
|
183 | + include $this->db_tmp_config_file; |
|
184 | + } |
|
185 | + if(FileHandler::exists($this->etc_tmp_config_file)) { |
|
186 | + include $this->etc_tmp_config_file; |
|
187 | + } |
|
172 | 188 | } |
173 | 189 | |
174 | 190 | // Set DB type and information |
@@ -176,7 +192,9 @@ discard block |
||
176 | 192 | // Create DB Instance |
177 | 193 | $oDB = &DB::getInstance(); |
178 | 194 | // Check if available to connect to the DB |
179 | - if(!$oDB->isConnected()) return $oDB->getError(); |
|
195 | + if(!$oDB->isConnected()) { |
|
196 | + return $oDB->getError(); |
|
197 | + } |
|
180 | 198 | |
181 | 199 | // Install all the modules |
182 | 200 | try { |
@@ -189,7 +207,9 @@ discard block |
||
189 | 207 | } |
190 | 208 | |
191 | 209 | // Create a config file |
192 | - if(!$this->makeConfigFile()) return new BaseObject(-1, 'msg_install_failed'); |
|
210 | + if(!$this->makeConfigFile()) { |
|
211 | + return new BaseObject(-1, 'msg_install_failed'); |
|
212 | + } |
|
193 | 213 | |
194 | 214 | // load script |
195 | 215 | $scripts = FileHandler::readDir(_XE_PATH_ . 'modules/install/script', '/(\.php)$/'); |
@@ -246,14 +266,17 @@ discard block |
||
246 | 266 | { |
247 | 267 | $https_port = (Context::get('https_port')) ? Context::get('https_port') : $_SERVER['SERVER_PORT']; |
248 | 268 | $https_port = (!$https_port != 443) ? $https_port : null; |
249 | - } |
|
250 | - else |
|
269 | + } else |
|
251 | 270 | { |
252 | 271 | $http_port = (Context::get('http_port')) ? Context::get('http_port') : $_SERVER['SERVER_PORT']; |
253 | 272 | $http_port = (!$http_port != 80) ? $http_port : null; |
254 | 273 | } |
255 | - if($http_port) $db_info->http_port = $http_port; |
|
256 | - if($https_port) $db_info->https_port = $https_port; |
|
274 | + if($http_port) { |
|
275 | + $db_info->http_port = $http_port; |
|
276 | + } |
|
277 | + if($https_port) { |
|
278 | + $db_info->https_port = $https_port; |
|
279 | + } |
|
257 | 280 | |
258 | 281 | return $db_info; |
259 | 282 | } |
@@ -263,12 +286,20 @@ discard block |
||
263 | 286 | */ |
264 | 287 | function procInstallFTP() |
265 | 288 | { |
266 | - if(Context::isInstalled()) return new BaseObject(-1, 'msg_already_installed'); |
|
289 | + if(Context::isInstalled()) { |
|
290 | + return new BaseObject(-1, 'msg_already_installed'); |
|
291 | + } |
|
267 | 292 | $ftp_info = Context::gets('ftp_host', 'ftp_user','ftp_password','ftp_port','ftp_root_path'); |
268 | 293 | $ftp_info->ftp_port = (int)$ftp_info->ftp_port; |
269 | - if(!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
270 | - if(!$ftp_info->ftp_host) $ftp_info->ftp_host = '127.0.0.1'; |
|
271 | - if(!$ftp_info->ftp_root_path) $ftp_info->ftp_root_path = '/'; |
|
294 | + if(!$ftp_info->ftp_port) { |
|
295 | + $ftp_info->ftp_port = 21; |
|
296 | + } |
|
297 | + if(!$ftp_info->ftp_host) { |
|
298 | + $ftp_info->ftp_host = '127.0.0.1'; |
|
299 | + } |
|
300 | + if(!$ftp_info->ftp_root_path) { |
|
301 | + $ftp_info->ftp_root_path = '/'; |
|
302 | + } |
|
272 | 303 | |
273 | 304 | $buff = array('<?php if(!defined("__XE__")) exit();'); |
274 | 305 | $buff[] = "\$ftp_info = new stdClass();"; |
@@ -280,11 +311,15 @@ discard block |
||
280 | 311 | // If safe_mode |
281 | 312 | if(ini_get('safe_mode')) |
282 | 313 | { |
283 | - if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new BaseObject(-1,'msg_safe_mode_ftp_needed'); |
|
314 | + if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) { |
|
315 | + return new BaseObject(-1,'msg_safe_mode_ftp_needed'); |
|
316 | + } |
|
284 | 317 | |
285 | 318 | require_once(_XE_PATH_.'libs/ftp.class.php'); |
286 | 319 | $oFtp = new ftp(); |
287 | - if(!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) return new BaseObject(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'host')); |
|
320 | + if(!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) { |
|
321 | + return new BaseObject(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'host')); |
|
322 | + } |
|
288 | 323 | |
289 | 324 | if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
290 | 325 | { |
@@ -326,10 +361,16 @@ discard block |
||
326 | 361 | { |
327 | 362 | $ftp_info = Context::gets('ftp_user','ftp_password','ftp_port','sftp'); |
328 | 363 | $ftp_info->ftp_port = (int)$ftp_info->ftp_port; |
329 | - if(!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
330 | - if(!$ftp_info->sftp) $ftp_info->sftp = 'N'; |
|
364 | + if(!$ftp_info->ftp_port) { |
|
365 | + $ftp_info->ftp_port = 21; |
|
366 | + } |
|
367 | + if(!$ftp_info->sftp) { |
|
368 | + $ftp_info->sftp = 'N'; |
|
369 | + } |
|
331 | 370 | |
332 | - if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new BaseObject(-1,'msg_safe_mode_ftp_needed'); |
|
371 | + if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) { |
|
372 | + return new BaseObject(-1,'msg_safe_mode_ftp_needed'); |
|
373 | + } |
|
333 | 374 | |
334 | 375 | if($ftp_info->sftp == 'Y') |
335 | 376 | { |
@@ -338,12 +379,13 @@ discard block |
||
338 | 379 | { |
339 | 380 | return new BaseObject(-1,'msg_ftp_invalid_auth_info'); |
340 | 381 | } |
341 | - } |
|
342 | - else |
|
382 | + } else |
|
343 | 383 | { |
344 | 384 | require_once(_XE_PATH_.'libs/ftp.class.php'); |
345 | 385 | $oFtp = new ftp(); |
346 | - if(!$oFtp->ftp_connect('127.0.0.1', $ftp_info->ftp_port)) return new BaseObject(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'localhost')); |
|
386 | + if(!$oFtp->ftp_connect('127.0.0.1', $ftp_info->ftp_port)) { |
|
387 | + return new BaseObject(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'localhost')); |
|
388 | + } |
|
347 | 389 | |
348 | 390 | if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
349 | 391 | { |
@@ -376,26 +418,47 @@ discard block |
||
376 | 418 | } |
377 | 419 | |
378 | 420 | // 1. Check permission |
379 | - if(is_writable('./')||is_writable('./files')) $checklist['permission'] = true; |
|
380 | - else $checklist['permission'] = false; |
|
421 | + if(is_writable('./')||is_writable('./files')) { |
|
422 | + $checklist['permission'] = true; |
|
423 | + } else { |
|
424 | + $checklist['permission'] = false; |
|
425 | + } |
|
381 | 426 | // 2. Check if xml_parser_create exists |
382 | - if(function_exists('xml_parser_create')) $checklist['xml'] = true; |
|
383 | - else $checklist['xml'] = false; |
|
427 | + if(function_exists('xml_parser_create')) { |
|
428 | + $checklist['xml'] = true; |
|
429 | + } else { |
|
430 | + $checklist['xml'] = false; |
|
431 | + } |
|
384 | 432 | // 3. Check if ini_get (session.auto_start) == 1 |
385 | - if(ini_get('session.auto_start')!=1) $checklist['session'] = true; |
|
386 | - else $checklist['session'] = false; |
|
433 | + if(ini_get('session.auto_start')!=1) { |
|
434 | + $checklist['session'] = true; |
|
435 | + } else { |
|
436 | + $checklist['session'] = false; |
|
437 | + } |
|
387 | 438 | // 4. Check if iconv exists |
388 | - if(function_exists('iconv')) $checklist['iconv'] = true; |
|
389 | - else $checklist['iconv'] = false; |
|
439 | + if(function_exists('iconv')) { |
|
440 | + $checklist['iconv'] = true; |
|
441 | + } else { |
|
442 | + $checklist['iconv'] = false; |
|
443 | + } |
|
390 | 444 | // 5. Check gd(imagecreatefromgif function) |
391 | - if(function_exists('imagecreatefromgif')) $checklist['gd'] = true; |
|
392 | - else $checklist['gd'] = false; |
|
445 | + if(function_exists('imagecreatefromgif')) { |
|
446 | + $checklist['gd'] = true; |
|
447 | + } else { |
|
448 | + $checklist['gd'] = false; |
|
449 | + } |
|
393 | 450 | // 6. Check DB |
394 | - if(DB::getEnableList()) $checklist['db'] = true; |
|
395 | - else $checklist['db'] = false; |
|
451 | + if(DB::getEnableList()) { |
|
452 | + $checklist['db'] = true; |
|
453 | + } else { |
|
454 | + $checklist['db'] = false; |
|
455 | + } |
|
396 | 456 | |
397 | - if(!$checklist['php_version'] || !$checklist['permission'] || !$checklist['xml'] || !$checklist['session'] || !$checklist['db']) $install_enable = false; |
|
398 | - else $install_enable = true; |
|
457 | + if(!$checklist['php_version'] || !$checklist['permission'] || !$checklist['xml'] || !$checklist['session'] || !$checklist['db']) { |
|
458 | + $install_enable = false; |
|
459 | + } else { |
|
460 | + $install_enable = true; |
|
461 | + } |
|
399 | 462 | |
400 | 463 | // Save the checked result to the Context |
401 | 464 | Context::set('checklist', $checklist); |
@@ -418,8 +481,7 @@ discard block |
||
418 | 481 | { |
419 | 482 | $currentTime = $_SERVER['REQUEST_TIME']; |
420 | 483 | FileHandler::writeFile($this->flagLicenseAgreement, $currentTime); |
421 | - } |
|
422 | - else |
|
484 | + } else |
|
423 | 485 | { |
424 | 486 | FileHandler::removeFile($this->flagLicenseAgreement); |
425 | 487 | return new BaseObject(-1, 'msg_must_accept_license_agreement'); |
@@ -514,13 +576,17 @@ discard block |
||
514 | 576 | $module = $tmp_arr[count($tmp_arr)-1]; |
515 | 577 | |
516 | 578 | $xml_info = $oModuleModel->getModuleInfoXml($module); |
517 | - if(!$xml_info) continue; |
|
579 | + if(!$xml_info) { |
|
580 | + continue; |
|
581 | + } |
|
518 | 582 | $modules[$xml_info->category][] = $module; |
519 | 583 | } |
520 | 584 | // Install "module" module in advance |
521 | 585 | $this->installModule('module','./modules/module'); |
522 | 586 | $oModule = getClass('module'); |
523 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
587 | + if($oModule->checkUpdate()) { |
|
588 | + $oModule->moduleUpdate(); |
|
589 | + } |
|
524 | 590 | // Determine the order of module installation depending on category |
525 | 591 | $install_step = array('system','content','member'); |
526 | 592 | // Install all the remaining modules |
@@ -530,13 +596,17 @@ discard block |
||
530 | 596 | { |
531 | 597 | foreach($modules[$category] as $module) |
532 | 598 | { |
533 | - if($module == 'module') continue; |
|
599 | + if($module == 'module') { |
|
600 | + continue; |
|
601 | + } |
|
534 | 602 | $this->installModule($module, sprintf('./modules/%s', $module)); |
535 | 603 | |
536 | 604 | $oModule = getClass($module); |
537 | 605 | if(is_object($oModule) && method_exists($oModule, 'checkUpdate')) |
538 | 606 | { |
539 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
607 | + if($oModule->checkUpdate()) { |
|
608 | + $oModule->moduleUpdate(); |
|
609 | + } |
|
540 | 610 | } |
541 | 611 | } |
542 | 612 | unset($modules[$category]); |
@@ -551,13 +621,17 @@ discard block |
||
551 | 621 | { |
552 | 622 | foreach($module_list as $module) |
553 | 623 | { |
554 | - if($module == 'module') continue; |
|
624 | + if($module == 'module') { |
|
625 | + continue; |
|
626 | + } |
|
555 | 627 | $this->installModule($module, sprintf('./modules/%s', $module)); |
556 | 628 | |
557 | 629 | $oModule = getClass($module); |
558 | 630 | if($oModule && method_exists($oModule, 'checkUpdate') && method_exists($oModule, 'moduleUpdate')) |
559 | 631 | { |
560 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
632 | + if($oModule->checkUpdate()) { |
|
633 | + $oModule->moduleUpdate(); |
|
634 | + } |
|
561 | 635 | } |
562 | 636 | } |
563 | 637 | } |
@@ -582,15 +656,20 @@ discard block |
||
582 | 656 | for($i=0;$i<$file_cnt;$i++) |
583 | 657 | { |
584 | 658 | $file = trim($schema_files[$i]); |
585 | - if(!$file || substr($file,-4)!='.xml') continue; |
|
659 | + if(!$file || substr($file,-4)!='.xml') { |
|
660 | + continue; |
|
661 | + } |
|
586 | 662 | $output = $oDB->createTableByXmlFile($file); |
587 | - if($output === false) |
|
588 | - throw new Exception('msg_create_table_failed'); |
|
663 | + if($output === false) { |
|
664 | + throw new Exception('msg_create_table_failed'); |
|
665 | + } |
|
589 | 666 | } |
590 | 667 | // Create a table and module instance and then execute install() method |
591 | 668 | unset($oModule); |
592 | 669 | $oModule = getClass($module); |
593 | - if(method_exists($oModule, 'moduleInstall')) $oModule->moduleInstall(); |
|
670 | + if(method_exists($oModule, 'moduleInstall')) { |
|
671 | + $oModule->moduleInstall(); |
|
672 | + } |
|
594 | 673 | return new BaseObject(); |
595 | 674 | } |
596 | 675 | |
@@ -625,13 +704,17 @@ discard block |
||
625 | 704 | $db_tmp_config_file = $this->db_tmp_config_file; |
626 | 705 | |
627 | 706 | $db_info = Context::getDBInfo(); |
628 | - if(!$db_info) return; |
|
707 | + if(!$db_info) { |
|
708 | + return; |
|
709 | + } |
|
629 | 710 | |
630 | 711 | $buff = $this->_getDBConfigFileContents($db_info); |
631 | 712 | |
632 | 713 | FileHandler::writeFile($db_tmp_config_file, $buff); |
633 | 714 | |
634 | - if(@file_exists($db_tmp_config_file)) return true; |
|
715 | + if(@file_exists($db_tmp_config_file)) { |
|
716 | + return true; |
|
717 | + } |
|
635 | 718 | return false; |
636 | 719 | } |
637 | 720 | |
@@ -651,7 +734,9 @@ discard block |
||
651 | 734 | |
652 | 735 | FileHandler::writeFile($etc_tmp_config_file, $buff); |
653 | 736 | |
654 | - if(@file_exists($etc_tmp_config_file)) return true; |
|
737 | + if(@file_exists($etc_tmp_config_file)) { |
|
738 | + return true; |
|
739 | + } |
|
655 | 740 | return false; |
656 | 741 | } |
657 | 742 | |
@@ -666,7 +751,9 @@ discard block |
||
666 | 751 | //if(file_exists($config_file)) return; |
667 | 752 | |
668 | 753 | $db_info = Context::getDBInfo(); |
669 | - if(!$db_info) return; |
|
754 | + if(!$db_info) { |
|
755 | + return; |
|
756 | + } |
|
670 | 757 | |
671 | 758 | $buff = $this->_getDBConfigFileContents($db_info); |
672 | 759 | |
@@ -687,7 +774,9 @@ discard block |
||
687 | 774 | function installByConfig($install_config_file) |
688 | 775 | { |
689 | 776 | include $install_config_file; |
690 | - if(!is_array($auto_config)) return false; |
|
777 | + if(!is_array($auto_config)) { |
|
778 | + return false; |
|
779 | + } |
|
691 | 780 | |
692 | 781 | $auto_config['module'] = 'install'; |
693 | 782 | $auto_config['act'] = 'procInstall'; |
@@ -697,7 +786,9 @@ discard block |
||
697 | 786 | $body = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<methodCall>\r\n<params>\r\n"; |
698 | 787 | foreach($auto_config as $k => $v) |
699 | 788 | { |
700 | - if(!in_array($k,array('host','port','path'))) $body .= sprintf($fstr,$k,$v,$k); |
|
789 | + if(!in_array($k,array('host','port','path'))) { |
|
790 | + $body .= sprintf($fstr,$k,$v,$k); |
|
791 | + } |
|
701 | 792 | } |
702 | 793 | $body .= "</params>\r\n</methodCall>"; |
703 | 794 |