@@ -104,8 +104,7 @@ discard block |
||
| 104 | 104 | $this->routes = $route; |
| 105 | 105 | unset($route); |
| 106 | 106 | } |
| 107 | - } |
|
| 108 | - else{ |
|
| 107 | + } else{ |
|
| 109 | 108 | show_error('Unable to find the routes configuration file [' . $routesPath . ']'); |
| 110 | 109 | } |
| 111 | 110 | |
@@ -115,8 +114,7 @@ discard block |
||
| 115 | 114 | if($modulesRoutes && is_array($modulesRoutes)){ |
| 116 | 115 | $this->routes = array_merge($this->routes, $modulesRoutes); |
| 117 | 116 | $this->logger->info('Routes for all modules loaded successfully'); |
| 118 | - } |
|
| 119 | - else{ |
|
| 117 | + } else{ |
|
| 120 | 118 | $this->logger->info('No routes found for all modules skipping.'); |
| 121 | 119 | } |
| 122 | 120 | $this->logger->info('The routes configuration are listed below: ' . stringfy_vars($this->routes)); |
@@ -132,8 +130,7 @@ discard block |
||
| 132 | 130 | if($suffix = get_config('url_suffix')){ |
| 133 | 131 | $this->logger->info('URL suffix is enabled in the configuration, the value is [' . $suffix . ']' ); |
| 134 | 132 | $uri = str_ireplace($suffix, '', $uri); |
| 135 | - } |
|
| 136 | - else{ |
|
| 133 | + } else{ |
|
| 137 | 134 | $this->logger->info('URL suffix is not enabled in the configuration'); |
| 138 | 135 | } |
| 139 | 136 | if(strpos($uri, '?') !== false){ |
@@ -226,8 +223,7 @@ discard block |
||
| 226 | 223 | $this->logger->info('The request URI contains the front controller'); |
| 227 | 224 | array_shift($segment); |
| 228 | 225 | $this->segments = $segment; |
| 229 | - } |
|
| 230 | - else{ |
|
| 226 | + } else{ |
|
| 231 | 227 | $this->logger->info('The request URI does not contain the front controller'); |
| 232 | 228 | } |
| 233 | 229 | $uri = implode('/', $segment); |
@@ -249,8 +245,7 @@ discard block |
||
| 249 | 245 | $this->logger->info('The current request use the module [' .$moduleControllerMethod[0]. ']'); |
| 250 | 246 | $this->module = $moduleControllerMethod[0]; |
| 251 | 247 | $moduleControllerMethod = explode('@', $moduleControllerMethod[1]); |
| 252 | - } |
|
| 253 | - else{ |
|
| 248 | + } else{ |
|
| 254 | 249 | $this->logger->info('The current request does not use the module'); |
| 255 | 250 | $moduleControllerMethod = explode('@', $this->callback[$index]); |
| 256 | 251 | } |
@@ -297,8 +292,7 @@ discard block |
||
| 297 | 292 | } |
| 298 | 293 | //args |
| 299 | 294 | $this->args = $segment; |
| 300 | - } |
|
| 301 | - else{ |
|
| 295 | + } else{ |
|
| 302 | 296 | $this->logger->info('The application contains a loaded module will check if the current request is found in the module list'); |
| 303 | 297 | if(in_array($segment[0], $modules)){ |
| 304 | 298 | $this->logger->info('Found, the current request use the module [' . $segment[0] . ']'); |
@@ -312,8 +306,7 @@ discard block |
||
| 312 | 306 | if(! $path){ |
| 313 | 307 | $this->logger->info('The controller [' . $this->getController() . '] not found in the module, may be will use the module [' . $this->getModule() . '] as controller'); |
| 314 | 308 | $this->controller = $this->getModule(); |
| 315 | - } |
|
| 316 | - else{ |
|
| 309 | + } else{ |
|
| 317 | 310 | $this->controllerPath = $path; |
| 318 | 311 | array_shift($segment); |
| 319 | 312 | } |
@@ -325,8 +318,7 @@ discard block |
||
| 325 | 318 | } |
| 326 | 319 | //the remaining is for args |
| 327 | 320 | $this->args = $segment; |
| 328 | - } |
|
| 329 | - else{ |
|
| 321 | + } else{ |
|
| 330 | 322 | $this->logger->info('The current request information is not found in the module list'); |
| 331 | 323 | //controller |
| 332 | 324 | if(isset($segment[0])){ |
@@ -354,8 +346,7 @@ discard block |
||
| 354 | 346 | //if it is the module controller |
| 355 | 347 | if($this->getModule()){ |
| 356 | 348 | $this->controllerPath = Module::findControllerFullPath(ucfirst($this->getController()), $this->getModule()); |
| 357 | - } |
|
| 358 | - else{ |
|
| 349 | + } else{ |
|
| 359 | 350 | $this->controllerPath = APPS_CONTROLLER_PATH . ucfirst($this->getController()) . '.php'; |
| 360 | 351 | } |
| 361 | 352 | } |
@@ -370,15 +361,13 @@ discard block |
||
| 370 | 361 | if(! class_exists($controller, false)){ |
| 371 | 362 | $e404 = true; |
| 372 | 363 | $this->logger->info('The controller file [' .$classFilePath. '] exists but does not contain the class [' . $controller . ']'); |
| 373 | - } |
|
| 374 | - else{ |
|
| 364 | + } else{ |
|
| 375 | 365 | $controllerInstance = new $controller(); |
| 376 | 366 | $controllerMethod = $this->getMethod(); |
| 377 | 367 | if(! method_exists($controllerInstance, $controllerMethod)){ |
| 378 | 368 | $e404 = true; |
| 379 | 369 | $this->logger->info('The controller [' . $controller . '] exist but does not contain the method [' . $controllerMethod . ']'); |
| 380 | - } |
|
| 381 | - else{ |
|
| 370 | + } else{ |
|
| 382 | 371 | $this->logger->info('Routing data is set correctly now GO!'); |
| 383 | 372 | call_user_func_array(array($controllerInstance, $controllerMethod), $this->getArgs()); |
| 384 | 373 | $obj = & get_instance(); |
@@ -387,8 +376,7 @@ discard block |
||
| 387 | 376 | $obj->response->renderFinalPage(); |
| 388 | 377 | } |
| 389 | 378 | } |
| 390 | - } |
|
| 391 | - else{ |
|
| 379 | + } else{ |
|
| 392 | 380 | $this->logger->info('The controller file path [' . $classFilePath . '] does not exist'); |
| 393 | 381 | $e404 = true; |
| 394 | 382 | } |
@@ -128,8 +128,7 @@ discard block |
||
| 128 | 128 | $logger->info('Delete config item ['.$item.']'); |
| 129 | 129 | unset(self::$config[$item]); |
| 130 | 130 | return true; |
| 131 | - } |
|
| 132 | - else{ |
|
| 131 | + } else{ |
|
| 133 | 132 | $logger->warning('Config item ['.$item.'] to be deleted does not exists'); |
| 134 | 133 | return false; |
| 135 | 134 | } |
@@ -156,15 +155,13 @@ discard block |
||
| 156 | 155 | //check if the server is running under IPv6 |
| 157 | 156 | if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE){ |
| 158 | 157 | $baseUrl = '['.$_SERVER['SERVER_ADDR'].']'; |
| 159 | - } |
|
| 160 | - else{ |
|
| 158 | + } else{ |
|
| 161 | 159 | $baseUrl = $_SERVER['SERVER_ADDR']; |
| 162 | 160 | } |
| 163 | 161 | $port = ((isset($_SERVER['SERVER_PORT']) && ($_SERVER['SERVER_PORT'] != '80' && ! is_https() || $_SERVER['SERVER_PORT'] != '443' && is_https()) ) ? ':' . $_SERVER['SERVER_PORT'] : ''); |
| 164 | 162 | $baseUrl = (is_https() ? 'https' : 'http').'://' . $baseUrl . $port |
| 165 | 163 | . substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME']))); |
| 166 | - } |
|
| 167 | - else{ |
|
| 164 | + } else{ |
|
| 168 | 165 | $logger->warning('Can not determine the application base URL automatically, use http://localhost as default'); |
| 169 | 166 | $baseUrl = 'http://localhost/'; |
| 170 | 167 | } |
@@ -59,8 +59,7 @@ discard block |
||
| 59 | 59 | if(! isset($this->listeners[$eventName])){ |
| 60 | 60 | $this->logger->info('This event does not have the registered event listener before, adding new one'); |
| 61 | 61 | $this->listeners[$eventName] = array(); |
| 62 | - } |
|
| 63 | - else{ |
|
| 62 | + } else{ |
|
| 64 | 63 | $this->logger->info('This event already have the registered listener, add this listener to the list'); |
| 65 | 64 | } |
| 66 | 65 | $this->listeners[$eventName][] = $listener; |
@@ -78,12 +77,10 @@ discard block |
||
| 78 | 77 | if(false !== $index = array_search($listener, $this->listeners[$eventName], true)){ |
| 79 | 78 | $this->logger->info('Found the listener at index [' .$index. '] remove it'); |
| 80 | 79 | unset($this->listeners[$eventName][$index]); |
| 81 | - } |
|
| 82 | - else{ |
|
| 80 | + } else{ |
|
| 83 | 81 | $this->logger->info('Cannot found this listener in the event listener list'); |
| 84 | 82 | } |
| 85 | - } |
|
| 86 | - else{ |
|
| 83 | + } else{ |
|
| 87 | 84 | $this->logger->info('This event does not have this listener ignore remove'); |
| 88 | 85 | } |
| 89 | 86 | } |
@@ -98,8 +95,7 @@ discard block |
||
| 98 | 95 | if($eventName !== null && isset($this->listeners[$eventName])){ |
| 99 | 96 | $this->logger->info('The event name is set of exist in the listener just remove all event listener for this event'); |
| 100 | 97 | unset($this->listeners[$eventName]); |
| 101 | - } |
|
| 102 | - else{ |
|
| 98 | + } else{ |
|
| 103 | 99 | $this->logger->info('The event name is not set or does not exist in the listener, so remove all event listener'); |
| 104 | 100 | $this->listeners = array(); |
| 105 | 101 | } |
@@ -132,8 +128,7 @@ discard block |
||
| 132 | 128 | if($event->returnBack){ |
| 133 | 129 | $this->logger->info('This event need return back, return the result for future use'); |
| 134 | 130 | return $this->dispatchToListerners($event); |
| 135 | - } |
|
| 136 | - else{ |
|
| 131 | + } else{ |
|
| 137 | 132 | $this->logger->info('This event no need return back the result, just dispatch it'); |
| 138 | 133 | $this->dispatchToListerners($event); |
| 139 | 134 | } |
@@ -153,8 +148,7 @@ discard block |
||
| 153 | 148 | return $event; |
| 154 | 149 | } |
| 155 | 150 | return; |
| 156 | - } |
|
| 157 | - else{ |
|
| 151 | + } else{ |
|
| 158 | 152 | $this->logger->info('Found the registered event listener for the event [' .$event->name. '] the list are: ' . stringfy_vars($list)); |
| 159 | 153 | } |
| 160 | 154 | foreach($list as $listener){ |
@@ -162,12 +156,10 @@ discard block |
||
| 162 | 156 | $returnedEvent = call_user_func_array($listener, array($event)); |
| 163 | 157 | if($returnedEvent instanceof EventInfo){ |
| 164 | 158 | $event = $returnedEvent; |
| 165 | - } |
|
| 166 | - else{ |
|
| 159 | + } else{ |
|
| 167 | 160 | show_error('This event [' .$event->name. '] need you return the event object after processing'); |
| 168 | 161 | } |
| 169 | - } |
|
| 170 | - else{ |
|
| 162 | + } else{ |
|
| 171 | 163 | call_user_func_array($listener, array($event)); |
| 172 | 164 | } |
| 173 | 165 | if($event->stop){ |
@@ -115,8 +115,7 @@ |
||
| 115 | 115 | protected function setLoggerFromParamOrCreateNewInstance(Log $logger = null){ |
| 116 | 116 | if($logger !== null){ |
| 117 | 117 | $this->logger = $logger; |
| 118 | - } |
|
| 119 | - else{ |
|
| 118 | + } else{ |
|
| 120 | 119 | $this->logger =& class_loader('Log', 'classes'); |
| 121 | 120 | $this->logger->setLogger('MainController'); |
| 122 | 121 | } |
@@ -220,8 +220,7 @@ discard block |
||
| 220 | 220 | //first check for CSRF |
| 221 | 221 | if ((get_config('csrf_enable', false) || $this->enableCsrfCheck) && ! Security::validateCSRF()){ |
| 222 | 222 | show_error('Invalide data, Cross Site Request Forgery do his job, the data to validate is corrupted.'); |
| 223 | - } |
|
| 224 | - else{ |
|
| 223 | + } else{ |
|
| 225 | 224 | $this->logger->info('CSRF is not enabled in configuration or not set manully, no need to check it'); |
| 226 | 225 | } |
| 227 | 226 | } |
@@ -231,8 +230,7 @@ discard block |
||
| 231 | 230 | foreach ($this->getData() as $inputName => $inputVal) { |
| 232 | 231 | if(is_array($this->data[$inputName])){ |
| 233 | 232 | $this->data[$inputName] = array_map('trim', $this->data[$inputName]); |
| 234 | - } |
|
| 235 | - else{ |
|
| 233 | + } else{ |
|
| 236 | 234 | $this->data[$inputName] = trim($this->data[$inputName]); |
| 237 | 235 | } |
| 238 | 236 | |
@@ -600,8 +598,7 @@ discard block |
||
| 600 | 598 | if ($inputVal == '' && $callbackReturn == true) { |
| 601 | 599 | $this->_setError($inputName, $ruleName, $this->_getLabel($inputName)); |
| 602 | 600 | } |
| 603 | - } |
|
| 604 | - else if($inputVal == '') { |
|
| 601 | + } else if($inputVal == '') { |
|
| 605 | 602 | $this->_setError($inputName, $ruleName, $this->_getLabel($inputName)); |
| 606 | 603 | } |
| 607 | 604 | } |
@@ -660,8 +657,7 @@ discard block |
||
| 660 | 657 | $this->_setError($inputName, $ruleName . ',post:key', array($this->_getLabel($inputName), $this->_getLabel(str_replace('post:', '', $doNotEqual)))); |
| 661 | 658 | continue; |
| 662 | 659 | } |
| 663 | - } |
|
| 664 | - else{ |
|
| 660 | + } else{ |
|
| 665 | 661 | if ($inputVal == $doNotEqual) { |
| 666 | 662 | $this->_setError($inputName, $ruleName . ',string', array($this->_getLabel($inputName), $doNotEqual)); |
| 667 | 663 | continue; |
@@ -43,8 +43,7 @@ |
||
| 43 | 43 | if(isset($classesMap[$class])){ |
| 44 | 44 | if(file_exists($classesMap[$class])){ |
| 45 | 45 | require_once $classesMap[$class]; |
| 46 | - } |
|
| 47 | - else{ |
|
| 46 | + } else{ |
|
| 48 | 47 | echo 'File for class ' . $class . ' not found'; |
| 49 | 48 | } |
| 50 | 49 | } |
@@ -226,16 +226,14 @@ discard block |
||
| 226 | 226 | ); |
| 227 | 227 | if (isset($http_status[$code])){ |
| 228 | 228 | $text = $http_status[$code]; |
| 229 | - } |
|
| 230 | - else{ |
|
| 229 | + } else{ |
|
| 231 | 230 | show_error('No HTTP status text found for your code please check it.'); |
| 232 | 231 | } |
| 233 | 232 | } |
| 234 | 233 | |
| 235 | 234 | if (strpos(php_sapi_name(), 'cgi') === 0){ |
| 236 | 235 | header('Status: ' . $code . ' ' . $text, TRUE); |
| 237 | - } |
|
| 238 | - else{ |
|
| 236 | + } else{ |
|
| 239 | 237 | $proto = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1'; |
| 240 | 238 | header($proto . ' ' . $code . ' ' . $text, TRUE, $code); |
| 241 | 239 | } |
@@ -277,11 +275,9 @@ discard block |
||
| 277 | 275 | */ |
| 278 | 276 | if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off'){ |
| 279 | 277 | return true; |
| 280 | - } |
|
| 281 | - else if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'){ |
|
| 278 | + } else if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'){ |
|
| 282 | 279 | return true; |
| 283 | - } |
|
| 284 | - else if (isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off'){ |
|
| 280 | + } else if (isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off'){ |
|
| 285 | 281 | return true; |
| 286 | 282 | } |
| 287 | 283 | return false; |
@@ -324,8 +320,7 @@ discard block |
||
| 324 | 320 | function php_exception_handler($ex){ |
| 325 | 321 | if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))){ |
| 326 | 322 | show_error('An exception is occured in file '. $ex->getFile() .' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception #' . $ex->getCode()); |
| 327 | - } |
|
| 328 | - else{ |
|
| 323 | + } else{ |
|
| 329 | 324 | save_to_log('error', 'An exception is occured in file ' . $ex->getFile() . ' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception'); |
| 330 | 325 | } |
| 331 | 326 | return true; |
@@ -447,15 +442,13 @@ discard block |
||
| 447 | 442 | function clean_input($str){ |
| 448 | 443 | if (is_array($str)){ |
| 449 | 444 | $str = array_map('clean_input', $str); |
| 450 | - } |
|
| 451 | - else if (is_object($str)){ |
|
| 445 | + } else if (is_object($str)){ |
|
| 452 | 446 | $obj = $str; |
| 453 | 447 | foreach ($str as $var => $value) { |
| 454 | 448 | $obj->$var = clean_input($value); |
| 455 | 449 | } |
| 456 | 450 | $str = $obj; |
| 457 | - } |
|
| 458 | - else{ |
|
| 451 | + } else{ |
|
| 459 | 452 | $str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8'); |
| 460 | 453 | } |
| 461 | 454 | return $str; |
@@ -528,8 +521,7 @@ discard block |
||
| 528 | 521 | session_save_path($sessionSavePath); |
| 529 | 522 | $logger->info('Session save path: ' . $sessionSavePath); |
| 530 | 523 | } |
| 531 | - } |
|
| 532 | - else if ($sessionHandler == 'database'){ |
|
| 524 | + } else if ($sessionHandler == 'database'){ |
|
| 533 | 525 | //load database session handle library |
| 534 | 526 | //Database Session handler Model |
| 535 | 527 | require_once CORE_CLASSES_MODEL_PATH . 'DBSessionHandlerModel.php'; |
@@ -537,8 +529,7 @@ discard block |
||
| 537 | 529 | $DBS =& class_loader('DBSessionHandler', 'classes'); |
| 538 | 530 | session_set_save_handler($DBS, true); |
| 539 | 531 | $logger->info('session save path: ' . get_config('session_save_path')); |
| 540 | - } |
|
| 541 | - else{ |
|
| 532 | + } else{ |
|
| 542 | 533 | show_error('Invalid session handler configuration'); |
| 543 | 534 | } |
| 544 | 535 | $lifetime = get_config('session_cookie_lifetime', 0); |
@@ -143,8 +143,7 @@ discard block |
||
| 143 | 143 | public function __construct(Database $db = null){ |
| 144 | 144 | if (is_object($db)){ |
| 145 | 145 | $this->setDatabaseInstance($db); |
| 146 | - } |
|
| 147 | - else{ |
|
| 146 | + } else{ |
|
| 148 | 147 | $obj = & get_instance(); |
| 149 | 148 | if (isset($obj->database) && is_object($obj->database)){ |
| 150 | 149 | /** |
@@ -260,8 +259,7 @@ discard block |
||
| 260 | 259 | $this->trigger('after_create', $insert_id); |
| 261 | 260 | //if the table doesn't have the auto increment field or sequence, the value of 0 will be returned |
| 262 | 261 | return ! $insert_id ? true : $insert_id; |
| 263 | - } |
|
| 264 | - else |
|
| 262 | + } else |
|
| 265 | 263 | { |
| 266 | 264 | return FALSE; |
| 267 | 265 | } |
@@ -298,8 +296,7 @@ discard block |
||
| 298 | 296 | $result = $this->_database->update($data, $escape); |
| 299 | 297 | $this->trigger('after_update', array($data, $result)); |
| 300 | 298 | return $result; |
| 301 | - } |
|
| 302 | - else |
|
| 299 | + } else |
|
| 303 | 300 | { |
| 304 | 301 | return FALSE; |
| 305 | 302 | } |
@@ -322,8 +319,7 @@ discard block |
||
| 322 | 319 | $result = $this->_database->update($data, $escape); |
| 323 | 320 | $this->trigger('after_update', array($data, $result)); |
| 324 | 321 | return $result; |
| 325 | - } |
|
| 326 | - else |
|
| 322 | + } else |
|
| 327 | 323 | { |
| 328 | 324 | return FALSE; |
| 329 | 325 | } |
@@ -340,8 +336,7 @@ discard block |
||
| 340 | 336 | if (is_array($args[1])){ |
| 341 | 337 | $data = array_pop($args); |
| 342 | 338 | } |
| 343 | - } |
|
| 344 | - else if (count($args) == 3){ |
|
| 339 | + } else if (count($args) == 3){ |
|
| 345 | 340 | if (is_array($args[2])){ |
| 346 | 341 | $data = array_pop($args); |
| 347 | 342 | } |
@@ -354,8 +349,7 @@ discard block |
||
| 354 | 349 | $result = $this->_database->update($data); |
| 355 | 350 | $this->trigger('after_update', array($data, $result)); |
| 356 | 351 | return $result; |
| 357 | - } |
|
| 358 | - else |
|
| 352 | + } else |
|
| 359 | 353 | { |
| 360 | 354 | return FALSE; |
| 361 | 355 | } |
@@ -385,8 +379,7 @@ discard block |
||
| 385 | 379 | { |
| 386 | 380 | $this->getQueryBuilder()->from($this->_table); |
| 387 | 381 | $result = $this->_database->update(array( $this->soft_delete_key => TRUE )); |
| 388 | - } |
|
| 389 | - else |
|
| 382 | + } else |
|
| 390 | 383 | { |
| 391 | 384 | $this->getQueryBuilder()->from($this->_table); |
| 392 | 385 | $result = $this->_database->delete(); |
@@ -409,8 +402,7 @@ discard block |
||
| 409 | 402 | { |
| 410 | 403 | $this->getQueryBuilder()->from($this->_table); |
| 411 | 404 | $result = $this->_database->update(array( $this->soft_delete_key => TRUE )); |
| 412 | - } |
|
| 413 | - else |
|
| 405 | + } else |
|
| 414 | 406 | { |
| 415 | 407 | $this->getQueryBuilder()->from($this->_table); |
| 416 | 408 | $result = $this->_database->delete(); |
@@ -431,8 +423,7 @@ discard block |
||
| 431 | 423 | { |
| 432 | 424 | $this->getQueryBuilder()->from($this->_table); |
| 433 | 425 | $result = $this->_database->update(array( $this->soft_delete_key => TRUE )); |
| 434 | - } |
|
| 435 | - else |
|
| 426 | + } else |
|
| 436 | 427 | { |
| 437 | 428 | $this->getQueryBuilder()->from($this->_table); |
| 438 | 429 | $result = $this->_database->delete(); |
@@ -494,8 +485,7 @@ discard block |
||
| 494 | 485 | if (count($args) == 2) |
| 495 | 486 | { |
| 496 | 487 | list($key, $value) = $args; |
| 497 | - } |
|
| 498 | - else |
|
| 488 | + } else |
|
| 499 | 489 | { |
| 500 | 490 | $key = $this->primary_key; |
| 501 | 491 | $value = $args[0]; |
@@ -647,8 +637,7 @@ discard block |
||
| 647 | 637 | if (is_object($row)) |
| 648 | 638 | { |
| 649 | 639 | $row->created_at = date('Y-m-d H:i:s'); |
| 650 | - } |
|
| 651 | - else |
|
| 640 | + } else |
|
| 652 | 641 | { |
| 653 | 642 | $row['created_at'] = date('Y-m-d H:i:s'); |
| 654 | 643 | } |
@@ -660,8 +649,7 @@ discard block |
||
| 660 | 649 | if (is_object($row)) |
| 661 | 650 | { |
| 662 | 651 | $row->updated_at = date('Y-m-d H:i:s'); |
| 663 | - } |
|
| 664 | - else |
|
| 652 | + } else |
|
| 665 | 653 | { |
| 666 | 654 | $row['updated_at'] = date('Y-m-d H:i:s'); |
| 667 | 655 | } |
@@ -688,8 +676,7 @@ discard block |
||
| 688 | 676 | if (is_array($row)) |
| 689 | 677 | { |
| 690 | 678 | $row[$column] = unserialize($row[$column]); |
| 691 | - } |
|
| 692 | - else |
|
| 679 | + } else |
|
| 693 | 680 | { |
| 694 | 681 | $row->$column = unserialize($row->$column); |
| 695 | 682 | } |
@@ -709,8 +696,7 @@ discard block |
||
| 709 | 696 | if (isset($row->$attr)){ |
| 710 | 697 | unset($row->$attr); |
| 711 | 698 | } |
| 712 | - } |
|
| 713 | - else |
|
| 699 | + } else |
|
| 714 | 700 | { |
| 715 | 701 | if (isset($row[$attr])){ |
| 716 | 702 | unset($row[$attr]); |
@@ -810,8 +796,7 @@ discard block |
||
| 810 | 796 | { |
| 811 | 797 | $this->getQueryBuilder()->orderBy($key, $value); |
| 812 | 798 | } |
| 813 | - } |
|
| 814 | - else |
|
| 799 | + } else |
|
| 815 | 800 | { |
| 816 | 801 | $this->getQueryBuilder()->orderBy($criteria, $order); |
| 817 | 802 | } |
@@ -842,8 +827,7 @@ discard block |
||
| 842 | 827 | { |
| 843 | 828 | $relationship = $value; |
| 844 | 829 | $options = array( 'primary_key' => $value . '_id', 'model' => $value . '_model' ); |
| 845 | - } |
|
| 846 | - else |
|
| 830 | + } else |
|
| 847 | 831 | { |
| 848 | 832 | $relationship = $key; |
| 849 | 833 | $options = $value; |
@@ -853,15 +837,13 @@ discard block |
||
| 853 | 837 | { |
| 854 | 838 | if (is_object($this->loaderInstance)){ |
| 855 | 839 | $this->loaderInstance->model($options['model'], $relationship . '_model'); |
| 856 | - } |
|
| 857 | - else{ |
|
| 840 | + } else{ |
|
| 858 | 841 | Loader::model($options['model'], $relationship . '_model'); |
| 859 | 842 | } |
| 860 | 843 | if (is_object($row)) |
| 861 | 844 | { |
| 862 | 845 | $row->{$relationship} = $this->{$relationship . '_model'}->get($row->{$options['primary_key']}); |
| 863 | - } |
|
| 864 | - else |
|
| 846 | + } else |
|
| 865 | 847 | { |
| 866 | 848 | $row[$relationship] = $this->{$relationship . '_model'}->get($row[$options['primary_key']]); |
| 867 | 849 | } |
@@ -881,8 +863,7 @@ discard block |
||
| 881 | 863 | { |
| 882 | 864 | $relationship = $value; |
| 883 | 865 | $options = array( 'primary_key' => $this->_table . '_id', 'model' => $value . '_model' ); |
| 884 | - } |
|
| 885 | - else |
|
| 866 | + } else |
|
| 886 | 867 | { |
| 887 | 868 | $relationship = $key; |
| 888 | 869 | $options = $value; |
@@ -892,15 +873,13 @@ discard block |
||
| 892 | 873 | { |
| 893 | 874 | if (is_object($this->loaderInstance)){ |
| 894 | 875 | $this->loaderInstance->model($options['model'], $relationship . '_model'); |
| 895 | - } |
|
| 896 | - else{ |
|
| 876 | + } else{ |
|
| 897 | 877 | Loader::model($options['model'], $relationship . '_model'); |
| 898 | 878 | } |
| 899 | 879 | if (is_object($row)) |
| 900 | 880 | { |
| 901 | 881 | $row->{$relationship} = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row->{$this->primary_key}); |
| 902 | - } |
|
| 903 | - else |
|
| 882 | + } else |
|
| 904 | 883 | { |
| 905 | 884 | $row[$relationship] = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row[$this->primary_key]); |
| 906 | 885 | } |
@@ -946,8 +925,7 @@ discard block |
||
| 946 | 925 | $fv = null; |
| 947 | 926 | if (is_object($this->formValidationInstance)){ |
| 948 | 927 | $fv = $this->formValidationInstance; |
| 949 | - } |
|
| 950 | - else{ |
|
| 928 | + } else{ |
|
| 951 | 929 | Loader::library('FormValidation'); |
| 952 | 930 | $fv = $this->formvalidation; |
| 953 | 931 | $this->setFormValidation($fv); |
@@ -959,13 +937,11 @@ discard block |
||
| 959 | 937 | if ($fv->run()) |
| 960 | 938 | { |
| 961 | 939 | return $data; |
| 962 | - } |
|
| 963 | - else |
|
| 940 | + } else |
|
| 964 | 941 | { |
| 965 | 942 | return FALSE; |
| 966 | 943 | } |
| 967 | - } |
|
| 968 | - else |
|
| 944 | + } else |
|
| 969 | 945 | { |
| 970 | 946 | return $data; |
| 971 | 947 | } |
@@ -982,14 +958,12 @@ discard block |
||
| 982 | 958 | if (is_array($filter)) |
| 983 | 959 | { |
| 984 | 960 | $this->getQueryBuilder()->in($field, $filter); |
| 985 | - } |
|
| 986 | - else |
|
| 961 | + } else |
|
| 987 | 962 | { |
| 988 | 963 | if (is_int($field)) |
| 989 | 964 | { |
| 990 | 965 | $this->getQueryBuilder()->where($filter); |
| 991 | - } |
|
| 992 | - else |
|
| 966 | + } else |
|
| 993 | 967 | { |
| 994 | 968 | $this->getQueryBuilder()->where($field, $filter); |
| 995 | 969 | } |
@@ -1006,33 +980,27 @@ discard block |
||
| 1006 | 980 | if (count($params) == 1 && is_array($params[0])) |
| 1007 | 981 | { |
| 1008 | 982 | $this->_set_where_array($params[0]); |
| 1009 | - } |
|
| 1010 | - else if (count($params) == 1) |
|
| 983 | + } else if (count($params) == 1) |
|
| 1011 | 984 | { |
| 1012 | 985 | $this->getQueryBuilder()->where($params[0]); |
| 1013 | - } |
|
| 1014 | - else if (count($params) == 2) |
|
| 986 | + } else if (count($params) == 2) |
|
| 1015 | 987 | { |
| 1016 | 988 | if (is_array($params[1])) |
| 1017 | 989 | { |
| 1018 | 990 | $this->getQueryBuilder()->in($params[0], $params[1]); |
| 1019 | - } |
|
| 1020 | - else |
|
| 991 | + } else |
|
| 1021 | 992 | { |
| 1022 | 993 | $this->getQueryBuilder()->where($params[0], $params[1]); |
| 1023 | 994 | } |
| 1024 | - } |
|
| 1025 | - else if (count($params) == 3) |
|
| 995 | + } else if (count($params) == 3) |
|
| 1026 | 996 | { |
| 1027 | 997 | $this->getQueryBuilder()->where($params[0], $params[1], $params[2]); |
| 1028 | - } |
|
| 1029 | - else |
|
| 998 | + } else |
|
| 1030 | 999 | { |
| 1031 | 1000 | if (is_array($params[1])) |
| 1032 | 1001 | { |
| 1033 | 1002 | $this->getQueryBuilder()->in($params[0], $params[1]); |
| 1034 | - } |
|
| 1035 | - else |
|
| 1003 | + } else |
|
| 1036 | 1004 | { |
| 1037 | 1005 | $this->getQueryBuilder()->where($params[0], $params[1]); |
| 1038 | 1006 | } |
@@ -153,14 +153,12 @@ discard block |
||
| 153 | 153 | $this->pdo->exec("SET CHARACTER SET '" . $config['charset'] . "'"); |
| 154 | 154 | $this->pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ); |
| 155 | 155 | return true; |
| 156 | - } |
|
| 157 | - catch (PDOException $e){ |
|
| 156 | + } catch (PDOException $e){ |
|
| 158 | 157 | $this->logger->fatal($e->getMessage()); |
| 159 | 158 | show_error('Cannot connect to Database.'); |
| 160 | 159 | return false; |
| 161 | 160 | } |
| 162 | - } |
|
| 163 | - else{ |
|
| 161 | + } else{ |
|
| 164 | 162 | show_error('Database configuration is not set.'); |
| 165 | 163 | return false; |
| 166 | 164 | } |
@@ -203,8 +201,7 @@ discard block |
||
| 203 | 201 | $query = $this->getAll(true); |
| 204 | 202 | if ($returnSQLQueryOrResultType === true){ |
| 205 | 203 | return $query; |
| 206 | - } |
|
| 207 | - else{ |
|
| 204 | + } else{ |
|
| 208 | 205 | return $this->query($query, false, $returnSQLQueryOrResultType == 'array'); |
| 209 | 206 | } |
| 210 | 207 | } |
@@ -628,15 +625,13 @@ discard block |
||
| 628 | 625 | //if need return all result like list of record |
| 629 | 626 | if (is_bool($all) && $all){ |
| 630 | 627 | $this->result = ($array === false) ? $pdoStatment->fetchAll(PDO::FETCH_OBJ) : $pdoStatment->fetchAll(PDO::FETCH_ASSOC); |
| 631 | - } |
|
| 632 | - else{ |
|
| 628 | + } else{ |
|
| 633 | 629 | $this->result = ($array === false) ? $pdoStatment->fetch(PDO::FETCH_OBJ) : $pdoStatment->fetch(PDO::FETCH_ASSOC); |
| 634 | 630 | } |
| 635 | 631 | //Sqlite and pgsql always return 0 when using rowCount() |
| 636 | 632 | if (in_array($this->config['driver'], array('sqlite', 'pgsql'))){ |
| 637 | 633 | $this->numRows = count($this->result); |
| 638 | - } |
|
| 639 | - else{ |
|
| 634 | + } else{ |
|
| 640 | 635 | $this->numRows = $pdoStatment->rowCount(); |
| 641 | 636 | } |
| 642 | 637 | } |
@@ -650,8 +645,7 @@ discard block |
||
| 650 | 645 | if (in_array($this->config['driver'], array('sqlite', 'pgsql'))){ |
| 651 | 646 | $this->result = true; //to test the result for the query like UPDATE, INSERT, DELETE |
| 652 | 647 | $this->numRows = 1; //TODO use the correct method to get the exact affected row |
| 653 | - } |
|
| 654 | - else{ |
|
| 648 | + } else{ |
|
| 655 | 649 | $this->result = $pdoStatment->rowCount() >= 0; //to test the result for the query like UPDATE, INSERT, DELETE |
| 656 | 650 | $this->numRows = $pdoStatment->rowCount(); |
| 657 | 651 | } |
@@ -776,8 +770,7 @@ discard block |
||
| 776 | 770 | protected function setLoggerFromParamOrCreateNewInstance(Log $logger = null){ |
| 777 | 771 | if ($logger !== null){ |
| 778 | 772 | $this->setLogger($logger); |
| 779 | - } |
|
| 780 | - else{ |
|
| 773 | + } else{ |
|
| 781 | 774 | $this->logger =& class_loader('Log', 'classes'); |
| 782 | 775 | $this->logger->setLogger('Library::Database'); |
| 783 | 776 | } |
@@ -790,8 +783,7 @@ discard block |
||
| 790 | 783 | protected function setQueryBuilderFromParamOrCreateNewInstance(DatabaseQueryBuilder $queryBuilder = null){ |
| 791 | 784 | if ($queryBuilder !== null){ |
| 792 | 785 | $this->setQueryBuilder($queryBuilder); |
| 793 | - } |
|
| 794 | - else{ |
|
| 786 | + } else{ |
|
| 795 | 787 | $this->queryBuilder =& class_loader('DatabaseQueryBuilder', 'classes'); |
| 796 | 788 | } |
| 797 | 789 | } |