diff --git a/bl-kernel/admin/controllers/manage-categories.php b/bl-kernel/admin/controllers/categories.php similarity index 100% rename from bl-kernel/admin/controllers/manage-categories.php rename to bl-kernel/admin/controllers/categories.php diff --git a/bl-kernel/admin/controllers/edit-category.php b/bl-kernel/admin/controllers/edit-category.php index dd7f60cc..785e8200 100644 --- a/bl-kernel/admin/controllers/edit-category.php +++ b/bl-kernel/admin/controllers/edit-category.php @@ -20,6 +20,11 @@ function edit($oldCategoryKey, $newCategory) global $dbPages; global $dbCategories; + if( Text::isEmpty($oldCategoryKey) || Text::isEmpty($newCategory) ) { + Alert::set($Language->g('Empty field')); + Redirect::page('admin', 'categories'); + } + if( $dbCategories->edit($oldCategoryKey, $newCategory) == false ) { Alert::set($Language->g('Already exist a category')); } @@ -29,7 +34,7 @@ function edit($oldCategoryKey, $newCategory) Alert::set($Language->g('The changes have been saved')); } - Redirect::page('admin', 'manage-categories'); + Redirect::page('admin', 'categories'); } function delete($categoryKey) @@ -41,7 +46,7 @@ function delete($categoryKey) Alert::set($Language->g('The changes have been saved')); - Redirect::page('admin', 'manage-categories'); + Redirect::page('admin', 'categories'); } // ============================================================================ @@ -58,7 +63,7 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' ) delete($_POST['categoryKey']); } elseif( isset($_POST['edit']) ) { - edit($_POST['categoryKey'], $_POST['categoryName']); + edit($_POST['categoryKey'], $_POST['category']); } } @@ -66,13 +71,13 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' ) // Main after POST // ============================================================================ -if(!$dbCategories->exists($categoryKey)) -{ - Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the category: '.$layout['parameters']); - Redirect::page('admin', 'manage-categories'); +$categoryKey = $layout['parameters']; + +if(!$dbCategories->exists($categoryKey)) { + Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the category: '.$categoryKey); + Redirect::page('admin', 'categories'); } -$categoryKey = $layout['parameters']; $category = $dbCategories->getName($layout['parameters']); $layout['title'] .= ' - '.$Language->g('Edit category').' - '.$category; diff --git a/bl-kernel/admin/controllers/new-category.php b/bl-kernel/admin/controllers/new-category.php index 467d5aea..65242649 100644 --- a/bl-kernel/admin/controllers/new-category.php +++ b/bl-kernel/admin/controllers/new-category.php @@ -44,7 +44,7 @@ function add($category) if( $_SERVER['REQUEST_METHOD'] == 'POST' ) { if( add($_POST['category']) ) { - Redirect::page('admin', 'manage-categories'); + Redirect::page('admin', 'categories'); } } diff --git a/bl-kernel/admin/views/manage-categories.php b/bl-kernel/admin/views/categories.php similarity index 100% rename from bl-kernel/admin/views/manage-categories.php rename to bl-kernel/admin/views/categories.php diff --git a/bl-kernel/admin/views/edit-category.php b/bl-kernel/admin/views/edit-category.php index e669b820..70f660c9 100644 --- a/bl-kernel/admin/views/edit-category.php +++ b/bl-kernel/admin/views/edit-category.php @@ -25,7 +25,7 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
'; diff --git a/bl-kernel/admin/views/new-category.php b/bl-kernel/admin/views/new-category.php index 8c678158..66fee044 100644 --- a/bl-kernel/admin/views/new-category.php +++ b/bl-kernel/admin/views/new-category.php @@ -19,7 +19,7 @@ HTML::formOpen(array('class'=>'uk-form-horizontal')); echo ''; diff --git a/bl-kernel/dbcategories.class.php b/bl-kernel/dbcategories.class.php index af76ed4b..ef595a77 100644 --- a/bl-kernel/dbcategories.class.php +++ b/bl-kernel/dbcategories.class.php @@ -150,7 +150,7 @@ class dbCategories extends dbJSON // Foreach post in the database foreach($db as $postKey=>$postData) { - if(!empty($postData['category'])) { + if( !empty($postData['category']) && $this->exists($postData['category']) ) { $categoryKey = $postData['category']; array_push($index, $postKey); } @@ -167,10 +167,12 @@ class dbCategories extends dbJSON { $index = array(); - // Foreach post in the database + // Foreach page in the database foreach($db as $pageKey=>$pageData) { - $categoryKey = $pageData['category']; - array_push($index, $pageKey); + if( !empty($pageData['category']) && $this->exists($pageData['category']) ) { + $categoryKey = $pageData['category']; + array_push($index, $pageKey); + } } $this->db[$categoryKey]['pages'] = $index;