@@ -22,7 +22,7 @@ |
||
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | - */ |
|
25 | + */ |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * DB session handler class |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | protected $sessionTableColumns = array(); |
47 | 47 | |
48 | - public function __construct(Database $db = null){ |
|
48 | + public function __construct(Database $db = null) { |
|
49 | 49 | parent::__construct($db); |
50 | 50 | } |
51 | 51 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * Return the session database table columns |
54 | 54 | * @return array |
55 | 55 | */ |
56 | - public function getSessionTableColumns(){ |
|
56 | + public function getSessionTableColumns() { |
|
57 | 57 | return $this->sessionTableColumns; |
58 | 58 | } |
59 | 59 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * Set the session database table columns |
62 | 62 | * @param array $columns the columns definition |
63 | 63 | */ |
64 | - public function setSessionTableColumns(array $columns){ |
|
64 | + public function setSessionTableColumns(array $columns) { |
|
65 | 65 | $this->sessionTableColumns = $columns; |
66 | 66 | return $this; |
67 | 67 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | - */ |
|
25 | + */ |
|
26 | 26 | |
27 | 27 | |
28 | 28 | class Url{ |
@@ -25,15 +25,15 @@ discard block |
||
25 | 25 | */ |
26 | 26 | |
27 | 27 | |
28 | - class Url{ |
|
28 | + class Url { |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Return the link using base_url config without front controller "index.php" |
32 | 32 | * @param string $path the link path or full URL |
33 | 33 | * @return string the full link URL |
34 | 34 | */ |
35 | - public static function base_url($path = ''){ |
|
36 | - if(is_url($path)){ |
|
35 | + public static function base_url($path = '') { |
|
36 | + if (is_url($path)) { |
|
37 | 37 | return $path; |
38 | 38 | } |
39 | 39 | return get_config('base_url') . $path; |
@@ -44,26 +44,26 @@ discard block |
||
44 | 44 | * @param string $path the link path or full URL |
45 | 45 | * @return string the full link URL |
46 | 46 | */ |
47 | - public static function site_url($path = ''){ |
|
48 | - if(is_url($path)){ |
|
47 | + public static function site_url($path = '') { |
|
48 | + if (is_url($path)) { |
|
49 | 49 | return $path; |
50 | 50 | } |
51 | 51 | $path = rtrim($path, '/'); |
52 | 52 | $baseUrl = get_config('base_url'); |
53 | 53 | $frontController = get_config('front_controller'); |
54 | 54 | $url = $baseUrl; |
55 | - if($frontController){ |
|
55 | + if ($frontController) { |
|
56 | 56 | $url .= $frontController . '/'; |
57 | 57 | } |
58 | - if(($suffix = get_config('url_suffix')) && $path){ |
|
59 | - if(strpos($path, '?') !== false){ |
|
58 | + if (($suffix = get_config('url_suffix')) && $path) { |
|
59 | + if (strpos($path, '?') !== false) { |
|
60 | 60 | $query = explode('?', $path); |
61 | 61 | $query[0] = str_ireplace($suffix, '', $query[0]); |
62 | 62 | $query[0] = rtrim($query[0], '/'); |
63 | 63 | $query[0] .= $suffix; |
64 | 64 | $path = implode('?', $query); |
65 | 65 | } |
66 | - else{ |
|
66 | + else { |
|
67 | 67 | $path .= $suffix; |
68 | 68 | } |
69 | 69 | } |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | * Return the current site URL |
75 | 75 | * @return string |
76 | 76 | */ |
77 | - public static function current(){ |
|
77 | + public static function current() { |
|
78 | 78 | $current = '/'; |
79 | 79 | $requestUri = get_instance()->request->requestUri(); |
80 | - if($requestUri){ |
|
80 | + if ($requestUri) { |
|
81 | 81 | $current = $requestUri; |
82 | 82 | } |
83 | 83 | return static::domain() . $current; |
@@ -90,18 +90,18 @@ discard block |
||
90 | 90 | * @param boolean $lowercase whether to set the final text to lowe case or not |
91 | 91 | * @return string the friendly generated text |
92 | 92 | */ |
93 | - public static function title($str = null, $separator = '-', $lowercase = true){ |
|
93 | + public static function title($str = null, $separator = '-', $lowercase = true) { |
|
94 | 94 | $str = trim($str); |
95 | - $from = array('ç','À','Á','Â','Ã','Ä','Å','à','á','â','ã','ä','å','Ò','Ó','Ô','Õ','Ö','Ø','ò','ó','ô','õ','ö','ø','È','É','Ê','Ë','è','é','ê','ë','Ç','ç','Ì','Í','Î','Ï','ì','í','î','ï','Ù','Ú','Û','Ü','ù','ú','û','ü','ÿ','Ñ','ñ'); |
|
96 | - $to = array('c','a','a','a','a','a','a','a','a','a','a','a','a','o','o','o','o','o','o','o','o','o','o','o','o','e','e','e','e','e','e','e','e','e','e','i','i','i','i','i','i','i','i','u','u','u','u','u','u','u','u','y','n','n'); |
|
95 | + $from = array('ç', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'à', 'á', 'â', 'ã', 'ä', 'å', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'È', 'É', 'Ê', 'Ë', 'è', 'é', 'ê', 'ë', 'Ç', 'ç', 'Ì', 'Í', 'Î', 'Ï', 'ì', 'í', 'î', 'ï', 'Ù', 'Ú', 'Û', 'Ü', 'ù', 'ú', 'û', 'ü', 'ÿ', 'Ñ', 'ñ'); |
|
96 | + $to = array('c', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'i', 'i', 'i', 'i', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'y', 'n', 'n'); |
|
97 | 97 | $str = str_replace($from, $to, $str); |
98 | 98 | $str = preg_replace('#([^a-z0-9]+)#i', $separator, $str); |
99 | 99 | $str = str_replace('--', $separator, $str); |
100 | 100 | //if after process we get something like one-two-three-, need truncate the last separator "-" |
101 | - if(substr($str, -1) == $separator){ |
|
101 | + if (substr($str, -1) == $separator) { |
|
102 | 102 | $str = substr($str, 0, -1); |
103 | 103 | } |
104 | - if($lowercase){ |
|
104 | + if ($lowercase) { |
|
105 | 105 | $str = strtolower($str); |
106 | 106 | } |
107 | 107 | return $str; |
@@ -111,36 +111,36 @@ discard block |
||
111 | 111 | * Get the current application domain with protocol |
112 | 112 | * @return string the domain name |
113 | 113 | */ |
114 | - public static function domain(){ |
|
114 | + public static function domain() { |
|
115 | 115 | $obj = & get_instance(); |
116 | 116 | $domain = 'localhost'; |
117 | 117 | $port = $obj->request->server('SERVER_PORT'); |
118 | 118 | $protocol = is_https() ? 'https' : 'http'; |
119 | 119 | |
120 | - if($obj->request->server('HTTP_HOST')){ |
|
120 | + if ($obj->request->server('HTTP_HOST')) { |
|
121 | 121 | $domain = $obj->request->server('HTTP_HOST'); |
122 | 122 | } |
123 | - else if($obj->request->server('SERVER_NAME')){ |
|
123 | + else if ($obj->request->server('SERVER_NAME')) { |
|
124 | 124 | $domain = $obj->request->server('SERVER_NAME'); |
125 | 125 | } |
126 | - else if($obj->request->server('SERVER_ADDR')){ |
|
126 | + else if ($obj->request->server('SERVER_ADDR')) { |
|
127 | 127 | $domain = $obj->request->server('SERVER_ADDR'); |
128 | 128 | } |
129 | - if($port && (is_https() && $port != 443 || !is_https() && $port != 80)){ |
|
129 | + if ($port && (is_https() && $port != 443 || !is_https() && $port != 80)) { |
|
130 | 130 | //some server use SSL but the port doesn't equal 443 sometime is 80 if is the case put the port at this end |
131 | 131 | //of the domain like https://my.domain.com:787 |
132 | - if(is_https() && $port != 80){ |
|
133 | - $domain .= ':'.$port; |
|
132 | + if (is_https() && $port != 80) { |
|
133 | + $domain .= ':' . $port; |
|
134 | 134 | } |
135 | 135 | } |
136 | - return $protocol.'://'.$domain; |
|
136 | + return $protocol . '://' . $domain; |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
140 | 140 | * Get the current request query string |
141 | 141 | * @return string |
142 | 142 | */ |
143 | - public static function queryString(){ |
|
143 | + public static function queryString() { |
|
144 | 144 | return get_instance()->request->server('QUERY_STRING'); |
145 | 145 | } |
146 | 146 | } |
147 | 147 | \ No newline at end of file |
@@ -62,8 +62,7 @@ discard block |
||
62 | 62 | $query[0] = rtrim($query[0], '/'); |
63 | 63 | $query[0] .= $suffix; |
64 | 64 | $path = implode('?', $query); |
65 | - } |
|
66 | - else{ |
|
65 | + } else{ |
|
67 | 66 | $path .= $suffix; |
68 | 67 | } |
69 | 68 | } |
@@ -119,11 +118,9 @@ discard block |
||
119 | 118 | |
120 | 119 | if($obj->request->server('HTTP_HOST')){ |
121 | 120 | $domain = $obj->request->server('HTTP_HOST'); |
122 | - } |
|
123 | - else if($obj->request->server('SERVER_NAME')){ |
|
121 | + } else if($obj->request->server('SERVER_NAME')){ |
|
124 | 122 | $domain = $obj->request->server('SERVER_NAME'); |
125 | - } |
|
126 | - else if($obj->request->server('SERVER_ADDR')){ |
|
123 | + } else if($obj->request->server('SERVER_ADDR')){ |
|
127 | 124 | $domain = $obj->request->server('SERVER_ADDR'); |
128 | 125 | } |
129 | 126 | if($port && (is_https() && $port != 443 || !is_https() && $port != 80)){ |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | - */ |
|
25 | + */ |
|
26 | 26 | class Session{ |
27 | 27 | |
28 | 28 | /** |
@@ -90,8 +90,7 @@ discard block |
||
90 | 90 | ($_SESSION[$key]) : $default; |
91 | 91 | if(array_key_exists($key, $_SESSION)){ |
92 | 92 | unset($_SESSION[$key]); |
93 | - } |
|
94 | - else{ |
|
93 | + } else{ |
|
95 | 94 | $logger->warning('Cannot find session flash item ['. $key .'] using the default value ['. $default .']'); |
96 | 95 | } |
97 | 96 | return $return; |
@@ -126,8 +125,7 @@ discard block |
||
126 | 125 | if(array_key_exists($item, $_SESSION)){ |
127 | 126 | $logger->info('Deleting of session for item ['.$item.' ]'); |
128 | 127 | unset($_SESSION[$item]); |
129 | - } |
|
130 | - else{ |
|
128 | + } else{ |
|
131 | 129 | $logger->warning('Session item ['.$item.'] to be deleted does not exists'); |
132 | 130 | } |
133 | 131 | } |
@@ -142,8 +140,7 @@ discard block |
||
142 | 140 | if(array_key_exists($key, $_SESSION)){ |
143 | 141 | $logger->info('Delete session flash for item ['.$item.']'); |
144 | 142 | unset($_SESSION[$item]); |
145 | - } |
|
146 | - else{ |
|
143 | + } else{ |
|
147 | 144 | $logger->warning('Dession flash item ['.$item.'] to be deleted does not exists'); |
148 | 145 | } |
149 | 146 | } |
@@ -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 Session{ |
|
26 | + class Session { |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * The session flash key to use |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | * Get the logger singleton instance |
42 | 42 | * @return Log the logger instance |
43 | 43 | */ |
44 | - private static function getLogger(){ |
|
45 | - if(self::$logger == null){ |
|
46 | - self::$logger[0] =& class_loader('Log', 'classes'); |
|
44 | + private static function getLogger() { |
|
45 | + if (self::$logger == null) { |
|
46 | + self::$logger[0] = & class_loader('Log', 'classes'); |
|
47 | 47 | self::$logger[0]->setLogger('Library::Session'); |
48 | 48 | } |
49 | 49 | return self::$logger[0]; |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | * @param mixed $default the default value to use if can not find the session item in the list |
56 | 56 | * @return mixed the session value if exist or the default value |
57 | 57 | */ |
58 | - public static function get($item, $default = null){ |
|
58 | + public static function get($item, $default = null) { |
|
59 | 59 | $logger = self::getLogger(); |
60 | - $logger->debug('Getting session data for item [' .$item. '] ...'); |
|
61 | - if(array_key_exists($item, $_SESSION)){ |
|
60 | + $logger->debug('Getting session data for item [' . $item . '] ...'); |
|
61 | + if (array_key_exists($item, $_SESSION)) { |
|
62 | 62 | $logger->info('Found session data for item [' . $item . '] the vaue is : [' . stringfy_vars($_SESSION[$item]) . ']'); |
63 | 63 | return $_SESSION[$item]; |
64 | 64 | } |
65 | - $logger->warning('Cannot find session item [' . $item . '] using the default value ['. $default . ']'); |
|
65 | + $logger->warning('Cannot find session item [' . $item . '] using the default value [' . $default . ']'); |
|
66 | 66 | return $default; |
67 | 67 | } |
68 | 68 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @param string $item the session item name to set |
72 | 72 | * @param mixed $value the session item value |
73 | 73 | */ |
74 | - public static function set($item, $value){ |
|
74 | + public static function set($item, $value) { |
|
75 | 75 | $logger = self::getLogger(); |
76 | 76 | $logger->debug('Setting session data for item [' . $item . '], value [' . stringfy_vars($value) . ']'); |
77 | 77 | $_SESSION[$item] = $value; |
@@ -83,16 +83,16 @@ discard block |
||
83 | 83 | * @param mixed $default the default value to use if can not find the session flash item in the list |
84 | 84 | * @return mixed the session flash value if exist or the default value |
85 | 85 | */ |
86 | - public static function getFlash($item, $default = null){ |
|
86 | + public static function getFlash($item, $default = null) { |
|
87 | 87 | $logger = self::getLogger(); |
88 | - $key = self::SESSION_FLASH_KEY.'_'.$item; |
|
88 | + $key = self::SESSION_FLASH_KEY . '_' . $item; |
|
89 | 89 | $return = array_key_exists($key, $_SESSION) ? |
90 | 90 | ($_SESSION[$key]) : $default; |
91 | - if(array_key_exists($key, $_SESSION)){ |
|
91 | + if (array_key_exists($key, $_SESSION)) { |
|
92 | 92 | unset($_SESSION[$key]); |
93 | 93 | } |
94 | - else{ |
|
95 | - $logger->warning('Cannot find session flash item ['. $key .'] using the default value ['. $default .']'); |
|
94 | + else { |
|
95 | + $logger->warning('Cannot find session flash item [' . $key . '] using the default value [' . $default . ']'); |
|
96 | 96 | } |
97 | 97 | return $return; |
98 | 98 | } |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | * @param string $item the session flash item name |
103 | 103 | * @return boolean |
104 | 104 | */ |
105 | - public static function hasFlash($item){ |
|
106 | - $key = self::SESSION_FLASH_KEY.'_'.$item; |
|
105 | + public static function hasFlash($item) { |
|
106 | + $key = self::SESSION_FLASH_KEY . '_' . $item; |
|
107 | 107 | return array_key_exists($key, $_SESSION); |
108 | 108 | } |
109 | 109 | |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | * @param string $item the session flash item name to set |
113 | 113 | * @param mixed $value the session flash item value |
114 | 114 | */ |
115 | - public static function setFlash($item, $value){ |
|
116 | - $key = self::SESSION_FLASH_KEY.'_'.$item; |
|
115 | + public static function setFlash($item, $value) { |
|
116 | + $key = self::SESSION_FLASH_KEY . '_' . $item; |
|
117 | 117 | $_SESSION[$key] = $value; |
118 | 118 | } |
119 | 119 | |
@@ -121,14 +121,14 @@ discard block |
||
121 | 121 | * Clear the session item in the list |
122 | 122 | * @param string $item the session item name to be deleted |
123 | 123 | */ |
124 | - public static function clear($item){ |
|
124 | + public static function clear($item) { |
|
125 | 125 | $logger = self::getLogger(); |
126 | - if(array_key_exists($item, $_SESSION)){ |
|
127 | - $logger->info('Deleting of session for item ['.$item.' ]'); |
|
126 | + if (array_key_exists($item, $_SESSION)) { |
|
127 | + $logger->info('Deleting of session for item [' . $item . ' ]'); |
|
128 | 128 | unset($_SESSION[$item]); |
129 | 129 | } |
130 | - else{ |
|
131 | - $logger->warning('Session item ['.$item.'] to be deleted does not exists'); |
|
130 | + else { |
|
131 | + $logger->warning('Session item [' . $item . '] to be deleted does not exists'); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | * Clear the session flash item in the list |
137 | 137 | * @param string $item the session flash item name to be deleted |
138 | 138 | */ |
139 | - public static function clearFlash($item){ |
|
139 | + public static function clearFlash($item) { |
|
140 | 140 | $logger = self::getLogger(); |
141 | - $key = self::SESSION_FLASH_KEY.'_'.$item; |
|
142 | - if(array_key_exists($key, $_SESSION)){ |
|
143 | - $logger->info('Delete session flash for item ['.$item.']'); |
|
141 | + $key = self::SESSION_FLASH_KEY . '_' . $item; |
|
142 | + if (array_key_exists($key, $_SESSION)) { |
|
143 | + $logger->info('Delete session flash for item [' . $item . ']'); |
|
144 | 144 | unset($_SESSION[$item]); |
145 | 145 | } |
146 | - else{ |
|
147 | - $logger->warning('Dession flash item ['.$item.'] to be deleted does not exists'); |
|
146 | + else { |
|
147 | + $logger->warning('Dession flash item [' . $item . '] to be deleted does not exists'); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
@@ -153,14 +153,14 @@ discard block |
||
153 | 153 | * @param string $item the session item name |
154 | 154 | * @return boolean |
155 | 155 | */ |
156 | - public static function exists($item){ |
|
156 | + public static function exists($item) { |
|
157 | 157 | return array_key_exists($item, $_SESSION); |
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
161 | 161 | * Destroy all session data values |
162 | 162 | */ |
163 | - public static function clearAll(){ |
|
163 | + public static function clearAll() { |
|
164 | 164 | session_unset(); |
165 | 165 | session_destroy(); |
166 | 166 | } |
@@ -82,8 +82,7 @@ discard block |
||
82 | 82 | if($cookieLang && $this->isValid($cookieLang)){ |
83 | 83 | $this->current = $cookieLang; |
84 | 84 | $this->logger->info('Language from cookie [' .$cfgKey. '] is valid so we will set the language using the cookie value [' .$cookieLang. ']'); |
85 | - } |
|
86 | - else{ |
|
85 | + } else{ |
|
87 | 86 | $this->logger->info('Language from cookie [' .$cfgKey. '] is not set, use the default value [' .$this->getDefault(). ']'); |
88 | 87 | $this->current = $this->getDefault(); |
89 | 88 | } |
@@ -171,8 +170,7 @@ discard block |
||
171 | 170 | } |
172 | 171 | if($this->isValid($name)){ |
173 | 172 | $this->availables[$name] = $description; |
174 | - } |
|
175 | - else{ |
|
173 | + } else{ |
|
176 | 174 | show_error('The language [' . $name . '] is not valid or does not exists.'); |
177 | 175 | } |
178 | 176 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | - */ |
|
25 | + */ |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * For application languages management |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * Construct new Lang instance |
69 | 69 | */ |
70 | 70 | public function __construct(){ |
71 | - $this->logger =& class_loader('Log', 'classes'); |
|
72 | - $this->logger->setLogger('Library::Lang'); |
|
71 | + $this->logger =& class_loader('Log', 'classes'); |
|
72 | + $this->logger->setLogger('Library::Lang'); |
|
73 | 73 | |
74 | 74 | $this->default = get_config('default_language', 'en'); |
75 | 75 | $this->logger->debug('Setting the supported languages'); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * For application languages management |
29 | 29 | */ |
30 | - class Lang{ |
|
30 | + class Lang { |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * The supported available language for this application. |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | /** |
68 | 68 | * Construct new Lang instance |
69 | 69 | */ |
70 | - public function __construct(){ |
|
71 | - $this->logger =& class_loader('Log', 'classes'); |
|
70 | + public function __construct() { |
|
71 | + $this->logger = & class_loader('Log', 'classes'); |
|
72 | 72 | $this->logger->setLogger('Library::Lang'); |
73 | 73 | |
74 | 74 | $this->default = get_config('default_language', 'en'); |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | |
77 | 77 | //add the supported languages ('key', 'display name') |
78 | 78 | $languages = get_config('languages', null); |
79 | - if(! empty($languages)){ |
|
80 | - foreach($languages as $key => $displayName){ |
|
79 | + if (!empty($languages)) { |
|
80 | + foreach ($languages as $key => $displayName) { |
|
81 | 81 | $this->addLang($key, $displayName); |
82 | 82 | } |
83 | 83 | } |
@@ -85,15 +85,15 @@ discard block |
||
85 | 85 | |
86 | 86 | //if the language exists in cookie use it |
87 | 87 | $cfgKey = get_config('language_cookie_name'); |
88 | - $this->logger->debug('Getting current language from cookie [' .$cfgKey. ']'); |
|
88 | + $this->logger->debug('Getting current language from cookie [' . $cfgKey . ']'); |
|
89 | 89 | $objCookie = & class_loader('Cookie'); |
90 | 90 | $cookieLang = $objCookie->get($cfgKey); |
91 | - if($cookieLang && $this->isValid($cookieLang)){ |
|
91 | + if ($cookieLang && $this->isValid($cookieLang)) { |
|
92 | 92 | $this->current = $cookieLang; |
93 | - $this->logger->info('Language from cookie [' .$cfgKey. '] is valid so we will set the language using the cookie value [' .$cookieLang. ']'); |
|
93 | + $this->logger->info('Language from cookie [' . $cfgKey . '] is valid so we will set the language using the cookie value [' . $cookieLang . ']'); |
|
94 | 94 | } |
95 | - else{ |
|
96 | - $this->logger->info('Language from cookie [' .$cfgKey. '] is not set, use the default value [' .$this->getDefault(). ']'); |
|
95 | + else { |
|
96 | + $this->logger->info('Language from cookie [' . $cfgKey . '] is not set, use the default value [' . $this->getDefault() . ']'); |
|
97 | 97 | $this->current = $this->getDefault(); |
98 | 98 | } |
99 | 99 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @return array the language message list |
105 | 105 | */ |
106 | - public function getAll(){ |
|
106 | + public function getAll() { |
|
107 | 107 | return $this->languages; |
108 | 108 | } |
109 | 109 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param string $key the language key to identify |
114 | 114 | * @param string $value the language message value |
115 | 115 | */ |
116 | - public function set($key, $value){ |
|
116 | + public function set($key, $value) { |
|
117 | 117 | $this->languages[$key] = $value; |
118 | 118 | } |
119 | 119 | |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @return string the language message value |
127 | 127 | */ |
128 | - public function get($key, $default = 'LANGUAGE_ERROR'){ |
|
129 | - if(isset($this->languages[$key])){ |
|
128 | + public function get($key, $default = 'LANGUAGE_ERROR') { |
|
129 | + if (isset($this->languages[$key])) { |
|
130 | 130 | return $this->languages[$key]; |
131 | 131 | } |
132 | - $this->logger->warning('Language key [' .$key. '] does not exist use the default value [' .$default. ']'); |
|
132 | + $this->logger->warning('Language key [' . $key . '] does not exist use the default value [' . $default . ']'); |
|
133 | 133 | return $default; |
134 | 134 | } |
135 | 135 | |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return boolean true if the language directory exists, false or not |
142 | 142 | */ |
143 | - public function isValid($language){ |
|
143 | + public function isValid($language) { |
|
144 | 144 | $searchDir = array(CORE_LANG_PATH, APP_LANG_PATH); |
145 | - foreach($searchDir as $dir){ |
|
146 | - if(file_exists($dir . $language) && is_dir($dir . $language)){ |
|
145 | + foreach ($searchDir as $dir) { |
|
146 | + if (file_exists($dir . $language) && is_dir($dir . $language)) { |
|
147 | 147 | return true; |
148 | 148 | } |
149 | 149 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @return string the default language |
157 | 157 | */ |
158 | - public function getDefault(){ |
|
158 | + public function getDefault() { |
|
159 | 159 | return $this->default; |
160 | 160 | } |
161 | 161 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @return string the current language |
166 | 166 | */ |
167 | - public function getCurrent(){ |
|
167 | + public function getCurrent() { |
|
168 | 168 | return $this->current; |
169 | 169 | } |
170 | 170 | |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | * @param string $name the short language name like "en", "fr". |
175 | 175 | * @param string $description the human readable description of this language |
176 | 176 | */ |
177 | - public function addLang($name, $description){ |
|
178 | - if(isset($this->availables[$name])){ |
|
177 | + public function addLang($name, $description) { |
|
178 | + if (isset($this->availables[$name])) { |
|
179 | 179 | return; //already added cost in performance |
180 | 180 | } |
181 | - if($this->isValid($name)){ |
|
181 | + if ($this->isValid($name)) { |
|
182 | 182 | $this->availables[$name] = $description; |
183 | 183 | } |
184 | - else{ |
|
184 | + else { |
|
185 | 185 | show_error('The language [' . $name . '] is not valid or does not exists.'); |
186 | 186 | } |
187 | 187 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @return array the list of the application language |
193 | 193 | */ |
194 | - public function getSupported(){ |
|
194 | + public function getSupported() { |
|
195 | 195 | return $this->availables; |
196 | 196 | } |
197 | 197 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @param array $langs the languages array of the messages to be added |
202 | 202 | */ |
203 | - public function addLangMessages(array $langs){ |
|
203 | + public function addLangMessages(array $langs) { |
|
204 | 204 | foreach ($langs as $key => $value) { |
205 | 205 | $this->set($key, $value); |
206 | 206 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | - */ |
|
25 | + */ |
|
26 | 26 | |
27 | 27 | class Security{ |
28 | 28 |
@@ -60,8 +60,7 @@ discard block |
||
60 | 60 | if(Session::exists($key) && Session::exists($keyExpire) && Session::get($keyExpire) > $currentTime){ |
61 | 61 | $logger->info('The CSRF token not yet expire just return it'); |
62 | 62 | return Session::get($key); |
63 | - } |
|
64 | - else{ |
|
63 | + } else{ |
|
65 | 64 | $newTime = $currentTime + $expire; |
66 | 65 | $token = sha1(uniqid()) . sha1(uniqid()); |
67 | 66 | $logger->info('The CSRF informations are listed below: key [' .$key. '], key expire [' .$keyExpire. '], expire time [' .$expire. '], token [' .$token. ']'); |
@@ -87,8 +86,7 @@ discard block |
||
87 | 86 | if(! Session::exists($key) || Session::get($keyExpire) <= $currentTime){ |
88 | 87 | $logger->warning('The CSRF session data is not valide'); |
89 | 88 | return false; |
90 | - } |
|
91 | - else{ |
|
89 | + } else{ |
|
92 | 90 | //perform form data |
93 | 91 | //need use request->query() for best retrieve |
94 | 92 | //super instance |
@@ -97,8 +95,7 @@ discard block |
||
97 | 95 | if(! $token || $token !== Session::get($key) || Session::get($keyExpire) <= $currentTime){ |
98 | 96 | $logger->warning('The CSRF data [' .$token. '] is not valide may be attacker do his job'); |
99 | 97 | return false; |
100 | - } |
|
101 | - else{ |
|
98 | + } else{ |
|
102 | 99 | $logger->info('The CSRF data [' .$token. '] is valide the form data is safe continue'); |
103 | 100 | //remove the token from session |
104 | 101 | Session::clear($key); |
@@ -127,8 +124,7 @@ discard block |
||
127 | 124 | $logger->info('IP address ' . $ip . ' allowed using the wildcard "*" or the full IP'); |
128 | 125 | //wildcard to access all ip address |
129 | 126 | return; |
130 | - } |
|
131 | - else{ |
|
127 | + } else{ |
|
132 | 128 | // go through all whitelisted ips |
133 | 129 | foreach ($list as $ipaddr) { |
134 | 130 | // find the wild card * in whitelisted ip (f.e. find position in "127.0.*" or "127*") |
@@ -153,8 +149,7 @@ discard block |
||
153 | 149 | show_error('Access to this application is not allowed'); |
154 | 150 | } |
155 | 151 | } |
156 | - } |
|
157 | - else{ |
|
152 | + } else{ |
|
158 | 153 | $logger->info('Whitelist IP access is not enabled in the configuration, ignore checking'); |
159 | 154 | } |
160 | 155 | } |
@@ -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 Security{ |
|
27 | + class Security { |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * The logger instance |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | * Get the logger singleton instance |
37 | 37 | * @return Log the logger instance |
38 | 38 | */ |
39 | - private static function getLogger(){ |
|
40 | - if(self::$logger == null){ |
|
41 | - self::$logger[0] =& class_loader('Log', 'classes'); |
|
39 | + private static function getLogger() { |
|
40 | + if (self::$logger == null) { |
|
41 | + self::$logger[0] = & class_loader('Log', 'classes'); |
|
42 | 42 | self::$logger[0]->setLogger('Library::Security'); |
43 | 43 | } |
44 | 44 | return self::$logger[0]; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * This method is used to generate the CSRF token |
50 | 50 | * @return string the generated CSRF token |
51 | 51 | */ |
52 | - public static function generateCSRF(){ |
|
52 | + public static function generateCSRF() { |
|
53 | 53 | $logger = self::getLogger(); |
54 | 54 | $logger->debug('Generation of CSRF ...'); |
55 | 55 | |
@@ -57,14 +57,14 @@ discard block |
||
57 | 57 | $expire = get_config('csrf_expire', 60); |
58 | 58 | $keyExpire = 'csrf_expire'; |
59 | 59 | $currentTime = time(); |
60 | - if(Session::exists($key) && Session::exists($keyExpire) && Session::get($keyExpire) > $currentTime){ |
|
60 | + if (Session::exists($key) && Session::exists($keyExpire) && Session::get($keyExpire) > $currentTime) { |
|
61 | 61 | $logger->info('The CSRF token not yet expire just return it'); |
62 | 62 | return Session::get($key); |
63 | 63 | } |
64 | - else{ |
|
64 | + else { |
|
65 | 65 | $newTime = $currentTime + $expire; |
66 | 66 | $token = sha1(uniqid()) . sha1(uniqid()); |
67 | - $logger->info('The CSRF informations are listed below: key [' .$key. '], key expire [' .$keyExpire. '], expire time [' .$expire. '], token [' .$token. ']'); |
|
67 | + $logger->info('The CSRF informations are listed below: key [' . $key . '], key expire [' . $keyExpire . '], expire time [' . $expire . '], token [' . $token . ']'); |
|
68 | 68 | Session::set($keyExpire, $newTime); |
69 | 69 | Session::set($key, $token); |
70 | 70 | return Session::get($key); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * This method is used to check the CSRF if is valid, not yet expire, etc. |
76 | 76 | * @return boolean true if valid, false if not valid |
77 | 77 | */ |
78 | - public static function validateCSRF(){ |
|
78 | + public static function validateCSRF() { |
|
79 | 79 | $logger = self::getLogger(); |
80 | 80 | $logger->debug('Validation of CSRF ...'); |
81 | 81 | |
@@ -83,23 +83,23 @@ discard block |
||
83 | 83 | $expire = get_config('csrf_expire', 60); |
84 | 84 | $keyExpire = 'csrf_expire'; |
85 | 85 | $currentTime = time(); |
86 | - $logger->info('The CSRF informations are listed below: key [' .$key. '], key expire [' .$keyExpire. '], expire time [' .$expire. ']'); |
|
87 | - if(! Session::exists($key) || Session::get($keyExpire) <= $currentTime){ |
|
86 | + $logger->info('The CSRF informations are listed below: key [' . $key . '], key expire [' . $keyExpire . '], expire time [' . $expire . ']'); |
|
87 | + if (!Session::exists($key) || Session::get($keyExpire) <= $currentTime) { |
|
88 | 88 | $logger->warning('The CSRF session data is not valide'); |
89 | 89 | return false; |
90 | 90 | } |
91 | - else{ |
|
91 | + else { |
|
92 | 92 | //perform form data |
93 | 93 | //need use request->query() for best retrieve |
94 | 94 | //super instance |
95 | 95 | $obj = & get_instance(); |
96 | 96 | $token = $obj->request->query($key); |
97 | - if(! $token || $token !== Session::get($key) || Session::get($keyExpire) <= $currentTime){ |
|
98 | - $logger->warning('The CSRF data [' .$token. '] is not valide may be attacker do his job'); |
|
97 | + if (!$token || $token !== Session::get($key) || Session::get($keyExpire) <= $currentTime) { |
|
98 | + $logger->warning('The CSRF data [' . $token . '] is not valide may be attacker do his job'); |
|
99 | 99 | return false; |
100 | 100 | } |
101 | - else{ |
|
102 | - $logger->info('The CSRF data [' .$token. '] is valide the form data is safe continue'); |
|
101 | + else { |
|
102 | + $logger->info('The CSRF data [' . $token . '] is valide the form data is safe continue'); |
|
103 | 103 | //remove the token from session |
104 | 104 | Session::clear($key); |
105 | 105 | Session::clear($keyExpire); |
@@ -111,24 +111,24 @@ discard block |
||
111 | 111 | /** |
112 | 112 | * This method is used to check the whitelist IP address access |
113 | 113 | */ |
114 | - public static function checkWhiteListIpAccess(){ |
|
114 | + public static function checkWhiteListIpAccess() { |
|
115 | 115 | $logger = self::getLogger(); |
116 | 116 | $logger->debug('Validation of the IP address access ...'); |
117 | 117 | $logger->debug('Check if whitelist IP access is enabled in the configuration ...'); |
118 | 118 | $isEnable = get_config('white_list_ip_enable', false); |
119 | - if($isEnable){ |
|
119 | + if ($isEnable) { |
|
120 | 120 | $logger->info('Whitelist IP access is enabled in the configuration'); |
121 | 121 | $list = get_config('white_list_ip_addresses', array()); |
122 | - if(! empty($list)){ |
|
122 | + if (!empty($list)) { |
|
123 | 123 | //Can't use Loader::functions() at this time because teh "Loader" library is loader after the security prossessing |
124 | 124 | require_once CORE_FUNCTIONS_PATH . 'function_user_agent.php'; |
125 | 125 | $ip = get_ip(); |
126 | - if((count($list) == 1 && $list[0] == '*') || in_array($ip, $list)){ |
|
126 | + if ((count($list) == 1 && $list[0] == '*') || in_array($ip, $list)) { |
|
127 | 127 | $logger->info('IP address ' . $ip . ' allowed using the wildcard "*" or the full IP'); |
128 | 128 | //wildcard to access all ip address |
129 | 129 | return; |
130 | 130 | } |
131 | - else{ |
|
131 | + else { |
|
132 | 132 | // go through all whitelisted ips |
133 | 133 | foreach ($list as $ipaddr) { |
134 | 134 | // find the wild card * in whitelisted ip (f.e. find position in "127.0.*" or "127*") |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | } |
155 | 155 | } |
156 | 156 | } |
157 | - else{ |
|
157 | + else { |
|
158 | 158 | $logger->info('Whitelist IP access is not enabled in the configuration, ignore checking'); |
159 | 159 | } |
160 | 160 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | - */ |
|
25 | + */ |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * This class represent the event dispatcher management, permit to record the listener and |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * also to dispatch the event |
30 | 30 | */ |
31 | 31 | |
32 | - class EventDispatcher{ |
|
32 | + class EventDispatcher { |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * The list of the registered listeners |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | */ |
45 | 45 | private $logger; |
46 | 46 | |
47 | - public function __construct(){ |
|
48 | - $this->logger =& class_loader('Log', 'classes'); |
|
47 | + public function __construct() { |
|
48 | + $this->logger = & class_loader('Log', 'classes'); |
|
49 | 49 | $this->logger->setLogger('Library::EventDispatcher'); |
50 | 50 | } |
51 | 51 | |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | * @param string $eventName the name of the event to register for |
55 | 55 | * @param callable $listener the function or class method to receive the event information after dispatch |
56 | 56 | */ |
57 | - public function addListener($eventName, callable $listener){ |
|
58 | - $this->logger->debug('Adding new event listener for the event name [' .$eventName. '], listener [' .stringfy_vars($listener). ']'); |
|
59 | - if(! isset($this->listeners[$eventName])){ |
|
57 | + public function addListener($eventName, callable $listener) { |
|
58 | + $this->logger->debug('Adding new event listener for the event name [' . $eventName . '], listener [' . stringfy_vars($listener) . ']'); |
|
59 | + if (!isset($this->listeners[$eventName])) { |
|
60 | 60 | $this->logger->info('This event does not have the registered event listener before, adding new one'); |
61 | 61 | $this->listeners[$eventName] = array(); |
62 | 62 | } |
63 | - else{ |
|
63 | + else { |
|
64 | 64 | $this->logger->info('This event already have the registered listener, add this listener to the list'); |
65 | 65 | } |
66 | 66 | $this->listeners[$eventName][] = $listener; |
@@ -71,19 +71,19 @@ discard block |
||
71 | 71 | * @param string $eventName the event name |
72 | 72 | * @param callable $listener the listener callback |
73 | 73 | */ |
74 | - public function removeListener($eventName, callable $listener){ |
|
75 | - $this->logger->debug('Removing of the event listener, the event name [' .$eventName. '], listener [' .stringfy_vars($listener). ']'); |
|
76 | - if(isset($this->listeners[$eventName])){ |
|
74 | + public function removeListener($eventName, callable $listener) { |
|
75 | + $this->logger->debug('Removing of the event listener, the event name [' . $eventName . '], listener [' . stringfy_vars($listener) . ']'); |
|
76 | + if (isset($this->listeners[$eventName])) { |
|
77 | 77 | $this->logger->info('This event have the listeners, check if this listener exists'); |
78 | - if(false !== $index = array_search($listener, $this->listeners[$eventName], true)){ |
|
79 | - $this->logger->info('Found the listener at index [' .$index. '] remove it'); |
|
78 | + if (false !== $index = array_search($listener, $this->listeners[$eventName], true)) { |
|
79 | + $this->logger->info('Found the listener at index [' . $index . '] remove it'); |
|
80 | 80 | unset($this->listeners[$eventName][$index]); |
81 | 81 | } |
82 | - else{ |
|
82 | + else { |
|
83 | 83 | $this->logger->info('Cannot found this listener in the event listener list'); |
84 | 84 | } |
85 | 85 | } |
86 | - else{ |
|
86 | + else { |
|
87 | 87 | $this->logger->info('This event does not have this listener ignore remove'); |
88 | 88 | } |
89 | 89 | } |
@@ -93,13 +93,13 @@ discard block |
||
93 | 93 | * remove all listeners for this event |
94 | 94 | * @param string $eventName the event name |
95 | 95 | */ |
96 | - public function removeAllListener($eventName = null){ |
|
97 | - $this->logger->debug('Removing of all event listener, the event name [' .$eventName. ']'); |
|
98 | - if($eventName !== null && isset($this->listeners[$eventName])){ |
|
96 | + public function removeAllListener($eventName = null) { |
|
97 | + $this->logger->debug('Removing of all event listener, the event name [' . $eventName . ']'); |
|
98 | + if ($eventName !== null && isset($this->listeners[$eventName])) { |
|
99 | 99 | $this->logger->info('The event name is set of exist in the listener just remove all event listener for this event'); |
100 | 100 | unset($this->listeners[$eventName]); |
101 | 101 | } |
102 | - else{ |
|
102 | + else { |
|
103 | 103 | $this->logger->info('The event name is not set or does not exist in the listener, so remove all event listener'); |
104 | 104 | $this->listeners = array(); |
105 | 105 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @param string $eventName the event name |
111 | 111 | * @return array the listeners for this event or empty array if this event does not contain any listener |
112 | 112 | */ |
113 | - public function getListeners($eventName){ |
|
113 | + public function getListeners($eventName) { |
|
114 | 114 | return isset($this->listeners[$eventName]) ? $this->listeners[$eventName] : array(); |
115 | 115 | } |
116 | 116 | |
@@ -119,21 +119,21 @@ discard block |
||
119 | 119 | * @param mixed|object $event the event information |
120 | 120 | * @return void|object if event need return, will return the final EventInfo object. |
121 | 121 | */ |
122 | - public function dispatch($event){ |
|
123 | - if(! $event || !$event instanceof EventInfo){ |
|
122 | + public function dispatch($event) { |
|
123 | + if (!$event || !$event instanceof EventInfo) { |
|
124 | 124 | $this->logger->info('The event is not set or is not an instance of "EventInfo" create the default "EventInfo" object to use instead of.'); |
125 | 125 | $event = new EventInfo((string) $event); |
126 | 126 | } |
127 | - $this->logger->debug('Dispatch to the event listener, the event [' .stringfy_vars($event). ']'); |
|
128 | - if(isset($event->stop) && $event->stop){ |
|
127 | + $this->logger->debug('Dispatch to the event listener, the event [' . stringfy_vars($event) . ']'); |
|
128 | + if (isset($event->stop) && $event->stop) { |
|
129 | 129 | $this->logger->info('This event need stopped, no need call any listener'); |
130 | 130 | return; |
131 | 131 | } |
132 | - if($event->returnBack){ |
|
132 | + if ($event->returnBack) { |
|
133 | 133 | $this->logger->info('This event need return back, return the result for future use'); |
134 | 134 | return $this->dispatchToListerners($event); |
135 | 135 | } |
136 | - else{ |
|
136 | + else { |
|
137 | 137 | $this->logger->info('This event no need return back the result, just dispatch it'); |
138 | 138 | $this->dispatchToListerners($event); |
139 | 139 | } |
@@ -144,38 +144,38 @@ discard block |
||
144 | 144 | * @param object EventInfo $event the event information |
145 | 145 | * @return void|object if event need return, will return the final EventInfo instance. |
146 | 146 | */ |
147 | - private function dispatchToListerners(EventInfo $event){ |
|
147 | + private function dispatchToListerners(EventInfo $event) { |
|
148 | 148 | $eBackup = $event; |
149 | 149 | $list = $this->getListeners($event->name); |
150 | - if(empty($list)){ |
|
151 | - $this->logger->info('No event listener is registered for the event [' .$event->name. '] skipping.'); |
|
152 | - if($event->returnBack){ |
|
150 | + if (empty($list)) { |
|
151 | + $this->logger->info('No event listener is registered for the event [' . $event->name . '] skipping.'); |
|
152 | + if ($event->returnBack) { |
|
153 | 153 | return $event; |
154 | 154 | } |
155 | 155 | return; |
156 | 156 | } |
157 | - else{ |
|
158 | - $this->logger->info('Found the registered event listener for the event [' .$event->name. '] the list are: ' . stringfy_vars($list)); |
|
157 | + else { |
|
158 | + $this->logger->info('Found the registered event listener for the event [' . $event->name . '] the list are: ' . stringfy_vars($list)); |
|
159 | 159 | } |
160 | - foreach($list as $listener){ |
|
161 | - if($eBackup->returnBack){ |
|
160 | + foreach ($list as $listener) { |
|
161 | + if ($eBackup->returnBack) { |
|
162 | 162 | $returnedEvent = call_user_func_array($listener, array($event)); |
163 | - if($returnedEvent instanceof EventInfo){ |
|
163 | + if ($returnedEvent instanceof EventInfo) { |
|
164 | 164 | $event = $returnedEvent; |
165 | 165 | } |
166 | - else{ |
|
167 | - show_error('This event [' .$event->name. '] need you return the event object after processing'); |
|
166 | + else { |
|
167 | + show_error('This event [' . $event->name . '] need you return the event object after processing'); |
|
168 | 168 | } |
169 | 169 | } |
170 | - else{ |
|
170 | + else { |
|
171 | 171 | call_user_func_array($listener, array($event)); |
172 | 172 | } |
173 | - if($event->stop){ |
|
173 | + if ($event->stop) { |
|
174 | 174 | break; |
175 | 175 | } |
176 | 176 | } |
177 | 177 | //only test for original event may be during the flow some listeners change this parameter |
178 | - if($eBackup->returnBack){ |
|
178 | + if ($eBackup->returnBack) { |
|
179 | 179 | return $event; |
180 | 180 | } |
181 | 181 | } |
@@ -59,8 +59,7 @@ discard block |
||
59 | 59 | if(! isset($this->listeners[$eventName])){ |
60 | 60 | $this->logger->info('This event does not have the registered event listener before, adding new one'); |
61 | 61 | $this->listeners[$eventName] = array(); |
62 | - } |
|
63 | - else{ |
|
62 | + } else{ |
|
64 | 63 | $this->logger->info('This event already have the registered listener, add this listener to the list'); |
65 | 64 | } |
66 | 65 | $this->listeners[$eventName][] = $listener; |
@@ -78,12 +77,10 @@ discard block |
||
78 | 77 | if(false !== $index = array_search($listener, $this->listeners[$eventName], true)){ |
79 | 78 | $this->logger->info('Found the listener at index [' .$index. '] remove it'); |
80 | 79 | unset($this->listeners[$eventName][$index]); |
81 | - } |
|
82 | - else{ |
|
80 | + } else{ |
|
83 | 81 | $this->logger->info('Cannot found this listener in the event listener list'); |
84 | 82 | } |
85 | - } |
|
86 | - else{ |
|
83 | + } else{ |
|
87 | 84 | $this->logger->info('This event does not have this listener ignore remove'); |
88 | 85 | } |
89 | 86 | } |
@@ -98,8 +95,7 @@ discard block |
||
98 | 95 | if($eventName !== null && isset($this->listeners[$eventName])){ |
99 | 96 | $this->logger->info('The event name is set of exist in the listener just remove all event listener for this event'); |
100 | 97 | unset($this->listeners[$eventName]); |
101 | - } |
|
102 | - else{ |
|
98 | + } else{ |
|
103 | 99 | $this->logger->info('The event name is not set or does not exist in the listener, so remove all event listener'); |
104 | 100 | $this->listeners = array(); |
105 | 101 | } |
@@ -132,8 +128,7 @@ discard block |
||
132 | 128 | if($event->returnBack){ |
133 | 129 | $this->logger->info('This event need return back, return the result for future use'); |
134 | 130 | return $this->dispatchToListerners($event); |
135 | - } |
|
136 | - else{ |
|
131 | + } else{ |
|
137 | 132 | $this->logger->info('This event no need return back the result, just dispatch it'); |
138 | 133 | $this->dispatchToListerners($event); |
139 | 134 | } |
@@ -153,8 +148,7 @@ discard block |
||
153 | 148 | return $event; |
154 | 149 | } |
155 | 150 | return; |
156 | - } |
|
157 | - else{ |
|
151 | + } else{ |
|
158 | 152 | $this->logger->info('Found the registered event listener for the event [' .$event->name. '] the list are: ' . stringfy_vars($list)); |
159 | 153 | } |
160 | 154 | foreach($list as $listener){ |
@@ -162,12 +156,10 @@ discard block |
||
162 | 156 | $returnedEvent = call_user_func_array($listener, array($event)); |
163 | 157 | if($returnedEvent instanceof EventInfo){ |
164 | 158 | $event = $returnedEvent; |
165 | - } |
|
166 | - else{ |
|
159 | + } else{ |
|
167 | 160 | show_error('This event [' .$event->name. '] need you return the event object after processing'); |
168 | 161 | } |
169 | - } |
|
170 | - else{ |
|
162 | + } else{ |
|
171 | 163 | call_user_func_array($listener, array($event)); |
172 | 164 | } |
173 | 165 | if($event->stop){ |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | - */ |
|
25 | + */ |
|
26 | 26 | class Loader{ |
27 | 27 | |
28 | 28 | /** |
@@ -148,8 +148,7 @@ discard block |
||
148 | 148 | if(isset($path[1])){ |
149 | 149 | $instance = strtolower($path[1]); |
150 | 150 | } |
151 | - } |
|
152 | - else{ |
|
151 | + } else{ |
|
153 | 152 | $instance = strtolower($class); |
154 | 153 | } |
155 | 154 | } |
@@ -169,8 +168,7 @@ discard block |
||
169 | 168 | $searchModuleName = $path[0]; |
170 | 169 | $class = ucfirst($path[1]); |
171 | 170 | } |
172 | - } |
|
173 | - else{ |
|
171 | + } else{ |
|
174 | 172 | $class = ucfirst($class); |
175 | 173 | } |
176 | 174 | |
@@ -181,8 +179,7 @@ discard block |
||
181 | 179 | if($moduleModelFilePath){ |
182 | 180 | $logger->info('Found model [' . $class . '] from module [' .$searchModuleName. '], the file path is [' .$moduleModelFilePath. '] we will used it'); |
183 | 181 | $classFilePath = $moduleModelFilePath; |
184 | - } |
|
185 | - else{ |
|
182 | + } else{ |
|
186 | 183 | $logger->info('Cannot find model [' . $class . '] from modules using the default location'); |
187 | 184 | } |
188 | 185 | $logger->info('The model file path to be loaded is [' . $classFilePath . ']'); |
@@ -194,12 +191,10 @@ discard block |
||
194 | 191 | $obj->{$instance} = $c; |
195 | 192 | static::$loaded[$instance] = $class; |
196 | 193 | $logger->info('Model [' . $class . '] --> ' . $classFilePath . ' loaded successfully.'); |
197 | - } |
|
198 | - else{ |
|
194 | + } else{ |
|
199 | 195 | show_error('The file '.$classFilePath.' exists but does not contain the class ['. $class . ']'); |
200 | 196 | } |
201 | - } |
|
202 | - else{ |
|
197 | + } else{ |
|
203 | 198 | show_error('Unable to find the model [' . $class . ']'); |
204 | 199 | } |
205 | 200 | } |
@@ -227,8 +222,7 @@ discard block |
||
227 | 222 | if(isset($path[1])){ |
228 | 223 | $instance = strtolower($path[1]); |
229 | 224 | } |
230 | - } |
|
231 | - else{ |
|
225 | + } else{ |
|
232 | 226 | $instance = strtolower($class); |
233 | 227 | } |
234 | 228 | } |
@@ -252,8 +246,7 @@ discard block |
||
252 | 246 | $libraryFilePath = CORE_LIBRARY_PATH . $file; |
253 | 247 | $class = ucfirst($class); |
254 | 248 | $logger->info('This library is a system library'); |
255 | - } |
|
256 | - else{ |
|
249 | + } else{ |
|
257 | 250 | $logger->info('This library is not a system library'); |
258 | 251 | //first check if this library is in the module |
259 | 252 | $logger->debug('Checking library [' . $class . '] from module list ...'); |
@@ -265,8 +258,7 @@ discard block |
||
265 | 258 | $searchModuleName = $path[0]; |
266 | 259 | $class = ucfirst($path[1]); |
267 | 260 | } |
268 | - } |
|
269 | - else{ |
|
261 | + } else{ |
|
270 | 262 | $class = ucfirst($class); |
271 | 263 | } |
272 | 264 | if(! $searchModuleName && !empty($obj->moduleName)){ |
@@ -276,8 +268,7 @@ discard block |
||
276 | 268 | if($moduleLibraryPath){ |
277 | 269 | $logger->info('Found library [' . $class . '] from module [' .$searchModuleName. '], the file path is [' .$moduleLibraryPath. '] we will used it'); |
278 | 270 | $libraryFilePath = $moduleLibraryPath; |
279 | - } |
|
280 | - else{ |
|
271 | + } else{ |
|
281 | 272 | $logger->info('Cannot find library [' . $class . '] from modules using the default location'); |
282 | 273 | } |
283 | 274 | } |
@@ -301,12 +292,10 @@ discard block |
||
301 | 292 | $obj->{$instance} = $c; |
302 | 293 | static::$loaded[$instance] = $class; |
303 | 294 | $logger->info('Library [' . $class . '] --> ' . $libraryFilePath . ' loaded successfully.'); |
304 | - } |
|
305 | - else{ |
|
295 | + } else{ |
|
306 | 296 | show_error('The file '.$libraryFilePath.' exists but does not contain the class '.$class); |
307 | 297 | } |
308 | - } |
|
309 | - else{ |
|
298 | + } else{ |
|
310 | 299 | show_error('Unable to find library class [' . $class . ']'); |
311 | 300 | } |
312 | 301 | } |
@@ -350,8 +339,7 @@ discard block |
||
350 | 339 | if($moduleFunctionPath){ |
351 | 340 | $logger->info('Found helper [' . $function . '] from module [' .$searchModuleName. '], the file path is [' .$moduleFunctionPath. '] we will used it'); |
352 | 341 | $functionFilePath = $moduleFunctionPath; |
353 | - } |
|
354 | - else{ |
|
342 | + } else{ |
|
355 | 343 | $logger->info('Cannot find helper [' . $function . '] from modules using the default location'); |
356 | 344 | } |
357 | 345 | if(! $functionFilePath){ |
@@ -370,8 +358,7 @@ discard block |
||
370 | 358 | require_once $functionFilePath; |
371 | 359 | static::$loaded['function_' . $function] = $functionFilePath; |
372 | 360 | $logger->info('Helper [' . $function . '] --> ' . $functionFilePath . ' loaded successfully.'); |
373 | - } |
|
374 | - else{ |
|
361 | + } else{ |
|
375 | 362 | show_error('Unable to find helper file [' . $file . ']'); |
376 | 363 | } |
377 | 364 | } |
@@ -414,8 +401,7 @@ discard block |
||
414 | 401 | if($moduleConfigPath){ |
415 | 402 | $logger->info('Found config [' . $filename . '] from module [' .$searchModuleName. '], the file path is [' .$moduleConfigPath. '] we will used it'); |
416 | 403 | $configFilePath = $moduleConfigPath; |
417 | - } |
|
418 | - else{ |
|
404 | + } else{ |
|
419 | 405 | $logger->info('Cannot find config [' . $filename . '] from modules using the default location'); |
420 | 406 | } |
421 | 407 | $logger->info('The config file path to be loaded is [' . $configFilePath . ']'); |
@@ -424,8 +410,7 @@ discard block |
||
424 | 410 | if(! empty($config) && is_array($config)){ |
425 | 411 | Config::setAll($config); |
426 | 412 | } |
427 | - } |
|
428 | - else{ |
|
413 | + } else{ |
|
429 | 414 | show_error('Unable to find config file ['. $configFilePath . ']'); |
430 | 415 | } |
431 | 416 | static::$loaded['config_' . $filename] = $configFilePath; |
@@ -483,8 +468,7 @@ discard block |
||
483 | 468 | if($moduleLanguagePath){ |
484 | 469 | $logger->info('Found language [' . $language . '] from module [' .$searchModuleName. '], the file path is [' .$moduleLanguagePath. '] we will used it'); |
485 | 470 | $languageFilePath = $moduleLanguagePath; |
486 | - } |
|
487 | - else{ |
|
471 | + } else{ |
|
488 | 472 | $logger->info('Cannot find language [' . $language . '] from modules using the default location'); |
489 | 473 | } |
490 | 474 | if(! $languageFilePath){ |
@@ -511,8 +495,7 @@ discard block |
||
511 | 495 | } |
512 | 496 | static::$loaded['lang_' . $language] = $languageFilePath; |
513 | 497 | $logger->info('Language [' . $language . '] --> ' . $languageFilePath . ' loaded successfully.'); |
514 | - } |
|
515 | - else{ |
|
498 | + } else{ |
|
516 | 499 | show_error('Unable to find language file [' . $file . ']'); |
517 | 500 | } |
518 | 501 | } |
@@ -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', $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 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | - */ |
|
25 | + */ |
|
26 | 26 | |
27 | 27 | class Request{ |
28 | 28 |
@@ -103,8 +103,7 @@ |
||
103 | 103 | $this->header = array(); |
104 | 104 | if(function_exists('apache_request_headers')){ |
105 | 105 | $this->header = apache_request_headers(); |
106 | - } |
|
107 | - else if(function_exists('getallheaders')){ |
|
106 | + } else if(function_exists('getallheaders')){ |
|
108 | 107 | $this->header = getallheaders(); |
109 | 108 | } |
110 | 109 | } |
@@ -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 Request{ |
|
27 | + class Request { |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * The value for the super global $_GET |
@@ -90,21 +90,21 @@ discard block |
||
90 | 90 | /** |
91 | 91 | * Construct new request instance |
92 | 92 | */ |
93 | - public function __construct(){ |
|
93 | + public function __construct() { |
|
94 | 94 | $this->get = $_GET; |
95 | 95 | $this->post = $_POST; |
96 | 96 | $this->server = $_SERVER; |
97 | 97 | $this->query = $_REQUEST; |
98 | 98 | $this->cookie = $_COOKIE; |
99 | 99 | $this->file = $_FILES; |
100 | - $this->session =& class_loader('Session', 'classes'); |
|
100 | + $this->session = & class_loader('Session', 'classes'); |
|
101 | 101 | $this->method = $this->server('REQUEST_METHOD'); |
102 | 102 | $this->requestUri = $this->server('REQUEST_URI'); |
103 | 103 | $this->header = array(); |
104 | - if(function_exists('apache_request_headers')){ |
|
104 | + if (function_exists('apache_request_headers')) { |
|
105 | 105 | $this->header = apache_request_headers(); |
106 | 106 | } |
107 | - else if(function_exists('getallheaders')){ |
|
107 | + else if (function_exists('getallheaders')) { |
|
108 | 108 | $this->header = getallheaders(); |
109 | 109 | } |
110 | 110 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * Get the request method |
114 | 114 | * @return string |
115 | 115 | */ |
116 | - public function method(){ |
|
116 | + public function method() { |
|
117 | 117 | return $this->method; |
118 | 118 | } |
119 | 119 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * Get the request URI |
122 | 122 | * @return string |
123 | 123 | */ |
124 | - public function requestUri(){ |
|
124 | + public function requestUri() { |
|
125 | 125 | return $this->requestUri; |
126 | 126 | } |
127 | 127 | |
@@ -131,13 +131,13 @@ discard block |
||
131 | 131 | * @param boolean $xss if need apply some XSS attack rule on the value |
132 | 132 | * @return array|mixed the item value if the key exists or all array if the key does not exists or is empty |
133 | 133 | */ |
134 | - public function query($key = null, $xss = true){ |
|
135 | - if(empty($key)){ |
|
134 | + public function query($key = null, $xss = true) { |
|
135 | + if (empty($key)) { |
|
136 | 136 | //return all |
137 | 137 | return $xss ? clean_input($this->query) : $this->query; |
138 | 138 | } |
139 | 139 | $query = array_key_exists($key, $this->query) ? $this->query[$key] : null; |
140 | - if($xss){ |
|
140 | + if ($xss) { |
|
141 | 141 | $query = clean_input($query); |
142 | 142 | } |
143 | 143 | return $query; |
@@ -149,13 +149,13 @@ discard block |
||
149 | 149 | * @param boolean $xss if need apply some XSS attack rule on the value |
150 | 150 | * @return array|mixed the item value if the key exists or all array if the key does not exists or is empty |
151 | 151 | */ |
152 | - public function get($key = null, $xss = true){ |
|
153 | - if(empty($key)){ |
|
152 | + public function get($key = null, $xss = true) { |
|
153 | + if (empty($key)) { |
|
154 | 154 | //return all |
155 | 155 | return $xss ? clean_input($this->get) : $this->get; |
156 | 156 | } |
157 | 157 | $get = array_key_exists($key, $this->get) ? $this->get[$key] : null; |
158 | - if($xss){ |
|
158 | + if ($xss) { |
|
159 | 159 | $get = clean_input($get); |
160 | 160 | } |
161 | 161 | return $get; |
@@ -167,13 +167,13 @@ discard block |
||
167 | 167 | * @param boolean $xss if need apply some XSS attack rule on the value |
168 | 168 | * @return array|mixed the item value if the key exists or all array if the key does not exists or is empty |
169 | 169 | */ |
170 | - public function post($key = null, $xss = true){ |
|
171 | - if(empty($key)){ |
|
170 | + public function post($key = null, $xss = true) { |
|
171 | + if (empty($key)) { |
|
172 | 172 | //return all |
173 | 173 | return $xss ? clean_input($this->post) : $this->post; |
174 | 174 | } |
175 | 175 | $post = array_key_exists($key, $this->post) ? $this->post[$key] : null; |
176 | - if($xss){ |
|
176 | + if ($xss) { |
|
177 | 177 | $post = clean_input($post); |
178 | 178 | } |
179 | 179 | return $post; |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | * @param boolean $xss if need apply some XSS attack rule on the value |
186 | 186 | * @return array|mixed the item value if the key exists or all array if the key does not exists or is empty |
187 | 187 | */ |
188 | - public function server($key = null, $xss = true){ |
|
189 | - if(empty($key)){ |
|
188 | + public function server($key = null, $xss = true) { |
|
189 | + if (empty($key)) { |
|
190 | 190 | //return all |
191 | 191 | return $xss ? clean_input($this->server) : $this->server; |
192 | 192 | } |
193 | 193 | $server = array_key_exists($key, $this->server) ? $this->server[$key] : null; |
194 | - if($xss){ |
|
194 | + if ($xss) { |
|
195 | 195 | $server = clean_input($server); |
196 | 196 | } |
197 | 197 | return $server; |
@@ -203,13 +203,13 @@ discard block |
||
203 | 203 | * @param boolean $xss if need apply some XSS attack rule on the value |
204 | 204 | * @return array|mixed the item value if the key exists or all array if the key does not exists or is empty |
205 | 205 | */ |
206 | - public function cookie($key = null, $xss = true){ |
|
207 | - if(empty($key)){ |
|
206 | + public function cookie($key = null, $xss = true) { |
|
207 | + if (empty($key)) { |
|
208 | 208 | //return all |
209 | 209 | return $xss ? clean_input($this->cookie) : $this->cookie; |
210 | 210 | } |
211 | 211 | $cookie = array_key_exists($key, $this->cookie) ? $this->cookie[$key] : null; |
212 | - if($xss){ |
|
212 | + if ($xss) { |
|
213 | 213 | $cookie = clean_input($cookie); |
214 | 214 | } |
215 | 215 | return $cookie; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @param string $key the item key to be fetched |
221 | 221 | * @return array|mixed the item value if the key exists or all array if the key does not exists or is empty |
222 | 222 | */ |
223 | - public function file($key){ |
|
223 | + public function file($key) { |
|
224 | 224 | $file = array_key_exists($key, $this->file) ? $this->file[$key] : null; |
225 | 225 | return $file; |
226 | 226 | } |
@@ -231,9 +231,9 @@ discard block |
||
231 | 231 | * @param boolean $xss if need apply some XSS attack rule on the value |
232 | 232 | * @return array|mixed the item value if the key exists or null if the key does not exists |
233 | 233 | */ |
234 | - public function session($key, $xss = true){ |
|
234 | + public function session($key, $xss = true) { |
|
235 | 235 | $session = $this->session->get($key); |
236 | - if($xss){ |
|
236 | + if ($xss) { |
|
237 | 237 | $session = clean_input($session); |
238 | 238 | } |
239 | 239 | return $session; |
@@ -245,9 +245,9 @@ discard block |
||
245 | 245 | * @param boolean $xss if need apply some XSS attack rule on the value |
246 | 246 | * @return mixed the item value if the key exists or null if the key does not exists |
247 | 247 | */ |
248 | - public function header($key, $xss = true){ |
|
248 | + public function header($key, $xss = true) { |
|
249 | 249 | $header = array_key_exists($key, $this->header) ? $this->header[$key] : null; |
250 | - if($xss){ |
|
250 | + if ($xss) { |
|
251 | 251 | $header = clean_input($header); |
252 | 252 | } |
253 | 253 | return $header; |
@@ -1,28 +1,28 @@ |
||
1 | 1 | <?php |
2 | 2 | defined('ROOT_PATH') || exit('Access denied'); |
3 | 3 | /** |
4 | - * TNH Framework |
|
5 | - * |
|
6 | - * A simple PHP framework using HMVC architecture |
|
7 | - * |
|
8 | - * This content is released under the GNU GPL License (GPL) |
|
9 | - * |
|
10 | - * Copyright (C) 2017 Tony NGUEREZA |
|
11 | - * |
|
12 | - * This program is free software; you can redistribute it and/or |
|
13 | - * modify it under the terms of the GNU General Public License |
|
14 | - * as published by the Free Software Foundation; either version 3 |
|
15 | - * of the License, or (at your option) any later version. |
|
16 | - * |
|
17 | - * This program is distributed in the hope that it will be useful, |
|
18 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 | - * GNU General Public License for more details. |
|
21 | - * |
|
22 | - * You should have received a copy of the GNU General Public License |
|
23 | - * along with this program; if not, write to the Free Software |
|
24 | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
25 | - */ |
|
4 | + * TNH Framework |
|
5 | + * |
|
6 | + * A simple PHP framework using HMVC architecture |
|
7 | + * |
|
8 | + * This content is released under the GNU GPL License (GPL) |
|
9 | + * |
|
10 | + * Copyright (C) 2017 Tony NGUEREZA |
|
11 | + * |
|
12 | + * This program is free software; you can redistribute it and/or |
|
13 | + * modify it under the terms of the GNU General Public License |
|
14 | + * as published by the Free Software Foundation; either version 3 |
|
15 | + * of the License, or (at your option) any later version. |
|
16 | + * |
|
17 | + * This program is distributed in the hope that it will be useful, |
|
18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 | + * GNU General Public License for more details. |
|
21 | + * |
|
22 | + * You should have received a copy of the GNU General Public License |
|
23 | + * along with this program; if not, write to the Free Software |
|
24 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
25 | + */ |
|
26 | 26 | |
27 | 27 | class Module{ |
28 | 28 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | 25 | */ |
26 | 26 | |
27 | - class Module{ |
|
27 | + class Module { |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * list of loaded module |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | * The signleton of the logger |
43 | 43 | * @return Object the Log instance |
44 | 44 | */ |
45 | - private static function getLogger(){ |
|
46 | - if(self::$logger == null){ |
|
47 | - self::$logger[0] =& class_loader('Log', 'classes'); |
|
45 | + private static function getLogger() { |
|
46 | + if (self::$logger == null) { |
|
47 | + self::$logger[0] = & class_loader('Log', 'classes'); |
|
48 | 48 | self::$logger[0]->setLogger('Library::Module'); |
49 | 49 | } |
50 | 50 | return self::$logger[0]; |
@@ -53,24 +53,24 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * Initialise the module list by scanning the directory MODULE_PATH |
55 | 55 | */ |
56 | - public function init(){ |
|
56 | + public function init() { |
|
57 | 57 | $logger = self::getLogger(); |
58 | 58 | $logger->debug('Check if the application contains the modules ...'); |
59 | 59 | $moduleDir = opendir(MODULE_PATH); |
60 | - if(is_resource($moduleDir)){ |
|
61 | - while(($module = readdir($moduleDir)) !== false){ |
|
62 | - if(preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)){ |
|
60 | + if (is_resource($moduleDir)) { |
|
61 | + while (($module = readdir($moduleDir)) !== false) { |
|
62 | + if (preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)) { |
|
63 | 63 | self::$list[] = $module; |
64 | 64 | } |
65 | - else{ |
|
66 | - $logger->info('Skipping [' .$module. '], may be this is not a directory or does not exists or is invalid name'); |
|
65 | + else { |
|
66 | + $logger->info('Skipping [' . $module . '], may be this is not a directory or does not exists or is invalid name'); |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | closedir($moduleDir); |
70 | 70 | } |
71 | 71 | ksort(self::$list); |
72 | 72 | |
73 | - if(self::hasModule()){ |
|
73 | + if (self::hasModule()) { |
|
74 | 74 | $logger->info('The application contains the module below [' . implode(', ', self::getModuleList()) . ']'); |
75 | 75 | } |
76 | 76 | } |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * Get the list of the custom autoload configuration from module if exists |
80 | 80 | * @return array|boolean the autoload configurations list or false if no module contains the autoload configuration values |
81 | 81 | */ |
82 | - public static function getModulesAutoloadConfig(){ |
|
82 | + public static function getModulesAutoloadConfig() { |
|
83 | 83 | $logger = self::getLogger(); |
84 | - if(! self::hasModule()){ |
|
84 | + if (!self::hasModule()) { |
|
85 | 85 | $logger->info('No module was loaded skipping.'); |
86 | 86 | return false; |
87 | 87 | } |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | |
95 | 95 | foreach (self::$list as $module) { |
96 | 96 | $file = MODULE_PATH . $module . DS . 'config' . DS . 'autoload.php'; |
97 | - if(file_exists($file)){ |
|
97 | + if (file_exists($file)) { |
|
98 | 98 | $autoload = array(); |
99 | 99 | require_once $file; |
100 | - if(! empty($autoload) && is_array($autoload)){ |
|
100 | + if (!empty($autoload) && is_array($autoload)) { |
|
101 | 101 | $autoloads = array_merge_recursive($autoloads, $autoload); |
102 | 102 | unset($autoload); |
103 | 103 | } |
@@ -110,19 +110,19 @@ discard block |
||
110 | 110 | * Get the list of the custom routes configuration from module if exists |
111 | 111 | * @return array|boolean the routes list or false if no module contains the routes configuration |
112 | 112 | */ |
113 | - public static function getModulesRoutes(){ |
|
113 | + public static function getModulesRoutes() { |
|
114 | 114 | $logger = self::getLogger(); |
115 | - if(! self::hasModule()){ |
|
115 | + if (!self::hasModule()) { |
|
116 | 116 | $logger->info('No module was loaded skipping.'); |
117 | 117 | return false; |
118 | 118 | } |
119 | 119 | $routes = array(); |
120 | 120 | foreach (self::$list as $module) { |
121 | 121 | $file = MODULE_PATH . $module . DS . 'config' . DS . 'routes.php'; |
122 | - if(file_exists($file)){ |
|
122 | + if (file_exists($file)) { |
|
123 | 123 | $route = array(); |
124 | 124 | require_once $file; |
125 | - if(! empty($route) && is_array($route)){ |
|
125 | + if (!empty($route) && is_array($route)) { |
|
126 | 126 | $routes = array_merge($routes, $route); |
127 | 127 | unset($route); |
128 | 128 | } |
@@ -138,23 +138,23 @@ discard block |
||
138 | 138 | * @param string $module the module name |
139 | 139 | * @return boolean|string false or null if no module have this controller, path the full path of the controller |
140 | 140 | */ |
141 | - public static function findControllerFullPath($class, $module = null){ |
|
141 | + public static function findControllerFullPath($class, $module = null) { |
|
142 | 142 | $logger = self::getLogger(); |
143 | - if(! self::hasModule()){ |
|
143 | + if (!self::hasModule()) { |
|
144 | 144 | $logger->info('No module was loaded skiping.'); |
145 | 145 | return false; |
146 | 146 | } |
147 | 147 | $class = str_ireplace('.php', '', $class); |
148 | 148 | $class = ucfirst($class); |
149 | - $classFile = $class.'.php'; |
|
150 | - $logger->debug('Checking the controller [' . $class . '] in module [' .$module. '] ...'); |
|
149 | + $classFile = $class . '.php'; |
|
150 | + $logger->debug('Checking the controller [' . $class . '] in module [' . $module . '] ...'); |
|
151 | 151 | $filePath = MODULE_PATH . $module . DS . 'controllers' . DS . $classFile; |
152 | - if(file_exists($filePath)){ |
|
153 | - $logger->info('Found controller [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
152 | + if (file_exists($filePath)) { |
|
153 | + $logger->info('Found controller [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']'); |
|
154 | 154 | return $filePath; |
155 | 155 | } |
156 | - else{ |
|
157 | - $logger->info('Controller [' . $class . '] does not exist in the module [' .$module. ']'); |
|
156 | + else { |
|
157 | + $logger->info('Controller [' . $class . '] does not exist in the module [' . $module . ']'); |
|
158 | 158 | return false; |
159 | 159 | } |
160 | 160 | } |
@@ -165,23 +165,23 @@ discard block |
||
165 | 165 | * @param string $module the module name |
166 | 166 | * @return boolean|string false or null if no module have this model, return the full path of this model |
167 | 167 | */ |
168 | - public static function findModelFullPath($class, $module = null){ |
|
168 | + public static function findModelFullPath($class, $module = null) { |
|
169 | 169 | $logger = self::getLogger(); |
170 | - if(! self::hasModule()){ |
|
170 | + if (!self::hasModule()) { |
|
171 | 171 | $logger->info('No module was loaded skiping.'); |
172 | 172 | return false; |
173 | 173 | } |
174 | 174 | $class = str_ireplace('.php', '', $class); |
175 | 175 | $class = ucfirst($class); |
176 | - $classFile = $class.'.php'; |
|
177 | - $logger->debug('Checking model [' . $class . '] in module [' .$module. '] ...'); |
|
176 | + $classFile = $class . '.php'; |
|
177 | + $logger->debug('Checking model [' . $class . '] in module [' . $module . '] ...'); |
|
178 | 178 | $filePath = MODULE_PATH . $module . DS . 'models' . DS . $classFile; |
179 | - if(file_exists($filePath)){ |
|
180 | - $logger->info('Found model [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
179 | + if (file_exists($filePath)) { |
|
180 | + $logger->info('Found model [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']'); |
|
181 | 181 | return $filePath; |
182 | 182 | } |
183 | - else{ |
|
184 | - $logger->info('Model [' . $class . '] does not exist in the module [' .$module. ']'); |
|
183 | + else { |
|
184 | + $logger->info('Model [' . $class . '] does not exist in the module [' . $module . ']'); |
|
185 | 185 | return false; |
186 | 186 | } |
187 | 187 | } |
@@ -192,22 +192,22 @@ discard block |
||
192 | 192 | * @param string $module the module name |
193 | 193 | * @return boolean|string false or null if no module have this configuration, return the full path of this configuration |
194 | 194 | */ |
195 | - public static function findConfigFullPath($configuration, $module = null){ |
|
195 | + public static function findConfigFullPath($configuration, $module = null) { |
|
196 | 196 | $logger = self::getLogger(); |
197 | - if(! self::hasModule()){ |
|
197 | + if (!self::hasModule()) { |
|
198 | 198 | $logger->info('No module was loaded skiping.'); |
199 | 199 | return false; |
200 | 200 | } |
201 | 201 | $configuration = str_ireplace('.php', '', $configuration); |
202 | - $file = $configuration.'.php'; |
|
203 | - $logger->debug('Checking configuration [' . $configuration . '] in module [' .$module. '] ...'); |
|
202 | + $file = $configuration . '.php'; |
|
203 | + $logger->debug('Checking configuration [' . $configuration . '] in module [' . $module . '] ...'); |
|
204 | 204 | $filePath = MODULE_PATH . $module . DS . 'config' . DS . $file; |
205 | - if(file_exists($filePath)){ |
|
206 | - $logger->info('Found configuration [' . $configuration . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
205 | + if (file_exists($filePath)) { |
|
206 | + $logger->info('Found configuration [' . $configuration . '] in module [' . $module . '], the file path is [' . $filePath . ']'); |
|
207 | 207 | return $filePath; |
208 | 208 | } |
209 | - else{ |
|
210 | - $logger->info('Configuration [' . $configuration . '] does not exist in the module [' .$module. ']'); |
|
209 | + else { |
|
210 | + $logger->info('Configuration [' . $configuration . '] does not exist in the module [' . $module . ']'); |
|
211 | 211 | return false; |
212 | 212 | } |
213 | 213 | } |
@@ -218,23 +218,23 @@ discard block |
||
218 | 218 | * @param string $module the module name |
219 | 219 | * @return boolean|string false or null if no module have this helper, return the full path of this helper |
220 | 220 | */ |
221 | - public static function findFunctionFullPath($helper, $module = null){ |
|
221 | + public static function findFunctionFullPath($helper, $module = null) { |
|
222 | 222 | $logger = self::getLogger(); |
223 | - if(! self::hasModule()){ |
|
223 | + if (!self::hasModule()) { |
|
224 | 224 | $logger->info('No module was loaded skiping.'); |
225 | 225 | return false; |
226 | 226 | } |
227 | 227 | $helper = str_ireplace('.php', '', $helper); |
228 | 228 | $helper = str_ireplace('function_', '', $helper); |
229 | - $file = 'function_'.$helper.'.php'; |
|
230 | - $logger->debug('Checking helper [' . $helper . '] in module [' .$module. '] ...'); |
|
229 | + $file = 'function_' . $helper . '.php'; |
|
230 | + $logger->debug('Checking helper [' . $helper . '] in module [' . $module . '] ...'); |
|
231 | 231 | $filePath = MODULE_PATH . $module . DS . 'functions' . DS . $file; |
232 | - if(file_exists($filePath)){ |
|
233 | - $logger->info('Found helper [' . $helper . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
232 | + if (file_exists($filePath)) { |
|
233 | + $logger->info('Found helper [' . $helper . '] in module [' . $module . '], the file path is [' . $filePath . ']'); |
|
234 | 234 | return $filePath; |
235 | 235 | } |
236 | - else{ |
|
237 | - $logger->info('Helper [' . $helper . '] does not exist in the module [' .$module. ']'); |
|
236 | + else { |
|
237 | + $logger->info('Helper [' . $helper . '] does not exist in the module [' . $module . ']'); |
|
238 | 238 | return false; |
239 | 239 | } |
240 | 240 | } |
@@ -246,22 +246,22 @@ discard block |
||
246 | 246 | * @param string $module the module name |
247 | 247 | * @return boolean|string false or null if no module have this library, return the full path of this library |
248 | 248 | */ |
249 | - public static function findLibraryFullPath($class, $module = null){ |
|
249 | + public static function findLibraryFullPath($class, $module = null) { |
|
250 | 250 | $logger = self::getLogger(); |
251 | - if(! self::hasModule()){ |
|
251 | + if (!self::hasModule()) { |
|
252 | 252 | $logger->info('No module was loaded skiping.'); |
253 | 253 | return false; |
254 | 254 | } |
255 | 255 | $class = str_ireplace('.php', '', $class); |
256 | - $file = $class.'.php'; |
|
257 | - $logger->debug('Checking library [' . $class . '] in module [' .$module. '] ...'); |
|
256 | + $file = $class . '.php'; |
|
257 | + $logger->debug('Checking library [' . $class . '] in module [' . $module . '] ...'); |
|
258 | 258 | $filePath = MODULE_PATH . $module . DS . 'libraries' . DS . $file; |
259 | - if(file_exists($filePath)){ |
|
260 | - $logger->info('Found library [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
259 | + if (file_exists($filePath)) { |
|
260 | + $logger->info('Found library [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']'); |
|
261 | 261 | return $filePath; |
262 | 262 | } |
263 | - else{ |
|
264 | - $logger->info('Library [' . $class . '] does not exist in the module [' .$module. ']'); |
|
263 | + else { |
|
264 | + $logger->info('Library [' . $class . '] does not exist in the module [' . $module . ']'); |
|
265 | 265 | return false; |
266 | 266 | } |
267 | 267 | } |
@@ -273,9 +273,9 @@ discard block |
||
273 | 273 | * @param string $module the module name to check |
274 | 274 | * @return boolean|string false or null if no module have this view, path the full path of the view |
275 | 275 | */ |
276 | - public static function findViewFullPath($view, $module = null){ |
|
276 | + public static function findViewFullPath($view, $module = null) { |
|
277 | 277 | $logger = self::getLogger(); |
278 | - if(! self::hasModule()){ |
|
278 | + if (!self::hasModule()) { |
|
279 | 279 | $logger->info('No module was loaded skiping.'); |
280 | 280 | return false; |
281 | 281 | } |
@@ -283,14 +283,14 @@ discard block |
||
283 | 283 | $view = trim($view, '/\\'); |
284 | 284 | $view = str_ireplace('/', DS, $view); |
285 | 285 | $viewFile = $view . '.php'; |
286 | - $logger->debug('Checking view [' . $view . '] in module [' .$module. '] ...'); |
|
286 | + $logger->debug('Checking view [' . $view . '] in module [' . $module . '] ...'); |
|
287 | 287 | $filePath = MODULE_PATH . $module . DS . 'views' . DS . $viewFile; |
288 | - if(file_exists($filePath)){ |
|
289 | - $logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
288 | + if (file_exists($filePath)) { |
|
289 | + $logger->info('Found view [' . $view . '] in module [' . $module . '], the file path is [' . $filePath . ']'); |
|
290 | 290 | return $filePath; |
291 | 291 | } |
292 | - else{ |
|
293 | - $logger->info('View [' . $view . '] does not exist in the module [' .$module. ']'); |
|
292 | + else { |
|
293 | + $logger->info('View [' . $view . '] does not exist in the module [' . $module . ']'); |
|
294 | 294 | return false; |
295 | 295 | } |
296 | 296 | } |
@@ -302,23 +302,23 @@ discard block |
||
302 | 302 | * @param string $appLang the application language like 'en', 'fr' |
303 | 303 | * @return boolean|string false or null if no module have this language, return the full path of this language |
304 | 304 | */ |
305 | - public static function findLanguageFullPath($language, $module = null, $appLang){ |
|
305 | + public static function findLanguageFullPath($language, $module = null, $appLang) { |
|
306 | 306 | $logger = self::getLogger(); |
307 | - if(! self::hasModule()){ |
|
307 | + if (!self::hasModule()) { |
|
308 | 308 | $logger->info('No module was loaded skiping.'); |
309 | 309 | return false; |
310 | 310 | } |
311 | 311 | $language = str_ireplace('.php', '', $language); |
312 | 312 | $language = str_ireplace('lang_', '', $language); |
313 | - $file = 'lang_'.$language.'.php'; |
|
314 | - $logger->debug('Checking language [' . $language . '] in module [' .$module. '] ...'); |
|
313 | + $file = 'lang_' . $language . '.php'; |
|
314 | + $logger->debug('Checking language [' . $language . '] in module [' . $module . '] ...'); |
|
315 | 315 | $filePath = MODULE_PATH . $module . DS . 'lang' . DS . $appLang . DS . $file; |
316 | - if(file_exists($filePath)){ |
|
317 | - $logger->info('Found language [' . $language . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
316 | + if (file_exists($filePath)) { |
|
317 | + $logger->info('Found language [' . $language . '] in module [' . $module . '], the file path is [' . $filePath . ']'); |
|
318 | 318 | return $filePath; |
319 | 319 | } |
320 | - else{ |
|
321 | - $logger->info('Language [' . $language . '] does not exist in the module [' .$module. ']'); |
|
320 | + else { |
|
321 | + $logger->info('Language [' . $language . '] does not exist in the module [' . $module . ']'); |
|
322 | 322 | return false; |
323 | 323 | } |
324 | 324 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * Get the list of module loaded |
328 | 328 | * @return array the module list |
329 | 329 | */ |
330 | - public static function getModuleList(){ |
|
330 | + public static function getModuleList() { |
|
331 | 331 | return self::$list; |
332 | 332 | } |
333 | 333 | |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | * Check if the application has an module |
336 | 336 | * @return boolean |
337 | 337 | */ |
338 | - public static function hasModule(){ |
|
338 | + public static function hasModule() { |
|
339 | 339 | return !empty(self::$list); |
340 | 340 | } |
341 | 341 |
@@ -61,8 +61,7 @@ discard block |
||
61 | 61 | while(($module = readdir($moduleDir)) !== false){ |
62 | 62 | if(preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)){ |
63 | 63 | self::$list[] = $module; |
64 | - } |
|
65 | - else{ |
|
64 | + } else{ |
|
66 | 65 | $logger->info('Skipping [' .$module. '], may be this is not a directory or does not exists or is invalid name'); |
67 | 66 | } |
68 | 67 | } |
@@ -152,8 +151,7 @@ discard block |
||
152 | 151 | if(file_exists($filePath)){ |
153 | 152 | $logger->info('Found controller [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
154 | 153 | return $filePath; |
155 | - } |
|
156 | - else{ |
|
154 | + } else{ |
|
157 | 155 | $logger->info('Controller [' . $class . '] does not exist in the module [' .$module. ']'); |
158 | 156 | return false; |
159 | 157 | } |
@@ -179,8 +177,7 @@ discard block |
||
179 | 177 | if(file_exists($filePath)){ |
180 | 178 | $logger->info('Found model [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
181 | 179 | return $filePath; |
182 | - } |
|
183 | - else{ |
|
180 | + } else{ |
|
184 | 181 | $logger->info('Model [' . $class . '] does not exist in the module [' .$module. ']'); |
185 | 182 | return false; |
186 | 183 | } |
@@ -205,8 +202,7 @@ discard block |
||
205 | 202 | if(file_exists($filePath)){ |
206 | 203 | $logger->info('Found configuration [' . $configuration . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
207 | 204 | return $filePath; |
208 | - } |
|
209 | - else{ |
|
205 | + } else{ |
|
210 | 206 | $logger->info('Configuration [' . $configuration . '] does not exist in the module [' .$module. ']'); |
211 | 207 | return false; |
212 | 208 | } |
@@ -232,8 +228,7 @@ discard block |
||
232 | 228 | if(file_exists($filePath)){ |
233 | 229 | $logger->info('Found helper [' . $helper . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
234 | 230 | return $filePath; |
235 | - } |
|
236 | - else{ |
|
231 | + } else{ |
|
237 | 232 | $logger->info('Helper [' . $helper . '] does not exist in the module [' .$module. ']'); |
238 | 233 | return false; |
239 | 234 | } |
@@ -259,8 +254,7 @@ discard block |
||
259 | 254 | if(file_exists($filePath)){ |
260 | 255 | $logger->info('Found library [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
261 | 256 | return $filePath; |
262 | - } |
|
263 | - else{ |
|
257 | + } else{ |
|
264 | 258 | $logger->info('Library [' . $class . '] does not exist in the module [' .$module. ']'); |
265 | 259 | return false; |
266 | 260 | } |
@@ -288,8 +282,7 @@ discard block |
||
288 | 282 | if(file_exists($filePath)){ |
289 | 283 | $logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
290 | 284 | return $filePath; |
291 | - } |
|
292 | - else{ |
|
285 | + } else{ |
|
293 | 286 | $logger->info('View [' . $view . '] does not exist in the module [' .$module. ']'); |
294 | 287 | return false; |
295 | 288 | } |
@@ -316,8 +309,7 @@ discard block |
||
316 | 309 | if(file_exists($filePath)){ |
317 | 310 | $logger->info('Found language [' . $language . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
318 | 311 | return $filePath; |
319 | - } |
|
320 | - else{ |
|
312 | + } else{ |
|
321 | 313 | $logger->info('Language [' . $language . '] does not exist in the module [' .$module. ']'); |
322 | 314 | return false; |
323 | 315 | } |