-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.php
More file actions
44 lines (39 loc) · 1.36 KB
/
search.php
File metadata and controls
44 lines (39 loc) · 1.36 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
<?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"];
}
$keywords = explode(" ", $_GET["keywords"]);
$itemList = $itemSvc->search($keywords, $postcode, $section);
// print_r($keywords);
$view = $twig->render("search.twig", array("sectionList" => $sectionList, "itemList" => $itemList, "keywords" => $keywords, "username" => $username, "cityList" => $cityList));
print($view);
} else {
$view = $twig->render("search.twig", array("sectionList" => $sectionList, "username" => $username, "cityList" => $cityList));
print($view);
}