From: Wolfgang M. M. <wol...@us...> - 2004-03-30 10:48:02
|
Update of /cvsroot/exist/exist_php In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30166 Modified Files: exist_class.php Log Message: Updated for eXist-1.0beta1 Index: exist_class.php =================================================================== RCS file: /cvsroot/exist/exist_php/exist_class.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** exist_class.php 9 Aug 2002 08:01:43 -0000 1.1.1.1 --- exist_class.php 30 Mar 2004 10:36:24 -0000 1.2 *************** *** 1,125 **** ! <?php ! // ############################################################################################################### ! // Title : exist_class.php ! // Version : 0.5 ! // Author : Andrew Jenks (aje...@ya...) ! // Last modification date : 07-08-2002 ! // Description : This class allows you to use an eXist native database from PHP using the XML-RPC API. ! // License : This code is released as is GNU General Public License (GPL) ! // ############################################################################################################### ! // History: ! // 07-08-2002 (first rev. to get the functionality that I need) ! // This class is an inspiration based on the same class written by Luis Argerich for the Xindice xml ! // native database. ! // ############################################################################################################### ! // Function Info: ! //function-->getCollectionDesc(); ! //returns a hashtable that has three fields: "name", "collections", "documents". "name" is the collection's //name,"documents" contains an array listing the names of all documents contained in this collection, //"collections"is an array listing the names of available sub-collections in this collection. ! // ! // function--> queryCollection(); ! //Execute the XPath query and return a reference to the generated result set. This method may later be used to ! //retrieve results or get a result-summary. ! // ! // function--> getSummary(); ! //Get a summary of query results for the result-set referenced by resultId. Returns a struct with the following ! //fields: "queryTime", "hits", "documents", "doctype". ! //"queryTime" and "hits" are integers, describing the time in milliseconds consumed by query execution and the ! //number of hits in the result-set. Field "documents" is an array of array (Object[][3]), representing a table ! //where every row identifies one document. The first field in each row contains the document-id as integer. The ! //second has the document's name as string. The third contains the number of hits found in this document (int). ! //The "doctype" field is an array of array (Object[][2]) in each row containing the doctype's public identifier ! //and the number of hits found for this doctype. ! // ! // function--> queryCollectionXML(); ! //Execute XPath query and return results. This method will directly return a part of the result-set, starting at ! //start, as a new XML document. The number of results returned is determined by parameter howmany. The ! //result-set will be deleted on the server, so later calls to this method will again execute the query. ! // ################################################################################################################ ! // How to use it: ! // To make a query to the database and return XML; ! // $xmlstring=$xi->queryCollectionXML("document(*)//HEADER[AUTHOR&='GEORGE']","ISO-8859-1",10,1,1); ! // ! // $xh = xslt_create(); ! // ! // $args = array ( '/_xml' => $xmlstring ); ! // $params = array ( 'somevariable' => 'somecontent' ); ! // ! // $result = xslt_process($xh, 'arg:/_xml', 'your_transform_file.xsl', NULL, $args, $params); ! // ! // echo $result; ! // ! // xslt_free($xh); ! // ################################################################################################################ ! ! include_once("xmlrpc/xmlrpc.inc"); ! ! class eXist { ! var $client; ! var $error; ! ! function getError() { ! return $this->error; ! } ! ! function setXmlRpcDebug($debug) { ! $this->client->setDebug($debug); ! } ! ! function eXist($server_host,$server_port) { ! $this->client=new xmlrpc_client("/",$server_host,$server_port); ! } ! ! // General collection functions ! ! function getCollectionDesc($collection) { ! $method="getCollectionDesc"; ! $msg=new xmlrpcmsg($method,array(new xmlrpcval($collection,"string"))); ! return $this->sendMsg($msg); ! } ! ! // Query functions ! ! function queryCollection($query) { ! $method="executeQuery"; ! $msg=new xmlrpcmsg($method,array(new xmlrpcval($query,"string"))); ! return $this->sendMsg($msg); ! } ! ! ! function getSummary($queryint) { ! $method="querySummary"; ! $msg=new xmlrpcmsg($method, array(new xmlrpcval($queryint,"int"))); ! return $this->sendMsg($msg); ! } ! ! function queryCollectionXML($xpath, $encoding, $howmany, $start, $prettyPrint ) { ! $method="query"; ! $msg=new xmlrpcmsg($method, array(new xmlrpcval($xpath,"string"),new xmlrpcval($encoding,"string"), new xmlrpcval($howmany,"int"), new xmlrpcval($start,"int"), new xmlrpcval($prettyPrint, "int"))); ! return $this->sendMsg($msg); ! } ! ! ! // PRIVATE METHODS ! function getBase($collection) { ! $paths=split('/',$collection); ! return $paths[0]; ! } ! ! function sendMsg($msg) { ! $result=$this->client->send($msg); ! if(!$result) { ! $this->error='Cannot send xmlrpc message to the server'; ! return 0; ! } ! if($result->faultCode()) { ! $this->error=$result->faultString(); ! return 0; ! } ! $ret=xmlrpc_decode($result->value()); ! return $ret; ! } ! ! ! } ! ! ?> \ No newline at end of file --- 1,129 ---- ! <?php ! // ############################################################################################################### ! // Title : exist_class.php ! // Version : 0.6 ! // Author : Andrew Jenks (aje...@ya...) ! // Last modification date : 03-30-2004 ! // Description : This class allows you to use an eXist native database from PHP using the XML-RPC API. ! // License : This code is released as is GNU General Public License (GPL) ! // $Id$ ! // ############################################################################################################### ! // History: ! // 07-08-2002 (first rev. to get the functionality that I need) ! // This class is an inspiration based on the same class written by Luis Argerich for the Xindice xml ! // native database. ! // ############################################################################################################### ! // Function Info: ! //function-->getCollectionDesc(); ! //returns a hashtable that has three fields: "name", "collections", "documents". "name" is the collection's //name,"documents" contains an array listing the names of all documents contained in this collection, //"collections"is an array listing the names of available sub-collections in this collection. ! // ! // function--> queryCollection(); ! //Execute the XPath query and return a reference to the generated result set. This method may later be used to ! //retrieve results or get a result-summary. ! // ! // function--> getSummary(); ! //Get a summary of query results for the result-set referenced by resultId. Returns a struct with the following ! //fields: "queryTime", "hits", "documents", "doctype". ! //"queryTime" and "hits" are integers, describing the time in milliseconds consumed by query execution and the ! //number of hits in the result-set. Field "documents" is an array of array (Object[][3]), representing a table ! //where every row identifies one document. The first field in each row contains the document-id as integer. The ! //second has the document's name as string. The third contains the number of hits found in this document (int). ! //The "doctype" field is an array of array (Object[][2]) in each row containing the doctype's public identifier ! //and the number of hits found for this doctype. ! // ! // function--> queryCollectionXML(); ! //Execute XPath query and return results. This method will directly return a part of the result-set, starting at ! //start, as a new XML document. The number of results returned is determined by parameter howmany. The ! //result-set will be deleted on the server, so later calls to this method will again execute the query. ! // ################################################################################################################ ! // How to use it: ! // To make a query to the database and return XML; ! // $xmlstring=$xi->queryCollectionXML("document(*)//HEADER[AUTHOR&='GEORGE']","ISO-8859-1",10,1,1); ! // ! // $xh = xslt_create(); ! // ! // $args = array ( '/_xml' => $xmlstring ); ! // $params = array ( 'somevariable' => 'somecontent' ); ! // ! // $result = xslt_process($xh, 'arg:/_xml', 'your_transform_file.xsl', NULL, $args, $params); ! // ! // echo $result; ! // ! // xslt_free($xh); ! // ################################################################################################################ ! ! include_once("/usr/local/xmlrpc-1.0.99.2/xmlrpc.inc"); ! ! class eXist { ! var $client; ! var $error; ! ! function getError() { ! return $this->error; ! } ! ! function setXmlRpcDebug($debug) { ! $this->client->setDebug($debug); ! } ! ! function eXist($server_host,$server_port) { ! $this->client=new xmlrpc_client("/",$server_host,$server_port); ! } ! ! // General collection functions ! ! function getCollectionDesc($collection) { ! $method="getCollectionDesc"; ! $msg=new xmlrpcmsg($method,array(new xmlrpcval($collection,"string"))); ! return $this->sendMsg($msg); ! } ! ! // Query functions ! ! function queryCollection($query) { ! $method="executeQuery"; ! $msg=new xmlrpcmsg($method,array(new xmlrpcval($query,"string"))); ! return $this->sendMsg($msg); ! } ! ! ! function getSummary($queryint) { ! $method="querySummary"; ! $msg=new xmlrpcmsg($method, array(new xmlrpcval($queryint,"int"))); ! return $this->sendMsg($msg); ! } ! ! function queryCollectionXML($xpath, $encoding, $howmany, $start) { //method signature changed , $prettyPrint ) { ! $method="query"; ! // a fake hash for now ! $myStruct=new xmlrpcval(array("geek" => new xmlrpcval("hacker","arashb")), "struct"); ! ! $msg=new xmlrpcmsg($method, array(new xmlrpcval($xpath,"string"),/*new xmlrpcval($encoding,"string"),*/ new xmlrpcval($howmany,"int"), new xmlrpcval($start,"int"), $myStruct)); ! return $this->sendMsg($msg); ! } ! ! ! // PRIVATE METHODS ! function getBase($collection) { ! $paths=split('/',$collection); ! return $paths[0]; ! } ! ! function sendMsg($msg) { ! $result=$this->client->send($msg); ! if(!$result) { ! $this->error='Cannot send xmlrpc message to the server'; ! return 0; ! } ! if($result->faultCode()) { ! $this->error=$result->faultString(); ! return 0; ! } ! $ret=xmlrpc_decode($result->value()); ! return $ret; ! } ! ! ! } ! ! ?> |