-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathresults.php
337 lines (328 loc) · 20.6 KB
/
results.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
<?php
include_once('includes/functions.php');
require_once 'includes/Paginator.class.php';
global $conn;
// Build query with $_GET values
$sql = buildQuery();
// Get and sanitize 'limit' and 'p' for pagination
$g_lim = filter_input(INPUT_GET, 'limit', FILTER_SANITIZE_NUMBER_INT);
$g_p = filter_input(INPUT_GET, 'p', FILTER_SANITIZE_NUMBER_INT);
$limit = ( $g_lim !== '' && $g_lim > 0 ) ? $g_lim : 25;
$page = ( $g_p !== '' && $g_p > 0 ) ? $g_p : 1;
$links = 3;
$Paginator = new Paginator( $conn, $sql );
// Get paginated results
$results = $Paginator->getData( $limit, $page );
// Cleaned, pipe delimited strings from 'actor' and 'role' arrays
$cleanedActors = (isset($_GET['actor'])) ? implode('|', $_GET['actor']) : '';
$cleanedRoles = (isset($_GET['role'])) ? implode('|', $_GET['role']) : '';
?>
<!doctype html>
<html class="no-js" lang="en">
<head>
<?php include_once('common/header.php'); ?>
<title>Search</title>
</head>
<body id="results">
<?php include_once('common/nav.php'); ?>
<div id="main" class="main grid-container">
<div class="sql-query-wrap">
<div class="toggle-query"><a id="toggle">Toggle Query</a></div>
<div class="sql-query">
<?php echo $sql; ?>
</div>
</div>
<form id="searchForm" class="form-accordion search-form grid-x" method="get" data-abide novalidate>
<div class="grid-container grid-x form-wrapper">
<div class="hide-for-large">
<button type="button" class="button hide-for-large open-filter-btn" data-toggle="filterMenu">
Open Search Filters
</button>
</div>
<div class="filter-menu form-section cell medium-4 large-3 off-canvas in-canvas-for-large position-left" id="filterMenu" data-off-canvas>
<button class="close-button" aria-label="Close menu" type="button" data-close>
<span aria-hidden="true">×</span>
</button>
<div class="download-btns">
<h2>Result Options</h2>
<a href="get_all_json.php?<?php echo $_SERVER['QUERY_STRING']; ?>" class="button dwnld-btn">Download JSON</a>
<!--<a href="get_all_xml.php?ids=<?php //echo htmlspecialchars(json_encode($allResultIds), ENT_QUOTES); ?>" class="button dwnld-btn">Download XML</a>-->
<a href="get_all_xml.php?<?php echo $_SERVER['QUERY_STRING']; ?>" class="button dwnld-btn">Download XML</a>
</div>
<h2>Search Filters</h2>
<div class="grid-x filter-sections-wrap form-accordion">
<div class="cell small-12 section-wrap">
<h2 class="active">Event</h2>
<div class="grid-x acc-section">
<div class="small-12 cell">
<div class="form-group field-theatre">
<label for="theatre" class="fb-select-label">Theatre</label>
<select class="theatre" name="theatre" id="theatre">
<option value="" disabled selected>Select a Theatre</option>
<option value="all">Any Theatre...</option>
<option disabled>_________</option>
<?php getTheatres(); ?>
</select>
</div>
<div class="form-group field-volume">
<label for="volume" class="fb-select-label">Volume</label>
<select class="volume" name="volume" id="volume">
<option value="" disabled selected>Select a Volume</option>
<option value="all">Any Volume...</option>
<option disabled>_________</option>
<option value="1" <?php getSticky(2, 'volume', '1'); ?>>1 (1659-1700)</option>
<option value="2" <?php getSticky(2, 'volume', '2'); ?>>2 (1700-1729)</option>
<option value="3" <?php getSticky(2, 'volume', '3'); ?>>3 (1729-1747)</option>
<option value="4" <?php getSticky(2, 'volume', '4'); ?>>4 (1747-1776)</option>
<option value="5" <?php getSticky(2, 'volume', '5'); ?>>5 (1776-1800)</option>
</select>
</div>
</div>
<div class="small-12 cell">
<div class="form-group field-dates">
<fieldset>
<legend>Date Range</legend>
<label class="hidden date-type hide" for="dateType">Date Type</label>
<select id="dateType" class="date-type hide" name="date-type">
<option value="1" <?php getSticky(2, 'date-type', '1'); ?>>Between</option>
<option value="2" <?php getSticky(2, 'date-type', '2'); ?>>Before</option>
<option value="3" <?php getSticky(2, 'date-type', '3'); ?>>On</option>
<option value="4" <?php getSticky(2, 'date-type', '4'); ?>>After</option>
</select>
<div class="year start-year">
<span class="year-title">Start</span>
<label class="hidden" for="startYear">Start Year</label>
<select class="date-year" id="startYear" name="start-year">
<option disabled selected>Year</option>
<?php getYears('start'); ?>
</select>
<label class="hidden" for="startMonth">Start Month</label>
<select class="date-month" id="startMonth" name="start-month" disabled>
<option disabled selected>Mon</option>
<?php getMonths('start'); ?>
</select>
<label class="hidden" for="startDay">Start Day</label>
<select class="date-day" id="startDay" name="start-day" disabled>
<option disabled selected>Day</option>
<?php getDays('start'); ?>
</select>
</div>
<div class="year end-year">
<span class="year-title">End</span>
<label class="hidden" for="endYear">End Year</label>
<select class="date-year" id="endYear" name="end-year">
<option disabled selected>Year</option>
<?php getYears('end'); ?>
</select>
<label class="hidden" for="endMonth">End Month</label>
<select class="date-month" id="endMonth" name="end-month" disabled>
<option disabled selected>Mon</option>
<?php getMonths('end'); ?>
</select>
<label class="hidden" for="endDay">End Day</label>
<select class="date-day" id="endDay" name="end-day" disabled>
<option disabled selected>Day</option>
<?php getDays('end'); ?>
</select>
</div>
</fieldset>
</div>
</div>
</div>
</div>
<!-- end event wrap -->
<div class="cell small-12 section-wrap">
<h2 class="active">Performance</h2>
<div class="grid-x acc-section">
<div class="small-12 cell">
<div class="form-group field-performance">
<label for="performance" class="fb-text-label">Title</label>
<input type="text" class="performance ui-autocomplete-input" name="performance" id="performance" value="<?php getSticky(1, 'performance'); ?>" onKeyPress="checkEnter(event)">
</div>
<div class="form-group field-author inline-label">
<label for="author" class="fb-select-label">Author</label>
<span data-tooltip class="top l-tooltip" tabindex="2" title="Searches not only for performances of plays known to be by this author, but also performances of associated titles, including adaptations.">?</span>
<input type="text" class="author" name="author" id="author" value="<?php getSticky(1, 'author'); ?>" onKeyPress="checkEnter(event)">
</div>
</div>
<div class="small-12 cell">
<div class="form-group field-ptype">
<fieldset class="ptype-contain">
<div class="ptype-legend">
<legend>Filter by Performance Type</legend>
</div>
<div class="ptype">
<input type="checkbox" name="ptype[]" value="p" id="mainpiece" <?php getSticky(3, 'ptype', 'p'); ?>><label for="mainpiece">Mainpiece</label><br>
<input type="checkbox" name="ptype[]" value="a" id="afterpiece" <?php getSticky(3, 'ptype', 'a'); ?>><label for="afterpiece">Afterpiece</label><br>
<input type="checkbox" name="ptype[]" value="m" id="music" <?php getSticky(3, 'ptype', 'm'); ?>><label for="music">Music</label><br>
<input type="checkbox" name="ptype[]" value="d" id="dance" <?php getSticky(3, 'ptype', 'd'); ?>><label for="dance">Dance</label><br>
<input type="checkbox" name="ptype[]" value="e" id="entertainment" <?php getSticky(3, 'ptype', 'e'); ?>><label for="entertainment">Entertainment</label><br>
<input type="checkbox" name="ptype[]" value="s" id="song" <?php getSticky(3, 'ptype', 's'); ?>><label for="song">Song</label><br>
<input type="checkbox" name="ptype[]" value="b" id="ballet" <?php getSticky(3, 'ptype', 'b'); ?>><label for="ballet">Ballet</label><br>
<input type="checkbox" name="ptype[]" value="i" id="instrumental" <?php getSticky(3, 'ptype', 'i'); ?>><label for="instrumental">Instrumental</label><br>
<input type="checkbox" name="ptype[]" value="o" id="opera" <?php getSticky(3, 'ptype', 'o'); ?>><label for="opera">Opera</label><br>
<input type="checkbox" name="ptype[]" value="u" id="monologue" <?php getSticky(3, 'ptype', 'u'); ?>><label for="monologue">Monologue</label><br>
<input type="checkbox" name="ptype[]" value="t" id="trick" <?php getSticky(3, 'ptype', 't'); ?>><label for="trick">Trick</label>
</div>
</fieldset>
</div>
</div>
</div>
</div>
<!-- end perf wrap -->
<div class="cell small-12 section-wrap">
<h2 class="active">Cast</h2>
<div class="grid-x acc-section">
<div class="small-12 cell">
<div class="form-group field-actor inline-label">
<label for="actor" class="fb-text-label">Actor</label>
<span data-tooltip class="top l-tooltip" tabindex="2" title="We recommend searching by last name (for example, instead of 'Dorothy Jordan,' search 'Jordan' to return instances where she is listed as 'Mrs Jordan')">?</span>
<span class="cast-switch">
<label for="actSwitch" class="show-for-sr">Select 'AND' or 'OR' search on multiple actors.</label>
<select name="actSwitch" id="actSwitch" title="Select 'AND' or 'OR' search on multiple actors." <?php echo (isset($_GET['actor']) && count(array_filter($_GET['actor'], 'strlen')) > 1) ? '' : 'disabled="disabled"'; ?>>
<option value="and" <?php getSticky(2, 'actSwitch', 'and'); ?>>AND</option>
<option value="or" <?php getSticky(2, 'actSwitch', 'or'); ?>>OR</option>
</select>
</span>
<span id="actors">
<?php
$actorArr = (isset($_GET['actor'])) ? array_filter($_GET['actor'], 'strlen') : [];
if (count($actorArr) > 0) {
$i = 0;
foreach($actorArr as $act) {
echo '<input type="text" class="actor actor-search" name="actor[]" id="actor" value="' . getSticky(5, 'actor', $actorArr[$i]) . '" onKeyPress="checkEnter(event)">';
$i++;
}
} else {
echo '<input type="text" class="actor actor-search" name="actor[]" id="actor" value="" onKeyPress="checkEnter(event)">';
}
?>
</span>
<div class="addActor"><a id="addActor" class="addCast" title="Add an actor">+</a></div>
</div>
</div>
<div class="small-12 cell">
<div class="form-group field-role inline-label">
<label for="role" class="fb-text-label">Role</label>
<span class="cast-switch">
<label for="roleSwitch" class="show-for-sr">Select 'AND' or 'OR' search on multiple roles.</label>
<select name="roleSwitch" id="roleSwitch" title="Select 'AND' or 'OR' search on multiple roles." <?php echo (isset($_GET['role']) && count(array_filter($_GET['role'], 'strlen')) > 1) ? '' : 'disabled="disabled"'; ?>>
<option value="and" <?php getSticky(2, 'roleSwitch', 'and'); ?>>AND</option>
<option value="or" <?php getSticky(2, 'roleSwitch', 'or'); ?>>OR</option>
</select>
</span>
<span id="roles">
<?php
$roleArr = (isset($_GET['role'])) ? array_filter($_GET['role'], 'strlen') : [];
if (count($roleArr) > 0) {
$i = 0;
foreach($roleArr as $act) {
echo '<input type="text" class="role role-search" name="role[]" id="role" value="' . getSticky(5, 'role', $roleArr[$i]) . '" onKeyPress="checkEnter(event)">';
$i++;
}
} else {
echo '<input type="text" class="role role-search" name="role[]" id="role" value="" onKeyPress="checkEnter(event)">';
}
?>
</span>
<div class="addRole"><a id="addRole" class="addCast" title="Add a role">+</a></div>
</div>
</div>
</div>
</div>
<!-- end cast wrap -->
<div class="cell small-12 section-wrap">
<h2 class="active">Keyword</h2>
<div class="grid-x acc-section">
<div class="small-12 cell">
<div class="form-group field-keyword inline-label">
<label for="keyword" class="fb-text-label">Keyword</label>
<span data-tooltip class="top l-tooltip" tabindex="2" title="Keyword searches event comments, performance titles, performance comments, roles, actors, and author names.">?</span>
<input type="text" class="keyword" name="keyword" id="keyword" value="<?php getSticky(1, 'keyword'); ?>" onKeyPress="checkEnter(event)">
</div>
</div>
</div>
</div>
</div>
<div class="cell small-12 button-wrap">
<a href="/search.php" class="new-search show-for-large">New Search</a>
<input type="submit" class="search-submit button" value="Update Results">
</div>
</div>
<div class="form-results cell small-12 large-9">
<div class="results-wrap">
<?php echo $results->total . ' results'; ?>
<?php if ($results->total > 0) { ?>
<div class="grid-x results-header">
<div class="input-group relevance-menu-wrap">
<label for="sortBy" class="input-group-label relevance-menu">Sort By
</label>
<select name="sortBy" id="sortBy" class="input-group-field">
<option value="relevance" <?php getSticky(2, 'sortBy', 'relevance'); ?>>Relevance</option>
<option value="date" <?php getSticky(2, 'sortBy', 'date'); ?>>Date</option>
</select>
<div class="input-group-button">
<input type="submit" class="search-submit button" value="Update">
</div>
</div>
<nav aria-label="Pagination" class="grid-x pag-wrap">
<?php echo $Paginator->createLinks( $links, 'pagination pagination-sm' ); ?>
</nav>
</div>
<div class="grid-x results-table">
<div class="cell">
<?php if ($_GET['author'] && $_GET['author'] !== '') : ?>
<div class="author-explain">
<span class="info-icon"></span>
<span>Results not only include performances of plays known to be by '<?php echo cleanQuotes(cleanStr($_GET['author'])); ?>', but also performances of associated titles, including adaptations.</span>
</div>
<?php endif; ?>
<?php for( $i = 0; $i < count( $results->data ); $i++ ) : ?>
<div class="event">
<?php $results->data[$i]['Performances'] = getPerformances($results->data[$i]['EventId']); ?>
<?php echo '<div class="evt-head grid-x">
<h2><a href="event.php?id=' . $results->data[$i]['EventId'] . '">' . formatDate($results->data[$i]['EventDate']); ?>
<span class="evt-theatre"> @ <?php echo getTheatreName($results->data[$i]['TheatreId']); ?></span>
</a>
</h2>
</div>
<div class="evt-body">
<?php if (isFoundIn($results->data[$i]['CommentC'], cleanQuotes($_GET['keyword']))) echo '<div class="evt-info"><b>Event Comment: </b>' . highlight(namedEntityLinks($results->data[$i]['CommentC']), cleanQuotes($_GET['keyword'])) . '</div>';?>
<div class="evt-other clearfix">
<div class="perfs">
<h3>Performances</h3>
<?php foreach ($results->data[$i]['Performances'] as $perf) {
echo '<div class="perf">';
echo '<h4><span class="info-heading">' . getPType($perf['PType']) . ' Title: </span><i>' . highlight(cleanItalics($perf['PerformanceTitle']), cleanQuotes($_GET['keyword']) . '|' . cleanQuotes($_GET['performance'])) . '</i></h4>';
if (isFoundIn($perf['CommentP'], cleanQuotes($_GET['keyword'])) ) echo '<b>Performance Comment: </b>' . highlight(namedEntityLinks($perf['CommentP']), cleanQuotes($_GET['keyword'])) . '<br>';
$inCast = isInCast(cleanQuotes($_GET['keyword']) . '|' . cleanQuotes($cleanedActors), cleanQuotes($_GET['keyword']) . '|' . cleanQuotes($cleanedRoles), $perf['cast']);
if ($inCast !== false) {
echo '<div class="cast"><h5>Cast</h5>';
foreach ($inCast as $cast) {
echo '<b>Role</b>: ' . highlight(linkedSearches('role', $cast['Role']), cleanQuotes($_GET['keyword']) . '|' . cleanQuotes($cleanedRoles)) . "\t\t <b>Actor</b>: " . highlight(linkedSearches('actor', $cast['Performer']), cleanQuotes($_GET['keyword']) . '|' . cleanQuotes($cleanedActors)) . '<br>';
}
echo '</div>';
}
echo '</div>';
} ?>
</div>
</div>
</div>
</div>
<?php endfor; ?>
</div>
</div>
<nav aria-label="Pagination" class="grid-x pag-wrap">
<?php echo $Paginator->createLinks( $links, 'pagination pagination-sm pag-bottom' ); ?>
</nav>
<?php } ?>
</div>
</div>
</div>
</form>
</div>
<?php include_once('common/footer.php'); ?>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="/js/search.js"></script>
</body>
</html>