Changes on admin panel, move some files, renew html

This commit is contained in:
Diego Najar 2018-04-22 17:45:31 +02:00
parent e8a5869405
commit ab1d795259
20 changed files with 506 additions and 253 deletions

View File

@ -79,7 +79,7 @@ class dbList extends dbJSON
} }
if (isset($this->db[$key])) { if (isset($this->db[$key])) {
Log::set(__METHOD__.LOG_SEP.'Error key already exist: '.$key); Log::set(__METHOD__.LOG_SEP.'Error key already exists: '.$key);
return false; return false;
} }
@ -111,7 +111,27 @@ class dbList extends dbJSON
$this->db[$newKey]['list'] = $this->db[$oldKey]['list']; $this->db[$newKey]['list'] = $this->db[$oldKey]['list'];
// Remove the old key // Remove the old key
if( $oldKey != $newKey ) { 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);
return false;
}
$this->db[$newKey]['name'] = $this->db[$oldKey]['name'];
$this->db[$newKey]['list'] = $this->db[$oldKey]['list'];
// Remove the old key
if ($oldKey!=$newKey) {
unset( $this->db[$oldKey] ); unset( $this->db[$oldKey] );
} }

View File

@ -15,15 +15,8 @@ if ($Login->role()!=='admin') {
// This function is used on the VIEW to show the tables // This function is used on the VIEW to show the tables
function printTable($title, $array) { function printTable($title, $array) {
echo '<h2>'.$title.'</h2>'; echo '<h2 class="mb-2 mt-4">'.$title.'</h2>';
echo ' echo '<table class="table table-striped mt-3">
<table class="uk-table uk-table-striped">
<thead>
<tr>
<th class="uk-width-1-5"></th>
<th class="uk-width-3-5"></th>
</tr>
</thead>
<tbody> <tbody>
'; ';

View File

@ -23,10 +23,9 @@ if ($Login->role()!=='admin') {
if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['delete'])) { if (isset($_POST['delete'])) {
deleteCategory($_POST['categoryKey']); deleteCategory($_POST);
} } elseif (isset($_POST['edit'])) {
elseif (isset($_POST['edit'])) { editCategory($_POST);
editCategory($_POST['categoryKey'], $_POST['category']);
} }
Redirect::page('categories'); Redirect::page('categories');
@ -42,7 +41,7 @@ if (!$dbCategories->exists($categoryKey)) {
Redirect::page('categories'); Redirect::page('categories');
} }
$category = $dbCategories->getName($layout['parameters']); $categoryName = $dbCategories->getName($layout['parameters']);
// Title of the page // Title of the page
$layout['title'] .= ' - '.$Language->g('Edit Category').' - '.$category; $layout['title'] .= ' - '.$Language->g('Edit Category').' - '.$categoryName;

View File

@ -22,8 +22,9 @@ if ($Login->role()!=='admin') {
// ============================================================================ // ============================================================================
if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($_SERVER['REQUEST_METHOD'] == 'POST') {
createCategory($_POST['category']); if (createCategory($_POST['category'])) {
Redirect::page('categories'); Redirect::page('categories');
}
} }
// ============================================================================ // ============================================================================

View File

@ -7,7 +7,7 @@
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<a class="navbar-brand" href="#"> <a class="navbar-brand" href="#">
<img src="img/logo.svg" width="30" height="30" class="d-inline-block align-top" alt=""> Bludit <img src="<?php echo HTML_PATH_ADMIN_THEME ?>img/logo.svg" width="30" height="30" class="d-inline-block align-top" alt=""> Bludit
</a> </a>
</nav> </nav>
</div> </div>

View File

@ -48,6 +48,34 @@ class Bootstrap {
return '<h2 class="mt-0 mb-3"><span class="oi oi-'.$args['icon'].'" style="font-size: 0.7em;"></span> '.$args['title'].'</h2>'; return '<h2 class="mt-0 mb-3"><span class="oi oi-'.$args['icon'].'" style="font-size: 0.7em;"></span> '.$args['title'].'</h2>';
} }
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'].'" ';
$html = '<form class="'.$class.'" '.$enctype.$id.' method="post" action="" autocomplete="off">';
return $html;
}
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;
}
public static function formTitle($args) public static function formTitle($args)
{ {
return '<h4 class="mt-4 mb-3">'.$args['title'].'</h4>'; return '<h4 class="mt-4 mb-3">'.$args['title'].'</h4>';
@ -71,7 +99,7 @@ class Bootstrap {
$html .= '<label for="'.$id.'">'.$args['label'].'</label>'; $html .= '<label for="'.$id.'">'.$args['label'].'</label>';
} }
$html .= '<input type="text" class="'.$class.'" id="'.$id.'" name="'.$args['name'].'" placeholder="'.$args['placeholder'].'">'; $html .= '<input type="text" value="'.$args['value'].'" class="'.$class.'" id="'.$id.'" name="'.$args['name'].'" placeholder="'.$args['placeholder'].'">';
if (isset($args['tip'])) { if (isset($args['tip'])) {
$html .= '<small class="form-text text-muted">'.$args['tip'].'</small>'; $html .= '<small class="form-text text-muted">'.$args['tip'].'</small>';
@ -131,6 +159,33 @@ class Bootstrap {
return $html; return $html;
} }
public static function formInputGroupText($args)
{
$label = $args['label'];
$labelInside = $args['labelInside'];
$tip = $args['tip'];
$value = $args['value'];
$name = $args['name'];
$id = 'js'.$name;
if (isset($args['id'])) {
$id = $args['id'];
}
$disabled = isset($args['disabled'])?'disabled':'';
return <<<EOF
<div class="form-group">
<label for="$id">$label</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text" id="$id">$labelInside</span>
</div>
<input id="$id" name="$name" value="$value" type="text" class="form-control" $disabled>
</div>
<small class="form-text text-muted">$tip</small>
</div>
EOF;
}
public static function formInputText($args) public static function formInputText($args)
{ {
$id = 'js'.$args['name']; $id = 'js'.$args['name'];

View File

@ -1,42 +1,37 @@
<?php <?php
HTML::title(array('title'=>$L->g('About'), 'icon'=>'support')); echo Bootstrap::pageTitle(array('title'=>$L->g('About'), 'icon'=>'person'));
echo ' echo '
<table class="uk-table uk-table-striped"> <table class="table table-striped mt-3">
<thead> <tbody>
<tr>
<th class="uk-width-1-5"></th>
<th class="uk-width-3-5"></th>
</tr>
</thead>
<tbody>
'; ';
echo '<tr>';
echo '<td>Bludit Edition</td>';
if (defined('BLUDIT_PRO')) {
echo '<td>PRO - '.$L->g('Thanks for support Bludit').'</td>';
} else {
echo '<td>Standard - <a target="_blank" href="https://pro.bludit.com">'.$L->g('Upgrade to Bludit PRO').'</a></td>';
}
echo '</tr>';
echo '<tr>'; echo '<tr>';
echo '<td>Bludit Version</td>'; echo '<td>Bludit Edition</td>';
echo '<td>'.BLUDIT_VERSION.'</td>'; if (defined('BLUDIT_PRO')) {
echo '</tr>'; echo '<td>PRO - '.$L->g('Thanks for support Bludit').'</td>';
} else {
echo '<td>Standard - <a target="_blank" href="https://pro.bludit.com">'.$L->g('Upgrade to Bludit PRO').'</a></td>';
}
echo '</tr>';
echo '<tr>'; echo '<tr>';
echo '<td>Bludit Codename</td>'; echo '<td>Bludit Version</td>';
echo '<td>'.BLUDIT_CODENAME.'</td>'; echo '<td>'.BLUDIT_VERSION.'</td>';
echo '</tr>'; echo '</tr>';
echo '<tr>'; echo '<tr>';
echo '<td>Bludit Build Number</td>'; echo '<td>Bludit Codename</td>';
echo '<td>'.BLUDIT_BUILD.'</td>'; echo '<td>'.BLUDIT_CODENAME.'</td>';
echo '</tr>'; echo '</tr>';
echo '<tr>';
echo '<td>Bludit Build Number</td>';
echo '<td>'.BLUDIT_BUILD.'</td>';
echo '</tr>';
echo ' echo '
</tbody> </tbody>
</table> </table>
'; ';

View File

@ -1,4 +1,4 @@
<?php <?php defined('BLUDIT') or die('Bludit CMS.');
echo Bootstrap::pageTitle(array('title'=>$L->g('Categories'), 'icon'=>'grid-three-up')); echo Bootstrap::pageTitle(array('title'=>$L->g('Categories'), 'icon'=>'grid-three-up'));

View File

@ -1,8 +1,8 @@
<?php <?php
HTML::title(array('title'=>$L->g('Developers'), 'icon'=>'support')); echo Bootstrap::pageTitle(array('title'=>$L->g('Developers'), 'icon'=>'beaker'));
echo '<h2>PHP version: '.phpversion().'</h2>'; echo '<h2 class="mb-4 mt-4"><b>PHP version: '.phpversion().'</b></h2>';
// PHP Ini // PHP Ini
$uploadOptions = array( $uploadOptions = array(

View File

@ -1,32 +1,49 @@
<?php <?php defined('BLUDIT') or die('Bludit CMS.');
HTML::title(array('title'=>$L->g('Edit Category'), 'icon'=>'globe')); echo Bootstrap::pageTitle(array('title'=>$L->g('Edit Category'), 'icon'=>'grid-three-up'));
HTML::formOpen(array('class'=>'uk-form-horizontal')); echo Bootstrap::formOpen(array());
HTML::formInputHidden(array( echo Bootstrap::formInputHidden(array(
'name'=>'tokenCSRF', 'name'=>'tokenCSRF',
'value'=>$Security->getTokenCSRF() 'value'=>$Security->getTokenCSRF()
)); ));
HTML::formInputHidden(array( echo Bootstrap::formInputHidden(array(
'name'=>'categoryKey', 'name'=>'oldCategoryName',
'value'=>$categoryName
));
echo Bootstrap::formInputHidden(array(
'name'=>'oldCategoryKey',
'value'=>$categoryKey 'value'=>$categoryKey
)); ));
HTML::formInputText(array( echo Bootstrap::formInputTextBlock(array(
'name'=>'category', 'name'=>'categoryName',
'label'=>$L->g('Name'), 'label'=>$L->g('Category name'),
'value'=>$category, 'value'=>$categoryName,
'class'=>'uk-width-1-2 uk-form-medium' 'class'=>'',
'placeholder'=>'',
'tip'=>''
)); ));
echo '<div class="uk-form-row"> echo Bootstrap::formInputGroupText(array(
<div class="uk-form-controls"> 'name'=>'categoryKey',
<button type="submit" name="edit" class="uk-button uk-button-primary">'.$L->g('Save').'</button> 'label'=>$L->g('Category key'),
<button type="submit" name="delete" class="uk-button uk-button-primary">'.$L->g('Delete').'</button> 'labelInside'=>DOMAIN_CATEGORIES,
<a href="'.HTML_PATH_ADMIN_ROOT.'categories" class="uk-button">'.$L->g('Cancel').'</a> 'value'=>$categoryKey,
</div> 'class'=>'',
</div>'; 'placeholder'=>'',
'tip'=>''
));
HTML::formClose(); echo '
<div class="form-group mt-4">
<button type="submit" class="btn btn-primary mr-2" name="edit">'.$L->g('Save').'</button>
<button type="submit" class="btn btn-secondary mr-2" name="delete">'.$L->g('Delete').'</button>
<a class="btn btn-secondary" href="'.HTML_PATH_ADMIN_ROOT.'categories" role="button">'.$L->g('Cancel').'</a>
</div>
';
echo Bootstrap::formClose();

View File

@ -1,26 +1,28 @@
<?php <?php defined('BLUDIT') or die('Bludit CMS.');
HTML::title(array('title'=>$L->g('New Category'), 'icon'=>'tag')); echo Bootstrap::pageTitle(array('title'=>$L->g('New Category'), 'icon'=>'grid-three-up'));
HTML::formOpen(array('class'=>'uk-form-horizontal')); echo Bootstrap::formOpen(array());
HTML::formInputHidden(array( echo Bootstrap::formInputHidden(array(
'name'=>'tokenCSRF', 'name'=>'tokenCSRF',
'value'=>$Security->getTokenCSRF() 'value'=>$Security->getTokenCSRF()
)); ));
HTML::formInputText(array( echo Bootstrap::formInputTextBlock(array(
'name'=>'category', 'name'=>'category',
'label'=>$L->g('Name'), 'label'=>$L->g('Category name'),
'value'=>'', 'value'=>isset($_POST['category'])?$_POST['category']:'',
'class'=>'uk-width-1-2 uk-form-medium' 'class'=>'',
'placeholder'=>'',
'tip'=>''
)); ));
echo '<div class="uk-form-row"> echo '
<div class="uk-form-controls"> <div class="form-group mt-4">
<button type="submit" class="uk-button uk-button-primary">'.$L->g('Save').'</button> <button type="submit" class="btn btn-primary mr-2">Save</button>
<a href="'.HTML_PATH_ADMIN_ROOT.'categories" class="uk-button">'.$L->g('Cancel').'</a> <a class="btn btn-secondary" href="'.HTML_PATH_ADMIN_ROOT.'categories" role="button">Cancel</a>
</div> </div>
</div>'; ';
HTML::formClose(); echo Bootstrap::formClose();

View File

@ -1,112 +0,0 @@
<?php
HTML::title(array('title'=>$L->g('General settings'), 'icon'=>'cogs'));
HTML::formOpen(array('class'=>'uk-form-horizontal'));
// Security token
HTML::formInputHidden(array(
'name'=>'tokenCSRF',
'value'=>$Security->getTokenCSRF()
));
HTML::legend(array('value'=>$L->g('Site information'), 'class'=>'first-child'));
HTML::formInputText(array(
'name'=>'title',
'label'=>$L->g('Site title'),
'value'=>$Site->title(),
'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>$L->g('use-this-field-to-name-your-site')
));
HTML::formInputText(array(
'name'=>'slogan',
'label'=>$L->g('Site slogan'),
'value'=>$Site->slogan(),
'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>$L->g('use-this-field-to-add-a-catchy-phrase')
));
HTML::formInputText(array(
'name'=>'description',
'label'=>$L->g('Site description'),
'value'=>$Site->description(),
'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>$L->g('you-can-add-a-site-description-to-provide')
));
HTML::formInputText(array(
'name'=>'footer',
'label'=>$L->g('Footer text'),
'value'=>$Site->footer(),
'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>$L->g('you-can-add-a-small-text-on-the-bottom')
));
HTML::legend(array('value'=>$L->g('Social networks links')));
HTML::formInputText(array(
'name'=>'twitter',
'label'=>'Twitter',
'value'=>$Site->twitter(),
'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>''
));
HTML::formInputText(array(
'name'=>'facebook',
'label'=>'Facebook',
'value'=>$Site->facebook(),
'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>''
));
HTML::formInputText(array(
'name'=>'codepen',
'label'=>'Codepen',
'value'=>$Site->codepen(),
'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>''
));
HTML::formInputText(array(
'name'=>'googlePlus',
'label'=>'Google+',
'value'=>$Site->googlePlus(),
'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>''
));
HTML::formInputText(array(
'name'=>'instagram',
'label'=>'Instagram',
'value'=>$Site->instagram(),
'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>''
));
HTML::formInputText(array(
'name'=>'github',
'label'=>'Github',
'value'=>$Site->github(),
'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>''
));
HTML::formInputText(array(
'name'=>'linkedin',
'label'=>'Linkedin',
'value'=>$Site->linkedin(),
'class'=>'uk-width-1-2 uk-form-medium',
'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 class="uk-button" href="'.HTML_PATH_ADMIN_ROOT.'settings-general">'.$L->g('Cancel').'</a>
</div>
</div>';
HTML::formClose();

View File

@ -0,0 +1,262 @@
<?php
echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
?>
<!-- TABS -->
<ul class="nav nav-tabs" id="dynamicTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="general-tab" data-toggle="tab" href="#general" role="tab" aria-controls="general" aria-selected="true">General</a>
</li>
<li class="nav-item">
<a class="nav-link " id="advanced-tab" data-toggle="tab" href="#advanced" role="tab" aria-controls="advanced" aria-selected="false">Advanced</a>
</li>
<li class="nav-item">
<a class="nav-link " id="social-tab" data-toggle="tab" href="#social" role="tab" aria-controls="social" aria-selected="false">Social Networks</a>
</li>
<li class="nav-item">
<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
// 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">
<?php
echo Bootstrap::formInputText(array(
'name'=>'title',
'label'=>$L->g('Site title'),
'value'=>$Site->title(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('use-this-field-to-name-your-site')
));
echo Bootstrap::formInputText(array(
'name'=>'slogan',
'label'=>$L->g('Site slogan'),
'value'=>$Site->slogan(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('use-this-field-to-add-a-catchy-phrase')
));
echo Bootstrap::formInputText(array(
'name'=>'description',
'label'=>$L->g('Site description'),
'value'=>$Site->description(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('you-can-add-a-site-description-to-provide')
));
echo Bootstrap::formInputText(array(
'name'=>'footer',
'label'=>$L->g('Footer text'),
'value'=>$Site->footer(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('you-can-add-a-small-text-on-the-bottom')
));
?>
</div>
<!-- TABS ADVANCED -->
<div class="tab-pane" id="advanced" role="tabpanel" aria-labelledby="advanced-tab">
<?php
echo Bootstrap::formTitle(array('title'=>$L->g('Content')));
echo Bootstrap::formSelect(array(
'name'=>'itemsPerPage',
'label'=>$L->g('Items per page'),
'options'=>array('1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8', '-1'=>$L->g('All content')),
'selected'=>$Site->itemsPerPage(),
'class'=>'',
'tip'=>$L->g('Number of items to show per page')
));
echo Bootstrap::formSelect(array(
'name'=>'orderBy',
'label'=>$L->g('Order content by'),
'options'=>array('date'=>$L->g('Date'),'position'=>$L->g('Position')),
'selected'=>$Site->orderBy(),
'class'=>'',
'tip'=>$L->g('order-the-content-by-date-to-build-a-blog')
));
echo Bootstrap::formTitle(array('title'=>$L->g('Predefined pages')));
echo Bootstrap::formSelect(array(
'name'=>'homepage',
'label'=>$L->g('Homepage'),
'options'=>array(),//$homepageOptions,
'selected'=>$Site->homepage(),
'class'=>'',
'tip'=>$L->g('Returning page for the main page')
));
$homepageOptions[' '] = '- '.$L->g('Default message').' -';
echo Bootstrap::formSelect(array(
'name'=>'pageNotFound',
'label'=>$L->g('Page not found'),
'options'=>$homepageOptions,
'selected'=>$Site->pageNotFound(),
'class'=>'',
'tip'=>$L->g('Returning page when the page doesnt exist')
));
echo Bootstrap::formTitle(array('title'=>$L->g('Email account settings')));
echo Bootstrap::formInputText(array(
'name'=>'emailFrom',
'label'=>$L->g('Sender email'),
'value'=>$Site->emailFrom(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('Emails will be sent from this address')
));
echo Bootstrap::formTitle(array('title'=>$L->g('Site URL')));
echo Bootstrap::formInputText(array(
'name'=>'url',
'label'=>'',
'value'=>$Site->url(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('full-url-of-your-site'),
'placeholder'=>'https://'
));
echo Bootstrap::formSelect(array(
'name'=>'extremeFriendly',
'label'=>$L->g('Extreme Friendly URL'),
'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'
));
echo Bootstrap::formTitle(array('title'=>$L->g('URL Filters')));
echo Bootstrap::formInputText(array(
'name'=>'uriPage',
'label'=>$L->g('Pages'),
'value'=>$Site->uriFilters('page'),
'class'=>'',
'placeholder'=>'',
'tip'=>DOMAIN_PAGES
));
echo Bootstrap::formInputText(array(
'name'=>'uriTag',
'label'=>$L->g('Tags'),
'value'=>$Site->uriFilters('tag'),
'class'=>'',
'placeholder'=>'',
'tip'=>DOMAIN_TAGS
));
echo Bootstrap::formInputText(array(
'name'=>'uriCategory',
'label'=>$L->g('Category'),
'value'=>$Site->uriFilters('category'),
'class'=>'',
'placeholder'=>'',
'tip'=>DOMAIN_CATEGORIES
));
echo Bootstrap::formInputText(array(
'name'=>'uriBlog',
'label'=>$L->g('Blog'),
'value'=>$Site->uriFilters('blog'),
'class'=>'',
'placeholder'=>'',
'tip'=>DOMAIN.$Site->uriFilters('blog'),
'disabled'=>!$Site->uriFilters('blog')
));
?>
</div>
<!-- TABS SOCIAL NETWORKS -->
<div class="tab-pane" id="social" role="tabpanel" aria-labelledby="social-tab">
<?php
echo Bootstrap::formInputText(array(
'name'=>'twitter',
'label'=>'Twitter',
'value'=>$Site->twitter(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
echo Bootstrap::formInputText(array(
'name'=>'facebook',
'label'=>'Facebook',
'value'=>$Site->facebook(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
echo Bootstrap::formInputText(array(
'name'=>'codepen',
'label'=>'Codepen',
'value'=>$Site->codepen(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
echo Bootstrap::formInputText(array(
'name'=>'googlePlus',
'label'=>'Google+',
'value'=>$Site->googlePlus(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
echo Bootstrap::formInputText(array(
'name'=>'instagram',
'label'=>'Instagram',
'value'=>$Site->instagram(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
echo Bootstrap::formInputText(array(
'name'=>'github',
'label'=>'Github',
'value'=>$Site->github(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
echo Bootstrap::formInputText(array(
'name'=>'linkedin',
'label'=>'Linkedin',
'value'=>$Site->linkedin(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
?>
</div>
<!-- TABS TIMEZONE AND LANGUAGES -->
<div class="tab-pane" id="language" role="tabpanel" aria-labelledby="language-tab">
</div>
</form>

View File

@ -201,6 +201,9 @@ define('PAGE_URI_FILTER', $Url->filters('page'));
// Content order by: date / position // Content order by: date / position
define('ORDER_BY', $Site->orderBy()); define('ORDER_BY', $Site->orderBy());
// Allow unicode characters in the URL
define('EXTREME_FRIENDLY_URL', $Site->extremeFriendly());
// --- PHP paths with dependency --- // --- PHP paths with dependency ---
// This paths are absolutes for the OS // This paths are absolutes for the OS
define('THEME_DIR', PATH_ROOT.'bl-themes'.DS.$Site->theme().DS); define('THEME_DIR', PATH_ROOT.'bl-themes'.DS.$Site->theme().DS);

View File

@ -86,9 +86,6 @@ define('TOKEN_EMAIL_TTL', '+15 minutes');
// Charset, default UTF-8. // Charset, default UTF-8.
define('CHARSET', 'UTF-8'); define('CHARSET', 'UTF-8');
// EXTREME FRIENDLY URL, TRUE for dissmiss internet standard. Experimental!
define('EXTREME_FRIENDLY_URL', FALSE);
// Permissions for new directories // Permissions for new directories
define('DIR_PERMISSIONS', 0755); define('DIR_PERMISSIONS', 0755);

View File

@ -763,16 +763,14 @@ class dbPages extends dbJSON
return $tmp; 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) public function changeCategory($oldCategoryKey, $newCategoryKey)
{ {
foreach($this->db as $key=>$value) { foreach ($this->db as $key=>$value) {
if($value['category']==$oldCategoryKey) { if ($value['category']===$oldCategoryKey) {
$this->db[$key]['category'] = $newCategoryKey; $this->db[$key]['category'] = $newCategoryKey;
} }
} }
// Save database
return $this->save(); return $this->save();
} }

View File

@ -31,7 +31,8 @@ class dbSite extends dbJSON
'instagram'=> array('inFile'=>false, 'value'=>''), 'instagram'=> array('inFile'=>false, 'value'=>''),
'github'=> array('inFile'=>false, 'value'=>''), 'github'=> array('inFile'=>false, 'value'=>''),
'linkedin'=> 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() function __construct()
@ -100,6 +101,11 @@ class dbSite extends dbJSON
return DOMAIN_BASE.'sitemap.xml'; return DOMAIN_BASE.'sitemap.xml';
} }
public function extremeFriendly()
{
return $this->getField('extremeFriendly');
}
public function twitter() public function twitter()
{ {
return $this->getField('twitter'); return $this->getField('twitter');

View File

@ -323,7 +323,7 @@ function pluginActivated($pluginClassName) {
function activatePlugin($pluginClassName) { function activatePlugin($pluginClassName) {
global $plugins; global $plugins;
global $Syslog; global $syslog;
global $Language; global $Language;
// Check if the plugin exists // Check if the plugin exists
@ -331,7 +331,7 @@ function activatePlugin($pluginClassName) {
$plugin = $plugins['all'][$pluginClassName]; $plugin = $plugins['all'][$pluginClassName];
if ($plugin->install()) { if ($plugin->install()) {
// Add to syslog // Add to syslog
$Syslog->add(array( $syslog->add(array(
'dictionaryKey'=>'plugin-activated', 'dictionaryKey'=>'plugin-activated',
'notes'=>$plugin->name() 'notes'=>$plugin->name()
)); ));
@ -346,7 +346,7 @@ function activatePlugin($pluginClassName) {
function deactivatePlugin($pluginClassName) { function deactivatePlugin($pluginClassName) {
global $plugins; global $plugins;
global $Syslog; global $syslog;
global $Language; global $Language;
// Check if the plugin exists // Check if the plugin exists
@ -355,7 +355,7 @@ function deactivatePlugin($pluginClassName) {
if ($plugin->uninstall()) { if ($plugin->uninstall()) {
// Add to syslog // Add to syslog
$Syslog->add(array( $syslog->add(array(
'dictionaryKey'=>'plugin-deactivated', 'dictionaryKey'=>'plugin-deactivated',
'notes'=>$plugin->name() 'notes'=>$plugin->name()
)); ));
@ -370,7 +370,7 @@ function deactivatePlugin($pluginClassName) {
function changePluginsPosition($pluginClassList) { function changePluginsPosition($pluginClassList) {
global $plugins; global $plugins;
global $Syslog; global $syslog;
global $Language; global $Language;
foreach ($pluginClassList as $position=>$pluginClassName) { foreach ($pluginClassList as $position=>$pluginClassName) {
@ -381,7 +381,7 @@ function changePluginsPosition($pluginClassList) {
} }
// Add to syslog // Add to syslog
$Syslog->add(array( $syslog->add(array(
'dictionaryKey'=>'plugins-sorted', 'dictionaryKey'=>'plugins-sorted',
'notes'=>'' 'notes'=>''
)); ));
@ -391,7 +391,7 @@ function changePluginsPosition($pluginClassList) {
function createPage($args) { function createPage($args) {
global $dbPages; global $dbPages;
global $Syslog; global $syslog;
global $Language; global $Language;
// The user is always the one loggued // The user is always the one loggued
@ -419,7 +419,7 @@ function createPage($args) {
reindextags(); reindextags();
// Add to syslog // Add to syslog
$Syslog->add(array( $syslog->add(array(
'dictionaryKey'=>'new-content-created', 'dictionaryKey'=>'new-content-created',
'notes'=>$args['title'] 'notes'=>$args['title']
)); ));
@ -439,7 +439,7 @@ function createPage($args) {
function editPage($args) { function editPage($args) {
global $dbPages; global $dbPages;
global $Syslog; global $syslog;
// Check the key is not empty // Check the key is not empty
if (empty($args['key'])) { if (empty($args['key'])) {
@ -482,7 +482,7 @@ function editPage($args) {
reindextags(); reindextags();
// Add to syslog // Add to syslog
$Syslog->add(array( $syslog->add(array(
'dictionaryKey'=>'content-edited', 'dictionaryKey'=>'content-edited',
'notes'=>$args['title'] 'notes'=>$args['title']
)); ));
@ -496,7 +496,7 @@ function editPage($args) {
function deletePage($key) { function deletePage($key) {
global $dbPages; global $dbPages;
global $Syslog; global $syslog;
if( $dbPages->delete($key) ) { if( $dbPages->delete($key) ) {
// Call the plugins after page deleted // Call the plugins after page deleted
@ -509,7 +509,7 @@ function deletePage($key) {
reindextags(); reindextags();
// Add to syslog // Add to syslog
$Syslog->add(array( $syslog->add(array(
'dictionaryKey'=>'content-deleted', 'dictionaryKey'=>'content-deleted',
'notes'=>$key 'notes'=>$key
)); ));
@ -523,7 +523,7 @@ function deletePage($key) {
function disableUser($username) { function disableUser($username) {
global $dbUsers; global $dbUsers;
global $Login; global $Login;
global $Syslog; global $syslog;
// The editors can't disable users // The editors can't disable users
if($Login->role()!=='admin') { if($Login->role()!=='admin') {
@ -532,7 +532,7 @@ function disableUser($username) {
if( $dbUsers->disableUser($username) ) { if( $dbUsers->disableUser($username) ) {
// Add to syslog // Add to syslog
$Syslog->add(array( $syslog->add(array(
'dictionaryKey'=>'user-disabled', 'dictionaryKey'=>'user-disabled',
'notes'=>$username 'notes'=>$username
)); ));
@ -545,11 +545,11 @@ function disableUser($username) {
function editUser($args) { function editUser($args) {
global $dbUsers; global $dbUsers;
global $Syslog; global $syslog;
if( $dbUsers->set($args) ) { if( $dbUsers->set($args) ) {
// Add to syslog // Add to syslog
$Syslog->add(array( $syslog->add(array(
'dictionaryKey'=>'user-edited', 'dictionaryKey'=>'user-edited',
'notes'=>$args['username'] 'notes'=>$args['username']
)); ));
@ -563,7 +563,7 @@ function editUser($args) {
function deleteUser($args, $deleteContent=false) { function deleteUser($args, $deleteContent=false) {
global $dbUsers; global $dbUsers;
global $Login; global $Login;
global $Syslog; global $syslog;
// The user admin cannot be deleted // The user admin cannot be deleted
if($args['username']=='admin') { if($args['username']=='admin') {
@ -584,7 +584,7 @@ function deleteUser($args, $deleteContent=false) {
if( $dbUsers->delete($args['username']) ) { if( $dbUsers->delete($args['username']) ) {
// Add to syslog // Add to syslog
$Syslog->add(array( $syslog->add(array(
'dictionaryKey'=>'user-deleted', 'dictionaryKey'=>'user-deleted',
'notes'=>$args['username'] 'notes'=>$args['username']
)); ));
@ -598,7 +598,7 @@ function deleteUser($args, $deleteContent=false) {
function createUser($args) { function createUser($args) {
global $dbUsers; global $dbUsers;
global $Language; global $Language;
global $Syslog; global $syslog;
// Check empty username // Check empty username
if( Text::isEmpty($args['new_username']) ) { if( Text::isEmpty($args['new_username']) ) {
@ -634,7 +634,7 @@ function createUser($args) {
// Add the user to the database // Add the user to the database
if( $dbUsers->add($tmp) ) { if( $dbUsers->add($tmp) ) {
// Add to syslog // Add to syslog
$Syslog->add(array( $syslog->add(array(
'dictionaryKey'=>'new-user-created', 'dictionaryKey'=>'new-user-created',
'notes'=>$tmp['username'] 'notes'=>$tmp['username']
)); ));
@ -647,7 +647,7 @@ function createUser($args) {
function editSettings($args) { function editSettings($args) {
global $Site; global $Site;
global $Syslog; global $syslog;
global $Language; global $Language;
global $dbPages; global $dbPages;
@ -692,7 +692,7 @@ function editSettings($args) {
} }
// Add syslog // Add syslog
$Syslog->add(array( $syslog->add(array(
'dictionaryKey'=>'changes-on-settings', 'dictionaryKey'=>'changes-on-settings',
'notes'=>'' 'notes'=>''
)); ));
@ -706,71 +706,80 @@ function editSettings($args) {
} }
// Add a new category to the system // Add a new category to the system
// Returns TRUE is success added, FALSE otherwise // Returns TRUE is successfully added, FALSE otherwise
function createCategory($category) { function createCategory($category) {
global $dbCategories; global $dbCategories;
global $Language; global $Language;
global $Syslog; global $syslog;
if (Text::isEmpty($category)) { if (Text::isEmpty($category)) {
// Set an alert
Alert::set($Language->g('Category name is empty'), ALERT_STATUS_FAIL); Alert::set($Language->g('Category name is empty'), ALERT_STATUS_FAIL);
return false; return false;
} }
if ($dbCategories->add($category)) { if ($dbCategories->add($category)) {
// Add to syslog $syslog->add(array(
$Syslog->add(array(
'dictionaryKey'=>'new-category-created', 'dictionaryKey'=>'new-category-created',
'notes'=>$category 'notes'=>$category
)); ));
// Set an alert
Alert::set($Language->g('Category added'), ALERT_STATUS_OK); Alert::set($Language->g('Category added'), ALERT_STATUS_OK);
return true; return true;
} }
Alert::set($Language->g('The category already exists'), ALERT_STATUS_FAIL);
return false; return false;
} }
function editCategory($oldCategoryKey, $newCategory) { function editCategory($args) {
global $Language; global $Language;
global $dbPages; global $dbPages;
global $dbCategories; 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')); Alert::set($Language->g('Empty fields'));
return false; return false;
} }
if( $dbCategories->edit($oldCategoryKey, $newCategory) == false ) { if ($args['oldCategoryKey']!==$args['categoryKey']) {
Alert::set($Language->g('Already exist a category')); // 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; 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', 'dictionaryKey'=>'category-edited',
'notes'=>$newCategory 'notes'=>$newCategoryKey
)); ));
Alert::set($Language->g('The changes have been saved')); Alert::set($Language->g('The changes have been saved'));
return true; return true;
} }
function deleteCategory($categoryKey) { function deleteCategory($args) {
global $Language; global $Language;
global $dbCategories; global $dbCategories;
global $Syslog; global $syslog;
// Remove the category by key // 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', 'dictionaryKey'=>'category-deleted',
'notes'=>$categoryKey 'notes'=>$args['oldCategoryKey']
)); ));
Alert::set($Language->g('The changes have been saved')); Alert::set($Language->g('The changes have been saved'));
@ -814,12 +823,12 @@ function getTags() {
function activateTheme($themeDirectory) { function activateTheme($themeDirectory) {
global $Site; global $Site;
global $Syslog; global $syslog;
if (Sanitize::pathFile(PATH_THEMES.$themeDirectory)) { if (Sanitize::pathFile(PATH_THEMES.$themeDirectory)) {
$Site->set(array('theme'=>$themeDirname)); $Site->set(array('theme'=>$themeDirname));
$Syslog->add(array( $syslog->add(array(
'dictionaryKey'=>'new-theme-configured', 'dictionaryKey'=>'new-theme-configured',
'notes'=>$themeDirname 'notes'=>$themeDirname
)); ));

View File

@ -121,7 +121,7 @@ class Text {
return str_replace(array_keys($replace), array_values($replace), $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 // Characters that cannot be converted will be removed from the string
// This function can return an empty string // This function can return an empty string
public static function cleanUrl($string, $separator='-') public static function cleanUrl($string, $separator='-')
@ -129,6 +129,8 @@ class Text {
global $Language; global $Language;
if (EXTREME_FRIENDLY_URL) { if (EXTREME_FRIENDLY_URL) {
$string = trim($string, '-');
$string = self::lowercase($string);
$string = preg_replace("/[\/_|+ -]+/", $separator, $string); $string = preg_replace("/[\/_|+ -]+/", $separator, $string);
return $string; return $string;
} }

View File

@ -222,6 +222,12 @@ class Page {
return $this->getValue('category'); return $this->getValue('category');
} }
// Returns the category permalink
public function categoryPermalink()
{
return DOMAIN_CATEGORIES.$this->categoryKey();
}
// Returns the field from the array // Returns the field from the array
// categoryMap = array( 'name'=>'', 'list'=>array() ) // categoryMap = array( 'name'=>'', 'list'=>array() )
public function categoryMap($field) public function categoryMap($field)