bug fixes
This commit is contained in:
parent
139dfee1ec
commit
efe9b742c7
|
@ -6,62 +6,13 @@
|
||||||
|
|
||||||
if($Login->role()!=='admin') {
|
if($Login->role()!=='admin') {
|
||||||
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
||||||
Redirect::page('admin', 'dashboard');
|
Redirect::page('dashboard');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Functions
|
// Functions
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
function edit($oldCategoryKey, $newCategory)
|
|
||||||
{
|
|
||||||
global $Language;
|
|
||||||
global $dbPages;
|
|
||||||
global $dbCategories;
|
|
||||||
|
|
||||||
if( Text::isEmpty($oldCategoryKey) || Text::isEmpty($newCategory) ) {
|
|
||||||
Alert::set($Language->g('Empty fields'));
|
|
||||||
Redirect::page('categories');
|
|
||||||
}
|
|
||||||
|
|
||||||
if( $dbCategories->edit($oldCategoryKey, $newCategory) == false ) {
|
|
||||||
Alert::set($Language->g('Already exist a category'));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$dbPages->changeCategory($oldCategoryKey, $newCategory);
|
|
||||||
Alert::set($Language->g('The changes have been saved'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add to syslog
|
|
||||||
$Syslog->add(array(
|
|
||||||
'dictionaryKey'=>'category-edited',
|
|
||||||
'notes'=>$newCategory
|
|
||||||
));
|
|
||||||
|
|
||||||
Redirect::page('categories');
|
|
||||||
}
|
|
||||||
|
|
||||||
function delete($categoryKey)
|
|
||||||
{
|
|
||||||
global $Language;
|
|
||||||
global $dbCategories;
|
|
||||||
|
|
||||||
// Remove the category by key
|
|
||||||
$dbCategories->remove($categoryKey);
|
|
||||||
|
|
||||||
// Add to syslog
|
|
||||||
$Syslog->add(array(
|
|
||||||
'dictionaryKey'=>'category-deleted',
|
|
||||||
'notes'=>$categoryKey
|
|
||||||
));
|
|
||||||
|
|
||||||
// Create an alert
|
|
||||||
Alert::set($Language->g('The changes have been saved'));
|
|
||||||
|
|
||||||
// Redirect
|
|
||||||
Redirect::page('categories');
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Main before POST
|
// Main before POST
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
@ -70,14 +21,16 @@ function delete($categoryKey)
|
||||||
// POST Method
|
// POST Method
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
if ($_SERVER['REQUEST_METHOD']=='POST') {
|
||||||
{
|
|
||||||
if( isset($_POST['delete']) ) {
|
if (isset($_POST['delete'])) {
|
||||||
delete($_POST['categoryKey']);
|
deleteCategory($_POST['categoryKey']);
|
||||||
}
|
}
|
||||||
elseif( isset($_POST['edit']) ) {
|
elseif (isset($_POST['edit'])) {
|
||||||
edit($_POST['categoryKey'], $_POST['category']);
|
editCategory($_POST['categoryKey'], $_POST['category']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Redirect::page('categories');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
|
@ -111,7 +111,7 @@ define('CLI_STATUS', 'published');
|
||||||
define('CLI_USERNAME', 'admin');
|
define('CLI_USERNAME', 'admin');
|
||||||
|
|
||||||
// Filename
|
// Filename
|
||||||
define('FILENAME', 'index.md');
|
define('FILENAME', 'index.txt');
|
||||||
|
|
||||||
// Database date format
|
// Database date format
|
||||||
define('DB_DATE_FORMAT', 'Y-m-d H:i:s');
|
define('DB_DATE_FORMAT', 'Y-m-d H:i:s');
|
||||||
|
|
|
@ -101,7 +101,7 @@ class dbUsers extends dbJSON
|
||||||
|
|
||||||
public function getUser($username)
|
public function getUser($username)
|
||||||
{
|
{
|
||||||
if($this->exists($username)) {
|
if ($this->exists($username)) {
|
||||||
$User = new User();
|
$User = new User();
|
||||||
$User->setField('username', $username);
|
$User->setField('username', $username);
|
||||||
|
|
||||||
|
|
|
@ -10,20 +10,20 @@ function buildPage($key) {
|
||||||
|
|
||||||
// Page object, content from index.txt file
|
// Page object, content from index.txt file
|
||||||
$page = new Page($key);
|
$page = new Page($key);
|
||||||
if( !$page->isValid() ) {
|
if (!$page->isValid()) {
|
||||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying build the page from file with key: '.$key);
|
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying build the page from file with key: '.$key);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the database from dbPages
|
// Get the database from dbPages
|
||||||
$db = $dbPages->getPageDB($key);
|
$db = $dbPages->getPageDB($key);
|
||||||
if( !$db ) {
|
if (!$db) {
|
||||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying build the page from database with key: '.$key);
|
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying build the page from database with key: '.$key);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Foreach field from database set on the object
|
// Foreach field from database set on the object
|
||||||
foreach($db as $field=>$value) {
|
foreach ($db as $field=>$value) {
|
||||||
$page->setField($field, $value);
|
$page->setField($field, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,4 +497,48 @@ function editSettings($args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function editCategory($oldCategoryKey, $newCategory) {
|
||||||
|
global $Language;
|
||||||
|
global $dbPages;
|
||||||
|
global $dbCategories;
|
||||||
|
global $Syslog;
|
||||||
|
|
||||||
|
if( Text::isEmpty($oldCategoryKey) || Text::isEmpty($newCategory) ) {
|
||||||
|
Alert::set($Language->g('Empty fields'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( $dbCategories->edit($oldCategoryKey, $newCategory) == false ) {
|
||||||
|
Alert::set($Language->g('Already exist a category'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$dbPages->changeCategory($oldCategoryKey, $newCategory);
|
||||||
|
|
||||||
|
$Syslog->add(array(
|
||||||
|
'dictionaryKey'=>'category-edited',
|
||||||
|
'notes'=>$newCategory
|
||||||
|
));
|
||||||
|
|
||||||
|
Alert::set($Language->g('The changes have been saved'));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteCategory($categoryKey) {
|
||||||
|
global $Language;
|
||||||
|
global $dbCategories;
|
||||||
|
global $Syslog;
|
||||||
|
|
||||||
|
// Remove the category by key
|
||||||
|
$dbCategories->remove($categoryKey);
|
||||||
|
|
||||||
|
$Syslog->add(array(
|
||||||
|
'dictionaryKey'=>'category-deleted',
|
||||||
|
'notes'=>$categoryKey
|
||||||
|
));
|
||||||
|
|
||||||
|
Alert::set($Language->g('The changes have been saved'));
|
||||||
|
return true;
|
||||||
}
|
}
|
|
@ -15,8 +15,10 @@
|
||||||
<nav class="links">
|
<nav class="links">
|
||||||
<ul>
|
<ul>
|
||||||
<?php
|
<?php
|
||||||
// Print all pages parents
|
$fixedPages = $dbPages->getFixedDB();
|
||||||
foreach($pagesByParent[PARENT] as $pageParent) {
|
$keys = array_keys($fixedPages);
|
||||||
|
foreach($keys as $pageKey) {
|
||||||
|
$pageParent = buildPage($pageKey);
|
||||||
echo '<li><a href="'.$pageParent->permalink().'">'.$pageParent->title().'</a></li>';
|
echo '<li><a href="'.$pageParent->permalink().'">'.$pageParent->title().'</a></li>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -36,7 +38,17 @@
|
||||||
<section>
|
<section>
|
||||||
<ul class="links">
|
<ul class="links">
|
||||||
<?php
|
<?php
|
||||||
foreach($pagesByParent[PARENT] as $pageParent) {
|
echo '<li>';
|
||||||
|
echo '<a href="'.$Site->url().'">
|
||||||
|
<h3>'.$Language->get('Home page').'</h3>
|
||||||
|
<p>'.$Site->description().'</p>
|
||||||
|
</a>';
|
||||||
|
echo '</li>';
|
||||||
|
|
||||||
|
$fixedPages = $dbPages->getFixedDB();
|
||||||
|
$keys = array_keys($fixedPages);
|
||||||
|
foreach($keys as $pageKey) {
|
||||||
|
$pageParent = buildPage($pageKey);
|
||||||
echo '<li>';
|
echo '<li>';
|
||||||
echo '<a href="'.$pageParent->permalink().'">
|
echo '<a href="'.$pageParent->permalink().'">
|
||||||
<h3>'.$pageParent->title().'</h3>
|
<h3>'.$pageParent->title().'</h3>
|
||||||
|
|
Loading…
Reference in New Issue