From: <ku...@us...> - 2007-08-22 10:18:10
|
Revision: 17 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=17&view=rev Author: kurzum Date: 2007-08-22 03:18:08 -0700 (Wed, 22 Aug 2007) Log Message: ----------- added php lcient Added Paths: ----------- trunk/src/php-client/LearnerClient.php trunk/src/php-client/Model.php trunk/src/php-client/Settings.php trunk/src/php-client/default.css trunk/src/php-client/index.php trunk/src/php-client/jscript/ trunk/src/php-client/jscript/script.js trunk/src/php-client/jscript/tip_centerwindow.js trunk/src/php-client/jscript/tip_followscroll.js trunk/src/php-client/jscript/wz_tooltip.js trunk/src/php-client/master.php trunk/src/php-client/ontologies/ trunk/src/php-client/ontologies/father.owl trunk/src/php-client/ontologies/moral_complete.owl trunk/src/php-client/ontologies/trains.owl trunk/src/php-client/pear/ trunk/src/php-client/pear/HTTP_Request.php trunk/src/php-client/pear/PEAR.php trunk/src/php-client/pear/Socket.php trunk/src/php-client/pear/URL.php trunk/src/php-client/save/ trunk/src/php-client/save/arch_working trunk/src/php-client/save/father_working trunk/src/php-client/save/not_working_for_testing trunk/src/php-client/save/train_working Property Changed: ---------------- trunk/src/php-client/ Property changes on: trunk/src/php-client ___________________________________________________________________ Name: svn:ignore + main.wsdl def0.xsd def1.xsd java_server.zip php_client.zip Added: trunk/src/php-client/LearnerClient.php =================================================================== --- trunk/src/php-client/LearnerClient.php (rev 0) +++ trunk/src/php-client/LearnerClient.php 2007-08-22 10:18:08 UTC (rev 17) @@ -0,0 +1,299 @@ +<?php +require_once 'pear/HTTP_Request.php'; + + + class LearnerClient{ + private $soapclient; + private $id; + + + public function __construct($wsdluri,$getID=0){ + + $this->loadWSDLfiles($wsdluri); + $this->soapclient = new SoapClient("main.wsdl"); + if($getID==0) + { + $this->id=$this->soapclient->getID(); + } + else + { + $this->id=$getID; + } + + + } + + /*public function __construct($wsdluri,$id){ + + $this->loadWSDLfiles($wsdluri); + $this->soapclient = new SoapClient("main.wsdl"); + $this->id=$id; + + }*/ + + public function getID(){ + return $this->id; + } + + + // this could maybe be a + //nice function which encapsulates everything + public function getClientState($id){ + + + } + + public function getInstances($id){ + $obj= $this->soapclient->getInstances($id); + return $this->parseStringlist($obj); + + } + + public function getAtomicConcepts($id) + { $obj= $this->soapclient->getAtomicConcepts($id); + return $this->parseStringlist($obj); + } + + public function retrieval($id,$concept){ + $obj= $this->soapclient->retrieval($id,$concept); + return $this->parseStringlist($obj); + } + + public function getAtomicRoles($id){ + $obj= $this->soapclient->getAtomicRoles($id); + return $this->parseStringlist($obj); + } + public function getIndividualsForARole($id,$Role){ + $obj= $this->soapclient->getIndividualsForARole($id,$Role); + return $this->parseStringlist($obj); + } + + public function getPositiveExamples($id){ + $obj= $this->soapclient->getPositiveExamples($id); + return $this->parseStringlist($obj); + + } + + public function getNegativeExamples($id){ + $obj= $this->soapclient->getNegativeExamples($id); + return $this->parseStringlist($obj); + + + } + public function getIgnoredConcepts($id){ + $obj= $this->soapclient->getIgnoredConcepts($id); + return $this->parseStringlist($obj); + } + public function getSubsumptionHierarchy($id){ + return $this->soapclient->getSubsumptionHierarchy($id); + } + + public function addPositiveExample($id,$name){ + return $this->soapclient->addPositiveExample($id,$name); + + } + + + + public function addNegativeExample($id,$name){ + return $this->soapclient->addNegativeExample($id,$name); + + } + public function addIgnoredConcept($id,$name){ + return $this->soapclient->addIgnoredConcept($id,$name); + + } + + public function selectInstancesForAConcept($id,$Concept){ + $obj=$this->soapclient->selectInstancesForAConcept($id,$Concept); + return $this->parseStringlist($obj); + } + public function selectAConcept($id,$Concept,$Percentage=100){ + $obj=$this->soapclient->selectAConcept($id,$Concept,$Percentage); + return $this->parseStringlist($obj); + } + + public function removePositiveExample($id,$name){ + return $this->soapclient->removePositiveExample($id,$name); + } + + public function removeNegativeExample($id,$name){ + return $this->soapclient->removeNegativeExample($id,$name); + } + public function removeAllPositiveExamples($id){ + return $this->soapclient->removeAllPositiveExamples($id); + } + public function removeAllNegativeExamples($id){ + return $this->soapclient->removeAllNegativeExamples($id); + } + public function removeAllExamples($id){ + return $this->soapclient->removeAllExamples($id); + } + public function removeIgnoredConcept($id,$name){ + return $this->soapclient->removeIgnoredConcept($id,$name); + } + + public function getCurrentOntologyURL($id){ + return $this->soapclient->getCurrentOntologyURL($id); + } + + public function removeOntology($id){ + $this->soapclient->removeOntology($id); + } + + public function readOntology($id,$ontologyURI,$format='RDF/XML'){ + $this->soapclient->readOntology($id,$ontologyURI,$format); + } + + public function getAlgorithmStatus($id){ + + return $this->soapclient->getAlgorithmStatus($id); + + } + + /*public function hello($arr){ + + return $this->soapclient->hello($arr); + + }*/ + + public function learnConcept($id){ + + + $concept = $this->soapclient->learnConcept($id); + return $concept; + } + + public function learnMonitored($id){ + $this->soapclient->learnMonitored($id); + } + + /*public function relearn($id,$concept){ + $this->soapclient->relearn($id,$concept); + }*/ + + + public function getLastResult($id){ + + + return $this->soapclient->getLastResult($id); + + } + + public function stop($id){ + try{ + $this->soapclient->stop($id); + }catch (Exception $e){echo "<xmp>"; print_r($e);} + } + + + + /**WSDL MANAGEMENT******/ + + + public function getInfo(){ + + $functions = $this->soapclient->__getFunctions(); + echo '<b>Verf\xFCgbare Methoden:</b>'; + echo '<pre>'; + print_r($functions); + echo '</pre>'; + + + } + + + public function loadWSDLfiles($wsdluri){ + $main=$this->getwsdl($wsdluri); + $other=$this->getOtherWSDL($main); + $newMain=$this->changeWSDL($main); + $this->writeToFile("main.wsdl",$newMain); + $x=0; + foreach ($other as $o){ + $this->writeToFile("def".($x++).".xsd",$this->getwsdl($o)); + } + + } + + public function changeWSDL($wsdl){ + $before="<xsd:import schemaLocation=\""; + $after="\" namespace=\""; + $newWSDL=""; + $desca="def"; + $descb=".xsd"; + $x=0; + while($posstart= strpos ( $wsdl, $before )){ + + $posstart+=strlen($before); + $newWSDL.=substr($wsdl,0,$posstart); + $wsdl=substr($wsdl,$posstart); + $newWSDL.=$desca.($x++).$descb; + $posend= strpos ( $wsdl, $after ); + $wsdl=substr($wsdl,$posend); + + } + return $newWSDL.$wsdl; + + } + + public function getOtherWSDL($wsdl){ + $before="<xsd:import schemaLocation=\""; + $after="\" namespace=\""; + $ret=array(); + while($posstart= strpos ( $wsdl, $before )){ + $posstart+=strlen($before); + $wsdl=substr($wsdl,$posstart); + $posend= strpos ( $wsdl, $after ); + $tmp=substr($wsdl,0,$posend); + $ret[]=$tmp; + $wsdl=substr($wsdl,$posend+strlen($after)); + } + return $ret; + } + + + + + public function getwsdl($wsdluri){ + // this is copied from the Pear example + // please don't ask me how it works + $req = &new HTTP_Request($wsdluri); + $message=""; + $req->setMethod(HTTP_REQUEST_METHOD_GET); + $req->sendRequest(); + $ret=$req->getResponseBody(); + return $ret; + } + + + + public function writeToFile($filename,$content){ + + $fp=fopen($filename,"w"); + fwrite($fp,$content); + fclose($fp); + + } + + public function parseStringlist($a) + { + ini_set('error_reporting',E_ALL & ~E_NOTICE); + $list=$a->item; + ini_set('error_reporting',E_ALL & ~E_NOTICE); + if(sizeof($list)==0) + { + + return array(); + } + else if(sizeof($list)==1) + { + $tmp=array(); + $tmp[]=$list; + return $tmp; + } + + return $list; + } +} + +?> \ No newline at end of file Added: trunk/src/php-client/Model.php =================================================================== --- trunk/src/php-client/Model.php (rev 0) +++ trunk/src/php-client/Model.php 2007-08-22 10:18:08 UTC (rev 17) @@ -0,0 +1,575 @@ +<?php + + +include_once("Settings.php"); +include_once("LearnerClient.php"); +require_once 'pear/HTTP_Request.php'; + + +class Model{ + + public $lc; + public $id; + + + + + public $lastResult; + public $currentOntology; + public $ontologySelected; + public $positives; + public $negatives; + public $instances; + public $error=""; + public $errorOccurred; + public $algorithmStatus; + public $message=""; + public $instancesOfConcepts; + public $conceptsOfinstances; + public $concepts; + public $rolesOfInstances; + public $roles; + public $retrievalActive; + public $ignoredClasses; + public $subsumptionHierarchy; + + + public function __construct($id,$learnerclient,$retrievalActive="active"){ + + $this->lc=$learnerclient; + $this->ontologySelected=false; + $this->id=$id; + $this->errorOccurred=false; + $this->algorithmStatus=""; + $this->conceptsOfinstances=array(); + $this->rolesOfInstances=array(); + $this->roles=array(); + $this->instancesOfConcepts=array(); + $this->ignoredConcepts=array(); + $this->retrievalActive=($retrievalActive=='active')?true:false; + + + + } + + + public function make(){ + + $this->lastResult=$this->lc->getLastResult($this->id); + + + try{ + + $this->currentOntology=$this->lc->getCurrentOntologyURL($this->id); + //exception is thrown above, if no ontology is selected + $this->ontologySelected=true; + $this->concepts=$this->lc->getAtomicConcepts($this->id); + $this->roles=$this->lc->getAtomicRoles($this->id); + $this->instances=$this->lc->getInstances($this->id); + //print_r($this->instances); + $this->positives=$this->lc->getPositiveExamples($this->id); + $this->negatives=$this->lc->getNegativeExamples($this->id); + $this->instances=array_diff($this->instances,$this->positives,$this->negatives); + $this->ignoredConcepts=$this->lc->getIgnoredConcepts($this->id); + $this->algorithmStatus=$this->lc->getAlgorithmStatus($this->id); + $this->subsumptionHierarchy=$this->lc->getSubsumptionHierarchy($this->id); + + if($this->retrievalActive) + { + foreach ($this->concepts as $one) + { + $instanceList=$this->lc->retrieval($this->id,$one); + $this->instancesOfConcepts["$one"]=$instanceList; + foreach ($instanceList as $inner) + { + $this->conceptsOfinstances["$inner"] []=$one; + } + } + foreach ($this->roles as $one) + { + $instanceList=$this->lc->getIndividualsForARole($this->id,$one); + foreach ($instanceList as $inner) + { + $this->rolesOfInstances["$inner"] []=$one; + } + } + + + } + + //echo "<xmp>"; + //print_r($this->instancesOfConcepts); + //print_r($this->conceptsOfinstances); + + + + + + + }catch(Exception $e){ + ini_set('error_reporting',E_ALL ); + $this->errorOccurred=true; + $this->error.="-".$e->getMessage()."<br>"; + if($this->error=="Select Ontology First"){ + $this->ontologySelected=false; + } + + + } + } + + + + public function getError(){ + return $this->error; + } + public function getMessage(){ + return $this->message; + } + + + public function getOntologySelect(){ + if($this->ontologySelected){ + + $ret= "Currently selected ontology: <br>".$this->currentOntology." + <a href='index.php?selectOntology='>choose other ontology</a>"; + return $ret; + } + + else { + + $ret= "Choose or type in Ontology:<br><br>"; + $settings=new Settings(); + $ontos=$this->listAvailableOntologies($settings->baseuri, $settings->ontodir); + //print_r( $ontos); + foreach (array_keys($ontos) as $ont){ + $ret.= "<a href=\"index.php?selectOntology=".$ontos["$ont"]." \">".$ont."</a><br>"; + } + $ret.= " <form action='index.php' method='get'> + <input type='text' name='selectOntology'> + <input type='submit' value='submit'> + </form>"; + return $ret; + } + } + + public function getInstanceView(){ + + if(sizeof($this->instances )==0){return "None";} + + $ret="Press 'pos' to add instance to positive examples, 'neg' for negative<br><br>"; + //$arr=array_diff($instances,$positives,$negatives); + + foreach ($this->instances as $a) + { + $b=$this->shorten($a); + //unable to use \n in tooltip, html only + $tooltip=$this->getTooltipForInstance($a); + $ret.= "<dummy ".$tooltip.">"; + $ret.=$b ."</dummy> + <a href='index.php?action=add&where=pos&subject=".urlencode($a)."'>pos</a>| + <a href='index.php?action=add&where=neg&subject=".urlencode($a)."'>neg</a> + <br>"; + } + + return $ret; + + } + + public function getExamples() + { + $ret= "<font color='#00AAAA'> + <b>Positive Examples</b> + (<a href='index.php?action=remove&where=examples&subject=pos'>clear</a>):<br>"; + if(sizeof($this->positives)==0) + { + $this->positives=array(); + $ret.= "None selected<br>"; + } + + foreach ($this->positives as $p) + { + $b=$this->shorten($p); + //unable to use \n in tooltip, html only + $tooltip=$this->getTooltipForInstance($p); + $ret.= "<dummy ".$tooltip.">"; + $ret.=$b ."</dummy> + <a href='index.php?action=remove&where=pos&subject=".urlencode($p)."'>remove</a><br>"; + } + + $ret.= "</font><br><font color='#FF0000'> + <b>Negative Examples</b> + (<a href='index.php?action=remove&where=examples&subject=neg'>clear</a>):<br>"; + if(sizeof($this->negatives)==0) + { + $this->negatives=array(); + $ret.= "None selected<br>"; + } + foreach ($this->negatives as $n) + { + $b=$this->shorten($n); + //unable to use \n in tooltip, html only + $tooltip=$this->getTooltipForInstance($n); + $ret.= "<dummy ".$tooltip." >"; + $ret.=$b ."</dummy> + <a href='index.php?action=remove&where=neg&subject=".urlencode($n)."'>remove</a><br>"; + } + $ret.="</font><br>"; + + + + $test=array_intersect($this->positives,$this->negatives); + + $tmp=""; + foreach ($test as $one) + { + $b=$this->shorten($one); + //unable to use \n in tooltip, html only + $tooltip=$this->getTooltipForInstance($one); + $tmp.= "<dummy ".$tooltip." >"; + $tmp.=$b ."</dummy> + <a href='index.php?action=remove&where=neg&subject=".urlencode($one)."'><font color='#00AAAA'>pos</font></a>| + <a href='index.php?action=remove&where=pos&subject=".urlencode($one)."'><font color='#FF0000'>neg</font></a> <br>"; + } + if(sizeof($test)>=1){ + $t=$this->getTooltip("Inconsistent examples means, that there instances<br> beloning at the same time to the positive and<br> negative example set<br>Choose in which set they should belong"); + $ret.="<font color='#FFAA00' ".$t."><b><blink>Inconsistencies:</blink></b><br>".$tmp."</font><br>"; + } + + if(sizeof($this->positives)>=1||sizeof($this->negatives)>=1) + { + $ret.=" + <br>save your example set here: + <br> + <form action='index.php' method='get'> + <input type='text' name='filename' value='filename'> + <input type='submit' name='savedset' value='save'> + </form><br> + <a href='index.php?action=remove&where=examples&subject=all' >clear all examples</a>"; + } + + + + return $ret; + } + + public function getConcepts() + { + if(sizeof( $this->concepts)==0){return "";} + else + { $ret=""; + $uri="index.php?"; + + $tt1=$this->getTooltip("Choose to automatically add instances of this class to positives examples<br>and try to estimate negative examples"); + $tt2=$this->getTooltip("Choose to ignore a class when learning, can be used to relearn a concept definition"); + + $ret.="Ignored Classes:<br>".((sizeof($this->ignoredConcepts)==0)?"None<br>":""); + + foreach ($this->ignoredConcepts as $one) + { + + $tooltip=$this->getTooltipForConcepts($one); + $ret.="<i ".$tooltip." >". + shorten($one)." (".sizeof($this->instancesOfConcepts["$one"]).") + </i>". + " <a href='".$uri."action=select&class=".urlencode($one)."' ".($tt1).">select</a> | + <a href='".$uri."action=aknowledge&class=".urlencode($one)."' ".($tt2).">aknowledge</a><br>"; + } + + $ret.="<br>Classes:<br>"; + foreach ($this->concepts as $one) + { + if(in_array($one,$this->ignoredConcepts))continue; + $tooltip=$this->getTooltipForConcepts($one); + $ret.="<dummy ".$tooltip." >". + shorten($one)." (".sizeof($this->instancesOfConcepts["$one"]).") + </dummy>". + " <a href='".$uri."action=select&class=".urlencode($one)."' ".($tt1).">select</a> | + <a href='".$uri."action=ignore&class=".urlencode($one)."' ".($tt2).">ignore</a><br>"; + } + return $ret; + } + + } + + public function getRoles() + { + if(sizeof( $this->roles)==0){return "";} + else + { $ret=""; + //$ret.="Ignored Classes:<br>".((sizeof($this->ignoredConcepts)==0)?"None<br>":""); + + foreach ($this->roles as $one) + { + $tooltip=$this->getTooltip($one); + $ret.="<li ".$tooltip." >". + shorten($one)." </li>"; + } + + + return $ret; + } + + } + + + + public function getPossibleActions() + { + $ret="Start learning: <br>"; + + if(!$this->ontologySelected) + { + $ret.="Select ontology first"; + } + + else if($this->algorithmStatus=="running") + { + $ret.="Algorithm is running, <br>try to refresh using the buttons"; + } + else if(sizeof(array_intersect($this->positives,$this->negatives))>=1) + { $t=$this->getTooltip("Inconsistent examples means, that there instances<br> beloning at the same time to the positive and<br> negative example set<br>Choose in which set they should belong"); + $ret.="<font color='#FFAA00' ".$t."><b>There are inconsistencies</b></font>"; + } + else if(sizeof($this->positives)*sizeof($this->negatives)>=1) + { + $ret.=" + <form action=index.php method=get> + <input type='submit' name='start' value='start'> + </form>"; + } + else + { + $ret.="<b>Select at least one positive and one negative instance first</b>"; + + } + + $tooltip="Retrieval means the extra tooltip information,<br> if you hover over the instances<br> greatly improves performance"; + if($this->retrievalActive){ + $ret.="<br><a href='index.php?retrieval=inactive' ".$this->getTooltip($tooltip).">stop retrieval</a>"; + } + else{ + $ret.="<br><a href='index.php?retrieval=active' ".$this->getTooltip($tooltip).">start retrieval</a>"; + } + + return $ret; + + + } + + public function getView(){ + + + + } + + public function shorten($a) + { + if(($strpos=strpos($a,'#'))>=4){ + return substr($a,$strpos); + } + else {return $a;} + } + + + + + public function getSavedSets($savedset=false,$filename=false,$desc=false){ + $ret=""; + $settings=new Settings(); + + switch ($savedset){ + case "delete": + if(is_file($settings->savedir.$filename)) + unlink($settings->savedir.$filename); + break; + case "restore": + $this->restoreSavedSet($filename); + break; + case "save": + $this->saveSets($filename,$desc); + break; + + } + + + $saves=$this->listdir($settings->savedir); + + foreach ($saves as $one){ + $xml=simplexml_load_file(($settings->savedir).$one); + if($xml->ontologyURI==$this->currentOntology) + { + $ret.="<li><dummy onmouseover=\"Tip('".$xml->description."')\" >" + .$one. + "</dummy> + <a href='index.php?savedset=restore&filename=".$one."'>restore</a> + <a href='index.php?savedset=delete&filename=".$one."'>delete</a></li> + <br>"; + } + + }//foreach + + if ($ret!=""){ + $ret="Hover over the names to get a description<br>".$ret; + } + return $ret; + // echo "<xmp>"; + // print_r($xml); + // echo "</xmp>"; + + } + public function saveSets($filename,$description){ + $filename=str_replace( " ","_",$filename); + + $xmlstr="<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><root></root>"; + $xml = new SimpleXMLElement($xmlstr); + $xml->addChild('ontologyURI',$this->currentOntology); + + $xml->addChild('positives'); + $xml->addChild('negatives'); + $description="".$this->currentOntology; + $description.="<br><br>positives:<br>"; + foreach ($this->positives as $one){ + $xml->positives->addChild('positive',$one); + $description.=$one."<br>"; + } + $description.="<br>negatives:<br>"; + foreach ($this->negatives as $one){ + $xml->negatives->addChild('negative',$one); + $description.=$one."<br>"; + } + + //$description=sizeof($this->positives)""; + $xml->addChild('description',$description); + $settings=new Settings(); + if(file_exists(urlencode($settings->savedir.$filename))) + $message.="Warning: file already existed and was overwritten<br>"; + $xml->asXML(urlencode($settings->savedir.$filename)); + + } + + public function restoreSavedSet($filename){ + + $settings=new Settings(); + $uri=($settings->uri)."index.php?plain=plain&id=".$this->id; + $xml=simplexml_load_file(($settings->savedir).$filename); + + $orders=array(); + //$orders[]=$uri."&selectOntology="; + //$orders[]=$uri."&selectOntology=".urlencode($xml->ontologyURI); + + foreach ($xml->positives[0] as $one) + { + $orders[]=$uri."&action=add&where=pos&subject=".urlencode($one); + + } + foreach ($xml->negatives[0] as $one) + { + $orders[]=$uri."&action=add&where=neg&subject=".urlencode($one); + + } + + foreach ($orders as $one) + { + //echo $one."<br>"; + $this->sendandreceive($one)."<br>"; + + + } + $this->message.= + "Refresh needed, hit the button: + <form action=index.php method=get> + <input type='submit' name='refresh' value='refresh'> + </form><br>"; + + + } + + public function getTooltip($tooltip){ + + return " onmouseover=\"Tip('".$tooltip."')\" "; + } + + public function getTooltipForInstance($inst){ + if(!$this->retrievalActive) return $this->getTooltip("deactivated for performance reasons,<br> see Possible Actions"); + $tooltip=$inst."<br>"; + $tooltip.="Instance of:<br>"; + //echo "<xmp>"; + //echo $inst; + + if(sizeof($this->conceptsOfinstances["$inst"])==0) + { $this->conceptsOfinstances["$inst"]=array(); + $tooltip.="<li>Thing</li><br>"; + } + foreach($this->conceptsOfinstances["$inst"] as $concept) + { + $tooltip.="<li>".shorten($concept)."</li>"; + } + $tooltip.="Properties:<br>"; + + if(sizeof($this->rolesOfInstances["$inst"])==0) + { $this->rolesOfInstances["$inst"]=array(); + $tooltip.="<li>None</li><br>"; + } + foreach($this->rolesOfInstances["$inst"] as $role) + { + $tooltip.="<li>".shorten($role)."</li>"; + } + return $this->getTooltip($tooltip); + + } + + public function getTooltipForConcepts($concept){ + if(!$this->retrievalActive) return $this->getTooltip("deactivated for performance reasons,<br> see Possible Actions"); + $tooltip="Class: ".$concept."<br>"; + $tooltip.="Instances:<br>"; + //print_r($this->instancesOfConcepts["$concept"]); + $x=0; + if(sizeof($this->instancesOfConcepts["$concept"] )==0) + { $this->instancesOfConcepts["$concept"] =array(); + $tooltip.="<li>None</li><br>"; + } + foreach($this->instancesOfConcepts["$concept"] as $one) + { $x++; + $tooltip.="".shorten($one)." | ".(($x%6==0)?"<br>":""); + //echo "<li>".shorten($one)."</li>"; + } + + //print_r($this->instancesOfConcepts); + $tooltip.="<br>"; + return $this->getTooltip($tooltip); + + } + + public function listAvailableOntologies($baseuri, $ontodir){ + $ontos=$this->listdir($ontodir); + $ret=array(); + foreach($ontos as $ont) + { + $ret[substr($ont,0,-4)]=$baseuri.$ont; + } + return $ret; + } + + public function listdir($dirname){ + $verz=opendir ($dirname); + $first= readdir ($verz); + $first= readdir ($verz); + $ret=array(); + while ($file = readdir ($verz)) + { + $ret[]=$file; + } + closedir($verz); + return $ret; + } + + public function sendandreceive($uri){ + $req = &new HTTP_Request($uri); + $message=""; + $req->setMethod(HTTP_REQUEST_METHOD_GET); + $req->sendRequest(); + $ret=$req->getResponseBody(); + } +} +?> \ No newline at end of file Added: trunk/src/php-client/Settings.php =================================================================== --- trunk/src/php-client/Settings.php (rev 0) +++ trunk/src/php-client/Settings.php 2007-08-22 10:18:08 UTC (rev 17) @@ -0,0 +1,19 @@ +<?php + +class Settings{ + + +public $wsdluri="http://localhost:8181/services?wsdl"; + + +public $uri="http://localhost/dllearner/"; +public $baseuri="http://localhost/dllearner/ontologies/"; +public $ontodir="ontologies/"; + +public $savedir="save/"; + + + + +} +?> \ No newline at end of file Added: trunk/src/php-client/default.css =================================================================== --- trunk/src/php-client/default.css (rev 0) +++ trunk/src/php-client/default.css 2007-08-22 10:18:08 UTC (rev 17) @@ -0,0 +1,453 @@ +/** + * default.css + * main Ontowiki style sheet + * @author: Norman Heino + * @version: $Id: default.css 751 2007-02-14 19:20:17Z nheino $ + */ + +/* remove browser specific margins */ +* { + margin: 0; + padding: 0; +} + +html { + font: 80%/1.2 "Lucida Grande", Helvetica, Arial, sans-serif; +} + +p { + margin: 8px 0; +} + +h2 { + margin: 0.5em 0 0.1em 0; +/* background-color: #eee;*/ + font-size: 110%; +} + + +/* + * Main site structure + */ + +#wrapper { + position: relative; + max-width: 100%; + padding: 15px; +/* margin: 15px;*/ +} + +#content { + margin: 0 19em; + overflow: hidden; +/* border-left: 1px solid #bbb; + border-right: 1px solid #bbb; + padding: 0 5px;*/ +} + +/* + * Side bars are positioned absolutely due to several reasons: + * (1)Internet Explorer has problems displaying float elements, + * (2) the content's position in html is irrelevant, + * (3) positioning the content div is more straightforward. + */ +#leftSidebar { + position: absolute; + width: 18em; +} + +#rightSidebar { + position: absolute; + width: 18em; + top: 15px; + right: 15px; +} + +#clear { + clear: both; +} + + +/* + * sidebar content (boxes) + */ + +.box { + color: #666; + margin-bottom: 20px; + border: 1px solid #bbb; + font-size: 85%; +} + +/*.box td { + font-size: 100%; +}*/ + +.box .boxtitle { + color: #666; + background-color: #eee; + padding: 3px 0.4em; + font-weight: bold; + white-space: nowrap; +} + +.box .boxtitle .boxtitle_string { + width: 80%; + overflow: hidden; +/* display: none;*/ +} + +.box .boxcontent { + padding: 0.6em; + border-top: 1px solid #bbb; +} + +/* restrict content of certain boxes */ +.box#predicates .boxcontent, +.box#classes .boxcontent { + overflow: hidden; +} + +.box p { + margin: 0 2px 4px 0; +} + +.box ul, .box ol { + margin: 0px; +/* padding-left: 15px;*/ + list-style-position: inside; +} + +.box ul.no_bullet, .box ul.no_bullet { + list-style-type: none; +} + +.box ul li.horizontal, .box ol li.horizontal, +.box ul.horizontal, .box ol.horizontal { + display: inline; +} + +.box a.title_switch { + position: absolute; + right: 0.5em; + margin: auto 0; + color: #666; + border: 1px solid #bbb; + width: 1em; + height: 1em; + background-color: #fff; + text-align: center; +} + +.box a.title_switch:hover { + color: #02a; + text-decoration: none; + background-color: #eee; +} + +.box hr { + margin: 0.5em 0; + border: none; + border-top: 1px dotted #bbb; + height: 0; +} + +.box#classes .boxcontent a { + display: block; +} + +/*.box select { + width: 250px; /* TODO remove absolute size */ +}*/ + +.box input { + width: auto; +} + +.box td input { + width: 100%; +} + +.box img.rating { + position: relative; + top: 1px; +} + +.hidden { + display: none; +} + + +/* + * Links + */ + +a, a:link, a:visited { + color: #02a; + text-decoration: none; + cursor: pointer; +} + +a:hover { + text-decoration: underline; +} + + +/* + * Tabs + */ + +/* all the tabs */ +.tabs { + float: left; + width: 100%; + background: #fff url("../images/tabs_back.png") repeat-x bottom; +} + +.tabs ul { + list-style: none; +} + +.tabs li { + float: left; + margin-right: 1px; +} + +.tabs a { + display: block; + margin-top: 1px; + padding: 0.35em 1.35em; + background-image: url("../images/tab_back.png"); + background-repeat: repeat-x; + background-color: #cbcbcb; + border: 1px solid #bbb; +} + +.tabs a:hover { + background: #fff; + text-decoration: none; +} + +.tabs a.current { + background: #fff; + border-bottom: 1px solid #fff; +} + +/* horizontal line underneath the tabs */ +#tab-line { + height: 1em; + clear: both; +} + +#instances { + float: right; +} + +.selected { + background-color: #bde; /*#b4d5fe;*/ +} + +.button { + border: solid black 1px; + padding: 0px 1px; + background-color: #eee; +} + +/* + * Tables + */ + +tr.odd { + background-color: #ccc; +} + +tr.even { + background-color: #eee; +} + +table.instanceTable th { + text-align: left; +/* background-color: #eee;*/ +} + +table.instanceTable > tbody > tr > td { + padding-top: 0.5em; +} + +table.instanceTable td.property { + text-align: right; + font-style: italic; + padding-right: 5px; +} + +table.instanceTable ul { + margin: 0px; + padding-left: 20px; +} + +table.instanceTable { + width: 100%; +} + +.searchHighlight { + background-color: orange; +} + +table.tripletable { + width: 100%; + font-size: 90%; +} + +.tripletable td { + padding: 0.4em; +} + +table.blind tr td { + padding-top: 0.4em; +} + +/* + * Instances + */ + +.instance .instance { + margin-left: 13px; + background-color: #ddd; +} +.instance .instance td { + font-size: 90%; +} +.instance .instance .instance { + background-color: #eee; +} + +.instance .instance .instance .instance { + background-color: #fff; +} + +#instanceEdit { + border-spacing: 0px; + width: 100%; +} + +#instanceEdit input, #instanceEdit textarea { +/* width: 250px;*/ + background-color: #fff; + font-size: 95%; + font-family: "Lucida Grande", Helvetica, Arial, sans-serif; + padding: 0.1em 0; +} + +#instanceEdit > tbody > tr > td, #instanceEdit > tr > td { + background-color: #eee; + padding: 5px; + border-bottom: 2px solid #fdfdfd; +} + +/* + * Calendar + */ + +table.calendar { + margin-top: 1em; + width: 100%; + height: 730px; + table-layout: fixed; + font-size: 90%; +} + +.calendar .weekday0 { + background-color: #eee; + padding: 0.4em; +} +.calendar .weekday1 { + background-color: #f5f5f5; + padding: 0.4em; +} +.calendar .weekend0 { + background-color: #ddd; + padding: 0.4em; +} +.calendar .weekend1 { + background-color: #eaeaea; + padding: 0.4em; +} + +#map { + margin-top: 0.5em; + width: 100%; + height: 750px; + font-size: 90%; +} + +#map .instance td { + font-size: 80%; + padding: 0 3px; + border-bottom: 5px solid white; +} + +#superClassPath { + margin-bottom: 0.5em; +} + +img { + border: none; +} + +span.submit { + float: right; + padding-right: 100px; +} + +/* + * Autosuggest box + */ +div.autosuggest { + font-size: 85%; + position: absolute; + background-color: #fff; + border: 1px solid #bbb; +} + +div.autosuggest ul { + list-style-type: none; + list-style-position: inside; + padding-left: 0px; +} + +div.autosuggest ul li.selected { + background-color: #bde; +} + +div.autosuggest ul li { + display: block; + padding: 0.2em; +/* height: 22px;*/ + cursor: pointer; +} + +span.formal { + display: none; +} + +/* + * Layer + */ +#layer { + width: 100%; + height: 100%; + position: absolute; + background-image: url("../images/black_50.png"); + background-repeat: repeat; + z-index: 98; +} + +#layerContent { + margin-top: 100px; + margin: auto; + width: 500px; + height: 300px; + background-color: #ffb; + border: 2px solid #bbb; + z-index: 99; +} Added: trunk/src/php-client/index.php =================================================================== --- trunk/src/php-client/index.php (rev 0) +++ trunk/src/php-client/index.php 2007-08-22 10:18:08 UTC (rev 17) @@ -0,0 +1,315 @@ +<?php + +@session_start(); +include_once("Settings.php"); +include_once("LearnerClient.php"); +include_once("Model.php"); + + ini_set("soap.wsdl_cache_enabled","0"); + ini_set('error_reporting',E_ALL); + ini_set('max_execution_time',200); + +$lastAction="View"; +$message=""; +$possibleActions=""; +$instances=" "; +$left=""; +$right=""; +$middle=""; + +$settings=new Settings(); + +echo "<a href='index.php?clearsession=clear'>start from scratch</a>"; +if(isset($_GET['clearsession']))$_SESSION['Learner_ID'] =false; + + + +if( (!isset($_SESSION['Learner_ID'] ) ) || ($_SESSION['Learner_ID']=="")) + { + //get new ID + $lc=new LearnerClient($settings->wsdluri); + $_SESSION['Learner_ID']=$lc->getID(); + //echo "New ID is: ".$_SESSION['Learner_ID']."<br>"; + } + +else{ + //echo "Current ID is: ".$_SESSION['Learner_ID']."<br>"; + $lc=new LearnerClient($settings->wsdluri,$_SESSION['Learner_ID']); + } + + + if(isset($_GET['id']) && $_GET['id']>=0) + { + $lc=new LearnerClient($settings->wsdluri,$_GET['id']); + $id=$_GET['id']; + } + else + { + $id=$_SESSION['Learner_ID']; + } + + +if( (!isset($_SESSION['retrieval'] ) ) || ($_SESSION['retrieval']==""))$_SESSION['retrieval']="inactive"; +if(isset($_GET['retrieval'])){ + $_SESSION['retrieval'] =($_GET['retrieval']=="active")?"active":"inactive"; + + } + + $system="Current id is ".$id; + $model=new Model($id,$lc,$_SESSION['retrieval']); +// Connection to the SOAP SERVER is established + +// for Information about methods +//$lc->getInfo(); + + +// ANALYSE THE GET VARIABLES + + if(isset($_GET['selectOntology'])) + { + if($_GET['selectOntology']=="") + { //remove Ontology + $lc->removeOntology($id); + $lastAction="removed ontology <br>"; + } + else + { //selectOntology + + try{ + $lc->readOntology($id,$_GET['selectOntology']); + $lastAction="read Ontology <br>".$_GET['selectOntology']; + }catch(Exception $e) + {$model->error.="-".$e->getMessage()."<br>"; + + $model->errorOccurred=true;} + } + } + +// ADD REMOVE/CLASS + if(isset($_GET['class'])) + { $class=$_GET['class']; + switch($_GET['action']){ + case "select": + $tmp=$lc->selectAConcept($id,$class,100); + //print_r( $tmp); + $lastAction="selected ".$class; + foreach ($tmp as $one){ + $model->message.="<br>".$one.""; + } + break; + case "ignore": + + $lc->addIgnoredConcept($id,$class); + $lastAction="ignored ".$class; + break; + + case "aknowledge": + $lc->removeIgnoredConcept($id,$class); + $lastAction="aknowledged ".$class; + break; + } + + } + + +// ADD REMOVE/INSTANCE + + if(isset($_GET['action'])) + { + switch ($_GET['action']) + { + + case "add": + + $inst=$_GET['subject']; + + if ($_GET['where']=='pos') + { + //$_SESSION['pos'][]=$inst; + $lc->addPositiveExample($id,$inst); + $lastAction="added: <br>".shorten($inst)." <br>to positive examples<br>"; + } + else if($_GET['where']=="neg") + { + //$_SESSION['neg'][]=$inst; + $lc->addNegativeExample($id,$inst); + $lastAction="added: <br>".shorten($inst)."<br>to negative examples<br>"; + } + + break; + + case "remove": + $inst=$_GET['subject']; + + if($_GET['where']=='examples') + { + if($inst=='all') + {$lc->removeAllExamples($id); + }else if($inst=='neg') + {$lc->removeAllNegativeExamples($id); + }else if($inst=='pos') + {$lc->removeAllPositiveExamples($id); + } + } + else if ($_GET['where']=="pos") + { + + $lc->removePositiveExample($id,$inst); + $lastAction="removed positive example:<br> ".shorten($inst)."<br>"; + + } + else if($_GET['where']=="neg") + { + $lc->removeNegativeExample($id,$inst); + $lastAction="removed negative example:<br> ".shorten($inst)."<br>"; + } + + + break; + + } + + } + + // START LEARNING + + + + + + if(isset($_GET['start']) && $_GET['start']=="start") + { + + $_SESSION['retrieval'] = "inactive"; + $lc->learnMonitored($id); + + $model->message.="<br> - retrieval has been automatically deactivated, switch on manually after learning"; + + } + + if(isset($_GET['stop']) && $_GET['stop']=="stop") + { + echo "stopped <br>"; + echo $lc->stop($id); + + } + + + + if(isset($_GET['plain']) && $_GET['plain']=="plain") + { + die; + + } + + + // only non saveable processes beyond this point + + + //$model=new Model($id,$lc); + $model->make(); + $system.="<br>Algorithm status: ".$model->algorithmStatus; + $system.="<br>Last action:<br>-".$lastAction; + + + if($model->algorithmStatus=="running") + { + $ret= "algorithm is running<br> + Currently best solution is:<br>" + .$lc->getLastResult($id)."<br><br>". + + "hit refresh or stop<br> + <form action=index.php method=get> + <input type='submit' name='refresh' value='refresh'> + <input type='submit' name='stop' value='stop'> + </form>"; + $middle.=makeBox("Result",$ret,false); + } + else if ($model->algorithmStatus=="finished") + { + $ret="Last result:<br>".$lc->getLastResult($id)."<br>"; + $middle.= makeBox("Result",$ret,false); + } + + + $left.=makeBox("Instances",$model->getInstanceView()); + $right.=makeBox("Examples",$model->getExamples()); + + if(($concepts=$model->getConcepts())!="") + { + $left.=makeBox("Classes",$concepts); + } + + + if(($subHier=$model->subsumptionHierarchy)!="") + { + $left.=makeBox("Class Tree","<h3><xmp>".$subHier."</xmp></h3>"); + } + if(($roles=$model->getRoles())!="") + { + $left.=makeBox("Properties",$roles); + } + + $possibleActions=$model->getPossibleActions(); + $ontology=$model->getOntologySelect(); + + ini_set('error_reporting',E_ALL & ~E_NOTICE); + $saved=$model->getSavedSets($_GET['savedset'],$_GET['filename'],$_GET['description']); + ini_set('error_reporting',E_ALL ); + + + //echo $saved; + if ($saved!=""){ + $right.=makebox("Saved Sets",$saved); + } + + if($model->errorOccurred) + { + $message="The following error(s) occured: <br>".$model->getError()."<br>"; + $message.=" + <form action=index.php method=get> + <input type='submit' name='refresh' value='refresh'> + </form>"; + } + + $message.=$model->getMessage(); + if($message=="")$message="None"; + + + + + include("master.php"); + + echo $masterContent; + + + + + + function makeBox($title,$content,$toggleBoxContent=true) + { + if($toggleBoxContent) + { + $click="<a class=\"title_switch\" onclick=\"toggleBoxContent(this);\">\x96</a>"; + } + else{$click="";} + $ret=" + <div class=\"box\" id=\"ontology\"> + <div class=\"boxtitle\">".$title.$click."</div> + <div class=\"boxcontent\"> + ".$content." + </div> <!-- boxcontent --> + </div> <!-- box -->"; + return $ret; + } + + + function shorten($a) + { + if(($strpos=strpos($a,'#'))>=4){ + return substr($a,$strpos); + } + else {return $a;} + } + +?> \ No newline at end of file Added: trunk/src/php-client/jscript/script.js =================================================================== --- trunk/src/php-client/jscript/script.js (rev 0) +++ trunk/src/php-client/jscript/script.js 2007-08-22 10:18:08 UTC (rev 17) @@ -0,0 +1,281 @@ +/* + * The only ow object in use + */ +var ow = {}; + +var ajaxOptions = { + onFailure: function(resp) { + alert('Ajax Error!'); + }, + onException: function(resp, exception) { + alert('Ajax Exception: ' + exception); + } +}; + +ow.openLayer = function(url) { + $('layer').toggle(); + new Ajax.Updater('layerContent', ow.uribase + 'rest/' + url, {asynchronous: false}); + Effect.Appear('layerContent', {duration: 0.3}); +} + +ow.closeLayer = function() { + $('layer').toggle(); +} + +ow.deleteStatement = function(id) { + new Ajax.Request(ow.uribase + 'rest/deleteStatement/?stId=' + id); + // ow.AjaxRequest(false, 'deleteStatement', id); + powl.remove($('stmId' + id).parentNode.parentNode); +} + +ow.tblEdit = function(img, prop, col) { + // imgsrc = img.src; + // img.src = ow.themebase + 'images/Throbber.gif'; + rows = powl.getAncestor(img, 'table').tBodies[0].rows; + for (var i = 1; i < rows.length; ++i) { + new Ajax.Updater(rows[i].cells[col+1], ow.uribase + 'rest/editInstance/' + rows[i].cells[0].getAttribute('name') + '/?property=' + prop); + // ow.AjaxRequest(rows[i].cells[col+1], 'editInstance', rows[i].cells[0].getAttribute('name'), prop); + } + // img.insertAdjacentHTML('afterEnd','<input type="submit" value="save" style="font-size:x-small;" />'); + powl.remove(img); +} + +ow.uriEscape = function(string) { +/* string=string.replace(/Ä/g,'Ae'); + string=string.replace(/Ö/g,'Oe'); + string=string.replace(/Ü/g,'Ue'); + string=string.replace(/ä/g,'ae'); + string=string.replace(/\ö/g,'oe'); + string=string.replace(/ü/g,'ue'); + string=string.replace(/ß/g,'sz');*/ + return string.replace(/[^A-Za-z0-9]/g, ''); +} + +ow.optionalToggle = function(name, nr) { + powl.setState('ow.optionalToggle', name, nr); + e = document.getElementsByName(name); + var a = 0, d = 0; + + for (var i = 0; i < e.length; i++) { + if (e[i].nodeName == 'A') { + e[i].setAttribute('class', a == nr ? 'selected' : ''); + a++; + } else if (e[i].nodeName == 'DIV') { + powl.setVisibility(e[i], d == nr ? '' : 'none'); + d++; + } + } +} + +ow.expand = function(img, instance) { + if (img.src.search(/plus/) != -1) { + if (img.nextSibling.nextSibling.innerHTML != '') { + powl.setVisibility(img.nextSibling.nextSibling, 'block'); + } else { + var uri = ow.uribase + 'rest/getInstance/?r=' + instance + '&allowEdit=false&maxLength=100'; + new Ajax.Updater(img.nextSibling.nextSibling, uri); + // ow.AjaxRequest(img.nextSibling.nextSibling, 'ontowiki::renderInstance', instance, 0, 100); + } + } else { + powl.setVisibility(img.nextSibling.nextSibling, 'none'); + } + powl.togglePlusMinus(img); +} + +ow.updateTable = function(el, id) { + if ($('autosuggest_choices' + id).getStyle('display') != 'block') { + new Ajax.Updater(el.parentNode.parentNode.getElementsByTagName('td')[1], ow.uribase + 'rest/editValues/?property=' + el.value, {evalScripts: true}); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +/* + * Editing and tag visibility + */ +function toggleTagVisibility(name) { + tie = document.getElementById('toggleTagVisibility' + name); + e = document.getElementsByName(name); + + for (var i = 0; i < e.length; i++) { + powl.toggleVisibility(e[i]); + } + + if (tie.getAttribute('class') == 'selected') { + /* powl.setStyleClass(tie, '');*/ + tie.setAttribute('class', ''); + } else { + /* powl.setStyleClass(tie, 'selected');*/ + tie.setAttribute('class', 'selected'); + } + + powl.setCookie('toggleTagVisibility' + name, tie.getAttribute('class')); +} + +/* + * deactivate tag visibility + */ +function deactivateTagVisibility(name) { + tie = document.getElementById('toggleTagVisibility' + name); + e = document.getElementsByName(name); + + if (tie.getAttribute('class') == 'selected') { + for (var i = 0; i < e.length; i++) { + powl.toggleVisibility(e[i]); + } + /* powl.setStyleClass(tie, '');*/ + tie.setAttribute('class', ''); + powl.setCookie('toggleTagVisibility' + name, tie.getAttribute('class')); + } + + +} + + +function toggleTagVisibilityEdit() { + toggleTagVisibility('edit'); +} + +function toggleTagVisibilityComment() { + toggleTagVisibility('comment'); +} + +if (powl.getCookie('toggleTagVisibilityedit') == 'selected') { + powl.SafeAddOnload(toggleTagVisibilityEdit); +} + +if (powl.getCookie('toggleTagVisibilitycomment') == 'selected') { + powl.SafeAddOnload(toggleTagVisibilityComment); +} + +/* + * Image resizing + */ +function resizeContentIMG() { + imgs = document.getElementsByName('contentIMG'); + for (i = 0; i < imgs.length; i++) { + resizeIMG(imgs[i]); + } +} + +function resizeIMG(img) { + maxWidth = 150; + maxHeight = 0; + if (maxWidth && img.width > maxWidth) { + img.height = img.height / (img.width / maxWidth); + img.width = maxWidth; + } + if (maxHeight && img.height > maxHeight) { + img.width = img.width / (img.height / maxHeight); + img.height = maxHeight; + } +} + +powl.SafeAddOnload(resizeContentIMG); + +/* + * Box helpers + */ +function toggleBoxContent(el) { + // get the second div child of the surrounding box + var boxContent = el.parentNode.parentNode.getElementsByTagName('div')[1]; + + if (boxContent.style.display == 'none') { + // open the box + // using scriptaculous + Effect.BlindDown(boxContent, {duration: 0.5}); + // old version + // boxContent.style.display = ''; + el.innerHTML = '–'; + new Ajax.Request(ow.uribase + '/rest/sessionStore?name=' + el.parentNode.parentNode.id + '_box&value=open'); + } + else { + // close the box + // using scriptaculous + Effect.BlindUp(boxContent, {duration: 0.5}); + // old version + // boxContent.style.display = 'none'; + el.innerHTML = ''; + new Ajax.Request(ow.uribase + '/rest/sessionStore?name=' + el.parentNode.parentNode.id + '_box&value=closed'); + } +} + +/* + * Javascript form submit + */ +function subm(form, elem) { + if (!form.combine || !form.combine.checked) { + for (i = 0; i < form.elements.length; ++i) { + if (elem != form.elements[i]) { + if (form.elements[i].type != 'hidden') { + form.elements[i].value = ''; + } /*else { + if (form.elements[i] != 'hidden') + form.elements[i].selectedIndex = 0; + }*/ + } + } + } + form.submit(); +} + +/* + * Rating support functions + */ +function ratingHighlight(img, num) { + // get all images named img.name + imgs = document.getElementsByName(img.name); + // array of ratings + var ratings = new Array('Awful', 'Poor', 'Average', 'Good', 'Excellent'); + // for any rating > 0 we need hover pictures + var name; + if (num == 0) { + name = 'white'; + } else { + name = 'hover'; + } + var name = (num == 0 ? 'white' : 'hover'); + for (var i = 0; i < imgs.length; i++) { + imgs[i].src = ow.themebase + 'images/stars/yri_star_' + name + '.png'; + if (((typeof num) == 'undefined' && img == imgs[i]) || i+1 == num) { + document.getElementById('ratingSpan').innerHTML = ratings[i]; + name = 'white'; + } + } +} + +function ratingReset(img, userRating) { + if (typeof ow.userRating != 'undefined') { + ratingHighlight(img, ow.userRating); + } else { + ratingHighlight(img, userRating); + } + document.getElementById('ratingSpan').innerHTML = ''; +} + +function ratingSet(instance, rating) { + // TODO: merge into one request + new Ajax.Request(ow.uribase + 'rest/setRating/' + instance + '/?rating=' + rating, {asynchronous: false}); + new Ajax.Updater($('ratingContainer'), ow.uribase + 'rest/getRating/' + instance); + ow.userRating = rating; +} + +/* + * Value editing helper + */ +function editValues(element, property, value) { + value = value ? value : ''; + new Ajax.Updater(element, ow.uribase + 'rest/editValues/?property=' + property + '&value=' + value); + // var ret = ow.AjaxRequest(false, 'editValues', cls, property, value); +} + +function addProperty(id, property, value) { + var table = document.getElementById('instanceEdit'); + row = table.insertRow(table.rows.length); + c1 = row.insertCell(0); + c2 = row.insertCell(1); + c1.setAttribute('style', 'vertical-align:top;'); + new Ajax.Updater(c1, ow.uribase + 'rest/getPropertySelector/?property=' + property, {evalScripts: true}); + // c1.insertAdjacentHTML('beforeEnd', getPropertySelector(property)); + // c2.insertAdjacentHTML('beforeEnd', (typeof value == 'string' ? editValues(property, value) : '')); +} Added: trunk/src/php-client/jscript/tip_centerwindow.js =================================================================== --- trunk/src/php-client/jscript/tip_centerwindow.js (rev 0) +++ trunk/src/php-client/jscript/tip_centerwindow.js 2007-08-22 10:18:08 UTC (rev 17) @@ -0,0 +1,100 @@ +/* +tip_centerwindow.js v. 1.2 + +The latest version is available at +http://www.walterzorn.com +or http://www.devira.com +or http://www.walterzorn.de + +Initial author: Walter Zorn +Last modified: 23.6.2007 + +Extension for the tooltip library wz_tooltip.js. +Centers a sticky tooltip in the window's visible clientarea, +optionally even if the window is being scrolled or resized. +*/ + +// Here we define new global configuration variable(s) (as members of the +// predefined "config." class). +// From each of these config variables, wz_tooltip.js will automatically derive +// a command which can be passed to Tip() or TagToTip() in order to customize +// tooltips individually. These command names are just the config variable +// name(s) translated to uppercase, +// e.g. from config. CenterWindow a command CENTERWINDOW will automatically be +// created. + +//=================== GLOBAL TOOPTIP CONFIGURATION =========================// +config. CenterWindow = false // true or false - set to true if you want this to be the default behaviour +config. CenterAlways = false // true or false - recenter if window is resized or scrolled +//======= END OF TOOLTIP CONFIG, DO NOT CHANGE ANYTHING BELOW ==============// + + +// Create a new tt_Extension object (make sure that the name of that object, +// here ctrwnd, is unique amongst the extensions available for +// wz_tooltips.js): +var ctrwnd = new tt_Extension(); + +// Implement extension eventhandlers on which our extension should react +ctrwnd.OnLoadConfig = function() +{ + if(tt_aV[CENTERWINDOW]) + { + // Permit CENTERWINDOW only if the tooltip is sticky + if(tt_aV[STICKY]) + { + if(tt_aV[CENTERALWAYS]) + { + // IE doesn't support style.position "fixed" + if(tt_ie) + tt_AddEvtFnc(window, "scroll", Ctrwnd_DoCenter); + else + tt_aElt[0].style.position = "fixed"; + tt_AddEvtFnc(window, "resize", Ctrwnd_DoCenter); + } + return true; + } + tt_aV[CENTERWINDOW] = false; + } + return false; +}; +// We react on the first OnMouseMove event to center the tip on that occasion +ctrwnd.OnMoveBefore = Ctrwnd_DoCenter; +ctrwnd.OnKill = function() +{ + if(tt_aV[CENTERWINDOW] && tt_aV[CENTERALWAYS]) + { + tt_RemEvtFnc(window, "resize", Ctrwnd_DoCenter); + if(tt_ie) + tt_RemEvtFnc(window, "scroll", Ctrwnd_DoCenter); + else + tt_aElt[0].style.position = "absolute"; + } + return false; +}; +// Helper function +function Ctrwnd_DoCenter() +{ + if(tt_aV[CENTERWINDOW]) + { + var x, y, dx, dy; + + // Here we use some functions and variables (tt_w, tt_h) which the + // extension API of wz_tooltip.js provides for us + if(tt_ie || !tt_aV[CENTERALWAYS]) + { + dx = tt_GetScrollX(); + dy = tt_GetScrollY(); + } + else + { + dx = 0; + dy = 0; + } + // Position the tip, offset from the center by OFFSETX and OFFSETY + x = (tt_GetClientW() - tt_w) / 2 + dx + tt_aV[OFFSETX]; + y = (tt_GetClientH() - tt_h) / 2 + dy + tt_aV[OFFSETY]; + tt_SetTipPos(x, y); + return true; + } + return false; +} Added: trunk/src/php-client/jscript/tip_followscroll.js =================================================================== --- trunk/src/php-client/jscript/tip_followscroll.js (rev 0) +++ trunk/src/php-client/jscript/tip_followscroll.js 2007-08-22 10:18:08 UTC (rev 17) @@ -0,0 +1,84 @@ +/* +tip_followscroll.js v. 1.1 + +The latest version is available at +http://www.walterzorn.com +or http://www.devira.com +or http://www.walterzorn.de + +Initial author: Walter Zorn +Last modified: 21.6.2007 + +Extension for the tooltip library wz_tooltip.js. +Lets a "sticky" tooltip keep its position inside the clientarea if the window +is scrolled. +*/ + +// Here we define new global configuration variable(s) (as members of the +// predefined "config." class). +// From each of these config variables, wz_tooltip.js will automatically derive +// a command which can be passed to Tip() or TagToTip() in order to customize +// tooltips individually. These command names are just the config variable +// name(s) translated to uppercase, +// e.g. from config. FollowScroll a command FOLLOWSCROLL will automatically be +// created. + +//=================== GLOBAL TOOPTIP CONFIGURATION ======================// +config. FollowScroll = false // true or false - set to true if you want this to be the default behaviour +//======= END OF TOOLTIP CONFIG, DO NOT CHANGE ANYTHING BELOW ==============// + + +// Create a new tt_Extension object (make sure that the name of that object, +// here fscrl, is unique amongst the extensions available for +// wz_tooltips.js): +var fscrl = new tt_Extension(); + +// Implement extension eventhandlers on which our extension should react +fscrl.OnShow = function() +{ + if(tt_aV[FOLLOWSCROLL]) + { + // Permit FOLLOWSCROLL only if the tooltip is sticky + if(tt_aV[STICKY]) + { + var x = tt_x - tt_GetScrollX(), y = tt_y - tt_GetScrollY(); + + if(tt_ie) + { + fscrl.MoveOnScrl.offX = x; + fscrl.MoveOnScrl.offY = y; + fscrl.AddRemEvtFncs(tt_AddEvtFnc); + } + else + { + tt_SetTipPos(x, y); + tt_aElt[0].style.position = "fixed"; + } + return true; + } + tt_aV[FOLLOWSCROLL] = false; + } + return false; +}; +fscrl.OnHide = function() +{ + if(tt_aV[FOLLOWSCROLL]) + { + if(tt_ie) + fscrl.AddRemEvtFncs(tt_RemEvtFnc); + else + tt_aElt[0].style.position = "absolute"; + } +}; +// Helper functions (encapsulate in the class to avoid conflicts with other +// extensions) +fscrl.MoveOnScrl = function() +{ + tt_SetTipPos(fscrl.MoveOnScrl.offX + tt_GetScrollX(), fscrl.MoveOnScrl.offY + tt_GetScrollY()); +}; +fscrl.AddRemEvtFncs = function(PAddRem) +{ + PAddRem(window, "resize", fscrl.MoveOnScrl); + PAddRem(window, "scroll", fscrl.MoveOnScrl); +}; + Added: trunk/src/php-client/jscript/wz_tooltip.js =================================================================== --- trunk/src/php-client/jscript/wz_tooltip.js (rev 0) +++ trunk/src/php-client/jscript/wz_tooltip.js 2007-08-22 10:18:08 UTC (rev 17) @@ -0,0 +1,1149 @@ +/* This notice must be untouched at all times. + +wz_tooltip.js v. 4.12 + +The latest version is available at +http://www.walterzorn.com +or http://www.devira.com +or http://www.walterzorn.de + +Copyright (c) 2002-2007 Walter Zorn. All rights reserved. +Created 1.12.2002 by Walter Zorn (Web: http://www.walterzorn.com ) +Last modified: 13.7.2007 + +Easy-to-use cross-browser tooltips. +Just include the script at the beginning of the <body> section, and invoke +Tip('Tooltip text') from within the desired HTML onmouseover eventhandlers. +No container DIV, no onmouseouts required. +By default, width of tooltips is automatically adapted to content. +Is even capable of dynamically converting arbitrary HTML elements to tooltips +by calling TagToTip('ID_of_HTML_element_to_be_converted') instead of Tip(), +which means you can put important, search-engine-relevant stuff into tooltips. +Appearance of tooltips can be individually configured +via commands passed to Tip() or TagToTip(). + +Tab Width: 4 +LICENSE: LGPL + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License (LGPL) as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library 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. + +For more details on the GNU Lesser General Public License, +see http://www.gnu.org/copyleft/lesser.html +*/ + +var config = new Object(); + + +//=================== GLOBAL TOOPTIP CONFIGURATION =========================// +var tt_Debug = true // false or true - recommended: false once you release your page to the public +var tt_Enabled = true // Allows to (temporarily) suppress tooltips, e.g. by providing the user with a button that sets this global variable to false +var TagsToTip = true // false or true - if true, the script is capable of converting HTML elements to tooltips + +// For each of the following config variables there exists a command, which is +// just the variablename in uppercase, to be passed to Tip() or TagToTip() to +// configure tooltips individually. Individual commands override global +// configuration. Order of commands is arbitrary. +// Example: onmouseover="Tip('Tooltip text', LEFT, true, BGCOLOR, '#FF9900', FADEIN, 400)" + +config. Above = false // false or true - tooltip above mousepointer? +config. BgColor = '#E4E7FF' // Background color +config. BgImg = '' // Path to background image, none if empty string '' +config. BorderColor = '#002299' +config. BorderStyle = 'solid' // Any permitted CSS value, but I recommend 'solid', 'dotted' or 'dashed' +config. BorderWidth = 1 +config. CenterMouse = false // false or true - center the tip horizontally below (or above) the mousepointer +config. ClickClose = false // false or true - close tooltip if the user clicks somewhere +config. CloseBtn = false // false or true - closebutton in titlebar +config. CloseBtnColors = ['#990000', '#FFFFFF', '#DD3333', '#FFFFFF'] // [Background, text, hovered background, hovered text] - use empty strings '' to inherit title colors +config. CloseBtnText = ' X ' // Close button text (may also be an image tag) +config. CopyContent = true // When converting a HTML element to a tooltip, copy only the element's content, rather than converting the element by its own +config. Delay = 400 // Time span in ms until tooltip shows up +config. Duration = 0 // Time span in ms after which the tooltip disappears; 0 for infinite duration +config. FadeIn = 0 // Fade-in duration in ms, e.g. 400; 0 for no animation +config. FadeOut = 0 +config. FadeInterval = 30 // Duration of each fade step in ms (recommended: 30) - shorter is smoother but causes more CPU-load +config. Fix = null // Fixated position - x- an y-oordinates in brackets, e.g. [210, 480], or null for no fixation +config. FollowMouse = true // false or true - tooltip follows the mouse +config. FontColor = '#000044' +config. FontFace = 'Verdana,Geneva,sans-serif' +config. FontSize = '8pt' // E.g. '9pt' or '12px' - unit is mandatory +config. FontWeight = 'normal' // 'normal' or 'bold'; +config. Left = false // false or true - tooltip on the left of the mouse +config. OffsetX = 14 // Horizontal offset of left-top corner from mousepointer +config. OffsetY = 8 // Vertical offset +config. Opacity = 100 // Integer between 0 and 100 - opacity of tooltip in percent +config. Padding = 3 // Spacing between border and content +config. Shadow = false // false or true +config. ShadowColor = '#C0C0C0' +config. ShadowWidth = 5 +config. Sticky = false // Do NOT hide tooltip on mouseout? false or true +config. TextAlign = 'left' // 'left', 'right' or 'justify' +config. Title = '' // Default title text applied to all tips (no default title: empty string '') +config. TitleAlign = 'left' // 'left' or 'right' - text alignment inside the title bar +config. TitleBgColor = '' // If empty string '', BorderColor will be used +config. TitleFontColor = '#ffffff' // Color of title text - if '', BgColor (of tooltip body) will be used +config. TitleFontFace = '' // If '' use FontFace (boldified) +config. TitleFontSize = '' // If '' use FontSize +config. Width = 0 // Tooltip width; 0 for automatic adaption to tooltip content +//======= END OF TOOLTIP CONFIG, DO NOT CHANGE ANYTHING BELOW ==============// + + + + +//====================== PUBLIC ============================================// +function Tip() +{ + tt_Tip(arguments, null); +} +function TagToTip() +{ + if(TagsToTip) + { + var t2t = tt_GetElt(arguments[0]); + if(t2t) + tt_Tip(arguments, t2t); + } +} + +//================== PUBLIC EXTENSION API ==================================// +// Extension eventhandlers currently supported: +// OnLoadConfig, OnCreateContentString, OnSubDivsCreated, OnShow, OnMoveBefore, +// OnMoveA... [truncated message content] |