-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathitems.php
214 lines (196 loc) · 10.9 KB
/
items.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
<?php
include_once 'data.php';
include_once 'functions.php';
session_write_close();
if (isset($_GET['delete']) && isset($_GET['file'])) {
database_connect($database_path, 'library');
$error = null;
$error = delete_record($dbHandle, $_GET['file']);
die($error);
}
if (isset($_GET['neighbors']) && isset($_GET['file'])) {
$export_files = read_export_files(0);
$current_record = array_search($_GET['file'], $export_files);
isset($export_files[$current_record - 1]) ? $prevrecord = $export_files[$current_record - 1] : $prevrecord = 'none';
isset($export_files[$current_record + 1]) ? $nextrecord = $export_files[$current_record + 1] : $nextrecord = 'none';
die($prevrecord.':'.$nextrecord);
}
$export_files = read_export_files(0);
if (empty($export_files)) {
//HACK, SOMETIMES CLIENT IS REFRESHING EXPORT FILES
sleep(1);
$export_files = read_export_files(0);
}
if (empty($export_files)) die('Error! No files to display.');
?>
<div id="items-left" class="noprint alternating_row" style="position:relative;float:left;width:233px;height:100%;overflow:scroll;border:0;margin:0">
<?php
if(empty($_GET['file'])) $_GET['file'] = $export_files[0];
$key = array_search(intval($_GET['file']), $export_files);
$offset = max($key-9, 0);
if ($offset > count($export_files) - 20) {
$offset = max(count($export_files) - 20, 0);
}
$show_items = array_slice($export_files, $offset, 20);
if ($offset > 0) {
print '<div class="ui-state-highlight lib-shadow-bottom" style="margin-bottom:4px;height:17px" title="Previous">';
print '<a href="items.php?file='.$export_files[$offset-1].'" class="navigation" style="display:block;width:100%" id="'.$export_files[$offset-1].'">';
print '<span class="ui-icon ui-icon-triangle-1-n" style="margin:auto"></span>';
print '</a></div>';
}
print '<div id="list-title-copy" class="items" style="font-weight:bold"></div><div class="separator"></div>';
$divs = array();
database_connect($database_path, 'library');
$query = join (",", $show_items);
$result = $dbHandle->query("SELECT id,title FROM library WHERE id IN (".$query.")");
$result = $result->fetchAll(PDO::FETCH_ASSOC);
//SORT QUERY RESULTS
$tempresult = array();
foreach ($result as $row) {
$key = array_search($row['id'], $show_items);
$tempresult[$key] = $row;
}
ksort($tempresult);
$result = $tempresult;
foreach ($result as $item) {
$divs[] = '<div id="list-item-'.$item['id'].'" class="items listleft">'.
$item['title'].
'</div>';
}
$result = null;
if (isset($_GET['file'])) {
$id_query = $dbHandle->quote($_GET['file']);
$result = $dbHandle->query("SELECT * FROM library WHERE id=$id_query LIMIT 1");
$paper = $result->fetch(PDO::FETCH_ASSOC);
$result = null;
$current_record = array_search($_GET['file'], $export_files);
isset($export_files[$current_record - 1]) ? $prevrecord = $export_files[$current_record - 1] : $prevrecord = null;
isset($export_files[$current_record + 1]) ? $nextrecord = $export_files[$current_record + 1] : $nextrecord = null;
}
$dbHandle = null;
$hr = '<div class="separator"></div>';
print join ($hr, $divs);
if ($offset < count($export_files) - 20) {
print '<div class="ui-state-highlight lib-shadow-top" style="margin-top:4px" title="Next">';
print '<a href="items.php?file='.$export_files[$offset+20].'" class="navigation" style="display:block;width:100%" id="file-'.$export_files[$offset+20].'">';
print '<span class="ui-icon ui-icon-triangle-1-s" style="margin:auto"></span>';
print '</a></div>';
}
?>
</div>
<div class="alternating_row middle-panel"
style="float:left;width:6px;height:100%;overflow:hidden;border-right:1px solid #b5b6b8;cursor:pointer">
<span class="ui-icon ui-icon-triangle-1-w" style="position:relative;left:-5px;top:49%"></span>
</div>
<div style="width:100%;height:100%;overflow:hidden" id="items-right" data-file="<?php echo $paper['id'] ?>">
<?php
if (!empty($paper['id'])) {
?>
<table cellspacing="0" class="top" style="margin-top:2px;margin-bottom:1px">
<tr>
<td class="top">
<div class="ui-state-highlight ui-corner-top" id="file-item" style="float:left;margin-left:2px;padding-right:4px">
<span class="ui-icon ui-icon-home" style="float:left;width:16px"></span>Item
</div>
<?php
if (isset($_SESSION['auth'])) {
?>
<div class="ui-state-highlight ui-corner-top" id="file-pdf" style="float:left;margin-left:2px;padding-right:4px">
<span class="ui-icon ui-icon-document" style="float:left"></span>PDF
</div>
<?php
if ($_SESSION['permissions'] != 'G') {
?>
<div class="ui-state-highlight ui-corner-top" id="file-edit" style="float:left;margin-left:2px;padding-right:4px">
<span class="ui-icon ui-icon-gear" style="float:left"></span>Edit
</div>
<?php
}
?>
<div class="ui-state-highlight ui-corner-top" id="file-notes" style="float:left;margin-left:2px;padding-right:4px">
<span class="ui-icon ui-icon-pencil" style="float:left"></span>Notes
</div>
<div class="ui-state-highlight ui-corner-top" id="file-categories" style="float:left;margin-left:2px;padding-right:4px">
<span class="ui-icon ui-icon-tag" style="float:left"></span>Categories
</div>
<div class="ui-state-highlight ui-corner-top" id="file-files" style="float:left;margin-left:2px;padding-right:4px">
<span class="ui-icon ui-icon-script" style="float:left"></span>Files
</div>
<div class="ui-state-highlight ui-corner-top" id="file-discussion" style="float:left;margin-left:2px;padding-right:4px">
<span class="ui-icon ui-icon-comment" style="float:left"></span>Discuss
</div>
<?php
}
?>
</td>
<td class="top">
<div class="ui-state-highlight backbutton ui-corner-top" style="float:right;margin-left:2px;margin-right:4px" title="Back to list view (Q)">
<span class="ui-icon ui-icon-squaresmall-close" style="float:left"></span>Close
</div>
<?php
if (isset($_SESSION['auth'])) {
if ($_SESSION['permissions'] != 'G') {
?>
<div class="ui-state-highlight ui-corner-top" style="float:right;margin-left:2px" id="deletebutton">
<span class="ui-icon ui-icon-trash" style="float:left"></span>Delete
</div>
<?php
}
?>
<div class="ui-state-highlight ui-corner-top" style="float:right;margin-left:2px" id="printbutton">
<span class="ui-icon ui-icon-print" style="float:left"></span>Print
</div>
<div id="exportfilebutton" class="ui-state-highlight ui-corner-top" style="float:right;margin-left:2px">
<span class="ui-icon ui-icon-suitcase" style="float:left"></span>Export
</div>
<div class="ui-state-highlight ui-corner-top" style="float:right;margin-left:2px">
<a href="mailto:?subject=Paper in I, Librarian&body=<?php
print htmlspecialchars(wordwrap($paper['title_ascii'], "75", "%0A", false))
. '%0A%0A' . htmlspecialchars(wordwrap(substr($paper['abstract_ascii'], 0, 512), "75", "%0A", false))
. htmlspecialchars(empty($paper['doi']) ? '' : '%0A%0APublisher link:%0Ahttp://dx.doi.org/' . $paper['doi'])
. '%0A%0AI, Librarian link:%0A' . htmlspecialchars($url . '?id=' . $paper['id'])
. (file_exists('library/' . $paper['file']) ? '%0A%0ADirect link to the PDF:%0A' . htmlspecialchars($url.'downloadpdf.php?file='.$paper['file']) : '')
?>"
target="_blank" style="color:black;display:inline-block">
<span class="ui-icon ui-icon-mail-closed" style="float:left"></span>E-Mail </a>
</div>
<?php
}
?>
</td>
</tr>
</table>
<div id="file-panel" style="width:100%;height:48%;border-top:1px solid #c6c8cc;border-bottom:1px solid #c6c8cc;overflow:auto">
</div>
<table class="top" cellspacing=0 style="width:100%">
<tr>
<td style="text-align:center">
<table cellspacing=0 style="margin:auto">
<tr>
<td>
<div title="Shortcut: W" class="prevrecord ui-state-highlight<?php print empty($prevrecord) ? ' ui-state-disabled' : '' ?>" id="prev-item-<?php print $prevrecord ?>">
<span class="ui-icon ui-icon-triangle-1-n" style="float:left"></span>Prev
</div>
</td>
<td style="padding:0px 8px">
<div class="ui-state-highlight backbutton noprint" title="Back to list view (Q)">
<span class="ui-icon ui-icon-squaresmall-close" style="float:left"></span>Close
</div>
</td>
<td>
<div title="Shortcut: S" class="nextrecord ui-state-highlight<?php print empty($nextrecord) ? ' ui-state-disabled' : '' ?>" id="next-item-<?php print $nextrecord ?>">
<span class="ui-icon ui-icon-triangle-1-s" style="float:left"></span>Next
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php
include_once 'coins.php';
} else {
print '<h3> Error! This item does not exist.<br> Reload of the library is recommended.</h3>';
}
?>
</div>