aboutsummaryrefslogtreecommitdiffstats
path: root/core/include/search/main.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/include/search/main.php')
-rw-r--r--core/include/search/main.php23
1 files changed, 22 insertions, 1 deletions
diff --git a/core/include/search/main.php b/core/include/search/main.php
index 564f0dd..14c2ac9 100644
--- a/core/include/search/main.php
+++ b/core/include/search/main.php
@@ -10,6 +10,16 @@ $Language = Application::getLanguage();
$PostRepository = Application::getRepository('Post');
$UserRepository = Application::getRepository('User');
+#===============================================================================
+# Pagination
+#===============================================================================
+$site_size = Application::get('POST.LIST_SIZE');
+$site_sort = Application::get('POST.LIST_SORT');
+
+$currentSite = HTTP::GET('site') ?? 1;
+$currentSite = intval($currentSite);
+$offset = ($currentSite-1) * $site_size;
+
if($search = HTTP::GET('q')) {
$filter = [
'day' => HTTP::GET('d'),
@@ -17,7 +27,7 @@ if($search = HTTP::GET('q')) {
'year' => HTTP::GET('y')
];
- if(!$posts = $PostRepository->search($search, $filter)) {
+ if(!$posts = $PostRepository->search($search, $filter, $site_size, $offset)) {
$message = $Language->text('search_no_results', escapeHTML($search));
}
}
@@ -49,6 +59,9 @@ if(!empty($posts)) {
$templates[] = generatePostItemTemplate($Post, $User);
}
+ $count = $PostRepository->getLastSearchOverallCount();
+ $last = ceil($count / $site_size);
+
$ResultTemplate = Template\Factory::build('search/result');
$ResultTemplate->set('FORM', $form_data);
$ResultTemplate->set('SEARCH', $search_data);
@@ -56,6 +69,14 @@ if(!empty($posts)) {
'LIST' => $templates ?? []
]);
+ $ResultTemplate->set('PAGINATION', [
+ 'THIS' => $currentSite,
+ 'LAST' => $last,
+ 'HTML' => createPaginationTemplate(
+ $currentSite, $last, Application::getURL('search/')
+ )
+ ]);
+
$MainTemplate = Template\Factory::build('main');
$MainTemplate->set('HTML', $ResultTemplate);
$MainTemplate->set('HEAD', [