New rule for routing URLs
This commit is contained in:
parent
53dbb3c25f
commit
2e33afda0c
|
@ -6,7 +6,7 @@ if (Session::started()===false) {
|
|||
exit('Bludit CMS. Session initialization failure.');
|
||||
}
|
||||
|
||||
$login = $Login = new Login();
|
||||
$login = new Login();
|
||||
|
||||
$layout = array(
|
||||
'controller'=>null,
|
||||
|
@ -52,6 +52,7 @@ if ($layout['slug']==='ajax') {
|
|||
else
|
||||
{
|
||||
// Boot rules
|
||||
include(PATH_RULES.'60.router.php');
|
||||
include(PATH_RULES.'69.pages.php');
|
||||
include(PATH_RULES.'99.header.php');
|
||||
include(PATH_RULES.'99.paginator.php');
|
||||
|
@ -62,16 +63,11 @@ else
|
|||
// User not logged.
|
||||
// Slug is login.
|
||||
// Slug is login-email.
|
||||
if($url->notFound() || !$login->isLogged() || ($url->slug()==='login') || ($url->slug()==='login-email') ) {
|
||||
if ($url->notFound() || !$login->isLogged() || ($url->slug()==='login') ) {
|
||||
$layout['controller'] = 'login';
|
||||
$layout['view'] = 'login';
|
||||
$layout['template'] = 'login.php';
|
||||
|
||||
if ($url->slug()==='login-email') {
|
||||
$layout['controller'] = 'login-email';
|
||||
$layout['view'] = 'login-email';
|
||||
}
|
||||
|
||||
// Generate the tokenCSRF for the user not logged, when the user log-in the token will be change.
|
||||
$security->generateTokenCSRF();
|
||||
}
|
||||
|
@ -84,17 +80,17 @@ else
|
|||
Theme::plugins('beforeAdminLoad');
|
||||
|
||||
// Load init.php if the theme has one.
|
||||
if( Sanitize::pathFile(PATH_ADMIN_THEMES, $site->adminTheme().DS.'init.php') ) {
|
||||
if (Sanitize::pathFile(PATH_ADMIN_THEMES, $site->adminTheme().DS.'init.php')) {
|
||||
include(PATH_ADMIN_THEMES.$site->adminTheme().DS.'init.php');
|
||||
}
|
||||
|
||||
// Load controller.
|
||||
if( Sanitize::pathFile(PATH_ADMIN_CONTROLLERS, $layout['controller'].'.php') ) {
|
||||
if (Sanitize::pathFile(PATH_ADMIN_CONTROLLERS, $layout['controller'].'.php')) {
|
||||
include(PATH_ADMIN_CONTROLLERS.$layout['controller'].'.php');
|
||||
}
|
||||
|
||||
// Load view and theme.
|
||||
if( Sanitize::pathFile(PATH_ADMIN_THEMES, $site->adminTheme().DS.$layout['template']) ) {
|
||||
if (Sanitize::pathFile(PATH_ADMIN_THEMES, $site->adminTheme().DS.$layout['template'])) {
|
||||
include(PATH_ADMIN_THEMES.$site->adminTheme().DS.$layout['template']);
|
||||
}
|
||||
|
||||
|
|
|
@ -227,7 +227,7 @@ define('DOMAIN_UPLOADS_THUMBNAILS', DOMAIN.HTML_PATH_UPLOADS_THUMBNAILS);
|
|||
define('DOMAIN_PLUGINS', DOMAIN.HTML_PATH_PLUGINS);
|
||||
define('DOMAIN_CONTENT', DOMAIN.HTML_PATH_CONTENT);
|
||||
|
||||
define('DOMAIN_ADMIN', DOMAIN_BASE.ADMIN_URI_FILTER);
|
||||
define('DOMAIN_ADMIN', DOMAIN_BASE.ADMIN_URI_FILTER.'/');
|
||||
|
||||
define('DOMAIN_TAGS', Text::addSlashes(DOMAIN_BASE.TAG_URI_FILTER, false, true));
|
||||
define('DOMAIN_CATEGORIES', Text::addSlashes(DOMAIN_BASE.CATEGORY_URI_FILTER, false, true));
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
// Redirect admin, from /admin to /admin/
|
||||
if ($url->uri()=='/'.ADMIN_URI_FILTER) {
|
||||
Redirect::url(DOMAIN_ADMIN);
|
||||
}
|
||||
|
||||
// Redirect pages, from /my-page/ to /my-page
|
||||
if ($url->whereAmI()=='page' && !$url->notFound()) {
|
||||
$pageKey = $url->slug();
|
||||
if (Text::endsWith($pageKey, '/')) {
|
||||
$pageKey = rtrim($pageKey, '/');
|
||||
Redirect::url(DOMAIN_PAGES.$pageKey);
|
||||
}
|
||||
}
|
|
@ -58,13 +58,6 @@ if ($site->homepage() && $url->whereAmI()==='home') {
|
|||
|
||||
// Build specific page
|
||||
if ($url->whereAmI()==='page') {
|
||||
// If the page ends with slash redirect to the correct url
|
||||
$pageKey = $url->slug();
|
||||
if (Text::endsWith($pageKey, '/')) {
|
||||
$pageKey = rtrim($pageKey, '/');
|
||||
Redirect::url(DOMAIN_PAGES.$pageKey);
|
||||
}
|
||||
|
||||
$content[0] = $page = buildThePage();
|
||||
}
|
||||
// Build content by tag
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
// // Start session if the cookie is defined
|
||||
// if (Cookie::get('BLUDIT-KEY')) {
|
||||
// if (!Session::started()) {
|
||||
// Session::start();
|
||||
// }
|
||||
// }
|
||||
|
||||
// Load plugins rules
|
||||
include(PATH_RULES.'60.plugins.php');
|
||||
|
||||
|
@ -14,6 +7,7 @@ include(PATH_RULES.'60.plugins.php');
|
|||
Theme::plugins('beforeAll');
|
||||
|
||||
// Load rules
|
||||
include(PATH_RULES.'60.router.php');
|
||||
include(PATH_RULES.'69.pages.php');
|
||||
include(PATH_RULES.'99.header.php');
|
||||
include(PATH_RULES.'99.paginator.php');
|
||||
|
|
|
@ -6,15 +6,15 @@ class Redirect {
|
|||
{
|
||||
if (!headers_sent()) {
|
||||
header("Location:".$url, TRUE, $httpCode);
|
||||
exit;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
exit ('<meta http-equiv="refresh" content="0; url='.$url.'"/>');
|
||||
exit('<meta http-equiv="refresh" content="0; url='.$url.'"/>');
|
||||
}
|
||||
|
||||
public static function page($page)
|
||||
{
|
||||
self::url(HTML_PATH_ROOT.ADMIN_URI_FILTER.'/'.$page);
|
||||
self::url(HTML_PATH_ADMIN_ROOT.$page);
|
||||
}
|
||||
|
||||
public static function home()
|
||||
|
|
|
@ -76,7 +76,7 @@ class Site extends dbJSON {
|
|||
// Also, you can get the a particular filter
|
||||
public function uriFilters($filter='')
|
||||
{
|
||||
$filters['admin'] = '/' . ADMIN_URI_FILTER . '/';
|
||||
$filters['admin'] = '/'.ADMIN_URI_FILTER.'/';
|
||||
$filters['page'] = $this->getField('uriPage');
|
||||
$filters['tag'] = $this->getField('uriTag');
|
||||
$filters['category'] = $this->getField('uriCategory');
|
||||
|
|
Loading…
Reference in New Issue