forked from jamesread/Vitae
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewDatabase.php
85 lines (68 loc) · 1.85 KB
/
viewDatabase.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
<?php
require_once 'common.php';
?>
<style type = "text/css">
a {
text-decoration: none;
}
a.delete:hover {
background-color: salmon;
color: white;
}
fieldset {
border: 0;
}
div.box {
background-color: beige;
display: inline-block;
}
h2 {
margin: 0;
}
hr {
border: 0;
border-bottom: 1px solid black;
}
</style>
<?php
$sql = 'SELECT o.id, o.title, o.description, o.keywords FROM objects o ORDER BY o.title ASC ';
$stmt = $db->prepare($sql);
$stmt->execute();
function deletionLinks($classes, $objectId, $fn) {
$classes = explode(',', $classes);
foreach ($classes as $key => $class) {
$classes[$key] = '<a class = "delete" href = "editor.php?delete=' . $fn . '&object=' . $objectId . '&class=' . $class. '">' . $class . '</a>';
}
$classes = implode(',', $classes);
return $classes;
}
echo '<table>';
echo '<tr><th colspan = "3">id</th><th>short title</th><th>full title</th><th>types (fits into)</th><th>provides (as well as the defaults for a type)</th><th>description</th><th>keywords</th></tr>';
foreach (getObjects() as $object) {
echo '<tr>';
echo '<td>' . $object['id'] . '</td>';
echo '<td><a class = "delete" href = "editor.php?delete=object&id=' . $object['id'] . '">X</a></td>';
echo '<td><img src = "resources/images/icons/' . $object['icon'] . '" /></td><td><a href = "editor.php?objectId=' . $object['id'] . '" />' . $object['title'] . '</a>';
echo '<td>' . $object['fullTitle'] . '</td>';
echo '<td>[' . deletionLinks($object['types'], $object['id'], 'types') . ']</td>';
echo '<td>[' . deletionLinks($object['provides'], $object['id'], 'provider') . ']</td>';
echo '<td>' . $object['description'] . '</td>';
echo '<td>' . $object['keywords'] . '</td>';
echo '</tr>';
}
echo '</table>';
?>
<style type = "text/css">
tr:hover td {
background-color: beige;
}
td {
padding: .2em;
}
table {
width: 100%;
}
th {
text-align: left;
}
</style>