This repository was archived by the owner on Aug 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewer.php
More file actions
225 lines (190 loc) · 9.08 KB
/
Copy pathviewer.php
File metadata and controls
225 lines (190 loc) · 9.08 KB
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
<?php
/**
* @file viewer.php
* @author Collin Haines - Center for Digital Humanities
*
* The metaphorical end-game of the Plants and Planters - Henry Ravenel site. This
* page allows our users to view two main categories: Transcripts or Specimens. All
* search results, map details, and random clicks will end here at one point.
*
* This page uses URL rewriting through the .htaccess file.
*
* NOTE: The terms 'Transcript' and 'Manuscript' are used interchangeably from here
* on in unless referring to the human-typed version of text within an image.
*
* @param string type
* Acceptable as either transcript or specimen.
* @param string institute
* Must be Carolina when the type is equal to specimen. Otherwise, is fair game
* as long as it matches correctly with the manuscript pointer.
* @param int number
* Representing a pointer (transcript) or catalog number (specimen).
* @param string search
* Mainly used when arrving from search results, this'll tell the application any
* word(s) to highlight.
*
*/
require_once "includes/configuration.php";
// AJAX method for viewing a specimen on the manuscript viewer.
// AJAX method for viewing a manuscript on the specimen viewer.
if (isset($_GET["catalogNumber"]) || isset($_GET["pointer"], $_GET["institute"])) {
$item = isset($_GET["catalogNumber"]) ? new Specimen($_GET["catalogNumber"]) : new Manuscript($_GET["pointer"], $_GET["institute"]);
$type = isset($_GET["catalogNumber"]) ? "specimen" : "manuscript";
// Panel viewer.
$panel = '<div class="col-md-6 panel-viewer" id="' . $type . 'SideViewer" style="display: none;">';
$panel .= '<div class="panel-thumbnail"><div class="thumbnail-overlay" style="max-width: 100%;"></div><img src="' . $item->getThumb() . '" class="img-responsive"></div>';
$panel .= '<div class="col-xs-12 panel-tools"><ul class="list-inline center-block">';
$panel .= '<li><a href="#zoom-in" class="btn btn-default zoom-plus" data-toggle="tooltip" data-placement="top" title="Zoom In"><i class="fa fa-plus"></i></a></li>';
$panel .= '<li><a href="#zoom-out" class="btn btn-default zoom-minus" data-toggle="tooltip" data-placement="top" title="Zoom Out"><i class="fa fa-minus"></i></a></li>';
$panel .= '<li><a href="#refresh" class="btn btn-default refresh disabled" data-toggle="tooltip" data-placement="top" title="Refresh"><i class="fa fa-refresh"></i></a></li>';
$panel .= '<li><a href="' . $item->getImage() . '" class="btn btn-default full-screen" data-effect="fancybox" data-toggle="tooltip" data-placement="top" title="Full Screen"><i class="fa fa-arrows-alt"></i></a></li>';
$panel .= "</ul></div>";
$panel .= '<img src="' . $item->getImage() . '" class="img-responsive max-width-transition"></div>';
// Metadata.
$data = '<div class="col-md-6 col-xs-12" id="' . $type . 'Data" style="display: none;">' . $item->renderViewerMetadata() . '</div>';
exit(json_encode(array("image" => $panel, "metadata" => $data)));
} // if (isset($_GET["catalogNumber"]) || isset($_GET["pointer"], $_GET["institute"]))
if (!isset($_GET["type"], $_GET["institute"], $_GET["number"])) {
header("Location: /");
} // if (!isset($_GET["type"], $_GET["institute"], $_GET["number"]))
// With the allowance of non-mandatory trailing slashes, this guy sometimes appear.
if (isset($_GET["search"]) && $_GET["search"] === ".php") {
header("Location: /viewer/" . $_GET["type"] . "/" . $_GET["institute"] . "/" . $_GET["number"]);
} // if (isset($_GET["search"]) && $_GET["search"] === ".php")
if ($_GET["number"] < 2000 && strcasecmp($_GET["institute"], "Carolina") === 0) {
header("Location: /viewer/" . $_GET["type"] . "/Clemson/" . $_GET["number"]);
} else if (2000 < $_GET["number"] && strcasecmp($_GET["institute"], "Clemson") === 0) {
header("Location: /viewer/" . $_GET["type"] . "/Carolina/" . $_GET["number"]);
} // if ($_GET["number"] < 2000 && strcasecmp($_GET["institute"], "Carolina") === 0)
// Define if there is a search.
$search = isset($_GET["search"]) ? str_replace("-", " ", $_GET["search"]) : "";
// Alert the page if it is a photograph.
$isPhoto = 9088 < $_GET["number"] && $_GET["number"] < 9154 && $_GET["type"] === "transcript";
try {
if ($_GET["type"] === "transcript") {
$manuscript = new Manuscript($_GET["number"], $_GET["institute"]);
$manuscript->setSearch($search);
// Set stuff within the page.
$image = $manuscript->getImage();
$thumb = $manuscript->getThumb();
$title = $manuscript->getData("title");
$application->setTitle($title . " - Manuscript Viewer");
} else if ($_GET["type"] === "specimen") {
$specimen = new Specimen($_GET["number"]);
$specimen->setSearch($search);
// Set stuff within the page.
$image = $specimen->getImage();
$thumb = $specimen->getThumb();
$title = $specimen->getName();
$application->setTitle($title . " - Specimen Viewer");
} else {
throw new Exception("Improper type: " . $_GET["type"]);
} // if ($_GET["type"] === "transcript")
require "layout/header.php";
} catch (Exception $e) {
$application->setTitle("Viewer");
require "layout/header.php";
?>
<div class="container">
<div class="row page-header" style="padding-top: 5vh; padding-bottom: 20vh;">
<div class="col-xs-12">
<h1>Error Rendering Viewer Page</h1>
<p class="lead"><?php print $e->getMessage(); ?></p>
</div>
</div>
</div>
<?php
require "layout/footer.php";
exit;
} // try
?>
<div class="container">
<div class="row page-header">
<div class="col-xs-12">
<h1><?php print $title; ?></h1>
<?php if ($search !== ""): ?>
<p class="text-muted">
<a href="<?php print ROOT_FOLDER; ?>search?search=<?php print urlencode($search); ?>" class="text-muted">Return to Search Results</a>
</p>
<?php endif; ?>
</div>
</div>
<div class="row">
<div class="<?php print $isPhoto ? "col-xs-12" : "col-md-6"; ?> panel-viewer height-transition" id="mainViewer" style="height: <?php print $isPhoto ? "1000px;" : "500px;"; ?>">
<div class="image-loading-icon">
<i class="fa fa-refresh fa-3x fa-spin"></i>
</div>
<div class="panel-thumbnail">
<div class="thumbnail-overlay max-width-height-transition" style="max-width: 100%;"></div>
<img src="<?php print $thumb; ?>" class="img-responsive">
</div>
<div class="col-xs-12 panel-tools">
<ul class="list-inline center-block">
<li>
<a href="#zoom-in" class="btn btn-default zoom-plus" data-toggle="tooltip" data-placement="top" title="Zoom In">
<i class="fa fa-plus"></i>
</a>
</li>
<li>
<a href="#zoom-out" class="btn btn-default zoom-minus" data-toggle="tooltip" data-placement="top" title="Zoom Out">
<i class="fa fa-minus"></i>
</a>
</li>
<li>
<a href="#refresh" class="btn btn-default refresh disabled" data-toggle="tooltip" data-placement="top" title="Refresh">
<i class="fa fa-refresh"></i>
</a>
</li>
<li>
<a href="<?php print $image; ?>" class="btn btn-default full-screen" data-effect="fancybox" data-toggle="tooltip" data-placement="top" title="Full Screen">
<i class="fa fa-arrows-alt"></i>
</a>
</li>
</ul>
</div>
<img src="<?php print $image; ?>" class="img-responsive max-width-height-transition" alt="<?php print $title; ?>" id="mainImage">
</div>
<?php if (!$isPhoto): ?>
<div class="col-md-6 panel-viewer panel-reading">
<div class="panel-content">
<?php
if ($_GET["type"] === "transcript") {
$renderData = false;
$transcript = $manuscript->getData("transc");
if ($transcript === "") {
$renderData = true;
print $manuscript->renderViewerMetadata();
} else {
print '<pre>' . $application->highlightSearchTerm($transcript, $search) . '</pre>';
} // if ($transcript === "")
} else if ($_GET["type"] === "specimen") {
print $specimen->renderViewerMetadata();
} // if ($_GET["type"] === "transcript")
?>
</div>
</div>
<?php endif; ?>
</div>
<?php if ($_GET["type"] === "transcript"): ?>
<div class="row" style="margin-top: 1.5%;">
<div class="col-md-6 text-center pages width-transition">
<?php print $manuscript->retrieveSiblings(); ?>
</div>
<div class="col-md-6 text-center" id="toggleRightPanel" style="display: none;"></div>
</div>
<?php endif; ?>
<hr>
<?php if (!$isPhoto): ?>
<div class="row">
<?php if ($_GET["type"] === "transcript" && !$renderData): ?>
<div class="col-md-6 col-xs-12 left-transition" id="viewerMetadata" style="left: 0;">
<?php print $manuscript->renderViewerMetadata(); ?>
</div>
<?php elseif ($_GET["type"] === "specimen"): ?>
<?php print $specimen->renderJournalMentions(); ?>
<?php print $specimen->renderSimilarSpecimens(); ?>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<?php require "layout/footer.php"; ?>