From aa9ff9d22908bebd25c5f6710fe27c4bd2ace139 Mon Sep 17 00:00:00 2001 From: Diego Najar Date: Wed, 10 May 2017 23:21:45 +0200 Subject: [PATCH] Removing posts --- bl-kernel/dbcategories.class.php | 2 -- bl-kernel/functions.php | 41 +++++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/bl-kernel/dbcategories.class.php b/bl-kernel/dbcategories.class.php index f4c2d0ab..bb1d2f6b 100644 --- a/bl-kernel/dbcategories.class.php +++ b/bl-kernel/dbcategories.class.php @@ -7,12 +7,10 @@ Database structure { "videos": { "name": "Videos", - "posts": [ "first-post", "bull-terrier" ], "pages": [ "my-page", "second-page" ] }, "pets": { "name": "Pets", - "posts": [ "second-post", "bull-terrier" ], "pages": [ "cats-and-dogs" ] } } diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php index cae236ca..9ebffc27 100644 --- a/bl-kernel/functions.php +++ b/bl-kernel/functions.php @@ -52,7 +52,6 @@ function buildPage($key) return $page; } - function reindexCategories() { global $dbPages; @@ -81,26 +80,52 @@ function reindexTags() return true; } -function buildPagesForAdmin($pageNumber) +function buildPagesForAdmin() { - return buildPagesFor('admin', $pageNumber); + return buildPagesFor('admin'); } -function buildPagesForHome($pageNumber) +function buildPagesForHome() { - return buildPagesFor('home', $pageNumber); + return buildPagesFor('home'); } -function buildPagesFor($for, $pageNumber) +function buildPagesByCategory($categoryKey) +{ + return buildPagesFor('category', $categoryKey, false); +} + +function buildPagesByTag($tagKey) +{ + return buildPagesFor('tag', false, $tagKey); +} + +function buildPagesFor($for, $categoryKey=false, $tagKey=false) { global $dbPages; + global $dbCategories; global $Site; + // Get the page number from URL + $pageNumber = $Url->pageNumber(); + if($for=='admin') { - $list = $dbPages->getList($pageNumber, ITEMS_PER_PAGE_ADMIN, false); + $onlyPublished = false; + $amountOfItems = ITEMS_PER_PAGE_ADMIN; + $list = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished); } elseif($for=='home') { - $list = $dbPages->getList($pageNumber, $Site->postsPerPage(), true); + $onlyPublished = true; + $amountOfItems = $Site->postsPerPage(); + $list = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished); + } + elseif($for=='category') { + $amountOfItems = $Site->postsPerPage(); + $list = $dbCategories->getList($categoryKey, $pageNumber, $amountOfItems); + } + elseif($for=='tag') { + $amountOfItems = $Site->postsPerPage(); + $list = $dbTags->getList($tagKey, $pageNumber, $amountOfItems); } // There are not items for the page number then set the page notfound