-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.php
More file actions
52 lines (40 loc) · 1.58 KB
/
search.php
File metadata and controls
52 lines (40 loc) · 1.58 KB
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
<?php
session_start();
require_once 'bootstrap.php';
use OWG\Weggeefwinkel\Business\SectionService;
use OWG\Weggeefwinkel\Business\ItemService;
use OWG\Weggeefwinkel\Business\CityService;
$sectionSvc = new SectionService();
$sectionList = $sectionSvc->getAll();
$citySvc = new CityService();
$cityList = $citySvc->getAll();
if (isset($_SESSION["username"])) {
$username = $_SESSION["username"];
} else {
$username = "";
}
if (isset($_GET["search"])) {
//print "wel";
$itemSvc = new ItemService();
$keywords = "";
$postcode = "";
$section = "";
if (isset($_GET["keywords"]) && $_GET["keywords"] != "") {
$keywords = $_GET["keywords"];
}
if (isset($_GET["postcode"]) && $_GET["postcode"] != "") {
$postcode = $_GET["postcode"];
}
if (isset($_GET["section"]) && $_GET["section"] != "") {
$section = $_GET["section"];
}
$usedKeywords = $keywords;
$keywords = explode(" ", $_GET["keywords"]);
$itemList = $itemSvc->search($keywords, $postcode, $section);
//print_r($itemList);
$view = $twig->render("search.twig", array("sectionList" => $sectionList, "itemList" => $itemList, "keywords" => $keywords, "usedKeywords" => $usedKeywords, "usedPostcode" => $postcode, "usedSection" => $section, "username" => $username, "cityList" => $cityList, "searchActive" => "active"));
print($view);
} else {
$view = $twig->render("search.twig", array("sectionList" => $sectionList, "username" => $username, "cityList" => $cityList, "searchActive" => "active"));
print($view);
}