From: <jen...@us...> - 2008-10-27 12:36:09
|
Revision: 1444 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1444&view=rev Author: jenslehmann Date: 2008-10-27 12:36:06 +0000 (Mon, 27 Oct 2008) Log Message: ----------- templates ctd. Modified Paths: -------------- trunk/src/dbpedia-navigator/templates/AbstractTemplate.php trunk/src/dbpedia-navigator/templates/CityTemplate.php Added Paths: ----------- trunk/src/dbpedia-navigator/templates/DefaultTemplate.php trunk/src/dbpedia-navigator/templates/PersonTemplate.php Modified: trunk/src/dbpedia-navigator/templates/AbstractTemplate.php =================================================================== --- trunk/src/dbpedia-navigator/templates/AbstractTemplate.php 2008-10-27 10:12:36 UTC (rev 1443) +++ trunk/src/dbpedia-navigator/templates/AbstractTemplate.php 2008-10-27 12:36:06 UTC (rev 1444) @@ -32,6 +32,64 @@ abstract function printTemplate($triples); + // function to be called after all "special" actions have been taken; + // it displays all remaining triples + function printRemainingTriples($triples) { + $i=1; + if (is_array($triples) && count($triples)>0) { + foreach($triples as $predicate=>$object) { + $number=count($object); + if ($i>0) + $backgroundcolor="eee"; + else + $backgroundcolor="ffffff"; + + $table .= '<tr style="background-color:#'.$backgroundcolor.';"><td><a href="'.$predicate.'" target="_blank">'.nicePredicate($predicate).'</a></td>'; + $table .= '<td>'; + if ($number>1) $table.='<ul>'; + $k=1; + foreach($object as $element) { + if ($k>3) $display=" style=\"display:none\""; + else $display=""; + if ($element['type']=="uri") { + if (strpos($element['value'],"http://dbpedia.org/resource/")===0&&substr_count($element['value'],"/")==4&&strpos($element['value'],"Template:")!=28){ + $label=str_replace('_',' ',substr($element['value'],28)); + if (strlen($label)>60) + $label=substr($label,0,60).'...'; + if ($number>1) + $table.='<li'.$display.'>'; + $table .= '<a href="#" onclick="get_article(\'label='.$element['value'].'&cache=-1\');">'.urldecode($label).'</a>'; + if ($number>1) + $table.='</li>'; + } else { + if ($number>1) + $table.='<li'.$display.'>'; + $label=urldecode($element['value']); + if (strlen($label)>60) + $label=substr($label,0,60).'...'; + $table .= '<a href="'.$element['value'].'" target="_blank">'.$label.'</a>'; + if ($number>1) + $table.='</li>'; + } + } else { + if ($number>1) + $table.='<li'.$display.'>'; + $table .= $element['value']; + if ($number>1) + $table.='</li>'; + } + $k++; + } + if ($number>3) $table.='<a href="javascript:none()" onclick="toggleAttributes(this)"><img src="images/arrow_down.gif"/> show</a>'; + if ($number>1) $table.='</ul>'; + $table .= '</td>'; + $i*=-1; + } + } + $table .= '</table>'; + return $table; + } + // utility method, which checks whether the given DBpedia ontology properties exists in the triples // is they exist, the method returns true and false otherwise; // TODO: use $dbpediaOntologyPrefix in $settings (how do we access those settings in all scripts?) @@ -57,6 +115,15 @@ return $value; } + // displays as list of values for this property; + // TODO: add toggle button here (as in remaining triples) + function displayMultipleValues($triples, $property) { + $objects = $triples[$property]; + foreach($objects as $object) { + // ... + } + } + } ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/templates/CityTemplate.php =================================================================== --- trunk/src/dbpedia-navigator/templates/CityTemplate.php 2008-10-27 10:12:36 UTC (rev 1443) +++ trunk/src/dbpedia-navigator/templates/CityTemplate.php 2008-10-27 12:36:06 UTC (rev 1444) @@ -30,7 +30,13 @@ $content = ""; $content .= '<table>'; $content .= '<tr><td colspan="2">City Information</td></tr>'; + // population $content .= '<tr><td>total population</td><td>' + getPopulationString($triples) + '</td></tr>'; + // location + $content .= '<tr><td>latitude</td><td>' + getLatitudeString($triples) + '</td></tr>'; + $content .= '<tr><td>longitude</td><td>' + getLongitudeString($triples) + '</td></tr>'; + // resources related to city + $content .= displayMultipleValues('city'); $content .= '</table>'; // .. continue ... Added: trunk/src/dbpedia-navigator/templates/DefaultTemplate.php =================================================================== --- trunk/src/dbpedia-navigator/templates/DefaultTemplate.php (rev 0) +++ trunk/src/dbpedia-navigator/templates/DefaultTemplate.php 2008-10-27 12:36:06 UTC (rev 1444) @@ -0,0 +1,37 @@ +<?php +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +/** + * The default template. It should correspond to the "remaining triples" + * view. + * + * @author Jens Lehmann + */ +class DefaultTemplate extends AbstractTemplate { + + // simply prints all triples without doing anything special + function printTemplate($triples) { + return printRemainingTriples($triples); + } + +} + +?> \ No newline at end of file Added: trunk/src/dbpedia-navigator/templates/PersonTemplate.php =================================================================== --- trunk/src/dbpedia-navigator/templates/PersonTemplate.php (rev 0) +++ trunk/src/dbpedia-navigator/templates/PersonTemplate.php 2008-10-27 12:36:06 UTC (rev 1444) @@ -0,0 +1,36 @@ +<?php +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +/** + * Template for persons. + */ +class PersonTemplate extends AbstractTemplate { + + function printTemplate($triples) { + $content = ""; + + $content .= printRemainingTriples($triples); + return $content; + } + +} + +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |