-
Notifications
You must be signed in to change notification settings - Fork 3
/
details.php
314 lines (265 loc) · 14.8 KB
/
details.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
<?php
use airmoi\FileMaker\FileMakerException;
require_once('utilities.php');
require_once ('credentials_controller.php');
require_once ('constants.php');
require_once ('DatabaseSearch.php');
session_set_cookie_params(0,'/','.ubc.ca',isset($_SERVER["HTTPS"]), true);
session_start();
define('DATABASE', $_GET['Database'] ?? null);
checkDatabaseField(DATABASE);
try {
$databaseSearch = DatabaseSearch::fromDatabaseName(DATABASE);
} catch (FileMakerException $e) {
$_SESSION['error'] = 'Unsupported database given';
header('Location: error.php');
exit;
}
$findCommand = $databaseSearch->getFileMaker()->newFindCommand($databaseSearch->getDetailLayout()->getName());
# add a search param to the query to exactly '==' equal the accession number
if (isset($_GET['AccessionNo']) && $_GET['AccessionNo'] !== '') {
$findCommand->addFindCriterion($databaseSearch->getIDFieldName(), '=='.$_GET['AccessionNo']);
}
try {
$result = $findCommand->execute();
} catch (FileMakerException $e) {
$_SESSION['error'] = 'Search fields returned an error!';
header('Location: error.php');
exit;
}
$allRecordsFound = $result->getRecords();
# we should only get one record back!
if (sizeof($allRecordsFound) != 1) {
$_SESSION['error'] = 'No records or more than one records found. This is an internal error. Please contact the admin!';
header('Location: error.php');
exit;
}
$record = $allRecordsFound[0];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://herbweb.botany.ubc.ca/arcgis_js_api/library/4.10/esri/css/main.css">
<link rel="stylesheet" href="css/details.css">
<?php
require_once('partials/conditionalCSS.php');
require_once ('partials/widgets.php');
HeaderWidget('Specie Details');
?>
</head>
<body class="d-flex flex-column">
<?php Navbar(); ?>
<?php TitleBanner(DATABASE); ?>
<div class="container-fluid">
<div class="row">
<!-- Specie Information -->
<div class="col-sm-9">
<!-- construct table for given layout and fields -->
<table class="table">
<tbody>
<?php
$fields = $record->getFields();
$ignoreLayoutFieldNames = ['SortNum', 'Accession Numerical', 'Photographs::photoContainer', 'Imaged', 'IIFRNo', 'Photographs::photoFileName', 'Event::eventDate', 'iffrCardNb', 'card01', 'Has Image', 'imaged','card02','card03','card04','card05','card06','card07','card08','card09','card10','card11','card12','card13'];
foreach($fields as $field) :
# ignore values in field keys contained in the ignored list
if (in_array($field, $ignoreLayoutFieldNames)) continue;?>
<tr>
<th><b><?php echo formatField($field) ?></b></th>
<?php if(formatField($field) == "Genus" || formatField($field) == "Species") : ?>
<td style="font-style:italic;">
<?php else: ?>
<td
<?php
if (formatField($field) === "Latitude") {echo "id='Latitude'"; $lat = $allRecordsFound[0]->getField($field);}
if (formatField($field) === "Longitude") {echo "id='Longitude'"; $long = $allRecordsFound[0]->getField($field);}
?>
>
<?php endif; ?>
<?php echo $allRecordsFound[0]->getField($field) ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<!-- Images and Maps -->
<div class="col-sm-3">
<!-- ArcGIS Map -->
<div class="row">
<div class="col">
<?php if(isset($lat) && isset($long)) : ?>
<div id="viewDiv" style="height: 300px;"></div>
<script src="https://herbweb.botany.ubc.ca/arcgis_js_api/library/4.10/dojo/dojo.js"></script>
<script src="js/map.js"></script>
<?php else: ?>
<div style="height: 300px; text-align:center; line-height:300px;">
<span style="">No coordinates for this record</span>
</div>
<?php endif; ?>
</div>
</div>
<!-- image code starts here -->
<div class="row">
<div class = "col">
<div class = "slideshow-container">
<?php
if (DATABASE === 'fish') {
$numOfCards = $allRecordsFound[0]->getField("iffrCardNb");
for ($num = 1; $num <= $numOfCards; $num++) {
$num_padded = sprintf("%02d", $num);
$cardName = "card".$num_padded;
$url = 'https://open.library.ubc.ca/media/download/jpg/fisheries/'.$allRecordsFound[0]->getField($cardName).'/0';
$linkToWebsite = 'https://open.library.ubc.ca/collections/fisheries/items/'.$allRecordsFound[0]->getField($cardName);
if (@getimagesize($url)[0] >0 && @getimagesize($url)[1] > 0) {
echo '<div class="mySlides">';
echo '<a href ='. htmlspecialchars($linkToWebsite).' target="_blank" rel="noopener noreferrer">'.
'<img id = "fish" class="img-fluid minHeight" src="'.htmlspecialchars($url) .'" alt="Image of the specimen"></a>';
} else {
echo '<div style="height: 300px; text-align:center; line-height:300px;">';
echo '<span style="">No picture found for this record</span>';
}
echo '</div>';
}
echo '<a class="prevbutton" onclick="plusSlides(-1)">❮</a>';
echo '<a class="nextbutton" onclick="plusSlides(1)">❯</a>';
}
else if (DATABASE === 'entomology') {
$genusPage = getGenusPage($allRecordsFound[0]);
$genusSpecies = getGenusSpecies($allRecordsFound[0]);
$semnumber = $allRecordsFound[0]->getField('SEM #');
$foundImage = false;
if($foundImage==false) {
echo '<div style="height: 300px; text-align:center; line-height:300px;">';
$order = $allRecordsFound[0]->getField('Order');
$fam=$allRecordsFound[0]->getField("Family");
echo ' <a href="https://www.zoology.ubc.ca/entomology/main/'.$order.'/'.$fam.'/" style="text-align:center;">
<role="button" class="btn btn-custom" id="showAll" > See more of '.$fam.' here!</button> </a> ';
echo '</div>';
}
}
else {
$validDb = false;
if (DATABASE == 'avian' ||DATABASE == 'herpetology' || DATABASE == 'mammal') {
$tableNamesObj = $allRecordsFound[0]->getRelatedSet('Photographs');
// if images, type = 'array'; else 'object'
if (gettype($tableNamesObj)=='array') {
foreach ($tableNamesObj as $relatedRow) {
$possible_answer = $relatedRow->getField('Photographs::photoContainer');
if (str_contains(strtolower($possible_answer), "jpg")){ // delete this if later
$possible_answer= "https://collections.zoology.ubc.ca".$possible_answer;
echo '<div class="mySlides">';
echo '<a href ='.$possible_answer.' target="_blank" rel="noopener noreferrer">'.
'<img id = "avian" class="img-fluid minHeight" src="'.$possible_answer .'"></a>';
echo '</div>';
}
}
echo '<a class="prevbutton" onclick="plusSlides(-1)">❮</a>';
echo '<a class="nextbutton" onclick="plusSlides(1)">❯</a>';
$validDb = false;
} else {
echo '<div style="height: 300px; text-align:center; line-height:300px;">';
echo '<span style="">No picture found for this record</span>';
echo '</div>';
}
}
else if (DATABASE == 'vwsp' || DATABASE == 'bryophytes' || DATABASE == 'fungi'
|| DATABASE == 'lichen' || DATABASE == 'algae') {
$url = getPhotoUrl($_GET['AccessionNo'], DATABASE);
$validDb = true;
}
if ($validDb) {
if (@getimagesize($url)[0] >0 && @getimagesize($url)[1] > 0) {
echo '<a href ='. htmlspecialchars($url).' target="_blank" rel="noopener noreferrer">'.'<img class="img-fluid minHeight" src="'.htmlspecialchars($url) .'"></a>';
} else {
echo '<div style="height: 300px; text-align:center; line-height:300px;">';
echo '<span style="">No picture found for this record</span>';
echo '</div>';
}
}
}
?>
</div>
<!-- Slideshow UI controller -->
<div style="text-align:center">
<?php // adds the dots to the slideshow
if (DATABASE === 'fish') {
for ($num=1; $num<=$numOfCards; $num++){
echo '<span class="dot" onclick="currentSlide('.$num.')"></span>';
}
}
if (DATABASE === 'avian' || DATABASE === 'mammal' || DATABASE === 'herpetology') {
$num =1;
foreach ($tableNamesObj as $relatedRow){
if (gettype($tableNamesObj)=='array') {
$possible_answer = $relatedRow->getField('Photographs::photoContainer');
if ((str_contains(strtolower($possible_answer), "jpg"))){ // delete if later
echo '<span class="dot" onclick="currentSlide('.$num.')"></span>';
}
}
$num++;
}
}
if (DATABASE === 'entomology'){
if ($foundImage===true){
$images = 0;
for ($num=1; $num<=sizeof($images); $num++){
echo '<span class="dot" onclick="currentSlide('.$num.')"></span>';
}
}
}
?>
</div>
</div>
</div>
<!-- entomology special link to more images -->
<div class="row">
<?php
if (DATABASE === 'entomology'){
if ($foundImage===true){
$fam=$allRecordsFound[0]->getField("Family");
$subfam=$allRecordsFound[0]->getField("Subfamily");
if ($subfam!==""){
echo '<a href="'.$url.'" style="text-align:center;">
<button class="btn btn-custom" id="showAll" > See more '.$subfam.' here!</button> </a>';
} else {
echo ' <a href="'.$url.'" style="text-align:center;">
<role="button" class="btn btn-custom" id="showAll" > See more '.$fam.' here!</button> </a> ';
}
}
}
?>
</div>
</div>
</div>
</div>
<?php FooterWidget('images/beatyLogo.png') ;?>
<script>
// js slideshow
let slideIndex = 1;
showSlides(slideIndex);
// Next/previous controls
function plusSlides(n) {
showSlides(slideIndex += n);
}
// Thumbnail image controls
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
let i;
const slides = document.getElementsByClassName("mySlides");
const dots = document.getElementsByClassName("dot");
if (n > slides.length) { slideIndex = 1 }
if (n < 1) { slideIndex = slides.length }
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
}
</script>
</body>
</html>