Passed
Push — 1.0.0-dev ( 7e13dc...c7a39c )
by nguereza
06:11
created
core/classes/DBSessionHandler.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * check if the interface "SessionHandlerInterface" exists (normally in PHP 5.4 this already exists)
29 29
 	 */
30
-	if( !interface_exists('SessionHandlerInterface')){
30
+	if (!interface_exists('SessionHandlerInterface')) {
31 31
 		show_error('"SessionHandlerInterface" interface does not exists or is disabled can not use it to handler database session.');
32 32
 	}
33 33
 
34
-	class DBSessionHandler implements SessionHandlerInterface{
34
+	class DBSessionHandler implements SessionHandlerInterface {
35 35
 		
36 36
 		/**
37 37
 		 * The encryption method to use to encrypt session data in database
@@ -81,25 +81,25 @@  discard block
 block discarded – undo
81 81
          */
82 82
         protected $loader = null;
83 83
 
84
-		public function __construct(DBSessionHandlerModel $modelInstance = null, Log $logger = null, Loader $loader = null){
84
+		public function __construct(DBSessionHandlerModel $modelInstance = null, Log $logger = null, Loader $loader = null) {
85 85
 			/**
86 86
 	         * instance of the Log class
87 87
 	         */
88
-	        if(is_object($logger)){
88
+	        if (is_object($logger)) {
89 89
 	          $this->setLogger($logger);
90 90
 	        }
91
-	        else{
92
-	            $this->logger =& class_loader('Log', 'classes');
91
+	        else {
92
+	            $this->logger = & class_loader('Log', 'classes');
93 93
 	            $this->logger->setLogger('Library::DBSessionHandler');
94 94
 	        }
95 95
 
96
-	        if(is_object($loader)){
96
+	        if (is_object($loader)) {
97 97
 	          $this->setLoader($loader);
98 98
 	        }
99 99
 		    $this->OBJ = & get_instance();
100 100
 
101 101
 		    
102
-			if(is_object($modelInstance)){
102
+			if (is_object($modelInstance)) {
103 103
 				$this->setModelInstance($modelInstance);
104 104
 			}
105 105
 		}
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		 * Set the session secret used to encrypt the data in database 
109 109
 		 * @param string $secret the base64 string secret
110 110
 		 */
111
-		public function setSessionSecret($secret){
111
+		public function setSessionSecret($secret) {
112 112
 			$this->sessionSecret = $secret;
113 113
 			return $this;
114 114
 		}
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		 * Return the session secret
118 118
 		 * @return string 
119 119
 		 */
120
-		public function getSessionSecret(){
120
+		public function getSessionSecret() {
121 121
 			return $this->sessionSecret;
122 122
 		}
123 123
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 		 * Set the initializer vector for openssl 
127 127
 		 * @param string $key the session secret used
128 128
 		 */
129
-		public function setInitializerVector($key){
129
+		public function setInitializerVector($key) {
130 130
 			$iv_length = openssl_cipher_iv_length(self::DB_SESSION_HASH_METHOD);
131 131
 			$key = base64_decode($key);
132 132
 			$this->iv = substr(hash('sha256', $key), 0, $iv_length);
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 		 * Return the initializer vector
138 138
 		 * @return string 
139 139
 		 */
140
-		public function getInitializerVector(){
140
+		public function getInitializerVector() {
141 141
 			return $this->iv;
142 142
 		}
143 143
 
@@ -147,17 +147,17 @@  discard block
 block discarded – undo
147 147
 		 * @param  string $sessionName the session name
148 148
 		 * @return boolean 
149 149
 		 */
150
-		public function open($savePath, $sessionName){
150
+		public function open($savePath, $sessionName) {
151 151
 			$this->logger->debug('Opening database session handler for [' . $sessionName . ']');
152 152
 			//try to check if session secret is set before
153 153
 			$secret = $this->getSessionSecret();
154
-			if(empty($secret)){
154
+			if (empty($secret)) {
155 155
 				$secret = get_config('session_secret', false);
156 156
 				$this->setSessionSecret($secret);
157 157
 			}
158 158
 			$this->logger->info('Session secret: ' . $secret);
159 159
 
160
-			if(! $this->getModelInstance()){
160
+			if (!$this->getModelInstance()) {
161 161
 				$this->setModelInstanceFromConfig();
162 162
 			}
163 163
 			$this->setInitializerVector($secret);
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 			//set session tables columns
166 166
 			$this->sessionTableColumns = $this->getModelInstance()->getSessionTableColumns();
167 167
 
168
-			if(empty($this->sessionTableColumns)){
168
+			if (empty($this->sessionTableColumns)) {
169 169
 				show_error('The session handler is "database" but the table columns not set');
170 170
 			}
171 171
 			$this->logger->info('Database session, the model columns are listed below: ' . stringfy_vars($this->sessionTableColumns));
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 		 * Close the session
182 182
 		 * @return boolean
183 183
 		 */
184
-		public function close(){
184
+		public function close() {
185 185
 			$this->logger->debug('Closing database session handler');
186 186
 			return true;
187 187
 		}
@@ -191,28 +191,28 @@  discard block
 block discarded – undo
191 191
 		 * @param  string $sid the session id to use
192 192
 		 * @return string      the session data in serialiaze format
193 193
 		 */
194
-		public function read($sid){
194
+		public function read($sid) {
195 195
 			$this->logger->debug('Reading database session data for SID: ' . $sid);
196 196
 			$instance = $this->getModelInstance();
197 197
 			$columns = $this->sessionTableColumns;
198
-			if($this->getLoader()){
198
+			if ($this->getLoader()) {
199 199
 				$this->getLoader()->functions('user_agent'); 
200 200
 				$this->getLoader()->library('Browser'); 
201 201
 			}
202
-			else{
202
+			else {
203 203
             	Loader::functions('user_agent');
204 204
             	Loader::library('Browser');
205 205
             }
206 206
 			
207 207
 			$ip = get_ip();
208 208
 			$host = @gethostbyaddr($ip) or null;
209
-			$browser = $this->OBJ->browser->getPlatform().', '.$this->OBJ->browser->getBrowser().' '.$this->OBJ->browser->getVersion();
209
+			$browser = $this->OBJ->browser->getPlatform() . ', ' . $this->OBJ->browser->getBrowser() . ' ' . $this->OBJ->browser->getVersion();
210 210
 			
211 211
 			$data = $instance->get_by(array($columns['sid'] => $sid, $columns['shost'] => $host, $columns['sbrowser'] => $browser));
212
-			if($data && isset($data->{$columns['sdata']})){
212
+			if ($data && isset($data->{$columns['sdata']})) {
213 213
 				//checking inactivity 
214 214
 				$timeInactivity = time() - get_config('session_inactivity_time', 100);
215
-				if($data->{$columns['stime']} < $timeInactivity){
215
+				if ($data->{$columns['stime']} < $timeInactivity) {
216 216
 					$this->logger->info('Database session data for SID: ' . $sid . ' already expired, destroy it');
217 217
 					$this->destroy($sid);
218 218
 					return null;
@@ -229,16 +229,16 @@  discard block
 block discarded – undo
229 229
 		 * @param  mixed $data the session data to save in serialize format
230 230
 		 * @return boolean 
231 231
 		 */
232
-		public function write($sid, $data){
232
+		public function write($sid, $data) {
233 233
 			$this->logger->debug('Saving database session data for SID: ' . $sid . ', data: ' . stringfy_vars($data));
234 234
 			$instance = $this->getModelInstance();
235 235
 			$columns = $this->sessionTableColumns;
236 236
 
237
-			if($this->getLoader()){
237
+			if ($this->getLoader()) {
238 238
 				$this->getLoader()->functions('user_agent'); 
239 239
 				$this->getLoader()->library('Browser'); 
240 240
 			}
241
-			else{
241
+			else {
242 242
             	Loader::functions('user_agent');
243 243
             	Loader::library('Browser');
244 244
             }
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 			$ip = get_ip();
247 247
 			$keyValue = $instance->getKeyValue();
248 248
 			$host = @gethostbyaddr($ip) or null;
249
-			$browser = $this->OBJ->browser->getPlatform().', '.$this->OBJ->browser->getBrowser().' '.$this->OBJ->browser->getVersion();
249
+			$browser = $this->OBJ->browser->getPlatform() . ', ' . $this->OBJ->browser->getBrowser() . ' ' . $this->OBJ->browser->getVersion();
250 250
 			$data = $this->encode($data);
251 251
 			$params = array(
252 252
 							$columns['sid'] => $sid,
@@ -259,13 +259,13 @@  discard block
 block discarded – undo
259 259
 						);
260 260
 			$this->logger->info('Database session data to save are listed below :' . stringfy_vars($params));
261 261
 			$exists = $instance->get($sid);
262
-			if($exists){
262
+			if ($exists) {
263 263
 				$this->logger->info('Session data for SID: ' . $sid . ' already exists, just update it');
264 264
 				//update
265 265
 				unset($params[$columns['sid']]);
266 266
 				$instance->update($sid, $params);
267 267
 			}
268
-			else{
268
+			else {
269 269
 				$this->logger->info('Session data for SID: ' . $sid . ' not yet exists, insert it now');
270 270
 				$instance->insert($params);
271 271
 			}
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 		 * @param  string $sid the session id value
279 279
 		 * @return boolean
280 280
 		 */
281
-		public function destroy($sid){
281
+		public function destroy($sid) {
282 282
 			$this->logger->debug('Destroy of session data for SID: ' . $sid);
283 283
 			$instance = $this->modelInstanceName;
284 284
 			$instance->delete($sid);
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 		 * @param  integer $maxLifetime the max lifetime
291 291
 		 * @return boolean
292 292
 		 */
293
-		public function gc($maxLifetime){
293
+		public function gc($maxLifetime) {
294 294
 			$instance = $this->modelInstanceName;
295 295
 			$time = time() - $maxLifetime;
296 296
 			$this->logger->debug('Garbage collector of expired session. maxLifetime [' . $maxLifetime . '] sec, expired time [' . $time . ']');
@@ -303,9 +303,9 @@  discard block
 block discarded – undo
303 303
 		 * @param  mixed $data the session data to encode
304 304
 		 * @return mixed the encoded session data
305 305
 		 */
306
-		public function encode($data){
306
+		public function encode($data) {
307 307
 			$key = base64_decode($this->sessionSecret);
308
-			$dataEncrypted = openssl_encrypt($data , self::DB_SESSION_HASH_METHOD, $key, OPENSSL_RAW_DATA, $this->getInitializerVector());
308
+			$dataEncrypted = openssl_encrypt($data, self::DB_SESSION_HASH_METHOD, $key, OPENSSL_RAW_DATA, $this->getInitializerVector());
309 309
 			$output = base64_encode($dataEncrypted);
310 310
 			return $output;
311 311
 		}
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 		 * @param  mixed $data the data to decode
317 317
 		 * @return mixed       the decoded data
318 318
 		 */
319
-		public function decode($data){
319
+		public function decode($data) {
320 320
 			$key = base64_decode($this->sessionSecret);
321 321
 			$data = base64_decode($data);
322 322
 			$data = openssl_decrypt($data, self::DB_SESSION_HASH_METHOD, $key, OPENSSL_RAW_DATA, $this->getInitializerVector());
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
          * Return the loader instance
329 329
          * @return object Loader the loader instance
330 330
          */
331
-        public function getLoader(){
331
+        public function getLoader() {
332 332
             return $this->loader;
333 333
         }
334 334
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
          * set the loader instance for future use
337 337
          * @param object Loader $loader the loader object
338 338
          */
339
-         public function setLoader($loader){
339
+         public function setLoader($loader) {
340 340
             $this->loader = $loader;
341 341
             return $this;
342 342
         }
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
          * Return the model instance
346 346
          * @return object DBSessionHandlerModel the model instance
347 347
          */
348
-        public function getModelInstance(){
348
+        public function getModelInstance() {
349 349
             return $this->modelInstanceName;
350 350
         }
351 351
 
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
          * set the model instance for future use
354 354
          * @param DBSessionHandlerModel $modelInstance the model object
355 355
          */
356
-         public function setModelInstance(DBSessionHandlerModel $modelInstance){
356
+         public function setModelInstance(DBSessionHandlerModel $modelInstance) {
357 357
             $this->modelInstanceName = $modelInstance;
358 358
             return $this;
359 359
         }
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 	     * Return the Log instance
363 363
 	     * @return Log
364 364
 	     */
365
-	    public function getLogger(){
365
+	    public function getLogger() {
366 366
 	      return $this->logger;
367 367
 	    }
368 368
 
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 	     * Set the log instance
371 371
 	     * @param Log $logger the log object
372 372
 	     */
373
-	    public function setLogger(Log $logger){
373
+	    public function setLogger(Log $logger) {
374 374
 	      $this->logger = $logger;
375 375
 	      return $this;
376 376
 	    }
@@ -378,18 +378,18 @@  discard block
 block discarded – undo
378 378
 	    /**
379 379
 	     * Set the model instance using the configuration for session
380 380
 	     */
381
-	    private function setModelInstanceFromConfig(){
381
+	    private function setModelInstanceFromConfig() {
382 382
 	    	$modelName = get_config('session_save_path');
383 383
 			$this->logger->info('The database session model: ' . $modelName);
384
-			if($this->getLoader()){
384
+			if ($this->getLoader()) {
385 385
 				$this->getLoader()->model($modelName, 'dbsessionhandlerinstance'); 
386 386
 			}
387 387
 			//@codeCoverageIgnoreStart
388
-			else{
388
+			else {
389 389
             	Loader::model($modelName, 'dbsessionhandlerinstance'); 
390 390
             }
391
-            if(isset($this->OBJ->dbsessionhandlerinstance) && ! $this->OBJ->dbsessionhandlerinstance instanceof DBSessionHandlerModel){
392
-				show_error('To use database session handler, your class model "'.get_class($this->OBJ->dbsessionhandlerinstance).'" need extends "DBSessionHandlerModel"');
391
+            if (isset($this->OBJ->dbsessionhandlerinstance) && !$this->OBJ->dbsessionhandlerinstance instanceof DBSessionHandlerModel) {
392
+				show_error('To use database session handler, your class model "' . get_class($this->OBJ->dbsessionhandlerinstance) . '" need extends "DBSessionHandlerModel"');
393 393
 			}  
394 394
 			//@codeCoverageIgnoreEnd
395 395
 			
Please login to merge, or discard this patch.
core/classes/model/Model.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      * @copyright Copyright (c) 2012, Jamie Rumbelow <http://jamierumbelow.net>
34 34
      */
35 35
 
36
-    class Model{
36
+    class Model {
37 37
 
38 38
         /* --------------------------------------------------------------
39 39
          * VARIABLES
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
          * Initialise the model, tie into the CodeIgniter superobject and
141 141
          * try our best to guess the table name.
142 142
          */
143
-        public function __construct(Database $db = null){
144
-            if(is_object($db)){
143
+        public function __construct(Database $db = null) {
144
+            if (is_object($db)) {
145 145
                 $this->setDatabaseInstance($db);
146 146
             }
147
-            else{
147
+            else {
148 148
                 $obj = & get_instance();
149
-        		if(isset($obj->database) && is_object($obj->database)){
149
+        		if (isset($obj->database) && is_object($obj->database)) {
150 150
                     /**
151 151
                     * NOTE: Need use "clone" because some Model need have the personal instance of the database library
152 152
                     * to prevent duplication
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
             if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE)
184 184
             {
185
-                $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted);
185
+                $this->_database->where($this->soft_delete_key, (bool) $this->_temporary_only_deleted);
186 186
             }
187 187
 
188 188
     		$this->_set_where($where);
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
             $this->trigger('before_get');
225 225
             if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE)
226 226
             {
227
-                $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted);
227
+                $this->_database->where($this->soft_delete_key, (bool) $this->_temporary_only_deleted);
228 228
             }
229
-			$type = $this->_temporary_return_type == 'array' ? 'array':false;
229
+			$type = $this->_temporary_return_type == 'array' ? 'array' : false;
230 230
             $result = $this->_database->from($this->_table)->getAll($type);
231 231
             $this->_temporary_return_type = $this->return_type;
232 232
 
@@ -332,13 +332,13 @@  discard block
 block discarded – undo
332 332
         {
333 333
             $args = func_get_args();
334 334
             $data = array();
335
-            if(count($args) == 2){
336
-                if(is_array($args[1])){
335
+            if (count($args) == 2) {
336
+                if (is_array($args[1])) {
337 337
                     $data = array_pop($args);
338 338
                 }
339 339
             }
340
-            else if(count($args) == 3){
341
-                if(is_array($args[2])){
340
+            else if (count($args) == 3) {
341
+                if (is_array($args[2])) {
342 342
                     $data = array_pop($args);
343 343
                 }
344 344
             }
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
             $this->_database->where($this->primary_key, $id);
377 377
             if ($this->soft_delete)
378 378
             {
379
-                $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE ));
379
+                $result = $this->_database->from($this->_table)->update(array($this->soft_delete_key => TRUE));
380 380
             }
381 381
             else
382 382
             {
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
             $this->_set_where($where);
398 398
             if ($this->soft_delete)
399 399
             {
400
-                $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE ));
400
+                $result = $this->_database->from($this->_table)->update(array($this->soft_delete_key => TRUE));
401 401
             }
402 402
             else
403 403
             {
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
             $this->_database->in($this->primary_key, $primary_values);
417 417
             if ($this->soft_delete)
418 418
             {
419
-                $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE ));
419
+                $result = $this->_database->from($this->_table)->update(array($this->soft_delete_key => TRUE));
420 420
             }
421 421
             else
422 422
             {
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
                 if (is_string($value))
463 463
                 {
464 464
                     $relationship = $value;
465
-                    $options = array( 'primary_key' => $value . '_id', 'model' => $value . '_model' );
465
+                    $options = array('primary_key' => $value . '_id', 'model' => $value . '_model');
466 466
                 }
467 467
                 else
468 468
                 {
@@ -472,10 +472,10 @@  discard block
 block discarded – undo
472 472
 
473 473
                 if (in_array($relationship, $this->_with))
474 474
                 {
475
-                    if(is_object($this->loaderInstance)){
475
+                    if (is_object($this->loaderInstance)) {
476 476
                         $this->loaderInstance->model($options['model'], $relationship . '_model');
477 477
                     }
478
-                    else{
478
+                    else {
479 479
                         Loader::model($options['model'], $relationship . '_model');    
480 480
                     }
481 481
                     if (is_object($row))
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
                 if (is_string($value))
495 495
                 {
496 496
                     $relationship = $value;
497
-                    $options = array( 'primary_key' => $this->_table . '_id', 'model' => $value . '_model' );
497
+                    $options = array('primary_key' => $this->_table . '_id', 'model' => $value . '_model');
498 498
                 }
499 499
                 else
500 500
                 {
@@ -504,10 +504,10 @@  discard block
 block discarded – undo
504 504
 
505 505
                 if (in_array($relationship, $this->_with))
506 506
                 {
507
-                    if(is_object($this->loaderInstance)){
507
+                    if (is_object($this->loaderInstance)) {
508 508
                         $this->loaderInstance->model($options['model'], $relationship . '_model');
509 509
                     }
510
-                    else{
510
+                    else {
511 511
                         Loader::model($options['model'], $relationship . '_model');    
512 512
                     }
513 513
                     if (is_object($row))
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
         public function dropdown()
534 534
         {
535 535
             $args = func_get_args();
536
-            if(count($args) == 2)
536
+            if (count($args) == 2)
537 537
             {
538 538
                 list($key, $value) = $args;
539 539
             }
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
                 $key = $this->primary_key;
543 543
                 $value = $args[0];
544 544
             }
545
-            $this->trigger('before_dropdown', array( $key, $value ));
545
+            $this->trigger('before_dropdown', array($key, $value));
546 546
             if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE)
547 547
             {
548 548
                 $this->_database->where($this->soft_delete_key, FALSE);
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
         {
567 567
             if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE)
568 568
             {
569
-                $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted);
569
+                $this->_database->where($this->soft_delete_key, (bool) $this->_temporary_only_deleted);
570 570
             }
571 571
             $where = func_get_args();
572 572
             $this->_set_where($where);
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
         {
582 582
             if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE)
583 583
             {
584
-                $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted);
584
+                $this->_database->where($this->soft_delete_key, (bool) $this->_temporary_only_deleted);
585 585
             }
586 586
             $this->_database->from($this->_table)->getAll();
587 587
             return $this->_database->numRows();
@@ -590,8 +590,8 @@  discard block
 block discarded – undo
590 590
 		/**
591 591
 		* Enabled cache temporary
592 592
 		*/
593
-		public function cached($ttl = 0){
594
-		  if($ttl > 0){
593
+		public function cached($ttl = 0) {
594
+		  if ($ttl > 0) {
595 595
 			$this->_database = $this->_database->cached($ttl);
596 596
 		  }
597 597
 		  return $this;
@@ -745,13 +745,13 @@  discard block
 block discarded – undo
745 745
             {
746 746
                 if (is_object($row))
747 747
                 {
748
-					if(isset($row->$attr)){
748
+					if (isset($row->$attr)) {
749 749
 						unset($row->$attr);
750 750
 					}
751 751
                 }
752 752
                 else
753 753
                 {
754
-					if(isset($row[$attr])){
754
+					if (isset($row[$attr])) {
755 755
 						unset($row[$attr]);
756 756
 					}
757 757
                 }
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
          * Return the database instance
764 764
          * @return Database the database instance
765 765
          */
766
-        public function getDatabaseInstance(){
766
+        public function getDatabaseInstance() {
767 767
             return $this->_database;
768 768
         }
769 769
 
@@ -771,9 +771,9 @@  discard block
 block discarded – undo
771 771
          * set the Database instance for future use
772 772
          * @param Database $db the database object
773 773
          */
774
-         public function setDatabaseInstance($db){
774
+         public function setDatabaseInstance($db) {
775 775
             $this->_database = $db;
776
-            if($this->dbCacheTime > 0){
776
+            if ($this->dbCacheTime > 0) {
777 777
                 $this->_database->setCache($this->dbCacheTime);
778 778
             }
779 779
             return $this;
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
          * Return the loader instance
784 784
          * @return Loader the loader instance
785 785
          */
786
-        public function getLoader(){
786
+        public function getLoader() {
787 787
             return $this->loaderInstance;
788 788
         }
789 789
 
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
          * set the loader instance for future use
792 792
          * @param Loader $loader the loader object
793 793
          */
794
-         public function setLoader($loader){
794
+         public function setLoader($loader) {
795 795
             $this->loaderInstance = $loader;
796 796
             return $this;
797 797
         }
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
          * Return the FormValidation instance
801 801
          * @return FormValidation the form validation instance
802 802
          */
803
-        public function getFormValidation(){
803
+        public function getFormValidation() {
804 804
             return $this->formValidationInstance;
805 805
         }
806 806
 
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
          * set the form validation instance for future use
809 809
          * @param FormValidation $fv the form validation object
810 810
          */
811
-         public function setFormValidation($fv){
811
+         public function setFormValidation($fv) {
812 812
             $this->formValidationInstance = $fv;
813 813
             return $this;
814 814
         }
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
          */
823 823
         public function order_by($criteria, $order = 'ASC')
824 824
         {
825
-            if ( is_array($criteria) )
825
+            if (is_array($criteria))
826 826
             {
827 827
                 foreach ($criteria as $key => $value)
828 828
                 {
@@ -878,17 +878,17 @@  discard block
 block discarded – undo
878 878
          */
879 879
         protected function validate(array $data)
880 880
         {
881
-            if($this->skip_validation)
881
+            if ($this->skip_validation)
882 882
             {
883 883
                 return $data;
884 884
             }
885
-            if(!empty($this->validate))
885
+            if (!empty($this->validate))
886 886
             {
887 887
                 $fv = null;
888
-                if(is_object($this->formValidationInstance)){
888
+                if (is_object($this->formValidationInstance)) {
889 889
                     $fv = $this->formValidationInstance;
890 890
                 }
891
-                else{
891
+                else {
892 892
                     Loader::library('FormValidation');
893 893
                     $fv = $this->formvalidation;
894 894
                     $this->setFormValidation($fv);
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
             {
944 944
                 $this->_database->where($params[0]);
945 945
             }
946
-        	else if(count($params) == 2)
946
+        	else if (count($params) == 2)
947 947
     		{
948 948
                 if (is_array($params[1]))
949 949
                 {
@@ -954,7 +954,7 @@  discard block
 block discarded – undo
954 954
                     $this->_database->where($params[0], $params[1]);
955 955
                 }
956 956
     		}
957
-    		else if(count($params) == 3)
957
+    		else if (count($params) == 3)
958 958
     		{
959 959
     			$this->_database->where($params[0], $params[1], $params[2]);
960 960
     		}
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
         /**
975 975
             Shortcut to controller
976 976
         */
977
-        public function __get($key){
977
+        public function __get($key) {
978 978
             return get_instance()->{$key};
979 979
         }
980 980
 
Please login to merge, or discard this patch.
core/classes/Response.php 1 patch
Spacing   +74 added lines, -74 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 Response{
27
+	class Response {
28 28
 
29 29
 		/**
30 30
 		 * The list of request header to send with response
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
 		/**
66 66
 		 * Construct new response instance
67 67
 		 */
68
-		public function __construct(){
69
-			$this->_currentUrl =  (! empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '' )
70
-					. (! empty($_SERVER['QUERY_STRING']) ? ('?' . $_SERVER['QUERY_STRING']) : '' );
68
+		public function __construct() {
69
+			$this->_currentUrl = (!empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '')
70
+					. (!empty($_SERVER['QUERY_STRING']) ? ('?' . $_SERVER['QUERY_STRING']) : '');
71 71
 					
72 72
 			$this->_currentUrlCacheKey = md5($this->_currentUrl);
73 73
 			
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
 		 * Get the logger singleton instance
83 83
 		 * @return Log the logger instance
84 84
 		 */
85
-		private static function getLogger(){
86
-			if(self::$logger == null){
87
-				self::$logger[0] =& class_loader('Log', 'classes');
85
+		private static function getLogger() {
86
+			if (self::$logger == null) {
87
+				self::$logger[0] = & class_loader('Log', 'classes');
88 88
 				self::$logger[0]->setLogger('Library::Response');
89 89
 			}
90 90
 			return self::$logger[0];
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
 		 * @param  integer $httpCode the HTTP status code
96 96
 		 * @param  array   $headers   the additional headers to add to the existing headers list
97 97
 		 */
98
-		public static function sendHeaders($httpCode = 200, array $headers = array()){
98
+		public static function sendHeaders($httpCode = 200, array $headers = array()) {
99 99
 			set_http_status_header($httpCode);
100 100
 			self::setHeaders($headers);
101
-			if(! headers_sent()){
102
-				foreach(self::getHeaders() as $key => $value){
103
-					header($key .': '.$value);
101
+			if (!headers_sent()) {
102
+				foreach (self::getHeaders() as $key => $value) {
103
+					header($key . ': ' . $value);
104 104
 				}
105 105
 			}
106 106
 		}
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		 * Get the list of the headers
110 110
 		 * @return array the headers list
111 111
 		 */
112
-		public static function getHeaders(){
112
+		public static function getHeaders() {
113 113
 			return self::$headers;
114 114
 		}
115 115
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 		 * @param  string $name the header name
119 119
 		 * @return string       the header value
120 120
 		 */
121
-		public static function getHeader($name){
121
+		public static function getHeader($name) {
122 122
 			return array_key_exists($name, self::$headers) ? self::$headers[$name] : null;
123 123
 		}
124 124
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 		 * @param string $name  the header name
129 129
 		 * @param string $value the header value to be set
130 130
 		 */
131
-		public static function setHeader($name, $value){
131
+		public static function setHeader($name, $value) {
132 132
 			self::$headers[$name] = $value;
133 133
 		}
134 134
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 		 * @param array $headers the list of the headers to set. 
138 138
 		 * Note: this will merge with the existing headers
139 139
 		 */
140
-		public static function setHeaders(array $headers){
140
+		public static function setHeaders(array $headers) {
141 141
 			self::$headers = array_merge(self::getHeaders(), $headers);
142 142
 		}
143 143
 		
@@ -145,17 +145,17 @@  discard block
 block discarded – undo
145 145
 		 * Redirect user in the specified page
146 146
 		 * @param  string $path the URL or URI to be redirect to
147 147
 		 */
148
-		public static function redirect($path = ''){
148
+		public static function redirect($path = '') {
149 149
 			$logger = self::getLogger();
150 150
 			$url = Url::site_url($path);
151
-			$logger->info('Redirect to URL [' .$url. ']');
152
-			if(! headers_sent()){
153
-				header('Location: '.$url);
151
+			$logger->info('Redirect to URL [' . $url . ']');
152
+			if (!headers_sent()) {
153
+				header('Location: ' . $url);
154 154
 				exit;
155 155
 			}
156
-			else{
156
+			else {
157 157
 				echo '<script>
158
-						location.href = "'.$url.'";
158
+						location.href = "'.$url . '";
159 159
 					</script>';
160 160
 			}
161 161
 		}
@@ -168,10 +168,10 @@  discard block
 block discarded – undo
168 168
 		 * @return void|string          if $return is true will return the view content otherwise
169 169
 		 * will display the view content.
170 170
 		 */
171
-		public function render($view, $data = null, $return = false){
171
+		public function render($view, $data = null, $return = false) {
172 172
 			$logger = self::getLogger();
173 173
 			//convert data to an array
174
-			$data = ! is_array($data) ? (array) $data : $data;
174
+			$data = !is_array($data) ? (array) $data : $data;
175 175
 			$view = str_ireplace('.php', '', $view);
176 176
 			$view = trim($view, '/\\');
177 177
 			$viewFile = $view . '.php';
@@ -180,42 +180,42 @@  discard block
 block discarded – undo
180 180
 			//super instance
181 181
 			$obj = & get_instance();
182 182
 			
183
-			if(Module::hasModule()){
183
+			if (Module::hasModule()) {
184 184
 				//check in module first
185 185
 				$logger->debug('Checking the view [' . $view . '] from module list ...');
186 186
 				$mod = null;
187 187
 				//check if the request class contains module name
188
-				if(strpos($view, '/') !== false){
188
+				if (strpos($view, '/') !== false) {
189 189
 					$viewPath = explode('/', $view);
190
-					if(isset($viewPath[0]) && in_array($viewPath[0], Module::getModuleList())){
190
+					if (isset($viewPath[0]) && in_array($viewPath[0], Module::getModuleList())) {
191 191
 						$mod = $viewPath[0];
192 192
 						array_shift($viewPath);
193 193
 						$view = implode('/', $viewPath);
194 194
 						$viewFile = $view . '.php';
195 195
 					}
196 196
 				}
197
-				if(! $mod && !empty($obj->moduleName)){
197
+				if (!$mod && !empty($obj->moduleName)) {
198 198
 					$mod = $obj->moduleName;
199 199
 				}
200
-				if($mod){
200
+				if ($mod) {
201 201
 					$moduleViewPath = Module::findViewFullPath($view, $mod);
202
-					if($moduleViewPath){
202
+					if ($moduleViewPath) {
203 203
 						$path = $moduleViewPath;
204
-						$logger->info('Found view [' . $view . '] in module [' .$mod. '], the file path is [' .$moduleViewPath. '] we will used it');
204
+						$logger->info('Found view [' . $view . '] in module [' . $mod . '], the file path is [' . $moduleViewPath . '] we will used it');
205 205
 					}
206
-					else{
207
-						$logger->info('Cannot find view [' . $view . '] in module [' .$mod. '] using the default location');
206
+					else {
207
+						$logger->info('Cannot find view [' . $view . '] in module [' . $mod . '] using the default location');
208 208
 					}
209 209
 				}
210
-				else{
210
+				else {
211 211
 					$logger->info('The current request does not use module using the default location.');
212 212
 				}
213 213
 			}
214 214
 			$logger->info('The view file path to be loaded is [' . $path . ']');
215 215
 			$found = false;
216
-			if(file_exists($path)){
217
-				foreach(get_object_vars($obj) as $key => $value){
218
-					if(! isset($this->{$key})){
216
+			if (file_exists($path)) {
217
+				foreach (get_object_vars($obj) as $key => $value) {
218
+					if (!isset($this->{$key})) {
219 219
 						$this->{$key} = & $obj->{$key};
220 220
 					}
221 221
 				}
@@ -224,39 +224,39 @@  discard block
 block discarded – undo
224 224
 				//need use require() instead of require_once because can load this view many time
225 225
 				require $path;
226 226
 				$content = ob_get_clean();
227
-				if($return){
227
+				if ($return) {
228 228
 					return $content;
229 229
 				}
230 230
 				$this->_pageRender .= $content;
231 231
 				$found = true;
232 232
 			}
233
-			if(! $found){
234
-				show_error('Unable to find view [' .$view . ']');
233
+			if (!$found) {
234
+				show_error('Unable to find view [' . $view . ']');
235 235
 			}
236 236
 		}
237 237
 		
238 238
 		/**
239 239
 		* Send the final page output to user
240 240
 		*/
241
-		public function renderFinalPage(){
241
+		public function renderFinalPage() {
242 242
 			$logger = self::getLogger();
243 243
 			$obj = & get_instance();
244 244
 			$cachePageStatus = get_config('cache_enable', false) && !empty($obj->view_cache_enable);
245 245
 			$dispatcher = $obj->eventdispatcher;
246 246
 			$content = $this->_pageRender;
247
-			if(! $content){
247
+			if (!$content) {
248 248
 				$logger->warning('The final view content is empty.');
249 249
 				return;
250 250
 			}
251 251
 			//dispatch
252 252
 			$event = $dispatcher->dispatch(new Event('FINAL_VIEW_READY', $content, true));
253
-			$content = ! empty($event->payload) ? $event->payload : null;
254
-			if(empty($content)){
253
+			$content = !empty($event->payload) ? $event->payload : null;
254
+			if (empty($content)) {
255 255
 				$logger->warning('The view content is empty after dispatch to Event Listeners.');
256 256
 			}
257 257
 			
258 258
 			//check whether need save the page into cache.
259
-			if($cachePageStatus){
259
+			if ($cachePageStatus) {
260 260
 				//current page URL
261 261
 				$url = $this->_currentUrl;
262 262
 				//Cache view Time to live in second
@@ -271,14 +271,14 @@  discard block
 block discarded – undo
271 271
 				
272 272
 				//get the cache information to prepare header to send to browser
273 273
 				$cacheInfo = $cacheInstance->getInfo($cacheKey);
274
-				if($cacheInfo){
274
+				if ($cacheInfo) {
275 275
 					$lastModified = $cacheInfo['mtime'];
276 276
 					$expire = $cacheInfo['expire'];
277 277
 					$maxAge = $expire - time();
278 278
 					self::setHeader('Pragma', 'public');
279 279
 					self::setHeader('Cache-Control', 'max-age=' . $maxAge . ', public');
280
-					self::setHeader('Expires', gmdate('D, d M Y H:i:s', $expire).' GMT');
281
-					self::setHeader('Last-modified', gmdate('D, d M Y H:i:s', $lastModified).' GMT');	
280
+					self::setHeader('Expires', gmdate('D, d M Y H:i:s', $expire) . ' GMT');
281
+					self::setHeader('Last-modified', gmdate('D, d M Y H:i:s', $lastModified) . ' GMT');	
282 282
 				}
283 283
 			}
284 284
 			
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
 			$content = str_replace(array('{elapsed_time}', '{memory_usage}'), array($elapsedTime, $memoryUsage), $content);
290 290
 			
291 291
 			//compress the output if is available
292
-			if (self::$_canCompressOutput){
292
+			if (self::$_canCompressOutput) {
293 293
 				ob_start('ob_gzhandler');
294 294
 			}
295
-			else{
295
+			else {
296 296
 				ob_start();
297 297
 			}
298 298
 			self::sendHeaders(200);
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 		/**
304 304
 		* Send the final page output to user if is cached
305 305
 		*/
306
-		public function renderFinalPageFromCache(&$cache){
306
+		public function renderFinalPageFromCache(&$cache) {
307 307
 			$logger = self::getLogger();
308 308
 			$url = $this->_currentUrl;					
309 309
 			//the current page cache key for identification
@@ -312,25 +312,25 @@  discard block
 block discarded – undo
312 312
 			$logger->debug('Checking if the page content for the URL [' . $url . '] is cached ...');
313 313
 			//get the cache information to prepare header to send to browser
314 314
 			$cacheInfo = $cache->getInfo($pageCacheKey);
315
-			if($cacheInfo){
315
+			if ($cacheInfo) {
316 316
 				$lastModified = $cacheInfo['mtime'];
317 317
 				$expire = $cacheInfo['expire'];
318 318
 				$maxAge = $expire - $_SERVER['REQUEST_TIME'];
319 319
 				self::setHeader('Pragma', 'public');
320 320
 				self::setHeader('Cache-Control', 'max-age=' . $maxAge . ', public');
321
-				self::setHeader('Expires', gmdate('D, d M Y H:i:s', $expire).' GMT');
322
-				self::setHeader('Last-modified', gmdate('D, d M Y H:i:s', $lastModified).' GMT');
323
-				if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $lastModified <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])){
321
+				self::setHeader('Expires', gmdate('D, d M Y H:i:s', $expire) . ' GMT');
322
+				self::setHeader('Last-modified', gmdate('D, d M Y H:i:s', $lastModified) . ' GMT');
323
+				if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $lastModified <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
324 324
 					$logger->info('The cache page content is not yet expire for the URL [' . $url . '] send 304 header to browser');
325 325
 					self::sendHeaders(304);
326 326
 					return;
327 327
 				}
328
-				else{
328
+				else {
329 329
 					$logger->info('The cache page content is expired or the browser don\'t send the HTTP_IF_MODIFIED_SINCE header for the URL [' . $url . '] send cache headers to tell the browser');
330 330
 					self::sendHeaders(200);
331 331
 					//get the cache content
332 332
 					$content = $cache->get($pageCacheKey);
333
-					if($content){
333
+					if ($content) {
334 334
 						$logger->info('The page content for the URL [' . $url . '] already cached just display it');
335 335
 						//load benchmark class
336 336
 						$benchmark = & class_loader('Benchmark');
@@ -343,17 +343,17 @@  discard block
 block discarded – undo
343 343
 						
344 344
 						///display the final output
345 345
 						//compress the output if is available
346
-						if (self::$_canCompressOutput){
346
+						if (self::$_canCompressOutput) {
347 347
 							ob_start('ob_gzhandler');
348 348
 						}
349
-						else{
349
+						else {
350 350
 							ob_start();
351 351
 						}
352 352
 						echo $content;
353 353
 						ob_end_flush();
354 354
 						return;
355 355
 					}
356
-					else{
356
+					else {
357 357
 						$logger->info('The page cache content for the URL [' . $url . '] is not valid may be already expired');
358 358
 						$cache->delete($pageCacheKey);
359 359
 					}
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 		* Get the final page to be rendered
366 366
 		* @return string
367 367
 		*/
368
-		public function getFinalPageRendered(){
368
+		public function getFinalPageRendered() {
369 369
 			return $this->_pageRender;
370 370
 		}
371 371
 
@@ -373,14 +373,14 @@  discard block
 block discarded – undo
373 373
 		 * Send the HTTP 404 error if can not found the 
374 374
 		 * routing information for the current request
375 375
 		 */
376
-		public static function send404(){
376
+		public static function send404() {
377 377
 			/********* for logs **************/
378 378
 			//can't use $obj = & get_instance()  here because the global super object will be available until
379 379
 			//the main controller is loaded even for Loader::library('xxxx');
380 380
 			$logger = self::getLogger();
381
-			$request =& class_loader('Request', 'classes');
382
-			$userAgent =& class_loader('Browser');
383
-			$browser = $userAgent->getPlatform().', '.$userAgent->getBrowser().' '.$userAgent->getVersion();
381
+			$request = & class_loader('Request', 'classes');
382
+			$userAgent = & class_loader('Browser');
383
+			$browser = $userAgent->getPlatform() . ', ' . $userAgent->getBrowser() . ' ' . $userAgent->getVersion();
384 384
 			
385 385
 			//here can't use Loader::functions just include the helper manually
386 386
 			require_once CORE_FUNCTIONS_PATH . 'function_user_agent.php';
@@ -390,12 +390,12 @@  discard block
 block discarded – undo
390 390
 			$logger->error($str);
391 391
 			/***********************************/
392 392
 			$path = CORE_VIEWS_PATH . '404.php';
393
-			if(file_exists($path)){
393
+			if (file_exists($path)) {
394 394
 				//compress the output if is available
395
-				if (self::$_canCompressOutput){
395
+				if (self::$_canCompressOutput) {
396 396
 					ob_start('ob_gzhandler');
397 397
 				}
398
-				else{
398
+				else {
399 399
 					ob_start();
400 400
 				}
401 401
 				require_once $path;
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 				self::sendHeaders(404);
404 404
 				echo $output;
405 405
 			}
406
-			else{
407
-				show_error('The 404 view [' .$path. '] does not exist');
406
+			else {
407
+				show_error('The 404 view [' . $path . '] does not exist');
408 408
 			}
409 409
 		}
410 410
 
@@ -412,14 +412,14 @@  discard block
 block discarded – undo
412 412
 		 * Display the error to user
413 413
 		 * @param  array  $data the error information
414 414
 		 */
415
-		public static function sendError(array $data = array()){
415
+		public static function sendError(array $data = array()) {
416 416
 			$path = CORE_VIEWS_PATH . 'errors.php';
417
-			if(file_exists($path)){
417
+			if (file_exists($path)) {
418 418
 				//compress the output if exists
419
-				if (self::$_canCompressOutput){
419
+				if (self::$_canCompressOutput) {
420 420
 					ob_start('ob_gzhandler');
421 421
 				}
422
-				else{
422
+				else {
423 423
 					ob_start();
424 424
 				}
425 425
 				extract($data);
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 				self::sendHeaders(503);
429 429
 				echo $output;
430 430
 			}
431
-			else{
431
+			else {
432 432
 				//can't use show_error() at this time because some dependencies not yet loaded and to prevent loop
433 433
 				set_http_status_header(503);
434 434
 				echo 'The error view [' . $path . '] does not exist';
Please login to merge, or discard this patch.
core/classes/Loader.php 1 patch
Spacing   +114 added lines, -114 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,77 +38,77 @@  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();
45 45
 			
46 46
 			$autoloads = array();
47 47
 			//loading of the resources in autoload.php configuration file
48
-			if(file_exists(CONFIG_PATH . 'autoload.php')){
48
+			if (file_exists(CONFIG_PATH . 'autoload.php')) {
49 49
 				require_once CONFIG_PATH . 'autoload.php';
50
-				if(! empty($autoload) && is_array($autoload)){
50
+				if (!empty($autoload) && is_array($autoload)) {
51 51
 					$autoloads = $autoload;
52 52
 					unset($autoload);
53 53
 				}
54 54
 			}
55 55
 			//loading autoload configuration for modules
56 56
 			$modulesAutoloads = Module::getModulesAutoloadConfig();
57
-			if(! empty($modulesAutoloads) && is_array($modulesAutoloads)){
57
+			if (!empty($modulesAutoloads) && is_array($modulesAutoloads)) {
58 58
 				//libraries autoload
59
-				if(! empty($modulesAutoloads['libraries']) && is_array($modulesAutoloads['libraries'])){
59
+				if (!empty($modulesAutoloads['libraries']) && is_array($modulesAutoloads['libraries'])) {
60 60
 					$autoloads['libraries'] = array_merge($autoloads['libraries'], $modulesAutoloads['libraries']);
61 61
 				}
62 62
 				//config autoload
63
-				if(! empty($modulesAutoloads['config']) && is_array($modulesAutoloads['config'])){
63
+				if (!empty($modulesAutoloads['config']) && is_array($modulesAutoloads['config'])) {
64 64
 					$autoloads['config'] = array_merge($autoloads['config'], $modulesAutoloads['config']);
65 65
 				}
66 66
 				//models autoload
67
-				if(! empty($modulesAutoloads['models']) && is_array($modulesAutoloads['models'])){
67
+				if (!empty($modulesAutoloads['models']) && is_array($modulesAutoloads['models'])) {
68 68
 					$autoloads['models'] = array_merge($autoloads['models'], $modulesAutoloads['models']);
69 69
 				}
70 70
 				//functions autoload
71
-				if(! empty($modulesAutoloads['functions']) && is_array($modulesAutoloads['functions'])){
71
+				if (!empty($modulesAutoloads['functions']) && is_array($modulesAutoloads['functions'])) {
72 72
 					$autoloads['functions'] = array_merge($autoloads['functions'], $modulesAutoloads['functions']);
73 73
 				}
74 74
 				//languages autoload
75
-				if(! empty($modulesAutoloads['languages']) && is_array($modulesAutoloads['languages'])){
75
+				if (!empty($modulesAutoloads['languages']) && is_array($modulesAutoloads['languages'])) {
76 76
 					$autoloads['languages'] = array_merge($autoloads['languages'], $modulesAutoloads['languages']);
77 77
 				}
78 78
 			}
79 79
 			
80 80
 			//config autoload
81
-			if(! empty($autoloads['config']) && is_array($autoloads['config'])){
82
-				foreach($autoloads['config'] as $c){
81
+			if (!empty($autoloads['config']) && is_array($autoloads['config'])) {
82
+				foreach ($autoloads['config'] as $c) {
83 83
 					$this->config($c);
84 84
 				}
85 85
 			}
86 86
 			
87 87
 			//languages autoload
88
-			if(! empty($autoloads['languages']) && is_array($autoloads['languages'])){
89
-				foreach($autoloads['languages'] as $language){
88
+			if (!empty($autoloads['languages']) && is_array($autoloads['languages'])) {
89
+				foreach ($autoloads['languages'] as $language) {
90 90
 					$this->lang($language);
91 91
 				}
92 92
 			}
93 93
 			
94 94
 			//libraries autoload
95
-			if(! empty($autoloads['libraries']) && is_array($autoloads['libraries'])){
96
-				foreach($autoloads['libraries'] as $library){
95
+			if (!empty($autoloads['libraries']) && is_array($autoloads['libraries'])) {
96
+				foreach ($autoloads['libraries'] as $library) {
97 97
 					$this->library($library);
98 98
 				}
99 99
 			}
100 100
 			
101 101
 			//models autoload
102
-			if(! empty($autoloads['models']) && is_array($autoloads['models'])){
102
+			if (!empty($autoloads['models']) && is_array($autoloads['models'])) {
103 103
 				require_once CORE_CLASSES_MODEL_PATH . 'Model.php';
104
-				foreach($autoloads['models'] as $model){
104
+				foreach ($autoloads['models'] as $model) {
105 105
 					$this->model($model);
106 106
 				}
107 107
 			}
108 108
 			
109 109
 			//functions autoload
110
-			if(! empty($autoloads['functions']) && is_array($autoloads['functions'])){
111
-				foreach($autoloads['functions'] as $function){
110
+			if (!empty($autoloads['functions']) && is_array($autoloads['functions'])) {
111
+				foreach ($autoloads['functions'] as $function) {
112 112
 					$this->functions($function);
113 113
 				}
114 114
 			}
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
 		 * Get the logger singleton instance
120 120
 		 * @return Log the logger instance
121 121
 		 */
122
-		private static function getLogger(){
123
-			if(self::$logger == null){
124
-				self::$logger[0] =& class_loader('Log', 'classes');
122
+		private static function getLogger() {
123
+			if (self::$logger == null) {
124
+				self::$logger[0] = & class_loader('Log', 'classes');
125 125
 				self::$logger[0]->setLogger('Library::Loader');
126 126
 			}
127 127
 			return self::$logger[0];
@@ -135,25 +135,25 @@  discard block
 block discarded – undo
135 135
 		 *
136 136
 		 * @return void
137 137
 		 */
138
-		public static function model($class, $instance = null){
138
+		public static function model($class, $instance = null) {
139 139
 			$logger = static::getLogger();
140 140
 			$class = str_ireplace('.php', '', $class);
141 141
 			$class = trim($class, '/\\');
142
-			$file = ucfirst($class).'.php';
142
+			$file = ucfirst($class) . '.php';
143 143
 			$logger->debug('Loading model [' . $class . '] ...');
144
-			if(! $instance){
144
+			if (!$instance) {
145 145
 				//for module
146
-				if(strpos($class, '/') !== false){
146
+				if (strpos($class, '/') !== false) {
147 147
 					$path = explode('/', $class);
148
-					if(isset($path[1])){
148
+					if (isset($path[1])) {
149 149
 						$instance = strtolower($path[1]);
150 150
 					}
151 151
 				}
152
-				else{
152
+				else {
153 153
 					$instance = strtolower($class);
154 154
 				}
155 155
 			}
156
-			if(isset(static::$loaded[$instance])){
156
+			if (isset(static::$loaded[$instance])) {
157 157
 				$logger->info('Model [' . $class . '] already loaded no need to load it again, cost in performance');
158 158
 				return;
159 159
 			}
@@ -163,43 +163,43 @@  discard block
 block discarded – undo
163 163
 			$searchModuleName = null;
164 164
 			$obj = & get_instance();
165 165
 			//check if the request class contains module name
166
-			if(strpos($class, '/') !== false){
166
+			if (strpos($class, '/') !== false) {
167 167
 				$path = explode('/', $class);
168
-				if(isset($path[0]) && in_array($path[0], Module::getModuleList())){
168
+				if (isset($path[0]) && in_array($path[0], Module::getModuleList())) {
169 169
 					$searchModuleName = $path[0];
170 170
 					$class = ucfirst($path[1]);
171 171
 				}
172 172
 			}
173
-			else{
173
+			else {
174 174
 				$class = ucfirst($class);
175 175
 			}
176 176
 
177
-			if(! $searchModuleName && !empty($obj->moduleName)){
177
+			if (!$searchModuleName && !empty($obj->moduleName)) {
178 178
 				$searchModuleName = $obj->moduleName;
179 179
 			}
180 180
 			$moduleModelFilePath = Module::findModelFullPath($class, $searchModuleName);
181
-			if($moduleModelFilePath){
182
-				$logger->info('Found model [' . $class . '] from module [' .$searchModuleName. '], the file path is [' .$moduleModelFilePath. '] we will used it');
181
+			if ($moduleModelFilePath) {
182
+				$logger->info('Found model [' . $class . '] from module [' . $searchModuleName . '], the file path is [' . $moduleModelFilePath . '] we will used it');
183 183
 				$classFilePath = $moduleModelFilePath;
184 184
 			}
185
-			else{
185
+			else {
186 186
 				$logger->info('Cannot find model [' . $class . '] from modules using the default location');
187 187
 			}
188 188
 			$logger->info('The model file path to be loaded is [' . $classFilePath . ']');
189
-			if(file_exists($classFilePath)){
189
+			if (file_exists($classFilePath)) {
190 190
 				require_once $classFilePath;
191
-				if(class_exists($class)){
191
+				if (class_exists($class)) {
192 192
 					$c = new $class();
193 193
 					$obj = & get_instance();
194 194
 					$obj->{$instance} = $c;
195 195
 					static::$loaded[$instance] = $class;
196 196
 					$logger->info('Model [' . $class . '] --> ' . $classFilePath . ' loaded successfully.');
197 197
 				}
198
-				else{
199
-					show_error('The file '.$classFilePath.' exists but does not contain the class ['. $class . ']');
198
+				else {
199
+					show_error('The file ' . $classFilePath . ' exists but does not contain the class [' . $class . ']');
200 200
 				}
201 201
 			}
202
-			else{
202
+			else {
203 203
 				show_error('Unable to find the model [' . $class . ']');
204 204
 			}
205 205
 		}
@@ -214,31 +214,31 @@  discard block
 block discarded – undo
214 214
 		 *
215 215
 		 * @return void
216 216
 		 */
217
-		public static function library($class, $instance = null, array $params = array()){
217
+		public static function library($class, $instance = null, array $params = array()) {
218 218
 			$logger = static::getLogger();
219 219
 			$class = str_ireplace('.php', '', $class);
220 220
 			$class = trim($class, '/\\');
221
-			$file = ucfirst($class) .'.php';
221
+			$file = ucfirst($class) . '.php';
222 222
 			$logger->debug('Loading library [' . $class . '] ...');
223
-			if(! $instance){
223
+			if (!$instance) {
224 224
 				//for module
225
-				if(strpos($class, '/') !== false){
225
+				if (strpos($class, '/') !== false) {
226 226
 					$path = explode('/', $class);
227
-					if(isset($path[1])){
227
+					if (isset($path[1])) {
228 228
 						$instance = strtolower($path[1]);
229 229
 					}
230 230
 				}
231
-				else{
231
+				else {
232 232
 					$instance = strtolower($class);
233 233
 				}
234 234
 			}
235
-			if(isset(static::$loaded[$instance])){
235
+			if (isset(static::$loaded[$instance])) {
236 236
 				$logger->info('Library [' . $class . '] already loaded no need to load it again, cost in performance');
237 237
 				return;
238 238
 			}
239 239
 			$obj = & get_instance();
240 240
 			//TODO for Database library
241
-			if(strtolower($class) == 'database'){
241
+			if (strtolower($class) == 'database') {
242 242
 				$logger->info('This is the Database library ...');
243 243
 				$dbInstance = & class_loader('Database', 'classes', $params);
244 244
 				$obj->{$instance} = $dbInstance;
@@ -248,44 +248,44 @@  discard block
 block discarded – undo
248 248
 			}
249 249
 			$libraryFilePath = null;
250 250
 			$logger->debug('Check if this is a system library ...');
251
-			if(file_exists(CORE_LIBRARY_PATH . $file)){
251
+			if (file_exists(CORE_LIBRARY_PATH . $file)) {
252 252
 				$libraryFilePath = CORE_LIBRARY_PATH . $file;
253 253
 				$class = ucfirst($class);
254 254
 				$logger->info('This library is a system library');
255 255
 			}
256
-			else{
256
+			else {
257 257
 				$logger->info('This library is not a system library');	
258 258
 				//first check if this library is in the module
259 259
 				$logger->debug('Checking library [' . $class . '] from module list ...');
260 260
 				$searchModuleName = null;
261 261
 				//check if the request class contains module name
262
-				if(strpos($class, '/') !== false){
262
+				if (strpos($class, '/') !== false) {
263 263
 					$path = explode('/', $class);
264
-					if(isset($path[0]) && in_array($path[0], Module::getModuleList())){
264
+					if (isset($path[0]) && in_array($path[0], Module::getModuleList())) {
265 265
 						$searchModuleName = $path[0];
266 266
 						$class = ucfirst($path[1]);
267 267
 					}
268 268
 				}
269
-				else{
269
+				else {
270 270
 					$class = ucfirst($class);
271 271
 				}
272
-				if(! $searchModuleName && !empty($obj->moduleName)){
272
+				if (!$searchModuleName && !empty($obj->moduleName)) {
273 273
 					$searchModuleName = $obj->moduleName;
274 274
 				}
275 275
 				$moduleLibraryPath = Module::findLibraryFullPath($class, $searchModuleName);
276
-				if($moduleLibraryPath){
277
-					$logger->info('Found library [' . $class . '] from module [' .$searchModuleName. '], the file path is [' .$moduleLibraryPath. '] we will used it');
276
+				if ($moduleLibraryPath) {
277
+					$logger->info('Found library [' . $class . '] from module [' . $searchModuleName . '], the file path is [' . $moduleLibraryPath . '] we will used it');
278 278
 					$libraryFilePath = $moduleLibraryPath;
279 279
 				}
280
-				else{
280
+				else {
281 281
 					$logger->info('Cannot find library [' . $class . '] from modules using the default location');
282 282
 				}
283 283
 			}
284
-			if(! $libraryFilePath){
284
+			if (!$libraryFilePath) {
285 285
 				$searchDir = array(LIBRARY_PATH);
286
-				foreach($searchDir as $dir){
286
+				foreach ($searchDir as $dir) {
287 287
 					$filePath = $dir . $file;
288
-					if(file_exists($filePath)){
288
+					if (file_exists($filePath)) {
289 289
 						$libraryFilePath = $filePath;
290 290
 						//is already found not to continue
291 291
 						break;
@@ -293,20 +293,20 @@  discard block
 block discarded – undo
293 293
 				}
294 294
 			}
295 295
 			$logger->info('The library file path to be loaded is [' . $libraryFilePath . ']');
296
-			if($libraryFilePath){
296
+			if ($libraryFilePath) {
297 297
 				require_once $libraryFilePath;
298
-				if(class_exists($class)){
298
+				if (class_exists($class)) {
299 299
 					$c = $params ? new $class($params) : new $class();
300 300
 					$obj = & get_instance();
301 301
 					$obj->{$instance} = $c;
302 302
 					static::$loaded[$instance] = $class;
303 303
 					$logger->info('Library [' . $class . '] --> ' . $libraryFilePath . ' loaded successfully.');
304 304
 				}
305
-				else{
306
-					show_error('The file '.$libraryFilePath.' exists but does not contain the class '.$class);
305
+				else {
306
+					show_error('The file ' . $libraryFilePath . ' exists but does not contain the class ' . $class);
307 307
 				}
308 308
 			}
309
-			else{
309
+			else {
310 310
 				show_error('Unable to find library class [' . $class . ']');
311 311
 			}
312 312
 		}
@@ -318,14 +318,14 @@  discard block
 block discarded – undo
318 318
 		 *
319 319
 		 * @return void
320 320
 		 */
321
-		public static function functions($function){
321
+		public static function functions($function) {
322 322
 			$logger = static::getLogger();
323 323
 			$function = str_ireplace('.php', '', $function);
324 324
 			$function = trim($function, '/\\');
325 325
 			$function = str_ireplace('function_', '', $function);
326
-			$file = 'function_'.$function.'.php';
326
+			$file = 'function_' . $function . '.php';
327 327
 			$logger->debug('Loading helper [' . $function . '] ...');
328
-			if(isset(static::$loaded['function_' . $function])){
328
+			if (isset(static::$loaded['function_' . $function])) {
329 329
 				$logger->info('Helper [' . $function . '] already loaded no need to load it again, cost in performance');
330 330
 				return;
331 331
 			}
@@ -335,30 +335,30 @@  discard block
 block discarded – undo
335 335
 			$searchModuleName = null;
336 336
 			$obj = & get_instance();
337 337
 			//check if the request class contains module name
338
-			if(strpos($function, '/') !== false){
338
+			if (strpos($function, '/') !== false) {
339 339
 				$path = explode('/', $function);
340
-				if(isset($path[0]) && in_array($path[0], Module::getModuleList())){
340
+				if (isset($path[0]) && in_array($path[0], Module::getModuleList())) {
341 341
 					$searchModuleName = $path[0];
342 342
 					$function = 'function_' . $path[1] . '.php';
343
-					$file = $path[0] . DS . 'function_'.$function.'.php';
343
+					$file = $path[0] . DS . 'function_' . $function . '.php';
344 344
 				}
345 345
 			}
346
-			if(! $searchModuleName && !empty($obj->moduleName)){
346
+			if (!$searchModuleName && !empty($obj->moduleName)) {
347 347
 				$searchModuleName = $obj->moduleName;
348 348
 			}
349 349
 			$moduleFunctionPath = Module::findFunctionFullPath($function, $searchModuleName);
350
-			if($moduleFunctionPath){
351
-				$logger->info('Found helper [' . $function . '] from module [' .$searchModuleName. '], the file path is [' .$moduleFunctionPath. '] we will used it');
350
+			if ($moduleFunctionPath) {
351
+				$logger->info('Found helper [' . $function . '] from module [' . $searchModuleName . '], the file path is [' . $moduleFunctionPath . '] we will used it');
352 352
 				$functionFilePath = $moduleFunctionPath;
353 353
 			}
354
-			else{
354
+			else {
355 355
 				$logger->info('Cannot find helper [' . $function . '] from modules using the default location');
356 356
 			}
357
-			if(! $functionFilePath){
357
+			if (!$functionFilePath) {
358 358
 				$searchDir = array(FUNCTIONS_PATH, CORE_FUNCTIONS_PATH);
359
-				foreach($searchDir as $dir){
359
+				foreach ($searchDir as $dir) {
360 360
 					$filePath = $dir . $file;
361
-					if(file_exists($filePath)){
361
+					if (file_exists($filePath)) {
362 362
 						$functionFilePath = $filePath;
363 363
 						//is already found not to continue
364 364
 						break;
@@ -366,12 +366,12 @@  discard block
 block discarded – undo
366 366
 				}
367 367
 			}
368 368
 			$logger->info('The helper file path to be loaded is [' . $functionFilePath . ']');
369
-			if($functionFilePath){
369
+			if ($functionFilePath) {
370 370
 				require_once $functionFilePath;
371 371
 				static::$loaded['function_' . $function] = $functionFilePath;
372 372
 				$logger->info('Helper [' . $function . '] --> ' . $functionFilePath . ' loaded successfully.');
373 373
 			}
374
-			else{
374
+			else {
375 375
 				show_error('Unable to find helper file [' . $file . ']');
376 376
 			}
377 377
 		}
@@ -383,14 +383,14 @@  discard block
 block discarded – undo
383 383
 		 *
384 384
 		 * @return void
385 385
 		 */
386
-		public static function config($filename){
386
+		public static function config($filename) {
387 387
 			$logger = static::getLogger();
388 388
 			$filename = str_ireplace('.php', '', $filename);
389 389
 			$filename = trim($filename, '/\\');
390 390
 			$filename = str_ireplace('config_', '', $filename);
391
-			$file = 'config_'.$filename.'.php';
391
+			$file = 'config_' . $filename . '.php';
392 392
 			$logger->debug('Loading configuration [' . $filename . '] ...');
393
-			if(isset(static::$loaded['config_' . $filename])){
393
+			if (isset(static::$loaded['config_' . $filename])) {
394 394
 				$logger->info('Configuration [' . $file . '] already loaded no need to load it again, cost in performance');
395 395
 				return;
396 396
 			}
@@ -400,33 +400,33 @@  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($filename, '/') !== false){
403
+			if (strpos($filename, '/') !== false) {
404 404
 				$path = explode('/', $filename);
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
 					$filename = $path[1] . '.php';
408 408
 				}
409 409
 			}
410
-			if(! $searchModuleName && !empty($obj->moduleName)){
410
+			if (!$searchModuleName && !empty($obj->moduleName)) {
411 411
 				$searchModuleName = $obj->moduleName;
412 412
 			}
413 413
 			$moduleConfigPath = Module::findConfigFullPath($filename, $searchModuleName);
414
-			if($moduleConfigPath){
415
-				$logger->info('Found config [' . $filename . '] from module [' .$searchModuleName. '], the file path is [' .$moduleConfigPath. '] we will used it');
414
+			if ($moduleConfigPath) {
415
+				$logger->info('Found config [' . $filename . '] from module [' . $searchModuleName . '], the file path is [' . $moduleConfigPath . '] we will used it');
416 416
 				$configFilePath = $moduleConfigPath;
417 417
 			}
418
-			else{
418
+			else {
419 419
 				$logger->info('Cannot find config [' . $filename . '] from modules using the default location');
420 420
 			}
421 421
 			$logger->info('The config file path to be loaded is [' . $configFilePath . ']');
422
-			if(file_exists($configFilePath)){
422
+			if (file_exists($configFilePath)) {
423 423
 				require_once $configFilePath;
424
-				if(! empty($config) && is_array($config)){
424
+				if (!empty($config) && is_array($config)) {
425 425
 					Config::setAll($config);
426 426
 				}
427 427
 			}
428
-			else{
429
-				show_error('Unable to find config file ['. $configFilePath . ']');
428
+			else {
429
+				show_error('Unable to find config file [' . $configFilePath . ']');
430 430
 			}
431 431
 			static::$loaded['config_' . $filename] = $configFilePath;
432 432
 			$logger->info('Configuration [' . $configFilePath . '] loaded successfully.');
@@ -442,14 +442,14 @@  discard block
 block discarded – undo
442 442
 		 *
443 443
 		 * @return void
444 444
 		 */
445
-		public static function lang($language){
445
+		public static function lang($language) {
446 446
 			$logger = static::getLogger();
447 447
 			$language = str_ireplace('.php', '', $language);
448 448
 			$language = trim($language, '/\\');
449 449
 			$language = str_ireplace('lang_', '', $language);
450
-			$file = 'lang_'.$language.'.php';
450
+			$file = 'lang_' . $language . '.php';
451 451
 			$logger->debug('Loading language [' . $language . '] ...');
452
-			if(isset(static::$loaded['lang_' . $language])){
452
+			if (isset(static::$loaded['lang_' . $language])) {
453 453
 				$logger->info('Language [' . $language . '] already loaded no need to load it again, cost in performance');
454 454
 				return;
455 455
 			}
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 			$cfgKey = get_config('language_cookie_name');
460 460
 			$objCookie = & class_loader('Cookie');
461 461
 			$cookieLang = $objCookie->get($cfgKey);
462
-			if($cookieLang){
462
+			if ($cookieLang) {
463 463
 				$appLang = $cookieLang;
464 464
 			}
465 465
 			$languageFilePath = null;
@@ -468,30 +468,30 @@  discard block
 block discarded – undo
468 468
 			$searchModuleName = null;
469 469
 			$obj = & get_instance();
470 470
 			//check if the request class contains module name
471
-			if(strpos($language, '/') !== false){
471
+			if (strpos($language, '/') !== false) {
472 472
 				$path = explode('/', $language);
473
-				if(isset($path[0]) && in_array($path[0], Module::getModuleList())){
473
+				if (isset($path[0]) && in_array($path[0], Module::getModuleList())) {
474 474
 					$searchModuleName = $path[0];
475 475
 					$language = 'lang_' . $path[1] . '.php';
476
-					$file = $path[0] . DS .$language;
476
+					$file = $path[0] . DS . $language;
477 477
 				}
478 478
 			}
479
-			if(! $searchModuleName && !empty($obj->moduleName)){
479
+			if (!$searchModuleName && !empty($obj->moduleName)) {
480 480
 				$searchModuleName = $obj->moduleName;
481 481
 			}
482 482
 			$moduleLanguagePath = Module::findLanguageFullPath($language, $searchModuleName, $appLang);
483
-			if($moduleLanguagePath){
484
-				$logger->info('Found language [' . $language . '] from module [' .$searchModuleName. '], the file path is [' .$moduleLanguagePath. '] we will used it');
483
+			if ($moduleLanguagePath) {
484
+				$logger->info('Found language [' . $language . '] from module [' . $searchModuleName . '], the file path is [' . $moduleLanguagePath . '] we will used it');
485 485
 				$languageFilePath = $moduleLanguagePath;
486 486
 			}
487
-			else{
487
+			else {
488 488
 				$logger->info('Cannot find language [' . $language . '] from modules using the default location');
489 489
 			}
490
-			if(! $languageFilePath){
490
+			if (!$languageFilePath) {
491 491
 				$searchDir = array(APP_LANG_PATH, CORE_LANG_PATH);
492
-				foreach($searchDir as $dir){
492
+				foreach ($searchDir as $dir) {
493 493
 					$filePath = $dir . $appLang . DS . $file;
494
-					if(file_exists($filePath)){
494
+					if (file_exists($filePath)) {
495 495
 						$languageFilePath = $filePath;
496 496
 						//is already found not to continue
497 497
 						break;
@@ -499,12 +499,12 @@  discard block
 block discarded – undo
499 499
 				}
500 500
 			}
501 501
 			$logger->info('The language file path to be loaded is [' . $languageFilePath . ']');
502
-			if($languageFilePath){
502
+			if ($languageFilePath) {
503 503
 				require_once $languageFilePath;
504
-				if(! empty($lang) && is_array($lang)){
505
-					$logger->info('Language file  [' .$languageFilePath. '] contains the valid languages keys add them to language list');
504
+				if (!empty($lang) && is_array($lang)) {
505
+					$logger->info('Language file  [' . $languageFilePath . '] contains the valid languages keys add them to language list');
506 506
 					//Note: may be here the class 'Lang' not yet loaded
507
-					$langObj =& class_loader('Lang', 'classes');
507
+					$langObj = & class_loader('Lang', 'classes');
508 508
 					$langObj->addLangMessages($lang);
509 509
 					//free the memory
510 510
 					unset($lang);
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 				static::$loaded['lang_' . $language] = $languageFilePath;
513 513
 				$logger->info('Language [' . $language . '] --> ' . $languageFilePath . ' loaded successfully.');
514 514
 			}
515
-			else{
515
+			else {
516 516
 				show_error('Unable to find language file [' . $file . ']');
517 517
 			}
518 518
 		}
Please login to merge, or discard this patch.
core/classes/Router.php 1 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.
core/classes/Log.php 1 patch
Spacing   +36 added lines, -36 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 Log{
27
+	class Log {
28 28
 		
29 29
 		/**
30 30
 		 * The defined constante for Log level
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
 		/**
53 53
 		 * Create new Log instance
54 54
 		 */
55
-		public function __construct(){
55
+		public function __construct() {
56 56
 		}
57 57
 
58 58
 		/**
59 59
 		 * Set the logger to identify each message in the log
60 60
 		 * @param string $logger the logger name
61 61
 		 */
62
-		public  function setLogger($logger){
62
+		public  function setLogger($logger) {
63 63
 			$this->logger = $logger;
64 64
 		}
65 65
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		 * @see Log::writeLog for more detail
69 69
 		 * @param  string $message the log message to save
70 70
 		 */
71
-		public function fatal($message){
71
+		public function fatal($message) {
72 72
 			$this->writeLog($message, self::FATAL);
73 73
 		} 
74 74
 		
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		 * @see Log::writeLog for more detail
78 78
 		 * @param  string $message the log message to save
79 79
 		 */
80
-		public function error($message){
80
+		public function error($message) {
81 81
 			$this->writeLog($message, self::ERROR);
82 82
 		} 
83 83
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		 * @see Log::writeLog for more detail
87 87
 		 * @param  string $message the log message to save
88 88
 		 */
89
-		public function warning($message){
89
+		public function warning($message) {
90 90
 			$this->writeLog($message, self::WARNING);
91 91
 		} 
92 92
 		
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		 * @see Log::writeLog for more detail
96 96
 		 * @param  string $message the log message to save
97 97
 		 */
98
-		public function info($message){
98
+		public function info($message) {
99 99
 			$this->writeLog($message, self::INFO);
100 100
 		} 
101 101
 		
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 		 * @see Log::writeLog for more detail
105 105
 		 * @param  string $message the log message to save
106 106
 		 */
107
-		public function debug($message){
107
+		public function debug($message) {
108 108
 			$this->writeLog($message, self::DEBUG);
109 109
 		} 
110 110
 		
@@ -115,59 +115,59 @@  discard block
 block discarded – undo
115 115
 		 * @param  integer|string $level   the log level in integer or string format, if is string will convert into integer
116 116
 		 * to allow check the log level threshold.
117 117
 		 */
118
-		public function writeLog($message, $level = self::INFO){
118
+		public function writeLog($message, $level = self::INFO) {
119 119
 			$configLogLevel = get_config('log_level');
120
-			if(! $configLogLevel){
120
+			if (!$configLogLevel) {
121 121
 				//so means no need log just stop here
122 122
 				return;
123 123
 			}
124 124
 			//check config log level
125
-			if(! self::isValidConfigLevel($configLogLevel)){
125
+			if (!self::isValidConfigLevel($configLogLevel)) {
126 126
 				//NOTE: here need put the show_error() "logging" to false to prevent loop
127 127
 				show_error('Invalid config log level [' . $configLogLevel . '], the value must be one of the following: ' . implode(', ', array_map('strtoupper', self::$validConfigLevel)), $title = 'Log Config Error', $logging = false);	
128 128
 			}
129 129
 			
130 130
 			//check if config log_logger_name is set
131
-			if($this->logger){
131
+			if ($this->logger) {
132 132
 				$configLoggerName = get_config('log_logger_name', '');
133
-				if($configLoggerName){
134
-					if (is_array($configLoggerName)){
133
+				if ($configLoggerName) {
134
+					if (is_array($configLoggerName)) {
135 135
 						//for best comparaison put all string to lowercase
136 136
 						$configLoggerName = array_map('strtolower', $configLoggerName);
137
-						if(! in_array(strtolower($this->logger), $configLoggerName)){
137
+						if (!in_array(strtolower($this->logger), $configLoggerName)) {
138 138
 							return;
139 139
 						}
140 140
 					}
141
-					else if(strtolower($this->logger) !== strtolower($configLoggerName)){
141
+					else if (strtolower($this->logger) !== strtolower($configLoggerName)) {
142 142
 						return; 
143 143
 					}
144 144
 				}
145 145
 			}
146 146
 			
147 147
 			//if $level is not an integer
148
-			if(! is_numeric($level)){
148
+			if (!is_numeric($level)) {
149 149
 				$level = self::getLevelValue($level);
150 150
 			}
151 151
 			
152 152
 			//check if can logging regarding the log level config
153 153
 			$configLevel = self::getLevelValue($configLogLevel);
154
-			if($configLevel > $level){
154
+			if ($configLevel > $level) {
155 155
 				//can't log
156 156
 				return;
157 157
 			}
158 158
 			
159 159
 			$logSavePath = get_config('log_save_path');
160
-			if(! $logSavePath){
160
+			if (!$logSavePath) {
161 161
 				$logSavePath = LOGS_PATH;
162 162
 			}
163 163
 			
164
-			if(! is_dir($logSavePath) || !is_writable($logSavePath)){
164
+			if (!is_dir($logSavePath) || !is_writable($logSavePath)) {
165 165
 				//NOTE: here need put the show_error() "logging" to false to prevent loop
166 166
 				show_error('Error : the log dir does not exists or is not writable', $title = 'Log directory error', $logging = false);
167 167
 			}
168 168
 			
169 169
 			$path = $logSavePath . 'logs-' . date('Y-m-d') . '.log';
170
-			if(! file_exists($path)){
170
+			if (!file_exists($path)) {
171 171
 				touch($path);
172 172
 			}
173 173
 			//may be at this time helper user_agent not yet included
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 			
190 190
 			$str = $logDate . ' [' . str_pad($levelName, 7 /*warning len*/) . '] ' . ' [' . str_pad($ip, 15) . '] ' . $this->logger . ' : ' . $message . ' ' . '[' . $fileInfo['file'] . '::' . $fileInfo['line'] . ']' . "\n";
191 191
 			$fp = fopen($path, 'a+');
192
-			if(is_resource($fp)){
192
+			if (is_resource($fp)) {
193 193
 				flock($fp, LOCK_EX); // exclusive lock, will get released when the file is closed
194 194
 				fwrite($fp, $str);
195 195
 				fclose($fp);
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		 *
204 204
 		 * @return boolean        true if the given log level is valid, false if not
205 205
 		 */
206
-		private static function isValidConfigLevel($level){
206
+		private static function isValidConfigLevel($level) {
207 207
 			$level = strtolower($level);
208 208
 			return in_array($level, self::$validConfigLevel);
209 209
 		}
@@ -213,27 +213,27 @@  discard block
 block discarded – undo
213 213
 		 * @param  string $level the log level in string format
214 214
 		 * @return int        the log level in integer format using the predefinied constants
215 215
 		 */
216
-		private static function getLevelValue($level){
216
+		private static function getLevelValue($level) {
217 217
 			$level = strtolower($level);
218 218
 			$value = self::NONE;
219 219
 			
220 220
 			//the default value is NONE, so means no need test for NONE
221
-			if($level == 'fatal'){
221
+			if ($level == 'fatal') {
222 222
 				$value = self::FATAL;
223 223
 			}
224
-			else if($level == 'error'){
224
+			else if ($level == 'error') {
225 225
 				$value = self::ERROR;
226 226
 			}
227
-			else if($level == 'warning' || $level == 'warn'){
227
+			else if ($level == 'warning' || $level == 'warn') {
228 228
 				$value = self::WARNING;
229 229
 			}
230
-			else if($level == 'info'){
230
+			else if ($level == 'info') {
231 231
 				$value = self::INFO;
232 232
 			}
233
-			else if($level == 'debug'){
233
+			else if ($level == 'debug') {
234 234
 				$value = self::DEBUG;
235 235
 			}
236
-			else if($level == 'all'){
236
+			else if ($level == 'all') {
237 237
 				$value = self::ALL;
238 238
 			}
239 239
 			return $value;
@@ -244,23 +244,23 @@  discard block
 block discarded – undo
244 244
 		 * @param  integer $level the log level in integer format
245 245
 		 * @return string        the log level in string format
246 246
 		 */
247
-		private static function getLevelName($level){
247
+		private static function getLevelName($level) {
248 248
 			$value = '';
249 249
 			
250 250
 			//the default value is NONE, so means no need test for NONE
251
-			if($level == self::FATAL){
251
+			if ($level == self::FATAL) {
252 252
 				$value = 'FATAL';
253 253
 			}
254
-			else if($level == self::ERROR){
254
+			else if ($level == self::ERROR) {
255 255
 				$value = 'ERROR';
256 256
 			}
257
-			else if($level == self::WARNING){
257
+			else if ($level == self::WARNING) {
258 258
 				$value = 'WARNING';
259 259
 			}
260
-			else if($level == self::INFO){
260
+			else if ($level == self::INFO) {
261 261
 				$value = 'INFO';
262 262
 			}
263
-			else if($level == self::DEBUG){
263
+			else if ($level == self::DEBUG) {
264 264
 				$value = 'DEBUG';
265 265
 			}
266 266
 			//no need for ALL
Please login to merge, or discard this patch.
core/classes/Lang.php 1 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/Database.php 1 patch
Spacing   +256 added lines, -256 removed lines patch added patch discarded remove patch
@@ -23,158 +23,158 @@  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 Database{
26
+  class Database {
27 27
 	
28 28
 	/**
29 29
 	 * The PDO instance
30 30
 	 * @var object
31 31
 	*/
32
-    private $pdo                 = null;
32
+    private $pdo = null;
33 33
     
34 34
 	/**
35 35
 	 * The database name used for the application
36 36
 	 * @var string
37 37
 	*/
38
-	private $databaseName        = null;
38
+	private $databaseName = null;
39 39
     
40 40
 	/**
41 41
 	 * The SQL SELECT statment
42 42
 	 * @var string
43 43
 	*/
44
-	private $select              = '*';
44
+	private $select = '*';
45 45
 	
46 46
 	/**
47 47
 	 * The SQL FROM statment
48 48
 	 * @var string
49 49
 	*/
50
-    private $from                = null;
50
+    private $from = null;
51 51
 	
52 52
 	/**
53 53
 	 * The SQL WHERE statment
54 54
 	 * @var string
55 55
 	*/
56
-    private $where               = null;
56
+    private $where = null;
57 57
 	
58 58
 	/**
59 59
 	 * The SQL LIMIT statment
60 60
 	 * @var string
61 61
 	*/
62
-    private $limit               = null;
62
+    private $limit = null;
63 63
 	
64 64
 	/**
65 65
 	 * The SQL JOIN statment
66 66
 	 * @var string
67 67
 	*/
68
-    private $join                = null;
68
+    private $join = null;
69 69
 	
70 70
 	/**
71 71
 	 * The SQL ORDER BY statment
72 72
 	 * @var string
73 73
 	*/
74
-    private $orderBy             = null;
74
+    private $orderBy = null;
75 75
 	
76 76
 	/**
77 77
 	 * The SQL GROUP BY statment
78 78
 	 * @var string
79 79
 	*/
80
-    private $groupBy             = null;
80
+    private $groupBy = null;
81 81
 	
82 82
 	/**
83 83
 	 * The SQL HAVING statment
84 84
 	 * @var string
85 85
 	*/
86
-    private $having              = null;
86
+    private $having = null;
87 87
 	
88 88
 	/**
89 89
 	 * The number of rows returned by the last query
90 90
 	 * @var int
91 91
 	*/
92
-    private $numRows             = 0;
92
+    private $numRows = 0;
93 93
 	
94 94
 	/**
95 95
 	 * The last insert id for the primary key column that have auto increment or sequence
96 96
 	 * @var mixed
97 97
 	*/
98
-    private $insertId            = null;
98
+    private $insertId = null;
99 99
 	
100 100
 	/**
101 101
 	 * The full SQL query statment after build for each command
102 102
 	 * @var string
103 103
 	*/
104
-    private $query               = null;
104
+    private $query = null;
105 105
 	
106 106
 	/**
107 107
 	 * The error returned for the last query
108 108
 	 * @var string
109 109
 	*/
110
-    private $error               = null;
110
+    private $error = null;
111 111
 	
112 112
 	/**
113 113
 	 * The result returned for the last query
114 114
 	 * @var mixed
115 115
 	*/
116
-    private $result              = array();
116
+    private $result = array();
117 117
 	
118 118
 	/**
119 119
 	 * The prefix used in each database table
120 120
 	 * @var string
121 121
 	*/
122
-    private $prefix              = null;
122
+    private $prefix = null;
123 123
 	
124 124
 	/**
125 125
 	 * The list of SQL valid operators
126 126
 	 * @var array
127 127
 	*/
128
-    private $operatorList        = array('=','!=','<','>','<=','>=','<>');
128
+    private $operatorList = array('=', '!=', '<', '>', '<=', '>=', '<>');
129 129
     
130 130
 	/**
131 131
 	 * The cache default time to live in second. 0 means no need to use the cache feature
132 132
 	 * @var int
133 133
 	*/
134
-	private $cacheTtl              = 0;
134
+	private $cacheTtl = 0;
135 135
 	
136 136
 	/**
137 137
 	 * The cache current time to live. 0 means no need to use the cache feature
138 138
 	 * @var int
139 139
 	*/
140
-    private $temporaryCacheTtl   = 0;
140
+    private $temporaryCacheTtl = 0;
141 141
 	
142 142
 	/**
143 143
 	 * The number of executed query for the current request
144 144
 	 * @var int
145 145
 	*/
146
-    private $queryCount          = 0;
146
+    private $queryCount = 0;
147 147
 	
148 148
 	/**
149 149
 	 * The default data to be used in the statments query INSERT, UPDATE
150 150
 	 * @var array
151 151
 	*/
152
-    private $data                = array();
152
+    private $data = array();
153 153
 	
154 154
 	/**
155 155
 	 * The database configuration
156 156
 	 * @var array
157 157
 	*/
158
-    private $config              = array();
158
+    private $config = array();
159 159
 	
160 160
 	/**
161 161
 	 * The logger instance
162 162
 	 * @var Log
163 163
 	 */
164
-    private $logger              = null;
164
+    private $logger = null;
165 165
 
166 166
 
167 167
     /**
168 168
     * The cache instance
169 169
     * @var CacheInterface
170 170
     */
171
-    private $cacheInstance       = null;
171
+    private $cacheInstance = null;
172 172
 
173 173
      /**
174 174
     * The benchmark instance
175 175
     * @var Benchmark
176 176
     */
177
-    private $benchmarkInstance   = null;
177
+    private $benchmarkInstance = null;
178 178
 
179 179
 
180 180
     /**
@@ -182,25 +182,25 @@  discard block
 block discarded – undo
182 182
      * @param array $overwriteConfig the config to overwrite with the config set in database.php
183 183
      * @param object $logger the log instance
184 184
      */
185
-    public function __construct($overwriteConfig = array(), Log $logger = null){
185
+    public function __construct($overwriteConfig = array(), Log $logger = null) {
186 186
         /**
187 187
          * instance of the Log class
188 188
          */
189
-        if(is_object($logger)){
189
+        if (is_object($logger)) {
190 190
           $this->logger = $logger;
191 191
         }
192
-        else{
193
-            $this->logger =& class_loader('Log', 'classes');
192
+        else {
193
+            $this->logger = & class_loader('Log', 'classes');
194 194
             $this->logger->setLogger('Library::Database');
195 195
         }
196 196
 
197 197
         $db = array();
198
-      	if(file_exists(CONFIG_PATH . 'database.php')){
198
+      	if (file_exists(CONFIG_PATH . 'database.php')) {
199 199
           //here don't use require_once because somewhere user can create database instance directly
200 200
       	  require CONFIG_PATH . 'database.php';
201 201
         }
202 202
           
203
-				if(! empty($overwriteConfig)){
203
+				if (!empty($overwriteConfig)) {
204 204
 				  $db = array_merge($db, $overwriteConfig);
205 205
 				}
206 206
         $config = array();
@@ -213,12 +213,12 @@  discard block
 block discarded – undo
213 213
 				$config['collation'] = isset($db['collation']) ? $db['collation'] : 'utf8_general_ci';
214 214
 				$config['prefix']    = isset($db['prefix']) ? $db['prefix'] : '';
215 215
         $port = '';
216
-        if(strstr($config['hostname'], ':')){
216
+        if (strstr($config['hostname'], ':')) {
217 217
           $p = explode(':', $config['hostname']);
218 218
           $port = isset($p[1]) ? $p[1] : '';
219 219
           $config['hostname'] = isset($p[0]) ? $p[0] : '';
220 220
         }
221
-				$config['port']      = $port;
221
+				$config['port'] = $port;
222 222
 				
223 223
 		  	$this->setDatabaseConfiguration($config);
224 224
     		$this->temporaryCacheTtl = $this->cacheTtl;
@@ -228,10 +228,10 @@  discard block
 block discarded – undo
228 228
      * This is used to connect to database
229 229
      * @return bool 
230 230
      */
231
-    public function connect(){
231
+    public function connect() {
232 232
       $config = $this->getDatabaseConfiguration();
233
-      if(! empty($config)){
234
-        try{
233
+      if (!empty($config)) {
234
+        try {
235 235
             $driverDsnMap = array(
236 236
               'mysql' => 'mysql:host=' . $config['hostname'] . ';' 
237 237
                           . (($config['port']) != '' ? 'port=' . $config['port'] . ';' : '') 
@@ -252,13 +252,13 @@  discard block
 block discarded – undo
252 252
             $this->pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
253 253
             return true;
254 254
           }
255
-          catch (PDOException $e){
255
+          catch (PDOException $e) {
256 256
             $this->logger->fatal($e->getMessage());
257 257
             show_error('Cannot connect to Database.');
258 258
             return false;
259 259
           }
260 260
       }
261
-      else{
261
+      else {
262 262
         show_error('Database configuration is not set.');
263 263
         return false;
264 264
       }
@@ -269,15 +269,15 @@  discard block
 block discarded – undo
269 269
      * @param  string|array $table the table name or array of table list
270 270
      * @return object        the current Database instance
271 271
      */
272
-    public function from($table){
273
-      if(is_array($table)){
272
+    public function from($table) {
273
+      if (is_array($table)) {
274 274
         $froms = '';
275
-        foreach($table as $key){
275
+        foreach ($table as $key) {
276 276
           $froms .= $this->prefix . $key . ', ';
277 277
         }
278 278
         $this->from = rtrim($froms, ', ');
279 279
       }
280
-      else{
280
+      else {
281 281
         $this->from = $this->prefix . $table;
282 282
       }
283 283
       return $this;
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
      * @param  string|array $fields the field name or array of field list
289 289
      * @return object        the current Database instance
290 290
      */
291
-    public function select($fields){
291
+    public function select($fields) {
292 292
       $select = (is_array($fields) ? implode(', ', $fields) : $fields);
293 293
       $this->select = ($this->select == '*' ? $select : $this->select . ', ' . $select);
294 294
       return $this;
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
      * @param  string $field the field name to distinct
300 300
      * @return object        the current Database instance
301 301
      */
302
-    public function distinct($field){
302
+    public function distinct($field) {
303 303
       $distinct = ' DISTINCT ' . $field;
304 304
       $this->select = ($this->select == '*' ? $distinct : $this->select . ', ' . $distinct);
305 305
 
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
      * @param  string $name  if is not null represent the alias used for this field in the result
313 313
      * @return object        the current Database instance
314 314
      */
315
-    public function max($field, $name = null){
315
+    public function max($field, $name = null) {
316 316
       $func = 'MAX(' . $field . ')' . (!is_null($name) ? ' AS ' . $name : '');
317 317
       $this->select = ($this->select == '*' ? $func : $this->select . ', ' . $func);
318 318
       return $this;
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
      * @param  string $name  if is not null represent the alias used for this field in the result
325 325
      * @return object        the current Database instance
326 326
      */
327
-    public function min($field, $name = null){
327
+    public function min($field, $name = null) {
328 328
       $func = 'MIN(' . $field . ')' . (!is_null($name) ? ' AS ' . $name : '');
329 329
       $this->select = ($this->select == '*' ? $func : $this->select . ', ' . $func);
330 330
       return $this;
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
      * @param  string $name  if is not null represent the alias used for this field in the result
337 337
      * @return object        the current Database instance
338 338
      */
339
-    public function sum($field, $name = null){
339
+    public function sum($field, $name = null) {
340 340
       $func = 'SUM(' . $field . ')' . (!is_null($name) ? ' AS ' . $name : '');
341 341
       $this->select = ($this->select == '*' ? $func : $this->select . ', ' . $func);
342 342
       return $this;
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
      * @param  string $name  if is not null represent the alias used for this field in the result
349 349
      * @return object        the current Database instance
350 350
      */
351
-    public function count($field = '*', $name = null){
351
+    public function count($field = '*', $name = null) {
352 352
       $func = 'COUNT(' . $field . ')' . (!is_null($name) ? ' AS ' . $name : '');
353 353
       $this->select = ($this->select == '*' ? $func : $this->select . ', ' . $func);
354 354
       return $this;
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
      * @param  string $name  if is not null represent the alias used for this field in the result
361 361
      * @return object        the current Database instance
362 362
      */
363
-    public function avg($field, $name = null){
363
+    public function avg($field, $name = null) {
364 364
       $func = 'AVG(' . $field . ')' . (!is_null($name) ? ' AS ' . $name : '');
365 365
       $this->select = ($this->select == '*' ? $func : $this->select . ', ' . $func);
366 366
       return $this;
@@ -375,16 +375,16 @@  discard block
 block discarded – undo
375 375
      * @param  string $type   the type of join (INNER, LEFT, RIGHT)
376 376
      * @return object        the current Database instance
377 377
      */
378
-    public function join($table, $field1 = null, $op = null, $field2 = null, $type = ''){
378
+    public function join($table, $field1 = null, $op = null, $field2 = null, $type = '') {
379 379
       $on = $field1;
380 380
       $table = $this->prefix . $table;
381
-      if(! is_null($op)){
382
-        $on = (! in_array($op, $this->operatorList) ? $this->prefix . $field1 . ' = ' . $this->prefix . $op : $this->prefix . $field1 . ' ' . $op . ' ' . $this->prefix . $field2);
381
+      if (!is_null($op)) {
382
+        $on = (!in_array($op, $this->operatorList) ? $this->prefix . $field1 . ' = ' . $this->prefix . $op : $this->prefix . $field1 . ' ' . $op . ' ' . $this->prefix . $field2);
383 383
       }
384
-      if (empty($this->join)){
384
+      if (empty($this->join)) {
385 385
         $this->join = ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on;
386 386
       }
387
-      else{
387
+      else {
388 388
         $this->join = $this->join . ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on;
389 389
       }
390 390
       return $this;
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
      * @see  Database::join()
396 396
      * @return object        the current Database instance
397 397
      */
398
-    public function innerJoin($table, $field1, $op = null, $field2 = ''){
398
+    public function innerJoin($table, $field1, $op = null, $field2 = '') {
399 399
       return $this->join($table, $field1, $op, $field2, 'INNER ');
400 400
     }
401 401
 
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
      * @see  Database::join()
405 405
      * @return object        the current Database instance
406 406
      */
407
-    public function leftJoin($table, $field1, $op = null, $field2 = ''){
407
+    public function leftJoin($table, $field1, $op = null, $field2 = '') {
408 408
       return $this->join($table, $field1, $op, $field2, 'LEFT ');
409 409
 	}
410 410
 
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
      * @see  Database::join()
414 414
      * @return object        the current Database instance
415 415
      */
416
-    public function rightJoin($table, $field1, $op = null, $field2 = ''){
416
+    public function rightJoin($table, $field1, $op = null, $field2 = '') {
417 417
       return $this->join($table, $field1, $op, $field2, 'RIGHT ');
418 418
     }
419 419
 
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
      * @see  Database::join()
423 423
      * @return object        the current Database instance
424 424
      */
425
-    public function fullOuterJoin($table, $field1, $op = null, $field2 = ''){
425
+    public function fullOuterJoin($table, $field1, $op = null, $field2 = '') {
426 426
     	return $this->join($table, $field1, $op, $field2, 'FULL OUTER ');
427 427
     }
428 428
 
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
      * @see  Database::join()
432 432
      * @return object        the current Database instance
433 433
      */
434
-    public function leftOuterJoin($table, $field1, $op = null, $field2 = ''){
434
+    public function leftOuterJoin($table, $field1, $op = null, $field2 = '') {
435 435
       return $this->join($table, $field1, $op, $field2, 'LEFT OUTER ');
436 436
     }
437 437
 
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
      * @see  Database::join()
441 441
      * @return object        the current Database instance
442 442
      */
443
-    public function rightOuterJoin($table, $field1, $op = null, $field2 = ''){
443
+    public function rightOuterJoin($table, $field1, $op = null, $field2 = '') {
444 444
       return $this->join($table, $field1, $op, $field2, 'RIGHT OUTER ');
445 445
     }
446 446
 
@@ -450,18 +450,18 @@  discard block
 block discarded – undo
450 450
      * @param  string $andOr the separator type used 'AND', 'OR', etc.
451 451
      * @return object        the current Database instance
452 452
      */
453
-    public function whereIsNull($field, $andOr = 'AND'){
454
-      if(is_array($field)){
455
-        foreach($field as $f){
453
+    public function whereIsNull($field, $andOr = 'AND') {
454
+      if (is_array($field)) {
455
+        foreach ($field as $f) {
456 456
         	$this->whereIsNull($f, $andOr);
457 457
         }
458 458
       }
459
-      else{
460
-        if (! $this->where){
461
-          $this->where = $field.' IS NULL ';
459
+      else {
460
+        if (!$this->where) {
461
+          $this->where = $field . ' IS NULL ';
462 462
         }
463
-        else{
464
-            $this->where = $this->where . ' '.$andOr.' ' . $field.' IS NULL ';
463
+        else {
464
+            $this->where = $this->where . ' ' . $andOr . ' ' . $field . ' IS NULL ';
465 465
           }
466 466
       }
467 467
       return $this;
@@ -473,18 +473,18 @@  discard block
 block discarded – undo
473 473
      * @param  string $andOr the separator type used 'AND', 'OR', etc.
474 474
      * @return object        the current Database instance
475 475
      */
476
-    public function whereIsNotNull($field, $andOr = 'AND'){
477
-      if(is_array($field)){
478
-        foreach($field as $f){
476
+    public function whereIsNotNull($field, $andOr = 'AND') {
477
+      if (is_array($field)) {
478
+        foreach ($field as $f) {
479 479
           $this->whereIsNotNull($f, $andOr);
480 480
         }
481 481
       }
482
-      else{
483
-        if (! $this->where){
484
-          $this->where = $field.' IS NOT NULL ';
482
+      else {
483
+        if (!$this->where) {
484
+          $this->where = $field . ' IS NOT NULL ';
485 485
         }
486
-        else{
487
-            $this->where = $this->where . ' '.$andOr.' ' . $field.' IS NOT NULL ';
486
+        else {
487
+            $this->where = $this->where . ' ' . $andOr . ' ' . $field . ' IS NOT NULL ';
488 488
           }
489 489
       }
490 490
       return $this;
@@ -500,24 +500,24 @@  discard block
 block discarded – undo
500 500
      * @param  boolean $escape whether to escape or not the $val
501 501
      * @return object        the current Database instance
502 502
      */
503
-    public function where($where, $op = null, $val = null, $type = '', $andOr = 'AND', $escape = true){
504
-      if (is_array($where)){
503
+    public function where($where, $op = null, $val = null, $type = '', $andOr = 'AND', $escape = true) {
504
+      if (is_array($where)) {
505 505
         $_where = array();
506
-        foreach ($where as $column => $data){
507
-          if(is_null($data)){
506
+        foreach ($where as $column => $data) {
507
+          if (is_null($data)) {
508 508
             $data = '';
509 509
           }
510 510
           $_where[] = $type . $column . '=' . ($escape ? $this->escape($data) : $data);
511 511
         }
512
-        $where = implode(' '.$andOr.' ', $_where);
512
+        $where = implode(' ' . $andOr . ' ', $_where);
513 513
       }
514
-      else{
515
-        if(is_array($op)){
514
+      else {
515
+        if (is_array($op)) {
516 516
           $x = explode('?', $where);
517 517
           $w = '';
518
-          foreach($x as $k => $v){
519
-            if(! empty($v)){
520
-                if(isset($op[$k]) && is_null($op[$k])){
518
+          foreach ($x as $k => $v) {
519
+            if (!empty($v)) {
520
+                if (isset($op[$k]) && is_null($op[$k])) {
521 521
                   $op[$k] = '';
522 522
                 }
523 523
                 $w .= $type . $v . (isset($op[$k]) ? ($escape ? $this->escape($op[$k]) : $op[$k]) : '');
@@ -525,28 +525,28 @@  discard block
 block discarded – undo
525 525
           }
526 526
           $where = $w;
527 527
         }
528
-        else if (! in_array((string)$op, $this->operatorList)){
529
-          if(is_null($op)){
528
+        else if (!in_array((string) $op, $this->operatorList)) {
529
+          if (is_null($op)) {
530 530
             $op = '';
531 531
           }
532 532
         	$where = $type . $where . ' = ' . ($escape ? $this->escape($op) : $op);
533 533
         }
534
-        else{
535
-          if(is_null($val)){
534
+        else {
535
+          if (is_null($val)) {
536 536
             $val = '';
537 537
           }
538 538
         	$where = $type . $where . $op . ($escape ? $this->escape($val) : $val);
539 539
         }
540 540
       }
541
-      if (empty($this->where)){
541
+      if (empty($this->where)) {
542 542
         $this->where = $where;
543 543
       }
544
-      else{
545
-        if(substr($this->where, -1) == '('){
544
+      else {
545
+        if (substr($this->where, -1) == '(') {
546 546
           $this->where = $this->where . ' ' . $where;
547 547
         }
548
-        else{
549
-          $this->where = $this->where . ' '.$andOr.' ' . $where;
548
+        else {
549
+          $this->where = $this->where . ' ' . $andOr . ' ' . $where;
550 550
         }
551 551
       }
552 552
       return $this;
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
      * @see  Database::where()
558 558
      * @return object        the current Database instance
559 559
      */
560
-    public function orWhere($where, $op = null, $val = null, $escape = true){
560
+    public function orWhere($where, $op = null, $val = null, $escape = true) {
561 561
       return $this->where($where, $op, $val, '', 'OR', $escape);
562 562
     }
563 563
 
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
      * @see  Database::where()
568 568
      * @return object        the current Database instance
569 569
      */
570
-    public function notWhere($where, $op = null, $val = null, $escape = true){
570
+    public function notWhere($where, $op = null, $val = null, $escape = true) {
571 571
       return $this->where($where, $op, $val, 'NOT ', 'AND', $escape);
572 572
     }
573 573
 
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
      * @see  Database::where()
577 577
      * @return object        the current Database instance
578 578
      */
579
-    public function orNotWhere($where, $op = null, $val = null, $escape = true){
579
+    public function orNotWhere($where, $op = null, $val = null, $escape = true) {
580 580
     	return $this->where($where, $op, $val, 'NOT ', 'OR', $escape);
581 581
     }
582 582
 
@@ -586,15 +586,15 @@  discard block
 block discarded – undo
586 586
      * @param  string $andOr the multiple conditions separator (AND, OR, etc.)
587 587
      * @return object        the current Database instance
588 588
      */
589
-    public function groupStart($type = '', $andOr = ' AND'){
590
-      if (empty($this->where)){
589
+    public function groupStart($type = '', $andOr = ' AND') {
590
+      if (empty($this->where)) {
591 591
         $this->where = $type . ' (';
592 592
       }
593
-      else{
594
-          if(substr($this->where, -1) == '('){
593
+      else {
594
+          if (substr($this->where, -1) == '(') {
595 595
             $this->where .= $type . ' (';
596 596
           }
597
-          else{
597
+          else {
598 598
           	$this->where .= $andOr . ' ' . $type . ' (';
599 599
           }
600 600
       }
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
      * @see  Database::groupStart()
607 607
      * @return object        the current Database instance
608 608
      */
609
-    public function notGroupStart(){
609
+    public function notGroupStart() {
610 610
       return $this->groupStart('NOT');
611 611
     }
612 612
 
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
      * @see  Database::groupStart()
616 616
      * @return object        the current Database instance
617 617
      */
618
-    public function orGroupStart(){
618
+    public function orGroupStart() {
619 619
       return $this->groupStart('', ' OR');
620 620
     }
621 621
 
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
      * @see  Database::groupStart()
625 625
      * @return object        the current Database instance
626 626
      */
627
-    public function orNotGroupStart(){
627
+    public function orNotGroupStart() {
628 628
       return $this->groupStart('NOT', ' OR');
629 629
     }
630 630
 
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
      * Close the parenthesis for the grouped SQL
633 633
      * @return object        the current Database instance
634 634
      */
635
-    public function groupEnd(){
635
+    public function groupEnd() {
636 636
       $this->where .= ')';
637 637
       return $this;
638 638
     }
@@ -646,24 +646,24 @@  discard block
 block discarded – undo
646 646
      * @param  boolean $escape whether to escape or not the values
647 647
      * @return object        the current Database instance
648 648
      */
649
-    public function in($field, array $keys, $type = '', $andOr = 'AND', $escape = true){
649
+    public function in($field, array $keys, $type = '', $andOr = 'AND', $escape = true) {
650 650
       $_keys = array();
651
-      foreach ($keys as $k => $v){
652
-        if(is_null($v)){
651
+      foreach ($keys as $k => $v) {
652
+        if (is_null($v)) {
653 653
           $v = '';
654 654
         }
655 655
         $_keys[] = (is_numeric($v) ? $v : ($escape ? $this->escape($v) : $v));
656 656
       }
657 657
       $keys = implode(', ', $_keys);
658
-      if (empty($this->where)){
658
+      if (empty($this->where)) {
659 659
         $this->where = $field . ' ' . $type . 'IN (' . $keys . ')';
660 660
       }
661
-      else{
662
-        if(substr($this->where, -1) == '('){
663
-          $this->where = $this->where . ' ' . $field . ' '.$type.'IN (' . $keys . ')';
661
+      else {
662
+        if (substr($this->where, -1) == '(') {
663
+          $this->where = $this->where . ' ' . $field . ' ' . $type . 'IN (' . $keys . ')';
664 664
         }
665
-        else{
666
-          $this->where = $this->where . ' ' . $andOr . ' ' . $field . ' '.$type.'IN (' . $keys . ')';
665
+        else {
666
+          $this->where = $this->where . ' ' . $andOr . ' ' . $field . ' ' . $type . 'IN (' . $keys . ')';
667 667
         }
668 668
       }
669 669
       return $this;
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
      * @see  Database::in()
675 675
      * @return object        the current Database instance
676 676
      */
677
-    public function notIn($field, array $keys, $escape = true){
677
+    public function notIn($field, array $keys, $escape = true) {
678 678
       return $this->in($field, $keys, 'NOT ', 'AND', $escape);
679 679
     }
680 680
 
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
      * @see  Database::in()
684 684
      * @return object        the current Database instance
685 685
      */
686
-    public function orIn($field, array $keys, $escape = true){
686
+    public function orIn($field, array $keys, $escape = true) {
687 687
       return $this->in($field, $keys, '', 'OR', $escape);
688 688
     }
689 689
 
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
      * @see  Database::in()
693 693
      * @return object        the current Database instance
694 694
      */
695
-    public function orNotIn($field, array $keys, $escape = true){
695
+    public function orNotIn($field, array $keys, $escape = true) {
696 696
       return $this->in($field, $keys, 'NOT ', 'OR', $escape);
697 697
     }
698 698
 
@@ -706,21 +706,21 @@  discard block
 block discarded – undo
706 706
      * @param  boolean $escape whether to escape or not the values
707 707
      * @return object        the current Database instance
708 708
      */
709
-    public function between($field, $value1, $value2, $type = '', $andOr = 'AND', $escape = true){
710
-      if(is_null($value1)){
709
+    public function between($field, $value1, $value2, $type = '', $andOr = 'AND', $escape = true) {
710
+      if (is_null($value1)) {
711 711
         $value1 = '';
712 712
       }
713
-      if(is_null($value2)){
713
+      if (is_null($value2)) {
714 714
         $value2 = '';
715 715
       }
716
-      if (empty($this->where)){
716
+      if (empty($this->where)) {
717 717
       	$this->where = $field . ' ' . $type . 'BETWEEN ' . ($escape ? $this->escape($value1) : $value1) . ' AND ' . ($escape ? $this->escape($value2) : $value2);
718 718
       }
719
-      else{
720
-        if(substr($this->where, -1) == '('){
719
+      else {
720
+        if (substr($this->where, -1) == '(') {
721 721
           $this->where = $this->where . ' ' . $field . ' ' . $type . 'BETWEEN ' . ($escape ? $this->escape($value1) : $value1) . ' AND ' . ($escape ? $this->escape($value2) : $value2);
722 722
         }
723
-        else{
723
+        else {
724 724
           $this->where = $this->where . ' ' . $andOr . ' ' . $field . ' ' . $type . 'BETWEEN ' . ($escape ? $this->escape($value1) : $value1) . ' AND ' . ($escape ? $this->escape($value2) : $value2);
725 725
         }
726 726
       }
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
      * @see  Database::between()
733 733
      * @return object        the current Database instance
734 734
      */
735
-    public function notBetween($field, $value1, $value2, $escape = true){
735
+    public function notBetween($field, $value1, $value2, $escape = true) {
736 736
       return $this->between($field, $value1, $value2, 'NOT ', 'AND', $escape);
737 737
     }
738 738
 
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
      * @see  Database::between()
742 742
      * @return object        the current Database instance
743 743
      */
744
-    public function orBetween($field, $value1, $value2, $escape = true){
744
+    public function orBetween($field, $value1, $value2, $escape = true) {
745 745
       return $this->between($field, $value1, $value2, '', 'OR', $escape);
746 746
     }
747 747
 
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
      * @see  Database::between()
751 751
      * @return object        the current Database instance
752 752
      */
753
-    public function orNotBetween($field, $value1, $value2, $escape = true){
753
+    public function orNotBetween($field, $value1, $value2, $escape = true) {
754 754
       return $this->between($field, $value1, $value2, 'NOT ', 'OR', $escape);
755 755
     }
756 756
 
@@ -763,20 +763,20 @@  discard block
 block discarded – undo
763 763
      * @param  boolean $escape whether to escape or not the values
764 764
      * @return object        the current Database instance
765 765
      */
766
-    public function like($field, $data, $type = '', $andOr = 'AND', $escape = true){
767
-      if(empty($data)){
766
+    public function like($field, $data, $type = '', $andOr = 'AND', $escape = true) {
767
+      if (empty($data)) {
768 768
         $data = '';
769 769
       }
770 770
       $like = $escape ? $this->escape($data) : $data;
771
-      if (empty($this->where)){
771
+      if (empty($this->where)) {
772 772
         $this->where = $field . ' ' . $type . 'LIKE ' . $like;
773 773
       }
774
-      else{
775
-        if(substr($this->where, -1) == '('){
774
+      else {
775
+        if (substr($this->where, -1) == '(') {
776 776
           $this->where = $this->where . ' ' . $field . ' ' . $type . 'LIKE ' . $like;
777 777
         }
778
-        else{
779
-          $this->where = $this->where . ' '.$andOr.' ' . $field . ' ' . $type . 'LIKE ' . $like;
778
+        else {
779
+          $this->where = $this->where . ' ' . $andOr . ' ' . $field . ' ' . $type . 'LIKE ' . $like;
780 780
         }
781 781
       }
782 782
       return $this;
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
      * @see  Database::like()
788 788
      * @return object        the current Database instance
789 789
      */
790
-    public function orLike($field, $data, $escape = true){
790
+    public function orLike($field, $data, $escape = true) {
791 791
       return $this->like($field, $data, '', 'OR', $escape);
792 792
     }
793 793
 
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
      * @see  Database::like()
797 797
      * @return object        the current Database instance
798 798
      */
799
-    public function notLike($field, $data, $escape = true){
799
+    public function notLike($field, $data, $escape = true) {
800 800
       return $this->like($field, $data, 'NOT ', 'AND', $escape);
801 801
     }
802 802
 
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
      * @see  Database::like()
806 806
      * @return object        the current Database instance
807 807
      */
808
-    public function orNotLike($field, $data, $escape = true){
808
+    public function orNotLike($field, $data, $escape = true) {
809 809
       return $this->like($field, $data, 'NOT ', 'OR', $escape);
810 810
     }
811 811
 
@@ -816,14 +816,14 @@  discard block
 block discarded – undo
816 816
      * @param  int $limitEnd the limit count
817 817
      * @return object        the current Database instance
818 818
      */
819
-    public function limit($limit, $limitEnd = null){
820
-      if(empty($limit)){
819
+    public function limit($limit, $limitEnd = null) {
820
+      if (empty($limit)) {
821 821
         return;
822 822
       }
823
-      if (! is_null($limitEnd)){
823
+      if (!is_null($limitEnd)) {
824 824
         $this->limit = $limit . ', ' . $limitEnd;
825 825
       }
826
-      else{
826
+      else {
827 827
         $this->limit = $limit;
828 828
       }
829 829
       return $this;
@@ -835,16 +835,16 @@  discard block
 block discarded – undo
835 835
      * @param  string $orderDir the order direction (ASC or DESC)
836 836
      * @return object        the current Database instance
837 837
      */
838
-    public function orderBy($orderBy, $orderDir = ' ASC'){
839
-      if (! empty($orderDir)){
840
-        $this->orderBy = ! $this->orderBy ? ($orderBy . ' ' . strtoupper($orderDir)) : $this->orderBy . ', ' . $orderBy . ' ' . strtoupper($orderDir);
838
+    public function orderBy($orderBy, $orderDir = ' ASC') {
839
+      if (!empty($orderDir)) {
840
+        $this->orderBy = !$this->orderBy ? ($orderBy . ' ' . strtoupper($orderDir)) : $this->orderBy . ', ' . $orderBy . ' ' . strtoupper($orderDir);
841 841
       }
842
-      else{
843
-        if(stristr($orderBy, ' ') || $orderBy == 'rand()'){
844
-          $this->orderBy = ! $this->orderBy ? $orderBy : $this->orderBy . ', ' . $orderBy;
842
+      else {
843
+        if (stristr($orderBy, ' ') || $orderBy == 'rand()') {
844
+          $this->orderBy = !$this->orderBy ? $orderBy : $this->orderBy . ', ' . $orderBy;
845 845
         }
846
-        else{
847
-          $this->orderBy = ! $this->orderBy ? ($orderBy . ' ASC') : $this->orderBy . ', ' . ($orderBy . ' ASC');
846
+        else {
847
+          $this->orderBy = !$this->orderBy ? ($orderBy . ' ASC') : $this->orderBy . ', ' . ($orderBy . ' ASC');
848 848
         }
849 849
       }
850 850
       return $this;
@@ -855,11 +855,11 @@  discard block
 block discarded – undo
855 855
      * @param  string|array $field the field name used or array of field list
856 856
      * @return object        the current Database instance
857 857
      */
858
-    public function groupBy($field){
859
-      if(is_array($field)){
858
+    public function groupBy($field) {
859
+      if (is_array($field)) {
860 860
         $this->groupBy = implode(', ', $field);
861 861
       }
862
-      else{
862
+      else {
863 863
         $this->groupBy = $field;
864 864
       }
865 865
       return $this;
@@ -873,13 +873,13 @@  discard block
 block discarded – undo
873 873
      * @param  boolean $escape whether to escape or not the values
874 874
      * @return object        the current Database instance
875 875
      */
876
-    public function having($field, $op = null, $val = null, $escape = true){
877
-      if(is_array($op)){
876
+    public function having($field, $op = null, $val = null, $escape = true) {
877
+      if (is_array($op)) {
878 878
         $x = explode('?', $field);
879 879
         $w = '';
880
-        foreach($x as $k => $v){
881
-  	      if(!empty($v)){
882
-            if(isset($op[$k]) && is_null($op[$k])){
880
+        foreach ($x as $k => $v) {
881
+  	      if (!empty($v)) {
882
+            if (isset($op[$k]) && is_null($op[$k])) {
883 883
               $op[$k] = '';
884 884
             }
885 885
   	      	$w .= $v . (isset($op[$k]) ? ($escape ? $this->escape($op[$k]) : $op[$k]) : '');
@@ -887,14 +887,14 @@  discard block
 block discarded – undo
887 887
       	}
888 888
         $this->having = $w;
889 889
       }
890
-      else if (! in_array($op, $this->operatorList)){
891
-        if(is_null($op)){
890
+      else if (!in_array($op, $this->operatorList)) {
891
+        if (is_null($op)) {
892 892
           $op = '';
893 893
         }
894 894
         $this->having = $field . ' > ' . ($escape ? $this->escape($op) : $op);
895 895
       }
896
-      else{
897
-        if(is_null($val)){
896
+      else {
897
+        if (is_null($val)) {
898 898
           $val = '';
899 899
         }
900 900
         $this->having = $field . ' ' . $op . ' ' . ($escape ? $this->escape($val) : $val);
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
      * Return the number of rows returned by the current query
907 907
      * @return int
908 908
      */
909
-    public function numRows(){
909
+    public function numRows() {
910 910
       return $this->numRows;
911 911
     }
912 912
 
@@ -914,15 +914,15 @@  discard block
 block discarded – undo
914 914
      * Return the last insert id value
915 915
      * @return mixed
916 916
      */
917
-    public function insertId(){
917
+    public function insertId() {
918 918
       return $this->insertId;
919 919
     }
920 920
 
921 921
     /**
922 922
      * Show an error got from the current query (SQL command synthax error, database driver returned error, etc.)
923 923
      */
924
-    public function error(){
925
-  		if($this->error){
924
+    public function error() {
925
+  		if ($this->error) {
926 926
   			show_error('Query: "' . $this->query . '" Error: ' . $this->error, 'Database Error');
927 927
   		}
928 928
     }
@@ -933,14 +933,14 @@  discard block
 block discarded – undo
933 933
      * If is string will determine the result type "array" or "object"
934 934
      * @return mixed       the query SQL string or the record result
935 935
      */
936
-    public function get($returnSQLQueryOrResultType = false){
936
+    public function get($returnSQLQueryOrResultType = false) {
937 937
       $this->limit = 1;
938 938
       $query = $this->getAll(true);
939
-      if($returnSQLQueryOrResultType === true){
939
+      if ($returnSQLQueryOrResultType === true) {
940 940
         return $query;
941 941
       }
942
-      else{
943
-        return $this->query( $query, false, (($returnSQLQueryOrResultType == 'array') ? true : false) );
942
+      else {
943
+        return $this->query($query, false, (($returnSQLQueryOrResultType == 'array') ? true : false));
944 944
       }
945 945
     }
946 946
 
@@ -950,37 +950,37 @@  discard block
 block discarded – undo
950 950
      * If is string will determine the result type "array" or "object"
951 951
      * @return mixed       the query SQL string or the record result
952 952
      */
953
-    public function getAll($returnSQLQueryOrResultType = false){
953
+    public function getAll($returnSQLQueryOrResultType = false) {
954 954
       $query = 'SELECT ' . $this->select . ' FROM ' . $this->from;
955
-      if (! empty($this->join)){
955
+      if (!empty($this->join)) {
956 956
         $query .= $this->join;
957 957
       }
958 958
 	  
959
-      if (! empty($this->where)){
959
+      if (!empty($this->where)) {
960 960
         $query .= ' WHERE ' . $this->where;
961 961
       }
962 962
 
963
-      if (! empty($this->groupBy)){
963
+      if (!empty($this->groupBy)) {
964 964
         $query .= ' GROUP BY ' . $this->groupBy;
965 965
       }
966 966
 
967
-      if (! empty($this->having)){
967
+      if (!empty($this->having)) {
968 968
         $query .= ' HAVING ' . $this->having;
969 969
       }
970 970
 
971
-      if (! empty($this->orderBy)){
971
+      if (!empty($this->orderBy)) {
972 972
           $query .= ' ORDER BY ' . $this->orderBy;
973 973
       }
974 974
 
975
-      if(! empty($this->limit)){
975
+      if (!empty($this->limit)) {
976 976
       	$query .= ' LIMIT ' . $this->limit;
977 977
       }
978 978
 	  
979
-	   if($returnSQLQueryOrResultType === true){
979
+	   if ($returnSQLQueryOrResultType === true) {
980 980
       	return $query;
981 981
       }
982
-      else{
983
-    	   return $this->query($query, true, (($returnSQLQueryOrResultType == 'array') ? true : false) );
982
+      else {
983
+    	   return $this->query($query, true, (($returnSQLQueryOrResultType == 'array') ? true : false));
984 984
       }
985 985
     }
986 986
 
@@ -990,15 +990,15 @@  discard block
 block discarded – undo
990 990
      * @param  boolean $escape  whether to escape or not the values
991 991
      * @return mixed          the insert id of the new record or null
992 992
      */
993
-    public function insert($data = array(), $escape = true){
993
+    public function insert($data = array(), $escape = true) {
994 994
       $column = array();
995 995
       $val = array();
996
-      if(empty($data) && $this->getData()){
996
+      if (empty($data) && $this->getData()) {
997 997
         $columns = array_keys($this->getData());
998 998
         $column = implode(',', $columns);
999 999
         $val = implode(', ', $this->getData());
1000 1000
       }
1001
-      else{
1001
+      else {
1002 1002
         $columns = array_keys($data);
1003 1003
         $column = implode(',', $columns);
1004 1004
         $val = implode(', ', ($escape ? array_map(array($this, 'escape'), $data) : $data));
@@ -1007,14 +1007,14 @@  discard block
 block discarded – undo
1007 1007
       $query = 'INSERT INTO ' . $this->from . ' (' . $column . ') VALUES (' . $val . ')';
1008 1008
       $query = $this->query($query);
1009 1009
 
1010
-      if ($query){
1011
-        if(! $this->pdo){
1010
+      if ($query) {
1011
+        if (!$this->pdo) {
1012 1012
           $this->connect();
1013 1013
         }
1014 1014
         $this->insertId = $this->pdo->lastInsertId();
1015 1015
         return $this->insertId();
1016 1016
       }
1017
-      else{
1017
+      else {
1018 1018
 		  return false;
1019 1019
       }
1020 1020
     }
@@ -1025,29 +1025,29 @@  discard block
 block discarded – undo
1025 1025
      * @param  boolean $escape  whether to escape or not the values
1026 1026
      * @return mixed          the update status
1027 1027
      */
1028
-    public function update($data = array(), $escape = true){
1028
+    public function update($data = array(), $escape = true) {
1029 1029
       $query = 'UPDATE ' . $this->from . ' SET ';
1030 1030
       $values = array();
1031
-      if(empty($data) && $this->getData()){
1032
-        foreach ($this->getData() as $column => $val){
1031
+      if (empty($data) && $this->getData()) {
1032
+        foreach ($this->getData() as $column => $val) {
1033 1033
           $values[] = $column . ' = ' . $val;
1034 1034
         }
1035 1035
       }
1036
-      else{
1037
-        foreach ($data as $column => $val){
1036
+      else {
1037
+        foreach ($data as $column => $val) {
1038 1038
           $values[] = $column . '=' . ($escape ? $this->escape($val) : $val);
1039 1039
         }
1040 1040
       }
1041 1041
       $query .= implode(', ', $values);
1042
-      if (! empty($this->where)){
1042
+      if (!empty($this->where)) {
1043 1043
         $query .= ' WHERE ' . $this->where;
1044 1044
       }
1045 1045
 
1046
-      if (! empty($this->orderBy)){
1046
+      if (!empty($this->orderBy)) {
1047 1047
         $query .= ' ORDER BY ' . $this->orderBy;
1048 1048
       }
1049 1049
 
1050
-      if (! empty($this->limit)){
1050
+      if (!empty($this->limit)) {
1051 1051
         $query .= ' LIMIT ' . $this->limit;
1052 1052
       }
1053 1053
       return $this->query($query);
@@ -1057,22 +1057,22 @@  discard block
 block discarded – undo
1057 1057
      * Delete the record in database
1058 1058
      * @return mixed the delete status
1059 1059
      */
1060
-    public function delete(){
1060
+    public function delete() {
1061 1061
     	$query = 'DELETE FROM ' . $this->from;
1062 1062
 
1063
-    	if (! empty($this->where)){
1063
+    	if (!empty($this->where)) {
1064 1064
     		$query .= ' WHERE ' . $this->where;
1065 1065
       	}
1066 1066
 
1067
-    	if (! empty($this->orderBy)){
1067
+    	if (!empty($this->orderBy)) {
1068 1068
     	  $query .= ' ORDER BY ' . $this->orderBy;
1069 1069
       	}
1070 1070
 
1071
-    	if (! empty($this->limit)){
1071
+    	if (!empty($this->limit)) {
1072 1072
     		$query .= ' LIMIT ' . $this->limit;
1073 1073
       	}
1074 1074
 
1075
-    	if($query == 'DELETE FROM ' . $this->from && $this->config['driver'] != 'sqlite'){  
1075
+    	if ($query == 'DELETE FROM ' . $this->from && $this->config['driver'] != 'sqlite') {  
1076 1076
     		$query = 'TRUNCATE TABLE ' . $this->from;
1077 1077
       }
1078 1078
     	return $this->query($query);
@@ -1085,13 +1085,13 @@  discard block
 block discarded – undo
1085 1085
      * @param  boolean $array return the result as array
1086 1086
      * @return mixed         the query result
1087 1087
      */
1088
-    public function query($query, $all = true, $array = false){
1088
+    public function query($query, $all = true, $array = false) {
1089 1089
       $this->reset();
1090
-      if(is_array($all)){
1090
+      if (is_array($all)) {
1091 1091
         $x = explode('?', $query);
1092 1092
         $q = '';
1093
-        foreach($x as $k => $v){
1094
-          if(! empty($v)){
1093
+        foreach ($x as $k => $v) {
1094
+          if (!empty($v)) {
1095 1095
             $q .= $v . (isset($all[$k]) ? $this->escape($all[$k]) : '');
1096 1096
           }
1097 1097
         }
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
 
1101 1101
       $this->query = preg_replace('/\s\s+|\t\t+/', ' ', trim($query));
1102 1102
       $sqlSELECTQuery = stristr($this->query, 'SELECT');
1103
-      $this->logger->info('Execute SQL query ['.$this->query.'], return type: ' . ($array?'ARRAY':'OBJECT') .', return as list: ' . ($all ? 'YES':'NO'));
1103
+      $this->logger->info('Execute SQL query [' . $this->query . '], return type: ' . ($array ? 'ARRAY' : 'OBJECT') . ', return as list: ' . ($all ? 'YES' : 'NO'));
1104 1104
       //cache expire time
1105 1105
   	  $cacheExpire = $this->temporaryCacheTtl;
1106 1106
   	  
@@ -1122,34 +1122,34 @@  discard block
 block discarded – undo
1122 1122
   	  //if can use cache feature for this query
1123 1123
   	  $dbCacheStatus = $cacheEnable && $cacheExpire > 0;
1124 1124
 	  
1125
-      if ($dbCacheStatus && $sqlSELECTQuery){
1125
+      if ($dbCacheStatus && $sqlSELECTQuery) {
1126 1126
         $this->logger->info('The cache is enabled for this query, try to get result from cache'); 
1127 1127
         $cacheKey = md5($query . $all . $array);
1128
-        if(is_object($this->cacheInstance)){
1128
+        if (is_object($this->cacheInstance)) {
1129 1129
           $cacheInstance = $this->cacheInstance;
1130 1130
         }
1131
-        else{
1131
+        else {
1132 1132
           $obj = & get_instance();
1133 1133
           $cacheInstance = $obj->cache;  
1134 1134
         }
1135 1135
         $cacheContent = $cacheInstance->get($cacheKey);        
1136 1136
       }
1137
-      else{
1137
+      else {
1138 1138
 		  $this->logger->info('The cache is not enabled for this query or is not the SELECT query, get the result directly from real database');
1139 1139
       }
1140 1140
 
1141
-      if(! $this->pdo){
1141
+      if (!$this->pdo) {
1142 1142
         $this->connect();
1143 1143
       }
1144 1144
       
1145
-      if (! $cacheContent && $sqlSELECTQuery){
1145
+      if (!$cacheContent && $sqlSELECTQuery) {
1146 1146
 		    //for database query execution time
1147 1147
         $benchmarkMarkerKey = md5($query . $all . $array);
1148 1148
         $bench = null;
1149
-        if(is_object($this->benchmarkInstance)){
1149
+        if (is_object($this->benchmarkInstance)) {
1150 1150
           $bench = $this->benchmarkInstance;
1151 1151
         }
1152
-        else{
1152
+        else {
1153 1153
           $obj = & get_instance();
1154 1154
           $bench = $obj->benchmark;  
1155 1155
         }
@@ -1160,64 +1160,64 @@  discard block
 block discarded – undo
1160 1160
     		//get response time for this query
1161 1161
         $responseTime = $bench->elapsedTime('DATABASE_QUERY_START(' . $benchmarkMarkerKey . ')', 'DATABASE_QUERY_END(' . $benchmarkMarkerKey . ')');
1162 1162
 	     	//TODO use the configuration value for the high response time currently is 1 second
1163
-        if($responseTime >= 1 ){
1164
-            $this->logger->warning('High response time while processing database query [' .$query. ']. The response time is [' .$responseTime. '] sec.');
1163
+        if ($responseTime >= 1) {
1164
+            $this->logger->warning('High response time while processing database query [' . $query . ']. The response time is [' . $responseTime . '] sec.');
1165 1165
         }
1166
-        if ($sqlQuery){
1166
+        if ($sqlQuery) {
1167 1167
             //if need return all result like list of record
1168
-            if ($all){
1168
+            if ($all) {
1169 1169
     				    $this->result = ($array === false) ? $sqlQuery->fetchAll(PDO::FETCH_OBJ) : $sqlQuery->fetchAll(PDO::FETCH_ASSOC);
1170 1170
     		    }
1171
-            else{
1171
+            else {
1172 1172
 				        $this->result = ($array === false) ? $sqlQuery->fetch(PDO::FETCH_OBJ) : $sqlQuery->fetch(PDO::FETCH_ASSOC);
1173 1173
             }
1174 1174
             //Sqlite and pgsql always return 0 when using rowCount()
1175
-            if(in_array($this->config['driver'], array('sqlite', 'pgsql'))){
1175
+            if (in_array($this->config['driver'], array('sqlite', 'pgsql'))) {
1176 1176
               $this->numRows = count($this->result);  
1177 1177
             }
1178
-            else{
1178
+            else {
1179 1179
               $this->numRows = $sqlQuery->rowCount(); 
1180 1180
             }
1181 1181
 
1182
-          if ($dbCacheStatus && $sqlSELECTQuery){
1183
-              $this->logger->info('Save the result for query [' .$this->query. '] into cache for future use');
1182
+          if ($dbCacheStatus && $sqlSELECTQuery) {
1183
+              $this->logger->info('Save the result for query [' . $this->query . '] into cache for future use');
1184 1184
               $cacheInstance->set($cacheKey, $this->result, $cacheExpire);
1185 1185
           }
1186 1186
         }
1187
-        else{
1187
+        else {
1188 1188
           $error = $this->pdo->errorInfo();
1189 1189
           $this->error = isset($error[2]) ? $error[2] : '';
1190 1190
           $this->logger->fatal('The database query execution got error: ' . stringfy_vars($error));
1191 1191
           $this->error();
1192 1192
         }
1193 1193
       }
1194
-      else if ((! $cacheContent && !$sqlSELECTQuery) || ($cacheContent && !$sqlSELECTQuery)){
1194
+      else if ((!$cacheContent && !$sqlSELECTQuery) || ($cacheContent && !$sqlSELECTQuery)) {
1195 1195
     		$queryStr = $this->pdo->query($this->query);
1196
-    		if($queryStr){
1196
+    		if ($queryStr) {
1197 1197
           //Sqlite and pgsql always return 0 when using rowCount()
1198
-          if(in_array($this->config['driver'], array('sqlite', 'pgsql'))){
1198
+          if (in_array($this->config['driver'], array('sqlite', 'pgsql'))) {
1199 1199
             $this->result = 1; //to test the result for the query like UPDATE, INSERT, DELETE
1200 1200
             $this->numRows = 1;  
1201 1201
           }
1202
-          else{
1202
+          else {
1203 1203
               $this->result = $queryStr->rowCount() >= 0; //to test the result for the query like UPDATE, INSERT, DELETE
1204 1204
               $this->numRows = $queryStr->rowCount(); 
1205 1205
           }
1206 1206
     		}
1207
-        if (! $this->result){
1207
+        if (!$this->result) {
1208 1208
           $error = $this->pdo->errorInfo();
1209 1209
           $this->error = isset($error[2]) ? $error[2] : '';
1210 1210
           $this->logger->fatal('The database query execution got error: ' . stringfy_vars($error));
1211 1211
           $this->error();
1212 1212
         }
1213 1213
       }
1214
-      else{
1215
-        $this->logger->info('The result for query [' .$this->query. '] already cached use it');
1214
+      else {
1215
+        $this->logger->info('The result for query [' . $this->query . '] already cached use it');
1216 1216
         $this->result = $cacheContent;
1217 1217
 	     	$this->numRows = count($this->result);
1218 1218
       }
1219 1219
       $this->queryCount++;
1220
-      if(! $this->result){
1220
+      if (!$this->result) {
1221 1221
         $this->logger->info('No result where found for the query [' . $query . ']');
1222 1222
       }
1223 1223
       return $this->result;
@@ -1228,8 +1228,8 @@  discard block
 block discarded – undo
1228 1228
      * @param integer $ttl the cache time to live in second
1229 1229
      * @return object        the current Database instance
1230 1230
      */
1231
-    public function setCache($ttl = 0){
1232
-      if($ttl > 0){
1231
+    public function setCache($ttl = 0) {
1232
+      if ($ttl > 0) {
1233 1233
         $this->cacheTtl = $ttl;
1234 1234
 		    $this->temporaryCacheTtl = $ttl;
1235 1235
       }
@@ -1241,8 +1241,8 @@  discard block
 block discarded – undo
1241 1241
 	 * @param  integer $ttl the cache time to live in second
1242 1242
 	 * @return object        the current Database instance
1243 1243
 	 */
1244
-	public function cached($ttl = 0){
1245
-      if($ttl > 0){
1244
+	public function cached($ttl = 0) {
1245
+      if ($ttl > 0) {
1246 1246
         $this->temporaryCacheTtl = $ttl;
1247 1247
       }
1248 1248
 	  return $this;
@@ -1253,11 +1253,11 @@  discard block
 block discarded – undo
1253 1253
      * @param  mixed $data the data to be escaped
1254 1254
      * @return mixed       the data after escaped
1255 1255
      */
1256
-    public function escape($data){
1257
-      if(is_null($data)){
1256
+    public function escape($data) {
1257
+      if (is_null($data)) {
1258 1258
         return null;
1259 1259
       }
1260
-      if(! $this->pdo){
1260
+      if (!$this->pdo) {
1261 1261
         $this->connect();
1262 1262
       }
1263 1263
       return $this->pdo->quote(trim($data));
@@ -1267,7 +1267,7 @@  discard block
 block discarded – undo
1267 1267
      * Return the number query executed count for the current request
1268 1268
      * @return int
1269 1269
      */
1270
-    public function queryCount(){
1270
+    public function queryCount() {
1271 1271
       return $this->queryCount;
1272 1272
     }
1273 1273
 
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
      * Return the current query SQL string
1276 1276
      * @return string
1277 1277
      */
1278
-    public function getQuery(){
1278
+    public function getQuery() {
1279 1279
       return $this->query;
1280 1280
     }
1281 1281
 
@@ -1283,7 +1283,7 @@  discard block
 block discarded – undo
1283 1283
      * Return the application database name
1284 1284
      * @return string
1285 1285
      */
1286
-    public function getDatabaseName(){
1286
+    public function getDatabaseName() {
1287 1287
       return $this->databaseName;
1288 1288
     }
1289 1289
 
@@ -1291,7 +1291,7 @@  discard block
 block discarded – undo
1291 1291
      * Return the database configuration
1292 1292
      * @return array
1293 1293
      */
1294
-    public  function getDatabaseConfiguration(){
1294
+    public  function getDatabaseConfiguration() {
1295 1295
       return $this->config;
1296 1296
     }
1297 1297
 
@@ -1299,7 +1299,7 @@  discard block
 block discarded – undo
1299 1299
      * set the database configuration
1300 1300
      * @param array $config the configuration
1301 1301
      */
1302
-    public function setDatabaseConfiguration(array $config){
1302
+    public function setDatabaseConfiguration(array $config) {
1303 1303
       $this->config = array_merge($this->config, $config);
1304 1304
       $this->prefix = $this->config['prefix'];
1305 1305
       $this->databaseName = $this->config['database'];
@@ -1311,7 +1311,7 @@  discard block
 block discarded – undo
1311 1311
      * Return the PDO instance
1312 1312
      * @return PDO
1313 1313
      */
1314
-    public function getPdo(){
1314
+    public function getPdo() {
1315 1315
       return $this->pdo;
1316 1316
     }
1317 1317
 
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
      * Set the PDO instance
1320 1320
      * @param PDO $pdo the pdo object
1321 1321
      */
1322
-    public function setPdo(PDO $pdo){
1322
+    public function setPdo(PDO $pdo) {
1323 1323
       $this->pdo = $pdo;
1324 1324
       return $this;
1325 1325
     }
@@ -1329,7 +1329,7 @@  discard block
 block discarded – undo
1329 1329
      * Return the Log instance
1330 1330
      * @return Log
1331 1331
      */
1332
-    public function getLogger(){
1332
+    public function getLogger() {
1333 1333
       return $this->logger;
1334 1334
     }
1335 1335
 
@@ -1337,7 +1337,7 @@  discard block
 block discarded – undo
1337 1337
      * Set the log instance
1338 1338
      * @param Log $logger the log object
1339 1339
      */
1340
-    public function setLogger($logger){
1340
+    public function setLogger($logger) {
1341 1341
       $this->logger = $logger;
1342 1342
       return $this;
1343 1343
     }
@@ -1346,7 +1346,7 @@  discard block
 block discarded – undo
1346 1346
      * Return the cache instance
1347 1347
      * @return CacheInterface
1348 1348
      */
1349
-    public function getCacheInstance(){
1349
+    public function getCacheInstance() {
1350 1350
       return $this->cacheInstance;
1351 1351
     }
1352 1352
 
@@ -1354,7 +1354,7 @@  discard block
 block discarded – undo
1354 1354
      * Set the cache instance
1355 1355
      * @param CacheInterface $cache the cache object
1356 1356
      */
1357
-    public function setCacheInstance($cache){
1357
+    public function setCacheInstance($cache) {
1358 1358
       $this->cacheInstance = $cache;
1359 1359
       return $this;
1360 1360
     }
@@ -1363,7 +1363,7 @@  discard block
 block discarded – undo
1363 1363
      * Return the benchmark instance
1364 1364
      * @return Benchmark
1365 1365
      */
1366
-    public function getBenchmark(){
1366
+    public function getBenchmark() {
1367 1367
       return $this->benchmarkInstance;
1368 1368
     }
1369 1369
 
@@ -1371,7 +1371,7 @@  discard block
 block discarded – undo
1371 1371
      * Set the benchmark instance
1372 1372
      * @param Benchmark $cache the cache object
1373 1373
      */
1374
-    public function setBenchmark($benchmark){
1374
+    public function setBenchmark($benchmark) {
1375 1375
       $this->benchmarkInstance = $benchmark;
1376 1376
       return $this;
1377 1377
     }
@@ -1380,7 +1380,7 @@  discard block
 block discarded – undo
1380 1380
      * Return the data to be used for insert, update, etc.
1381 1381
      * @return array
1382 1382
      */
1383
-    public function getData(){
1383
+    public function getData() {
1384 1384
       return $this->data;
1385 1385
     }
1386 1386
 
@@ -1391,7 +1391,7 @@  discard block
 block discarded – undo
1391 1391
      * @param boolean $escape whether to escape or not the $value
1392 1392
      * @return object        the current Database instance
1393 1393
      */
1394
-    public function setData($key, $value, $escape = true){
1394
+    public function setData($key, $value, $escape = true) {
1395 1395
       $this->data[$key] = $escape ? $this->escape($value) : $value;
1396 1396
       return $this;
1397 1397
     }
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
   /**
1401 1401
    * Reset the database class attributs to the initail values before each query.
1402 1402
    */
1403
-  private function reset(){
1403
+  private function reset() {
1404 1404
     $this->select   = '*';
1405 1405
     $this->from     = null;
1406 1406
     $this->where    = null;
@@ -1420,7 +1420,7 @@  discard block
 block discarded – undo
1420 1420
   /**
1421 1421
    * The class destructor
1422 1422
    */
1423
-  public function __destruct(){
1423
+  public function __destruct() {
1424 1424
     $this->pdo = null;
1425 1425
   }
1426 1426
 
Please login to merge, or discard this patch.
core/classes/Session.php 1 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.