\ No newline at end of file
diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php
index ab6312a4..599641b6 100644
--- a/bl-kernel/boot/init.php
+++ b/bl-kernel/boot/init.php
@@ -201,6 +201,9 @@ define('PAGE_URI_FILTER', $Url->filters('page'));
// Content order by: date / position
define('ORDER_BY', $Site->orderBy());
+// Allow unicode characters in the URL
+define('EXTREME_FRIENDLY_URL', $Site->extremeFriendly());
+
// --- PHP paths with dependency ---
// This paths are absolutes for the OS
define('THEME_DIR', PATH_ROOT.'bl-themes'.DS.$Site->theme().DS);
diff --git a/bl-kernel/boot/variables.php b/bl-kernel/boot/variables.php
index 38c9c2f4..f3262968 100644
--- a/bl-kernel/boot/variables.php
+++ b/bl-kernel/boot/variables.php
@@ -86,9 +86,6 @@ define('TOKEN_EMAIL_TTL', '+15 minutes');
// Charset, default UTF-8.
define('CHARSET', 'UTF-8');
-// EXTREME FRIENDLY URL, TRUE for dissmiss internet standard. Experimental!
-define('EXTREME_FRIENDLY_URL', FALSE);
-
// Permissions for new directories
define('DIR_PERMISSIONS', 0755);
diff --git a/bl-kernel/dbpages.class.php b/bl-kernel/dbpages.class.php
index 9283d3f2..8d09490d 100644
--- a/bl-kernel/dbpages.class.php
+++ b/bl-kernel/dbpages.class.php
@@ -763,16 +763,14 @@ class dbPages extends dbJSON
return $tmp;
}
- // Change all posts with the old category key for the new category key
+ // Change all pages with the old category key to the new category key
public function changeCategory($oldCategoryKey, $newCategoryKey)
{
- foreach($this->db as $key=>$value) {
- if($value['category']==$oldCategoryKey) {
+ foreach ($this->db as $key=>$value) {
+ if ($value['category']===$oldCategoryKey) {
$this->db[$key]['category'] = $newCategoryKey;
}
}
-
- // Save database
return $this->save();
}
diff --git a/bl-kernel/dbsite.class.php b/bl-kernel/dbsite.class.php
index ae73e547..09564d3f 100644
--- a/bl-kernel/dbsite.class.php
+++ b/bl-kernel/dbsite.class.php
@@ -31,7 +31,8 @@ class dbSite extends dbJSON
'instagram'=> array('inFile'=>false, 'value'=>''),
'github'=> array('inFile'=>false, 'value'=>''),
'linkedin'=> array('inFile'=>false, 'value'=>''),
- 'orderBy'=> array('inFile'=>false, 'value'=>'date') // date or position
+ 'orderBy'=> array('inFile'=>false, 'value'=>'date'), // date or position
+ 'extremeFriendly'=> array('inFile'=>false, 'value'=>true)
);
function __construct()
@@ -100,6 +101,11 @@ class dbSite extends dbJSON
return DOMAIN_BASE.'sitemap.xml';
}
+ public function extremeFriendly()
+ {
+ return $this->getField('extremeFriendly');
+ }
+
public function twitter()
{
return $this->getField('twitter');
diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php
index cb2e6c87..b408e96b 100644
--- a/bl-kernel/functions.php
+++ b/bl-kernel/functions.php
@@ -323,7 +323,7 @@ function pluginActivated($pluginClassName) {
function activatePlugin($pluginClassName) {
global $plugins;
- global $Syslog;
+ global $syslog;
global $Language;
// Check if the plugin exists
@@ -331,7 +331,7 @@ function activatePlugin($pluginClassName) {
$plugin = $plugins['all'][$pluginClassName];
if ($plugin->install()) {
// Add to syslog
- $Syslog->add(array(
+ $syslog->add(array(
'dictionaryKey'=>'plugin-activated',
'notes'=>$plugin->name()
));
@@ -346,7 +346,7 @@ function activatePlugin($pluginClassName) {
function deactivatePlugin($pluginClassName) {
global $plugins;
- global $Syslog;
+ global $syslog;
global $Language;
// Check if the plugin exists
@@ -355,7 +355,7 @@ function deactivatePlugin($pluginClassName) {
if ($plugin->uninstall()) {
// Add to syslog
- $Syslog->add(array(
+ $syslog->add(array(
'dictionaryKey'=>'plugin-deactivated',
'notes'=>$plugin->name()
));
@@ -370,7 +370,7 @@ function deactivatePlugin($pluginClassName) {
function changePluginsPosition($pluginClassList) {
global $plugins;
- global $Syslog;
+ global $syslog;
global $Language;
foreach ($pluginClassList as $position=>$pluginClassName) {
@@ -381,7 +381,7 @@ function changePluginsPosition($pluginClassList) {
}
// Add to syslog
- $Syslog->add(array(
+ $syslog->add(array(
'dictionaryKey'=>'plugins-sorted',
'notes'=>''
));
@@ -391,7 +391,7 @@ function changePluginsPosition($pluginClassList) {
function createPage($args) {
global $dbPages;
- global $Syslog;
+ global $syslog;
global $Language;
// The user is always the one loggued
@@ -419,7 +419,7 @@ function createPage($args) {
reindextags();
// Add to syslog
- $Syslog->add(array(
+ $syslog->add(array(
'dictionaryKey'=>'new-content-created',
'notes'=>$args['title']
));
@@ -439,7 +439,7 @@ function createPage($args) {
function editPage($args) {
global $dbPages;
- global $Syslog;
+ global $syslog;
// Check the key is not empty
if (empty($args['key'])) {
@@ -482,7 +482,7 @@ function editPage($args) {
reindextags();
// Add to syslog
- $Syslog->add(array(
+ $syslog->add(array(
'dictionaryKey'=>'content-edited',
'notes'=>$args['title']
));
@@ -496,7 +496,7 @@ function editPage($args) {
function deletePage($key) {
global $dbPages;
- global $Syslog;
+ global $syslog;
if( $dbPages->delete($key) ) {
// Call the plugins after page deleted
@@ -509,7 +509,7 @@ function deletePage($key) {
reindextags();
// Add to syslog
- $Syslog->add(array(
+ $syslog->add(array(
'dictionaryKey'=>'content-deleted',
'notes'=>$key
));
@@ -523,7 +523,7 @@ function deletePage($key) {
function disableUser($username) {
global $dbUsers;
global $Login;
- global $Syslog;
+ global $syslog;
// The editors can't disable users
if($Login->role()!=='admin') {
@@ -532,7 +532,7 @@ function disableUser($username) {
if( $dbUsers->disableUser($username) ) {
// Add to syslog
- $Syslog->add(array(
+ $syslog->add(array(
'dictionaryKey'=>'user-disabled',
'notes'=>$username
));
@@ -545,11 +545,11 @@ function disableUser($username) {
function editUser($args) {
global $dbUsers;
- global $Syslog;
+ global $syslog;
if( $dbUsers->set($args) ) {
// Add to syslog
- $Syslog->add(array(
+ $syslog->add(array(
'dictionaryKey'=>'user-edited',
'notes'=>$args['username']
));
@@ -563,7 +563,7 @@ function editUser($args) {
function deleteUser($args, $deleteContent=false) {
global $dbUsers;
global $Login;
- global $Syslog;
+ global $syslog;
// The user admin cannot be deleted
if($args['username']=='admin') {
@@ -584,7 +584,7 @@ function deleteUser($args, $deleteContent=false) {
if( $dbUsers->delete($args['username']) ) {
// Add to syslog
- $Syslog->add(array(
+ $syslog->add(array(
'dictionaryKey'=>'user-deleted',
'notes'=>$args['username']
));
@@ -598,7 +598,7 @@ function deleteUser($args, $deleteContent=false) {
function createUser($args) {
global $dbUsers;
global $Language;
- global $Syslog;
+ global $syslog;
// Check empty username
if( Text::isEmpty($args['new_username']) ) {
@@ -634,7 +634,7 @@ function createUser($args) {
// Add the user to the database
if( $dbUsers->add($tmp) ) {
// Add to syslog
- $Syslog->add(array(
+ $syslog->add(array(
'dictionaryKey'=>'new-user-created',
'notes'=>$tmp['username']
));
@@ -647,7 +647,7 @@ function createUser($args) {
function editSettings($args) {
global $Site;
- global $Syslog;
+ global $syslog;
global $Language;
global $dbPages;
@@ -692,7 +692,7 @@ function editSettings($args) {
}
// Add syslog
- $Syslog->add(array(
+ $syslog->add(array(
'dictionaryKey'=>'changes-on-settings',
'notes'=>''
));
@@ -706,71 +706,80 @@ function editSettings($args) {
}
// Add a new category to the system
-// Returns TRUE is success added, FALSE otherwise
+// Returns TRUE is successfully added, FALSE otherwise
function createCategory($category) {
global $dbCategories;
global $Language;
- global $Syslog;
+ global $syslog;
if (Text::isEmpty($category)) {
- // Set an alert
Alert::set($Language->g('Category name is empty'), ALERT_STATUS_FAIL);
return false;
}
if ($dbCategories->add($category)) {
- // Add to syslog
- $Syslog->add(array(
+ $syslog->add(array(
'dictionaryKey'=>'new-category-created',
'notes'=>$category
));
- // Set an alert
Alert::set($Language->g('Category added'), ALERT_STATUS_OK);
return true;
}
+ Alert::set($Language->g('The category already exists'), ALERT_STATUS_FAIL);
return false;
}
-function editCategory($oldCategoryKey, $newCategory) {
+function editCategory($args) {
global $Language;
global $dbPages;
global $dbCategories;
- global $Syslog;
+ global $syslog;
- if( Text::isEmpty($oldCategoryKey) || Text::isEmpty($newCategory) ) {
+ if (Text::isEmpty($args['categoryName']) || Text::isEmpty($args['categoryKey']) ) {
Alert::set($Language->g('Empty fields'));
return false;
}
- if( $dbCategories->edit($oldCategoryKey, $newCategory) == false ) {
- Alert::set($Language->g('Already exist a category'));
+ if ($args['oldCategoryKey']!==$args['categoryKey']) {
+ // Edit the category key and keep the category name
+ $newCategoryKey = $dbCategories->changeKey($args['oldCategoryKey'], $args['categoryKey']);
+ } else {
+ // Edit the category name
+ $newCategoryKey = $dbCategories->edit($args['oldCategoryKey'], $args['categoryName']);
+ }
+
+ if ($newCategoryKey==false) {
+ Alert::set($Language->g('The category already exists'));
return false;
}
- $dbPages->changeCategory($oldCategoryKey, $newCategory);
+ // Change the category key in the pages database
+ $dbPages->changeCategory($args['oldCategoryKey'], $newCategoryKey);
- $Syslog->add(array(
+ $syslog->add(array(
'dictionaryKey'=>'category-edited',
- 'notes'=>$newCategory
+ 'notes'=>$newCategoryKey
));
Alert::set($Language->g('The changes have been saved'));
return true;
}
-function deleteCategory($categoryKey) {
+function deleteCategory($args) {
global $Language;
global $dbCategories;
- global $Syslog;
+ global $syslog;
// Remove the category by key
- $dbCategories->remove($categoryKey);
+ $dbCategories->remove($args['oldCategoryKey']);
- $Syslog->add(array(
+ // Remove the category from the pages ? or keep it if the user want to recovery the category ?
+
+ $syslog->add(array(
'dictionaryKey'=>'category-deleted',
- 'notes'=>$categoryKey
+ 'notes'=>$args['oldCategoryKey']
));
Alert::set($Language->g('The changes have been saved'));
@@ -814,12 +823,12 @@ function getTags() {
function activateTheme($themeDirectory) {
global $Site;
- global $Syslog;
+ global $syslog;
if (Sanitize::pathFile(PATH_THEMES.$themeDirectory)) {
$Site->set(array('theme'=>$themeDirname));
- $Syslog->add(array(
+ $syslog->add(array(
'dictionaryKey'=>'new-theme-configured',
'notes'=>$themeDirname
));
diff --git a/bl-kernel/helpers/text.class.php b/bl-kernel/helpers/text.class.php
index d029601d..fadd820f 100644
--- a/bl-kernel/helpers/text.class.php
+++ b/bl-kernel/helpers/text.class.php
@@ -121,7 +121,7 @@ class Text {
return str_replace(array_keys($replace), array_values($replace), $text);
}
- // Convert invalid characters to valid characters for a URL
+ // Convert unicode characters to utf-8 characters
// Characters that cannot be converted will be removed from the string
// This function can return an empty string
public static function cleanUrl($string, $separator='-')
@@ -129,6 +129,8 @@ class Text {
global $Language;
if (EXTREME_FRIENDLY_URL) {
+ $string = trim($string, '-');
+ $string = self::lowercase($string);
$string = preg_replace("/[\/_|+ -]+/", $separator, $string);
return $string;
}
diff --git a/bl-kernel/page.class.php b/bl-kernel/page.class.php
index e5b5ac30..cc4d0b61 100644
--- a/bl-kernel/page.class.php
+++ b/bl-kernel/page.class.php
@@ -222,6 +222,12 @@ class Page {
return $this->getValue('category');
}
+ // Returns the category permalink
+ public function categoryPermalink()
+ {
+ return DOMAIN_CATEGORIES.$this->categoryKey();
+ }
+
// Returns the field from the array
// categoryMap = array( 'name'=>'', 'list'=>array() )
public function categoryMap($field)