aboutsummaryrefslogtreecommitdiffstats
path: root/core/include
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2021-07-02 20:17:42 +0200
committerThomas Lange <code@nerdmind.de>2021-07-02 20:17:42 +0200
commitf5f94531c9d5b369fdf9c287f63c41476496e5ee (patch)
tree54aa2e26a044dca2d1f3604a920f1527c34e9021 /core/include
parent3939dc93d0c11438e8a3e44c48aab2f37128eebc (diff)
downloadblog-f5f94531c9d5b369fdf9c287f63c41476496e5ee.tar.gz
blog-f5f94531c9d5b369fdf9c287f63c41476496e5ee.tar.xz
blog-f5f94531c9d5b369fdf9c287f63c41476496e5ee.zip
Add generic function to create pagination template
This commit adds and uses the new function createPaginationTemplate to create the generic pagination template for various entity lists. This function replaces the many old confusing functions: * generateNaviTemplate * generatePageNaviTemplate * generatePostNaviTemplate * generateUserNaviTemplate * generateCategoryNaviTemplate * generateCategoryPostNaviTemplate
Diffstat (limited to 'core/include')
-rw-r--r--core/include/category/list.php3
-rw-r--r--core/include/category/main.php3
-rw-r--r--core/include/home.php9
-rw-r--r--core/include/page/list.php4
-rw-r--r--core/include/post/list.php3
-rw-r--r--core/include/user/list.php4
6 files changed, 20 insertions, 6 deletions
diff --git a/core/include/category/list.php b/core/include/category/list.php
index 4702a79..3a5720b 100644
--- a/core/include/category/list.php
+++ b/core/include/category/list.php
@@ -52,7 +52,8 @@ $ListTemplate = Template\Factory::build('category/list');
$ListTemplate->set('PAGINATION', [
'THIS' => $currentSite,
'LAST' => $lastSite,
- 'HTML' => generateCategoryNaviTemplate($currentSite)
+ 'HTML' => createPaginationTemplate(
+ $currentSite, $lastSite, Application::getCategoryURL())
]);
$ListTemplate->set('LIST', [
'CATEGORIES' => $templates ?? []
diff --git a/core/include/category/main.php b/core/include/category/main.php
index 066ea26..b1bea72 100644
--- a/core/include/category/main.php
+++ b/core/include/category/main.php
@@ -111,7 +111,8 @@ $CategoryTemplate->set('COUNT', [
$CategoryTemplate->set('PAGINATION', [
'THIS' => $currentSite,
'LAST' => $lastSite,
- 'HTML' => generateCategoryPostNaviTemplate($currentSite, $Category)
+ 'HTML' => createPaginationTemplate(
+ $currentSite, $lastSite, Application::getEntityURL($Category))
]);
$CategoryTemplate->set('LIST', [
'POSTS' => $post_templates ?? [],
diff --git a/core/include/home.php b/core/include/home.php
index bc73bef..2893f0e 100644
--- a/core/include/home.php
+++ b/core/include/home.php
@@ -19,11 +19,18 @@ foreach($posts as $Post) {
}
#===============================================================================
+# Pagination
+#===============================================================================
+$count = $PostRepository->getCount();
+$lastSite = ceil($count / Application::get('POST.LIST_SIZE'));
+
+#===============================================================================
# Build document
#===============================================================================
$HomeTemplate = Template\Factory::build('home');
$HomeTemplate->set('PAGINATION', [
- 'HTML' => generatePostNaviTemplate(1)
+ 'HTML' => createPaginationTemplate(
+ 1, $lastSite, Application::getPostURL())
]);
$HomeTemplate->set('LIST', [
'POSTS' => $templates ?? []
diff --git a/core/include/page/list.php b/core/include/page/list.php
index f7541fa..8cfbce5 100644
--- a/core/include/page/list.php
+++ b/core/include/page/list.php
@@ -55,7 +55,9 @@ $ListTemplate = Template\Factory::build('page/list');
$ListTemplate->set('PAGINATION', [
'THIS' => $currentSite,
'LAST' => $lastSite,
- 'HTML' => generatePageNaviTemplate($currentSite)
+ 'HTML' => createPaginationTemplate(
+ $currentSite, $lastSite, Application::getPageURL()
+ )
]);
$ListTemplate->set('LIST', [
'PAGES' => $templates ?? []
diff --git a/core/include/post/list.php b/core/include/post/list.php
index 4599883..ab48552 100644
--- a/core/include/post/list.php
+++ b/core/include/post/list.php
@@ -55,7 +55,8 @@ $ListTemplate = Template\Factory::build('post/list');
$ListTemplate->set('PAGINATION', [
'THIS' => $currentSite,
'LAST' => $lastSite,
- 'HTML' => generatePostNaviTemplate($currentSite)
+ 'HTML' => createPaginationTemplate(
+ $currentSite, $lastSite, Application::getPostURL())
]);
$ListTemplate->set('LIST', [
'POSTS' => $templates ?? []
diff --git a/core/include/user/list.php b/core/include/user/list.php
index f6f794a..f4aec77 100644
--- a/core/include/user/list.php
+++ b/core/include/user/list.php
@@ -53,7 +53,9 @@ $ListTemplate = Template\Factory::build('user/list');
$ListTemplate->set('PAGINATION', [
'THIS' => $currentSite,
'LAST' => $lastSite,
- 'HTML' => generateUserNaviTemplate($currentSite)
+ 'HTML' => createPaginationTemplate(
+ $currentSite, $lastSite, Application::getUserURL()
+ )
]);
$ListTemplate->set('LIST', [
'USERS' => $templates ?? []