/
view_publication.php
executable file
·267 lines (209 loc) · 8.65 KB
/
view_publication.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
<?php
/**
* View Publication
*
* Given a publication id number this page shows most of the information about
* the publication. It does not display the extra information which is hidden
* and used only for the search function. It provides links to all the authors
* that are included. If a user is logged in, then there is an option to edit
* or delete the current publication.
*
* @package PapersDB
* @subpackage HTML_Generator
*/
/** Requries the base class and classes to access the database. */
require_once 'includes/pdHtmlPage.php';
require_once 'includes/pdPublication.php';
require_once 'includes/pdAttachmentTypesList.php';
/**
* Renders the whole page.
*
* @package PapersDB
*/
class view_publication extends pdHtmlPage {
private $debug = 0;
protected $pub_id;
protected $submit_pending;
protected $submit;
public function __construct() {
parent::__construct('view_publication', 'View Publication',
'view_publication.php');
if ($this->loginError) return;
$this->loadHttpVars();
if (!isset($this->pub_id) || !is_numeric($this->pub_id)) {
$this->pageError = true;
return;
}
$pub = new pdPublication();
$result = $pub->dbLoad($this->db, $this->pub_id);
if (!$result) {
echo 'Publication does not exist';
return;
}
if (isset($this->submit_pending) && $this->submit_pending) {
// check if this pub entry is pending
$q = $this->db->selectRow('pub_pending', '*',
array('pub_id' => $this->pub_id));
assert('$q');
$form = new HTML_QuickForm('submit_pending');
$form->addElement('hidden', 'submit_pending', true);
$form->addElement('hidden', 'pub_id', $this->pub_id);
$elements = array();
$elements[] = HTML_QuickForm::createElement(
'advcheckbox', 'valid', null, 'Valid', null, array(0, 1));
$elements[] = HTML_QuickForm::createElement(
'submit', 'submit', 'Submit');
$form->addGroup($elements, 'elgroup', '', ' ', false);
// create a new renderer because $form->defaultRenderer() creates
// a single copy
$renderer = new HTML_QuickForm_Renderer_Default();
$form->accept($renderer);
if ($form->validate()) {
$values =& $form->exportValues();
$pub->markValid($this->db);
echo 'Publication entry marked as valid.';
return;
}
else {
echo "<h2>This publication entry requires validation</h2>\n";
echo $renderer->toHtml();
}
}
$this->showPublication($pub);
}
private function showPublication(&$pub) {
$content = "<h2>" . $pub->title;
if ($this->access_level > 0) {
$content .= getPubIcons($this->db, $pub, 0xc);
}
$content .= "</h2>\n" . $pub->authorsToHtml();
if (isset($pub->paper) && (strtolower($pub->paper) != 'no paper')
&& (basename($pub->paper) != 'paper_')) {
if ($pub->paperExists()) {
$content .= 'Full Text: <a href="' . $pub->paperAttGetUrl()
. '">';
$name = split('paper_', $pub->paper);
if ($name[1] != '')
$content .= $name[1];
$content .= '</a> ';
$content .= getPubIcons($this->db, $pub, 0x1) . "<br/>\n";
}
}
// Show Additional Materials
$att_types = pdAttachmentTypesList::create($this->db);
if (count($pub->additional_info) > 0) {
$table = new HTML_Table(array('width' => '350',
'border' => '0',
'cellpadding' => '6',
'cellspacing' => '0'));
$heading = 'Other Attachments:';
$add_count = 1;
foreach ($pub->additional_info as $att) {
$cell = '';
if ($pub->attExists($att)) {
$name = split('additional_', $att->location);
$cell .= '<a href="'
. $pub->attachmentGetUrl($add_count - 1) . '">';
if ($name[1] != '')
$cell .= $name[1];
$cell .= '</a>';
if (in_array($att->type, $att_types))
$cell .= ' [' . $att->type . ']';
$cell .= ' <a href="'
. $pub->attachmentGetUrl($add_count - 1) . '">'
. $this->getPubAddAttIcons($att) . '</a>';
$add_count++;
}
$table->addRow(array($heading, $cell));
$heading = '';
}
$content .= $table->toHtml();
}
$content .= '<p/>' . stripslashes($pub->abstract) . '<p/>'
. '<h3>Citation</h3>' . $pub->getCitationHtml(). '<p/>';
$table = new HTML_Table(array('width' => '600',
'border' => '0',
'cellpadding' => '6',
'cellspacing' => '0'));
$category = '';
if (isset($pub->category) && isset($pub->category->category))
$category = $pub->category->category;
$table->addRow(array('Keywords:', $pub->keywordsGet()));
$table->addRow(array('Category:', $category));
if (isset($_SESSION['user'])
&& ($_SESSION['user']->showInternalInfo())) {
$table->addRow(array('Ranking:', $pub->ranking));
if (is_array($pub->collaborations)
&& (count($pub->collaborations) > 0)) {
$col_desciptions = $pub->collaborationsGet($this->db);
foreach ($pub->collaborations as $col_id) {
$values[] = $col_desciptions[$col_id];
}
$table->addRow(array('Collaboration:',
implode(', ', $values)));
}
$table->addRow(array('Extra Info:', $pub->extraInfoGet()));
}
if (isset($_SESSION['user'])
&& ($_SESSION['user']->showUserInfo())) {
$table->addRow(array('User Info:', $pub->user));
}
$web_links = $pub->getWebLinks();
if (count($web_links) > 0) {
$c = 0;
foreach ($web_links as $name => $url) {
if ($c == 0)
$label = 'Web Links:';
else
$label = '';
$table->addRow(array($label, '<a href="' . $url . '" '
. 'target="_blank">' . $name . '</a>'));
$c++;
}
}
if (count($pub->relatedPubsGet()) > 0) {
$c = 0;
foreach ($pub->relatedPubsGet() as $related_pub_id) {
if ($c == 0)
$label = 'Related Publication(s):';
else
$label = '';
$rel_pub = new pdPublication();
$rel_pub->dbLoad($this->db, $related_pub_id);
$table->addRow(array($label, '<a href="view_publication.php?'
. 'pub_id=' . $rel_pub->pub_id . '" '
. ' target="_blank">'
. $rel_pub->title . '</a>'));
$c++;
}
}
$table->updateColAttributes(0, array('class' => 'emph',
'width' => '25%'));
$content .= $table->toHtml();
$bibtex = $pub->getBibtex();
if ($bibtex !== false)
$content .= '<h3>BibTeX</h3><pre class="bibtex">' . $bibtex
. '</pre><p/>';
$updateStr = $this->lastUpdateGet($pub);
if ($updateStr != '') {
$updateStr ='Last Updated: ' . $updateStr . '<br/>';
}
$updateStr .= 'Submitted by ' . $pub->submit;
echo $content, '<span class="small">', $updateStr, '</span>';
}
public function lastUpdateGet($pub) {
$string = "";
$published = split("-",$pub->updated);
if (count($published) != 3) return false;
if ($published[1] != 00)
$string .= date("F", mktime (0,0,0,$published[1]))." ";
if ($published[2] != 00)
$string .= $published[2].", ";
if ($published[0] != 0000)
$string .= $published[0];
return $string;
}
}
$page = new view_publication();
echo $page->toHtml();
?>