diff --git a/.htaccess.sample b/.htaccess.sample new file mode 100644 index 0000000..6973102 --- /dev/null +++ b/.htaccess.sample @@ -0,0 +1,9 @@ + +RewriteEngine On +RewriteBase / +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^(.*)$ /index.php/$1 [L] +AcceptPathInfo On + + diff --git a/libraries/Routes.php b/libraries/Routes.php index 861b707..aa09c69 100644 --- a/libraries/Routes.php +++ b/libraries/Routes.php @@ -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; + +} diff --git a/libraries/Utils.php b/libraries/Utils.php index b73157d..5bfd390 100644 --- a/libraries/Utils.php +++ b/libraries/Utils.php @@ -34,23 +34,7 @@ class Utils { static public function slugify($text, $respect_upper=0, $replace_space='-', $replace_dot=0, $replace_barr=0) { - - /*$from='àáâãäåæçèéêëìíîïðòóôõöøùúûýþÿŕñ'; - $to= 'aaaaaaaceeeeiiiidoooooouuuybyrn'; - - //$text = utf8_decode(urldecode($text)); - - $text = strtr($text, utf8_encode($from), $to); - echo $text; - $text=strtolower(trim($text)); - - $text=str_replace(' ', $replace_space, $text); - - $text=preg_replace('~-+~', $replace_space, $text); - - $text=preg_replace('~[^-\w]+~', '', $text); - - return $text;*/ + /* $from='àáâãäåæçèéêëìíîïðòóôõöøùúûýþÿŕñÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÐÒÓÔÕÖØÙÚÛÝỲŸÞŔÑ¿?!¡()"|#*%,;+&$ºª<>`çÇ{}@~=^:´[]'; $to= 'aaaaaaaceeeeiiiidoooooouuuybyrnAAAAAACEEEEIIIIDOOOOOOUUUYYYBRN---------------------------------'; @@ -84,13 +68,23 @@ class Utils { $text = strtolower($text); - } + }*/ + + $text=iconv('utf-8', 'us-ascii//TRANSLIT', $text); $text=trim(preg_replace('~'.$replace_space.'+~', $replace_space, $text), '-'); $text=preg_replace('~[^-\w]+~', '', $text); - return utf8_encode($text); + if (empty($text)) { + + return 'n-a'; + + }else { + + return iconv('us-ascii//TRANSLIT', 'utf-8', $text); // utf8_encode($text); + + } } diff --git a/modules/welcome/controllers/index.php b/modules/welcome/controllers/app.php similarity index 100% rename from modules/welcome/controllers/index.php rename to modules/welcome/controllers/app.php