Skip to content

Instantly share code, notes, and snippets.

@njh
Created September 3, 2012 22:51
Show Gist options
  • Select an option

  • Save njh/3614362 to your computer and use it in GitHub Desktop.

Select an option

Save njh/3614362 to your computer and use it in GitHub Desktop.
American Poets
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib/');
require_once "EasyRdf.php";
EasyRdf_Namespace::set('dbpedia', 'http://dbpedia.org/ontology/');
EasyRdf_Namespace::set('dbprop', 'http://dbpedia.org/property/');
$sparql = new EasyRdf_Sparql_Client('http://dbpedia.org/sparql');
$limit = 50;
$query=<<<EOQ
SELECT DISTINCT ?name ?wikipedia_url ?abstract ?thumbnail
WHERE
{
?poet dcterms:subject <http://dbpedia.org/resource/Category:American_poets> ;
foaf:name ?name ;
foaf:surname ?surname ;
dbpedia:thumbnail ?thumbnail ;
dbpedia:abstract ?abstract ;
foaf:isPrimaryTopicOf ?wikipedia_url .
FILTER ( lang(?abstract) = "en" )
} ORDER BY ASC(?surname)
LIMIT $limit
EOQ;
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Information about American Poets</title>
<link rel="stylesheet" href="_css/colorbox.css" />
<!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>-->
<style type="text/css" title="currentStyle">
@import "media/css/demo_table_jui.css";
@import "examples_support/themes/smoothness/jquery-ui-1.8.4.custom.css";
tr th {
font-family: Tahoma, Geneva, sans-serif;
font-size: 1.8em;
font-weight: bold;
font-variant: small-caps;
color: rgba(0,102,204,1);
}
tr td ul li {
list-style-position: inside;
list-style-type: circle;
}
</style>
<script type="text/javascript" language="javascript" src="media/jsjquery.js"></script>
<script type="text/javascript" language="javascript"
src="media/js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
oTable = $('#example').dataTable({
"bJQueryUI": true,
"bSort": false,
"aoColumns": [
null,
null,
{ "bSearchable": false },
null
],
"sPaginationType": "full_numbers"
});
} );
</script>
<script src="_js/colorbox/jquery.colorbox-min.js"></script>
</head>
<body>
<table border="2" class="display" id="example">
<thead>
<th colspan="4">American Poets and their Influences</th>
<tr><td colspan="4">
<p style="font-size:1.2em">The first column lists a poet, followed ... them.</p>
<h1 style="color: #DC2E06; text-align: center;">Please wait... This may take a while to load
<br />
Loading <?= $limit ?> Poets</h1>
</td></tr>
<tr>
<td width="20%">Name of Poet</td>
<td width="40%">Poet Abstract</td>
<td width="20%">Photo:</td>
<td width="20%">Influenced:</td>
</tr>
</thead>
<tbody>
<?php
$result = $sparql->query($query);
foreach ($result as $row) {
echo "<tr>\n";
echo "<td>".$row->wikipedia_url->htmlLink($row->name)."</td>";
echo "<td>".htmlspecialchars($row->abstract)."</td>";
echo "<td><img src='$row->thumbnail' /></td>";
echo "</tr>\n";
}
?>
</tbody>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment