[Mapbender-commits] r5152 - in trunk/mapbender/http: classes javascripts php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Sat Dec 12 05:14:51 EST 2009


Author: armin11
Date: 2009-12-12 05:14:51 -0500 (Sat, 12 Dec 2009)
New Revision: 5152

Added:
   trunk/mapbender/http/classes/class_csw.php
   trunk/mapbender/http/classes/class_cswrecord.php
   trunk/mapbender/http/javascripts/mod_CSWFunctions.js
   trunk/mapbender/http/javascripts/mod_searchCSW_ajax.php
   trunk/mapbender/http/javascripts/mod_searchCSW_form.php
   trunk/mapbender/http/php/mod_loadCatalog.php
   trunk/mapbender/http/php/mod_loadCatalogCapabilities.php
   trunk/mapbender/http/php/mod_loadCatalogToGui.php
   trunk/mapbender/http/php/mod_searchCatQueryBuilder_server.php
Log:
initial CSW client from mifan-dev

Added: trunk/mapbender/http/classes/class_csw.php
===================================================================
--- trunk/mapbender/http/classes/class_csw.php	                        (rev 0)
+++ trunk/mapbender/http/classes/class_csw.php	2009-12-12 10:14:51 UTC (rev 5152)
@@ -0,0 +1,431 @@
+<?php
+# $Id$
+# http://www.mapbender.org/index.php/class_csw
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program 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.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/class_connector.php");
+require_once(dirname(__FILE__)."/class_user.php");
+require_once(dirname(__FILE__)."/class_administration.php");
+
+/**
+ * CSW main class to hold catalog object
+ * @author nazgul
+ *
+ */
+class csw{
+	var $cat_id;
+	var $cat_title;
+	var $cat_abstract;
+	var $cat_version;
+	
+	var $cat_op_getcapabilities;
+	var $cat_op_getrecords;
+	var $cat_op_getrecordbyid;
+	var $cat_op_describerecord;
+	var $cat_getcapabilities_doc;
+	
+	var $cat_get_capabilities_values = array();
+	var $cat_get_records_values = array();
+	
+	var $cat_op_values = array();
+	
+	var $cat_upload_url;
+	var $fees;
+	var $accessconstraints;
+	var $contactperson;
+	var $contactposition;
+	var $contactorganization;
+	var $address;
+	var $city;
+	var $stateorprovince;
+	var $postcode;
+	var $country;
+	var $contactvoicetelephone;
+	var $contactfacsimiletelephone;
+	var $contactelectronicmailaddress;
+	
+	var $keywords = array();
+	
+	var $catowner;
+	var $cattimestamp;
+	var $providername;
+	var $providersite;
+	var $delivery='';
+	
+	//store catalog retrieval status
+	var $cat_status;
+	
+	function csw(){
+		
+	}
+	
+	//Getters of common items
+	function getCatVersion(){
+		return $this->cat_version;	
+	}
+	
+	/**
+	 * 
+	 * @param $request_type getrecords,describerecords..
+	 * @param $request_method get,post,soap
+	 * @return unknown_type
+	 * @todo error check to see whether value is available in method
+	 */
+	function getURLValue($request_type,$request_method){
+		return $this->cat_op_values[$request_type][$request_method];
+	}
+	
+	
+	public function getCatURL($type){
+		
+	}
+	
+	//XML to Persistance
+	/**
+	 * Called by admin function when adding catalog
+	 * Create Catalog object from Getcapabilities XML
+	 * @return unknown_type
+	 * @param $url URL of getcapabilities request
+	 */
+	public function createCatObjFromXML($url)
+	{
+		//import connector
+		$x = new connector($url);
+		$data = $x->file;
+		
+		if(!$data){
+			$this->cat_status = false;
+			echo "Error1";
+			return false;
+		}
+		else {
+			$this->cat_status = true;
+		}
+		
+		//arrays to hold xml struct values and index
+		$value_array = null;
+		$index_array = null;
+		
+		//operational vars
+		$op_type=null; //get-capabilities, getrecords ...
+		$op_sub_type=null; //get,post,....
+		$op_constraint=false;
+		
+		$this->cat_getcapabilities_doc = $data;
+		$this->cat_upload_url = $url;
+		$this->cat_id="";//Auto-assing catalog id
+		
+		$parser = xml_parser_create("");
+		xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
+		xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
+		xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING,CHARSET);
+		xml_parse_into_struct($parser,$data,$value_array,$index_array);
+		
+		//echo "values:".print_r($value_array);
+		//echo "index:".print_r($vindex_array);
+		
+		$code = xml_get_error_code($parser);
+		if ($code) {
+			$line = xml_get_current_line_number($parser); 
+			$mb_exception = new mb_exception(xml_error_string($code) .  " in line " . $line);
+		}
+		
+		xml_parser_free($parser);
+		
+		foreach($value_array as $element){
+			//Version 2.0.2
+			//@todo: handle other profiles
+			
+			if((mb_strtoupper($element[tag]) == "CSW:CAPABILITIES" OR mb_strtoupper($element[tag]) == "CAPABILITIES") && $element[type] == "open"){
+				$this->cat_version = $element[attributes][version];
+			}
+			
+			//Title
+			if((mb_strtoupper($element[tag]) == "OWS:TITLE" OR mb_strtoupper($element[tag]) == "TITLE") && $element[level] == '3'){
+				$this->cat_title = $this->stripEndlineAndCarriageReturn($element[value]);
+			}
+			
+			//Abstract
+			
+			if((mb_strtoupper($element[tag]) == "OWS:ABSTRACT" OR mb_strtoupper($element[tag]) == "ABSTRACT") && $element[level] == '3'){
+				$this->cat_abstract = $this->stripEndlineAndCarriageReturn($element[value]);
+			}
+			
+			//fees
+			if(mb_strtolower($element[tag]) == "ows:fees" OR mb_strtolower($element[tag]) == "fees"){
+				$this->fees = $element[value];
+			}
+			//
+			if(mb_strtolower($element[tag]) == "ows:accessconstraints" OR mb_strtolower($element[tag]) == "accessconstraints"){
+				$this->accessconstraints = $element[value];
+			}
+			if(mb_strtolower($element[tag]) == "ows:individualname" OR mb_strtolower($element[tag]) == "individualname"){
+				$this->contactperson = $element[value];
+			}
+			if(mb_strtolower($element[tag]) == "ows:positionname" OR mb_strtolower($element[tag]) == "positionname"){
+				$this->contactposition = $element[value];
+			}
+			if(mb_strtolower($element[tag]) == "contactorganization" OR mb_strtolower($element[tag]) == "contactorganization"){
+				$this->contactorganization = $element[value];
+			}
+			if(mb_strtolower($element[tag]) == "address"){
+				$this->address = $element[value];
+			}
+			if(mb_strtolower($element[tag]) == "city"){
+				$this->city = $element[value];
+			}
+			if(mb_strtolower($element[tag]) == "stateorprovince"){
+				$this->stateorprovince = $element[value];
+			}
+			if(mb_strtolower($element[tag]) == "postcode"){
+				$this->postcode = $element[value];
+			}
+			if(mb_strtolower($element[tag]) == "country"){
+				$this->country = $element[value];
+			}
+			if(mb_strtolower($element[tag]) == "ows:Voice" OR mb_strtolower($element[tag]) == "Voice"){
+				$this->contactvoicetelephone = $element[value];
+			}
+			if(mb_strtolower($element[tag]) == "contactfacsimiletelephone"){
+				$this->contactfacsimiletelephone = $element[value];
+			}
+			if(mb_strtolower($element[tag]) == "ows:electronicmailaddress" OR mb_strtolower($element[tag]) == "electronicmailaddress"){
+				$this->contactelectronicmailaddress = $element[value];
+			}
+			
+			//Store array of keywords
+	  		if(mb_strtolower($element[tag]) == "OWS:KEYWORD" OR mb_strtolower($element[tag]) == "KEYWORD"){
+				$this->keywords[count($this->keywords)] = $element[value];
+			}
+			
+
+			
+			//Handle operational elements
+			//Open operational element
+			if((mb_strtoupper($element[tag]) == "OWS:OPERATION" OR mb_strtoupper($element[tag]) == "OPERATION") && $element[type] == "open"){
+				$op_type = $element[attributes][name];
+			}
+			
+			//Handle GET
+			if(($op_type!=null) && (mb_strtoupper($element[tag]) == "OWS:GET" OR mb_strtoupper($element[tag]) == "GET")){
+				//$this->cat_op_getcapabilities = $element[attributes]["xlink:href"];
+				$this->cat_op_values[mb_strtolower($op_type)]['get']['dflt']=$element[attributes]["xlink:href"];
+			}
+			
+			//Handle POST
+			if(($op_type!=null) && (mb_strtoupper($element[tag]) == "OWS:POST" OR mb_strtoupper($element[tag]) == "POST")){
+				//$this->cat_op_getcapabilities = $element[attributes]["xlink:href"];
+				$this->cat_op_values[mb_strtolower($op_type)]['post']['dflt']=$element[attributes]["xlink:href"];
+				$op_sub_type='post';
+			}
+			
+			//Handle Constraint
+			if(($op_type!=null) && (mb_strtoupper($element[tag]) == "OWS:CONSTRAINT" OR mb_strtoupper($element[tag]) == "CONSTRAINT")){
+				$op_constraint=$element[attributes]["name"];
+			}
+			
+			// Handle POST Constraint
+			if(($op_type!=null) && (mb_strtolower($op_constraint)=='postencoding') && (mb_strtoupper($element[tag]) == "OWS:VALUE" OR mb_strtoupper($element[tag]) == "VALUE")){
+				//$this->cat_op_getcapabilities = $element[attributes]["xlink:href"];
+				$this->cat_op_values[mb_strtolower($op_type)]['post'][mb_strtolower($element[value])]=$this->cat_op_values[mb_strtolower($op_type)]['post']['dflt'];
+				//Assume one value per constraint
+				$op_constraint=null;
+			}
+			
+			/*
+			//GETCAPABILITIES
+			if((mb_strtoupper($op_type)=='GETCAPABILITIES') &&   (mb_strtoupper($element[tag]) == "OWS:GET" OR mb_strtoupper($element[tag]) == "GET")){
+				$this->cat_op_getcapabilities = $element[attributes]["xlink:href"];
+				$this->cat_op_values['getcapabilities_get']=$element[attributes]["xlink:href"];
+			}
+			
+			//GETRECORDS
+			if((mb_strtoupper($op_type)=='GETRECORDS') &&   (mb_strtoupper($element[tag]) == "OWS:GET" OR mb_strtoupper($element[tag]) == "GET")){
+				$this->cat_op_getrecords = $element[attributes]["xlink:href"];
+				$this->cat_op_values['getrecords_get']=$element[attributes]["xlink:href"];
+			}
+			
+			//GETRECORDS
+			if((mb_strtoupper($op_type)=='GETRECORDBYID') &&   (mb_strtoupper($element[tag]) == "OWS:GET" OR mb_strtoupper($element[tag]) == "GET")){
+				$this->cat_op_getrecordbyid = $element[attributes]["xlink:href"];
+				$this->cat_op_values['getrecordbyid_get']=$element[attributes]["xlink:href"];
+			}
+			
+			//DESCRIBERECORD
+			if((mb_strtoupper($op_type)=='DESCRIBERECORDS') &&   (mb_strtoupper($element[tag]) == "OWS:GET" OR mb_strtoupper($element[tag]) == "GET")){
+				$this->cat_op_describerecord = $element[attributes]["xlink:href"];
+				$this->cat_op_values['getcapabilities_get']=$element[attributes]["xlink:href"];
+			}
+			*/
+			
+			//Close operational element
+			if((mb_strtoupper($element[tag]) == "OWS:OPERATION" OR mb_strtoupper($element[tag]) == "OPERATION") && $element[type] == "close"){
+				$op_type = null;
+			}
+			
+		}
+		
+		//Success/Failure
+		if(!$this->cat_title || $this->cat_title == ""){
+			$this->cat_status = false;
+			$e = new mb_exception("class_csw: createCatObjFromXML: CSW " . $url . " could not be loaded.");
+			return false;
+		}
+		else{
+			$this->cat_status = true;
+			$e = new mb_notice("class_csw: createCatObjFromXML: CSW " . $url . " has been loaded successfully.");
+			return true;
+		}
+		
+		
+		
+	}
+	
+	/**
+	 * Get catalog object from DB
+	 * @param $cat_id
+	 * @return unknown_type
+	 */
+	public function createCatObjFromDB($cat_id)
+	{
+		$sql = "select * from cat where cat_id = $1";
+		$v = array($cat_id);
+		$t = array('i');
+		$res = db_prep_query($sql,$v,$t);
+		while($row = db_fetch_array($res)){
+			$this->cat_id = $row['cat_id'];
+			$this->cat_version = $row['cat_version'];
+			$this->cat_abstract = administration::convertIncomingString($this->stripEndlineAndCarriageReturn($row['cat_abstract']));
+			$this->cat_title = administration::convertIncomingString($this->stripEndlineAndCarriageReturn($row['cat_title']));
+			$this->cat_upload_url = $row['cat_upload_url'];
+			$this->cat_getcapabilities_doc = $row['cat_getcapabilities_doc'];
+			$this->cat_id = $row['cat_id'];
+
+			//Get op values
+			$sql = "select * from cat_op_conf where fk_cat_id=$1";
+			$v = array($cat_id);
+			$t = array('i');
+			$res = db_prep_query($sql,$v,$t);
+			while($subrow = db_fetch_array($res)){
+				$this->cat_op_values[$subrow['param_type']][$subrow['param_name']]=$subrow['param_value'];
+			}
+		}
+	}
+	
+	/**
+	 * Write catalog object to persistent storage
+	 * @param $gui
+	 * @return unknown_type
+	 */
+	public function setCatObjToDB($gui)
+	{
+		global $con;
+		
+		$admin = new administration();//to char_encode XML
+		db_begin();
+		
+		# INSERT INTO TABLE cat - auto insert cat_id
+		$sql = "INSERT INTO cat( ";
+        $sql .= "cat_version, cat_title, cat_abstract, ";  
+        $sql .= "cat_upload_url, fees, accessconstraints, providername, providersite, "; 
+        $sql .= "individualname, positionname, voice, facsimile, deliverypoint, "; 
+        $sql .= "city, administrativearea, postalcode, country, electronicmailaddress, "; 
+        $sql .= "cat_getcapabilities_doc, cat_owner, cat_timestamp) ";
+    	$sql .= "VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21)";
+    	
+		$v = array($this->cat_version,$this->cat_title,$this->cat_abstract,
+			$this->cat_upload_url,$this->fees,$this->accessconstraints,$this->providername,$this->providersite,
+			$this->contactperson, $this->contactposition, $this->contactvoicetelephone,$this->contactfacsimiletelephone,$this->delivery,
+			$this->city,$this->address,$this->postcode,$this->country,$this->contactelectronicmailaddress,
+			$admin->char_encode($this->cat_getcapabilities_doc),
+			$_SESSION['mb_user_id'],strtotime("now"));
+			
+		$t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','i','i');
+		
+		$res = db_prep_query($sql,$v,$t);
+		if(!$res){
+			db_rollback();
+		}
+		
+		$cat_insert_id = db_insert_id($con,'cat', 'cat_id');
+		
+		//GUI_CAT 
+		$sql ="INSERT INTO gui_cat (fkey_gui_id, fkey_cat_id) ";
+		$sql .= "VALUES($1,$2)";
+		$v = array($gui,$cat_insert_id);
+		$t = array('s','i');
+		$res = db_prep_query($sql,$v,$t);
+		if(!$res){
+			db_rollback();	
+		}
+		
+		//Insert operational values into cat_op_conf
+		//CAT_OP_CONF
+		
+		
+		foreach ($this->cat_op_values as $op_category=>$op_name_array){
+			foreach($op_name_array as $op_type=>$op_value_array){
+				foreach($op_value_array as $op_sub_type=>$value){
+					$op_type_value = $op_type;
+					if($op_sub_type != 'dflt'){
+						//If not dflt, then it is either soap or xml - store this info as post_xml etc
+						$op_type_value .= '_'.$op_sub_type;
+					}
+					//Store values
+					$sql = " INSERT INTO cat_op_conf(fk_cat_id, param_type, param_name, param_value) " ;
+	    			$sql .= " VALUES ($1, $2, $3, $4)";
+	    			$v = array($cat_insert_id,$op_category,$op_type_value,$value);
+					$t = array('i','s','s','s');
+					$res = db_prep_query($sql,$v,$t);
+					if(!$res){
+						db_rollback();	
+					}
+				}
+			}
+		}
+		
+		
+		//Commit Changes
+		db_commit();
+		
+		$this->cat_id = $cat_insert_id;
+	}
+	
+	public function displayCatalog(){
+		echo "Your Catalog Has Been Successfully Added <br />";
+		echo "Catalog Details: <br/>";
+		echo "Id: " . $this->cat_id . " <br />";
+		echo "Version: " . $this->cat_version . " <br />";
+		echo "Title: " . $this->cat_title . " <br />";
+		echo "Abstract: " . $this->cat_abstract . " <br />";
+		
+	} 
+	
+	/**
+	 * Function to handle whitespace and carriage returns
+	 * Inspired by WMS code
+	 * @param $string
+	 * @return unknown_type
+	 */
+	function stripEndlineAndCarriageReturn($string) {
+	  	return preg_replace("/\n/", "", preg_replace("/\r/", " ", $string));
+	}
+	
+
+}
+?>
\ No newline at end of file

Added: trunk/mapbender/http/classes/class_cswrecord.php
===================================================================
--- trunk/mapbender/http/classes/class_cswrecord.php	                        (rev 0)
+++ trunk/mapbender/http/classes/class_cswrecord.php	2009-12-12 10:14:51 UTC (rev 5152)
@@ -0,0 +1,282 @@
+<?php
+# $Id$
+# http://www.mapbender.org/index.php/class_cat_record
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program 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.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/class_connector.php");
+require_once(dirname(__FILE__)."/class_user.php");
+require_once(dirname(__FILE__)."/class_administration.php");
+
+/**
+ * CSW main class to hold catalog object
+ * @author nazgul
+ *
+ */
+class cswrecord{
+	
+	var $getrecords_status;
+	var $elementSet;
+	var $numberOfRecordsMatched;
+	
+	//Store GetRecords response XML for future caching needs
+	var $getRecordsDoc;
+	
+	//Array of cswSummaryRecord Objects
+	var $SummaryRecordsArray = array();
+	
+	//Constructor
+	function cswrecord(){
+		
+	}
+	
+	// Public Methods
+	
+	/**
+	 * Create cswrecord object from GetRecords XML response
+	 * @return unknown_type
+	 * @param $url URL of getrecords
+	 * @param $xml Post, SOAP XML
+	 * @todo handle XML for POST,SOAP
+	 */
+	public function createCSWRecordFromXML($url,$xml=null)
+	{
+		//create connector
+		$data=null;
+		//@todo handle post,soap
+		if($xml != null){
+			$connection = new connector();
+        	$connection->set("httpType", "post");
+        	$connection->set("httpContentType", "xml");
+        	$connection->set("httpPostData", $xml);
+        	$data = $connection->load($url);
+		}
+		else{
+			$x = new connector($url);
+			$data = $x->file;
+		}
+        
+		if(!$data){
+			$this->getrecords_status=false;
+			$e = new mb_exception("CAT getrecords returned no result: " . $url . "\n" . $postData);
+			return false;
+		}
+		else {
+			$this->getrecords_status=true;
+		}
+		
+		//arrays to hold xml struct values and index
+		$value_array = null;
+		$index_array = null;
+		
+		//operational vars
+		$op_type=null; //get-capabilities, getrecords ...
+		$op_sub_type=null; //get,post,....
+		$op_constraint=false;
+		
+		//Store XML response
+		//@todo cache this
+		$this->getRecordsDoc = $data;
+		
+		$parser = xml_parser_create("");
+		xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
+		xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
+		xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING,CHARSET);
+		xml_parse_into_struct($parser,$data,$value_array,$index_array);
+		
+		//echo "values:".print_r($value_array);
+		//echo "index:".print_r($vindex_array);
+		
+		$code = xml_get_error_code($parser);
+		if ($code) {
+			$line = xml_get_current_line_number($parser); 
+			$mb_exception = new mb_exception(xml_error_string($code) .  " in line " . $line);
+		}
+		
+		xml_parser_free($parser);
+		
+		foreach($value_array as $element){
+			//Version 2.0.2
+			//@todo: handle other profiles
+			
+			if((mb_strtoupper($element[tag]) == "CSW:SEARCHRESULTS" OR mb_strtoupper($element[tag]) == "SEARCHRESULTS") && $element[type] == "open"){
+				$this->elementSet = $element[attributes][elementSet];
+				$this->numberOfRecordsMatched = $element[attributes][numberOfRecordsMatched];
+			}
+			
+			if((mb_strtoupper($element[tag]) == "CSW:SUMMARYRECORD" OR mb_strtoupper($element[tag]) == "SUMMARYRECORD") && $element[type] == "open"){
+				//Create SummaryRecords Object
+				$summaryObj = new cswSummaryRecord();
+			}
+			
+			//SummaryRecord elements
+			
+			//ID
+			if((mb_strtoupper($element[tag]) == "DC:IDENTIFIER" OR mb_strtoupper($element[tag]) == "IDENTIFIER")){
+				$summaryObj->identifier = $element[value];
+			}
+			//Title
+			if((mb_strtoupper($element[tag]) == "DC:TITLE" OR mb_strtoupper($element[tag]) == "TITLE")){
+				$summaryObj->title = $element[value];
+			}
+			
+			//@todo handle multiple subject elements
+			//Subject
+			if((mb_strtoupper($element[tag]) == "DC:SUBJECT" OR mb_strtoupper($element[tag]) == "SUBJECT")){
+				$summaryObj->subject = $element[value];
+			}
+			
+			//Abstract
+			if((mb_strtoupper($element[tag]) == "DC:ABSTRACT" OR mb_strtoupper($element[tag]) == "ABSTRACT" OR mb_strtoupper($element[tag]) == "DCT:ABSTRACT")){
+				$summaryObj->abstract = $element[value];
+			}
+			
+			//Modified
+			if((mb_strtoupper($element[tag]) == "DC:MODIFIED" OR mb_strtoupper($element[tag]) == "MODIFIED")){
+				$summaryObj->modified = $element[value];
+			}
+			
+			//Type
+			if((mb_strtoupper($element[tag]) == "DC:TYPE" OR mb_strtoupper($element[tag]) == "TYPE")){
+				$summaryObj->type = $element[value];
+			}
+			
+			//Format
+			if((mb_strtoupper($element[tag]) == "DC:FORMAT" OR mb_strtoupper($element[tag]) == "FORMAT")){
+				$summaryObj->format = $element[value];
+			}
+			
+			if((mb_strtoupper($element[tag]) == "CSW:SUMMARYRECORD" OR mb_strtoupper($element[tag]) == "SUMMARYRECORD") && $element[type] == "close"){
+				//{ush SummaryRecords Object to Array
+				array_push($this->SummaryRecordsArray,$summaryObj);
+			}
+		}
+		
+		//Success/Failure
+		if($this->numberOfRecordsMatched==0){
+			$this->getrecords_status=false;
+			$e = new mb_exception("There are no records that match your criteria");
+			return false;
+		}
+		else{
+			$this->getrecords_status = true;
+			$e = new mb_notice("GetRecords Results Returned");
+			return true;
+		}	
+		
+	}
+			
+	/**
+	 * Function to handle whitespace and carriage returns
+	 * Inspired by WMS code
+	 * @param $string
+	 * @return unknown_type
+	 */
+	function stripEndlineAndCarriageReturn($string) {
+	  	return preg_replace("/\n/", "", preg_replace("/\r/", " ", $string));
+	}
+	
+}
+
+/**
+ * cswSummaryRecord to hold SummaryRecord Objects
+ * GetRecord(1)-SummaryRecord(n) 
+ * @author nazgul
+ *
+ */
+class cswSummaryRecord{
+	
+	//Vars
+	var $identifier;
+	var $title;
+	var $subject;
+	var $abstract;
+	var $modified;
+	var $type;
+	var $format;
+	
+	//Constructor
+	function cswSummaryRecord(){
+		
+	}
+	
+	//Getters
+	
+	public function getIdentifier(){
+		return $this->identifier;
+	}
+	
+	public function getTitle(){
+		return $this->title;
+	}
+	
+	public function getSubject(){
+		return $this->subject;
+	}
+	
+	//return abstract
+	public function getAbstract(){
+		return $this->abstract;
+	}
+	
+	public function getModified(){
+		return $this->modified;
+	}
+	
+	public function getType(){
+		return $this->type;
+	}
+	
+	public function getFormat(){
+		return $this->format;
+	}
+	
+	//Setters
+	
+	public function setIdentifier($identifier){
+		return $this->identifier = $identifier;
+	}
+	
+	public function setTitle($title){
+		return $this->title = $title;
+	}
+	
+	public function setSubject($subject){
+		return $this->subject = $subject;
+	}
+	
+	public function setAbstract($abstract){
+		return $this->abstract = $abstract;
+	}
+	
+	public function setModified($modified){
+		return $this->modified = $modified;
+	}
+	
+	public function setType($type){
+		return $this->type = $type;
+	}
+	
+	public function setFormat($format){
+		return $this->format = $format;
+	}
+	
+}
+
+
+
+?>
\ No newline at end of file

Added: trunk/mapbender/http/javascripts/mod_CSWFunctions.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_CSWFunctions.js	                        (rev 0)
+++ trunk/mapbender/http/javascripts/mod_CSWFunctions.js	2009-12-12 10:14:51 UTC (rev 5152)
@@ -0,0 +1,9 @@
+/**
+ * Admin function to load catalog into DB
+ * @param caps_url
+ * @return
+ */
+function mod_CSW_load_catalog(caps_url){
+	var capUrl = "../php/mod_createJSObjFromXML.php?" + mb_session_name + "=" + mb_nr + "&caps=" + encodeURIComponent(caps);
+	window.frames['loadData'].document.location.href = capUrl;
+}
\ No newline at end of file

Added: trunk/mapbender/http/javascripts/mod_searchCSW_ajax.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_searchCSW_ajax.php	                        (rev 0)
+++ trunk/mapbender/http/javascripts/mod_searchCSW_ajax.php	2009-12-12 10:14:51 UTC (rev 5152)
@@ -0,0 +1,526 @@
+<?php
+# $Id$
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program 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.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
+
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+
+<head>
+	<meta http-equiv="cache-control" content="no-cache" />
+	<meta http-equiv="pragma" content="no-cache" />
+	<meta http-equiv="expires" content="0" />
+	<?php printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\" />",CHARSET);	?>
+	<title>Search Catalog</title>
+	<style type="text/css">
+	<!--
+	div.form-container form { padding: 5px; background-color: #FFF; border: #EEE 1px solid; background-color: #FbFbFb; }
+	div.form-container p { margin: 0.5em 0 0 0; }
+	div.form-container form p { margin: 0; }
+	div.form-container form p.note { font-style: italic; margin-left: 18em; font-size: 80%; color: #666; }
+	div.form-container form fieldset { margin:0 0 10px 0; padding: 10px; border: #DDD 1px solid; background-color:#FFF;}
+	div.form-container form fieldset input:focus,
+	div.form-container form fieldset input.errorfield:focus,
+	div.form-container form fieldset textarea:focus { background-color: #FFC; border-color: #FC6;  }
+	div.form-container form fieldset label{ position:relative; margin-right: 10px; padding-right: 10px; width: 15em; display: block; float: left; text-align: right;min-height:1em;top:0.25em;}
+	div.form-container form fieldset label.errorfield,
+	div.form-container form fieldset span.errorfield { color: #C00; }
+	div.form-container form fieldset label.value{display:block;text-align:left;width:auto;}
+	
+	
+	
+	-->
+	</style>
+	<script type="text/javascript">
+	<!--
+	// Set default for element variables if they are undefined
+	/*
+	option_dball      = (typeof(option_dball) !== 'undefined')      ? option_dball      : '1';
+	option_dbgroup    = (typeof(option_dbgroup) !== 'undefined')    ? option_dbgroup    : '0';
+	option_dbgui      = (typeof(option_dbgui) !== 'undefined')      ? option_dbgui      : '0';
+	capabilitiesInput = (typeof(capabilitiesInput) !== 'undefined') ? capabilitiesInput : '1';
+	gui_list          = (typeof(gui_list) !== 'undefined')          ? gui_list          : '';
+	*/
+
+	/*
+	var guis = gui_list.split(',');
+	
+	if(gui_list === '') {
+		guis = [];
+	}
+	*/
+
+	var global_source = 'capabilities';  // [capabilities,db]
+
+	
+	var global_is_advanced = false;
+
+	//defaults
+	var getrecords_media = 'GET';
+	var getrecords_query = 'CQL';
+	
+	//set server side URL for query builder
+	var phpUrl  = '../php/mod_searchCatQueryBuilder_server.php?<?php echo $urlParameters;?>';
+
+
+
+	function hide_advanced_form(){
+
+		global_is_advanced = false;
+		var html='';
+		html = html + "<fieldset>";
+		html = html + "<input type='button' id='adv_search_show' name='adv_search_show' value='<?php echo _mb('+ Advanced'); ?>' onclick='show_advanced_form();' />";
+		html = html + "</fieldset>";
+
+		document.getElementById('advanced_div').innerHTML=html;
+	}
+
+	// Form fields
+
+	function show_advanced_form(){
+		
+		global_is_advanced = true;
+		var html = '';
+		html = html + "<fieldset>";
+		html = html + "<input type='button' value='--Advanced' onclick=hide_advanced_form() />";
+		html = html + "</fieldset>";
+		html = html + "<fieldset>";
+		html = html + "<legend>Advanced Search</legend>";
+		html = html + "<fieldset id='cont_adv_summary'>";
+		html = html + "<label for='adv_title'><?php echo _mb('Title '); ?>:</label>";
+		html = html + "<input type='text' id='adv_title' name='adv_title' /> <br /><br />";
+		html = html + "<label for='adv_abstract'><?php echo _mb('Abstract'); ?>:</label>";
+		html = html + "<input type='text' id='adv_abstract' name='adv_abstract' /><br /><br />";
+		html = html + "<label for='adv_keywords'><?php echo _mb('Keywords'); ?>:</label>";
+		html = html + "<input type='text' id='adv_keywords' name='adv_keywords' /><br /><br />";
+		html = html + "</fieldset>";
+
+		
+		html = html + "<fieldset>";
+		html = html + "<table>";
+		html = html + "<tr>";
+		html = html + "<td></td>";
+		html = html + "<td>";
+		html = html + "<label for='latmin'><?php echo _mb('Lat-Min'); ?>:</label>";
+		html = html + "<input type='text' id='latmin' name='latmin' size=8/>";
+		html = html + "</td>";
+		html = html + "<td></td>";
+		html = html + "</tr>";
+		html = html + "<tr>";
+		html = html + "<td>";
+		html = html + "<label for='lonmin'><?php echo _mb('Lon-Min'); ?>:</label>";
+		html = html + "<input type='text' id='lonmin' name='lonmin' />";
+		html = html + "</td>";
+		html = html + "<td></td>";
+		html = html + "<td>";
+		html = html + "<label for='latmax'><?php echo _mb('Lat-Max'); ?>:</label>";
+		html = html + "<input type='text' id='latmax' name='latmax' />";
+		html = html + "</td>";
+		html = html + "</tr>";
+		html = html + "<tr>";
+		html = html + "<td></td>";
+		html = html + "<td>";
+		html = html + "<label for='lonmax'><?php echo _mb('Lon-Max'); ?>:</label>";
+		html = html + "<input type='text' id='lonmax' name='lonmax' />";
+		html = html + "<td></td>";
+		html = html + "</tr>";
+		html = html + "</table>";
+		html = html + "</fieldset>";
+		
+		document.getElementById('advanced_div').innerHTML=html;			
+			
+	}
+
+	function show_options_form(){
+		var html = '';
+		html = html + "<fieldset>";
+		html = html + "<input type='button' value='- Options' onclick=hide_options_form() />";
+		html = html + "</fieldset>";
+		html = html + "<fieldset>";
+		html = html + "<legend>Search Options</legend>";
+		html = html + "<fieldset id='cont_options'>";
+		html = html + "<label for='opt_result_cont'><?php echo _mb('No. of Hits'); ?>:</label>";
+		html = html + "<input type='text' id='opt_result_cont' name='opt_result_cont' /> <br /><br />";
+		html = html + "<label for='opt_getrecords_media'><?php echo _mb('Getrecords Medium'); ?>:</label>";
+		html = html + "<select id='opt_getrecords_media' name='opt_getrecords_media'>";
+		html = html + "<option value='get'>GET</option>";
+		html = html + "<option value='post'>POST</option>";
+		html = html + "<option value='post-soap' disabled>SOAP</option>";
+		html = html + "</select>";
+		html = html + "<br /><br />";
+
+		html = html + "<label for='opt_getrecords_query'><?php echo _mb('Query Language'); ?>:</label>";
+		html = html + "<select id='opt_getrecords_query' name='opt_getrecords_query'>";
+		html = html + "<option value='cql'>CQL</option>";
+		html = html + "<option value='filter'>Filter</option>";
+		html = html + "</select>";
+		html = html + "<br /><br />";
+		
+		html = html + "</fieldset>";
+		document.getElementById('options_div').innerHTML=html;
+	}
+
+	function hide_options_form(){
+
+		var html='';
+		html = html + "<fieldset>";
+		html = html + "<input type='button' id='options_show' name='options_show' value='<?php echo _mb('+ Options'); ?>' onclick='show_options_form();' />";
+		html = html + "</fieldset>";
+
+		document.getElementById('options_div').innerHTML=html;
+	}
+
+	// End of Form fields
+	
+
+
+	// -----------------  Display results --------------------
+
+	function removeChildNodes(node) {
+		while (node.childNodes.length > 0) {
+			var childNode = node.firstChild;
+			node.removeChild(childNode);
+		}
+	}
+
+	function setTableHeader(text,titleLeft,titleRight) {
+		document.getElementById('resultString').innerHTML = text;
+		document.getElementById('titleLeft').innerHTML    = titleLeft;
+		document.getElementById('titleRight').innerHTML   = titleRight;
+		
+		removeChildNodes(document.getElementById('resultTableBody'));
+	}
+
+	function addTableRow(leftText,rightText,onClick) {
+		var resultTableBoy        = document.getElementById('resultTableBody');
+		var leftTableCell         = document.createElement('td');
+		var rightTableCell        = document.createElement('td');
+		var leftTableCellContent  = document.createElement('strong');
+		var rightTableCellContent = document.createElement('em');
+		var tableRow              = document.createElement('tr');
+				
+		leftTableCellContent.innerHTML  = leftText;
+		rightTableCellContent.innerHTML = rightText;
+
+		leftTableCell.appendChild(leftTableCellContent);
+		rightTableCell.appendChild(rightTableCellContent);
+		tableRow.appendChild(leftTableCell);
+		tableRow.appendChild(rightTableCell);
+		
+		tableRow.onclick = function () {
+			eval(onClick);
+		}
+
+		if(resultTableBoy.childNodes.length % 2 !== 0) {
+			tableRow.className += tableRow.className + ' alternate';
+		}
+
+		resultTableBoy.appendChild(tableRow);
+	}
+
+	function imageOn() {
+		document.getElementById("progressIndicator").style.visibility = "visible";
+		document.getElementById("progressIndicator").style.display = "block";
+		document.getElementById("resultTable").style.visibility = "hidden";
+		document.getElementById("resultTable").style.display = "none";
+		document.getElementById("resultString").style.visibility = "hidden";
+		document.getElementById("resultString").style.display = "none";
+	}
+
+	function imageOff() {
+		document.getElementById("progressIndicator").style.visibility = "hidden";
+		document.getElementById("progressIndicator").style.display = "none";
+		document.getElementById("resultTable").style.visibility = "visible";
+		document.getElementById("resultTable").style.display = "block";
+		document.getElementById("resultString").style.visibility = "visible";
+		document.getElementById("resultString").style.display = "block";
+	}
+
+	function noResult() {
+		document.getElementById("resultTable").style.visibility = 'hidden';
+		document.getElementById("resultString").innerHTML = noResultText;
+	}
+
+	function noResultV(val) {
+		document.getElementById("resultTable").style.visibility = 'hidden';
+		document.getElementById("resultString").innerHTML = noResultText+val;
+	}
+
+	function setButtons() {
+		var containerCapabilities = document.getElementById('container_capabilities');
+		var containerButtons      = document.getElementById('container_buttons');
+		var optionButton          = false;
+
+		// If only one is active load list imidiately
+		if(
+			parseInt(option_dbgui) + 
+			parseInt(option_dbgroup) + 
+			parseInt(option_dball)
+		=== 1) {
+			if(option_dball === '1'){
+				optionButton = document.getElementById('button_dbAll');
+			}
+			if(option_dbgroup === '1') {
+				optionButton = document.getElementById('button_dbGroup');
+			}
+			if(option_dbgui === '1') {
+				optionButton = document.getElementById('button_dbGui');
+			}
+
+			if(optionButton) {
+				optionButton.onclick();
+				containerButtons.parentNode.removeChild(containerButtons);
+				
+				return;
+			}
+		}
+
+		if(option_dball === '0') {
+			optionButton = document.getElementById('button_dbAll');
+			optionButton.parentNode.removeChild(optionButton);
+		}
+		if(option_dbgroup === '0') {
+			optionButton = document.getElementById('button_dbGroup');
+			optionButton.parentNode.removeChild(optionButton);
+		}
+		if(option_dbgui === '0') {
+			optionButton = document.getElementById('button_dbGui');
+			optionButton.parentNode.removeChild(optionButton);
+		}
+		
+		if(capabilitiesInput === '0') {
+			optionButton = document.getElementById('capabilitiesForm');
+			optionButton.parentNode.removeChild(optionButton);
+			containerCapabilities.parentNode.removeChild(containerCapabilities);
+		}
+	}
+
+	function displayGroups (groupArray) {
+		if (groupArray.length > 0) {
+			setTableHeader(selectGroupText, groupNameText, groupAbstractText);
+			
+			for (var i = 0; i < groupArray.length; i++) {
+				var onClick = "getWMSByGroup('" + groupArray[i].id + "')";
+				addTableRow(groupArray[i].name, groupArray[i].description, onClick);	
+			}
+		}
+		else {
+			noResult();
+		}
+	}
+
+	function displayGUIs (guiArray) {
+		if (guiArray.length > 0) {
+			setTableHeader(selectGuiText, guiNameText, guiAbstractText);
+			
+			for (var i = 0; i < guiArray.length; i++) {
+				var onClick = "getWMSByGUI('" + guiArray[i].id + "')";
+				if(guis.length>0){
+					for(var j=0; j < guis.length; j++){
+						if(guiArray[i].id==guis[j]){
+							addTableRow(guiArray[i].name, guiArray[i].description, onClick);	
+							break;
+						}
+					}
+				}
+				else
+					addTableRow(guiArray[i].name, guiArray[i].description, onClick);	
+			}
+		}
+		else {
+			noResult();
+		}
+	}
+
+	function displayWMS (wmsArray, guiId) {
+		if (wmsArray.length > 0) {
+			setTableHeader(selectWmsText, wmsNameText, wmsAbstractText);
+
+			for (var i = 0; i < wmsArray.length; i++) {
+
+				if (global_source == "db" && typeof(guiId) !== "undefined" ) {
+					var onClick = "mod_addWMSfromDB('" + guiId + "', '" + wmsArray[i].id + "')";
+				}		
+				else {
+					var onClick = "mod_addWMSfromfilteredList('" + wmsArray[i].getCapabilitiesUrl + "', '" + wmsArray[i].version + "')";
+				}
+				addTableRow(wmsArray[i].title, wmsArray[i].abstract, onClick);
+			}
+		}
+		else {
+			noResult();
+		}
+	}
+
+
+	// Display Catalog records returned by getrecords
+	function displayRecords(catarray){
+	
+		if (catarray.length > 0) {
+			setTableHeader(CatTitle, CatName, CatAbstract);
+
+			for (var i = 0; i < catarray.length; i++) {
+
+				/*
+				if (global_source == "db" && typeof(guiId) !== "undefined" ) {
+					var onClick = "mod_addWMSfromDB('" + guiId + "', '" + wmsArray[i].id + "')";
+				}		
+				else {
+					var onClick = "mod_addWMSfromfilteredList('" + wmsArray[i].getCapabilitiesUrl + "', '" + wmsArray[i].version + "')";
+				}
+				*/
+				addTableRow(catarray[i].title, catarray[i].abstractt);
+			}
+		}
+		else {
+			noResultV(catarray[0]);
+		}
+		
+	}
+	
+
+
+	//Build CSW query and search
+	function mod_searchCSW(){
+		imageOn();
+		
+		var simplesearchterm = document.getElementById('basic_search').value;
+		try{
+			getrecords_media = document.getElementById('opt_getrecords_media').value;
+		}
+		catch(err){
+			//getrecords_media = 'get';
+		}
+		try{
+			getrecords_query = document.getElementById('opt_getrecords_query').value;
+		}
+		catch(err){
+			//getrecords_query = 'cql';
+		}
+		//check for simple or advanced
+		if(global_is_advanced){
+			//handle advanced search
+			try{
+				advanced_title = document.getElementById('adv_title').value;
+				advanced_abstract = document.getElementById('adv_abstract').value;
+				advanced_keywords = document.getElementById('adv_keyword').value;
+				advanced_bb_latmin = document.getElementById('latmin').value;
+				advanced_bb_latmax = document.getElementById('latmax').value;
+				advanced_bb_lonmin = document.getElementById('lonmin').value;
+				advanced_bb_lonmax = document.getElementById('lonmax').value;
+			}
+			catch(err){
+				
+			}
+			//imageOn();
+			parent.mb_ajax_json(phpUrl, {"command":"getrecordsadvanced","adv_title":adv_title,"adv_abstract":adv_abstract,"adv_keyword":adv_keyword,"latmin":latmin,"latmax":latmax,"lonmin":lonmin,"lonmax":lonmax}, function (json, status) {
+				//imageOff();
+				displayRecords(json.cats);
+				//displayGroups(json.group);
+			});
+				
+		}
+		else{
+			//handle simple search
+			//imageOff();
+			parent.mb_ajax_json(phpUrl, {"command":"getrecordssimple", "search":simplesearchterm, "getrecordsmedia":getrecords_media,"getrecordsquery":getrecords_query }, function (json, status) {
+			//imageOn();	
+			displayRecords(json.cats);
+			imageOff();
+			});
+				
+		}	
+		
+	}
+
+		
+	-->
+	</script>
+	<?php include("../include/dyn_css.php"); ?>
+	<script type="text/javascript">
+
+	var CatName = '<?php echo _mb("Record Title");?>';
+	var CatAbstract = '<?php echo _mb("Record Abstract");?>';
+	var CatTitle = '<?php echo _mb("Returned Results...");?>';
+
+
+
+	</script>
+
+</head>
+
+<body onLoad="imageOff();">
+<h1><?php echo _mb("Catalog Service for Web Client"); ?></h1>
+<div class='note'>
+	<?php echo _mb("Do a Basic or Advanced Search of Catalogs in the system. Please visit the Catalog Admin to add a Catalog"); ?>
+</div>
+
+<div class="form-container">
+<form id="capabilitiesForm" name="addURLForm" method="post" action="">
+	<fieldset id="container_capabilities">
+		<legend>Capabilities</legend>
+			<p> 
+				<label for="basic_search"><?php echo _mb("Search for "); ?>:</label> 
+				<input type="text" id="basic_search" name="basic_search" />
+				<br /> 
+			</p>
+	</fieldset>
+		
+		<!-- Show via inner HTML -->
+		<div id="advanced_div">
+		<fieldset>
+			<input type="button" id="adv_search_show" name="adv_search_show" value="<?php echo _mb("+ Advanced"); ?>" onclick="show_advanced_form();" />
+		</fieldset>
+		</div>
+		
+		<div id="options_div">
+		<fieldset>
+			<input type="button" id="options_show" name="options_show" value="<?php echo _mb("+ Options"); ?>" onclick="show_options_form();" />
+		</fieldset>
+		</div>
+		
+		
+		<input type="button" id="basic_search_submit" name="addCapURL" value="<?php echo _mb("Search CSW"); ?>" onclick="mod_searchCSW();" />
+</form>
+</div>
+ 
+  
+<p id="progressIndicator" name="progressIndicator">
+	<img src="../img/indicator_wheel.gif" />
+	<?php echo _mb("Loading"); ?> ... 
+</p>
+
+
+<h2 id="resultString" name="resultString"></h2>
+
+<table id="resultTable" name="resultTable">
+	<thead>
+		<tr>
+			<th id="titleLeft" name="titleLeft"></th>
+			<th id="titleMiddle" name="titleMiddle"></th>
+			<th id="titleRight" name="titleRight"></th>
+		</tr>
+	</thead>
+	<tbody id="resultTableBody" name="resultTableBody">
+	</tbody>
+</table>
+</body>
+
+</html>
\ No newline at end of file

Added: trunk/mapbender/http/javascripts/mod_searchCSW_form.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_searchCSW_form.php	                        (rev 0)
+++ trunk/mapbender/http/javascripts/mod_searchCSW_form.php	2009-12-12 10:14:51 UTC (rev 5152)
@@ -0,0 +1,88 @@
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program 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.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
+//ob_start();
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+
+<head>
+	<meta http-equiv="cache-control" content="no-cache" />
+	<meta http-equiv="pragma" content="no-cache" />
+	<meta http-equiv="expires" content="0" />
+	<?php printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\" />",CHARSET);	?>
+	<title>Search CSW</title>
+	
+	<script type="javascript">
+	function mod_searchCSWSimple()
+	{
+		alert('Call');
+	}
+
+	function show_advanced()
+	{
+		document.container_advanced.InnerHTML;
+	}
+
+	function build_query_from_search()
+	{
+	}
+
+
+	</script>
+</head>
+<body>
+	<h1><?php echo _mb("Search CSW"); ?></h1>
+	<p><?php echo _mb("Search catalog metadata"); ?></p>
+
+	<form id="cswSimpleSearchForm" name="addURLForm" method="post" action="">
+		<fieldset id="container_simple">
+		<legend>Basic Search</legend>
+		<p>
+			<label for="basic_search"><?php echo _mb("Search for "); ?>:</label> 
+			<input type="text" id="basic_search" name="basic_search" />
+			<br /> 
+			<input type="button" id="basic_search_submit" name="addCapURL" value="<?php echo _mb("Search CSW"); ?>" onclick="mod_searchCSWSimple();" />
+		</p>
+		</fieldset>
+		<a href="#" onclick='show_advanced()'>+ Advanced</a>
+		<!-- Show via inner HTML -->
+		<fieldset id="container_advanced">
+		<legend>Advanced Search</legend>
+			<fieldset id="cont_adv_summary">
+				<label for="adv_title"><?php echo _mb("Title "); ?>:</label> 
+				<input type="text" id="adv_title" name="adv_title" />
+				<label for="adv_abstract"><?php echo _mb("Abstract"); ?>:</label> 
+				<input type="text" id="adv_abstract" name="adv_abstract" />
+				<label for="adv_keywords"><?php echo _mb("Keywords"); ?>:</label> 
+				<input type="text" id="adv_keywords" name="adv_keywords" />
+				<br /> 
+			</fieldset>
+			<fieldset id="cont_adv_bbox">
+				<label for="adv_title"><?php echo _mb("Lat-Min"); ?>:</label> 
+				<input type="text" id="adv_title" name="adv_title" />
+				<label for="adv_abstract"><?php echo _mb("Lat-Maz"); ?>:</label> 
+				<input type="text" id="adv_abstract" name="adv_abstract" />
+				<label for="adv_keywords"><?php echo _mb("Lon-Min"); ?>:</label> 
+				<input type="text" id="adv_keywords" name="adv_keywords" />
+				<label for="adv_keywords"><?php echo _mb("Lon-Max"); ?>:</label> 
+				<input type="text" id="adv_keywords" name="adv_keywords" />
+				<br /> 
+			</fieldset>
+			<input type="button" id="basic_search_submit" name="addCapURL" value="<?php echo _mb("Search CSW"); ?>" onclick="mod_searchCSWSimple();" />
+		</fieldset>
+	</form>
+</body>
\ No newline at end of file

Added: trunk/mapbender/http/php/mod_loadCatalog.php
===================================================================
--- trunk/mapbender/http/php/mod_loadCatalog.php	                        (rev 0)
+++ trunk/mapbender/http/php/mod_loadCatalog.php	2009-12-12 10:14:51 UTC (rev 5152)
@@ -0,0 +1,39 @@
+<?php
+# $Id$
+# http://www.mapbender.org/index.php/Administration
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program 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.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# File to load a catalog into the system
+
+require_once(dirname(__FILE__) . "/mb_validatePermission.php");
+require_once(dirname(__FILE__) . "/../classes/class_csw.php"); 
+
+//get list of GUIs
+$gui_list = $_REQUEST["guiList"];
+
+//Get Catalog Capabilities XML
+$cat_xml_url = $_REQUEST["xml_file"];
+//echo "url:".$cat_xml_url;
+
+$catalog = new csw();
+$catalog->createCatObjFromXML($cat_xml_url);
+
+$catalog->setCatObjToDB($gui_list);
+
+//Display Catalog data
+$catalog->displayCatalog();
+?>
\ No newline at end of file

Added: trunk/mapbender/http/php/mod_loadCatalogCapabilities.php
===================================================================
--- trunk/mapbender/http/php/mod_loadCatalogCapabilities.php	                        (rev 0)
+++ trunk/mapbender/http/php/mod_loadCatalogCapabilities.php	2009-12-12 10:14:51 UTC (rev 5152)
@@ -0,0 +1,193 @@
+<?php
+# $Id$
+# http://www.mapbender.org/index.php/Administration
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program 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.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+//Include required files
+import_request_variables("PG");
+require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<?php
+	echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';	
+?>
+<!-- What about localization of Title values as below - do we handle that? -->
+<title>Load Catalog</title>
+<?php
+include '../include/dyn_css.php';
+?>
+<style type="text/css">
+  	<!--
+  	body{
+      background-color: #ffffff;
+  		font-family: Arial, Helvetica, sans-serif;
+  		font-size : 12px;
+  		color: #808080
+  	}
+  	.list_guis{
+  		font-family: Arial, Helvetica, sans-serif;
+  		font-size : 12px;
+  		color: #808080;
+  	}
+  	a:link{
+  		font-family: Arial, Helvetica, sans-serif;
+  		font-size : 12px;
+  		text-decoration : none;
+  		color: #808080;
+  	}
+  	a:visited {
+  		font-family: Arial, Helvetica, sans-serif;
+  		text-decoration : none;
+  		color: #808080;
+  		font-size : 12px;
+  	}
+  	a:active {
+  		font-family: Arial, Helvetica, sans-serif;
+  		text-decoration : none;
+  		color: #808080;
+  		font-size : 12px;
+  	}
+  	#csw_info {
+  		font-family: Arial, Helvetica, sans-serif;
+  		text-decoration : none;
+  		color: #808FFF;
+  		font-size : 18px;
+  	}
+  	
+  	.confirmation { border: #070 1px solid; background: url(img/dialog-confirmation.png) #E5FFE5 no-repeat 5px 5px; }
+	.confirmation p em { color:#070; }
+  	
+  	-->
+</style>
+
+<script language="JavaScript">
+function validate(value){
+	if(value == 'guiList'){
+		var listIndex = document.form1.guiList.selectedIndex;
+		if(listIndex<0){
+			alert("Please select a GUI to add Catalog to.");
+			return false;
+		}
+		else{
+			var gui_id=document.form1.guiList.options[listIndex].value;
+			document.form1.action = '../php/mod_loadCatalog.php?<?php echo $urlParameters ?>';
+			document.form1.submit();
+		}
+	}
+}
+</script>
+</head>
+<body>
+
+<?php
+
+//Get GUIs for present user
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+$admin = new administration();
+$ownguis = $admin->getGuisByOwner($_SESSION["mb_user_id"],true);
+
+echo "<form name='form1' action='" . $self ."' method='post'>";
+echo "<fieldset name=form1_field1><legend>GUI Catalogs</legend>";
+echo "<table cellpadding='0' cellspacing='0' border='0'>";
+echo "<tr>";
+echo "<td>";
+if (count($ownguis)>0){
+	echo"GUI";
+	echo"<br>";
+	$v = array();
+	$t = array();
+	$sql = "SELECT * FROM gui WHERE gui_id IN ("; 
+	for($i=0; $i<count($ownguis); $i++){
+		if($i>0){ $sql .= ",";}
+		$sql .= "$".($i+1);
+		array_push($v,$ownguis[$i]);
+		array_push($t,'s');
+	}
+	$sql .= ") ORDER BY gui_name";
+	$res = db_prep_query($sql,$v,$t);
+	echo"<select size='8' name='guiList' style='width:200px' onClick='submit()'>";
+	while($row = db_fetch_array($res)){
+		echo "<option value='".$row["gui_id"]."' ";
+		if($guiList && $guiList == $row["gui_name"]){
+			echo "selected";
+		}
+		echo ">".$row["gui_name"]."</option>";
+	} 
+	$arrayGUIs=$_SESSION["mb_user_guis"];
+	echo count($arrayGUIs);
+	echo "</select><br><br>";
+	echo "</td>";
+	echo "<td>";
+	echo"CATALOG";
+	echo"<br>";
+	
+	//Change to catalog tables: mif
+	if(isset($guiList) && $guiList!=""){
+		$sql = "SELECT DISTINCT cat.cat_title from gui_cat JOIN ";
+		$sql .= "gui on gui_cat.fkey_gui_id = gui.gui_id JOIN cat ON gui_cat.fkey_cat_id = cat.cat_id ";
+		$sql .= "and gui_cat.fkey_gui_id = gui.gui_id where gui.gui_name = $1";
+		$v = array($guiList);
+		$t = array('s');
+		$res = db_prep_query($sql,$v,$t);
+		$count=0;
+		echo"<select size='8' name='catList' style='width:200px'>";
+	
+		while($row = db_fetch_array($res)){
+			if ($row["cat_title"]!=""){
+				echo "<option value='' ";
+				echo ">".$row["cat_title"]."</option>";
+			}
+			$count++;
+		}
+	    echo "</select><br><br>";
+	}
+	else{
+		echo"<select size='8' name='catList' style='width:200px' on Click='submit()'>";
+		echo "</select><br><br>";
+	}
+	
+	echo "</td>";
+	echo "<tr></table><br>";
+	echo "</fieldset>";
+	//echo "<div id='csw_info'>";
+	echo "<fieldset name=form1_field2>";
+	echo "<div class='confirmation'>";
+	echo "<p>Provide a link here to the Catalog Capabilities URL:<br/>";
+	echo "Add one of the following REQUEST to the Online Resource URL to obtain the CSW Capabilities document:<br />";
+	echo "<i>(Triple click to select and copy)</i><br>"; 
+	echo "<em>REQUEST=GetCapabilities&SERVICE=CSW&VERSION=2.0.2</em><br/></p>";
+	echo "</div>";
+	
+	echo "<fieldset name=form1_field1_field1><legend>Link to Capabilities URL</legend>";
+	if (isset($xml_file)){
+		echo"<input type='text' name='xml_file' size='50' value='".$xml_file."'>";
+	}else{
+		echo"<input type='text' name='xml_file' size='50' value='http://'>";
+	}
+	echo"<input type='button' name='loadCap' value='Load Catalog' onClick='validate(\"guiList\")'>";
+	echo "</fieldset>";
+	echo "</fieldset>";
+	echo "</form>";
+}
+else{
+	echo "There are no guis available for this user. Please create a gui first.";
+}
+?>
+</body>
+</html>
\ No newline at end of file

Added: trunk/mapbender/http/php/mod_loadCatalogToGui.php
===================================================================
--- trunk/mapbender/http/php/mod_loadCatalogToGui.php	                        (rev 0)
+++ trunk/mapbender/http/php/mod_loadCatalogToGui.php	2009-12-12 10:14:51 UTC (rev 5152)
@@ -0,0 +1,272 @@
+<?php
+# $Id$
+# http://www.mapbender.org/index.php/Administration
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program 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.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+import_request_variables("PG");
+require(dirname(__FILE__)."/../php/mb_validatePermission.php");
+?>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+<head>
+<?php
+echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';	
+?>
+<title>Load WMS from Catalog</title>
+<?php
+include '../include/dyn_css.php';
+?>
+<style type="text/css">
+  	<!--
+  	body{
+      background-color: #ffffff;
+  		font-family: Arial, Helvetica, sans-serif;
+  		font-size : 12px;
+  		color: #808080
+  	}
+  	.list_guis{
+  		font-family: Arial, Helvetica, sans-serif;
+  		font-size : 12px;
+  		color: #808080;
+  	}
+	.text1{
+	   font-family: Arial, Helvetica, sans-serif;
+	   font-size : 15px;
+	   position:absolute;
+	   top:190px;
+	}
+	.select1{
+	   position:absolute;
+	   top:210px;
+	   width:270px;
+	}
+	.text2{
+	   font-family: Arial, Helvetica, sans-serif;
+	   font-size : 15px;
+	   position:absolute;
+	   top:190px;
+	   left:300px;
+	}
+	.select2{
+	   position:absolute;
+	   top:210px;
+	   left:300px;
+	}
+	.getcapabilities{
+	   font-family: Arial, Helvetica, sans-serif;
+	   font-size : 15px;
+	   position:absolute;
+	   top:570px;
+	}
+
+  	-->
+</style>
+<script language="JavaScript">
+function validate(vals){
+   if(vals == 'guiList'){
+      var listIndex = document.form1.guiList.selectedIndex;
+      if(listIndex<0){
+		   alert("Please select a GUI.");
+			return false;
+      }
+      else{
+         var gui_id=document.form1.guiList.options[listIndex].value;
+         	//LOAD CATALOG
+			document.form1.action='../php/mod_loadCatalog.php<?php echo SID;?>';
+			document.form1.submit();
+      }
+   }
+}
+function load(){
+      if(document.form1.guiList.selectedIndex<0){
+		   alert("Please Select a GUI.");
+			return false;
+      }
+      var gui_ind = document.form1.guiList.selectedIndex;
+      var ind = document.form1.catID.selectedIndex;
+      var ind2 = document.form1.guiID_.selectedIndex;
+			var indexCatList = document.form1.catID.selectedIndex;
+			var permission = true;
+
+			var selectedCatId = document.form1.catID.options[document.form1.catID.selectedIndex].value;
+			for (i = 0; i < document.form1.catList.length; i++) {
+						if (document.form1.catList.options[i].value == selectedCatId){
+							 permission = false;							 
+							 alert ('The Catalog (' + selectedCatId + ') is already loaded in this application.');
+							 break;
+						}
+			}			 
+			
+  			if (permission) { // only check if permission is not false 
+        	var loadConfirmed = confirm("Load " + document.form1.catID.options[ind].text + " FROM " + document.form1.guiID_.options[ind2].value + " INTO "+document.form1.guiList.options[gui_ind].value+" ?");
+
+            if(loadConfirmed){
+             document.form1.submit();
+          	}
+          	else{
+             	document.form1.guiID_.selectedIndex = -1;
+          	}
+		}	
+			
+}
+</script>
+</head>
+<body>
+
+<?php
+
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+$admin = new administration();
+$ownguis = $admin->getGuisByOwner($_SESSION["mb_user_id"],true);
+
+
+// insert values here
+if(isset($catID) && isset($guiID_)){
+	
+	$sql_ins = "INSERT INTO gui_cat (fkey_gui_id,fkey_cat_id) ";
+	$sql_ins .= "VALUES ($1,$2)";
+	$v = array($guiList,$catID);
+	$t = array('s','i');
+	db_prep_query($sql_ins,$v,$t);
+
+}
+
+echo "<form name='form1' action='" . $self."' method='post'>";
+
+echo "<table cellpadding='0' cellspacing='0' border='0'>";
+echo "<tr>";
+echo "<td>";
+if (count($ownguis)>0){
+	echo"GUI";
+	echo"<br/>";
+	 
+	$sql = "SELECT * FROM gui WHERE gui_id IN (";
+	$v = $ownguis;
+	$t = array();
+	for ($i = 1; $i <= count($ownguis); $i++){
+		if ($i > 1) { 
+			$sql .= ",";
+		}
+		$sql .= "$".$i;
+		array_push($t, "s");
+	}
+	$sql .= ") ORDER BY gui_name";	
+	$res = db_prep_query($sql, $v, $t);
+	$count=0;
+	echo"<select size='8' name='guiList' style='width:200px' onClick='submit()'>";
+	while($row = db_fetch_array($res)){
+		$gui_name[$count]=$row["gui_name"];
+		$gui_description[$count]=$row["gui_description"];
+		$count++;
+		echo "<option value='".$row["gui_id"]."' ";
+		if($guiList && $guiList == $row["gui_name"]){
+			echo "selected";
+		}
+		echo ">".$row["gui_name"]."</option>";
+	}
+	
+	$arrayGUIs=$_SESSION["mb_user_guis"];
+	echo count($arrayGUIs);
+	echo "</select><br/><br/>";
+	
+	echo "</td>";
+	echo "<td>";
+	echo "Catalog";
+	echo "<br/>";
+	if(isset($guiList) && $guiList!=""){
+		$sql = "SELECT DISTINCT cat_id, cat_title FROM gui_cat ";
+		$sql .= "JOIN gui ON gui_cat.fkey_gui_id = gui.gui_id JOIN cat ON gui_cat.fkey_cat_id=cat.cat_id ";
+		$sql .= "AND gui_cat.fkey_gui_id=gui.gui_id WHERE gui.gui_name = $1";
+		$v = array($guiList);
+		$t = array('s');
+		$res = db_prep_query($sql,$v,$t);	
+		$count=0;
+		echo"<select size='8' name='catList' style='width:200px'>";
+	
+		while($row = db_fetch_array($res)){
+			if ($row["cat_title"]!=""){
+				echo "<option value='".$row["cat_id"]."' ";
+				echo ">".$row["cat_title"]."</option>";
+			}
+			$count++;
+		}
+		echo "</select><br><br>";
+	}else{
+		echo"<select size='8' name='catList' style='width:200px' on Click='submit()'>";
+		echo "</select><br><br>";
+	}
+	echo "</td>";
+	echo "<tr></table><br>";
+	
+	echo"<div class='text1'>Load Catalog</div>";
+	$sql = "SELECT DISTINCT cat.cat_id,cat.cat_title,cat.cat_abstract,cat.cat_owner FROM gui_cat JOIN cat ON ";
+	$sql .= "cat.cat_id = gui_cat.fkey_cat_id WHERE gui_cat.fkey_gui_id IN(";
+	$v = $arrayGUIs;
+	$t = array();
+	for ($i = 1; $i <= count($arrayGUIs); $i++){
+		if ($i > 1) {
+			$sql .= ",";
+		}
+		$sql .= "$" . $i;
+		array_push($t, "s");
+	}
+	$sql .= ") ORDER BY cat.cat_title";
+	$res = db_prep_query($sql, $v, $t);
+	echo "<select class='select1' name='catID' size='20' onchange='submit()'>";
+	$cnt = 0;
+	while($row = db_fetch_array($res)){
+		echo "<option value='".$row["cat_id"]."' ";
+		if($row["cat_owner"] == $_SESSION["mb_user_id"]){
+			echo "style='color:green' ";	
+		}
+		else{
+			echo "style='color:red' ";
+		}
+		if(isset($catID) && $catID == $row["cat_id"]){
+			echo "selected";
+			$wms_getcapabilities = $row["wms_getcapabilities"];
+		}
+		echo ">".$row["cat_title"]."</option>";
+		$cnt++;
+	}
+	echo "</select>";
+	
+	if(isset($catID)){
+		echo "<div class='text2'>FROM:</div>";
+		$sql = "SELECT * from gui_cat WHERE fkey_cat_id = $1 ORDER BY fkey_gui_id";
+		$v = array($catID);
+		$t = array("s");
+		$res = db_prep_query($sql, $v, $t);
+		echo "<select class='select2' name='guiID_' size='20' onchange='load()'>";
+		$cnt = 0;
+		while($row = db_fetch_array($res)){
+			echo "<option value='".$row["fkey_gui_id"]."' ";
+			echo ">".$row["fkey_gui_id"]."</option>";
+			$cnt++;
+		}
+	echo "</select>";
+}
+echo "</form>";
+}else{
+	echo "There are no GUIs available for this user. Please create a GUI first.";
+}
+echo "<div class='getcapabilities'>" . $wms_getcapabilities . "</div>";
+?>
+</body>
+</html>
\ No newline at end of file

Added: trunk/mapbender/http/php/mod_searchCatQueryBuilder_server.php
===================================================================
--- trunk/mapbender/http/php/mod_searchCatQueryBuilder_server.php	                        (rev 0)
+++ trunk/mapbender/http/php/mod_searchCatQueryBuilder_server.php	2009-12-12 10:14:51 UTC (rev 5152)
@@ -0,0 +1,302 @@
+<?php
+# $Id$
+# http://www.mapbender.org/index.php/class_wms
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program 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.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../classes/class_connector.php");
+require_once(dirname(__FILE__)."/../php/mb_validateSession.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
+ * get get/post url for catalog
+ * construct query on url via get/xml
+ * make queries sequentially
+ * parse responses
+ * show responses with cat-name in results	
+ */
+
+$DEBUG_ = false;
+
+//Init Variables
+$userId = $_SESSION["mb_user_id"];
+$command = $_REQUEST["command"];
+$guiId = $_REQUEST["guiID"];
+$simplesearch = $_REQUEST['search'];
+$getrecords_type = $_REQUEST['getrecordsmedia'];
+$getrecords_query = $_REQUEST['getrecordsquery'];
+
+$admin = new administration();
+$guiIdArray = $admin->getGuisByPermission($userId, false);
+
+$resultObj = array();
+$resultObj['cats'] = array();
+
+if($DEBUG_)
+array_push($resultObj['cats'],array("id"=>'id',"title"=>'test'));
+
+if ($command == "getrecordssimple") {
+	//$resultObj["cats"] = array();
+	if($DEBUG_)
+	array_push($resultObj['cats'],array("id"=>'id2',"title"=>$getrecords_type));	
+	$catalogIDs = array();
+	
+	switch(mb_strtolower($getrecords_type)){
+		case 'get':
+			$guicats = get_catalogs_for_gui($guiId);
+			if($DEBUG_)
+			$guicats = array('13');
+			$catalogIDs = get_catalogs_by_supported_type($guicats,'getrecords','get');
+			//$catalogIDs = get_catalogs_by_supported_type(array(9,10),'getrecords','get');
+			//$catalogIDs['7']= 'ac';		
+			if($DEBUG_)
+				array_push($resultObj['cats'],array("id"=>'id35'.$guiId,"title"=>$guicats[0]));
+			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');
+	}
+	
+	//main controller
+	//loop for each catalog
+	foreach($catalogIDs as $catalog_id=>$url){
+		//$cat_obj = new csw();
+		//$cat_obj->createCatObjFromDB($catalogs);
+		//list($getrecordsurl,$getrecordsxml) = getrecords_get_build_query($url,$simplesearch);
+		list($getrecordsurl,$getrecordsxml) = getrecords_build_query($url,$getrecords_type,$command);
+		if($DEBUG_)
+		array_push($resultObj['cats'],array("id"=>$catalog_id,"title"=>$getrecordsurl));
+		//array_push($resultObj['cats'],array("title"=>$catalog_id.'url',"abstractt"=>$getrecordsurl));
+		//Create Record Objects
+		$RecordObj = new cswrecord();
+		$RecordObj->createCSWRecordFromXML($getrecordsurl,$getrecordsxml);
+		
+		//Populate JSON for each summary record for each catalog
+		//Loop for each Summary Record
+		foreach ($RecordObj->SummaryRecordsArray as $SummaryRecordObj){
+			$title = $SummaryRecordObj->getTitle();
+			$abstract = $SummaryRecordObj->getAbstract();
+		
+				array_push($resultObj['cats'],array("title"=>$title,"abstractt"=>$abstract));
+		}
+		
+	}
+}
+
+/**
+ * Build Query
+ * @param $getrecords_url
+ * @return array URL and XML
+ */
+function getrecords_build_query($getrecords_url,$type,$command){
+	
+	//CHECK FOR COMMAND, GET POST. HANDLE THINGS HERE
+	
+	$url = null;
+	$xml = null;
+	
+	$request = 'GetRecords';
+	$version = '2.0.2';
+	$resulttype = 'results';
+	$typename = 'csw:Record';
+	$service='CSW';
+	global $simplesearch;
+	
+	switch(strtolower($type)){
+		case 'get':
+			$url = $getrecords_url.'?request='.$request.'&service='.$service.'&ResultType='.$resulttype.'&TypeNames='.$typename.'&version='.$version;
+			if($command=='getrecordssimple'){
+				
+				//Simple GetRecords via GET
+				$tmpurl = "csw:AnyText Like '%$simplesearch%'";
+				$suburl = urlencode($tmpurl);
+				$aurl = "%$simplesearch%";
+				$aurl = urlencode($aurl);
+				$tmpurl = "csw:AnyText%20Like%20%27$aurl%27";
+				$url .= (isset($simplesearch) && $simplesearch!="")?'&constraintlanguage=CQLTEXT&constraint='.$tmpurl:'';
+				
+			}
+			else {
+				//Advanced GetRecords via GET
+				$url = getrecords_advanced_get($getrecords_url);
+			}
+			break;
+		case 'post':
+			$url = $getrecords_url;
+			$xml = build_getrecords_xml();
+			break;
+		case 'soap':
+			break;
+		default:
+			break;
+	}
+	
+	return array($url,$xml);
+}	
+
+function getrecords_advanced_get($url){
+	
+	$adv_title = $_REQUEST['adv_title'];
+	$adv_subject = $_REQUEST['adv_keyword'];
+	$adv_abstract = $_REQUEST['adv_abstract'];
+	$latmin = $_REQUEST['latmin'];
+	$latmax = $_REQUEST['latmax'];
+	$lonmin = $_REQUEST['lonmin'];
+	$lonmax = $_REQUEST['lonmax'];
+	
+	$url .= '&constraintlanguage=CQLTEXT&constraint=';
+	$query = '';
+	$query .= (isset($adv_title) && $adv_title!="")?"dc:Title Like %$adv_title%":'';
+	$query .= (isset($adv_abstract) && $adv_abstract!="")?"AND dc:Abstract Like %$adv_abstract%":'';
+	$query .= (isset($adv_subject) && $adv_subject!="")?"AND dc:Subject Like %$adv_subject%":'';
+	
+	$url = $url.urlencode($query);
+	return $url;
+}
+
+/**
+ * 
+ * @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;
+}
+
+/**
+ * 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.'&version='.$version;
+	//$url_encode = urlencode($url_encode);
+	
+	return array($url_encode,null);
+}
+
+/**
+ * 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){
+	
+				//array_push($resultObj['cats'],array("id"=>'id5',"title"=>$operation_type));
+	$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($DEBUG_)
+				array_push($resultObj['cats'],array("id"=>'id4',"title"=>$row));
+		if(in_array($row['fk_cat_id'],$cat_array,true)){
+			//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
+ */
+function build_getrecords_xml() {
+	$xml = '<?xml version="1.0" encoding="UTF-8"?>';
+	$xml .= '<GetRecords';
+	$xml .= 'service="CSW"';
+	$xml .= 'version="2.0.2"';
+	$xml .= 'maxRecords="5"';
+	$xml .= 'startPosition="1"';
+	$xml .= 'resultType="results"';
+	$xml .= 'outputFormat="application/xml"';
+	$xml .= 'outputSchema="http://www.opengis.net/cat/csw/2.0.2"';
+	$xml .= 'xmlns="http://www.opengis.net/cat/csw/2.0.2"';
+  	$xml .= 'xmlns:csw="http://www.opengis.net/cat/csw/2.0.2"';
+  	$xml .= 'xmlns:ogc="http://www.opengis.net/ogc"';
+  	$xml .= 'xmlns:ows="http://www.opengis.net/ows"';
+  	$xml .= 'xmlns:dc="http://purl.org/dc/elements/1.1/"';
+  	$xml .= 'xmlns:dct="http://purl.org/dc/terms/"';
+  	$xml .= 'xmlns:gml="http://www.opengis.net/gml"';
+  	$xml .= 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"';
+	$xml .= 'xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2/CSW-discovery.xsd">';
+	$xml .= '<Query typeNames="csw:Record">';
+	$xml .= '</Query>';
+	$xml .= '</GetRecords>';
+	
+	return $xml;
+	
+}
+
+
+function getrecords_post ($url, $postData) {
+	 	$connection = new connector();
+        $connection->set("httpType", "post");
+        $connection->set("httpContentType", "xml");
+        $connection->set("httpPostData", $postData);
+
+        $e = new mb_notice("CAT REQUEST: " . $url . "\n\n" . $postData);
+        $data = $connection->load($url);
+        if (!$data) {
+            $e = new mb_exception("CAT getrecords returned no result: " . $url . "\n" . $postData);
+            return null;
+        }
+        return $data;
+}
+
+
+
+$json = new Mapbender_JSON();
+$output = $json->encode($resultObj);
+echo $output;
+
+?>
\ No newline at end of file



More information about the Mapbender_commits mailing list