[Mapbender-commits] r4516 - branches/mifan_dev/mapbender/http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Aug 13 16:10:07 EDT 2009
Author: mifan
Date: 2009-08-13 16:10:07 -0400 (Thu, 13 Aug 2009)
New Revision: 4516
Modified:
branches/mifan_dev/mapbender/http/php/mod_searchCatQueryBuilder_server.php
Log:
changes to accept csw:record
Modified: branches/mifan_dev/mapbender/http/php/mod_searchCatQueryBuilder_server.php
===================================================================
--- branches/mifan_dev/mapbender/http/php/mod_searchCatQueryBuilder_server.php 2009-08-13 20:08:36 UTC (rev 4515)
+++ branches/mifan_dev/mapbender/http/php/mod_searchCatQueryBuilder_server.php 2009-08-13 20:10:07 UTC (rev 4516)
@@ -19,9 +19,12 @@
require_once(dirname(__FILE__)."/../classes/class_connector.php");
require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-require_once(dirname(__FILE__)."/../classes/class_wms.php");
+require_once(dirname(__FILE__)."/../classes/class_csw.php");
+require_once(dirname(__FILE__)."/../classes/class_cswrecord.php");
require_once(dirname(__FILE__)."/../classes/class_administration.php");
require_once(dirname(__FILE__)."/../classes/class_json.php");
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/../classes/class_connector.php");
/*
* get catalogs for gui
@@ -32,32 +35,13 @@
* show responses with cat-name in results
*/
+$DEBUG_ = true;
-/**
- *
- * @param $gui_id
- * @param $getrecords_type
- * @return array list of cats
- */
-function get_catalogs_for_gui($gui_id,$getrecords_type){
- $sql = "select fkey_cat_id from gui_cat where fkey_gui_id = $1";
- $v = array($gui_id);
- $t = array('s');
- $res = db_prep_query($sql,$v,$t);
- $list_of_cat = array();
- while($row = db_fetch_array($res)){
- array_push($list_of_cat,$row['fkey_cat_id']);
- }
- return $list_of_cat;
-}
-
-
-
+//Init Variables
$userId = $_SESSION["mb_user_id"];
-$command = $_GET["command"];
-$guiId = $_GET["guiId"];
+$command = $_REQUEST["command"];
+$guiId = $_REQUEST["guiId"];
$simplesearch = $_REQUEST['search'];
-
$getrecords_type = $_REQUEST['getrecordsmedia'];
$getrecords_query = $_REQUEST['getrecordsquery'];
@@ -67,34 +51,131 @@
$resultObj = array();
$resultObj['cats'] = array();
+if($DEBUG_)
array_push($resultObj['cats'],array("id"=>'id',"title"=>'test'));
-
if ($command == "getrecordssimple") {
- $resultObj["cats"] = array();
+ //$resultObj["cats"] = array();
+ if($DEBUG_)
+ array_push($resultObj['cats'],array("id"=>'id2',"title"=>$getrecords_type));
+ $catalogIDs = array();
switch(mb_strtolower($getrecords_type)){
case 'get':
-
+ $catalogIDs = get_catalogs_by_supported_type(get_catalogs_for_gui($guiId),'getrecords','get');
break;
case 'post':
+ $catalogIDs = get_catalogs_by_supported_type(get_catalogs_for_gui($guiId),'getrecords','post');
break;
case 'soap':
+ $catalogIDs = get_catalogs_by_supported_type(get_catalogs_for_gui($guiId),'getrecords','soap');
break;
default:
+ $catalogIDs = get_catalogs_by_supported_type(get_catalogs_for_gui($guiId),'getrecords','get');
}
- $xml_req = build_getrecords_xml();
+ //main controller
+ foreach($catalogIDs as $catalog_id=>$url){
+ array_push($resultObj['cats'],array("id"=>$catalog_id,"title"=>$getrecords_type));
+ //$cat_obj = new csw();
+ //$cat_obj->createCatObjFromDB($catalogs);
+ list($getrecordsurl,$getrecordsxml) = getrecords_get_build_query($url,$simplesearch);
+
+ //Create Record Objects
+ $RecordObj = new cswrecord();
+ $RecordObj->createCSWRecordFromXML($getrecordsurl,$getrecordsxml);
+
+ //Populate JSON for each summary record for each catalog
+ foreach ($RecordObj->SummaryRecordsArray as $SummaryRecordObj){
+ $title = $SummaryRecordObj;
+ array_push($resultObj['cats'],array("id"=>$catalog_id,"title"=>$getrecords_type));
+ }
+
+ }
+}
+
+/**
+ * Build Query
+ * @param $getrecords_url
+ * @return array URL and XML
+ */
+function getrecords_build_query($getrecords_url){
- $url = urlencode('http://gdi-de.sdisuite.de/soapServices/CSWStartup');
- $data = getrecords_post($url,$xml_req);
- array_push($resultObj['cats'],$data);
- array_push($resultObj['cats'],'something');
- //echo $data;
+ //CHECK FOR COMMAND, GET POST. HANDLE THINGS HERE
+ return array('url'=>$url,'xml'=>$xml);
}
+/**
+ *
+ * @param $gui_id
+ * @param $getrecords_type
+ * @return array list of cats
+ */
+function get_catalogs_for_gui($gui_id){
+ $sql = "select fkey_cat_id from gui_cat where fkey_gui_id = $1";
+ $v = array($gui_id);
+ $t = array('s');
+ $res = db_prep_query($sql,$v,$t);
+ $list_of_cat = array();
+ while($row = db_fetch_array($res)){
+ array_push($list_of_cat,$row['fkey_cat_id']);
+ }
+ return $list_of_cat;
+}
+function get_url_for_operation($catalog_id,$operation_type,$fetch_mode){
+
+}
+
+function do_getrecords_get($catalog_id_array){
+
+}
+
/**
+ * http://geomatics.nlr.nl/excat/csw?request=GetRecords&service=CSW&version=2.0.2&ResultType=results&TypeName=csw:Record&TYPENAMES=csw:dataset
+ * @param $url
+ * @param $search
+ * @return unknown_type
+ */
+function getrecords_get_build_query($url,$search){
+
+ $request = 'GetRecords';
+ $version = '2.0.2';
+ $resulttype = 'results';
+ $typename = 'csw:Record';
+ $service='CSW';
+
+ $url_encode = $url.'?request='.$request.'&service='.$service.'&ResultType='.$resulttype.'&TypeNames='.$typename;
+ $url_encode = urlencode($url_encode);
+
+ return $url_encode;
+}
+
+/**
+ * Get catalog URL which support fetch mode for operation type
+ * @param $cat_array array of catalogs for guis
+ * @param $operation_type getrecords,describerecords..
+ * @param $fetch_mode get|post|soap
+ * @return array of supported catalog ids
+ */
+function get_catalogs_by_supported_type($cat_array,$operation_type,$fetch_mode){
+ $cat_supported = array();
+ $sql = "select fk_cat_id,param_value from cat_op_conf where param_name=$1 and param_type=$2";
+ $v = array($fetch_mode,$operation_type);
+ $t = array('s','s');
+ $res = db_prep_query($sql,$v,$t);
+
+ while($row = db_fetch_array($res)){
+ //array_push($list_of_cat,$row['fkey_cat_id']);
+ if(in_array($row['fk_cat_id'],$cat_array)){
+ //array_push($cat_supported,$row['fk_cat_id']);
+ $cat_supported[$row['fk_cat_id']] = $row['param_value'];
+ }
+ }
+ return $cat_supported;
+}
+
+/**
* Build XML query for getrecords
* @return string xml file
* @todo: get values dynamically
@@ -147,6 +228,8 @@
return $data;
}
+
+
$json = new Mapbender_JSON();
$output = $json->encode($resultObj);
echo $output;
More information about the Mapbender_commits
mailing list