-
Notifications
You must be signed in to change notification settings - Fork 1
/
search.php
59 lines (47 loc) · 1.66 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* @var array $config
* @var array $categories
* @var string $pageTitle
* @var mysqli $link
*/
require_once __DIR__ . "/bootstrap.php";
if (empty($_GET['search'])) {
$message = 'Введите запрос в строку поиска';
}
$lotsPerPage = $config['pagination']['lotsPerPage'];
$message = 'Результаты поиска по запросу ';
$search = filterSearchForm($_GET);
$currentPageNumber = getCurrentPageNumber($_GET);
$itemsCount = getCountTotalFoundLotsFromSearch($link, $search);
$totalPagesCount = getTotalPagesCount($itemsCount, $lotsPerPage);
$lots = searchLots($link, $search, $lotsPerPage, $currentPageNumber);
$getParam = '&search=' . $search;
if (!empty($search) && $itemsCount === 0) {
$message = 'Ничего не найдено по запросу ';
}
$menu = includeTemplate('menu.php', ['categories' => $categories]);
$pagination = includeTemplate('pagination.php', [
'lotsPerPage' => $lotsPerPage,
'itemsCount' => $itemsCount,
'currentPageNumber' => $currentPageNumber,
'search' => $search,
'totalPagesCount' => $totalPagesCount,
'getParam' => $getParam,
]);
$pageContent = includeTemplate('search-tmp.php', [
'pagination' => $pagination,
'message' => $message,
'search' => $search,
'categories' => $categories,
'lots' => $lots,
]);
$footer = includeTemplate('footer.php', ['menu' => $menu]);
$layoutContent = includeTemplate('layout.php', [
'menu' => $menu,
'footer' => $footer,
'categories' => $categories,
'pageTitle' => $pageTitle,
'pageContent' => $pageContent,
]);
print ($layoutContent);