@@ -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 | |
@@ -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 Html{ |
|
| 27 | + class Html { |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Generate the html anchor link |
@@ -35,21 +35,21 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @return string|void the anchor link generated html if $return is true or display it if not |
| 37 | 37 | */ |
| 38 | - public static function a($link = '', $anchor = null, array $attributes = array(), $return = true){ |
|
| 39 | - if(! is_url($link)){ |
|
| 38 | + public static function a($link = '', $anchor = null, array $attributes = array(), $return = true) { |
|
| 39 | + if (!is_url($link)) { |
|
| 40 | 40 | $link = Url::site_url($link); |
| 41 | 41 | } |
| 42 | - if(! $anchor){ |
|
| 42 | + if (!$anchor) { |
|
| 43 | 43 | $anchor = $link; |
| 44 | 44 | } |
| 45 | 45 | $str = null; |
| 46 | - $str .= '<a href = "'.$link.'"'; |
|
| 46 | + $str .= '<a href = "' . $link . '"'; |
|
| 47 | 47 | $str .= attributes_to_string($attributes); |
| 48 | 48 | $str .= '>'; |
| 49 | 49 | $str .= $anchor; |
| 50 | 50 | $str .= '</a>'; |
| 51 | 51 | |
| 52 | - if($return){ |
|
| 52 | + if ($return) { |
|
| 53 | 53 | return $str; |
| 54 | 54 | } |
| 55 | 55 | echo $str; |
@@ -64,18 +64,18 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @return string|void the generated html for mailto link if $return is true or display it if not |
| 66 | 66 | */ |
| 67 | - public static function mailto($link, $anchor = null, array $attributes = array(), $return = true){ |
|
| 68 | - if(! $anchor){ |
|
| 67 | + public static function mailto($link, $anchor = null, array $attributes = array(), $return = true) { |
|
| 68 | + if (!$anchor) { |
|
| 69 | 69 | $anchor = $link; |
| 70 | 70 | } |
| 71 | 71 | $str = null; |
| 72 | - $str .= '<a href = "mailto:'.$link.'"'; |
|
| 72 | + $str .= '<a href = "mailto:' . $link . '"'; |
|
| 73 | 73 | $str .= attributes_to_string($attributes); |
| 74 | 74 | $str .= '>'; |
| 75 | 75 | $str .= $anchor; |
| 76 | 76 | $str .= '</a>'; |
| 77 | 77 | |
| 78 | - if($return){ |
|
| 78 | + if ($return) { |
|
| 79 | 79 | return $str; |
| 80 | 80 | } |
| 81 | 81 | echo $str; |
@@ -88,14 +88,14 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @return string|void the generated "br" html if $return is true or display it if not |
| 90 | 90 | */ |
| 91 | - public static function br($nb = 1, $return = true){ |
|
| 91 | + public static function br($nb = 1, $return = true) { |
|
| 92 | 92 | $nb = (int) $nb; |
| 93 | 93 | $str = null; |
| 94 | 94 | for ($i = 1; $i <= $nb; $i++) { |
| 95 | 95 | $str .= '<br />'; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if($return){ |
|
| 98 | + if ($return) { |
|
| 99 | 99 | return $str; |
| 100 | 100 | } |
| 101 | 101 | echo $str; |
@@ -109,13 +109,13 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @return string|void the generated "hr" html if $return is true or display it if not. |
| 111 | 111 | */ |
| 112 | - public static function hr($nb = 1, array $attributes = array(), $return = true){ |
|
| 112 | + public static function hr($nb = 1, array $attributes = array(), $return = true) { |
|
| 113 | 113 | $nb = (int) $nb; |
| 114 | 114 | $str = null; |
| 115 | 115 | for ($i = 1; $i <= $nb; $i++) { |
| 116 | - $str .= '<hr' .attributes_to_string($attributes). ' />'; |
|
| 116 | + $str .= '<hr' . attributes_to_string($attributes) . ' />'; |
|
| 117 | 117 | } |
| 118 | - if($return){ |
|
| 118 | + if ($return) { |
|
| 119 | 119 | return $str; |
| 120 | 120 | } |
| 121 | 121 | echo $str; |
@@ -131,17 +131,17 @@ discard block |
||
| 131 | 131 | * |
| 132 | 132 | * @return string|void the generated header html if $return is true or display it if not. |
| 133 | 133 | */ |
| 134 | - public static function head($type = 1, $text = null, $nb = 1, array $attributes = array(), $return = true){ |
|
| 134 | + public static function head($type = 1, $text = null, $nb = 1, array $attributes = array(), $return = true) { |
|
| 135 | 135 | $nb = (int) $nb; |
| 136 | 136 | $type = (int) $type; |
| 137 | - if($type <= 0 || $type > 6){ |
|
| 137 | + if ($type <= 0 || $type > 6) { |
|
| 138 | 138 | $type = 1; |
| 139 | 139 | } |
| 140 | 140 | $str = null; |
| 141 | 141 | for ($i = 1; $i <= $nb; $i++) { |
| 142 | - $str .= '<h' . $type . attributes_to_string($attributes). '>' .$text. '</h' . $type . '>'; |
|
| 142 | + $str .= '<h' . $type . attributes_to_string($attributes) . '>' . $text . '</h' . $type . '>'; |
|
| 143 | 143 | } |
| 144 | - if($return){ |
|
| 144 | + if ($return) { |
|
| 145 | 145 | return $str; |
| 146 | 146 | } |
| 147 | 147 | echo $str; |
@@ -156,15 +156,15 @@ discard block |
||
| 156 | 156 | * |
| 157 | 157 | * @return string|void the generated "ul" html if $return is true or display it if not. |
| 158 | 158 | */ |
| 159 | - public static function ul($data = array(), $attributes = array(), $return = true){ |
|
| 159 | + public static function ul($data = array(), $attributes = array(), $return = true) { |
|
| 160 | 160 | $data = (array) $data; |
| 161 | 161 | $str = null; |
| 162 | - $str .= '<ul' . (! empty($attributes['ul']) ? attributes_to_string($attributes['ul']):'') . '>'; |
|
| 162 | + $str .= '<ul' . (!empty($attributes['ul']) ? attributes_to_string($attributes['ul']) : '') . '>'; |
|
| 163 | 163 | foreach ($data as $row) { |
| 164 | - $str .= '<li' . (! empty($attributes['li']) ? attributes_to_string($attributes['li']):'') .'>' .$row. '</li>'; |
|
| 164 | + $str .= '<li' . (!empty($attributes['li']) ? attributes_to_string($attributes['li']) : '') . '>' . $row . '</li>'; |
|
| 165 | 165 | } |
| 166 | 166 | $str .= '</ul>'; |
| 167 | - if($return){ |
|
| 167 | + if ($return) { |
|
| 168 | 168 | return $str; |
| 169 | 169 | } |
| 170 | 170 | echo $str; |
@@ -178,15 +178,15 @@ discard block |
||
| 178 | 178 | * @param boolean $return whether need return the generated html or just display it directly |
| 179 | 179 | * @return string|void the generated "ol" html if $return is true or display it if not. |
| 180 | 180 | */ |
| 181 | - public static function ol($data = array(), $attributes = array(), $return = true){ |
|
| 181 | + public static function ol($data = array(), $attributes = array(), $return = true) { |
|
| 182 | 182 | $data = (array) $data; |
| 183 | 183 | $str = null; |
| 184 | - $str .= '<ol' . (!empty($attributes['ol']) ? attributes_to_string($attributes['ol']):'') . '>'; |
|
| 184 | + $str .= '<ol' . (!empty($attributes['ol']) ? attributes_to_string($attributes['ol']) : '') . '>'; |
|
| 185 | 185 | foreach ($data as $row) { |
| 186 | - $str .= '<li' . (!empty($attributes['li']) ? attributes_to_string($attributes['li']):'') .'>' .$row. '</li>'; |
|
| 186 | + $str .= '<li' . (!empty($attributes['li']) ? attributes_to_string($attributes['li']) : '') . '>' . $row . '</li>'; |
|
| 187 | 187 | } |
| 188 | 188 | $str .= '</ol>'; |
| 189 | - if($return){ |
|
| 189 | + if ($return) { |
|
| 190 | 190 | return $str; |
| 191 | 191 | } |
| 192 | 192 | echo $str; |
@@ -204,46 +204,46 @@ discard block |
||
| 204 | 204 | * @param boolean $return whether need return the generated html or just display it directly |
| 205 | 205 | * @return string|void the generated "table" html if $return is true or display it if not. |
| 206 | 206 | */ |
| 207 | - public static function table($headers = array(), $body = array(), $attributes = array(), $use_footer = false, $return = true){ |
|
| 207 | + public static function table($headers = array(), $body = array(), $attributes = array(), $use_footer = false, $return = true) { |
|
| 208 | 208 | $headers = (array) $headers; |
| 209 | 209 | $body = (array) $body; |
| 210 | 210 | $str = null; |
| 211 | - $str .= '<table' . (! empty($attributes['table']) ? attributes_to_string($attributes['table']):'') . '>'; |
|
| 212 | - if(! empty($headers)){ |
|
| 213 | - $str .= '<thead' . (! empty($attributes['thead']) ? attributes_to_string($attributes['thead']):'') .'>'; |
|
| 214 | - $str .= '<tr' . (! empty($attributes['thead_tr']) ? attributes_to_string($attributes['thead_tr']):'') .'>'; |
|
| 211 | + $str .= '<table' . (!empty($attributes['table']) ? attributes_to_string($attributes['table']) : '') . '>'; |
|
| 212 | + if (!empty($headers)) { |
|
| 213 | + $str .= '<thead' . (!empty($attributes['thead']) ? attributes_to_string($attributes['thead']) : '') . '>'; |
|
| 214 | + $str .= '<tr' . (!empty($attributes['thead_tr']) ? attributes_to_string($attributes['thead_tr']) : '') . '>'; |
|
| 215 | 215 | foreach ($headers as $value) { |
| 216 | - $str .= '<th' . (! empty($attributes['thead_th']) ? attributes_to_string($attributes['thead_th']):'') .'>' .$value. '</th>'; |
|
| 216 | + $str .= '<th' . (!empty($attributes['thead_th']) ? attributes_to_string($attributes['thead_th']) : '') . '>' . $value . '</th>'; |
|
| 217 | 217 | } |
| 218 | 218 | $str .= '</tr>'; |
| 219 | 219 | $str .= '</thead>'; |
| 220 | 220 | } |
| 221 | - else{ |
|
| 221 | + else { |
|
| 222 | 222 | //no need check for footer |
| 223 | 223 | $use_footer = false; |
| 224 | 224 | } |
| 225 | - $str .= '<tbody' . (! empty($attributes['tbody']) ? attributes_to_string($attributes['tbody']):'') .'>'; |
|
| 225 | + $str .= '<tbody' . (!empty($attributes['tbody']) ? attributes_to_string($attributes['tbody']) : '') . '>'; |
|
| 226 | 226 | foreach ($body as $row) { |
| 227 | - if(is_array($row)){ |
|
| 228 | - $str .= '<tr' . (! empty($attributes['tbody_tr']) ? attributes_to_string($attributes['tbody_tr']):'') .'>'; |
|
| 227 | + if (is_array($row)) { |
|
| 228 | + $str .= '<tr' . (!empty($attributes['tbody_tr']) ? attributes_to_string($attributes['tbody_tr']) : '') . '>'; |
|
| 229 | 229 | foreach ($row as $value) { |
| 230 | - $str .= '<td' . (! empty($attributes['tbody_td']) ? attributes_to_string($attributes['tbody_td']):'') .'>' .$value. '</td>'; |
|
| 230 | + $str .= '<td' . (!empty($attributes['tbody_td']) ? attributes_to_string($attributes['tbody_td']) : '') . '>' . $value . '</td>'; |
|
| 231 | 231 | } |
| 232 | 232 | $str .= '</tr>'; |
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | $str .= '</tbody>'; |
| 236 | - if($use_footer){ |
|
| 237 | - $str .= '<tfoot' . (! empty($attributes['tfoot']) ? attributes_to_string($attributes['tfoot']):'') .'>'; |
|
| 238 | - $str .= '<tr' . (! empty($attributes['tfoot_tr']) ? attributes_to_string($attributes['tfoot_tr']):'') .'>'; |
|
| 236 | + if ($use_footer) { |
|
| 237 | + $str .= '<tfoot' . (!empty($attributes['tfoot']) ? attributes_to_string($attributes['tfoot']) : '') . '>'; |
|
| 238 | + $str .= '<tr' . (!empty($attributes['tfoot_tr']) ? attributes_to_string($attributes['tfoot_tr']) : '') . '>'; |
|
| 239 | 239 | foreach ($headers as $value) { |
| 240 | - $str .= '<th' . (! empty($attributes['tfoot_th']) ? attributes_to_string($attributes['tfoot_th']):'') .'>' .$value. '</th>'; |
|
| 240 | + $str .= '<th' . (!empty($attributes['tfoot_th']) ? attributes_to_string($attributes['tfoot_th']) : '') . '>' . $value . '</th>'; |
|
| 241 | 241 | } |
| 242 | 242 | $str .= '</tr>'; |
| 243 | 243 | $str .= '</tfoot>'; |
| 244 | 244 | } |
| 245 | 245 | $str .= '</table>'; |
| 246 | - if($return){ |
|
| 246 | + if ($return) { |
|
| 247 | 247 | return $str; |
| 248 | 248 | } |
| 249 | 249 | echo $str; |
@@ -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 | |
@@ -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'], |
@@ -24,13 +24,13 @@ discard block |
||
| 24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | - class DatabaseQueryResult{ |
|
| 27 | + class DatabaseQueryResult { |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * The database query result |
| 31 | 31 | * @var mixed |
| 32 | 32 | */ |
| 33 | - private $result = null; |
|
| 33 | + private $result = null; |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @param mixed $result the query result |
| 46 | 46 | * @param int $numRows the number of rows returned by the query |
| 47 | 47 | */ |
| 48 | - public function __construct($result = null, $numRows = 0){ |
|
| 48 | + public function __construct($result = null, $numRows = 0) { |
|
| 49 | 49 | $this->result = $result; |
| 50 | 50 | $this->numRows = $numRows; |
| 51 | 51 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * |
| 57 | 57 | * @return mixed |
| 58 | 58 | */ |
| 59 | - public function getResult(){ |
|
| 59 | + public function getResult() { |
|
| 60 | 60 | return $this->result; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @return object DatabaseQueryResult |
| 68 | 68 | */ |
| 69 | - public function setResult($result){ |
|
| 69 | + public function setResult($result) { |
|
| 70 | 70 | $this->result = $result; |
| 71 | 71 | return $this; |
| 72 | 72 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @return int |
| 78 | 78 | */ |
| 79 | - public function getNumRows(){ |
|
| 79 | + public function getNumRows() { |
|
| 80 | 80 | return $this->numRows; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @return object DatabaseQueryResult |
| 88 | 88 | */ |
| 89 | - public function setNumRows($numRows){ |
|
| 89 | + public function setNumRows($numRows) { |
|
| 90 | 90 | $this->numRows = $numRows; |
| 91 | 91 | return $this; |
| 92 | 92 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 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 | - class Loader{ |
|
| 26 | + class Loader { |
|
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * List of loaded resources |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | private static $logger; |
| 39 | 39 | |
| 40 | 40 | |
| 41 | - public function __construct(){ |
|
| 41 | + public function __construct() { |
|
| 42 | 42 | //add the resources already loaded during application bootstrap |
| 43 | 43 | //in the list to prevent duplicate or loading the resources again. |
| 44 | 44 | static::$loaded = class_loaded(); |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | * Get the logger singleton instance |
| 52 | 52 | * @return Log the logger instance |
| 53 | 53 | */ |
| 54 | - private static function getLogger(){ |
|
| 55 | - if(self::$logger == null){ |
|
| 56 | - self::$logger[0] =& class_loader('Log', 'classes'); |
|
| 54 | + private static function getLogger() { |
|
| 55 | + if (self::$logger == null) { |
|
| 56 | + self::$logger[0] = & class_loader('Log', 'classes'); |
|
| 57 | 57 | self::$logger[0]->setLogger('Library::Loader'); |
| 58 | 58 | } |
| 59 | 59 | return self::$logger[0]; |
@@ -67,25 +67,25 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @return void |
| 69 | 69 | */ |
| 70 | - public static function model($class, $instance = null){ |
|
| 70 | + public static function model($class, $instance = null) { |
|
| 71 | 71 | $logger = static::getLogger(); |
| 72 | 72 | $class = str_ireplace('.php', '', $class); |
| 73 | 73 | $class = trim($class, '/\\'); |
| 74 | - $file = ucfirst($class).'.php'; |
|
| 74 | + $file = ucfirst($class) . '.php'; |
|
| 75 | 75 | $logger->debug('Loading model [' . $class . '] ...'); |
| 76 | - if(! $instance){ |
|
| 76 | + if (!$instance) { |
|
| 77 | 77 | //for module |
| 78 | - if(strpos($class, '/') !== false){ |
|
| 78 | + if (strpos($class, '/') !== false) { |
|
| 79 | 79 | $path = explode('/', $class); |
| 80 | - if(isset($path[1])){ |
|
| 80 | + if (isset($path[1])) { |
|
| 81 | 81 | $instance = strtolower($path[1]); |
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | - else{ |
|
| 84 | + else { |
|
| 85 | 85 | $instance = strtolower($class); |
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | - if(isset(static::$loaded[$instance])){ |
|
| 88 | + if (isset(static::$loaded[$instance])) { |
|
| 89 | 89 | $logger->info('Model [' . $class . '] already loaded no need to load it again, cost in performance'); |
| 90 | 90 | return; |
| 91 | 91 | } |
@@ -95,43 +95,43 @@ discard block |
||
| 95 | 95 | $searchModuleName = null; |
| 96 | 96 | $obj = & get_instance(); |
| 97 | 97 | //check if the request class contains module name |
| 98 | - if(strpos($class, '/') !== false){ |
|
| 98 | + if (strpos($class, '/') !== false) { |
|
| 99 | 99 | $path = explode('/', $class); |
| 100 | - if(isset($path[0]) && in_array($path[0], Module::getModuleList())){ |
|
| 100 | + if (isset($path[0]) && in_array($path[0], Module::getModuleList())) { |
|
| 101 | 101 | $searchModuleName = $path[0]; |
| 102 | 102 | $class = ucfirst($path[1]); |
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | - else{ |
|
| 105 | + else { |
|
| 106 | 106 | $class = ucfirst($class); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if(! $searchModuleName && !empty($obj->moduleName)){ |
|
| 109 | + if (!$searchModuleName && !empty($obj->moduleName)) { |
|
| 110 | 110 | $searchModuleName = $obj->moduleName; |
| 111 | 111 | } |
| 112 | 112 | $moduleModelFilePath = Module::findModelFullPath($class, $searchModuleName); |
| 113 | - if($moduleModelFilePath){ |
|
| 114 | - $logger->info('Found model [' . $class . '] from module [' .$searchModuleName. '], the file path is [' .$moduleModelFilePath. '] we will used it'); |
|
| 113 | + if ($moduleModelFilePath) { |
|
| 114 | + $logger->info('Found model [' . $class . '] from module [' . $searchModuleName . '], the file path is [' . $moduleModelFilePath . '] we will used it'); |
|
| 115 | 115 | $classFilePath = $moduleModelFilePath; |
| 116 | 116 | } |
| 117 | - else{ |
|
| 117 | + else { |
|
| 118 | 118 | $logger->info('Cannot find model [' . $class . '] from modules using the default location'); |
| 119 | 119 | } |
| 120 | 120 | $logger->info('The model file path to be loaded is [' . $classFilePath . ']'); |
| 121 | - if(file_exists($classFilePath)){ |
|
| 121 | + if (file_exists($classFilePath)) { |
|
| 122 | 122 | require_once $classFilePath; |
| 123 | - if(class_exists($class)){ |
|
| 123 | + if (class_exists($class)) { |
|
| 124 | 124 | $c = new $class(); |
| 125 | 125 | $obj = & get_instance(); |
| 126 | 126 | $obj->{$instance} = $c; |
| 127 | 127 | static::$loaded[$instance] = $class; |
| 128 | 128 | $logger->info('Model [' . $class . '] --> ' . $classFilePath . ' loaded successfully.'); |
| 129 | 129 | } |
| 130 | - else{ |
|
| 131 | - show_error('The file '.$classFilePath.' exists but does not contain the class ['. $class . ']'); |
|
| 130 | + else { |
|
| 131 | + show_error('The file ' . $classFilePath . ' exists but does not contain the class [' . $class . ']'); |
|
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | - else{ |
|
| 134 | + else { |
|
| 135 | 135 | show_error('Unable to find the model [' . $class . ']'); |
| 136 | 136 | } |
| 137 | 137 | } |
@@ -146,31 +146,31 @@ discard block |
||
| 146 | 146 | * |
| 147 | 147 | * @return void |
| 148 | 148 | */ |
| 149 | - public static function library($class, $instance = null, array $params = array()){ |
|
| 149 | + public static function library($class, $instance = null, array $params = array()) { |
|
| 150 | 150 | $logger = static::getLogger(); |
| 151 | 151 | $class = str_ireplace('.php', '', $class); |
| 152 | 152 | $class = trim($class, '/\\'); |
| 153 | - $file = ucfirst($class) .'.php'; |
|
| 153 | + $file = ucfirst($class) . '.php'; |
|
| 154 | 154 | $logger->debug('Loading library [' . $class . '] ...'); |
| 155 | - if(! $instance){ |
|
| 155 | + if (!$instance) { |
|
| 156 | 156 | //for module |
| 157 | - if(strpos($class, '/') !== false){ |
|
| 157 | + if (strpos($class, '/') !== false) { |
|
| 158 | 158 | $path = explode('/', $class); |
| 159 | - if(isset($path[1])){ |
|
| 159 | + if (isset($path[1])) { |
|
| 160 | 160 | $instance = strtolower($path[1]); |
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | - else{ |
|
| 163 | + else { |
|
| 164 | 164 | $instance = strtolower($class); |
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | - if(isset(static::$loaded[$instance])){ |
|
| 167 | + if (isset(static::$loaded[$instance])) { |
|
| 168 | 168 | $logger->info('Library [' . $class . '] already loaded no need to load it again, cost in performance'); |
| 169 | 169 | return; |
| 170 | 170 | } |
| 171 | 171 | $obj = & get_instance(); |
| 172 | 172 | //TODO for Database library |
| 173 | - if(strtolower($class) == 'database'){ |
|
| 173 | + if (strtolower($class) == 'database') { |
|
| 174 | 174 | $logger->info('This is the Database library ...'); |
| 175 | 175 | $dbInstance = & class_loader('Database', 'classes/database', $params); |
| 176 | 176 | $obj->{$instance} = $dbInstance; |
@@ -180,44 +180,44 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | $libraryFilePath = null; |
| 182 | 182 | $logger->debug('Check if this is a system library ...'); |
| 183 | - if(file_exists(CORE_LIBRARY_PATH . $file)){ |
|
| 183 | + if (file_exists(CORE_LIBRARY_PATH . $file)) { |
|
| 184 | 184 | $libraryFilePath = CORE_LIBRARY_PATH . $file; |
| 185 | 185 | $class = ucfirst($class); |
| 186 | 186 | $logger->info('This library is a system library'); |
| 187 | 187 | } |
| 188 | - else{ |
|
| 188 | + else { |
|
| 189 | 189 | $logger->info('This library is not a system library'); |
| 190 | 190 | //first check if this library is in the module |
| 191 | 191 | $logger->debug('Checking library [' . $class . '] from module list ...'); |
| 192 | 192 | $searchModuleName = null; |
| 193 | 193 | //check if the request class contains module name |
| 194 | - if(strpos($class, '/') !== false){ |
|
| 194 | + if (strpos($class, '/') !== false) { |
|
| 195 | 195 | $path = explode('/', $class); |
| 196 | - if(isset($path[0]) && in_array($path[0], Module::getModuleList())){ |
|
| 196 | + if (isset($path[0]) && in_array($path[0], Module::getModuleList())) { |
|
| 197 | 197 | $searchModuleName = $path[0]; |
| 198 | 198 | $class = ucfirst($path[1]); |
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | - else{ |
|
| 201 | + else { |
|
| 202 | 202 | $class = ucfirst($class); |
| 203 | 203 | } |
| 204 | - if(! $searchModuleName && !empty($obj->moduleName)){ |
|
| 204 | + if (!$searchModuleName && !empty($obj->moduleName)) { |
|
| 205 | 205 | $searchModuleName = $obj->moduleName; |
| 206 | 206 | } |
| 207 | 207 | $moduleLibraryPath = Module::findLibraryFullPath($class, $searchModuleName); |
| 208 | - if($moduleLibraryPath){ |
|
| 209 | - $logger->info('Found library [' . $class . '] from module [' .$searchModuleName. '], the file path is [' .$moduleLibraryPath. '] we will used it'); |
|
| 208 | + if ($moduleLibraryPath) { |
|
| 209 | + $logger->info('Found library [' . $class . '] from module [' . $searchModuleName . '], the file path is [' . $moduleLibraryPath . '] we will used it'); |
|
| 210 | 210 | $libraryFilePath = $moduleLibraryPath; |
| 211 | 211 | } |
| 212 | - else{ |
|
| 212 | + else { |
|
| 213 | 213 | $logger->info('Cannot find library [' . $class . '] from modules using the default location'); |
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | - if(! $libraryFilePath){ |
|
| 216 | + if (!$libraryFilePath) { |
|
| 217 | 217 | $searchDir = array(LIBRARY_PATH); |
| 218 | - foreach($searchDir as $dir){ |
|
| 218 | + foreach ($searchDir as $dir) { |
|
| 219 | 219 | $filePath = $dir . $file; |
| 220 | - if(file_exists($filePath)){ |
|
| 220 | + if (file_exists($filePath)) { |
|
| 221 | 221 | $libraryFilePath = $filePath; |
| 222 | 222 | //is already found not to continue |
| 223 | 223 | break; |
@@ -225,20 +225,20 @@ discard block |
||
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | $logger->info('The library file path to be loaded is [' . $libraryFilePath . ']'); |
| 228 | - if($libraryFilePath){ |
|
| 228 | + if ($libraryFilePath) { |
|
| 229 | 229 | require_once $libraryFilePath; |
| 230 | - if(class_exists($class)){ |
|
| 230 | + if (class_exists($class)) { |
|
| 231 | 231 | $c = $params ? new $class($params) : new $class(); |
| 232 | 232 | $obj = & get_instance(); |
| 233 | 233 | $obj->{$instance} = $c; |
| 234 | 234 | static::$loaded[$instance] = $class; |
| 235 | 235 | $logger->info('Library [' . $class . '] --> ' . $libraryFilePath . ' loaded successfully.'); |
| 236 | 236 | } |
| 237 | - else{ |
|
| 238 | - show_error('The file '.$libraryFilePath.' exists but does not contain the class '.$class); |
|
| 237 | + else { |
|
| 238 | + show_error('The file ' . $libraryFilePath . ' exists but does not contain the class ' . $class); |
|
| 239 | 239 | } |
| 240 | 240 | } |
| 241 | - else{ |
|
| 241 | + else { |
|
| 242 | 242 | show_error('Unable to find library class [' . $class . ']'); |
| 243 | 243 | } |
| 244 | 244 | } |
@@ -250,14 +250,14 @@ discard block |
||
| 250 | 250 | * |
| 251 | 251 | * @return void |
| 252 | 252 | */ |
| 253 | - public static function functions($function){ |
|
| 253 | + public static function functions($function) { |
|
| 254 | 254 | $logger = static::getLogger(); |
| 255 | 255 | $function = str_ireplace('.php', '', $function); |
| 256 | 256 | $function = trim($function, '/\\'); |
| 257 | 257 | $function = str_ireplace('function_', '', $function); |
| 258 | - $file = 'function_'.$function.'.php'; |
|
| 258 | + $file = 'function_' . $function . '.php'; |
|
| 259 | 259 | $logger->debug('Loading helper [' . $function . '] ...'); |
| 260 | - if(isset(static::$loaded['function_' . $function])){ |
|
| 260 | + if (isset(static::$loaded['function_' . $function])) { |
|
| 261 | 261 | $logger->info('Helper [' . $function . '] already loaded no need to load it again, cost in performance'); |
| 262 | 262 | return; |
| 263 | 263 | } |
@@ -267,30 +267,30 @@ discard block |
||
| 267 | 267 | $searchModuleName = null; |
| 268 | 268 | $obj = & get_instance(); |
| 269 | 269 | //check if the request class contains module name |
| 270 | - if(strpos($function, '/') !== false){ |
|
| 270 | + if (strpos($function, '/') !== false) { |
|
| 271 | 271 | $path = explode('/', $function); |
| 272 | - if(isset($path[0]) && in_array($path[0], Module::getModuleList())){ |
|
| 272 | + if (isset($path[0]) && in_array($path[0], Module::getModuleList())) { |
|
| 273 | 273 | $searchModuleName = $path[0]; |
| 274 | 274 | $function = 'function_' . $path[1] . '.php'; |
| 275 | - $file = $path[0] . DS . 'function_'.$function.'.php'; |
|
| 275 | + $file = $path[0] . DS . 'function_' . $function . '.php'; |
|
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | - if(! $searchModuleName && !empty($obj->moduleName)){ |
|
| 278 | + if (!$searchModuleName && !empty($obj->moduleName)) { |
|
| 279 | 279 | $searchModuleName = $obj->moduleName; |
| 280 | 280 | } |
| 281 | 281 | $moduleFunctionPath = Module::findFunctionFullPath($function, $searchModuleName); |
| 282 | - if($moduleFunctionPath){ |
|
| 283 | - $logger->info('Found helper [' . $function . '] from module [' .$searchModuleName. '], the file path is [' .$moduleFunctionPath. '] we will used it'); |
|
| 282 | + if ($moduleFunctionPath) { |
|
| 283 | + $logger->info('Found helper [' . $function . '] from module [' . $searchModuleName . '], the file path is [' . $moduleFunctionPath . '] we will used it'); |
|
| 284 | 284 | $functionFilePath = $moduleFunctionPath; |
| 285 | 285 | } |
| 286 | - else{ |
|
| 286 | + else { |
|
| 287 | 287 | $logger->info('Cannot find helper [' . $function . '] from modules using the default location'); |
| 288 | 288 | } |
| 289 | - if(! $functionFilePath){ |
|
| 289 | + if (!$functionFilePath) { |
|
| 290 | 290 | $searchDir = array(FUNCTIONS_PATH, CORE_FUNCTIONS_PATH); |
| 291 | - foreach($searchDir as $dir){ |
|
| 291 | + foreach ($searchDir as $dir) { |
|
| 292 | 292 | $filePath = $dir . $file; |
| 293 | - if(file_exists($filePath)){ |
|
| 293 | + if (file_exists($filePath)) { |
|
| 294 | 294 | $functionFilePath = $filePath; |
| 295 | 295 | //is already found not to continue |
| 296 | 296 | break; |
@@ -298,12 +298,12 @@ discard block |
||
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | 300 | $logger->info('The helper file path to be loaded is [' . $functionFilePath . ']'); |
| 301 | - if($functionFilePath){ |
|
| 301 | + if ($functionFilePath) { |
|
| 302 | 302 | require_once $functionFilePath; |
| 303 | 303 | static::$loaded['function_' . $function] = $functionFilePath; |
| 304 | 304 | $logger->info('Helper [' . $function . '] --> ' . $functionFilePath . ' loaded successfully.'); |
| 305 | 305 | } |
| 306 | - else{ |
|
| 306 | + else { |
|
| 307 | 307 | show_error('Unable to find helper file [' . $file . ']'); |
| 308 | 308 | } |
| 309 | 309 | } |
@@ -315,14 +315,14 @@ discard block |
||
| 315 | 315 | * |
| 316 | 316 | * @return void |
| 317 | 317 | */ |
| 318 | - public static function config($filename){ |
|
| 318 | + public static function config($filename) { |
|
| 319 | 319 | $logger = static::getLogger(); |
| 320 | 320 | $filename = str_ireplace('.php', '', $filename); |
| 321 | 321 | $filename = trim($filename, '/\\'); |
| 322 | 322 | $filename = str_ireplace('config_', '', $filename); |
| 323 | - $file = 'config_'.$filename.'.php'; |
|
| 323 | + $file = 'config_' . $filename . '.php'; |
|
| 324 | 324 | $logger->debug('Loading configuration [' . $filename . '] ...'); |
| 325 | - if(isset(static::$loaded['config_' . $filename])){ |
|
| 325 | + if (isset(static::$loaded['config_' . $filename])) { |
|
| 326 | 326 | $logger->info('Configuration [' . $file . '] already loaded no need to load it again, cost in performance'); |
| 327 | 327 | return; |
| 328 | 328 | } |
@@ -332,34 +332,34 @@ discard block |
||
| 332 | 332 | $searchModuleName = null; |
| 333 | 333 | $obj = & get_instance(); |
| 334 | 334 | //check if the request class contains module name |
| 335 | - if(strpos($filename, '/') !== false){ |
|
| 335 | + if (strpos($filename, '/') !== false) { |
|
| 336 | 336 | $path = explode('/', $filename); |
| 337 | - if(isset($path[0]) && in_array($path[0], Module::getModuleList())){ |
|
| 337 | + if (isset($path[0]) && in_array($path[0], Module::getModuleList())) { |
|
| 338 | 338 | $searchModuleName = $path[0]; |
| 339 | 339 | $filename = $path[1] . '.php'; |
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | - if(! $searchModuleName && !empty($obj->moduleName)){ |
|
| 342 | + if (!$searchModuleName && !empty($obj->moduleName)) { |
|
| 343 | 343 | $searchModuleName = $obj->moduleName; |
| 344 | 344 | } |
| 345 | 345 | $moduleConfigPath = Module::findConfigFullPath($filename, $searchModuleName); |
| 346 | - if($moduleConfigPath){ |
|
| 347 | - $logger->info('Found config [' . $filename . '] from module [' .$searchModuleName. '], the file path is [' .$moduleConfigPath. '] we will used it'); |
|
| 346 | + if ($moduleConfigPath) { |
|
| 347 | + $logger->info('Found config [' . $filename . '] from module [' . $searchModuleName . '], the file path is [' . $moduleConfigPath . '] we will used it'); |
|
| 348 | 348 | $configFilePath = $moduleConfigPath; |
| 349 | 349 | } |
| 350 | - else{ |
|
| 350 | + else { |
|
| 351 | 351 | $logger->info('Cannot find config [' . $filename . '] from modules using the default location'); |
| 352 | 352 | } |
| 353 | 353 | $logger->info('The config file path to be loaded is [' . $configFilePath . ']'); |
| 354 | 354 | $config = array(); |
| 355 | - if(file_exists($configFilePath)){ |
|
| 355 | + if (file_exists($configFilePath)) { |
|
| 356 | 356 | require_once $configFilePath; |
| 357 | - if(! empty($config) && is_array($config)){ |
|
| 357 | + if (!empty($config) && is_array($config)) { |
|
| 358 | 358 | Config::setAll($config); |
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | - else{ |
|
| 362 | - show_error('Unable to find config file ['. $configFilePath . ']'); |
|
| 361 | + else { |
|
| 362 | + show_error('Unable to find config file [' . $configFilePath . ']'); |
|
| 363 | 363 | } |
| 364 | 364 | static::$loaded['config_' . $filename] = $configFilePath; |
| 365 | 365 | $logger->info('Configuration [' . $configFilePath . '] loaded successfully.'); |
@@ -375,14 +375,14 @@ discard block |
||
| 375 | 375 | * |
| 376 | 376 | * @return void |
| 377 | 377 | */ |
| 378 | - public static function lang($language){ |
|
| 378 | + public static function lang($language) { |
|
| 379 | 379 | $logger = static::getLogger(); |
| 380 | 380 | $language = str_ireplace('.php', '', $language); |
| 381 | 381 | $language = trim($language, '/\\'); |
| 382 | 382 | $language = str_ireplace('lang_', '', $language); |
| 383 | - $file = 'lang_'.$language.'.php'; |
|
| 383 | + $file = 'lang_' . $language . '.php'; |
|
| 384 | 384 | $logger->debug('Loading language [' . $language . '] ...'); |
| 385 | - if(isset(static::$loaded['lang_' . $language])){ |
|
| 385 | + if (isset(static::$loaded['lang_' . $language])) { |
|
| 386 | 386 | $logger->info('Language [' . $language . '] already loaded no need to load it again, cost in performance'); |
| 387 | 387 | return; |
| 388 | 388 | } |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | $cfgKey = get_config('language_cookie_name'); |
| 393 | 393 | $objCookie = & class_loader('Cookie'); |
| 394 | 394 | $cookieLang = $objCookie->get($cfgKey); |
| 395 | - if($cookieLang){ |
|
| 395 | + if ($cookieLang) { |
|
| 396 | 396 | $appLang = $cookieLang; |
| 397 | 397 | } |
| 398 | 398 | $languageFilePath = null; |
@@ -401,30 +401,30 @@ discard block |
||
| 401 | 401 | $searchModuleName = null; |
| 402 | 402 | $obj = & get_instance(); |
| 403 | 403 | //check if the request class contains module name |
| 404 | - if(strpos($language, '/') !== false){ |
|
| 404 | + if (strpos($language, '/') !== false) { |
|
| 405 | 405 | $path = explode('/', $language); |
| 406 | - if(isset($path[0]) && in_array($path[0], Module::getModuleList())){ |
|
| 406 | + if (isset($path[0]) && in_array($path[0], Module::getModuleList())) { |
|
| 407 | 407 | $searchModuleName = $path[0]; |
| 408 | 408 | $language = 'lang_' . $path[1] . '.php'; |
| 409 | - $file = $path[0] . DS .$language; |
|
| 409 | + $file = $path[0] . DS . $language; |
|
| 410 | 410 | } |
| 411 | 411 | } |
| 412 | - if(! $searchModuleName && !empty($obj->moduleName)){ |
|
| 412 | + if (!$searchModuleName && !empty($obj->moduleName)) { |
|
| 413 | 413 | $searchModuleName = $obj->moduleName; |
| 414 | 414 | } |
| 415 | 415 | $moduleLanguagePath = Module::findLanguageFullPath($language, $searchModuleName, $appLang); |
| 416 | - if($moduleLanguagePath){ |
|
| 417 | - $logger->info('Found language [' . $language . '] from module [' .$searchModuleName. '], the file path is [' .$moduleLanguagePath. '] we will used it'); |
|
| 416 | + if ($moduleLanguagePath) { |
|
| 417 | + $logger->info('Found language [' . $language . '] from module [' . $searchModuleName . '], the file path is [' . $moduleLanguagePath . '] we will used it'); |
|
| 418 | 418 | $languageFilePath = $moduleLanguagePath; |
| 419 | 419 | } |
| 420 | - else{ |
|
| 420 | + else { |
|
| 421 | 421 | $logger->info('Cannot find language [' . $language . '] from modules using the default location'); |
| 422 | 422 | } |
| 423 | - if(! $languageFilePath){ |
|
| 423 | + if (!$languageFilePath) { |
|
| 424 | 424 | $searchDir = array(APP_LANG_PATH, CORE_LANG_PATH); |
| 425 | - foreach($searchDir as $dir){ |
|
| 425 | + foreach ($searchDir as $dir) { |
|
| 426 | 426 | $filePath = $dir . $appLang . DS . $file; |
| 427 | - if(file_exists($filePath)){ |
|
| 427 | + if (file_exists($filePath)) { |
|
| 428 | 428 | $languageFilePath = $filePath; |
| 429 | 429 | //is already found not to continue |
| 430 | 430 | break; |
@@ -432,13 +432,13 @@ discard block |
||
| 432 | 432 | } |
| 433 | 433 | } |
| 434 | 434 | $logger->info('The language file path to be loaded is [' . $languageFilePath . ']'); |
| 435 | - if($languageFilePath){ |
|
| 435 | + if ($languageFilePath) { |
|
| 436 | 436 | $lang = array(); |
| 437 | 437 | require_once $languageFilePath; |
| 438 | - if(! empty($lang) && is_array($lang)){ |
|
| 439 | - $logger->info('Language file [' .$languageFilePath. '] contains the valid languages keys add them to language list'); |
|
| 438 | + if (!empty($lang) && is_array($lang)) { |
|
| 439 | + $logger->info('Language file [' . $languageFilePath . '] contains the valid languages keys add them to language list'); |
|
| 440 | 440 | //Note: may be here the class 'Lang' not yet loaded |
| 441 | - $langObj =& class_loader('Lang', 'classes'); |
|
| 441 | + $langObj = & class_loader('Lang', 'classes'); |
|
| 442 | 442 | $langObj->addLangMessages($lang); |
| 443 | 443 | //free the memory |
| 444 | 444 | unset($lang); |
@@ -446,13 +446,13 @@ discard block |
||
| 446 | 446 | static::$loaded['lang_' . $language] = $languageFilePath; |
| 447 | 447 | $logger->info('Language [' . $language . '] --> ' . $languageFilePath . ' loaded successfully.'); |
| 448 | 448 | } |
| 449 | - else{ |
|
| 449 | + else { |
|
| 450 | 450 | show_error('Unable to find language file [' . $file . ']'); |
| 451 | 451 | } |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | |
| 455 | - private function getResourcesFromAutoloadConfig(){ |
|
| 455 | + private function getResourcesFromAutoloadConfig() { |
|
| 456 | 456 | $autoloads = array(); |
| 457 | 457 | $autoloads['config'] = array(); |
| 458 | 458 | $autoloads['languages'] = array(); |
@@ -460,17 +460,17 @@ discard block |
||
| 460 | 460 | $autoloads['models'] = array(); |
| 461 | 461 | $autoloads['functions'] = array(); |
| 462 | 462 | //loading of the resources in autoload.php configuration file |
| 463 | - if(file_exists(CONFIG_PATH . 'autoload.php')){ |
|
| 463 | + if (file_exists(CONFIG_PATH . 'autoload.php')) { |
|
| 464 | 464 | $autoload = array(); |
| 465 | 465 | require_once CONFIG_PATH . 'autoload.php'; |
| 466 | - if(! empty($autoload) && is_array($autoload)){ |
|
| 466 | + if (!empty($autoload) && is_array($autoload)) { |
|
| 467 | 467 | $autoloads = array_merge($autoloads, $autoload); |
| 468 | 468 | unset($autoload); |
| 469 | 469 | } |
| 470 | 470 | } |
| 471 | 471 | //loading autoload configuration for modules |
| 472 | 472 | $modulesAutoloads = Module::getModulesAutoloadConfig(); |
| 473 | - if(! empty($modulesAutoloads) && is_array($modulesAutoloads)){ |
|
| 473 | + if (!empty($modulesAutoloads) && is_array($modulesAutoloads)) { |
|
| 474 | 474 | $autoloads = array_merge_recursive($autoloads, $modulesAutoloads); |
| 475 | 475 | } |
| 476 | 476 | return $autoloads; |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | * Load the autoload configuration |
| 481 | 481 | * @return void |
| 482 | 482 | */ |
| 483 | - private function loadResourcesFromAutoloadConfig(){ |
|
| 483 | + private function loadResourcesFromAutoloadConfig() { |
|
| 484 | 484 | $autoloads = array(); |
| 485 | 485 | $autoloads['config'] = array(); |
| 486 | 486 | $autoloads['languages'] = array(); |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | * @param array $resources the resource to load |
| 514 | 514 | * @return void |
| 515 | 515 | */ |
| 516 | - private function loadAutoloadResourcesArray($method, array $resources){ |
|
| 516 | + private function loadAutoloadResourcesArray($method, array $resources) { |
|
| 517 | 517 | foreach ($resources as $name) { |
| 518 | 518 | $this->{$method}($name); |
| 519 | 519 | } |
@@ -23,19 +23,19 @@ discard block |
||
| 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 | - class DatabaseQueryRunner{ |
|
| 26 | + class DatabaseQueryRunner { |
|
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * The logger instance |
| 30 | 30 | * @var object |
| 31 | 31 | */ |
| 32 | - private $logger = null; |
|
| 32 | + private $logger = null; |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * The last query result |
| 36 | 36 | * @var object |
| 37 | 37 | */ |
| 38 | - private $queryResult = null; |
|
| 38 | + private $queryResult = null; |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * The benchmark instance |
@@ -47,45 +47,45 @@ discard block |
||
| 47 | 47 | * The SQL query statment to execute |
| 48 | 48 | * @var string |
| 49 | 49 | */ |
| 50 | - private $query = null; |
|
| 50 | + private $query = null; |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * Indicate if we need return result as list (boolean) |
| 54 | 54 | * or the data used to replace the placeholder (array) |
| 55 | 55 | * @var array|boolean |
| 56 | 56 | */ |
| 57 | - private $returnAsList = true; |
|
| 57 | + private $returnAsList = true; |
|
| 58 | 58 | |
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * Indicate if we need return result as array or not |
| 62 | 62 | * @var boolean |
| 63 | 63 | */ |
| 64 | - private $returnAsArray = true; |
|
| 64 | + private $returnAsArray = true; |
|
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * The last PDOStatment instance |
| 68 | 68 | * @var object |
| 69 | 69 | */ |
| 70 | - private $pdoStatment = null; |
|
| 70 | + private $pdoStatment = null; |
|
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | 73 | * The error returned for the last query |
| 74 | 74 | * @var string |
| 75 | 75 | */ |
| 76 | - private $error = null; |
|
| 76 | + private $error = null; |
|
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * The PDO instance |
| 80 | 80 | * @var object |
| 81 | 81 | */ |
| 82 | - private $pdo = null; |
|
| 82 | + private $pdo = null; |
|
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * The database driver name used |
| 86 | 86 | * @var string |
| 87 | 87 | */ |
| 88 | - private $driver = null; |
|
| 88 | + private $driver = null; |
|
| 89 | 89 | |
| 90 | 90 | |
| 91 | 91 | |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | * @param boolean $returnAsList if need return as list or just one row |
| 97 | 97 | * @param boolean $returnAsArray whether to return the result as array or not |
| 98 | 98 | */ |
| 99 | - public function __construct(PDO $pdo = null, $query = null, $returnAsList = true, $returnAsArray = false){ |
|
| 100 | - if (is_object($pdo)){ |
|
| 99 | + public function __construct(PDO $pdo = null, $query = null, $returnAsList = true, $returnAsArray = false) { |
|
| 100 | + if (is_object($pdo)) { |
|
| 101 | 101 | $this->pdo = $pdo; |
| 102 | 102 | } |
| 103 | 103 | $this->query = $query; |
@@ -112,13 +112,13 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @return object|void |
| 114 | 114 | */ |
| 115 | - public function execute(){ |
|
| 115 | + public function execute() { |
|
| 116 | 116 | //reset instance |
| 117 | 117 | $this->reset(); |
| 118 | 118 | |
| 119 | 119 | //for database query execution time |
| 120 | 120 | $benchmarkMarkerKey = $this->getBenchmarkKey(); |
| 121 | - if (! is_object($this->benchmarkInstance)){ |
|
| 121 | + if (!is_object($this->benchmarkInstance)) { |
|
| 122 | 122 | $this->benchmarkInstance = & class_loader('Benchmark'); |
| 123 | 123 | } |
| 124 | 124 | |
@@ -134,19 +134,19 @@ discard block |
||
| 134 | 134 | 'DATABASE_QUERY_END(' . $benchmarkMarkerKey . ')' |
| 135 | 135 | ); |
| 136 | 136 | //TODO use the configuration value for the high response time currently is 1 second |
| 137 | - if ($responseTime >= 1 ){ |
|
| 137 | + if ($responseTime >= 1) { |
|
| 138 | 138 | $this->logger->warning( |
| 139 | 139 | 'High response time while processing database query [' . $this->query . ']. |
| 140 | - The response time is [' .$responseTime. '] sec.' |
|
| 140 | + The response time is [' .$responseTime . '] sec.' |
|
| 141 | 141 | ); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - if ($this->pdoStatment !== false){ |
|
| 144 | + if ($this->pdoStatment !== false) { |
|
| 145 | 145 | $isSqlSELECTQuery = stristr($this->query, 'SELECT') !== false; |
| 146 | - if($isSqlSELECTQuery){ |
|
| 146 | + if ($isSqlSELECTQuery) { |
|
| 147 | 147 | $this->setResultForSelect(); |
| 148 | 148 | } |
| 149 | - else{ |
|
| 149 | + else { |
|
| 150 | 150 | $this->setResultForNonSelect(); |
| 151 | 151 | } |
| 152 | 152 | return $this->queryResult; |
@@ -158,28 +158,28 @@ discard block |
||
| 158 | 158 | * Return the result for SELECT query |
| 159 | 159 | * @see DatabaseQueryRunner::execute |
| 160 | 160 | */ |
| 161 | - protected function setResultForSelect(){ |
|
| 161 | + protected function setResultForSelect() { |
|
| 162 | 162 | //if need return all result like list of record |
| 163 | 163 | $result = null; |
| 164 | 164 | $numRows = 0; |
| 165 | 165 | $fetchMode = PDO::FETCH_OBJ; |
| 166 | - if($this->returnAsArray){ |
|
| 166 | + if ($this->returnAsArray) { |
|
| 167 | 167 | $fetchMode = PDO::FETCH_ASSOC; |
| 168 | 168 | } |
| 169 | - if ($this->returnAsList){ |
|
| 169 | + if ($this->returnAsList) { |
|
| 170 | 170 | $result = $this->pdoStatment->fetchAll($fetchMode); |
| 171 | 171 | } |
| 172 | - else{ |
|
| 172 | + else { |
|
| 173 | 173 | $result = $this->pdoStatment->fetch($fetchMode); |
| 174 | 174 | } |
| 175 | 175 | //Sqlite and pgsql always return 0 when using rowCount() |
| 176 | - if (in_array($this->driver, array('sqlite', 'pgsql'))){ |
|
| 176 | + if (in_array($this->driver, array('sqlite', 'pgsql'))) { |
|
| 177 | 177 | $numRows = count($result); |
| 178 | 178 | } |
| 179 | - else{ |
|
| 179 | + else { |
|
| 180 | 180 | $numRows = $this->pdoStatment->rowCount(); |
| 181 | 181 | } |
| 182 | - if(! is_object($this->queryResult)){ |
|
| 182 | + if (!is_object($this->queryResult)) { |
|
| 183 | 183 | $this->queryResult = & class_loader('DatabaseQueryResult', 'classes/database'); |
| 184 | 184 | } |
| 185 | 185 | $this->queryResult->setResult($result); |
@@ -190,20 +190,20 @@ discard block |
||
| 190 | 190 | * Return the result for non SELECT query |
| 191 | 191 | * @see DatabaseQueryRunner::execute |
| 192 | 192 | */ |
| 193 | - protected function setResultForNonSelect(){ |
|
| 193 | + protected function setResultForNonSelect() { |
|
| 194 | 194 | //Sqlite and pgsql always return 0 when using rowCount() |
| 195 | 195 | $result = false; |
| 196 | 196 | $numRows = 0; |
| 197 | - if (in_array($this->driver, array('sqlite', 'pgsql'))){ |
|
| 197 | + if (in_array($this->driver, array('sqlite', 'pgsql'))) { |
|
| 198 | 198 | $result = true; //to test the result for the query like UPDATE, INSERT, DELETE |
| 199 | 199 | $numRows = 1; //TODO use the correct method to get the exact affected row |
| 200 | 200 | } |
| 201 | - else{ |
|
| 201 | + else { |
|
| 202 | 202 | //to test the result for the query like UPDATE, INSERT, DELETE |
| 203 | 203 | $result = $this->pdoStatment->rowCount() >= 0; |
| 204 | 204 | $numRows = $this->pdoStatment->rowCount(); |
| 205 | 205 | } |
| 206 | - if(! is_object($this->queryResult)){ |
|
| 206 | + if (!is_object($this->queryResult)) { |
|
| 207 | 207 | $this->queryResult = & class_loader('DatabaseQueryResult', 'classes/database'); |
| 208 | 208 | } |
| 209 | 209 | $this->queryResult->setResult($result); |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | * Return the benchmark instance |
| 216 | 216 | * @return Benchmark |
| 217 | 217 | */ |
| 218 | - public function getBenchmark(){ |
|
| 218 | + public function getBenchmark() { |
|
| 219 | 219 | return $this->benchmarkInstance; |
| 220 | 220 | } |
| 221 | 221 | |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | * @param Benchmark $benchmark the benchmark object |
| 225 | 225 | * @return object DatabaseQueryRunner |
| 226 | 226 | */ |
| 227 | - public function setBenchmark($benchmark){ |
|
| 227 | + public function setBenchmark($benchmark) { |
|
| 228 | 228 | $this->benchmarkInstance = $benchmark; |
| 229 | 229 | return $this; |
| 230 | 230 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * |
| 235 | 235 | * @return object DatabaseQueryResult |
| 236 | 236 | */ |
| 237 | - public function getQueryResult(){ |
|
| 237 | + public function getQueryResult() { |
|
| 238 | 238 | return $this->queryResult; |
| 239 | 239 | } |
| 240 | 240 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | * |
| 245 | 245 | * @return object DatabaseQueryRunner |
| 246 | 246 | */ |
| 247 | - public function setQueryResult(DatabaseQueryResult $queryResult){ |
|
| 247 | + public function setQueryResult(DatabaseQueryResult $queryResult) { |
|
| 248 | 248 | $this->queryResult = $queryResult; |
| 249 | 249 | return $this; |
| 250 | 250 | } |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | * Return the Log instance |
| 254 | 254 | * @return Log |
| 255 | 255 | */ |
| 256 | - public function getLogger(){ |
|
| 256 | + public function getLogger() { |
|
| 257 | 257 | return $this->logger; |
| 258 | 258 | } |
| 259 | 259 | |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | * @param Log $logger the log object |
| 263 | 263 | * @return object DatabaseQueryRunner |
| 264 | 264 | */ |
| 265 | - public function setLogger($logger){ |
|
| 265 | + public function setLogger($logger) { |
|
| 266 | 266 | $this->logger = $logger; |
| 267 | 267 | return $this; |
| 268 | 268 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | * Return the current query SQL string |
| 272 | 272 | * @return string |
| 273 | 273 | */ |
| 274 | - public function getQuery(){ |
|
| 274 | + public function getQuery() { |
|
| 275 | 275 | return $this->query; |
| 276 | 276 | } |
| 277 | 277 | |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | * @param string $query the SQL query to set |
| 281 | 281 | * @return object DatabaseQueryRunner |
| 282 | 282 | */ |
| 283 | - public function setQuery($query){ |
|
| 283 | + public function setQuery($query) { |
|
| 284 | 284 | $this->query = $query; |
| 285 | 285 | return $this; |
| 286 | 286 | } |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * @param boolean $returnType |
| 291 | 291 | * @return object DatabaseQueryRunner |
| 292 | 292 | */ |
| 293 | - public function setReturnType($returnType){ |
|
| 293 | + public function setReturnType($returnType) { |
|
| 294 | 294 | $this->returnAsList = $returnType; |
| 295 | 295 | return $this; |
| 296 | 296 | } |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | * @param boolean $status the status if true will return as array |
| 301 | 301 | * @return object DatabaseQueryRunner |
| 302 | 302 | */ |
| 303 | - public function setReturnAsArray($status = true){ |
|
| 303 | + public function setReturnAsArray($status = true) { |
|
| 304 | 304 | $this->returnAsArray = $status; |
| 305 | 305 | return $this; |
| 306 | 306 | } |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | * Return the error for last query execution |
| 310 | 310 | * @return string |
| 311 | 311 | */ |
| 312 | - public function getQueryError(){ |
|
| 312 | + public function getQueryError() { |
|
| 313 | 313 | return $this->error; |
| 314 | 314 | } |
| 315 | 315 | |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | * Return the PDO instance |
| 318 | 318 | * @return object |
| 319 | 319 | */ |
| 320 | - public function getPdo(){ |
|
| 320 | + public function getPdo() { |
|
| 321 | 321 | return $this->pdo; |
| 322 | 322 | } |
| 323 | 323 | |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | * @param PDO $pdo the pdo object |
| 327 | 327 | * @return object DatabaseQueryRunner |
| 328 | 328 | */ |
| 329 | - public function setPdo(PDO $pdo = null){ |
|
| 329 | + public function setPdo(PDO $pdo = null) { |
|
| 330 | 330 | $this->pdo = $pdo; |
| 331 | 331 | return $this; |
| 332 | 332 | } |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | * Return the database driver |
| 336 | 336 | * @return string |
| 337 | 337 | */ |
| 338 | - public function getDriver(){ |
|
| 338 | + public function getDriver() { |
|
| 339 | 339 | return $this->driver; |
| 340 | 340 | } |
| 341 | 341 | |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | * @param string $driver the new driver |
| 345 | 345 | * @return object DatabaseQueryRunner |
| 346 | 346 | */ |
| 347 | - public function setDriver($driver){ |
|
| 347 | + public function setDriver($driver) { |
|
| 348 | 348 | $this->driver = $driver; |
| 349 | 349 | return $this; |
| 350 | 350 | } |
@@ -354,14 +354,14 @@ discard block |
||
| 354 | 354 | * |
| 355 | 355 | * @return string |
| 356 | 356 | */ |
| 357 | - protected function getBenchmarkKey(){ |
|
| 357 | + protected function getBenchmarkKey() { |
|
| 358 | 358 | return md5($this->query . $this->returnAsList . $this->returnAsArray); |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | /** |
| 362 | 362 | * Set error for database query execution |
| 363 | 363 | */ |
| 364 | - protected function setQueryRunnerError(){ |
|
| 364 | + protected function setQueryRunnerError() { |
|
| 365 | 365 | $error = $this->pdo->errorInfo(); |
| 366 | 366 | $this->error = isset($error[2]) ? $error[2] : ''; |
| 367 | 367 | $this->logger->error('The database query execution got an error: ' . stringfy_vars($error)); |
@@ -373,12 +373,12 @@ discard block |
||
| 373 | 373 | * Set the Log instance using argument or create new instance |
| 374 | 374 | * @param object $logger the Log instance if not null |
| 375 | 375 | */ |
| 376 | - protected function setLoggerFromParamOrCreateNewInstance(Log $logger = null){ |
|
| 377 | - if ($logger !== null){ |
|
| 376 | + protected function setLoggerFromParamOrCreateNewInstance(Log $logger = null) { |
|
| 377 | + if ($logger !== null) { |
|
| 378 | 378 | $this->logger = $logger; |
| 379 | 379 | } |
| 380 | - else{ |
|
| 381 | - $this->logger =& class_loader('Log', 'classes'); |
|
| 380 | + else { |
|
| 381 | + $this->logger = & class_loader('Log', 'classes'); |
|
| 382 | 382 | $this->logger->setLogger('Library::DatabaseQueryRunner'); |
| 383 | 383 | } |
| 384 | 384 | } |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | /** |
| 388 | 388 | * Reset the instance before run each query |
| 389 | 389 | */ |
| 390 | - private function reset(){ |
|
| 390 | + private function reset() { |
|
| 391 | 391 | $this->error = null; |
| 392 | 392 | $this->pdoStatment = null; |
| 393 | 393 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | |
| 43 | 43 | |
| 44 | - if(! function_exists('get_ip')){ |
|
| 44 | + if (!function_exists('get_ip')) { |
|
| 45 | 45 | /** |
| 46 | 46 | * Retrieves the user's IP address |
| 47 | 47 | * |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return string the IP address. |
| 52 | 52 | */ |
| 53 | - function get_ip(){ |
|
| 53 | + function get_ip() { |
|
| 54 | 54 | $ip = '127.0.0.1'; |
| 55 | 55 | $ipServerVars = array( |
| 56 | 56 | 'REMOTE_ADDR', |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | 'HTTP_FORWARDED' |
| 62 | 62 | ); |
| 63 | 63 | foreach ($ipServerVars as $var) { |
| 64 | - if(isset($_SERVER[$var])){ |
|
| 64 | + if (isset($_SERVER[$var])) { |
|
| 65 | 65 | $ip = $_SERVER[$var]; |
| 66 | 66 | break; |
| 67 | 67 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * @since 1.0.0 |
| 39 | 39 | * @filesource |
| 40 | 40 | */ |
| 41 | - class Assets{ |
|
| 41 | + class Assets { |
|
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * The logger instance |
@@ -50,10 +50,10 @@ discard block |
||
| 50 | 50 | * The signleton of the logger |
| 51 | 51 | * @return Object the Log instance |
| 52 | 52 | */ |
| 53 | - private static function getLogger(){ |
|
| 54 | - if(self::$logger == null){ |
|
| 53 | + private static function getLogger() { |
|
| 54 | + if (self::$logger == null) { |
|
| 55 | 55 | //can't assign reference to static variable |
| 56 | - self::$logger[0] =& class_loader('Log', 'classes'); |
|
| 56 | + self::$logger[0] = & class_loader('Log', 'classes'); |
|
| 57 | 57 | self::$logger[0]->setLogger('Library::Assets'); |
| 58 | 58 | } |
| 59 | 59 | return self::$logger[0]; |
@@ -72,13 +72,13 @@ discard block |
||
| 72 | 72 | * @param string $asset the name of the assets file path with the extension. |
| 73 | 73 | * @return string|null the absolute path of the assets file, if it exists otherwise returns null if the file does not exist. |
| 74 | 74 | */ |
| 75 | - public static function path($asset){ |
|
| 75 | + public static function path($asset) { |
|
| 76 | 76 | $logger = self::getLogger(); |
| 77 | 77 | $path = ASSETS_PATH . $asset; |
| 78 | 78 | |
| 79 | 79 | $logger->debug('Including the Assets file [' . $path . ']'); |
| 80 | 80 | //Check if the file exists |
| 81 | - if(file_exists($path)){ |
|
| 81 | + if (file_exists($path)) { |
|
| 82 | 82 | $logger->info('Assets file [' . $path . '] included successfully'); |
| 83 | 83 | return Url::base_url($path); |
| 84 | 84 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * @param string $path the name of the css file without the extension. |
| 99 | 99 | * @return string|null the absolute path of the css file, if it exists otherwise returns null if the file does not exist. |
| 100 | 100 | */ |
| 101 | - public static function css($path){ |
|
| 101 | + public static function css($path) { |
|
| 102 | 102 | $logger = self::getLogger(); |
| 103 | 103 | /* |
| 104 | 104 | * if the file name contains the ".css" extension, replace it with |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | $logger->debug('Including the Assets file [' . $path . '] for CSS'); |
| 111 | 111 | //Check if the file exists |
| 112 | - if(file_exists($path)){ |
|
| 112 | + if (file_exists($path)) { |
|
| 113 | 113 | $logger->info('Assets file [' . $path . '] for CSS included successfully'); |
| 114 | 114 | return Url::base_url($path); |
| 115 | 115 | } |
@@ -129,12 +129,12 @@ discard block |
||
| 129 | 129 | * @param string $path the name of the javascript file without the extension. |
| 130 | 130 | * @return string|null the absolute path of the javascript file, if it exists otherwise returns null if the file does not exist. |
| 131 | 131 | */ |
| 132 | - public static function js($path){ |
|
| 132 | + public static function js($path) { |
|
| 133 | 133 | $logger = self::getLogger(); |
| 134 | 134 | $path = str_ireplace('.js', '', $path); |
| 135 | 135 | $path = ASSETS_PATH . 'js/' . $path . '.js'; |
| 136 | 136 | $logger->debug('Including the Assets file [' . $path . '] for javascript'); |
| 137 | - if(file_exists($path)){ |
|
| 137 | + if (file_exists($path)) { |
|
| 138 | 138 | $logger->info('Assets file [' . $path . '] for Javascript included successfully'); |
| 139 | 139 | return Url::base_url($path); |
| 140 | 140 | } |
@@ -154,11 +154,11 @@ discard block |
||
| 154 | 154 | * @param string $path the name of the image file with the extension. |
| 155 | 155 | * @return string|null the absolute path of the image file, if it exists otherwise returns null if the file does not exist. |
| 156 | 156 | */ |
| 157 | - public static function img($path){ |
|
| 157 | + public static function img($path) { |
|
| 158 | 158 | $logger = self::getLogger(); |
| 159 | 159 | $path = ASSETS_PATH . 'images/' . $path; |
| 160 | 160 | $logger->debug('Including the Assets file [' . $path . '] for image'); |
| 161 | - if(file_exists($path)){ |
|
| 161 | + if (file_exists($path)) { |
|
| 162 | 162 | $logger->info('Assets file [' . $path . '] for image included successfully'); |
| 163 | 163 | return Url::base_url($path); |
| 164 | 164 | } |