My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
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
<?php
require_once "paget_widget.class.php";
require_once MORIARTY_DIR . "httprequest.class.php";

class PAGET_OntologyWidget extends PAGET_Widget {
var $desc;

function __construct(&$desc) {
$this->desc = $desc;
}


function render($resource_uri) {
$inline = array();

$index = $this->desc->get_index();

$descriptions = $this->desc->get_literal_triple_values($resource_uri, array(DC_DESCRIPTION, RDFS_COMMENT));
if (count($descriptions) > 0) {
foreach ($descriptions as $description) {
echo '<p>' . htmlspecialchars($description) . '</p>';
}
}

$key_properties = array('http://purl.org/vocab/vann/preferredNamespaceUri',
'http://purl.org/vocab/vann/preferredNamespacePrefix',
'http://purl.org/dc/elements/1.1/contributor',
'http://purl.org/dc/elements/1.1/rights',
);

$this->emit_property_value_list($resource_uri,$key_properties);

$inverse_index = $this->desc->get_inverse_index();
$def_uri = '';
if (array_key_exists($resource_uri, $inverse_index) && array_key_exists(RDFS_ISDEFINEDBY, $inverse_index[$resource_uri])) {
$def_uri = $resource_uri;
}
else if (array_key_exists($resource_uri . '/', $inverse_index) && array_key_exists(RDFS_ISDEFINEDBY, $inverse_index[$resource_uri . '/'])) {
$def_uri = $resource_uri . '/';
}

if (strlen($def_uri) > 0) {

$terms = $inverse_index[$def_uri][RDFS_ISDEFINEDBY];
if (count($terms) > 0) {
$tw = new PAGET_TermWidget($this->desc);
$rows = array();
foreach ($terms as $v_info) {
if ( $v_info['type'] == 'uri' ) {
$term_uri = $v_info['value'];
$title = $tw->get_title($term_uri);
$row = '<tr><td valign="top"><a href="' . htmlspecialchars($term_uri) . '">' . htmlspecialchars($title) . '</a></td>';
$row .= '<td valign="top">' . htmlspecialchars($tw->get_description($term_uri)) . '</td></tr>';

$rows[$title] = $row;
}
}
if (count($rows) > 0) {
ksort( $rows );
echo '<h2>Properties and Classes</h2>';
echo '<table>';
foreach ($rows as $key => $row) {
echo $row . "\n";
}
echo '</table>';
}
}
}




if ( $this->desc->subject_has_property($resource_uri, 'http://purl.org/vocab/vann/example')) {
echo '<h2>Examples</h2>';
echo '<ul>';
foreach ($index[$resource_uri] as $p => $v_list) {
foreach ($v_list as $v_info) {
if ( $p == 'http://purl.org/vocab/vann/example' && $v_info['type'] == 'uri') {
$title = $this->desc->get_first_literal($v_info['value'], array(RDFS_LABEL, DC_TITLE), 'Example');
echo '<li><a href="' . htmlspecialchars($v_info['value']) . '">' . htmlspecialchars($title) . '</a></li>';
}
}
}
echo '</ul>';
}

if ( $this->desc->subject_has_property($resource_uri, 'http://www.w3.org/2004/02/skos/core#changeNote') || $this->desc->subject_has_property($resource_uri, 'http://www.w3.org/2004/02/skos/core#historyNote' ) || $this->desc->subject_has_property($resource_uri, 'http://purl.org/dc/terms/issued' ) ) {
echo '<h2>History</h2>';
$history_widget = new PAGET_HistoryWidget($this->desc);
$history_widget->render($resource_uri);
}


echo '<h2>Other Information</h2>';
$data_widget = new PAGET_DataWidget($this->desc);
$data_widget->ignore_properties(array(DC_TITLE, RDFS_LABEL, DC_DESCRIPTION, RDFS_COMMENT, 'http://purl.org/vocab/vann/example'));
$data_widget->ignore_properties($key_properties);
$data_widget->ignore_properties(array('http://www.w3.org/2004/02/skos/core#changeNote', 'http://www.w3.org/2004/02/skos/core#historyNote', 'http://purl.org/dc/terms/issued'));
$data_widget->render($resource_uri);

}
}

Change log

r20 by m...@iandavis.com on Nov 4, 2008   Diff
Simplified inclusion of examples in
ontologywidget
Go to: 
Project members, sign in to write a code review

Older revisions

r16 by m...@iandavis.com on Nov 4, 2008   Diff
Improved history display
r14 by m...@iandavis.com on Nov 4, 2008   Diff
[No log message]
r13 by m...@iandavis.com on Oct 27, 2008   Diff
Completely revised design
All revisions of this file

File info

Size: 4155 bytes, 102 lines
Powered by Google Project Hosting