Improve the router, added /blog/, minor changes on languages
This commit is contained in:
parent
39b62882ad
commit
1389b74493
@ -97,6 +97,14 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
|
||||
'tip'=>DOMAIN_CATEGORIES
|
||||
));
|
||||
|
||||
HTML::formInputText(array(
|
||||
'name'=>'uriBlog',
|
||||
'label'=>$L->g('Blog'),
|
||||
'value'=>$Site->uriFilters('blog'),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'tip'=>DOMAIN_BLOG
|
||||
));
|
||||
|
||||
echo '<div class="uk-form-row">
|
||||
<div class="uk-form-controls">
|
||||
<button type="submit" class="uk-button uk-button-primary">'.$L->g('Save').'</button>
|
||||
|
@ -3,8 +3,8 @@
|
||||
// Bludit version
|
||||
define('BLUDIT_VERSION', '2.0');
|
||||
define('BLUDIT_CODENAME', '');
|
||||
define('BLUDIT_RELEASE_DATE', '2017-10-10');
|
||||
define('BLUDIT_BUILD', '20171010');
|
||||
define('BLUDIT_RELEASE_DATE', '2017-09-11');
|
||||
define('BLUDIT_BUILD', '20170911');
|
||||
|
||||
// Debug mode
|
||||
// Change to FALSE, for prevent warning or errors on browser
|
||||
@ -280,6 +280,9 @@ define('CATEGORY_URI_FILTER', $Url->filters('category'));
|
||||
// Page URI filter
|
||||
define('PAGE_URI_FILTER', $Url->filters('page'));
|
||||
|
||||
// Blog URI filter
|
||||
define('BLOG_URI_FILTER', $Url->filters('blog'));
|
||||
|
||||
// Content order by: date / position
|
||||
define('ORDER_BY', $Site->orderBy());
|
||||
|
||||
@ -309,6 +312,7 @@ define('DOMAIN_UPLOADS_THUMBNAILS', DOMAIN.HTML_PATH_UPLOADS_THUMBNAILS);
|
||||
define('DOMAIN_TAGS', Text::addSlashes(DOMAIN_BASE.TAG_URI_FILTER, false, true));
|
||||
define('DOMAIN_CATEGORIES', Text::addSlashes(DOMAIN_BASE.CATEGORY_URI_FILTER, false, true));
|
||||
define('DOMAIN_PAGES', Text::addSlashes(DOMAIN_BASE.PAGE_URI_FILTER, false, true));
|
||||
define('DOMAIN_BLOG', Text::addSlashes(DOMAIN_BASE.BLOG_URI_FILTER, false, true));
|
||||
|
||||
$ADMIN_CONTROLLER = '';
|
||||
$ADMIN_VIEW = '';
|
||||
|
@ -99,6 +99,10 @@ if ($Site->homepage() && $Url->whereAmI()==='home') {
|
||||
}
|
||||
}
|
||||
|
||||
if ($Url->whereAmI()==='blog') {
|
||||
$Url->setWhereAmI('home');
|
||||
}
|
||||
|
||||
// Build specific page
|
||||
if ($Url->whereAmI()==='page') {
|
||||
buildThePage();
|
||||
|
@ -18,6 +18,7 @@ class dbSite extends dbJSON
|
||||
'uriPage'=> array('inFile'=>false, 'value'=>'/'),
|
||||
'uriTag'=> array('inFile'=>false, 'value'=>'/tag/'),
|
||||
'uriCategory'=> array('inFile'=>false, 'value'=>'/category/'),
|
||||
'uriBlog'=> array('inFile'=>false, 'value'=>'/blog/'),
|
||||
'url'=> array('inFile'=>false, 'value'=>''),
|
||||
'emailFrom'=> array('inFile'=>false, 'value'=>''),
|
||||
'dateFormat'=> array('inFile'=>false, 'value'=>'F j, Y'),
|
||||
@ -67,6 +68,7 @@ class dbSite extends dbJSON
|
||||
$filters['page'] = $this->getField('uriPage');
|
||||
$filters['tag'] = $this->getField('uriTag');
|
||||
$filters['category'] = $this->getField('uriCategory');
|
||||
$filters['blog'] = $this->getField('uriBlog');
|
||||
|
||||
if(empty($filter)) {
|
||||
return $filters;
|
||||
@ -91,7 +93,12 @@ class dbSite extends dbJSON
|
||||
{
|
||||
$filter = $this->getField('uriCategory');
|
||||
return $this->url().ltrim($filter, '/');
|
||||
}
|
||||
|
||||
public function urlBlog()
|
||||
{
|
||||
$filter = $this->getField('uriBlog');
|
||||
return $this->url().ltrim($filter, '/');
|
||||
}
|
||||
|
||||
// Returns the URL of the rss.xml file
|
||||
|
@ -561,6 +561,10 @@ function editSettings($args) {
|
||||
$args['uriCategory'] = Text::addSlashes($args['uriCategory']);
|
||||
}
|
||||
|
||||
if (isset($args['uriBlog'])) {
|
||||
$args['uriBlog'] = Text::addSlashes($args['uriBlog']);
|
||||
}
|
||||
|
||||
if ($Site->set($args)) {
|
||||
// Check current order-by if changed it reorder the content
|
||||
if ($Site->orderBy()!=ORDER_BY) {
|
||||
|
@ -37,47 +37,34 @@ class Url
|
||||
// Ex (English): Array('post'=>'/post/', 'tag'=>'/tag/', ....)
|
||||
public function checkFilters($filters)
|
||||
{
|
||||
// Store the admin filter and remove
|
||||
// Put the "admin" filter first
|
||||
$adminFilter['admin'] = $filters['admin'];
|
||||
unset($filters['admin']);
|
||||
|
||||
// Sort filters by length
|
||||
uasort($filters, array($this, 'sortByLength'));
|
||||
$this->filters = $adminFilter + $filters;
|
||||
|
||||
// Push the admin filter first
|
||||
$filters = $adminFilter + $filters;
|
||||
$this->filters = $filters;
|
||||
foreach ($this->filters as $filterName=>$filterURI) {
|
||||
// $filterName = 'category'
|
||||
// $filterURI = '/category/'
|
||||
|
||||
foreach($filters as $filterName=>$filterURI) {
|
||||
$filterFull = ltrim($filterURI, '/');
|
||||
$filterFull = HTML_PATH_ROOT.$filterFull;
|
||||
$filterLenght = mb_strlen($filterFull, CHARSET);
|
||||
|
||||
// $slug will be FALSE if the filter is not included in the URI
|
||||
$slug = $this->getSlugAfterFilter($filterURI);
|
||||
|
||||
if($slug!==false) {
|
||||
$this->slug = $slug;
|
||||
if (mb_substr($this->uri, 0, $filterLenght, CHARSET)==$filterURI) {
|
||||
$this->slug = mb_substr($this->uri, $filterLenght+1);
|
||||
$this->whereAmI = $filterName;
|
||||
$this->activeFilter = $filterURI;
|
||||
|
||||
// If the slug is empty
|
||||
if( Text::isEmpty($slug) ) {
|
||||
|
||||
if($filterURI==='/') {
|
||||
$this->whereAmI = 'home';
|
||||
break;
|
||||
}
|
||||
|
||||
if($filterURI===$adminFilter['admin']) {
|
||||
$this->whereAmI = 'admin';
|
||||
$this->slug = 'dashboard';
|
||||
break;
|
||||
}
|
||||
|
||||
$this->setNotFound();
|
||||
if (empty($this->slug) && (($filterName=='blog') || ($filterURI=='/')) ) {
|
||||
$this->whereAmI = 'home';
|
||||
}
|
||||
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->setNotFound();
|
||||
}
|
||||
|
||||
public function slug()
|
||||
@ -170,52 +157,6 @@ class Url
|
||||
$this->httpMessage = $msg;
|
||||
}
|
||||
|
||||
// Returns the slug after the $filter, the slug could be an empty string
|
||||
// If the filter is not included in the uri, returns FALSE
|
||||
// ex: http://domain.com/cms/$filter/slug123 => slug123
|
||||
// ex: http://domain.com/cms/$filter/name/lastname => name/lastname
|
||||
// ex: http://domain.com/cms/$filter/ => empty string
|
||||
// ex: http://domain.com/cms/$filter => empty string
|
||||
private function getSlugAfterFilter($filter)
|
||||
{
|
||||
// Remove both slash from the filter
|
||||
$filter = trim($filter, '/');
|
||||
|
||||
// Add to the filter the root directory
|
||||
$filter = HTML_PATH_ROOT.$filter;
|
||||
|
||||
// Check if the filter is in the uri.
|
||||
$position = Text::stringPosition($this->uri, $filter);
|
||||
|
||||
// If the position is FALSE, the filter isn't in the URI.
|
||||
if($position===false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Start position to cut
|
||||
$start = $position + Text::length($filter);
|
||||
|
||||
// End position to cut
|
||||
$end = $this->uriStrlen;
|
||||
|
||||
// Get the slug from the URI
|
||||
$slug = Text::cut($this->uri, $start, $end);
|
||||
|
||||
if(Text::isEmpty($slug)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if($slug[0]=='/') {
|
||||
return ltrim($slug, '/');
|
||||
}
|
||||
|
||||
if($filter==HTML_PATH_ROOT) {
|
||||
return $slug;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function sortByLength($a, $b)
|
||||
{
|
||||
return strlen($b)-strlen($a);
|
||||
|
@ -201,5 +201,7 @@
|
||||
"ip-address-has-been-blocked": "IP address has been blocked",
|
||||
"try-again-in-a-few-minutes": "Try again in a few minutes",
|
||||
"page-published-from-scheduler": "Page published from scheduler",
|
||||
"installer-page-about-content": "The about page is an important and powerful for potential clients and partners. For those who wonder who is behind the website, your About page is the first source of information."
|
||||
"installer-page-about-content": "The about page is an important and powerful for potential clients and partners. For those who wonder who is behind the website, your About page is the first source of information.",
|
||||
"blog": "Blog",
|
||||
"complete-all-fields": "Complete all fields"
|
||||
}
|
@ -356,6 +356,7 @@ function install($adminPassword, $email, $timezone)
|
||||
'uriPage'=>'/',
|
||||
'uriTag'=>'/tag/',
|
||||
'uriCategory'=>'/category/',
|
||||
'uriBlog'=>'/blog/',
|
||||
'url'=>$siteUrl,
|
||||
'emailFrom'=>'no-reply@'.DOMAIN,
|
||||
'orderBy'=>'date'
|
||||
|
Loading…
Reference in New Issue
Block a user