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
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
<?php
include_once "paget_termwidget.class.php";
include_once "paget_datawidget.class.php";
include_once "paget_historywidget.class.php";
include_once "paget_ontologywidget.class.php";

class PAGET_SimpleHtmlRepresentation {
var $_config;
function __construct($config = array()) {
$this->_config = $config;
}

function emit(&$desc) {
$resource_uri = $desc->get_primary_resource_uri();
$document_base = $resource_uri;
if ( preg_match('~^(.+)' . preg_quote($this->_config['format_delimiter']) . 'html$~', $desc->get_uri(), $m)) {
$document_base = $m[1];
}

$title = $desc->get_label();

$widgets= array();
if ( $desc->has_resource_triple($resource_uri, RDF_TYPE, RDF_PROPERTY) || $desc->has_resource_triple($resource_uri, RDF_TYPE, RDFS_CLASS) ) {
$widgets[] = new PAGET_TermWidget($desc);
}
else if ( $desc->has_resource_triple($resource_uri, RDF_TYPE, 'http://www.w3.org/2002/07/owl#Ontology') ) {
$widgets[] = new PAGET_OntologyWidget($desc);
}
else {
$widgets[] = new PAGET_DataWidget($desc);
}

header('Content-type: text/html');
echo "<?";

?>
xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title><?php e($widgets[0]->get_title($resource_uri));?></title>

<?php
$formats = $desc->get_resource_triple_values($desc->get_uri(), 'http://purl.org/dc/terms/hasFormat');
foreach ($formats as $format_uri) {
$media_type = $desc->get_first_literal($format_uri, 'http://purl.org/dc/elements/1.1/format');
$label = $desc->get_first_literal($format_uri, RDFS_LABEL, $media_type);
echo ' <link rel="alternate" type="' . htmlspecialchars($media_type) . '" href="' . htmlspecialchars($format_uri) . '" title="' . htmlspecialchars($label) . ' version of this document"/>' . "\n";
}
?>
<style media="screen" type="text/css">
/* <!-- */
body {margin:0; padding:0; border:0; width:100%; background:#fff;font-size:90%;}
a {color:#369;}
a:hover {color:#fff; background:#369; text-decoration:none;}
h1, h2, h3 {margin:.8em 0 .2em 0; padding:0;}
p {margin:.4em 0 .8em 0; padding:0;}
img { margin:10px 0 5px;}
#header {clear:both; float:left; width:100%;}
#header {border-bottom:1px solid #000;}
#header p, #header h1, #header h2 {padding:.4em 15px 0 15px; margin:0;}
#header ul {clear:left; float:left; width:100%; list-style:none; margin:10px 0 0 0; padding:0;}
#header ul li {display:inline; list-style:none; margin:0; padding:0;}
#header ul li a {display:block; float:left; margin:0 0 0 1px; padding:3px 10px; text-align:center; background:#eee; color:#000; text-decoration:none; position:relative; left:15px; line-height:1.3em;}
#header ul li a:hover { background:#369; color:#fff;}
#header ul li a.active, #header ul li a.active:hover {color:#fff; background:#000; font-weight:bold;}
#header ul li a span {display:block;}
#layoutdims { clear:both; background:#eee; border-top:4px solid #000; margin:0; padding:6px 15px !important; text-align:right;}
.colmask { position:relative; clear:both; float:left; width:100%; overflow:hidden;}
.fullpage {background:#fff;}
.fullpage .col1 {margin:0 0.5 em; padding: 0.5em;}
#footer {clear:both;float:left; width:100%; border-top:1px solid #000;}
#footer p { padding:10px; margin:0;}
code.xml .text {color: #000000; background: transparent;}
code.xml .elem {color: #000080; background: transparent;}
code.xml .attr {color: #008080; background: transparent;}
code.xml .attrVal {color: #666666;background: transparent;}
code.xml .highlight {background: #ffff00;}
pre {border: 1px #999999 dotted;background-color: #eeeeee; color: #000000;}


/* --> */
</style>
</head>
<body>

<div id="header">
<h1><?php echo(htmlspecialchars($widgets[0]->get_title($resource_uri))) ?></h1>
<p id="layoutdims">This data in other formats:
<?php
$formats = $desc->get_resource_triple_values($desc->get_uri(), 'http://purl.org/dc/terms/hasFormat');
$done_first = false;
foreach ($formats as $format_uri) {
$media_type = $desc->get_first_literal($format_uri, 'http://purl.org/dc/elements/1.1/format');
$label = $desc->get_first_literal($format_uri, RDFS_LABEL, $media_type);

if ($done_first) {
echo ' | ';
}
echo '<a href="' . htmlspecialchars($format_uri) . '" rel="alternate" title="' . htmlspecialchars($label) . ' version of this document" type="' . htmlspecialchars($media_type) . '">' . htmlspecialchars($label) . '</a>' . "\n";
$done_first = true;
}

?>
</p>
</div>
<div class="colmask fullpage">
<div class="col1">
<?php


foreach ($widgets as $widget) {
$widget->render($resource_uri);
}

$resources = array();
$index = $desc->get_index();
foreach ($index as $subject => $subject_data) {
if (strpos($subject, $resource_uri . '#') === 0) {
$resources[] = $subject;
}
}

foreach ($resources as $resource_uri_to_describe) {
$secondary_widgets = array();
if ( $desc->has_resource_triple($resource_uri_to_describe, RDF_TYPE, RDF_PROPERTY) || $desc->has_resource_triple($resource_uri_to_describe, RDF_TYPE, RDFS_CLASS) ) {
$secondary_widgets[] = new PAGET_TermWidget($desc);
}
else if ( $desc->has_resource_triple($resource_uri_to_describe, RDF_TYPE, 'http://www.w3.org/2002/07/owl#Ontology') ) {
$secondary_widgets[] = new PAGET_OntologyWidget($desc);
}
else {
$secondary_widgets[] = new PAGET_DataWidget($desc);
}


echo '<h2>';
echo(htmlspecialchars($secondary_widgets[0]->get_title($resource_uri_to_describe)));
echo '</h2>';
foreach ($secondary_widgets as $widget) {
$widget->render($resource_uri_to_describe);
}

}


?>
</div>
</div>

<div id="footer">
<!-- Page template based on http://matthewjamestaylor.com/blog/ultimate-1-column-full-page-ems.htm -->
<p><?php echo($this->_config['credits_html']); ?></p>
</div>
<?php
if (isset($this->_config['google_analytics_code'])) {
?>
<script type="text/javascript">var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));</script>
<script type="text/javascript">var pageTracker = _gat._getTracker("<?php e($this->_config['google_analytics_code']); ?>");pageTracker._trackPageview();</script>
<?php
}
?>

</body>
</html>
<?php
}

function remote_to_local($uri) {
if (preg_match('~http://([^/]+)/~i', $uri, $m)) {
if ( $_SERVER["HTTP_HOST"] == $m[1] . '.local' ) {
return str_replace($m[1], $_SERVER["HTTP_HOST"], $uri);
}
else {
return $uri;
}
}
}


}





Change log

r19 by m...@iandavis.com on Nov 4, 2008   Diff
Fixed 404 problem
Go to: 
Project members, sign in to write a code review

Older revisions

r18 by m...@iandavis.com on Nov 4, 2008   Diff
Improved description of terms
r17 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]
All revisions of this file

File info

Size: 7300 bytes, 186 lines
Powered by Google Project Hosting