From: <sk...@us...> - 2008-09-23 10:46:27
|
Revision: 1241 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1241&view=rev Author: sknappe Date: 2008-09-23 10:46:20 +0000 (Tue, 23 Sep 2008) Log Message: ----------- changed design stuff, filtered some triples and made a simple characteristics view for persons and a seperate part for owl:sameAs property Modified Paths: -------------- trunk/src/dbpedia-navigator/ajax_get_article.php trunk/src/dbpedia-navigator/helper_functions.php Modified: trunk/src/dbpedia-navigator/ajax_get_article.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_get_article.php 2008-09-23 10:44:04 UTC (rev 1240) +++ trunk/src/dbpedia-navigator/ajax_get_article.php 2008-09-23 10:46:20 UTC (rev 1241) @@ -59,8 +59,10 @@ $artTitle=urldecode(str_replace("_"," ",substr (strrchr ($url, "/"), 1))); // display a picture if there is one + if (isset($triples['http://dbpedia.org/property/imageCaption'])&&$triples['http://dbpedia.org/property/imageCaption'][0]['type']!='uri') $alt=$triples['http://dbpedia.org/property/imageCaption'][0]['value']; + else $alt='Picture of '.$artTitle; if(isset($triples['http://xmlns.com/foaf/0.1/depiction'])) - $content.='<img src="'.$triples['http://xmlns.com/foaf/0.1/depiction'][0]['value'].'" alt="Picture of '.$artTitle.'" style="float:right; max-width:200px;" \>'; + $content.='<img src="'.$triples['http://xmlns.com/foaf/0.1/depiction'][0]['value'].'" alt="'.$alt.'" style="float:right; max-width:200px;" \>'; //display where it was redirected from, if it was redirected $redirect=""; @@ -128,33 +130,68 @@ $long=""; } + $characteristic=array(); //display only one birthdate - $birthdates=array("http://dbpedia.org/property/dateOfBirth","http://dbpedia.org/property/birth","http://dbpedia.org/property/birthDate"); - $date=false; + $birthdates=array("http://dbpedia.org/property/dateOfBirth","http://dbpedia.org/property/birth","http://dbpedia.org/property/birthdate","http://dbpedia.org/property/birthDate"); + $birthdate=false; + $birthuri=false; foreach ($birthdates as $dates){ - if ($date){ + if ($birthdate!=false){ unset($triples[$dates]); continue; } - if (isset($triples[$dates])&&$triples[$dates][0]['type']!='uri') $date=true; + if (isset($triples[$dates])&&$triples[$dates][0]['type']!='uri'){ + $birthdate=$dates; + $characteristics['Birthdate']=$triples[$dates]; + } + else if ($triples[$dates][0]['type']=='uri'&&$birthuri==false){ + $birthuri=$dates; + $characteristics['Birthdate']=$triples[$dates]; + } else unset($triples[$dates]); } //display only one deathdate - $deathdates=array("http://dbpedia.org/property/death","http://dbpedia.org/property/dateOfDeath","http://dbpedia.org/property/deathDate"); - $date=false; + $deathdates=array("http://dbpedia.org/property/death","http://dbpedia.org/property/dateOfDeath","http://dbpedia.org/property/deathdate","http://dbpedia.org/property/deathDate"); + $deathdate=false; + $deathuri=false; foreach ($deathdates as $dates){ - if ($date){ + if ($deathdate!=false){ unset($triples[$dates]); continue; } - if (isset($triples[$dates])&&$triples[$dates][0]['type']!='uri') $date=true; + if (isset($triples[$dates])&&$triples[$dates][0]['type']!='uri'){ + $deathdate=$dates; + $characteristics['Deathdate']=$triples[$dates]; + } + else if ($triples[$dates][0]['type']=='uri'&&$deathuri==false){ + $deathuri=$dates; + $characteristics['Deathdate']=$triples[$dates]; + } else unset($triples[$dates]); } //display a small characteristics of a person, if at least the birth date is given - if ($date){ - $information=array(); + if ($birthdate!=false||$birthuri!=false){ + $content.='<br/><hr><h4>Characteristics</h4><br/>'; + + if (isset($triples['http://dbpedia.org/property/birthname'])) $characteristics['Birthname']=$triples['http://dbpedia.org/property/birthname']; + if (isset($triples['http://dbpedia.org/property/birthPlace'])) $characteristics['Birthplace']=$triples['http://dbpedia.org/property/birthPlace']; + if (isset($triples['http://dbpedia.org/property/deathPlace'])) $characteristics['Deathplace']=$triples['http://dbpedia.org/property/deathPlace']; + if (isset($triples['http://dbpedia.org/property/spouse'])) $characteristics['Spouse']=$triples['http://dbpedia.org/property/spouse']; + if (isset($triples['http://dbpedia.org/property/shortDescription'])) $characteristics['Short Description']=$triples['http://dbpedia.org/property/shortDescription']; + if (isset($triples['http://dbpedia.org/property/alternativeNames'])) $characteristics['Alternative Names']=$triples['http://dbpedia.org/property/alternativeNames']; + $content.=createCharacteristics($characteristics); + unset($triples['http://dbpedia.org/property/birthname']); + unset($triples['http://dbpedia.org/property/birthPlace']); + unset($triples['http://dbpedia.org/property/deathPlace']); + unset($triples['http://dbpedia.org/property/spouse']); + unset($triples['http://dbpedia.org/property/shortDescription']); + unset($triples['http://dbpedia.org/property/alternativeNames']); + if ($birthdate!=false) unset($triples[$birthdate]); + if ($birthuri!=false) unset($triples[$birthuri]); + if ($deathdate!=false) unset($triples[$deathdate]); + if ($deathuri!=false) unset($triples[$deathuri]); } @@ -226,6 +263,9 @@ unset($triples['http://www.geonames.org/ontology#featureCode']); unset($triples['http://www.geonames.org/ontology#featureClass']); unset($triples['http://dbpedia.org/property/dmozProperty']); + unset($triples['http://dbpedia.org/property/color']); + unset($triples['http://dbpedia.org/property/imageCaption']); + unset($triples['http://dbpedia.org/property/name']); if (count($triples)>0){ $content.='<br/><hr><h4>Remaining Triples</h4><br/>'; Modified: trunk/src/dbpedia-navigator/helper_functions.php =================================================================== --- trunk/src/dbpedia-navigator/helper_functions.php 2008-09-23 10:44:04 UTC (rev 1240) +++ trunk/src/dbpedia-navigator/helper_functions.php 2008-09-23 10:46:20 UTC (rev 1241) @@ -225,21 +225,34 @@ $table = '<table border="0"><tr><td><b>Predicate</b></td><td><b>Object</b></td></tr>'; $i=1; 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><ul>'; + $table .= '<td>'; + if ($number>1) $table.='<ul>'; foreach($object as $element) { 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)); - $table .= '<li><a href="#" onclick="get_article(\'label='.$element['value'].'&cache=-1\');return false;">'.urldecode($label).'</a></li>'; + if ($number>1) $table.='<li>'; + $table .= '<a href="#" onclick="get_article(\'label='.$element['value'].'&cache=-1\');return false;">'.urldecode($label).'</a>'; + if ($number>1) $table.='</li>'; } - else $table .= '<li><a href="'.$element['value'].'" target="_blank">'.urldecode($element['value']).'</a></li>'; + else{ + if ($number>1) $table.='<li>'; + $table .= '<a href="'.$element['value'].'" target="_blank">'.urldecode($element['value']).'</a>'; + if ($number>1) $table.='</li>'; + } } - else $table .= '<li>'.$element['value'].'</li>'; + else{ + if ($number>1) $table.='<li>'; + $table .= $element['value']; + if ($number>1) $table.='</li>'; + } } - $table .= '</ul></td>'; + if ($number>1) $table.='</ul>'; + $table .= '</td>'; $i*=-1; } $table .= '</table>'; @@ -371,4 +384,46 @@ return $ret; } + +function createCharacteristics($char) +{ + $ret='<table border="0" style="padding:5px">'; + $i=0; + foreach ($char as $label=>$value){ + if ($i%2==0) + $ret.='<tr>'; + $ret.='<td style="width:20%;text-align:right"><b>'.$label.'</b>:</td><td style="width:30%;text-align:left">'; + $number=count($value); + if ($number>1) $ret.='<ul>'; + foreach ($value as $val){ + if ($val['type']=="uri"){ + if (strpos($val['value'],"http://dbpedia.org/resource/")===0&&substr_count($val['value'],"/")==4&&strpos($val['value'],"Template:")!=28){ + $label=str_replace('_',' ',substr($val['value'],28)); + if ($number>1) $ret.='<li>'; + $ret .= '<a href="#" onclick="get_article(\'label='.$val['value'].'&cache=-1\');return false;">'.urldecode($label).'</a>'; + if ($number>1) $ret.='</li>'; + } + else{ + if ($number>1) $ret.='<li>'; + $ret .= '<a href="'.$val['value'].'" target="_blank">'.urldecode($val['value']).'</a>'; + if ($number>1) $ret.='</li>'; + } + } + else{ + if ($number>1) $ret.='<li>'; + $ret .= $val['value']; + if ($number>1) $ret.='</li>'; + } + } + if ($number>1) $ret.='</ul>'; + $ret.='</td>'; + if ($i%2==1||$i==count($char)-1){ + $ret.='</tr>'; + $ret.='<tr><td colspan="4" style="height:10px"></td></tr>'; + } + $i++; + } + $ret.='</table>'; + return $ret; +} ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |