From: <sk...@us...> - 2008-10-27 16:43:10
|
Revision: 1455 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1455&view=rev Author: sknappe Date: 2008-10-27 16:42:58 +0000 (Mon, 27 Oct 2008) Log Message: ----------- changes to use new ontology Modified Paths: -------------- trunk/src/dbpedia-navigator/ajax_get_article.php trunk/src/dbpedia-navigator/templates/AbstractTemplate.php trunk/src/dbpedia-navigator/templates/DefaultTemplate.php Modified: trunk/src/dbpedia-navigator/ajax_get_article.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_get_article.php 2008-10-27 16:01:36 UTC (rev 1454) +++ trunk/src/dbpedia-navigator/ajax_get_article.php 2008-10-27 16:42:58 UTC (rev 1455) @@ -120,10 +120,6 @@ // 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); - //display owl:sameAs properties if (isset($triples['http://www.w3.org/2002/07/owl#sameAs'])||isset($subjecttriples['http://www.w3.org/2002/07/owl#sameAs'])){ $content.='<br/><hr><h4>Same as</h4><br/>'; @@ -272,13 +268,15 @@ // have already been displayed filterTriples(&$triples, &$subjecttriples); - - if (count($triples)>0||count($subjecttriples)>0){ + // display template for this instance (currently the template is similar to the remaining + // instance view apart from beautifications) + $content .= $template->printTemplate($triples,$subjecttriples); + /*if (count($triples)>0||count($subjecttriples)>0){ $content.='<br/><hr><h4>Remaining Triples</h4><br/>'; // display the remaining properties as list which can be used for further navigation $content .= get_triple_table($triples,$subjecttriples); - } + }*/ //Restart the Session session_start(); Modified: trunk/src/dbpedia-navigator/templates/AbstractTemplate.php =================================================================== --- trunk/src/dbpedia-navigator/templates/AbstractTemplate.php 2008-10-27 16:01:36 UTC (rev 1454) +++ trunk/src/dbpedia-navigator/templates/AbstractTemplate.php 2008-10-27 16:42:58 UTC (rev 1455) @@ -34,59 +34,91 @@ // 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>'; + function printRemainingTriples($triples,$subjecttriples) { + 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); + 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; + } + if (is_array($subjecttriples)&&count($subjecttriples)>0) foreach($subjecttriples 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">is '.nicePredicate($predicate).' of </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>'; + } + else $table="No Tripel left."; return $table; } Modified: trunk/src/dbpedia-navigator/templates/DefaultTemplate.php =================================================================== --- trunk/src/dbpedia-navigator/templates/DefaultTemplate.php 2008-10-27 16:01:36 UTC (rev 1454) +++ trunk/src/dbpedia-navigator/templates/DefaultTemplate.php 2008-10-27 16:42:58 UTC (rev 1455) @@ -28,9 +28,8 @@ class DefaultTemplate extends AbstractTemplate { // simply prints all triples without doing anything special to group/format them - function printTemplate($triples) { - $content = '<table>'; - $content .= $this->printRemainingTriples($triples); + function printTemplate($triples,$subjecttriples) { + $content = $this->printRemainingTriples($triples,$subjecttriples); return $content; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |