diff --git a/bl-kernel/abstract/dblist.class.php b/bl-kernel/abstract/dblist.class.php
index 133b158e..0cc953ea 100644
--- a/bl-kernel/abstract/dblist.class.php
+++ b/bl-kernel/abstract/dblist.class.php
@@ -6,10 +6,12 @@ Database structure
{
"videos": {
"name": "Videos",
+ "template: "",
"list": [ "my-page", "second-page" ]
},
"pets": {
"name": "Pets",
+ "template: "",
"list": [ "cats-and-dogs" ]
}
}
@@ -24,77 +26,62 @@ class dbList extends dbJSON
parent::__construct($file);
}
- // Returns an array with a list of key of pages, FALSE if out of range
+ // Returns the list of keys filter by pageNumber
public function getList($key, $pageNumber, $amountOfItems)
{
- if (empty($key)) {
- return false;
- }
-
if (!isset($this->db[$key])) {
Log::set(__METHOD__.LOG_SEP.'Error key does not exist '.$key);
return false;
}
+ // List of keys
$list = $this->db[$key]['list'];
+ // Returns all the items from the list
if ($amountOfItems==-1) {
// Invert keys to values, is necesary returns as key the key pages
- //$list = array_flip($list);
+ $list = array_flip($list);
return $list;
}
// The first page number is 1, so the real is 0
$realPageNumber = $pageNumber - 1;
-
- $total = count($list);
- $init = (int) $amountOfItems * $realPageNumber;
- $end = (int) min( ($init + $amountOfItems - 1), $total );
- $outrange = $init<0 ? true : $init>$end;
-
- if($outrange) {
- Log::set(__METHOD__.LOG_SEP.'Error out of range');
- return false;
+ $chunks = array_chunk($list, $realPageNumber);
+ if (isset($chunks[$realPageNumber])) {
+ return $chunks[$realPageNumber];
}
- //$list = array_flip($list);
- return array_slice($list, $init, $amountOfItems, true);
+ // Out of index,returns FALSE
+ return false;
}
public function generateKey($name)
{
$key = Text::cleanUrl($name);
- if (empty($key)) {
- return false;
+ while (isset($this->db[$key])) {
+ $key++;
}
return $key;
}
- public function add($name)
+ // Add a new item to the dblist
+ // $args => 'name', 'template', 'list'
+ public function add($args)
{
- $key = $this->generateKey($name);
- if ($key===false) {
- Log::set(__METHOD__.LOG_SEP.'Error when try to generate the key');
- return false;
- }
+ $key = $this->generateKey($args['name']);
- if (isset($this->db[$key])) {
- Log::set(__METHOD__.LOG_SEP.'Error key already exists: '.$key);
- return false;
- }
-
- $this->db[$key]['name'] = Sanitize::html($name);
- $this->db[$key]['list'] = array();
+ $this->db[$key]['name'] = $args['name'];
+ $this->db[$key]['template'] = isset($args['template'])?$args['template']:'';
+ $this->db[$key]['list'] = isset($args['list'])?$args['list']:array();
$this->sortAlphanumeric();
$this->save();
-
return $key;
}
public function remove($key)
{
- if( !isset($this->db[$key]) ) {
+ if (!isset($this->db[$key])) {
Log::set(__METHOD__.LOG_SEP.'The key does not exist, key: '.$key);
return false;
}
@@ -103,41 +90,27 @@ class dbList extends dbJSON
return $this->save();
}
- public function edit($oldKey, $newName)
+ // Edit an item to the dblist
+ // $args => 'name', 'oldkey', 'newKey', 'template'
+ public function edit($args)
{
- $newKey = $this->generateKey($newName);
-
- $this->db[$newKey]['name'] = Sanitize::html($newName);
- $this->db[$newKey]['list'] = $this->db[$oldKey]['list'];
-
- // Remove the old key
- if ($oldKey!=$newKey) {
- unset( $this->db[$oldKey] );
- }
-
- $this->sortAlphanumeric();
- $this->save();
- return $newKey;
- }
-
- public function changeKey($oldKey, $newKey)
- {
- if ($this->exists($newKey)) {
- Log::set(__METHOD__.LOG_SEP.'Error key already exists: '.$newKey);
+ if (isset($this->db[$args['newKey']])) {
+ Log::set(__METHOD__.LOG_SEP.'The new key already exists. Key: '.$args['newKey']);
return false;
}
- $this->db[$newKey]['name'] = $this->db[$oldKey]['name'];
- $this->db[$newKey]['list'] = $this->db[$oldKey]['list'];
+ $this->db[$args['newKey']]['name'] = $args['name'];
+ $this->db[$args['newKey']]['template'] = isset($args['template'])?$args['template']:'';
+ $this->db[$args['newKey']]['list'] = $this->db[$args['oldKey']]['list'];
- // Remove the old key
- if ($oldKey!=$newKey) {
- unset( $this->db[$oldKey] );
+ // Remove the old category
+ if ($args['oldKey'] !== $args['newKey']) {
+ unset( $this->db[$args['oldKey']] );
}
$this->sortAlphanumeric();
$this->save();
- return $newKey;
+ return $args['newKey'];
}
// Sort the categories by "Natural order"
@@ -150,10 +123,9 @@ class dbList extends dbJSON
// Returns the name associated to the key, FALSE if the key doesn't exist
public function getName($key)
{
- if( isset($this->db[$key]) ) {
+ if (isset($this->db[$key])) {
return $this->db[$key]['name'];
}
-
return false;
}
@@ -164,7 +136,6 @@ class dbList extends dbJSON
foreach($this->db as $key=>$fields) {
$tmp[$key] = $fields['name'];
}
-
return $tmp;
}
@@ -174,7 +145,6 @@ class dbList extends dbJSON
if( isset($this->db[$key]) ) {
return count($this->db[$key]['list']);
}
-
return 0;
}
@@ -183,14 +153,25 @@ class dbList extends dbJSON
return isset( $this->db[$key] );
}
+ public function existsName($name)
+ {
+ foreach ($this->db as $key=>$fields) {
+ if ($name==$fields['name']) {
+ return true;
+ }
+ }
+ return false;
+ }
+
// Returns an array with a portion of the database filtered by key
- // Returns array( 'name'=>'', 'list'=>array() )
+ // Returns array( 'key'=>'', 'name'=>'', 'template'=>'', 'list'=>array() )
public function getMap($key)
{
- if( isset($this->db[$key]) ) {
- return $this->db[$key];
+ if (isset($this->db[$key])) {
+ $tmp = $this->db[$key];
+ $tmp['key'] = $key;
+ return $tmp;
}
-
return false;
}
diff --git a/bl-kernel/admin/controllers/edit-category.php b/bl-kernel/admin/controllers/edit-category.php
index 8675480f..b0f133be 100644
--- a/bl-kernel/admin/controllers/edit-category.php
+++ b/bl-kernel/admin/controllers/edit-category.php
@@ -41,7 +41,7 @@ if (!$dbCategories->exists($categoryKey)) {
Redirect::page('categories');
}
-$categoryName = $dbCategories->getName($layout['parameters']);
+$categoryMap = $dbCategories->getMap($categoryKey);
// Title of the page
-$layout['title'] .= ' - '.$Language->g('Edit Category').' - '.$categoryName;
\ No newline at end of file
+$layout['title'] .= ' - '.$Language->g('Edit Category').' [ '.$categoryMap['name'] . ' ] ';
\ No newline at end of file
diff --git a/bl-kernel/admin/controllers/edit-user.php b/bl-kernel/admin/controllers/edit-user.php
index fa312712..d0c8e635 100644
--- a/bl-kernel/admin/controllers/edit-user.php
+++ b/bl-kernel/admin/controllers/edit-user.php
@@ -12,21 +12,20 @@
// POST Method
// ============================================================================
-if( $_SERVER['REQUEST_METHOD'] == 'POST' )
-{
+if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Prevent non-administrators to change other users
- if($Login->role()!=='admin') {
+ if ($Login->role()!=='admin') {
$_POST['username'] = $Login->username();
unset($_POST['role']);
}
- if(isset($_POST['delete-user-all'])) {
+ if (isset($_POST['delete-user-all'])) {
deleteUser($_POST, $deleteContent=true);
}
- elseif(isset($_POST['delete-user-associate'])) {
+ elseif (isset($_POST['delete-user-associate'])) {
deleteUser($_POST, $deleteContent=false);
}
- elseif(isset($_POST['disable-user'])) {
+ elseif (isset($_POST['disable-user'])) {
disableUser($_POST['username']);
}
else {
diff --git a/bl-kernel/admin/controllers/add-user.php b/bl-kernel/admin/controllers/new-user.php
similarity index 100%
rename from bl-kernel/admin/controllers/add-user.php
rename to bl-kernel/admin/controllers/new-user.php
diff --git a/bl-kernel/admin/controllers/settings-advanced.php b/bl-kernel/admin/controllers/settings.php
similarity index 61%
rename from bl-kernel/admin/controllers/settings-advanced.php
rename to bl-kernel/admin/controllers/settings.php
index 71f153fc..46e41738 100644
--- a/bl-kernel/admin/controllers/settings-advanced.php
+++ b/bl-kernel/admin/controllers/settings.php
@@ -23,31 +23,12 @@ if ($Login->role()!=='admin') {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
editSettings($_POST);
- Redirect::page('settings-advanced');
+ Redirect::page('settings');
}
// ============================================================================
// Main after POST
// ============================================================================
-$allPages = buildAllpages($publishedPages=true, $staticPages=true, $draftPages=false, $scheduledPages=false);
-
-// Generate $pagesByParentByKey and pagesByParent
-$pagesByParent = array(PARENT=>array());
-$pagesByParentByKey = array(PARENT=>array());
-buildPagesByParent(true, true);
-
-// Homepage select options
-$homepageOptions = array(' '=>'- '.$L->g('Default').' -');
-foreach ($allPages as $key=>$page) {
- $parentKey = $page->parentKey();
- if ($parentKey) {
- $homepageOptions[$key] = $pagesByParentByKey[PARENT][$parentKey]->title() .'->'. $page->title();
- } else {
- $homepageOptions[$key] = $page->title();
- }
-
- ksort($homepageOptions);
-}
// Title of the page
$layout['title'] .= ' - '.$Language->g('Advanced Settings');
\ No newline at end of file
diff --git a/bl-kernel/admin/themes/booty/index.php b/bl-kernel/admin/themes/booty/index.php
index 8b3df20b..1ecb222c 100644
--- a/bl-kernel/admin/themes/booty/index.php
+++ b/bl-kernel/admin/themes/booty/index.php
@@ -57,8 +57,8 @@
if (Sanitize::pathFile(PATH_ADMIN_VIEWS, $layout['view'].'.php')) {
include(PATH_ADMIN_VIEWS.$layout['view'].'.php');
} else {
- echo '
'.$L->g('Page not found').' ';
- echo ''.$L->g('Choose a page from the sidebar.').' ';
+ echo ''.$L->g('Page not found').' ';
+ echo ''.$L->g('Choose a page from the sidebar.').' ';
}
?>
diff --git a/bl-kernel/admin/themes/booty/init.php b/bl-kernel/admin/themes/booty/init.php
index 4f4b1502..9a5deb2d 100644
--- a/bl-kernel/admin/themes/booty/init.php
+++ b/bl-kernel/admin/themes/booty/init.php
@@ -45,40 +45,51 @@ class Bootstrap {
public static function pageTitle($args)
{
- return ' '.$args['title'].' ';
+ $icon = $args['icon'];
+ $title = $args['title'];
+return <<
+ $title
+
+EOF;
}
public static function formOpen($args)
{
- $class = empty($args['class']) ? '' : ' '.$args['class'];
- $id = empty($args['id']) ? '' : ' id="'.$args['id'].'" ';
- $enctype = empty($args['enctype']) ? '' : ' enctype="'.$args['enctype'].'" ';
+ $class = empty($args['class'])?'':'class="'.$args['class'].'"';
+ $id = empty($args['id'])?'':'id="'.$args['id'].'"';
+ $enctype = empty($args['enctype'])?'':'enctype="'.$args['enctype'].'"';
+ $action = empty($args['action'])?'action=""':'action="'.$args['action'].'"';
+ $method = empty($args['method'])?'method="post"':'method="'.$args['method'].'"';
- $html = '';
-
- $script = '';
-
- return $html.$script;
+return <<
+
+EOF;
}
public static function formTitle($args)
{
- return ''.$args['title'].' ';
+ $title = $args['title'];
+return <<$title
+EOF;
}
public static function formInputTextBlock($args)
@@ -188,31 +199,36 @@ EOF;
public static function formInputText($args)
{
- $id = 'js'.$args['name'];
+ $label = isset($args['label'])?$args['label']:'';
+ $placeholder = isset($args['placeholder'])?$args['placeholder']:'';
+ $tip = isset($args['tip'])?$args['tip']:'';
+ $value = isset($args['value'])?$args['value']:'';
+ $name = $args['name'];
+ $id = 'js'.$name;
if (isset($args['id'])) {
$id = $args['id'];
}
+ $disabled = isset($args['disabled'])?'disabled':'';
$class = 'form-control';
if (isset($args['class'])) {
$class = $class.' '.$args['class'];
}
- $html = '';
-
- return $html;
+return <<
+ $label
+
+
+ $tip
+
+
+EOF;
}
public static function formSelect($args)
diff --git a/bl-kernel/admin/views/edit-category.php b/bl-kernel/admin/views/edit-category.php
index e8c669f5..94cdf292 100644
--- a/bl-kernel/admin/views/edit-category.php
+++ b/bl-kernel/admin/views/edit-category.php
@@ -10,29 +10,33 @@ echo Bootstrap::formOpen(array());
));
echo Bootstrap::formInputHidden(array(
- 'name'=>'oldCategoryName',
- 'value'=>$categoryName
- ));
-
- echo Bootstrap::formInputHidden(array(
- 'name'=>'oldCategoryKey',
- 'value'=>$categoryKey
+ 'name'=>'oldKey',
+ 'value'=>$categoryMap['key']
));
echo Bootstrap::formInputTextBlock(array(
- 'name'=>'categoryName',
+ 'name'=>'name',
'label'=>$L->g('Category name'),
- 'value'=>$categoryName,
+ 'value'=>$categoryMap['name'],
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
echo Bootstrap::formInputGroupText(array(
- 'name'=>'categoryKey',
+ 'name'=>'newKey',
'label'=>$L->g('Category key'),
'labelInside'=>DOMAIN_CATEGORIES,
- 'value'=>$categoryKey,
+ 'value'=>$categoryMap['key'],
+ 'class'=>'',
+ 'placeholder'=>'',
+ 'tip'=>''
+ ));
+
+ echo Bootstrap::formInputTextBlock(array(
+ 'name'=>'template',
+ 'label'=>$L->g('Category template'),
+ 'value'=>isset($categoryMap['template'])?$categoryMap['template']:'',
'class'=>'',
'placeholder'=>'',
'tip'=>''
diff --git a/bl-kernel/admin/views/new-user.php b/bl-kernel/admin/views/new-user.php
index 859c888a..93c2ceea 100644
--- a/bl-kernel/admin/views/new-user.php
+++ b/bl-kernel/admin/views/new-user.php
@@ -1,60 +1,66 @@
-$L->g('Add a new user'), 'icon'=>'user-plus'));
+echo Bootstrap::pageTitle(array('title'=>$L->g('Add a new user'), 'icon'=>'person'));
-HTML::formOpen(array('id'=>'add-user-form', 'class'=>'uk-form-horizontal'));
+echo Bootstrap::formOpen(array());
- // Security token
- HTML::formInputHidden(array(
+ echo Bootstrap::formInputHidden(array(
'name'=>'tokenCSRF',
'value'=>$Security->getTokenCSRF()
));
- HTML::formInputText(array(
+ echo Bootstrap::formInputText(array(
'name'=>'new_username',
'label'=>$L->g('Username'),
'value'=>(isset($_POST['new_username'])?$_POST['new_username']:''),
- 'class'=>'uk-width-1-2 uk-form-medium',
+ 'class'=>'',
+ 'placeholder'=>'',
'tip'=>''
));
- HTML::formInputPassword(array(
+ echo Bootstrap::formInputText(array(
'name'=>'new_password',
+ 'type'=>'password',
'label'=>$L->g('Password'),
'value'=>'',
- 'class'=>'uk-width-1-2 uk-form-medium',
+ 'class'=>'',
+ 'placeholder'=>'',
'tip'=>''
));
- HTML::formInputPassword(array(
+ echo Bootstrap::formInputText(array(
'name'=>'confirm_password',
+ 'type'=>'password',
'label'=>$L->g('Confirm Password'),
'value'=>'',
- 'class'=>'uk-width-1-2 uk-form-medium',
+ 'class'=>'',
+ 'placeholder'=>'',
'tip'=>''
));
- HTML::formSelect(array(
+ echo Bootstrap::formSelect(array(
'name'=>'role',
'label'=>$L->g('Role'),
'options'=>array('editor'=>$L->g('Editor'), 'admin'=>$L->g('Administrator')),
'selected'=>'editor',
+ 'class'=>'',
'tip'=>''
));
- HTML::formInputText(array(
+ echo Bootstrap::formInputText(array(
'name'=>'email',
'label'=>$L->g('Email'),
'value'=>(isset($_POST['email'])?$_POST['email']:''),
- 'class'=>'uk-width-1-2 uk-form-medium',
+ 'class'=>'',
+ 'placeholder'=>'',
'tip'=>''
));
- echo '';
+ echo '
+
+ ';
-HTML::formClose();
\ No newline at end of file
+echo Bootstrap::formClose();
\ No newline at end of file
diff --git a/bl-kernel/admin/views/plugins.php b/bl-kernel/admin/views/plugins.php
index ce01aa3f..dd0fd89d 100644
--- a/bl-kernel/admin/views/plugins.php
+++ b/bl-kernel/admin/views/plugins.php
@@ -1,58 +1,61 @@
$L->g('Plugins'), 'icon'=>'puzzle-piece'));
+echo Bootstrap::pageTitle(array('title'=>$L->g('Plugins'), 'icon'=>'puzzle-piece'));
-echo ' '.$L->g('Change the position of the plugins').' ';
+echo Bootstrap::link(array(
+ 'title'=>$L->g('Change the position of the plugins'),
+ 'href'=>HTML_PATH_ADMIN_ROOT.'plugins-position',
+ 'icon'=>'elevator'
+));
echo '
-
-
-
- '.$L->g('Name').'
- '.$L->g('Description').'
- '.$L->g('Version').'
- '.$L->g('Author').'
-
-
-
+
+
+
+ '.$L->g('Name').'
+ '.$L->g('Description').'
+ '.$L->g('Version').'
+ '.$L->g('Author').'
+
+
+
';
-foreach ($plugins['all'] as $Plugin) {
- echo 'installed()?'class="plugin-installed"':'class="plugin-notInstalled"').'>
-
- '.$Plugin->name().'
- ';
+foreach ($plugins['all'] as $plugin) {
+ echo '
installed()?'class="bg-light"':'').'>
- if ($Plugin->installed()) {
- if (method_exists($Plugin, 'form')) {
- echo ''.$L->g('Settings').' ';
- echo ' | ';
+
+ '.$plugin->name().'
+ ';
+ echo '';
echo ' ';
- echo '';
- echo $Plugin->description();
+ echo ' ';
+ echo $plugin->description();
echo ' ';
- echo '';
- // if( !$Plugin->isCompatible() ) {
- // echo ' ';
- // }
- echo ''.$Plugin->version().' ';
+ echo ' ';
+ echo ''.$plugin->version().' ';
echo ' ';
- echo ''.$Plugin->author().' ';
+ echo '
+ '.$plugin->author().'
+ ';
echo ' ';
}
echo '
-
+
';
\ No newline at end of file
diff --git a/bl-kernel/admin/views/settings.php b/bl-kernel/admin/views/settings.php
index 351b1fae..5ecf730f 100644
--- a/bl-kernel/admin/views/settings.php
+++ b/bl-kernel/admin/views/settings.php
@@ -19,15 +19,18 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
Language
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/bl-kernel/admin/views/themes.php b/bl-kernel/admin/views/themes.php
index 71c4eaa1..08514077 100644
--- a/bl-kernel/admin/views/themes.php
+++ b/bl-kernel/admin/views/themes.php
@@ -1,54 +1,53 @@
$L->g('Themes'), 'icon'=>'paint-brush'));
+echo Bootstrap::pageTitle(array('title'=>$L->g('Themes'), 'icon'=>'puzzle-piece'));
echo '
-
-
-
- '.$L->g('Name').'
- '.$L->g('Description').'
- '.$L->g('Version').'
- '.$L->g('Author').'
-
-
-
+
+
+
+ '.$L->g('Name').'
+ '.$L->g('Description').'
+ '.$L->g('Version').'
+ '.$L->g('Author').'
+
+
+
';
-foreach($themes as $theme)
-{
+foreach ($themes as $theme) {
echo '
- theme()?'class="theme-installed"':'class="theme-notInstalled"').'>
-
- '.$theme['name'].'
-
+
theme()?'class="bg-light"':'').'>
+
+ '.$theme['name'].'
+
- ';
+
+
+ ';
- echo '';
+ echo ' ';
echo $theme['description'];
echo ' ';
- echo '';
- // if( !$theme['compatible'] ) {
- // echo ' ';
- // }
- echo $theme['version'];
+ echo ' ';
+ echo ''.$theme['version'].' ';
echo ' ';
- echo ''.$theme['author'].' ';
+ echo '
+ '.$theme['author'].'
+ ';
echo ' ';
}
echo '
-
+
';
\ No newline at end of file
diff --git a/bl-kernel/admin/views/users.php b/bl-kernel/admin/views/users.php
index 8c1d6121..3aa54d6c 100644
--- a/bl-kernel/admin/views/users.php
+++ b/bl-kernel/admin/views/users.php
@@ -13,12 +13,12 @@ echo '
'.$L->g('Username').'
- '.$L->g('First name').'
- '.$L->g('Last name').'
+ '.$L->g('First name').'
+ '.$L->g('Last name').'
'.$L->g('Email').'
'.$L->g('Status').'
'.$L->g('Role').'
- '.$L->g('Registered').'
+ '.$L->g('Registered').'
@@ -28,12 +28,12 @@ $users = $dbUsers->getAllUsers();
foreach ($users as $username=>$User) {
echo '';
echo ''.$username.' ';
- echo ''.$User->firstName().' ';
- echo ''.$User->lastName().' ';
+ echo ''.$User->firstName().' ';
+ echo ''.$User->lastName().' ';
echo ''.$User->email().' ';
- echo ''.($User->enabled()?''.$L->g('Enabled').' ':$L->g('Disabled')).' ';
- echo ''.($User->role()=='admin'?$L->g('Administrator'):$L->g('Editor')).' ';
- echo ''.Date::format($User->registered(), DB_DATE_FORMAT, ADMIN_PANEL_DATE_FORMAT).' ';
+ echo ''.($User->enabled()?''.$L->g('Enabled').' ':$L->g('Disabled')).' ';
+ echo ''.($User->role()=='admin'?$L->g('Administrator'):$L->g('Editor')).' ';
+ echo ''.Date::format($User->registered(), DB_DATE_FORMAT, ADMIN_PANEL_DATE_FORMAT).' ';
echo ' ';
}
diff --git a/bl-kernel/category.class.php b/bl-kernel/category.class.php
index 87dca557..2a09d95b 100644
--- a/bl-kernel/category.class.php
+++ b/bl-kernel/category.class.php
@@ -10,6 +10,7 @@ class Category {
if (isset($dbCategories->db[$key])) {
$this->vars['name'] = $dbCategories->db[$key]['name'];
+ $this->vars['template'] = $dbCategories->db[$key]['template'];
$this->vars['key'] = $key;
$this->vars['permalink'] = DOMAIN_CATEGORIES . $key;
$this->vars['list'] = $dbCategories->db[$key]['list'];
@@ -48,9 +49,14 @@ class Category {
return $this->getValue('permalink');
}
+ public function template()
+ {
+ return $this->getValue('template');
+ }
+
// Returns an array with the keys of pages linked to the category
public function pages()
{
return $this->getValue('list');
}
-}
\ No newline at end of file
+}
diff --git a/bl-kernel/dbusers.class.php b/bl-kernel/dbusers.class.php
index a64b2a61..5560630c 100644
--- a/bl-kernel/dbusers.class.php
+++ b/bl-kernel/dbusers.class.php
@@ -47,18 +47,15 @@ class dbUsers extends dbJSON
$dataForDb = array();
// Verify arguments with the database fields
- foreach($this->dbFields as $field=>$options) {
- if( isset($args[$field]) ) {
+ foreach ($this->dbFields as $field=>$options) {
+ if (isset($args[$field])) {
$value = Sanitize::html($args[$field]);
- }
- else {
+ } else {
$value = $options['value'];
}
// Set type
settype($value, gettype($options['value']));
-
- // Save on database
$dataForDb[$field] = $value;
}
diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php
index b408e96b..3c669e00 100644
--- a/bl-kernel/functions.php
+++ b/bl-kernel/functions.php
@@ -601,25 +601,25 @@ function createUser($args) {
global $syslog;
// Check empty username
- if( Text::isEmpty($args['new_username']) ) {
+ if (Text::isEmpty($args['new_username'])) {
Alert::set($Language->g('username-field-is-empty'), ALERT_STATUS_FAIL);
return false;
}
// Check already exist username
- if( $dbUsers->exists($args['new_username']) ) {
+ if ($dbUsers->exists($args['new_username'])) {
Alert::set($Language->g('username-already-exists'), ALERT_STATUS_FAIL);
return false;
}
// Password length
- if( Text::length($args['new_password']) < PASSWORD_LENGTH ) {
+ if (Text::length($args['new_password']) < PASSWORD_LENGTH) {
Alert::set($Language->g('Password must be at least '.PASSWORD_LENGTH.' characters long'), ALERT_STATUS_FAIL);
return false;
}
// Check new password and confirm password are equal
- if( $args['new_password'] != $args['confirm_password'] ) {
+ if ($args['new_password'] != $args['confirm_password']) {
Alert::set($Language->g('The password and confirmation password do not match'), ALERT_STATUS_FAIL);
return false;
}
@@ -632,7 +632,7 @@ function createUser($args) {
$tmp['email'] = $args['email'];
// Add the user to the database
- if( $dbUsers->add($tmp) ) {
+ if ($dbUsers->add($tmp)) {
// Add to syslog
$syslog->add(array(
'dictionaryKey'=>'new-user-created',
@@ -717,7 +717,7 @@ function createCategory($category) {
return false;
}
- if ($dbCategories->add($category)) {
+ if ($dbCategories->add(array('name'=>$category))) {
$syslog->add(array(
'dictionaryKey'=>'new-category-created',
'notes'=>$category
@@ -737,18 +737,12 @@ function editCategory($args) {
global $dbCategories;
global $syslog;
- if (Text::isEmpty($args['categoryName']) || Text::isEmpty($args['categoryKey']) ) {
+ if (Text::isEmpty($args['name']) || Text::isEmpty($args['newKey']) ) {
Alert::set($Language->g('Empty fields'));
return false;
}
- 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']);
- }
+ $newCategoryKey = $dbCategories->edit($args);
if ($newCategoryKey==false) {
Alert::set($Language->g('The category already exists'));
@@ -756,7 +750,7 @@ function editCategory($args) {
}
// Change the category key in the pages database
- $dbPages->changeCategory($args['oldCategoryKey'], $newCategoryKey);
+ $dbPages->changeCategory($args['oldKey'], $newCategoryKey);
$syslog->add(array(
'dictionaryKey'=>'category-edited',
diff --git a/bl-kernel/page.class.php b/bl-kernel/page.class.php
index cc4d0b61..b2c654d8 100644
--- a/bl-kernel/page.class.php
+++ b/bl-kernel/page.class.php
@@ -216,6 +216,12 @@ class Page {
return $this->categoryMap('name');
}
+ // Returns the category name
+ public function categoryTemplate()
+ {
+ return $this->categoryMap('template');
+ }
+
// Returns the category key
public function categoryKey()
{