@@ -241,12 +241,12 @@ discard block |
||
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
| 244 | - * Setting the route configuration using the configuration file and additional configuration from param |
|
| 245 | - * @param array $overwriteConfig the additional configuration to overwrite with the existing one |
|
| 246 | - * @param boolean $useConfigFile whether to use route configuration file |
|
| 247 | - * |
|
| 248 | - * @return object |
|
| 249 | - */ |
|
| 244 | + * Setting the route configuration using the configuration file and additional configuration from param |
|
| 245 | + * @param array $overwriteConfig the additional configuration to overwrite with the existing one |
|
| 246 | + * @param boolean $useConfigFile whether to use route configuration file |
|
| 247 | + * |
|
| 248 | + * @return object |
|
| 249 | + */ |
|
| 250 | 250 | public function setRouteConfiguration(array $overwriteConfig = array(), $useConfigFile = true) { |
| 251 | 251 | $route = array(); |
| 252 | 252 | if ($useConfigFile && file_exists(CONFIG_PATH . 'routes.php')) { |
@@ -423,11 +423,11 @@ discard block |
||
| 423 | 423 | } |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | - /** |
|
| 427 | - * Remove the URL suffix and query string values if exists |
|
| 428 | - * @param string $uri the route URI to process |
|
| 429 | - * @return string the final route uri after processed |
|
| 430 | - */ |
|
| 426 | + /** |
|
| 427 | + * Remove the URL suffix and query string values if exists |
|
| 428 | + * @param string $uri the route URI to process |
|
| 429 | + * @return string the final route uri after processed |
|
| 430 | + */ |
|
| 431 | 431 | protected function removeSuffixAndQueryStringFromUri($uri) { |
| 432 | 432 | $this->logger->debug('Check if URL suffix is enabled in the configuration'); |
| 433 | 433 | //remove url suffix from the request URI |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | $this->logger->info( |
| 541 | 541 | 'After loop in predefined routes configuration,' |
| 542 | 542 | . 'the module name is set but the controller is not set,' |
| 543 | - . 'so we will use module as the controller' |
|
| 543 | + . 'so we will use module as the controller' |
|
| 544 | 544 | ); |
| 545 | 545 | $this->controller = $this->module; |
| 546 | 546 | } |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | * Remove the DOCUMENT_ROOT and front controller from segments if exists |
| 444 | 444 | * @return void |
| 445 | 445 | */ |
| 446 | - protected function removeDocumentRootFrontControllerFromSegments(){ |
|
| 446 | + protected function removeDocumentRootFrontControllerFromSegments() { |
|
| 447 | 447 | $segment = $this->segments; |
| 448 | 448 | $baseUrl = get_config('base_url'); |
| 449 | 449 | //check if the app is not in DOCUMENT_ROOT |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | break; |
| 562 | 562 | } |
| 563 | 563 | } |
| 564 | - if($findIndex !== -1){ |
|
| 564 | + if ($findIndex !== -1) { |
|
| 565 | 565 | //$args[0] => full string captured by preg_match |
| 566 | 566 | //$args[1], $args[2], $args[n] => contains the value of |
| 567 | 567 | //(:num), (:alpha), (:alnum), (:any) |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | * Find file path of the current controller using the current module |
| 587 | 587 | * @return boolean true if the file path is found otherwise false. |
| 588 | 588 | */ |
| 589 | - protected function findControllerFullPathUsingCurrentModule(){ |
|
| 589 | + protected function findControllerFullPathUsingCurrentModule() { |
|
| 590 | 590 | $path = $this->moduleInstance->findControllerFullPath(ucfirst($this->controller), $this->module); |
| 591 | 591 | if (!$path) { |
| 592 | 592 | $this->logger->info('The controller [' . $this->controller . '] not found in the module, may be will use the module [' . $this->module . '] as controller'); |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | * or the current request does not use module |
| 603 | 603 | * @return void |
| 604 | 604 | */ |
| 605 | - protected function setRouteParamsIfNoModuleOrNotFound(){ |
|
| 605 | + protected function setRouteParamsIfNoModuleOrNotFound() { |
|
| 606 | 606 | $segment = $this->segments; |
| 607 | 607 | //controller |
| 608 | 608 | if (isset($segment[0])) { |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | * or the current request use module |
| 624 | 624 | * @return void |
| 625 | 625 | */ |
| 626 | - protected function setRouteParamsIfAppHasModuleOrFound(){ |
|
| 626 | + protected function setRouteParamsIfAppHasModuleOrFound() { |
|
| 627 | 627 | //get the module list |
| 628 | 628 | $modules = $this->moduleInstance->getModuleList(); |
| 629 | 629 | $segment = $this->segments; |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | $this->controller = $segment[0]; |
| 637 | 637 | |
| 638 | 638 | //check if the request use the same module name and controller |
| 639 | - if($this->findControllerFullPathUsingCurrentModule()){ |
|
| 639 | + if ($this->findControllerFullPathUsingCurrentModule()) { |
|
| 640 | 640 | array_shift($segment); |
| 641 | 641 | } |
| 642 | 642 | } |
@@ -84,10 +84,10 @@ |
||
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | - * This method is used to check the whitelist IP address access |
|
| 88 | - * |
|
| 89 | - * @return boolean |
|
| 90 | - */ |
|
| 87 | + * This method is used to check the whitelist IP address access |
|
| 88 | + * |
|
| 89 | + * @return boolean |
|
| 90 | + */ |
|
| 91 | 91 | public static function checkWhiteListIpAccess() { |
| 92 | 92 | $logger = self::getLogger(); |
| 93 | 93 | $logger->debug('Validation of the IP address access ...'); |
@@ -45,7 +45,7 @@ |
||
| 45 | 45 | $attributes['accept-charset'] = get_config('charset', 'UTF-8'); |
| 46 | 46 | } |
| 47 | 47 | if (!empty($enctype)) { |
| 48 | - $attributes['enctype'] = $enctype; |
|
| 48 | + $attributes['enctype'] = $enctype; |
|
| 49 | 49 | } |
| 50 | 50 | $str .= attributes_to_string($attributes); |
| 51 | 51 | $str .= '>'; |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | * Set the file array data generally in constructor this is already set using $_FILES |
| 277 | 277 | * @param array $fileArray the new value |
| 278 | 278 | */ |
| 279 | - public function setFileArray($fileArray){ |
|
| 279 | + public function setFileArray($fileArray) { |
|
| 280 | 280 | $this->file_array = $fileArray; |
| 281 | 281 | } |
| 282 | 282 | |
@@ -594,7 +594,7 @@ discard block |
||
| 594 | 594 | * @return string |
| 595 | 595 | */ |
| 596 | 596 | public function getDestinationDirectory() { |
| 597 | - return $this->destination_directory ; |
|
| 597 | + return $this->destination_directory; |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | /** |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | * @return boolean |
| 603 | 603 | */ |
| 604 | 604 | public function isAllowOverwriting() { |
| 605 | - return $this->overwrite_file ; |
|
| 605 | + return $this->overwrite_file; |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | /** |
@@ -1,32 +1,32 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | defined('ROOT_PATH') || exit('Access denied'); |
| 3 | - /** |
|
| 4 | - * TNH Framework |
|
| 5 | - * |
|
| 6 | - * A simple PHP framework using HMVC architecture |
|
| 7 | - * |
|
| 8 | - * This content is released under the MIT License (MIT) |
|
| 9 | - * |
|
| 10 | - * Copyright (c) 2017 TNH Framework |
|
| 11 | - * |
|
| 12 | - * Permission is hereby granted, free of charge, to any person obtaining a copy |
|
| 13 | - * of this software and associated documentation files (the "Software"), to deal |
|
| 14 | - * in the Software without restriction, including without limitation the rights |
|
| 15 | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
| 16 | - * copies of the Software, and to permit persons to whom the Software is |
|
| 17 | - * furnished to do so, subject to the following conditions: |
|
| 18 | - * |
|
| 19 | - * The above copyright notice and this permission notice shall be included in all |
|
| 20 | - * copies or substantial portions of the Software. |
|
| 21 | - * |
|
| 22 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
| 23 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
| 24 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
| 25 | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
| 26 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
| 27 | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
| 28 | - * SOFTWARE. |
|
| 29 | - */ |
|
| 3 | + /** |
|
| 4 | + * TNH Framework |
|
| 5 | + * |
|
| 6 | + * A simple PHP framework using HMVC architecture |
|
| 7 | + * |
|
| 8 | + * This content is released under the MIT License (MIT) |
|
| 9 | + * |
|
| 10 | + * Copyright (c) 2017 TNH Framework |
|
| 11 | + * |
|
| 12 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
|
| 13 | + * of this software and associated documentation files (the "Software"), to deal |
|
| 14 | + * in the Software without restriction, including without limitation the rights |
|
| 15 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
| 16 | + * copies of the Software, and to permit persons to whom the Software is |
|
| 17 | + * furnished to do so, subject to the following conditions: |
|
| 18 | + * |
|
| 19 | + * The above copyright notice and this permission notice shall be included in all |
|
| 20 | + * copies or substantial portions of the Software. |
|
| 21 | + * |
|
| 22 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
| 23 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
| 24 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
| 25 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
| 26 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
| 27 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
| 28 | + * SOFTWARE. |
|
| 29 | + */ |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * @file bootstrap.php |
@@ -29,8 +29,8 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | - * DB session handler model class |
|
| 33 | - */ |
|
| 32 | + * DB session handler model class |
|
| 33 | + */ |
|
| 34 | 34 | abstract class DBSessionHandlerModel extends Model { |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -387,9 +387,9 @@ discard block |
||
| 387 | 387 | $this->queryCount++; |
| 388 | 388 | |
| 389 | 389 | $queryResult = $this->queryRunner->setQuery($query) |
| 390 | - ->setReturnType($returnAsList) |
|
| 391 | - ->setReturnAsArray($returnAsArray) |
|
| 392 | - ->execute(); |
|
| 390 | + ->setReturnType($returnAsList) |
|
| 391 | + ->setReturnAsArray($returnAsArray) |
|
| 392 | + ->execute(); |
|
| 393 | 393 | |
| 394 | 394 | if (is_object($queryResult)) { |
| 395 | 395 | $this->result = $queryResult->getResult(); |
@@ -405,11 +405,11 @@ discard block |
||
| 405 | 405 | return $this->result; |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - /** |
|
| 409 | - * Set the connection instance using database configuration file |
|
| 410 | - * |
|
| 411 | - * @return object|void |
|
| 412 | - */ |
|
| 408 | + /** |
|
| 409 | + * Set the connection instance using database configuration file |
|
| 410 | + * |
|
| 411 | + * @return object|void |
|
| 412 | + */ |
|
| 413 | 413 | protected function setConnectionUsingConfigFile(){ |
| 414 | 414 | $dbConfigFromFile = $this->getDatabaseConfigFromFile(); |
| 415 | 415 | $connection = &class_loader('DatabaseConnection', 'classes/database'); |
@@ -422,7 +422,6 @@ discard block |
||
| 422 | 422 | |
| 423 | 423 | /** |
| 424 | 424 | * Get the database configuration using the configuration file |
| 425 | - |
|
| 426 | 425 | * @return array the database configuration from file |
| 427 | 426 | */ |
| 428 | 427 | protected function getDatabaseConfigFromFile() { |
@@ -410,7 +410,7 @@ |
||
| 410 | 410 | * |
| 411 | 411 | * @return object|void |
| 412 | 412 | */ |
| 413 | - protected function setConnectionUsingConfigFile(){ |
|
| 413 | + protected function setConnectionUsingConfigFile() { |
|
| 414 | 414 | $dbConfigFromFile = $this->getDatabaseConfigFromFile(); |
| 415 | 415 | $connection = &class_loader('DatabaseConnection', 'classes/database'); |
| 416 | 416 | $connection->setConfig($dbConfigFromFile); |
@@ -42,28 +42,28 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | private $driver = null; |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * The database hostname |
|
| 47 | - * @var string |
|
| 48 | - */ |
|
| 45 | + /** |
|
| 46 | + * The database hostname |
|
| 47 | + * @var string |
|
| 48 | + */ |
|
| 49 | 49 | private $hostname = null; |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * The database port |
|
| 53 | - * @var integer |
|
| 54 | - */ |
|
| 51 | + /** |
|
| 52 | + * The database port |
|
| 53 | + * @var integer |
|
| 54 | + */ |
|
| 55 | 55 | private $port = null; |
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * The database username |
|
| 59 | - * @var string |
|
| 60 | - */ |
|
| 57 | + /** |
|
| 58 | + * The database username |
|
| 59 | + * @var string |
|
| 60 | + */ |
|
| 61 | 61 | private $username = null; |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * The database password |
|
| 65 | - * @var string |
|
| 66 | - */ |
|
| 63 | + /** |
|
| 64 | + * The database password |
|
| 65 | + * @var string |
|
| 66 | + */ |
|
| 67 | 67 | private $password = null; |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -72,10 +72,10 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | private $databaseName = null; |
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * The database charset |
|
| 77 | - * @var string |
|
| 78 | - */ |
|
| 75 | + /** |
|
| 76 | + * The database charset |
|
| 77 | + * @var string |
|
| 78 | + */ |
|
| 79 | 79 | private $charset = null; |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -84,10 +84,10 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | private $collation = null; |
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * The database tables prefix |
|
| 89 | - * @var string |
|
| 90 | - */ |
|
| 87 | + /** |
|
| 88 | + * The database tables prefix |
|
| 89 | + * @var string |
|
| 90 | + */ |
|
| 91 | 91 | private $prefix = null; |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - /** |
|
| 118 | - * This is method is used to connect to database |
|
| 119 | - * |
|
| 120 | - * @return boolean true in case of successfully connection false if error |
|
| 121 | - */ |
|
| 117 | + /** |
|
| 118 | + * This is method is used to connect to database |
|
| 119 | + * |
|
| 120 | + * @return boolean true in case of successfully connection false if error |
|
| 121 | + */ |
|
| 122 | 122 | public function connect() { |
| 123 | 123 | try { |
| 124 | 124 | $this->pdo = new PDO($this->getDsnValue(), $this->getUsername(), $this->getPassword()); |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | $this->populatePropertiesFromConfig(); |
| 410 | 410 | |
| 411 | 411 | if (!empty($this->config)) { |
| 412 | - //For logging |
|
| 412 | + //For logging |
|
| 413 | 413 | $configInfo = $this->config; |
| 414 | 414 | //Hide password from log |
| 415 | 415 | $configInfo['password'] = string_hidden($this->getPassword()); |
@@ -418,11 +418,11 @@ discard block |
||
| 418 | 418 | return $this; |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - /** |
|
| 422 | - * Update the properties using the current database configuration |
|
| 423 | - * |
|
| 424 | - * @return object the current instance |
|
| 425 | - */ |
|
| 421 | + /** |
|
| 422 | + * Update the properties using the current database configuration |
|
| 423 | + * |
|
| 424 | + * @return object the current instance |
|
| 425 | + */ |
|
| 426 | 426 | protected function populatePropertiesFromConfig() { |
| 427 | 427 | foreach ($this->config as $key => $value) { |
| 428 | 428 | $setter = 'set' . ucfirst($key); |
@@ -30,10 +30,10 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | class DatabaseQueryBuilder { |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * The DatabaseConnection instance |
|
| 35 | - * @var object |
|
| 36 | - */ |
|
| 33 | + /** |
|
| 34 | + * The DatabaseConnection instance |
|
| 35 | + * @var object |
|
| 36 | + */ |
|
| 37 | 37 | private $connection = null; |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -727,12 +727,12 @@ discard block |
||
| 727 | 727 | * |
| 728 | 728 | * @return string|null |
| 729 | 729 | */ |
| 730 | - protected function buildQueryPart($property, $command = ''){ |
|
| 730 | + protected function buildQueryPart($property, $command = ''){ |
|
| 731 | 731 | if (!empty($this->{$property})) { |
| 732 | 732 | return $command . $this->{$property}; |
| 733 | 733 | } |
| 734 | 734 | return null; |
| 735 | - } |
|
| 735 | + } |
|
| 736 | 736 | |
| 737 | 737 | |
| 738 | 738 | /** |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | $_keys = array(); |
| 415 | 415 | foreach ($keys as $k => $v) { |
| 416 | 416 | $v = $this->checkForNullValue($v); |
| 417 | - if (! is_numeric($v)) { |
|
| 417 | + if (!is_numeric($v)) { |
|
| 418 | 418 | $v = $this->connection->escape($v, $escape); |
| 419 | 419 | } |
| 420 | 420 | $_keys[] = $v; |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | * |
| 728 | 728 | * @return string|null |
| 729 | 729 | */ |
| 730 | - protected function buildQueryPart($property, $command = ''){ |
|
| 730 | + protected function buildQueryPart($property, $command = '') { |
|
| 731 | 731 | if (!empty($this->{$property})) { |
| 732 | 732 | return $command . $this->{$property}; |
| 733 | 733 | } |
@@ -742,7 +742,7 @@ discard block |
||
| 742 | 742 | * @param string $clause the clause type "IS NULL", "IS NOT NULLs" |
| 743 | 743 | * @return object the current DatabaseQueryBuilder instance |
| 744 | 744 | */ |
| 745 | - protected function whereIsNullAndNotNull($field, $andOr = 'AND', $clause = 'IS NULL'){ |
|
| 745 | + protected function whereIsNullAndNotNull($field, $andOr = 'AND', $clause = 'IS NULL') { |
|
| 746 | 746 | if (is_array($field)) { |
| 747 | 747 | foreach ($field as $f) { |
| 748 | 748 | $this->whereIsNullAndNotNull($f, $andOr, $clause); |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | * |
| 761 | 761 | * @return object the current instance |
| 762 | 762 | */ |
| 763 | - protected function setSelectStr($newSelect){ |
|
| 763 | + protected function setSelectStr($newSelect) { |
|
| 764 | 764 | $this->select = (($this->select == '*' || empty($this->select)) |
| 765 | 765 | ? $newSelect |
| 766 | 766 | : $this->select . ', ' . $newSelect); |
@@ -774,8 +774,8 @@ discard block |
||
| 774 | 774 | * @return string the empty string if the value is null |
| 775 | 775 | * otherwise the same value will be returned |
| 776 | 776 | */ |
| 777 | - protected function checkForNullValue($value){ |
|
| 778 | - if(is_null($value)){ |
|
| 777 | + protected function checkForNullValue($value) { |
|
| 778 | + if (is_null($value)) { |
|
| 779 | 779 | return ''; |
| 780 | 780 | } |
| 781 | 781 | return $value; |