@@ -230,16 +230,14 @@ discard block |
||
| 230 | 230 | ); |
| 231 | 231 | if(isset($http_status[$code])){ |
| 232 | 232 | $text = $http_status[$code]; |
| 233 | - } |
|
| 234 | - else{ |
|
| 233 | + } else{ |
|
| 235 | 234 | show_error('No HTTP status text found for your code please check it.'); |
| 236 | 235 | } |
| 237 | 236 | } |
| 238 | 237 | |
| 239 | 238 | if(strpos(php_sapi_name(), 'cgi') === 0){ |
| 240 | 239 | header('Status: ' . $code . ' ' . $text, TRUE); |
| 241 | - } |
|
| 242 | - else{ |
|
| 240 | + } else{ |
|
| 243 | 241 | $proto = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1'; |
| 244 | 242 | header($proto . ' ' . $code . ' ' . $text, TRUE, $code); |
| 245 | 243 | } |
@@ -281,11 +279,9 @@ discard block |
||
| 281 | 279 | */ |
| 282 | 280 | if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off'){ |
| 283 | 281 | return true; |
| 284 | - } |
|
| 285 | - else if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'){ |
|
| 282 | + } else if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'){ |
|
| 286 | 283 | return true; |
| 287 | - } |
|
| 288 | - else if(isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off'){ |
|
| 284 | + } else if(isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off'){ |
|
| 289 | 285 | return true; |
| 290 | 286 | } |
| 291 | 287 | return false; |
@@ -328,8 +324,7 @@ discard block |
||
| 328 | 324 | function php_exception_handler($ex){ |
| 329 | 325 | if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))){ |
| 330 | 326 | show_error('An exception is occured in file '. $ex->getFile() .' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception #' . $ex->getCode()); |
| 331 | - } |
|
| 332 | - else{ |
|
| 327 | + } else{ |
|
| 333 | 328 | save_to_log('error', 'An exception is occured in file ' . $ex->getFile() . ' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception'); |
| 334 | 329 | } |
| 335 | 330 | return true; |
@@ -452,15 +447,13 @@ discard block |
||
| 452 | 447 | function clean_input($str){ |
| 453 | 448 | if(is_array($str)){ |
| 454 | 449 | $str = array_map('clean_input', $str); |
| 455 | - } |
|
| 456 | - else if(is_object($str)){ |
|
| 450 | + } else if(is_object($str)){ |
|
| 457 | 451 | $obj = $str; |
| 458 | 452 | foreach ($str as $var => $value) { |
| 459 | 453 | $obj->$var = clean_input($value); |
| 460 | 454 | } |
| 461 | 455 | $str = $obj; |
| 462 | - } |
|
| 463 | - else{ |
|
| 456 | + } else{ |
|
| 464 | 457 | $str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8'); |
| 465 | 458 | } |
| 466 | 459 | return $str; |
@@ -533,8 +526,7 @@ discard block |
||
| 533 | 526 | session_save_path($sessionSavePath); |
| 534 | 527 | $logger->info('Session save path: ' . $sessionSavePath); |
| 535 | 528 | } |
| 536 | - } |
|
| 537 | - else if($sessionHandler == 'database'){ |
|
| 529 | + } else if($sessionHandler == 'database'){ |
|
| 538 | 530 | //load database session handle library |
| 539 | 531 | //Model |
| 540 | 532 | require_once CORE_CLASSES_MODEL_PATH . 'Model.php'; |
@@ -545,8 +537,7 @@ discard block |
||
| 545 | 537 | $DBS =& class_loader('DBSessionHandler', 'classes'); |
| 546 | 538 | session_set_save_handler($DBS, true); |
| 547 | 539 | $logger->info('session save path: ' . get_config('session_save_path')); |
| 548 | - } |
|
| 549 | - else{ |
|
| 540 | + } else{ |
|
| 550 | 541 | show_error('Invalid session handler configuration'); |
| 551 | 542 | } |
| 552 | 543 | $lifetime = get_config('session_cookie_lifetime', 0); |
@@ -59,8 +59,7 @@ discard block |
||
| 59 | 59 | if(! isset($this->listeners[$eventName])){ |
| 60 | 60 | $this->logger->info('This event does not have the registered event listener before, adding new one'); |
| 61 | 61 | $this->listeners[$eventName] = array(); |
| 62 | - } |
|
| 63 | - else{ |
|
| 62 | + } else{ |
|
| 64 | 63 | $this->logger->info('This event already have the registered listener, add this listener to the list'); |
| 65 | 64 | } |
| 66 | 65 | $this->listeners[$eventName][] = $listener; |
@@ -78,12 +77,10 @@ discard block |
||
| 78 | 77 | if(false !== $index = array_search($listener, $this->listeners[$eventName], true)){ |
| 79 | 78 | $this->logger->info('Found the listener at index [' .$index. '] remove it'); |
| 80 | 79 | unset($this->listeners[$eventName][$index]); |
| 81 | - } |
|
| 82 | - else{ |
|
| 80 | + } else{ |
|
| 83 | 81 | $this->logger->info('Cannot found this listener in the event listener list'); |
| 84 | 82 | } |
| 85 | - } |
|
| 86 | - else{ |
|
| 83 | + } else{ |
|
| 87 | 84 | $this->logger->info('This event does not have this listener ignore remove'); |
| 88 | 85 | } |
| 89 | 86 | } |
@@ -98,8 +95,7 @@ discard block |
||
| 98 | 95 | if($eventName !== null && isset($this->listeners[$eventName])){ |
| 99 | 96 | $this->logger->info('The Event name is set of exist in the listener just remove all Event Listener for this event'); |
| 100 | 97 | unset($this->listeners[$eventName]); |
| 101 | - } |
|
| 102 | - else{ |
|
| 98 | + } else{ |
|
| 103 | 99 | $this->logger->info('The Event name is not set or does not exist in the listener, so remove all Event Listener'); |
| 104 | 100 | $this->listeners = array(); |
| 105 | 101 | } |
@@ -132,8 +128,7 @@ discard block |
||
| 132 | 128 | if($event->returnBack){ |
| 133 | 129 | $this->logger->info('This event need return back, return the result for future use'); |
| 134 | 130 | return $this->dispatchToListerners($event); |
| 135 | - } |
|
| 136 | - else{ |
|
| 131 | + } else{ |
|
| 137 | 132 | $this->logger->info('This event no need return back the result, just dispatch it'); |
| 138 | 133 | $this->dispatchToListerners($event); |
| 139 | 134 | } |
@@ -153,8 +148,7 @@ discard block |
||
| 153 | 148 | return $event; |
| 154 | 149 | } |
| 155 | 150 | return; |
| 156 | - } |
|
| 157 | - else{ |
|
| 151 | + } else{ |
|
| 158 | 152 | $this->logger->info('Found the registered Event listener for the event [' .$event->name. '] the list are: ' . stringfy_vars($list)); |
| 159 | 153 | } |
| 160 | 154 | foreach($list as $listener){ |
@@ -162,12 +156,10 @@ discard block |
||
| 162 | 156 | $returnedEvent = call_user_func_array($listener, array($event)); |
| 163 | 157 | if($returnedEvent instanceof Event){ |
| 164 | 158 | $event = $returnedEvent; |
| 165 | - } |
|
| 166 | - else{ |
|
| 159 | + } else{ |
|
| 167 | 160 | show_error('This event [' .$event->name. '] need you return the event object after processing'); |
| 168 | 161 | } |
| 169 | - } |
|
| 170 | - else{ |
|
| 162 | + } else{ |
|
| 171 | 163 | call_user_func_array($listener, array($event)); |
| 172 | 164 | } |
| 173 | 165 | if($event->stop){ |
@@ -143,8 +143,7 @@ discard block |
||
| 143 | 143 | public function __construct(Database $db = null){ |
| 144 | 144 | if(is_object($db)){ |
| 145 | 145 | $this->setDatabaseInstance($db); |
| 146 | - } |
|
| 147 | - else{ |
|
| 146 | + } else{ |
|
| 148 | 147 | $obj = & get_instance(); |
| 149 | 148 | if(isset($obj->database) && is_object($obj->database)){ |
| 150 | 149 | /** |
@@ -256,8 +255,7 @@ discard block |
||
| 256 | 255 | $insert_id = $this->_database->insertId(); |
| 257 | 256 | $this->trigger('after_create', $insert_id); |
| 258 | 257 | return $insert_id; |
| 259 | - } |
|
| 260 | - else |
|
| 258 | + } else |
|
| 261 | 259 | { |
| 262 | 260 | return FALSE; |
| 263 | 261 | } |
@@ -294,8 +292,7 @@ discard block |
||
| 294 | 292 | ->update($data, $escape); |
| 295 | 293 | $this->trigger('after_update', array($data, $result)); |
| 296 | 294 | return $result; |
| 297 | - } |
|
| 298 | - else |
|
| 295 | + } else |
|
| 299 | 296 | { |
| 300 | 297 | return FALSE; |
| 301 | 298 | } |
@@ -318,8 +315,7 @@ discard block |
||
| 318 | 315 | ->update($data, $escape); |
| 319 | 316 | $this->trigger('after_update', array($data, $result)); |
| 320 | 317 | return $result; |
| 321 | - } |
|
| 322 | - else |
|
| 318 | + } else |
|
| 323 | 319 | { |
| 324 | 320 | return FALSE; |
| 325 | 321 | } |
@@ -336,8 +332,7 @@ discard block |
||
| 336 | 332 | if(is_array($args[1])){ |
| 337 | 333 | $data = array_pop($args); |
| 338 | 334 | } |
| 339 | - } |
|
| 340 | - else if(count($args) == 3){ |
|
| 335 | + } else if(count($args) == 3){ |
|
| 341 | 336 | if(is_array($args[2])){ |
| 342 | 337 | $data = array_pop($args); |
| 343 | 338 | } |
@@ -349,8 +344,7 @@ discard block |
||
| 349 | 344 | $result = $this->_database->from($this->_table)->update($data); |
| 350 | 345 | $this->trigger('after_update', array($data, $result)); |
| 351 | 346 | return $result; |
| 352 | - } |
|
| 353 | - else |
|
| 347 | + } else |
|
| 354 | 348 | { |
| 355 | 349 | return FALSE; |
| 356 | 350 | } |
@@ -377,8 +371,7 @@ discard block |
||
| 377 | 371 | if ($this->soft_delete) |
| 378 | 372 | { |
| 379 | 373 | $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE )); |
| 380 | - } |
|
| 381 | - else |
|
| 374 | + } else |
|
| 382 | 375 | { |
| 383 | 376 | $result = $this->_database->from($this->_table)->delete(); |
| 384 | 377 | } |
@@ -398,8 +391,7 @@ discard block |
||
| 398 | 391 | if ($this->soft_delete) |
| 399 | 392 | { |
| 400 | 393 | $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE )); |
| 401 | - } |
|
| 402 | - else |
|
| 394 | + } else |
|
| 403 | 395 | { |
| 404 | 396 | $result = $this->_database->from($this->_table)->delete(); |
| 405 | 397 | } |
@@ -417,8 +409,7 @@ discard block |
||
| 417 | 409 | if ($this->soft_delete) |
| 418 | 410 | { |
| 419 | 411 | $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE )); |
| 420 | - } |
|
| 421 | - else |
|
| 412 | + } else |
|
| 422 | 413 | { |
| 423 | 414 | $result = $this->_database->from($this->_table)->delete(); |
| 424 | 415 | } |
@@ -463,8 +454,7 @@ discard block |
||
| 463 | 454 | { |
| 464 | 455 | $relationship = $value; |
| 465 | 456 | $options = array( 'primary_key' => $value . '_id', 'model' => $value . '_model' ); |
| 466 | - } |
|
| 467 | - else |
|
| 457 | + } else |
|
| 468 | 458 | { |
| 469 | 459 | $relationship = $key; |
| 470 | 460 | $options = $value; |
@@ -474,15 +464,13 @@ discard block |
||
| 474 | 464 | { |
| 475 | 465 | if(is_object($this->loaderInstance)){ |
| 476 | 466 | $this->loaderInstance->model($options['model'], $relationship . '_model'); |
| 477 | - } |
|
| 478 | - else{ |
|
| 467 | + } else{ |
|
| 479 | 468 | Loader::model($options['model'], $relationship . '_model'); |
| 480 | 469 | } |
| 481 | 470 | if (is_object($row)) |
| 482 | 471 | { |
| 483 | 472 | $row->{$relationship} = $this->{$relationship . '_model'}->get($row->{$options['primary_key']}); |
| 484 | - } |
|
| 485 | - else |
|
| 473 | + } else |
|
| 486 | 474 | { |
| 487 | 475 | $row[$relationship] = $this->{$relationship . '_model'}->get($row[$options['primary_key']]); |
| 488 | 476 | } |
@@ -495,8 +483,7 @@ discard block |
||
| 495 | 483 | { |
| 496 | 484 | $relationship = $value; |
| 497 | 485 | $options = array( 'primary_key' => $this->_table . '_id', 'model' => $value . '_model' ); |
| 498 | - } |
|
| 499 | - else |
|
| 486 | + } else |
|
| 500 | 487 | { |
| 501 | 488 | $relationship = $key; |
| 502 | 489 | $options = $value; |
@@ -506,15 +493,13 @@ discard block |
||
| 506 | 493 | { |
| 507 | 494 | if(is_object($this->loaderInstance)){ |
| 508 | 495 | $this->loaderInstance->model($options['model'], $relationship . '_model'); |
| 509 | - } |
|
| 510 | - else{ |
|
| 496 | + } else{ |
|
| 511 | 497 | Loader::model($options['model'], $relationship . '_model'); |
| 512 | 498 | } |
| 513 | 499 | if (is_object($row)) |
| 514 | 500 | { |
| 515 | 501 | $row->{$relationship} = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row->{$this->primary_key}); |
| 516 | - } |
|
| 517 | - else |
|
| 502 | + } else |
|
| 518 | 503 | { |
| 519 | 504 | $row[$relationship] = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row[$this->primary_key]); |
| 520 | 505 | } |
@@ -536,8 +521,7 @@ discard block |
||
| 536 | 521 | if(count($args) == 2) |
| 537 | 522 | { |
| 538 | 523 | list($key, $value) = $args; |
| 539 | - } |
|
| 540 | - else |
|
| 524 | + } else |
|
| 541 | 525 | { |
| 542 | 526 | $key = $this->primary_key; |
| 543 | 527 | $value = $args[0]; |
@@ -685,8 +669,7 @@ discard block |
||
| 685 | 669 | if (is_object($row)) |
| 686 | 670 | { |
| 687 | 671 | $row->created_at = date('Y-m-d H:i:s'); |
| 688 | - } |
|
| 689 | - else |
|
| 672 | + } else |
|
| 690 | 673 | { |
| 691 | 674 | $row['created_at'] = date('Y-m-d H:i:s'); |
| 692 | 675 | } |
@@ -699,8 +682,7 @@ discard block |
||
| 699 | 682 | if (is_object($row)) |
| 700 | 683 | { |
| 701 | 684 | $row->updated_at = date('Y-m-d H:i:s'); |
| 702 | - } |
|
| 703 | - else |
|
| 685 | + } else |
|
| 704 | 686 | { |
| 705 | 687 | $row['updated_at'] = date('Y-m-d H:i:s'); |
| 706 | 688 | } |
@@ -727,8 +709,7 @@ discard block |
||
| 727 | 709 | if (is_array($row)) |
| 728 | 710 | { |
| 729 | 711 | $row[$column] = unserialize($row[$column]); |
| 730 | - } |
|
| 731 | - else |
|
| 712 | + } else |
|
| 732 | 713 | { |
| 733 | 714 | $row->$column = unserialize($row->$column); |
| 734 | 715 | } |
@@ -748,8 +729,7 @@ discard block |
||
| 748 | 729 | if(isset($row->$attr)){ |
| 749 | 730 | unset($row->$attr); |
| 750 | 731 | } |
| 751 | - } |
|
| 752 | - else |
|
| 732 | + } else |
|
| 753 | 733 | { |
| 754 | 734 | if(isset($row[$attr])){ |
| 755 | 735 | unset($row[$attr]); |
@@ -828,8 +808,7 @@ discard block |
||
| 828 | 808 | { |
| 829 | 809 | $this->_database->orderBy($key, $value); |
| 830 | 810 | } |
| 831 | - } |
|
| 832 | - else |
|
| 811 | + } else |
|
| 833 | 812 | { |
| 834 | 813 | $this->_database->orderBy($criteria, $order); |
| 835 | 814 | } |
@@ -887,8 +866,7 @@ discard block |
||
| 887 | 866 | $fv = null; |
| 888 | 867 | if(is_object($this->formValidationInstance)){ |
| 889 | 868 | $fv = $this->formValidationInstance; |
| 890 | - } |
|
| 891 | - else{ |
|
| 869 | + } else{ |
|
| 892 | 870 | Loader::library('FormValidation'); |
| 893 | 871 | $fv = $this->formvalidation; |
| 894 | 872 | $this->setFormValidation($fv); |
@@ -900,13 +878,11 @@ discard block |
||
| 900 | 878 | if ($fv->run()) |
| 901 | 879 | { |
| 902 | 880 | return $data; |
| 903 | - } |
|
| 904 | - else |
|
| 881 | + } else |
|
| 905 | 882 | { |
| 906 | 883 | return FALSE; |
| 907 | 884 | } |
| 908 | - } |
|
| 909 | - else |
|
| 885 | + } else |
|
| 910 | 886 | { |
| 911 | 887 | return $data; |
| 912 | 888 | } |
@@ -925,46 +901,38 @@ discard block |
||
| 925 | 901 | if (is_array($filter)) |
| 926 | 902 | { |
| 927 | 903 | $this->_database->in($field, $filter); |
| 928 | - } |
|
| 929 | - else |
|
| 904 | + } else |
|
| 930 | 905 | { |
| 931 | 906 | if (is_int($field)) |
| 932 | 907 | { |
| 933 | 908 | $this->_database->where($filter); |
| 934 | - } |
|
| 935 | - else |
|
| 909 | + } else |
|
| 936 | 910 | { |
| 937 | 911 | $this->_database->where($field, $filter); |
| 938 | 912 | } |
| 939 | 913 | } |
| 940 | 914 | } |
| 941 | - } |
|
| 942 | - else if (count($params) == 1) |
|
| 915 | + } else if (count($params) == 1) |
|
| 943 | 916 | { |
| 944 | 917 | $this->_database->where($params[0]); |
| 945 | - } |
|
| 946 | - else if(count($params) == 2) |
|
| 918 | + } else if(count($params) == 2) |
|
| 947 | 919 | { |
| 948 | 920 | if (is_array($params[1])) |
| 949 | 921 | { |
| 950 | 922 | $this->_database->in($params[0], $params[1]); |
| 951 | - } |
|
| 952 | - else |
|
| 923 | + } else |
|
| 953 | 924 | { |
| 954 | 925 | $this->_database->where($params[0], $params[1]); |
| 955 | 926 | } |
| 956 | - } |
|
| 957 | - else if(count($params) == 3) |
|
| 927 | + } else if(count($params) == 3) |
|
| 958 | 928 | { |
| 959 | 929 | $this->_database->where($params[0], $params[1], $params[2]); |
| 960 | - } |
|
| 961 | - else |
|
| 930 | + } else |
|
| 962 | 931 | { |
| 963 | 932 | if (is_array($params[1])) |
| 964 | 933 | { |
| 965 | 934 | $this->_database->in($params[0], $params[1]); |
| 966 | - } |
|
| 967 | - else |
|
| 935 | + } else |
|
| 968 | 936 | { |
| 969 | 937 | $this->_database->where($params[0], $params[1]); |
| 970 | 938 | } |
@@ -152,8 +152,7 @@ discard block |
||
| 152 | 152 | if(! headers_sent()){ |
| 153 | 153 | header('Location: '.$url); |
| 154 | 154 | exit; |
| 155 | - } |
|
| 156 | - else{ |
|
| 155 | + } else{ |
|
| 157 | 156 | echo '<script> |
| 158 | 157 | location.href = "'.$url.'"; |
| 159 | 158 | </script>'; |
@@ -202,12 +201,10 @@ discard block |
||
| 202 | 201 | if($moduleViewPath){ |
| 203 | 202 | $path = $moduleViewPath; |
| 204 | 203 | $logger->info('Found view [' . $view . '] in module [' .$mod. '], the file path is [' .$moduleViewPath. '] we will used it'); |
| 205 | - } |
|
| 206 | - else{ |
|
| 204 | + } else{ |
|
| 207 | 205 | $logger->info('Cannot find view [' . $view . '] in module [' .$mod. '] using the default location'); |
| 208 | 206 | } |
| 209 | - } |
|
| 210 | - else{ |
|
| 207 | + } else{ |
|
| 211 | 208 | $logger->info('The current request does not use module using the default location.'); |
| 212 | 209 | } |
| 213 | 210 | } |
@@ -291,8 +288,7 @@ discard block |
||
| 291 | 288 | //compress the output if is available |
| 292 | 289 | if (self::$_canCompressOutput){ |
| 293 | 290 | ob_start('ob_gzhandler'); |
| 294 | - } |
|
| 295 | - else{ |
|
| 291 | + } else{ |
|
| 296 | 292 | ob_start(); |
| 297 | 293 | } |
| 298 | 294 | self::sendHeaders(200); |
@@ -324,8 +320,7 @@ discard block |
||
| 324 | 320 | $logger->info('The cache page content is not yet expire for the URL [' . $url . '] send 304 header to browser'); |
| 325 | 321 | self::sendHeaders(304); |
| 326 | 322 | return; |
| 327 | - } |
|
| 328 | - else{ |
|
| 323 | + } else{ |
|
| 329 | 324 | $logger->info('The cache page content is expired or the browser don\'t send the HTTP_IF_MODIFIED_SINCE header for the URL [' . $url . '] send cache headers to tell the browser'); |
| 330 | 325 | self::sendHeaders(200); |
| 331 | 326 | //get the cache content |
@@ -345,15 +340,13 @@ discard block |
||
| 345 | 340 | //compress the output if is available |
| 346 | 341 | if (self::$_canCompressOutput){ |
| 347 | 342 | ob_start('ob_gzhandler'); |
| 348 | - } |
|
| 349 | - else{ |
|
| 343 | + } else{ |
|
| 350 | 344 | ob_start(); |
| 351 | 345 | } |
| 352 | 346 | echo $content; |
| 353 | 347 | ob_end_flush(); |
| 354 | 348 | return; |
| 355 | - } |
|
| 356 | - else{ |
|
| 349 | + } else{ |
|
| 357 | 350 | $logger->info('The page cache content for the URL [' . $url . '] is not valid may be already expired'); |
| 358 | 351 | $cache->delete($pageCacheKey); |
| 359 | 352 | } |
@@ -394,16 +387,14 @@ discard block |
||
| 394 | 387 | //compress the output if is available |
| 395 | 388 | if (self::$_canCompressOutput){ |
| 396 | 389 | ob_start('ob_gzhandler'); |
| 397 | - } |
|
| 398 | - else{ |
|
| 390 | + } else{ |
|
| 399 | 391 | ob_start(); |
| 400 | 392 | } |
| 401 | 393 | require_once $path; |
| 402 | 394 | $output = ob_get_clean(); |
| 403 | 395 | self::sendHeaders(404); |
| 404 | 396 | echo $output; |
| 405 | - } |
|
| 406 | - else{ |
|
| 397 | + } else{ |
|
| 407 | 398 | show_error('The 404 view [' .$path. '] does not exist'); |
| 408 | 399 | } |
| 409 | 400 | } |
@@ -418,8 +409,7 @@ discard block |
||
| 418 | 409 | //compress the output if exists |
| 419 | 410 | if (self::$_canCompressOutput){ |
| 420 | 411 | ob_start('ob_gzhandler'); |
| 421 | - } |
|
| 422 | - else{ |
|
| 412 | + } else{ |
|
| 423 | 413 | ob_start(); |
| 424 | 414 | } |
| 425 | 415 | extract($data); |
@@ -427,8 +417,7 @@ discard block |
||
| 427 | 417 | $output = ob_get_clean(); |
| 428 | 418 | self::sendHeaders(503); |
| 429 | 419 | echo $output; |
| 430 | - } |
|
| 431 | - else{ |
|
| 420 | + } else{ |
|
| 432 | 421 | //can't use show_error() at this time because some dependencies not yet loaded and to prevent loop |
| 433 | 422 | set_http_status_header(503); |
| 434 | 423 | echo 'The error view [' . $path . '] does not exist'; |
@@ -148,8 +148,7 @@ discard block |
||
| 148 | 148 | if(isset($path[1])){ |
| 149 | 149 | $instance = strtolower($path[1]); |
| 150 | 150 | } |
| 151 | - } |
|
| 152 | - else{ |
|
| 151 | + } else{ |
|
| 153 | 152 | $instance = strtolower($class); |
| 154 | 153 | } |
| 155 | 154 | } |
@@ -169,8 +168,7 @@ discard block |
||
| 169 | 168 | $searchModuleName = $path[0]; |
| 170 | 169 | $class = ucfirst($path[1]); |
| 171 | 170 | } |
| 172 | - } |
|
| 173 | - else{ |
|
| 171 | + } else{ |
|
| 174 | 172 | $class = ucfirst($class); |
| 175 | 173 | } |
| 176 | 174 | |
@@ -181,8 +179,7 @@ discard block |
||
| 181 | 179 | if($moduleModelFilePath){ |
| 182 | 180 | $logger->info('Found model [' . $class . '] from module [' .$searchModuleName. '], the file path is [' .$moduleModelFilePath. '] we will used it'); |
| 183 | 181 | $classFilePath = $moduleModelFilePath; |
| 184 | - } |
|
| 185 | - else{ |
|
| 182 | + } else{ |
|
| 186 | 183 | $logger->info('Cannot find model [' . $class . '] from modules using the default location'); |
| 187 | 184 | } |
| 188 | 185 | $logger->info('The model file path to be loaded is [' . $classFilePath . ']'); |
@@ -194,12 +191,10 @@ discard block |
||
| 194 | 191 | $obj->{$instance} = $c; |
| 195 | 192 | static::$loaded[$instance] = $class; |
| 196 | 193 | $logger->info('Model [' . $class . '] --> ' . $classFilePath . ' loaded successfully.'); |
| 197 | - } |
|
| 198 | - else{ |
|
| 194 | + } else{ |
|
| 199 | 195 | show_error('The file '.$classFilePath.' exists but does not contain the class ['. $class . ']'); |
| 200 | 196 | } |
| 201 | - } |
|
| 202 | - else{ |
|
| 197 | + } else{ |
|
| 203 | 198 | show_error('Unable to find the model [' . $class . ']'); |
| 204 | 199 | } |
| 205 | 200 | } |
@@ -227,8 +222,7 @@ discard block |
||
| 227 | 222 | if(isset($path[1])){ |
| 228 | 223 | $instance = strtolower($path[1]); |
| 229 | 224 | } |
| 230 | - } |
|
| 231 | - else{ |
|
| 225 | + } else{ |
|
| 232 | 226 | $instance = strtolower($class); |
| 233 | 227 | } |
| 234 | 228 | } |
@@ -252,8 +246,7 @@ discard block |
||
| 252 | 246 | $libraryFilePath = CORE_LIBRARY_PATH . $file; |
| 253 | 247 | $class = ucfirst($class); |
| 254 | 248 | $logger->info('This library is a system library'); |
| 255 | - } |
|
| 256 | - else{ |
|
| 249 | + } else{ |
|
| 257 | 250 | $logger->info('This library is not a system library'); |
| 258 | 251 | //first check if this library is in the module |
| 259 | 252 | $logger->debug('Checking library [' . $class . '] from module list ...'); |
@@ -265,8 +258,7 @@ discard block |
||
| 265 | 258 | $searchModuleName = $path[0]; |
| 266 | 259 | $class = ucfirst($path[1]); |
| 267 | 260 | } |
| 268 | - } |
|
| 269 | - else{ |
|
| 261 | + } else{ |
|
| 270 | 262 | $class = ucfirst($class); |
| 271 | 263 | } |
| 272 | 264 | if(! $searchModuleName && !empty($obj->moduleName)){ |
@@ -276,8 +268,7 @@ discard block |
||
| 276 | 268 | if($moduleLibraryPath){ |
| 277 | 269 | $logger->info('Found library [' . $class . '] from module [' .$searchModuleName. '], the file path is [' .$moduleLibraryPath. '] we will used it'); |
| 278 | 270 | $libraryFilePath = $moduleLibraryPath; |
| 279 | - } |
|
| 280 | - else{ |
|
| 271 | + } else{ |
|
| 281 | 272 | $logger->info('Cannot find library [' . $class . '] from modules using the default location'); |
| 282 | 273 | } |
| 283 | 274 | } |
@@ -301,12 +292,10 @@ discard block |
||
| 301 | 292 | $obj->{$instance} = $c; |
| 302 | 293 | static::$loaded[$instance] = $class; |
| 303 | 294 | $logger->info('Library [' . $class . '] --> ' . $libraryFilePath . ' loaded successfully.'); |
| 304 | - } |
|
| 305 | - else{ |
|
| 295 | + } else{ |
|
| 306 | 296 | show_error('The file '.$libraryFilePath.' exists but does not contain the class '.$class); |
| 307 | 297 | } |
| 308 | - } |
|
| 309 | - else{ |
|
| 298 | + } else{ |
|
| 310 | 299 | show_error('Unable to find library class [' . $class . ']'); |
| 311 | 300 | } |
| 312 | 301 | } |
@@ -350,8 +339,7 @@ discard block |
||
| 350 | 339 | if($moduleFunctionPath){ |
| 351 | 340 | $logger->info('Found helper [' . $function . '] from module [' .$searchModuleName. '], the file path is [' .$moduleFunctionPath. '] we will used it'); |
| 352 | 341 | $functionFilePath = $moduleFunctionPath; |
| 353 | - } |
|
| 354 | - else{ |
|
| 342 | + } else{ |
|
| 355 | 343 | $logger->info('Cannot find helper [' . $function . '] from modules using the default location'); |
| 356 | 344 | } |
| 357 | 345 | if(! $functionFilePath){ |
@@ -370,8 +358,7 @@ discard block |
||
| 370 | 358 | require_once $functionFilePath; |
| 371 | 359 | static::$loaded['function_' . $function] = $functionFilePath; |
| 372 | 360 | $logger->info('Helper [' . $function . '] --> ' . $functionFilePath . ' loaded successfully.'); |
| 373 | - } |
|
| 374 | - else{ |
|
| 361 | + } else{ |
|
| 375 | 362 | show_error('Unable to find helper file [' . $file . ']'); |
| 376 | 363 | } |
| 377 | 364 | } |
@@ -414,8 +401,7 @@ discard block |
||
| 414 | 401 | if($moduleConfigPath){ |
| 415 | 402 | $logger->info('Found config [' . $filename . '] from module [' .$searchModuleName. '], the file path is [' .$moduleConfigPath. '] we will used it'); |
| 416 | 403 | $configFilePath = $moduleConfigPath; |
| 417 | - } |
|
| 418 | - else{ |
|
| 404 | + } else{ |
|
| 419 | 405 | $logger->info('Cannot find config [' . $filename . '] from modules using the default location'); |
| 420 | 406 | } |
| 421 | 407 | $logger->info('The config file path to be loaded is [' . $configFilePath . ']'); |
@@ -424,8 +410,7 @@ discard block |
||
| 424 | 410 | if(! empty($config) && is_array($config)){ |
| 425 | 411 | Config::setAll($config); |
| 426 | 412 | } |
| 427 | - } |
|
| 428 | - else{ |
|
| 413 | + } else{ |
|
| 429 | 414 | show_error('Unable to find config file ['. $configFilePath . ']'); |
| 430 | 415 | } |
| 431 | 416 | static::$loaded['config_' . $filename] = $configFilePath; |
@@ -483,8 +468,7 @@ discard block |
||
| 483 | 468 | if($moduleLanguagePath){ |
| 484 | 469 | $logger->info('Found language [' . $language . '] from module [' .$searchModuleName. '], the file path is [' .$moduleLanguagePath. '] we will used it'); |
| 485 | 470 | $languageFilePath = $moduleLanguagePath; |
| 486 | - } |
|
| 487 | - else{ |
|
| 471 | + } else{ |
|
| 488 | 472 | $logger->info('Cannot find language [' . $language . '] from modules using the default location'); |
| 489 | 473 | } |
| 490 | 474 | if(! $languageFilePath){ |
@@ -511,8 +495,7 @@ discard block |
||
| 511 | 495 | } |
| 512 | 496 | static::$loaded['lang_' . $language] = $languageFilePath; |
| 513 | 497 | $logger->info('Language [' . $language . '] --> ' . $languageFilePath . ' loaded successfully.'); |
| 514 | - } |
|
| 515 | - else{ |
|
| 498 | + } else{ |
|
| 516 | 499 | show_error('Unable to find language file [' . $file . ']'); |
| 517 | 500 | } |
| 518 | 501 | } |
@@ -104,8 +104,7 @@ discard block |
||
| 104 | 104 | $this->routes = $route; |
| 105 | 105 | unset($route); |
| 106 | 106 | } |
| 107 | - } |
|
| 108 | - else{ |
|
| 107 | + } else{ |
|
| 109 | 108 | show_error('Unable to find the routes configuration file [' . $routesPath . ']'); |
| 110 | 109 | } |
| 111 | 110 | |
@@ -115,8 +114,7 @@ discard block |
||
| 115 | 114 | if($modulesRoutes && is_array($modulesRoutes)){ |
| 116 | 115 | $this->routes = array_merge($this->routes, $modulesRoutes); |
| 117 | 116 | $this->logger->info('Routes for all modules loaded successfully'); |
| 118 | - } |
|
| 119 | - else{ |
|
| 117 | + } else{ |
|
| 120 | 118 | $this->logger->info('No routes found for all modules skipping.'); |
| 121 | 119 | } |
| 122 | 120 | $this->logger->info('The routes configuration are listed below: ' . stringfy_vars($this->routes)); |
@@ -132,8 +130,7 @@ discard block |
||
| 132 | 130 | if($suffix = get_config('url_suffix')){ |
| 133 | 131 | $this->logger->info('URL suffix is enabled in the configuration, the value is [' . $suffix . ']' ); |
| 134 | 132 | $uri = str_ireplace($suffix, '', $uri); |
| 135 | - } |
|
| 136 | - else{ |
|
| 133 | + } else{ |
|
| 137 | 134 | $this->logger->info('URL suffix is not enabled in the configuration'); |
| 138 | 135 | } |
| 139 | 136 | if(strpos($uri, '?') !== false){ |
@@ -226,8 +223,7 @@ discard block |
||
| 226 | 223 | $this->logger->info('The request URI contains the front controller'); |
| 227 | 224 | array_shift($segment); |
| 228 | 225 | $this->segments = $segment; |
| 229 | - } |
|
| 230 | - else{ |
|
| 226 | + } else{ |
|
| 231 | 227 | $this->logger->info('The request URI does not contain the front controller'); |
| 232 | 228 | } |
| 233 | 229 | $uri = implode('/', $segment); |
@@ -249,8 +245,7 @@ discard block |
||
| 249 | 245 | $this->logger->info('The current request use the module [' .$moduleControllerMethod[0]. ']'); |
| 250 | 246 | $this->module = $moduleControllerMethod[0]; |
| 251 | 247 | $moduleControllerMethod = explode('@', $moduleControllerMethod[1]); |
| 252 | - } |
|
| 253 | - else{ |
|
| 248 | + } else{ |
|
| 254 | 249 | $this->logger->info('The current request does not use the module'); |
| 255 | 250 | $moduleControllerMethod = explode('@', $this->callback[$index]); |
| 256 | 251 | } |
@@ -297,8 +292,7 @@ discard block |
||
| 297 | 292 | } |
| 298 | 293 | //args |
| 299 | 294 | $this->args = $segment; |
| 300 | - } |
|
| 301 | - else{ |
|
| 295 | + } else{ |
|
| 302 | 296 | $this->logger->info('The application contains a loaded module will check if the current request is found in the module list'); |
| 303 | 297 | if(in_array($segment[0], $modules)){ |
| 304 | 298 | $this->logger->info('Found, the current request use the module [' . $segment[0] . ']'); |
@@ -312,8 +306,7 @@ discard block |
||
| 312 | 306 | if(! $path){ |
| 313 | 307 | $this->logger->info('The controller [' . $this->getController() . '] not found in the module, may be will use the module [' . $this->getModule() . '] as controller'); |
| 314 | 308 | $this->controller = $this->getModule(); |
| 315 | - } |
|
| 316 | - else{ |
|
| 309 | + } else{ |
|
| 317 | 310 | $this->controllerPath = $path; |
| 318 | 311 | array_shift($segment); |
| 319 | 312 | } |
@@ -325,8 +318,7 @@ discard block |
||
| 325 | 318 | } |
| 326 | 319 | //the remaining is for args |
| 327 | 320 | $this->args = $segment; |
| 328 | - } |
|
| 329 | - else{ |
|
| 321 | + } else{ |
|
| 330 | 322 | $this->logger->info('The current request information is not found in the module list'); |
| 331 | 323 | //controller |
| 332 | 324 | if(isset($segment[0])){ |
@@ -354,8 +346,7 @@ discard block |
||
| 354 | 346 | //if it is the module controller |
| 355 | 347 | if($this->getModule()){ |
| 356 | 348 | $this->controllerPath = Module::findControllerFullPath(ucfirst($this->getController()), $this->getModule()); |
| 357 | - } |
|
| 358 | - else{ |
|
| 349 | + } else{ |
|
| 359 | 350 | $this->controllerPath = APPS_CONTROLLER_PATH . ucfirst($this->getController()) . '.php'; |
| 360 | 351 | } |
| 361 | 352 | } |
@@ -370,15 +361,13 @@ discard block |
||
| 370 | 361 | if(! class_exists($controller, false)){ |
| 371 | 362 | $e404 = true; |
| 372 | 363 | $this->logger->info('The controller file [' .$classFilePath. '] exists but does not contain the class [' . $controller . ']'); |
| 373 | - } |
|
| 374 | - else{ |
|
| 364 | + } else{ |
|
| 375 | 365 | $controllerInstance = new $controller(); |
| 376 | 366 | $controllerMethod = $this->getMethod(); |
| 377 | 367 | if(! method_exists($controllerInstance, $controllerMethod)){ |
| 378 | 368 | $e404 = true; |
| 379 | 369 | $this->logger->info('The controller [' . $controller . '] exist but does not contain the method [' . $controllerMethod . ']'); |
| 380 | - } |
|
| 381 | - else{ |
|
| 370 | + } else{ |
|
| 382 | 371 | $this->logger->info('Routing data is set correctly now GO!'); |
| 383 | 372 | call_user_func_array(array($controllerInstance, $controllerMethod), $this->getArgs()); |
| 384 | 373 | $obj = & get_instance(); |
@@ -387,8 +376,7 @@ discard block |
||
| 387 | 376 | $obj->response->renderFinalPage(); |
| 388 | 377 | } |
| 389 | 378 | } |
| 390 | - } |
|
| 391 | - else{ |
|
| 379 | + } else{ |
|
| 392 | 380 | $this->logger->info('The controller file path [' . $classFilePath . '] does not exist'); |
| 393 | 381 | $e404 = true; |
| 394 | 382 | } |
@@ -188,8 +188,7 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | if(is_object($logger)){ |
| 190 | 190 | $this->logger = $logger; |
| 191 | - } |
|
| 192 | - else{ |
|
| 191 | + } else{ |
|
| 193 | 192 | $this->logger =& class_loader('Log', 'classes'); |
| 194 | 193 | $this->logger->setLogger('Library::Database'); |
| 195 | 194 | } |
@@ -251,14 +250,12 @@ discard block |
||
| 251 | 250 | $this->pdo->exec("SET CHARACTER SET '" . $config['charset'] . "'"); |
| 252 | 251 | $this->pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ); |
| 253 | 252 | return true; |
| 254 | - } |
|
| 255 | - catch (PDOException $e){ |
|
| 253 | + } catch (PDOException $e){ |
|
| 256 | 254 | $this->logger->fatal($e->getMessage()); |
| 257 | 255 | show_error('Cannot connect to Database.'); |
| 258 | 256 | return false; |
| 259 | 257 | } |
| 260 | - } |
|
| 261 | - else{ |
|
| 258 | + } else{ |
|
| 262 | 259 | show_error('Database configuration is not set.'); |
| 263 | 260 | return false; |
| 264 | 261 | } |
@@ -276,8 +273,7 @@ discard block |
||
| 276 | 273 | $froms .= $this->prefix . $key . ', '; |
| 277 | 274 | } |
| 278 | 275 | $this->from = rtrim($froms, ', '); |
| 279 | - } |
|
| 280 | - else{ |
|
| 276 | + } else{ |
|
| 281 | 277 | $this->from = $this->prefix . $table; |
| 282 | 278 | } |
| 283 | 279 | return $this; |
@@ -383,8 +379,7 @@ discard block |
||
| 383 | 379 | } |
| 384 | 380 | if (empty($this->join)){ |
| 385 | 381 | $this->join = ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on; |
| 386 | - } |
|
| 387 | - else{ |
|
| 382 | + } else{ |
|
| 388 | 383 | $this->join = $this->join . ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on; |
| 389 | 384 | } |
| 390 | 385 | return $this; |
@@ -455,12 +450,10 @@ discard block |
||
| 455 | 450 | foreach($field as $f){ |
| 456 | 451 | $this->whereIsNull($f, $andOr); |
| 457 | 452 | } |
| 458 | - } |
|
| 459 | - else{ |
|
| 453 | + } else{ |
|
| 460 | 454 | if (! $this->where){ |
| 461 | 455 | $this->where = $field.' IS NULL '; |
| 462 | - } |
|
| 463 | - else{ |
|
| 456 | + } else{ |
|
| 464 | 457 | $this->where = $this->where . ' '.$andOr.' ' . $field.' IS NULL '; |
| 465 | 458 | } |
| 466 | 459 | } |
@@ -478,12 +471,10 @@ discard block |
||
| 478 | 471 | foreach($field as $f){ |
| 479 | 472 | $this->whereIsNotNull($f, $andOr); |
| 480 | 473 | } |
| 481 | - } |
|
| 482 | - else{ |
|
| 474 | + } else{ |
|
| 483 | 475 | if (! $this->where){ |
| 484 | 476 | $this->where = $field.' IS NOT NULL '; |
| 485 | - } |
|
| 486 | - else{ |
|
| 477 | + } else{ |
|
| 487 | 478 | $this->where = $this->where . ' '.$andOr.' ' . $field.' IS NOT NULL '; |
| 488 | 479 | } |
| 489 | 480 | } |
@@ -510,8 +501,7 @@ discard block |
||
| 510 | 501 | $_where[] = $type . $column . '=' . ($escape ? $this->escape($data) : $data); |
| 511 | 502 | } |
| 512 | 503 | $where = implode(' '.$andOr.' ', $_where); |
| 513 | - } |
|
| 514 | - else{ |
|
| 504 | + } else{ |
|
| 515 | 505 | if(is_array($op)){ |
| 516 | 506 | $x = explode('?', $where); |
| 517 | 507 | $w = ''; |
@@ -524,14 +514,12 @@ discard block |
||
| 524 | 514 | } |
| 525 | 515 | } |
| 526 | 516 | $where = $w; |
| 527 | - } |
|
| 528 | - else if (! in_array((string)$op, $this->operatorList)){ |
|
| 517 | + } else if (! in_array((string)$op, $this->operatorList)){ |
|
| 529 | 518 | if(is_null($op)){ |
| 530 | 519 | $op = ''; |
| 531 | 520 | } |
| 532 | 521 | $where = $type . $where . ' = ' . ($escape ? $this->escape($op) : $op); |
| 533 | - } |
|
| 534 | - else{ |
|
| 522 | + } else{ |
|
| 535 | 523 | if(is_null($val)){ |
| 536 | 524 | $val = ''; |
| 537 | 525 | } |
@@ -540,12 +528,10 @@ discard block |
||
| 540 | 528 | } |
| 541 | 529 | if (empty($this->where)){ |
| 542 | 530 | $this->where = $where; |
| 543 | - } |
|
| 544 | - else{ |
|
| 531 | + } else{ |
|
| 545 | 532 | if(substr($this->where, -1) == '('){ |
| 546 | 533 | $this->where = $this->where . ' ' . $where; |
| 547 | - } |
|
| 548 | - else{ |
|
| 534 | + } else{ |
|
| 549 | 535 | $this->where = $this->where . ' '.$andOr.' ' . $where; |
| 550 | 536 | } |
| 551 | 537 | } |
@@ -589,12 +575,10 @@ discard block |
||
| 589 | 575 | public function groupStart($type = '', $andOr = ' AND'){ |
| 590 | 576 | if (empty($this->where)){ |
| 591 | 577 | $this->where = $type . ' ('; |
| 592 | - } |
|
| 593 | - else{ |
|
| 578 | + } else{ |
|
| 594 | 579 | if(substr($this->where, -1) == '('){ |
| 595 | 580 | $this->where .= $type . ' ('; |
| 596 | - } |
|
| 597 | - else{ |
|
| 581 | + } else{ |
|
| 598 | 582 | $this->where .= $andOr . ' ' . $type . ' ('; |
| 599 | 583 | } |
| 600 | 584 | } |
@@ -657,12 +641,10 @@ discard block |
||
| 657 | 641 | $keys = implode(', ', $_keys); |
| 658 | 642 | if (empty($this->where)){ |
| 659 | 643 | $this->where = $field . ' ' . $type . 'IN (' . $keys . ')'; |
| 660 | - } |
|
| 661 | - else{ |
|
| 644 | + } else{ |
|
| 662 | 645 | if(substr($this->where, -1) == '('){ |
| 663 | 646 | $this->where = $this->where . ' ' . $field . ' '.$type.'IN (' . $keys . ')'; |
| 664 | - } |
|
| 665 | - else{ |
|
| 647 | + } else{ |
|
| 666 | 648 | $this->where = $this->where . ' ' . $andOr . ' ' . $field . ' '.$type.'IN (' . $keys . ')'; |
| 667 | 649 | } |
| 668 | 650 | } |
@@ -715,12 +697,10 @@ discard block |
||
| 715 | 697 | } |
| 716 | 698 | if (empty($this->where)){ |
| 717 | 699 | $this->where = $field . ' ' . $type . 'BETWEEN ' . ($escape ? $this->escape($value1) : $value1) . ' AND ' . ($escape ? $this->escape($value2) : $value2); |
| 718 | - } |
|
| 719 | - else{ |
|
| 700 | + } else{ |
|
| 720 | 701 | if(substr($this->where, -1) == '('){ |
| 721 | 702 | $this->where = $this->where . ' ' . $field . ' ' . $type . 'BETWEEN ' . ($escape ? $this->escape($value1) : $value1) . ' AND ' . ($escape ? $this->escape($value2) : $value2); |
| 722 | - } |
|
| 723 | - else{ |
|
| 703 | + } else{ |
|
| 724 | 704 | $this->where = $this->where . ' ' . $andOr . ' ' . $field . ' ' . $type . 'BETWEEN ' . ($escape ? $this->escape($value1) : $value1) . ' AND ' . ($escape ? $this->escape($value2) : $value2); |
| 725 | 705 | } |
| 726 | 706 | } |
@@ -770,12 +750,10 @@ discard block |
||
| 770 | 750 | $like = $escape ? $this->escape($data) : $data; |
| 771 | 751 | if (empty($this->where)){ |
| 772 | 752 | $this->where = $field . ' ' . $type . 'LIKE ' . $like; |
| 773 | - } |
|
| 774 | - else{ |
|
| 753 | + } else{ |
|
| 775 | 754 | if(substr($this->where, -1) == '('){ |
| 776 | 755 | $this->where = $this->where . ' ' . $field . ' ' . $type . 'LIKE ' . $like; |
| 777 | - } |
|
| 778 | - else{ |
|
| 756 | + } else{ |
|
| 779 | 757 | $this->where = $this->where . ' '.$andOr.' ' . $field . ' ' . $type . 'LIKE ' . $like; |
| 780 | 758 | } |
| 781 | 759 | } |
@@ -822,8 +800,7 @@ discard block |
||
| 822 | 800 | } |
| 823 | 801 | if (! is_null($limitEnd)){ |
| 824 | 802 | $this->limit = $limit . ', ' . $limitEnd; |
| 825 | - } |
|
| 826 | - else{ |
|
| 803 | + } else{ |
|
| 827 | 804 | $this->limit = $limit; |
| 828 | 805 | } |
| 829 | 806 | return $this; |
@@ -838,12 +815,10 @@ discard block |
||
| 838 | 815 | public function orderBy($orderBy, $orderDir = ' ASC'){ |
| 839 | 816 | if (! empty($orderDir)){ |
| 840 | 817 | $this->orderBy = ! $this->orderBy ? ($orderBy . ' ' . strtoupper($orderDir)) : $this->orderBy . ', ' . $orderBy . ' ' . strtoupper($orderDir); |
| 841 | - } |
|
| 842 | - else{ |
|
| 818 | + } else{ |
|
| 843 | 819 | if(stristr($orderBy, ' ') || $orderBy == 'rand()'){ |
| 844 | 820 | $this->orderBy = ! $this->orderBy ? $orderBy : $this->orderBy . ', ' . $orderBy; |
| 845 | - } |
|
| 846 | - else{ |
|
| 821 | + } else{ |
|
| 847 | 822 | $this->orderBy = ! $this->orderBy ? ($orderBy . ' ASC') : $this->orderBy . ', ' . ($orderBy . ' ASC'); |
| 848 | 823 | } |
| 849 | 824 | } |
@@ -858,8 +833,7 @@ discard block |
||
| 858 | 833 | public function groupBy($field){ |
| 859 | 834 | if(is_array($field)){ |
| 860 | 835 | $this->groupBy = implode(', ', $field); |
| 861 | - } |
|
| 862 | - else{ |
|
| 836 | + } else{ |
|
| 863 | 837 | $this->groupBy = $field; |
| 864 | 838 | } |
| 865 | 839 | return $this; |
@@ -886,14 +860,12 @@ discard block |
||
| 886 | 860 | } |
| 887 | 861 | } |
| 888 | 862 | $this->having = $w; |
| 889 | - } |
|
| 890 | - else if (! in_array($op, $this->operatorList)){ |
|
| 863 | + } else if (! in_array($op, $this->operatorList)){ |
|
| 891 | 864 | if(is_null($op)){ |
| 892 | 865 | $op = ''; |
| 893 | 866 | } |
| 894 | 867 | $this->having = $field . ' > ' . ($escape ? $this->escape($op) : $op); |
| 895 | - } |
|
| 896 | - else{ |
|
| 868 | + } else{ |
|
| 897 | 869 | if(is_null($val)){ |
| 898 | 870 | $val = ''; |
| 899 | 871 | } |
@@ -938,8 +910,7 @@ discard block |
||
| 938 | 910 | $query = $this->getAll(true); |
| 939 | 911 | if($returnSQLQueryOrResultType === true){ |
| 940 | 912 | return $query; |
| 941 | - } |
|
| 942 | - else{ |
|
| 913 | + } else{ |
|
| 943 | 914 | return $this->query( $query, false, (($returnSQLQueryOrResultType == 'array') ? true : false) ); |
| 944 | 915 | } |
| 945 | 916 | } |
@@ -978,8 +949,7 @@ discard block |
||
| 978 | 949 | |
| 979 | 950 | if($returnSQLQueryOrResultType === true){ |
| 980 | 951 | return $query; |
| 981 | - } |
|
| 982 | - else{ |
|
| 952 | + } else{ |
|
| 983 | 953 | return $this->query($query, true, (($returnSQLQueryOrResultType == 'array') ? true : false) ); |
| 984 | 954 | } |
| 985 | 955 | } |
@@ -997,8 +967,7 @@ discard block |
||
| 997 | 967 | $columns = array_keys($this->getData()); |
| 998 | 968 | $column = implode(',', $columns); |
| 999 | 969 | $val = implode(', ', $this->getData()); |
| 1000 | - } |
|
| 1001 | - else{ |
|
| 970 | + } else{ |
|
| 1002 | 971 | $columns = array_keys($data); |
| 1003 | 972 | $column = implode(',', $columns); |
| 1004 | 973 | $val = implode(', ', ($escape ? array_map(array($this, 'escape'), $data) : $data)); |
@@ -1013,8 +982,7 @@ discard block |
||
| 1013 | 982 | } |
| 1014 | 983 | $this->insertId = $this->pdo->lastInsertId(); |
| 1015 | 984 | return $this->insertId(); |
| 1016 | - } |
|
| 1017 | - else{ |
|
| 985 | + } else{ |
|
| 1018 | 986 | return false; |
| 1019 | 987 | } |
| 1020 | 988 | } |
@@ -1032,8 +1000,7 @@ discard block |
||
| 1032 | 1000 | foreach ($this->getData() as $column => $val){ |
| 1033 | 1001 | $values[] = $column . ' = ' . $val; |
| 1034 | 1002 | } |
| 1035 | - } |
|
| 1036 | - else{ |
|
| 1003 | + } else{ |
|
| 1037 | 1004 | foreach ($data as $column => $val){ |
| 1038 | 1005 | $values[] = $column . '=' . ($escape ? $this->escape($val) : $val); |
| 1039 | 1006 | } |
@@ -1127,14 +1094,12 @@ discard block |
||
| 1127 | 1094 | $cacheKey = md5($query . $all . $array); |
| 1128 | 1095 | if(is_object($this->cacheInstance)){ |
| 1129 | 1096 | $cacheInstance = $this->cacheInstance; |
| 1130 | - } |
|
| 1131 | - else{ |
|
| 1097 | + } else{ |
|
| 1132 | 1098 | $obj = & get_instance(); |
| 1133 | 1099 | $cacheInstance = $obj->cache; |
| 1134 | 1100 | } |
| 1135 | 1101 | $cacheContent = $cacheInstance->get($cacheKey); |
| 1136 | - } |
|
| 1137 | - else{ |
|
| 1102 | + } else{ |
|
| 1138 | 1103 | $this->logger->info('The cache is not enabled for this query or is not the SELECT query, get the result directly from real database'); |
| 1139 | 1104 | } |
| 1140 | 1105 | |
@@ -1148,8 +1113,7 @@ discard block |
||
| 1148 | 1113 | $bench = null; |
| 1149 | 1114 | if(is_object($this->benchmarkInstance)){ |
| 1150 | 1115 | $bench = $this->benchmarkInstance; |
| 1151 | - } |
|
| 1152 | - else{ |
|
| 1116 | + } else{ |
|
| 1153 | 1117 | $obj = & get_instance(); |
| 1154 | 1118 | $bench = $obj->benchmark; |
| 1155 | 1119 | } |
@@ -1167,15 +1131,13 @@ discard block |
||
| 1167 | 1131 | //if need return all result like list of record |
| 1168 | 1132 | if ($all){ |
| 1169 | 1133 | $this->result = ($array === false) ? $sqlQuery->fetchAll(PDO::FETCH_OBJ) : $sqlQuery->fetchAll(PDO::FETCH_ASSOC); |
| 1170 | - } |
|
| 1171 | - else{ |
|
| 1134 | + } else{ |
|
| 1172 | 1135 | $this->result = ($array === false) ? $sqlQuery->fetch(PDO::FETCH_OBJ) : $sqlQuery->fetch(PDO::FETCH_ASSOC); |
| 1173 | 1136 | } |
| 1174 | 1137 | //Sqlite and pgsql always return 0 when using rowCount() |
| 1175 | 1138 | if(in_array($this->config['driver'], array('sqlite', 'pgsql'))){ |
| 1176 | 1139 | $this->numRows = count($this->result); |
| 1177 | - } |
|
| 1178 | - else{ |
|
| 1140 | + } else{ |
|
| 1179 | 1141 | $this->numRows = $sqlQuery->rowCount(); |
| 1180 | 1142 | } |
| 1181 | 1143 | |
@@ -1183,23 +1145,20 @@ discard block |
||
| 1183 | 1145 | $this->logger->info('Save the result for query [' .$this->query. '] into cache for future use'); |
| 1184 | 1146 | $cacheInstance->set($cacheKey, $this->result, $cacheExpire); |
| 1185 | 1147 | } |
| 1186 | - } |
|
| 1187 | - else{ |
|
| 1148 | + } else{ |
|
| 1188 | 1149 | $error = $this->pdo->errorInfo(); |
| 1189 | 1150 | $this->error = isset($error[2]) ? $error[2] : ''; |
| 1190 | 1151 | $this->logger->fatal('The database query execution got error: ' . stringfy_vars($error)); |
| 1191 | 1152 | $this->error(); |
| 1192 | 1153 | } |
| 1193 | - } |
|
| 1194 | - else if ((! $cacheContent && !$sqlSELECTQuery) || ($cacheContent && !$sqlSELECTQuery)){ |
|
| 1154 | + } else if ((! $cacheContent && !$sqlSELECTQuery) || ($cacheContent && !$sqlSELECTQuery)){ |
|
| 1195 | 1155 | $queryStr = $this->pdo->query($this->query); |
| 1196 | 1156 | if($queryStr){ |
| 1197 | 1157 | //Sqlite and pgsql always return 0 when using rowCount() |
| 1198 | 1158 | if(in_array($this->config['driver'], array('sqlite', 'pgsql'))){ |
| 1199 | 1159 | $this->result = 1; //to test the result for the query like UPDATE, INSERT, DELETE |
| 1200 | 1160 | $this->numRows = 1; |
| 1201 | - } |
|
| 1202 | - else{ |
|
| 1161 | + } else{ |
|
| 1203 | 1162 | $this->result = $queryStr->rowCount() >= 0; //to test the result for the query like UPDATE, INSERT, DELETE |
| 1204 | 1163 | $this->numRows = $queryStr->rowCount(); |
| 1205 | 1164 | } |
@@ -1210,8 +1169,7 @@ discard block |
||
| 1210 | 1169 | $this->logger->fatal('The database query execution got error: ' . stringfy_vars($error)); |
| 1211 | 1170 | $this->error(); |
| 1212 | 1171 | } |
| 1213 | - } |
|
| 1214 | - else{ |
|
| 1172 | + } else{ |
|
| 1215 | 1173 | $this->logger->info('The result for query [' .$this->query. '] already cached use it'); |
| 1216 | 1174 | $this->result = $cacheContent; |
| 1217 | 1175 | $this->numRows = count($this->result); |
@@ -60,8 +60,7 @@ discard block |
||
| 60 | 60 | while(($module = readdir($moduleDir)) !== false){ |
| 61 | 61 | if($module != '.' && $module != '..' && preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)){ |
| 62 | 62 | self::$list[] = $module; |
| 63 | - } |
|
| 64 | - else{ |
|
| 63 | + } else{ |
|
| 65 | 64 | $logger->info('Skipping [' .$module. '], may be this is not a directory or does not exists or is invalid name'); |
| 66 | 65 | } |
| 67 | 66 | } |
@@ -70,8 +69,7 @@ discard block |
||
| 70 | 69 | |
| 71 | 70 | if(self::hasModule()){ |
| 72 | 71 | $logger->info('The application contains the module below [' . implode(', ', self::getModuleList()) . ']'); |
| 73 | - } |
|
| 74 | - else{ |
|
| 72 | + } else{ |
|
| 75 | 73 | $logger->info('The application contains no module skipping'); |
| 76 | 74 | } |
| 77 | 75 | } |
@@ -143,8 +141,7 @@ discard block |
||
| 143 | 141 | if(! empty($route) && is_array($route)){ |
| 144 | 142 | $routes = array_merge($routes, $route); |
| 145 | 143 | unset($route); |
| 146 | - } |
|
| 147 | - else{ |
|
| 144 | + } else{ |
|
| 148 | 145 | show_error('No routing configuration found in [' .$file. '] for module [' . $module . ']'); |
| 149 | 146 | } |
| 150 | 147 | } |
@@ -173,8 +170,7 @@ discard block |
||
| 173 | 170 | if(file_exists($filePath)){ |
| 174 | 171 | $logger->info('Found controller [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
| 175 | 172 | return $filePath; |
| 176 | - } |
|
| 177 | - else{ |
|
| 173 | + } else{ |
|
| 178 | 174 | $logger->info('Controller [' . $class . '] does not exist in the module [' .$module. ']'); |
| 179 | 175 | return false; |
| 180 | 176 | } |
@@ -200,8 +196,7 @@ discard block |
||
| 200 | 196 | if(file_exists($filePath)){ |
| 201 | 197 | $logger->info('Found model [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
| 202 | 198 | return $filePath; |
| 203 | - } |
|
| 204 | - else{ |
|
| 199 | + } else{ |
|
| 205 | 200 | $logger->info('Model [' . $class . '] does not exist in the module [' .$module. ']'); |
| 206 | 201 | return false; |
| 207 | 202 | } |
@@ -226,8 +221,7 @@ discard block |
||
| 226 | 221 | if(file_exists($filePath)){ |
| 227 | 222 | $logger->info('Found configuration [' . $configuration . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
| 228 | 223 | return $filePath; |
| 229 | - } |
|
| 230 | - else{ |
|
| 224 | + } else{ |
|
| 231 | 225 | $logger->info('Configuration [' . $configuration . '] does not exist in the module [' .$module. ']'); |
| 232 | 226 | return false; |
| 233 | 227 | } |
@@ -253,8 +247,7 @@ discard block |
||
| 253 | 247 | if(file_exists($filePath)){ |
| 254 | 248 | $logger->info('Found helper [' . $helper . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
| 255 | 249 | return $filePath; |
| 256 | - } |
|
| 257 | - else{ |
|
| 250 | + } else{ |
|
| 258 | 251 | $logger->info('Helper [' . $helper . '] does not exist in the module [' .$module. ']'); |
| 259 | 252 | return false; |
| 260 | 253 | } |
@@ -280,8 +273,7 @@ discard block |
||
| 280 | 273 | if(file_exists($filePath)){ |
| 281 | 274 | $logger->info('Found library [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
| 282 | 275 | return $filePath; |
| 283 | - } |
|
| 284 | - else{ |
|
| 276 | + } else{ |
|
| 285 | 277 | $logger->info('Library [' . $class . '] does not exist in the module [' .$module. ']'); |
| 286 | 278 | return false; |
| 287 | 279 | } |
@@ -309,8 +301,7 @@ discard block |
||
| 309 | 301 | if(file_exists($filePath)){ |
| 310 | 302 | $logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
| 311 | 303 | return $filePath; |
| 312 | - } |
|
| 313 | - else{ |
|
| 304 | + } else{ |
|
| 314 | 305 | $logger->info('View [' . $view . '] does not exist in the module [' .$module. ']'); |
| 315 | 306 | return false; |
| 316 | 307 | } |
@@ -337,8 +328,7 @@ discard block |
||
| 337 | 328 | if(file_exists($filePath)){ |
| 338 | 329 | $logger->info('Found language [' . $language . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
| 339 | 330 | return $filePath; |
| 340 | - } |
|
| 341 | - else{ |
|
| 331 | + } else{ |
|
| 342 | 332 | $logger->info('Language [' . $language . '] does not exist in the module [' .$module. ']'); |
| 343 | 333 | return false; |
| 344 | 334 | } |