-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
94 lines (89 loc) · 3.13 KB
/
index.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
<?php
include "env/config.php";
include "lib/helpers.php";
?>
<html>
<?php include "layout/head.html"; ?>
<script>
$(function() {
$(".ref-toggle").click(function() {
$(".ref").each(function() {
if ($(this).hasClass("collapsed")) { $(this).removeClass("collapsed") }
else { $(this).addClass("collapsed") }
});
})
});
</script>
<body>
<?php include "layout/navbar.php"; ?>
<div class="container">
<h4>Annotations by Status</h4>
<div class="navbar">
<ul class="nav nav-pills">
<?php echo make_link(""); ?>
<?php echo make_link("Needs Correction", "Correction"); ?>
<?php echo make_link("Needs Annotation", "Annotation"); ?>
<?php echo make_link("Draft"); ?>
<?php echo make_link("Complete"); ?>
<?php echo make_link("Published"); ?>
</ul>
</div>
<div class="results">
<?php
// GET a request to the flask url for the requested tag (or no tags if all annotations)
$curl = curl_init();
$url = (isset($_GET["tag"])
? $flask_url."/search?limit=$status_index_annos_max&tags=" . $_GET["tag"]
: $flask_url."/search?limit=$status_index_annos_max")
;
$url = str_replace(" ", "%20", $url);
curl_setopt($curl, CURLOPT_URL, $url);
// Set user agent to not trigger mod_security rule for no user agent
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (curl; Linux x86_64; Annotonia Status)');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// Disable cert checking to bypass curl cert error with Acme.sh certs
// Local only traffic and public data, so not really a risk
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$res = curl_exec($curl);
curl_close($curl);
// Parse json and display results
$annotations = json_decode($res, true);
$annos_returned = count($annotations["rows"]);
?>
<h5>
<?php echo $annotations["total"] ?> annotation(s), displaying the most
recently edited <?php echo $annos_returned ?>
</h5>
<?php
$refs_present = false;
for ($i = 0; $i < $annos_returned; $i++):
$anno = $annotations["rows"][$i];
if (isset($anno["anno_ref_id"]) && $anno["anno_ref_id"] !== "") {
$ref_present = true;
break;
}
endfor;
if ($ref_present) {
echo <<<END
<div class="form-inline">
<div class="checkbox">
<input id="ref-toggle" class="ref-toggle" type="checkbox"
checked="checked">
<label for="ref-toggle">Hide reference annotations</label>
</div>
</div>
END;
}
?>
<hr>
<div>
<?php for ($i = 0; $i < $annos_returned; $i++):
$anno = $annotations["rows"][$i];
$tag_html = generate_tags($anno["tags"]);
include "includes/annotation.php";
endfor ?>
</div>
</div>
</div>
</body>
</html>