Passed
Branch 1.0.0-dev (958860)
by nguereza
06:24
created
core/classes/model/DBSessionHandlerModel.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
core/classes/Url.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
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{
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -25,15 +25,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -62,8 +62,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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)){
Please login to merge, or discard this patch.
core/classes/Session.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
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
 		/**
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -90,8 +90,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
core/classes/Lang.php 3 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -82,8 +82,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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');
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 			}
Please login to merge, or discard this patch.
core/classes/Security.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
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
 		
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -60,8 +60,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		 }
Please login to merge, or discard this patch.
core/classes/EventDispatcher.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
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 
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -59,8 +59,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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){
Please login to merge, or discard this patch.
core/classes/Loader.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
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
 		/**
Please login to merge, or discard this patch.
Braces   +17 added lines, -34 removed lines patch added patch discarded remove patch
@@ -148,8 +148,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
-			if(file_exists($configFilePath)){
354
+			if (file_exists($configFilePath)) {
355 355
 				$config = array();
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,23 +460,23 @@  discard block
 block discarded – undo
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;
477 477
 		}
478 478
 
479
-		private function loadResourcesFromAutoloadConfig(){
479
+		private function loadResourcesFromAutoloadConfig() {
480 480
 			$autoloads = array();
481 481
 			$autoloads['config']    = array();
482 482
 			$autoloads['languages'] = array();
@@ -488,28 +488,28 @@  discard block
 block discarded – undo
488 488
 
489 489
 			$autoloads = array_merge($autoloads, $list);
490 490
 			//config autoload
491
-			foreach($autoloads['config'] as $c){
491
+			foreach ($autoloads['config'] as $c) {
492 492
 				$this->config($c);
493 493
 			}
494 494
 			
495 495
 			//languages autoload
496
-			foreach($autoloads['languages'] as $language){
496
+			foreach ($autoloads['languages'] as $language) {
497 497
 				$this->lang($language);
498 498
 			}
499 499
 			
500 500
 			//libraries autoload
501
-			foreach($autoloads['libraries'] as $library){
501
+			foreach ($autoloads['libraries'] as $library) {
502 502
 				$this->library($library);
503 503
 			}
504 504
 
505 505
 			//models autoload
506
-			if(! empty($autoloads['models']) && is_array($autoloads['models'])){
507
-				foreach($autoloads['models'] as $model){
506
+			if (!empty($autoloads['models']) && is_array($autoloads['models'])) {
507
+				foreach ($autoloads['models'] as $model) {
508 508
 					$this->model($model);
509 509
 				}
510 510
 			}
511 511
 			
512
-			foreach($autoloads['functions'] as $function){
512
+			foreach ($autoloads['functions'] as $function) {
513 513
 				$this->functions($function);
514 514
 			}
515 515
 		}
Please login to merge, or discard this patch.
core/classes/Request.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
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
 		
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -103,8 +103,7 @@
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
core/classes/Module.php 3 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,28 +1,28 @@
 block discarded – undo
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
 		
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,27 +53,27 @@  discard block
 block discarded – undo
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
-			else{
76
+			else {
77 77
 				$logger->info('The application contains no module skipping');
78 78
 			}
79 79
 		}
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
 		 * Get the list of the custom autoload configuration from module if exists
83 83
 		 * @return array|boolean the autoload configurations list or false if no module contains the autoload configuration values
84 84
 		 */
85
-		public static function getModulesAutoloadConfig(){
85
+		public static function getModulesAutoloadConfig() {
86 86
 			$logger = self::getLogger();
87
-			if(! self::hasModule()){
87
+			if (!self::hasModule()) {
88 88
 				$logger->info('No module was loaded skipping.');
89 89
 				return false;
90 90
 			}
@@ -97,10 +97,10 @@  discard block
 block discarded – undo
97 97
 			
98 98
 			foreach (self::$list as $module) {
99 99
 				$file = MODULE_PATH . $module . DS . 'config' . DS . 'autoload.php';
100
-				if(file_exists($file)){
100
+				if (file_exists($file)) {
101 101
 					$autoload = array();
102 102
 					require_once $file;
103
-					if(! empty($autoload) && is_array($autoload)){
103
+					if (!empty($autoload) && is_array($autoload)) {
104 104
 						$autoloads = array_merge_recursive($autoloads, $autoload);
105 105
 						unset($autoload);
106 106
 					}
@@ -113,23 +113,23 @@  discard block
 block discarded – undo
113 113
 		 * Get the list of the custom routes configuration from module if exists
114 114
 		 * @return array|boolean the routes list or false if no module contains the routes configuration
115 115
 		 */
116
-		public static function getModulesRoutes(){
116
+		public static function getModulesRoutes() {
117 117
 			$logger = self::getLogger();
118
-			if(! self::hasModule()){
118
+			if (!self::hasModule()) {
119 119
 				$logger->info('No module was loaded skipping.');
120 120
 				return false;
121 121
 			}
122 122
 			$routes = array();
123 123
 			foreach (self::$list as $module) {
124 124
 				$file = MODULE_PATH . $module . DS . 'config' . DS . 'routes.php';
125
-				if(file_exists($file)){
125
+				if (file_exists($file)) {
126 126
 					require_once $file;
127
-					if(! empty($route) && is_array($route)){
127
+					if (!empty($route) && is_array($route)) {
128 128
 						$routes = array_merge($routes, $route);
129 129
 						unset($route);
130 130
 					}
131
-					else{
132
-						show_error('No routing configuration found in [' .$file. '] for module [' . $module . ']');
131
+					else {
132
+						show_error('No routing configuration found in [' . $file . '] for module [' . $module . ']');
133 133
 					}
134 134
 				}
135 135
 			}
@@ -143,23 +143,23 @@  discard block
 block discarded – undo
143 143
 		 * @param  string $module  the module name
144 144
 		 * @return boolean|string  false or null if no module have this controller, path the full path of the controller
145 145
 		 */
146
-		public static function findControllerFullPath($class, $module = null){
146
+		public static function findControllerFullPath($class, $module = null) {
147 147
 			$logger = self::getLogger();
148
-			if(! self::hasModule()){
148
+			if (!self::hasModule()) {
149 149
 				$logger->info('No module was loaded skiping.');
150 150
 				return false;
151 151
 			}
152 152
 			$class = str_ireplace('.php', '', $class);
153 153
 			$class = ucfirst($class);
154
-			$classFile = $class.'.php';
155
-			$logger->debug('Checking the controller [' . $class . '] in module [' .$module. '] ...');
154
+			$classFile = $class . '.php';
155
+			$logger->debug('Checking the controller [' . $class . '] in module [' . $module . '] ...');
156 156
 			$filePath = MODULE_PATH . $module . DS . 'controllers' . DS . $classFile;
157
-			if(file_exists($filePath)){
158
-				$logger->info('Found controller [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']');
157
+			if (file_exists($filePath)) {
158
+				$logger->info('Found controller [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']');
159 159
 				return $filePath;
160 160
 			}
161
-			else{
162
-				$logger->info('Controller [' . $class . '] does not exist in the module [' .$module. ']');
161
+			else {
162
+				$logger->info('Controller [' . $class . '] does not exist in the module [' . $module . ']');
163 163
 				return false;
164 164
 			}
165 165
 		}
@@ -170,23 +170,23 @@  discard block
 block discarded – undo
170 170
 		 * @param string $module the module name
171 171
 		 * @return boolean|string  false or null if no module have this model, return the full path of this model
172 172
 		 */
173
-		public static function findModelFullPath($class, $module = null){
173
+		public static function findModelFullPath($class, $module = null) {
174 174
 			$logger = self::getLogger();
175
-			if(! self::hasModule()){
175
+			if (!self::hasModule()) {
176 176
 				$logger->info('No module was loaded skiping.');
177 177
 				return false;
178 178
 			}
179 179
 			$class = str_ireplace('.php', '', $class);
180 180
 			$class = ucfirst($class);
181
-			$classFile = $class.'.php';
182
-			$logger->debug('Checking model [' . $class . '] in module [' .$module. '] ...');
181
+			$classFile = $class . '.php';
182
+			$logger->debug('Checking model [' . $class . '] in module [' . $module . '] ...');
183 183
 			$filePath = MODULE_PATH . $module . DS . 'models' . DS . $classFile;
184
-			if(file_exists($filePath)){
185
-				$logger->info('Found model [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']');
184
+			if (file_exists($filePath)) {
185
+				$logger->info('Found model [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']');
186 186
 				return $filePath;
187 187
 			}
188
-			else{
189
-				$logger->info('Model [' . $class . '] does not exist in the module [' .$module. ']');
188
+			else {
189
+				$logger->info('Model [' . $class . '] does not exist in the module [' . $module . ']');
190 190
 				return false;
191 191
 			}
192 192
 		}
@@ -197,22 +197,22 @@  discard block
 block discarded – undo
197 197
 		 * @param string $module the module name
198 198
 		 * @return boolean|string  false or null if no module have this configuration,  return the full path of this configuration
199 199
 		 */
200
-		public static function findConfigFullPath($configuration, $module = null){
200
+		public static function findConfigFullPath($configuration, $module = null) {
201 201
 			$logger = self::getLogger();
202
-			if(! self::hasModule()){
202
+			if (!self::hasModule()) {
203 203
 				$logger->info('No module was loaded skiping.');
204 204
 				return false;
205 205
 			}
206 206
 			$configuration = str_ireplace('.php', '', $configuration);
207
-			$file = $configuration.'.php';
208
-			$logger->debug('Checking configuration [' . $configuration . '] in module [' .$module. '] ...');
207
+			$file = $configuration . '.php';
208
+			$logger->debug('Checking configuration [' . $configuration . '] in module [' . $module . '] ...');
209 209
 			$filePath = MODULE_PATH . $module . DS . 'config' . DS . $file;
210
-			if(file_exists($filePath)){
211
-				$logger->info('Found configuration [' . $configuration . '] in module [' .$module. '], the file path is [' .$filePath. ']');
210
+			if (file_exists($filePath)) {
211
+				$logger->info('Found configuration [' . $configuration . '] in module [' . $module . '], the file path is [' . $filePath . ']');
212 212
 				return $filePath;
213 213
 			}
214
-			else{
215
-				$logger->info('Configuration [' . $configuration . '] does not exist in the module [' .$module. ']');
214
+			else {
215
+				$logger->info('Configuration [' . $configuration . '] does not exist in the module [' . $module . ']');
216 216
 				return false;
217 217
 			}
218 218
 		}
@@ -223,23 +223,23 @@  discard block
 block discarded – undo
223 223
 		 * @param string $module the module name
224 224
 		 * @return boolean|string  false or null if no module have this helper,  return the full path of this helper
225 225
 		 */
226
-		public static function findFunctionFullPath($helper, $module = null){
226
+		public static function findFunctionFullPath($helper, $module = null) {
227 227
 			$logger = self::getLogger();
228
-			if(! self::hasModule()){
228
+			if (!self::hasModule()) {
229 229
 				$logger->info('No module was loaded skiping.');
230 230
 				return false;
231 231
 			}
232 232
 			$helper = str_ireplace('.php', '', $helper);
233 233
 			$helper = str_ireplace('function_', '', $helper);
234
-			$file = 'function_'.$helper.'.php';
235
-			$logger->debug('Checking helper [' . $helper . '] in module [' .$module. '] ...');
234
+			$file = 'function_' . $helper . '.php';
235
+			$logger->debug('Checking helper [' . $helper . '] in module [' . $module . '] ...');
236 236
 			$filePath = MODULE_PATH . $module . DS . 'functions' . DS . $file;
237
-			if(file_exists($filePath)){
238
-				$logger->info('Found helper [' . $helper . '] in module [' .$module. '], the file path is [' .$filePath. ']');
237
+			if (file_exists($filePath)) {
238
+				$logger->info('Found helper [' . $helper . '] in module [' . $module . '], the file path is [' . $filePath . ']');
239 239
 				return $filePath;
240 240
 			}
241
-			else{
242
-				$logger->info('Helper [' . $helper . '] does not exist in the module [' .$module. ']');
241
+			else {
242
+				$logger->info('Helper [' . $helper . '] does not exist in the module [' . $module . ']');
243 243
 				return false;
244 244
 			}
245 245
 		}
@@ -251,22 +251,22 @@  discard block
 block discarded – undo
251 251
 		 * @param string $module the module name
252 252
 		 * @return boolean|string  false or null if no module have this library,  return the full path of this library
253 253
 		 */
254
-		public static function findLibraryFullPath($class, $module = null){
254
+		public static function findLibraryFullPath($class, $module = null) {
255 255
 			$logger = self::getLogger();
256
-			if(! self::hasModule()){
256
+			if (!self::hasModule()) {
257 257
 				$logger->info('No module was loaded skiping.');
258 258
 				return false;
259 259
 			}
260 260
 			$class = str_ireplace('.php', '', $class);
261
-			$file = $class.'.php';
262
-			$logger->debug('Checking library [' . $class . '] in module [' .$module. '] ...');
261
+			$file = $class . '.php';
262
+			$logger->debug('Checking library [' . $class . '] in module [' . $module . '] ...');
263 263
 			$filePath = MODULE_PATH . $module . DS . 'libraries' . DS . $file;
264
-			if(file_exists($filePath)){
265
-				$logger->info('Found library [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']');
264
+			if (file_exists($filePath)) {
265
+				$logger->info('Found library [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']');
266 266
 				return $filePath;
267 267
 			}
268
-			else{
269
-				$logger->info('Library [' . $class . '] does not exist in the module [' .$module. ']');
268
+			else {
269
+				$logger->info('Library [' . $class . '] does not exist in the module [' . $module . ']');
270 270
 				return false;
271 271
 			}
272 272
 		}
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
 		 * @param string $module the module name to check
279 279
 		 * @return boolean|string  false or null if no module have this view, path the full path of the view
280 280
 		 */
281
-		public static function findViewFullPath($view, $module = null){
281
+		public static function findViewFullPath($view, $module = null) {
282 282
 			$logger = self::getLogger();
283
-			if(! self::hasModule()){
283
+			if (!self::hasModule()) {
284 284
 				$logger->info('No module was loaded skiping.');
285 285
 				return false;
286 286
 			}
@@ -288,14 +288,14 @@  discard block
 block discarded – undo
288 288
 			$view = trim($view, '/\\');
289 289
 			$view = str_ireplace('/', DS, $view);
290 290
 			$viewFile = $view . '.php';
291
-			$logger->debug('Checking view [' . $view . '] in module [' .$module. '] ...');
291
+			$logger->debug('Checking view [' . $view . '] in module [' . $module . '] ...');
292 292
 			$filePath = MODULE_PATH . $module . DS . 'views' . DS . $viewFile;
293
-			if(file_exists($filePath)){
294
-				$logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$filePath. ']');
293
+			if (file_exists($filePath)) {
294
+				$logger->info('Found view [' . $view . '] in module [' . $module . '], the file path is [' . $filePath . ']');
295 295
 				return $filePath;
296 296
 			}
297
-			else{
298
-				$logger->info('View [' . $view . '] does not exist in the module [' .$module. ']');
297
+			else {
298
+				$logger->info('View [' . $view . '] does not exist in the module [' . $module . ']');
299 299
 				return false;
300 300
 			}
301 301
 		}
@@ -307,23 +307,23 @@  discard block
 block discarded – undo
307 307
 		 * @param string $appLang the application language like 'en', 'fr'
308 308
 		 * @return boolean|string  false or null if no module have this language,  return the full path of this language
309 309
 		 */
310
-		public static function findLanguageFullPath($language, $module = null, $appLang){
310
+		public static function findLanguageFullPath($language, $module = null, $appLang) {
311 311
 			$logger = self::getLogger();
312
-			if(! self::hasModule()){
312
+			if (!self::hasModule()) {
313 313
 				$logger->info('No module was loaded skiping.');
314 314
 				return false;
315 315
 			}
316 316
 			$language = str_ireplace('.php', '', $language);
317 317
 			$language = str_ireplace('lang_', '', $language);
318
-			$file = 'lang_'.$language.'.php';
319
-			$logger->debug('Checking language [' . $language . '] in module [' .$module. '] ...');
318
+			$file = 'lang_' . $language . '.php';
319
+			$logger->debug('Checking language [' . $language . '] in module [' . $module . '] ...');
320 320
 			$filePath = MODULE_PATH . $module . DS . 'lang' . DS . $appLang . DS . $file;
321
-			if(file_exists($filePath)){
322
-				$logger->info('Found language [' . $language . '] in module [' .$module. '], the file path is [' .$filePath. ']');
321
+			if (file_exists($filePath)) {
322
+				$logger->info('Found language [' . $language . '] in module [' . $module . '], the file path is [' . $filePath . ']');
323 323
 				return $filePath;
324 324
 			}
325
-			else{
326
-				$logger->info('Language [' . $language . '] does not exist in the module [' .$module. ']');
325
+			else {
326
+				$logger->info('Language [' . $language . '] does not exist in the module [' . $module . ']');
327 327
 				return false;
328 328
 			}
329 329
 		}
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 		 * Get the list of module loaded
333 333
 		 * @return array the module list
334 334
 		 */
335
-		public static function getModuleList(){
335
+		public static function getModuleList() {
336 336
 			return self::$list;
337 337
 		}
338 338
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 		 * Check if the application has an module
341 341
 		 * @return boolean
342 342
 		 */
343
-		public static function hasModule(){
343
+		public static function hasModule() {
344 344
 			return !empty(self::$list);
345 345
 		}
346 346
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -20 removed lines patch added patch discarded remove patch
@@ -61,8 +61,7 @@  discard block
 block discarded – undo
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
 				}
@@ -72,8 +71,7 @@  discard block
 block discarded – undo
72 71
 			
73 72
 			if(self::hasModule()){
74 73
 				$logger->info('The application contains the module below [' . implode(', ', self::getModuleList()) . ']');
75
-			}
76
-			else{
74
+			} else{
77 75
 				$logger->info('The application contains no module skipping');
78 76
 			}
79 77
 		}
@@ -127,8 +125,7 @@  discard block
 block discarded – undo
127 125
 					if(! empty($route) && is_array($route)){
128 126
 						$routes = array_merge($routes, $route);
129 127
 						unset($route);
130
-					}
131
-					else{
128
+					} else{
132 129
 						show_error('No routing configuration found in [' .$file. '] for module [' . $module . ']');
133 130
 					}
134 131
 				}
@@ -157,8 +154,7 @@  discard block
 block discarded – undo
157 154
 			if(file_exists($filePath)){
158 155
 				$logger->info('Found controller [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']');
159 156
 				return $filePath;
160
-			}
161
-			else{
157
+			} else{
162 158
 				$logger->info('Controller [' . $class . '] does not exist in the module [' .$module. ']');
163 159
 				return false;
164 160
 			}
@@ -184,8 +180,7 @@  discard block
 block discarded – undo
184 180
 			if(file_exists($filePath)){
185 181
 				$logger->info('Found model [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']');
186 182
 				return $filePath;
187
-			}
188
-			else{
183
+			} else{
189 184
 				$logger->info('Model [' . $class . '] does not exist in the module [' .$module. ']');
190 185
 				return false;
191 186
 			}
@@ -210,8 +205,7 @@  discard block
 block discarded – undo
210 205
 			if(file_exists($filePath)){
211 206
 				$logger->info('Found configuration [' . $configuration . '] in module [' .$module. '], the file path is [' .$filePath. ']');
212 207
 				return $filePath;
213
-			}
214
-			else{
208
+			} else{
215 209
 				$logger->info('Configuration [' . $configuration . '] does not exist in the module [' .$module. ']');
216 210
 				return false;
217 211
 			}
@@ -237,8 +231,7 @@  discard block
 block discarded – undo
237 231
 			if(file_exists($filePath)){
238 232
 				$logger->info('Found helper [' . $helper . '] in module [' .$module. '], the file path is [' .$filePath. ']');
239 233
 				return $filePath;
240
-			}
241
-			else{
234
+			} else{
242 235
 				$logger->info('Helper [' . $helper . '] does not exist in the module [' .$module. ']');
243 236
 				return false;
244 237
 			}
@@ -264,8 +257,7 @@  discard block
 block discarded – undo
264 257
 			if(file_exists($filePath)){
265 258
 				$logger->info('Found library [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']');
266 259
 				return $filePath;
267
-			}
268
-			else{
260
+			} else{
269 261
 				$logger->info('Library [' . $class . '] does not exist in the module [' .$module. ']');
270 262
 				return false;
271 263
 			}
@@ -293,8 +285,7 @@  discard block
 block discarded – undo
293 285
 			if(file_exists($filePath)){
294 286
 				$logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$filePath. ']');
295 287
 				return $filePath;
296
-			}
297
-			else{
288
+			} else{
298 289
 				$logger->info('View [' . $view . '] does not exist in the module [' .$module. ']');
299 290
 				return false;
300 291
 			}
@@ -321,8 +312,7 @@  discard block
 block discarded – undo
321 312
 			if(file_exists($filePath)){
322 313
 				$logger->info('Found language [' . $language . '] in module [' .$module. '], the file path is [' .$filePath. ']');
323 314
 				return $filePath;
324
-			}
325
-			else{
315
+			} else{
326 316
 				$logger->info('Language [' . $language . '] does not exist in the module [' .$module. ']');
327 317
 				return false;
328 318
 			}
Please login to merge, or discard this patch.