Dev8D Examples
This page has examples of using the Graphite Library to work with the RDF Programme of Dev8D and Semantic Wiki RDF data.
Walk the Programme
This example walks through the entire RDF programme.
Code
<?php include_once("arc/ARC2.php"); include_once("Graphite.php"); $graph = new Graphite( array( "iswc" => "http://data.semanticweb.org/ns/swc/ontology#", "cal" => "http://www.w3.org/2002/12/cal#", "prog" => "http://programme.ecs.soton.ac.uk/2010/programme-schema#", "dev8d" => "http://data.dev8d.org/2010/programme/dev8d_programme.rdf#", "dev8dwiki" => "http://wiki.2010.dev8d.org/w/Special:URIResolver/" ) ); $graph->load("http://data.dev8d.org/2010/programme/dev8d_programme.rdf"); $main_prog = $graph->primaryTopic(); print "<h1>".$main_prog->label()."</h1>"; print "<ul>"; foreach( $main_prog->all( "prog:hasSubProgramme" ) as $day_prog ) { print "<li>"; print $day_prog->label(); print "<ul><li>Timeslots<ul>"; foreach( $day_prog->all( "prog:hasTimeSlot" ) as $time_slot ) { print "<li>".$time_slot->get( "cal:summary" )."</li>"; } print "</ul></li>"; print "<li>Events<ul>"; foreach( $day_prog->all( "prog:hasUnstreamedEvent", "prog:hasStreamedEvent" ) as $event) { print "<li>"; print "<a href='$event'>".$event->get("cal:summary")."</a>"; print "</li>"; } print "</ul></li>"; print "</ul>"; print "</li>"; } print "</ul>"; ?>
Output
JISC Dev8D 2010 Programme
- Wed 24th: Challenges Announced!
- Timeslots
- Object id #25
- Object id #25
- Object id #25
- Object id #25
- Object id #25
- Object id #25
- Object id #25
- Object id #25
- Object id #25
- Events
- Timeslots
- Thu 25th: Cloud, Mobile, Learning Tools and Miscellaneous
- Timeslots
- Object id #22
- Object id #22
- Object id #22
- Object id #22
- Object id #22
- Object id #22
- Object id #22
- Events
- Timeslots
- Fri 26th: Linked Data, Mashups and Miscellaneous
- Timeslots
- Object id #15
- Object id #15
- Object id #15
- Object id #15
- Object id #15
- Object id #15
- Events
- Timeslots
- Sat 27th: Finale!
- Timeslots
- Object id #20
- Object id #20
- Object id #20
- Object id #20
- Object id #20
- Object id #20
- Events
- Timeslots
Link with Wiki RDF
This example starts with a session in the RDF programme, uses the rdf:sameAs to load info from the wiki, then walks through every talk in that session.
Code
<?php include_once("arc/ARC2.php"); include_once("Graphite.php"); $graph = new Graphite( array( "iswc" => "http://data.semanticweb.org/ns/swc/ontology#", "cal" => "http://www.w3.org/2002/12/cal#", "prog" => "http://programme.ecs.soton.ac.uk/2010/programme-schema#", "dev8d" => "http://data.dev8d.org/2010/programme/dev8d_programme.rdf#", "dev8dwikiprop" => "http://wiki.2010.dev8d.org/w/Special:URIResolver/Property-3A", "dev8dwiki" => "http://wiki.2010.dev8d.org/w/Special:URIResolver/" ) ); $graph->load("http://data.dev8d.org/2010/programme/dev8d_programme.rdf"); $session_id = $_GET["session_id"]; if( $session_id == "" ) { $session_id = "dev8d:event-thu-1030-1300-expert"; } $session = $graph->resource( $session_id ); $session->loadSameAs(); print "<ul>"; foreach( $session->all( "dev8dwiki:Property-3ATalk" ) as $talk ) { $talk->load(); print "<li>"; print $talk->get( "dev8dwikiprop:Title" ); print "<ul>"; print "<li>Speaker: ".join( ", ", $talk->all( "dev8dwikiprop:Speaker_Name"))."</li>"; print "<li>Starts: ".$talk->get( "dev8dwikiprop:Begin_Time" )."</li>"; print "<li>".$talk->get( "dev8dwikiprop:Description" )."</li>"; print "</ul>"; print "</li>"; } print "</ul>";
Output
Notice: Undefined index: session_id in /var/ecsweb/sites/ecs.soton.ac.uk/graphite/htdocs/dev8d/linked.php on line 14
- Are we ready for Cloud computing?
- Speaker:
- Starts: Object id #33
- Object id #33
Warning: join() [function.join]: Bad arguments. in /var/ecsweb/sites/ecs.soton.ac.uk/graphite/htdocs/dev8d/linked.php on line 26
- Public Data and the Linked Data Cloud
- Speaker:
- Starts: Object id #37
- Object id #37
Warning: join() [function.join]: Bad arguments. in /var/ecsweb/sites/ecs.soton.ac.uk/graphite/htdocs/dev8d/linked.php on line 26
- Web Security
- Speaker:
- Starts: Object id #41
- Object id #41
Warning: join() [function.join]: Bad arguments. in /var/ecsweb/sites/ecs.soton.ac.uk/graphite/htdocs/dev8d/linked.php on line 26
- Stay the hell out of perl_lib
- Speaker:
- Starts: Object id #46
- Object id #46
Warning: join() [function.join]: Bad arguments. in /var/ecsweb/sites/ecs.soton.ac.uk/graphite/htdocs/dev8d/linked.php on line 26
- Symbian Application Development
- Speaker:
- Starts: Object id #49
- Object id #49
Warning: join() [function.join]: Bad arguments. in /var/ecsweb/sites/ecs.soton.ac.uk/graphite/htdocs/dev8d/linked.php on line 26
- iPhone and that other device...
- Speaker:
- Starts: Object id #53
- Object id #53
Warning: join() [function.join]: Bad arguments. in /var/ecsweb/sites/ecs.soton.ac.uk/graphite/htdocs/dev8d/linked.php on line 26
- Android LiveWallpapers
- Speaker:
- Starts: Object id #57
- Object id #57
Warning: join() [function.join]: Bad arguments. in /var/ecsweb/sites/ecs.soton.ac.uk/graphite/htdocs/dev8d/linked.php on line 26
- REPRAP 3D printer
- Speaker:
- Starts: Object id #61
- Object id #61
Warning: join() [function.join]: Bad arguments. in /var/ecsweb/sites/ecs.soton.ac.uk/graphite/htdocs/dev8d/linked.php on line 26
- REPRAP 3D printer
- Speaker:
- Starts: Object id #65
- Object id #65
Warning: join() [function.join]: Bad arguments. in /var/ecsweb/sites/ecs.soton.ac.uk/graphite/htdocs/dev8d/linked.php on line 26
- Emergence or Genetic Algorithms
- Speaker:
- Starts: Object id #69
- Object id #69
Warning: join() [function.join]: Bad arguments. in /var/ecsweb/sites/ecs.soton.ac.uk/graphite/htdocs/dev8d/linked.php on line 26