-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.php
More file actions
92 lines (88 loc) · 3.89 KB
/
search.php
File metadata and controls
92 lines (88 loc) · 3.89 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<?php
require_once(dirname(__FILE__).'/Controllers/Controller.php');
$msg = Controller::process();
if (isset($_GET['type']) && isset($_GET['query'])) {
$query = $_GET['query'];
if ($_GET['type'] == 'movie') {
$movie_aux = new Movie();
$movie_aux->title = $query;
$movie_results = $movie_aux->searchByTitle();
}
else if ($_GET['type'] == 'people') {
$person_aux = new Person();
$person_aux->first_name = $query;
$person_results = $person_aux->searchByName();
}
else {
header('Location:notFound.php');
}
}
else {
header('Location:notFound.php');
}
?>
<html>
<head>
<link href="css/search.css" rel="stylesheet" type="text/css"/>
<link rel="shortcut icon" href="img/main/favicon.ico"/>
<title>Showtime - Search Results</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<?php
include('page-elements/header.php');
function getYear($date) {
$exploded = explode('-', $date);
return $exploded[0];
}
?>
<main>
<div id="all">
<h1>Search results for "<?php echo $query;?>"</h1>
<?php
if ($_GET['type'] == 'movie') { if ($movie_results) {?>
<table id="movie">
<h1 class="tablet">Movies</h1>
<?php
foreach ($movie_results as $obj=>$attr) {
if (isset ($attr->release_date)) { $year = getYear($attr->release_date);} else {$year = "";}
$poster = 'img/movies/' . $attr->id_movie . '.jpg';
if (!file_exists($poster)) {
$poster = 'img/misc/placeholder-poster.png';
}
echo '<tr><td><a href="movie.php?m=' . $attr->id_movie . '"><img class="matrix-img" src="' . $poster .
'"/></a></td><td><a href="movie.php?m=' . $attr->id_movie . '">' . $attr->title . '</a></td><td>' . $year . '</td></tr>';
}
?>
</table>
<?php } } else if ($_GET['type'] == 'people') { if ($person_results) {?>
<table id="person">
<h1 class="table_t">People</h1>
<?php
foreach ($person_results as $obj=>$attr) {
if (isset ($attr->birthdate)) { $year = getYear($attr->birthdate);} else {$year = "";}
$avatar = 'img/people/' . $attr->id_person . '.jpg';
if (!file_exists($avatar)) {
$avatar = 'img/misc/placeholder-avatar.png';
}
echo '<tr><td><a href="person.php?p=' . $attr->id_person . '"><img class="matrix-img" src="' . $avatar .
'"/></a></td><td><a href="person.php?p=' . $attr->id_person . '">' . $attr->first_name . ' ' . $attr->last_name . '</a></td><td>' . $year . '</td></tr>';
}
?>
</table>
<?php } } else {
if ($_GET['type'] == 'movie') {
echo '<h3>No movies were found!</h3>';
}
else if ($_GET['type'] == 'people') {
echo '<h3>No people were found!</h3>';
}
}?>
</div>
</main>
<?php
include('page-elements/footer.php');
?>
</body>