-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
147 lines (146 loc) · 9.05 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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<!DOCTYPE html>
<?php
require "functions.php";
// https://stackoverflow.com/a/1764199
if ($_GET) {
// https://www.php.net/manual/en/reserved.variables.server.php
parse_str($_SERVER['QUERY_STRING'], $url_params);
$params = array(
'keywords',
'exact',
'start_year',
'end_year',
'journal'
);
foreach ($params as $param)
if (!array_key_exists($param, $url_params))
$url_params[$param] = '';
$resp = CallAPI("GET", "https://georgeeliotarchive.org/api/items?collection=17");
$data = json_decode($resp, true);
$entries = getSearchResults($data, $url_params);
$years = arrangeEntriesByYear($entries);
} else {
$url_params = array(
'keywords' => '',
'exact' => '',
'start_year' => '',
'end_year' => '',
'journal' => ''
);
}
?>
<html>
<head>
<title>Journal Search</title>
<?php require "common_head.php"; ?>
<style type="text/css">
.topnav {
margin-left: 10px;
//margin-top: 30px;
width: 100%;
}
</style>
</head>
<body>
<div class="topnav">
<h1>Search Options</h1>
<h3>Search for journal entries with:</h3>
<hr style="width:600px; margin-left:0px">
<form action="./search.php" method="get">
Any of these Keywords: <?php echo
'<input name="keywords" type="text" value="'.$url_params["keywords"].'">';
?>.<br>
<hr style="width:600px; margin-left:0px">
This exact text: <?php echo
'<input name="exact" type="text" value="'.$url_params["exact"].'">';
?>.<br>
<hr style="width:600px; margin-left:0px">
In the years from
<select name="start_year" style="width:100px">
<option value="1854" <?php if($url_params['start_year']=="1854"||$url_params['start_year']=='')echo'selected';?>>1854</option>
<option value="1855" <?php if($url_params['start_year']=="1855")echo'selected';?>>1855</option>
<option value="1856" <?php if($url_params['start_year']=="1856")echo'selected';?>>1856</option>
<option value="1857" <?php if($url_params['start_year']=="1857")echo'selected';?>>1857</option>
<option value="1858" <?php if($url_params['start_year']=="1858")echo'selected';?>>1858</option>
<option value="1859" <?php if($url_params['start_year']=="1859")echo'selected';?>>1859</option>
<option value="1860" <?php if($url_params['start_year']=="1860")echo'selected';?>>1860</option>
<option value="1861" <?php if($url_params['start_year']=="1861")echo'selected';?>>1861</option>
<option value="1862" <?php if($url_params['start_year']=="1862")echo'selected';?>>1862</option>
<option value="1863" <?php if($url_params['start_year']=="1863")echo'selected';?>>1863</option>
<option value="1864" <?php if($url_params['start_year']=="1864")echo'selected';?>>1864</option>
<option value="1865" <?php if($url_params['start_year']=="1865")echo'selected';?>>1865</option>
<option value="1866" <?php if($url_params['start_year']=="1866")echo'selected';?>>1866</option>
<option value="1867" <?php if($url_params['start_year']=="1867")echo'selected';?>>1867</option>
<option value="1868" <?php if($url_params['start_year']=="1868")echo'selected';?>>1868</option>
<option value="1869" <?php if($url_params['start_year']=="1869")echo'selected';?>>1869</option>
<option value="1870" <?php if($url_params['start_year']=="1870")echo'selected';?>>1870</option>
<option value="1871" <?php if($url_params['start_year']=="1871")echo'selected';?>>1871</option>
<option value="1872" <?php if($url_params['start_year']=="1872")echo'selected';?>>1872</option>
<option value="1873" <?php if($url_params['start_year']=="1873")echo'selected';?>>1873</option>
<option value="1874" <?php if($url_params['start_year']=="1874")echo'selected';?>>1874</option>
<option value="1875" <?php if($url_params['start_year']=="1875")echo'selected';?>>1875</option>
<option value="1876" <?php if($url_params['start_year']=="1876")echo'selected';?>>1876</option>
<option value="1877" <?php if($url_params['start_year']=="1877")echo'selected';?>>1877</option>
<option value="1879" <?php if($url_params['start_year']=="1879")echo'selected';?>>1879</option>
<option value="1880" <?php if($url_params['start_year']=="1880")echo'selected';?>>1880</option>
</select>
to
<select name="end_year" style="width:100px">
<option value="1854" <?php if($url_params['end_year']=="1854")echo'selected';?>>1854</option>
<option value="1855" <?php if($url_params['end_year']=="1855")echo'selected';?>>1855</option>
<option value="1856" <?php if($url_params['end_year']=="1856")echo'selected';?>>1856</option>
<option value="1857" <?php if($url_params['end_year']=="1857")echo'selected';?>>1857</option>
<option value="1858" <?php if($url_params['end_year']=="1858")echo'selected';?>>1858</option>
<option value="1859" <?php if($url_params['end_year']=="1859")echo'selected';?>>1859</option>
<option value="1860" <?php if($url_params['end_year']=="1860")echo'selected';?>>1860</option>
<option value="1861" <?php if($url_params['end_year']=="1861")echo'selected';?>>1861</option>
<option value="1862" <?php if($url_params['end_year']=="1862")echo'selected';?>>1862</option>
<option value="1863" <?php if($url_params['end_year']=="1863")echo'selected';?>>1863</option>
<option value="1864" <?php if($url_params['end_year']=="1864")echo'selected';?>>1864</option>
<option value="1865" <?php if($url_params['end_year']=="1865")echo'selected';?>>1865</option>
<option value="1866" <?php if($url_params['end_year']=="1866")echo'selected';?>>1866</option>
<option value="1867" <?php if($url_params['end_year']=="1867")echo'selected';?>>1867</option>
<option value="1868" <?php if($url_params['end_year']=="1868")echo'selected';?>>1868</option>
<option value="1869" <?php if($url_params['end_year']=="1869")echo'selected';?>>1869</option>
<option value="1870" <?php if($url_params['end_year']=="1870")echo'selected';?>>1870</option>
<option value="1871" <?php if($url_params['end_year']=="1871")echo'selected';?>>1871</option>
<option value="1872" <?php if($url_params['end_year']=="1872")echo'selected';?>>1872</option>
<option value="1873" <?php if($url_params['end_year']=="1873")echo'selected';?>>1873</option>
<option value="1874" <?php if($url_params['end_year']=="1874")echo'selected';?>>1874</option>
<option value="1875" <?php if($url_params['end_year']=="1875")echo'selected';?>>1875</option>
<option value="1876" <?php if($url_params['end_year']=="1876")echo'selected';?>>1876</option>
<option value="1877" <?php if($url_params['end_year']=="1877")echo'selected';?>>1877</option>
<option value="1879" <?php if($url_params['end_year']=="1879")echo'selected';?>>1879</option>
<option value="1880" <?php if($url_params['end_year']=="1880"||$url_params['end_year']=='')echo'selected';?>>1880</option>
</select>.
<hr style="width:600px; margin-left:0px">
From the following source:
<select name="journal" style="width:350px">
<option <?php if($url_params['journal']=="")echo'selected';?> value="">All Journals</option>
<option <?php if($url_params['journal']=="Diary 1854-1861")echo'selected';?> value="Diary 1854-1861">Diary 1854-1861</option>
<option <?php if($url_params['journal']=="Diary 1861-1877")echo'selected';?> value="Diary 1861-1877">Diary 1861-1877</option>
<option <?php if($url_params['journal']=="Diary 1879")echo'selected';?> value="Diary 1879">Diary 1879</option>
<option <?php if($url_params['journal']=="Diary 1880")echo'selected';?> value="Diary 1880">Diary 1880</option>
<option <?php if($url_params['journal']=="Germany 1858")echo'selected';?> value="Germany 1858">Germany 1858</option>
<option <?php if($url_params['journal']=="Italy 1864")echo'selected';?> value="Italy 1864">Italy 1864</option>
<option <?php if($url_params['journal']=="Journal to Normandy in 1865")echo'selected';?> value="Journal to Normandy in 1865">Journal to Normandy in 1865</option>
<option <?php if($url_params['journal']=="The Making of George Eliot 1857-1859")echo'selected';?> value="The Making of George Eliot 1857-1859">The Making of George Eliot 1857-1859</option>
</select>.
<hr style="width:600px; margin-left:0px">
<button type="submit">Search</button>
</form>
<hr>
</div>
<?php if ($_GET) { ?>
<header>
<h1>Search Results</h1>
</header>
<?php
if (count($years) > 0)
require "multi_year_body.php";
else { ?>
<h3>No results found for your query.</h3>
<?php } ?>
<?php } ?>
</body>
</html>