-
Notifications
You must be signed in to change notification settings - Fork 0
/
expt.php
402 lines (338 loc) · 14.5 KB
/
expt.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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
<?php
/**
* @file expt.php
* @brief Experiment File.
*
* @author Nathalie Castells
*
* This page describe the experiment. It is a frame in which one can add modules
* In this development stage, some variables are encoded here but will eventually come from database or URL.
* @date 9/27/2018
*
*
*/
include_once 'includes/init.php'; // these are the settings that refer to more than one page
if (! isset($expt)) {
$expt = 'rbk1';
}
$exptFirst = $expt[0];
switch ($exptFirst) {
case "r":
$stationName = 'Rothamsted';
break;
case "s":
$stationName = 'Saxmundham';
break;
case "b":
$stationName = "Broom's Barn";
break;
case "w":
$stationName = "Woburn";
break;
}
// default experiment arbitrarily broadbalk. We could be more clever? random experiment?
$exptFolder = 'metadata/' . $expt;
$pageinfo = getPageInfo($expt);
$KeyRef = '';
if (is_array($pageinfo)) {
$KeyRef = $pageinfo['KeyRef'];
}
$page_title .= $pageinfo['Experiment']; // This is used in the head file as the title tag
$filedatacite = $exptFolder . '/' . 'experiment.json';
$hasDatacite = file_exists($filedatacite);
$datacite = "";
if ($hasDatacite) {
$datacite = file_get_contents($filedatacite);
$datacite = utf8_encode($datacite);
$experiment = json_decode($datacite, true);
$page_description = htmlentities($experiment['administrative']['description']);
# $page_keywords .= htmlentities(implode(' , ', $experiment['keywords']));
}
$fileExperiments = 'metadata/default/experiments.json';
$hasExperiments = file_exists($fileExperiments);
if ($hasExperiments) {
$Experiments = file_get_contents($fileExperiments);
$Experiments = utf8_encode($Experiments);
$Experiments = json_decode($Experiments, true);
}
$infofilessource = 'metadata/default/infofiles.json';
$hasFiles = file_exists($infofilessource);
if ($hasFiles) {
$infofiles = file_get_contents($infofilessource);
$infofiles = utf8_encode($infofiles);
$arrInfofiles = json_decode($infofiles, true);
}
if ($displayValue == 0) {# intranet site, we want to see all the pages including the ones that are not reviewed.
$pairs = array(
'exptID' => $expt,
'isInfo'=> '1',
'Type' => 'html'
);
} else { # live site: only display the pages that have been reviewed
$pairs = array(
'exptID' => $expt,
'isInfo'=> '1',
'isReviewed'=> '1',
'Type' => 'html'
);
}
$arrFilteredfiles = multiSearch($arrInfofiles, $pairs);
$hasDocs = count($arrFilteredfiles);
$fileTimeline = $exptFolder . '/' . 'timeline.json';
$hasTimeline = file_exists($fileTimeline);
if ($hasTimeline) {
$timeline = file_get_contents($fileTimeline);
}
$filePerson = $exptFolder . '/person.json';
$hasPerson = file_exists($filePerson);
if ($hasPerson) {
$jdata = file_get_contents($filePerson);
$jdata = utf8_encode($jdata);
$person = json_decode($jdata, true);
}
$fileSite = $exptFolder . '/site.json';
$hasSite = file_exists($fileSite);
if ($hasSite) {
$jdata = file_get_contents($fileSite);
$jdata = utf8_encode($jdata);
$site = json_decode($jdata, true);
}
$fileDesign = $exptFolder . '/design.json';
$hasDesign = file_exists($fileDesign);
if ($hasDesign) {
$jdata = file_get_contents($fileDesign);
$jdata = utf8_encode($jdata);
$design = json_decode($jdata, true);
$showDesign = FALSE;
if ($design[0]['administrative']['type'] != null) {
$showDesign = TRUE;
}
}
$fileDataset = $exptFolder . '/' . 'datasets.json';
$hasDatasets = file_exists($fileDataset);
$displayDatasets = 0;
if ($hasDatasets) {
$jdatasets = file_get_contents($fileDataset);
$jdatasets = utf8_encode($jdatasets);
$datasets = json_decode($jdatasets, true);
foreach ($datasets as $dataset) {
if ($dataset['isReady'] > $displayValue) {
$displayDatasets = 1;
}
}
}
$fileMedia = $exptFolder . '/' . 'medialist.html';
$hasMedia = file_exists($fileMedia);
$imageurl = $exptFolder . '/' . 'images.json';
$hasImages = file_exists($imageurl);
if ($hasImages) {
$jimages = file_get_contents($imageurl);
$jimages = utf8_encode($jimages);
$images = json_decode($jimages, true);
$displayImages = 0;
foreach ($images as $image) {
$displayImages += 1;
}
}
?>
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<?php
include 'includes/meta.html'; // that is the <meta and link tags> superseeds head.html
$script = ''; // $script is added to the header as the
if ($hasDatacite) {
$script = "<script type=\"application/ld+json\">" . $datacite . "</script>";
echo $script;
}
?>
</head>
<body>
<div class="container bg-white px-0">
<?php
include 'includes/header.html'; // all the menus at the top
// -- start dependant content ---------------------------------------------------------
?>
<div id="idExpt" class="p-0 mb-0">
<h1 class="mx-3"><?php
// /experimentname is found in the datadescription file.
echo title_case($experiment['administrative']['name']);
?></h1>
<div class="row">
<div class="col-12 pt-3">
<ul class="nav nav-tabs nav-fill text-body " id="Expttabs" role="tablist" >
<li class="nav-item">
<a class="nav-link active" id="overview-tab" data-toggle="tab" href="#overview" aria-controls="overview" aria-selected="true">Overview</a>
</li>
<li class="nav-item">
<a class="nav-link" id="site-tab" data-toggle="tab" href="#site" aria-controls="site" aria-selected="false">Site</a>
</li>
<?php if ($showDesign == TRUE) {?>
<li class="nav-item">
<a class="nav-link" id="design-tab" data-toggle="tab" href="#design" aria-controls="design" aria-selected="false">Design</a>
</li>
<?php }?>
<li class="nav-item">
<a class="nav-link" id="datasets-tab" data-toggle="tab" href="#datasets" aria-controls="datasets" aria-selected="false">Datasets</a>
</li>
<?php if ($displayImages >0) {?>
<li class="nav-item">
<a class="nav-link" id="images-tab" data-toggle="tab" href="#images" aria-controls="images" aria-selected="false">Media</a>
</li>
<?php }
if ($hasDocs >0 ) {?>
<li class="nav-item"><a class="nav-link" id="documents-tab" data-toggle="tab" href="#documents" aria-controls="documents" aria-selected="false">Information</a></li>
<?php
}
?>
<li class="nav-item"><a class="nav-link" id="bibliography-tab" data-toggle="tab" href="#bibliography" aria-controls="bibliography" aria-selected="false">Bibliography</a></li>
</ul>
<div class="tab-content mh-100" id="idExptTabs">
<div class="tab-pane fade show active pb-3" id="overview" role="tabpanel"
aria-labelledby="overview-tab">
<?php
include '_summary.php';
?>
</div>
<div class="tab-pane fade pb-3" id="design" role="tabpanel" aria-labelledby="design-tab">
<?php include '_design.php';?>
</div>
<div class="tab-pane fade pb-3" id="site" role="tabpanel" aria-labelledby="site-tab">
<?php include '_site.php';?>
</div>
<div class="tab-pane fade pb-3" id="datasets" role="tabpanel" aria-labelledby="datasets-tab">
<?php
$inDet = array(
"rbk1",
"rhb2",
"rpg5",
"rms",
"wms",
"bms"
);
if ($displayDatasets > 0) {
include '_datasets.php';
echo "<div class=\"mx-3\"><ul><li><a href=\"info/datasets\">List all eRA datasets</a></li><li>Additional data is available through <a class=\"btn btn-info m-1\" target=\"_BLANK\"
href=\"http://www3.rothamsted.ac.uk/cdera/extract/pages/data_extraction_prototype6.html\"><i
class=\"fa fa-list-alt\"></i> e-RAdata</a>. Please <a href=\"newGold.php\" >register for access</a></li></ul>. </div>";
} else if ($displayDatasets == 0) {
if (in_array($expt, $inDet)) {
echo "<div class=\"mx-auto\" style=\"width: 600px;\">Additional data is available through
<a class=\"btn btn-info m-1\" target=\"_BLANK\"
href=\"http://www3.rothamsted.ac.uk/cdera/extract/pages/data_extraction_prototype6.html\"><i
class=\"fa fa-list-alt\"></i> e-RAdata</a>.
Please <a href=\"newGold.php\" >register for access</a>. </div>
<div class=\"mx-auto\" style=\"width: 600px;\">
<img class=\"mx-auto\" src=\"images/600x400/DETtop2021.jpg\" alt\"Extract data\" width=\"600\" height=\"400\">
</div>";
} else if ($expt == "rwf3") {
echo "<div class=\"mx-auto\" style=\"width: 600px;\"> Datasets for Alternate Wheat and Fallow
are only available through <a class=\"btn btn-info m-1\" target=\"_BLANK\"
href=\"http://www3.rothamsted.ac.uk/cdera/extract/pages/data_extraction_prototype6.html\"><i
class=\"fa fa-list-alt\"></i> e-RAdata</a>. Please <a href=\"newGold.php\" >register for access</a>. </div>
<div class=\"mx-auto\" style=\"width: 600px;\">
<img class=\"mx-auto\" src=\"images/600x400/DETtop2021.jpg\" alt\"Extract data\" width=\"600\" height=\"400\">
</div>
";
} else {
echo "<div class=\"mx-auto\" style=\"width: 600px;\">There are currently no prepared datasets online for this experiment. However,
there may still be data available but requiring curation.
For more information please <a href=\"mailto:[email protected]\">contact the e-RA curators</a>. </div>
<div class=\"mx-auto\" style=\"width: 600px;\">
<img class=\"mx-auto\" src=\"images/600x400/sortingsamples.jpg\" alt\"Working on it\" width=\"600\" height=\"400\">
</div>";
}
}
?>
</div>
<div class="tab-pane fade" id="images" role="tabpanel" aria-labelledby="images-tab">
<h2 class="mx-3">License</h2>
<p class="mx-3">
<a rel="license" target="_blank" href="http://creativecommons.org/licenses/by/4.0/" target="out">
<img
style="width: 50px;"
alt="Creative Commons License"
src="images/logos/cc4.png"
/></a> These media (images and videos) are
available under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons
Attribution Licence (4.0)</a> with attribution to Rothamsted Research.
</p>
<?php if ($hasMedia) {
include $fileMedia;
} ?>
<?php include '_images.php';?>
</div>
<?php if ($hasDocs>0) {?>
<div class="tab-pane pb-3" id="documents" role="tabpanel" aria-labelledby="documents-tab">
<div class="mx-3">
<?php
/* include $fileDocs;
if (isset($sub)) {
$docpage = $exptFolder . '/' . $sub . '.html';
echo("<hr />");
include $docpage;
}
*/
include('_information.php');
?>
</div>
</div>
<?php }?>
<div class="tab-pane fade pb-3" id="bibliography" role="tabpanel"
aria-labelledby="bibliography-tab">
<div class="mx-3">
<?php
include '_keyrefs.php';
?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
// -- start footers ----------------------------
include_once 'includes/footer.html';
?>
<?php
include_once 'includes/finish.inc'; // this has the common js scripts
?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.10.0/baguetteBox.min.js"></script>
<script>
baguetteBox.run('.compact-gallery', {
animation: 'slideIn',
captions: function (element) {
return element.getElementsByTagName('img')[0].alt;
}
});
</script>
<script>
$(document).ready(() => {
let url = location.href.replace(/\/$/, "");
if (location.hash) {
const hash = url.split("#");
$('#Expttabs a[href="#' + hash[1] + '"]').tab("show");
$('li.active').removeClass('active');
$('a[href="#' + hash[1] + '"]').closest('li').addClass('active');
url = location.href.replace(/\/#/, "#");
history.replaceState(null, null, url);
setTimeout(() => {
$(window).scrollTop(0);
}, 400);
}
$('a[data-toggle="tab"]').on("click", function () {
let newUrl;
const hash = $(this).attr("href");
if (hash == "#home") {
newUrl = url.split("#")[0];
} else {
newUrl = url.split("#")[0] + hash;
}
newUrl += "/";
history.replaceState(null, null, newUrl);
});
});
</script>
</div>
</body>
</html>