Changes on admin panel, categories templates

This commit is contained in:
Diego Najar 2018-04-27 20:36:43 +02:00
parent ab1d795259
commit 75a7190ca0
17 changed files with 337 additions and 271 deletions

View File

@ -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;
}

View File

@ -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;
$layout['title'] .= ' - '.$Language->g('Edit Category').' [ '.$categoryMap['name'] . ' ] ';

View File

@ -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 {

View File

@ -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');

View File

@ -57,8 +57,8 @@
if (Sanitize::pathFile(PATH_ADMIN_VIEWS, $layout['view'].'.php')) {
include(PATH_ADMIN_VIEWS.$layout['view'].'.php');
} else {
echo '<h1 style="width:100%; text-align:center">'.$L->g('Page not found').'</h1>';
echo '<h2 style="width:100%; text-align:center">'.$L->g('Choose a page from the sidebar.').'</h2>';
echo '<h1 class="text-center">'.$L->g('Page not found').'</h1>';
echo '<h2 class="text-center">'.$L->g('Choose a page from the sidebar.').'</h2>';
}
?>
</div>

View File

@ -45,40 +45,51 @@ class Bootstrap {
public static function pageTitle($args)
{
return '<h2 class="mt-0 mb-3"><span class="oi oi-'.$args['icon'].'" style="font-size: 0.7em;"></span> '.$args['title'].'</h2>';
$icon = $args['icon'];
$title = $args['title'];
return <<<EOF
<h2 class="mt-0 mb-3">
<span class="oi oi-$icon" style="font-size: 0.7em;"></span> $title
</h2>
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 = '<form class="'.$class.'" '.$enctype.$id.' method="post" action="" autocomplete="off">';
return $html;
return <<<EOF
<form $class $enctype $id $method $action autocomplete="off">
EOF;
}
public static function formClose()
{
$html = '</form>';
$script = '<script>
$(document).ready(function() {
// Prevent the form submit when press enter key.
$("form").keypress(function(e) {
if ((e.which == 13) && (e.target.type !== "textarea")) {
return false;
}
});
});
</script>';
return $html.$script;
return <<<EOF
</form>
<script>
$(document).ready(function() {
// Prevent the form submit when press enter key.
$("form").keypress(function(e) {
if ((e.which == 13) && (e.target.type !== "textarea")) {
return false;
}
});
});
</script>
EOF;
}
public static function formTitle($args)
{
return '<h4 class="mt-4 mb-3">'.$args['title'].'</h4>';
$title = $args['title'];
return <<<EOF
<h4 class="mt-4 mb-3 font-weight-normal">$title</h4>
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 = '<div class="form-group row">';
if (isset($args['label'])) {
$html .= '<label for="'.$id.'" class="col-sm-2 col-form-label">'.$args['label'].'</label>';
$type = 'text';
if (isset($args['type'])) {
$type = $args['type'];
}
$html .= '<div class="col-sm-10">';
$html .= '<input type="text" class="'.$class.'" id="'.$id.'" name="'.$args['name'].'" placeholder="'.$args['placeholder'].'">';
if (isset($args['tip'])) {
$html .= '<small class="form-text text-muted">'.$args['tip'].'</small>';
}
$html .= '</div>';
$html .= '</div>';
return $html;
return <<<EOF
<div class="form-group row">
<label for="$id" class="col-sm-2 col-form-label">$label</label>
<div class="col-sm-10">
<input class="$class" id="$id" name="$name" value="$value" placeholder="$placeholder" type="$type" $disabled>
<small class="form-text text-muted">$tip</small>
</div>
</div>
EOF;
}
public static function formSelect($args)

View File

@ -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'=>''

View File

@ -1,60 +1,66 @@
<?php
<?php defined('BLUDIT') or die('Bludit CMS.');
HTML::title(array('title'=>$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 '<div class="uk-form-row">
<div class="uk-form-controls">
<button type="submit" class="uk-button uk-button-primary">'.$L->g('Save').'</button>
<a href="'.HTML_PATH_ADMIN_ROOT.'users" class="uk-button">'.$L->g('Cancel').'</a>
</div>
</div>';
echo '
<div class="form-group mt-4">
<button type="submit" class="btn btn-primary mr-2" name="save">'.$L->g('Save').'</button>
<a class="btn btn-secondary" href="'.HTML_PATH_ADMIN_ROOT.'users" role="button">'.$L->g('Cancel').'</a>
</div>
';
HTML::formClose();
echo Bootstrap::formClose();

View File

@ -1,58 +1,61 @@
<?php
HTML::title(array('title'=>$L->g('Plugins'), 'icon'=>'puzzle-piece'));
echo Bootstrap::pageTitle(array('title'=>$L->g('Plugins'), 'icon'=>'puzzle-piece'));
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'plugins-position"><i class="uk-icon-plus"></i> '.$L->g('Change the position of the plugins').'</a>';
echo Bootstrap::link(array(
'title'=>$L->g('Change the position of the plugins'),
'href'=>HTML_PATH_ADMIN_ROOT.'plugins-position',
'icon'=>'elevator'
));
echo '
<table class="uk-table">
<thead>
<tr>
<th class="uk-width-1-5">'.$L->g('Name').'</th>
<th class="uk-width-3-5">'.$L->g('Description').'</th>
<th class="uk-text-center">'.$L->g('Version').'</th>
<th class="uk-text-center">'.$L->g('Author').'</th>
</tr>
</thead>
<tbody>
<table class="table mt-3">
<thead>
<tr>
<th class="border-bottom-0 w-25" scope="col">'.$L->g('Name').'</th>
<th class="border-bottom-0" scope="col">'.$L->g('Description').'</th>
<th class="text-center border-bottom-0 d-none d-lg-table-cell" scope="col">'.$L->g('Version').'</th>
<th class="text-center border-bottom-0 d-none d-lg-table-cell" scope="col">'.$L->g('Author').'</th>
</tr>
</thead>
<tbody>
';
foreach ($plugins['all'] as $Plugin) {
echo '<tr id="'.$Plugin->className().'" '.($Plugin->installed()?'class="plugin-installed"':'class="plugin-notInstalled"').'>
<td>
<div class="plugin-name">'.$Plugin->name().'</div>
<div class="plugin-links">';
foreach ($plugins['all'] as $plugin) {
echo '<tr id="'.$plugin->className().'" '.($plugin->installed()?'class="bg-light"':'').'>
if ($Plugin->installed()) {
if (method_exists($Plugin, 'form')) {
echo '<a class="configure" href="'.HTML_PATH_ADMIN_ROOT.'configure-plugin/'.$Plugin->className().'">'.$L->g('Settings').'</a>';
echo '<span class="separator"> | </span>';
<td class="align-middle pt-3 pb-3">
<div>'.$plugin->name().'</div>
<div class="mt-1">';
if ($plugin->installed()) {
if (method_exists($plugin, 'form')) {
echo '<a class="mr-3" href="'.HTML_PATH_ADMIN_ROOT.'configure-plugin/'.$plugin->className().'">'.$L->g('Settings').'</a>';
}
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'uninstall-plugin/'.$plugin->className().'">'.$L->g('Deactivate').'</a>';
} else {
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'install-plugin/'.$plugin->className().'">'.$L->g('Activate').'</a>';
}
echo '<a class="uninstall" href="'.HTML_PATH_ADMIN_ROOT.'uninstall-plugin/'.$Plugin->className().'">'.$L->g('Deactivate').'</a>';
} else {
echo '<a class="install" href="'.HTML_PATH_ADMIN_ROOT.'install-plugin/'.$Plugin->className().'">'.$L->g('Activate').'</a>';
}
echo '</div>';
echo '</div>';
echo '</td>';
echo '<td>';
echo $Plugin->description();
echo '<td class="align-middle">';
echo $plugin->description();
echo '</td>';
echo '<td class="uk-text-center">';
// if( !$Plugin->isCompatible() ) {
// echo '<i class="uk-icon-exclamation-triangle incompatible-warning" title="'.$L->g('This plugin may not be supported by this version of Bludit').'"></i>';
// }
echo '<span>'.$Plugin->version().'</span>';
echo '<td class="text-center align-middle d-none d-lg-table-cell">';
echo '<span>'.$plugin->version().'</span>';
echo '</td>';
echo '<td class="uk-text-center"><a target="_blank" href="'.$Plugin->website().'">'.$Plugin->author().'</a></td>';
echo '<td class="text-center align-middle d-none d-lg-table-cell">
<a target="_blank" href="'.$plugin->website().'">'.$plugin->author().'</a>
</td>';
echo '</tr>';
}
echo '
</tbody>
</tbody>
</table>
';

View File

@ -19,15 +19,18 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
<a class="nav-link" id="language-tab" data-toggle="tab" href="#language" role="tab" aria-controls="language" aria-selected="false">Language</a>
</li>
</ul>
<form class="tab-content mt-4" id="dynamicTabContent">
<?php
echo Bootstrap::formOpen(array(
'id'=>'dynamicTabContent',
'class'=>'tab-content mt-4',
));
<?php
// Token CSRF
echo Bootstrap::formInputHidden(array(
'name'=>'tokenCSRF',
'value'=>$Security->getTokenCSRF()
));
?>
// Token CSRF
echo Bootstrap::formInputHidden(array(
'name'=>'tokenCSRF',
'value'=>$Security->getTokenCSRF()
));
?>
<!-- TABS GENERAL -->
<div class="tab-pane show active" id="general" role="tabpanel" aria-labelledby="general-tab">
@ -67,6 +70,13 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
'placeholder'=>'',
'tip'=>$L->g('you-can-add-a-small-text-on-the-bottom')
));
echo '
<div class="form-group mt-4">
<button type="submit" class="btn btn-primary mr-2" name="save">'.$L->g('Save').'</button>
<a class="btn btn-secondary" href="'.HTML_PATH_ADMIN_ROOT.'dashboard" role="button">'.$L->g('Cancel').'</a>
</div>
';
?>
</div>
@ -129,7 +139,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array(
'name'=>'url',
'label'=>'',
'label'=>'URL',
'value'=>$Site->url(),
'class'=>'',
'placeholder'=>'',
@ -137,13 +147,15 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
'placeholder'=>'https://'
));
echo Bootstrap::formTitle(array('title'=>$L->g('Extreme friendly URL')));
echo Bootstrap::formSelect(array(
'name'=>'extremeFriendly',
'label'=>$L->g('Extreme Friendly URL'),
'label'=>'Allow Unicode',
'options'=>array('true'=>'Enabled', 'false'=>'Disable'),
'selected'=>$Site->extremeFriendly(),
'class'=>'',
'tip'=>'Is on, allow unicode characters in the URL and some part of the system'
'tip'=>'Allow unicode characters in the URL and some part of the system.'
));
echo Bootstrap::formTitle(array('title'=>$L->g('URL Filters')));
@ -184,6 +196,13 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
'tip'=>DOMAIN.$Site->uriFilters('blog'),
'disabled'=>!$Site->uriFilters('blog')
));
echo '
<div class="form-group mt-4">
<button type="submit" class="btn btn-primary mr-2" name="save">'.$L->g('Save').'</button>
<a class="btn btn-secondary" href="'.HTML_PATH_ADMIN_ROOT.'dashboard" role="button">'.$L->g('Cancel').'</a>
</div>
';
?>
</div>
@ -252,11 +271,66 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
'placeholder'=>'',
'tip'=>''
));
echo '
<div class="form-group mt-4">
<button type="submit" class="btn btn-primary mr-2" name="save">'.$L->g('Save').'</button>
<a class="btn btn-secondary" href="'.HTML_PATH_ADMIN_ROOT.'dashboard" role="button">'.$L->g('Cancel').'</a>
</div>
';
?>
</div>
<!-- TABS TIMEZONE AND LANGUAGES -->
<div class="tab-pane" id="language" role="tabpanel" aria-labelledby="language-tab">
<?php
echo Bootstrap::formSelect(array(
'name'=>'language',
'label'=>$L->g('Language'),
'options'=>$Language->getLanguageList(),
'selected'=>$Site->language(),
'class'=>'',
'tip'=>$L->g('select-your-sites-language')
));
echo Bootstrap::formSelect(array(
'name'=>'timezone',
'label'=>$L->g('Timezone'),
'options'=>Date::timezoneList(),
'selected'=>$Site->timezone(),
'class'=>'',
'tip'=>$L->g('select-a-timezone-for-a-correct')
));
echo Bootstrap::formInputText(array(
'name'=>'locale',
'label'=>$L->g('Locale'),
'value'=>$Site->locale(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('with-the-locales-you-can-set-the-regional-user-interface')
));
echo Bootstrap::formTitle(array('title'=>$L->g('Date and time formats')));
echo Bootstrap::formInputText(array(
'name'=>'dateFormat',
'label'=>$L->g('Date format'),
'value'=>$Site->dateFormat(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('Current format').': '.Date::current($Site->dateFormat())
));
echo '
<div class="form-group mt-4">
<button type="submit" class="btn btn-primary mr-2" name="save">'.$L->g('Save').'</button>
<a class="btn btn-secondary" href="'.HTML_PATH_ADMIN_ROOT.'dashboard" role="button">'.$L->g('Cancel').'</a>
</div>
';
?>
</div>
</form>
<?php
echo Bootstrap::formClose();
?>

View File

@ -1,54 +1,53 @@
<?php
HTML::title(array('title'=>$L->g('Themes'), 'icon'=>'paint-brush'));
echo Bootstrap::pageTitle(array('title'=>$L->g('Themes'), 'icon'=>'puzzle-piece'));
echo '
<table class="uk-table">
<thead>
<tr>
<th class="uk-width-1-5">'.$L->g('Name').'</th>
<th class="uk-width-3-5">'.$L->g('Description').'</th>
<th class="uk-text-center">'.$L->g('Version').'</th>
<th class="uk-text-center">'.$L->g('Author').'</th>
</tr>
</thead>
<tbody>
<table class="table mt-3">
<thead>
<tr>
<th class="border-bottom-0 w-25" scope="col">'.$L->g('Name').'</th>
<th class="border-bottom-0" scope="col">'.$L->g('Description').'</th>
<th class="text-center border-bottom-0 d-none d-lg-table-cell" scope="col">'.$L->g('Version').'</th>
<th class="text-center border-bottom-0 d-none d-lg-table-cell" scope="col">'.$L->g('Author').'</th>
</tr>
</thead>
<tbody>
';
foreach($themes as $theme)
{
foreach ($themes as $theme) {
echo '
<tr '.($theme['dirname']==$Site->theme()?'class="theme-installed"':'class="theme-notInstalled"').'>
<td>
<div class="plugin-name">'.$theme['name'].'</div>
<div class="plugin-links">
<tr '.($theme['dirname']==$Site->theme()?'class="bg-light"':'').'>
<td class="align-middle pt-3 pb-3">
<div>'.$theme['name'].'</div>
<div class="mt-1">
';
if($theme['dirname']!=$Site->theme()) {
echo '<a class="install" href="'.HTML_PATH_ADMIN_ROOT.'install-theme/'.$theme['dirname'].'">'.$L->g('Activate').'</a>';
if ($theme['dirname']!=$Site->theme()) {
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'install-theme/'.$theme['dirname'].'">'.$L->g('Activate').'</a>';
}
echo '
</div>
</td>';
</div>
</td>
';
echo '<td>';
echo '<td class="align-middle">';
echo $theme['description'];
echo '</td>';
echo '<td class="uk-text-center">';
// if( !$theme['compatible'] ) {
// echo '<i class="uk-icon-exclamation-triangle incompatible-warning" title="'.$L->g('This theme may not be supported by this version of Bludit').'"></i>';
// }
echo $theme['version'];
echo '<td class="text-center align-middle d-none d-lg-table-cell">';
echo '<span>'.$theme['version'].'</span>';
echo '</td>';
echo '<td class="uk-text-center"><a targe="_blank" href="'.$theme['website'].'">'.$theme['author'].'</a></td>';
echo '<td class="text-center align-middle d-none d-lg-table-cell">
<a target="_blank" href="'.$theme['website'].'">'.$theme['author'].'</a>
</td>';
echo '</tr>';
}
echo '
</tbody>
</tbody>
</table>
';

View File

@ -13,12 +13,12 @@ echo '
<thead>
<tr>
<th class="border-bottom-0" scope="col">'.$L->g('Username').'</th>
<th class="border-bottom-0" scope="col">'.$L->g('First name').'</th>
<th class="border-bottom-0" scope="col">'.$L->g('Last name').'</th>
<th class="border-bottom-0 d-none d-lg-table-cell" scope="col">'.$L->g('First name').'</th>
<th class="border-bottom-0 d-none d-lg-table-cell" scope="col">'.$L->g('Last name').'</th>
<th class="border-bottom-0" scope="col">'.$L->g('Email').'</th>
<th class="border-bottom-0" scope="col">'.$L->g('Status').'</th>
<th class="border-bottom-0" scope="col">'.$L->g('Role').'</th>
<th class="border-bottom-0" scope="col">'.$L->g('Registered').'</th>
<th class="border-bottom-0 d-none d-lg-table-cell" scope="col">'.$L->g('Registered').'</th>
</tr>
</thead>
<tbody>
@ -28,12 +28,12 @@ $users = $dbUsers->getAllUsers();
foreach ($users as $username=>$User) {
echo '<tr>';
echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-user/'.$username.'">'.$username.'</a></td>';
echo '<td>'.$User->firstName().'</td>';
echo '<td>'.$User->lastName().'</td>';
echo '<td class="d-none d-lg-table-cell">'.$User->firstName().'</td>';
echo '<td class="d-none d-lg-table-cell">'.$User->lastName().'</td>';
echo '<td>'.$User->email().'</td>';
echo '<td class="uk-text-center">'.($User->enabled()?'<b>'.$L->g('Enabled').'</b>':$L->g('Disabled')).'</td>';
echo '<td class="uk-text-center">'.($User->role()=='admin'?$L->g('Administrator'):$L->g('Editor')).'</td>';
echo '<td class="uk-text-center">'.Date::format($User->registered(), DB_DATE_FORMAT, ADMIN_PANEL_DATE_FORMAT).'</td>';
echo '<td>'.($User->enabled()?'<b>'.$L->g('Enabled').'</b>':$L->g('Disabled')).'</td>';
echo '<td>'.($User->role()=='admin'?$L->g('Administrator'):$L->g('Editor')).'</td>';
echo '<td class="d-none d-lg-table-cell">'.Date::format($User->registered(), DB_DATE_FORMAT, ADMIN_PANEL_DATE_FORMAT).'</td>';
echo '</tr>';
}

View File

@ -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');
}
}
}

View File

@ -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;
}

View File

@ -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',

View File

@ -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()
{