@@ -30,7 +30,7 @@ |
||
30 | 30 | |
31 | 31 | // Get configurations (using module model object) |
32 | 32 | $config = $oModuleModel->getModuleConfig('message'); |
33 | - Context::set('config',$config); |
|
33 | + Context::set('config', $config); |
|
34 | 34 | |
35 | 35 | // Set a template file |
36 | 36 | $this->setTemplatePath($this->module_path.'tpl'); |
@@ -333,8 +333,7 @@ discard block |
||
333 | 333 | '<!--BeforeComment(%d,%d)--><div class="comment_%d_%d xe_content">%s</div><!--AfterComment(%d,%d)-->', $this->comment_srl, $memberSrl, $this->comment_srl, $memberSrl, $content, $this->comment_srl, $memberSrl |
334 | 334 | ); |
335 | 335 | // xe_content class name should be specified although content access is not necessary. |
336 | - } |
|
337 | - else |
|
336 | + } else |
|
338 | 337 | { |
339 | 338 | if($add_xe_content_class) |
340 | 339 | { |
@@ -569,7 +568,9 @@ discard block |
||
569 | 568 | } |
570 | 569 | } |
571 | 570 | |
572 | - if(!preg_match("!<img!is", $content)) return; |
|
571 | + if(!preg_match("!<img!is", $content)) { |
|
572 | + return; |
|
573 | + } |
|
573 | 574 | } |
574 | 575 | |
575 | 576 | // get thumbail generation info on the doc module configuration. |
@@ -589,8 +590,7 @@ discard block |
||
589 | 590 | if(filesize($thumbnail_file) < 1) |
590 | 591 | { |
591 | 592 | return FALSE; |
592 | - } |
|
593 | - else |
|
593 | + } else |
|
594 | 594 | { |
595 | 595 | return $thumbnail_url; |
596 | 596 | } |
@@ -608,7 +608,9 @@ discard block |
||
608 | 608 | $first_image = null; |
609 | 609 | foreach($file_list as $file) |
610 | 610 | { |
611 | - if($file->direct_download !== 'Y') continue; |
|
611 | + if($file->direct_download !== 'Y') { |
|
612 | + continue; |
|
613 | + } |
|
612 | 614 | |
613 | 615 | if($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
614 | 616 | { |
@@ -616,7 +618,9 @@ discard block |
||
616 | 618 | break; |
617 | 619 | } |
618 | 620 | |
619 | - if($first_image) continue; |
|
621 | + if($first_image) { |
|
622 | + continue; |
|
623 | + } |
|
620 | 624 | |
621 | 625 | if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
622 | 626 | { |
@@ -644,7 +648,9 @@ discard block |
||
644 | 648 | foreach($matches as $target_image) |
645 | 649 | { |
646 | 650 | $target_src = trim($target_image[1]); |
647 | - if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
651 | + if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) { |
|
652 | + continue; |
|
653 | + } |
|
648 | 654 | |
649 | 655 | if(!preg_match('/^(http|https):\/\//i',$target_src)) |
650 | 656 | { |
@@ -655,7 +661,9 @@ discard block |
||
655 | 661 | |
656 | 662 | $tmp_file = _XE_PATH_ . 'files/cache/tmp/' . $random->createSecureSalt(32, 'hex'); |
657 | 663 | FileHandler::getRemoteFile($target_src, $tmp_file); |
658 | - if(!file_exists($tmp_file)) continue; |
|
664 | + if(!file_exists($tmp_file)) { |
|
665 | + continue; |
|
666 | + } |
|
659 | 667 | |
660 | 668 | $imageinfo = getimagesize($tmp_file); |
661 | 669 | list($_w, $_h) = $imageinfo; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | function _loadFromDB() |
51 | 51 | { |
52 | - if(!$this->comment_srl) |
|
52 | + if (!$this->comment_srl) |
|
53 | 53 | { |
54 | 54 | return; |
55 | 55 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | function setAttribute($attribute) |
69 | 69 | { |
70 | - if(!$attribute->comment_srl) |
|
70 | + if (!$attribute->comment_srl) |
|
71 | 71 | { |
72 | 72 | $this->comment_srl = NULL; |
73 | 73 | return; |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | $this->adds($attribute); |
78 | 78 | |
79 | 79 | // define vars on the object for backward compatibility of skins |
80 | - if(count($attribute)) |
|
80 | + if (count($attribute)) |
|
81 | 81 | { |
82 | - foreach($attribute as $key => $val) |
|
82 | + foreach ($attribute as $key => $val) |
|
83 | 83 | { |
84 | 84 | $this->{$key} = $val; |
85 | 85 | } |
@@ -93,29 +93,29 @@ discard block |
||
93 | 93 | |
94 | 94 | function isGranted() |
95 | 95 | { |
96 | - if($_SESSION['own_comment'][$this->comment_srl]) |
|
96 | + if ($_SESSION['own_comment'][$this->comment_srl]) |
|
97 | 97 | { |
98 | 98 | return TRUE; |
99 | 99 | } |
100 | 100 | |
101 | - if(!Context::get('is_logged')) |
|
101 | + if (!Context::get('is_logged')) |
|
102 | 102 | { |
103 | 103 | return FALSE; |
104 | 104 | } |
105 | 105 | |
106 | 106 | $logged_info = Context::get('logged_info'); |
107 | - if($logged_info->is_admin == 'Y') |
|
107 | + if ($logged_info->is_admin == 'Y') |
|
108 | 108 | { |
109 | 109 | return TRUE; |
110 | 110 | } |
111 | 111 | |
112 | 112 | $grant = Context::get('grant'); |
113 | - if($grant->manager) |
|
113 | + if ($grant->manager) |
|
114 | 114 | { |
115 | 115 | return TRUE; |
116 | 116 | } |
117 | 117 | |
118 | - if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl') * -1 == $logged_info->member_srl)) |
|
118 | + if ($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl') * -1 == $logged_info->member_srl)) |
|
119 | 119 | { |
120 | 120 | return TRUE; |
121 | 121 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | function isEditable() |
138 | 138 | { |
139 | - if($this->isGranted() || !$this->get('member_srl')) |
|
139 | + if ($this->isGranted() || !$this->get('member_srl')) |
|
140 | 140 | { |
141 | 141 | return TRUE; |
142 | 142 | } |
@@ -150,12 +150,12 @@ discard block |
||
150 | 150 | |
151 | 151 | function isAccessible() |
152 | 152 | { |
153 | - if($_SESSION['accessibled_comment'][$this->comment_srl]) |
|
153 | + if ($_SESSION['accessibled_comment'][$this->comment_srl]) |
|
154 | 154 | { |
155 | 155 | return TRUE; |
156 | 156 | } |
157 | 157 | |
158 | - if($this->isGranted() || !$this->isSecret()) |
|
158 | + if ($this->isGranted() || !$this->isSecret()) |
|
159 | 159 | { |
160 | 160 | $this->setAccessible(); |
161 | 161 | return TRUE; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | |
164 | 164 | $oDocumentModel = getModel('document'); |
165 | 165 | $oDocument = $oDocumentModel->getDocument($this->get('document_srl')); |
166 | - if($oDocument->isGranted()) |
|
166 | + if ($oDocument->isGranted()) |
|
167 | 167 | { |
168 | 168 | $this->setAccessible(); |
169 | 169 | return TRUE; |
@@ -184,20 +184,20 @@ discard block |
||
184 | 184 | function notify($type, $content) |
185 | 185 | { |
186 | 186 | // return if not useNotify |
187 | - if(!$this->useNotify()) |
|
187 | + if (!$this->useNotify()) |
|
188 | 188 | { |
189 | 189 | return; |
190 | 190 | } |
191 | 191 | |
192 | 192 | // pass if the author is not logged-in user |
193 | - if(!$this->get('member_srl')) |
|
193 | + if (!$this->get('member_srl')) |
|
194 | 194 | { |
195 | 195 | return; |
196 | 196 | } |
197 | 197 | |
198 | 198 | // return if the currently logged-in user is an author of the comment. |
199 | 199 | $logged_info = Context::get('logged_info'); |
200 | - if($logged_info->member_srl == $this->get('member_srl')) |
|
200 | + if ($logged_info->member_srl == $this->get('member_srl')) |
|
201 | 201 | { |
202 | 202 | return; |
203 | 203 | } |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | $oDocument = $oDocumentModel->getDocument($this->get('document_srl')); |
208 | 208 | |
209 | 209 | // Variables |
210 | - if($type) |
|
210 | + if ($type) |
|
211 | 211 | { |
212 | - $title = "[" . $type . "] "; |
|
212 | + $title = "[".$type."] "; |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | $title .= cut_str(strip_tags($content), 30, '...'); |
@@ -224,17 +224,17 @@ discard block |
||
224 | 224 | |
225 | 225 | function getIpAddress() |
226 | 226 | { |
227 | - if($this->isGranted()) |
|
227 | + if ($this->isGranted()) |
|
228 | 228 | { |
229 | 229 | return $this->get('ipaddress'); |
230 | 230 | } |
231 | 231 | |
232 | - return '*' . strstr($this->get('ipaddress'), '.'); |
|
232 | + return '*'.strstr($this->get('ipaddress'), '.'); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | function isExistsHomepage() |
236 | 236 | { |
237 | - if(trim($this->get('homepage'))) |
|
237 | + if (trim($this->get('homepage'))) |
|
238 | 238 | { |
239 | 239 | return TRUE; |
240 | 240 | } |
@@ -245,14 +245,14 @@ discard block |
||
245 | 245 | function getHomepageUrl() |
246 | 246 | { |
247 | 247 | $url = trim($this->get('homepage')); |
248 | - if(!$url) |
|
248 | + if (!$url) |
|
249 | 249 | { |
250 | 250 | return; |
251 | 251 | } |
252 | 252 | |
253 | - if(strncasecmp('http://', $url, 7) !== 0) |
|
253 | + if (strncasecmp('http://', $url, 7) !== 0) |
|
254 | 254 | { |
255 | - $url = "http://" . $url; |
|
255 | + $url = "http://".$url; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | return htmlspecialchars($url, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
@@ -284,14 +284,14 @@ discard block |
||
284 | 284 | */ |
285 | 285 | function getContentText($strlen = 0) |
286 | 286 | { |
287 | - if($this->isSecret() && !$this->isAccessible()) |
|
287 | + if ($this->isSecret() && !$this->isAccessible()) |
|
288 | 288 | { |
289 | 289 | return Context::getLang('msg_is_secret'); |
290 | 290 | } |
291 | 291 | |
292 | 292 | $content = $this->get('content'); |
293 | 293 | |
294 | - if($strlen) |
|
294 | + if ($strlen) |
|
295 | 295 | { |
296 | 296 | return cut_str(strip_tags($content), $strlen, '...'); |
297 | 297 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | */ |
306 | 306 | function getContent($add_popup_menu = TRUE, $add_content_info = TRUE, $add_xe_content_class = TRUE) |
307 | 307 | { |
308 | - if($this->isSecret() && !$this->isAccessible()) |
|
308 | + if ($this->isSecret() && !$this->isAccessible()) |
|
309 | 309 | { |
310 | 310 | return Context::getLang('msg_is_secret'); |
311 | 311 | } |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | stripEmbedTagForAdmin($content, $this->get('member_srl')); |
315 | 315 | |
316 | 316 | // when displaying the comment on the pop-up menu |
317 | - if($add_popup_menu && Context::get('is_logged')) |
|
317 | + if ($add_popup_menu && Context::get('is_logged')) |
|
318 | 318 | { |
319 | 319 | $content = sprintf( |
320 | 320 | '%s<div class="comment_popup_menu"><a href="#popup_menu_area" class="comment_%d" onclick="return false">%s</a></div>', $content, $this->comment_srl, Context::getLang('cmd_comment_do') |
@@ -322,10 +322,10 @@ discard block |
||
322 | 322 | } |
323 | 323 | |
324 | 324 | // if additional information which can access contents is set |
325 | - if($add_content_info) |
|
325 | + if ($add_content_info) |
|
326 | 326 | { |
327 | 327 | $memberSrl = $this->get('member_srl'); |
328 | - if($memberSrl < 0) |
|
328 | + if ($memberSrl < 0) |
|
329 | 329 | { |
330 | 330 | $memberSrl = 0; |
331 | 331 | } |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | } |
337 | 337 | else |
338 | 338 | { |
339 | - if($add_xe_content_class) |
|
339 | + if ($add_xe_content_class) |
|
340 | 340 | { |
341 | 341 | $content = sprintf('<div class="xe_content">%s</div>', $content); |
342 | 342 | } |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | |
397 | 397 | function getRegdateGM() |
398 | 398 | { |
399 | - return $this->getRegdate('D, d M Y H:i:s') . ' ' . $GLOBALS['_time_zone']; |
|
399 | + return $this->getRegdate('D, d M Y H:i:s').' '.$GLOBALS['_time_zone']; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | function getUpdate($format = 'Y.m.d H:i:s') |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | |
407 | 407 | function getPermanentUrl() |
408 | 408 | { |
409 | - return getFullUrl('', 'document_srl', $this->get('document_srl')) . '#comment_' . $this->get('comment_srl'); |
|
409 | + return getFullUrl('', 'document_srl', $this->get('document_srl')).'#comment_'.$this->get('comment_srl'); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | function getUpdateTime() |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | |
428 | 428 | function hasUploadedFiles() |
429 | 429 | { |
430 | - if(($this->isSecret() && !$this->isAccessible()) && !$this->isGranted()) |
|
430 | + if (($this->isSecret() && !$this->isAccessible()) && !$this->isGranted()) |
|
431 | 431 | { |
432 | 432 | return FALSE; |
433 | 433 | } |
@@ -436,12 +436,12 @@ discard block |
||
436 | 436 | |
437 | 437 | function getUploadedFiles() |
438 | 438 | { |
439 | - if(($this->isSecret() && !$this->isAccessible()) && !$this->isGranted()) |
|
439 | + if (($this->isSecret() && !$this->isAccessible()) && !$this->isGranted()) |
|
440 | 440 | { |
441 | 441 | return; |
442 | 442 | } |
443 | 443 | |
444 | - if(!$this->get('uploaded_count')) |
|
444 | + if (!$this->get('uploaded_count')) |
|
445 | 445 | { |
446 | 446 | return; |
447 | 447 | } |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | function getEditor() |
459 | 459 | { |
460 | 460 | $module_srl = $this->get('module_srl'); |
461 | - if(!$module_srl) |
|
461 | + if (!$module_srl) |
|
462 | 462 | { |
463 | 463 | $module_srl = Context::get('module_srl'); |
464 | 464 | } |
@@ -472,13 +472,13 @@ discard block |
||
472 | 472 | */ |
473 | 473 | function getProfileImage() |
474 | 474 | { |
475 | - if(!$this->isExists() || !$this->get('member_srl')) |
|
475 | + if (!$this->isExists() || !$this->get('member_srl')) |
|
476 | 476 | { |
477 | 477 | return; |
478 | 478 | } |
479 | 479 | $oMemberModel = getModel('member'); |
480 | 480 | $profile_info = $oMemberModel->getProfileImage($this->get('member_srl')); |
481 | - if(!$profile_info) |
|
481 | + if (!$profile_info) |
|
482 | 482 | { |
483 | 483 | return; |
484 | 484 | } |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | function getSignature() |
494 | 494 | { |
495 | 495 | // pass if the posting not exists. |
496 | - if(!$this->isExists() || !$this->get('member_srl')) |
|
496 | + if (!$this->isExists() || !$this->get('member_srl')) |
|
497 | 497 | { |
498 | 498 | return; |
499 | 499 | } |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | $signature = $oMemberModel->getSignature($this->get('member_srl')); |
504 | 504 | |
505 | 505 | // check if max height of the signiture is specified on the member module |
506 | - if(!isset($GLOBALS['__member_signature_max_height'])) |
|
506 | + if (!isset($GLOBALS['__member_signature_max_height'])) |
|
507 | 507 | { |
508 | 508 | $oModuleModel = getModel('module'); |
509 | 509 | $member_config = $oModuleModel->getModuleConfig('member'); |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | |
513 | 513 | $max_signature_height = $GLOBALS['__member_signature_max_height']; |
514 | 514 | |
515 | - if($max_signature_height) |
|
515 | + if ($max_signature_height) |
|
516 | 516 | { |
517 | 517 | $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); |
518 | 518 | } |
@@ -522,12 +522,12 @@ discard block |
||
522 | 522 | |
523 | 523 | function thumbnailExists($width = 80, $height = 0, $type = '') |
524 | 524 | { |
525 | - if(!$this->comment_srl) |
|
525 | + if (!$this->comment_srl) |
|
526 | 526 | { |
527 | 527 | return FALSE; |
528 | 528 | } |
529 | 529 | |
530 | - if(!$this->getThumbnail($width, $height, $type)) |
|
530 | + if (!$this->getThumbnail($width, $height, $type)) |
|
531 | 531 | { |
532 | 532 | return FALSE; |
533 | 533 | } |
@@ -538,42 +538,42 @@ discard block |
||
538 | 538 | function getThumbnail($width = 80, $height = 0, $thumbnail_type = '') |
539 | 539 | { |
540 | 540 | // return false if no doc exists |
541 | - if(!$this->comment_srl) |
|
541 | + if (!$this->comment_srl) |
|
542 | 542 | { |
543 | 543 | return; |
544 | 544 | } |
545 | 545 | |
546 | - if($this->isSecret() && !$this->isGranted()) |
|
546 | + if ($this->isSecret() && !$this->isGranted()) |
|
547 | 547 | { |
548 | 548 | return; |
549 | 549 | } |
550 | 550 | |
551 | 551 | // If signiture height setting is omitted, create a square |
552 | - if(!$height) |
|
552 | + if (!$height) |
|
553 | 553 | { |
554 | 554 | $height = $width; |
555 | 555 | } |
556 | 556 | |
557 | 557 | $content = $this->get('content'); |
558 | - if(!$this->hasUploadedFiles()) |
|
558 | + if (!$this->hasUploadedFiles()) |
|
559 | 559 | { |
560 | - if(!$content) |
|
560 | + if (!$content) |
|
561 | 561 | { |
562 | 562 | $args = new stdClass(); |
563 | 563 | $args->comment_srl = $this->comment_srl; |
564 | 564 | $output = executeQuery('document.getComment', $args, array('content')); |
565 | - if($output->toBool() && $output->data) |
|
565 | + if ($output->toBool() && $output->data) |
|
566 | 566 | { |
567 | 567 | $content = $output->data->content; |
568 | 568 | $this->add('content', $content); |
569 | 569 | } |
570 | 570 | } |
571 | 571 | |
572 | - if(!preg_match("!<img!is", $content)) return; |
|
572 | + if (!preg_match("!<img!is", $content)) return; |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | // get thumbail generation info on the doc module configuration. |
576 | - if(!in_array($thumbnail_type, array('crop', 'ratio'))) |
|
576 | + if (!in_array($thumbnail_type, array('crop', 'ratio'))) |
|
577 | 577 | { |
578 | 578 | $thumbnail_type = 'crop'; |
579 | 579 | } |
@@ -582,12 +582,12 @@ discard block |
||
582 | 582 | $thumbnail_path = sprintf('files/thumbnails/%s', getNumberingPath($this->comment_srl, 3)); |
583 | 583 | $thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type); |
584 | 584 | $thumbnail_lockfile = sprintf('%s%dx%d.%s.lock', $thumbnail_path, $width, $height, $thumbnail_type); |
585 | - $thumbnail_url = Context::getRequestUri() . $thumbnail_file; |
|
585 | + $thumbnail_url = Context::getRequestUri().$thumbnail_file; |
|
586 | 586 | |
587 | 587 | // return false if a size of existing thumbnail file is 0. otherwise return the file path |
588 | - if(file_exists($thumbnail_file) || file_exists($thumbnail_lockfile)) |
|
588 | + if (file_exists($thumbnail_file) || file_exists($thumbnail_lockfile)) |
|
589 | 589 | { |
590 | - if(filesize($thumbnail_file) < 1) |
|
590 | + if (filesize($thumbnail_file) < 1) |
|
591 | 591 | { |
592 | 592 | return FALSE; |
593 | 593 | } |
@@ -605,33 +605,33 @@ discard block |
||
605 | 605 | $is_tmp_file = FALSE; |
606 | 606 | |
607 | 607 | // find an image file among attached files |
608 | - if($this->hasUploadedFiles()) |
|
608 | + if ($this->hasUploadedFiles()) |
|
609 | 609 | { |
610 | 610 | $file_list = $this->getUploadedFiles(); |
611 | 611 | |
612 | 612 | $first_image = null; |
613 | - foreach($file_list as $file) |
|
613 | + foreach ($file_list as $file) |
|
614 | 614 | { |
615 | - if($file->direct_download !== 'Y') continue; |
|
615 | + if ($file->direct_download !== 'Y') continue; |
|
616 | 616 | |
617 | - if($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
|
617 | + if ($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
|
618 | 618 | { |
619 | 619 | $source_file = $file->uploaded_filename; |
620 | 620 | break; |
621 | 621 | } |
622 | 622 | |
623 | - if($first_image) continue; |
|
623 | + if ($first_image) continue; |
|
624 | 624 | |
625 | - if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
|
625 | + if (preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
|
626 | 626 | { |
627 | - if(file_exists($file->uploaded_filename)) |
|
627 | + if (file_exists($file->uploaded_filename)) |
|
628 | 628 | { |
629 | 629 | $first_image = $file->uploaded_filename; |
630 | 630 | } |
631 | 631 | } |
632 | 632 | } |
633 | 633 | |
634 | - if(!$source_file && $first_image) |
|
634 | + if (!$source_file && $first_image) |
|
635 | 635 | { |
636 | 636 | $source_file = $first_image; |
637 | 637 | } |
@@ -639,31 +639,31 @@ discard block |
||
639 | 639 | |
640 | 640 | // get an image file from the doc content if no file attached. |
641 | 641 | $is_tmp_file = false; |
642 | - if(!$source_file) |
|
642 | + if (!$source_file) |
|
643 | 643 | { |
644 | 644 | $random = new Password(); |
645 | 645 | |
646 | 646 | preg_match_all("!<img[^>]*src=(?:\"|\')([^\"\']*?)(?:\"|\')!is", $content, $matches, PREG_SET_ORDER); |
647 | 647 | |
648 | - foreach($matches as $target_image) |
|
648 | + foreach ($matches as $target_image) |
|
649 | 649 | { |
650 | 650 | $target_src = trim($target_image[1]); |
651 | - if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
651 | + if (preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
652 | 652 | |
653 | - if(!preg_match('/^(http|https):\/\//i',$target_src)) |
|
653 | + if (!preg_match('/^(http|https):\/\//i', $target_src)) |
|
654 | 654 | { |
655 | 655 | $target_src = Context::getRequestUri().$target_src; |
656 | 656 | } |
657 | 657 | |
658 | 658 | $target_src = htmlspecialchars_decode($target_src); |
659 | 659 | |
660 | - $tmp_file = _XE_PATH_ . 'files/cache/tmp/' . $random->createSecureSalt(32, 'hex'); |
|
660 | + $tmp_file = _XE_PATH_.'files/cache/tmp/'.$random->createSecureSalt(32, 'hex'); |
|
661 | 661 | FileHandler::getRemoteFile($target_src, $tmp_file); |
662 | - if(!file_exists($tmp_file)) continue; |
|
662 | + if (!file_exists($tmp_file)) continue; |
|
663 | 663 | |
664 | 664 | $imageinfo = getimagesize($tmp_file); |
665 | 665 | list($_w, $_h) = $imageinfo; |
666 | - if($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) { |
|
666 | + if ($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) { |
|
667 | 667 | FileHandler::removeFile($tmp_file); |
668 | 668 | continue; |
669 | 669 | } |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | $output = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, 'jpg', $thumbnail_type); |
678 | 678 | |
679 | 679 | // Remove source file if it was temporary |
680 | - if($is_tmp_file) |
|
680 | + if ($is_tmp_file) |
|
681 | 681 | { |
682 | 682 | FileHandler::removeFile($source_file); |
683 | 683 | } |
@@ -686,14 +686,14 @@ discard block |
||
686 | 686 | FileHandler::removeFile($thumbnail_lockfile); |
687 | 687 | |
688 | 688 | // Return the thumbnail path if it was successfully generated |
689 | - if($output) |
|
689 | + if ($output) |
|
690 | 690 | { |
691 | 691 | return $thumbnail_url; |
692 | 692 | } |
693 | 693 | // Create an empty file if thumbnail generation failed |
694 | 694 | else |
695 | 695 | { |
696 | - FileHandler::writeFile($thumbnail_file, '','w'); |
|
696 | + FileHandler::writeFile($thumbnail_file, '', 'w'); |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | return; |
@@ -19,11 +19,11 @@ |
||
19 | 19 | { |
20 | 20 | $event = $subject->getLastEvent(); |
21 | 21 | |
22 | - switch($event['name']) |
|
22 | + switch ($event['name']) |
|
23 | 23 | { |
24 | 24 | case 'receivedHeaders': |
25 | 25 | $this->fp = @fopen($this->filename, 'wb'); |
26 | - if(!$this->fp) |
|
26 | + if (!$this->fp) |
|
27 | 27 | { |
28 | 28 | throw new Exception("Cannot open target file '{$filename}'"); |
29 | 29 | } |
@@ -39,7 +39,9 @@ discard block |
||
39 | 39 | |
40 | 40 | // Check the point name |
41 | 41 | $config->point_name = $args->point_name; |
42 | - if(!$config->point_name) $config->point_name = 'point'; |
|
42 | + if(!$config->point_name) { |
|
43 | + $config->point_name = 'point'; |
|
44 | + } |
|
43 | 45 | // Specify the default points |
44 | 46 | $config->signup_point = (int)$args->signup_point; |
45 | 47 | $config->login_point = (int)$args->login_point; |
@@ -52,16 +54,26 @@ discard block |
||
52 | 54 | $config->blamed = (int)$args->blamed; |
53 | 55 | // The highest level |
54 | 56 | $config->max_level = $args->max_level; |
55 | - if($config->max_level>1000) $config->max_level = 1000; |
|
56 | - if($config->max_level<1) $config->max_level = 1; |
|
57 | + if($config->max_level>1000) { |
|
58 | + $config->max_level = 1000; |
|
59 | + } |
|
60 | + if($config->max_level<1) { |
|
61 | + $config->max_level = 1; |
|
62 | + } |
|
57 | 63 | // Set the level icon |
58 | 64 | $config->level_icon = $args->level_icon; |
59 | 65 | // Check if downloads are not allowed |
60 | - if($args->disable_download == 'Y') $config->disable_download = 'Y'; |
|
61 | - else $config->disable_download = 'N'; |
|
66 | + if($args->disable_download == 'Y') { |
|
67 | + $config->disable_download = 'Y'; |
|
68 | + } else { |
|
69 | + $config->disable_download = 'N'; |
|
70 | + } |
|
62 | 71 | // Check if reading a document is not allowed |
63 | - if($args->disable_read_document == 'Y') $config->disable_read_document = 'Y'; |
|
64 | - else $config->disable_read_document = 'N'; |
|
72 | + if($args->disable_read_document == 'Y') { |
|
73 | + $config->disable_read_document = 'Y'; |
|
74 | + } else { |
|
75 | + $config->disable_read_document = 'N'; |
|
76 | + } |
|
65 | 77 | |
66 | 78 | $oMemberModel = getModel('member'); |
67 | 79 | $group_list = $oMemberModel->getGroups(); |
@@ -71,7 +83,9 @@ discard block |
||
71 | 83 | foreach($group_list as $group) |
72 | 84 | { |
73 | 85 | // Admin group should not be connected to point. |
74 | - if($group->is_admin == 'Y' || $group->is_default == 'Y') continue; |
|
86 | + if($group->is_admin == 'Y' || $group->is_default == 'Y') { |
|
87 | + continue; |
|
88 | + } |
|
75 | 89 | |
76 | 90 | $group_srl = $group->group_srl; |
77 | 91 | |
@@ -102,8 +116,7 @@ discard block |
||
102 | 116 | } |
103 | 117 | // A function to calculate per-level points |
104 | 118 | $config->expression = $args->expression; |
105 | - } |
|
106 | - else |
|
119 | + } else |
|
107 | 120 | { |
108 | 121 | //module IO config is OFF, Other settings will not be modified. |
109 | 122 | $config->able_module = 'N'; |
@@ -165,16 +178,23 @@ discard block |
||
165 | 178 | function procPointAdminInsertPointModuleConfig() |
166 | 179 | { |
167 | 180 | $module_srl = Context::get('target_module_srl'); |
168 | - if(!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
181 | + if(!$module_srl) { |
|
182 | + return new Object(-1, 'msg_invalid_request'); |
|
183 | + } |
|
169 | 184 | // In case of batch configuration of several modules |
170 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
171 | - else $module_srl = array($module_srl); |
|
185 | + if(preg_match('/^([0-9,]+)$/',$module_srl)) { |
|
186 | + $module_srl = explode(',',$module_srl); |
|
187 | + } else { |
|
188 | + $module_srl = array($module_srl); |
|
189 | + } |
|
172 | 190 | // Save configurations |
173 | 191 | $oModuleController = getController('module'); |
174 | 192 | for($i=0;$i<count($module_srl);$i++) |
175 | 193 | { |
176 | 194 | $srl = trim($module_srl[$i]); |
177 | - if(!$srl) continue; |
|
195 | + if(!$srl) { |
|
196 | + continue; |
|
197 | + } |
|
178 | 198 | unset($config); |
179 | 199 | $config['insert_document'] = (int)Context::get('insert_document'); |
180 | 200 | $config['insert_comment'] = (int)Context::get('insert_comment'); |
@@ -244,29 +264,40 @@ discard block |
||
244 | 264 | |
245 | 265 | // Get member infomation |
246 | 266 | $output = executeQueryArray('point.getMemberCount'); |
247 | - if(!$output->toBool()) return $output; |
|
267 | + if(!$output->toBool()) { |
|
268 | + return $output; |
|
269 | + } |
|
248 | 270 | |
249 | 271 | if($output->data) |
250 | 272 | { |
251 | 273 | foreach($output->data as $key => $val) |
252 | 274 | { |
253 | - if(!$val->member_srl) continue; |
|
275 | + if(!$val->member_srl) { |
|
276 | + continue; |
|
277 | + } |
|
254 | 278 | $member[$val->member_srl] = 0; |
255 | 279 | } |
256 | 280 | } |
257 | 281 | |
258 | 282 | // Get post information |
259 | 283 | $output = executeQueryArray('point.getDocumentPoint'); |
260 | - if(!$output->toBool()) return $output; |
|
284 | + if(!$output->toBool()) { |
|
285 | + return $output; |
|
286 | + } |
|
261 | 287 | |
262 | 288 | if($output->data) |
263 | 289 | { |
264 | 290 | foreach($output->data as $key => $val) |
265 | 291 | { |
266 | - if($module_config[$val->module_srl]['insert_document']) $insert_point = $module_config[$val->module_srl]['insert_document']; |
|
267 | - else $insert_point = $config->insert_document; |
|
292 | + if($module_config[$val->module_srl]['insert_document']) { |
|
293 | + $insert_point = $module_config[$val->module_srl]['insert_document']; |
|
294 | + } else { |
|
295 | + $insert_point = $config->insert_document; |
|
296 | + } |
|
268 | 297 | |
269 | - if(!$val->member_srl) continue; |
|
298 | + if(!$val->member_srl) { |
|
299 | + continue; |
|
300 | + } |
|
270 | 301 | $point = $insert_point * $val->count; |
271 | 302 | $member[$val->member_srl] += $point; |
272 | 303 | } |
@@ -275,16 +306,23 @@ discard block |
||
275 | 306 | $output = null; |
276 | 307 | // Get comments information |
277 | 308 | $output = executeQueryArray('point.getCommentPoint'); |
278 | - if(!$output->toBool()) return $output; |
|
309 | + if(!$output->toBool()) { |
|
310 | + return $output; |
|
311 | + } |
|
279 | 312 | |
280 | 313 | if($output->data) |
281 | 314 | { |
282 | 315 | foreach($output->data as $key => $val) |
283 | 316 | { |
284 | - if($module_config[$val->module_srl]['insert_comment']) $insert_point = $module_config[$val->module_srl]['insert_comment']; |
|
285 | - else $insert_point = $config->insert_comment; |
|
317 | + if($module_config[$val->module_srl]['insert_comment']) { |
|
318 | + $insert_point = $module_config[$val->module_srl]['insert_comment']; |
|
319 | + } else { |
|
320 | + $insert_point = $config->insert_comment; |
|
321 | + } |
|
286 | 322 | |
287 | - if(!$val->member_srl) continue; |
|
323 | + if(!$val->member_srl) { |
|
324 | + continue; |
|
325 | + } |
|
288 | 326 | $point = $insert_point * $val->count; |
289 | 327 | $member[$val->member_srl] += $point; |
290 | 328 | } |
@@ -292,16 +330,23 @@ discard block |
||
292 | 330 | $output = null; |
293 | 331 | // Get the attached files' information |
294 | 332 | $output = executeQueryArray('point.getFilePoint'); |
295 | - if(!$output->toBool()) return $output; |
|
333 | + if(!$output->toBool()) { |
|
334 | + return $output; |
|
335 | + } |
|
296 | 336 | |
297 | 337 | if($output->data) |
298 | 338 | { |
299 | 339 | foreach($output->data as $key => $val) |
300 | 340 | { |
301 | - if($module_config[$val->module_srl]['upload_file']) $insert_point = $module_config[$val->module_srl]['upload_file']; |
|
302 | - else $insert_point = $config->upload_file; |
|
341 | + if($module_config[$val->module_srl]['upload_file']) { |
|
342 | + $insert_point = $module_config[$val->module_srl]['upload_file']; |
|
343 | + } else { |
|
344 | + $insert_point = $config->upload_file; |
|
345 | + } |
|
303 | 346 | |
304 | - if(!$val->member_srl) continue; |
|
347 | + if(!$val->member_srl) { |
|
348 | + continue; |
|
349 | + } |
|
305 | 350 | $point = $insert_point * $val->count; |
306 | 351 | $member[$val->member_srl] += $point; |
307 | 352 | } |
@@ -309,7 +354,9 @@ discard block |
||
309 | 354 | $output = null; |
310 | 355 | // Set all members' points to 0 |
311 | 356 | $output = executeQuery("point.initMemberPoint"); |
312 | - if(!$output->toBool()) return $output; |
|
357 | + if(!$output->toBool()) { |
|
358 | + return $output; |
|
359 | + } |
|
313 | 360 | // Save the file temporarily |
314 | 361 | |
315 | 362 | $str = ''; |
@@ -334,7 +381,9 @@ discard block |
||
334 | 381 | $position = (int)Context::get('position'); |
335 | 382 | $total = (int)Context::get('total'); |
336 | 383 | |
337 | - if(!file_exists('./files/cache/pointRecal.txt')) return new Object(-1, 'msg_invalid_request'); |
|
384 | + if(!file_exists('./files/cache/pointRecal.txt')) { |
|
385 | + return new Object(-1, 'msg_invalid_request'); |
|
386 | + } |
|
338 | 387 | |
339 | 388 | $idx = 0; |
340 | 389 | $f = fopen("./files/cache/pointRecal.txt","r"); |
@@ -350,7 +399,9 @@ discard block |
||
350 | 399 | $args->member_srl = $member_srl; |
351 | 400 | $args->point = $point; |
352 | 401 | $output = executeQuery('point.insertPoint',$args); |
353 | - if($idx%5000==0) break; |
|
402 | + if($idx%5000==0) { |
|
403 | + break; |
|
404 | + } |
|
354 | 405 | } |
355 | 406 | } |
356 | 407 | |
@@ -377,16 +428,23 @@ discard block |
||
377 | 428 | function procPointAdminReset() |
378 | 429 | { |
379 | 430 | $module_srl = Context::get('module_srls'); |
380 | - if(!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
431 | + if(!$module_srl) { |
|
432 | + return new Object(-1, 'msg_invalid_request'); |
|
433 | + } |
|
381 | 434 | // In case of batch configuration of several modules |
382 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
383 | - else $module_srl = array($module_srl); |
|
435 | + if(preg_match('/^([0-9,]+)$/',$module_srl)) { |
|
436 | + $module_srl = explode(',',$module_srl); |
|
437 | + } else { |
|
438 | + $module_srl = array($module_srl); |
|
439 | + } |
|
384 | 440 | // Save configurations |
385 | 441 | $oModuleController = getController('module'); |
386 | 442 | for($i=0;$i<count($module_srl);$i++) |
387 | 443 | { |
388 | 444 | $srl = trim($module_srl[$i]); |
389 | - if(!$srl) continue; |
|
445 | + if(!$srl) { |
|
446 | + continue; |
|
447 | + } |
|
390 | 448 | $args = new stdClass(); |
391 | 449 | $args->module = 'point'; |
392 | 450 | $args->module_srl = $srl; |
@@ -26,10 +26,10 @@ discard block |
||
26 | 26 | $args = Context::getRequestVars(); |
27 | 27 | |
28 | 28 | //if module IO config is off |
29 | - if($args->able_module == 'Y') |
|
29 | + if ($args->able_module == 'Y') |
|
30 | 30 | { |
31 | 31 | // Re-install triggers, if it was disabled. |
32 | - if($config->able_module == 'N') |
|
32 | + if ($config->able_module == 'N') |
|
33 | 33 | { |
34 | 34 | $this->moduleUpdate(); |
35 | 35 | } |
@@ -39,28 +39,28 @@ discard block |
||
39 | 39 | |
40 | 40 | // Check the point name |
41 | 41 | $config->point_name = $args->point_name; |
42 | - if(!$config->point_name) $config->point_name = 'point'; |
|
42 | + if (!$config->point_name) $config->point_name = 'point'; |
|
43 | 43 | // Specify the default points |
44 | - $config->signup_point = (int)$args->signup_point; |
|
45 | - $config->login_point = (int)$args->login_point; |
|
46 | - $config->insert_document = (int)$args->insert_document; |
|
47 | - $config->read_document = (int)$args->read_document; |
|
48 | - $config->insert_comment = (int)$args->insert_comment; |
|
49 | - $config->upload_file = (int)$args->upload_file; |
|
50 | - $config->download_file = (int)$args->download_file; |
|
51 | - $config->voted = (int)$args->voted; |
|
52 | - $config->blamed = (int)$args->blamed; |
|
44 | + $config->signup_point = (int) $args->signup_point; |
|
45 | + $config->login_point = (int) $args->login_point; |
|
46 | + $config->insert_document = (int) $args->insert_document; |
|
47 | + $config->read_document = (int) $args->read_document; |
|
48 | + $config->insert_comment = (int) $args->insert_comment; |
|
49 | + $config->upload_file = (int) $args->upload_file; |
|
50 | + $config->download_file = (int) $args->download_file; |
|
51 | + $config->voted = (int) $args->voted; |
|
52 | + $config->blamed = (int) $args->blamed; |
|
53 | 53 | // The highest level |
54 | 54 | $config->max_level = $args->max_level; |
55 | - if($config->max_level>1000) $config->max_level = 1000; |
|
56 | - if($config->max_level<1) $config->max_level = 1; |
|
55 | + if ($config->max_level > 1000) $config->max_level = 1000; |
|
56 | + if ($config->max_level < 1) $config->max_level = 1; |
|
57 | 57 | // Set the level icon |
58 | 58 | $config->level_icon = $args->level_icon; |
59 | 59 | // Check if downloads are not allowed |
60 | - if($args->disable_download == 'Y') $config->disable_download = 'Y'; |
|
60 | + if ($args->disable_download == 'Y') $config->disable_download = 'Y'; |
|
61 | 61 | else $config->disable_download = 'N'; |
62 | 62 | // Check if reading a document is not allowed |
63 | - if($args->disable_read_document == 'Y') $config->disable_read_document = 'Y'; |
|
63 | + if ($args->disable_read_document == 'Y') $config->disable_read_document = 'Y'; |
|
64 | 64 | else $config->disable_read_document = 'N'; |
65 | 65 | |
66 | 66 | $oMemberModel = getModel('member'); |
@@ -68,23 +68,23 @@ discard block |
||
68 | 68 | $config->point_group = array(); |
69 | 69 | |
70 | 70 | // Per-level group configurations |
71 | - foreach($group_list as $group) |
|
71 | + foreach ($group_list as $group) |
|
72 | 72 | { |
73 | 73 | // Admin group should not be connected to point. |
74 | - if($group->is_admin == 'Y' || $group->is_default == 'Y') continue; |
|
74 | + if ($group->is_admin == 'Y' || $group->is_default == 'Y') continue; |
|
75 | 75 | |
76 | 76 | $group_srl = $group->group_srl; |
77 | 77 | |
78 | - if(isset($args->{'point_group_'.$group_srl})) |
|
78 | + if (isset($args->{'point_group_'.$group_srl})) |
|
79 | 79 | { |
80 | 80 | //if group level is higher than max level, change to max level |
81 | - if($args->{'point_group_'.$group_srl} > $args->max_level) |
|
81 | + if ($args->{'point_group_'.$group_srl} > $args->max_level) |
|
82 | 82 | { |
83 | 83 | $args->{'point_group_'.$group_srl} = $args->max_level; |
84 | 84 | } |
85 | 85 | |
86 | 86 | //if group level is lower than 1, change to 1 |
87 | - if($args->{'point_group_'.$group_srl} < 1) |
|
87 | + if ($args->{'point_group_'.$group_srl} < 1) |
|
88 | 88 | { |
89 | 89 | $args->{'point_group_'.$group_srl} = 1; |
90 | 90 | } |
@@ -95,10 +95,10 @@ discard block |
||
95 | 95 | $config->group_reset = $args->group_reset; |
96 | 96 | // Per-level point configurations |
97 | 97 | unset($config->level_step); |
98 | - for($i=1;$i<=$config->max_level;$i++) |
|
98 | + for ($i = 1; $i <= $config->max_level; $i++) |
|
99 | 99 | { |
100 | 100 | $key = "level_step_".$i; |
101 | - $config->level_step[$i] = (int)$args->{$key}; |
|
101 | + $config->level_step[$i] = (int) $args->{$key}; |
|
102 | 102 | } |
103 | 103 | // A function to calculate per-level points |
104 | 104 | $config->expression = $args->expression; |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | $args = Context::getRequestVars(); |
131 | 131 | |
132 | 132 | $configTypeList = array('insert_document', 'insert_comment', 'upload_file', 'download_file', 'read_document', 'voted', 'blamed'); |
133 | - foreach($configTypeList AS $config) |
|
133 | + foreach ($configTypeList AS $config) |
|
134 | 134 | { |
135 | - if(is_array($args->{$config})) |
|
135 | + if (is_array($args->{$config})) |
|
136 | 136 | { |
137 | - foreach($args->{$config} AS $key=>$value) |
|
137 | + foreach ($args->{$config} AS $key=>$value) |
|
138 | 138 | { |
139 | 139 | $module_config[$key][$config] = $value; |
140 | 140 | } |
@@ -142,16 +142,16 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | $oModuleController = getController('module'); |
145 | - if(count($module_config)) |
|
145 | + if (count($module_config)) |
|
146 | 146 | { |
147 | - foreach($module_config as $module_srl => $config) |
|
147 | + foreach ($module_config as $module_srl => $config) |
|
148 | 148 | { |
149 | - $oModuleController->insertModulePartConfig('point',$module_srl,$config); |
|
149 | + $oModuleController->insertModulePartConfig('point', $module_srl, $config); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | 153 | $this->setMessage('success_updated'); |
154 | - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
|
154 | + if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) |
|
155 | 155 | { |
156 | 156 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispPointAdminModuleConfig'); |
157 | 157 | header('location:'.$returnUrl); |
@@ -165,24 +165,24 @@ discard block |
||
165 | 165 | function procPointAdminInsertPointModuleConfig() |
166 | 166 | { |
167 | 167 | $module_srl = Context::get('target_module_srl'); |
168 | - if(!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
168 | + if (!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
169 | 169 | // In case of batch configuration of several modules |
170 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
170 | + if (preg_match('/^([0-9,]+)$/', $module_srl)) $module_srl = explode(',', $module_srl); |
|
171 | 171 | else $module_srl = array($module_srl); |
172 | 172 | // Save configurations |
173 | 173 | $oModuleController = getController('module'); |
174 | - for($i=0;$i<count($module_srl);$i++) |
|
174 | + for ($i = 0; $i < count($module_srl); $i++) |
|
175 | 175 | { |
176 | 176 | $srl = trim($module_srl[$i]); |
177 | - if(!$srl) continue; |
|
177 | + if (!$srl) continue; |
|
178 | 178 | unset($config); |
179 | - $config['insert_document'] = (int)Context::get('insert_document'); |
|
180 | - $config['insert_comment'] = (int)Context::get('insert_comment'); |
|
181 | - $config['upload_file'] = (int)Context::get('upload_file'); |
|
182 | - $config['download_file'] = (int)Context::get('download_file'); |
|
183 | - $config['read_document'] = (int)Context::get('read_document'); |
|
184 | - $config['voted'] = (int)Context::get('voted'); |
|
185 | - $config['blamed'] = (int)Context::get('blamed'); |
|
179 | + $config['insert_document'] = (int) Context::get('insert_document'); |
|
180 | + $config['insert_comment'] = (int) Context::get('insert_comment'); |
|
181 | + $config['upload_file'] = (int) Context::get('upload_file'); |
|
182 | + $config['download_file'] = (int) Context::get('download_file'); |
|
183 | + $config['read_document'] = (int) Context::get('read_document'); |
|
184 | + $config['voted'] = (int) Context::get('voted'); |
|
185 | + $config['blamed'] = (int) Context::get('blamed'); |
|
186 | 186 | $oModuleController->insertModulePartConfig('point', $srl, $config); |
187 | 187 | } |
188 | 188 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | preg_match('/^(\+|-)?([1-9][0-9]*)$/', $point, $m); |
205 | 205 | |
206 | 206 | $action = ''; |
207 | - switch($m[1]) |
|
207 | + switch ($m[1]) |
|
208 | 208 | { |
209 | 209 | case '+': |
210 | 210 | $action = 'add'; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $point = $m[2]; |
220 | 220 | |
221 | 221 | $oPointController = getController('point'); |
222 | - $output = $oPointController->setPoint($member_srl, (int)$point, $action); |
|
222 | + $output = $oPointController->setPoint($member_srl, (int) $point, $action); |
|
223 | 223 | |
224 | 224 | $this->setError(-1); |
225 | 225 | $this->setMessage('success_updated', 'info'); |
@@ -244,29 +244,29 @@ discard block |
||
244 | 244 | |
245 | 245 | // Get member infomation |
246 | 246 | $output = executeQueryArray('point.getMemberCount'); |
247 | - if(!$output->toBool()) return $output; |
|
247 | + if (!$output->toBool()) return $output; |
|
248 | 248 | |
249 | - if($output->data) |
|
249 | + if ($output->data) |
|
250 | 250 | { |
251 | - foreach($output->data as $key => $val) |
|
251 | + foreach ($output->data as $key => $val) |
|
252 | 252 | { |
253 | - if(!$val->member_srl) continue; |
|
253 | + if (!$val->member_srl) continue; |
|
254 | 254 | $member[$val->member_srl] = 0; |
255 | 255 | } |
256 | 256 | } |
257 | 257 | |
258 | 258 | // Get post information |
259 | 259 | $output = executeQueryArray('point.getDocumentPoint'); |
260 | - if(!$output->toBool()) return $output; |
|
260 | + if (!$output->toBool()) return $output; |
|
261 | 261 | |
262 | - if($output->data) |
|
262 | + if ($output->data) |
|
263 | 263 | { |
264 | - foreach($output->data as $key => $val) |
|
264 | + foreach ($output->data as $key => $val) |
|
265 | 265 | { |
266 | - if($module_config[$val->module_srl]['insert_document']) $insert_point = $module_config[$val->module_srl]['insert_document']; |
|
266 | + if ($module_config[$val->module_srl]['insert_document']) $insert_point = $module_config[$val->module_srl]['insert_document']; |
|
267 | 267 | else $insert_point = $config->insert_document; |
268 | 268 | |
269 | - if(!$val->member_srl) continue; |
|
269 | + if (!$val->member_srl) continue; |
|
270 | 270 | $point = $insert_point * $val->count; |
271 | 271 | $member[$val->member_srl] += $point; |
272 | 272 | } |
@@ -275,16 +275,16 @@ discard block |
||
275 | 275 | $output = null; |
276 | 276 | // Get comments information |
277 | 277 | $output = executeQueryArray('point.getCommentPoint'); |
278 | - if(!$output->toBool()) return $output; |
|
278 | + if (!$output->toBool()) return $output; |
|
279 | 279 | |
280 | - if($output->data) |
|
280 | + if ($output->data) |
|
281 | 281 | { |
282 | - foreach($output->data as $key => $val) |
|
282 | + foreach ($output->data as $key => $val) |
|
283 | 283 | { |
284 | - if($module_config[$val->module_srl]['insert_comment']) $insert_point = $module_config[$val->module_srl]['insert_comment']; |
|
284 | + if ($module_config[$val->module_srl]['insert_comment']) $insert_point = $module_config[$val->module_srl]['insert_comment']; |
|
285 | 285 | else $insert_point = $config->insert_comment; |
286 | 286 | |
287 | - if(!$val->member_srl) continue; |
|
287 | + if (!$val->member_srl) continue; |
|
288 | 288 | $point = $insert_point * $val->count; |
289 | 289 | $member[$val->member_srl] += $point; |
290 | 290 | } |
@@ -292,16 +292,16 @@ discard block |
||
292 | 292 | $output = null; |
293 | 293 | // Get the attached files' information |
294 | 294 | $output = executeQueryArray('point.getFilePoint'); |
295 | - if(!$output->toBool()) return $output; |
|
295 | + if (!$output->toBool()) return $output; |
|
296 | 296 | |
297 | - if($output->data) |
|
297 | + if ($output->data) |
|
298 | 298 | { |
299 | - foreach($output->data as $key => $val) |
|
299 | + foreach ($output->data as $key => $val) |
|
300 | 300 | { |
301 | - if($module_config[$val->module_srl]['upload_file']) $insert_point = $module_config[$val->module_srl]['upload_file']; |
|
301 | + if ($module_config[$val->module_srl]['upload_file']) $insert_point = $module_config[$val->module_srl]['upload_file']; |
|
302 | 302 | else $insert_point = $config->upload_file; |
303 | 303 | |
304 | - if(!$val->member_srl) continue; |
|
304 | + if (!$val->member_srl) continue; |
|
305 | 305 | $point = $insert_point * $val->count; |
306 | 306 | $member[$val->member_srl] += $point; |
307 | 307 | } |
@@ -309,13 +309,13 @@ discard block |
||
309 | 309 | $output = null; |
310 | 310 | // Set all members' points to 0 |
311 | 311 | $output = executeQuery("point.initMemberPoint"); |
312 | - if(!$output->toBool()) return $output; |
|
312 | + if (!$output->toBool()) return $output; |
|
313 | 313 | // Save the file temporarily |
314 | 314 | |
315 | 315 | $str = ''; |
316 | - foreach($member as $key => $val) |
|
316 | + foreach ($member as $key => $val) |
|
317 | 317 | { |
318 | - $val += (int)$config->signup_point; |
|
318 | + $val += (int) $config->signup_point; |
|
319 | 319 | $str .= $key.','.$val."\r\n"; |
320 | 320 | } |
321 | 321 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | |
324 | 324 | $this->add('total', count($member)); |
325 | 325 | $this->add('position', 0); |
326 | - $this->setMessage( sprintf(Context::getLang('point_recal_message'), 0, $this->get('total')) ); |
|
326 | + $this->setMessage(sprintf(Context::getLang('point_recal_message'), 0, $this->get('total'))); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -331,35 +331,35 @@ discard block |
||
331 | 331 | */ |
332 | 332 | function procPointAdminApplyPoint() |
333 | 333 | { |
334 | - $position = (int)Context::get('position'); |
|
335 | - $total = (int)Context::get('total'); |
|
334 | + $position = (int) Context::get('position'); |
|
335 | + $total = (int) Context::get('total'); |
|
336 | 336 | |
337 | - if(!file_exists('./files/cache/pointRecal.txt')) return new Object(-1, 'msg_invalid_request'); |
|
337 | + if (!file_exists('./files/cache/pointRecal.txt')) return new Object(-1, 'msg_invalid_request'); |
|
338 | 338 | |
339 | 339 | $idx = 0; |
340 | - $f = fopen("./files/cache/pointRecal.txt","r"); |
|
341 | - while(!feof($f)) |
|
340 | + $f = fopen("./files/cache/pointRecal.txt", "r"); |
|
341 | + while (!feof($f)) |
|
342 | 342 | { |
343 | 343 | $str = trim(fgets($f, 1024)); |
344 | - $idx ++; |
|
345 | - if($idx > $position) |
|
344 | + $idx++; |
|
345 | + if ($idx > $position) |
|
346 | 346 | { |
347 | - list($member_srl, $point) = explode(',',$str); |
|
347 | + list($member_srl, $point) = explode(',', $str); |
|
348 | 348 | |
349 | 349 | $args = new stdClass(); |
350 | 350 | $args->member_srl = $member_srl; |
351 | 351 | $args->point = $point; |
352 | - $output = executeQuery('point.insertPoint',$args); |
|
353 | - if($idx%5000==0) break; |
|
352 | + $output = executeQuery('point.insertPoint', $args); |
|
353 | + if ($idx % 5000 == 0) break; |
|
354 | 354 | } |
355 | 355 | } |
356 | 356 | |
357 | - if(feof($f)) |
|
357 | + if (feof($f)) |
|
358 | 358 | { |
359 | 359 | FileHandler::removeFile('./files/cache/pointRecal.txt'); |
360 | 360 | $idx = $total; |
361 | 361 | |
362 | - FileHandler::rename('./files/member_extra_info/point','./files/member_extra_info/point.old'); |
|
362 | + FileHandler::rename('./files/member_extra_info/point', './files/member_extra_info/point.old'); |
|
363 | 363 | |
364 | 364 | FileHandler::removeDir('./files/member_extra_info/point.old'); |
365 | 365 | } |
@@ -377,16 +377,16 @@ discard block |
||
377 | 377 | function procPointAdminReset() |
378 | 378 | { |
379 | 379 | $module_srl = Context::get('module_srls'); |
380 | - if(!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
380 | + if (!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
381 | 381 | // In case of batch configuration of several modules |
382 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
382 | + if (preg_match('/^([0-9,]+)$/', $module_srl)) $module_srl = explode(',', $module_srl); |
|
383 | 383 | else $module_srl = array($module_srl); |
384 | 384 | // Save configurations |
385 | 385 | $oModuleController = getController('module'); |
386 | - for($i=0;$i<count($module_srl);$i++) |
|
386 | + for ($i = 0; $i < count($module_srl); $i++) |
|
387 | 387 | { |
388 | 388 | $srl = trim($module_srl[$i]); |
389 | - if(!$srl) continue; |
|
389 | + if (!$srl) continue; |
|
390 | 390 | $args = new stdClass(); |
391 | 391 | $args->module = 'point'; |
392 | 392 | $args->module_srl = $srl; |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | } |
395 | 395 | |
396 | 396 | $oCacheHandler = CacheHandler::getInstance('object', null, true); |
397 | - if($oCacheHandler->isSupport()) |
|
397 | + if ($oCacheHandler->isSupport()) |
|
398 | 398 | { |
399 | 399 | $oCacheHandler->invalidateGroupKey('site_and_module'); |
400 | 400 | } |
@@ -8,12 +8,12 @@ discard block |
||
8 | 8 | { |
9 | 9 | // If member_srl < 0, then return text only in the body |
10 | 10 | $member_srl = $matches[3]; |
11 | - if($member_srl < 0) |
|
11 | + if ($member_srl < 0) |
|
12 | 12 | { |
13 | 13 | return $matches[5]; |
14 | 14 | } |
15 | 15 | // If member_srl=o(not a member), return the entire body |
16 | - if(!$member_srl) |
|
16 | + if (!$member_srl) |
|
17 | 17 | { |
18 | 18 | return $matches[0]; |
19 | 19 | } |
@@ -22,22 +22,22 @@ discard block |
||
22 | 22 | $nick_name = $matches[5]; |
23 | 23 | |
24 | 24 | // Initialize global variable for cache |
25 | - if(!isset($GLOBALS['_transImageNameList'][$member_srl])) |
|
25 | + if (!isset($GLOBALS['_transImageNameList'][$member_srl])) |
|
26 | 26 | { |
27 | 27 | $GLOBALS['_transImageNameList'][$member_srl] = new stdClass(); |
28 | 28 | } |
29 | 29 | $_tmp = &$GLOBALS['_transImageNameList'][$member_srl]; |
30 | 30 | |
31 | 31 | // If pre-defined data in the global variables, return it |
32 | - if(!$_tmp->cached) |
|
32 | + if (!$_tmp->cached) |
|
33 | 33 | { |
34 | 34 | $_tmp->cached = true; |
35 | 35 | $image_name_file = sprintf('files/member_extra_info/image_name/%s%d.gif', getNumberingPath($member_srl), $member_srl); |
36 | 36 | $image_mark_file = sprintf('files/member_extra_info/image_mark/%s%d.gif', getNumberingPath($member_srl), $member_srl); |
37 | 37 | |
38 | - if(file_exists(_XE_PATH_ . $image_name_file)) |
|
38 | + if (file_exists(_XE_PATH_.$image_name_file)) |
|
39 | 39 | { |
40 | - $_tmp->image_name_file = $image_name_file . '?' . date('YmdHis', filemtime(_XE_PATH_ . $image_name_file)); |
|
40 | + $_tmp->image_name_file = $image_name_file.'?'.date('YmdHis', filemtime(_XE_PATH_.$image_name_file)); |
|
41 | 41 | $image_name_file = $_tmp->image_name_file; |
42 | 42 | } |
43 | 43 | else |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | $image_name_file = ''; |
46 | 46 | } |
47 | 47 | |
48 | - if(file_exists(_XE_PATH_ . $image_mark_file)) |
|
48 | + if (file_exists(_XE_PATH_.$image_mark_file)) |
|
49 | 49 | { |
50 | - $_tmp->image_mark_file = $image_mark_file . '?' . date('YmdHis', filemtime(_XE_PATH_ . $image_mark_file)); |
|
50 | + $_tmp->image_mark_file = $image_mark_file.'?'.date('YmdHis', filemtime(_XE_PATH_.$image_mark_file)); |
|
51 | 51 | $image_mark_file = $_tmp->image_mark_file; |
52 | 52 | } |
53 | 53 | else |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | // If image name and mark doesn't exist, set the original information |
70 | - if(!$image_name_file && !$image_mark_file && !$group_image) |
|
70 | + if (!$image_name_file && !$image_mark_file && !$group_image) |
|
71 | 71 | { |
72 | 72 | return $matches[0]; |
73 | 73 | } |
@@ -76,21 +76,21 @@ discard block |
||
76 | 76 | |
77 | 77 | $config = $oMemberModel->getMemberConfig(); |
78 | 78 | |
79 | - if($config->image_name == 'Y' && $image_name_file) |
|
79 | + if ($config->image_name == 'Y' && $image_name_file) |
|
80 | 80 | { |
81 | 81 | $nick_name = sprintf('<img src="%s%s" alt="id: %s" title="id: %s" style="border:0;vertical-align:middle;margin-right:3px" />', Context::getRequestUri(), $image_name_file, strip_tags($nick_name), strip_tags($nick_name)); |
82 | 82 | } |
83 | - if($config->image_mark == 'Y' && $image_mark_file) |
|
83 | + if ($config->image_mark == 'Y' && $image_mark_file) |
|
84 | 84 | { |
85 | 85 | $nick_name = sprintf('<img src="%s%s" alt="id: %s" title="id : %s" style="border:0;vertical-align:middle;margin-right:3px"/>%s', Context::getRequestUri(), $image_mark_file, strip_tags($nick_name), strip_tags($nick_name), $nick_name); |
86 | 86 | } |
87 | 87 | |
88 | - if($group_image) |
|
88 | + if ($group_image) |
|
89 | 89 | { |
90 | 90 | $nick_name = sprintf('<img src="%s" style="border:0;max-height:16px;vertical-align:middle;margin-right:3px" alt="%s" title="%s" />%s', $group_image->src, $group_image->title, $group_image->description, $nick_name); |
91 | 91 | } |
92 | 92 | |
93 | - return preg_replace('/' . preg_quote($matches[5], '/') . '<\/' . $matches[6] . '>$/', '', $matches[0]) . $nick_name . '</' . $matches[6] . '>'; |
|
93 | + return preg_replace('/'.preg_quote($matches[5], '/').'<\/'.$matches[6].'>$/', '', $matches[0]).$nick_name.'</'.$matches[6].'>'; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /* End of file member_extra_info.lib.php */ |
@@ -39,8 +39,7 @@ discard block |
||
39 | 39 | { |
40 | 40 | $_tmp->image_name_file = $image_name_file . '?' . date('YmdHis', filemtime(_XE_PATH_ . $image_name_file)); |
41 | 41 | $image_name_file = $_tmp->image_name_file; |
42 | - } |
|
43 | - else |
|
42 | + } else |
|
44 | 43 | { |
45 | 44 | $image_name_file = ''; |
46 | 45 | } |
@@ -49,8 +48,7 @@ discard block |
||
49 | 48 | { |
50 | 49 | $_tmp->image_mark_file = $image_mark_file . '?' . date('YmdHis', filemtime(_XE_PATH_ . $image_mark_file)); |
51 | 50 | $image_mark_file = $_tmp->image_mark_file; |
52 | - } |
|
53 | - else |
|
51 | + } else |
|
54 | 52 | { |
55 | 53 | $image_mark_file = ''; |
56 | 54 | } |
@@ -58,8 +56,7 @@ discard block |
||
58 | 56 | $site_module_info = Context::get('site_module_info'); |
59 | 57 | $group_image = $oMemberModel->getGroupImageMark($member_srl, $site_module_info->site_srl); |
60 | 58 | $_tmp->group_image = $group_image; |
61 | - } |
|
62 | - else |
|
59 | + } else |
|
63 | 60 | { |
64 | 61 | $group_image = $_tmp->group_image; |
65 | 62 | $image_name_file = $_tmp->image_name_file; |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | */ |
49 | 49 | function LimitTag($index) |
50 | 50 | { |
51 | - if($index->page && $index->page->attrs && $index->page_count && $index->page_count->attrs) |
|
51 | + if ($index->page && $index->page->attrs && $index->page_count && $index->page_count->attrs) |
|
52 | 52 | { |
53 | - if(!isset($index->page->attrs->default)) |
|
53 | + if (!isset($index->page->attrs->default)) |
|
54 | 54 | $index->page->attrs->default = 1; |
55 | - if(!isset($index->page_count->attrs->default)) |
|
55 | + if (!isset($index->page_count->attrs->default)) |
|
56 | 56 | $index->page_count->attrs->default = 10; |
57 | 57 | $this->page = new QueryArgument($index->page); |
58 | 58 | $this->page_count = new QueryArgument($index->page_count); |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | $this->arguments[] = $this->page_count; |
61 | 61 | } |
62 | 62 | |
63 | - if(!isset($index->list_count->attrs->default)) |
|
63 | + if (!isset($index->list_count->attrs->default)) |
|
64 | 64 | $index->list_count->attrs->default = 0; |
65 | 65 | $this->list_count = new QueryArgument($index->list_count); |
66 | 66 | $this->arguments[] = $this->list_count; |
67 | 67 | |
68 | - if(isset($index->offset) && isset($index->offset->attrs)) |
|
68 | + if (isset($index->offset) && isset($index->offset->attrs)) |
|
69 | 69 | { |
70 | 70 | $this->offset = new QueryArgument($index->offset); |
71 | 71 | $this->arguments[] = $this->offset; |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | |
75 | 75 | function toString() |
76 | 76 | { |
77 | - if($this->page) |
|
77 | + if ($this->page) |
|
78 | 78 | { |
79 | 79 | return sprintf('new Limit(${\'%s_argument\'}, ${\'%s_argument\'}, ${\'%s_argument\'})', $this->list_count->getArgumentName(), $this->page->getArgumentName(), $this->page_count->getArgumentName()); |
80 | 80 | } |
81 | - elseif($this->offset) |
|
81 | + elseif ($this->offset) |
|
82 | 82 | { |
83 | 83 | return sprintf('new Limit(${\'%s_argument\'}, NULL, NULL, ${\'%s_argument\'})', $this->list_count->getArgumentName(), $this->offset->getArgumentName()); |
84 | 84 | } |
@@ -50,18 +50,21 @@ discard block |
||
50 | 50 | { |
51 | 51 | if($index->page && $index->page->attrs && $index->page_count && $index->page_count->attrs) |
52 | 52 | { |
53 | - if(!isset($index->page->attrs->default)) |
|
54 | - $index->page->attrs->default = 1; |
|
55 | - if(!isset($index->page_count->attrs->default)) |
|
56 | - $index->page_count->attrs->default = 10; |
|
53 | + if(!isset($index->page->attrs->default)) { |
|
54 | + $index->page->attrs->default = 1; |
|
55 | + } |
|
56 | + if(!isset($index->page_count->attrs->default)) { |
|
57 | + $index->page_count->attrs->default = 10; |
|
58 | + } |
|
57 | 59 | $this->page = new QueryArgument($index->page); |
58 | 60 | $this->page_count = new QueryArgument($index->page_count); |
59 | 61 | $this->arguments[] = $this->page; |
60 | 62 | $this->arguments[] = $this->page_count; |
61 | 63 | } |
62 | 64 | |
63 | - if(!isset($index->list_count->attrs->default)) |
|
64 | - $index->list_count->attrs->default = 0; |
|
65 | + if(!isset($index->list_count->attrs->default)) { |
|
66 | + $index->list_count->attrs->default = 0; |
|
67 | + } |
|
65 | 68 | $this->list_count = new QueryArgument($index->list_count); |
66 | 69 | $this->arguments[] = $this->list_count; |
67 | 70 | |
@@ -77,12 +80,10 @@ discard block |
||
77 | 80 | if($this->page) |
78 | 81 | { |
79 | 82 | return sprintf('new Limit(${\'%s_argument\'}, ${\'%s_argument\'}, ${\'%s_argument\'})', $this->list_count->getArgumentName(), $this->page->getArgumentName(), $this->page_count->getArgumentName()); |
80 | - } |
|
81 | - elseif($this->offset) |
|
83 | + } elseif($this->offset) |
|
82 | 84 | { |
83 | 85 | return sprintf('new Limit(${\'%s_argument\'}, NULL, NULL, ${\'%s_argument\'})', $this->list_count->getArgumentName(), $this->offset->getArgumentName()); |
84 | - } |
|
85 | - else |
|
86 | + } else |
|
86 | 87 | { |
87 | 88 | return sprintf('new Limit(${\'%s_argument\'})', $this->list_count->getArgumentName()); |
88 | 89 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | function Limit($list_count, $page = NULL, $page_count = NULL, $offset = NULL) |
45 | 45 | { |
46 | 46 | $this->list_count = $list_count; |
47 | - if($page) |
|
47 | + if ($page) |
|
48 | 48 | { |
49 | 49 | $list_count_value = $list_count->getValue(); |
50 | 50 | $page_value = $page->getValue(); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $this->page_count = $page_count; |
53 | 53 | $this->page = $page; |
54 | 54 | } |
55 | - elseif($offset) |
|
55 | + elseif ($offset) |
|
56 | 56 | { |
57 | 57 | $this->start = $offset->getValue(); |
58 | 58 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | function isPageHandler() |
66 | 66 | { |
67 | - if($this->page) |
|
67 | + if ($this->page) |
|
68 | 68 | { |
69 | 69 | return true; |
70 | 70 | } |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | |
87 | 87 | function toString() |
88 | 88 | { |
89 | - if($this->page || $this->start) |
|
89 | + if ($this->page || $this->start) |
|
90 | 90 | { |
91 | - return $this->start . ' , ' . $this->list_count->getValue(); |
|
91 | + return $this->start.' , '.$this->list_count->getValue(); |
|
92 | 92 | } |
93 | 93 | else |
94 | 94 | { |
@@ -51,8 +51,7 @@ discard block |
||
51 | 51 | $this->start = ($page_value - 1) * $list_count_value; |
52 | 52 | $this->page_count = $page_count; |
53 | 53 | $this->page = $page; |
54 | - } |
|
55 | - elseif($offset) |
|
54 | + } elseif($offset) |
|
56 | 55 | { |
57 | 56 | $this->start = $offset->getValue(); |
58 | 57 | } |
@@ -67,8 +66,7 @@ discard block |
||
67 | 66 | if($this->page) |
68 | 67 | { |
69 | 68 | return true; |
70 | - } |
|
71 | - else |
|
69 | + } else |
|
72 | 70 | { |
73 | 71 | return false; |
74 | 72 | } |
@@ -89,8 +87,7 @@ discard block |
||
89 | 87 | if($this->page || $this->start) |
90 | 88 | { |
91 | 89 | return $this->start . ' , ' . $this->list_count->getValue(); |
92 | - } |
|
93 | - else |
|
90 | + } else |
|
94 | 91 | { |
95 | 92 | return $this->list_count->getValue(); |
96 | 93 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | function DBMssql($auto_connect = TRUE) |
46 | 46 | { |
47 | 47 | $this->_setDBInfo(); |
48 | - if($auto_connect) $this->_connect(); |
|
48 | + if ($auto_connect) $this->_connect(); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | //sqlsrv_configure( 'LogSubsystems', SQLSRV_LOG_SYSTEM_ALL ); |
71 | 71 | $result = @sqlsrv_connect($connection["db_hostname"], array('Database' => $connection["db_database"], 'UID' => $connection["db_userid"], 'PWD' => $connection["db_password"])); |
72 | 72 | |
73 | - if(!$result) |
|
73 | + if (!$result) |
|
74 | 74 | { |
75 | 75 | $errors = print_r(sqlsrv_errors(), true); |
76 | - $this->setError(-1, 'database connect fail' . PHP_EOL . $errors); |
|
76 | + $this->setError(-1, 'database connect fail'.PHP_EOL.$errors); |
|
77 | 77 | return; |
78 | 78 | } |
79 | 79 | return $result; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | function addQuotes($string) |
101 | 101 | { |
102 | - if(version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) |
|
102 | + if (version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) |
|
103 | 103 | { |
104 | 104 | $string = stripslashes(str_replace("\\", "\\\\", $string)); |
105 | 105 | } |
@@ -117,16 +117,16 @@ discard block |
||
117 | 117 | { |
118 | 118 | $connection = $this->_getConnection('master'); |
119 | 119 | |
120 | - if(!$transactionLevel) |
|
120 | + if (!$transactionLevel) |
|
121 | 121 | { |
122 | - if(sqlsrv_begin_transaction($connection) === false) |
|
122 | + if (sqlsrv_begin_transaction($connection) === false) |
|
123 | 123 | { |
124 | 124 | return; |
125 | 125 | } |
126 | 126 | } |
127 | 127 | else |
128 | 128 | { |
129 | - $this->_query("SAVE TRANS SP" . $transactionLevel, $connection); |
|
129 | + $this->_query("SAVE TRANS SP".$transactionLevel, $connection); |
|
130 | 130 | } |
131 | 131 | return true; |
132 | 132 | } |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | |
143 | 143 | $point = $transactionLevel - 1; |
144 | 144 | |
145 | - if($point) |
|
145 | + if ($point) |
|
146 | 146 | { |
147 | - $this->_query("ROLLBACK TRANS SP" . $point, $connection); |
|
147 | + $this->_query("ROLLBACK TRANS SP".$point, $connection); |
|
148 | 148 | } |
149 | 149 | else |
150 | 150 | { |
@@ -176,18 +176,18 @@ discard block |
||
176 | 176 | { |
177 | 177 | $_param = array(); |
178 | 178 | |
179 | - if(count($this->param)) |
|
179 | + if (count($this->param)) |
|
180 | 180 | { |
181 | - foreach($this->param as $k => $o) |
|
181 | + foreach ($this->param as $k => $o) |
|
182 | 182 | { |
183 | - if($o->isColumnName()) |
|
183 | + if ($o->isColumnName()) |
|
184 | 184 | { |
185 | 185 | continue; |
186 | 186 | } |
187 | - if($o->getType() == 'number') |
|
187 | + if ($o->getType() == 'number') |
|
188 | 188 | { |
189 | 189 | $value = $o->getUnescapedValue(); |
190 | - if(is_array($value)) |
|
190 | + if (is_array($value)) |
|
191 | 191 | { |
192 | 192 | $_param = array_merge($_param, $value); |
193 | 193 | } |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | else |
200 | 200 | { |
201 | 201 | $value = $o->getUnescapedValue(); |
202 | - if(is_array($value)) |
|
202 | + if (is_array($value)) |
|
203 | 203 | { |
204 | - foreach($value as $v) |
|
204 | + foreach ($value as $v) |
|
205 | 205 | { |
206 | 206 | $_param[] = array($v, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8')); |
207 | 207 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | |
217 | 217 | // Run the query statement |
218 | 218 | $result = false; |
219 | - if(count($_param)) |
|
219 | + if (count($_param)) |
|
220 | 220 | { |
221 | 221 | $args = $this->_getParametersByReference($_param); |
222 | 222 | $stmt = sqlsrv_prepare($connection, $query, $args); |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $stmt = sqlsrv_prepare($connection, $query); |
227 | 227 | } |
228 | 228 | |
229 | - if(!$stmt) |
|
229 | + if (!$stmt) |
|
230 | 230 | { |
231 | 231 | $result = false; |
232 | 232 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | } |
237 | 237 | |
238 | 238 | // Error Check |
239 | - if(!$result) |
|
239 | + if (!$result) |
|
240 | 240 | { |
241 | 241 | $this->setError(print_r(sqlsrv_errors(), true)); |
242 | 242 | } |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | $copy = array(); |
260 | 260 | $args = array(); |
261 | 261 | $i = 0; |
262 | - foreach($_param as $key => $value) |
|
262 | + foreach ($_param as $key => $value) |
|
263 | 263 | { |
264 | - if(is_array($value)) |
|
264 | + if (is_array($value)) |
|
265 | 265 | { |
266 | 266 | $value_copy = $value; |
267 | 267 | $value_arg = array(); |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | function _fetch($result, $arrayIndexEndValue = NULL) |
289 | 289 | { |
290 | 290 | $output = array(); |
291 | - if(!$this->isConnected() || $this->isError() || !$result) |
|
291 | + if (!$this->isConnected() || $this->isError() || !$result) |
|
292 | 292 | { |
293 | 293 | return $output; |
294 | 294 | } |
@@ -296,18 +296,18 @@ discard block |
||
296 | 296 | $c = sqlsrv_num_fields($result); |
297 | 297 | $m = null; |
298 | 298 | |
299 | - while(sqlsrv_fetch($result)) |
|
299 | + while (sqlsrv_fetch($result)) |
|
300 | 300 | { |
301 | - if(!$m) |
|
301 | + if (!$m) |
|
302 | 302 | { |
303 | 303 | $m = sqlsrv_field_metadata($result); |
304 | 304 | } |
305 | 305 | unset($row); |
306 | - for($i = 0; $i < $c; $i++) |
|
306 | + for ($i = 0; $i < $c; $i++) |
|
307 | 307 | { |
308 | 308 | $row->{$m[$i]['Name']} = sqlsrv_get_field($result, $i, SQLSRV_PHPTYPE_STRING('utf-8')); |
309 | 309 | } |
310 | - if($arrayIndexEndValue) |
|
310 | + if ($arrayIndexEndValue) |
|
311 | 311 | { |
312 | 312 | $output[$arrayIndexEndValue--] = $row; |
313 | 313 | } |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | } |
318 | 318 | } |
319 | 319 | |
320 | - if(count($output) == 1) |
|
320 | + if (count($output) == 1) |
|
321 | 321 | { |
322 | - if(isset($arrayIndexEndValue)) |
|
322 | + if (isset($arrayIndexEndValue)) |
|
323 | 323 | { |
324 | 324 | return $output; |
325 | 325 | } |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | $result = $this->_query($query); |
361 | 361 | $tmp = $this->_fetch($result); |
362 | 362 | |
363 | - if(!$tmp) |
|
363 | + if (!$tmp) |
|
364 | 364 | { |
365 | 365 | return false; |
366 | 366 | } |
@@ -379,18 +379,18 @@ discard block |
||
379 | 379 | */ |
380 | 380 | function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = null, $notnull = false) |
381 | 381 | { |
382 | - if($this->isColumnExists($table_name, $column_name)) |
|
382 | + if ($this->isColumnExists($table_name, $column_name)) |
|
383 | 383 | { |
384 | 384 | return; |
385 | 385 | } |
386 | 386 | $type = $this->column_type[$type]; |
387 | - if(strtoupper($type) == 'INTEGER') |
|
387 | + if (strtoupper($type) == 'INTEGER') |
|
388 | 388 | { |
389 | 389 | $size = ''; |
390 | 390 | } |
391 | 391 | |
392 | 392 | $query = sprintf("alter table %s%s add %s ", $this->prefix, $table_name, $column_name); |
393 | - if($size) |
|
393 | + if ($size) |
|
394 | 394 | { |
395 | 395 | $query .= sprintf(" %s(%s) ", $type, $size); |
396 | 396 | } |
@@ -399,11 +399,11 @@ discard block |
||
399 | 399 | $query .= sprintf(" %s ", $type); |
400 | 400 | } |
401 | 401 | |
402 | - if(isset($default)) |
|
402 | + if (isset($default)) |
|
403 | 403 | { |
404 | 404 | $query .= sprintf(" default '%s' ", $default); |
405 | 405 | } |
406 | - if($notnull) |
|
406 | + if ($notnull) |
|
407 | 407 | { |
408 | 408 | $query .= " not null "; |
409 | 409 | } |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | */ |
420 | 420 | function dropColumn($table_name, $column_name) |
421 | 421 | { |
422 | - if(!$this->isColumnExists($table_name, $column_name)) |
|
422 | + if (!$this->isColumnExists($table_name, $column_name)) |
|
423 | 423 | { |
424 | 424 | return; |
425 | 425 | } |
@@ -437,12 +437,12 @@ discard block |
||
437 | 437 | { |
438 | 438 | $query = sprintf("select syscolumns.name as name from syscolumns, sysobjects where sysobjects.name = '%s%s' and sysobjects.id = syscolumns.id and syscolumns.name = '%s'", $this->prefix, $table_name, $column_name); |
439 | 439 | $result = $this->_query($query); |
440 | - if($this->isError()) |
|
440 | + if ($this->isError()) |
|
441 | 441 | { |
442 | 442 | return; |
443 | 443 | } |
444 | 444 | $tmp = $this->_fetch($result); |
445 | - if(!$tmp->name) |
|
445 | + if (!$tmp->name) |
|
446 | 446 | { |
447 | 447 | return false; |
448 | 448 | } |
@@ -461,11 +461,11 @@ discard block |
||
461 | 461 | */ |
462 | 462 | function addIndex($table_name, $index_name, $target_columns, $is_unique = false) |
463 | 463 | { |
464 | - if($this->isIndexExists($table_name, $index_name)) |
|
464 | + if ($this->isIndexExists($table_name, $index_name)) |
|
465 | 465 | { |
466 | 466 | return; |
467 | 467 | } |
468 | - if(!is_array($target_columns)) |
|
468 | + if (!is_array($target_columns)) |
|
469 | 469 | { |
470 | 470 | $target_columns = array($target_columns); |
471 | 471 | } |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | */ |
484 | 484 | function dropIndex($table_name, $index_name, $is_unique = false) |
485 | 485 | { |
486 | - if(!$this->isIndexExists($table_name, $index_name)) |
|
486 | + if (!$this->isIndexExists($table_name, $index_name)) |
|
487 | 487 | { |
488 | 488 | return; |
489 | 489 | } |
@@ -502,13 +502,13 @@ discard block |
||
502 | 502 | $query = sprintf("select sysindexes.name as name from sysindexes, sysobjects where sysobjects.name = '%s%s' and sysobjects.id = sysindexes.id and sysindexes.name = '%s'", $this->prefix, $table_name, $index_name); |
503 | 503 | |
504 | 504 | $result = $this->_query($query); |
505 | - if($this->isError()) |
|
505 | + if ($this->isError()) |
|
506 | 506 | { |
507 | 507 | return; |
508 | 508 | } |
509 | 509 | $tmp = $this->_fetch($result); |
510 | 510 | |
511 | - if(!$tmp->name) |
|
511 | + if (!$tmp->name) |
|
512 | 512 | { |
513 | 513 | return false; |
514 | 514 | } |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | */ |
533 | 533 | function createTableByXmlFile($file_name) |
534 | 534 | { |
535 | - if(!file_exists($file_name)) |
|
535 | + if (!file_exists($file_name)) |
|
536 | 536 | { |
537 | 537 | return; |
538 | 538 | } |
@@ -557,22 +557,22 @@ discard block |
||
557 | 557 | $xml_obj = $oXml->parse($xml_doc); |
558 | 558 | // Create a table schema |
559 | 559 | $table_name = $xml_obj->table->attrs->name; |
560 | - if($this->isTableExists($table_name)) |
|
560 | + if ($this->isTableExists($table_name)) |
|
561 | 561 | { |
562 | 562 | return; |
563 | 563 | } |
564 | 564 | |
565 | - if($table_name == 'sequence') |
|
565 | + if ($table_name == 'sequence') |
|
566 | 566 | { |
567 | - $table_name = $this->prefix . $table_name; |
|
567 | + $table_name = $this->prefix.$table_name; |
|
568 | 568 | $query = sprintf('create table %s ( sequence int identity(1,1), seq int )', $table_name); |
569 | 569 | return $this->_query($query); |
570 | 570 | } |
571 | 571 | else |
572 | 572 | { |
573 | - $table_name = $this->prefix . $table_name; |
|
573 | + $table_name = $this->prefix.$table_name; |
|
574 | 574 | |
575 | - if(!is_array($xml_obj->table->column)) |
|
575 | + if (!is_array($xml_obj->table->column)) |
|
576 | 576 | { |
577 | 577 | $columns[] = $xml_obj->table->column; |
578 | 578 | } |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | $index_list = array(); |
587 | 587 | |
588 | 588 | $typeList = array('number' => 1, 'text' => 1); |
589 | - foreach($columns as $column) |
|
589 | + foreach ($columns as $column) |
|
590 | 590 | { |
591 | 591 | $name = $column->attrs->name; |
592 | 592 | $type = $column->attrs->type; |
@@ -598,48 +598,48 @@ discard block |
||
598 | 598 | $default = $column->attrs->default; |
599 | 599 | $auto_increment = $column->attrs->auto_increment; |
600 | 600 | |
601 | - $column_schema[] = sprintf('[%s] %s%s %s %s %s', $name, $this->column_type[$type], !isset($typeList[$type]) && $size ? '(' . $size . ')' : '', isset($default) ? "default '" . $default . "'" : '', $notnull ? 'not null' : 'null', $auto_increment ? 'identity(1,1)' : ''); |
|
601 | + $column_schema[] = sprintf('[%s] %s%s %s %s %s', $name, $this->column_type[$type], !isset($typeList[$type]) && $size ? '('.$size.')' : '', isset($default) ? "default '".$default."'" : '', $notnull ? 'not null' : 'null', $auto_increment ? 'identity(1,1)' : ''); |
|
602 | 602 | |
603 | - if($primary_key) |
|
603 | + if ($primary_key) |
|
604 | 604 | { |
605 | 605 | $primary_list[] = $name; |
606 | 606 | } |
607 | - else if($unique) |
|
607 | + else if ($unique) |
|
608 | 608 | { |
609 | 609 | $unique_list[$unique][] = $name; |
610 | 610 | } |
611 | - else if($index) |
|
611 | + else if ($index) |
|
612 | 612 | { |
613 | 613 | $index_list[$index][] = $name; |
614 | 614 | } |
615 | 615 | } |
616 | 616 | |
617 | - if(count($primary_list)) |
|
617 | + if (count($primary_list)) |
|
618 | 618 | { |
619 | - $column_schema[] = sprintf("primary key (%s)", '"' . implode($primary_list, '","') . '"'); |
|
619 | + $column_schema[] = sprintf("primary key (%s)", '"'.implode($primary_list, '","').'"'); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | $schema = sprintf('create table [%s] (%s%s)', $this->addQuotes($table_name), "\n", implode($column_schema, ",\n")); |
623 | 623 | $output = $this->_query($schema); |
624 | - if(!$output) |
|
624 | + if (!$output) |
|
625 | 625 | { |
626 | 626 | return false; |
627 | 627 | } |
628 | 628 | |
629 | - if(count($unique_list)) |
|
629 | + if (count($unique_list)) |
|
630 | 630 | { |
631 | - foreach($unique_list as $key => $val) |
|
631 | + foreach ($unique_list as $key => $val) |
|
632 | 632 | { |
633 | - $query = sprintf("create unique index %s on %s (%s);", $key, $table_name, '[' . implode('],[', $val) . ']'); |
|
633 | + $query = sprintf("create unique index %s on %s (%s);", $key, $table_name, '['.implode('],[', $val).']'); |
|
634 | 634 | $this->_query($query); |
635 | 635 | } |
636 | 636 | } |
637 | 637 | |
638 | - if(count($index_list)) |
|
638 | + if (count($index_list)) |
|
639 | 639 | { |
640 | - foreach($index_list as $key => $val) |
|
640 | + foreach ($index_list as $key => $val) |
|
641 | 641 | { |
642 | - $query = sprintf("create index %s on %s (%s);", $key, $table_name, '[' . implode('],[', $val) . ']'); |
|
642 | + $query = sprintf("create index %s on %s (%s);", $key, $table_name, '['.implode('],[', $val).']'); |
|
643 | 643 | $this->_query($query); |
644 | 644 | } |
645 | 645 | } |
@@ -682,34 +682,34 @@ discard block |
||
682 | 682 | function getUpdateSql($query, $with_values = true, $with_priority = false) |
683 | 683 | { |
684 | 684 | $columnsList = $query->getUpdateString($with_values); |
685 | - if($columnsList == '') |
|
685 | + if ($columnsList == '') |
|
686 | 686 | { |
687 | 687 | return new Object(-1, "Invalid query"); |
688 | 688 | } |
689 | 689 | |
690 | 690 | $from = $query->getFromString($with_values); |
691 | - if($from == '') |
|
691 | + if ($from == '') |
|
692 | 692 | { |
693 | 693 | return new Object(-1, "Invalid query"); |
694 | 694 | } |
695 | 695 | |
696 | 696 | $tables = $query->getTables(); |
697 | 697 | $alias_list = ''; |
698 | - foreach($tables as $table) |
|
698 | + foreach ($tables as $table) |
|
699 | 699 | { |
700 | 700 | $alias_list .= $table->getAlias(); |
701 | 701 | } |
702 | 702 | implode(',', explode(' ', $alias_list)); |
703 | 703 | |
704 | 704 | $where = $query->getWhereString($with_values); |
705 | - if($where != '') |
|
705 | + if ($where != '') |
|
706 | 706 | { |
707 | - $where = ' WHERE ' . $where; |
|
707 | + $where = ' WHERE '.$where; |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | $priority = $with_priority ? $query->getPriority() : ''; |
711 | 711 | |
712 | - return "UPDATE $priority $alias_list SET $columnsList FROM " . $from . $where; |
|
712 | + return "UPDATE $priority $alias_list SET $columnsList FROM ".$from.$where; |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | /** |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | * @param boolean $with_values |
731 | 731 | * @return string |
732 | 732 | */ |
733 | - function getSelectSql($query, $with_values = TRUE, $connection=NULL) |
|
733 | + function getSelectSql($query, $with_values = TRUE, $connection = NULL) |
|
734 | 734 | { |
735 | 735 | $with_values = false; |
736 | 736 | |
@@ -740,75 +740,75 @@ discard block |
||
740 | 740 | $limit = ''; |
741 | 741 | $limitCount = ''; |
742 | 742 | $limitQueryPart = $query->getLimit(); |
743 | - if($limitQueryPart) |
|
743 | + if ($limitQueryPart) |
|
744 | 744 | { |
745 | 745 | $limitCount = $limitQueryPart->getLimit(); |
746 | 746 | } |
747 | - if($limitCount != '') |
|
747 | + if ($limitCount != '') |
|
748 | 748 | { |
749 | - $limit = 'SELECT TOP ' . $limitCount; |
|
749 | + $limit = 'SELECT TOP '.$limitCount; |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | $select = $query->getSelectString($with_values); |
753 | - if($select == '') |
|
753 | + if ($select == '') |
|
754 | 754 | { |
755 | 755 | return new Object(-1, "Invalid query"); |
756 | 756 | } |
757 | - if($limit != '') |
|
757 | + if ($limit != '') |
|
758 | 758 | { |
759 | - $select = $limit . ' ' . $select; |
|
759 | + $select = $limit.' '.$select; |
|
760 | 760 | } |
761 | 761 | else |
762 | 762 | { |
763 | - $select = 'SELECT ' . $select; |
|
763 | + $select = 'SELECT '.$select; |
|
764 | 764 | } |
765 | 765 | |
766 | 766 | $from = $query->getFromString($with_values); |
767 | - if($from == '') |
|
767 | + if ($from == '') |
|
768 | 768 | { |
769 | 769 | return new Object(-1, "Invalid query"); |
770 | 770 | } |
771 | - $from = ' FROM ' . $from; |
|
771 | + $from = ' FROM '.$from; |
|
772 | 772 | |
773 | 773 | $where = $query->getWhereString($with_values); |
774 | - if($where != '') |
|
774 | + if ($where != '') |
|
775 | 775 | { |
776 | - $where = ' WHERE ' . $where; |
|
776 | + $where = ' WHERE '.$where; |
|
777 | 777 | } |
778 | 778 | |
779 | 779 | $groupBy = $query->getGroupByString(); |
780 | - if($groupBy != '') |
|
780 | + if ($groupBy != '') |
|
781 | 781 | { |
782 | - $groupBy = ' GROUP BY ' . $groupBy; |
|
782 | + $groupBy = ' GROUP BY '.$groupBy; |
|
783 | 783 | } |
784 | 784 | |
785 | 785 | $orderBy = $query->getOrderByString(); |
786 | - if($orderBy != '') |
|
786 | + if ($orderBy != '') |
|
787 | 787 | { |
788 | - $orderBy = ' ORDER BY ' . $orderBy; |
|
788 | + $orderBy = ' ORDER BY '.$orderBy; |
|
789 | 789 | } |
790 | 790 | |
791 | - if($limitCount != '' && $query->limit->start > 0) |
|
791 | + if ($limitCount != '' && $query->limit->start > 0) |
|
792 | 792 | { |
793 | 793 | $order = $query->getOrder(); |
794 | 794 | $first_columns = array(); |
795 | - foreach($order as $val) |
|
795 | + foreach ($order as $val) |
|
796 | 796 | { |
797 | 797 | $tmpColumnName = $val->getPureColumnName(); |
798 | - $first_columns[] = sprintf('%s(%s) as %s', $val->getPureSortOrder()=='asc'?'max':'min', $tmpColumnName, $tmpColumnName); |
|
798 | + $first_columns[] = sprintf('%s(%s) as %s', $val->getPureSortOrder() == 'asc' ? 'max' : 'min', $tmpColumnName, $tmpColumnName); |
|
799 | 799 | $first_sub_columns[] = $tmpColumnName; |
800 | 800 | } |
801 | 801 | |
802 | - $first_query = sprintf("select %s from (select top %d %s %s %s %s %s) xet", implode(',',$first_columns), $query->limit->start, implode(',',$first_sub_columns), $from, $where, $groupBy, $orderBy); |
|
802 | + $first_query = sprintf("select %s from (select top %d %s %s %s %s %s) xet", implode(',', $first_columns), $query->limit->start, implode(',', $first_sub_columns), $from, $where, $groupBy, $orderBy); |
|
803 | 803 | $this->param = $query->getArguments(); |
804 | 804 | $result = $this->__query($first_query, $connection); |
805 | 805 | $tmp = $this->_fetch($result); |
806 | 806 | |
807 | 807 | $sub_cond = array(); |
808 | - foreach($order as $k => $v) |
|
808 | + foreach ($order as $k => $v) |
|
809 | 809 | { |
810 | 810 | //for example... use Document |
811 | - if(get_class($v->sort_order) == 'SortArgument') |
|
811 | + if (get_class($v->sort_order) == 'SortArgument') |
|
812 | 812 | { |
813 | 813 | $sort_order = $v->sort_order->value; |
814 | 814 | } |
@@ -818,19 +818,19 @@ discard block |
||
818 | 818 | $sort_order = $v->sort_order; |
819 | 819 | } |
820 | 820 | |
821 | - $sub_cond[] = sprintf("%s %s '%s'", $v->getPureColumnName(), $sort_order=='asc'?'>':'<', $tmp->{$v->getPureColumnName()}); |
|
821 | + $sub_cond[] = sprintf("%s %s '%s'", $v->getPureColumnName(), $sort_order == 'asc' ? '>' : '<', $tmp->{$v->getPureColumnName()}); |
|
822 | 822 | } |
823 | 823 | |
824 | - if(!$where) |
|
824 | + if (!$where) |
|
825 | 825 | { |
826 | - $sub_condition = ' WHERE ( '.implode(' and ',$sub_cond).' )'; |
|
826 | + $sub_condition = ' WHERE ( '.implode(' and ', $sub_cond).' )'; |
|
827 | 827 | } |
828 | 828 | else |
829 | 829 | { |
830 | - $sub_condition = ' and ( '.implode(' and ',$sub_cond).' )'; |
|
830 | + $sub_condition = ' and ( '.implode(' and ', $sub_cond).' )'; |
|
831 | 831 | } |
832 | 832 | } |
833 | - return $select . ' ' . $from . ' ' . $where .$sub_condition. ' ' . $groupBy . ' ' . $orderBy; |
|
833 | + return $select.' '.$from.' '.$where.$sub_condition.' '.$groupBy.' '.$orderBy; |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | /** |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | { |
846 | 846 | $query = $this->getSelectSql($queryObject, true, $connection); |
847 | 847 | |
848 | - if(strpos($query, "substr")) |
|
848 | + if (strpos($query, "substr")) |
|
849 | 849 | { |
850 | 850 | $query = str_replace("substr", "substring", $query); |
851 | 851 | } |
@@ -853,10 +853,10 @@ discard block |
||
853 | 853 | // TODO Decide if we continue to pass parameters like this |
854 | 854 | $this->param = $queryObject->getArguments(); |
855 | 855 | |
856 | - $query .= (__DEBUG_QUERY__ & 1 && $output->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
856 | + $query .= (__DEBUG_QUERY__ & 1 && $output->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
857 | 857 | $result = $this->_query($query, $connection); |
858 | 858 | |
859 | - if($this->isError()) |
|
859 | + if ($this->isError()) |
|
860 | 860 | { |
861 | 861 | return $this->queryError($queryObject); |
862 | 862 | } |
@@ -884,9 +884,9 @@ discard block |
||
884 | 884 | function queryError($queryObject) |
885 | 885 | { |
886 | 886 | $limit = $queryObject->getLimit(); |
887 | - if($limit && $limit->isPageHandler()) |
|
887 | + if ($limit && $limit->isPageHandler()) |
|
888 | 888 | { |
889 | - $buff = new Object (); |
|
889 | + $buff = new Object(); |
|
890 | 890 | $buff->total_count = 0; |
891 | 891 | $buff->total_page = 0; |
892 | 892 | $buff->page = 1; |
@@ -910,52 +910,52 @@ discard block |
||
910 | 910 | function queryPageLimit($queryObject, $result, $connection) |
911 | 911 | { |
912 | 912 | $limit = $queryObject->getLimit(); |
913 | - if($limit && $limit->isPageHandler()) |
|
913 | + if ($limit && $limit->isPageHandler()) |
|
914 | 914 | { |
915 | 915 | // Total count |
916 | 916 | $temp_where = $queryObject->getWhereString(true, false); |
917 | - $count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString(), ($temp_where === '' ? '' : ' WHERE ' . $temp_where)); |
|
917 | + $count_query = sprintf('select count(*) as "count" %s %s', 'FROM '.$queryObject->getFromString(), ($temp_where === '' ? '' : ' WHERE '.$temp_where)); |
|
918 | 918 | |
919 | 919 | // Check for distinct query and if found update count query structure |
920 | 920 | $temp_select = $queryObject->getSelectString(true); |
921 | 921 | $uses_distinct = stripos($temp_select, "distinct") !== false; |
922 | 922 | $uses_groupby = $queryObject->getGroupByString() != ''; |
923 | - if($uses_distinct || $uses_groupby) |
|
923 | + if ($uses_distinct || $uses_groupby) |
|
924 | 924 | { |
925 | 925 | $count_query = sprintf('select %s %s %s %s' |
926 | 926 | , $temp_select |
927 | - , 'FROM ' . $queryObject->getFromString(true) |
|
928 | - , ($temp_where === '' ? '' : ' WHERE ' . $temp_where) |
|
929 | - , ($uses_groupby ? ' GROUP BY ' . $queryObject->getGroupByString() : '') |
|
927 | + , 'FROM '.$queryObject->getFromString(true) |
|
928 | + , ($temp_where === '' ? '' : ' WHERE '.$temp_where) |
|
929 | + , ($uses_groupby ? ' GROUP BY '.$queryObject->getGroupByString() : '') |
|
930 | 930 | ); |
931 | 931 | |
932 | 932 | // If query uses grouping or distinct, count from original select |
933 | 933 | $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query); |
934 | 934 | } |
935 | 935 | |
936 | - $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
936 | + $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
937 | 937 | $this->param = $queryObject->getArguments(); |
938 | 938 | $result_count = $this->_query($count_query, $connection); |
939 | 939 | $count_output = $this->_fetch($result_count); |
940 | 940 | $total_count = (int) $count_output->count; |
941 | 941 | |
942 | 942 | $list_count = $limit->list_count->getValue(); |
943 | - if(!$list_count) |
|
943 | + if (!$list_count) |
|
944 | 944 | { |
945 | 945 | $list_count = 20; |
946 | 946 | } |
947 | 947 | $page_count = $limit->page_count->getValue(); |
948 | - if(!$page_count) |
|
948 | + if (!$page_count) |
|
949 | 949 | { |
950 | 950 | $page_count = 10; |
951 | 951 | } |
952 | 952 | $page = $limit->page->getValue(); |
953 | - if(!$page || $page < 1) |
|
953 | + if (!$page || $page < 1) |
|
954 | 954 | { |
955 | 955 | $page = 1; |
956 | 956 | } |
957 | 957 | // Total pages |
958 | - if($total_count) |
|
958 | + if ($total_count) |
|
959 | 959 | { |
960 | 960 | $total_page = (int) (($total_count - 1) / $list_count) + 1; |
961 | 961 | } |
@@ -965,11 +965,11 @@ discard block |
||
965 | 965 | } |
966 | 966 | |
967 | 967 | // check the page variables |
968 | - if($page > $total_page) |
|
968 | + if ($page > $total_page) |
|
969 | 969 | { |
970 | 970 | // If requested page is bigger than total number of pages, return empty list |
971 | 971 | |
972 | - $buff = new Object (); |
|
972 | + $buff = new Object(); |
|
973 | 973 | $buff->total_count = $total_count; |
974 | 974 | $buff->total_page = $total_page; |
975 | 975 | $buff->page = $page; |
@@ -977,7 +977,7 @@ discard block |
||
977 | 977 | $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count); |
978 | 978 | return $buff; |
979 | 979 | |
980 | - if($queryObject->usesClickCount()) |
|
980 | + if ($queryObject->usesClickCount()) |
|
981 | 981 | { |
982 | 982 | $update_query = $this->getClickCountQuery($queryObject); |
983 | 983 | $this->_executeUpdateAct($update_query); |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | $virtual_no = $total_count - $start_count; |
990 | 990 | $data = $this->_fetch($result, $virtual_no); |
991 | 991 | |
992 | - $buff = new Object (); |
|
992 | + $buff = new Object(); |
|
993 | 993 | $buff->total_count = $total_count; |
994 | 994 | $buff->total_page = $total_page; |
995 | 995 | $buff->page = $page; |
@@ -999,7 +999,7 @@ discard block |
||
999 | 999 | else |
1000 | 1000 | { |
1001 | 1001 | $data = $this->_fetch($result); |
1002 | - $buff = new Object (); |
|
1002 | + $buff = new Object(); |
|
1003 | 1003 | $buff->data = $data; |
1004 | 1004 | } |
1005 | 1005 | return $buff; |
@@ -45,7 +45,9 @@ discard block |
||
45 | 45 | function DBMssql($auto_connect = TRUE) |
46 | 46 | { |
47 | 47 | $this->_setDBInfo(); |
48 | - if($auto_connect) $this->_connect(); |
|
48 | + if($auto_connect) { |
|
49 | + $this->_connect(); |
|
50 | + } |
|
49 | 51 | } |
50 | 52 | |
51 | 53 | /** |
@@ -123,8 +125,7 @@ discard block |
||
123 | 125 | { |
124 | 126 | return; |
125 | 127 | } |
126 | - } |
|
127 | - else |
|
128 | + } else |
|
128 | 129 | { |
129 | 130 | $this->_query("SAVE TRANS SP" . $transactionLevel, $connection); |
130 | 131 | } |
@@ -145,8 +146,7 @@ discard block |
||
145 | 146 | if($point) |
146 | 147 | { |
147 | 148 | $this->_query("ROLLBACK TRANS SP" . $point, $connection); |
148 | - } |
|
149 | - else |
|
149 | + } else |
|
150 | 150 | { |
151 | 151 | sqlsrv_rollback($connection); |
152 | 152 | } |
@@ -190,13 +190,11 @@ discard block |
||
190 | 190 | if(is_array($value)) |
191 | 191 | { |
192 | 192 | $_param = array_merge($_param, $value); |
193 | - } |
|
194 | - else |
|
193 | + } else |
|
195 | 194 | { |
196 | 195 | $_param[] = $o->getUnescapedValue(); |
197 | 196 | } |
198 | - } |
|
199 | - else |
|
197 | + } else |
|
200 | 198 | { |
201 | 199 | $value = $o->getUnescapedValue(); |
202 | 200 | if(is_array($value)) |
@@ -205,8 +203,7 @@ discard block |
||
205 | 203 | { |
206 | 204 | $_param[] = array($v, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8')); |
207 | 205 | } |
208 | - } |
|
209 | - else |
|
206 | + } else |
|
210 | 207 | { |
211 | 208 | $_param[] = array($value, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8')); |
212 | 209 | } |
@@ -220,8 +217,7 @@ discard block |
||
220 | 217 | { |
221 | 218 | $args = $this->_getParametersByReference($_param); |
222 | 219 | $stmt = sqlsrv_prepare($connection, $query, $args); |
223 | - } |
|
224 | - else |
|
220 | + } else |
|
225 | 221 | { |
226 | 222 | $stmt = sqlsrv_prepare($connection, $query); |
227 | 223 | } |
@@ -229,8 +225,7 @@ discard block |
||
229 | 225 | if(!$stmt) |
230 | 226 | { |
231 | 227 | $result = false; |
232 | - } |
|
233 | - else |
|
228 | + } else |
|
234 | 229 | { |
235 | 230 | $result = sqlsrv_execute($stmt); |
236 | 231 | } |
@@ -268,8 +263,7 @@ discard block |
||
268 | 263 | $value_arg[] = &$value_copy[0]; |
269 | 264 | $value_arg[] = $value_copy[1]; |
270 | 265 | $value_arg[] = $value_copy[2]; |
271 | - } |
|
272 | - else |
|
266 | + } else |
|
273 | 267 | { |
274 | 268 | $value_arg = $value; |
275 | 269 | } |
@@ -310,8 +304,7 @@ discard block |
||
310 | 304 | if($arrayIndexEndValue) |
311 | 305 | { |
312 | 306 | $output[$arrayIndexEndValue--] = $row; |
313 | - } |
|
314 | - else |
|
307 | + } else |
|
315 | 308 | { |
316 | 309 | $output[] = $row; |
317 | 310 | } |
@@ -322,8 +315,7 @@ discard block |
||
322 | 315 | if(isset($arrayIndexEndValue)) |
323 | 316 | { |
324 | 317 | return $output; |
325 | - } |
|
326 | - else |
|
318 | + } else |
|
327 | 319 | { |
328 | 320 | return $output[0]; |
329 | 321 | } |
@@ -393,8 +385,7 @@ discard block |
||
393 | 385 | if($size) |
394 | 386 | { |
395 | 387 | $query .= sprintf(" %s(%s) ", $type, $size); |
396 | - } |
|
397 | - else |
|
388 | + } else |
|
398 | 389 | { |
399 | 390 | $query .= sprintf(" %s ", $type); |
400 | 391 | } |
@@ -567,16 +558,14 @@ discard block |
||
567 | 558 | $table_name = $this->prefix . $table_name; |
568 | 559 | $query = sprintf('create table %s ( sequence int identity(1,1), seq int )', $table_name); |
569 | 560 | return $this->_query($query); |
570 | - } |
|
571 | - else |
|
561 | + } else |
|
572 | 562 | { |
573 | 563 | $table_name = $this->prefix . $table_name; |
574 | 564 | |
575 | 565 | if(!is_array($xml_obj->table->column)) |
576 | 566 | { |
577 | 567 | $columns[] = $xml_obj->table->column; |
578 | - } |
|
579 | - else |
|
568 | + } else |
|
580 | 569 | { |
581 | 570 | $columns = $xml_obj->table->column; |
582 | 571 | } |
@@ -603,12 +592,10 @@ discard block |
||
603 | 592 | if($primary_key) |
604 | 593 | { |
605 | 594 | $primary_list[] = $name; |
606 | - } |
|
607 | - else if($unique) |
|
595 | + } else if($unique) |
|
608 | 596 | { |
609 | 597 | $unique_list[$unique][] = $name; |
610 | - } |
|
611 | - else if($index) |
|
598 | + } else if($index) |
|
612 | 599 | { |
613 | 600 | $index_list[$index][] = $name; |
614 | 601 | } |
@@ -757,8 +744,7 @@ discard block |
||
757 | 744 | if($limit != '') |
758 | 745 | { |
759 | 746 | $select = $limit . ' ' . $select; |
760 | - } |
|
761 | - else |
|
747 | + } else |
|
762 | 748 | { |
763 | 749 | $select = 'SELECT ' . $select; |
764 | 750 | } |
@@ -824,8 +810,7 @@ discard block |
||
824 | 810 | if(!$where) |
825 | 811 | { |
826 | 812 | $sub_condition = ' WHERE ( '.implode(' and ',$sub_cond).' )'; |
827 | - } |
|
828 | - else |
|
813 | + } else |
|
829 | 814 | { |
830 | 815 | $sub_condition = ' and ( '.implode(' and ',$sub_cond).' )'; |
831 | 816 | } |
@@ -859,8 +844,7 @@ discard block |
||
859 | 844 | if($this->isError()) |
860 | 845 | { |
861 | 846 | return $this->queryError($queryObject); |
862 | - } |
|
863 | - else |
|
847 | + } else |
|
864 | 848 | { |
865 | 849 | return $this->queryPageLimit($queryObject, $result, $connection); |
866 | 850 | } |
@@ -893,8 +877,7 @@ discard block |
||
893 | 877 | $buff->data = array(); |
894 | 878 | $buff->page_navigation = new PageHandler(/* $total_count */0, /* $total_page */1, /* $page */1, /* $page_count */10); //default page handler values |
895 | 879 | return $buff; |
896 | - } |
|
897 | - else |
|
880 | + } else |
|
898 | 881 | { |
899 | 882 | return; |
900 | 883 | } |
@@ -958,8 +941,7 @@ discard block |
||
958 | 941 | if($total_count) |
959 | 942 | { |
960 | 943 | $total_page = (int) (($total_count - 1) / $list_count) + 1; |
961 | - } |
|
962 | - else |
|
944 | + } else |
|
963 | 945 | { |
964 | 946 | $total_page = 1; |
965 | 947 | } |
@@ -995,8 +977,7 @@ discard block |
||
995 | 977 | $buff->page = $page; |
996 | 978 | $buff->data = $data; |
997 | 979 | $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count); |
998 | - } |
|
999 | - else |
|
980 | + } else |
|
1000 | 981 | { |
1001 | 982 | $data = $this->_fetch($result); |
1002 | 983 | $buff = new Object (); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | /** |
112 | 112 | * DB transaction start |
113 | 113 | * this method is private |
114 | - * @return boolean |
|
114 | + * @return null|boolean |
|
115 | 115 | */ |
116 | 116 | function _begin($transactionLevel = 0) |
117 | 117 | { |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * this method is private |
171 | 171 | * @param string $query |
172 | 172 | * @param resource $connection |
173 | - * @return resource|boolean Returns a statement resource on success and FALSE if an error occurred. |
|
173 | + * @return resource Returns a statement resource on success and FALSE if an error occurred. |
|
174 | 174 | */ |
175 | 175 | function __query($query, $connection) |
176 | 176 | { |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * @param int $size column size |
376 | 376 | * @param string|int $default default value |
377 | 377 | * @param boolean $notnull not null status, default value is false |
378 | - * @return void |
|
378 | + * @return null|resource |
|
379 | 379 | */ |
380 | 380 | function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = null, $notnull = false) |
381 | 381 | { |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | * Check column exist status of the table |
432 | 432 | * @param string $table_name table name |
433 | 433 | * @param string $column_name column name |
434 | - * @return boolean |
|
434 | + * @return null|boolean |
|
435 | 435 | */ |
436 | 436 | function isColumnExists($table_name, $column_name) |
437 | 437 | { |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | * Check index status of the table |
496 | 496 | * @param string $table_name table name |
497 | 497 | * @param string $index_name index name |
498 | - * @return boolean |
|
498 | + * @return null|boolean |
|
499 | 499 | */ |
500 | 500 | function isIndexExists($table_name, $index_name) |
501 | 501 | { |
@@ -728,6 +728,7 @@ discard block |
||
728 | 728 | * Return select query string |
729 | 729 | * @param object $query |
730 | 730 | * @param boolean $with_values |
731 | + * @param resource $connection |
|
731 | 732 | * @return string |
732 | 733 | */ |
733 | 734 | function getSelectSql($query, $with_values = TRUE, $connection=NULL) |
@@ -839,7 +840,7 @@ discard block |
||
839 | 840 | * it supports a method as navigation |
840 | 841 | * @param Object $queryObject |
841 | 842 | * @param resource $connection |
842 | - * @return Object |
|
843 | + * @return Object|null |
|
843 | 844 | */ |
844 | 845 | function _executeSelectAct($queryObject, $connection = null) |
845 | 846 | { |
@@ -879,7 +880,7 @@ discard block |
||
879 | 880 | /** |
880 | 881 | * If have a error, return error object |
881 | 882 | * @param Object $queryObject |
882 | - * @return Object |
|
883 | + * @return Object|null |
|
883 | 884 | */ |
884 | 885 | function queryError($queryObject) |
885 | 886 | { |
@@ -394,7 +394,7 @@ |
||
394 | 394 | * Arrage css index |
395 | 395 | * |
396 | 396 | * @param string $dirName First directory name of css path |
397 | - * @param array $file file info. |
|
397 | + * @param stdClass $file file info. |
|
398 | 398 | * @return void |
399 | 399 | */ |
400 | 400 | function _arrangeCssIndex($dirName, &$file) |
@@ -50,7 +50,7 @@ |
||
50 | 50 | * Check SSL |
51 | 51 | * |
52 | 52 | * @return bool If using ssl returns true, otherwise returns false. |
53 | - * @deprecated |
|
53 | + * @deprecated |
|
54 | 54 | */ |
55 | 55 | function isSsl() |
56 | 56 | { |
@@ -108,15 +108,13 @@ discard block |
||
108 | 108 | $mapIndex = &$this->cssMapIndex; |
109 | 109 | |
110 | 110 | $this->_arrangeCssIndex($pathInfo['dirname'], $file); |
111 | - } |
|
112 | - else if($file->fileExtension == 'js') |
|
111 | + } else if($file->fileExtension == 'js') |
|
113 | 112 | { |
114 | 113 | if($args[1] == 'body') |
115 | 114 | { |
116 | 115 | $map = &$this->jsBodyMap; |
117 | 116 | $mapIndex = &$this->jsBodyMapIndex; |
118 | - } |
|
119 | - else |
|
117 | + } else |
|
120 | 118 | { |
121 | 119 | $map = &$this->jsHeadMap; |
122 | 120 | $mapIndex = &$this->jsHeadMapIndex; |
@@ -174,8 +172,7 @@ discard block |
||
174 | 172 | { |
175 | 173 | $file->fileName = $minifiedFileName; |
176 | 174 | } |
177 | - } |
|
178 | - else |
|
175 | + } else |
|
179 | 176 | { |
180 | 177 | // Remove .min |
181 | 178 | if(file_exists(implode('/', array($file->fileRealPath, $file->keyName)))) |
@@ -195,8 +192,7 @@ discard block |
||
195 | 192 | $file->media = 'all'; |
196 | 193 | } |
197 | 194 | $file->key = $file->filePath . $file->keyName . "\t" . $file->targetIe . "\t" . $file->media; |
198 | - } |
|
199 | - else if($file->fileExtension == 'js') |
|
195 | + } else if($file->fileExtension == 'js') |
|
200 | 196 | { |
201 | 197 | $file->key = $file->filePath . $file->keyName . "\t" . $file->targetIe; |
202 | 198 | } |
@@ -223,8 +219,7 @@ discard block |
||
223 | 219 | $index = $this->cssMapIndex[$file->key]; |
224 | 220 | unset($this->cssMap[$index][$file->key], $this->cssMapIndex[$file->key]); |
225 | 221 | } |
226 | - } |
|
227 | - else |
|
222 | + } else |
|
228 | 223 | { |
229 | 224 | if(isset($this->jsHeadMapIndex[$file->key])) |
230 | 225 | { |
@@ -286,7 +281,9 @@ discard block |
||
286 | 281 | } |
287 | 282 | if($file->query) |
288 | 283 | { |
289 | - if($query) $query .= '&'; |
|
284 | + if($query) { |
|
285 | + $query .= '&'; |
|
286 | + } |
|
290 | 287 | $query .= $file->query; |
291 | 288 | } |
292 | 289 | $query = ($query) ? '?' . $query : ''; |
@@ -315,8 +312,7 @@ discard block |
||
315 | 312 | { |
316 | 313 | $map = &$this->jsHeadMap; |
317 | 314 | $mapIndex = &$this->jsHeadMapIndex; |
318 | - } |
|
319 | - else |
|
315 | + } else |
|
320 | 316 | { |
321 | 317 | $map = &$this->jsBodyMap; |
322 | 318 | $mapIndex = &$this->jsBodyMapIndex; |
@@ -336,7 +332,9 @@ discard block |
||
336 | 332 | } |
337 | 333 | if($file->query) |
338 | 334 | { |
339 | - if($query) $query .= '&'; |
|
335 | + if($query) { |
|
336 | + $query .= '&'; |
|
337 | + } |
|
340 | 338 | $query .= $file->query; |
341 | 339 | } |
342 | 340 | $query = ($query) ? '?' . $query : ''; |
@@ -375,8 +373,7 @@ discard block |
||
375 | 373 | if(strpos($path, '://') === FALSE && $path{0} != '/' && $path{0} != '.') |
376 | 374 | { |
377 | 375 | $path = './' . $path; |
378 | - } |
|
379 | - elseif(!strncmp($path, '//', 2)) |
|
376 | + } elseif(!strncmp($path, '//', 2)) |
|
380 | 377 | { |
381 | 378 | return preg_replace('#^//+#', '//', $path); |
382 | 379 | } |
@@ -407,13 +404,11 @@ discard block |
||
407 | 404 | if($script_path == '/' || $script_path == '\\') |
408 | 405 | { |
409 | 406 | $path = '/' . substr($path, 2); |
410 | - } |
|
411 | - else |
|
407 | + } else |
|
412 | 408 | { |
413 | 409 | $path = $script_path . substr($path, 2); |
414 | 410 | } |
415 | - } |
|
416 | - else if(strpos($file, '../') === 0) |
|
411 | + } else if(strpos($file, '../') === 0) |
|
417 | 412 | { |
418 | 413 | $path = $this->_normalizeFilePath($script_path . $path); |
419 | 414 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | function isSsl() |
56 | 56 | { |
57 | - if(!is_null(self::$isSSL)) |
|
57 | + if (!is_null(self::$isSSL)) |
|
58 | 58 | { |
59 | 59 | return self::$isSSL; |
60 | 60 | } |
@@ -88,30 +88,30 @@ discard block |
||
88 | 88 | * */ |
89 | 89 | function loadFile($args) |
90 | 90 | { |
91 | - if(!is_array($args)) |
|
91 | + if (!is_array($args)) |
|
92 | 92 | { |
93 | 93 | $args = array($args); |
94 | 94 | } |
95 | 95 | $file = $this->getFileInfo($args[0], $args[2], $args[1]); |
96 | 96 | |
97 | 97 | $availableExtension = array('css' => 1, 'js' => 1); |
98 | - if(!isset($availableExtension[$file->fileExtension])) |
|
98 | + if (!isset($availableExtension[$file->fileExtension])) |
|
99 | 99 | { |
100 | 100 | return; |
101 | 101 | } |
102 | 102 | |
103 | 103 | $file->index = (int) $args[3]; |
104 | 104 | |
105 | - if($file->fileExtension == 'css') |
|
105 | + if ($file->fileExtension == 'css') |
|
106 | 106 | { |
107 | 107 | $map = &$this->cssMap; |
108 | 108 | $mapIndex = &$this->cssMapIndex; |
109 | 109 | |
110 | 110 | $this->_arrangeCssIndex($pathInfo['dirname'], $file); |
111 | 111 | } |
112 | - else if($file->fileExtension == 'js') |
|
112 | + else if ($file->fileExtension == 'js') |
|
113 | 113 | { |
114 | - if($args[1] == 'body') |
|
114 | + if ($args[1] == 'body') |
|
115 | 115 | { |
116 | 116 | $map = &$this->jsBodyMap; |
117 | 117 | $mapIndex = &$this->jsBodyMapIndex; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | (is_null($file->index)) ? $file->index = 0 : $file->index = $file->index; |
127 | - if(!isset($mapIndex[$file->key]) || $mapIndex[$file->key] > $file->index) |
|
127 | + if (!isset($mapIndex[$file->key]) || $mapIndex[$file->key] > $file->index) |
|
128 | 128 | { |
129 | 129 | $this->unloadFile($args[0], $args[2], $args[1]); |
130 | 130 | $map[$file->index][$file->key] = $file; |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | { |
145 | 145 | static $existsInfo = array(); |
146 | 146 | |
147 | - if(isset($existsInfo[$existsKey])) |
|
147 | + if (isset($existsInfo[$existsKey])) |
|
148 | 148 | { |
149 | 149 | return $existsInfo[$existsKey]; |
150 | 150 | } |
151 | 151 | |
152 | 152 | $fileName = preg_replace('/(?:[\/]{3,})(.*)/', '//$1', $fileName); |
153 | 153 | $url_info = parse_url($fileName); |
154 | - $pathInfo = pathinfo(str_replace('?' . $url_info['query'], '', $fileName)); |
|
154 | + $pathInfo = pathinfo(str_replace('?'.$url_info['query'], '', $fileName)); |
|
155 | 155 | |
156 | 156 | $file = new stdClass(); |
157 | 157 | $file->fileName = basename($url_info['path']); |
@@ -164,14 +164,14 @@ discard block |
||
164 | 164 | $file->keyName = implode('.', array($file->fileNameNoExt, $file->fileExtension)); |
165 | 165 | $file->cdnPath = $this->_normalizeFilePath($pathInfo['dirname']); |
166 | 166 | |
167 | - if(!$file->external) |
|
167 | + if (!$file->external) |
|
168 | 168 | { |
169 | - if(!__DEBUG__ && __XE_VERSION_STABLE__) |
|
169 | + if (!__DEBUG__ && __XE_VERSION_STABLE__) |
|
170 | 170 | { |
171 | 171 | // if no debug mode, load minifed file |
172 | 172 | $minifiedFileName = implode('.', array($file->fileNameNoExt, 'min', $file->fileExtension)); |
173 | 173 | $minifiedRealPath = implode('/', array($file->fileRealPath, $minifiedFileName)); |
174 | - if(file_exists($minifiedRealPath)) |
|
174 | + if (file_exists($minifiedRealPath)) |
|
175 | 175 | { |
176 | 176 | $file->fileName = $minifiedFileName; |
177 | 177 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | else |
180 | 180 | { |
181 | 181 | // Remove .min |
182 | - if(file_exists(implode('/', array($file->fileRealPath, $file->keyName)))) |
|
182 | + if (file_exists(implode('/', array($file->fileRealPath, $file->keyName)))) |
|
183 | 183 | { |
184 | 184 | $file->fileName = $file->keyName; |
185 | 185 | } |
@@ -188,18 +188,18 @@ discard block |
||
188 | 188 | |
189 | 189 | $file->targetIe = $targetIe; |
190 | 190 | |
191 | - if($file->fileExtension == 'css') |
|
191 | + if ($file->fileExtension == 'css') |
|
192 | 192 | { |
193 | 193 | $file->media = $media; |
194 | - if(!$file->media) |
|
194 | + if (!$file->media) |
|
195 | 195 | { |
196 | 196 | $file->media = 'all'; |
197 | 197 | } |
198 | - $file->key = $file->filePath . $file->keyName . "\t" . $file->targetIe . "\t" . $file->media; |
|
198 | + $file->key = $file->filePath.$file->keyName."\t".$file->targetIe."\t".$file->media; |
|
199 | 199 | } |
200 | - else if($file->fileExtension == 'js') |
|
200 | + else if ($file->fileExtension == 'js') |
|
201 | 201 | { |
202 | - $file->key = $file->filePath . $file->keyName . "\t" . $file->targetIe; |
|
202 | + $file->key = $file->filePath.$file->keyName."\t".$file->targetIe; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | return $file; |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | { |
218 | 218 | $file = $this->getFileInfo($fileName, $targetIe, $media); |
219 | 219 | |
220 | - if($file->fileExtension == 'css') |
|
220 | + if ($file->fileExtension == 'css') |
|
221 | 221 | { |
222 | - if(isset($this->cssMapIndex[$file->key])) |
|
222 | + if (isset($this->cssMapIndex[$file->key])) |
|
223 | 223 | { |
224 | 224 | $index = $this->cssMapIndex[$file->key]; |
225 | 225 | unset($this->cssMap[$index][$file->key], $this->cssMapIndex[$file->key]); |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | } |
228 | 228 | else |
229 | 229 | { |
230 | - if(isset($this->jsHeadMapIndex[$file->key])) |
|
230 | + if (isset($this->jsHeadMapIndex[$file->key])) |
|
231 | 231 | { |
232 | 232 | $index = $this->jsHeadMapIndex[$file->key]; |
233 | 233 | unset($this->jsHeadMap[$index][$file->key], $this->jsHeadMapIndex[$file->key]); |
234 | 234 | } |
235 | - if(isset($this->jsBodyMapIndex[$file->key])) |
|
235 | + if (isset($this->jsBodyMapIndex[$file->key])) |
|
236 | 236 | { |
237 | 237 | $index = $this->jsBodyMapIndex[$file->key]; |
238 | 238 | unset($this->jsBodyMap[$index][$file->key], $this->jsBodyMapIndex[$file->key]); |
@@ -248,13 +248,13 @@ discard block |
||
248 | 248 | */ |
249 | 249 | function unloadAllFiles($type = 'all') |
250 | 250 | { |
251 | - if($type == 'css' || $type == 'all') |
|
251 | + if ($type == 'css' || $type == 'all') |
|
252 | 252 | { |
253 | 253 | $this->cssMap = array(); |
254 | 254 | $this->cssMapIndex = array(); |
255 | 255 | } |
256 | 256 | |
257 | - if($type == 'js' || $type == 'all') |
|
257 | + if ($type == 'js' || $type == 'all') |
|
258 | 258 | { |
259 | 259 | $this->jsHeadMap = array(); |
260 | 260 | $this->jsBodyMap = array(); |
@@ -276,23 +276,23 @@ discard block |
||
276 | 276 | $this->_sortMap($map, $mapIndex); |
277 | 277 | |
278 | 278 | $result = array(); |
279 | - foreach($map as $indexedMap) |
|
279 | + foreach ($map as $indexedMap) |
|
280 | 280 | { |
281 | - foreach($indexedMap as $file) |
|
281 | + foreach ($indexedMap as $file) |
|
282 | 282 | { |
283 | 283 | $query = ''; |
284 | - if(!$file->external && is_readable($file->cdnPath . '/' . $file->fileName)) |
|
284 | + if (!$file->external && is_readable($file->cdnPath.'/'.$file->fileName)) |
|
285 | 285 | { |
286 | - $query = date('YmdHis', filemtime($file->cdnPath . '/' . $file->fileName)); |
|
286 | + $query = date('YmdHis', filemtime($file->cdnPath.'/'.$file->fileName)); |
|
287 | 287 | } |
288 | - if($file->query) |
|
288 | + if ($file->query) |
|
289 | 289 | { |
290 | - if($query) $query .= '&'; |
|
290 | + if ($query) $query .= '&'; |
|
291 | 291 | $query .= $file->query; |
292 | 292 | } |
293 | - $query = ($query) ? '?' . $query : ''; |
|
293 | + $query = ($query) ? '?'.$query : ''; |
|
294 | 294 | |
295 | - $fullFilePath = $file->filePath . '/' . $file->fileName . $query; |
|
295 | + $fullFilePath = $file->filePath.'/'.$file->fileName.$query; |
|
296 | 296 | $result[] = array( |
297 | 297 | 'file' => $fullFilePath, |
298 | 298 | 'media' => $file->media, |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | */ |
313 | 313 | function getJsFileList($type = 'head') |
314 | 314 | { |
315 | - if($type == 'head') |
|
315 | + if ($type == 'head') |
|
316 | 316 | { |
317 | 317 | $map = &$this->jsHeadMap; |
318 | 318 | $mapIndex = &$this->jsHeadMapIndex; |
@@ -326,23 +326,23 @@ discard block |
||
326 | 326 | $this->_sortMap($map, $mapIndex); |
327 | 327 | |
328 | 328 | $result = array(); |
329 | - foreach($map as $indexedMap) |
|
329 | + foreach ($map as $indexedMap) |
|
330 | 330 | { |
331 | - foreach($indexedMap as $file) |
|
331 | + foreach ($indexedMap as $file) |
|
332 | 332 | { |
333 | 333 | $query = ''; |
334 | - if(!$file->external && is_readable($file->cdnPath . '/' . $file->fileName)) |
|
334 | + if (!$file->external && is_readable($file->cdnPath.'/'.$file->fileName)) |
|
335 | 335 | { |
336 | - $query = date('YmdHis', filemtime($file->cdnPath . '/' . $file->fileName)); |
|
336 | + $query = date('YmdHis', filemtime($file->cdnPath.'/'.$file->fileName)); |
|
337 | 337 | } |
338 | - if($file->query) |
|
338 | + if ($file->query) |
|
339 | 339 | { |
340 | - if($query) $query .= '&'; |
|
340 | + if ($query) $query .= '&'; |
|
341 | 341 | $query .= $file->query; |
342 | 342 | } |
343 | - $query = ($query) ? '?' . $query : ''; |
|
343 | + $query = ($query) ? '?'.$query : ''; |
|
344 | 344 | |
345 | - $fullFilePath = $file->filePath . '/' . $file->fileName . $query; |
|
345 | + $fullFilePath = $file->filePath.'/'.$file->fileName.$query; |
|
346 | 346 | $result[] = array( |
347 | 347 | 'file' => $fullFilePath, |
348 | 348 | 'targetie' => $file->targetIe |
@@ -373,18 +373,18 @@ discard block |
||
373 | 373 | */ |
374 | 374 | function _normalizeFilePath($path) |
375 | 375 | { |
376 | - if(strpos($path, '://') === FALSE && $path{0} != '/' && $path{0} != '.') |
|
376 | + if (strpos($path, '://') === FALSE && $path{0} != '/' && $path{0} != '.') |
|
377 | 377 | { |
378 | - $path = './' . $path; |
|
378 | + $path = './'.$path; |
|
379 | 379 | } |
380 | - elseif(!strncmp($path, '//', 2)) |
|
380 | + elseif (!strncmp($path, '//', 2)) |
|
381 | 381 | { |
382 | 382 | return preg_replace('#^//+#', '//', $path); |
383 | 383 | } |
384 | 384 | |
385 | 385 | $path = preg_replace('@/\./|(?<!:)\/\/@', '/', $path); |
386 | 386 | |
387 | - while(strpos($path, '/../')) |
|
387 | + while (strpos($path, '/../')) |
|
388 | 388 | { |
389 | 389 | $path = preg_replace('/\/([^\/]+)\/\.\.\//s', '/', $path, 1); |
390 | 390 | } |
@@ -403,20 +403,20 @@ discard block |
||
403 | 403 | $path = $this->_normalizeFilePath($path); |
404 | 404 | $script_path = getScriptPath(); |
405 | 405 | |
406 | - if(strpos($path, './') === 0) |
|
406 | + if (strpos($path, './') === 0) |
|
407 | 407 | { |
408 | - if($script_path == '/' || $script_path == '\\') |
|
408 | + if ($script_path == '/' || $script_path == '\\') |
|
409 | 409 | { |
410 | - $path = '/' . substr($path, 2); |
|
410 | + $path = '/'.substr($path, 2); |
|
411 | 411 | } |
412 | 412 | else |
413 | 413 | { |
414 | - $path = $script_path . substr($path, 2); |
|
414 | + $path = $script_path.substr($path, 2); |
|
415 | 415 | } |
416 | 416 | } |
417 | - else if(strpos($file, '../') === 0) |
|
417 | + else if (strpos($file, '../') === 0) |
|
418 | 418 | { |
419 | - $path = $this->_normalizeFilePath($script_path . $path); |
|
419 | + $path = $this->_normalizeFilePath($script_path.$path); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | return $path; |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | */ |
432 | 432 | function _arrangeCssIndex($dirName, &$file) |
433 | 433 | { |
434 | - if($file->index !== 0) |
|
434 | + if ($file->index !== 0) |
|
435 | 435 | { |
436 | 436 | return; |
437 | 437 | } |