bug fixes
This commit is contained in:
parent
139dfee1ec
commit
efe9b742c7
@ -6,62 +6,13 @@
|
||||
|
||||
if($Login->role()!=='admin') {
|
||||
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
||||
Redirect::page('admin', 'dashboard');
|
||||
Redirect::page('dashboard');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// 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
|
||||
// ============================================================================
|
||||
@ -70,14 +21,16 @@ function delete($categoryKey)
|
||||
// POST Method
|
||||
// ============================================================================
|
||||
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
if( isset($_POST['delete']) ) {
|
||||
delete($_POST['categoryKey']);
|
||||
if ($_SERVER['REQUEST_METHOD']=='POST') {
|
||||
|
||||
if (isset($_POST['delete'])) {
|
||||
deleteCategory($_POST['categoryKey']);
|
||||
}
|
||||
elseif( isset($_POST['edit']) ) {
|
||||
edit($_POST['categoryKey'], $_POST['category']);
|
||||
elseif (isset($_POST['edit'])) {
|
||||
editCategory($_POST['categoryKey'], $_POST['category']);
|
||||
}
|
||||
|
||||
Redirect::page('categories');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
@ -111,7 +111,7 @@ define('CLI_STATUS', 'published');
|
||||
define('CLI_USERNAME', 'admin');
|
||||
|
||||
// Filename
|
||||
define('FILENAME', 'index.md');
|
||||
define('FILENAME', 'index.txt');
|
||||
|
||||
// Database date format
|
||||
define('DB_DATE_FORMAT', 'Y-m-d H:i:s');
|
||||
|
@ -101,7 +101,7 @@ class dbUsers extends dbJSON
|
||||
|
||||
public function getUser($username)
|
||||
{
|
||||
if($this->exists($username)) {
|
||||
if ($this->exists($username)) {
|
||||
$User = new User();
|
||||
$User->setField('username', $username);
|
||||
|
||||
|
@ -10,20 +10,20 @@ function buildPage($key) {
|
||||
|
||||
// Page object, content from index.txt file
|
||||
$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);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the database from dbPages
|
||||
$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);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Foreach field from database set on the object
|
||||
foreach($db as $field=>$value) {
|
||||
foreach ($db as $field=>$value) {
|
||||
$page->setField($field, $value);
|
||||
}
|
||||
|
||||
@ -497,4 +497,48 @@ function editSettings($args) {
|
||||
}
|
||||
|
||||
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">
|
||||
<ul>
|
||||
<?php
|
||||
// Print all pages parents
|
||||
foreach($pagesByParent[PARENT] as $pageParent) {
|
||||
$fixedPages = $dbPages->getFixedDB();
|
||||
$keys = array_keys($fixedPages);
|
||||
foreach($keys as $pageKey) {
|
||||
$pageParent = buildPage($pageKey);
|
||||
echo '<li><a href="'.$pageParent->permalink().'">'.$pageParent->title().'</a></li>';
|
||||
}
|
||||
?>
|
||||
@ -36,7 +38,17 @@
|
||||
<section>
|
||||
<ul class="links">
|
||||
<?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 '<a href="'.$pageParent->permalink().'">
|
||||
<h3>'.$pageParent->title().'</h3>
|
||||
|
Loading…
Reference in New Issue
Block a user