@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @copyright Copyright (c) 2012, Jamie Rumbelow <http://jamierumbelow.net> |
| 34 | 34 | */ |
| 35 | 35 | |
| 36 | - class Model{ |
|
| 36 | + class Model { |
|
| 37 | 37 | |
| 38 | 38 | /* -------------------------------------------------------------- |
| 39 | 39 | * VARIABLES |
@@ -140,13 +140,13 @@ discard block |
||
| 140 | 140 | * Initialise the model, tie into the CodeIgniter superobject and |
| 141 | 141 | * try our best to guess the table name. |
| 142 | 142 | */ |
| 143 | - public function __construct(Database $db = null){ |
|
| 144 | - if (is_object($db)){ |
|
| 143 | + public function __construct(Database $db = null) { |
|
| 144 | + if (is_object($db)) { |
|
| 145 | 145 | $this->setDatabaseInstance($db); |
| 146 | 146 | } |
| 147 | - else{ |
|
| 147 | + else { |
|
| 148 | 148 | $obj = & get_instance(); |
| 149 | - if (isset($obj->database) && is_object($obj->database)){ |
|
| 149 | + if (isset($obj->database) && is_object($obj->database)) { |
|
| 150 | 150 | /** |
| 151 | 151 | * NOTE: Need use "clone" because some Model need have the personal instance of the database library |
| 152 | 152 | * to prevent duplication |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) |
| 184 | 184 | { |
| 185 | - $this->getQueryBuilder()->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); |
|
| 185 | + $this->getQueryBuilder()->where($this->soft_delete_key, (bool) $this->_temporary_only_deleted); |
|
| 186 | 186 | } |
| 187 | 187 | $this->_set_where($where); |
| 188 | 188 | |
@@ -224,9 +224,9 @@ discard block |
||
| 224 | 224 | $this->trigger('before_get'); |
| 225 | 225 | if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) |
| 226 | 226 | { |
| 227 | - $this->getQueryBuilder()->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); |
|
| 227 | + $this->getQueryBuilder()->where($this->soft_delete_key, (bool) $this->_temporary_only_deleted); |
|
| 228 | 228 | } |
| 229 | - $type = $this->_temporary_return_type == 'array' ? 'array':false; |
|
| 229 | + $type = $this->_temporary_return_type == 'array' ? 'array' : false; |
|
| 230 | 230 | $this->getQueryBuilder()->from($this->_table); |
| 231 | 231 | $result = $this->_database->getAll($type); |
| 232 | 232 | $this->_temporary_return_type = $this->return_type; |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | $insert_id = $this->_database->insertId(); |
| 260 | 260 | $this->trigger('after_create', $insert_id); |
| 261 | 261 | //if the table doesn't have the auto increment field or sequence, the value of 0 will be returned |
| 262 | - return ! $insert_id ? true : $insert_id; |
|
| 262 | + return !$insert_id ? true : $insert_id; |
|
| 263 | 263 | } |
| 264 | 264 | else |
| 265 | 265 | { |
@@ -336,13 +336,13 @@ discard block |
||
| 336 | 336 | { |
| 337 | 337 | $args = func_get_args(); |
| 338 | 338 | $data = array(); |
| 339 | - if (count($args) == 2){ |
|
| 340 | - if (is_array($args[1])){ |
|
| 339 | + if (count($args) == 2) { |
|
| 340 | + if (is_array($args[1])) { |
|
| 341 | 341 | $data = array_pop($args); |
| 342 | 342 | } |
| 343 | 343 | } |
| 344 | - else if (count($args) == 3){ |
|
| 345 | - if (is_array($args[2])){ |
|
| 344 | + else if (count($args) == 3) { |
|
| 345 | + if (is_array($args[2])) { |
|
| 346 | 346 | $data = array_pop($args); |
| 347 | 347 | } |
| 348 | 348 | } |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | if ($this->soft_delete) |
| 385 | 385 | { |
| 386 | 386 | $this->getQueryBuilder()->from($this->_table); |
| 387 | - $result = $this->_database->update(array( $this->soft_delete_key => TRUE )); |
|
| 387 | + $result = $this->_database->update(array($this->soft_delete_key => TRUE)); |
|
| 388 | 388 | } |
| 389 | 389 | else |
| 390 | 390 | { |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | if ($this->soft_delete) |
| 409 | 409 | { |
| 410 | 410 | $this->getQueryBuilder()->from($this->_table); |
| 411 | - $result = $this->_database->update(array( $this->soft_delete_key => TRUE )); |
|
| 411 | + $result = $this->_database->update(array($this->soft_delete_key => TRUE)); |
|
| 412 | 412 | } |
| 413 | 413 | else |
| 414 | 414 | { |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | if ($this->soft_delete) |
| 431 | 431 | { |
| 432 | 432 | $this->getQueryBuilder()->from($this->_table); |
| 433 | - $result = $this->_database->update(array( $this->soft_delete_key => TRUE )); |
|
| 433 | + $result = $this->_database->update(array($this->soft_delete_key => TRUE)); |
|
| 434 | 434 | } |
| 435 | 435 | else |
| 436 | 436 | { |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | $key = $this->primary_key; |
| 501 | 501 | $value = $args[0]; |
| 502 | 502 | } |
| 503 | - $this->trigger('before_dropdown', array( $key, $value )); |
|
| 503 | + $this->trigger('before_dropdown', array($key, $value)); |
|
| 504 | 504 | if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) |
| 505 | 505 | { |
| 506 | 506 | $this->getQueryBuilder()->where($this->soft_delete_key, FALSE); |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | { |
| 526 | 526 | if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) |
| 527 | 527 | { |
| 528 | - $this->getQueryBuilder()->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); |
|
| 528 | + $this->getQueryBuilder()->where($this->soft_delete_key, (bool) $this->_temporary_only_deleted); |
|
| 529 | 529 | } |
| 530 | 530 | $where = func_get_args(); |
| 531 | 531 | $this->_set_where($where); |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | { |
| 542 | 542 | if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) |
| 543 | 543 | { |
| 544 | - $this->getQueryBuilder()->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); |
|
| 544 | + $this->getQueryBuilder()->where($this->soft_delete_key, (bool) $this->_temporary_only_deleted); |
|
| 545 | 545 | } |
| 546 | 546 | $this->getQueryBuilder()->from($this->_table); |
| 547 | 547 | $this->_database->getAll(); |
@@ -551,8 +551,8 @@ discard block |
||
| 551 | 551 | /** |
| 552 | 552 | * Enabled cache temporary |
| 553 | 553 | */ |
| 554 | - public function cached($ttl = 0){ |
|
| 555 | - if ($ttl > 0){ |
|
| 554 | + public function cached($ttl = 0) { |
|
| 555 | + if ($ttl > 0) { |
|
| 556 | 556 | $this->_database = $this->_database->cached($ttl); |
| 557 | 557 | } |
| 558 | 558 | return $this; |
@@ -706,13 +706,13 @@ discard block |
||
| 706 | 706 | { |
| 707 | 707 | if (is_object($row)) |
| 708 | 708 | { |
| 709 | - if (isset($row->$attr)){ |
|
| 709 | + if (isset($row->$attr)) { |
|
| 710 | 710 | unset($row->$attr); |
| 711 | 711 | } |
| 712 | 712 | } |
| 713 | 713 | else |
| 714 | 714 | { |
| 715 | - if (isset($row[$attr])){ |
|
| 715 | + if (isset($row[$attr])) { |
|
| 716 | 716 | unset($row[$attr]); |
| 717 | 717 | } |
| 718 | 718 | } |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | * Return the database instance |
| 725 | 725 | * @return Database the database instance |
| 726 | 726 | */ |
| 727 | - public function getDatabaseInstance(){ |
|
| 727 | + public function getDatabaseInstance() { |
|
| 728 | 728 | return $this->_database; |
| 729 | 729 | } |
| 730 | 730 | |
@@ -732,9 +732,9 @@ discard block |
||
| 732 | 732 | * set the Database instance for future use |
| 733 | 733 | * @param Database $db the database object |
| 734 | 734 | */ |
| 735 | - public function setDatabaseInstance($db){ |
|
| 735 | + public function setDatabaseInstance($db) { |
|
| 736 | 736 | $this->_database = $db; |
| 737 | - if ($this->dbCacheTime > 0){ |
|
| 737 | + if ($this->dbCacheTime > 0) { |
|
| 738 | 738 | $this->_database->setCache($this->dbCacheTime); |
| 739 | 739 | } |
| 740 | 740 | return $this; |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | * Return the loader instance |
| 745 | 745 | * @return Loader the loader instance |
| 746 | 746 | */ |
| 747 | - public function getLoader(){ |
|
| 747 | + public function getLoader() { |
|
| 748 | 748 | return $this->loaderInstance; |
| 749 | 749 | } |
| 750 | 750 | |
@@ -753,7 +753,7 @@ discard block |
||
| 753 | 753 | * @param Loader $loader the loader object |
| 754 | 754 | * @return object |
| 755 | 755 | */ |
| 756 | - public function setLoader($loader){ |
|
| 756 | + public function setLoader($loader) { |
|
| 757 | 757 | $this->loaderInstance = $loader; |
| 758 | 758 | return $this; |
| 759 | 759 | } |
@@ -762,7 +762,7 @@ discard block |
||
| 762 | 762 | * Return the queryBuilder instance this is the shortcut to database queryBuilder |
| 763 | 763 | * @return object the DatabaseQueryBuilder instance |
| 764 | 764 | */ |
| 765 | - public function getQueryBuilder(){ |
|
| 765 | + public function getQueryBuilder() { |
|
| 766 | 766 | return $this->_database->getQueryBuilder(); |
| 767 | 767 | } |
| 768 | 768 | |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | * @param object $queryBuilder the DatabaseQueryBuilder object |
| 772 | 772 | * @return object |
| 773 | 773 | */ |
| 774 | - public function setQueryBuilder($queryBuilder){ |
|
| 774 | + public function setQueryBuilder($queryBuilder) { |
|
| 775 | 775 | $this->_database->setQueryBuilder($queryBuilder); |
| 776 | 776 | return $this; |
| 777 | 777 | } |
@@ -781,7 +781,7 @@ discard block |
||
| 781 | 781 | * Return the FormValidation instance |
| 782 | 782 | * @return FormValidation the form validation instance |
| 783 | 783 | */ |
| 784 | - public function getFormValidation(){ |
|
| 784 | + public function getFormValidation() { |
|
| 785 | 785 | return $this->formValidationInstance; |
| 786 | 786 | } |
| 787 | 787 | |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | * @param FormValidation $fv the form validation object |
| 791 | 791 | * @return object |
| 792 | 792 | */ |
| 793 | - public function setFormValidation($fv){ |
|
| 793 | + public function setFormValidation($fv) { |
|
| 794 | 794 | $this->formValidationInstance = $fv; |
| 795 | 795 | return $this; |
| 796 | 796 | } |
@@ -804,7 +804,7 @@ discard block |
||
| 804 | 804 | */ |
| 805 | 805 | public function order_by($criteria, $order = 'ASC') |
| 806 | 806 | { |
| 807 | - if ( is_array($criteria) ) |
|
| 807 | + if (is_array($criteria)) |
|
| 808 | 808 | { |
| 809 | 809 | foreach ($criteria as $key => $value) |
| 810 | 810 | { |
@@ -835,13 +835,13 @@ discard block |
||
| 835 | 835 | * relate for the relation "belongs_to" |
| 836 | 836 | * @return mixed |
| 837 | 837 | */ |
| 838 | - protected function relateBelongsTo($row){ |
|
| 838 | + protected function relateBelongsTo($row) { |
|
| 839 | 839 | foreach ($this->belongs_to as $key => $value) |
| 840 | 840 | { |
| 841 | 841 | if (is_string($value)) |
| 842 | 842 | { |
| 843 | 843 | $relationship = $value; |
| 844 | - $options = array( 'primary_key' => $value . '_id', 'model' => $value . '_model' ); |
|
| 844 | + $options = array('primary_key' => $value . '_id', 'model' => $value . '_model'); |
|
| 845 | 845 | } |
| 846 | 846 | else |
| 847 | 847 | { |
@@ -851,10 +851,10 @@ discard block |
||
| 851 | 851 | |
| 852 | 852 | if (in_array($relationship, $this->_with)) |
| 853 | 853 | { |
| 854 | - if (is_object($this->loaderInstance)){ |
|
| 854 | + if (is_object($this->loaderInstance)) { |
|
| 855 | 855 | $this->loaderInstance->model($options['model'], $relationship . '_model'); |
| 856 | 856 | } |
| 857 | - else{ |
|
| 857 | + else { |
|
| 858 | 858 | Loader::model($options['model'], $relationship . '_model'); |
| 859 | 859 | } |
| 860 | 860 | if (is_object($row)) |
@@ -874,13 +874,13 @@ discard block |
||
| 874 | 874 | * relate for the relation "has_many" |
| 875 | 875 | * @return mixed |
| 876 | 876 | */ |
| 877 | - protected function relateHasMany($row){ |
|
| 877 | + protected function relateHasMany($row) { |
|
| 878 | 878 | foreach ($this->has_many as $key => $value) |
| 879 | 879 | { |
| 880 | 880 | if (is_string($value)) |
| 881 | 881 | { |
| 882 | 882 | $relationship = $value; |
| 883 | - $options = array( 'primary_key' => $this->_table . '_id', 'model' => $value . '_model' ); |
|
| 883 | + $options = array('primary_key' => $this->_table . '_id', 'model' => $value . '_model'); |
|
| 884 | 884 | } |
| 885 | 885 | else |
| 886 | 886 | { |
@@ -890,10 +890,10 @@ discard block |
||
| 890 | 890 | |
| 891 | 891 | if (in_array($relationship, $this->_with)) |
| 892 | 892 | { |
| 893 | - if (is_object($this->loaderInstance)){ |
|
| 893 | + if (is_object($this->loaderInstance)) { |
|
| 894 | 894 | $this->loaderInstance->model($options['model'], $relationship . '_model'); |
| 895 | 895 | } |
| 896 | - else{ |
|
| 896 | + else { |
|
| 897 | 897 | Loader::model($options['model'], $relationship . '_model'); |
| 898 | 898 | } |
| 899 | 899 | if (is_object($row)) |
@@ -944,10 +944,10 @@ discard block |
||
| 944 | 944 | if (!empty($this->validate)) |
| 945 | 945 | { |
| 946 | 946 | $fv = null; |
| 947 | - if (is_object($this->formValidationInstance)){ |
|
| 947 | + if (is_object($this->formValidationInstance)) { |
|
| 948 | 948 | $fv = $this->formValidationInstance; |
| 949 | 949 | } |
| 950 | - else{ |
|
| 950 | + else { |
|
| 951 | 951 | Loader::library('FormValidation'); |
| 952 | 952 | $fv = $this->formvalidation; |
| 953 | 953 | $this->setFormValidation($fv); |
@@ -976,7 +976,7 @@ discard block |
||
| 976 | 976 | * Set WHERE parameters, when is array |
| 977 | 977 | * @param array $params |
| 978 | 978 | */ |
| 979 | - protected function _set_where_array(array $params){ |
|
| 979 | + protected function _set_where_array(array $params) { |
|
| 980 | 980 | foreach ($params as $field => $filter) |
| 981 | 981 | { |
| 982 | 982 | if (is_array($filter)) |
@@ -1042,7 +1042,7 @@ discard block |
||
| 1042 | 1042 | /** |
| 1043 | 1043 | Shortcut to controller |
| 1044 | 1044 | */ |
| 1045 | - public function __get($key){ |
|
| 1045 | + public function __get($key) { |
|
| 1046 | 1046 | return get_instance()->{$key}; |
| 1047 | 1047 | } |
| 1048 | 1048 | |
@@ -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 | /** |
@@ -260,8 +259,7 @@ discard block |
||
| 260 | 259 | $this->trigger('after_create', $insert_id); |
| 261 | 260 | //if the table doesn't have the auto increment field or sequence, the value of 0 will be returned |
| 262 | 261 | return ! $insert_id ? true : $insert_id; |
| 263 | - } |
|
| 264 | - else |
|
| 262 | + } else |
|
| 265 | 263 | { |
| 266 | 264 | return FALSE; |
| 267 | 265 | } |
@@ -298,8 +296,7 @@ discard block |
||
| 298 | 296 | $result = $this->_database->update($data, $escape); |
| 299 | 297 | $this->trigger('after_update', array($data, $result)); |
| 300 | 298 | return $result; |
| 301 | - } |
|
| 302 | - else |
|
| 299 | + } else |
|
| 303 | 300 | { |
| 304 | 301 | return FALSE; |
| 305 | 302 | } |
@@ -322,8 +319,7 @@ discard block |
||
| 322 | 319 | $result = $this->_database->update($data, $escape); |
| 323 | 320 | $this->trigger('after_update', array($data, $result)); |
| 324 | 321 | return $result; |
| 325 | - } |
|
| 326 | - else |
|
| 322 | + } else |
|
| 327 | 323 | { |
| 328 | 324 | return FALSE; |
| 329 | 325 | } |
@@ -340,8 +336,7 @@ discard block |
||
| 340 | 336 | if (is_array($args[1])){ |
| 341 | 337 | $data = array_pop($args); |
| 342 | 338 | } |
| 343 | - } |
|
| 344 | - else if (count($args) == 3){ |
|
| 339 | + } else if (count($args) == 3){ |
|
| 345 | 340 | if (is_array($args[2])){ |
| 346 | 341 | $data = array_pop($args); |
| 347 | 342 | } |
@@ -354,8 +349,7 @@ discard block |
||
| 354 | 349 | $result = $this->_database->update($data); |
| 355 | 350 | $this->trigger('after_update', array($data, $result)); |
| 356 | 351 | return $result; |
| 357 | - } |
|
| 358 | - else |
|
| 352 | + } else |
|
| 359 | 353 | { |
| 360 | 354 | return FALSE; |
| 361 | 355 | } |
@@ -385,8 +379,7 @@ discard block |
||
| 385 | 379 | { |
| 386 | 380 | $this->getQueryBuilder()->from($this->_table); |
| 387 | 381 | $result = $this->_database->update(array( $this->soft_delete_key => TRUE )); |
| 388 | - } |
|
| 389 | - else |
|
| 382 | + } else |
|
| 390 | 383 | { |
| 391 | 384 | $this->getQueryBuilder()->from($this->_table); |
| 392 | 385 | $result = $this->_database->delete(); |
@@ -409,8 +402,7 @@ discard block |
||
| 409 | 402 | { |
| 410 | 403 | $this->getQueryBuilder()->from($this->_table); |
| 411 | 404 | $result = $this->_database->update(array( $this->soft_delete_key => TRUE )); |
| 412 | - } |
|
| 413 | - else |
|
| 405 | + } else |
|
| 414 | 406 | { |
| 415 | 407 | $this->getQueryBuilder()->from($this->_table); |
| 416 | 408 | $result = $this->_database->delete(); |
@@ -431,8 +423,7 @@ discard block |
||
| 431 | 423 | { |
| 432 | 424 | $this->getQueryBuilder()->from($this->_table); |
| 433 | 425 | $result = $this->_database->update(array( $this->soft_delete_key => TRUE )); |
| 434 | - } |
|
| 435 | - else |
|
| 426 | + } else |
|
| 436 | 427 | { |
| 437 | 428 | $this->getQueryBuilder()->from($this->_table); |
| 438 | 429 | $result = $this->_database->delete(); |
@@ -494,8 +485,7 @@ discard block |
||
| 494 | 485 | if (count($args) == 2) |
| 495 | 486 | { |
| 496 | 487 | list($key, $value) = $args; |
| 497 | - } |
|
| 498 | - else |
|
| 488 | + } else |
|
| 499 | 489 | { |
| 500 | 490 | $key = $this->primary_key; |
| 501 | 491 | $value = $args[0]; |
@@ -647,8 +637,7 @@ discard block |
||
| 647 | 637 | if (is_object($row)) |
| 648 | 638 | { |
| 649 | 639 | $row->created_at = date('Y-m-d H:i:s'); |
| 650 | - } |
|
| 651 | - else |
|
| 640 | + } else |
|
| 652 | 641 | { |
| 653 | 642 | $row['created_at'] = date('Y-m-d H:i:s'); |
| 654 | 643 | } |
@@ -660,8 +649,7 @@ discard block |
||
| 660 | 649 | if (is_object($row)) |
| 661 | 650 | { |
| 662 | 651 | $row->updated_at = date('Y-m-d H:i:s'); |
| 663 | - } |
|
| 664 | - else |
|
| 652 | + } else |
|
| 665 | 653 | { |
| 666 | 654 | $row['updated_at'] = date('Y-m-d H:i:s'); |
| 667 | 655 | } |
@@ -688,8 +676,7 @@ discard block |
||
| 688 | 676 | if (is_array($row)) |
| 689 | 677 | { |
| 690 | 678 | $row[$column] = unserialize($row[$column]); |
| 691 | - } |
|
| 692 | - else |
|
| 679 | + } else |
|
| 693 | 680 | { |
| 694 | 681 | $row->$column = unserialize($row->$column); |
| 695 | 682 | } |
@@ -709,8 +696,7 @@ discard block |
||
| 709 | 696 | if (isset($row->$attr)){ |
| 710 | 697 | unset($row->$attr); |
| 711 | 698 | } |
| 712 | - } |
|
| 713 | - else |
|
| 699 | + } else |
|
| 714 | 700 | { |
| 715 | 701 | if (isset($row[$attr])){ |
| 716 | 702 | unset($row[$attr]); |
@@ -810,8 +796,7 @@ discard block |
||
| 810 | 796 | { |
| 811 | 797 | $this->getQueryBuilder()->orderBy($key, $value); |
| 812 | 798 | } |
| 813 | - } |
|
| 814 | - else |
|
| 799 | + } else |
|
| 815 | 800 | { |
| 816 | 801 | $this->getQueryBuilder()->orderBy($criteria, $order); |
| 817 | 802 | } |
@@ -842,8 +827,7 @@ discard block |
||
| 842 | 827 | { |
| 843 | 828 | $relationship = $value; |
| 844 | 829 | $options = array( 'primary_key' => $value . '_id', 'model' => $value . '_model' ); |
| 845 | - } |
|
| 846 | - else |
|
| 830 | + } else |
|
| 847 | 831 | { |
| 848 | 832 | $relationship = $key; |
| 849 | 833 | $options = $value; |
@@ -853,15 +837,13 @@ discard block |
||
| 853 | 837 | { |
| 854 | 838 | if (is_object($this->loaderInstance)){ |
| 855 | 839 | $this->loaderInstance->model($options['model'], $relationship . '_model'); |
| 856 | - } |
|
| 857 | - else{ |
|
| 840 | + } else{ |
|
| 858 | 841 | Loader::model($options['model'], $relationship . '_model'); |
| 859 | 842 | } |
| 860 | 843 | if (is_object($row)) |
| 861 | 844 | { |
| 862 | 845 | $row->{$relationship} = $this->{$relationship . '_model'}->get($row->{$options['primary_key']}); |
| 863 | - } |
|
| 864 | - else |
|
| 846 | + } else |
|
| 865 | 847 | { |
| 866 | 848 | $row[$relationship] = $this->{$relationship . '_model'}->get($row[$options['primary_key']]); |
| 867 | 849 | } |
@@ -881,8 +863,7 @@ discard block |
||
| 881 | 863 | { |
| 882 | 864 | $relationship = $value; |
| 883 | 865 | $options = array( 'primary_key' => $this->_table . '_id', 'model' => $value . '_model' ); |
| 884 | - } |
|
| 885 | - else |
|
| 866 | + } else |
|
| 886 | 867 | { |
| 887 | 868 | $relationship = $key; |
| 888 | 869 | $options = $value; |
@@ -892,15 +873,13 @@ discard block |
||
| 892 | 873 | { |
| 893 | 874 | if (is_object($this->loaderInstance)){ |
| 894 | 875 | $this->loaderInstance->model($options['model'], $relationship . '_model'); |
| 895 | - } |
|
| 896 | - else{ |
|
| 876 | + } else{ |
|
| 897 | 877 | Loader::model($options['model'], $relationship . '_model'); |
| 898 | 878 | } |
| 899 | 879 | if (is_object($row)) |
| 900 | 880 | { |
| 901 | 881 | $row->{$relationship} = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row->{$this->primary_key}); |
| 902 | - } |
|
| 903 | - else |
|
| 882 | + } else |
|
| 904 | 883 | { |
| 905 | 884 | $row[$relationship] = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row[$this->primary_key]); |
| 906 | 885 | } |
@@ -946,8 +925,7 @@ discard block |
||
| 946 | 925 | $fv = null; |
| 947 | 926 | if (is_object($this->formValidationInstance)){ |
| 948 | 927 | $fv = $this->formValidationInstance; |
| 949 | - } |
|
| 950 | - else{ |
|
| 928 | + } else{ |
|
| 951 | 929 | Loader::library('FormValidation'); |
| 952 | 930 | $fv = $this->formvalidation; |
| 953 | 931 | $this->setFormValidation($fv); |
@@ -959,13 +937,11 @@ discard block |
||
| 959 | 937 | if ($fv->run()) |
| 960 | 938 | { |
| 961 | 939 | return $data; |
| 962 | - } |
|
| 963 | - else |
|
| 940 | + } else |
|
| 964 | 941 | { |
| 965 | 942 | return FALSE; |
| 966 | 943 | } |
| 967 | - } |
|
| 968 | - else |
|
| 944 | + } else |
|
| 969 | 945 | { |
| 970 | 946 | return $data; |
| 971 | 947 | } |
@@ -982,14 +958,12 @@ discard block |
||
| 982 | 958 | if (is_array($filter)) |
| 983 | 959 | { |
| 984 | 960 | $this->getQueryBuilder()->in($field, $filter); |
| 985 | - } |
|
| 986 | - else |
|
| 961 | + } else |
|
| 987 | 962 | { |
| 988 | 963 | if (is_int($field)) |
| 989 | 964 | { |
| 990 | 965 | $this->getQueryBuilder()->where($filter); |
| 991 | - } |
|
| 992 | - else |
|
| 966 | + } else |
|
| 993 | 967 | { |
| 994 | 968 | $this->getQueryBuilder()->where($field, $filter); |
| 995 | 969 | } |
@@ -1006,33 +980,27 @@ discard block |
||
| 1006 | 980 | if (count($params) == 1 && is_array($params[0])) |
| 1007 | 981 | { |
| 1008 | 982 | $this->_set_where_array($params[0]); |
| 1009 | - } |
|
| 1010 | - else if (count($params) == 1) |
|
| 983 | + } else if (count($params) == 1) |
|
| 1011 | 984 | { |
| 1012 | 985 | $this->getQueryBuilder()->where($params[0]); |
| 1013 | - } |
|
| 1014 | - else if (count($params) == 2) |
|
| 986 | + } else if (count($params) == 2) |
|
| 1015 | 987 | { |
| 1016 | 988 | if (is_array($params[1])) |
| 1017 | 989 | { |
| 1018 | 990 | $this->getQueryBuilder()->in($params[0], $params[1]); |
| 1019 | - } |
|
| 1020 | - else |
|
| 991 | + } else |
|
| 1021 | 992 | { |
| 1022 | 993 | $this->getQueryBuilder()->where($params[0], $params[1]); |
| 1023 | 994 | } |
| 1024 | - } |
|
| 1025 | - else if (count($params) == 3) |
|
| 995 | + } else if (count($params) == 3) |
|
| 1026 | 996 | { |
| 1027 | 997 | $this->getQueryBuilder()->where($params[0], $params[1], $params[2]); |
| 1028 | - } |
|
| 1029 | - else |
|
| 998 | + } else |
|
| 1030 | 999 | { |
| 1031 | 1000 | if (is_array($params[1])) |
| 1032 | 1001 | { |
| 1033 | 1002 | $this->getQueryBuilder()->in($params[0], $params[1]); |
| 1034 | - } |
|
| 1035 | - else |
|
| 1003 | + } else |
|
| 1036 | 1004 | { |
| 1037 | 1005 | $this->getQueryBuilder()->where($params[0], $params[1]); |
| 1038 | 1006 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * You should have received a copy of the GNU General Public License |
| 23 | 23 | * along with this program; if not, write to the Free Software |
| 24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 25 | - */ |
|
| 25 | + */ |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -120,10 +120,10 @@ discard block |
||
| 120 | 120 | protected $_temporary_return_type = NULL; |
| 121 | 121 | |
| 122 | 122 | |
| 123 | - /** |
|
| 123 | + /** |
|
| 124 | 124 | The database cache time |
| 125 | - */ |
|
| 126 | - protected $dbCacheTime = 0; |
|
| 125 | + */ |
|
| 126 | + protected $dbCacheTime = 0; |
|
| 127 | 127 | |
| 128 | 128 | /** |
| 129 | 129 | * Instance of the Loader class |
@@ -151,12 +151,12 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | else{ |
| 153 | 153 | $obj = & get_instance(); |
| 154 | - if (isset($obj->database) && is_object($obj->database)){ |
|
| 154 | + if (isset($obj->database) && is_object($obj->database)){ |
|
| 155 | 155 | /** |
| 156 | - * NOTE: Need use "clone" because some Model need have the personal instance of the database library |
|
| 157 | - * to prevent duplication |
|
| 158 | - */ |
|
| 159 | - $this->setDatabaseInstance(clone $obj->database); |
|
| 156 | + * NOTE: Need use "clone" because some Model need have the personal instance of the database library |
|
| 157 | + * to prevent duplication |
|
| 158 | + */ |
|
| 159 | + $this->setDatabaseInstance(clone $obj->database); |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | public function get($primary_value) |
| 176 | 176 | { |
| 177 | - return $this->get_by($this->primary_key, $primary_value); |
|
| 177 | + return $this->get_by($this->primary_key, $primary_value); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -189,12 +189,12 @@ discard block |
||
| 189 | 189 | { |
| 190 | 190 | $this->getQueryBuilder()->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); |
| 191 | 191 | } |
| 192 | - $this->_set_where($where); |
|
| 192 | + $this->_set_where($where); |
|
| 193 | 193 | |
| 194 | 194 | $this->trigger('before_get'); |
| 195 | - $type = $this->_temporary_return_type == 'array' ? 'array' : false; |
|
| 195 | + $type = $this->_temporary_return_type == 'array' ? 'array' : false; |
|
| 196 | 196 | $this->getQueryBuilder()->from($this->_table); |
| 197 | - $row = $this->_database->get($type); |
|
| 197 | + $row = $this->_database->get($type); |
|
| 198 | 198 | $this->_temporary_return_type = $this->return_type; |
| 199 | 199 | $row = $this->trigger('after_get', $row); |
| 200 | 200 | $this->_with = array(); |
@@ -231,9 +231,9 @@ discard block |
||
| 231 | 231 | { |
| 232 | 232 | $this->getQueryBuilder()->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); |
| 233 | 233 | } |
| 234 | - $type = $this->_temporary_return_type == 'array' ? 'array':false; |
|
| 234 | + $type = $this->_temporary_return_type == 'array' ? 'array':false; |
|
| 235 | 235 | $this->getQueryBuilder()->from($this->_table); |
| 236 | - $result = $this->_database->getAll($type); |
|
| 236 | + $result = $this->_database->getAll($type); |
|
| 237 | 237 | $this->_temporary_return_type = $this->return_type; |
| 238 | 238 | |
| 239 | 239 | foreach ($result as $key => &$row) |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | /** |
| 248 | 248 | * Insert a new row into the table. $data should be an associative array |
| 249 | 249 | * of data to be inserted. Returns newly created ID. |
| 250 | - * @see Database::insert |
|
| 250 | + * @see Database::insert |
|
| 251 | 251 | */ |
| 252 | 252 | public function insert($data = array(), $skip_validation = FALSE, $escape = true) |
| 253 | 253 | { |
@@ -260,11 +260,11 @@ discard block |
||
| 260 | 260 | { |
| 261 | 261 | $data = $this->trigger('before_create', $data); |
| 262 | 262 | $this->getQueryBuilder()->from($this->_table); |
| 263 | - $this->_database->insert($data, $escape); |
|
| 263 | + $this->_database->insert($data, $escape); |
|
| 264 | 264 | $insert_id = $this->_database->insertId(); |
| 265 | 265 | $this->trigger('after_create', $insert_id); |
| 266 | - //if the table doesn't have the auto increment field or sequence, the value of 0 will be returned |
|
| 267 | - return ! $insert_id ? true : $insert_id; |
|
| 266 | + //if the table doesn't have the auto increment field or sequence, the value of 0 will be returned |
|
| 267 | + return ! $insert_id ? true : $insert_id; |
|
| 268 | 268 | } |
| 269 | 269 | else |
| 270 | 270 | { |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | { |
| 325 | 325 | $this->getQueryBuilder()->in($this->primary_key, $primary_values) |
| 326 | 326 | ->from($this->_table); |
| 327 | - $result = $this->_database->update($data, $escape); |
|
| 327 | + $result = $this->_database->update($data, $escape); |
|
| 328 | 328 | $this->trigger('after_update', array($data, $result)); |
| 329 | 329 | return $result; |
| 330 | 330 | } |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | { |
| 357 | 357 | $this->_set_where($args); |
| 358 | 358 | $this->getQueryBuilder()->from($this->_table); |
| 359 | - $result = $this->_database->update($data); |
|
| 359 | + $result = $this->_database->update($data); |
|
| 360 | 360 | $this->trigger('after_update', array($data, $result)); |
| 361 | 361 | return $result; |
| 362 | 362 | } |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | { |
| 374 | 374 | $data = $this->trigger('before_update', $data); |
| 375 | 375 | $this->getQueryBuilder()->from($this->_table); |
| 376 | - $result = $this->_database->update($data, $escape); |
|
| 376 | + $result = $this->_database->update($data, $escape); |
|
| 377 | 377 | $this->trigger('after_update', array($data, $result)); |
| 378 | 378 | return $result; |
| 379 | 379 | } |
@@ -385,16 +385,16 @@ discard block |
||
| 385 | 385 | { |
| 386 | 386 | $this->trigger('before_delete', $id); |
| 387 | 387 | $this->getQueryBuilder()->where($this->primary_key, $id); |
| 388 | - $result = false; |
|
| 388 | + $result = false; |
|
| 389 | 389 | if ($this->soft_delete) |
| 390 | 390 | { |
| 391 | 391 | $this->getQueryBuilder()->from($this->_table); |
| 392 | - $result = $this->_database->update(array( $this->soft_delete_key => TRUE )); |
|
| 392 | + $result = $this->_database->update(array( $this->soft_delete_key => TRUE )); |
|
| 393 | 393 | } |
| 394 | 394 | else |
| 395 | 395 | { |
| 396 | 396 | $this->getQueryBuilder()->from($this->_table); |
| 397 | - $result = $this->_database->delete(); |
|
| 397 | + $result = $this->_database->delete(); |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | $this->trigger('after_delete', $result); |
@@ -407,18 +407,18 @@ discard block |
||
| 407 | 407 | public function delete_by() |
| 408 | 408 | { |
| 409 | 409 | $where = func_get_args(); |
| 410 | - $where = $this->trigger('before_delete', $where); |
|
| 410 | + $where = $this->trigger('before_delete', $where); |
|
| 411 | 411 | $this->_set_where($where); |
| 412 | - $result = false; |
|
| 412 | + $result = false; |
|
| 413 | 413 | if ($this->soft_delete) |
| 414 | 414 | { |
| 415 | 415 | $this->getQueryBuilder()->from($this->_table); |
| 416 | - $result = $this->_database->update(array( $this->soft_delete_key => TRUE )); |
|
| 416 | + $result = $this->_database->update(array( $this->soft_delete_key => TRUE )); |
|
| 417 | 417 | } |
| 418 | 418 | else |
| 419 | 419 | { |
| 420 | 420 | $this->getQueryBuilder()->from($this->_table); |
| 421 | - $result = $this->_database->delete(); |
|
| 421 | + $result = $this->_database->delete(); |
|
| 422 | 422 | } |
| 423 | 423 | $this->trigger('after_delete', $result); |
| 424 | 424 | return $result; |
@@ -431,16 +431,16 @@ discard block |
||
| 431 | 431 | { |
| 432 | 432 | $primary_values = $this->trigger('before_delete', $primary_values); |
| 433 | 433 | $this->getQueryBuilder()->in($this->primary_key, $primary_values); |
| 434 | - $result = false; |
|
| 434 | + $result = false; |
|
| 435 | 435 | if ($this->soft_delete) |
| 436 | 436 | { |
| 437 | 437 | $this->getQueryBuilder()->from($this->_table); |
| 438 | - $result = $this->_database->update(array( $this->soft_delete_key => TRUE )); |
|
| 438 | + $result = $this->_database->update(array( $this->soft_delete_key => TRUE )); |
|
| 439 | 439 | } |
| 440 | 440 | else |
| 441 | 441 | { |
| 442 | 442 | $this->getQueryBuilder()->from($this->_table); |
| 443 | - $result = $this->_database->delete(); |
|
| 443 | + $result = $this->_database->delete(); |
|
| 444 | 444 | } |
| 445 | 445 | $this->trigger('after_delete', $result); |
| 446 | 446 | return $result; |
@@ -452,8 +452,8 @@ discard block |
||
| 452 | 452 | */ |
| 453 | 453 | public function truncate() |
| 454 | 454 | { |
| 455 | - $this->getQueryBuilder()->from($this->_table); |
|
| 456 | - $result = $this->_database->delete(); |
|
| 455 | + $this->getQueryBuilder()->from($this->_table); |
|
| 456 | + $result = $this->_database->delete(); |
|
| 457 | 457 | return $result; |
| 458 | 458 | } |
| 459 | 459 | |
@@ -471,14 +471,14 @@ discard block |
||
| 471 | 471 | return $this; |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | - /** |
|
| 475 | - * Relationship |
|
| 476 | - */ |
|
| 474 | + /** |
|
| 475 | + * Relationship |
|
| 476 | + */ |
|
| 477 | 477 | public function relate($row) |
| 478 | 478 | { |
| 479 | - if (empty($row)) |
|
| 479 | + if (empty($row)) |
|
| 480 | 480 | { |
| 481 | - return $row; |
|
| 481 | + return $row; |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | $row = $this->relateBelongsTo($row); |
@@ -511,9 +511,9 @@ discard block |
||
| 511 | 511 | $this->getQueryBuilder()->where($this->soft_delete_key, FALSE); |
| 512 | 512 | } |
| 513 | 513 | $this->getQueryBuilder() |
| 514 | - ->select(array($key, $value)) |
|
| 515 | - ->from($this->_table); |
|
| 516 | - $result = $this->_database->getAll(); |
|
| 514 | + ->select(array($key, $value)) |
|
| 515 | + ->from($this->_table); |
|
| 516 | + $result = $this->_database->getAll(); |
|
| 517 | 517 | $options = array(); |
| 518 | 518 | foreach ($result as $row) |
| 519 | 519 | { |
@@ -535,7 +535,7 @@ discard block |
||
| 535 | 535 | $where = func_get_args(); |
| 536 | 536 | $this->_set_where($where); |
| 537 | 537 | $this->getQueryBuilder()->from($this->_table); |
| 538 | - $this->_database->getAll(); |
|
| 538 | + $this->_database->getAll(); |
|
| 539 | 539 | return $this->_database->numRows(); |
| 540 | 540 | } |
| 541 | 541 | |
@@ -548,20 +548,20 @@ discard block |
||
| 548 | 548 | { |
| 549 | 549 | $this->getQueryBuilder()->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); |
| 550 | 550 | } |
| 551 | - $this->getQueryBuilder()->from($this->_table); |
|
| 552 | - $this->_database->getAll(); |
|
| 551 | + $this->getQueryBuilder()->from($this->_table); |
|
| 552 | + $this->_database->getAll(); |
|
| 553 | 553 | return $this->_database->numRows(); |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | - /** |
|
| 557 | - * Enabled cache temporary |
|
| 558 | - */ |
|
| 559 | - public function cached($ttl = 0){ |
|
| 560 | - if ($ttl > 0){ |
|
| 561 | - $this->_database = $this->_database->cached($ttl); |
|
| 562 | - } |
|
| 563 | - return $this; |
|
| 564 | - } |
|
| 556 | + /** |
|
| 557 | + * Enabled cache temporary |
|
| 558 | + */ |
|
| 559 | + public function cached($ttl = 0){ |
|
| 560 | + if ($ttl > 0){ |
|
| 561 | + $this->_database = $this->_database->cached($ttl); |
|
| 562 | + } |
|
| 563 | + return $this; |
|
| 564 | + } |
|
| 565 | 565 | |
| 566 | 566 | /** |
| 567 | 567 | * Tell the class to skip the insert validation |
@@ -585,10 +585,10 @@ discard block |
||
| 585 | 585 | */ |
| 586 | 586 | public function get_next_id() |
| 587 | 587 | { |
| 588 | - $this->getQueryBuilder()->select('AUTO_INCREMENT') |
|
| 589 | - ->from('information_schema.TABLES') |
|
| 590 | - ->where('TABLE_NAME', $this->_table) |
|
| 591 | - ->where('TABLE_SCHEMA', $this->_database->getDatabaseName()); |
|
| 588 | + $this->getQueryBuilder()->select('AUTO_INCREMENT') |
|
| 589 | + ->from('information_schema.TABLES') |
|
| 590 | + ->where('TABLE_NAME', $this->_table) |
|
| 591 | + ->where('TABLE_SCHEMA', $this->_database->getDatabaseName()); |
|
| 592 | 592 | return (int) $this->_database->get()->AUTO_INCREMENT; |
| 593 | 593 | } |
| 594 | 594 | |
@@ -711,24 +711,24 @@ discard block |
||
| 711 | 711 | { |
| 712 | 712 | if (is_object($row)) |
| 713 | 713 | { |
| 714 | - if (isset($row->$attr)){ |
|
| 715 | - unset($row->$attr); |
|
| 716 | - } |
|
| 714 | + if (isset($row->$attr)){ |
|
| 715 | + unset($row->$attr); |
|
| 716 | + } |
|
| 717 | 717 | } |
| 718 | 718 | else |
| 719 | 719 | { |
| 720 | - if (isset($row[$attr])){ |
|
| 721 | - unset($row[$attr]); |
|
| 722 | - } |
|
| 720 | + if (isset($row[$attr])){ |
|
| 721 | + unset($row[$attr]); |
|
| 722 | + } |
|
| 723 | 723 | } |
| 724 | 724 | } |
| 725 | 725 | return $row; |
| 726 | 726 | } |
| 727 | 727 | |
| 728 | - /** |
|
| 729 | - * Return the database instance |
|
| 730 | - * @return Database the database instance |
|
| 731 | - */ |
|
| 728 | + /** |
|
| 729 | + * Return the database instance |
|
| 730 | + * @return Database the database instance |
|
| 731 | + */ |
|
| 732 | 732 | public function getDatabaseInstance(){ |
| 733 | 733 | return $this->_database; |
| 734 | 734 | } |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | * set the Database instance for future use |
| 738 | 738 | * @param Database $db the database object |
| 739 | 739 | */ |
| 740 | - public function setDatabaseInstance($db){ |
|
| 740 | + public function setDatabaseInstance($db){ |
|
| 741 | 741 | $this->_database = $db; |
| 742 | 742 | if ($this->dbCacheTime > 0){ |
| 743 | 743 | $this->_database->setCache($this->dbCacheTime); |
@@ -756,14 +756,14 @@ discard block |
||
| 756 | 756 | /** |
| 757 | 757 | * Set the loader instance for future use |
| 758 | 758 | * @param Loader $loader the loader object |
| 759 | - * @return object |
|
| 759 | + * @return object |
|
| 760 | 760 | */ |
| 761 | - public function setLoader($loader){ |
|
| 761 | + public function setLoader($loader){ |
|
| 762 | 762 | $this->loaderInstance = $loader; |
| 763 | 763 | return $this; |
| 764 | 764 | } |
| 765 | 765 | |
| 766 | - /** |
|
| 766 | + /** |
|
| 767 | 767 | * Return the queryBuilder instance this is the shortcut to database queryBuilder |
| 768 | 768 | * @return object the DatabaseQueryBuilder instance |
| 769 | 769 | */ |
@@ -774,9 +774,9 @@ discard block |
||
| 774 | 774 | /** |
| 775 | 775 | * Set the DatabaseQueryBuilder instance for future use |
| 776 | 776 | * @param object $queryBuilder the DatabaseQueryBuilder object |
| 777 | - * @return object |
|
| 777 | + * @return object |
|
| 778 | 778 | */ |
| 779 | - public function setQueryBuilder($queryBuilder){ |
|
| 779 | + public function setQueryBuilder($queryBuilder){ |
|
| 780 | 780 | $this->_database->setQueryBuilder($queryBuilder); |
| 781 | 781 | return $this; |
| 782 | 782 | } |
@@ -793,9 +793,9 @@ discard block |
||
| 793 | 793 | /** |
| 794 | 794 | * Set the form validation instance for future use |
| 795 | 795 | * @param FormValidation $fv the form validation object |
| 796 | - * @return object |
|
| 796 | + * @return object |
|
| 797 | 797 | */ |
| 798 | - public function setFormValidation($fv){ |
|
| 798 | + public function setFormValidation($fv){ |
|
| 799 | 799 | $this->formValidationInstance = $fv; |
| 800 | 800 | return $this; |
| 801 | 801 | } |
@@ -836,12 +836,12 @@ discard block |
||
| 836 | 836 | * INTERNAL METHODS |
| 837 | 837 | * ------------------------------------------------------------ */ |
| 838 | 838 | |
| 839 | - /** |
|
| 840 | - * relate for the relation "belongs_to" |
|
| 841 | - * @return mixed |
|
| 842 | - */ |
|
| 843 | - protected function relateBelongsTo($row){ |
|
| 844 | - foreach ($this->belongs_to as $key => $value) |
|
| 839 | + /** |
|
| 840 | + * relate for the relation "belongs_to" |
|
| 841 | + * @return mixed |
|
| 842 | + */ |
|
| 843 | + protected function relateBelongsTo($row){ |
|
| 844 | + foreach ($this->belongs_to as $key => $value) |
|
| 845 | 845 | { |
| 846 | 846 | if (is_string($value)) |
| 847 | 847 | { |
@@ -872,15 +872,15 @@ discard block |
||
| 872 | 872 | } |
| 873 | 873 | } |
| 874 | 874 | } |
| 875 | - return $row; |
|
| 876 | - } |
|
| 877 | - |
|
| 878 | - /** |
|
| 879 | - * relate for the relation "has_many" |
|
| 880 | - * @return mixed |
|
| 881 | - */ |
|
| 882 | - protected function relateHasMany($row){ |
|
| 883 | - foreach ($this->has_many as $key => $value) |
|
| 875 | + return $row; |
|
| 876 | + } |
|
| 877 | + |
|
| 878 | + /** |
|
| 879 | + * relate for the relation "has_many" |
|
| 880 | + * @return mixed |
|
| 881 | + */ |
|
| 882 | + protected function relateHasMany($row){ |
|
| 883 | + foreach ($this->has_many as $key => $value) |
|
| 884 | 884 | { |
| 885 | 885 | if (is_string($value)) |
| 886 | 886 | { |
@@ -911,8 +911,8 @@ discard block |
||
| 911 | 911 | } |
| 912 | 912 | } |
| 913 | 913 | } |
| 914 | - return $row; |
|
| 915 | - } |
|
| 914 | + return $row; |
|
| 915 | + } |
|
| 916 | 916 | |
| 917 | 917 | /** |
| 918 | 918 | * Trigger an event and call its observers. Pass through the event name |
@@ -977,30 +977,30 @@ discard block |
||
| 977 | 977 | } |
| 978 | 978 | |
| 979 | 979 | |
| 980 | - /** |
|
| 981 | - * Set WHERE parameters, when is array |
|
| 982 | - * @param array $params |
|
| 983 | - */ |
|
| 984 | - protected function _set_where_array(array $params){ |
|
| 985 | - foreach ($params as $field => $filter) |
|
| 986 | - { |
|
| 987 | - if (is_array($filter)) |
|
| 988 | - { |
|
| 989 | - $this->getQueryBuilder()->in($field, $filter); |
|
| 990 | - } |
|
| 991 | - else |
|
| 992 | - { |
|
| 993 | - if (is_int($field)) |
|
| 994 | - { |
|
| 995 | - $this->getQueryBuilder()->where($filter); |
|
| 996 | - } |
|
| 997 | - else |
|
| 998 | - { |
|
| 999 | - $this->getQueryBuilder()->where($field, $filter); |
|
| 1000 | - } |
|
| 1001 | - } |
|
| 1002 | - } |
|
| 1003 | - } |
|
| 980 | + /** |
|
| 981 | + * Set WHERE parameters, when is array |
|
| 982 | + * @param array $params |
|
| 983 | + */ |
|
| 984 | + protected function _set_where_array(array $params){ |
|
| 985 | + foreach ($params as $field => $filter) |
|
| 986 | + { |
|
| 987 | + if (is_array($filter)) |
|
| 988 | + { |
|
| 989 | + $this->getQueryBuilder()->in($field, $filter); |
|
| 990 | + } |
|
| 991 | + else |
|
| 992 | + { |
|
| 993 | + if (is_int($field)) |
|
| 994 | + { |
|
| 995 | + $this->getQueryBuilder()->where($filter); |
|
| 996 | + } |
|
| 997 | + else |
|
| 998 | + { |
|
| 999 | + $this->getQueryBuilder()->where($field, $filter); |
|
| 1000 | + } |
|
| 1001 | + } |
|
| 1002 | + } |
|
| 1003 | + } |
|
| 1004 | 1004 | |
| 1005 | 1005 | |
| 1006 | 1006 | /** |
@@ -1016,8 +1016,8 @@ discard block |
||
| 1016 | 1016 | { |
| 1017 | 1017 | $this->getQueryBuilder()->where($params[0]); |
| 1018 | 1018 | } |
| 1019 | - else if (count($params) == 2) |
|
| 1020 | - { |
|
| 1019 | + else if (count($params) == 2) |
|
| 1020 | + { |
|
| 1021 | 1021 | if (is_array($params[1])) |
| 1022 | 1022 | { |
| 1023 | 1023 | $this->getQueryBuilder()->in($params[0], $params[1]); |
@@ -1026,11 +1026,11 @@ discard block |
||
| 1026 | 1026 | { |
| 1027 | 1027 | $this->getQueryBuilder()->where($params[0], $params[1]); |
| 1028 | 1028 | } |
| 1029 | - } |
|
| 1030 | - else if (count($params) == 3) |
|
| 1031 | - { |
|
| 1032 | - $this->getQueryBuilder()->where($params[0], $params[1], $params[2]); |
|
| 1033 | - } |
|
| 1029 | + } |
|
| 1030 | + else if (count($params) == 3) |
|
| 1031 | + { |
|
| 1032 | + $this->getQueryBuilder()->where($params[0], $params[1], $params[2]); |
|
| 1033 | + } |
|
| 1034 | 1034 | else |
| 1035 | 1035 | { |
| 1036 | 1036 | if (is_array($params[1])) |
@@ -1046,7 +1046,7 @@ discard block |
||
| 1046 | 1046 | |
| 1047 | 1047 | /** |
| 1048 | 1048 | Shortcut to controller |
| 1049 | - */ |
|
| 1049 | + */ |
|
| 1050 | 1050 | public function __get($key){ |
| 1051 | 1051 | return get_instance()->{$key}; |
| 1052 | 1052 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | - class Module{ |
|
| 27 | + class Module { |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * list of loaded module |
@@ -42,9 +42,9 @@ discard block |
||
| 42 | 42 | * The signleton of the logger |
| 43 | 43 | * @return Object the Log instance |
| 44 | 44 | */ |
| 45 | - private static function getLogger(){ |
|
| 46 | - if(self::$logger == null){ |
|
| 47 | - self::$logger[0] =& class_loader('Log', 'classes'); |
|
| 45 | + private static function getLogger() { |
|
| 46 | + if (self::$logger == null) { |
|
| 47 | + self::$logger[0] = & class_loader('Log', 'classes'); |
|
| 48 | 48 | self::$logger[0]->setLogger('Library::Module'); |
| 49 | 49 | } |
| 50 | 50 | return self::$logger[0]; |
@@ -53,24 +53,24 @@ discard block |
||
| 53 | 53 | /** |
| 54 | 54 | * Initialise the module list by scanning the directory MODULE_PATH |
| 55 | 55 | */ |
| 56 | - public function init(){ |
|
| 56 | + public function init() { |
|
| 57 | 57 | $logger = self::getLogger(); |
| 58 | 58 | $logger->debug('Check if the application contains the modules ...'); |
| 59 | 59 | $moduleDir = opendir(MODULE_PATH); |
| 60 | - if(is_resource($moduleDir)){ |
|
| 61 | - while(($module = readdir($moduleDir)) !== false){ |
|
| 62 | - if(preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)){ |
|
| 60 | + if (is_resource($moduleDir)) { |
|
| 61 | + while (($module = readdir($moduleDir)) !== false) { |
|
| 62 | + if (preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)) { |
|
| 63 | 63 | self::$list[] = $module; |
| 64 | 64 | } |
| 65 | - else{ |
|
| 66 | - $logger->info('Skipping [' .$module. '], may be this is not a directory or does not exists or is invalid name'); |
|
| 65 | + else { |
|
| 66 | + $logger->info('Skipping [' . $module . '], may be this is not a directory or does not exists or is invalid name'); |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | closedir($moduleDir); |
| 70 | 70 | } |
| 71 | 71 | ksort(self::$list); |
| 72 | 72 | |
| 73 | - if(self::hasModule()){ |
|
| 73 | + if (self::hasModule()) { |
|
| 74 | 74 | $logger->info('The application contains the module below [' . implode(', ', self::getModuleList()) . ']'); |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | * Get the list of the custom autoload configuration from module if exists |
| 80 | 80 | * @return array|boolean the autoload configurations list or false if no module contains the autoload configuration values |
| 81 | 81 | */ |
| 82 | - public static function getModulesAutoloadConfig(){ |
|
| 82 | + public static function getModulesAutoloadConfig() { |
|
| 83 | 83 | $logger = self::getLogger(); |
| 84 | - if(! self::hasModule()){ |
|
| 84 | + if (!self::hasModule()) { |
|
| 85 | 85 | $logger->info('No module was loaded skipping.'); |
| 86 | 86 | return false; |
| 87 | 87 | } |
@@ -94,10 +94,10 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | foreach (self::$list as $module) { |
| 96 | 96 | $file = MODULE_PATH . $module . DS . 'config' . DS . 'autoload.php'; |
| 97 | - if(file_exists($file)){ |
|
| 97 | + if (file_exists($file)) { |
|
| 98 | 98 | $autoload = array(); |
| 99 | 99 | require_once $file; |
| 100 | - if(! empty($autoload) && is_array($autoload)){ |
|
| 100 | + if (!empty($autoload) && is_array($autoload)) { |
|
| 101 | 101 | $autoloads = array_merge_recursive($autoloads, $autoload); |
| 102 | 102 | unset($autoload); |
| 103 | 103 | } |
@@ -110,19 +110,19 @@ discard block |
||
| 110 | 110 | * Get the list of the custom routes configuration from module if exists |
| 111 | 111 | * @return array|boolean the routes list or false if no module contains the routes configuration |
| 112 | 112 | */ |
| 113 | - public static function getModulesRoutes(){ |
|
| 113 | + public static function getModulesRoutes() { |
|
| 114 | 114 | $logger = self::getLogger(); |
| 115 | - if(! self::hasModule()){ |
|
| 115 | + if (!self::hasModule()) { |
|
| 116 | 116 | $logger->info('No module was loaded skipping.'); |
| 117 | 117 | return false; |
| 118 | 118 | } |
| 119 | 119 | $routes = array(); |
| 120 | 120 | foreach (self::$list as $module) { |
| 121 | 121 | $file = MODULE_PATH . $module . DS . 'config' . DS . 'routes.php'; |
| 122 | - if(file_exists($file)){ |
|
| 122 | + if (file_exists($file)) { |
|
| 123 | 123 | $route = array(); |
| 124 | 124 | require_once $file; |
| 125 | - if(! empty($route) && is_array($route)){ |
|
| 125 | + if (!empty($route) && is_array($route)) { |
|
| 126 | 126 | $routes = array_merge($routes, $route); |
| 127 | 127 | unset($route); |
| 128 | 128 | } |
@@ -138,23 +138,23 @@ discard block |
||
| 138 | 138 | * @param string $module the module name |
| 139 | 139 | * @return boolean|string false or null if no module have this controller, path the full path of the controller |
| 140 | 140 | */ |
| 141 | - public static function findControllerFullPath($class, $module = null){ |
|
| 141 | + public static function findControllerFullPath($class, $module = null) { |
|
| 142 | 142 | $logger = self::getLogger(); |
| 143 | - if(! self::hasModule()){ |
|
| 143 | + if (!self::hasModule()) { |
|
| 144 | 144 | $logger->info('No module was loaded skiping.'); |
| 145 | 145 | return false; |
| 146 | 146 | } |
| 147 | 147 | $class = str_ireplace('.php', '', $class); |
| 148 | 148 | $class = ucfirst($class); |
| 149 | - $classFile = $class.'.php'; |
|
| 150 | - $logger->debug('Checking the controller [' . $class . '] in module [' .$module. '] ...'); |
|
| 149 | + $classFile = $class . '.php'; |
|
| 150 | + $logger->debug('Checking the controller [' . $class . '] in module [' . $module . '] ...'); |
|
| 151 | 151 | $filePath = MODULE_PATH . $module . DS . 'controllers' . DS . $classFile; |
| 152 | - if(file_exists($filePath)){ |
|
| 153 | - $logger->info('Found controller [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 152 | + if (file_exists($filePath)) { |
|
| 153 | + $logger->info('Found controller [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']'); |
|
| 154 | 154 | return $filePath; |
| 155 | 155 | } |
| 156 | - else{ |
|
| 157 | - $logger->info('Controller [' . $class . '] does not exist in the module [' .$module. ']'); |
|
| 156 | + else { |
|
| 157 | + $logger->info('Controller [' . $class . '] does not exist in the module [' . $module . ']'); |
|
| 158 | 158 | return false; |
| 159 | 159 | } |
| 160 | 160 | } |
@@ -165,23 +165,23 @@ discard block |
||
| 165 | 165 | * @param string $module the module name |
| 166 | 166 | * @return boolean|string false or null if no module have this model, return the full path of this model |
| 167 | 167 | */ |
| 168 | - public static function findModelFullPath($class, $module = null){ |
|
| 168 | + public static function findModelFullPath($class, $module = null) { |
|
| 169 | 169 | $logger = self::getLogger(); |
| 170 | - if(! self::hasModule()){ |
|
| 170 | + if (!self::hasModule()) { |
|
| 171 | 171 | $logger->info('No module was loaded skiping.'); |
| 172 | 172 | return false; |
| 173 | 173 | } |
| 174 | 174 | $class = str_ireplace('.php', '', $class); |
| 175 | 175 | $class = ucfirst($class); |
| 176 | - $classFile = $class.'.php'; |
|
| 177 | - $logger->debug('Checking model [' . $class . '] in module [' .$module. '] ...'); |
|
| 176 | + $classFile = $class . '.php'; |
|
| 177 | + $logger->debug('Checking model [' . $class . '] in module [' . $module . '] ...'); |
|
| 178 | 178 | $filePath = MODULE_PATH . $module . DS . 'models' . DS . $classFile; |
| 179 | - if(file_exists($filePath)){ |
|
| 180 | - $logger->info('Found model [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 179 | + if (file_exists($filePath)) { |
|
| 180 | + $logger->info('Found model [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']'); |
|
| 181 | 181 | return $filePath; |
| 182 | 182 | } |
| 183 | - else{ |
|
| 184 | - $logger->info('Model [' . $class . '] does not exist in the module [' .$module. ']'); |
|
| 183 | + else { |
|
| 184 | + $logger->info('Model [' . $class . '] does not exist in the module [' . $module . ']'); |
|
| 185 | 185 | return false; |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -192,22 +192,22 @@ discard block |
||
| 192 | 192 | * @param string $module the module name |
| 193 | 193 | * @return boolean|string false or null if no module have this configuration, return the full path of this configuration |
| 194 | 194 | */ |
| 195 | - public static function findConfigFullPath($configuration, $module = null){ |
|
| 195 | + public static function findConfigFullPath($configuration, $module = null) { |
|
| 196 | 196 | $logger = self::getLogger(); |
| 197 | - if(! self::hasModule()){ |
|
| 197 | + if (!self::hasModule()) { |
|
| 198 | 198 | $logger->info('No module was loaded skiping.'); |
| 199 | 199 | return false; |
| 200 | 200 | } |
| 201 | 201 | $configuration = str_ireplace('.php', '', $configuration); |
| 202 | - $file = $configuration.'.php'; |
|
| 203 | - $logger->debug('Checking configuration [' . $configuration . '] in module [' .$module. '] ...'); |
|
| 202 | + $file = $configuration . '.php'; |
|
| 203 | + $logger->debug('Checking configuration [' . $configuration . '] in module [' . $module . '] ...'); |
|
| 204 | 204 | $filePath = MODULE_PATH . $module . DS . 'config' . DS . $file; |
| 205 | - if(file_exists($filePath)){ |
|
| 206 | - $logger->info('Found configuration [' . $configuration . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 205 | + if (file_exists($filePath)) { |
|
| 206 | + $logger->info('Found configuration [' . $configuration . '] in module [' . $module . '], the file path is [' . $filePath . ']'); |
|
| 207 | 207 | return $filePath; |
| 208 | 208 | } |
| 209 | - else{ |
|
| 210 | - $logger->info('Configuration [' . $configuration . '] does not exist in the module [' .$module. ']'); |
|
| 209 | + else { |
|
| 210 | + $logger->info('Configuration [' . $configuration . '] does not exist in the module [' . $module . ']'); |
|
| 211 | 211 | return false; |
| 212 | 212 | } |
| 213 | 213 | } |
@@ -218,23 +218,23 @@ discard block |
||
| 218 | 218 | * @param string $module the module name |
| 219 | 219 | * @return boolean|string false or null if no module have this helper, return the full path of this helper |
| 220 | 220 | */ |
| 221 | - public static function findFunctionFullPath($helper, $module = null){ |
|
| 221 | + public static function findFunctionFullPath($helper, $module = null) { |
|
| 222 | 222 | $logger = self::getLogger(); |
| 223 | - if(! self::hasModule()){ |
|
| 223 | + if (!self::hasModule()) { |
|
| 224 | 224 | $logger->info('No module was loaded skiping.'); |
| 225 | 225 | return false; |
| 226 | 226 | } |
| 227 | 227 | $helper = str_ireplace('.php', '', $helper); |
| 228 | 228 | $helper = str_ireplace('function_', '', $helper); |
| 229 | - $file = 'function_'.$helper.'.php'; |
|
| 230 | - $logger->debug('Checking helper [' . $helper . '] in module [' .$module. '] ...'); |
|
| 229 | + $file = 'function_' . $helper . '.php'; |
|
| 230 | + $logger->debug('Checking helper [' . $helper . '] in module [' . $module . '] ...'); |
|
| 231 | 231 | $filePath = MODULE_PATH . $module . DS . 'functions' . DS . $file; |
| 232 | - if(file_exists($filePath)){ |
|
| 233 | - $logger->info('Found helper [' . $helper . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 232 | + if (file_exists($filePath)) { |
|
| 233 | + $logger->info('Found helper [' . $helper . '] in module [' . $module . '], the file path is [' . $filePath . ']'); |
|
| 234 | 234 | return $filePath; |
| 235 | 235 | } |
| 236 | - else{ |
|
| 237 | - $logger->info('Helper [' . $helper . '] does not exist in the module [' .$module. ']'); |
|
| 236 | + else { |
|
| 237 | + $logger->info('Helper [' . $helper . '] does not exist in the module [' . $module . ']'); |
|
| 238 | 238 | return false; |
| 239 | 239 | } |
| 240 | 240 | } |
@@ -246,22 +246,22 @@ discard block |
||
| 246 | 246 | * @param string $module the module name |
| 247 | 247 | * @return boolean|string false or null if no module have this library, return the full path of this library |
| 248 | 248 | */ |
| 249 | - public static function findLibraryFullPath($class, $module = null){ |
|
| 249 | + public static function findLibraryFullPath($class, $module = null) { |
|
| 250 | 250 | $logger = self::getLogger(); |
| 251 | - if(! self::hasModule()){ |
|
| 251 | + if (!self::hasModule()) { |
|
| 252 | 252 | $logger->info('No module was loaded skiping.'); |
| 253 | 253 | return false; |
| 254 | 254 | } |
| 255 | 255 | $class = str_ireplace('.php', '', $class); |
| 256 | - $file = $class.'.php'; |
|
| 257 | - $logger->debug('Checking library [' . $class . '] in module [' .$module. '] ...'); |
|
| 256 | + $file = $class . '.php'; |
|
| 257 | + $logger->debug('Checking library [' . $class . '] in module [' . $module . '] ...'); |
|
| 258 | 258 | $filePath = MODULE_PATH . $module . DS . 'libraries' . DS . $file; |
| 259 | - if(file_exists($filePath)){ |
|
| 260 | - $logger->info('Found library [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 259 | + if (file_exists($filePath)) { |
|
| 260 | + $logger->info('Found library [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']'); |
|
| 261 | 261 | return $filePath; |
| 262 | 262 | } |
| 263 | - else{ |
|
| 264 | - $logger->info('Library [' . $class . '] does not exist in the module [' .$module. ']'); |
|
| 263 | + else { |
|
| 264 | + $logger->info('Library [' . $class . '] does not exist in the module [' . $module . ']'); |
|
| 265 | 265 | return false; |
| 266 | 266 | } |
| 267 | 267 | } |
@@ -273,9 +273,9 @@ discard block |
||
| 273 | 273 | * @param string $module the module name to check |
| 274 | 274 | * @return boolean|string false or null if no module have this view, path the full path of the view |
| 275 | 275 | */ |
| 276 | - public static function findViewFullPath($view, $module = null){ |
|
| 276 | + public static function findViewFullPath($view, $module = null) { |
|
| 277 | 277 | $logger = self::getLogger(); |
| 278 | - if(! self::hasModule()){ |
|
| 278 | + if (!self::hasModule()) { |
|
| 279 | 279 | $logger->info('No module was loaded skiping.'); |
| 280 | 280 | return false; |
| 281 | 281 | } |
@@ -283,14 +283,14 @@ discard block |
||
| 283 | 283 | $view = trim($view, '/\\'); |
| 284 | 284 | $view = str_ireplace('/', DS, $view); |
| 285 | 285 | $viewFile = $view . '.php'; |
| 286 | - $logger->debug('Checking view [' . $view . '] in module [' .$module. '] ...'); |
|
| 286 | + $logger->debug('Checking view [' . $view . '] in module [' . $module . '] ...'); |
|
| 287 | 287 | $filePath = MODULE_PATH . $module . DS . 'views' . DS . $viewFile; |
| 288 | - if(file_exists($filePath)){ |
|
| 289 | - $logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 288 | + if (file_exists($filePath)) { |
|
| 289 | + $logger->info('Found view [' . $view . '] in module [' . $module . '], the file path is [' . $filePath . ']'); |
|
| 290 | 290 | return $filePath; |
| 291 | 291 | } |
| 292 | - else{ |
|
| 293 | - $logger->info('View [' . $view . '] does not exist in the module [' .$module. ']'); |
|
| 292 | + else { |
|
| 293 | + $logger->info('View [' . $view . '] does not exist in the module [' . $module . ']'); |
|
| 294 | 294 | return false; |
| 295 | 295 | } |
| 296 | 296 | } |
@@ -302,23 +302,23 @@ discard block |
||
| 302 | 302 | * @param string $appLang the application language like 'en', 'fr' |
| 303 | 303 | * @return boolean|string false or null if no module have this language, return the full path of this language |
| 304 | 304 | */ |
| 305 | - public static function findLanguageFullPath($language, $module = null, $appLang){ |
|
| 305 | + public static function findLanguageFullPath($language, $module = null, $appLang) { |
|
| 306 | 306 | $logger = self::getLogger(); |
| 307 | - if(! self::hasModule()){ |
|
| 307 | + if (!self::hasModule()) { |
|
| 308 | 308 | $logger->info('No module was loaded skiping.'); |
| 309 | 309 | return false; |
| 310 | 310 | } |
| 311 | 311 | $language = str_ireplace('.php', '', $language); |
| 312 | 312 | $language = str_ireplace('lang_', '', $language); |
| 313 | - $file = 'lang_'.$language.'.php'; |
|
| 314 | - $logger->debug('Checking language [' . $language . '] in module [' .$module. '] ...'); |
|
| 313 | + $file = 'lang_' . $language . '.php'; |
|
| 314 | + $logger->debug('Checking language [' . $language . '] in module [' . $module . '] ...'); |
|
| 315 | 315 | $filePath = MODULE_PATH . $module . DS . 'lang' . DS . $appLang . DS . $file; |
| 316 | - if(file_exists($filePath)){ |
|
| 317 | - $logger->info('Found language [' . $language . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 316 | + if (file_exists($filePath)) { |
|
| 317 | + $logger->info('Found language [' . $language . '] in module [' . $module . '], the file path is [' . $filePath . ']'); |
|
| 318 | 318 | return $filePath; |
| 319 | 319 | } |
| 320 | - else{ |
|
| 321 | - $logger->info('Language [' . $language . '] does not exist in the module [' .$module. ']'); |
|
| 320 | + else { |
|
| 321 | + $logger->info('Language [' . $language . '] does not exist in the module [' . $module . ']'); |
|
| 322 | 322 | return false; |
| 323 | 323 | } |
| 324 | 324 | } |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | * Get the list of module loaded |
| 328 | 328 | * @return array the module list |
| 329 | 329 | */ |
| 330 | - public static function getModuleList(){ |
|
| 330 | + public static function getModuleList() { |
|
| 331 | 331 | return self::$list; |
| 332 | 332 | } |
| 333 | 333 | |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | * Check if the application has an module |
| 336 | 336 | * @return boolean |
| 337 | 337 | */ |
| 338 | - public static function hasModule(){ |
|
| 338 | + public static function hasModule() { |
|
| 339 | 339 | return !empty(self::$list); |
| 340 | 340 | } |
| 341 | 341 | |
@@ -61,8 +61,7 @@ discard block |
||
| 61 | 61 | while(($module = readdir($moduleDir)) !== false){ |
| 62 | 62 | if(preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)){ |
| 63 | 63 | self::$list[] = $module; |
| 64 | - } |
|
| 65 | - else{ |
|
| 64 | + } else{ |
|
| 66 | 65 | $logger->info('Skipping [' .$module. '], may be this is not a directory or does not exists or is invalid name'); |
| 67 | 66 | } |
| 68 | 67 | } |
@@ -152,8 +151,7 @@ discard block |
||
| 152 | 151 | if(file_exists($filePath)){ |
| 153 | 152 | $logger->info('Found controller [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
| 154 | 153 | return $filePath; |
| 155 | - } |
|
| 156 | - else{ |
|
| 154 | + } else{ |
|
| 157 | 155 | $logger->info('Controller [' . $class . '] does not exist in the module [' .$module. ']'); |
| 158 | 156 | return false; |
| 159 | 157 | } |
@@ -179,8 +177,7 @@ discard block |
||
| 179 | 177 | if(file_exists($filePath)){ |
| 180 | 178 | $logger->info('Found model [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
| 181 | 179 | return $filePath; |
| 182 | - } |
|
| 183 | - else{ |
|
| 180 | + } else{ |
|
| 184 | 181 | $logger->info('Model [' . $class . '] does not exist in the module [' .$module. ']'); |
| 185 | 182 | return false; |
| 186 | 183 | } |
@@ -205,8 +202,7 @@ discard block |
||
| 205 | 202 | if(file_exists($filePath)){ |
| 206 | 203 | $logger->info('Found configuration [' . $configuration . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
| 207 | 204 | return $filePath; |
| 208 | - } |
|
| 209 | - else{ |
|
| 205 | + } else{ |
|
| 210 | 206 | $logger->info('Configuration [' . $configuration . '] does not exist in the module [' .$module. ']'); |
| 211 | 207 | return false; |
| 212 | 208 | } |
@@ -232,8 +228,7 @@ discard block |
||
| 232 | 228 | if(file_exists($filePath)){ |
| 233 | 229 | $logger->info('Found helper [' . $helper . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
| 234 | 230 | return $filePath; |
| 235 | - } |
|
| 236 | - else{ |
|
| 231 | + } else{ |
|
| 237 | 232 | $logger->info('Helper [' . $helper . '] does not exist in the module [' .$module. ']'); |
| 238 | 233 | return false; |
| 239 | 234 | } |
@@ -259,8 +254,7 @@ discard block |
||
| 259 | 254 | if(file_exists($filePath)){ |
| 260 | 255 | $logger->info('Found library [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
| 261 | 256 | return $filePath; |
| 262 | - } |
|
| 263 | - else{ |
|
| 257 | + } else{ |
|
| 264 | 258 | $logger->info('Library [' . $class . '] does not exist in the module [' .$module. ']'); |
| 265 | 259 | return false; |
| 266 | 260 | } |
@@ -288,8 +282,7 @@ discard block |
||
| 288 | 282 | if(file_exists($filePath)){ |
| 289 | 283 | $logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
| 290 | 284 | return $filePath; |
| 291 | - } |
|
| 292 | - else{ |
|
| 285 | + } else{ |
|
| 293 | 286 | $logger->info('View [' . $view . '] does not exist in the module [' .$module. ']'); |
| 294 | 287 | return false; |
| 295 | 288 | } |
@@ -316,8 +309,7 @@ discard block |
||
| 316 | 309 | if(file_exists($filePath)){ |
| 317 | 310 | $logger->info('Found language [' . $language . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
| 318 | 311 | return $filePath; |
| 319 | - } |
|
| 320 | - else{ |
|
| 312 | + } else{ |
|
| 321 | 313 | $logger->info('Language [' . $language . '] does not exist in the module [' .$module. ']'); |
| 322 | 314 | return false; |
| 323 | 315 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | - /** |
|
| 2 | + defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | + /** |
|
| 4 | 4 | * TNH Framework |
| 5 | 5 | * |
| 6 | 6 | * A simple PHP framework using HMVC architecture |
@@ -22,321 +22,321 @@ discard block |
||
| 22 | 22 | * You should have received a copy of the GNU General Public License |
| 23 | 23 | * along with this program; if not, write to the Free Software |
| 24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 25 | - */ |
|
| 25 | + */ |
|
| 26 | 26 | |
| 27 | - class Module{ |
|
| 27 | + class Module{ |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * list of loaded module |
|
| 31 | - * @var array |
|
| 32 | - */ |
|
| 33 | - private static $list = array(); |
|
| 29 | + /** |
|
| 30 | + * list of loaded module |
|
| 31 | + * @var array |
|
| 32 | + */ |
|
| 33 | + private static $list = array(); |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * logger instance |
|
| 37 | - * @var Log |
|
| 38 | - */ |
|
| 39 | - private static $logger; |
|
| 35 | + /** |
|
| 36 | + * logger instance |
|
| 37 | + * @var Log |
|
| 38 | + */ |
|
| 39 | + private static $logger; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * The signleton of the logger |
|
| 43 | - * @return Object the Log instance |
|
| 44 | - */ |
|
| 45 | - private static function getLogger(){ |
|
| 46 | - if(self::$logger == null){ |
|
| 47 | - self::$logger[0] =& class_loader('Log', 'classes'); |
|
| 48 | - self::$logger[0]->setLogger('Library::Module'); |
|
| 49 | - } |
|
| 50 | - return self::$logger[0]; |
|
| 51 | - } |
|
| 41 | + /** |
|
| 42 | + * The signleton of the logger |
|
| 43 | + * @return Object the Log instance |
|
| 44 | + */ |
|
| 45 | + private static function getLogger(){ |
|
| 46 | + if(self::$logger == null){ |
|
| 47 | + self::$logger[0] =& class_loader('Log', 'classes'); |
|
| 48 | + self::$logger[0]->setLogger('Library::Module'); |
|
| 49 | + } |
|
| 50 | + return self::$logger[0]; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Initialise the module list by scanning the directory MODULE_PATH |
|
| 55 | - */ |
|
| 56 | - public function init(){ |
|
| 57 | - $logger = self::getLogger(); |
|
| 58 | - $logger->debug('Check if the application contains the modules ...'); |
|
| 59 | - $moduleDir = opendir(MODULE_PATH); |
|
| 60 | - if(is_resource($moduleDir)){ |
|
| 61 | - while(($module = readdir($moduleDir)) !== false){ |
|
| 62 | - if(preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)){ |
|
| 63 | - self::$list[] = $module; |
|
| 64 | - } |
|
| 65 | - else{ |
|
| 66 | - $logger->info('Skipping [' .$module. '], may be this is not a directory or does not exists or is invalid name'); |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - closedir($moduleDir); |
|
| 70 | - } |
|
| 71 | - ksort(self::$list); |
|
| 53 | + /** |
|
| 54 | + * Initialise the module list by scanning the directory MODULE_PATH |
|
| 55 | + */ |
|
| 56 | + public function init(){ |
|
| 57 | + $logger = self::getLogger(); |
|
| 58 | + $logger->debug('Check if the application contains the modules ...'); |
|
| 59 | + $moduleDir = opendir(MODULE_PATH); |
|
| 60 | + if(is_resource($moduleDir)){ |
|
| 61 | + while(($module = readdir($moduleDir)) !== false){ |
|
| 62 | + if(preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)){ |
|
| 63 | + self::$list[] = $module; |
|
| 64 | + } |
|
| 65 | + else{ |
|
| 66 | + $logger->info('Skipping [' .$module. '], may be this is not a directory or does not exists or is invalid name'); |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + closedir($moduleDir); |
|
| 70 | + } |
|
| 71 | + ksort(self::$list); |
|
| 72 | 72 | |
| 73 | - if(self::hasModule()){ |
|
| 74 | - $logger->info('The application contains the module below [' . implode(', ', self::getModuleList()) . ']'); |
|
| 75 | - } |
|
| 76 | - } |
|
| 73 | + if(self::hasModule()){ |
|
| 74 | + $logger->info('The application contains the module below [' . implode(', ', self::getModuleList()) . ']'); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Get the list of the custom autoload configuration from module if exists |
|
| 80 | - * @return array|boolean the autoload configurations list or false if no module contains the autoload configuration values |
|
| 81 | - */ |
|
| 82 | - public static function getModulesAutoloadConfig(){ |
|
| 83 | - $logger = self::getLogger(); |
|
| 84 | - if(! self::hasModule()){ |
|
| 85 | - $logger->info('No module was loaded skipping.'); |
|
| 86 | - return false; |
|
| 87 | - } |
|
| 88 | - $autoloads = array(); |
|
| 89 | - $autoloads['libraries'] = array(); |
|
| 90 | - $autoloads['config'] = array(); |
|
| 91 | - $autoloads['models'] = array(); |
|
| 92 | - $autoloads['functions'] = array(); |
|
| 93 | - $autoloads['languages'] = array(); |
|
| 78 | + /** |
|
| 79 | + * Get the list of the custom autoload configuration from module if exists |
|
| 80 | + * @return array|boolean the autoload configurations list or false if no module contains the autoload configuration values |
|
| 81 | + */ |
|
| 82 | + public static function getModulesAutoloadConfig(){ |
|
| 83 | + $logger = self::getLogger(); |
|
| 84 | + if(! self::hasModule()){ |
|
| 85 | + $logger->info('No module was loaded skipping.'); |
|
| 86 | + return false; |
|
| 87 | + } |
|
| 88 | + $autoloads = array(); |
|
| 89 | + $autoloads['libraries'] = array(); |
|
| 90 | + $autoloads['config'] = array(); |
|
| 91 | + $autoloads['models'] = array(); |
|
| 92 | + $autoloads['functions'] = array(); |
|
| 93 | + $autoloads['languages'] = array(); |
|
| 94 | 94 | |
| 95 | - foreach (self::$list as $module) { |
|
| 96 | - $file = MODULE_PATH . $module . DS . 'config' . DS . 'autoload.php'; |
|
| 97 | - if(file_exists($file)){ |
|
| 98 | - $autoload = array(); |
|
| 99 | - require_once $file; |
|
| 100 | - if(! empty($autoload) && is_array($autoload)){ |
|
| 101 | - $autoloads = array_merge_recursive($autoloads, $autoload); |
|
| 102 | - unset($autoload); |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - return $autoloads; |
|
| 107 | - } |
|
| 95 | + foreach (self::$list as $module) { |
|
| 96 | + $file = MODULE_PATH . $module . DS . 'config' . DS . 'autoload.php'; |
|
| 97 | + if(file_exists($file)){ |
|
| 98 | + $autoload = array(); |
|
| 99 | + require_once $file; |
|
| 100 | + if(! empty($autoload) && is_array($autoload)){ |
|
| 101 | + $autoloads = array_merge_recursive($autoloads, $autoload); |
|
| 102 | + unset($autoload); |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + return $autoloads; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Get the list of the custom routes configuration from module if exists |
|
| 111 | - * @return array|boolean the routes list or false if no module contains the routes configuration |
|
| 112 | - */ |
|
| 113 | - public static function getModulesRoutes(){ |
|
| 114 | - $logger = self::getLogger(); |
|
| 115 | - if(! self::hasModule()){ |
|
| 116 | - $logger->info('No module was loaded skipping.'); |
|
| 117 | - return false; |
|
| 118 | - } |
|
| 119 | - $routes = array(); |
|
| 120 | - foreach (self::$list as $module) { |
|
| 121 | - $file = MODULE_PATH . $module . DS . 'config' . DS . 'routes.php'; |
|
| 122 | - if(file_exists($file)){ |
|
| 123 | - $route = array(); |
|
| 124 | - require_once $file; |
|
| 125 | - if(! empty($route) && is_array($route)){ |
|
| 126 | - $routes = array_merge($routes, $route); |
|
| 127 | - unset($route); |
|
| 128 | - } |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - return $routes; |
|
| 132 | - } |
|
| 109 | + /** |
|
| 110 | + * Get the list of the custom routes configuration from module if exists |
|
| 111 | + * @return array|boolean the routes list or false if no module contains the routes configuration |
|
| 112 | + */ |
|
| 113 | + public static function getModulesRoutes(){ |
|
| 114 | + $logger = self::getLogger(); |
|
| 115 | + if(! self::hasModule()){ |
|
| 116 | + $logger->info('No module was loaded skipping.'); |
|
| 117 | + return false; |
|
| 118 | + } |
|
| 119 | + $routes = array(); |
|
| 120 | + foreach (self::$list as $module) { |
|
| 121 | + $file = MODULE_PATH . $module . DS . 'config' . DS . 'routes.php'; |
|
| 122 | + if(file_exists($file)){ |
|
| 123 | + $route = array(); |
|
| 124 | + require_once $file; |
|
| 125 | + if(! empty($route) && is_array($route)){ |
|
| 126 | + $routes = array_merge($routes, $route); |
|
| 127 | + unset($route); |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + return $routes; |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | 134 | |
| 135 | - /** |
|
| 136 | - * Check if in module list can have this controller |
|
| 137 | - * @param string $class the controller class |
|
| 138 | - * @param string $module the module name |
|
| 139 | - * @return boolean|string false or null if no module have this controller, path the full path of the controller |
|
| 140 | - */ |
|
| 141 | - public static function findControllerFullPath($class, $module = null){ |
|
| 142 | - $logger = self::getLogger(); |
|
| 143 | - if(! self::hasModule()){ |
|
| 144 | - $logger->info('No module was loaded skiping.'); |
|
| 145 | - return false; |
|
| 146 | - } |
|
| 147 | - $class = str_ireplace('.php', '', $class); |
|
| 148 | - $class = ucfirst($class); |
|
| 149 | - $classFile = $class.'.php'; |
|
| 150 | - $logger->debug('Checking the controller [' . $class . '] in module [' .$module. '] ...'); |
|
| 151 | - $filePath = MODULE_PATH . $module . DS . 'controllers' . DS . $classFile; |
|
| 152 | - if(file_exists($filePath)){ |
|
| 153 | - $logger->info('Found controller [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 154 | - return $filePath; |
|
| 155 | - } |
|
| 156 | - else{ |
|
| 157 | - $logger->info('Controller [' . $class . '] does not exist in the module [' .$module. ']'); |
|
| 158 | - return false; |
|
| 159 | - } |
|
| 160 | - } |
|
| 135 | + /** |
|
| 136 | + * Check if in module list can have this controller |
|
| 137 | + * @param string $class the controller class |
|
| 138 | + * @param string $module the module name |
|
| 139 | + * @return boolean|string false or null if no module have this controller, path the full path of the controller |
|
| 140 | + */ |
|
| 141 | + public static function findControllerFullPath($class, $module = null){ |
|
| 142 | + $logger = self::getLogger(); |
|
| 143 | + if(! self::hasModule()){ |
|
| 144 | + $logger->info('No module was loaded skiping.'); |
|
| 145 | + return false; |
|
| 146 | + } |
|
| 147 | + $class = str_ireplace('.php', '', $class); |
|
| 148 | + $class = ucfirst($class); |
|
| 149 | + $classFile = $class.'.php'; |
|
| 150 | + $logger->debug('Checking the controller [' . $class . '] in module [' .$module. '] ...'); |
|
| 151 | + $filePath = MODULE_PATH . $module . DS . 'controllers' . DS . $classFile; |
|
| 152 | + if(file_exists($filePath)){ |
|
| 153 | + $logger->info('Found controller [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 154 | + return $filePath; |
|
| 155 | + } |
|
| 156 | + else{ |
|
| 157 | + $logger->info('Controller [' . $class . '] does not exist in the module [' .$module. ']'); |
|
| 158 | + return false; |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - /** |
|
| 163 | - * Check if in module list can have this model |
|
| 164 | - * @param string $class the model class |
|
| 165 | - * @param string $module the module name |
|
| 166 | - * @return boolean|string false or null if no module have this model, return the full path of this model |
|
| 167 | - */ |
|
| 168 | - public static function findModelFullPath($class, $module = null){ |
|
| 169 | - $logger = self::getLogger(); |
|
| 170 | - if(! self::hasModule()){ |
|
| 171 | - $logger->info('No module was loaded skiping.'); |
|
| 172 | - return false; |
|
| 173 | - } |
|
| 174 | - $class = str_ireplace('.php', '', $class); |
|
| 175 | - $class = ucfirst($class); |
|
| 176 | - $classFile = $class.'.php'; |
|
| 177 | - $logger->debug('Checking model [' . $class . '] in module [' .$module. '] ...'); |
|
| 178 | - $filePath = MODULE_PATH . $module . DS . 'models' . DS . $classFile; |
|
| 179 | - if(file_exists($filePath)){ |
|
| 180 | - $logger->info('Found model [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 181 | - return $filePath; |
|
| 182 | - } |
|
| 183 | - else{ |
|
| 184 | - $logger->info('Model [' . $class . '] does not exist in the module [' .$module. ']'); |
|
| 185 | - return false; |
|
| 186 | - } |
|
| 187 | - } |
|
| 162 | + /** |
|
| 163 | + * Check if in module list can have this model |
|
| 164 | + * @param string $class the model class |
|
| 165 | + * @param string $module the module name |
|
| 166 | + * @return boolean|string false or null if no module have this model, return the full path of this model |
|
| 167 | + */ |
|
| 168 | + public static function findModelFullPath($class, $module = null){ |
|
| 169 | + $logger = self::getLogger(); |
|
| 170 | + if(! self::hasModule()){ |
|
| 171 | + $logger->info('No module was loaded skiping.'); |
|
| 172 | + return false; |
|
| 173 | + } |
|
| 174 | + $class = str_ireplace('.php', '', $class); |
|
| 175 | + $class = ucfirst($class); |
|
| 176 | + $classFile = $class.'.php'; |
|
| 177 | + $logger->debug('Checking model [' . $class . '] in module [' .$module. '] ...'); |
|
| 178 | + $filePath = MODULE_PATH . $module . DS . 'models' . DS . $classFile; |
|
| 179 | + if(file_exists($filePath)){ |
|
| 180 | + $logger->info('Found model [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 181 | + return $filePath; |
|
| 182 | + } |
|
| 183 | + else{ |
|
| 184 | + $logger->info('Model [' . $class . '] does not exist in the module [' .$module. ']'); |
|
| 185 | + return false; |
|
| 186 | + } |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - /** |
|
| 190 | - * Check if in module list can have this config |
|
| 191 | - * @param string $configuration the config name |
|
| 192 | - * @param string $module the module name |
|
| 193 | - * @return boolean|string false or null if no module have this configuration, return the full path of this configuration |
|
| 194 | - */ |
|
| 195 | - public static function findConfigFullPath($configuration, $module = null){ |
|
| 196 | - $logger = self::getLogger(); |
|
| 197 | - if(! self::hasModule()){ |
|
| 198 | - $logger->info('No module was loaded skiping.'); |
|
| 199 | - return false; |
|
| 200 | - } |
|
| 201 | - $configuration = str_ireplace('.php', '', $configuration); |
|
| 202 | - $file = $configuration.'.php'; |
|
| 203 | - $logger->debug('Checking configuration [' . $configuration . '] in module [' .$module. '] ...'); |
|
| 204 | - $filePath = MODULE_PATH . $module . DS . 'config' . DS . $file; |
|
| 205 | - if(file_exists($filePath)){ |
|
| 206 | - $logger->info('Found configuration [' . $configuration . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 207 | - return $filePath; |
|
| 208 | - } |
|
| 209 | - else{ |
|
| 210 | - $logger->info('Configuration [' . $configuration . '] does not exist in the module [' .$module. ']'); |
|
| 211 | - return false; |
|
| 212 | - } |
|
| 213 | - } |
|
| 189 | + /** |
|
| 190 | + * Check if in module list can have this config |
|
| 191 | + * @param string $configuration the config name |
|
| 192 | + * @param string $module the module name |
|
| 193 | + * @return boolean|string false or null if no module have this configuration, return the full path of this configuration |
|
| 194 | + */ |
|
| 195 | + public static function findConfigFullPath($configuration, $module = null){ |
|
| 196 | + $logger = self::getLogger(); |
|
| 197 | + if(! self::hasModule()){ |
|
| 198 | + $logger->info('No module was loaded skiping.'); |
|
| 199 | + return false; |
|
| 200 | + } |
|
| 201 | + $configuration = str_ireplace('.php', '', $configuration); |
|
| 202 | + $file = $configuration.'.php'; |
|
| 203 | + $logger->debug('Checking configuration [' . $configuration . '] in module [' .$module. '] ...'); |
|
| 204 | + $filePath = MODULE_PATH . $module . DS . 'config' . DS . $file; |
|
| 205 | + if(file_exists($filePath)){ |
|
| 206 | + $logger->info('Found configuration [' . $configuration . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 207 | + return $filePath; |
|
| 208 | + } |
|
| 209 | + else{ |
|
| 210 | + $logger->info('Configuration [' . $configuration . '] does not exist in the module [' .$module. ']'); |
|
| 211 | + return false; |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - /** |
|
| 216 | - * Check if in module list can have this helper |
|
| 217 | - * @param string $helper the helper name |
|
| 218 | - * @param string $module the module name |
|
| 219 | - * @return boolean|string false or null if no module have this helper, return the full path of this helper |
|
| 220 | - */ |
|
| 221 | - public static function findFunctionFullPath($helper, $module = null){ |
|
| 222 | - $logger = self::getLogger(); |
|
| 223 | - if(! self::hasModule()){ |
|
| 224 | - $logger->info('No module was loaded skiping.'); |
|
| 225 | - return false; |
|
| 226 | - } |
|
| 227 | - $helper = str_ireplace('.php', '', $helper); |
|
| 228 | - $helper = str_ireplace('function_', '', $helper); |
|
| 229 | - $file = 'function_'.$helper.'.php'; |
|
| 230 | - $logger->debug('Checking helper [' . $helper . '] in module [' .$module. '] ...'); |
|
| 231 | - $filePath = MODULE_PATH . $module . DS . 'functions' . DS . $file; |
|
| 232 | - if(file_exists($filePath)){ |
|
| 233 | - $logger->info('Found helper [' . $helper . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 234 | - return $filePath; |
|
| 235 | - } |
|
| 236 | - else{ |
|
| 237 | - $logger->info('Helper [' . $helper . '] does not exist in the module [' .$module. ']'); |
|
| 238 | - return false; |
|
| 239 | - } |
|
| 240 | - } |
|
| 215 | + /** |
|
| 216 | + * Check if in module list can have this helper |
|
| 217 | + * @param string $helper the helper name |
|
| 218 | + * @param string $module the module name |
|
| 219 | + * @return boolean|string false or null if no module have this helper, return the full path of this helper |
|
| 220 | + */ |
|
| 221 | + public static function findFunctionFullPath($helper, $module = null){ |
|
| 222 | + $logger = self::getLogger(); |
|
| 223 | + if(! self::hasModule()){ |
|
| 224 | + $logger->info('No module was loaded skiping.'); |
|
| 225 | + return false; |
|
| 226 | + } |
|
| 227 | + $helper = str_ireplace('.php', '', $helper); |
|
| 228 | + $helper = str_ireplace('function_', '', $helper); |
|
| 229 | + $file = 'function_'.$helper.'.php'; |
|
| 230 | + $logger->debug('Checking helper [' . $helper . '] in module [' .$module. '] ...'); |
|
| 231 | + $filePath = MODULE_PATH . $module . DS . 'functions' . DS . $file; |
|
| 232 | + if(file_exists($filePath)){ |
|
| 233 | + $logger->info('Found helper [' . $helper . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 234 | + return $filePath; |
|
| 235 | + } |
|
| 236 | + else{ |
|
| 237 | + $logger->info('Helper [' . $helper . '] does not exist in the module [' .$module. ']'); |
|
| 238 | + return false; |
|
| 239 | + } |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | 242 | |
| 243 | - /** |
|
| 244 | - * Check if in module list can have this library |
|
| 245 | - * @param string $class the library name |
|
| 246 | - * @param string $module the module name |
|
| 247 | - * @return boolean|string false or null if no module have this library, return the full path of this library |
|
| 248 | - */ |
|
| 249 | - public static function findLibraryFullPath($class, $module = null){ |
|
| 250 | - $logger = self::getLogger(); |
|
| 251 | - if(! self::hasModule()){ |
|
| 252 | - $logger->info('No module was loaded skiping.'); |
|
| 253 | - return false; |
|
| 254 | - } |
|
| 255 | - $class = str_ireplace('.php', '', $class); |
|
| 256 | - $file = $class.'.php'; |
|
| 257 | - $logger->debug('Checking library [' . $class . '] in module [' .$module. '] ...'); |
|
| 258 | - $filePath = MODULE_PATH . $module . DS . 'libraries' . DS . $file; |
|
| 259 | - if(file_exists($filePath)){ |
|
| 260 | - $logger->info('Found library [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 261 | - return $filePath; |
|
| 262 | - } |
|
| 263 | - else{ |
|
| 264 | - $logger->info('Library [' . $class . '] does not exist in the module [' .$module. ']'); |
|
| 265 | - return false; |
|
| 266 | - } |
|
| 267 | - } |
|
| 243 | + /** |
|
| 244 | + * Check if in module list can have this library |
|
| 245 | + * @param string $class the library name |
|
| 246 | + * @param string $module the module name |
|
| 247 | + * @return boolean|string false or null if no module have this library, return the full path of this library |
|
| 248 | + */ |
|
| 249 | + public static function findLibraryFullPath($class, $module = null){ |
|
| 250 | + $logger = self::getLogger(); |
|
| 251 | + if(! self::hasModule()){ |
|
| 252 | + $logger->info('No module was loaded skiping.'); |
|
| 253 | + return false; |
|
| 254 | + } |
|
| 255 | + $class = str_ireplace('.php', '', $class); |
|
| 256 | + $file = $class.'.php'; |
|
| 257 | + $logger->debug('Checking library [' . $class . '] in module [' .$module. '] ...'); |
|
| 258 | + $filePath = MODULE_PATH . $module . DS . 'libraries' . DS . $file; |
|
| 259 | + if(file_exists($filePath)){ |
|
| 260 | + $logger->info('Found library [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 261 | + return $filePath; |
|
| 262 | + } |
|
| 263 | + else{ |
|
| 264 | + $logger->info('Library [' . $class . '] does not exist in the module [' .$module. ']'); |
|
| 265 | + return false; |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | 268 | |
| 269 | 269 | |
| 270 | - /** |
|
| 271 | - * Check if in module list can have this view |
|
| 272 | - * @param string $view the view path |
|
| 273 | - * @param string $module the module name to check |
|
| 274 | - * @return boolean|string false or null if no module have this view, path the full path of the view |
|
| 275 | - */ |
|
| 276 | - public static function findViewFullPath($view, $module = null){ |
|
| 277 | - $logger = self::getLogger(); |
|
| 278 | - if(! self::hasModule()){ |
|
| 279 | - $logger->info('No module was loaded skiping.'); |
|
| 280 | - return false; |
|
| 281 | - } |
|
| 282 | - $view = str_ireplace('.php', '', $view); |
|
| 283 | - $view = trim($view, '/\\'); |
|
| 284 | - $view = str_ireplace('/', DS, $view); |
|
| 285 | - $viewFile = $view . '.php'; |
|
| 286 | - $logger->debug('Checking view [' . $view . '] in module [' .$module. '] ...'); |
|
| 287 | - $filePath = MODULE_PATH . $module . DS . 'views' . DS . $viewFile; |
|
| 288 | - if(file_exists($filePath)){ |
|
| 289 | - $logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 290 | - return $filePath; |
|
| 291 | - } |
|
| 292 | - else{ |
|
| 293 | - $logger->info('View [' . $view . '] does not exist in the module [' .$module. ']'); |
|
| 294 | - return false; |
|
| 295 | - } |
|
| 296 | - } |
|
| 270 | + /** |
|
| 271 | + * Check if in module list can have this view |
|
| 272 | + * @param string $view the view path |
|
| 273 | + * @param string $module the module name to check |
|
| 274 | + * @return boolean|string false or null if no module have this view, path the full path of the view |
|
| 275 | + */ |
|
| 276 | + public static function findViewFullPath($view, $module = null){ |
|
| 277 | + $logger = self::getLogger(); |
|
| 278 | + if(! self::hasModule()){ |
|
| 279 | + $logger->info('No module was loaded skiping.'); |
|
| 280 | + return false; |
|
| 281 | + } |
|
| 282 | + $view = str_ireplace('.php', '', $view); |
|
| 283 | + $view = trim($view, '/\\'); |
|
| 284 | + $view = str_ireplace('/', DS, $view); |
|
| 285 | + $viewFile = $view . '.php'; |
|
| 286 | + $logger->debug('Checking view [' . $view . '] in module [' .$module. '] ...'); |
|
| 287 | + $filePath = MODULE_PATH . $module . DS . 'views' . DS . $viewFile; |
|
| 288 | + if(file_exists($filePath)){ |
|
| 289 | + $logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 290 | + return $filePath; |
|
| 291 | + } |
|
| 292 | + else{ |
|
| 293 | + $logger->info('View [' . $view . '] does not exist in the module [' .$module. ']'); |
|
| 294 | + return false; |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | 297 | |
| 298 | - /** |
|
| 299 | - * Check if in module list can have this language |
|
| 300 | - * @param string $language the language name |
|
| 301 | - * @param string $module the module name |
|
| 302 | - * @param string $appLang the application language like 'en', 'fr' |
|
| 303 | - * @return boolean|string false or null if no module have this language, return the full path of this language |
|
| 304 | - */ |
|
| 305 | - public static function findLanguageFullPath($language, $module = null, $appLang){ |
|
| 306 | - $logger = self::getLogger(); |
|
| 307 | - if(! self::hasModule()){ |
|
| 308 | - $logger->info('No module was loaded skiping.'); |
|
| 309 | - return false; |
|
| 310 | - } |
|
| 311 | - $language = str_ireplace('.php', '', $language); |
|
| 312 | - $language = str_ireplace('lang_', '', $language); |
|
| 313 | - $file = 'lang_'.$language.'.php'; |
|
| 314 | - $logger->debug('Checking language [' . $language . '] in module [' .$module. '] ...'); |
|
| 315 | - $filePath = MODULE_PATH . $module . DS . 'lang' . DS . $appLang . DS . $file; |
|
| 316 | - if(file_exists($filePath)){ |
|
| 317 | - $logger->info('Found language [' . $language . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 318 | - return $filePath; |
|
| 319 | - } |
|
| 320 | - else{ |
|
| 321 | - $logger->info('Language [' . $language . '] does not exist in the module [' .$module. ']'); |
|
| 322 | - return false; |
|
| 323 | - } |
|
| 324 | - } |
|
| 298 | + /** |
|
| 299 | + * Check if in module list can have this language |
|
| 300 | + * @param string $language the language name |
|
| 301 | + * @param string $module the module name |
|
| 302 | + * @param string $appLang the application language like 'en', 'fr' |
|
| 303 | + * @return boolean|string false or null if no module have this language, return the full path of this language |
|
| 304 | + */ |
|
| 305 | + public static function findLanguageFullPath($language, $module = null, $appLang){ |
|
| 306 | + $logger = self::getLogger(); |
|
| 307 | + if(! self::hasModule()){ |
|
| 308 | + $logger->info('No module was loaded skiping.'); |
|
| 309 | + return false; |
|
| 310 | + } |
|
| 311 | + $language = str_ireplace('.php', '', $language); |
|
| 312 | + $language = str_ireplace('lang_', '', $language); |
|
| 313 | + $file = 'lang_'.$language.'.php'; |
|
| 314 | + $logger->debug('Checking language [' . $language . '] in module [' .$module. '] ...'); |
|
| 315 | + $filePath = MODULE_PATH . $module . DS . 'lang' . DS . $appLang . DS . $file; |
|
| 316 | + if(file_exists($filePath)){ |
|
| 317 | + $logger->info('Found language [' . $language . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 318 | + return $filePath; |
|
| 319 | + } |
|
| 320 | + else{ |
|
| 321 | + $logger->info('Language [' . $language . '] does not exist in the module [' .$module. ']'); |
|
| 322 | + return false; |
|
| 323 | + } |
|
| 324 | + } |
|
| 325 | 325 | |
| 326 | - /** |
|
| 327 | - * Get the list of module loaded |
|
| 328 | - * @return array the module list |
|
| 329 | - */ |
|
| 330 | - public static function getModuleList(){ |
|
| 331 | - return self::$list; |
|
| 332 | - } |
|
| 326 | + /** |
|
| 327 | + * Get the list of module loaded |
|
| 328 | + * @return array the module list |
|
| 329 | + */ |
|
| 330 | + public static function getModuleList(){ |
|
| 331 | + return self::$list; |
|
| 332 | + } |
|
| 333 | 333 | |
| 334 | - /** |
|
| 335 | - * Check if the application has an module |
|
| 336 | - * @return boolean |
|
| 337 | - */ |
|
| 338 | - public static function hasModule(){ |
|
| 339 | - return !empty(self::$list); |
|
| 340 | - } |
|
| 334 | + /** |
|
| 335 | + * Check if the application has an module |
|
| 336 | + * @return boolean |
|
| 337 | + */ |
|
| 338 | + public static function hasModule(){ |
|
| 339 | + return !empty(self::$list); |
|
| 340 | + } |
|
| 341 | 341 | |
| 342 | - } |
|
| 342 | + } |
|
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @package FileUpload |
| 38 | 38 | * @version 1.5 |
| 39 | 39 | */ |
| 40 | - class Upload{ |
|
| 40 | + class Upload { |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * Version |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @version 1.0 |
| 70 | 70 | * @var array |
| 71 | 71 | */ |
| 72 | - private $file_array = array(); |
|
| 72 | + private $file_array = array(); |
|
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * If the file you are trying to upload already exists it will |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * @version 1.0 |
| 120 | 120 | * @var float |
| 121 | 121 | */ |
| 122 | - private $max_file_size= 0.0; |
|
| 122 | + private $max_file_size = 0.0; |
|
| 123 | 123 | |
| 124 | 124 | /** |
| 125 | 125 | * List of allowed mime types |
@@ -217,12 +217,12 @@ discard block |
||
| 217 | 217 | * @return object |
| 218 | 218 | * @method object __construct |
| 219 | 219 | */ |
| 220 | - public function __construct(){ |
|
| 221 | - $this->logger =& class_loader('Log', 'classes'); |
|
| 220 | + public function __construct() { |
|
| 221 | + $this->logger = & class_loader('Log', 'classes'); |
|
| 222 | 222 | $this->logger->setLogger('Library::Upload'); |
| 223 | 223 | |
| 224 | 224 | Loader::lang('file_upload'); |
| 225 | - $obj =& get_instance(); |
|
| 225 | + $obj = & get_instance(); |
|
| 226 | 226 | |
| 227 | 227 | $this->error_messages = array( |
| 228 | 228 | 'upload_err_ini_size' => $obj->lang->get('fu_upload_err_ini_size'), |
@@ -239,15 +239,15 @@ discard block |
||
| 239 | 239 | ); |
| 240 | 240 | |
| 241 | 241 | $this->file = array( |
| 242 | - 'status' => false, // True: success upload |
|
| 243 | - 'mime' => '', // Empty string |
|
| 244 | - 'filename' => '', // Empty string |
|
| 245 | - 'original' => '', // Empty string |
|
| 246 | - 'size' => 0, // 0 Bytes |
|
| 247 | - 'sizeFormated' => '0B', // 0 Bytes |
|
| 248 | - 'destination' => './', // Default: ./ |
|
| 249 | - 'allowed_mime_types' => array(), // Allowed mime types |
|
| 250 | - 'error' => null, // File error |
|
| 242 | + 'status' => false, // True: success upload |
|
| 243 | + 'mime' => '', // Empty string |
|
| 244 | + 'filename' => '', // Empty string |
|
| 245 | + 'original' => '', // Empty string |
|
| 246 | + 'size' => 0, // 0 Bytes |
|
| 247 | + 'sizeFormated' => '0B', // 0 Bytes |
|
| 248 | + 'destination' => './', // Default: ./ |
|
| 249 | + 'allowed_mime_types' => array(), // Allowed mime types |
|
| 250 | + 'error' => null, // File error |
|
| 251 | 251 | ); |
| 252 | 252 | |
| 253 | 253 | // Change dir to current dir |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | if (isset($_FILES) && is_array($_FILES)) { |
| 258 | 258 | $this->file_array = $_FILES; |
| 259 | 259 | } |
| 260 | - $this->logger->info('The upload file information are : ' .stringfy_vars($this->file_array)); |
|
| 260 | + $this->logger->info('The upload file information are : ' . stringfy_vars($this->file_array)); |
|
| 261 | 261 | } |
| 262 | 262 | /** |
| 263 | 263 | * Set input. |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | */ |
| 274 | 274 | public function setInput($input) |
| 275 | 275 | { |
| 276 | - if (!empty($input) && (is_string($input) || is_numeric($input) )) { |
|
| 276 | + if (!empty($input) && (is_string($input) || is_numeric($input))) { |
|
| 277 | 277 | $this->input = $input; |
| 278 | 278 | } |
| 279 | 279 | return $this; |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | */ |
| 310 | 310 | public function setAutoFilename() |
| 311 | 311 | { |
| 312 | - $this->filename = sha1(mt_rand(1, 9999).uniqid()); |
|
| 312 | + $this->filename = sha1(mt_rand(1, 9999) . uniqid()); |
|
| 313 | 313 | $this->filename .= time(); |
| 314 | 314 | return $this; |
| 315 | 315 | } |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | $php_size = $this->sizeInBytes((int) ini_get('upload_max_filesize')); |
| 331 | 331 | // Calculate difference |
| 332 | 332 | if ($php_size < $file_size) { |
| 333 | - $this->logger->warning('The upload max file size you set [' .$file_size. '] is greather than the PHP configuration for upload max file size [' .$php_size. ']'); |
|
| 333 | + $this->logger->warning('The upload max file size you set [' . $file_size . '] is greather than the PHP configuration for upload max file size [' . $php_size . ']'); |
|
| 334 | 334 | } |
| 335 | 335 | $this->max_file_size = $file_size; |
| 336 | 336 | } |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | public function setAllowedMimeTypes(array $mimes) |
| 349 | 349 | { |
| 350 | 350 | if (count($mimes) > 0) { |
| 351 | - array_map(array($this , 'setAllowMimeType'), $mimes); |
|
| 351 | + array_map(array($this, 'setAllowMimeType'), $mimes); |
|
| 352 | 352 | } |
| 353 | 353 | return $this; |
| 354 | 354 | } |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | { |
| 414 | 414 | if (!empty($name) && is_string($name)) { |
| 415 | 415 | if (array_key_exists($name, $this->mime_helping)) { |
| 416 | - return $this->setAllowedMimeTypes($this->mime_helping[ $name ]); |
|
| 416 | + return $this->setAllowedMimeTypes($this->mime_helping[$name]); |
|
| 417 | 417 | } |
| 418 | 418 | } |
| 419 | 419 | return $this; |
@@ -432,8 +432,8 @@ discard block |
||
| 432 | 432 | */ |
| 433 | 433 | public function setUploadFunction($function) |
| 434 | 434 | { |
| 435 | - if (!empty($function) && (is_array($function) || is_string($function) )) { |
|
| 436 | - if (is_callable( $function)) { |
|
| 435 | + if (!empty($function) && (is_array($function) || is_string($function))) { |
|
| 436 | + if (is_callable($function)) { |
|
| 437 | 437 | $this->upload_function = $function; |
| 438 | 438 | } |
| 439 | 439 | } |
@@ -478,8 +478,8 @@ discard block |
||
| 478 | 478 | $this->destination_directory = $destination_directory; |
| 479 | 479 | chdir($destination_directory); |
| 480 | 480 | } |
| 481 | - else{ |
|
| 482 | - $this->logger->warning('Can not create the upload directory [' .$destination_directory. ']'); |
|
| 481 | + else { |
|
| 482 | + $this->logger->warning('Can not create the upload directory [' . $destination_directory . ']'); |
|
| 483 | 483 | } |
| 484 | 484 | } |
| 485 | 485 | } |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | public function isFilename($filename) |
| 530 | 530 | { |
| 531 | 531 | $filename = basename($filename); |
| 532 | - return (!empty($filename) && (is_string( $filename) || is_numeric($filename))); |
|
| 532 | + return (!empty($filename) && (is_string($filename) || is_numeric($filename))); |
|
| 533 | 533 | } |
| 534 | 534 | /** |
| 535 | 535 | * Validate mime type with allowed mime types, |
@@ -571,11 +571,11 @@ discard block |
||
| 571 | 571 | */ |
| 572 | 572 | public function isDirpath($path) |
| 573 | 573 | { |
| 574 | - if (!empty( $path) && (is_string( $path) || is_numeric($path) )) { |
|
| 574 | + if (!empty($path) && (is_string($path) || is_numeric($path))) { |
|
| 575 | 575 | if (DIRECTORY_SEPARATOR == '/') { |
| 576 | - return (preg_match( '/^[^*?"<>|:]*$/' , $path) == 1 ); |
|
| 576 | + return (preg_match('/^[^*?"<>|:]*$/', $path) == 1); |
|
| 577 | 577 | } else { |
| 578 | - return (preg_match( "/^[^*?\"<>|:]*$/" , substr($path,2) ) == 1); |
|
| 578 | + return (preg_match("/^[^*?\"<>|:]*$/", substr($path, 2)) == 1); |
|
| 579 | 579 | } |
| 580 | 580 | } |
| 581 | 581 | return false; |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | */ |
| 604 | 604 | public function getInfo() |
| 605 | 605 | { |
| 606 | - return (object)$this->file; |
|
| 606 | + return (object) $this->file; |
|
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | * Check if the file is uploaded |
| 612 | 612 | * @return boolean |
| 613 | 613 | */ |
| 614 | - public function isUploaded(){ |
|
| 614 | + public function isUploaded() { |
|
| 615 | 615 | return isset($this->file_array[$this->input]) |
| 616 | 616 | && is_uploaded_file($this->file_array[$this->input]['tmp_name']); |
| 617 | 617 | } |
@@ -625,13 +625,13 @@ discard block |
||
| 625 | 625 | * @return boolean |
| 626 | 626 | * @method boolean save |
| 627 | 627 | */ |
| 628 | - public function save(){ |
|
| 628 | + public function save() { |
|
| 629 | 629 | if (count($this->file_array) > 0 && array_key_exists($this->input, $this->file_array)) { |
| 630 | 630 | // set original filename if not have a new name |
| 631 | 631 | if (empty($this->filename)) { |
| 632 | 632 | $this->filename = $this->file_array[$this->input]['name']; |
| 633 | 633 | } |
| 634 | - else{ |
|
| 634 | + else { |
|
| 635 | 635 | // Replace %s for extension in filename |
| 636 | 636 | // Before: /[\w\d]*(.[\d\w]+)$/i |
| 637 | 637 | // After: /^[\s[:alnum:]\-\_\.]*\.([\d\w]+)$/iu |
@@ -655,10 +655,10 @@ discard block |
||
| 655 | 655 | $this->file['filename'] = $this->filename; |
| 656 | 656 | $this->file['error'] = $this->file_array[$this->input]['error']; |
| 657 | 657 | |
| 658 | - $this->logger->info('The upload file information to process is : ' .stringfy_vars($this->file)); |
|
| 658 | + $this->logger->info('The upload file information to process is : ' . stringfy_vars($this->file)); |
|
| 659 | 659 | |
| 660 | 660 | $error = $this->uploadHasError(); |
| 661 | - if($error){ |
|
| 661 | + if ($error) { |
|
| 662 | 662 | return false; |
| 663 | 663 | } |
| 664 | 664 | // Execute input callback |
@@ -692,10 +692,10 @@ discard block |
||
| 692 | 692 | */ |
| 693 | 693 | public function sizeFormat($size, $precision = 2) |
| 694 | 694 | { |
| 695 | - if($size > 0){ |
|
| 695 | + if ($size > 0) { |
|
| 696 | 696 | $base = log($size) / log(1024); |
| 697 | 697 | $suffixes = array('B', 'K', 'M', 'G', 'T'); |
| 698 | - return round(pow(1024, $base - floor($base)), $precision) . ( isset($suffixes[floor($base)]) ? $suffixes[floor($base)] : ''); |
|
| 698 | + return round(pow(1024, $base - floor($base)), $precision) . (isset($suffixes[floor($base)]) ? $suffixes[floor($base)] : ''); |
|
| 699 | 699 | } |
| 700 | 700 | return null; |
| 701 | 701 | } |
@@ -719,14 +719,14 @@ discard block |
||
| 719 | 719 | if (array_key_exists('unit', $matches)) { |
| 720 | 720 | $unit = strtoupper($matches['unit']); |
| 721 | 721 | } |
| 722 | - return (floatval($matches['size']) * pow(1024, $units[$unit]) ) ; |
|
| 722 | + return (floatval($matches['size']) * pow(1024, $units[$unit])); |
|
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | /** |
| 726 | 726 | * Get the upload error message |
| 727 | 727 | * @return string |
| 728 | 728 | */ |
| 729 | - public function getError(){ |
|
| 729 | + public function getError() { |
|
| 730 | 730 | return $this->error; |
| 731 | 731 | } |
| 732 | 732 | |
@@ -734,7 +734,7 @@ discard block |
||
| 734 | 734 | * Set the upload error message |
| 735 | 735 | * @param string $message the upload error message to set |
| 736 | 736 | */ |
| 737 | - public function setError($message){ |
|
| 737 | + public function setError($message) { |
|
| 738 | 738 | $this->logger->info('The file upload got error : ' . $message); |
| 739 | 739 | $this->error = $message; |
| 740 | 740 | } |
@@ -744,9 +744,9 @@ discard block |
||
| 744 | 744 | * @param string $type the type of callback "input" or "output" |
| 745 | 745 | * @return void |
| 746 | 746 | */ |
| 747 | - protected function runCallback($type){ |
|
| 748 | - if (!empty( $this->callbacks[$type])) { |
|
| 749 | - call_user_func($this->callbacks[$type], (object)$this->file); |
|
| 747 | + protected function runCallback($type) { |
|
| 748 | + if (!empty($this->callbacks[$type])) { |
|
| 749 | + call_user_func($this->callbacks[$type], (object) $this->file); |
|
| 750 | 750 | } |
| 751 | 751 | } |
| 752 | 752 | |
@@ -754,21 +754,21 @@ discard block |
||
| 754 | 754 | * Check if file upload has error |
| 755 | 755 | * @return boolean |
| 756 | 756 | */ |
| 757 | - protected function uploadHasError(){ |
|
| 757 | + protected function uploadHasError() { |
|
| 758 | 758 | //check if file upload is allowed in the configuration |
| 759 | - if(! ini_get('file_uploads')){ |
|
| 759 | + if (!ini_get('file_uploads')) { |
|
| 760 | 760 | $this->setError($this->error_messages['file_uploads']); |
| 761 | 761 | return true; |
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | //check for php upload error |
| 765 | - if(is_numeric($this->file['error']) && $this->file['error'] > 0){ |
|
| 765 | + if (is_numeric($this->file['error']) && $this->file['error'] > 0) { |
|
| 766 | 766 | $this->setError($this->getPhpUploadErrorMessageByCode($this->file['error'])); |
| 767 | 767 | return true; |
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | //check for mime type |
| 771 | - if (! $this->checkMimeType($this->file['mime'])) { |
|
| 771 | + if (!$this->checkMimeType($this->file['mime'])) { |
|
| 772 | 772 | $this->setError($this->error_messages['accept_file_types']); |
| 773 | 773 | return true; |
| 774 | 774 | } |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | * @param int $code the error code |
| 793 | 793 | * @return string the error message |
| 794 | 794 | */ |
| 795 | - private function getPhpUploadErrorMessageByCode($code){ |
|
| 795 | + private function getPhpUploadErrorMessageByCode($code) { |
|
| 796 | 796 | $codeMessageMaps = array( |
| 797 | 797 | 1 => $this->error_messages['upload_err_ini_size'], |
| 798 | 798 | 2 => $this->error_messages['upload_err_form_size'], |
@@ -477,8 +477,7 @@ discard block |
||
| 477 | 477 | if (mkdir($destination_directory, 0775, true)) { |
| 478 | 478 | $this->destination_directory = $destination_directory; |
| 479 | 479 | chdir($destination_directory); |
| 480 | - } |
|
| 481 | - else{ |
|
| 480 | + } else{ |
|
| 482 | 481 | $this->logger->warning('Can not create the upload directory [' .$destination_directory. ']'); |
| 483 | 482 | } |
| 484 | 483 | } |
@@ -630,8 +629,7 @@ discard block |
||
| 630 | 629 | // set original filename if not have a new name |
| 631 | 630 | if (empty($this->filename)) { |
| 632 | 631 | $this->filename = $this->file_array[$this->input]['name']; |
| 633 | - } |
|
| 634 | - else{ |
|
| 632 | + } else{ |
|
| 635 | 633 | // Replace %s for extension in filename |
| 636 | 634 | // Before: /[\w\d]*(.[\d\w]+)$/i |
| 637 | 635 | // After: /^[\s[:alnum:]\-\_\.]*\.([\d\w]+)$/iu |
@@ -22,139 +22,139 @@ discard block |
||
| 22 | 22 | * You should have received a copy of the GNU General Public License |
| 23 | 23 | * along with this program; if not, write to the Free Software |
| 24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 25 | - */ |
|
| 25 | + */ |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | - * Upload |
|
| 31 | - * |
|
| 32 | - * A complete class to upload files with php 5 or higher, but the best: very simple to use. |
|
| 33 | - * |
|
| 34 | - * @author Olaf Erlandsen <[email protected]> |
|
| 35 | - * @author http://www.webdevfreelance.com/ |
|
| 36 | - * |
|
| 37 | - * @package FileUpload |
|
| 38 | - * @version 1.5 |
|
| 39 | - */ |
|
| 30 | + * Upload |
|
| 31 | + * |
|
| 32 | + * A complete class to upload files with php 5 or higher, but the best: very simple to use. |
|
| 33 | + * |
|
| 34 | + * @author Olaf Erlandsen <[email protected]> |
|
| 35 | + * @author http://www.webdevfreelance.com/ |
|
| 36 | + * |
|
| 37 | + * @package FileUpload |
|
| 38 | + * @version 1.5 |
|
| 39 | + */ |
|
| 40 | 40 | class Upload{ |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | - * Version |
|
| 44 | - * |
|
| 45 | - * @since 1.5 |
|
| 46 | - * @version 1.0 |
|
| 47 | - */ |
|
| 43 | + * Version |
|
| 44 | + * |
|
| 45 | + * @since 1.5 |
|
| 46 | + * @version 1.0 |
|
| 47 | + */ |
|
| 48 | 48 | const VERSION = '1.5'; |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | - * Upload function name |
|
| 52 | - * Remember: |
|
| 53 | - * Default function: move_uploaded_file |
|
| 54 | - * Native options: |
|
| 55 | - * - move_uploaded_file (Default and best option) |
|
| 56 | - * - copy |
|
| 57 | - * |
|
| 58 | - * @since 1.0 |
|
| 59 | - * @version 1.0 |
|
| 60 | - * @var string |
|
| 61 | - */ |
|
| 51 | + * Upload function name |
|
| 52 | + * Remember: |
|
| 53 | + * Default function: move_uploaded_file |
|
| 54 | + * Native options: |
|
| 55 | + * - move_uploaded_file (Default and best option) |
|
| 56 | + * - copy |
|
| 57 | + * |
|
| 58 | + * @since 1.0 |
|
| 59 | + * @version 1.0 |
|
| 60 | + * @var string |
|
| 61 | + */ |
|
| 62 | 62 | private $upload_function = 'move_uploaded_file'; |
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | - * Array with the information obtained from the |
|
| 66 | - * variable $_FILES or $HTTP_POST_FILES. |
|
| 67 | - * |
|
| 68 | - * @since 1.0 |
|
| 69 | - * @version 1.0 |
|
| 70 | - * @var array |
|
| 71 | - */ |
|
| 65 | + * Array with the information obtained from the |
|
| 66 | + * variable $_FILES or $HTTP_POST_FILES. |
|
| 67 | + * |
|
| 68 | + * @since 1.0 |
|
| 69 | + * @version 1.0 |
|
| 70 | + * @var array |
|
| 71 | + */ |
|
| 72 | 72 | private $file_array = array(); |
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | - * If the file you are trying to upload already exists it will |
|
| 76 | - * be overwritten if you set the variable to true. |
|
| 77 | - * |
|
| 78 | - * @since 1.0 |
|
| 79 | - * @version 1.0 |
|
| 80 | - * @var boolean |
|
| 81 | - */ |
|
| 75 | + * If the file you are trying to upload already exists it will |
|
| 76 | + * be overwritten if you set the variable to true. |
|
| 77 | + * |
|
| 78 | + * @since 1.0 |
|
| 79 | + * @version 1.0 |
|
| 80 | + * @var boolean |
|
| 81 | + */ |
|
| 82 | 82 | private $overwrite_file = false; |
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | - * Input element |
|
| 86 | - * Example: |
|
| 87 | - * <input type="file" name="file" /> |
|
| 88 | - * Result: |
|
| 89 | - * FileUpload::$input = file |
|
| 90 | - * |
|
| 91 | - * @since 1.0 |
|
| 92 | - * @version 1.0 |
|
| 93 | - * @var string |
|
| 94 | - */ |
|
| 85 | + * Input element |
|
| 86 | + * Example: |
|
| 87 | + * <input type="file" name="file" /> |
|
| 88 | + * Result: |
|
| 89 | + * FileUpload::$input = file |
|
| 90 | + * |
|
| 91 | + * @since 1.0 |
|
| 92 | + * @version 1.0 |
|
| 93 | + * @var string |
|
| 94 | + */ |
|
| 95 | 95 | private $input; |
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | - * Path output |
|
| 99 | - * |
|
| 100 | - * @since 1.0 |
|
| 101 | - * @version 1.0 |
|
| 102 | - * @var string |
|
| 103 | - */ |
|
| 98 | + * Path output |
|
| 99 | + * |
|
| 100 | + * @since 1.0 |
|
| 101 | + * @version 1.0 |
|
| 102 | + * @var string |
|
| 103 | + */ |
|
| 104 | 104 | private $destination_directory; |
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | - * Output filename |
|
| 108 | - * |
|
| 109 | - * @since 1.0 |
|
| 110 | - * @version 1.0 |
|
| 111 | - * @var string |
|
| 112 | - */ |
|
| 107 | + * Output filename |
|
| 108 | + * |
|
| 109 | + * @since 1.0 |
|
| 110 | + * @version 1.0 |
|
| 111 | + * @var string |
|
| 112 | + */ |
|
| 113 | 113 | private $filename; |
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | - * Max file size |
|
| 117 | - * |
|
| 118 | - * @since 1.0 |
|
| 119 | - * @version 1.0 |
|
| 120 | - * @var float |
|
| 121 | - */ |
|
| 116 | + * Max file size |
|
| 117 | + * |
|
| 118 | + * @since 1.0 |
|
| 119 | + * @version 1.0 |
|
| 120 | + * @var float |
|
| 121 | + */ |
|
| 122 | 122 | private $max_file_size= 0.0; |
| 123 | 123 | |
| 124 | 124 | /** |
| 125 | - * List of allowed mime types |
|
| 126 | - * |
|
| 127 | - * @since 1.0 |
|
| 128 | - * @version 1.0 |
|
| 129 | - * @var array |
|
| 130 | - */ |
|
| 125 | + * List of allowed mime types |
|
| 126 | + * |
|
| 127 | + * @since 1.0 |
|
| 128 | + * @version 1.0 |
|
| 129 | + * @var array |
|
| 130 | + */ |
|
| 131 | 131 | private $allowed_mime_types = array(); |
| 132 | 132 | |
| 133 | 133 | /** |
| 134 | - * Callbacks |
|
| 135 | - * |
|
| 136 | - * @since 1.0 |
|
| 137 | - * @version 1.0 |
|
| 138 | - * @var array |
|
| 139 | - */ |
|
| 134 | + * Callbacks |
|
| 135 | + * |
|
| 136 | + * @since 1.0 |
|
| 137 | + * @version 1.0 |
|
| 138 | + * @var array |
|
| 139 | + */ |
|
| 140 | 140 | private $callbacks = array('before' => null, 'after' => null); |
| 141 | 141 | |
| 142 | 142 | /** |
| 143 | - * File object |
|
| 144 | - * |
|
| 145 | - * @since 1.0 |
|
| 146 | - * @version 1.0 |
|
| 147 | - * @var object |
|
| 148 | - */ |
|
| 143 | + * File object |
|
| 144 | + * |
|
| 145 | + * @since 1.0 |
|
| 146 | + * @version 1.0 |
|
| 147 | + * @var object |
|
| 148 | + */ |
|
| 149 | 149 | private $file; |
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | - * Helping mime types |
|
| 153 | - * |
|
| 154 | - * @since 1.0 |
|
| 155 | - * @version 1.0 |
|
| 156 | - * @var array |
|
| 157 | - */ |
|
| 152 | + * Helping mime types |
|
| 153 | + * |
|
| 154 | + * @since 1.0 |
|
| 155 | + * @version 1.0 |
|
| 156 | + * @var array |
|
| 157 | + */ |
|
| 158 | 158 | private $mime_helping = array( |
| 159 | 159 | 'text' => array('text/plain',), |
| 160 | 160 | 'image' => array( |
@@ -210,13 +210,13 @@ discard block |
||
| 210 | 210 | |
| 211 | 211 | |
| 212 | 212 | /** |
| 213 | - * Construct |
|
| 214 | - * |
|
| 215 | - * @since 0.1 |
|
| 216 | - * @version 1.0.1 |
|
| 217 | - * @return object |
|
| 218 | - * @method object __construct |
|
| 219 | - */ |
|
| 213 | + * Construct |
|
| 214 | + * |
|
| 215 | + * @since 0.1 |
|
| 216 | + * @version 1.0.1 |
|
| 217 | + * @return object |
|
| 218 | + * @method object __construct |
|
| 219 | + */ |
|
| 220 | 220 | public function __construct(){ |
| 221 | 221 | $this->logger =& class_loader('Log', 'classes'); |
| 222 | 222 | $this->logger->setLogger('Library::Upload'); |
@@ -260,17 +260,17 @@ discard block |
||
| 260 | 260 | $this->logger->info('The upload file information are : ' .stringfy_vars($this->file_array)); |
| 261 | 261 | } |
| 262 | 262 | /** |
| 263 | - * Set input. |
|
| 264 | - * If you have $_FILES["file"], you must use the key "file" |
|
| 265 | - * Example: |
|
| 266 | - * $object->setInput("file"); |
|
| 267 | - * |
|
| 268 | - * @since 1.0 |
|
| 269 | - * @version 1.0 |
|
| 270 | - * @param string $input |
|
| 271 | - * @return object |
|
| 272 | - * @method boolean setInput |
|
| 273 | - */ |
|
| 263 | + * Set input. |
|
| 264 | + * If you have $_FILES["file"], you must use the key "file" |
|
| 265 | + * Example: |
|
| 266 | + * $object->setInput("file"); |
|
| 267 | + * |
|
| 268 | + * @since 1.0 |
|
| 269 | + * @version 1.0 |
|
| 270 | + * @param string $input |
|
| 271 | + * @return object |
|
| 272 | + * @method boolean setInput |
|
| 273 | + */ |
|
| 274 | 274 | public function setInput($input) |
| 275 | 275 | { |
| 276 | 276 | if (!empty($input) && (is_string($input) || is_numeric($input) )) { |
@@ -279,18 +279,18 @@ discard block |
||
| 279 | 279 | return $this; |
| 280 | 280 | } |
| 281 | 281 | /** |
| 282 | - * Set new filename |
|
| 283 | - * Example: |
|
| 284 | - * FileUpload::setFilename("new file.txt") |
|
| 285 | - * Remember: |
|
| 286 | - * Use %s to retrive file extension |
|
| 287 | - * |
|
| 288 | - * @since 1.0 |
|
| 289 | - * @version 1.0 |
|
| 290 | - * @param string $filename |
|
| 291 | - * @return object |
|
| 292 | - * @method boolean setFilename |
|
| 293 | - */ |
|
| 282 | + * Set new filename |
|
| 283 | + * Example: |
|
| 284 | + * FileUpload::setFilename("new file.txt") |
|
| 285 | + * Remember: |
|
| 286 | + * Use %s to retrive file extension |
|
| 287 | + * |
|
| 288 | + * @since 1.0 |
|
| 289 | + * @version 1.0 |
|
| 290 | + * @param string $filename |
|
| 291 | + * @return object |
|
| 292 | + * @method boolean setFilename |
|
| 293 | + */ |
|
| 294 | 294 | public function setFilename($filename) |
| 295 | 295 | { |
| 296 | 296 | if ($this->isFilename($filename)) { |
@@ -299,14 +299,14 @@ discard block |
||
| 299 | 299 | return $this; |
| 300 | 300 | } |
| 301 | 301 | /** |
| 302 | - * Set automatic filename |
|
| 303 | - * |
|
| 304 | - * @since 1.0 |
|
| 305 | - * @version 1.5 |
|
| 306 | - * @param string $extension |
|
| 307 | - * @return object |
|
| 308 | - * @method boolean setAutoFilename |
|
| 309 | - */ |
|
| 302 | + * Set automatic filename |
|
| 303 | + * |
|
| 304 | + * @since 1.0 |
|
| 305 | + * @version 1.5 |
|
| 306 | + * @param string $extension |
|
| 307 | + * @return object |
|
| 308 | + * @method boolean setAutoFilename |
|
| 309 | + */ |
|
| 310 | 310 | public function setAutoFilename() |
| 311 | 311 | { |
| 312 | 312 | $this->filename = sha1(mt_rand(1, 9999).uniqid()); |
@@ -314,14 +314,14 @@ discard block |
||
| 314 | 314 | return $this; |
| 315 | 315 | } |
| 316 | 316 | /** |
| 317 | - * Set file size limit |
|
| 318 | - * |
|
| 319 | - * @since 1.0 |
|
| 320 | - * @version 1.0 |
|
| 321 | - * @param double $file_size |
|
| 322 | - * @return object |
|
| 323 | - * @method boolean setMaxFileSize |
|
| 324 | - */ |
|
| 317 | + * Set file size limit |
|
| 318 | + * |
|
| 319 | + * @since 1.0 |
|
| 320 | + * @version 1.0 |
|
| 321 | + * @param double $file_size |
|
| 322 | + * @return object |
|
| 323 | + * @method boolean setMaxFileSize |
|
| 324 | + */ |
|
| 325 | 325 | public function setMaxFileSize($file_size) |
| 326 | 326 | { |
| 327 | 327 | $file_size = $this->sizeInBytes($file_size); |
@@ -337,14 +337,14 @@ discard block |
||
| 337 | 337 | return $this; |
| 338 | 338 | } |
| 339 | 339 | /** |
| 340 | - * Set array mime types |
|
| 341 | - * |
|
| 342 | - * @since 1.0 |
|
| 343 | - * @version 1.0 |
|
| 344 | - * @param array $mimes |
|
| 345 | - * @return object |
|
| 346 | - * @method boolean setAllowedMimeTypes |
|
| 347 | - */ |
|
| 340 | + * Set array mime types |
|
| 341 | + * |
|
| 342 | + * @since 1.0 |
|
| 343 | + * @version 1.0 |
|
| 344 | + * @param array $mimes |
|
| 345 | + * @return object |
|
| 346 | + * @method boolean setAllowedMimeTypes |
|
| 347 | + */ |
|
| 348 | 348 | public function setAllowedMimeTypes(array $mimes) |
| 349 | 349 | { |
| 350 | 350 | if (count($mimes) > 0) { |
@@ -353,14 +353,14 @@ discard block |
||
| 353 | 353 | return $this; |
| 354 | 354 | } |
| 355 | 355 | /** |
| 356 | - * Set input callback |
|
| 357 | - * |
|
| 358 | - * @since 1.0 |
|
| 359 | - * @version 1.0 |
|
| 360 | - * @param mixed $callback |
|
| 361 | - * @return object |
|
| 362 | - * @method boolean setCallbackInput |
|
| 363 | - */ |
|
| 356 | + * Set input callback |
|
| 357 | + * |
|
| 358 | + * @since 1.0 |
|
| 359 | + * @version 1.0 |
|
| 360 | + * @param mixed $callback |
|
| 361 | + * @return object |
|
| 362 | + * @method boolean setCallbackInput |
|
| 363 | + */ |
|
| 364 | 364 | public function setCallbackInput($callback) |
| 365 | 365 | { |
| 366 | 366 | if (is_callable($callback, false)) { |
@@ -369,14 +369,14 @@ discard block |
||
| 369 | 369 | return $this; |
| 370 | 370 | } |
| 371 | 371 | /** |
| 372 | - * Set output callback |
|
| 373 | - * |
|
| 374 | - * @since 1.0 |
|
| 375 | - * @version 1.0 |
|
| 376 | - * @param mixed $callback |
|
| 377 | - * @return object |
|
| 378 | - * @method boolean setCallbackOutput |
|
| 379 | - */ |
|
| 372 | + * Set output callback |
|
| 373 | + * |
|
| 374 | + * @since 1.0 |
|
| 375 | + * @version 1.0 |
|
| 376 | + * @param mixed $callback |
|
| 377 | + * @return object |
|
| 378 | + * @method boolean setCallbackOutput |
|
| 379 | + */ |
|
| 380 | 380 | public function setCallbackOutput($callback) |
| 381 | 381 | { |
| 382 | 382 | if (is_callable($callback, false)) { |
@@ -385,14 +385,14 @@ discard block |
||
| 385 | 385 | return $this; |
| 386 | 386 | } |
| 387 | 387 | /** |
| 388 | - * Append a mime type to allowed mime types |
|
| 389 | - * |
|
| 390 | - * @since 1.0 |
|
| 391 | - * @version 1.0.1 |
|
| 392 | - * @param string $mime |
|
| 393 | - * @return object |
|
| 394 | - * @method boolean setAllowMimeType |
|
| 395 | - */ |
|
| 388 | + * Append a mime type to allowed mime types |
|
| 389 | + * |
|
| 390 | + * @since 1.0 |
|
| 391 | + * @version 1.0.1 |
|
| 392 | + * @param string $mime |
|
| 393 | + * @return object |
|
| 394 | + * @method boolean setAllowMimeType |
|
| 395 | + */ |
|
| 396 | 396 | public function setAllowMimeType($mime) |
| 397 | 397 | { |
| 398 | 398 | if (!empty($mime) && is_string($mime)) { |
@@ -402,13 +402,13 @@ discard block |
||
| 402 | 402 | return $this; |
| 403 | 403 | } |
| 404 | 404 | /** |
| 405 | - * Set allowed mime types from mime helping |
|
| 406 | - * |
|
| 407 | - * @since 1.0.1 |
|
| 408 | - * @version 1.0.1 |
|
| 409 | - * @return object |
|
| 410 | - * @method boolean setMimeHelping |
|
| 411 | - */ |
|
| 405 | + * Set allowed mime types from mime helping |
|
| 406 | + * |
|
| 407 | + * @since 1.0.1 |
|
| 408 | + * @version 1.0.1 |
|
| 409 | + * @return object |
|
| 410 | + * @method boolean setMimeHelping |
|
| 411 | + */ |
|
| 412 | 412 | public function setMimeHelping($name) |
| 413 | 413 | { |
| 414 | 414 | if (!empty($name) && is_string($name)) { |
@@ -419,17 +419,17 @@ discard block |
||
| 419 | 419 | return $this; |
| 420 | 420 | } |
| 421 | 421 | /** |
| 422 | - * Set function to upload file |
|
| 423 | - * Examples: |
|
| 424 | - * 1.- FileUpload::setUploadFunction("move_uploaded_file"); |
|
| 425 | - * 2.- FileUpload::setUploadFunction("copy"); |
|
| 426 | - * |
|
| 427 | - * @since 1.0 |
|
| 428 | - * @version 1.0 |
|
| 429 | - * @param string $function |
|
| 430 | - * @return object |
|
| 431 | - * @method boolean setUploadFunction |
|
| 432 | - */ |
|
| 422 | + * Set function to upload file |
|
| 423 | + * Examples: |
|
| 424 | + * 1.- FileUpload::setUploadFunction("move_uploaded_file"); |
|
| 425 | + * 2.- FileUpload::setUploadFunction("copy"); |
|
| 426 | + * |
|
| 427 | + * @since 1.0 |
|
| 428 | + * @version 1.0 |
|
| 429 | + * @param string $function |
|
| 430 | + * @return object |
|
| 431 | + * @method boolean setUploadFunction |
|
| 432 | + */ |
|
| 433 | 433 | public function setUploadFunction($function) |
| 434 | 434 | { |
| 435 | 435 | if (!empty($function) && (is_array($function) || is_string($function) )) { |
@@ -440,13 +440,13 @@ discard block |
||
| 440 | 440 | return $this; |
| 441 | 441 | } |
| 442 | 442 | /** |
| 443 | - * Clear allowed mime types cache |
|
| 444 | - * |
|
| 445 | - * @since 1.0 |
|
| 446 | - * @version 1.0 |
|
| 447 | - * @return object |
|
| 448 | - * @method boolean clearAllowedMimeTypes |
|
| 449 | - */ |
|
| 443 | + * Clear allowed mime types cache |
|
| 444 | + * |
|
| 445 | + * @since 1.0 |
|
| 446 | + * @version 1.0 |
|
| 447 | + * @return object |
|
| 448 | + * @method boolean clearAllowedMimeTypes |
|
| 449 | + */ |
|
| 450 | 450 | public function clearAllowedMimeTypes() |
| 451 | 451 | { |
| 452 | 452 | $this->allowed_mime_types = array(); |
@@ -454,15 +454,15 @@ discard block |
||
| 454 | 454 | return $this; |
| 455 | 455 | } |
| 456 | 456 | /** |
| 457 | - * Set destination output |
|
| 458 | - * |
|
| 459 | - * @since 1.0 |
|
| 460 | - * @version 1.0 |
|
| 461 | - * @param string $destination_directory Destination path |
|
| 462 | - * @param boolean $create_if_not_exist |
|
| 463 | - * @return object |
|
| 464 | - * @method boolean setDestinationDirectory |
|
| 465 | - */ |
|
| 457 | + * Set destination output |
|
| 458 | + * |
|
| 459 | + * @since 1.0 |
|
| 460 | + * @version 1.0 |
|
| 461 | + * @param string $destination_directory Destination path |
|
| 462 | + * @param boolean $create_if_not_exist |
|
| 463 | + * @return object |
|
| 464 | + * @method boolean setDestinationDirectory |
|
| 465 | + */ |
|
| 466 | 466 | public function setDestinationDirectory($destination_directory, $create_if_not_exist = false) { |
| 467 | 467 | $destination_directory = realpath($destination_directory); |
| 468 | 468 | if (substr($destination_directory, -1) != DIRECTORY_SEPARATOR) { |
@@ -486,14 +486,14 @@ discard block |
||
| 486 | 486 | return $this; |
| 487 | 487 | } |
| 488 | 488 | /** |
| 489 | - * Check file exists |
|
| 490 | - * |
|
| 491 | - * @since 1.0 |
|
| 492 | - * @version 1.0.1 |
|
| 493 | - * @param string $file_destination |
|
| 494 | - * @return boolean |
|
| 495 | - * @method boolean fileExists |
|
| 496 | - */ |
|
| 489 | + * Check file exists |
|
| 490 | + * |
|
| 491 | + * @since 1.0 |
|
| 492 | + * @version 1.0.1 |
|
| 493 | + * @param string $file_destination |
|
| 494 | + * @return boolean |
|
| 495 | + * @method boolean fileExists |
|
| 496 | + */ |
|
| 497 | 497 | public function fileExists($file_destination) |
| 498 | 498 | { |
| 499 | 499 | if ($this->isFilename($file_destination)) { |
@@ -502,14 +502,14 @@ discard block |
||
| 502 | 502 | return false; |
| 503 | 503 | } |
| 504 | 504 | /** |
| 505 | - * Check dir exists |
|
| 506 | - * |
|
| 507 | - * @since 1.0 |
|
| 508 | - * @version 1.0.1 |
|
| 509 | - * @param string $path |
|
| 510 | - * @return boolean |
|
| 511 | - * @method boolean dirExists |
|
| 512 | - */ |
|
| 505 | + * Check dir exists |
|
| 506 | + * |
|
| 507 | + * @since 1.0 |
|
| 508 | + * @version 1.0.1 |
|
| 509 | + * @param string $path |
|
| 510 | + * @return boolean |
|
| 511 | + * @method boolean dirExists |
|
| 512 | + */ |
|
| 513 | 513 | public function dirExists($path) |
| 514 | 514 | { |
| 515 | 515 | if ($this->isDirpath($path)) { |
@@ -518,29 +518,29 @@ discard block |
||
| 518 | 518 | return false; |
| 519 | 519 | } |
| 520 | 520 | /** |
| 521 | - * Check valid filename |
|
| 522 | - * |
|
| 523 | - * @since 1.0 |
|
| 524 | - * @version 1.0.1 |
|
| 525 | - * @param string $filename |
|
| 526 | - * @return boolean |
|
| 527 | - * @method boolean isFilename |
|
| 528 | - */ |
|
| 521 | + * Check valid filename |
|
| 522 | + * |
|
| 523 | + * @since 1.0 |
|
| 524 | + * @version 1.0.1 |
|
| 525 | + * @param string $filename |
|
| 526 | + * @return boolean |
|
| 527 | + * @method boolean isFilename |
|
| 528 | + */ |
|
| 529 | 529 | public function isFilename($filename) |
| 530 | 530 | { |
| 531 | 531 | $filename = basename($filename); |
| 532 | 532 | return (!empty($filename) && (is_string( $filename) || is_numeric($filename))); |
| 533 | 533 | } |
| 534 | 534 | /** |
| 535 | - * Validate mime type with allowed mime types, |
|
| 536 | - * but if allowed mime types is empty, this method return true |
|
| 537 | - * |
|
| 538 | - * @since 1.0 |
|
| 539 | - * @version 1.0 |
|
| 540 | - * @param string $mime |
|
| 541 | - * @return boolean |
|
| 542 | - * @method boolean checkMimeType |
|
| 543 | - */ |
|
| 535 | + * Validate mime type with allowed mime types, |
|
| 536 | + * but if allowed mime types is empty, this method return true |
|
| 537 | + * |
|
| 538 | + * @since 1.0 |
|
| 539 | + * @version 1.0 |
|
| 540 | + * @param string $mime |
|
| 541 | + * @return boolean |
|
| 542 | + * @method boolean checkMimeType |
|
| 543 | + */ |
|
| 544 | 544 | public function checkMimeType($mime) |
| 545 | 545 | { |
| 546 | 546 | if (count($this->allowed_mime_types) == 0) { |
@@ -549,26 +549,26 @@ discard block |
||
| 549 | 549 | return in_array(strtolower($mime), $this->allowed_mime_types); |
| 550 | 550 | } |
| 551 | 551 | /** |
| 552 | - * Retrive status of upload |
|
| 553 | - * |
|
| 554 | - * @since 1.0 |
|
| 555 | - * @version 1.0 |
|
| 556 | - * @return boolean |
|
| 557 | - * @method boolean getStatus |
|
| 558 | - */ |
|
| 552 | + * Retrive status of upload |
|
| 553 | + * |
|
| 554 | + * @since 1.0 |
|
| 555 | + * @version 1.0 |
|
| 556 | + * @return boolean |
|
| 557 | + * @method boolean getStatus |
|
| 558 | + */ |
|
| 559 | 559 | public function getStatus() |
| 560 | 560 | { |
| 561 | 561 | return $this->file['status']; |
| 562 | 562 | } |
| 563 | 563 | /** |
| 564 | - * Check valid path |
|
| 565 | - * |
|
| 566 | - * @since 1.0 |
|
| 567 | - * @version 1.0.1 |
|
| 568 | - * @param string $filename |
|
| 569 | - * @return boolean |
|
| 570 | - * @method boolean isDirpath |
|
| 571 | - */ |
|
| 564 | + * Check valid path |
|
| 565 | + * |
|
| 566 | + * @since 1.0 |
|
| 567 | + * @version 1.0.1 |
|
| 568 | + * @param string $filename |
|
| 569 | + * @return boolean |
|
| 570 | + * @method boolean isDirpath |
|
| 571 | + */ |
|
| 572 | 572 | public function isDirpath($path) |
| 573 | 573 | { |
| 574 | 574 | if (!empty( $path) && (is_string( $path) || is_numeric($path) )) { |
@@ -581,26 +581,26 @@ discard block |
||
| 581 | 581 | return false; |
| 582 | 582 | } |
| 583 | 583 | /** |
| 584 | - * Allow overwriting files |
|
| 585 | - * |
|
| 586 | - * @since 1.0 |
|
| 587 | - * @version 1.0 |
|
| 588 | - * @return object |
|
| 589 | - * @method boolean allowOverwriting |
|
| 590 | - */ |
|
| 584 | + * Allow overwriting files |
|
| 585 | + * |
|
| 586 | + * @since 1.0 |
|
| 587 | + * @version 1.0 |
|
| 588 | + * @return object |
|
| 589 | + * @method boolean allowOverwriting |
|
| 590 | + */ |
|
| 591 | 591 | public function allowOverwriting() |
| 592 | 592 | { |
| 593 | 593 | $this->overwrite_file = true; |
| 594 | 594 | return $this; |
| 595 | 595 | } |
| 596 | 596 | /** |
| 597 | - * File info |
|
| 598 | - * |
|
| 599 | - * @since 1.0 |
|
| 600 | - * @version 1.0 |
|
| 601 | - * @return object |
|
| 602 | - * @method object getInfo |
|
| 603 | - */ |
|
| 597 | + * File info |
|
| 598 | + * |
|
| 599 | + * @since 1.0 |
|
| 600 | + * @version 1.0 |
|
| 601 | + * @return object |
|
| 602 | + * @method object getInfo |
|
| 603 | + */ |
|
| 604 | 604 | public function getInfo() |
| 605 | 605 | { |
| 606 | 606 | return (object)$this->file; |
@@ -618,13 +618,13 @@ discard block |
||
| 618 | 618 | |
| 619 | 619 | |
| 620 | 620 | /** |
| 621 | - * Upload file |
|
| 622 | - * |
|
| 623 | - * @since 1.0 |
|
| 624 | - * @version 1.0.1 |
|
| 625 | - * @return boolean |
|
| 626 | - * @method boolean save |
|
| 627 | - */ |
|
| 621 | + * Upload file |
|
| 622 | + * |
|
| 623 | + * @since 1.0 |
|
| 624 | + * @version 1.0.1 |
|
| 625 | + * @return boolean |
|
| 626 | + * @method boolean save |
|
| 627 | + */ |
|
| 628 | 628 | public function save(){ |
| 629 | 629 | if (count($this->file_array) > 0 && array_key_exists($this->input, $this->file_array)) { |
| 630 | 630 | // set original filename if not have a new name |
@@ -681,15 +681,15 @@ discard block |
||
| 681 | 681 | |
| 682 | 682 | |
| 683 | 683 | /** |
| 684 | - * File size for humans. |
|
| 685 | - * |
|
| 686 | - * @since 1.0 |
|
| 687 | - * @version 1.0 |
|
| 688 | - * @param integer $bytes |
|
| 689 | - * @param integer $precision |
|
| 690 | - * @return string |
|
| 691 | - * @method string sizeFormat |
|
| 692 | - */ |
|
| 684 | + * File size for humans. |
|
| 685 | + * |
|
| 686 | + * @since 1.0 |
|
| 687 | + * @version 1.0 |
|
| 688 | + * @param integer $bytes |
|
| 689 | + * @param integer $precision |
|
| 690 | + * @return string |
|
| 691 | + * @method string sizeFormat |
|
| 692 | + */ |
|
| 693 | 693 | public function sizeFormat($size, $precision = 2) |
| 694 | 694 | { |
| 695 | 695 | if($size > 0){ |
@@ -702,14 +702,14 @@ discard block |
||
| 702 | 702 | |
| 703 | 703 | |
| 704 | 704 | /** |
| 705 | - * Convert human file size to bytes |
|
| 706 | - * |
|
| 707 | - * @since 1.0 |
|
| 708 | - * @version 1.0.1 |
|
| 709 | - * @param integer|double $size |
|
| 710 | - * @return integer|double |
|
| 711 | - * @method string sizeInBytes |
|
| 712 | - */ |
|
| 705 | + * Convert human file size to bytes |
|
| 706 | + * |
|
| 707 | + * @since 1.0 |
|
| 708 | + * @version 1.0.1 |
|
| 709 | + * @param integer|double $size |
|
| 710 | + * @return integer|double |
|
| 711 | + * @method string sizeInBytes |
|
| 712 | + */ |
|
| 713 | 713 | public function sizeInBytes($size) |
| 714 | 714 | { |
| 715 | 715 | $unit = 'B'; |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | return true; |
| 762 | 762 | } |
| 763 | 763 | |
| 764 | - //check for php upload error |
|
| 764 | + //check for php upload error |
|
| 765 | 765 | if(is_numeric($this->file['error']) && $this->file['error'] > 0){ |
| 766 | 766 | $this->setError($this->getPhpUploadErrorMessageByCode($this->file['error'])); |
| 767 | 767 | return true; |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | return true; |
| 774 | 774 | } |
| 775 | 775 | |
| 776 | - // Check file size |
|
| 776 | + // Check file size |
|
| 777 | 777 | if ($this->max_file_size > 0 && $this->max_file_size < $this->file['size']) { |
| 778 | 778 | $this->setError(sprintf($this->error_messages['max_file_size'], $this->sizeFormat($this->max_file_size))); |
| 779 | 779 | return true; |
@@ -1,25 +1,25 @@ |
||
| 1 | 1 | <?php |
| 2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
| 2 | + defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | 3 | |
| 4 | - /** |
|
| 5 | - * |
|
| 6 | - */ |
|
| 7 | - class Home extends Controller { |
|
| 4 | + /** |
|
| 5 | + * |
|
| 6 | + */ |
|
| 7 | + class Home extends Controller { |
|
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * the class constructor |
|
| 11 | - */ |
|
| 12 | - public function __construct() { |
|
| 13 | - parent::__construct(); |
|
| 14 | - } |
|
| 9 | + /** |
|
| 10 | + * the class constructor |
|
| 11 | + */ |
|
| 12 | + public function __construct() { |
|
| 13 | + parent::__construct(); |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * The default method |
|
| 18 | - * @return null |
|
| 19 | - */ |
|
| 20 | - public function index() { |
|
| 21 | - Loader::library('Assets'); |
|
| 22 | - Loader::library('Html'); |
|
| 23 | - $this->response->render('home'); |
|
| 24 | - } |
|
| 25 | - } |
|
| 16 | + /** |
|
| 17 | + * The default method |
|
| 18 | + * @return null |
|
| 19 | + */ |
|
| 20 | + public function index() { |
|
| 21 | + Loader::library('Assets'); |
|
| 22 | + Loader::library('Html'); |
|
| 23 | + $this->response->render('home'); |
|
| 24 | + } |
|
| 25 | + } |
|
@@ -1,31 +1,31 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | - use PHPUnit\Framework\TestCase; |
|
| 3 | + use PHPUnit\Framework\TestCase; |
|
| 4 | 4 | |
| 5 | - class RequestTest extends TestCase |
|
| 6 | - { |
|
| 5 | + class RequestTest extends TestCase |
|
| 6 | + { |
|
| 7 | 7 | |
| 8 | - public static function setUpBeforeClass() |
|
| 9 | - { |
|
| 8 | + public static function setUpBeforeClass() |
|
| 9 | + { |
|
| 10 | 10 | |
| 11 | - } |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - public static function tearDownAfterClass() |
|
| 14 | - { |
|
| 13 | + public static function tearDownAfterClass() |
|
| 14 | + { |
|
| 15 | 15 | |
| 16 | - } |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - protected function setUp() |
|
| 19 | - { |
|
| 20 | - } |
|
| 18 | + protected function setUp() |
|
| 19 | + { |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - protected function tearDown() |
|
| 23 | - { |
|
| 24 | - } |
|
| 22 | + protected function tearDown() |
|
| 23 | + { |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - public function testNotYet() |
|
| 27 | - { |
|
| 28 | - $this->markTestSkipped(); |
|
| 29 | - } |
|
| 26 | + public function testNotYet() |
|
| 27 | + { |
|
| 28 | + $this->markTestSkipped(); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - } |
|
| 32 | 31 | \ No newline at end of file |
| 32 | + } |
|
| 33 | 33 | \ No newline at end of file |
@@ -1,31 +1,31 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | - use PHPUnit\Framework\TestCase; |
|
| 3 | + use PHPUnit\Framework\TestCase; |
|
| 4 | 4 | |
| 5 | - class LoaderTest extends TestCase |
|
| 6 | - { |
|
| 5 | + class LoaderTest extends TestCase |
|
| 6 | + { |
|
| 7 | 7 | |
| 8 | - public static function setUpBeforeClass() |
|
| 9 | - { |
|
| 8 | + public static function setUpBeforeClass() |
|
| 9 | + { |
|
| 10 | 10 | |
| 11 | - } |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - public static function tearDownAfterClass() |
|
| 14 | - { |
|
| 13 | + public static function tearDownAfterClass() |
|
| 14 | + { |
|
| 15 | 15 | |
| 16 | - } |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - protected function setUp() |
|
| 19 | - { |
|
| 20 | - } |
|
| 18 | + protected function setUp() |
|
| 19 | + { |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - protected function tearDown() |
|
| 23 | - { |
|
| 24 | - } |
|
| 22 | + protected function tearDown() |
|
| 23 | + { |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - public function testNotYet() |
|
| 27 | - { |
|
| 28 | - $this->markTestSkipped(); |
|
| 29 | - } |
|
| 26 | + public function testNotYet() |
|
| 27 | + { |
|
| 28 | + $this->markTestSkipped(); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - } |
|
| 32 | 31 | \ No newline at end of file |
| 32 | + } |
|
| 33 | 33 | \ No newline at end of file |
@@ -1,33 +1,33 @@ |
||
| 1 | 1 | <?php |
| 2 | - use PHPUnit\Framework\TestCase; |
|
| 2 | + use PHPUnit\Framework\TestCase; |
|
| 3 | 3 | |
| 4 | - class SessionTest extends TestCase |
|
| 5 | - { |
|
| 4 | + class SessionTest extends TestCase |
|
| 5 | + { |
|
| 6 | 6 | |
| 7 | - public static function setUpBeforeClass() |
|
| 8 | - { |
|
| 7 | + public static function setUpBeforeClass() |
|
| 8 | + { |
|
| 9 | 9 | |
| 10 | - } |
|
| 10 | + } |
|
| 11 | 11 | |
| 12 | - public static function tearDownAfterClass() |
|
| 13 | - { |
|
| 12 | + public static function tearDownAfterClass() |
|
| 13 | + { |
|
| 14 | 14 | |
| 15 | - } |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | 17 | |
| 18 | - protected function setUp() |
|
| 19 | - { |
|
| 20 | - } |
|
| 18 | + protected function setUp() |
|
| 19 | + { |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - protected function tearDown() |
|
| 23 | - { |
|
| 24 | - } |
|
| 22 | + protected function tearDown() |
|
| 23 | + { |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - // tests |
|
| 27 | - public function testSomeFeature() |
|
| 28 | - { |
|
| 29 | - Session::set('foo', 'bar'); |
|
| 30 | - $this->assertEquals('bar', Session::get('foo')); |
|
| 31 | - //$this->expectException(InvalidArgumentException::class); |
|
| 32 | - } |
|
| 33 | - } |
|
| 34 | 26 | \ No newline at end of file |
| 27 | + // tests |
|
| 28 | + public function testSomeFeature() |
|
| 29 | + { |
|
| 30 | + Session::set('foo', 'bar'); |
|
| 31 | + $this->assertEquals('bar', Session::get('foo')); |
|
| 32 | + //$this->expectException(InvalidArgumentException::class); |
|
| 33 | + } |
|
| 34 | + } |
|
| 35 | 35 | \ No newline at end of file |
@@ -1,31 +1,31 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | - use PHPUnit\Framework\TestCase; |
|
| 3 | + use PHPUnit\Framework\TestCase; |
|
| 4 | 4 | |
| 5 | - class UrlTest extends TestCase |
|
| 6 | - { |
|
| 5 | + class UrlTest extends TestCase |
|
| 6 | + { |
|
| 7 | 7 | |
| 8 | - public static function setUpBeforeClass() |
|
| 9 | - { |
|
| 8 | + public static function setUpBeforeClass() |
|
| 9 | + { |
|
| 10 | 10 | |
| 11 | - } |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - public static function tearDownAfterClass() |
|
| 14 | - { |
|
| 13 | + public static function tearDownAfterClass() |
|
| 14 | + { |
|
| 15 | 15 | |
| 16 | - } |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - protected function setUp() |
|
| 19 | - { |
|
| 20 | - } |
|
| 18 | + protected function setUp() |
|
| 19 | + { |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - protected function tearDown() |
|
| 23 | - { |
|
| 24 | - } |
|
| 22 | + protected function tearDown() |
|
| 23 | + { |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - public function testNotYet() |
|
| 27 | - { |
|
| 28 | - $this->markTestSkipped(); |
|
| 29 | - } |
|
| 26 | + public function testNotYet() |
|
| 27 | + { |
|
| 28 | + $this->markTestSkipped(); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - } |
|
| 32 | 31 | \ No newline at end of file |
| 32 | + } |
|
| 33 | 33 | \ No newline at end of file |
@@ -1,31 +1,31 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | - use PHPUnit\Framework\TestCase; |
|
| 3 | + use PHPUnit\Framework\TestCase; |
|
| 4 | 4 | |
| 5 | - class LogTest extends TestCase |
|
| 6 | - { |
|
| 5 | + class LogTest extends TestCase |
|
| 6 | + { |
|
| 7 | 7 | |
| 8 | - public static function setUpBeforeClass() |
|
| 9 | - { |
|
| 8 | + public static function setUpBeforeClass() |
|
| 9 | + { |
|
| 10 | 10 | |
| 11 | - } |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - public static function tearDownAfterClass() |
|
| 14 | - { |
|
| 13 | + public static function tearDownAfterClass() |
|
| 14 | + { |
|
| 15 | 15 | |
| 16 | - } |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - protected function setUp() |
|
| 19 | - { |
|
| 20 | - } |
|
| 18 | + protected function setUp() |
|
| 19 | + { |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - protected function tearDown() |
|
| 23 | - { |
|
| 24 | - } |
|
| 22 | + protected function tearDown() |
|
| 23 | + { |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - public function testNotYet() |
|
| 27 | - { |
|
| 28 | - $this->markTestSkipped(); |
|
| 29 | - } |
|
| 26 | + public function testNotYet() |
|
| 27 | + { |
|
| 28 | + $this->markTestSkipped(); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - } |
|
| 32 | 31 | \ No newline at end of file |
| 32 | + } |
|
| 33 | 33 | \ No newline at end of file |