Passed
Branch 1.0.0-dev (c78053)
by nguereza
04:10 queued 15s
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/Router.php 3 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -22,23 +22,23 @@  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
 	class Router {
28 28
 		
29 29
 		/**
30
-		* @var array $pattern: The list of URIs to validate against
31
-		*/
30
+		 * @var array $pattern: The list of URIs to validate against
31
+		 */
32 32
 		private $pattern = array();
33 33
 
34 34
 		/**
35
-		* @var array $callback: The list of callback to call
36
-		*/
35
+		 * @var array $callback: The list of callback to call
36
+		 */
37 37
 		private $callback = array();
38 38
 
39 39
 		/**
40
-		* @var string $uriTrim: The char to remove from the URIs
41
-		*/
40
+		 * @var string $uriTrim: The char to remove from the URIs
41
+		 */
42 42
 		protected $uriTrim = '/\^$';
43 43
 
44 44
 		/**
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 		 */
95 95
 		public function __construct(){
96 96
 			$this->logger =& class_loader('Log', 'classes');
97
-	        $this->logger->setLogger('Library::Router');
98
-	        $routesPath = CONFIG_PATH . 'routes.php';
99
-	        $this->logger->debug('Loading of routes configuration file --> ' . $routesPath . ' ...');
97
+			$this->logger->setLogger('Library::Router');
98
+			$routesPath = CONFIG_PATH . 'routes.php';
99
+			$this->logger->debug('Loading of routes configuration file --> ' . $routesPath . ' ...');
100 100
 			if(file_exists($routesPath)){
101 101
 				 $this->logger->info('Found routes configuration file --> ' . $routesPath. ' now load it');
102 102
 				require_once $routesPath;
@@ -147,11 +147,11 @@  discard block
 block discarded – undo
147 147
 		}
148 148
 
149 149
 		/**
150
-		* Add the URI and callback to the list of URIs to validate
151
-		*
152
-		* @param string $uri the request URI
153
-		* @param object $callback the callback function
154
-		*/
150
+		 * Add the URI and callback to the list of URIs to validate
151
+		 *
152
+		 * @param string $uri the request URI
153
+		 * @param object $callback the callback function
154
+		 */
155 155
 		public function add($uri, $callback) {
156 156
 			$uri = trim($uri, $this->uriTrim);
157 157
 			if(in_array($uri, $this->pattern)){
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -92,36 +92,36 @@  discard block
 block discarded – undo
92 92
 		/**
93 93
 		 * Construct the new Router instance
94 94
 		 */
95
-		public function __construct(){
96
-			$this->logger =& class_loader('Log', 'classes');
95
+		public function __construct() {
96
+			$this->logger = & class_loader('Log', 'classes');
97 97
 	        $this->logger->setLogger('Library::Router');
98 98
 	        $routesPath = CONFIG_PATH . 'routes.php';
99 99
 	        $this->logger->debug('Loading of routes configuration file --> ' . $routesPath . ' ...');
100
-			if(file_exists($routesPath)){
101
-				 $this->logger->info('Found routes configuration file --> ' . $routesPath. ' now load it');
100
+			if (file_exists($routesPath)) {
101
+				 $this->logger->info('Found routes configuration file --> ' . $routesPath . ' now load it');
102 102
 				require_once $routesPath;
103
-				if(! empty($route) && is_array($route)){
103
+				if (!empty($route) && is_array($route)) {
104 104
 					$this->routes = $route;
105 105
 					unset($route);
106 106
 				}
107 107
 			}
108
-			else{
108
+			else {
109 109
 				show_error('Unable to find the routes configuration file [' . $routesPath . ']');
110 110
 			}
111 111
 			
112 112
 			//loading routes for module
113 113
 			$this->logger->debug('Loading of modules routes ... ');
114 114
 			$modulesRoutes = Module::getModulesRoutes();
115
-			if($modulesRoutes && is_array($modulesRoutes)){
115
+			if ($modulesRoutes && is_array($modulesRoutes)) {
116 116
 				$this->routes = array_merge($this->routes, $modulesRoutes);
117 117
 				$this->logger->info('Routes for all modules loaded successfully');
118 118
 			}
119
-			else{
119
+			else {
120 120
 				$this->logger->info('No routes found for all modules skipping.');
121 121
 			}
122 122
 			$this->logger->info('The routes configuration are listed below: ' . stringfy_vars($this->routes));
123 123
 
124
-			foreach($this->routes as $pattern => $callback){
124
+			foreach ($this->routes as $pattern => $callback) {
125 125
 				$this->add($pattern, $callback);
126 126
 			}
127 127
 			
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
 			$uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
130 130
 			$this->logger->debug('Check if URL suffix is enabled in the configuration');
131 131
 			//remove url suffix from the request URI
132
-			if($suffix = get_config('url_suffix')){
133
-				$this->logger->info('URL suffix is enabled in the configuration, the value is [' . $suffix . ']' );
132
+			if ($suffix = get_config('url_suffix')) {
133
+				$this->logger->info('URL suffix is enabled in the configuration, the value is [' . $suffix . ']');
134 134
 				$uri = str_ireplace($suffix, '', $uri);
135 135
 			}
136
-			else{
136
+			else {
137 137
 				$this->logger->info('URL suffix is not enabled in the configuration');
138 138
 			}
139
-			if(strpos($uri, '?') !== false){
139
+			if (strpos($uri, '?') !== false) {
140 140
 				$uri = substr($uri, 0, strpos($uri, '?'));
141 141
 			}
142 142
 			$uri = trim($uri, $this->uriTrim);
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 		*/
152 152
 		public function add($uri, $callback) {
153 153
 			$uri = trim($uri, $this->uriTrim);
154
-			if(in_array($uri, $this->pattern)){
154
+			if (in_array($uri, $this->pattern)) {
155 155
 				$this->logger->warning('The route [' . $uri . '] already added, may be adding again can have route conflict');
156 156
 			}
157 157
 			$this->pattern[] = $uri;
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 		 * Get the module name
163 163
 		 * @return string
164 164
 		 */
165
-		public function getModule(){
165
+		public function getModule() {
166 166
 			return $this->module;
167 167
 		}
168 168
 		
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		 * Get the controller name
171 171
 		 * @return string
172 172
 		 */
173
-		public function getController(){
173
+		public function getController() {
174 174
 			return $this->controller;
175 175
 		}
176 176
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 		 * Get the controller file path
179 179
 		 * @return string
180 180
 		 */
181
-		public function getControllerPath(){
181
+		public function getControllerPath() {
182 182
 			return $this->controllerPath;
183 183
 		}
184 184
 
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 		 * Get the controller method
187 187
 		 * @return string
188 188
 		 */
189
-		public function getMethod(){
189
+		public function getMethod() {
190 190
 			return $this->method;
191 191
 		}
192 192
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 		 * Get the request arguments
195 195
 		 * @return array
196 196
 		 */
197
-		public function getArgs(){
197
+		public function getArgs() {
198 198
 			return $this->args;
199 199
 		}
200 200
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 		 * Get the URL segments array
203 203
 		 * @return array
204 204
 		 */
205
-		public function getSegments(){
205
+		public function getSegments() {
206 206
 			return $this->segments;
207 207
 		}
208 208
 
@@ -211,27 +211,27 @@  discard block
 block discarded – undo
211 211
 		 * otherwise send 404 error.
212 212
 		 */
213 213
 		public function run() {
214
-			$benchmark =& class_loader('Benchmark');
214
+			$benchmark = & class_loader('Benchmark');
215 215
 			$benchmark->mark('ROUTING_PROCESS_START');
216 216
 			$this->logger->debug('Routing process start ...');
217 217
 			$segment = $this->segments;
218 218
 			$baseUrl = get_config('base_url');
219 219
 			//check if the app is not in DOCUMENT_ROOT
220
-			if(isset($segment[0]) && stripos($baseUrl, $segment[0]) != false){
220
+			if (isset($segment[0]) && stripos($baseUrl, $segment[0]) != false) {
221 221
 				array_shift($segment);
222 222
 				$this->segments = $segment;
223 223
 			}
224 224
 			$this->logger->debug('Check if the request URI contains the front controller');
225
-			if(isset($segment[0]) && $segment[0] == SELF){
225
+			if (isset($segment[0]) && $segment[0] == SELF) {
226 226
 				$this->logger->info('The request URI contains the front controller');
227 227
 				array_shift($segment);
228 228
 				$this->segments = $segment;
229 229
 			}
230
-			else{
230
+			else {
231 231
 				$this->logger->info('The request URI does not contain the front controller');
232 232
 			}
233 233
 			$uri = implode('/', $segment);
234
-			$this->logger->info('The final Request URI is [' . $uri . ']' );
234
+			$this->logger->info('The final Request URI is [' . $uri . ']');
235 235
 			//generic routes
236 236
 			$pattern = array(':num', ':alpha', ':alnum', ':any');
237 237
 			$replace = array('[0-9]+', '[a-zA-Z]+', '[a-zA-Z0-9]+', '.*');
@@ -245,20 +245,20 @@  discard block
 block discarded – undo
245 245
 					array_shift($args);
246 246
 					//check if this contains an module
247 247
 					$moduleControllerMethod = explode('#', $this->callback[$index]);
248
-					if(is_array($moduleControllerMethod) && count($moduleControllerMethod) >= 2){
249
-						$this->logger->info('The current request use the module [' .$moduleControllerMethod[0]. ']');
248
+					if (is_array($moduleControllerMethod) && count($moduleControllerMethod) >= 2) {
249
+						$this->logger->info('The current request use the module [' . $moduleControllerMethod[0] . ']');
250 250
 						$this->module = $moduleControllerMethod[0];
251 251
 						$moduleControllerMethod = explode('@', $moduleControllerMethod[1]);
252 252
 					}
253
-					else{
253
+					else {
254 254
 						$this->logger->info('The current request does not use the module');
255 255
 						$moduleControllerMethod = explode('@', $this->callback[$index]);
256 256
 					}
257
-					if(is_array($moduleControllerMethod)){
258
-						if(isset($moduleControllerMethod[0])){
257
+					if (is_array($moduleControllerMethod)) {
258
+						if (isset($moduleControllerMethod[0])) {
259 259
 							$this->controller = $moduleControllerMethod[0];	
260 260
 						}
261
-						if(isset($moduleControllerMethod[1])){
261
+						if (isset($moduleControllerMethod[1])) {
262 262
 							$this->method = $moduleControllerMethod[1];
263 263
 						}
264 264
 						$this->args = $args;
@@ -268,73 +268,73 @@  discard block
 block discarded – undo
268 268
 				}
269 269
 			}
270 270
 			//first if the controller is not set and the module is set use the module name as the controller
271
-			if(! $this->getController() && $this->getModule()){
271
+			if (!$this->getController() && $this->getModule()) {
272 272
 				$this->logger->info('After loop in predefined routes configuration, the module name is set but the controller is not set, so we will use module as the controller');
273 273
 				$this->controller = $this->getModule();
274 274
 			}
275 275
 			//if can not determine the module/controller/method via the defined routes configuration we will use
276 276
 			//the URL like http://domain.com/module/controller/method/arg1/arg2
277
-			if(! $this->getController()){
277
+			if (!$this->getController()) {
278 278
 				$this->logger->info('Cannot determine the routing information using the predefined routes configuration, will use the request URI parameters');
279 279
 				$nbSegment = count($segment);
280 280
 				//if segment is null so means no need to perform
281
-				if($nbSegment > 0){
281
+				if ($nbSegment > 0) {
282 282
 					//get the module list
283 283
 					$modules = Module::getModuleList();
284 284
 					//first check if no module
285
-					if(! $modules){
285
+					if (!$modules) {
286 286
 						$this->logger->info('No module was loaded will skip the module checking');
287 287
 						//the application don't use module
288 288
 						//controller
289
-						if(isset($segment[0])){
289
+						if (isset($segment[0])) {
290 290
 							$this->controller = $segment[0];
291 291
 							array_shift($segment);
292 292
 						}
293 293
 						//method
294
-						if(isset($segment[0])){
294
+						if (isset($segment[0])) {
295 295
 							$this->method = $segment[0];
296 296
 							array_shift($segment);
297 297
 						}
298 298
 						//args
299 299
 						$this->args = $segment;
300 300
 					}
301
-					else{
301
+					else {
302 302
 						$this->logger->info('The application contains a loaded module will check if the current request is found in the module list');
303
-						if(in_array($segment[0], $modules)){
303
+						if (in_array($segment[0], $modules)) {
304 304
 							$this->logger->info('Found, the current request use the module [' . $segment[0] . ']');
305 305
 							$this->module = $segment[0];
306 306
 							array_shift($segment);
307 307
 							//check if the second arg is the controller from module
308
-							if(isset($segment[0])){
308
+							if (isset($segment[0])) {
309 309
 								$this->controller = $segment[0];
310 310
 								//check if the request use the same module name and controller
311 311
 								$path = Module::findControllerFullPath(ucfirst($this->getController()), $this->getModule());
312
-								if(! $path){
312
+								if (!$path) {
313 313
 									$this->logger->info('The controller [' . $this->getController() . '] not found in the module, may be will use the module [' . $this->getModule() . '] as controller');
314 314
 									$this->controller = $this->getModule();
315 315
 								}
316
-								else{
316
+								else {
317 317
 									$this->controllerPath = $path;
318 318
 									array_shift($segment);
319 319
 								}
320 320
 							}
321 321
 							//check for method
322
-							if(isset($segment[0])){
322
+							if (isset($segment[0])) {
323 323
 								$this->method = $segment[0];
324 324
 								array_shift($segment);
325 325
 							}
326 326
 							//the remaining is for args
327 327
 							$this->args = $segment;
328 328
 						}
329
-						else{
329
+						else {
330 330
 							$this->logger->info('The current request information is not found in the module list');
331 331
 							//controller
332
-							if(isset($segment[0])){
332
+							if (isset($segment[0])) {
333 333
 								$this->controller = $segment[0];
334 334
 								array_shift($segment);
335 335
 							}
336 336
 							//method
337
-							if(isset($segment[0])){
337
+							if (isset($segment[0])) {
338 338
 								$this->method = $segment[0];
339 339
 								array_shift($segment);
340 340
 							}
@@ -344,18 +344,18 @@  discard block
 block discarded – undo
344 344
 					}
345 345
 				}
346 346
 			}
347
-			if(! $this->getController() && $this->getModule()){
347
+			if (!$this->getController() && $this->getModule()) {
348 348
 				$this->logger->info('After using the request URI the module name is set but the controller is not set so we will use module as the controller');
349 349
 				$this->controller = $this->getModule();
350 350
 			}
351 351
 			//did we set the controller, so set the controller path
352
-			if($this->getController() && ! $this->getControllerPath()){
352
+			if ($this->getController() && !$this->getControllerPath()) {
353 353
 				$this->logger->debug('Setting the file path for the controller [' . $this->getController() . ']');
354 354
 				//if it is the module controller
355
-				if($this->getModule()){
355
+				if ($this->getModule()) {
356 356
 					$this->controllerPath = Module::findControllerFullPath(ucfirst($this->getController()), $this->getModule());
357 357
 				}
358
-				else{
358
+				else {
359 359
 					$this->controllerPath = APPS_CONTROLLER_PATH . ucfirst($this->getController()) . '.php';
360 360
 				}
361 361
 			}
@@ -365,20 +365,20 @@  discard block
 block discarded – undo
365 365
 			$this->logger->debug('Loading controller [' . $controller . '], the file path is [' . $classFilePath . ']...');
366 366
 			$benchmark->mark('ROUTING_PROCESS_END');
367 367
 			$e404 = false;
368
-			if(file_exists($classFilePath)){
368
+			if (file_exists($classFilePath)) {
369 369
 				require_once $classFilePath;
370
-				if(! class_exists($controller, false)){
370
+				if (!class_exists($controller, false)) {
371 371
 					$e404 = true;
372
-					$this->logger->info('The controller file [' .$classFilePath. '] exists but does not contain the class [' . $controller . ']');
372
+					$this->logger->info('The controller file [' . $classFilePath . '] exists but does not contain the class [' . $controller . ']');
373 373
 				}
374
-				else{
374
+				else {
375 375
 					$controllerInstance = new $controller();
376 376
 					$controllerMethod = $this->getMethod();
377
-					if(! method_exists($controllerInstance, $controllerMethod)){
377
+					if (!method_exists($controllerInstance, $controllerMethod)) {
378 378
 						$e404 = true;
379 379
 						$this->logger->info('The controller [' . $controller . '] exist but does not contain the method [' . $controllerMethod . ']');
380 380
 					}
381
-					else{
381
+					else {
382 382
 						$this->logger->info('Routing data is set correctly now GO!');
383 383
 						call_user_func_array(array($controllerInstance, $controllerMethod), $this->getArgs());
384 384
 						$obj = & get_instance();
@@ -388,12 +388,12 @@  discard block
 block discarded – undo
388 388
 					}
389 389
 				}
390 390
 			}
391
-			else{
391
+			else {
392 392
 				$this->logger->info('The controller file path [' . $classFilePath . '] does not exist');
393 393
 				$e404 = true;
394 394
 			}
395
-			if($e404){
396
-				$response =& class_loader('Response', 'classes');
395
+			if ($e404) {
396
+				$response = & class_loader('Response', 'classes');
397 397
 				$response->send404();
398 398
 			}
399 399
 		}
Please login to merge, or discard this patch.
Braces   +12 added lines, -24 removed lines patch added patch discarded remove patch
@@ -104,8 +104,7 @@  discard block
 block discarded – undo
104 104
 					$this->routes = $route;
105 105
 					unset($route);
106 106
 				}
107
-			}
108
-			else{
107
+			} else{
109 108
 				show_error('Unable to find the routes configuration file [' . $routesPath . ']');
110 109
 			}
111 110
 			
@@ -115,8 +114,7 @@  discard block
 block discarded – undo
115 114
 			if($modulesRoutes && is_array($modulesRoutes)){
116 115
 				$this->routes = array_merge($this->routes, $modulesRoutes);
117 116
 				$this->logger->info('Routes for all modules loaded successfully');
118
-			}
119
-			else{
117
+			} else{
120 118
 				$this->logger->info('No routes found for all modules skipping.');
121 119
 			}
122 120
 			$this->logger->info('The routes configuration are listed below: ' . stringfy_vars($this->routes));
@@ -132,8 +130,7 @@  discard block
 block discarded – undo
132 130
 			if($suffix = get_config('url_suffix')){
133 131
 				$this->logger->info('URL suffix is enabled in the configuration, the value is [' . $suffix . ']' );
134 132
 				$uri = str_ireplace($suffix, '', $uri);
135
-			}
136
-			else{
133
+			} else{
137 134
 				$this->logger->info('URL suffix is not enabled in the configuration');
138 135
 			}
139 136
 			if(strpos($uri, '?') !== false){
@@ -226,8 +223,7 @@  discard block
 block discarded – undo
226 223
 				$this->logger->info('The request URI contains the front controller');
227 224
 				array_shift($segment);
228 225
 				$this->segments = $segment;
229
-			}
230
-			else{
226
+			} else{
231 227
 				$this->logger->info('The request URI does not contain the front controller');
232 228
 			}
233 229
 			$uri = implode('/', $segment);
@@ -249,8 +245,7 @@  discard block
 block discarded – undo
249 245
 						$this->logger->info('The current request use the module [' .$moduleControllerMethod[0]. ']');
250 246
 						$this->module = $moduleControllerMethod[0];
251 247
 						$moduleControllerMethod = explode('@', $moduleControllerMethod[1]);
252
-					}
253
-					else{
248
+					} else{
254 249
 						$this->logger->info('The current request does not use the module');
255 250
 						$moduleControllerMethod = explode('@', $this->callback[$index]);
256 251
 					}
@@ -297,8 +292,7 @@  discard block
 block discarded – undo
297 292
 						}
298 293
 						//args
299 294
 						$this->args = $segment;
300
-					}
301
-					else{
295
+					} else{
302 296
 						$this->logger->info('The application contains a loaded module will check if the current request is found in the module list');
303 297
 						if(in_array($segment[0], $modules)){
304 298
 							$this->logger->info('Found, the current request use the module [' . $segment[0] . ']');
@@ -312,8 +306,7 @@  discard block
 block discarded – undo
312 306
 								if(! $path){
313 307
 									$this->logger->info('The controller [' . $this->getController() . '] not found in the module, may be will use the module [' . $this->getModule() . '] as controller');
314 308
 									$this->controller = $this->getModule();
315
-								}
316
-								else{
309
+								} else{
317 310
 									$this->controllerPath = $path;
318 311
 									array_shift($segment);
319 312
 								}
@@ -325,8 +318,7 @@  discard block
 block discarded – undo
325 318
 							}
326 319
 							//the remaining is for args
327 320
 							$this->args = $segment;
328
-						}
329
-						else{
321
+						} else{
330 322
 							$this->logger->info('The current request information is not found in the module list');
331 323
 							//controller
332 324
 							if(isset($segment[0])){
@@ -354,8 +346,7 @@  discard block
 block discarded – undo
354 346
 				//if it is the module controller
355 347
 				if($this->getModule()){
356 348
 					$this->controllerPath = Module::findControllerFullPath(ucfirst($this->getController()), $this->getModule());
357
-				}
358
-				else{
349
+				} else{
359 350
 					$this->controllerPath = APPS_CONTROLLER_PATH . ucfirst($this->getController()) . '.php';
360 351
 				}
361 352
 			}
@@ -370,15 +361,13 @@  discard block
 block discarded – undo
370 361
 				if(! class_exists($controller, false)){
371 362
 					$e404 = true;
372 363
 					$this->logger->info('The controller file [' .$classFilePath. '] exists but does not contain the class [' . $controller . ']');
373
-				}
374
-				else{
364
+				} else{
375 365
 					$controllerInstance = new $controller();
376 366
 					$controllerMethod = $this->getMethod();
377 367
 					if(! method_exists($controllerInstance, $controllerMethod)){
378 368
 						$e404 = true;
379 369
 						$this->logger->info('The controller [' . $controller . '] exist but does not contain the method [' . $controllerMethod . ']');
380
-					}
381
-					else{
370
+					} else{
382 371
 						$this->logger->info('Routing data is set correctly now GO!');
383 372
 						call_user_func_array(array($controllerInstance, $controllerMethod), $this->getArgs());
384 373
 						$obj = & get_instance();
@@ -387,8 +376,7 @@  discard block
 block discarded – undo
387 376
 						$obj->response->renderFinalPage();
388 377
 					}
389 378
 				}
390
-			}
391
-			else{
379
+			} else{
392 380
 				$this->logger->info('The controller file path [' . $classFilePath . '] does not exist');
393 381
 				$e404 = true;
394 382
 			}
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,33 +332,33 @@  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
 				require_once $configFilePath;
356
-				if(! empty($config) && is_array($config)){
356
+				if (!empty($config) && is_array($config)) {
357 357
 					Config::setAll($config);
358 358
 				}
359 359
 			}
360
-			else{
361
-				show_error('Unable to find config file ['. $configFilePath . ']');
360
+			else {
361
+				show_error('Unable to find config file [' . $configFilePath . ']');
362 362
 			}
363 363
 			static::$loaded['config_' . $filename] = $configFilePath;
364 364
 			$logger->info('Configuration [' . $configFilePath . '] loaded successfully.');
@@ -374,14 +374,14 @@  discard block
 block discarded – undo
374 374
 		 *
375 375
 		 * @return void
376 376
 		 */
377
-		public static function lang($language){
377
+		public static function lang($language) {
378 378
 			$logger = static::getLogger();
379 379
 			$language = str_ireplace('.php', '', $language);
380 380
 			$language = trim($language, '/\\');
381 381
 			$language = str_ireplace('lang_', '', $language);
382
-			$file = 'lang_'.$language.'.php';
382
+			$file = 'lang_' . $language . '.php';
383 383
 			$logger->debug('Loading language [' . $language . '] ...');
384
-			if(isset(static::$loaded['lang_' . $language])){
384
+			if (isset(static::$loaded['lang_' . $language])) {
385 385
 				$logger->info('Language [' . $language . '] already loaded no need to load it again, cost in performance');
386 386
 				return;
387 387
 			}
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 			$cfgKey = get_config('language_cookie_name');
392 392
 			$objCookie = & class_loader('Cookie');
393 393
 			$cookieLang = $objCookie->get($cfgKey);
394
-			if($cookieLang){
394
+			if ($cookieLang) {
395 395
 				$appLang = $cookieLang;
396 396
 			}
397 397
 			$languageFilePath = null;
@@ -400,30 +400,30 @@  discard block
 block discarded – undo
400 400
 			$searchModuleName = null;
401 401
 			$obj = & get_instance();
402 402
 			//check if the request class contains module name
403
-			if(strpos($language, '/') !== false){
403
+			if (strpos($language, '/') !== false) {
404 404
 				$path = explode('/', $language);
405
-				if(isset($path[0]) && in_array($path[0], Module::getModuleList())){
405
+				if (isset($path[0]) && in_array($path[0], Module::getModuleList())) {
406 406
 					$searchModuleName = $path[0];
407 407
 					$language = 'lang_' . $path[1] . '.php';
408
-					$file = $path[0] . DS .$language;
408
+					$file = $path[0] . DS . $language;
409 409
 				}
410 410
 			}
411
-			if(! $searchModuleName && !empty($obj->moduleName)){
411
+			if (!$searchModuleName && !empty($obj->moduleName)) {
412 412
 				$searchModuleName = $obj->moduleName;
413 413
 			}
414 414
 			$moduleLanguagePath = Module::findLanguageFullPath($language, $searchModuleName, $appLang);
415
-			if($moduleLanguagePath){
416
-				$logger->info('Found language [' . $language . '] from module [' .$searchModuleName. '], the file path is [' .$moduleLanguagePath. '] we will used it');
415
+			if ($moduleLanguagePath) {
416
+				$logger->info('Found language [' . $language . '] from module [' . $searchModuleName . '], the file path is [' . $moduleLanguagePath . '] we will used it');
417 417
 				$languageFilePath = $moduleLanguagePath;
418 418
 			}
419
-			else{
419
+			else {
420 420
 				$logger->info('Cannot find language [' . $language . '] from modules using the default location');
421 421
 			}
422
-			if(! $languageFilePath){
422
+			if (!$languageFilePath) {
423 423
 				$searchDir = array(APP_LANG_PATH, CORE_LANG_PATH);
424
-				foreach($searchDir as $dir){
424
+				foreach ($searchDir as $dir) {
425 425
 					$filePath = $dir . $appLang . DS . $file;
426
-					if(file_exists($filePath)){
426
+					if (file_exists($filePath)) {
427 427
 						$languageFilePath = $filePath;
428 428
 						//is already found not to continue
429 429
 						break;
@@ -431,12 +431,12 @@  discard block
 block discarded – undo
431 431
 				}
432 432
 			}
433 433
 			$logger->info('The language file path to be loaded is [' . $languageFilePath . ']');
434
-			if($languageFilePath){
434
+			if ($languageFilePath) {
435 435
 				require_once $languageFilePath;
436
-				if(! empty($lang) && is_array($lang)){
437
-					$logger->info('Language file  [' .$languageFilePath. '] contains the valid languages keys add them to language list');
436
+				if (!empty($lang) && is_array($lang)) {
437
+					$logger->info('Language file  [' . $languageFilePath . '] contains the valid languages keys add them to language list');
438 438
 					//Note: may be here the class 'Lang' not yet loaded
439
-					$langObj =& class_loader('Lang', 'classes');
439
+					$langObj = & class_loader('Lang', 'classes');
440 440
 					$langObj->addLangMessages($lang);
441 441
 					//free the memory
442 442
 					unset($lang);
@@ -444,13 +444,13 @@  discard block
 block discarded – undo
444 444
 				static::$loaded['lang_' . $language] = $languageFilePath;
445 445
 				$logger->info('Language [' . $language . '] --> ' . $languageFilePath . ' loaded successfully.');
446 446
 			}
447
-			else{
447
+			else {
448 448
 				show_error('Unable to find language file [' . $file . ']');
449 449
 			}
450 450
 		}
451 451
 
452 452
 
453
-		private function getResourcesFromAutoloadConfig(){
453
+		private function getResourcesFromAutoloadConfig() {
454 454
 			$autoloads = array();
455 455
 			$autoloads['config']    = array();
456 456
 			$autoloads['languages'] = array();
@@ -458,22 +458,22 @@  discard block
 block discarded – undo
458 458
 			$autoloads['models']    = array();
459 459
 			$autoloads['functions'] = array();
460 460
 			//loading of the resources in autoload.php configuration file
461
-			if(file_exists(CONFIG_PATH . 'autoload.php')){
461
+			if (file_exists(CONFIG_PATH . 'autoload.php')) {
462 462
 				require_once CONFIG_PATH . 'autoload.php';
463
-				if(! empty($autoload) && is_array($autoload)){
463
+				if (!empty($autoload) && is_array($autoload)) {
464 464
 					$autoloads = array_merge($autoloads, $autoload);
465 465
 					unset($autoload);
466 466
 				}
467 467
 			}
468 468
 			//loading autoload configuration for modules
469 469
 			$modulesAutoloads = Module::getModulesAutoloadConfig();
470
-			if(! empty($modulesAutoloads) && is_array($modulesAutoloads)){
470
+			if (!empty($modulesAutoloads) && is_array($modulesAutoloads)) {
471 471
 				$autoloads = array_merge_recursive($autoloads, $modulesAutoloads);
472 472
 			}
473 473
 			return $autoloads;
474 474
 		}
475 475
 
476
-		private function loadResourcesFromAutoloadConfig(){
476
+		private function loadResourcesFromAutoloadConfig() {
477 477
 			$autoloads = array();
478 478
 			$autoloads['config']    = array();
479 479
 			$autoloads['languages'] = array();
@@ -485,29 +485,29 @@  discard block
 block discarded – undo
485 485
 
486 486
 			$autoloads = array_merge($autoloads, $list);
487 487
 			//config autoload
488
-			foreach($autoloads['config'] as $c){
488
+			foreach ($autoloads['config'] as $c) {
489 489
 				$this->config($c);
490 490
 			}
491 491
 			
492 492
 			//languages autoload
493
-			foreach($autoloads['languages'] as $language){
493
+			foreach ($autoloads['languages'] as $language) {
494 494
 				$this->lang($language);
495 495
 			}
496 496
 			
497 497
 			//libraries autoload
498
-			foreach($autoloads['libraries'] as $library){
498
+			foreach ($autoloads['libraries'] as $library) {
499 499
 				$this->library($library);
500 500
 			}
501 501
 
502 502
 			//models autoload
503
-			if(! empty($autoloads['models']) && is_array($autoloads['models'])){
503
+			if (!empty($autoloads['models']) && is_array($autoloads['models'])) {
504 504
 				require_once CORE_CLASSES_MODEL_PATH . 'Model.php';
505
-				foreach($autoloads['models'] as $model){
505
+				foreach ($autoloads['models'] as $model) {
506 506
 					$this->model($model);
507 507
 				}
508 508
 			}
509 509
 			
510
-			foreach($autoloads['functions'] as $function){
510
+			foreach ($autoloads['functions'] as $function) {
511 511
 				$this->functions($function);
512 512
 			}
513 513
 		}
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.