/
index.php
executable file
·65 lines (48 loc) · 1.58 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
<?php
/**
* Main page for PapersDB.
*
* Main page for public access, provides a login, and a function that selects
* the most recent publications added.
*
* @package PapersDB
* @subpackage HTML_Generator
*/
/** Requries the base class and classes to access the database. */
require_once 'includes/pdHtmlPage.php';
require_once 'includes/pdPubList.php';
/**
* Renders the whole page.
*
* @package PapersDB
*/
class index extends pdHtmlPage {
public function __construct() {
parent::__construct('home');
if ($this->loginError) return;
$this->recentAdditions();
$this->pubByYears();
}
private function recentAdditions() {
$pub_list = pdPubList::create($this->db, array('sort_by_updated' => true));
if (empty($pub_list) || (count($pub_list) == 0)) return;
echo '<h2>Recent Additions:</h2>';
echo displayPubList($this->db, $pub_list, false, 6);
}
private function pubByYears() {
$pub_years = pdPubList::create($this->db, array('year_list' => true));
if (empty($pub_years) || (count($pub_years) == 0)) return;
$table = new HTML_Table(array('class' => 'nomargins',
'width' => '60%'));
$text = '';
foreach (array_values($pub_years) as $item) {
$text .= '<a href="list_publication.php?year=' . $item['year']
. '">' . $item['year'] . '</a> ';
}
$table->addRow(array($text));
echo '<h2>Publications by Year:</h2>', $table->toHtml();
}
}
$page = new index();
echo $page->toHtml();
?>