forked from CenterForDigitalHumanities/DigiSig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index-backup.php
378 lines (291 loc) · 11.6 KB
/
index-backup.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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
<?php
// ALPHA version: July 2015
#functions
//my functions
include "include/function.php";
//functions copied from other people
include "include/function_parsepath.php";
#connection details
require_once("config/config.php");
#constants and default values
include "include/constants.php";
/* If the page has received instructions via the 'post' method this
* code captures the 'post' and interprets it as a new header.*/
if ($_POST['submit']) {
$page = "/" . strtolower($_POST['submit']);
IF ($_POST['field']) {
$field = "/" . strtolower($_POST['field']);}
If ($_POST['index']) {
$index = "/" . strtolower($_POST['index']);}
If ($_POST['term']) {
$term = "/" . ($_POST['term']);}
If ($_POST['exact']) {
$exact = "/e";}
$url = ($address . $page . $field . $index . $term . $exact);
// reload the page with the new header
header ( 'Location:' .$url);
}
// reset the post array to clear any lingering data
$_POST = array();
/* If the page has NOT received instructions via 'post'
* check to see if header contains search instructions
*/
$path_info = parse_path();
if ($path_info[call_parts][0] == "search") {
$field = ($path_info[call_parts][1]);
$index = ($path_info[call_parts][2]);
$term = ($path_info [call_parts][3]);
$exact = ($path_info [call_parts][4]);
$title = "RESULTS";
}
if ($path_info[call_parts][0] == "entity") {
$id= ($path_info[call_parts][1]);
//find the last digit in the id number because it indicates the type of entity
$entity = substr($id, -1);
$title = $id;
}
//Dataset statistics
$query = "SELECT COUNT (*) FROM seal";
$queryresults = pg_query($query);
$row = pg_fetch_assoc($queryresults);
$sealcount = $row[count];
/* this file loads the header which is consistent on on all pages
* It has these parts:
* 1) Banner / Title
* 2) Navigation bar
* 3) Introduction text
* 4) Basic Search bar
*/
include "include/page.php";
// load the optional extra parts of the page depending on the header
switch($path_info['call_parts'][0]) {
case 'search':
//test to see if the search string has more than 1 character
if (strlen($term) > 0) {
$term = str_replace("_", "/", $term);
// if someone searches 'all fields' run the query for all possible searches
// otherwise, just run the query on the specified field
if ($field == "all_fields") {
$query12 = "SELECT field_url FROM field";
$query12result = pg_query($query12);
while ($row = pg_fetch_array($query12result)) {
$searchfield = $row[field_url];
queryResult($searchfield, $index, $term, $address, $exact);
}
} else {
queryResult($field, $index, $term, $address, $exact);
}
}
break;
case 'entity':
# show information about a specific entity
// first test that we have an entity number and proceed if yes
if ($id > 0) {
# 1) determine what view to query using the entity number
$query6 = "SELECT * FROM entity WHERE entity_code = $entity";
$query6result = pg_query($query6);
$row = pg_fetch_object($query6result);
$column = $row->entity_column;
$view = $row->entity_view;
# 2) formulate and return the basic search string
$query8 = "SELECT * FROM $view WHERE $column = $id";
$query8result = pg_query($query8);
//start rowcounter for table output
$rowcount = 1;
#the format for each version of the output depends on the nature of the data
//for shelfmarks
If ($entity == 0) {
$row = pg_fetch_array($query8result);
$value1 = $row[repository_fulltitle];
$value2 = $row[shelfmark];
$value10 = $row[repository_startdate];
$value11 = $row[repository_enddate];
$value12 = $row[repository_location];
$value13 = $row[repository_description];
$value14 = $row[connection];
$value15 = $row[ui_event_repository];
echo "ITEM";
echo "<br> DIGISIG ID:" . $id;
echo "<br> Permalink: http://digisig.org/entity/".$id;
echo "<br><br>" . $value1 . ": " . $value2;
echo '<a href="' . $value14 . $value15 . '">external link</a>';
echo "<br> dated:" . $value10 . " to " . $value11;
echo "<br> Location:" . $value12;
echo "<br> Description:" . $value13;
$query12 = "SELECT * FROM shelfmark_view WHERE id_item = $id ORDER BY position_latin";
$query12result = pg_query($query12);
// table detailing which seal impressions are associated with this item
echo '<table border = 1><tr><td></td><td>Examples</td></tr><tr><td></td><td>nature</td><td>number</td><td>position</td><td>shape</td></tr>';
while ($row = pg_fetch_array($query12result)) {
$value3 = $row[nature];
$value4 = $row[number];
$value5 = $row[position_latin];
$value6 = $row[shape];
$value7 = $row[id_seal];
$value8 = $row[representation_filename];
$value9 = $row[name_first] . " " . $row[name_last];
echo '<tr><td>' . $rowcount . '</td>';
echo '<td>' . $value3 . '</td>';
echo '<td>' . $value4 . '</td>';
echo '<td>' . $value5 . '</td>';
echo '<td>' . $value6 . '</td>';
echo '<td><a href=' . $address . '/entity/' .$value7.'>view seal</a></td>';
echo '<td><a href="'. $manifestation . $value8 . '" data-lightbox="example-1" data-title="' . $value2 . '<br>photo: ' . $value9 . '"><img src="'. $manifestation . $value8 . '" </img></a></td></tr>';
$rowcount++;
}
echo '</table>';
}
//for seal descriptions
If ($entity == 3) {
$row = pg_fetch_array($query8result);
//assign variables
$value1 = $row[index];
$value2 = $row[catalogue_volume];
$value3 = $row[catalogue_pagenumber];
$value4 = $row[sealdescription_identifier];
$value5 = $row[realizer];
$value6 = $row[motif_obverse];
if (isset($row[motif_reverse])) {
$value6 = "obverse: ". $value6 . "<br>reverse: " . $row[motif_reverse];
}
$value7 = $row[legend_obverse];
if (isset($row[legend_reverse])) {
$value6 = "obverse: ". $value6 . "<br>reverse: " . $row[legend_reverse];
}
$value8 = $row[shape];
$value9 = $row[sesalsize_vertical];
$value10 = $row[sealsize_horizontal];
$value11 = $row[id_seal];
$value12 = $row[representation_filename];
//formulate header
echo "SEAL DESCRIPTION";
echo "<br> DIGISIG ID: " . $id;
echo "<br> Permalink: http://digisig.org/entity/" . $id . "<br>";
// title
echo $value1 .":".$value4;
if (isset($value2)) {
echo ", vol." . $value2;
}
if (isset($value3)) {
if (strpos($value3,'-') !== false) {
echo ", p." . $value3;
}
else {
echo ", pp." . $value3;}
}
//output entry -- only output variables with values
if (isset($value5)) {
echo '<br><br> Name:'. $value5. '<br>';
}
if (isset($value6)) {
echo '<br> Motif:'.$value6. '<br>';
}
if (isset($value7)) {
echo '<br> Legend:'.$value7. '<br>';
}
if (isset($value8 )) {
echo '<br> Shape:'.$value8. '<br>';
}
if (isset($value9)) {
echo '<br> Size Vertical:'.$value9. '<br>';
}
if (isset($value10)) {
echo '<br> Size Horizontal:'.$value10. '<br>';
}
//prepare the photograph -- if it is available
if (isset($value12)) {
echo '<a href="'. $description . $value12 . '" data-lightbox="example-1" data-title=""><img src="'. $description . $value12 . '" height=200></img></a><br>';
}
//link to seal page
echo '<br><a href=' . $address . '/entity/' .$value11.'>view seal</a><br>';
//check for other seal descriptions
$query12 = "SELECT * FROM sealdescription_view WHERE id_seal = $value11";
$query12result = pg_query($query12);
$count = pg_num_rows($query12result);
if ($count > 1) {
echo "other descriptions";
$duplicate = $id;
sealdescription($query12result, $address, $duplicate);
}
}
//for a seal
If ($entity == 1) {
echo "SEAL";
echo "<br> DIGISIG ID:" . $id;
echo "<br> Permalink: http://digisig.org/entity/".$id;
echo '<table border = 1><tr><td>Shape</td><td>Height</td><td>Width</td></tr>';
// note that a seal can have two faces but I am going to assume that the double side ones are the same
$row = pg_fetch_array($query8result);
$value3 = $row[shape];
$value4 = $row[face_vertical];
$value5 = $row[face_horizontal];
echo '<td>' . $value3 . '</td>';
echo '<td>' . $value4 . '</td>';
echo '<td>' . $value5 . '</td></tr>';
$id_seal = $row[id];
echo "</table><br>";
// call seal description function to make list of associated seal descriptions
$query12 = "SELECT * FROM sealdescription_view WHERE id_seal = $id";
$query12result = pg_query($query12);
sealdescription($query12result, $address);
// list of associated seal impressions
$query10 = "SELECT * FROM shelfmark_view WHERE id_seal = $id";
$query10result = pg_query($query10);
echo '<table border = 1><tr><td>Examples</td></tr><tr><td></td><td>';
$rowcount = 1;
while ($row = pg_fetch_array($query10result)) {
$value1 = $row[nature];
$value2 = $row[number];
$value3 = $row[position_latin];
$value4 = $row[shape];
$value5 = $row[shelfmark];
$value6 = $row[id_item];
$value7 = $row[representation_filename];
$value8 = $row[name_first] . " " . $row[name_last];
$value9 = $row[repository_startdate];
$value10 = $row[repository_enddate];
echo '<tr><td>' . $rowcount . '</td>';
echo '<td>' . $value1 . '</td>';
echo '<td>' . $value2 . '</td>';
echo '<td>' . $value3 . '</td>';
echo '<td>' . $value4 . '</td>';
echo '<td> dated:' . $value9 . ' to ' . $value10;
echo '<td><a href=' . $address . '/entity/' .$value6.'>'. $value5 . '</a></td>';
echo '<td><a href="'. $manifestation . $value7 . '" data-lightbox="example-1" data-title="' . $value5 . '<br>photo: ' . $value8 . '"><img src="'. $manifestation . $value7 . '" height=50></img></a></td>';
echo '</tr>';
$rowcount++;
}
echo "</table><br>";
}
}
break;
case 'about': {
echo "<br>Text about the project";}
break;
case 'advanced search': {
echo "<br>Text about forthcoming search options";}
break;
case 'contact': {
echo "<br>Where to contact us";}
break;
default:
echo "Includes records from the following:<br>";
echo "<b>publications and projects</b><br>";
$query = "SELECT DISTINCT title, uri_catalogue FROM search_view WHERE title NOT IN ('Public Index') ORDER BY title";
$queryresults = pg_query($query);
while ($row = pg_fetch_assoc($queryresults)){
echo '<a href="' . $row[uri_catalogue] . '" target="_blank">' . $row[title] . '</a>';
echo "<br>";
}
echo "<b>repositories</b><br>";
$query = "SELECT DISTINCT repository_fulltitle, id_archoncode FROM shelfmark_view ORDER BY repository_fulltitle";
$queryresults = pg_query($query);
while ($row = pg_fetch_assoc($queryresults)){
echo '<a href="'. $archonsearch . "?_ref=" . $row[id_archoncode] . '" target="_blank">' . $row[repository_fulltitle] . '</a>';
echo "<br>";
}
}
include "include/footer.php";
?>
<script src="../DigiSig/include/lightbox/js/lightbox-plus-jquery.min.js"></script>
</body></html>