From: <sk...@us...> - 2008-08-18 15:33:24
|
Revision: 1095 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1095&view=rev Author: sknappe Date: 2008-08-18 15:33:18 +0000 (Mon, 18 Aug 2008) Log Message: ----------- changed look of articel, added some helpful tooltips, added best search results on left side, last articles is working, changed error messages and some other stuff Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajax_get_article.php trunk/src/dbpedia-navigator/ajax_search.php trunk/src/dbpedia-navigator/helper_functions.php trunk/src/dbpedia-navigator/index.php Added Paths: ----------- trunk/src/dbpedia-navigator/images/dbpedia-favicon.ico trunk/src/dbpedia-navigator/images/flickr.png trunk/src/dbpedia-navigator/js/ trunk/src/dbpedia-navigator/js/ajax.js Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-08-15 17:55:39 UTC (rev 1094) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-08-18 15:33:18 UTC (rev 1095) @@ -129,10 +129,11 @@ function getTriples($uri) { + //i am filtering the references out at the moment, because they are causing errors with URL with ...&profile=bla, the XMLParser thinks &profile is a HTML-Entitie and misses the ; $query="SELECT ?pred ?obj ". "WHERE {{<".$uri."> ?pred ?obj.Filter(!regex(str(?pred),'http://dbpedia.org/property/reference'))}UNION{<".$uri."> <http://dbpedia.org/property/redirect> ?Conc.?Conc ?pred ?obj.Filter(!regex(str(?pred),'http://dbpedia.org/property/reference'))}}"; $result=json_decode($this->getSparqlResultThreaded($query),true); - if (count($result['results']['bindings'])==0) throw new Exception("Your query brought no result. The Label-Search is started."); + if (count($result['results']['bindings'])==0) throw new Exception("An article with that name does not exist. The Search is started ..."); $ret=array(); foreach ($result['results']['bindings'] as $results){ $value=$results['obj']; @@ -181,6 +182,8 @@ return $result; } + //at the moment the subject search uses a database, so this function is not needed + /* function getSubjects($label,$checkedInstances) { $offset=1; @@ -235,7 +238,7 @@ $return['tagcloud']=$tagcloud; $return['tagcloudlabel']=$tagcloudLabel; return $return; - } + }*/ function getSubjectsFromConcept($concept) { Modified: trunk/src/dbpedia-navigator/ajax_get_article.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_get_article.php 2008-08-15 17:55:39 UTC (rev 1094) +++ trunk/src/dbpedia-navigator/ajax_get_article.php 2008-08-18 15:33:18 UTC (rev 1095) @@ -5,6 +5,8 @@ $subject=$_POST['label']; $fromCache=$_POST['cache']; + if (isset($_POST['path'])) $path=$_POST['path']; + else $path=""; if (isset($_SESSION['articles'])) $articles=$_SESSION['articles']; $id=$_SESSION['id']; @@ -19,7 +21,7 @@ if (isset($articles)){ foreach ($articles as $key => $value) { - if ($value['subject']==$subject){ + if ($value['uri']==$uri){ $fromCache=$key; break; } @@ -32,7 +34,6 @@ $artTitle=""; //get the article - //if $fromCache is -2, no new SearchResults should be processed //if $fromCache is -1, everything is normal //if $fromCache is >=0, the article is taken out of the cache if ($fromCache<0) { @@ -48,7 +49,7 @@ // display a picture if there is one 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 '.$subject.'" style="float:right; max-width:200px;" \>'; + $content.='<img src="'.$triples['http://xmlns.com/foaf/0.1/depiction'][0]['value'].'" alt="Picture of '.$triples['http://www.w3.org/2000/01/rdf-schema#label'][0]['value'].'" style="float:right; max-width:200px;" \>'; //display where it was redirected from, if it was redirected $redirect=""; @@ -62,38 +63,47 @@ // give the link to the corresponding Wikipedia article if(isset($triples['http://xmlns.com/foaf/0.1/page'])) - $content .= '<p><img src="'.$_GET['path'].'images/wikipedia_favicon.png" alt="Wikipedia" /> <a href="'.$triples['http://xmlns.com/foaf/0.1/page'][0]['value'].'">view Wikipedia article</a>, '; - $content .= '<a href="'.$uri.'">view DBpedia resource description</a></p>'; - + $content .= '<p><img src="'.$path.'images/wikipedia_favicon.png" alt="Wikipedia" style="max-width:20px;" /> <a href="#" onclick="window.open(\''.getPrintableURL($triples['http://xmlns.com/foaf/0.1/page'][0]['value']).'\',\'Wikiwindow\',\'width=800,height=500,top=50,left=50,scrollbars=yes\');">view Wikipedia article</a>, '; + $content .= '<img src="'.$path.'images/dbpedia-favicon.ico" alt="DBpedia" style="max-width:20px;"/> <a href="#" onclick="window.open(\''.$uri.'\',\'Wikiwindow\',\'width=800,height=500,top=50,left=50,scrollbars=yes\');">view DBpedia resource description</a>'; + //display photo collection, if there is one + if (isset($triples['http://dbpedia.org/property/hasPhotoCollection'])){ + $content.=', <img src="'.$path.'images/flickr.png" alt="Flickr" style="max-width:20px;" /> <a href="#" onclick="window.open(\''.$triples['http://dbpedia.org/property/hasPhotoCollection'][0]['value'].'\',\'Wikiwindow\',\'width=800,height=500,top=50,left=50,scrollbars=yes\');">view photo collection</a></p>'; + } + + $content.='<br/><hr><h4>Classes and Categories</h4><br/>'; + // display a list of classes if(isset($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type'])) - $content .= '<p>classes: '.formatClassArray($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']).'</p>'; - - if(isset($triples['http://dbpedia.org/property/reference'])) { + $content .= '<p>Yago classes: '.formatClassArray($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']).'</p>'; + + //skos-subjects + if (isset($triples['http://www.w3.org/2004/02/skos/core#subject'])){ + $content .= '<br/><p>Skos categories: <ul>'; + foreach($triples['http://www.w3.org/2004/02/skos/core#subject'] as $skos) + $content .= '<li><a href="'.$skos['value'].'">'.$skos['value'].'</a></li>'; + $content .= '</ul></p>'; + } + + //not used at the moment + /*if(isset($triples['http://dbpedia.org/property/reference'])) { $content .= '<p>references: <ul>'; foreach($triples['http://dbpedia.org/property/reference'] as $reference) $content .= '<li><a href="'.$reference['value'].'">'.$reference['value'].'</a></li>'; $content .= '</ul></p>'; - } + }*/ //display a Google Map if Geo-koordinates are available if (isset($triples['http://www.w3.org/2003/01/geo/wgs84_pos#long'])&&isset($triples['http://www.w3.org/2003/01/geo/wgs84_pos#lat'])){ - $content.="<br/><img src=\"".$_GET['path']."images/mobmaps_googlemapsicon.jpg\" alt=\"Google Maps\" style=\"max-width:25px;\" /> <a href=\"\" onClick=\"loadGoogleMap(".$triples['http://www.w3.org/2003/01/geo/wgs84_pos#lat'][0]['value'].",".$triples['http://www.w3.org/2003/01/geo/wgs84_pos#long'][0]['value'].",'".$triples['http://www.w3.org/2000/01/rdf-schema#label'][0]['value']."');return false;\">Toggle a map of the location</a><br/><br/><div id=\"map\" style=\"width: 500px; height: 300px;display:none;\"></div>"; + $content.='<br/><hr><h4>Map of the location</h4><br/>'; + $content.='<div id="map" style="width: 500px; height: 300px;margin-left:30px;"></div>'; + $lat=$triples['http://www.w3.org/2003/01/geo/wgs84_pos#lat'][0]['value']; + $long=$triples['http://www.w3.org/2003/01/geo/wgs84_pos#long'][0]['value']; } - - //display photo collection, if there is one - if (isset($triples['http://dbpedia.org/property/hasPhotoCollection'])){ - $content.="<br/><img src=\"".$_GET['path']."images/flickr.jpg\" alt=\"Flickr\" style=\"max-width:25px;\" /> <a href=\"".$triples['http://dbpedia.org/property/hasPhotoCollection'][0]['value']."\">view a photo collection</a><br/>"; + else{ + $lat=""; + $long=""; } - //skos-subjects - if (isset($triples['http://www.w3.org/2004/02/skos/core#subject'])){ - $content .= '<br/><p>skos subjects: <ul>'; - foreach($triples['http://www.w3.org/2004/02/skos/core#subject'] as $skos) - $content .= '<li><a href="'.$skos['value'].'">'.$skos['value'].'</a></li>'; - $content .= '</ul></p>'; - } - //BUILD ARTICLE TITLE $artTitle=$triples['http://www.w3.org/2000/01/rdf-schema#label'][0]['value']; @@ -110,15 +120,18 @@ unset($triples['http://dbpedia.org/property/hasPhotoCollection']); unset($triples['http://www.w3.org/2004/02/skos/core#subject']); unset($triples['http://www.w3.org/2000/01/rdf-schema#label']); + unset($triples['http://www.w3.org/2000/01/rdf-schema#comment']); + $content.='<br/><hr><h4>Remaining Triples</h4><br/>'; + // display the remaining properties as list which can be used for further navigation - $content .= '<br/><br/><br/>'.get_triple_table($triples); + $content .= get_triple_table($triples); //Restart the Session session_start(); //store article in session, to navigate between last 5 articles quickly - $contentArray=array('content' => $content,'subject' => $artTitle); + $contentArray=array('content' => $content,'subject' => $artTitle,'uri' => $uri); if (!isset($_SESSION['nextArticle'])){ $_SESSION['nextArticle']=0; $_SESSION['articles']=array(); @@ -146,8 +159,7 @@ } catch (Exception $e) { $content=$e->getMessage(); - $artTitle="No Result"; - //$objResponse->call('xajax_getsubjects',$subject); + $artTitle="Article not found"; } } else { @@ -161,7 +173,7 @@ if (isset($_SESSION['articles'])){ foreach ($_SESSION['articles'] as $key => $value) { - $lastArticles.="<a href=\"\" onclick=\"xajax_getarticle('',".$key.");return false;\">".$value['subject']."</a><br/>"; + $lastArticles.="<a href=\"\" onclick=\"get_article('label=&cache=".$key."');return false;\">".$value['subject']."</a><br/>"; } } @@ -176,7 +188,11 @@ print '$$'; print $interests[0]; print '$$'; - print $interests[1]; + print $interests[1]; + print '$$'; + print $lat; + print '$$'; + print $long; //$objResponse->call('xajax_learnConcept'); ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/ajax_search.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_search.php 2008-08-15 17:55:39 UTC (rev 1094) +++ trunk/src/dbpedia-navigator/ajax_search.php 2008-08-18 15:33:18 UTC (rev 1095) @@ -21,33 +21,41 @@ mysql_select_db("navigator_db"); $query="SELECT name, label, category FROM rank WHERE MATCH (label) AGAINST ('$label') ORDER BY number DESC LIMIT ".$number; $res=mysql_query($query); - $names=array(); - $labels=array(); - $classes=array(); - $tags=array(); - $catlabels=array(); - while ($result=mysql_fetch_array($res)){ - $labels[]=$result['label']; - $names[]=$result['name']; - if (!isset($result['category'])){ - $result['category']="NoCategory"; - $result2['label']="No Category"; + $bestsearches=""; + if (mysql_num_rows($res)>0){ + $names=array(); + $labels=array(); + $classes=array(); + $tags=array(); + $catlabels=array(); + while ($result=mysql_fetch_array($res)){ + $labels[]=$result['label']; + $names[]=$result['name']; + if (!isset($result['category'])){ + $result['category']="NoCategory"; + $result2['label']="No Category"; + } + else + { + $query="SELECT label FROM categories WHERE category='".$result['category']."' LIMIT 1"; + $res2=mysql_query($query); + $result2=mysql_fetch_array($res2); + } + $classes[]=$result['category']; + if (!isset($tags[$result['category']])) $tags[$result['category']]=1; + else $tags[$result['category']]++; + if (!isset($catlabels[$result['category']])) $catlabels[$result['category']]=$result2['label']; } - else - { - $query="SELECT label FROM categories WHERE category='".$result['category']."' LIMIT 1"; - $res2=mysql_query($query); - $result2=mysql_fetch_array($res2); - } - $classes[]=$result['category']; - if (!isset($tags[$result['category']])) $tags[$result['category']]=1; - else $tags[$result['category']]++; - if (!isset($catlabels[$result['category']])) $catlabels[$result['category']]=$result2['label']; + $content.=getTagCloud($tags,$catlabels); + $content.=getResultsTable($names,$labels,$classes,$number); + $bestsearches=getBestSearches($names,$labels); } - $content.=getTagCloud($tags,$catlabels); - $content.=getResultsTable($names,$labels,$classes,$number); + else + $content.="Your Search brought no results."; print $content; print '$$'; print "Searchresult for \"".$label."\""; + print '$$'; + print $bestsearches; ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/helper_functions.php =================================================================== --- trunk/src/dbpedia-navigator/helper_functions.php 2008-08-15 17:55:39 UTC (rev 1094) +++ trunk/src/dbpedia-navigator/helper_functions.php 2008-08-18 15:33:18 UTC (rev 1095) @@ -88,6 +88,25 @@ return $ret; } +function getBestSearches($names,$labels) +{ + $ret="<div id=\"best-results\">"; + for ($j=0;($j<10)&&$j<count($names);$j++) + { + $name=$names[$j]; + $label=$labels[$j]; + $ret.=' '.($j+1).'. <a href="" onclick="get_article(\'label='.$name.'&cache=-1\');return false;">'.$label.'</a><br/>'; + } + $ret.="</div>"; + return $ret; +} + +function getPrintableURL($url) +{ + $parts=explode('/',$url); + return $parts[0].'//'.$parts[2].'/w/index.php?title='.$parts[4].'&printable=yes'; +} + function setRunning($id,$running) { if(!is_dir("temp")) mkdir("temp"); @@ -106,7 +125,7 @@ $table .= '<tr style="background-color:#'.$backgroundcolor.';"><td><a href="'.$predicate.'">'.nicePredicate($predicate).'</a></td>'; $table .= '<td><ul>'; foreach($object as $element) { - if ($element['type']=="uri") $table .= '<li><a href="'.$element['value'].'">'.$element['value'].'</a></li>'; + if ($element['type']=="uri") $table .= '<li><a href="'.$element['value'].'" target="_blank">'.$element['value'].'</a></li>'; else $table .= '<li>'.$element['value'].'</li>'; } $table .= '</ul></td>'; @@ -146,9 +165,10 @@ } function formatClassArray($ar) { - $string = formatClass($ar[0]['value']); + if ($ar[0]['value']!="http://xmlns.com/foaf/0.1/Person") $string = formatClass($ar[0]['value']); for($i=1; $i<count($ar); $i++) { - $string .= ', ' . formatClass($ar[$i]['value']); + if ($ar[0]['value']!="http://xmlns.com/foaf/0.1/Person"||$i>1) $string .= ', ' . formatClass($ar[$i]['value']); + else $string .= formatClass($ar[$i]['value']); } return $string; } @@ -179,14 +199,15 @@ function show_Interests($sess) { + $ret=array(); + $ret[0]=""; + $ret[1]=""; if (isset($sess['positive'])) foreach($sess['positive'] as $name=>$lab){ - $ret[0]=$lab." <a href=\"\" onclick=\"toNegative('subject=".$name."&label=".$lab."');return false;\"><img src=\"".$_GET['path']."images/minus.jpg\" alt=\"Minus\"/></a> <a href=\"\" onclick=\"removePosInterest('subject=".$name."');return false;\"><img src=\"".$_GET['path']."images/remove.png\" alt=\"Delete\"/></a><br/>"; + $ret[0].=$lab." <a href=\"\" onclick=\"toNegative('subject=".$name."&label=".$lab."');return false;\"><img src=\"".$_GET['path']."images/minus.jpg\" alt=\"Minus\"/></a> <a href=\"\" onclick=\"removePosInterest('subject=".$name."');return false;\"><img src=\"".$_GET['path']."images/remove.png\" alt=\"Delete\"/></a><br/>"; } - else $ret[0]=""; if (isset($sess['negative'])) foreach($sess['negative'] as $name=>$lab){ - $ret[1]=$lab." <a href=\"\" onclick=\"toPositive('subject=".$name."&label=".$lab."');return false;\"><img src=\"".$_GET['path']."images/plus.jpg\" alt=\"Plus\"/></a> <a href=\"\" onclick=\"removeNegInterest('subject=".$name."');return false;\"><img src=\"".$_GET['path']."images/remove.png\" alt=\"Delete\"/></a><br/>"; + $ret[1].=$lab." <a href=\"\" onclick=\"toPositive('subject=".$name."&label=".$lab."');return false;\"><img src=\"".$_GET['path']."images/plus.jpg\" alt=\"Plus\"/></a> <a href=\"\" onclick=\"removeNegInterest('subject=".$name."');return false;\"><img src=\"".$_GET['path']."images/remove.png\" alt=\"Delete\"/></a><br/>"; } - else $ret[1]=""; return $ret; } Property changes on: trunk/src/dbpedia-navigator/images/dbpedia-favicon.ico ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Property changes on: trunk/src/dbpedia-navigator/images/flickr.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-08-15 17:55:39 UTC (rev 1094) +++ trunk/src/dbpedia-navigator/index.php 2008-08-18 15:33:18 UTC (rev 1095) @@ -17,18 +17,18 @@ require_once('Settings.php'); $settings=new Settings(); -/* + //what happens onLoad -$onLoad="onLoad=\""; +$onLoad="onLoad=\"document.getElementById('label').focus();"; if (isset($_GET['resource'])){ - $onLoad.="xajax_getarticle('".$_GET['resource']."',-1);"; + $onLoad.="get_article('label=".$_GET['resource']."&cache=-1');"; unset($_GET['resource']); } else if (isset($_SESSION['currentArticle'])){ - $onLoad.="xajax_getarticle('',".$_SESSION['currentArticle'].");"; + $onLoad.="get_article('label=&cache=".$_SESSION['currentArticle']."');"; } $onLoad.="\""; -*/ + echo '<?xml version="1.0" encoding="UTF-8"?>'; ?> @@ -45,351 +45,31 @@ type="text/javascript"></script> <script src="<?php print $path;?>treemenu/dhtmlxcommon.js"></script> <script src="<?php print $path;?>treemenu/dhtmlxtree.js"></script> + <script src="<?php print $path;?>js/ajax.js"></script> <script type="text/javascript"> - function showdiv(id){ - document.getElementById(id).style.display='block'; - } - - function hidediv(id) { - document.getElementById(id).style.display='none'; - } - + function setRunning(running) + { + if (running) document.getElementById('Loading').style.display='inline'; + else document.getElementById('Loading').style.display='none'; + } + function loadGoogleMap(Lat,Lng,Label) { - if (document.getElementById("map").style.display=="none"){ - document.getElementById("map").style.display='block'; - if (GBrowserIsCompatible()) { - // Create and Center a Map - var map = new GMap2(document.getElementById("map")); - map.setCenter(new GLatLng(Lat, Lng), 12); - map.addControl(new GLargeMapControl()); - map.addControl(new GMapTypeControl()); - var marker=new GMarker(new GLatLng(Lat, Lng)); - GEvent.addListener(marker, "click", function() { - marker.openInfoWindowHtml(Label); - }); - map.addOverlay(marker); - } - } - else { - document.getElementById("map").style.display='none'; + if (GBrowserIsCompatible()) { + // Create and Center a Map + var map = new GMap2(document.getElementById("map")); + map.setCenter(new GLatLng(Lat, Lng), 12); + map.addControl(new GLargeMapControl()); + map.addControl(new GMapTypeControl()); + var marker=new GMarker(new GLatLng(Lat, Lng)); + map.addOverlay(marker); } } - - function search_it(param) - { - if (document.all){ - //IE - var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); - } - else{ - //Mozilla - var XhrObj = new XMLHttpRequest(); - } - - XhrObj.open("POST",'ajax_search.php'); - - XhrObj.onreadystatechange = function() - { - if (XhrObj.readyState == 4 && XhrObj.status == 200){ - var response = XhrObj.responseText.split('$$'); - document.getElementById('articlecontent').innerHTML=response[0]; - document.getElementById('ArticleTitle').innerHTML=response[1]; - } - } - - XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); - XhrObj.send(param); - } - - function get_article(param) - { - if (document.all){ - //IE - var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); - } - else{ - //Mozilla - var XhrObj = new XMLHttpRequest(); - } - - XhrObj.open("POST",'ajax_get_article.php'); - - XhrObj.onreadystatechange = function() - { - if (XhrObj.readyState == 4 && XhrObj.status == 200){ - var response = XhrObj.responseText.split('$$'); - document.getElementById('articlecontent').innerHTML=response[0]; - document.getElementById('ArticleTitle').innerHTML=response[1]; - document.getElementById('lastarticles').innerHTML=response[2]; - document.getElementById('Positives').innerHTML=response[3]; - document.getElementById('Negatives').innerHTML=response[4]; - } - } - - XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); - XhrObj.send(param); - } - - function show_results(class, number) - { - var links=document.getElementById('results').getElementsByTagName('p'); - var j=0; - for (var i=0;i<links.length;i++){ - if (links[i].getElementsByTagName('a')[0].className==class||class=='all'){ - if ((j+1)>number&&j<(number+25)) links[i].style.display='block'; - else links[i].style.display='none'; - j++; - } - else links[i].style.display='none'; - } - if (j<number){ - show_results(class,0); - return; - } - - var sitenumbers=document.getElementById('sitenumbers').getElementsByTagName('span'); - for (var i=0;i<sitenumbers.length;i++){ - if ((parseInt(sitenumbers[i].getElementsByTagName('a')[0].innerHTML)-1)*25==number) sitenumbers[i].getElementsByTagName('a')[0].style.textDecoration='none'; - else sitenumbers[i].getElementsByTagName('a')[0].style.textDecoration='underline'; - if ((parseInt(sitenumbers[i].getElementsByTagName('a')[0].innerHTML)-1)*25>=j) - sitenumbers[i].style.display='none'; - else - sitenumbers[i].style.display='inline'; - } - } - - function toPositive(param) - { - if (document.all){ - //IE - var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); - } - else{ - //Mozilla - var XhrObj = new XMLHttpRequest(); - } - - XhrObj.open("POST",'ajax_to_positive.php'); - - XhrObj.onreadystatechange = function() - { - if (XhrObj.readyState == 4 && XhrObj.status == 200){ - var response = XhrObj.responseText.split('$$'); - document.getElementById('Positives').innerHTML=response[0]; - document.getElementById('Negatives').innerHTML=response[1]; - } - } - - XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); - XhrObj.send(param); - } - - function toNegative(param) - { - if (document.all){ - //IE - var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); - } - else{ - //Mozilla - var XhrObj = new XMLHttpRequest(); - } - - XhrObj.open("POST",'ajax_to_negative.php'); - - XhrObj.onreadystatechange = function() - { - if (XhrObj.readyState == 4 && XhrObj.status == 200){ - var response = XhrObj.responseText.split('$$'); - document.getElementById('Positives').innerHTML=response[0]; - document.getElementById('Negatives').innerHTML=response[1]; - } - } - - XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); - XhrObj.send(param); - } - - function clearPositives() - { - if (document.all){ - //IE - var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); - } - else{ - //Mozilla - var XhrObj = new XMLHttpRequest(); - } - - XhrObj.open("POST",'ajax_clear_positives.php'); - - XhrObj.onreadystatechange = function() - { - if (XhrObj.readyState == 4 && XhrObj.status == 200){ - document.getElementById('Positives').innerHTML = XhrObj.responseText; - } - } - - XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); - XhrObj.send(); - } - - function clearNegatives() - { - if (document.all){ - //IE - var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); - } - else{ - //Mozilla - var XhrObj = new XMLHttpRequest(); - } - - XhrObj.open("POST",'ajax_clear_negatives.php'); - - XhrObj.onreadystatechange = function() - { - if (XhrObj.readyState == 4 && XhrObj.status == 200){ - document.getElementById('Negatives').innerHTML = XhrObj.responseText; - } - } - - XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); - XhrObj.send(); - } - - function removePosInterest(param) - { - if (document.all){ - //IE - var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); - } - else{ - //Mozilla - var XhrObj = new XMLHttpRequest(); - } - - XhrObj.open("POST",'ajax_remove_pos_interest.php'); - - XhrObj.onreadystatechange = function() - { - if (XhrObj.readyState == 4 && XhrObj.status == 200){ - var response = XhrObj.responseText.split('$$'); - document.getElementById('Positives').innerHTML=response[0]; - document.getElementById('Negatives').innerHTML=response[1]; - } - } - - XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); - XhrObj.send(param); - } - - function removeNegInterest(param) - { - if (document.all){ - //IE - var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); - } - else{ - //Mozilla - var XhrObj = new XMLHttpRequest(); - } - - XhrObj.open("POST",'ajax_remove_neg_interest.php'); - - XhrObj.onreadystatechange = function() - { - if (XhrObj.readyState == 4 && XhrObj.status == 200){ - var response = XhrObj.responseText.split('$$'); - document.getElementById('Positives').innerHTML=response[0]; - document.getElementById('Negatives').innerHTML=response[1]; - } - } - - XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); - XhrObj.send(param); - } - - function learnConcept() - { - if (document.all){ - //IE - var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); - } - else{ - //Mozilla - var XhrObj = new XMLHttpRequest(); - } - - XhrObj.open("POST",'ajax_learn_concepts.php'); - - XhrObj.onreadystatechange = function() - { - if (XhrObj.readyState == 4 && XhrObj.status == 200){ - var response = XhrObj.responseText.split('$$'); - document.getElementById('conceptlink').innerHTML=response[0]; - document.getElementById('ConceptInformation').innerHTML=response[1]; - } - } - - XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); - XhrObj.send(); - } - - function stopServerCall() - { - if (document.all){ - //IE - var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); - } - else{ - //Mozilla - var XhrObj = new XMLHttpRequest(); - } - - XhrObj.open("POST",'ajax_stop_server_call.php'); - - XhrObj.onreadystatechange = function() - { - if (XhrObj.readyState == 4 && XhrObj.status == 200){ - } - } - - XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); - XhrObj.send(); - } - - function getSubjectsFromConcept(param) - { - if (document.all){ - //IE - var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); - } - else{ - //Mozilla - var XhrObj = new XMLHttpRequest(); - } - - XhrObj.open("POST",'ajax_get_subjects_from_concept.php'); - - XhrObj.onreadystatechange = function() - { - if (XhrObj.readyState == 4 && XhrObj.status == 200){ - var response = XhrObj.responseText.split('$$'); - document.getElementById('articlecontent').innerHTML=response[0]; - document.getElementById('ArticleTitle').innerHTML=response[1]; - } - } - - XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); - XhrObj.send(param); - } </script> </head> - <body> + <body <?php print $onLoad;?>> <!-- <h1>DBpedia Navigator</h1> --> -<div><table border="0" width="100%"><tr><td width="35%"><img src="<?php print $path;?>images/dbpedia_navigator.png" alt="DBpedia Navigator" style="padding:5px" /></td><td width="50%"><span id="conceptlink"></span></td><td width="15%"><span id="Loading" style="display:none">Server Call... <img src="<?php print $path;?>images/remove.png" onclick="xajax_stopServerCall();return false;" /></span></td></tr></table></div> +<div><table border="0" width="100%"><tr><td width="35%"><img src="<?php print $path;?>images/dbpedia_navigator.png" alt="DBpedia Navigator" style="padding:5px" /></td><td width="50%"><span id="conceptlink"></span></td><td width="15%"><span id="Loading" style="display:none">Server Call... <a href=""><img src="<?php print $path;?>images/remove.png" onclick="stopServerCall();return false;" /></a></span></td></tr></table></div> <div id="layer" style="display:none"> <div id="layerContent" style="display:none"></div> </div> @@ -398,26 +78,26 @@ <div id="leftSidebar"> <div class="box"> - <div class="boxtitle">Search DBpedia</div> + <div class="boxtitle" style="cursor:help;" title="Show an article or search for several articles in the DBpedia database.">Search DBpedia</div> <div class="boxcontent" id="search"> <!-- Search:<br/> --> - <form onSubmit="get_article('label='+document.getElementById('label').value+'&cache=-1');return false;"> - <input type="text" name="label" id="label" /><br/> - <input type="button" value="Article" class="button" onclick="get_article('label='+document.getElementById('label').value+'&cache=-1');return false;" /> <input type="button" value="Search" class="button" onclick="var list=tree.getAllChecked();search_it('label='+document.getElementById('label').value+'&list='+list+'&number=10');return false;" /> + <form onsubmit="get_article('label='+document.getElementById('label').value+'&cache=-1');return false;"> + <input type="text" name="label" id="label"/><br/> + <input type="button" value="Article" class="button" onclick="get_article('label='+document.getElementById('label').value+'&cache=-1');return false;" title="Search an article with that name."/> <input type="button" value="Search" class="button" onclick="var list=tree.getAllChecked();search_it('label='+document.getElementById('label').value+'&list='+list+'&number=10');return false;" title="Search a number of articles related to that name."/> <!-- <input type="button" value="Fulltext" class="button" onclick=""/> --> </form> </div> <!-- boxcontent --> </div> <!-- box --> <div class="box" id="SearchResultBox" style="display:none"> - <div class="boxtitle">Search Results</div> + <div class="boxtitle" style="cursor:help;" title="The best 10 Search Results are shown here.">Search Results</div> <div class="boxcontent"> <div id="searchcontent" style="display:block"></div> </div> <!-- boxcontent --> </div> <!-- box --> <div class="box" id="NavigationBox"> - <div class="boxtitle">Navigate</div> + <div class="boxtitle" style="cursor:help;" title="Navigate through the Class hierarchy and show instances of that class.">Navigate</div> <div class="boxcontent"> <div id="treeboxbox_tree" style="height:218px;overflow:auto;"> </div> @@ -430,8 +110,12 @@ tree.setOnClickHandler(doOnClick); function doOnClick(nodeId){ var myUrl = tree.getUserData(nodeId,"myurl"); - xajax_getSubjectsFromConcept(myUrl); + getSubjectsFromConcept('concept='+myUrl); } + function myErrorHandler(type, desc, erData){ + alert('An error occured while trying to navigate through Class Tree.\nPlease try again later.'); + } + dhtmlxError.catchError("ALL",myErrorHandler); tree.setXMLAutoLoading("processTreeMenu.php"); tree.loadXML("processTreeMenu.php?id=0"); </script> @@ -549,7 +233,7 @@ <div class="boxtitle">Detailed Concept Information</div> <div class="boxcontent" id="ConceptInformation"></div> </div> - + </body> </html> \ No newline at end of file Added: trunk/src/dbpedia-navigator/js/ajax.js =================================================================== --- trunk/src/dbpedia-navigator/js/ajax.js (rev 0) +++ trunk/src/dbpedia-navigator/js/ajax.js 2008-08-18 15:33:18 UTC (rev 1095) @@ -0,0 +1,322 @@ +function search_it(param) +{ + if (document.all){ + //IE + var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); + } + else{ + //Mozilla + var XhrObj = new XMLHttpRequest(); + } + + XhrObj.open("POST",'ajax_search.php'); + + XhrObj.onreadystatechange = function() + { + if (XhrObj.readyState == 4 && XhrObj.status == 200){ + var response = XhrObj.responseText.split('$$'); + document.getElementById('articlecontent').innerHTML=response[0]; + document.getElementById('ArticleTitle').innerHTML=response[1]; + if (response[2].length>0){ + document.getElementById('searchcontent').innerHTML=response[2]; + document.getElementById('SearchResultBox').style.display='block'; + } + } + } + + XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); + XhrObj.send(param); +} + +function get_article(param) +{ + setRunning(true); + if (document.all){ + //IE + var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); + } + else{ + //Mozilla + var XhrObj = new XMLHttpRequest(); + } + + XhrObj.open("POST",'ajax_get_article.php'); + + XhrObj.onreadystatechange = function() + { + if (XhrObj.readyState == 4 && XhrObj.status == 200){ + var response = XhrObj.responseText.split('$$'); + document.getElementById('articlecontent').innerHTML=response[0]; + document.getElementById('ArticleTitle').innerHTML=response[1]; + document.getElementById('lastarticles').innerHTML=response[2]; + document.getElementById('Positives').innerHTML=response[3]; + document.getElementById('Negatives').innerHTML=response[4]; + setRunning(false); + if (response[1]=='Article not found'){ + setTimeout("var list=tree.getAllChecked();search_it('label='+document.getElementById('label').value+'&list='+list+'&number=10')",2000); + } + else + document.getElementById('LastArticlesBox').style.display='block'; + } + if (response[5].length>0&&response[6].length>0) + loadGoogleMap(response[5],response[6],''+response[1]); + } + + XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); + XhrObj.send(param); +} + +function show_results(class, number) +{ + var links=document.getElementById('results').getElementsByTagName('p'); + var j=0; + for (var i=0;i<links.length;i++){ + if (links[i].getElementsByTagName('a')[0].className==class||class=='all'){ + if ((j+1)>number&&j<(number+25)) links[i].style.display='block'; + else links[i].style.display='none'; + j++; + } + else links[i].style.display='none'; + } + if (j<number){ + show_results(class,0); + return; + } + + var sitenumbers=document.getElementById('sitenumbers').getElementsByTagName('span'); + for (var i=0;i<sitenumbers.length;i++){ + if ((parseInt(sitenumbers[i].getElementsByTagName('a')[0].innerHTML)-1)*25==number) sitenumbers[i].getElementsByTagName('a')[0].style.textDecoration='none'; + else sitenumbers[i].getElementsByTagName('a')[0].style.textDecoration='underline'; + if ((parseInt(sitenumbers[i].getElementsByTagName('a')[0].innerHTML)-1)*25>=j) + sitenumbers[i].style.display='none'; + else + sitenumbers[i].style.display='inline'; + } +} + +function toPositive(param) +{ + if (document.all){ + //IE + var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); + } + else{ + //Mozilla + var XhrObj = new XMLHttpRequest(); + } + + XhrObj.open("POST",'ajax_to_positive.php'); + + XhrObj.onreadystatechange = function() + { + if (XhrObj.readyState == 4 && XhrObj.status == 200){ + var response = XhrObj.responseText.split('$$'); + document.getElementById('Positives').innerHTML=response[0]; + document.getElementById('Negatives').innerHTML=response[1]; + } + } + + XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); + XhrObj.send(param); +} + +function toNegative(param) +{ + if (document.all){ + //IE + var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); + } + else{ + //Mozilla + var XhrObj = new XMLHttpRequest(); + } + + XhrObj.open("POST",'ajax_to_negative.php'); + + XhrObj.onreadystatechange = function() + { + if (XhrObj.readyState == 4 && XhrObj.status == 200){ + var response = XhrObj.responseText.split('$$'); + document.getElementById('Positives').innerHTML=response[0]; + document.getElementById('Negatives').innerHTML=response[1]; + } + } + + XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); + XhrObj.send(param); +} + + function clearPositives() + { + if (document.all){ + //IE + var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); + } + else{ + //Mozilla + var XhrObj = new XMLHttpRequest(); + } + + XhrObj.open("POST",'ajax_clear_positives.php'); + + XhrObj.onreadystatechange = function() + { + if (XhrObj.readyState == 4 && XhrObj.status == 200){ + document.getElementById('Positives').innerHTML = XhrObj.responseText; + } + } + + XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); + XhrObj.send(); + } + + function clearNegatives() + { + if (document.all){ + //IE + var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); + } + else{ + //Mozilla + var XhrObj = new XMLHttpRequest(); + } + + XhrObj.open("POST",'ajax_clear_negatives.php'); + + XhrObj.onreadystatechange = function() + { + if (XhrObj.readyState == 4 && XhrObj.status == 200){ + document.getElementById('Negatives').innerHTML = XhrObj.responseText; + } + } + + XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); + XhrObj.send(); + } + + function removePosInterest(param) + { + if (document.all){ + //IE + var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); + } + else{ + //Mozilla + var XhrObj = new XMLHttpRequest(); + } + + XhrObj.open("POST",'ajax_remove_pos_interest.php'); + + XhrObj.onreadystatechange = function() + { + if (XhrObj.readyState == 4 && XhrObj.status == 200){ + var response = XhrObj.responseText.split('$$'); + document.getElementById('Positives').innerHTML=response[0]; + document.getElementById('Negatives').innerHTML=response[1]; + } + } + + XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); + XhrObj.send(param); + } + + function removeNegInterest(param) + { + if (document.all){ + //IE + var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); + } + else{ + //Mozilla + var XhrObj = new XMLHttpRequest(); + } + + XhrObj.open("POST",'ajax_remove_neg_interest.php'); + + XhrObj.onreadystatechange = function() + { + if (XhrObj.readyState == 4 && XhrObj.status == 200){ + var response = XhrObj.responseText.split('$$'); + document.getElementById('Positives').innerHTML=response[0]; + document.getElementById('Negatives').innerHTML=response[1]; + } + } + + XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); + XhrObj.send(param); + } + + function learnConcept() + { + if (document.all){ + //IE + var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); + } + else{ + //Mozilla + var XhrObj = new XMLHttpRequest(); + } + + XhrObj.open("POST",'ajax_learn_concepts.php'); + + XhrObj.onreadystatechange = function() + { + if (XhrObj.readyState == 4 && XhrObj.status == 200){ + var response = XhrObj.responseText.split('$$'); + document.getElementById('conceptlink').innerHTML=response[0]; + document.getElementById('ConceptInformation').innerHTML=response[1]; + } + } + + XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); + XhrObj.send(); + } + + function stopServerCall() + { + if (document.all){ + //IE + var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); + } + else{ + //Mozilla + var XhrObj = new XMLHttpRequest(); + } + + XhrObj.open("POST",'ajax_stop_server_call.php'); + + XhrObj.onreadystatechange = function() + { + if (XhrObj.readyState == 4 && XhrObj.status == 200){ + } + } + + XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); + XhrObj.send(); + } + + function getSubjectsFromConcept(param) + { + if (document.all){ + //IE + var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); + } + else{ + //Mozilla + var XhrObj = new XMLHttpRequest(); + } + + XhrObj.open("POST",'ajax_get_subjects_from_concept.php'); + + XhrObj.onreadystatechange = function() + { + if (XhrObj.readyState == 4 && XhrObj.status == 200){ + var response = XhrObj.responseText.split('$$'); + document.getElementById('articlecontent').innerHTML=response[0]; + document.getElementById('ArticleTitle').innerHTML=response[1]; + } + } + + XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); + XhrObj.send(param); + } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |