Fixes in routes, urls, etc
This commit is contained in:
parent
841b16266a
commit
22b90ea1f6
4 changed files with 58 additions and 22 deletions
|
|
@ -9,6 +9,8 @@ class Config {
|
|||
|
||||
static public $modules_allowed=['welcome'];
|
||||
|
||||
static public $base_url='';
|
||||
|
||||
}
|
||||
|
||||
function get_controller($controller, $args=[]) {
|
||||
|
|
@ -32,6 +34,10 @@ function get_controller($controller, $args=[]) {
|
|||
|
||||
}
|
||||
|
||||
//Route is: /module/switch/
|
||||
//Route is: /module/file/switch/
|
||||
//Route is: /module/file/switch/parameter1/parameter2
|
||||
|
||||
function get_route($path_info) {
|
||||
|
||||
if($path_info!='') {
|
||||
|
|
@ -42,7 +48,7 @@ function get_route($path_info) {
|
|||
|
||||
case 0:
|
||||
|
||||
$controller='modules/'.\PhangoApp\PhaRouter\Config::$home_module.'/controllers/index.php';
|
||||
$controller='modules/'.\PhangoApp\PhaRouter\Config::$home_module.'/controllers/app.php';
|
||||
|
||||
return \PhangoApp\PhaRouter\get_controller($controller, []);
|
||||
|
||||
|
|
@ -50,7 +56,7 @@ function get_route($path_info) {
|
|||
|
||||
case 1:
|
||||
|
||||
$controller='modules/'.$arr_path[1].'/controllers/index.php';
|
||||
$controller='modules/'.$arr_path[1].'/controllers/app.php';
|
||||
|
||||
if(in_array($arr_path[1], Config::$modules_allowed)) {
|
||||
|
||||
|
|
@ -91,7 +97,7 @@ function get_route($path_info) {
|
|||
}
|
||||
else {
|
||||
|
||||
$controller='modules/'.\PhangoApp\PhaRouter\Config::$home_module.'/controllers/index.php';
|
||||
$controller='modules/'.\PhangoApp\PhaRouter\Config::$home_module.'/controllers/app.php';
|
||||
|
||||
return \PhangoApp\PhaRouter\get_controller($controller, []);
|
||||
|
||||
|
|
@ -140,3 +146,30 @@ function filter_path($path_info) {
|
|||
return $final_path;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function make_url($module, $script='', $file='', $args=[]) {
|
||||
|
||||
$url='/'.$module;
|
||||
|
||||
if($script!='') {
|
||||
|
||||
$url.='/'.$script;
|
||||
|
||||
}
|
||||
|
||||
if($file!='') {
|
||||
|
||||
$url.='/'.$file;
|
||||
|
||||
}
|
||||
|
||||
if(count($args)>0) {
|
||||
|
||||
$url.='/'.implode('/', $args);
|
||||
|
||||
}
|
||||
|
||||
return Config::$base_url.'/index.php'.$url;
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue