@@ -32,8 +32,8 @@ |
||
| 32 | 32 | <p>Required PHP version : <b>PHP >= <?php echo TNH_MIN_PHP_VERSION; ?>, PHP < <?php echo TNH_MAX_PHP_VERSION; ?></b></p> |
| 33 | 33 | <p>Release date : <b><?php echo TNH_RELEASE_DATE; ?></b></p> |
| 34 | 34 | <hr /> |
| 35 | - <p>Current controller: <b class = "text-muted label-danger"><?php echo APPS_CONTROLLER_PATH . 'Home.php';?></b> |
|
| 36 | - <p>Current view: <b class = "text-muted label-danger"><?php echo APPS_VIEWS_PATH . 'home.php';?></b> |
|
| 35 | + <p>Current controller: <b class = "text-muted label-danger"><?php echo APPS_CONTROLLER_PATH . 'Home.php'; ?></b> |
|
| 36 | + <p>Current view: <b class = "text-muted label-danger"><?php echo APPS_VIEWS_PATH . 'home.php'; ?></b> |
|
| 37 | 37 | </div> |
| 38 | 38 | </div> |
| 39 | 39 | </div> |
@@ -234,10 +234,10 @@ discard block |
||
| 234 | 234 | return $this->removeVars($_ENV, $key); |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - /** |
|
| 238 | - * Get the value from $GLOBALS for given key. if the key is empty will return all values |
|
| 239 | - * @see GlobalVar::getVars |
|
| 240 | - */ |
|
| 237 | + /** |
|
| 238 | + * Get the value from $GLOBALS for given key. if the key is empty will return all values |
|
| 239 | + * @see GlobalVar::getVars |
|
| 240 | + */ |
|
| 241 | 241 | public function globals($key = null, $xss = true) { |
| 242 | 242 | return $this->getVars($GLOBALS, $key, $xss); |
| 243 | 243 | } |
@@ -259,16 +259,16 @@ discard block |
||
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | |
| 262 | - /** |
|
| 263 | - * Set the value for $_GET, $_POST, $_SERVER etc. if the key is an array will |
|
| 264 | - * set the current super variable value by this. |
|
| 265 | - * @param array $var the super global variable to use, can be "$_POST", "$_GET", etc. |
|
| 266 | - * @param string|array $key the item key to be set or array if need set the current global variable |
|
| 267 | - * by this value |
|
| 268 | - * @param mixed $value the value to set if $key is not an array |
|
| 269 | - * |
|
| 270 | - * @return object the current instance |
|
| 271 | - */ |
|
| 262 | + /** |
|
| 263 | + * Set the value for $_GET, $_POST, $_SERVER etc. if the key is an array will |
|
| 264 | + * set the current super variable value by this. |
|
| 265 | + * @param array $var the super global variable to use, can be "$_POST", "$_GET", etc. |
|
| 266 | + * @param string|array $key the item key to be set or array if need set the current global variable |
|
| 267 | + * by this value |
|
| 268 | + * @param mixed $value the value to set if $key is not an array |
|
| 269 | + * |
|
| 270 | + * @return object the current instance |
|
| 271 | + */ |
|
| 272 | 272 | protected function setVars(&$var, $key, $value = null) { |
| 273 | 273 | if (is_array($key)) { |
| 274 | 274 | //set all |
@@ -207,10 +207,10 @@ |
||
| 207 | 207 | return $this; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - /** |
|
| 211 | - * Return the instance of session. |
|
| 212 | - * @return object the session instance |
|
| 213 | - */ |
|
| 210 | + /** |
|
| 211 | + * Return the instance of session. |
|
| 212 | + * @return object the session instance |
|
| 213 | + */ |
|
| 214 | 214 | public function getSession() { |
| 215 | 215 | return $this->session; |
| 216 | 216 | } |
@@ -163,17 +163,17 @@ |
||
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
| 166 | - * Return the server port using variable |
|
| 167 | - * |
|
| 168 | - * @codeCoverageIgnore |
|
| 169 | - * @return string |
|
| 170 | - */ |
|
| 166 | + * Return the server port using variable |
|
| 167 | + * |
|
| 168 | + * @codeCoverageIgnore |
|
| 169 | + * @return string |
|
| 170 | + */ |
|
| 171 | 171 | protected function getServerPort() { |
| 172 | 172 | $globals = & class_loader('GlobalVar', 'classes'); |
| 173 | 173 | $serverPortValue = $globals->server('SERVER_PORT'); |
| 174 | 174 | $serverPort = 80; |
| 175 | 175 | if ($serverPortValue) { |
| 176 | - $serverPort = $serverPortValue; |
|
| 176 | + $serverPort = $serverPortValue; |
|
| 177 | 177 | } |
| 178 | 178 | $port = ''; |
| 179 | 179 | if ((is_https() && $serverPort != 443) || (!is_https() && $serverPort != 80)) { |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $this->logger->debug('Check if the application contains the modules ...'); |
| 47 | 47 | $dirList = glob(MODULE_PATH . '*', GLOB_ONLYDIR); |
| 48 | 48 | if ($dirList !== false) { |
| 49 | - $this->list = array_map('basename', $dirList); |
|
| 49 | + $this->list = array_map('basename', $dirList); |
|
| 50 | 50 | } |
| 51 | 51 | if (!empty($this->list)) { |
| 52 | 52 | $this->logger->info('The application contains the module below [' . implode(', ', $this->list) . ']'); |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function add($name) { |
| 63 | 63 | if (in_array($name, $this->list)) { |
| 64 | - $this->logger->info('The module [' .$name. '] already added skipping.'); |
|
| 65 | - return $this; |
|
| 64 | + $this->logger->info('The module [' .$name. '] already added skipping.'); |
|
| 65 | + return $this; |
|
| 66 | 66 | } |
| 67 | 67 | $this->list[] = $name; |
| 68 | 68 | return $this; |
@@ -93,10 +93,10 @@ discard block |
||
| 93 | 93 | $this->list = array(); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Get the list of module loaded |
|
| 98 | - * @return array the module list |
|
| 99 | - */ |
|
| 96 | + /** |
|
| 97 | + * Get the list of module loaded |
|
| 98 | + * @return array the module list |
|
| 99 | + */ |
|
| 100 | 100 | public function getModuleList() { |
| 101 | 101 | return $this->list; |
| 102 | 102 | } |
@@ -61,7 +61,7 @@ |
||
| 61 | 61 | */ |
| 62 | 62 | public function add($name) { |
| 63 | 63 | if (in_array($name, $this->list)) { |
| 64 | - $this->logger->info('The module [' .$name. '] already added skipping.'); |
|
| 64 | + $this->logger->info('The module [' . $name . '] already added skipping.'); |
|
| 65 | 65 | return $this; |
| 66 | 66 | } |
| 67 | 67 | $this->list[] = $name; |
@@ -680,22 +680,22 @@ discard block |
||
| 680 | 680 | return $data; |
| 681 | 681 | } |
| 682 | 682 | |
| 683 | - /** |
|
| 684 | - * Get the return type array or object |
|
| 685 | - * @return string|boolean |
|
| 686 | - */ |
|
| 683 | + /** |
|
| 684 | + * Get the return type array or object |
|
| 685 | + * @return string|boolean |
|
| 686 | + */ |
|
| 687 | 687 | protected function getReturnType(){ |
| 688 | 688 | $type = false; |
| 689 | 689 | if ($this->_temporary_return_type == 'array') { |
| 690 | - $type = 'array'; |
|
| 690 | + $type = 'array'; |
|
| 691 | 691 | } |
| 692 | 692 | return $type; |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | - /** |
|
| 696 | - * Check if soft delete is enable setting the condition |
|
| 697 | - * @return object the current instance |
|
| 698 | - */ |
|
| 695 | + /** |
|
| 696 | + * Check if soft delete is enable setting the condition |
|
| 697 | + * @return object the current instance |
|
| 698 | + */ |
|
| 699 | 699 | protected function checkForSoftDelete(){ |
| 700 | 700 | if ($this->soft_delete && $this->_temporary_with_deleted !== true) { |
| 701 | 701 | $this->getQueryBuilder()->where($this->soft_delete_key, (bool) $this->_temporary_only_deleted); |
@@ -703,14 +703,14 @@ discard block |
||
| 703 | 703 | return $this; |
| 704 | 704 | } |
| 705 | 705 | |
| 706 | - /** |
|
| 707 | - * Relate for "belongs_to" and "has_many" |
|
| 708 | - * @param string $relationship the name of relation |
|
| 709 | - * @param string|array $options the model and primary key values |
|
| 710 | - * @param object|array $row the row to update |
|
| 711 | - * @param string $type the type can be "belongs_to", "has_many" |
|
| 712 | - * @return mixed the final row values |
|
| 713 | - */ |
|
| 706 | + /** |
|
| 707 | + * Relate for "belongs_to" and "has_many" |
|
| 708 | + * @param string $relationship the name of relation |
|
| 709 | + * @param string|array $options the model and primary key values |
|
| 710 | + * @param object|array $row the row to update |
|
| 711 | + * @param string $type the type can be "belongs_to", "has_many" |
|
| 712 | + * @return mixed the final row values |
|
| 713 | + */ |
|
| 714 | 714 | protected function relateBelongsToAndHasMany($relationship, $options, $row, $type){ |
| 715 | 715 | if (in_array($relationship, $this->_with)) { |
| 716 | 716 | get_instance()->loader->model($options['model'], $relationship . '_model'); |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | $instance = $db; |
| 144 | 144 | } else { |
| 145 | 145 | $obj = & get_instance(); |
| 146 | - if (isset($obj->database)){ |
|
| 146 | + if (isset($obj->database)) { |
|
| 147 | 147 | /** |
| 148 | 148 | * NOTE: Need use "clone" because some Model need have the personal instance of the database library |
| 149 | 149 | * to prevent duplication |
@@ -684,7 +684,7 @@ discard block |
||
| 684 | 684 | * Get the return type array or object |
| 685 | 685 | * @return string|boolean |
| 686 | 686 | */ |
| 687 | - protected function getReturnType(){ |
|
| 687 | + protected function getReturnType() { |
|
| 688 | 688 | $type = false; |
| 689 | 689 | if ($this->_temporary_return_type == 'array') { |
| 690 | 690 | $type = 'array'; |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | * Check if soft delete is enable setting the condition |
| 697 | 697 | * @return object the current instance |
| 698 | 698 | */ |
| 699 | - protected function checkForSoftDelete(){ |
|
| 699 | + protected function checkForSoftDelete() { |
|
| 700 | 700 | if ($this->soft_delete && $this->_temporary_with_deleted !== true) { |
| 701 | 701 | $this->getQueryBuilder()->where($this->soft_delete_key, (bool) $this->_temporary_only_deleted); |
| 702 | 702 | } |
@@ -711,11 +711,11 @@ discard block |
||
| 711 | 711 | * @param string $type the type can be "belongs_to", "has_many" |
| 712 | 712 | * @return mixed the final row values |
| 713 | 713 | */ |
| 714 | - protected function relateBelongsToAndHasMany($relationship, $options, $row, $type){ |
|
| 714 | + protected function relateBelongsToAndHasMany($relationship, $options, $row, $type) { |
|
| 715 | 715 | if (in_array($relationship, $this->_with)) { |
| 716 | 716 | get_instance()->loader->model($options['model'], $relationship . '_model'); |
| 717 | 717 | |
| 718 | - if($type == 'belongs_to'){ |
|
| 718 | + if ($type == 'belongs_to') { |
|
| 719 | 719 | if (is_object($row)) { |
| 720 | 720 | $row->{$relationship} = $this->{$relationship . '_model'}->get($row->{$options['primary_key']}); |
| 721 | 721 | } else { |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * |
| 94 | 94 | * @codeCoverageIgnore |
| 95 | 95 | */ |
| 96 | - protected function startAppSession() { |
|
| 96 | + protected function startAppSession() { |
|
| 97 | 97 | //$_SESSION is not available on cli mode |
| 98 | 98 | if (!IS_CLI) { |
| 99 | 99 | //set session params |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * @codeCoverageIgnore |
| 144 | 144 | */ |
| 145 | 145 | protected function setAppSessionConfig() { |
| 146 | - //the default is to store in the files |
|
| 146 | + //the default is to store in the files |
|
| 147 | 147 | $sessionHandler = $this->config->get('session_handler', 'files'); |
| 148 | 148 | $this->logger->info('Session handler: ' . $sessionHandler); |
| 149 | 149 | if ($sessionHandler == 'files') { |
@@ -98,10 +98,10 @@ |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | - * This method is used to check the whitelist IP address access |
|
| 102 | - * |
|
| 103 | - * @return boolean |
|
| 104 | - */ |
|
| 101 | + * This method is used to check the whitelist IP address access |
|
| 102 | + * |
|
| 103 | + * @return boolean |
|
| 104 | + */ |
|
| 105 | 105 | public function checkWhiteListIpAccess() { |
| 106 | 106 | $this->logger->debug('Validation of the IP address access ...'); |
| 107 | 107 | $this->logger->debug('Check if whitelist IP access is enabled in the configuration ...'); |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | } else { |
| 188 | 188 | $this->logger->info('Cannot find view [' . $view . '] in module [' . $module . '] using the default location'); |
| 189 | 189 | } |
| 190 | - if (!$path) { |
|
| 190 | + if (!$path) { |
|
| 191 | 191 | $path = $this->getDefaultFilePathForView($viewFile); |
| 192 | 192 | } |
| 193 | 193 | $this->logger->info('The view file path to be loaded is [' . $path . ']'); |
@@ -290,12 +290,12 @@ discard block |
||
| 290 | 290 | return $this->_pageRender; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - /** |
|
| 294 | - * Set the final page to be rendered |
|
| 295 | - * @param string $finalPage the content of the final page |
|
| 296 | - * |
|
| 297 | - * @return object |
|
| 298 | - */ |
|
| 293 | + /** |
|
| 294 | + * Set the final page to be rendered |
|
| 295 | + * @param string $finalPage the content of the final page |
|
| 296 | + * |
|
| 297 | + * @return object |
|
| 298 | + */ |
|
| 299 | 299 | public function setFinalPageContent($finalPage) { |
| 300 | 300 | $this->_pageRender = $finalPage; |
| 301 | 301 | return $this; |
@@ -363,12 +363,12 @@ discard block |
||
| 363 | 363 | ob_end_flush(); |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - /** |
|
| 367 | - * Return the default full file path for view |
|
| 368 | - * @param string $file the filename |
|
| 369 | - * |
|
| 370 | - * @return string|null the full file path |
|
| 371 | - */ |
|
| 366 | + /** |
|
| 367 | + * Return the default full file path for view |
|
| 368 | + * @param string $file the filename |
|
| 369 | + * |
|
| 370 | + * @return string|null the full file path |
|
| 371 | + */ |
|
| 372 | 372 | protected function getDefaultFilePathForView($file){ |
| 373 | 373 | $searchDir = array(APPS_VIEWS_PATH, CORE_VIEWS_PATH); |
| 374 | 374 | $fullFilePath = null; |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | $headerModifiedSince = $globals->server('HTTP_IF_MODIFIED_SINCE'); |
| 402 | 402 | if (!empty($headerModifiedSince) && $lastModified <= strtotime($headerModifiedSince)) { |
| 403 | 403 | $this->logger->info('The cache page content is not yet expire for the ' |
| 404 | - . 'URL [' . $this->_currentUrl . '] send 304 header to browser'); |
|
| 404 | + . 'URL [' . $this->_currentUrl . '] send 304 header to browser'); |
|
| 405 | 405 | $this->sendHeaders(304); |
| 406 | 406 | return true; |
| 407 | 407 | } |
@@ -416,8 +416,8 @@ discard block |
||
| 416 | 416 | */ |
| 417 | 417 | protected function sendCachePageContentToBrowser(&$cache) { |
| 418 | 418 | $this->logger->info('The cache page content is expired or the browser does ' |
| 419 | - . 'not send the HTTP_IF_MODIFIED_SINCE header for the URL [' . $this->_currentUrl . '] ' |
|
| 420 | - . 'send cache headers to tell the browser'); |
|
| 419 | + . 'not send the HTTP_IF_MODIFIED_SINCE header for the URL [' . $this->_currentUrl . '] ' |
|
| 420 | + . 'send cache headers to tell the browser'); |
|
| 421 | 421 | |
| 422 | 422 | $this->sendHeaders(200); |
| 423 | 423 | //current page cache key |
@@ -559,18 +559,18 @@ discard block |
||
| 559 | 559 | } |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | - /** |
|
| 563 | - * Set the mandory headers, like security, etc. |
|
| 564 | - */ |
|
| 562 | + /** |
|
| 563 | + * Set the mandory headers, like security, etc. |
|
| 564 | + */ |
|
| 565 | 565 | protected function setRequiredHeaders() { |
| 566 | 566 | $requiredHeaders = array( |
| 567 | 567 | 'X-XSS-Protection' => '1; mode=block', |
| 568 | 568 | 'X-Frame-Options' => 'SAMEORIGIN' |
| 569 | 569 | ); |
| 570 | 570 | foreach ($requiredHeaders as $key => $value) { |
| 571 | - if (!isset($this->headers[$key])) { |
|
| 571 | + if (!isset($this->headers[$key])) { |
|
| 572 | 572 | $this->headers[$key] = $value; |
| 573 | - } |
|
| 573 | + } |
|
| 574 | 574 | } |
| 575 | 575 | } |
| 576 | 576 | } |
@@ -369,7 +369,7 @@ |
||
| 369 | 369 | * |
| 370 | 370 | * @return string|null the full file path |
| 371 | 371 | */ |
| 372 | - protected function getDefaultFilePathForView($file){ |
|
| 372 | + protected function getDefaultFilePathForView($file) { |
|
| 373 | 373 | $searchDir = array(APPS_VIEWS_PATH, CORE_VIEWS_PATH); |
| 374 | 374 | $fullFilePath = null; |
| 375 | 375 | foreach ($searchDir as $dir) { |