@@ -1,240 +1,240 @@ |
||
| 1 | 1 | <?php |
| 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 GNU GPL License (GPL) |
|
| 9 | - * |
|
| 10 | - * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | - * |
|
| 12 | - * This program is free software; you can redistribute it and/or |
|
| 13 | - * modify it under the terms of the GNU General Public License |
|
| 14 | - * as published by the Free Software Foundation; either version 3 |
|
| 15 | - * of the License, or (at your option) any later version. |
|
| 16 | - * |
|
| 17 | - * This program is distributed in the hope that it will be useful, |
|
| 18 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | - * GNU General Public License for more details. |
|
| 21 | - * |
|
| 22 | - * You should have received a copy of the GNU General Public License |
|
| 23 | - * along with this program; if not, write to the Free Software |
|
| 24 | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | - */ |
|
| 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 GNU GPL License (GPL) |
|
| 9 | + * |
|
| 10 | + * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | + * |
|
| 12 | + * This program is free software; you can redistribute it and/or |
|
| 13 | + * modify it under the terms of the GNU General Public License |
|
| 14 | + * as published by the Free Software Foundation; either version 3 |
|
| 15 | + * of the License, or (at your option) any later version. |
|
| 16 | + * |
|
| 17 | + * This program is distributed in the hope that it will be useful, |
|
| 18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | + * GNU General Public License for more details. |
|
| 21 | + * |
|
| 22 | + * You should have received a copy of the GNU General Public License |
|
| 23 | + * along with this program; if not, write to the Free Software |
|
| 24 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | + */ |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | - function & class_loader($class, $dir = 'libraries', $params = null){ |
|
| 29 | - //put the first letter of class to upper case |
|
| 30 | - $class = ucfirst($class); |
|
| 31 | - static $classes = array(); |
|
| 32 | - if(isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log'){ |
|
| 33 | - return $classes[$class]; |
|
| 34 | - } |
|
| 35 | - $found = false; |
|
| 36 | - foreach (array(ROOT_PATH, CORE_PATH) as $path) { |
|
| 37 | - $file = $path . $dir . '/' . $class . '.php'; |
|
| 38 | - if(file_exists($file)){ |
|
| 39 | - if(class_exists($class, false) === false){ |
|
| 40 | - require_once $file; |
|
| 41 | - } |
|
| 42 | - //already found |
|
| 43 | - $found = true; |
|
| 44 | - break; |
|
| 45 | - } |
|
| 46 | - } |
|
| 47 | - if(! $found){ |
|
| 48 | - //can't use show_error() at this time because some dependencies not yet loaded |
|
| 49 | - set_http_status_header(503); |
|
| 50 | - echo 'Cannot find the class [' . $class . ']'; |
|
| 51 | - die(); |
|
| 52 | - } |
|
| 28 | + function & class_loader($class, $dir = 'libraries', $params = null){ |
|
| 29 | + //put the first letter of class to upper case |
|
| 30 | + $class = ucfirst($class); |
|
| 31 | + static $classes = array(); |
|
| 32 | + if(isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log'){ |
|
| 33 | + return $classes[$class]; |
|
| 34 | + } |
|
| 35 | + $found = false; |
|
| 36 | + foreach (array(ROOT_PATH, CORE_PATH) as $path) { |
|
| 37 | + $file = $path . $dir . '/' . $class . '.php'; |
|
| 38 | + if(file_exists($file)){ |
|
| 39 | + if(class_exists($class, false) === false){ |
|
| 40 | + require_once $file; |
|
| 41 | + } |
|
| 42 | + //already found |
|
| 43 | + $found = true; |
|
| 44 | + break; |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | + if(! $found){ |
|
| 48 | + //can't use show_error() at this time because some dependencies not yet loaded |
|
| 49 | + set_http_status_header(503); |
|
| 50 | + echo 'Cannot find the class [' . $class . ']'; |
|
| 51 | + die(); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /* |
|
| 54 | + /* |
|
| 55 | 55 | TODO use the best method to get the Log instance |
| 56 | 56 | */ |
| 57 | - if($class == 'Log'){ |
|
| 58 | - //can't use the instruction like "return new Log()" |
|
| 59 | - //because we need return the reference instance of the loaded class. |
|
| 60 | - $log = new Log(); |
|
| 61 | - return $log; |
|
| 62 | - } |
|
| 63 | - //track of loaded classes |
|
| 64 | - class_loaded($class); |
|
| 57 | + if($class == 'Log'){ |
|
| 58 | + //can't use the instruction like "return new Log()" |
|
| 59 | + //because we need return the reference instance of the loaded class. |
|
| 60 | + $log = new Log(); |
|
| 61 | + return $log; |
|
| 62 | + } |
|
| 63 | + //track of loaded classes |
|
| 64 | + class_loaded($class); |
|
| 65 | 65 | |
| 66 | - //record the class instance |
|
| 67 | - $classes[$class] = isset($params) ? new $class($params) : new $class(); |
|
| 66 | + //record the class instance |
|
| 67 | + $classes[$class] = isset($params) ? new $class($params) : new $class(); |
|
| 68 | 68 | |
| 69 | - return $classes[$class]; |
|
| 70 | - } |
|
| 69 | + return $classes[$class]; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | 72 | |
| 73 | - function & class_loaded($class = null){ |
|
| 74 | - static $list = array(); |
|
| 75 | - if($class != null){ |
|
| 76 | - $list[strtolower($class)] = $class; |
|
| 77 | - } |
|
| 78 | - return $list; |
|
| 79 | - } |
|
| 73 | + function & class_loaded($class = null){ |
|
| 74 | + static $list = array(); |
|
| 75 | + if($class != null){ |
|
| 76 | + $list[strtolower($class)] = $class; |
|
| 77 | + } |
|
| 78 | + return $list; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - function & load_configurations(array $overwrite_values = array()){ |
|
| 82 | - static $config; |
|
| 83 | - if(empty($config)){ |
|
| 84 | - $file = CONFIG_PATH . 'config.php'; |
|
| 85 | - require_once $file; |
|
| 81 | + function & load_configurations(array $overwrite_values = array()){ |
|
| 82 | + static $config; |
|
| 83 | + if(empty($config)){ |
|
| 84 | + $file = CONFIG_PATH . 'config.php'; |
|
| 85 | + require_once $file; |
|
| 86 | 86 | |
| 87 | - foreach ($overwrite_values as $key => $value) { |
|
| 88 | - $config[$key] = $value; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - return $config; |
|
| 92 | - } |
|
| 87 | + foreach ($overwrite_values as $key => $value) { |
|
| 88 | + $config[$key] = $value; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + return $config; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * @test |
|
| 96 | - */ |
|
| 97 | - function get_config($key, $default = null){ |
|
| 98 | - static $cfg; |
|
| 99 | - if(empty($cfg)){ |
|
| 100 | - $cfg[0] = & load_configurations(); |
|
| 101 | - } |
|
| 102 | - return array_key_exists($key, $cfg[0]) ? $cfg[0][$key] : $default; |
|
| 103 | - } |
|
| 94 | + /** |
|
| 95 | + * @test |
|
| 96 | + */ |
|
| 97 | + function get_config($key, $default = null){ |
|
| 98 | + static $cfg; |
|
| 99 | + if(empty($cfg)){ |
|
| 100 | + $cfg[0] = & load_configurations(); |
|
| 101 | + } |
|
| 102 | + return array_key_exists($key, $cfg[0]) ? $cfg[0][$key] : $default; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - function save_to_log($level, $message, $logger = null){ |
|
| 106 | - echo 'save_to_log('.$level . ',' . $message . ',' . $logger . ")\n"; |
|
| 107 | - } |
|
| 105 | + function save_to_log($level, $message, $logger = null){ |
|
| 106 | + echo 'save_to_log('.$level . ',' . $message . ',' . $logger . ")\n"; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | 109 | |
| 110 | - function set_http_status_header($code = 200, $text = null){ |
|
| 111 | - echo 'header(' . $code . ', ' . $text . ')'; |
|
| 112 | - return true; |
|
| 113 | - } |
|
| 110 | + function set_http_status_header($code = 200, $text = null){ |
|
| 111 | + echo 'header(' . $code . ', ' . $text . ')'; |
|
| 112 | + return true; |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | 115 | |
| 116 | - function show_error($msg, $title = 'error', $logging = true){ |
|
| 117 | - //show only and continue to help track of some error occured |
|
| 118 | - echo 'show_error(' . $msg . ', ' . $title . ', ' . ($logging ? 'Y' : 'N') . ")\n"; |
|
| 119 | - } |
|
| 116 | + function show_error($msg, $title = 'error', $logging = true){ |
|
| 117 | + //show only and continue to help track of some error occured |
|
| 118 | + echo 'show_error(' . $msg . ', ' . $title . ', ' . ($logging ? 'Y' : 'N') . ")\n"; |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - function is_https(){ |
|
| 122 | - return false; |
|
| 123 | - } |
|
| 121 | + function is_https(){ |
|
| 122 | + return false; |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - /** |
|
| 126 | - * @test |
|
| 127 | - */ |
|
| 128 | - function is_url($url){ |
|
| 129 | - return preg_match('/^(http|https|ftp):\/\/(.*)/', $url); |
|
| 130 | - } |
|
| 125 | + /** |
|
| 126 | + * @test |
|
| 127 | + */ |
|
| 128 | + function is_url($url){ |
|
| 129 | + return preg_match('/^(http|https|ftp):\/\/(.*)/', $url); |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - function php_exception_handler($ex){ |
|
| 133 | - //show only and continue to help track of some error occured |
|
| 134 | - echo 'php_exception_handler('.$ex->getMessage().', '.$ex->getFile().', '.$ex->getLine() . ")\n"; |
|
| 135 | - } |
|
| 132 | + function php_exception_handler($ex){ |
|
| 133 | + //show only and continue to help track of some error occured |
|
| 134 | + echo 'php_exception_handler('.$ex->getMessage().', '.$ex->getFile().', '.$ex->getLine() . ")\n"; |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | 137 | |
| 138 | - function php_error_handler($errno , $errstr, $errfile , $errline){ |
|
| 139 | - //show only and continue to help track of some error occured |
|
| 140 | - echo 'php_error_handler('.$errno .', ' . $errstr.', ' . $errfile.', '.$errline . ")\n"; |
|
| 141 | - } |
|
| 138 | + function php_error_handler($errno , $errstr, $errfile , $errline){ |
|
| 139 | + //show only and continue to help track of some error occured |
|
| 140 | + echo 'php_error_handler('.$errno .', ' . $errstr.', ' . $errfile.', '.$errline . ")\n"; |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - function php_shudown_handler(){ |
|
| 144 | - return true; |
|
| 145 | - } |
|
| 143 | + function php_shudown_handler(){ |
|
| 144 | + return true; |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * @test |
|
| 150 | - */ |
|
| 151 | - function attributes_to_string(array $attributes){ |
|
| 152 | - $str = ' '; |
|
| 153 | - //we check that the array passed as an argument is not empty. |
|
| 154 | - if(! empty($attributes)){ |
|
| 155 | - foreach($attributes as $key => $value){ |
|
| 156 | - $key = trim(htmlspecialchars($key)); |
|
| 157 | - $value = trim(htmlspecialchars($value)); |
|
| 158 | - /* |
|
| 148 | + /** |
|
| 149 | + * @test |
|
| 150 | + */ |
|
| 151 | + function attributes_to_string(array $attributes){ |
|
| 152 | + $str = ' '; |
|
| 153 | + //we check that the array passed as an argument is not empty. |
|
| 154 | + if(! empty($attributes)){ |
|
| 155 | + foreach($attributes as $key => $value){ |
|
| 156 | + $key = trim(htmlspecialchars($key)); |
|
| 157 | + $value = trim(htmlspecialchars($value)); |
|
| 158 | + /* |
|
| 159 | 159 | * To predict the case where the string to convert contains the character " |
| 160 | 160 | * we check if this is the case we add a slash to solve this problem. |
| 161 | 161 | * For example: |
| 162 | 162 | * $attr = array('placeholder' => 'I am a "puple"') |
| 163 | 163 | * $str = attributes_to_string($attr); => placeholder = "I am a \"puple\"" |
| 164 | 164 | */ |
| 165 | - if($value && strpos('"', $value) !== false){ |
|
| 166 | - $value = addslashes($value); |
|
| 167 | - } |
|
| 168 | - $str .= $key.' = "'.$value.'" '; |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - //remove the space after using rtrim() |
|
| 172 | - return rtrim($str); |
|
| 173 | - } |
|
| 165 | + if($value && strpos('"', $value) !== false){ |
|
| 166 | + $value = addslashes($value); |
|
| 167 | + } |
|
| 168 | + $str .= $key.' = "'.$value.'" '; |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | + //remove the space after using rtrim() |
|
| 172 | + return rtrim($str); |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - function stringfy_vars($var){ |
|
| 176 | - return print_r($var, true); |
|
| 177 | - } |
|
| 175 | + function stringfy_vars($var){ |
|
| 176 | + return print_r($var, true); |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - /** |
|
| 180 | - * @test |
|
| 181 | - */ |
|
| 182 | - function clean_input($str){ |
|
| 183 | - if(is_array($str)){ |
|
| 184 | - $str = array_map('clean_input', $str); |
|
| 185 | - } |
|
| 186 | - else if(is_object($str)){ |
|
| 187 | - $obj = $str; |
|
| 188 | - foreach ($str as $var => $value) { |
|
| 189 | - $obj->$var = clean_input($value); |
|
| 190 | - } |
|
| 191 | - $str = $obj; |
|
| 192 | - } |
|
| 193 | - else{ |
|
| 194 | - $str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8'); |
|
| 195 | - } |
|
| 196 | - return $str; |
|
| 197 | - } |
|
| 179 | + /** |
|
| 180 | + * @test |
|
| 181 | + */ |
|
| 182 | + function clean_input($str){ |
|
| 183 | + if(is_array($str)){ |
|
| 184 | + $str = array_map('clean_input', $str); |
|
| 185 | + } |
|
| 186 | + else if(is_object($str)){ |
|
| 187 | + $obj = $str; |
|
| 188 | + foreach ($str as $var => $value) { |
|
| 189 | + $obj->$var = clean_input($value); |
|
| 190 | + } |
|
| 191 | + $str = $obj; |
|
| 192 | + } |
|
| 193 | + else{ |
|
| 194 | + $str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8'); |
|
| 195 | + } |
|
| 196 | + return $str; |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - /** |
|
| 200 | - * @test |
|
| 201 | - */ |
|
| 202 | - function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*'){ |
|
| 203 | - //get the string length |
|
| 204 | - $len = strlen($str); |
|
| 205 | - //if str is empty |
|
| 206 | - if($len <= 0){ |
|
| 207 | - return str_repeat($hiddenChar, 6); |
|
| 208 | - } |
|
| 209 | - //if the length is less than startCount and endCount |
|
| 210 | - //or the startCount and endCount length is 0 |
|
| 211 | - //or startCount is negative or endCount is negative |
|
| 212 | - //return the full string hidden |
|
| 199 | + /** |
|
| 200 | + * @test |
|
| 201 | + */ |
|
| 202 | + function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*'){ |
|
| 203 | + //get the string length |
|
| 204 | + $len = strlen($str); |
|
| 205 | + //if str is empty |
|
| 206 | + if($len <= 0){ |
|
| 207 | + return str_repeat($hiddenChar, 6); |
|
| 208 | + } |
|
| 209 | + //if the length is less than startCount and endCount |
|
| 210 | + //or the startCount and endCount length is 0 |
|
| 211 | + //or startCount is negative or endCount is negative |
|
| 212 | + //return the full string hidden |
|
| 213 | 213 | |
| 214 | - if((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)){ |
|
| 215 | - return str_repeat($hiddenChar, $len); |
|
| 216 | - } |
|
| 217 | - //the start non hidden string |
|
| 218 | - $startNonHiddenStr = substr($str, 0, $startCount); |
|
| 219 | - //the end non hidden string |
|
| 220 | - $endNonHiddenStr = null; |
|
| 221 | - if($endCount > 0){ |
|
| 222 | - $endNonHiddenStr = substr($str, - $endCount); |
|
| 223 | - } |
|
| 224 | - //the hidden string |
|
| 225 | - $hiddenStr = str_repeat($hiddenChar, $len - ($startCount + $endCount)); |
|
| 214 | + if((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)){ |
|
| 215 | + return str_repeat($hiddenChar, $len); |
|
| 216 | + } |
|
| 217 | + //the start non hidden string |
|
| 218 | + $startNonHiddenStr = substr($str, 0, $startCount); |
|
| 219 | + //the end non hidden string |
|
| 220 | + $endNonHiddenStr = null; |
|
| 221 | + if($endCount > 0){ |
|
| 222 | + $endNonHiddenStr = substr($str, - $endCount); |
|
| 223 | + } |
|
| 224 | + //the hidden string |
|
| 225 | + $hiddenStr = str_repeat($hiddenChar, $len - ($startCount + $endCount)); |
|
| 226 | 226 | |
| 227 | - return $startNonHiddenStr . $hiddenStr . $endNonHiddenStr; |
|
| 228 | - } |
|
| 227 | + return $startNonHiddenStr . $hiddenStr . $endNonHiddenStr; |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - function set_session_config(){ |
|
| 231 | - return true; |
|
| 232 | - } |
|
| 230 | + function set_session_config(){ |
|
| 231 | + return true; |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - function & get_instance(){ |
|
| 235 | - if(! Controller::get_instance()){ |
|
| 236 | - $c = new Controller(); |
|
| 237 | - return $c; |
|
| 238 | - } |
|
| 239 | - return Controller::get_instance(); |
|
| 240 | - } |
|
| 234 | + function & get_instance(){ |
|
| 235 | + if(! Controller::get_instance()){ |
|
| 236 | + $c = new Controller(); |
|
| 237 | + return $c; |
|
| 238 | + } |
|
| 239 | + return Controller::get_instance(); |
|
| 240 | + } |
|
@@ -1,54 +1,54 @@ |
||
| 1 | 1 | <?php |
| 2 | - //Autoload function |
|
| 3 | - function tests_autoload($class){ |
|
| 4 | - $classesMap = array( |
|
| 5 | - //Caches |
|
| 6 | - 'ApcCache' => CORE_CLASSES_CACHE_PATH . 'ApcCache.php', |
|
| 7 | - 'CacheInterface' => CORE_CLASSES_CACHE_PATH . 'CacheInterface.php', |
|
| 8 | - 'FileCache' => CORE_CLASSES_CACHE_PATH . 'FileCache.php', |
|
| 9 | - //models |
|
| 10 | - 'DBSessionHandlerModel' => CORE_CLASSES_MODEL_PATH . 'DBSessionHandlerModel.php', |
|
| 11 | - 'Model' => CORE_CLASSES_MODEL_PATH . 'Model.php', |
|
| 12 | - //Core classes |
|
| 13 | - 'Config' => CORE_CLASSES_PATH . 'Config.php', |
|
| 14 | - 'Controller' => CORE_CLASSES_PATH . 'Controller.php', |
|
| 15 | - 'Database' => CORE_CLASSES_DATABASE_PATH . 'Database.php', |
|
| 16 | - 'DatabaseQueryBuilder' => CORE_CLASSES_DATABASE_PATH . 'DatabaseQueryBuilder.php', |
|
| 17 | - 'DatabaseQueryResult' => CORE_CLASSES_DATABASE_PATH . 'DatabaseQueryResult.php', |
|
| 18 | - 'DatabaseQueryRunner' => CORE_CLASSES_DATABASE_PATH . 'DatabaseQueryRunner.php', |
|
| 19 | - 'DBSessionHandler' => CORE_CLASSES_PATH . 'DBSessionHandler.php', |
|
| 20 | - 'EventInfo' => CORE_CLASSES_PATH . 'EventInfo.php', |
|
| 21 | - 'EventDispatcher' => CORE_CLASSES_PATH . 'EventDispatcher.php', |
|
| 22 | - 'Lang' => CORE_CLASSES_PATH . 'Lang.php', |
|
| 23 | - 'Loader' => CORE_CLASSES_PATH . 'Loader.php', |
|
| 24 | - 'Log' => CORE_CLASSES_PATH . 'Log.php', |
|
| 25 | - 'Module' => CORE_CLASSES_PATH . 'Module.php', |
|
| 26 | - 'Request' => CORE_CLASSES_PATH . 'Request.php', |
|
| 27 | - 'Response' => CORE_CLASSES_PATH . 'Response.php', |
|
| 28 | - 'Router' => CORE_CLASSES_PATH . 'Router.php', |
|
| 29 | - 'Security' => CORE_CLASSES_PATH . 'Security.php', |
|
| 30 | - 'Session' => CORE_CLASSES_PATH . 'Session.php', |
|
| 31 | - 'Url' => CORE_CLASSES_PATH . 'Url.php', |
|
| 32 | - //Core libraries |
|
| 33 | - 'Assets' => CORE_LIBRARY_PATH . 'Assets.php', |
|
| 34 | - 'Benchmark' => CORE_LIBRARY_PATH . 'Benchmark.php', |
|
| 35 | - 'Browser' => CORE_LIBRARY_PATH . 'Browser.php', |
|
| 36 | - 'Cookie' => CORE_LIBRARY_PATH . 'Cookie.php', |
|
| 37 | - 'Email' => CORE_LIBRARY_PATH . 'Email.php', |
|
| 38 | - 'Form' => CORE_LIBRARY_PATH . 'Form.php', |
|
| 39 | - 'FormValidation' => CORE_LIBRARY_PATH . 'FormValidation.php', |
|
| 40 | - 'Html' => CORE_LIBRARY_PATH . 'Html.php', |
|
| 41 | - 'Pagination' => CORE_LIBRARY_PATH . 'Pagination.php', |
|
| 42 | - 'PDF' => CORE_LIBRARY_PATH . 'PDF.php', |
|
| 43 | - 'StringHash' => CORE_LIBRARY_PATH . 'StringHash.php', |
|
| 44 | - 'Upload' => CORE_LIBRARY_PATH . 'Upload.php', |
|
| 45 | - ); |
|
| 46 | - if(isset($classesMap[$class])){ |
|
| 47 | - if(file_exists($classesMap[$class])){ |
|
| 48 | - require_once $classesMap[$class]; |
|
| 49 | - } |
|
| 50 | - else{ |
|
| 51 | - echo 'File for class ' . $class . ' not found'; |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | 2 | \ No newline at end of file |
| 3 | + //Autoload function |
|
| 4 | + function tests_autoload($class){ |
|
| 5 | + $classesMap = array( |
|
| 6 | + //Caches |
|
| 7 | + 'ApcCache' => CORE_CLASSES_CACHE_PATH . 'ApcCache.php', |
|
| 8 | + 'CacheInterface' => CORE_CLASSES_CACHE_PATH . 'CacheInterface.php', |
|
| 9 | + 'FileCache' => CORE_CLASSES_CACHE_PATH . 'FileCache.php', |
|
| 10 | + //models |
|
| 11 | + 'DBSessionHandlerModel' => CORE_CLASSES_MODEL_PATH . 'DBSessionHandlerModel.php', |
|
| 12 | + 'Model' => CORE_CLASSES_MODEL_PATH . 'Model.php', |
|
| 13 | + //Core classes |
|
| 14 | + 'Config' => CORE_CLASSES_PATH . 'Config.php', |
|
| 15 | + 'Controller' => CORE_CLASSES_PATH . 'Controller.php', |
|
| 16 | + 'Database' => CORE_CLASSES_DATABASE_PATH . 'Database.php', |
|
| 17 | + 'DatabaseQueryBuilder' => CORE_CLASSES_DATABASE_PATH . 'DatabaseQueryBuilder.php', |
|
| 18 | + 'DatabaseQueryResult' => CORE_CLASSES_DATABASE_PATH . 'DatabaseQueryResult.php', |
|
| 19 | + 'DatabaseQueryRunner' => CORE_CLASSES_DATABASE_PATH . 'DatabaseQueryRunner.php', |
|
| 20 | + 'DBSessionHandler' => CORE_CLASSES_PATH . 'DBSessionHandler.php', |
|
| 21 | + 'EventInfo' => CORE_CLASSES_PATH . 'EventInfo.php', |
|
| 22 | + 'EventDispatcher' => CORE_CLASSES_PATH . 'EventDispatcher.php', |
|
| 23 | + 'Lang' => CORE_CLASSES_PATH . 'Lang.php', |
|
| 24 | + 'Loader' => CORE_CLASSES_PATH . 'Loader.php', |
|
| 25 | + 'Log' => CORE_CLASSES_PATH . 'Log.php', |
|
| 26 | + 'Module' => CORE_CLASSES_PATH . 'Module.php', |
|
| 27 | + 'Request' => CORE_CLASSES_PATH . 'Request.php', |
|
| 28 | + 'Response' => CORE_CLASSES_PATH . 'Response.php', |
|
| 29 | + 'Router' => CORE_CLASSES_PATH . 'Router.php', |
|
| 30 | + 'Security' => CORE_CLASSES_PATH . 'Security.php', |
|
| 31 | + 'Session' => CORE_CLASSES_PATH . 'Session.php', |
|
| 32 | + 'Url' => CORE_CLASSES_PATH . 'Url.php', |
|
| 33 | + //Core libraries |
|
| 34 | + 'Assets' => CORE_LIBRARY_PATH . 'Assets.php', |
|
| 35 | + 'Benchmark' => CORE_LIBRARY_PATH . 'Benchmark.php', |
|
| 36 | + 'Browser' => CORE_LIBRARY_PATH . 'Browser.php', |
|
| 37 | + 'Cookie' => CORE_LIBRARY_PATH . 'Cookie.php', |
|
| 38 | + 'Email' => CORE_LIBRARY_PATH . 'Email.php', |
|
| 39 | + 'Form' => CORE_LIBRARY_PATH . 'Form.php', |
|
| 40 | + 'FormValidation' => CORE_LIBRARY_PATH . 'FormValidation.php', |
|
| 41 | + 'Html' => CORE_LIBRARY_PATH . 'Html.php', |
|
| 42 | + 'Pagination' => CORE_LIBRARY_PATH . 'Pagination.php', |
|
| 43 | + 'PDF' => CORE_LIBRARY_PATH . 'PDF.php', |
|
| 44 | + 'StringHash' => CORE_LIBRARY_PATH . 'StringHash.php', |
|
| 45 | + 'Upload' => CORE_LIBRARY_PATH . 'Upload.php', |
|
| 46 | + ); |
|
| 47 | + if(isset($classesMap[$class])){ |
|
| 48 | + if(file_exists($classesMap[$class])){ |
|
| 49 | + require_once $classesMap[$class]; |
|
| 50 | + } |
|
| 51 | + else{ |
|
| 52 | + echo 'File for class ' . $class . ' not found'; |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | 56 | \ No newline at end of file |
@@ -1,94 +1,94 @@ |
||
| 1 | 1 | <?php |
| 2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | - /** |
|
| 4 | - * TNH Framework |
|
| 5 | - * |
|
| 6 | - * A simple PHP framework created using the concept of codeigniter with bootstrap twitter |
|
| 7 | - * |
|
| 8 | - * This content is released under the GNU GPL License (GPL) |
|
| 9 | - * |
|
| 10 | - * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | - * |
|
| 12 | - * This program is free software; you can redistribute it and/or |
|
| 13 | - * modify it under the terms of the GNU General Public License |
|
| 14 | - * as published by the Free Software Foundation; either version 3 |
|
| 15 | - * of the License, or (at your option) any later version. |
|
| 16 | - * |
|
| 17 | - * This program is distributed in the hope that it will be useful, |
|
| 18 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | - * GNU General Public License for more details. |
|
| 21 | - * |
|
| 22 | - * You should have received a copy of the GNU General Public License |
|
| 23 | - * along with this program; if not, write to the Free Software |
|
| 24 | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | - */ |
|
| 2 | + defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | + /** |
|
| 4 | + * TNH Framework |
|
| 5 | + * |
|
| 6 | + * A simple PHP framework created using the concept of codeigniter with bootstrap twitter |
|
| 7 | + * |
|
| 8 | + * This content is released under the GNU GPL License (GPL) |
|
| 9 | + * |
|
| 10 | + * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | + * |
|
| 12 | + * This program is free software; you can redistribute it and/or |
|
| 13 | + * modify it under the terms of the GNU General Public License |
|
| 14 | + * as published by the Free Software Foundation; either version 3 |
|
| 15 | + * of the License, or (at your option) any later version. |
|
| 16 | + * |
|
| 17 | + * This program is distributed in the hope that it will be useful, |
|
| 18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | + * GNU General Public License for more details. |
|
| 21 | + * |
|
| 22 | + * You should have received a copy of the GNU General Public License |
|
| 23 | + * along with this program; if not, write to the Free Software |
|
| 24 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | + */ |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * This file contains the configuration of resources that you want to load automatically: |
|
| 29 | - * personal or system libraries, configuration files, models, |
|
| 30 | - * personal functions or systems that are used most often in your application |
|
| 31 | - * instead of loading them every time you want to use it. |
|
| 32 | - * Note: loading a lot of resources can decrease the performance of your application. |
|
| 33 | - */ |
|
| 27 | + /** |
|
| 28 | + * This file contains the configuration of resources that you want to load automatically: |
|
| 29 | + * personal or system libraries, configuration files, models, |
|
| 30 | + * personal functions or systems that are used most often in your application |
|
| 31 | + * instead of loading them every time you want to use it. |
|
| 32 | + * Note: loading a lot of resources can decrease the performance of your application. |
|
| 33 | + */ |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * If you have personal libraries or systems to load automatically, then list them in the following array. |
|
| 38 | - * For example : |
|
| 39 | - * |
|
| 40 | - * $autoload['libraries'] = array('library1', 'library1'); |
|
| 41 | - * |
|
| 42 | - * Note: Personal libraries have priority over system libraries, |
|
| 43 | - * ie the loading order is as follows: it looks in the folder of the personal libraries, |
|
| 44 | - * if it is found, it is loaded, if not , we search in the system libraries folder, |
|
| 45 | - * before returning an error in case it does not find it. |
|
| 46 | - */ |
|
| 47 | - $autoload['libraries'] = array(); |
|
| 36 | + /** |
|
| 37 | + * If you have personal libraries or systems to load automatically, then list them in the following array. |
|
| 38 | + * For example : |
|
| 39 | + * |
|
| 40 | + * $autoload['libraries'] = array('library1', 'library1'); |
|
| 41 | + * |
|
| 42 | + * Note: Personal libraries have priority over system libraries, |
|
| 43 | + * ie the loading order is as follows: it looks in the folder of the personal libraries, |
|
| 44 | + * if it is found, it is loaded, if not , we search in the system libraries folder, |
|
| 45 | + * before returning an error in case it does not find it. |
|
| 46 | + */ |
|
| 47 | + $autoload['libraries'] = array(); |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * If you have configuration files to load automatically, then list them in the following array. |
|
| 51 | - * For example : |
|
| 52 | - * |
|
| 53 | - * $autoload['config'] = array('config1', 'config2'); |
|
| 54 | - * |
|
| 55 | - * Note 1: the file name must have as prefix "config_" |
|
| 56 | - * for example "config_name_of_the_file_config.php" and contains as configuration variable the array $config, |
|
| 57 | - * otherwise the system can not find this configuration file. |
|
| 58 | - * For example : |
|
| 59 | - * |
|
| 60 | - * $config['key1'] = value1; |
|
| 61 | - * $config['key2'] = value2; |
|
| 62 | - * |
|
| 63 | - * Note 2: the files to be loaded must be in the folder defined by the constant "CONFIG_PATH" in "index.php". |
|
| 64 | - */ |
|
| 65 | - $autoload['config'] = array(); |
|
| 49 | + /** |
|
| 50 | + * If you have configuration files to load automatically, then list them in the following array. |
|
| 51 | + * For example : |
|
| 52 | + * |
|
| 53 | + * $autoload['config'] = array('config1', 'config2'); |
|
| 54 | + * |
|
| 55 | + * Note 1: the file name must have as prefix "config_" |
|
| 56 | + * for example "config_name_of_the_file_config.php" and contains as configuration variable the array $config, |
|
| 57 | + * otherwise the system can not find this configuration file. |
|
| 58 | + * For example : |
|
| 59 | + * |
|
| 60 | + * $config['key1'] = value1; |
|
| 61 | + * $config['key2'] = value2; |
|
| 62 | + * |
|
| 63 | + * Note 2: the files to be loaded must be in the folder defined by the constant "CONFIG_PATH" in "index.php". |
|
| 64 | + */ |
|
| 65 | + $autoload['config'] = array(); |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * If you have models to load automatically, then list them in the following table. |
|
| 69 | - * For example : |
|
| 70 | - * |
|
| 71 | - * $autoload['models'] = array('model1', 'model2'); |
|
| 72 | - */ |
|
| 73 | - $autoload['models'] = array(); |
|
| 67 | + /** |
|
| 68 | + * If you have models to load automatically, then list them in the following table. |
|
| 69 | + * For example : |
|
| 70 | + * |
|
| 71 | + * $autoload['models'] = array('model1', 'model2'); |
|
| 72 | + */ |
|
| 73 | + $autoload['models'] = array(); |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * If you have system or personal functions to load automatically, specify them in the following array. |
|
| 77 | - * For example : |
|
| 78 | - * |
|
| 79 | - * $autoload['functions'] = array('function1', 'function2'); |
|
| 80 | - * |
|
| 81 | - * Note: Personal functions have priority over system functions, |
|
| 82 | - * that is to say that the order of loading is the following : it looks in the directory of the personal functions, |
|
| 83 | - * if it is found, it is loaded, otherwise, it looks in the directory of the system functions, |
|
| 84 | - * before returning an error in case he does not find it. |
|
| 85 | - */ |
|
| 86 | - $autoload['functions'] = array(); |
|
| 75 | + /** |
|
| 76 | + * If you have system or personal functions to load automatically, specify them in the following array. |
|
| 77 | + * For example : |
|
| 78 | + * |
|
| 79 | + * $autoload['functions'] = array('function1', 'function2'); |
|
| 80 | + * |
|
| 81 | + * Note: Personal functions have priority over system functions, |
|
| 82 | + * that is to say that the order of loading is the following : it looks in the directory of the personal functions, |
|
| 83 | + * if it is found, it is loaded, otherwise, it looks in the directory of the system functions, |
|
| 84 | + * before returning an error in case he does not find it. |
|
| 85 | + */ |
|
| 86 | + $autoload['functions'] = array(); |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * If you have system or personal language to load automatically, specify them in the following array. |
|
| 90 | - * For example : |
|
| 91 | - * |
|
| 92 | - * $autoload['languages'] = array('lang1', 'lang2'); |
|
| 93 | - */ |
|
| 94 | - $autoload['languages'] = array(); |
|
| 88 | + /** |
|
| 89 | + * If you have system or personal language to load automatically, specify them in the following array. |
|
| 90 | + * For example : |
|
| 91 | + * |
|
| 92 | + * $autoload['languages'] = array('lang1', 'lang2'); |
|
| 93 | + */ |
|
| 94 | + $autoload['languages'] = array(); |
|
@@ -1,341 +1,341 @@ |
||
| 1 | 1 | <?php |
| 2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | - /** |
|
| 4 | - * TNH Framework |
|
| 5 | - * |
|
| 6 | - * A simple PHP framework created using the concept of codeigniter with bootstrap twitter |
|
| 7 | - * |
|
| 8 | - * This content is released under the GNU GPL License (GPL) |
|
| 9 | - * |
|
| 10 | - * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | - * |
|
| 12 | - * This program is free software; you can redistribute it and/or |
|
| 13 | - * modify it under the terms of the GNU General Public License |
|
| 14 | - * as published by the Free Software Foundation; either version 3 |
|
| 15 | - * of the License, or (at your option) any later version. |
|
| 16 | - * |
|
| 17 | - * This program is distributed in the hope that it will be useful, |
|
| 18 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | - * GNU General Public License for more details. |
|
| 21 | - * |
|
| 22 | - * You should have received a copy of the GNU General Public License |
|
| 23 | - * along with this program; if not, write to the Free Software |
|
| 24 | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | - */ |
|
| 2 | + defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | + /** |
|
| 4 | + * TNH Framework |
|
| 5 | + * |
|
| 6 | + * A simple PHP framework created using the concept of codeigniter with bootstrap twitter |
|
| 7 | + * |
|
| 8 | + * This content is released under the GNU GPL License (GPL) |
|
| 9 | + * |
|
| 10 | + * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | + * |
|
| 12 | + * This program is free software; you can redistribute it and/or |
|
| 13 | + * modify it under the terms of the GNU General Public License |
|
| 14 | + * as published by the Free Software Foundation; either version 3 |
|
| 15 | + * of the License, or (at your option) any later version. |
|
| 16 | + * |
|
| 17 | + * This program is distributed in the hope that it will be useful, |
|
| 18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | + * GNU General Public License for more details. |
|
| 21 | + * |
|
| 22 | + * You should have received a copy of the GNU General Public License |
|
| 23 | + * along with this program; if not, write to the Free Software |
|
| 24 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | + */ |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * This file contains the main configuration of your application |
|
| 29 | - * web address, front controller, error logging, session parameters, CSRF, Cache, |
|
| 30 | - * Whitelist IP access, etc. |
|
| 31 | - */ |
|
| 27 | + /** |
|
| 28 | + * This file contains the main configuration of your application |
|
| 29 | + * web address, front controller, error logging, session parameters, CSRF, Cache, |
|
| 30 | + * Whitelist IP access, etc. |
|
| 31 | + */ |
|
| 32 | 32 | |
| 33 | - /*+---------------------------------------------------------------+ |
|
| 33 | + /*+---------------------------------------------------------------+ |
|
| 34 | 34 | * Basic configuration section |
| 35 | 35 | +------------------------------------------------------------------+ |
| 36 | 36 | */ |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * The web address of your application. |
|
| 40 | - * |
|
| 41 | - * The address of your application or website terminated by a slash. |
|
| 42 | - * You can use a domain name or IP address, for example: |
|
| 43 | - * |
|
| 44 | - * $config['base_url'] = 'http://www.mysite.com'; |
|
| 45 | - * or |
|
| 46 | - * $config['base_url'] = 'http://198.15.25.12'; |
|
| 47 | - * |
|
| 48 | - * If this value is empty, we try to determine it automatically by using |
|
| 49 | - * the server variables "SERVER_ADDR" or "SCRIPT_NAME", |
|
| 50 | - * we recommend that you specify this value for a server in production this may reduce the performance of your application. |
|
| 51 | - */ |
|
| 52 | - $config['base_url'] = ''; |
|
| 38 | + /** |
|
| 39 | + * The web address of your application. |
|
| 40 | + * |
|
| 41 | + * The address of your application or website terminated by a slash. |
|
| 42 | + * You can use a domain name or IP address, for example: |
|
| 43 | + * |
|
| 44 | + * $config['base_url'] = 'http://www.mysite.com'; |
|
| 45 | + * or |
|
| 46 | + * $config['base_url'] = 'http://198.15.25.12'; |
|
| 47 | + * |
|
| 48 | + * If this value is empty, we try to determine it automatically by using |
|
| 49 | + * the server variables "SERVER_ADDR" or "SCRIPT_NAME", |
|
| 50 | + * we recommend that you specify this value for a server in production this may reduce the performance of your application. |
|
| 51 | + */ |
|
| 52 | + $config['base_url'] = ''; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * The front controller |
|
| 56 | - * |
|
| 57 | - * This represents the name of the file called by the application during the loading |
|
| 58 | - * process generally the file "index.php". |
|
| 59 | - * If your webserver supports the url rewrite module, then you can leave this value empty. |
|
| 60 | - * You will find a sample file to hide this file in the url inside the root folder of your |
|
| 61 | - * application "htaccess.txt" for the apache web server just rename it to ".htaccess" |
|
| 62 | - * |
|
| 63 | - * Without the rewrite module url enabled, leave this value to "index.php", in this case your urls look like: |
|
| 64 | - * |
|
| 65 | - * http://www.yoursite.com/index.php/controller/method |
|
| 66 | - * |
|
| 67 | - * otherwise if the module is available and activated you can put this value empty and your urls look like: |
|
| 68 | - * |
|
| 69 | - * http://www.yoursite.com/controller/method |
|
| 70 | - * |
|
| 71 | - */ |
|
| 72 | - $config['front_controller'] = 'index.php'; |
|
| 54 | + /** |
|
| 55 | + * The front controller |
|
| 56 | + * |
|
| 57 | + * This represents the name of the file called by the application during the loading |
|
| 58 | + * process generally the file "index.php". |
|
| 59 | + * If your webserver supports the url rewrite module, then you can leave this value empty. |
|
| 60 | + * You will find a sample file to hide this file in the url inside the root folder of your |
|
| 61 | + * application "htaccess.txt" for the apache web server just rename it to ".htaccess" |
|
| 62 | + * |
|
| 63 | + * Without the rewrite module url enabled, leave this value to "index.php", in this case your urls look like: |
|
| 64 | + * |
|
| 65 | + * http://www.yoursite.com/index.php/controller/method |
|
| 66 | + * |
|
| 67 | + * otherwise if the module is available and activated you can put this value empty and your urls look like: |
|
| 68 | + * |
|
| 69 | + * http://www.yoursite.com/controller/method |
|
| 70 | + * |
|
| 71 | + */ |
|
| 72 | + $config['front_controller'] = 'index.php'; |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Url suffix |
|
| 76 | - */ |
|
| 77 | - $config['url_suffix'] = ''; |
|
| 74 | + /** |
|
| 75 | + * Url suffix |
|
| 76 | + */ |
|
| 77 | + $config['url_suffix'] = ''; |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * site charset |
|
| 81 | - */ |
|
| 82 | - $config['charset'] = 'UTF-8'; |
|
| 79 | + /** |
|
| 80 | + * site charset |
|
| 81 | + */ |
|
| 82 | + $config['charset'] = 'UTF-8'; |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Compress the output before send to browser |
|
| 86 | - * |
|
| 87 | - * Enables Gzip output compression for faster page loads. When enabled, |
|
| 88 | - * the Response class will test whether your server supports Gzip. |
|
| 89 | - * Even if it does, however, not all browsers support compression |
|
| 90 | - * so enable only if you are reasonably sure your visitors can handle it. |
|
| 91 | - * |
|
| 92 | - * This is only used if "zlib.output_compression" is turned off in your php configuration. |
|
| 93 | - * Please do not use it together with httpd-level output compression. |
|
| 94 | - * |
|
| 95 | - * IMPORTANT NOTE: If you are getting a blank page when compression is enabled it |
|
| 96 | - * means you are prematurely outputting something to your browser. It could |
|
| 97 | - * even be a line of whitespace at the end of one of your scripts. For |
|
| 98 | - * compression to work, nothing can be sent before the output buffer is called |
|
| 99 | - * by the Response class. Do not 'echo' any values with compression enabled. |
|
| 100 | - */ |
|
| 101 | - $config['compress_output'] = false; |
|
| 84 | + /** |
|
| 85 | + * Compress the output before send to browser |
|
| 86 | + * |
|
| 87 | + * Enables Gzip output compression for faster page loads. When enabled, |
|
| 88 | + * the Response class will test whether your server supports Gzip. |
|
| 89 | + * Even if it does, however, not all browsers support compression |
|
| 90 | + * so enable only if you are reasonably sure your visitors can handle it. |
|
| 91 | + * |
|
| 92 | + * This is only used if "zlib.output_compression" is turned off in your php configuration. |
|
| 93 | + * Please do not use it together with httpd-level output compression. |
|
| 94 | + * |
|
| 95 | + * IMPORTANT NOTE: If you are getting a blank page when compression is enabled it |
|
| 96 | + * means you are prematurely outputting something to your browser. It could |
|
| 97 | + * even be a line of whitespace at the end of one of your scripts. For |
|
| 98 | + * compression to work, nothing can be sent before the output buffer is called |
|
| 99 | + * by the Response class. Do not 'echo' any values with compression enabled. |
|
| 100 | + */ |
|
| 101 | + $config['compress_output'] = false; |
|
| 102 | 102 | |
| 103 | - /*+---------------------------------------------------------------+ |
|
| 103 | + /*+---------------------------------------------------------------+ |
|
| 104 | 104 | * Language configuration section |
| 105 | 105 | +------------------------------------------------------------------+ |
| 106 | 106 | */ |
| 107 | - /** |
|
| 108 | - * list of available supported language |
|
| 109 | - * array( |
|
| 110 | - * 'lang_key' => 'human readable' |
|
| 111 | - * ) |
|
| 112 | - */ |
|
| 113 | - $config['languages'] = array('en' => 'english'); |
|
| 107 | + /** |
|
| 108 | + * list of available supported language |
|
| 109 | + * array( |
|
| 110 | + * 'lang_key' => 'human readable' |
|
| 111 | + * ) |
|
| 112 | + */ |
|
| 113 | + $config['languages'] = array('en' => 'english'); |
|
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * the default language to use if can not find the client language |
|
| 117 | - * need match with the array key of the supported languages |
|
| 118 | - */ |
|
| 119 | - $config['default_language'] = 'en'; //en = english, fr = french |
|
| 115 | + /** |
|
| 116 | + * the default language to use if can not find the client language |
|
| 117 | + * need match with the array key of the supported languages |
|
| 118 | + */ |
|
| 119 | + $config['default_language'] = 'en'; //en = english, fr = french |
|
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * the name of cookie used to store the client language |
|
| 123 | - */ |
|
| 124 | - $config['language_cookie_name'] = 'cookie_lang'; |
|
| 121 | + /** |
|
| 122 | + * the name of cookie used to store the client language |
|
| 123 | + */ |
|
| 124 | + $config['language_cookie_name'] = 'cookie_lang'; |
|
| 125 | 125 | |
| 126 | 126 | |
| 127 | - /*+---------------------------------------------------------------+ |
|
| 127 | + /*+---------------------------------------------------------------+ |
|
| 128 | 128 | * Logs configuration section |
| 129 | 129 | +------------------------------------------------------------------+ |
| 130 | 130 | */ |
| 131 | 131 | |
| 132 | - /** |
|
| 133 | - * The log level |
|
| 134 | - * |
|
| 135 | - * The valid level are: OFF, NONE, FATAL, ERROR, WARNING, WARN, INFO, DEBUG, ALL |
|
| 136 | - * |
|
| 137 | - * 'OFF' or 'NONE' = do not save log |
|
| 138 | - * 'FATAL' = enable log for fatal level and above (FATAL) |
|
| 139 | - * 'ERROR' = enable log for error level and above (ERROR, FATAL) |
|
| 140 | - * 'WARNING' or WARN = enable log for warning level and above (WARNING, ERROR, FATAL) |
|
| 141 | - * 'INFO' = enable log for info level and above (INFO, WARNING, ERROR, FATAL) |
|
| 142 | - * 'DEBUG' = enable log for debug level and above (DEBUG, INFO, WARNING, ERROR, FATAL) |
|
| 143 | - * 'ALL' = enable log for all level |
|
| 144 | - * |
|
| 145 | - * The default value is NONE if the config value is: null, '', 0, false |
|
| 146 | - * |
|
| 147 | - * Note: in production environment it's recommand to set the log level to 'WARNING' if not in small |
|
| 148 | - * of time the log file size will increase very fast and will cost the application performance |
|
| 149 | - * and also the filesystem usage of your server. |
|
| 150 | - */ |
|
| 151 | - $config['log_level'] = 'NONE'; |
|
| 132 | + /** |
|
| 133 | + * The log level |
|
| 134 | + * |
|
| 135 | + * The valid level are: OFF, NONE, FATAL, ERROR, WARNING, WARN, INFO, DEBUG, ALL |
|
| 136 | + * |
|
| 137 | + * 'OFF' or 'NONE' = do not save log |
|
| 138 | + * 'FATAL' = enable log for fatal level and above (FATAL) |
|
| 139 | + * 'ERROR' = enable log for error level and above (ERROR, FATAL) |
|
| 140 | + * 'WARNING' or WARN = enable log for warning level and above (WARNING, ERROR, FATAL) |
|
| 141 | + * 'INFO' = enable log for info level and above (INFO, WARNING, ERROR, FATAL) |
|
| 142 | + * 'DEBUG' = enable log for debug level and above (DEBUG, INFO, WARNING, ERROR, FATAL) |
|
| 143 | + * 'ALL' = enable log for all level |
|
| 144 | + * |
|
| 145 | + * The default value is NONE if the config value is: null, '', 0, false |
|
| 146 | + * |
|
| 147 | + * Note: in production environment it's recommand to set the log level to 'WARNING' if not in small |
|
| 148 | + * of time the log file size will increase very fast and will cost the application performance |
|
| 149 | + * and also the filesystem usage of your server. |
|
| 150 | + */ |
|
| 151 | + $config['log_level'] = 'NONE'; |
|
| 152 | 152 | |
| 153 | 153 | |
| 154 | - /** |
|
| 155 | - * The path to log directory |
|
| 156 | - * |
|
| 157 | - * The path that the log data will be saved ending with de "/" or "\", leave empty if you |
|
| 158 | - * want use the default configuration |
|
| 159 | - * warning : if set, this directory must exist and will be writable and owned by the web server |
|
| 160 | - * else the default value will be used i.e the constant LOG_PATH |
|
| 161 | - * for security raison this directory must be outside of the document root of your |
|
| 162 | - * website. |
|
| 163 | - */ |
|
| 164 | - $config['log_save_path'] = ''; |
|
| 154 | + /** |
|
| 155 | + * The path to log directory |
|
| 156 | + * |
|
| 157 | + * The path that the log data will be saved ending with de "/" or "\", leave empty if you |
|
| 158 | + * want use the default configuration |
|
| 159 | + * warning : if set, this directory must exist and will be writable and owned by the web server |
|
| 160 | + * else the default value will be used i.e the constant LOG_PATH |
|
| 161 | + * for security raison this directory must be outside of the document root of your |
|
| 162 | + * website. |
|
| 163 | + */ |
|
| 164 | + $config['log_save_path'] = ''; |
|
| 165 | 165 | |
| 166 | - /** |
|
| 167 | - * The logger name to use for the log |
|
| 168 | - * |
|
| 169 | - * You can use an string or array of logger. If this config is set so means only log message with this or these logger(s) will be accepted |
|
| 170 | - * |
|
| 171 | - * Example: |
|
| 172 | - * //using string for only one logger name |
|
| 173 | - * $config['log_logger_name'] = 'MY_LOGGER'; //only log message with MY_LOGGER will be saved in file. |
|
| 174 | - * |
|
| 175 | - * //using array for muliple logger names |
|
| 176 | - * $config['log_logger_name'] = array('MY_LOGGER1', 'MY_LOGGER2'); //only log message with MY_LOGGER1 or MY_LOGGER2 will be saved in file. |
|
| 177 | - */ |
|
| 178 | - $config['log_logger_name'] = ''; |
|
| 166 | + /** |
|
| 167 | + * The logger name to use for the log |
|
| 168 | + * |
|
| 169 | + * You can use an string or array of logger. If this config is set so means only log message with this or these logger(s) will be accepted |
|
| 170 | + * |
|
| 171 | + * Example: |
|
| 172 | + * //using string for only one logger name |
|
| 173 | + * $config['log_logger_name'] = 'MY_LOGGER'; //only log message with MY_LOGGER will be saved in file. |
|
| 174 | + * |
|
| 175 | + * //using array for muliple logger names |
|
| 176 | + * $config['log_logger_name'] = array('MY_LOGGER1', 'MY_LOGGER2'); //only log message with MY_LOGGER1 or MY_LOGGER2 will be saved in file. |
|
| 177 | + */ |
|
| 178 | + $config['log_logger_name'] = ''; |
|
| 179 | 179 | |
| 180 | 180 | |
| 181 | - /*+---------------------------------------------------------------+ |
|
| 181 | + /*+---------------------------------------------------------------+ |
|
| 182 | 182 | * Session configuration section |
| 183 | 183 | +------------------------------------------------------------------+ |
| 184 | 184 | */ |
| 185 | 185 | |
| 186 | - /** |
|
| 187 | - * The session name |
|
| 188 | - * |
|
| 189 | - * By default is PHPSESSID. this must be alpha-numerical characters |
|
| 190 | - */ |
|
| 191 | - $config['session_name'] = 'PHPSESSID'; |
|
| 186 | + /** |
|
| 187 | + * The session name |
|
| 188 | + * |
|
| 189 | + * By default is PHPSESSID. this must be alpha-numerical characters |
|
| 190 | + */ |
|
| 191 | + $config['session_name'] = 'PHPSESSID'; |
|
| 192 | 192 | |
| 193 | - /** |
|
| 194 | - * Session save path |
|
| 195 | - * |
|
| 196 | - * The path that the session data will be saved, leave empty if you |
|
| 197 | - * want use the default configuration in the php.ini |
|
| 198 | - * warning : if set, this directory must exist and will be writable and owned by the web server |
|
| 199 | - * for security raison this directory must be outside of the document root of your |
|
| 200 | - * website. |
|
| 201 | - * Note: if the session handler is "database" the session_save_path is the model name to use |
|
| 202 | - */ |
|
| 203 | - $config['session_save_path'] = ''; |
|
| 193 | + /** |
|
| 194 | + * Session save path |
|
| 195 | + * |
|
| 196 | + * The path that the session data will be saved, leave empty if you |
|
| 197 | + * want use the default configuration in the php.ini |
|
| 198 | + * warning : if set, this directory must exist and will be writable and owned by the web server |
|
| 199 | + * for security raison this directory must be outside of the document root of your |
|
| 200 | + * website. |
|
| 201 | + * Note: if the session handler is "database" the session_save_path is the model name to use |
|
| 202 | + */ |
|
| 203 | + $config['session_save_path'] = ''; |
|
| 204 | 204 | |
| 205 | - /** |
|
| 206 | - * Session handler |
|
| 207 | - * |
|
| 208 | - * The session handler that we will use to manage the session. |
|
| 209 | - * currently the possible values are "files", "database". |
|
| 210 | - */ |
|
| 211 | - $config['session_handler'] = 'files'; |
|
| 205 | + /** |
|
| 206 | + * Session handler |
|
| 207 | + * |
|
| 208 | + * The session handler that we will use to manage the session. |
|
| 209 | + * currently the possible values are "files", "database". |
|
| 210 | + */ |
|
| 211 | + $config['session_handler'] = 'files'; |
|
| 212 | 212 | |
| 213 | - /** |
|
| 214 | - * Session secret |
|
| 215 | - * |
|
| 216 | - * This is used to hash the session data if the config "session_handler" is set to "database" |
|
| 217 | - * warning : do not change this value until you already set |
|
| 218 | - * for security raison use the very complicated value include $%)@^&^\''\'\' |
|
| 219 | - * NOTE: this value is an base64 so you need use the tool that generate it, like |
|
| 220 | - * PHP function base64_encode() |
|
| 221 | - */ |
|
| 222 | - $config['session_secret'] = ''; |
|
| 213 | + /** |
|
| 214 | + * Session secret |
|
| 215 | + * |
|
| 216 | + * This is used to hash the session data if the config "session_handler" is set to "database" |
|
| 217 | + * warning : do not change this value until you already set |
|
| 218 | + * for security raison use the very complicated value include $%)@^&^\''\'\' |
|
| 219 | + * NOTE: this value is an base64 so you need use the tool that generate it, like |
|
| 220 | + * PHP function base64_encode() |
|
| 221 | + */ |
|
| 222 | + $config['session_secret'] = ''; |
|
| 223 | 223 | |
| 224 | - /** |
|
| 225 | - * number of second that consider the session already expire |
|
| 226 | - */ |
|
| 227 | - $config['session_inactivity_time'] = 600; //in second |
|
| 224 | + /** |
|
| 225 | + * number of second that consider the session already expire |
|
| 226 | + */ |
|
| 227 | + $config['session_inactivity_time'] = 600; //in second |
|
| 228 | 228 | |
| 229 | - /** |
|
| 230 | - * Session cookie lifetime |
|
| 231 | - * |
|
| 232 | - * The cookie lifetime that the session will be dropped in seconds, leave 0 if you want |
|
| 233 | - * the cookie expire after the browser is closed |
|
| 234 | - */ |
|
| 235 | - $config['session_cookie_lifetime'] = 0; |
|
| 229 | + /** |
|
| 230 | + * Session cookie lifetime |
|
| 231 | + * |
|
| 232 | + * The cookie lifetime that the session will be dropped in seconds, leave 0 if you want |
|
| 233 | + * the cookie expire after the browser is closed |
|
| 234 | + */ |
|
| 235 | + $config['session_cookie_lifetime'] = 0; |
|
| 236 | 236 | |
| 237 | - /** |
|
| 238 | - * Session cookie path |
|
| 239 | - * |
|
| 240 | - * The path to your website that the cookie is available "/" means all path is available |
|
| 241 | - * example : /mysubdirectory => available in http://www.mysite.com/mysubdirectory |
|
| 242 | - */ |
|
| 243 | - $config['session_cookie_path'] = '/'; |
|
| 237 | + /** |
|
| 238 | + * Session cookie path |
|
| 239 | + * |
|
| 240 | + * The path to your website that the cookie is available "/" means all path is available |
|
| 241 | + * example : /mysubdirectory => available in http://www.mysite.com/mysubdirectory |
|
| 242 | + */ |
|
| 243 | + $config['session_cookie_path'] = '/'; |
|
| 244 | 244 | |
| 245 | - /** |
|
| 246 | - * Session cookie domain |
|
| 247 | - * |
|
| 248 | - * The domain of your website that the cookie is available if you want the cookie is available |
|
| 249 | - * in all your subdomain use this dot before the domain name for example ".mysite.com". |
|
| 250 | - * leave empty if you want use the default configuration |
|
| 251 | - */ |
|
| 252 | - $config['session_cookie_domain'] = ''; |
|
| 245 | + /** |
|
| 246 | + * Session cookie domain |
|
| 247 | + * |
|
| 248 | + * The domain of your website that the cookie is available if you want the cookie is available |
|
| 249 | + * in all your subdomain use this dot before the domain name for example ".mysite.com". |
|
| 250 | + * leave empty if you want use the default configuration |
|
| 251 | + */ |
|
| 252 | + $config['session_cookie_domain'] = ''; |
|
| 253 | 253 | |
| 254 | - /** |
|
| 255 | - * Session cookie secure |
|
| 256 | - * |
|
| 257 | - * If your website use SSL i.e https, you set "true" for this configuration, so the cookie |
|
| 258 | - * is available only if the website use the secure connection else set this value to "false" |
|
| 259 | - */ |
|
| 260 | - $config['session_cookie_secure'] = false; |
|
| 254 | + /** |
|
| 255 | + * Session cookie secure |
|
| 256 | + * |
|
| 257 | + * If your website use SSL i.e https, you set "true" for this configuration, so the cookie |
|
| 258 | + * is available only if the website use the secure connection else set this value to "false" |
|
| 259 | + */ |
|
| 260 | + $config['session_cookie_secure'] = false; |
|
| 261 | 261 | |
| 262 | 262 | |
| 263 | - /*+---------------------------------------------------------------+ |
|
| 263 | + /*+---------------------------------------------------------------+ |
|
| 264 | 264 | * CSRF configuration section |
| 265 | 265 | +------------------------------------------------------------------+ |
| 266 | 266 | */ |
| 267 | 267 | |
| 268 | - /** |
|
| 269 | - * CSRF status |
|
| 270 | - * |
|
| 271 | - * if you would to use the CSRF (that we recommand you), set this key to true |
|
| 272 | - */ |
|
| 273 | - $config['csrf_enable'] = false; |
|
| 268 | + /** |
|
| 269 | + * CSRF status |
|
| 270 | + * |
|
| 271 | + * if you would to use the CSRF (that we recommand you), set this key to true |
|
| 272 | + */ |
|
| 273 | + $config['csrf_enable'] = false; |
|
| 274 | 274 | |
| 275 | - /** |
|
| 276 | - * CSRF key |
|
| 277 | - * |
|
| 278 | - * the key used to store the csrf data |
|
| 279 | - */ |
|
| 280 | - $config['csrf_key'] = 'csrf_key'; |
|
| 275 | + /** |
|
| 276 | + * CSRF key |
|
| 277 | + * |
|
| 278 | + * the key used to store the csrf data |
|
| 279 | + */ |
|
| 280 | + $config['csrf_key'] = 'csrf_key'; |
|
| 281 | 281 | |
| 282 | - /** |
|
| 283 | - * CSRF expire |
|
| 284 | - * |
|
| 285 | - * expire time in seconds of the CSRF data |
|
| 286 | - */ |
|
| 287 | - $config['csrf_expire'] = 120; |
|
| 282 | + /** |
|
| 283 | + * CSRF expire |
|
| 284 | + * |
|
| 285 | + * expire time in seconds of the CSRF data |
|
| 286 | + */ |
|
| 287 | + $config['csrf_expire'] = 120; |
|
| 288 | 288 | |
| 289 | 289 | |
| 290 | - /*+---------------------------------------------------------------+ |
|
| 290 | + /*+---------------------------------------------------------------+ |
|
| 291 | 291 | * Cache configuration section |
| 292 | 292 | +------------------------------------------------------------------+ |
| 293 | 293 | */ |
| 294 | 294 | |
| 295 | - /** |
|
| 296 | - * Cache status |
|
| 297 | - * |
|
| 298 | - * If you would to use the cache functionnality set this value to true |
|
| 299 | - */ |
|
| 300 | - $config['cache_enable'] = false; |
|
| 295 | + /** |
|
| 296 | + * Cache status |
|
| 297 | + * |
|
| 298 | + * If you would to use the cache functionnality set this value to true |
|
| 299 | + */ |
|
| 300 | + $config['cache_enable'] = false; |
|
| 301 | 301 | |
| 302 | - /** |
|
| 303 | - * Cache Time To Live |
|
| 304 | - * |
|
| 305 | - * expire time in seconds of the cache data |
|
| 306 | - */ |
|
| 307 | - $config['cache_ttl'] = 120; //in second |
|
| 302 | + /** |
|
| 303 | + * Cache Time To Live |
|
| 304 | + * |
|
| 305 | + * expire time in seconds of the cache data |
|
| 306 | + */ |
|
| 307 | + $config['cache_ttl'] = 120; //in second |
|
| 308 | 308 | |
| 309 | - /** |
|
| 310 | - * Cache handler class |
|
| 311 | - * |
|
| 312 | - * The cache handler class inside (CORE_CLASSES_CACHE_PATH, LIBRARY_PATH) directories that implements |
|
| 313 | - * the interface "CacheInterface" that we will use to manage the cache. |
|
| 314 | - * currently the possible values are "FileCache", "ApcCache". |
|
| 315 | - */ |
|
| 316 | - $config['cache_handler'] = 'FileCache'; |
|
| 309 | + /** |
|
| 310 | + * Cache handler class |
|
| 311 | + * |
|
| 312 | + * The cache handler class inside (CORE_CLASSES_CACHE_PATH, LIBRARY_PATH) directories that implements |
|
| 313 | + * the interface "CacheInterface" that we will use to manage the cache. |
|
| 314 | + * currently the possible values are "FileCache", "ApcCache". |
|
| 315 | + */ |
|
| 316 | + $config['cache_handler'] = 'FileCache'; |
|
| 317 | 317 | |
| 318 | 318 | |
| 319 | - /*+---------------------------------------------------------------+ |
|
| 319 | + /*+---------------------------------------------------------------+ |
|
| 320 | 320 | * White list IP access configuration section |
| 321 | 321 | +------------------------------------------------------------------+ |
| 322 | 322 | */ |
| 323 | 323 | |
| 324 | - /** |
|
| 325 | - * White list ip status |
|
| 326 | - * |
|
| 327 | - * if you would to use the white list ip access, set this key to true |
|
| 328 | - */ |
|
| 329 | - $config['white_list_ip_enable'] = false; |
|
| 324 | + /** |
|
| 325 | + * White list ip status |
|
| 326 | + * |
|
| 327 | + * if you would to use the white list ip access, set this key to true |
|
| 328 | + */ |
|
| 329 | + $config['white_list_ip_enable'] = false; |
|
| 330 | 330 | |
| 331 | - /** |
|
| 332 | - * White listed ip addresses |
|
| 333 | - * |
|
| 334 | - * add the allowed ip address list to access this application. |
|
| 335 | - * You can use the wildcard address |
|
| 336 | - * @example: '18.90.09.*', '10.*.*.*', '*' |
|
| 337 | - * |
|
| 338 | - */ |
|
| 339 | - $config['white_list_ip_addresses'] = array('127.0.0.1', '::1'); |
|
| 331 | + /** |
|
| 332 | + * White listed ip addresses |
|
| 333 | + * |
|
| 334 | + * add the allowed ip address list to access this application. |
|
| 335 | + * You can use the wildcard address |
|
| 336 | + * @example: '18.90.09.*', '10.*.*.*', '*' |
|
| 337 | + * |
|
| 338 | + */ |
|
| 339 | + $config['white_list_ip_addresses'] = array('127.0.0.1', '::1'); |
|
| 340 | 340 | |
| 341 | - |
|
| 342 | 341 | \ No newline at end of file |
| 342 | + |
|
| 343 | 343 | \ No newline at end of file |
@@ -1,127 +1,127 @@ |
||
| 1 | 1 | <?php |
| 2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | - /** |
|
| 4 | - * TNH Framework |
|
| 5 | - * |
|
| 6 | - * A simple PHP framework created using the concept of codeigniter with bootstrap twitter |
|
| 7 | - * |
|
| 8 | - * This content is released under the GNU GPL License (GPL) |
|
| 9 | - * |
|
| 10 | - * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | - * |
|
| 12 | - * This program is free software; you can redistribute it and/or |
|
| 13 | - * modify it under the terms of the GNU General Public License |
|
| 14 | - * as published by the Free Software Foundation; either version 3 |
|
| 15 | - * of the License, or (at your option) any later version. |
|
| 16 | - * |
|
| 17 | - * This program is distributed in the hope that it will be useful, |
|
| 18 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | - * GNU General Public License for more details. |
|
| 21 | - * |
|
| 22 | - * You should have received a copy of the GNU General Public License |
|
| 23 | - * along with this program; if not, write to the Free Software |
|
| 24 | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | - */ |
|
| 2 | + defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | + /** |
|
| 4 | + * TNH Framework |
|
| 5 | + * |
|
| 6 | + * A simple PHP framework created using the concept of codeigniter with bootstrap twitter |
|
| 7 | + * |
|
| 8 | + * This content is released under the GNU GPL License (GPL) |
|
| 9 | + * |
|
| 10 | + * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | + * |
|
| 12 | + * This program is free software; you can redistribute it and/or |
|
| 13 | + * modify it under the terms of the GNU General Public License |
|
| 14 | + * as published by the Free Software Foundation; either version 3 |
|
| 15 | + * of the License, or (at your option) any later version. |
|
| 16 | + * |
|
| 17 | + * This program is distributed in the hope that it will be useful, |
|
| 18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | + * GNU General Public License for more details. |
|
| 21 | + * |
|
| 22 | + * You should have received a copy of the GNU General Public License |
|
| 23 | + * along with this program; if not, write to the Free Software |
|
| 24 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | + */ |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * This file contains the connection information to your database, this file is read when you load the "Database" library. |
|
| 29 | - * You will find all its configuration parameters at your web hosting. |
|
| 30 | - */ |
|
| 27 | + /** |
|
| 28 | + * This file contains the connection information to your database, this file is read when you load the "Database" library. |
|
| 29 | + * You will find all its configuration parameters at your web hosting. |
|
| 30 | + */ |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * The type or driver of your database. |
|
| 34 | - * |
|
| 35 | - * Note: the "Database" library uses the PHP PDO extension to interact with your database, |
|
| 36 | - * so most of the PDO supported drivers namely: mysql, pgsql, sqlite, oracle are accepted. |
|
| 37 | - * For example : |
|
| 38 | - * |
|
| 39 | - * $db['driver'] = 'mysql'; // for MySQL Database |
|
| 40 | - * or |
|
| 41 | - * $db['driver'] = 'pgsql'; // for PostgreSQL Database |
|
| 42 | - * or |
|
| 43 | - * $db['driver'] = 'sqlite'; // for SQLite Database |
|
| 44 | - * or |
|
| 45 | - * $db['driver'] = 'oracle'; // for Oracle Database |
|
| 46 | - * |
|
| 47 | - */ |
|
| 48 | - $db['driver'] = 'mysql'; |
|
| 32 | + /** |
|
| 33 | + * The type or driver of your database. |
|
| 34 | + * |
|
| 35 | + * Note: the "Database" library uses the PHP PDO extension to interact with your database, |
|
| 36 | + * so most of the PDO supported drivers namely: mysql, pgsql, sqlite, oracle are accepted. |
|
| 37 | + * For example : |
|
| 38 | + * |
|
| 39 | + * $db['driver'] = 'mysql'; // for MySQL Database |
|
| 40 | + * or |
|
| 41 | + * $db['driver'] = 'pgsql'; // for PostgreSQL Database |
|
| 42 | + * or |
|
| 43 | + * $db['driver'] = 'sqlite'; // for SQLite Database |
|
| 44 | + * or |
|
| 45 | + * $db['driver'] = 'oracle'; // for Oracle Database |
|
| 46 | + * |
|
| 47 | + */ |
|
| 48 | + $db['driver'] = 'mysql'; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * The address of your database server |
|
| 52 | - * |
|
| 53 | - * It can be a domain name or IP address, for example: |
|
| 54 | - * $db['hostname'] = 'localhost'; |
|
| 55 | - * or |
|
| 56 | - * $db['hostname'] = 'mysql.host.com'; |
|
| 57 | - * or |
|
| 58 | - * $db['hostname'] = '187.15.14.17'; |
|
| 59 | - * * or if port is not a standart port |
|
| 60 | - * $db['hostname'] = 'mydb.server.com:6356'; |
|
| 61 | - */ |
|
| 62 | - $db['hostname'] = 'localhost'; |
|
| 50 | + /** |
|
| 51 | + * The address of your database server |
|
| 52 | + * |
|
| 53 | + * It can be a domain name or IP address, for example: |
|
| 54 | + * $db['hostname'] = 'localhost'; |
|
| 55 | + * or |
|
| 56 | + * $db['hostname'] = 'mysql.host.com'; |
|
| 57 | + * or |
|
| 58 | + * $db['hostname'] = '187.15.14.17'; |
|
| 59 | + * * or if port is not a standart port |
|
| 60 | + * $db['hostname'] = 'mydb.server.com:6356'; |
|
| 61 | + */ |
|
| 62 | + $db['hostname'] = 'localhost'; |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * The username of your database server |
|
| 66 | - * for example : |
|
| 67 | - * |
|
| 68 | - * $db['username'] = 'root'; |
|
| 69 | - * or |
|
| 70 | - * $db['username'] = 'myusername'; |
|
| 71 | - */ |
|
| 72 | - $db['username'] = 'root'; |
|
| 64 | + /** |
|
| 65 | + * The username of your database server |
|
| 66 | + * for example : |
|
| 67 | + * |
|
| 68 | + * $db['username'] = 'root'; |
|
| 69 | + * or |
|
| 70 | + * $db['username'] = 'myusername'; |
|
| 71 | + */ |
|
| 72 | + $db['username'] = 'root'; |
|
| 73 | 73 | |
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * The password of your database server. |
|
| 77 | - * |
|
| 78 | - * Note: Some configuration settings on some database management systems do not allow |
|
| 79 | - * connection with a user without password, so it is recommended to set a password for this user for a security measure. |
|
| 80 | - * for example : |
|
| 81 | - * |
|
| 82 | - * $db['password'] = ''; //for an empty password, this is the case most often, if you are in local, ie for the user "root". |
|
| 83 | - * or |
|
| 84 | - * $db['password'] = 'M@5CUR3P@$$W0rd'; |
|
| 85 | - */ |
|
| 86 | - $db['password'] = ''; |
|
| 75 | + /** |
|
| 76 | + * The password of your database server. |
|
| 77 | + * |
|
| 78 | + * Note: Some configuration settings on some database management systems do not allow |
|
| 79 | + * connection with a user without password, so it is recommended to set a password for this user for a security measure. |
|
| 80 | + * for example : |
|
| 81 | + * |
|
| 82 | + * $db['password'] = ''; //for an empty password, this is the case most often, if you are in local, ie for the user "root". |
|
| 83 | + * or |
|
| 84 | + * $db['password'] = 'M@5CUR3P@$$W0rd'; |
|
| 85 | + */ |
|
| 86 | + $db['password'] = ''; |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * The name of your database |
|
| 90 | - * |
|
| 91 | - * for example : |
|
| 92 | - * |
|
| 93 | - * $db['database'] = 'database_name'; |
|
| 94 | - */ |
|
| 95 | - $db['database'] = ''; |
|
| 88 | + /** |
|
| 89 | + * The name of your database |
|
| 90 | + * |
|
| 91 | + * for example : |
|
| 92 | + * |
|
| 93 | + * $db['database'] = 'database_name'; |
|
| 94 | + */ |
|
| 95 | + $db['database'] = ''; |
|
| 96 | 96 | |
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * The character set that will be used by the database server. |
|
| 100 | - * for example : |
|
| 101 | - * |
|
| 102 | - * $db['charset'] = 'utf8'; |
|
| 103 | - */ |
|
| 104 | - $db['charset'] = 'utf8'; |
|
| 98 | + /** |
|
| 99 | + * The character set that will be used by the database server. |
|
| 100 | + * for example : |
|
| 101 | + * |
|
| 102 | + * $db['charset'] = 'utf8'; |
|
| 103 | + */ |
|
| 104 | + $db['charset'] = 'utf8'; |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * In addition to the character set, a certain database management system allows you to |
|
| 108 | - * choose how the data will be classified (ORDER BY) by what is called a "COLLATE". |
|
| 109 | - * This makes it possible, for example, to answer the classic problem of case sensitivity. |
|
| 110 | - * for example : |
|
| 111 | - * $db['collation'] = 'utf8_general_ci'; |
|
| 112 | - */ |
|
| 113 | - $db['collation'] = 'utf8_general_ci'; |
|
| 106 | + /** |
|
| 107 | + * In addition to the character set, a certain database management system allows you to |
|
| 108 | + * choose how the data will be classified (ORDER BY) by what is called a "COLLATE". |
|
| 109 | + * This makes it possible, for example, to answer the classic problem of case sensitivity. |
|
| 110 | + * for example : |
|
| 111 | + * $db['collation'] = 'utf8_general_ci'; |
|
| 112 | + */ |
|
| 113 | + $db['collation'] = 'utf8_general_ci'; |
|
| 114 | 114 | |
| 115 | 115 | |
| 116 | - /** |
|
| 117 | - * If your tables in your database contain prefixes, this is the case most on some application, |
|
| 118 | - * to avoid the conflict of name of the tables between different database, |
|
| 119 | - * it is possible to define prefixes for the tables. |
|
| 120 | - * for example : |
|
| 121 | - * |
|
| 122 | - * $db['prefix'] = 'pf_'; |
|
| 123 | - * or |
|
| 124 | - * |
|
| 125 | - * $db['prefix'] = 'my_db_'; |
|
| 126 | - */ |
|
| 127 | - $db['prefix'] = ''; |
|
| 128 | 116 | \ No newline at end of file |
| 117 | + /** |
|
| 118 | + * If your tables in your database contain prefixes, this is the case most on some application, |
|
| 119 | + * to avoid the conflict of name of the tables between different database, |
|
| 120 | + * it is possible to define prefixes for the tables. |
|
| 121 | + * for example : |
|
| 122 | + * |
|
| 123 | + * $db['prefix'] = 'pf_'; |
|
| 124 | + * or |
|
| 125 | + * |
|
| 126 | + * $db['prefix'] = 'my_db_'; |
|
| 127 | + */ |
|
| 128 | + $db['prefix'] = ''; |
|
| 129 | 129 | \ No newline at end of file |
@@ -1,88 +1,88 @@ |
||
| 1 | 1 | <?php |
| 2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | - /** |
|
| 4 | - * TNH Framework |
|
| 5 | - * |
|
| 6 | - * A simple PHP framework created using the concept of codeigniter with bootstrap twitter |
|
| 7 | - * |
|
| 8 | - * This content is released under the GNU GPL License (GPL) |
|
| 9 | - * |
|
| 10 | - * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | - * |
|
| 12 | - * This program is free software; you can redistribute it and/or |
|
| 13 | - * modify it under the terms of the GNU General Public License |
|
| 14 | - * as published by the Free Software Foundation; either version 3 |
|
| 15 | - * of the License, or (at your option) any later version. |
|
| 16 | - * |
|
| 17 | - * This program is distributed in the hope that it will be useful, |
|
| 18 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | - * GNU General Public License for more details. |
|
| 21 | - * |
|
| 22 | - * You should have received a copy of the GNU General Public License |
|
| 23 | - * along with this program; if not, write to the Free Software |
|
| 24 | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | - */ |
|
| 2 | + defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | + /** |
|
| 4 | + * TNH Framework |
|
| 5 | + * |
|
| 6 | + * A simple PHP framework created using the concept of codeigniter with bootstrap twitter |
|
| 7 | + * |
|
| 8 | + * This content is released under the GNU GPL License (GPL) |
|
| 9 | + * |
|
| 10 | + * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | + * |
|
| 12 | + * This program is free software; you can redistribute it and/or |
|
| 13 | + * modify it under the terms of the GNU General Public License |
|
| 14 | + * as published by the Free Software Foundation; either version 3 |
|
| 15 | + * of the License, or (at your option) any later version. |
|
| 16 | + * |
|
| 17 | + * This program is distributed in the hope that it will be useful, |
|
| 18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | + * GNU General Public License for more details. |
|
| 21 | + * |
|
| 22 | + * You should have received a copy of the GNU General Public License |
|
| 23 | + * along with this program; if not, write to the Free Software |
|
| 24 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | + */ |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * This file contains the configuration of your routes that is to say that links to your URLs. |
|
| 29 | - * The index of the $route array contains the url address to capture and the value contains |
|
| 30 | - * the name of the module, controller and the method to call. |
|
| 31 | - * For example : |
|
| 32 | - * |
|
| 33 | - * $route['/users/login'] = 'moduleUsers#UsersController@login_action'; |
|
| 34 | - * |
|
| 35 | - * it means, if the user type in the address bar an URL like http://yoursite.com/users/login, |
|
| 36 | - * that will call the module "moduleUsers", the controller "UsersController" and the method "login_action". |
|
| 37 | - * Note 1: it is recommended that each index in the $route array start with a slash "/" |
|
| 38 | - * otherwise on some system this will not work. |
|
| 39 | - * Note 2: to define the default controller route (homepage) of your application you use only the index "/" |
|
| 40 | - * for example the following route represents the homepage: |
|
| 41 | - * |
|
| 42 | - * $route['/'] = 'Home'; //only the controller or module name |
|
| 43 | - * |
|
| 44 | - * $route['/'] = 'Home@index'; //only the controller or module name with the method |
|
| 45 | - * |
|
| 46 | - * $route['/'] = 'module#Home@index'; //with module name, controller and method |
|
| 47 | - * |
|
| 48 | - * Note 3: If the method is not specified then the "index" method will be used as |
|
| 49 | - * default method. For example in the case of our homepage, this will be able to make: |
|
| 50 | - * |
|
| 51 | - * $route['/'] = 'Home'; |
|
| 52 | - * |
|
| 53 | - * Note 4: All methods called must have "public" visibility if you know the principle of |
|
| 54 | - * Object Oriented Programming, you know what visibility means (public, protected, private). |
|
| 55 | - * |
|
| 56 | - * In the index of your route, you can use the markers (:num), (:alpha), (:alnum) and (:any) which correspond |
|
| 57 | - * respectively to the regular expression [0-9], [a-zA-Z], [a-zA-Z0-9] and. *. |
|
| 58 | - * For example : |
|
| 59 | - * |
|
| 60 | - * - $route['/profile/(:num)'] = 'UsersController@profile'; => http://yoursite.com/profile/4 will be captured but |
|
| 61 | - * http://yoursite.com/profile/a will not captured. |
|
| 62 | - * |
|
| 63 | - * - $route['/profile/(:alpha)'] = 'UsersController@profile'; => http://yoursite.com/profile/a will be captured |
|
| 64 | - * but http://yoursite.com/profile/1457 will not captured. |
|
| 65 | - * |
|
| 66 | - * - $route['/profile/(:alnum)'] = 'UsersController@profile'; => http://yoursite.com/profile/4a, |
|
| 67 | - * http://yoursite.com/profile/7 will be captured but http://yoursite.com/profile/7-dangerous will not captured. |
|
| 68 | - * |
|
| 69 | - * - $route['/(:any)'] = 'ArticleController@read'; => http://yoursite.com/1-my-super-article, |
|
| 70 | - * http://yoursite.com/7, will be captured. |
|
| 71 | - * |
|
| 72 | - * Note 5: The order of definition of each route is important. |
|
| 73 | - * For example, the following definitions work: |
|
| 74 | - * |
|
| 75 | - * $route['/article/add'] = 'Article@add'; |
|
| 76 | - * $route['article/(:any)'] = 'Article@read'; |
|
| 77 | - * |
|
| 78 | - * however, the following definitions does not work as intended |
|
| 79 | - * |
|
| 80 | - * $route['article/(:any)'] = 'Article@read'; |
|
| 81 | - * $route['/article/add'] = 'Article@add'; |
|
| 82 | - * |
|
| 83 | - */ |
|
| 27 | + /** |
|
| 28 | + * This file contains the configuration of your routes that is to say that links to your URLs. |
|
| 29 | + * The index of the $route array contains the url address to capture and the value contains |
|
| 30 | + * the name of the module, controller and the method to call. |
|
| 31 | + * For example : |
|
| 32 | + * |
|
| 33 | + * $route['/users/login'] = 'moduleUsers#UsersController@login_action'; |
|
| 34 | + * |
|
| 35 | + * it means, if the user type in the address bar an URL like http://yoursite.com/users/login, |
|
| 36 | + * that will call the module "moduleUsers", the controller "UsersController" and the method "login_action". |
|
| 37 | + * Note 1: it is recommended that each index in the $route array start with a slash "/" |
|
| 38 | + * otherwise on some system this will not work. |
|
| 39 | + * Note 2: to define the default controller route (homepage) of your application you use only the index "/" |
|
| 40 | + * for example the following route represents the homepage: |
|
| 41 | + * |
|
| 42 | + * $route['/'] = 'Home'; //only the controller or module name |
|
| 43 | + * |
|
| 44 | + * $route['/'] = 'Home@index'; //only the controller or module name with the method |
|
| 45 | + * |
|
| 46 | + * $route['/'] = 'module#Home@index'; //with module name, controller and method |
|
| 47 | + * |
|
| 48 | + * Note 3: If the method is not specified then the "index" method will be used as |
|
| 49 | + * default method. For example in the case of our homepage, this will be able to make: |
|
| 50 | + * |
|
| 51 | + * $route['/'] = 'Home'; |
|
| 52 | + * |
|
| 53 | + * Note 4: All methods called must have "public" visibility if you know the principle of |
|
| 54 | + * Object Oriented Programming, you know what visibility means (public, protected, private). |
|
| 55 | + * |
|
| 56 | + * In the index of your route, you can use the markers (:num), (:alpha), (:alnum) and (:any) which correspond |
|
| 57 | + * respectively to the regular expression [0-9], [a-zA-Z], [a-zA-Z0-9] and. *. |
|
| 58 | + * For example : |
|
| 59 | + * |
|
| 60 | + * - $route['/profile/(:num)'] = 'UsersController@profile'; => http://yoursite.com/profile/4 will be captured but |
|
| 61 | + * http://yoursite.com/profile/a will not captured. |
|
| 62 | + * |
|
| 63 | + * - $route['/profile/(:alpha)'] = 'UsersController@profile'; => http://yoursite.com/profile/a will be captured |
|
| 64 | + * but http://yoursite.com/profile/1457 will not captured. |
|
| 65 | + * |
|
| 66 | + * - $route['/profile/(:alnum)'] = 'UsersController@profile'; => http://yoursite.com/profile/4a, |
|
| 67 | + * http://yoursite.com/profile/7 will be captured but http://yoursite.com/profile/7-dangerous will not captured. |
|
| 68 | + * |
|
| 69 | + * - $route['/(:any)'] = 'ArticleController@read'; => http://yoursite.com/1-my-super-article, |
|
| 70 | + * http://yoursite.com/7, will be captured. |
|
| 71 | + * |
|
| 72 | + * Note 5: The order of definition of each route is important. |
|
| 73 | + * For example, the following definitions work: |
|
| 74 | + * |
|
| 75 | + * $route['/article/add'] = 'Article@add'; |
|
| 76 | + * $route['article/(:any)'] = 'Article@read'; |
|
| 77 | + * |
|
| 78 | + * however, the following definitions does not work as intended |
|
| 79 | + * |
|
| 80 | + * $route['article/(:any)'] = 'Article@read'; |
|
| 81 | + * $route['/article/add'] = 'Article@add'; |
|
| 82 | + * |
|
| 83 | + */ |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * The default route like your home page |
|
| 87 | - */ |
|
| 88 | - $route['/'] = 'Home'; |
|
| 89 | 85 | \ No newline at end of file |
| 86 | + /** |
|
| 87 | + * The default route like your home page |
|
| 88 | + */ |
|
| 89 | + $route['/'] = 'Home'; |
|
| 90 | 90 | \ No newline at end of file |
@@ -1,90 +1,90 @@ |
||
| 1 | 1 | <?php |
| 2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | - /** |
|
| 4 | - * TNH Framework |
|
| 5 | - * |
|
| 6 | - * A simple PHP framework created using the concept of codeigniter with bootstrap twitter |
|
| 7 | - * |
|
| 8 | - * This content is released under the GNU GPL License (GPL) |
|
| 9 | - * |
|
| 10 | - * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | - * |
|
| 12 | - * This program is free software; you can redistribute it and/or |
|
| 13 | - * modify it under the terms of the GNU General Public License |
|
| 14 | - * as published by the Free Software Foundation; either version 3 |
|
| 15 | - * of the License, or (at your option) any later version. |
|
| 16 | - * |
|
| 17 | - * This program is distributed in the hope that it will be useful, |
|
| 18 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | - * GNU General Public License for more details. |
|
| 21 | - * |
|
| 22 | - * You should have received a copy of the GNU General Public License |
|
| 23 | - * along with this program; if not, write to the Free Software |
|
| 24 | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | - */ |
|
| 2 | + defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | + /** |
|
| 4 | + * TNH Framework |
|
| 5 | + * |
|
| 6 | + * A simple PHP framework created using the concept of codeigniter with bootstrap twitter |
|
| 7 | + * |
|
| 8 | + * This content is released under the GNU GPL License (GPL) |
|
| 9 | + * |
|
| 10 | + * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | + * |
|
| 12 | + * This program is free software; you can redistribute it and/or |
|
| 13 | + * modify it under the terms of the GNU General Public License |
|
| 14 | + * as published by the Free Software Foundation; either version 3 |
|
| 15 | + * of the License, or (at your option) any later version. |
|
| 16 | + * |
|
| 17 | + * This program is distributed in the hope that it will be useful, |
|
| 18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | + * GNU General Public License for more details. |
|
| 21 | + * |
|
| 22 | + * You should have received a copy of the GNU General Public License |
|
| 23 | + * along with this program; if not, write to the Free Software |
|
| 24 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | + */ |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * This file contains the pagination library configuration of your application |
|
| 29 | - */ |
|
| 27 | + /** |
|
| 28 | + * This file contains the pagination library configuration of your application |
|
| 29 | + */ |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Number of pagination digit |
|
| 33 | - */ |
|
| 34 | - $config['nb_link'] = 10; |
|
| 31 | + /** |
|
| 32 | + * Number of pagination digit |
|
| 33 | + */ |
|
| 34 | + $config['nb_link'] = 10; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * The pagination. |
|
| 38 | - * |
|
| 39 | - * Represents the number of data to display per page. |
|
| 40 | - * Note: this value must be strictly greater than zero (0) |
|
| 41 | - */ |
|
| 42 | - $config['pagination_per_page'] = 10; |
|
| 36 | + /** |
|
| 37 | + * The pagination. |
|
| 38 | + * |
|
| 39 | + * Represents the number of data to display per page. |
|
| 40 | + * Note: this value must be strictly greater than zero (0) |
|
| 41 | + */ |
|
| 42 | + $config['pagination_per_page'] = 10; |
|
| 43 | 43 | |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * The query string name used to fetch the current page |
|
| 47 | - */ |
|
| 48 | - $config['page_query_string_name'] = 'page'; |
|
| 45 | + /** |
|
| 46 | + * The query string name used to fetch the current page |
|
| 47 | + */ |
|
| 48 | + $config['page_query_string_name'] = 'page'; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * The opened and closed tag for active link |
|
| 52 | - */ |
|
| 53 | - $config['active_link_open'] = '<li class = "active"><a href = "#">'; |
|
| 54 | - $config['active_link_close'] = '</a></li>'; |
|
| 50 | + /** |
|
| 51 | + * The opened and closed tag for active link |
|
| 52 | + */ |
|
| 53 | + $config['active_link_open'] = '<li class = "active"><a href = "#">'; |
|
| 54 | + $config['active_link_close'] = '</a></li>'; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * The opened and closed tag for previous link |
|
| 58 | - */ |
|
| 59 | - $config['previous_open'] = '<li>'; |
|
| 60 | - $config['previous_close'] = '</li>'; |
|
| 56 | + /** |
|
| 57 | + * The opened and closed tag for previous link |
|
| 58 | + */ |
|
| 59 | + $config['previous_open'] = '<li>'; |
|
| 60 | + $config['previous_close'] = '</li>'; |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * The opened and closed tag for next link |
|
| 64 | - */ |
|
| 65 | - $config['next_open'] = '<li>'; |
|
| 66 | - $config['next_close'] = '</li>'; |
|
| 62 | + /** |
|
| 63 | + * The opened and closed tag for next link |
|
| 64 | + */ |
|
| 65 | + $config['next_open'] = '<li>'; |
|
| 66 | + $config['next_close'] = '</li>'; |
|
| 67 | 67 | |
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * The displayed text for previous and next link |
|
| 71 | - */ |
|
| 72 | - $config['previous_text'] = '««'; |
|
| 73 | - $config['next_text'] = '»»'; |
|
| 69 | + /** |
|
| 70 | + * The displayed text for previous and next link |
|
| 71 | + */ |
|
| 72 | + $config['previous_text'] = '««'; |
|
| 73 | + $config['next_text'] = '»»'; |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * The opened and closed tag for the pagination bloc |
|
| 77 | - */ |
|
| 78 | - $config['pagination_open'] = '<ul class = "pagination">'; |
|
| 79 | - $config['pagination_close'] = '</ul>'; |
|
| 75 | + /** |
|
| 76 | + * The opened and closed tag for the pagination bloc |
|
| 77 | + */ |
|
| 78 | + $config['pagination_open'] = '<ul class = "pagination">'; |
|
| 79 | + $config['pagination_close'] = '</ul>'; |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * The opened and closed tag for each link digit |
|
| 83 | - */ |
|
| 84 | - $config['digit_open'] = '<li>'; |
|
| 85 | - $config['digit_close'] = '</li>'; |
|
| 81 | + /** |
|
| 82 | + * The opened and closed tag for each link digit |
|
| 83 | + */ |
|
| 84 | + $config['digit_open'] = '<li>'; |
|
| 85 | + $config['digit_close'] = '</li>'; |
|
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * The HTML attributes to use in each link |
|
| 89 | - */ |
|
| 90 | - $config['attributes'] = array(); |
|
| 91 | 87 | \ No newline at end of file |
| 88 | + /** |
|
| 89 | + * The HTML attributes to use in each link |
|
| 90 | + */ |
|
| 91 | + $config['attributes'] = array(); |
|
| 92 | 92 | \ No newline at end of file |
@@ -1,260 +1,260 @@ |
||
| 1 | 1 | <?php |
| 2 | - /** |
|
| 3 | - * TNH Framework |
|
| 4 | - * |
|
| 5 | - * A simple PHP framework using HMVC architecture |
|
| 6 | - * |
|
| 7 | - * This content is released under the GNU GPL License (GPL) |
|
| 8 | - * |
|
| 9 | - * Copyright (C) 2017 Tony NGUEREZA |
|
| 10 | - * |
|
| 11 | - * This program is free software; you can redistribute it and/or |
|
| 12 | - * modify it under the terms of the GNU General Public License |
|
| 13 | - * as published by the Free Software Foundation; either version 3 |
|
| 14 | - * of the License, or (at your option) any later version. |
|
| 15 | - * |
|
| 16 | - * This program is distributed in the hope that it will be useful, |
|
| 17 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 18 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 19 | - * GNU General Public License for more details. |
|
| 20 | - * |
|
| 21 | - * You should have received a copy of the GNU General Public License |
|
| 22 | - * along with this program; if not, write to the Free Software |
|
| 23 | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 24 | - */ |
|
| 2 | + /** |
|
| 3 | + * TNH Framework |
|
| 4 | + * |
|
| 5 | + * A simple PHP framework using HMVC architecture |
|
| 6 | + * |
|
| 7 | + * This content is released under the GNU GPL License (GPL) |
|
| 8 | + * |
|
| 9 | + * Copyright (C) 2017 Tony NGUEREZA |
|
| 10 | + * |
|
| 11 | + * This program is free software; you can redistribute it and/or |
|
| 12 | + * modify it under the terms of the GNU General Public License |
|
| 13 | + * as published by the Free Software Foundation; either version 3 |
|
| 14 | + * of the License, or (at your option) any later version. |
|
| 15 | + * |
|
| 16 | + * This program is distributed in the hope that it will be useful, |
|
| 17 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 18 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 19 | + * GNU General Public License for more details. |
|
| 20 | + * |
|
| 21 | + * You should have received a copy of the GNU General Public License |
|
| 22 | + * along with this program; if not, write to the Free Software |
|
| 23 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 24 | + */ |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * the directory separator, under windows it is \ and unix, linux / |
|
| 28 | - */ |
|
| 29 | - define('DS', DIRECTORY_SEPARATOR); |
|
| 26 | + /** |
|
| 27 | + * the directory separator, under windows it is \ and unix, linux / |
|
| 28 | + */ |
|
| 29 | + define('DS', DIRECTORY_SEPARATOR); |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * The root directory of the application. |
|
| 33 | - * |
|
| 34 | - * you can place this directory outside of your web directory, for example "/home/your_app", etc. |
|
| 35 | - */ |
|
| 36 | - define('ROOT_PATH', dirname(realpath(__FILE__)) . DS); |
|
| 31 | + /** |
|
| 32 | + * The root directory of the application. |
|
| 33 | + * |
|
| 34 | + * you can place this directory outside of your web directory, for example "/home/your_app", etc. |
|
| 35 | + */ |
|
| 36 | + define('ROOT_PATH', dirname(realpath(__FILE__)) . DS); |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * The path to the directory. |
|
| 40 | - * |
|
| 41 | - * That contains your static files (javascript, css, images, etc.) |
|
| 42 | - * Note: the path must be relative to the file index.php (the front-end controller). |
|
| 43 | - */ |
|
| 44 | - define('ASSETS_PATH', 'assets/'); |
|
| 38 | + /** |
|
| 39 | + * The path to the directory. |
|
| 40 | + * |
|
| 41 | + * That contains your static files (javascript, css, images, etc.) |
|
| 42 | + * Note: the path must be relative to the file index.php (the front-end controller). |
|
| 43 | + */ |
|
| 44 | + define('ASSETS_PATH', 'assets/'); |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * The path to the directory of your cache files. |
|
| 48 | - * |
|
| 49 | - * This feature is available currently for database and views. |
|
| 50 | - */ |
|
| 51 | - define('CACHE_PATH', ROOT_PATH . 'cache' . DS); |
|
| 46 | + /** |
|
| 47 | + * The path to the directory of your cache files. |
|
| 48 | + * |
|
| 49 | + * This feature is available currently for database and views. |
|
| 50 | + */ |
|
| 51 | + define('CACHE_PATH', ROOT_PATH . 'cache' . DS); |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * The path to the application directory. |
|
| 55 | - * |
|
| 56 | - * It contains your most often used files that is to say which contains your files of the application, |
|
| 57 | - * in MVC architecture (controllers, models, views). |
|
| 58 | - */ |
|
| 59 | - define('APPS_PATH', ROOT_PATH . 'classes' . DS); |
|
| 53 | + /** |
|
| 54 | + * The path to the application directory. |
|
| 55 | + * |
|
| 56 | + * It contains your most often used files that is to say which contains your files of the application, |
|
| 57 | + * in MVC architecture (controllers, models, views). |
|
| 58 | + */ |
|
| 59 | + define('APPS_PATH', ROOT_PATH . 'classes' . DS); |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * The path to the controller directory of your application. |
|
| 63 | - * |
|
| 64 | - * If you already know the MVC architecture you know what a controller means; |
|
| 65 | - * it is he who makes the business logic of your application in general. |
|
| 66 | - */ |
|
| 67 | - define('APPS_CONTROLLER_PATH', APPS_PATH . 'controllers' . DS); |
|
| 61 | + /** |
|
| 62 | + * The path to the controller directory of your application. |
|
| 63 | + * |
|
| 64 | + * If you already know the MVC architecture you know what a controller means; |
|
| 65 | + * it is he who makes the business logic of your application in general. |
|
| 66 | + */ |
|
| 67 | + define('APPS_CONTROLLER_PATH', APPS_PATH . 'controllers' . DS); |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * The path to the directory of your model classes of your application. |
|
| 71 | - * |
|
| 72 | - * If you already know the MVC architecture you know what a model means; |
|
| 73 | - * it's the one who interacts with the database, in one word persistent data from your application. |
|
| 74 | - */ |
|
| 75 | - define('APPS_MODEL_PATH', APPS_PATH . 'models' . DS); |
|
| 69 | + /** |
|
| 70 | + * The path to the directory of your model classes of your application. |
|
| 71 | + * |
|
| 72 | + * If you already know the MVC architecture you know what a model means; |
|
| 73 | + * it's the one who interacts with the database, in one word persistent data from your application. |
|
| 74 | + */ |
|
| 75 | + define('APPS_MODEL_PATH', APPS_PATH . 'models' . DS); |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * The path to the directory of your views. |
|
| 79 | - * |
|
| 80 | - * If you already know the MVC architecture you know what a view means, |
|
| 81 | - * a view is just a user interface (html page, form, etc.) that is to say |
|
| 82 | - * everything displayed in the browser interface, etc. |
|
| 83 | - */ |
|
| 84 | - define('APPS_VIEWS_PATH', APPS_PATH . 'views' . DS); |
|
| 77 | + /** |
|
| 78 | + * The path to the directory of your views. |
|
| 79 | + * |
|
| 80 | + * If you already know the MVC architecture you know what a view means, |
|
| 81 | + * a view is just a user interface (html page, form, etc.) that is to say |
|
| 82 | + * everything displayed in the browser interface, etc. |
|
| 83 | + */ |
|
| 84 | + define('APPS_VIEWS_PATH', APPS_PATH . 'views' . DS); |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * The path to the configuration directory. |
|
| 88 | - * |
|
| 89 | - * That contains most of the configuration files for your |
|
| 90 | - * application (database, class loading file, functions, etc.) |
|
| 91 | - */ |
|
| 92 | - define('CONFIG_PATH', ROOT_PATH . 'config' . DS); |
|
| 86 | + /** |
|
| 87 | + * The path to the configuration directory. |
|
| 88 | + * |
|
| 89 | + * That contains most of the configuration files for your |
|
| 90 | + * application (database, class loading file, functions, etc.) |
|
| 91 | + */ |
|
| 92 | + define('CONFIG_PATH', ROOT_PATH . 'config' . DS); |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * The core directory |
|
| 96 | - * |
|
| 97 | - * It is recommended to put this folder out of the web directory of your server and |
|
| 98 | - * you should not change its content because in case of update you could lose the modified files. |
|
| 99 | - */ |
|
| 100 | - define('CORE_PATH', ROOT_PATH . 'core' . DS); |
|
| 94 | + /** |
|
| 95 | + * The core directory |
|
| 96 | + * |
|
| 97 | + * It is recommended to put this folder out of the web directory of your server and |
|
| 98 | + * you should not change its content because in case of update you could lose the modified files. |
|
| 99 | + */ |
|
| 100 | + define('CORE_PATH', ROOT_PATH . 'core' . DS); |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * The path to the directory of core classes that used by the system. |
|
| 104 | - * |
|
| 105 | - * It contains PHP classes that are used by the framework internally. |
|
| 106 | - */ |
|
| 107 | - define('CORE_CLASSES_PATH', CORE_PATH . 'classes' . DS); |
|
| 102 | + /** |
|
| 103 | + * The path to the directory of core classes that used by the system. |
|
| 104 | + * |
|
| 105 | + * It contains PHP classes that are used by the framework internally. |
|
| 106 | + */ |
|
| 107 | + define('CORE_CLASSES_PATH', CORE_PATH . 'classes' . DS); |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * The path to the directory of core classes for the cache used by the system. |
|
| 111 | - * |
|
| 112 | - * It contains PHP classes for the cache drivers. |
|
| 113 | - */ |
|
| 114 | - define('CORE_CLASSES_CACHE_PATH', CORE_CLASSES_PATH . 'cache' . DS); |
|
| 109 | + /** |
|
| 110 | + * The path to the directory of core classes for the cache used by the system. |
|
| 111 | + * |
|
| 112 | + * It contains PHP classes for the cache drivers. |
|
| 113 | + */ |
|
| 114 | + define('CORE_CLASSES_CACHE_PATH', CORE_CLASSES_PATH . 'cache' . DS); |
|
| 115 | 115 | |
| 116 | - /** |
|
| 117 | - * The path to the directory of core classes for the model used by the system. |
|
| 118 | - * |
|
| 119 | - * It contains PHP classes for the models. |
|
| 120 | - */ |
|
| 121 | - define('CORE_CLASSES_MODEL_PATH', CORE_CLASSES_PATH . 'model' . DS); |
|
| 116 | + /** |
|
| 117 | + * The path to the directory of core classes for the model used by the system. |
|
| 118 | + * |
|
| 119 | + * It contains PHP classes for the models. |
|
| 120 | + */ |
|
| 121 | + define('CORE_CLASSES_MODEL_PATH', CORE_CLASSES_PATH . 'model' . DS); |
|
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * The path to the directory of functions or helper systems. |
|
| 125 | - * |
|
| 126 | - * It contains PHP functions that perform a particular task: character string processing, URL, etc. |
|
| 127 | - */ |
|
| 128 | - define('CORE_FUNCTIONS_PATH', CORE_PATH . 'functions' . DS); |
|
| 123 | + /** |
|
| 124 | + * The path to the directory of functions or helper systems. |
|
| 125 | + * |
|
| 126 | + * It contains PHP functions that perform a particular task: character string processing, URL, etc. |
|
| 127 | + */ |
|
| 128 | + define('CORE_FUNCTIONS_PATH', CORE_PATH . 'functions' . DS); |
|
| 129 | 129 | |
| 130 | - /** |
|
| 131 | - * The path to the core directory of languages files. |
|
| 132 | - * |
|
| 133 | - */ |
|
| 134 | - define('CORE_LANG_PATH', CORE_PATH . 'lang' . DS); |
|
| 130 | + /** |
|
| 131 | + * The path to the core directory of languages files. |
|
| 132 | + * |
|
| 133 | + */ |
|
| 134 | + define('CORE_LANG_PATH', CORE_PATH . 'lang' . DS); |
|
| 135 | 135 | |
| 136 | - /** |
|
| 137 | - * The path to the system library directory. |
|
| 138 | - * |
|
| 139 | - * Which contains the libraries most often used in your web application, as for the |
|
| 140 | - * core directory it is advisable to put it out of the root directory of your application. |
|
| 141 | - */ |
|
| 142 | - define('CORE_LIBRARY_PATH', CORE_PATH . 'libraries' . DS); |
|
| 136 | + /** |
|
| 137 | + * The path to the system library directory. |
|
| 138 | + * |
|
| 139 | + * Which contains the libraries most often used in your web application, as for the |
|
| 140 | + * core directory it is advisable to put it out of the root directory of your application. |
|
| 141 | + */ |
|
| 142 | + define('CORE_LIBRARY_PATH', CORE_PATH . 'libraries' . DS); |
|
| 143 | 143 | |
| 144 | - /** |
|
| 145 | - * The path to the system view directory. |
|
| 146 | - * |
|
| 147 | - * That contains the views used for the system, such as error messages, and so on. |
|
| 148 | - */ |
|
| 149 | - define('CORE_VIEWS_PATH', CORE_PATH . 'views' . DS); |
|
| 144 | + /** |
|
| 145 | + * The path to the system view directory. |
|
| 146 | + * |
|
| 147 | + * That contains the views used for the system, such as error messages, and so on. |
|
| 148 | + */ |
|
| 149 | + define('CORE_VIEWS_PATH', CORE_PATH . 'views' . DS); |
|
| 150 | 150 | |
| 151 | - /** |
|
| 152 | - * The path to the directory of your PHP personal functions or helper. |
|
| 153 | - * |
|
| 154 | - * It contains your PHP functions that perform a particular task: utilities, etc. |
|
| 155 | - * Note: Do not put your personal functions or helpers in the system functions directory, |
|
| 156 | - * because if you update the system you may lose them. |
|
| 157 | - */ |
|
| 158 | - define('FUNCTIONS_PATH', ROOT_PATH . 'functions' . DS); |
|
| 151 | + /** |
|
| 152 | + * The path to the directory of your PHP personal functions or helper. |
|
| 153 | + * |
|
| 154 | + * It contains your PHP functions that perform a particular task: utilities, etc. |
|
| 155 | + * Note: Do not put your personal functions or helpers in the system functions directory, |
|
| 156 | + * because if you update the system you may lose them. |
|
| 157 | + */ |
|
| 158 | + define('FUNCTIONS_PATH', ROOT_PATH . 'functions' . DS); |
|
| 159 | 159 | |
| 160 | - /** |
|
| 161 | - * The path to the app directory of personal language. |
|
| 162 | - * |
|
| 163 | - * This feature is not yet available. |
|
| 164 | - * You can help us do this if you are nice or wish to see the developed framework. |
|
| 165 | - */ |
|
| 166 | - define('APP_LANG_PATH', ROOT_PATH . 'lang' . DS); |
|
| 160 | + /** |
|
| 161 | + * The path to the app directory of personal language. |
|
| 162 | + * |
|
| 163 | + * This feature is not yet available. |
|
| 164 | + * You can help us do this if you are nice or wish to see the developed framework. |
|
| 165 | + */ |
|
| 166 | + define('APP_LANG_PATH', ROOT_PATH . 'lang' . DS); |
|
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * The path to the directory of your personal libraries |
|
| 170 | - * |
|
| 171 | - * It contains your PHP classes, package, etc. |
|
| 172 | - * Note: you should not put your personal libraries in the system library directory, |
|
| 173 | - * because it is recalled in case of updating the system you might have surprises. |
|
| 174 | - */ |
|
| 175 | - define('LIBRARY_PATH', ROOT_PATH . 'libraries' . DS); |
|
| 168 | + /** |
|
| 169 | + * The path to the directory of your personal libraries |
|
| 170 | + * |
|
| 171 | + * It contains your PHP classes, package, etc. |
|
| 172 | + * Note: you should not put your personal libraries in the system library directory, |
|
| 173 | + * because it is recalled in case of updating the system you might have surprises. |
|
| 174 | + */ |
|
| 175 | + define('LIBRARY_PATH', ROOT_PATH . 'libraries' . DS); |
|
| 176 | 176 | |
| 177 | - /** |
|
| 178 | - * The path to the directory that contains the log files. |
|
| 179 | - * |
|
| 180 | - * Note: This directory must be available in writing and if possible must have as owner the user who launches your web server, |
|
| 181 | - * under unix or linux most often with the apache web server it is "www-data" or "httpd" even "nobody" for more |
|
| 182 | - * details see the documentation of your web server. |
|
| 183 | - * Example for Unix or linux with apache web server: |
|
| 184 | - * # chmod -R 700 /path/to/your/logs/directory/ |
|
| 185 | - * # chown -R www-data:www-data /path/to/your/logs/directory/ |
|
| 186 | - */ |
|
| 187 | - define('LOGS_PATH', ROOT_PATH . 'logs' . DS); |
|
| 177 | + /** |
|
| 178 | + * The path to the directory that contains the log files. |
|
| 179 | + * |
|
| 180 | + * Note: This directory must be available in writing and if possible must have as owner the user who launches your web server, |
|
| 181 | + * under unix or linux most often with the apache web server it is "www-data" or "httpd" even "nobody" for more |
|
| 182 | + * details see the documentation of your web server. |
|
| 183 | + * Example for Unix or linux with apache web server: |
|
| 184 | + * # chmod -R 700 /path/to/your/logs/directory/ |
|
| 185 | + * # chown -R www-data:www-data /path/to/your/logs/directory/ |
|
| 186 | + */ |
|
| 187 | + define('LOGS_PATH', ROOT_PATH . 'logs' . DS); |
|
| 188 | 188 | |
| 189 | - /** |
|
| 190 | - * The path to the modules directory. |
|
| 191 | - * |
|
| 192 | - * It contains your modules used files (config, controllers, libraries, etc.) that is to say which contains your files of the modules, |
|
| 193 | - * in HMVC architecture (hierichical, controllers, models, views). |
|
| 194 | - */ |
|
| 195 | - define('MODULE_PATH', ROOT_PATH . 'modules' . DS); |
|
| 189 | + /** |
|
| 190 | + * The path to the modules directory. |
|
| 191 | + * |
|
| 192 | + * It contains your modules used files (config, controllers, libraries, etc.) that is to say which contains your files of the modules, |
|
| 193 | + * in HMVC architecture (hierichical, controllers, models, views). |
|
| 194 | + */ |
|
| 195 | + define('MODULE_PATH', ROOT_PATH . 'modules' . DS); |
|
| 196 | 196 | |
| 197 | - /** |
|
| 198 | - * The path to the directory of sources external to your application. |
|
| 199 | - * |
|
| 200 | - * If you have already used "composer" you know what that means. |
|
| 201 | - */ |
|
| 202 | - define('VENDOR_PATH', ROOT_PATH . 'vendor' . DS); |
|
| 197 | + /** |
|
| 198 | + * The path to the directory of sources external to your application. |
|
| 199 | + * |
|
| 200 | + * If you have already used "composer" you know what that means. |
|
| 201 | + */ |
|
| 202 | + define('VENDOR_PATH', ROOT_PATH . 'vendor' . DS); |
|
| 203 | 203 | |
| 204 | - /** |
|
| 205 | - * The front controller of your application. |
|
| 206 | - * |
|
| 207 | - * "index.php" it is through this file that all the requests come, there is a possibility to hidden it in the url of |
|
| 208 | - * your application by using the rewrite module URL of your web server . |
|
| 209 | - * For example, under apache web server, there is a configuration example file that is located at the root |
|
| 210 | - * of your framework folder : "htaccess.txt" rename it to ".htaccess". |
|
| 211 | - */ |
|
| 212 | - define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME)); |
|
| 204 | + /** |
|
| 205 | + * The front controller of your application. |
|
| 206 | + * |
|
| 207 | + * "index.php" it is through this file that all the requests come, there is a possibility to hidden it in the url of |
|
| 208 | + * your application by using the rewrite module URL of your web server . |
|
| 209 | + * For example, under apache web server, there is a configuration example file that is located at the root |
|
| 210 | + * of your framework folder : "htaccess.txt" rename it to ".htaccess". |
|
| 211 | + */ |
|
| 212 | + define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME)); |
|
| 213 | 213 | |
| 214 | - /** |
|
| 215 | - * Check if user run the application under CLI |
|
| 216 | - */ |
|
| 217 | - define('IS_CLI', stripos('cli', php_sapi_name()) !== false); |
|
| 214 | + /** |
|
| 215 | + * Check if user run the application under CLI |
|
| 216 | + */ |
|
| 217 | + define('IS_CLI', stripos('cli', php_sapi_name()) !== false); |
|
| 218 | 218 | |
| 219 | - /** |
|
| 220 | - * The environment of your application (production, test, development). |
|
| 221 | - * |
|
| 222 | - * if your application is still in development you use the value "development" |
|
| 223 | - * so you will have the display of the error messages, etc. |
|
| 224 | - * Once you finish the development of your application that is to put it online |
|
| 225 | - * you change this value to "production" or "testing", in this case there will be deactivation of error messages, |
|
| 226 | - * the loading of the system, will be fast. |
|
| 227 | - */ |
|
| 228 | - define('ENVIRONMENT', 'development'); |
|
| 219 | + /** |
|
| 220 | + * The environment of your application (production, test, development). |
|
| 221 | + * |
|
| 222 | + * if your application is still in development you use the value "development" |
|
| 223 | + * so you will have the display of the error messages, etc. |
|
| 224 | + * Once you finish the development of your application that is to put it online |
|
| 225 | + * you change this value to "production" or "testing", in this case there will be deactivation of error messages, |
|
| 226 | + * the loading of the system, will be fast. |
|
| 227 | + */ |
|
| 228 | + define('ENVIRONMENT', 'development'); |
|
| 229 | 229 | |
| 230 | - /* ---------------------------------------------------------------------------------- */ |
|
| 231 | - /////////////////////////////////////////////////////////////////////////////////////// |
|
| 232 | - /******************** DO NOT CHANGE THE LINES BELOW *********************************/ |
|
| 233 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
| 230 | + /* ---------------------------------------------------------------------------------- */ |
|
| 231 | + /////////////////////////////////////////////////////////////////////////////////////// |
|
| 232 | + /******************** DO NOT CHANGE THE LINES BELOW *********************************/ |
|
| 233 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
| 234 | 234 | |
| 235 | - switch (ENVIRONMENT) { |
|
| 236 | - case 'development': |
|
| 237 | - error_reporting(-1); |
|
| 238 | - ini_set('display_errors', 1); |
|
| 239 | - break; |
|
| 240 | - case 'testing': |
|
| 241 | - case 'production': |
|
| 242 | - ini_set('display_errors', 0); |
|
| 243 | - if (version_compare(PHP_VERSION, '5.3', '>=')) { |
|
| 244 | - error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED); |
|
| 245 | - } |
|
| 246 | - else{ |
|
| 247 | - error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE); |
|
| 248 | - } |
|
| 249 | - break; |
|
| 250 | - default: |
|
| 251 | - header('HTTP/1.1 503 Service Unavailable.', TRUE, 503); |
|
| 252 | - echo 'The application environment is not set correctly.'; |
|
| 253 | - exit(1); |
|
| 254 | - } |
|
| 235 | + switch (ENVIRONMENT) { |
|
| 236 | + case 'development': |
|
| 237 | + error_reporting(-1); |
|
| 238 | + ini_set('display_errors', 1); |
|
| 239 | + break; |
|
| 240 | + case 'testing': |
|
| 241 | + case 'production': |
|
| 242 | + ini_set('display_errors', 0); |
|
| 243 | + if (version_compare(PHP_VERSION, '5.3', '>=')) { |
|
| 244 | + error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED); |
|
| 245 | + } |
|
| 246 | + else{ |
|
| 247 | + error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE); |
|
| 248 | + } |
|
| 249 | + break; |
|
| 250 | + default: |
|
| 251 | + header('HTTP/1.1 503 Service Unavailable.', TRUE, 503); |
|
| 252 | + echo 'The application environment is not set correctly.'; |
|
| 253 | + exit(1); |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - /** |
|
| 257 | - * let's go. |
|
| 258 | - * Everything is OK now we launch our application. |
|
| 259 | - */ |
|
| 260 | - require_once CORE_PATH . 'bootstrap.php'; |
|
| 261 | 256 | \ No newline at end of file |
| 257 | + /** |
|
| 258 | + * let's go. |
|
| 259 | + * Everything is OK now we launch our application. |
|
| 260 | + */ |
|
| 261 | + require_once CORE_PATH . 'bootstrap.php'; |
|
| 262 | 262 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | - /** |
|
| 2 | + defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | + /** |
|
| 4 | 4 | * TNH Framework |
| 5 | 5 | * |
| 6 | 6 | * A simple PHP framework using HMVC architecture |
@@ -22,321 +22,321 @@ discard block |
||
| 22 | 22 | * You should have received a copy of the GNU General Public License |
| 23 | 23 | * along with this program; if not, write to the Free Software |
| 24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 25 | - */ |
|
| 25 | + */ |
|
| 26 | 26 | |
| 27 | - class Module{ |
|
| 27 | + class Module{ |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * list of loaded module |
|
| 31 | - * @var array |
|
| 32 | - */ |
|
| 33 | - private static $list = array(); |
|
| 29 | + /** |
|
| 30 | + * list of loaded module |
|
| 31 | + * @var array |
|
| 32 | + */ |
|
| 33 | + private static $list = array(); |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * logger instance |
|
| 37 | - * @var Log |
|
| 38 | - */ |
|
| 39 | - private static $logger; |
|
| 35 | + /** |
|
| 36 | + * logger instance |
|
| 37 | + * @var Log |
|
| 38 | + */ |
|
| 39 | + private static $logger; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * The signleton of the logger |
|
| 43 | - * @return Object the Log instance |
|
| 44 | - */ |
|
| 45 | - private static function getLogger(){ |
|
| 46 | - if(self::$logger == null){ |
|
| 47 | - self::$logger[0] =& class_loader('Log', 'classes'); |
|
| 48 | - self::$logger[0]->setLogger('Library::Module'); |
|
| 49 | - } |
|
| 50 | - return self::$logger[0]; |
|
| 51 | - } |
|
| 41 | + /** |
|
| 42 | + * The signleton of the logger |
|
| 43 | + * @return Object the Log instance |
|
| 44 | + */ |
|
| 45 | + private static function getLogger(){ |
|
| 46 | + if(self::$logger == null){ |
|
| 47 | + self::$logger[0] =& class_loader('Log', 'classes'); |
|
| 48 | + self::$logger[0]->setLogger('Library::Module'); |
|
| 49 | + } |
|
| 50 | + return self::$logger[0]; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Initialise the module list by scanning the directory MODULE_PATH |
|
| 55 | - */ |
|
| 56 | - public function init(){ |
|
| 57 | - $logger = self::getLogger(); |
|
| 58 | - $logger->debug('Check if the application contains the modules ...'); |
|
| 59 | - $moduleDir = opendir(MODULE_PATH); |
|
| 60 | - if(is_resource($moduleDir)){ |
|
| 61 | - while(($module = readdir($moduleDir)) !== false){ |
|
| 62 | - if(preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)){ |
|
| 63 | - self::$list[] = $module; |
|
| 64 | - } |
|
| 65 | - else{ |
|
| 66 | - $logger->info('Skipping [' .$module. '], may be this is not a directory or does not exists or is invalid name'); |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - closedir($moduleDir); |
|
| 70 | - } |
|
| 71 | - ksort(self::$list); |
|
| 53 | + /** |
|
| 54 | + * Initialise the module list by scanning the directory MODULE_PATH |
|
| 55 | + */ |
|
| 56 | + public function init(){ |
|
| 57 | + $logger = self::getLogger(); |
|
| 58 | + $logger->debug('Check if the application contains the modules ...'); |
|
| 59 | + $moduleDir = opendir(MODULE_PATH); |
|
| 60 | + if(is_resource($moduleDir)){ |
|
| 61 | + while(($module = readdir($moduleDir)) !== false){ |
|
| 62 | + if(preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)){ |
|
| 63 | + self::$list[] = $module; |
|
| 64 | + } |
|
| 65 | + else{ |
|
| 66 | + $logger->info('Skipping [' .$module. '], may be this is not a directory or does not exists or is invalid name'); |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + closedir($moduleDir); |
|
| 70 | + } |
|
| 71 | + ksort(self::$list); |
|
| 72 | 72 | |
| 73 | - if(self::hasModule()){ |
|
| 74 | - $logger->info('The application contains the module below [' . implode(', ', self::getModuleList()) . ']'); |
|
| 75 | - } |
|
| 76 | - } |
|
| 73 | + if(self::hasModule()){ |
|
| 74 | + $logger->info('The application contains the module below [' . implode(', ', self::getModuleList()) . ']'); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Get the list of the custom autoload configuration from module if exists |
|
| 80 | - * @return array|boolean the autoload configurations list or false if no module contains the autoload configuration values |
|
| 81 | - */ |
|
| 82 | - public static function getModulesAutoloadConfig(){ |
|
| 83 | - $logger = self::getLogger(); |
|
| 84 | - if(! self::hasModule()){ |
|
| 85 | - $logger->info('No module was loaded skipping.'); |
|
| 86 | - return false; |
|
| 87 | - } |
|
| 88 | - $autoloads = array(); |
|
| 89 | - $autoloads['libraries'] = array(); |
|
| 90 | - $autoloads['config'] = array(); |
|
| 91 | - $autoloads['models'] = array(); |
|
| 92 | - $autoloads['functions'] = array(); |
|
| 93 | - $autoloads['languages'] = array(); |
|
| 78 | + /** |
|
| 79 | + * Get the list of the custom autoload configuration from module if exists |
|
| 80 | + * @return array|boolean the autoload configurations list or false if no module contains the autoload configuration values |
|
| 81 | + */ |
|
| 82 | + public static function getModulesAutoloadConfig(){ |
|
| 83 | + $logger = self::getLogger(); |
|
| 84 | + if(! self::hasModule()){ |
|
| 85 | + $logger->info('No module was loaded skipping.'); |
|
| 86 | + return false; |
|
| 87 | + } |
|
| 88 | + $autoloads = array(); |
|
| 89 | + $autoloads['libraries'] = array(); |
|
| 90 | + $autoloads['config'] = array(); |
|
| 91 | + $autoloads['models'] = array(); |
|
| 92 | + $autoloads['functions'] = array(); |
|
| 93 | + $autoloads['languages'] = array(); |
|
| 94 | 94 | |
| 95 | - foreach (self::$list as $module) { |
|
| 96 | - $file = MODULE_PATH . $module . DS . 'config' . DS . 'autoload.php'; |
|
| 97 | - if(file_exists($file)){ |
|
| 98 | - $autoload = array(); |
|
| 99 | - require_once $file; |
|
| 100 | - if(! empty($autoload) && is_array($autoload)){ |
|
| 101 | - $autoloads = array_merge_recursive($autoloads, $autoload); |
|
| 102 | - unset($autoload); |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - return $autoloads; |
|
| 107 | - } |
|
| 95 | + foreach (self::$list as $module) { |
|
| 96 | + $file = MODULE_PATH . $module . DS . 'config' . DS . 'autoload.php'; |
|
| 97 | + if(file_exists($file)){ |
|
| 98 | + $autoload = array(); |
|
| 99 | + require_once $file; |
|
| 100 | + if(! empty($autoload) && is_array($autoload)){ |
|
| 101 | + $autoloads = array_merge_recursive($autoloads, $autoload); |
|
| 102 | + unset($autoload); |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + return $autoloads; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Get the list of the custom routes configuration from module if exists |
|
| 111 | - * @return array|boolean the routes list or false if no module contains the routes configuration |
|
| 112 | - */ |
|
| 113 | - public static function getModulesRoutes(){ |
|
| 114 | - $logger = self::getLogger(); |
|
| 115 | - if(! self::hasModule()){ |
|
| 116 | - $logger->info('No module was loaded skipping.'); |
|
| 117 | - return false; |
|
| 118 | - } |
|
| 119 | - $routes = array(); |
|
| 120 | - foreach (self::$list as $module) { |
|
| 121 | - $file = MODULE_PATH . $module . DS . 'config' . DS . 'routes.php'; |
|
| 122 | - if(file_exists($file)){ |
|
| 123 | - $route = array(); |
|
| 124 | - require_once $file; |
|
| 125 | - if(! empty($route) && is_array($route)){ |
|
| 126 | - $routes = array_merge($routes, $route); |
|
| 127 | - unset($route); |
|
| 128 | - } |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - return $routes; |
|
| 132 | - } |
|
| 109 | + /** |
|
| 110 | + * Get the list of the custom routes configuration from module if exists |
|
| 111 | + * @return array|boolean the routes list or false if no module contains the routes configuration |
|
| 112 | + */ |
|
| 113 | + public static function getModulesRoutes(){ |
|
| 114 | + $logger = self::getLogger(); |
|
| 115 | + if(! self::hasModule()){ |
|
| 116 | + $logger->info('No module was loaded skipping.'); |
|
| 117 | + return false; |
|
| 118 | + } |
|
| 119 | + $routes = array(); |
|
| 120 | + foreach (self::$list as $module) { |
|
| 121 | + $file = MODULE_PATH . $module . DS . 'config' . DS . 'routes.php'; |
|
| 122 | + if(file_exists($file)){ |
|
| 123 | + $route = array(); |
|
| 124 | + require_once $file; |
|
| 125 | + if(! empty($route) && is_array($route)){ |
|
| 126 | + $routes = array_merge($routes, $route); |
|
| 127 | + unset($route); |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + return $routes; |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | 134 | |
| 135 | - /** |
|
| 136 | - * Check if in module list can have this controller |
|
| 137 | - * @param string $class the controller class |
|
| 138 | - * @param string $module the module name |
|
| 139 | - * @return boolean|string false or null if no module have this controller, path the full path of the controller |
|
| 140 | - */ |
|
| 141 | - public static function findControllerFullPath($class, $module = null){ |
|
| 142 | - $logger = self::getLogger(); |
|
| 143 | - if(! self::hasModule()){ |
|
| 144 | - $logger->info('No module was loaded skiping.'); |
|
| 145 | - return false; |
|
| 146 | - } |
|
| 147 | - $class = str_ireplace('.php', '', $class); |
|
| 148 | - $class = ucfirst($class); |
|
| 149 | - $classFile = $class.'.php'; |
|
| 150 | - $logger->debug('Checking the controller [' . $class . '] in module [' .$module. '] ...'); |
|
| 151 | - $filePath = MODULE_PATH . $module . DS . 'controllers' . DS . $classFile; |
|
| 152 | - if(file_exists($filePath)){ |
|
| 153 | - $logger->info('Found controller [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 154 | - return $filePath; |
|
| 155 | - } |
|
| 156 | - else{ |
|
| 157 | - $logger->info('Controller [' . $class . '] does not exist in the module [' .$module. ']'); |
|
| 158 | - return false; |
|
| 159 | - } |
|
| 160 | - } |
|
| 135 | + /** |
|
| 136 | + * Check if in module list can have this controller |
|
| 137 | + * @param string $class the controller class |
|
| 138 | + * @param string $module the module name |
|
| 139 | + * @return boolean|string false or null if no module have this controller, path the full path of the controller |
|
| 140 | + */ |
|
| 141 | + public static function findControllerFullPath($class, $module = null){ |
|
| 142 | + $logger = self::getLogger(); |
|
| 143 | + if(! self::hasModule()){ |
|
| 144 | + $logger->info('No module was loaded skiping.'); |
|
| 145 | + return false; |
|
| 146 | + } |
|
| 147 | + $class = str_ireplace('.php', '', $class); |
|
| 148 | + $class = ucfirst($class); |
|
| 149 | + $classFile = $class.'.php'; |
|
| 150 | + $logger->debug('Checking the controller [' . $class . '] in module [' .$module. '] ...'); |
|
| 151 | + $filePath = MODULE_PATH . $module . DS . 'controllers' . DS . $classFile; |
|
| 152 | + if(file_exists($filePath)){ |
|
| 153 | + $logger->info('Found controller [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 154 | + return $filePath; |
|
| 155 | + } |
|
| 156 | + else{ |
|
| 157 | + $logger->info('Controller [' . $class . '] does not exist in the module [' .$module. ']'); |
|
| 158 | + return false; |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - /** |
|
| 163 | - * Check if in module list can have this model |
|
| 164 | - * @param string $class the model class |
|
| 165 | - * @param string $module the module name |
|
| 166 | - * @return boolean|string false or null if no module have this model, return the full path of this model |
|
| 167 | - */ |
|
| 168 | - public static function findModelFullPath($class, $module = null){ |
|
| 169 | - $logger = self::getLogger(); |
|
| 170 | - if(! self::hasModule()){ |
|
| 171 | - $logger->info('No module was loaded skiping.'); |
|
| 172 | - return false; |
|
| 173 | - } |
|
| 174 | - $class = str_ireplace('.php', '', $class); |
|
| 175 | - $class = ucfirst($class); |
|
| 176 | - $classFile = $class.'.php'; |
|
| 177 | - $logger->debug('Checking model [' . $class . '] in module [' .$module. '] ...'); |
|
| 178 | - $filePath = MODULE_PATH . $module . DS . 'models' . DS . $classFile; |
|
| 179 | - if(file_exists($filePath)){ |
|
| 180 | - $logger->info('Found model [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 181 | - return $filePath; |
|
| 182 | - } |
|
| 183 | - else{ |
|
| 184 | - $logger->info('Model [' . $class . '] does not exist in the module [' .$module. ']'); |
|
| 185 | - return false; |
|
| 186 | - } |
|
| 187 | - } |
|
| 162 | + /** |
|
| 163 | + * Check if in module list can have this model |
|
| 164 | + * @param string $class the model class |
|
| 165 | + * @param string $module the module name |
|
| 166 | + * @return boolean|string false or null if no module have this model, return the full path of this model |
|
| 167 | + */ |
|
| 168 | + public static function findModelFullPath($class, $module = null){ |
|
| 169 | + $logger = self::getLogger(); |
|
| 170 | + if(! self::hasModule()){ |
|
| 171 | + $logger->info('No module was loaded skiping.'); |
|
| 172 | + return false; |
|
| 173 | + } |
|
| 174 | + $class = str_ireplace('.php', '', $class); |
|
| 175 | + $class = ucfirst($class); |
|
| 176 | + $classFile = $class.'.php'; |
|
| 177 | + $logger->debug('Checking model [' . $class . '] in module [' .$module. '] ...'); |
|
| 178 | + $filePath = MODULE_PATH . $module . DS . 'models' . DS . $classFile; |
|
| 179 | + if(file_exists($filePath)){ |
|
| 180 | + $logger->info('Found model [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 181 | + return $filePath; |
|
| 182 | + } |
|
| 183 | + else{ |
|
| 184 | + $logger->info('Model [' . $class . '] does not exist in the module [' .$module. ']'); |
|
| 185 | + return false; |
|
| 186 | + } |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - /** |
|
| 190 | - * Check if in module list can have this config |
|
| 191 | - * @param string $configuration the config name |
|
| 192 | - * @param string $module the module name |
|
| 193 | - * @return boolean|string false or null if no module have this configuration, return the full path of this configuration |
|
| 194 | - */ |
|
| 195 | - public static function findConfigFullPath($configuration, $module = null){ |
|
| 196 | - $logger = self::getLogger(); |
|
| 197 | - if(! self::hasModule()){ |
|
| 198 | - $logger->info('No module was loaded skiping.'); |
|
| 199 | - return false; |
|
| 200 | - } |
|
| 201 | - $configuration = str_ireplace('.php', '', $configuration); |
|
| 202 | - $file = $configuration.'.php'; |
|
| 203 | - $logger->debug('Checking configuration [' . $configuration . '] in module [' .$module. '] ...'); |
|
| 204 | - $filePath = MODULE_PATH . $module . DS . 'config' . DS . $file; |
|
| 205 | - if(file_exists($filePath)){ |
|
| 206 | - $logger->info('Found configuration [' . $configuration . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 207 | - return $filePath; |
|
| 208 | - } |
|
| 209 | - else{ |
|
| 210 | - $logger->info('Configuration [' . $configuration . '] does not exist in the module [' .$module. ']'); |
|
| 211 | - return false; |
|
| 212 | - } |
|
| 213 | - } |
|
| 189 | + /** |
|
| 190 | + * Check if in module list can have this config |
|
| 191 | + * @param string $configuration the config name |
|
| 192 | + * @param string $module the module name |
|
| 193 | + * @return boolean|string false or null if no module have this configuration, return the full path of this configuration |
|
| 194 | + */ |
|
| 195 | + public static function findConfigFullPath($configuration, $module = null){ |
|
| 196 | + $logger = self::getLogger(); |
|
| 197 | + if(! self::hasModule()){ |
|
| 198 | + $logger->info('No module was loaded skiping.'); |
|
| 199 | + return false; |
|
| 200 | + } |
|
| 201 | + $configuration = str_ireplace('.php', '', $configuration); |
|
| 202 | + $file = $configuration.'.php'; |
|
| 203 | + $logger->debug('Checking configuration [' . $configuration . '] in module [' .$module. '] ...'); |
|
| 204 | + $filePath = MODULE_PATH . $module . DS . 'config' . DS . $file; |
|
| 205 | + if(file_exists($filePath)){ |
|
| 206 | + $logger->info('Found configuration [' . $configuration . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 207 | + return $filePath; |
|
| 208 | + } |
|
| 209 | + else{ |
|
| 210 | + $logger->info('Configuration [' . $configuration . '] does not exist in the module [' .$module. ']'); |
|
| 211 | + return false; |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - /** |
|
| 216 | - * Check if in module list can have this helper |
|
| 217 | - * @param string $helper the helper name |
|
| 218 | - * @param string $module the module name |
|
| 219 | - * @return boolean|string false or null if no module have this helper, return the full path of this helper |
|
| 220 | - */ |
|
| 221 | - public static function findFunctionFullPath($helper, $module = null){ |
|
| 222 | - $logger = self::getLogger(); |
|
| 223 | - if(! self::hasModule()){ |
|
| 224 | - $logger->info('No module was loaded skiping.'); |
|
| 225 | - return false; |
|
| 226 | - } |
|
| 227 | - $helper = str_ireplace('.php', '', $helper); |
|
| 228 | - $helper = str_ireplace('function_', '', $helper); |
|
| 229 | - $file = 'function_'.$helper.'.php'; |
|
| 230 | - $logger->debug('Checking helper [' . $helper . '] in module [' .$module. '] ...'); |
|
| 231 | - $filePath = MODULE_PATH . $module . DS . 'functions' . DS . $file; |
|
| 232 | - if(file_exists($filePath)){ |
|
| 233 | - $logger->info('Found helper [' . $helper . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 234 | - return $filePath; |
|
| 235 | - } |
|
| 236 | - else{ |
|
| 237 | - $logger->info('Helper [' . $helper . '] does not exist in the module [' .$module. ']'); |
|
| 238 | - return false; |
|
| 239 | - } |
|
| 240 | - } |
|
| 215 | + /** |
|
| 216 | + * Check if in module list can have this helper |
|
| 217 | + * @param string $helper the helper name |
|
| 218 | + * @param string $module the module name |
|
| 219 | + * @return boolean|string false or null if no module have this helper, return the full path of this helper |
|
| 220 | + */ |
|
| 221 | + public static function findFunctionFullPath($helper, $module = null){ |
|
| 222 | + $logger = self::getLogger(); |
|
| 223 | + if(! self::hasModule()){ |
|
| 224 | + $logger->info('No module was loaded skiping.'); |
|
| 225 | + return false; |
|
| 226 | + } |
|
| 227 | + $helper = str_ireplace('.php', '', $helper); |
|
| 228 | + $helper = str_ireplace('function_', '', $helper); |
|
| 229 | + $file = 'function_'.$helper.'.php'; |
|
| 230 | + $logger->debug('Checking helper [' . $helper . '] in module [' .$module. '] ...'); |
|
| 231 | + $filePath = MODULE_PATH . $module . DS . 'functions' . DS . $file; |
|
| 232 | + if(file_exists($filePath)){ |
|
| 233 | + $logger->info('Found helper [' . $helper . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 234 | + return $filePath; |
|
| 235 | + } |
|
| 236 | + else{ |
|
| 237 | + $logger->info('Helper [' . $helper . '] does not exist in the module [' .$module. ']'); |
|
| 238 | + return false; |
|
| 239 | + } |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | 242 | |
| 243 | - /** |
|
| 244 | - * Check if in module list can have this library |
|
| 245 | - * @param string $class the library name |
|
| 246 | - * @param string $module the module name |
|
| 247 | - * @return boolean|string false or null if no module have this library, return the full path of this library |
|
| 248 | - */ |
|
| 249 | - public static function findLibraryFullPath($class, $module = null){ |
|
| 250 | - $logger = self::getLogger(); |
|
| 251 | - if(! self::hasModule()){ |
|
| 252 | - $logger->info('No module was loaded skiping.'); |
|
| 253 | - return false; |
|
| 254 | - } |
|
| 255 | - $class = str_ireplace('.php', '', $class); |
|
| 256 | - $file = $class.'.php'; |
|
| 257 | - $logger->debug('Checking library [' . $class . '] in module [' .$module. '] ...'); |
|
| 258 | - $filePath = MODULE_PATH . $module . DS . 'libraries' . DS . $file; |
|
| 259 | - if(file_exists($filePath)){ |
|
| 260 | - $logger->info('Found library [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 261 | - return $filePath; |
|
| 262 | - } |
|
| 263 | - else{ |
|
| 264 | - $logger->info('Library [' . $class . '] does not exist in the module [' .$module. ']'); |
|
| 265 | - return false; |
|
| 266 | - } |
|
| 267 | - } |
|
| 243 | + /** |
|
| 244 | + * Check if in module list can have this library |
|
| 245 | + * @param string $class the library name |
|
| 246 | + * @param string $module the module name |
|
| 247 | + * @return boolean|string false or null if no module have this library, return the full path of this library |
|
| 248 | + */ |
|
| 249 | + public static function findLibraryFullPath($class, $module = null){ |
|
| 250 | + $logger = self::getLogger(); |
|
| 251 | + if(! self::hasModule()){ |
|
| 252 | + $logger->info('No module was loaded skiping.'); |
|
| 253 | + return false; |
|
| 254 | + } |
|
| 255 | + $class = str_ireplace('.php', '', $class); |
|
| 256 | + $file = $class.'.php'; |
|
| 257 | + $logger->debug('Checking library [' . $class . '] in module [' .$module. '] ...'); |
|
| 258 | + $filePath = MODULE_PATH . $module . DS . 'libraries' . DS . $file; |
|
| 259 | + if(file_exists($filePath)){ |
|
| 260 | + $logger->info('Found library [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 261 | + return $filePath; |
|
| 262 | + } |
|
| 263 | + else{ |
|
| 264 | + $logger->info('Library [' . $class . '] does not exist in the module [' .$module. ']'); |
|
| 265 | + return false; |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | 268 | |
| 269 | 269 | |
| 270 | - /** |
|
| 271 | - * Check if in module list can have this view |
|
| 272 | - * @param string $view the view path |
|
| 273 | - * @param string $module the module name to check |
|
| 274 | - * @return boolean|string false or null if no module have this view, path the full path of the view |
|
| 275 | - */ |
|
| 276 | - public static function findViewFullPath($view, $module = null){ |
|
| 277 | - $logger = self::getLogger(); |
|
| 278 | - if(! self::hasModule()){ |
|
| 279 | - $logger->info('No module was loaded skiping.'); |
|
| 280 | - return false; |
|
| 281 | - } |
|
| 282 | - $view = str_ireplace('.php', '', $view); |
|
| 283 | - $view = trim($view, '/\\'); |
|
| 284 | - $view = str_ireplace('/', DS, $view); |
|
| 285 | - $viewFile = $view . '.php'; |
|
| 286 | - $logger->debug('Checking view [' . $view . '] in module [' .$module. '] ...'); |
|
| 287 | - $filePath = MODULE_PATH . $module . DS . 'views' . DS . $viewFile; |
|
| 288 | - if(file_exists($filePath)){ |
|
| 289 | - $logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 290 | - return $filePath; |
|
| 291 | - } |
|
| 292 | - else{ |
|
| 293 | - $logger->info('View [' . $view . '] does not exist in the module [' .$module. ']'); |
|
| 294 | - return false; |
|
| 295 | - } |
|
| 296 | - } |
|
| 270 | + /** |
|
| 271 | + * Check if in module list can have this view |
|
| 272 | + * @param string $view the view path |
|
| 273 | + * @param string $module the module name to check |
|
| 274 | + * @return boolean|string false or null if no module have this view, path the full path of the view |
|
| 275 | + */ |
|
| 276 | + public static function findViewFullPath($view, $module = null){ |
|
| 277 | + $logger = self::getLogger(); |
|
| 278 | + if(! self::hasModule()){ |
|
| 279 | + $logger->info('No module was loaded skiping.'); |
|
| 280 | + return false; |
|
| 281 | + } |
|
| 282 | + $view = str_ireplace('.php', '', $view); |
|
| 283 | + $view = trim($view, '/\\'); |
|
| 284 | + $view = str_ireplace('/', DS, $view); |
|
| 285 | + $viewFile = $view . '.php'; |
|
| 286 | + $logger->debug('Checking view [' . $view . '] in module [' .$module. '] ...'); |
|
| 287 | + $filePath = MODULE_PATH . $module . DS . 'views' . DS . $viewFile; |
|
| 288 | + if(file_exists($filePath)){ |
|
| 289 | + $logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 290 | + return $filePath; |
|
| 291 | + } |
|
| 292 | + else{ |
|
| 293 | + $logger->info('View [' . $view . '] does not exist in the module [' .$module. ']'); |
|
| 294 | + return false; |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | 297 | |
| 298 | - /** |
|
| 299 | - * Check if in module list can have this language |
|
| 300 | - * @param string $language the language name |
|
| 301 | - * @param string $module the module name |
|
| 302 | - * @param string $appLang the application language like 'en', 'fr' |
|
| 303 | - * @return boolean|string false or null if no module have this language, return the full path of this language |
|
| 304 | - */ |
|
| 305 | - public static function findLanguageFullPath($language, $module = null, $appLang){ |
|
| 306 | - $logger = self::getLogger(); |
|
| 307 | - if(! self::hasModule()){ |
|
| 308 | - $logger->info('No module was loaded skiping.'); |
|
| 309 | - return false; |
|
| 310 | - } |
|
| 311 | - $language = str_ireplace('.php', '', $language); |
|
| 312 | - $language = str_ireplace('lang_', '', $language); |
|
| 313 | - $file = 'lang_'.$language.'.php'; |
|
| 314 | - $logger->debug('Checking language [' . $language . '] in module [' .$module. '] ...'); |
|
| 315 | - $filePath = MODULE_PATH . $module . DS . 'lang' . DS . $appLang . DS . $file; |
|
| 316 | - if(file_exists($filePath)){ |
|
| 317 | - $logger->info('Found language [' . $language . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 318 | - return $filePath; |
|
| 319 | - } |
|
| 320 | - else{ |
|
| 321 | - $logger->info('Language [' . $language . '] does not exist in the module [' .$module. ']'); |
|
| 322 | - return false; |
|
| 323 | - } |
|
| 324 | - } |
|
| 298 | + /** |
|
| 299 | + * Check if in module list can have this language |
|
| 300 | + * @param string $language the language name |
|
| 301 | + * @param string $module the module name |
|
| 302 | + * @param string $appLang the application language like 'en', 'fr' |
|
| 303 | + * @return boolean|string false or null if no module have this language, return the full path of this language |
|
| 304 | + */ |
|
| 305 | + public static function findLanguageFullPath($language, $module = null, $appLang){ |
|
| 306 | + $logger = self::getLogger(); |
|
| 307 | + if(! self::hasModule()){ |
|
| 308 | + $logger->info('No module was loaded skiping.'); |
|
| 309 | + return false; |
|
| 310 | + } |
|
| 311 | + $language = str_ireplace('.php', '', $language); |
|
| 312 | + $language = str_ireplace('lang_', '', $language); |
|
| 313 | + $file = 'lang_'.$language.'.php'; |
|
| 314 | + $logger->debug('Checking language [' . $language . '] in module [' .$module. '] ...'); |
|
| 315 | + $filePath = MODULE_PATH . $module . DS . 'lang' . DS . $appLang . DS . $file; |
|
| 316 | + if(file_exists($filePath)){ |
|
| 317 | + $logger->info('Found language [' . $language . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 318 | + return $filePath; |
|
| 319 | + } |
|
| 320 | + else{ |
|
| 321 | + $logger->info('Language [' . $language . '] does not exist in the module [' .$module. ']'); |
|
| 322 | + return false; |
|
| 323 | + } |
|
| 324 | + } |
|
| 325 | 325 | |
| 326 | - /** |
|
| 327 | - * Get the list of module loaded |
|
| 328 | - * @return array the module list |
|
| 329 | - */ |
|
| 330 | - public static function getModuleList(){ |
|
| 331 | - return self::$list; |
|
| 332 | - } |
|
| 326 | + /** |
|
| 327 | + * Get the list of module loaded |
|
| 328 | + * @return array the module list |
|
| 329 | + */ |
|
| 330 | + public static function getModuleList(){ |
|
| 331 | + return self::$list; |
|
| 332 | + } |
|
| 333 | 333 | |
| 334 | - /** |
|
| 335 | - * Check if the application has an module |
|
| 336 | - * @return boolean |
|
| 337 | - */ |
|
| 338 | - public static function hasModule(){ |
|
| 339 | - return !empty(self::$list); |
|
| 340 | - } |
|
| 334 | + /** |
|
| 335 | + * Check if the application has an module |
|
| 336 | + * @return boolean |
|
| 337 | + */ |
|
| 338 | + public static function hasModule(){ |
|
| 339 | + return !empty(self::$list); |
|
| 340 | + } |
|
| 341 | 341 | |
| 342 | - } |
|
| 342 | + } |
|