From: <sk...@us...> - 2008-02-05 15:59:49
|
Revision: 497 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=497&view=rev Author: sknappe Date: 2008-02-05 07:59:48 -0800 (Tue, 05 Feb 2008) Log Message: ----------- now everything is in one function, no session variables needed anymore Modified Paths: -------------- trunk/src/dbpedia-navigator/ajax.php trunk/src/dbpedia-navigator/ajaxfunctions.php trunk/src/dbpedia-navigator/index.php Modified: trunk/src/dbpedia-navigator/ajax.php =================================================================== --- trunk/src/dbpedia-navigator/ajax.php 2008-02-05 15:39:08 UTC (rev 496) +++ trunk/src/dbpedia-navigator/ajax.php 2008-02-05 15:59:48 UTC (rev 497) @@ -4,35 +4,28 @@ $xajax = new xajax("ajaxfunctions.php?sid=$sid"); $xajax->configureMany(array('debug'=>true)); -$xajax->register(XAJAX_FUNCTION, 'showSubjects', array( + +$xajax->register(XAJAX_FUNCTION, 'getsubjects', array( 'onResponseDelay' => 'showLoading', 'beforeResponseProcessing' => 'hideLoading' )); -$xajax->registerFunction('getarticle'); -$xajax->registerFunction('toPositive'); -$xajax->registerFunction('toNegative'); -$xajax->registerFunction('clearPositives'); -$xajax->registerFunction('clearNegatives'); -$xajax->registerFunction('showInterests'); -$xajax->registerFunction('getAndShowArticle'); -$xajax->registerFunction('learnConcept'); -$xajax->registerFunction('getSubjectsFromConcept'); -$xajax->registerFunction('getAndShowSubjects'); -$xajax->registerFunction('getsubjects'); -$xajax->register(XAJAX_FUNCTION,'showArticle', array( +$xajax->register(XAJAX_FUNCTION,'getarticle', array( 'onResponseDelay' => 'showLoading', 'beforeResponseProcessing' => 'hideLoading' )); -$xajax->registerFunction('removePosInterest'); -$xajax->registerFunction('removeNegInterest'); -$xajax->register(XAJAX_FUNCTION,'showConcept', array( +$xajax->register(XAJAX_FUNCTION,'learnConcept', array( 'onResponseDelay' => 'showLoading', 'beforeResponseProcessing' => 'hideLoading' )); -$xajax->registerFunction('learnAndShowConcept'); -$xajax->register(XAJAX_FUNCTION,'showSubjectsFromConcept', array( +$xajax->register(XAJAX_FUNCTION,'getSubjectsFromConcept', array( 'onResponseDelay' => 'showLoading', 'beforeResponseProcessing' => 'hideLoading' )); -$xajax->registerFunction('getAndShowSubjectsFromConcept'); + $xajax->registerFunction('toPositive'); +$xajax->registerFunction('toNegative'); +$xajax->registerFunction('clearPositives'); +$xajax->registerFunction('clearNegatives'); +$xajax->registerFunction('showInterests'); +$xajax->registerFunction('removePosInterest'); +$xajax->registerFunction('removeNegInterest'); ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-02-05 15:39:08 UTC (rev 496) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-02-05 15:59:48 UTC (rev 497) @@ -21,29 +21,17 @@ foreach ($subjects as $subject) { - $content.="<a href=\"\" onclick=\"xajax_getAndShowArticle('".urldecode(str_replace("_"," ",substr (strrchr ($subject, "/"), 1)))."',-2);return false;\">".urldecode(str_replace("_"," ",substr (strrchr ($subject, "/"), 1)))."</a><br/>"; + $content.="<a href=\"\" onclick=\"xajax_getarticle('".urldecode(str_replace("_"," ",substr (strrchr ($subject, "/"), 1)))."',-2);return false;\">".urldecode(str_replace("_"," ",substr (strrchr ($subject, "/"), 1)))."</a><br/>"; } } catch (Exception $e){ $content=$e->getMessage(); } - $_SESSION['subjects']=$content; - $objResponse = new xajaxResponse(); + $objResponse->assign("searchcontent", "innerHTML", $content); return $objResponse; } -function showSubjects() -{ - while (!isset($_SESSION['subjects'])){ - sleep(0.5); - } - $objResponse = new xajaxResponse(); - $objResponse->assign("searchcontent", "innerHTML", $_SESSION['subjects']); - unset($_SESSION['subjects']); - return $objResponse; -} - function getarticle($subject,$fromCache) { //if article is in session, get it out of the session @@ -143,7 +131,7 @@ //BUILD SEARCHRESULT if ($fromCache==-1) - $searchResult.="<a href=\"\" onclick=\"xajax_getAndShowSubjects('".$subject."');return false;\">Show more Results</a>"; + $searchResult.="<a href=\"\" onclick=\"xajax_getsubjects('".$subject."');return false;\">Show more Results</a>"; } catch (Exception $e) { $content=$e->getMessage(); @@ -160,49 +148,20 @@ if (isset($_SESSION['articles'])){ foreach ($_SESSION['articles'] as $key => $value) { - $lastArticles.="<a href=\"\" onclick=\"xajax_getAndShowArticle('',".$key.");return false;\">".$value['subject']."</a><br/>"; + $lastArticles.="<a href=\"\" onclick=\"xajax_getarticle('',".$key.");return false;\">".$value['subject']."</a><br/>"; } } - //put whole site content into session - $_SESSION['artContent']=$content; - $_SESSION['artTitle']=$artTitle; - $_SESSION['artLast']=$lastArticles; - $_SESSION['artSubjects']=$searchResult; - $objResponse = new xajaxResponse(); + $objResponse->assign("articlecontent", "innerHTML", $content); + $objResponse->assign("ArticleTitle","innerHTML",$artTitle); + $objResponse->assign("lastarticles","innerHTML",$lastArticles); + $objResponse->assign("searchcontent", "innerHTML", $searchResult); + + $objResponse->call('xajax_showInterests'); return $objResponse; } -function showArticle() -{ - while (!isset($_SESSION['artSubjects'])){ - sleep(0.5); - } - $objResponse = new xajaxResponse(); - $objResponse->assign("articlecontent", "innerHTML", $_SESSION['artContent']); - $objResponse->assign("ArticleTitle","innerHTML",$_SESSION['artTitle']); - $objResponse->assign("lastarticles","innerHTML",$_SESSION['artLast']); - if ($_SESSION['artSubjects']!="") $objResponse->assign("searchcontent", "innerHTML", $_SESSION['artSubjects']); - if (strpos($_SESSION['artContent'],"Did not find an article with that name")===0) - $objResponse->call('xajax_getAndShowSubjects',$_SESSION['artTitle']); - unset($_SESSION['artContent']); - unset($_SESSION['artTitle']); - unset($_SESSION['artLast']); - unset($_SESSION['artSubjects']); - - $objResponse->call('xajax_showInterests'); - return $objResponse; -} - -function getAndShowArticle($subject,$fromCache) -{ - $objResponse = new xajaxResponse(); - $objResponse->call('xajax_getarticle',$subject,$fromCache); - $objResponse->call('xajax_showArticle'); - return $objResponse; -} - function toPositive($subject) { unset($_SESSION['negative'][$subject]); @@ -315,15 +274,14 @@ $_SESSION['lastLearnedConcept']=$concepts; $concept.="<table border=0>\n"; foreach ($concepts as $con){ - $concept.="<tr><td><a href=\"\" onclick=\"xajax_getAndShowSubjectsFromConcept('".$con."');return false;\" />".$con."</a></td></tr>"; + $concept.="<tr><td><a href=\"\" onclick=\"xajax_getSubjectsFromConcept('".$con."');return false;\" />".$con."</a></td></tr>"; } $concept.="</table>"; } else $concept="You must choose at least one positive example."; - $_SESSION['conceptcontent']=$concept; - $objResponse = new xajaxResponse(); + $objResponse->assign("conceptlink", "innerHTML", $concept); return $objResponse; } @@ -336,65 +294,17 @@ $subjects=$sc->getSubjectsFromConcept($concept); foreach ($subjects as $subject) { - $content.="<a href=\"\" onclick=\"xajax_getAndShowArticle('".urldecode(str_replace("_"," ",substr (strrchr ($subject, "/"), 1)))."',-2);return false;\">".urldecode(str_replace("_"," ",substr (strrchr ($subject, "/"), 1)))."</a><br/>"; + $content.="<a href=\"\" onclick=\"xajax_getarticle('".urldecode(str_replace("_"," ",substr (strrchr ($subject, "/"), 1)))."',-2);return false;\">".urldecode(str_replace("_"," ",substr (strrchr ($subject, "/"), 1)))."</a><br/>"; } } catch (Exception $e){ $content=$e->getMessage(); } - $_SESSION['conceptsubjectcontent']=$content; $objResponse = new xajaxResponse(); + $objResponse->assign("searchcontent", "innerHTML", $content); return $objResponse; } -function getAndShowSubjects($keyword) -{ - $objResponse = new xajaxResponse(); - $objResponse->call('xajax_getsubjects',$keyword); - $objResponse->call('xajax_showSubjects'); - return $objResponse; -} - -function learnAndShowConcept() -{ - $objResponse = new xajaxResponse(); - $objResponse->call('xajax_learnConcept'); - $objResponse->call('xajax_showConcept'); - return $objResponse; -} - -function showConcept() -{ - while (!isset($_SESSION['conceptcontent'])){ - sleep(0.5); - } - - $objResponse = new xajaxResponse(); - $objResponse->assign("conceptlink", "innerHTML", $_SESSION['conceptcontent']); - unset($_SESSION['conceptcontent']); - return $objResponse; -} - -function getAndShowSubjectsFromConcept($concept) -{ - $objResponse = new xajaxResponse(); - $objResponse->call('xajax_getSubjectsFromConcept',$concept); - $objResponse->call('xajax_showSubjectsFromConcept'); - return $objResponse; -} - -function showSubjectsFromConcept() -{ - while (!isset($_SESSION['conceptsubjectcontent'])){ - sleep(0.5); - } - - $objResponse = new xajaxResponse(); - $objResponse->assign("searchcontent", "innerHTML", $_SESSION['conceptsubjectcontent']); - unset($_SESSION['conceptsubjectcontent']); - return $objResponse; -} - /////////////////////// // Helper Functions. // /////////////////////// Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-02-05 15:39:08 UTC (rev 496) +++ trunk/src/dbpedia-navigator/index.php 2008-02-05 15:59:48 UTC (rev 497) @@ -42,7 +42,7 @@ <body> <!-- <h1>DBpedia Navigator</h1> --> -<div><img src="images/dbpedia_navigator.png" alt="DBpedia Navigator" style="padding:5px" /> <input type="button" value="Learn" class="button" onclick="xajax_learnAndShowConcept();return false;" /> <span id="conceptlink"></span><span id="Loading" style="display:none">Loading...</span></div> +<div><img src="images/dbpedia_navigator.png" alt="DBpedia Navigator" style="padding:5px" /> <input type="button" value="Learn" class="button" onclick="xajax_learnConcept();return false;" /> <span id="conceptlink"></span><span id="Loading" style="display:none">Loading...</span></div> <div id="layer" style="display:none"> <div id="layerContent" style="display:none"></div> </div> @@ -54,9 +54,9 @@ <div class="boxtitle">Search DBpedia</div> <div class="boxcontent" id="search"> <!-- Search:<br/> --> - <form onSubmit="xajax_getAndShowArticle(document.getElementById('label').value,-1);return false;"> + <form onSubmit="xajax_getarticle(document.getElementById('label').value,-1);return false;"> <input type="text" name="label" id="label" /><br/> - <input type="button" value="Search" class="button" onclick="xajax_getAndShowArticle(document.getElementById('label').value,-1);return false;" /> + <input type="button" value="Search" class="button" onclick="xajax_getarticle(document.getElementById('label').value,-1);return false;" /> <!-- <input type="button" value="Fulltext" class="button" onclick=""/> --> </form> </div> <!-- boxcontent --> @@ -66,7 +66,6 @@ <div class="boxtitle">Search Results</div> <div class="boxcontent"> <div id="searchcontent" style="display:block"></div> - <div id="loadingSubject" style="display:none"><img src="ajax-loader.gif" alt="Loading..."/></div> </div> <!-- boxcontent --> </div> <!-- box --> @@ -96,7 +95,6 @@ and uses the background knowledge in DBpedia to suggest possible interesting navigation links. </div> - <div id="loadingArticle" style="display:none"><img src="ajax-loader.gif" alt="Loading..."/></div> </div> <!-- boxcontent --> </div> <!-- box --> </div><!-- content --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |