From: <Jen...@us...> - 2008-10-28 13:43:23
|
Revision: 1475 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1475&view=rev Author: JensLehmann Date: 2008-10-28 10:50:04 +0000 (Tue, 28 Oct 2008) Log Message: ----------- integrated city and person template Modified Paths: -------------- trunk/src/dbpedia-navigator/ajax_get_article.php trunk/src/dbpedia-navigator/templates/AbstractTemplate.php trunk/src/dbpedia-navigator/templates/CityTemplate.php trunk/src/dbpedia-navigator/templates/DefaultTemplate.php trunk/src/dbpedia-navigator/templates/PersonTemplate.php trunk/src/dbpedia-navigator/templates/PlaceTemplate.php Modified: trunk/src/dbpedia-navigator/ajax_get_article.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_get_article.php 2008-10-28 10:24:19 UTC (rev 1474) +++ trunk/src/dbpedia-navigator/ajax_get_article.php 2008-10-28 10:50:04 UTC (rev 1475) @@ -259,14 +259,22 @@ $pages=substr($pages,0,strlen($pages)-2); $content.='<br/><hr><h4>Wikipedia articles in different languages</h4><br/><p>'.$pages.'</p>'; } + + $content .= '<br/><hr><h4>Further Information</h4><br/>'; + // detect appropriate template (currently always default) + if($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']) == 'http://dbpedia.org/ontology/City) { + $template = new CityTemplate(); + } else if($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']) == 'http://dbpedia.org/ontology/Person) { + $template = new PersonTemplate(); + } else { + $template = new DefaultTemplate(); + } + // filter out uninteresting properties and properties which // have already been displayed - filterTriples(&$triples, &$subjecttriples); + filterTriples(&$triples, &$subjecttriples); - $content .= '<br/><hr><h4>Further Information</h4><br/>'; - // detect appropriate template (currently always default) - $template = new DefaultTemplate(); // display template for this instance (currently the template is similar to the remaining // instance view apart from beautifications) $content .= $template->printTemplate($triples,$subjecttriples); Modified: trunk/src/dbpedia-navigator/templates/AbstractTemplate.php =================================================================== --- trunk/src/dbpedia-navigator/templates/AbstractTemplate.php 2008-10-28 10:24:19 UTC (rev 1474) +++ trunk/src/dbpedia-navigator/templates/AbstractTemplate.php 2008-10-28 10:50:04 UTC (rev 1475) @@ -32,11 +32,15 @@ abstract function printTemplate($triples,$subjecttriples); + function getTableHeader() { + return '<table border="0" style="width:100%;overflow:hidden"><tr><td><b>Predicate</b></td><td><b>Object/Subject</b></td></tr>'; + } + // function to be called after all "special" actions have been taken; // it displays all remaining triples function printRemainingTriples($triples,$subjecttriples) { + $table = ''; if ((is_array($triples)&&count($triples)>0)||(is_array($subjecttriples)&&count($subjecttriples)>0)){ - $table = '<table border="0" style="width:100%;overflow:hidden"><tr><td><b>Predicate</b></td><td><b>Object/Subject</b></td></tr>'; $i=1; if (is_array($triples)&&count($triples)>0) foreach($triples as $predicate=>$object) { $number=count($object); @@ -118,7 +122,7 @@ } $table .= '</table>'; } - else $table="No Tripel left."; + else $table="No triple left."; return $table; } Modified: trunk/src/dbpedia-navigator/templates/CityTemplate.php =================================================================== --- trunk/src/dbpedia-navigator/templates/CityTemplate.php 2008-10-28 10:24:19 UTC (rev 1474) +++ trunk/src/dbpedia-navigator/templates/CityTemplate.php 2008-10-28 10:50:04 UTC (rev 1475) @@ -29,9 +29,8 @@ class CityTemplate extends PopulatedPlaceTemplate { function printTemplate($triples,$subjecttriples) { - $content = ""; - $content .= '<table>'; - $content .= '<tr><td colspan="2">City Information</td></tr>'; + $content = $this-getTableHeader(); + // $content .= '<tr><td colspan="2">City Information</td></tr>'; // population $content .= '<tr><td>total population</td><td>' + $this->getPopulationString($triples) + '</td></tr>'; // location @@ -39,9 +38,9 @@ $content .= '<tr><td>longitude</td><td>' + $this->getLongitudeString($triples) + '</td></tr>'; // resources related to city // $content .= displayMultipleValues('city'); - $content .= '</table>'; + // $content .= '</table>'; - // .. continue ... + $content .= $this->printRemainingTriples(); return $content; } Modified: trunk/src/dbpedia-navigator/templates/DefaultTemplate.php =================================================================== --- trunk/src/dbpedia-navigator/templates/DefaultTemplate.php 2008-10-28 10:24:19 UTC (rev 1474) +++ trunk/src/dbpedia-navigator/templates/DefaultTemplate.php 2008-10-28 10:50:04 UTC (rev 1475) @@ -29,7 +29,8 @@ // simply prints all triples without doing anything special to group/format them function printTemplate($triples,$subjecttriples) { - $content = $this->printRemainingTriples($triples,$subjecttriples); + $content = $this->getTableHeader(); + $content .= $this->printRemainingTriples($triples,$subjecttriples); return $content; } Modified: trunk/src/dbpedia-navigator/templates/PersonTemplate.php =================================================================== --- trunk/src/dbpedia-navigator/templates/PersonTemplate.php 2008-10-28 10:24:19 UTC (rev 1474) +++ trunk/src/dbpedia-navigator/templates/PersonTemplate.php 2008-10-28 10:50:04 UTC (rev 1475) @@ -25,8 +25,7 @@ class PersonTemplate extends AbstractTemplate { function printTemplate($triples,$subjecttriples) { - $content = ""; - + $content = $this->getTableHeader(); $content .= $this->printRemainingTriples($triples,$subjecttriples); return $content; } Modified: trunk/src/dbpedia-navigator/templates/PlaceTemplate.php =================================================================== --- trunk/src/dbpedia-navigator/templates/PlaceTemplate.php 2008-10-28 10:24:19 UTC (rev 1474) +++ trunk/src/dbpedia-navigator/templates/PlaceTemplate.php 2008-10-28 10:50:04 UTC (rev 1475) @@ -36,9 +36,9 @@ return "unknown"; } - $latitude = $triples['http://dbpedia.org/ontology/latitutedegrees'] + "° " - + $triples['http://dbpedia.org/ontology/latitudeminutes'] + "′" - + $triples['http://dbpedia.org/ontology/latitudeseconds'] + "″N"; + $latitude = $this->extractPropValue('latitutedegrees') + "° " + + $this->extractPropValue('latitudeminutes') + "′" + + $this->extractPropValue('latitudeseconds') + "″N"; return $latitude; } @@ -48,10 +48,10 @@ return "unknown"; } - $longitude = $triples['http://dbpedia.org/ontology/longitutedegrees'] + "° " - + $triples['http://dbpedia.org/ontology/longitudeminutes'] + "′" - + $triples['http://dbpedia.org/ontology/longitudeseconds'] + "″N"; - return $longitude; + $longitude = $this->extractPropValue('longitutedegrees') + "° " + + $this->extractPropValue('http://dbpedia.org/ontology/longitudeminutes') + "′" + + $this->extractPropValue('http://dbpedia.org/ontology/longitudeseconds') + "″N"; + return $longitude; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |