[Mapbender-commits] r5998 - in trunk/mapbender/http: classes
javascripts php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Apr 22 05:45:47 EDT 2010
Author: armin11
Date: 2010-04-22 05:45:43 -0400 (Thu, 22 Apr 2010)
New Revision: 5998
Added:
trunk/mapbender/http/javascripts/mod_deleteWfsConf_client.html
trunk/mapbender/http/php/mod_deleteWfsConf_server.php
Modified:
trunk/mapbender/http/classes/class_metadata_new.php
trunk/mapbender/http/php/mod_callMetadata.php
trunk/mapbender/http/php/mod_deleteWFS.php
trunk/mapbender/http/php/mod_metadataWrite.php
trunk/mapbender/http/php/mod_updateWMS.php
Log:
some new functions from geoportal.rlp
Modified: trunk/mapbender/http/classes/class_metadata_new.php
===================================================================
--- trunk/mapbender/http/classes/class_metadata_new.php 2010-04-21 15:37:42 UTC (rev 5997)
+++ trunk/mapbender/http/classes/class_metadata_new.php 2010-04-22 09:45:43 UTC (rev 5998)
@@ -1,1259 +1,890 @@
<?php
-#Script to call this class: http://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php
-#Class for getting results out of the mapbender service registry
-#Resulttypes: WMS, WMS-Layer, (WFS), WFS-Featurtyps, WFS-Conf, WMC, GeoRSS-Feeds, ...
-#Possible filters: registrating organizations, time, bbox (fully inside, intersects, fully outside), ISO Topic Categories, INSPIRE themes, INSPIRE: keywords, classification of data/service ... - maybe relevant for the german broker not for one instance, quality and actuality (maybe spatial and temporal), bbox, deegree of conformity with ir, access and use constraints, responsible parties - maybe one is enough? We must have a look at the INSPIRE Metadata IR
-#Metadata we need to fullfil the demands of INSPIRE:
-#1. INSPIRE conformity classification for WMS/WFS/WCS
-#2. Temporal Extents at WMS/WMS-Layer/WFS/WFS-Featuretype levels - for datasets if demanded - til now there is no demand defined in the guidance-paper for metadata ir
-#3. Classified access and use contraints - which classes? - Check IR Data Sharing and IR Metadata
-#4.
-#Every ressource which should be send to INSPIRE can be filtered - but is not neccessary for a standardized approach
-#Another problem is the ranking of the different ressources. The ranking should be homogeneus.
-#Till now we rank the using of WMS Layers when Caps are requested and when s.o. load one layer into the geoportal.
-#The same things have to be done for the wfs-conf, wmc and georssfeeds
-#The searching for metadata should be parallel done. We need different classes for doing the search. They should be requested by one central class (class_metadata.php).
-#Classes for filtering after the results have been send to the portal:
-#1. ISO Topic Categories
-#2. INSPIRE Themes
-#3. Access and use classification
-#4. departments which provides the ressources - we need the new concept for the administration of this departments - store the addresses in the group table and give the relation - originating group in table mb_user_mb_group
-#Cause we have a authorization layer, we need the id of the requesting user which is defined in the session. If no session is set, it should be the anonymous user of the portal.
-#We need a parameter for internationalization - it should be send with the search request! Some of the Classes can be provided with different languages.
-#WMC and GeoRSS-Feeds have no or a to complex authorization info - maybe we need to test if wmc consists of info which is fully or only partually available to the anonymous user.
-
+#http://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php?searchText=sozial&outputFormat=json&resultTarget=web&searchResources=wfs
+#http://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php?searchText=sozial+schwanger&outputFormat=json&resultTarget=web&searchResources=wfs®istratingDepartments=72
+#http://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php?searchText=sozial&outputFormat=json&resultTarget=web&searchResources=wms&
+#http://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php?searchText=niedersachsen&outputFormat=json&resultTarget=web&searchResources=wms&maxResults=50
+#http://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php?searchId=wal&searchText=wald&outputFormat=json&resultTarget=web&searchResources=wms&maxResults=10
+#http://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php?searchId=test&searchText=e,w&outputFormat=json®istratingDepartments=44,33,29,30,31,35,40,61,101,87&languageCode=en&resultTarget=web&searchResources=wms&maxResults=10
+#http://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php?searchId=45&searchText=e&outputFormat=json®istratingDepartments=44,33,29,30,31,35,40,61,101,87&languageCode=en&resultTarget=debug&searchResources=wms&maxResults=10&searchPages=1&isoCategories=10
+#http://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php?searchId=45&searchText=e&outputFormat=json®istratingDepartments=44,33,29,30,31,35,40,61,101,87&languageCode=en&resultTarget=debug&searchResources=wms&maxResults=20&searchPages=1&isoCategories=10,5
+#http://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php?searchId=wa&searchText=e&outputFormat=json&languageCode=de&resultTarget=debug&searchResources=wms&maxResults=10&isoCategories=10,5®istratingDepartments=44,31
+#http://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php?searchId=wa&searchText=e&outputFormat=json&languageCode=de&resultTarget=debug&searchResources=wms&maxResults=5®istratingDepartments=44,31&inspireThemes=11&isoCategories=5,10
+#http://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php?searchId=wa&searchText=e&outputFormat=json&languageCode=de&resultTarget=debug&searchResources=wms&maxResults=5®istratingDepartments=44,31&inspireThemes=11&isoCategories=5,10
+#http://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php?searchId=wa&searchText=e&outputFormat=json&languageCode=de&resultTarget=debug&searchResources=wms&maxResults=5®istratingDepartments=44,31&inspireThemes=11&isoCategories=5,10&searchBbox=7,48,9,51
+#http://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php?searchId=wa&searchText=e&outputFormat=json&languageCode=de&resultTarget=debug&searchResources=wms&maxResults=99®istratingDepartments=44,31,52&inspireThemes=11&isoCategories=5,10&searchBbox=7,48,9,51®TimeBegin=2001-12-24®TimeEnd=2020-10-10
+#http://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php?searchId=wa&outputFormat=json&languageCode=de&resultTarget=debug&searchResources=wms&maxResults=99®istratingDepartments=44,31,52&inspireThemes=11&isoCategories=5,10&searchBbox=7,48,9,51®TimeBegin=2001-12-24®TimeEnd=2020-10-10
require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
-require_once(dirname(__FILE__)."/class_administration.php");
-require_once(dirname(__FILE__)."/class_mb_exception.php");
-require_once(dirname(__FILE__)."/class_json.php");
+require_once(dirname(__FILE__)."/../../conf/geoportal.conf");
+require_once(dirname(__FILE__)."/../classes/class_metadata_new.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
+session_start();
+//initialize request parameters:
+$searchId = "dummysearch";
+$searchText = "e";
+#$registratingDepartments = "33,29,30,31,35,40,61,101,87,44";
+$registratingDepartments = NULL;
+#$isoCategories = "1,2,3";
+$isoCategories = NULL;
+$inspireThemes = NULL;
+$customCategories = NULL;
+$timeBegin = NULL;
+$timeEnd = NULL;
+$regTimeBegin = NULL;
+$regTimeEnd = NULL;
+$maxResults = 5;
+#$searchBbox = "-180.0,-90.0,180.0,90.0";
+$searchBbox = NULL;
+$searchTypeBbox = "intersects"; //outside / inside
+$accessRestrictions = "false";
+$languageCode = "de";
+$outputFormat = 'json';
+#$searchResources = "wms,wfs,wmc,georss";
+#$searchResources = "wms";
+$searchPages = "1";
+$resultTarget = "debug";
+$searchEPSG = "EPSG:31466";
+$classJSON = new Mapbender_JSON;
+#$tempFolder = "/tmp";
+$tempFolder = TMPDIR;
+$orderBy = "rank"; //rank or title or id
+$hostName = $_SERVER['HTTP_HOST'];
-//definition for the things which are common to all kind of metadata ressources
+//read the whole query string:
+$searchURL = $_SERVER['QUERY_STRING'];
-class searchMetadata {
- var $userId;
- var $searchId;
- var $searchText;
- var $registratingDepartments;
- var $isoCategories;
- var $inspireThemes;
- var $customCategories;
- var $timeBegin;
- var $timeEnd;
- var $regTimeBegin;
- var $regTimeEnd;
- var $maxResults;
- var $searchBbox;
- var $searchTypeBbox;
- var $accessRestrictions;
- var $languageCode;
- var $searchStartTime;
- var $searchView;
- var $searchURL;
- var $searchEPSG;
- var $searchResources;
- var $searchPages;
- var $outputFormat;
- var $resultTarget;
- var $tempFolder;
- var $orderBy;
+//control if some request variables are not set and set them explicit to NULL
- function __construct($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResources, $searchPages, $outputFormat, $resultTarget, $searchURL, $customCategories){
- $this->userId = (integer)$userId;
- $this->searchId = $searchId;
- $this->searchText = $searchText;
- $this->registratingDepartments = $registratingDepartments; //array with ids of the registrating groups in the mb database
- $this->registratingDepartmentsArray = explode(",",$this->registratingDepartments);
- $this->isoCategories = $isoCategories;
- $this->inspireThemes = $inspireThemes;
- $this->customCategories = $customCategories;
- $this->timeBegin = $timeBegin;
- $this->timeEnd = $timeEnd;
- $this->regTimeBegin = $regTimeBegin;
- $this->regTimeEnd = $regTimeEnd;
- $this->maxResults = (integer)$maxResults;
- $this->searchBbox = $searchBbox;
- $this->searchTypeBbox = $searchTypeBbox;
- $this->accessRestrictions = $accessRestrictions;
- $this->languageCode = $languageCode;
- $this->searchEPSG = $searchEPSG;
- $this->searchResources = $searchResources;
- $this->searchPages = $searchPages;
- $this->outputFormat = $outputFormat;
- $this->resultTarget = $resultTarget;
- $this->searchURL = $searchURL;
- $this->tempFolder = "/tmp"; //TODO define another path - maybe the one which is given in mapbender.conf
- if ($this->outputFormat == 'json'){
- $this->json = new Mapbender_JSON;
- }
- $this->accessableLayers = NULL;
- //set a time to find time consumers
- $this->searchStartTime = $this->microtime_float();
- //Defining of the different database categories
- $this->resourceClassifications = array();
- $this->resourceClassifications[0]['title'] = "ISO 19115"; //TODO: define the translations somewhere? - This is done in call_metadata.php before. Maybe we can get them from there? - It will be shown in the rightside categories table
- $this->resourceClassifications[0]['tablename'] = 'md_topic_category';
- $this->resourceClassifications[0]['requestName'] = 'isoCategories';
- $this->resourceClassifications[0]['id_wms'] = 'layer_id';
- $this->resourceClassifications[0]['id_wfs'] = 'featuretype_id';
- $this->resourceClassifications[0]['relation_wms'] = 'layer_md_topic_category';
- $this->resourceClassifications[0]['relation_wfs'] = 'featuretype_md_topic_category';//TODO: define this in mapbender
- $this->resourceClassifications[1]['title'] = "INSPIRE"; //TODO: define the translations somewhere? - This is done in call_metadata.php before. Maybe we can get them from there? - It will be shown in the rightside categories table
- $this->resourceClassifications[1]['tablename'] = 'inspire_category';
- $this->resourceClassifications[1]['requestName'] = 'inspireThemes';
- $this->resourceClassifications[1]['id_wms'] = 'layer_id';
- $this->resourceClassifications[1]['id_wfs'] = 'featuretype_id';
- $this->resourceClassifications[1]['relation_wms'] = 'layer_inspire_category';
- $this->resourceClassifications[1]['relation_wfs'] = 'featuretype_inspire_category';//TODO: define this in mapbender
+$checkForNullRequests = array("registratingDepartments","isoCategories","inspireThemes","customCategories","regTimeBegin","regTimeEnd","timeBegin","timeEnd","searchBbox","searchTypeBbox","searchResources","orderBy","hostName");
- $this->resourceClassifications[2]['title'] = "Custom"; //TODO: define the translations somewhere? - This is done in call_metadata.php before. Maybe we can get them from there? - It will be shown in the rightside categories table
- $this->resourceClassifications[2]['tablename'] = 'custom_category';
- $this->resourceClassifications[2]['requestName'] = 'customCategories';
- $this->resourceClassifications[2]['id_wms'] = 'layer_id';
- $this->resourceClassifications[2]['id_wfs'] = 'featuretype_id';
- $this->resourceClassifications[2]['relation_wms'] = 'layer_custom_category';
- $this->resourceClassifications[2]['relation_wfs'] = 'featuretype_custom_category';//TODO: define this in mapbender
+for($i=0; $i < count($checkForNullRequests); $i++){
+ if (!$_REQUEST[$checkForNullRequests[$i]] or $_REQUEST[$checkForNullRequests[$i]] == 'false' or $_REQUEST[$checkForNullRequests[$i]] == 'undefined') {
+ $_REQUEST[$checkForNullRequests[$i]] = "";
+ $searchURL = delTotalFromQuery($checkForNullRequests[$i],$searchURL);
+ }
+}
+//Read out request Parameter:
+if (isset($_REQUEST["searchId"]) & $_REQUEST["searchId"] != "") {
+ //gernerate md5 representation, cause the id is used as a filename later on! - no validation needed
+ $searchId = md5($_REQUEST["searchId"]);
+}
+if (isset($_REQUEST["searchText"]) & $_REQUEST["searchText"] != "") {
+ $test="(SELECT\s[\w\*\)\(\,\s]+\sFROM\s[\w]+)| (UPDATE\s[\w]+\sSET\s[\w\,\'\=]+)| (INSERT\sINTO\s[\d\w]+[\s\w\d\)\(\,]*\sVALUES\s\([\d\w\'\,\)]+)| (DELETE\sFROM\s[\d\w\'\=]+)";
+ //validate to csv integer list
+ $testMatch = $_REQUEST["searchText"];
+ $pattern = '/(\%27)|(\')|(\-\-)|(\")|(\%22)/';
+ if (preg_match($pattern,$testMatch)){
+ echo 'searchText: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ $searchText = $testMatch;
+ $testMatch = NULL;
+}
+if (isset($_REQUEST["registratingDepartments"]) & $_REQUEST["registratingDepartments"] != "") {
+ //validate to csv integer list
+ $testMatch = $_REQUEST["registratingDepartments"];
+ $pattern = '/^[\d,]*$/';
+ if (!preg_match($pattern,$testMatch)){
+ echo 'registratingDepartments: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ $registratingDepartments = $testMatch;
+ $testMatch = NULL;
+}
+if (isset($_REQUEST["isoCategories"]) & $_REQUEST["isoCategories"] != "") {
+ //validate to csv integer list
+ $testMatch = $_REQUEST["isoCategories"];
+ $pattern = '/^[\d,]*$/';
+ if (!preg_match($pattern,$testMatch)){
+ echo 'isoCategories: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ $isoCategories = $testMatch;
+ $testMatch = NULL;
+}
+if (isset($_REQUEST["inspireThemes"]) & $_REQUEST["inspireThemes"] != "") {
+ //validate to csv integer list
+ $testMatch = $_REQUEST["inspireThemes"];
+ $pattern = '/^[\d,]*$/';
+ if (!preg_match($pattern,$testMatch)){
+ echo 'inspireThemes: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ $inspireThemes = $testMatch;
+ $testMatch = NULL;
+}
- //Defining of the different result categories
- $this->resourceCategories = array();
- $this->resourceCategories[0]['name'] = 'WMS';
- $this->resourceCategories[1]['name'] = 'WFS';
- $this->resourceCategories[2]['name'] = 'WMC';
- $this->resourceCategories[3]['name'] = 'GeoRSS';
- switch($this->languageCode){
- case 'de':
- $this->resourceCategories[0]['name2show'] = 'Darstellungsdienste';
- $this->resourceCategories[1]['name2show'] = 'Such- und Downloaddienste';
- $this->resourceCategories[2]['name2show'] = 'Kartenzusammenstellungen';
- $this->resourceCategories[3]['name2show'] = 'Geokodierte Newsfeeds';
- break;
- case 'en':
- $this->resourceCategories[0]['name2show'] = 'Viewingservices';
- $this->resourceCategories[1]['name2show'] = 'Search- and Downloadservices';
- $this->resourceCategories[2]['name2show'] = 'Combined Maps';
- $this->resourceCategories[3]['name2show'] = 'Geocodet Newsfeeds';
- break;
- case 'fr':
- $this->resourceCategories[0]['name2show'] = 'Viewingservices';
- $this->resourceCategories[1]['name2show'] = 'Search- and Downloadservices';
- $this->resourceCategories[2]['name2show'] = 'Combined Maps';
- $this->resourceCategories[3]['name2show'] = 'Geocodet Newsfeeds';
- break;
- default:
- $this->resourceCategories[0]['name2show'] = 'Darstellungsdienste';
- $this->resourceCategories[1]['name2show'] = 'Such- und Downloaddienste';
- $this->resourceCategories[2]['name2show'] = 'Kartenzusammenstellungen';
- $this->resourceCategories[3]['name2show'] = 'Geokodierte Newsfeeds';
- }
- //not needed til now - maybe usefull for georss output
- if ($this->outputFormat == "xml") {
- //Initialize XML documents
- if (isset($this->searchResources) & strtolower($this->searchResources) === "wms") {
- $this->wmsDoc = new DOMDocument('1.0');
- }
- if (isset($this->searchResources) & strtolower($this->searchResources) === "wfs") {
- $this->wfsDoc = new DOMDocument('1.0');
- $this->generateWFSMetadata($this->wfsDoc);
- }
- if (isset($this->searchResources) & strtolower($this->searchResources) === "wmc") {
- $this->wmcDoc = new DOMDocument('1.0');
- }
- if (isset($this->searchResources) & strtolower($this->searchResources) === "georss") {
- $this->georssDoc = new DOMDocument('1.0');
- }
- }
-
- if ($this->outputFormat === "json") {
- if (isset($this->searchResources) & strtolower($this->searchResources) === "wfs") {
- $this->searchView = 'search_wfs_view';
- $this->orderBy = " ORDER BY wfs_id,featuretype_id,wfs_conf_id ";
- $this->resourceClasses = NULL;
- $this->generateWFSMetadata($this->wfsDoc);
- }
- if (isset($this->searchResources) & strtolower($this->searchResources) === "wms") {
- $this->searchView = 'wms_search_table_test';
- $this->orderBy = " ORDER BY load_count DESC";
- $this->resourceClasses = array(0,1,2);
- $this->generateWMSMetadata($this->wmsDoc);
- }
- }
+if (isset($_REQUEST["customCategories"]) & $_REQUEST["customCategories"] != "") {
+ //validate to csv integer list
+ $testMatch = $_REQUEST["customCategories"];
+ $pattern = '/^[\d,]*$/';
+ if (!preg_match($pattern,$testMatch)){
+ echo 'customCategories: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ $customCategories = $testMatch;
+ $testMatch = NULL;
+}
+if (isset($_REQUEST["timeBegin"]) & $_REQUEST["timeBegin"] != "") {
+ //validate to iso date format YYYY-MM-DD
+ $testMatch = $_REQUEST["timeBegin"];
+ $pattern = '/^(19|20)[0-9]{2}[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/';
+ if (!preg_match($pattern,$testMatch)){
+ echo 'timeBegin: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ $timeBegin = $testMatch;
+ $testMatch = NULL;
+}
+if (isset($_REQUEST["timeEnd"]) & $_REQUEST["timeEnd"] != "") {
+ $testMatch = $_REQUEST["timeEnd"];
+ $pattern = '/^(19|20)[0-9]{2}[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/';
+ if (!preg_match($pattern,$testMatch)){
+ echo 'timeEnd: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ $timeEnd = $testMatch;
+ $testMatch = NULL;
+}
+if (isset($_REQUEST["regTimeBegin"]) & $_REQUEST["regTimeBegin"] != "") {
+ //validate to iso date format YYYY-MM-DD
+ $testMatch = $_REQUEST["regTimeBegin"];
+ $pattern = '/^(19|20)[0-9]{2}[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/';
+ if (!preg_match($pattern,$testMatch)){
+ echo 'regTimeBegin: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ $regTimeBegin = $testMatch;
+ $testMatch = NULL;
+}
+if (isset($_REQUEST["regTimeEnd"]) & $_REQUEST["regTimeEnd"] != "") {
+ //validate to iso date format YYYY-MM-DD
+ $testMatch = $_REQUEST["regTimeEnd"];
+ $pattern = '/^(19|20)[0-9]{2}[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/';
+ if (!preg_match($pattern,$testMatch)){
+ echo 'regTimeEnd: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ $regTimeEnd = $testMatch;
+ $testMatch = NULL;
+}
+if (isset($_REQUEST["maxResults"]) & $_REQUEST["maxResults"] != "") {
+ //validate integer to 100 - not more
+ $testMatch = $_REQUEST["maxResults"];
+ //give max 99 entries - more will be to slow
+ $pattern = '/^([0-9]{0,1})([0-9]{1})$/';
+ if (!preg_match($pattern,$testMatch)){
+ echo 'maxResults: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ $maxResults = $testMatch;
+ $testMatch = NULL;
+}
+if (isset($_REQUEST["searchBbox"]) & $_REQUEST["searchBbox"] != "") {
+ //validate to float/integer
+ $testMatch = $_REQUEST["searchBbox"];
+ //$pattern = '/^[-\d,]*$/';
+ $pattern = '/^[-+]?([0-9]*\.[0-9]+|[0-9]+)*$/';
+ $testMatchArray = explode(',',$testMatch);
+ if (count($testMatchArray) != 4) {
+ echo 'searchBbox: <b>'.$testMatch.'</b> has a wrong amount of entries.<br/>';
+ die();
}
-
- private function microtime_float() {
- list($usec, $sec) = explode(" ", microtime());
- return ((float)$usec + (float)$sec);
+ for($i=0; $i<count($testMatchArray);$i++){
+ if (!preg_match($pattern,$testMatchArray[$i])){
+ echo 'searchBbox: <b>'.$testMatchArray[$i].'</b> is not a valid coordinate value.<br/>';
+ die();
+ }
}
- private function generateXMLHead($xmlDoc) {
- $xmlDoc->encoding = CHARSET;
- $result = $xmlDoc->createElement("result");
- $xmlDoc->appendChild($result);
- //Result Count
- $overLimit = $xmlDoc->createElement("overLimit");
- $result->appendChild($overLimit);
- //$tr_text = $xmlDoc->createTextNode($this->isOverLimit);
- $tr_text = $xmlDoc->createTextNode("really?");
- $overLimit->appendChild($tr_text);
- $rd = $xmlDoc->createElement("redirect");
- $result->appendChild($rd);
- $trd = $xmlDoc->createTextNode("not yet ready...");
- $rd->appendChild($trd);
- }
- private function generateXMLFoot($xmlDoc){
- $results = $xmlDoc->getElementsByTagName("result");
- foreach ($results as $result) {
- $result->appendChild($ready);
+ $searchBbox = $testMatch;
+ $testMatch = NULL;
+}
+if (isset($_REQUEST["searchTypeBbox"]) & $_REQUEST["searchTypeBbox"] != "") {
+ //validate to inside / outside - TODO implement other ones than intersects which is default
+ $testMatch = $_REQUEST["searchTypeBbox"];
+ if (!($testMatch == 'inside' or $testMatch == 'outside' or $testMatch == 'intersects')){
+ echo 'searchTypeBbox: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ #$searchTypeBbox = $testMatch; //TODO activate this
+ $testMatch = NULL;
+}
+if (isset($_REQUEST["accessRestrictions"]) & $_REQUEST["accessRestrictions"] != "") {
+ //validate to ?
+ #TODO implement me //$accessRestrictions = $_REQUEST["accessRestrictions"];
+}
+if (isset($_REQUEST["languageCode"]) & $_REQUEST["languageCode"] != "") {
+ //validate to de, en, fr
+ $testMatch = $_REQUEST["languageCode"];
+ if (!($testMatch == 'de' or $testMatch == 'en' or $testMatch == 'fr')){
+ echo 'languageCode: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ $languageCode = $testMatch;
+ $testMatch = NULL;
+}
+if (isset($_REQUEST["outputFormat"]) & $_REQUEST["outputFormat"] != "") {
+ $testMatch = $_REQUEST["outputFormat"];
+ if (!($testMatch == 'json' or $testMatch == 'georss')){
+ echo 'outputFormat: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ $outputFormat = $testMatch;
+ $testMatch = NULL;
+}
+if (isset($_REQUEST["hostName"]) & $_REQUEST["hostName"] != "") {
+ $testMatch = $_REQUEST["hostName"];
+ if (!($testMatch == 'www.geoportal.rlp' or $testMatch == 'www.geoportal.rlp.de' or $testMatch == 'geoportal.rlp' or $testMatch == '10.7.101.165' or $testMatch == 'localhost:16580' or $testMatch == 'localhost')){
+ echo 'hostName: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ $hostName = $testMatch;
+ $testMatch = NULL;
+}
+if (isset($_REQUEST["orderBy"]) & $_REQUEST["orderBy"] != "") {
+ $testMatch = $_REQUEST["orderBy"];
+ if (!($testMatch == 'rank' or $testMatch == 'title' or $testMatch == 'id')){
+ echo 'orderBy: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ $orderBy = $testMatch;
+ $testMatch = NULL;
+}// else {
+//$orderBy= 'rank';
+//}
+if (isset($_REQUEST["searchResources"]) & $_REQUEST["searchResources"] != "") {
+ //validate to wms,wfs,wmc,georss
+ $testMatch = $_REQUEST["searchResources"];
+ #$pattern = '/^(19|20)[0-9]{2}[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/';
+ $countSR = count(explode(',',$testMatch));
+ if (!($countSR >= 1 && $countSR <= 4)){
+ echo 'searchResources: <b>'.$testMatch.'</b> count of requested resources out of sync.<br/>';
+ die();
+ } else {
+ $testArray = explode(',',$testMatch);
+ for($i=0; $i<count($testArray);$i++){
+ if (!($testArray[$i] == 'wms' or $testArray[$i] == 'wfs' or $testArray[$i] == 'wmc' or $testArray[$i] == 'georss')) {
+ echo 'searchResources: <b>'.$testMatch.'</b>at least one of them does not exists!<br/>';
+ die();
+ }
}
+ unset($i);
}
- private function flipDiagonally($arr) {
- $out = array();
- foreach ($arr as $key => $subarr) {
- foreach ($subarr as $subkey => $subvalue) {
- $out[$subkey][$key] = $subvalue;
- }
- }
- return $out;
+ $searchResources = $testMatch;
+ $testMatch = NULL;
+}
+if (isset($_REQUEST["searchPages"]) & $_REQUEST["searchPages"] != "") {
+ //validate to csv integer list with dimension of searchResources list
+ $testMatch = $_REQUEST["searchPages"];
+ $pattern = '/^[-\d,]*$/';
+ if (!preg_match($pattern,$testMatch)){
+ echo 'searchPages: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ if (count(explode(',',$testMatch)) != count(explode(',',$searchResources))) {
+ echo 'searchPages: <b>'.$testMatch.'</b> has a wrong amount of entries.<br/>';
+ die();
}
+ $searchPages = $testMatch;
+ $testMatch = NULL;
+#$searchPages = $_REQUEST["searchPages"];
+ #$searchPages = split(',',$searchPages);
+
+}
+if (isset($_REQUEST["resultTarget"]) & $_REQUEST["resultTarget"] != "") {
+ //validate to web,debug,file
+ $testMatch = $_REQUEST["resultTarget"];
+ if (!($testMatch == 'web' or $testMatch == 'debug' or $testMatch == 'file')){
+ echo 'resultTarget: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ $resultTarget = $testMatch;
+ $testMatch = NULL;
+}
- private function generateWFSMetadataJSON($res, $n) {
- //initialize object
- $this->wfsJSON = new stdClass;
- $this->wfsJSON->wfs = (object) array(
- 'md' => (object) array(
- 'nresults' => $n,
- 'p' => $this->searchPages,
- 'rpp' => $this->maxResults
- ),
- 'srv' => array()
- );
-
- //read out records
- $serverCount = 0;
- $wfsMatrix = db_fetch_all($res);
- //sort result for accessing the right services
- $wfsMatrix = $this->flipDiagonally($wfsMatrix);
- //TODO check if order by db or order by php is faster!
- #array_multisort($wfsMatrix['wfs_id'], SORT_ASC,$wfsMatrix['featuretype_id'], SORT_ASC,$wfsMatrix['wfs_conf_id'], SORT_ASC); //have some problems - the database version is more stable
- #print_r($wfsMatrix);
- $wfsMatrix = $this->flipDiagonally($wfsMatrix);
- //read out first server entry - maybe this a little bit timeconsuming TODO
- $j = 0; //count identical wfs_id => double featuretype
- $l = 0; //index featuretype and or modul per wfs
- $m = 0; //index modul per featuretype
- for($i=0; $i<count($wfsMatrix);$i++){
- $this->wfsJSON->wfs->srv[$i-$j]->id = $wfsMatrix[$i]['wfs_id'];
- $this->wfsJSON->wfs->srv[$i-$j]->title = $wfsMatrix[$i]['wfs_title'];
- $this->wfsJSON->wfs->srv[$i-$j]->abstract = $wfsMatrix[$i]['wfs_abstract'];
- $this->wfsJSON->wfs->srv[$i-$j]->date = date("d.m.Y",$wfsMatrix[$i]['wfs_timestamp']);
- $this->wfsJSON->wfs->srv[$i-$j]->respOrg = $wfsMatrix[$i]['mb_group_name'];
- $this->wfsJSON->wfs->srv[$i-$j]->mdLink = $_SERVER['HOSTNAME']."/mapbender/x_geoportal/showWFSMetadata.php?id=".$wfsMatrix[$i]['wfs_id'];
- $spatialSource = "";
- $stateOrProvince = $wfsMatrix[$i]['administrativearea'];
- if ($stateOrProvince == "NULL" || $stateOrProvince == "") {
- $spatialSource = $wfsMatrix[$i]['country'];
- } else {
- $spatialSource = $wfsMatrix[$i]['administrativearea'];
- }
- $this->wfsJSON->wfs->srv[$i-$j]->iso3166 = $spatialSource;
- $this->wfsJSON->wfs->srv[$i-$j]->respOrg = $wfsMatrix[$i]['mb_group_name'];
- $this->wfsJSON->wfs->srv[$i-$j]->tou = $wfsMatrix[$i]['termsofuse'];
- //TODO check the field accessconstraints - which should be presented?
- $this->wfsJSON->wfs->srv[$i-$j]->status = NULL; //$wfsMatrix[$i][''];
- $this->wfsJSON->wfs->srv[$i-$j]->avail = NULL; //$wfsMatrix[$i][''];
- $this->wfsJSON->wfs->srv[$i-$j]->logged = NULL; //$wfsMatrix[$i][''];
- $this->wfsJSON->wfs->srv[$i-$j]->price = NULL; //$wfsMatrix[$i][''];
- $this->wfsJSON->wfs->srv[$i-$j]->nwaccess = NULL; //$wfsMatrix[$i][''];
- $this->wfsJSON->wfs->srv[$i-$j]->bbox = array(-180.0,-90.0,180.0,90.0); //$wfsMatrix[$i][''];
- //if featuretype hasn't been created - do it
- if (!isset($this->wfsJSON->wfs->srv[$i-$j]->ftype)) {
- $this->wfsJSON->wfs->srv[$i-$j]->ftype = array();
- }
- //fill in featuretype infos
- $this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->id = (integer)$wfsMatrix[$i]['featuretype_id'];
- $this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->title = $wfsMatrix[$i]['featuretype_title'];
- $this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->abstract = $wfsMatrix[$i]['featuretype_abstract'];
- $this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->mdLink = $_SERVER['HOST']."/mapbender/x_geoportal/showWFeatureTypeMetadata.php?id=".$wfsMatrix[$i]['featuretype_id'];
- $this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->geomtype = $wfsMatrix[$i]['element_type'];
- $this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->bbox = array(-180.0,-90.0,180.0,90.0);//TODO: $wfsMatrix[$i]['bbox'];
- //fill in categories
- if (!isset($this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->cat)) {
- $this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->cat = array();
- }
- if (isset($wfsMatrix[$i]['iso_categories'])) {
- }
- //if (isset($wfsMatrix[$i]['inspire_category'])) {
- //TODO write the categories as JSON into Database!
- $this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->cat[0]->type = 'INSPIRE Kategorie';
- $this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->cat[0]->value = 'Umwelt';
- $this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->cat[0]->symbol = 'umwelt.png';
- //}
- if (isset($wfsMatrix[$i]['custom_categories'])) {
- }
- //if modul hasn't been created - do it
- if (!isset($this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->modul)) {
- $this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->modul = array();
- }
- //fill in modul infos
- $this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->modul[$m]->id = $wfsMatrix[$i]['wfs_conf_id'];
- $this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->modul[$m]->title = $wfsMatrix[$i]['wfs_conf_description'];
- $this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->modul[$m]->abstract = $wfsMatrix[$i]['wfs_conf_abstract'];
- $this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->modul[$m]->type = $wfsMatrix[$i]['modultype'];
- $equalEPSG = $wfsMatrix[$i]['featuretype_srs'];
- $isEqual = "true";
- //control if EPSG is supported by Client
- if ($equalEPSG == $this->searchEPSG){
- $isEqual = "false";
- }
- $this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->modul[$m]->srsProblem = $isEqual;
- //generate Link to show metadata
- $this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->modul[$m]->mdLink = $_SERVER['HOST']."/mapbender/x_geoportal/showWFSConfMetadata.php?id=".$wfsMatrix[$i]['wfs_conf_id'];
- $perText = $this->getPermissionValueForWFS($wfsMatrix[$i]['wfs_id'], $wfsMatrix[$i]['wfs_conf_id']);
- $this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->modul[$m]->permission = $perText;
- if ($wfsMatrix[$i]['wfs_id'] == $wfsMatrix[$i+1]['wfs_id']){
- $j++; //next record is the same service
- $l++;
- }
- else
- {
- $l = 0;
- }
+if (isset($_REQUEST["userId"]) & $_REQUEST["userId"] != "") {
+ //validate integer to 100 - not more
+ $testMatch = $_REQUEST["userId"];
+ //give max 99 entries - more will be to slow
+ $pattern = '/^[0-9]*$/';
+ if (!preg_match($pattern,$testMatch)){
+ echo 'userId: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ $userId = $testMatch;
+ $testMatch = NULL;
+} else {
- if ($wfsMatrix[$i]['featuretype_id'] == $wfsMatrix[$i+1]['featuretype_id']){
- $m++;
- }
- else
- {
- $m = 0;
- }
- }
-
- }
- private function generateWMSMetadataJSON($res, $n) {
- //initialize object
- $this->wmsJSON = new stdClass;
- $this->wmsJSON->wms = (object) array(
- 'md' => (object) array(
- 'nresults' => $n,
- 'p' => $this->searchPages,
- 'rpp' => $this->maxResults
- ),
- 'srv' => array()
- );
- //read out records
- $serverCount = 0;
- $wmsMatrix = db_fetch_all($res);
- $layerIdArray = array();
- //read out array with unique wms_ids in wmsMatrix
- $wmsIdArray = array();
- //initialize root layer id;
- $rootLayerId = -1;
- $j = 0;
- //get array with all available layer_id for this user:
- $admin = new administration();
- $this->accessableLayers = $admin->getLayersByPermission($this->userId);
- #echo "<br>user_id: ".$this->userId."<br><br>";
- #var_dump($this->accessableLayers);
- #echo "<br>";
-
- #$countWmsMatrix = count($wmsMatrix);
- #echo $countWmsMatrix;
- if ($n != 0) {
- for($i=0; $i<count($wmsMatrix);$i++){
- $layerID = $wmsMatrix[$i]['layer_id'];
- #echo "<br>LayerID: ".$layerID."<br>";
- #$wmsID = $wmsMatrix[$i]['wms_id']; //get first wms id - in the next loop - dont get second, but some else!
- if (!in_array($layerID, $layerIdArray) or !in_array($rootLayerId, $layerIdArray)) {
- $wmsID = $wmsMatrix[$i]['wms_id']; //get first wms id - in the next loop - dont get second, but some else!
- //Select all layers of with this wms_id into new array per WMS - the grouping should be done by wms!
- $subLayers = $this->filter_by_value($wmsMatrix, 'wms_id', $wmsID);
- #echo "<br>wms_id: ".$wmsID."<br>";
- #echo "<br>Number of sublayers: <br>";
- #print(count($subLayers));
- //Sort array by load_count - problem: maybe there are some groups between where count is to low (they have no load count because you cannot load them by name)? - Therefor we need some ideas - or pull them out of the database and show them greyed out. Another way will be to define a new group (or wms with the same id) for those layers which are more than one integer away from their parents
- $subLayersFlip = $this->flipDiagonally($subLayers);
- #var_dump($subLayers['layer_pos']);
- #$subLayers = $this->flipDiagonally($subLayers);
- //go backwards through the layerTree to get the layer with the highest position without gaps in between
- #var_dump($subLayers['layer_id']);
- #echo "<br>";
- $index = array_search($layerID, $subLayersFlip['layer_id']);
- #echo "<br>found layer_id= ".$layerID." at index: ".$index." in sublayerstable layer_pos=".$subLayers[$index]['layer_pos']." <br>";
-
- #echo "<br>sublayers: ";
- #var_dump($subLayersFlip);
- #echo "<br>";
- $rootIndex = $this->getLayerParent($subLayersFlip, $index);
- $rootLayerPos = $subLayers[$rootIndex]['layer_pos'];
- $rootLayerId = $subLayers[$rootIndex]['layer_id'];
- #echo "<br>root layer for this layer: <br>";
- #echo "<br>id= "..""
- #echo "<br>";
- #echo "<br>LayerId:<br>";
- #echo "<br>".$layerID."<br>";
- #echo "<br>rootLayerPos:<br>";
- #echo "<br>".$rootLayerPos."<br>";
- #echo "<br>rootLayerId:<br>";
- #echo "<br>".$rootLayerId."<br>";
- //push root layer id in array
- array_push($layerIdArray, $rootLayerId);
-
- #echo "<br>root Layer ID: ".$rootLayerId."<br>";
- #array_multisort($subLayers['layer_pos'], SORT_ASC);
- #print_r($subLayers);
- #$subLayers = $this->flipDiagonally($subLayers);
- #print_r("<br>rootIndex: ".$rootIndex."<br>");
- //Create object for wms service level
- $this->wmsJSON->wms->srv[$j]->id = (integer)$subLayers[$rootIndex]['wms_id'];
- $this->wmsJSON->wms->srv[$j]->title = $subLayers[$rootIndex]['wms_title'];
- $this->wmsJSON->wms->srv[$j]->abstract = $subLayers[$rootIndex]['wms_abstract'];
- $this->wmsJSON->wms->srv[$j]->date = date("d.m.Y",$subLayers[$rootIndex]['wms_timestamp']);
- $this->wmsJSON->wms->srv[$j]->respOrg = $subLayers[$rootIndex]['mb_group_name'];
- $this->wmsJSON->wms->srv[$j]->loadCount = (integer)$subLayers[$rootIndex]['load_count'];
- $this->wmsJSON->wms->srv[$j]->mdLink = "http://".$_SERVER['HTTP_HOST']."/mapbender/x_geoportal/mod_layerMetadata.php?id=".$rootLayerId;
- $spatialSource = "";
- $stateOrProvince = $wmsMatrix[$i]['administrativearea'];
- if ($stateOrProvince == "NULL" || $stateOrProvince == "") {
- $spatialSource = $wmsMatrix[$i]['country'];
- } else {
- $spatialSource = $wmsMatrix[$i]['administrativearea'];
- }
- $this->wmsJSON->wms->srv[$j]->iso3166 = $spatialSource;
- $this->wmsJSON->wms->srv[$j]->respOrg = $subLayers[$rootIndex]['mb_group_name'];
- $this->wmsJSON->wms->srv[$j]->tou = $subLayers[$rootIndex]['termsofuse'];
- //TODO check the field accessconstraints - which should be presented?
- $this->wmsJSON->wms->srv[$j]->status = $subLayers[$rootIndex]['status']; //$wmsMatrix[$i][''];
- $this->wmsJSON->wms->srv[$j]->avail = $subLayers[$rootIndex]['availability']; //$wmsMatrix[$i][''];
- //get info about defined price
- if ($subLayers[$rootIndex]['wms_pricevolume'] == '' OR $subLayers[$rootIndex]['wms_pricevolume'] == 0){
- $this->wmsJSON->wms->srv[$j]->price = NULL;
- }
- else {
- $this->wmsJSON->wms->srv[$j]->price = $subLayers[$rootIndex]['wms_pricevolume'];
- }
- //get info about logging of resource
- if ($subLayers[$rootIndex]['wms_proxylog'] == NULL OR $subLayers[$rootIndex]['wms_proxylog'] == 0){
- $this->wmsJSON->wms->srv[$j]->logged = false;
- }
- else {
- $this->wmsJSON->wms->srv[$j]->logged = true;
- }
- //get info about network_accessability
- if ($subLayers[$rootIndex]['wms_network_access'] == NULL OR $subLayers[$rootIndex]['wms_network_access'] == 0){
- $this->wmsJSON->wms->srv[$j]->nwaccess = false;
- }
- else {
- $this->wmsJSON->wms->srv[$j]->nwaccess = true;
- }
+if (!isset($_SESSION['mb_user_id']) ) {
+ $userId = ANONYMOUS_USER;
+}
+else
+{
+ $userId = $_SESSION['mb_user_id'];
+}
- $this->wmsJSON->wms->srv[$j]->logged = NULL; //$wmsMatrix[$i][''];
- $this->wmsJSON->wms->srv[$j]->price = NULL; //$wmsMatrix[$i][''];
- $this->wmsJSON->wms->srv[$j]->nwaccess = NULL; //$wmsMatrix[$i][''];
- $this->wmsJSON->wms->srv[$j]->bbox = $subLayers[$rootIndex]['bbox']; //$wmsMatrix[$i][''];
- //Call recursively the child elements, give and pull $layerIdArray to push the done elements in the array to avoid double results
- #print_r($subLayers);
- //generate the layer-entry for the so called root layer - maybe this is only a group layer if there is a gap in the layer hierachy
- $this->wmsJSON->wms->srv[$j]->layer = array();
- $this->wmsJSON->wms->srv[$j]->layer[0]->id = (integer)$subLayers[$rootIndex]['layer_id'];
- $this->wmsJSON->wms->srv[$j]->layer[0]->title = $subLayers[$rootIndex]['layer_title'];
- $this->wmsJSON->wms->srv[$j]->layer[0]->abstract = $subLayers[$rootIndex]['layer_abstract'];
- if ($subLayers[$rootIndex]['layer_name'] == ''){
- $this->wmsJSON->wms->srv[$j]->layer[0]->loadable = 0;
- }
- else {
- $this->wmsJSON->wms->srv[$j]->layer[0]->loadable = 1;
- }
- if ($subLayers[$rootIndex]['layer_pos'] == '0'){
- $this->wmsJSON->wms->srv[$j]->layer[0]->isRoot = true;
- }
- else {
- $this->wmsJSON->wms->srv[$j]->layer[0]->isRoot = false;
- }
- //give info for inspire categories - not relevant for other services or instances of mapbender TODO: comment it if the mapbender installation is not used to generate inspire output
- if ($subLayers[$rootIndex]['md_inspire_cats'] == ''){
- $this->wmsJSON->wms->srv[$j]->layer[0]->inspire = 0;
- }
- else {
- $this->wmsJSON->wms->srv[$j]->layer[0]->inspire = 1;
- }
- //get info about queryable or not
- if ($subLayers[$rootIndex]['layer_queryable'] == 1){
- $this->wmsJSON->wms->srv[$j]->layer[0]->queryable = 1;
- }
- else {
- $this->wmsJSON->wms->srv[$j]->layer[0]->queryable = 0;
- }
-
- #if ($subLayers[$rootIndex]['layer_name'] == ''){
- # $this->wmsJSON->wms->srv[$i-$j]->layer[0]->loadable = 0;
- #}
- #else {
- # $this->wmsJSON->wms->srv[$i-$j]->layer[0]->loadable = 1;
- #}
- $this->wmsJSON->wms->srv[$j]->layer[0]->loadCount = $subLayers[$rootIndex]['load_count'];
- #$servObject->layer[$countsublayer]->mdLink = $_SERVER['HOST']."/mapbender/x_geoportal/showWFeatureTypeMetadata.php?id=".$wfsMatrix[$i]['featuretype_id'];
- #$servObject->layer[$countsublayer]->geomtype = $wfsMatrix[$i]['element_type'];
- $this->wmsJSON->wms->srv[$j]->layer[0]->bbox = $subLayers[$rootIndex]['bbox'];
- $this->wmsJSON->wms->srv[$j]->layer[0]->permission = $this->getPermissionValueForLayer($subLayers[$rootIndex]['layer_id'], $subLayers[$rootIndex]['wms_id']); //TODO: Make this much more faster
- //when the entry for the first server has been written, the server entry is fixed and the next one will be a new server or a part of the old one.
- //increment server (highest object id)
-
- $layerIdArray = $this->writeWMSChilds($layerIdArray, $rootLayerPos, $subLayers, $this->wmsJSON->wms->srv[$j]->layer[0]);
- $j++;
- //generate php object - if root layer was found - > layer_parent='' give hint to visualize folder symbol.
- }
- }
- }
+}
+
+
+
+#$searchResources = array('wms','wfs','wmc','georss');
+#$searchPages = array(1,1,1,1);
+
+//TODO: if class is called directly
+
+
+
+
+
+
+
+
+
+
+
+
+if ($resultTarget == 'debug') {
+ echo "<br>DEBUG: searchURL: ".$searchURL."<br>";
+ #echo "<br>DEBUG: languageCode: ".$languageCode."<br>";
+}
+
+
+if ($resultTarget == 'file') {
+ if (!isset($searchResources) OR ($searchResources == "")) {
+ $searchResources = "wms,wfs";
+ $searchPages = "1,1";
}
- private function generateWMSMetadata($xmlDoc) {
- $starttime = $this->microtime_float();
- list($sql, $v, $t, $n) = $this->generateSearchSQL();
- //call database search in limits
- $res = db_prep_query($sql, $v, $t);
- if ($this->outputFormat == 'json'){
- //generate json
- $this->generateWMSMetadataJSON($res,$n);
- $usedTime = $this->microtime_float() - $starttime;
- //put in the time to generate the data
- $this->wmsJSON->wms->md->genTime = $usedTime;
- $this->wmsJSON = $this->json->encode($this->wmsJSON);
- if ($this->resultTarget == 'file') {
- if($wmsFileHandle = fopen($this->tempFolder."/".$this->searchId."_".$this->searchResources."_".$this->searchPages.".json","w")){
- fwrite($wmsFileHandle,$this->wmsJSON);
- fclose($wmsFileHandle);
- }
- }
- if ($this->resultTarget == 'web' or $this->resultTarget == 'debug') {
- echo $this->wmsJSON;
- }
- }
- $usedTime2 = $this->microtime_float() - $starttime;
- //echo "<br>used time: ".$usedTime."<br>";
- $e = new mb_exception("Time to generate WMS-Metadata: ".$usedTime2);
- $e = new mb_exception("Wrote the MD_WMS-File");
+}
+if ($resultTarget == 'web' or $resultTarget == 'debug') {
+ if (!isset($searchResources) OR ($searchResources == "")) {
+ $searchResources = "wms";
+ $searchPages = "1";
}
+}
+//convert the respources and the pagenumbers into arrays
+$searchResources = explode(",",$searchResources);
+$searchPages = explode(",",$searchPages);
- private function generateWFSMetadata($xmlDoc) {
- $starttime = $this->microtime_float();
- list($sql, $v, $t, $n) = $this->generateSearchSQL();
- //call database search
- $res = db_prep_query($sql, $v, $t);
- if ($this->outputFormat == 'json'){
- //generate json
- $this->generateWFSMetadataJSON($res, $n);
- $this->wfsJSON = $this->json->encode($this->wfsJSON);
- if ($this->resultTarget == 'file') {
- if($wfsFileHandle = fopen($this->tempFolder."/".$this->searchId."_".$this->searchResources."_".$this->searchPages.".json","w")){
- fwrite($wfsFileHandle,$this->wfsJSON);
- fclose($wfsFileHandle);
- }
+//Generate search filter file. This file holds the defined search filter to allow the user to see how he searched
+//The user should become the possibility to drop the search filters by clicking in some buttons
+//list of options to display:
+//searchText (textfields) - dropping only if more than one text is given
+//registratingDepartments (list) - dropping allowed - maybe give a webservice for mb_group data
+//isoCategories - dropping allowed
+//inspireThemes - dropping allowed
+//customCategories - dropping allowed
+//bbox (show) - dropping allowed
+//regTimeBegin - dropping allowed
+//regTimeEnd -dropping allowed
+//the idea is, to rewrite the searchURL directly and then have another url for the special case!
+//we have to get the searchURL as a parameter for this wrapper cause the class_metadata should give filters for the found categories
+//use regular expressions to do this!
+
+//define internationalization
+//searchText
+//registratingDepartments
+//bbox
+
+//generate query json:
+//some objects like names of categories and other objects have to be pulled of the database. Maybe a webservice is the better way? But now there are no webservices - therefor: pull the names out of the database into arrays - only those who are requested:
+
+//function to get the information about the registrating departments (mb_groups) out of the mapbender database
+function get_registratingDepartmentsArray($departmentIds,$languageCode) {
+ $sql = "SELECT mb_group_id, mb_group_name FROM mb_group WHERE mb_group_id IN (";
+ $v = array();
+ $t = array();
+ $departmentsArray = array();
+ for($i=0; $i<count($departmentIds);$i++){
+ if($i > 0){$sql .= ",";}
+ $sql .= "$".strval($i+1);
+ array_push($v,$departmentIds[$i]);
+ array_push($t,"i");
}
- if ($this->resultTarget == 'web'or $this->resultTarget == 'debug') {
- echo $this->wfsJSON;
+ $sql .= ")";
+ $res = db_prep_query($sql,$v,$t);
+ $countDepArray = 0;
+ while($row = db_fetch_array($res)){
+ $departmentsArray[$countDepArray]["id"] = $row["mb_group_id"];
+ $departmentsArray[$countDepArray]["name"] = $row["mb_group_name"];
+ $departmentsArray[$countDepArray]["showScript"] = "../php/mod_showRegistratingGroup.php?";
+ $countDepArray = $countDepArray + 1;
}
+ return $departmentsArray;
}
- if ($this->outputFormat == 'xml'){
- //generate xml
- $this->generateXMLHead($xmlDoc);
- $this->generateXMLFoot($xmlDoc);
- $this->generateWFSResultXML($xmlDoc,$res);
- if ($this->resultTarget == 'file') {
- if($wfsFileHandleXML = fopen($this->tempFolder."/".$this->searchId."_".$this->searchResources."_".$this->searchPages.".xml","w")){
- fwrite($wfsFileHandleXML,$xmlDoc->saveXML());
- fclose($wfsFileHandleXML);
- }
+
+//get the information about the requested isoCategories
+function get_isoCategoriesArray($isoCategoryIds,$languageCode) {
+
+ $sql = "SELECT md_topic_category_id, md_topic_category_code_".$languageCode;
+ #$e = new mb_exception("php/mod_callMetadata.php: language code: ".$languageCode);
+ $sql .= " FROM md_topic_category WHERE md_topic_category_id IN (";
+ $v = array();
+ $t = array();
+ $isoCategoryArray = array();
+ for($i=0; $i<count($isoCategoryIds);$i++){
+ if($i > 0){$sql .= ",";}
+ $sql .= "$".strval($i+1);
+ array_push($v,$isoCategoryIds[$i]);
+ array_push($t,"i");
}
- if ($this->resultTarget == 'web') {
- header("Content-type: application/xhtml+xml; charset=UTF-8");
- echo $xmlDoc->saveXML();
+ $sql .= ")";
+ #$e = new mb_exception("php/mod_callMetadata.php: sql for getting topic cats: ".$sql);
+ $res = db_prep_query($sql,$v,$t);
+ $countIsoArray = 0;
+ while($row = db_fetch_array($res)){
+ $isoCategoryArray[$countIsoArray]["id"] = $row["md_topic_category_id"];
+ $isoCategoryArray[$countIsoArray]["name"] = $row["md_topic_category_code_".$languageCode];
+ $countIsoArray = $countDepArray + 1;
}
+ return $isoCategoryArray;
}
- $usedTime = $this->microtime_float() - $starttime;
- $e = new mb_exception("Time to generate WFS-Metadata: ".$usedTime);
- $e = new mb_exception("Wrote the MD_WFS-File");
- }
- private function replaceChars_all($text){
- $search = array( "ä", "ö", "ü", "Ä", "Ö", "Ü", "ß");
- $repWith = array("ae", "oe", "ue", "AE", "OE", "UE", "ss");
- $replaced = str_replace($search, $repWith, $text);
- return $replaced;
- }
- private function generateSearchSQL() {
- //elements needed to exist in mb wfs view or table:
- //1. textfield - all texts - searchText
- //2. responsible organisations - given id
- //3. bbox - is not explicit given in the wfs metadata? Since WFS 1.1.0 a latlonbbox is present
- //4. isoTopicCategory - is not been saved til now
- //5. ...
- //parse searchText into different array elements to allow an AND search
- $searchStringArray = $this->generateSearchStringArray();
- $v = array();
- $t = array();
- $sql = "SELECT * from ".$this->searchView." where ";
- #$sqlN = "SELECT count(".$this->searchResources."_id) from ".$this->searchView." where ";
- $whereStr = "";
- $whereCondArray = array();
- $isTextSearch = "false";
- $e = new mb_exception("Number of used searchstrings: ".count($searchStringArray));
- //textsearch
- if ($this->searchText != NULL) {
- for($i=0; $i < count($searchStringArray); $i++){
- $isTextSearch = "true";
- if($i>0) {
- $whereStr .= " AND ";
- }
- $whereStr .= "searchtext LIKE $".($i+1);
- //output for debugging
- $e = new mb_notice("Part of string".$i.": ".$searchStringArray[$i]);
- $e = new mb_notice("converted: ".$this->replaceChars_all($searchStringArray[$i]));
- $va = "%".trim(strtoupper($this->replaceChars_all($searchStringArray[$i])))."%";
- $e = new mb_notice($this->searchResources." Searchtext in SQL: ".$va);
- array_push($v,$va);
- array_push($t,"s");
+
+//get the information about the inspireThemes
+function get_inspireThemesArray($inspireThemesIds,$languageCode) {
+ $sql = "SELECT inspire_category_id, inspire_category_code_".$languageCode." FROM inspire_category WHERE inspire_category_id IN (";
+ $v = array();
+ $t = array();
+ $inspireCategoryArray = array();
+ for($i=0; $i<count($inspireThemesIds);$i++){
+ if($i > 0){$sql .= ",";}
+ $sql .= "$".strval($i+1);
+ array_push($v,$inspireThemesIds[$i]);
+ array_push($t,"i");
}
+ $sql .= ")";
+ $e = new mb_exception("php/mod_callMetadata.php: sql for getting inspire cats: ".$sql);
+ $res = db_prep_query($sql,$v,$t);
+ $countInspireArray = 0;
+ while($row = db_fetch_array($res)){
+ $inspireCategoryArray[$countInspireArray]["id"] = $row["inspire_category_id"];
+ $inspireCategoryArray[$countInspireArray]["name"] = $row["inspire_category_code_".$languageCode];
+ $countInspireArray = $countInspireArray + 1;
+ }
+ return $inspireCategoryArray;
}
-/* This is only for the later postgis versions. The within and disjoint is to slow, cause there is no usage of the geometrical index in the old versions!
- //spatial search filter - ist should be the first filter in the where clause, cause it is
- //
- if (strtolower($this->searchResources) === "wms" & $this->searchBbox != NULL) {
- #$spatialFilter = "(the_geom ";
- #echo "<br> spatial operator: ".$this->searchTypeBbox."<br>";
- if ($this->searchTypeBbox == 'outside') {
- $spatialFilter = ' disjoint(';
- } elseif ($this->searchTypeBbox == 'inside') {
- $spatialFilter = ' within(';
- } else {
- $spatialFilter = ' intersects(';
+
+function get_customCategoriesArray($customCategoriesIds,$languageCode) {
+ $sql = "SELECT custom_category_id, custom_category_code_".$languageCode." FROM custom_category WHERE custom_category_id IN (";
+ $v = array();
+ $t = array();
+ $customCategoryArray = array();
+ for($i=0; $i<count($customCategoriesIds);$i++){
+ if($i > 0){$sql .= ",";}
+ $sql .= "$".strval($i+1);
+ array_push($v,$customCategoriesIds[$i]);
+ array_push($t,"i");
}
- //define spatial filter
- if(count(explode(',',$this->searchBbox)) == 4){ //if searchBbox has 4 entries
-
- $spatialFilterCoords = explode(',',$this->searchBbox);//read out searchBbox
- //definition of the spatial filter
- $spatialFilter .= 'GeomFromText(\'POLYGON(('.$spatialFilterCoords[0];//minx
- $spatialFilter .= ' '.$spatialFilterCoords[1].',';//miny
- $spatialFilter .= $spatialFilterCoords[0];//minx
- $spatialFilter .= ' '.$spatialFilterCoords[3].',';//maxy
- $spatialFilter .= $spatialFilterCoords[2];//maxx
- $spatialFilter .= ' '.$spatialFilterCoords[3].',';//maxy
- $spatialFilter .= $spatialFilterCoords[2];//maxx
- $spatialFilter .= ' '.$spatialFilterCoords[1].',';//miny
- $spatialFilter .= $spatialFilterCoords[0];//minx
- $spatialFilter .= ' '.$spatialFilterCoords[1].'))\',4326)';//miny
- $spatialFilter .= ",the_geom)";
- array_push($whereCondArray, $spatialFilter);
+ $sql .= ")";
+ $e = new mb_exception("php/mod_callMetadata.php: sql for getting custom cats: ".$sql);
+ $res = db_prep_query($sql,$v,$t);
+ $countCustomArray = 0;
+ while($row = db_fetch_array($res)){
+ $customCategoryArray[$countCustomArray]["id"] = $row["custom_category_id"];
+ $customCategoryArray[$countCustomArray]["name"] = $row["custom_category_code_".$languageCode];
+ $countCustomArray = $countCustomArray + 1;
}
- #array_push($whereCondArray, $spatialFilter);
+ return $customCategoryArray;
}
-*/
- //spatial search filter - ist should be the first filter in the where clause, cause it is
- //
- if (strtolower($this->searchResources) === "wms" & $this->searchBbox != NULL) {
- #$spatialFilter = "(the_geom ";
- #echo "<br> spatial operator: ".$this->searchTypeBbox."<br>";
- #if ($this->searchTypeBbox == 'outside') {
- # $spatialFilter = ' disjoint(';
- #} elseif ($this->searchTypeBbox == 'inside') {
- # $spatialFilter = ' within(';
- #} else {
- # $spatialFilter = ' intersects(';
- #}
- $spatialFilter = ' the_geom && ';
- //define spatial filter
- if(count(explode(',',$this->searchBbox)) == 4){ //if searchBbox has 4 entries
-
- $spatialFilterCoords = explode(',',$this->searchBbox);//read out searchBbox
- //definition of the spatial filter
- $spatialFilter .= 'GeomFromText(\'POLYGON(('.$spatialFilterCoords[0];//minx
- $spatialFilter .= ' '.$spatialFilterCoords[1].',';//miny
- $spatialFilter .= $spatialFilterCoords[0];//minx
- $spatialFilter .= ' '.$spatialFilterCoords[3].',';//maxy
- $spatialFilter .= $spatialFilterCoords[2];//maxx
- $spatialFilter .= ' '.$spatialFilterCoords[3].',';//maxy
- $spatialFilter .= $spatialFilterCoords[2];//maxx
- $spatialFilter .= ' '.$spatialFilterCoords[1].',';//miny
- $spatialFilter .= $spatialFilterCoords[0];//minx
- $spatialFilter .= ' '.$spatialFilterCoords[1].'))\',4326)';//miny
- #$spatialFilter .= ",the_geom)";
- array_push($whereCondArray, $spatialFilter);
- }
- #array_push($whereCondArray, $spatialFilter);
- }
- //search filter for md_topic_categories
- //
- if (strtolower($this->searchResources) === "wms" & $this->isoCategories != NULL) {
-
- $isoArray = explode(',',$this->isoCategories);
- $topicCond = "(";
- for($i=0; $i < count($isoArray); $i++){
- if ($i == 0) {
- $topicCond .= "(md_topic_cats LIKE '%{".$isoArray[$i]."}%') ";
- } else {
- $topicCond .= "OR (md_topic_cats LIKE '%{".$isoArray[$i]."}%') ";
- }
- }
- $topicCond .= ")";
- array_push($whereCondArray, $topicCond);
+
+
+//define where to become the information from - this is relavant for the information which must be pulled out of the database
+$classificationElements = array();
+
+
+
+
+
+$classificationElements[0]['name'] = 'searchText';
+$classificationElements[1]['name'] = 'registratingDepartments';
+$classificationElements[2]['name'] = 'isoCategories';
+$classificationElements[3]['name'] = 'inspireThemes';
+$classificationElements[4]['name'] = 'customCategories';
+$classificationElements[5]['name'] = 'searchBbox';
+$classificationElements[6]['name'] = 'regTimeBegin';
+$classificationElements[7]['name'] = 'regTimeEnd';
+
+$classificationElements[0]['source'] = '';
+$classificationElements[1]['source'] = 'database';
+$classificationElements[2]['source'] = 'database';
+$classificationElements[3]['source'] = 'database';
+$classificationElements[4]['source'] = 'database';
+$classificationElements[5]['source'] = '';
+$classificationElements[6]['source'] = '';
+$classificationElements[7]['source'] = '';
+
+$classificationElements[0]['list'] = true;
+$classificationElements[1]['list'] = true;
+$classificationElements[2]['list'] = true;
+$classificationElements[3]['list'] = true;
+$classificationElements[4]['list'] = true;
+$classificationElements[5]['list'] = false;
+$classificationElements[6]['list'] = false;
+$classificationElements[7]['list'] = false;
+
+//Defining of the different result categories
+ $resourceCategories = array();
+ #$resourceCategories[0]['wms'] = 'WMS';
+ #$resourceCategories[1]['wfs'] = 'WFS';
+ #$resourceCategories[2]['wmc'] = 'WMC';
+ #$resourceCategories[3]['georss'] = 'GeoRSS';
+
+
+switch($languageCode){
+ case 'de':
+ $classificationElements[0]['name2show'] = 'Suchbegriff(e):';
+ $classificationElements[1]['name2show'] = 'Anbietende Stelle(n):';
+ $classificationElements[3]['name2show'] = 'INSPIRE Themen:';
+ $classificationElements[2]['name2show'] = 'ISO Kategorien:';
+ $classificationElements[4]['name2show'] = 'RP Kategorien:';
+ $classificationElements[5]['name2show'] = 'Räumliche Einschränkung:';
+ $classificationElements[6]['name2show'] = 'Registrierung/Aktualisierung von:';
+ $classificationElements[7]['name2show'] = 'Registrierung/Aktualisierung bis:';
+
+ $resourceCategories['wms'] = 'Darstellungsdienste';
+ $resourceCategories['wfs'] = 'Such- und Downloaddienste';
+ $resourceCategories['wmc'] = 'Kartenzusammenstellungen';
+ $resourceCategories['georss'] = 'Geokodierte Newsfeeds';
+
+ $orderByTitle['header'] = 'Sortierung nach:';
+ $orderByTitle['id'] = 'ID';
+ $orderByTitle['title'] = 'Titel';
+ $orderByTitle['rank'] = 'Relevanz';
+
+
+ break;
+ case 'en':
+ $classificationElements[0]['name2show'] = 'Search Term(s):';
+ $classificationElements[1]['name2show'] = 'Department(s):';
+ $classificationElements[3]['name2show'] = 'INSPIRE Themes:';
+ $classificationElements[2]['name2show'] = 'ISO Topic Categories:';
+ $classificationElements[4]['name2show'] = 'RP Categories:';
+ $classificationElements[5]['name2show'] = 'Spatial Filter:';
+ $classificationElements[6]['name2show'] = 'Registration/Update from:';
+ $classificationElements[7]['name2show'] = 'Registration/Update till:';
+
+ $resourceCategories['wms'] = 'Viewingservices';
+ $resourceCategories['wfs'] = 'Search- and Downloadservices';
+ $resourceCategories['wmc'] = 'Combined Maps';
+ $resourceCategories['georss'] = 'Geocodet Newsfeeds';
+
+ $orderByTitle['header'] = 'Sort by:';
+ $orderByTitle['id'] = 'ID';
+ $orderByTitle['title'] = 'title';
+ $orderByTitle['rank'] = 'relevance';
+
+ break;
+ case 'fr':
+ $classificationElements[0]['name2show'] = 'Suchbegriff(e):';
+ $classificationElements[1]['name2show'] = 'Anbietende Stelle(n):';
+ $classificationElements[3]['name2show'] = 'INSPIRE Themen:';
+ $classificationElements[2]['name2show'] = 'ISO Kategorien:';
+ $classificationElements[4]['name2show'] = 'RP Kategorien:';
+ $classificationElements[5]['name2show'] = 'Räumliche Einschränkung:';
+ $classificationElements[6]['name2show'] = 'Registrierung/Aktualisierung von:';
+ $classificationElements[7]['name2show'] = 'Registrierung/Aktualisierung bis:';
+
+ $resourceCategories['wms'] = 'Viewingservices';
+ $resourceCategories['wfs'] = 'Search- and Downloadservices';
+ $resourceCategories['wmc'] = 'Combined Maps';
+ $resourceCategories['georss'] = 'Geocodet Newsfeeds';
+
+ $orderByTitle['header'] = 'Sort by:';
+ $orderByTitle['id'] = 'identification';
+ $orderByTitle['title'] = 'title';
+ $orderByTitle['rank'] = 'relevance';
+
+ break;
+ default:
+ $classificationElements[0]['name2show'] = 'Suchbegriff(e):';
+ $classificationElements[1]['name2show'] = 'Anbietende Stelle(n):';
+ $classificationElements[3]['name2show'] = 'INSPIRE Themen:';
+ $classificationElements[2]['name2show'] = 'ISO Kategorien:';
+ $classificationElements[4]['name2show'] = 'RP Kategorien:';
+ $classificationElements[5]['name2show'] = 'Räumliche Einschränkung:';
+ $classificationElements[6]['name2show'] = 'Registrierung/Aktualisierung von:';
+ $classificationElements[7]['name2show'] = 'Registrierung/Aktualisierung bis:';
+
+ $resourceCategories['wms'] = 'Darstellungsdienste';
+ $resourceCategories['wfs'] = 'Such- und Downloaddienste';
+ $resourceCategories['wmc'] = 'Kartenzusammenstellungen';
+ $resourceCategories['georss'] = 'Geokodierte Newsfeeds';
+
+ $orderByTitle['header'] = 'Sortierung nach:';
+ $orderByTitle['id'] = 'ID';
+ $orderByTitle['title'] = 'Titel';
+ $orderByTitle['rank'] = 'Relevanz';
+
+}
+
+$queryJSON = new stdClass;
+$queryJSON->searchFilter = (object) array();
+$queryJSON->searchFilter->origURL = $searchURL;
+#$queryJSON->searchFilter->classes = (object) array();
+for($i=0; $i<count($searchResources);$i++){
+//fill in the different search classes into the filter - the client can generate the headers out of this information
+ $queryJSON->searchFilter->classes[$i]->title = $resourceCategories[$searchResources[$i]];
+ $queryJSON->searchFilter->classes[$i]->name = $searchResources[$i];
+}
+//generate search filter file - if more categories are defined give
+#echo "<br> number of filter elements: ".count($classificationElements)."<br>";
+for($i=0; $i < count($classificationElements); $i++){
+ if (isset(${$classificationElements[$i]['name']}) & ${$classificationElements[$i]['name']} !='' & ${$classificationElements[$i]['name']} != NULL) {
+ //pull register information out of database in arrays
+ if ($classificationElements[$i]['source'] == 'database') {
+ $funcName = "get_".$classificationElements[$i]['name']."Array";
+ ${$classificationElements[$i]['name']."Array"} = $funcName(explode(',',${$classificationElements[$i]['name']}),$languageCode);
}
- //search filter for inspire_categories
- //
- if (strtolower($this->searchResources) === "wms" & $this->inspireThemes != NULL) {
-
- $inspireArray = explode(',',$this->inspireThemes);
- $inspireCond = "(";
- for($i=0; $i < count($inspireArray); $i++){
- if ($i == 0) {
- $inspireCond .= "(md_inspire_cats LIKE '%{".$inspireArray[$i]."}%') ";
+ $queryJSON->searchFilter->{$classificationElements[$i]['name']}->title = $classificationElements[$i]['name2show'];
+ //check if the filter has subfilters - if not delete the whole filter from query
+ if ($classificationElements[$i]['list'] == false) { //the object has no subsets - like bbox or time filters
+ $queryJSON->searchFilter->{$classificationElements[$i]['name']}->delLink = delTotalFromQuery($classificationElements[$i]['name'],$searchURL);
+ } else {
+
+
+
+ //TODO delete all entries of this main category (not for searchText)
+ if ($classificationElements[$i]['name'] != 'searchText') {
+ $queryJSON->searchFilter->{$classificationElements[$i]['name']}->delLink = delTotalFromQuery($classificationElements[$i]['name'],$searchURL);
+ } else {
+ $queryJSON->searchFilter->{$classificationElements[$i]['name']}->delLink = NULL;
+ }
+ $queryJSON->searchFilter->{$classificationElements[$i]['name']}->item = array();
+ $queryArray = explode(',',${$classificationElements[$i]['name']});
+ //loop for the subcategories
+ for($j=0; $j < count($queryArray); $j++){
+ if ($classificationElements[$i]['source'] == 'database') {
+ $identArray = ${$classificationElements[$i]['name']."Array"};
+ $identArray = flipDiagonally($identArray);
+ //find searched id in information from database
+ $key = array_search($queryArray[$j], $identArray['id']);
+ if ($key === false) {
+ $queryJSON->searchFilter->{$classificationElements[$i]['name']}->item[$j]->title = "no information found in database";
+ } else {
+ $queryJSON->searchFilter->{$classificationElements[$i]['name']}->item[$j]->title = ${$classificationElements[$i]['name']."Array"}[$key]['name'];
+ }
} else {
- $inspireCond .= "OR (md_inspire_cats LIKE '%{".$inspireArray[$i]."}%') ";
+ $queryJSON->searchFilter->{$classificationElements[$i]['name']}->item[$j]->title = $queryArray[$j];
}
- }
- $inspireCond .= ")";
- array_push($whereCondArray, $inspireCond);
- }
- //search filter for custom_categories
- //
- if (strtolower($this->searchResources) === "wms" & $this->customCategories != NULL) {
-
- $customArray = explode(',',$this->customCategories);
- $customCond = "(";
- for($i=0; $i < count($customArray); $i++){
- if ($i == 0) {
- $customCond .= "(md_custom_cats LIKE '%{".$customArray[$i]."}%') ";
+ //generate links to disable filters on a simple way
+ if ($classificationElements[$i]['name'] === 'searchText' & count(explode(',',${$classificationElements[$i]['name']})) === 1) {
+ $queryJSON->searchFilter->{$classificationElements[$i]['name']}->item[$j]->delLink = NULL;
} else {
- $customCond .= "OR (md_custom_cats LIKE '%{".$customArray[$i]."}%') ";
+ $newSearchLink = delFromQuery($classificationElements[$i]['name'], $searchURL,$queryArray[$j],$queryArray,${$classificationElements[$i]['name']});
+ $newSearchLink = delTotalFromQuery('searchId',$newSearchLink);
+ $queryJSON->searchFilter->{$classificationElements[$i]['name']}->item[$j]->delLink = $newSearchLink;
}
}
- $customCond .= ")";
- array_push($whereCondArray, $customCond);
}
-
+ }
+}
- //date condition
- //if begin and end are set
- //echo "<br> regTimeBegin: ".$this-> regTimeBegin." regTimeEnd: ".$this-> regTimeEnd."<br>";
-
- if ($this->regTimeBegin != NULL && $this->regTimeEnd != NULL){
- $time ="(TO_TIMESTAMP(".$this->searchResources."_timestamp) BETWEEN '".$this->regTimeBegin."' AND '".$this->regTimeEnd."')";
- array_push($whereCondArray, $time);
- //only begin is set
- }
- if ($this->regTimeBegin != NULL && $this->regTimeEnd == NULL){
- $time ="(TO_TIMESTAMP(".$this->searchResources."_timestamp) > '".$this->regTimeBegin."')";
- array_push($whereCondArray, $time);
- }
- if ($this->regTimeBegin == NULL && $this->regTimeEnd != NULL){
- $time ="(TO_TIMESTAMP(".$this->searchResources."_timestamp) < '".$this->regTimeEnd."')";
- array_push($whereCondArray, $time);
- }
+//generate filter for different order possibilities
-
- //department condition
- //TODO: generate filter for new sql check if at least some department is requested
- //generate array
- //$this->registratingDepartments = explode(',',$this->registratingDepartments);
- #if(count($this->registratingDepartments) > 0 & $this->registratingDepartments){
- if($this->registratingDepartments != NULL){
- $dep = " department IN (".$this->registratingDepartments.") ";
- array_push($whereCondArray, $dep);
- }
- // Creating the WHERE clause, based on a array
- if(count($whereCondArray) > 0){
- $txt_whereCond = "";
- for ($index = 0; $index < sizeof($whereCondArray); $index++) {
- $array_element = $whereCondArray[$index];
- if($isTextSearch == "true") {
- $txt_whereCond .= " AND ".$array_element;
- } else {
- if($index>0){
- $txt_whereCond .= " AND ".$array_element;
- } else {
- $txt_whereCond .= " ".$array_element;
- }
- }
- }
- $whereStr .= $txt_whereCond;
- }
- //Add WHERE condition to search
- $sql .= $whereStr;
- //TODO ORDER BY in SQL - not necessary for counting things:
- $sql .= $this->orderBy;
- //Calculate Paging for OFFSET and LIMIT values:
- $offset = ((integer)$this->maxResults) * ((integer)$this->searchPages -1);
- $limit = (integer)$this->maxResults;
- //defining range for paging
- $sql .= " LIMIT ".$limit." OFFSET ".$offset."";
- //Print out search SQL term
- $e = new mb_exception("class_metadata.php: Search => SQL-Request of ".$this->searchResources." service metadata: ".$sql."");
- //parameter: searchId -> can be used global, searchResources -> is only one type per instance!!-> global,which categories -> can be defined global! $whereStr
- $n = $this->writeCategories($whereStr, $v, $t);
- //write counts to filesystem to avoid to many database connections
- //only write them, if searchId is given - problem: searches with same searchId's maybe get wrong information
- return array($sql, $v, $t, $n);
- }
+//$queryJSON->searchFilter = (object) array();
+if ($_REQUEST["orderBy"] == '') {
+//echo "<br>orderBy:>".$_REQUEST["orderBy"]."<<br>";
+ $queryJSON->searchFilter->orderFilter->title = $orderByTitle['header'];
+
- private function writeCategories($whereStr, $v, $t) {
- //generate count sql
- //generate count of all entries
- $sqlN = "SELECT count(".$this->searchResources."_id) from ".$this->searchView." where ";
- $sqlN .= $whereStr;
- //Get total number of results
- $count = db_prep_query($sqlN, $v, $t);
- $n = db_fetch_all($count);
- #echo "<br>N: ".var_dump($n)."<br>";
- $n = $n[0]['count'];
- $e = new mb_notice("class_metadata.php: Search => SQL-Request of ".$this->searchResources." service metadata N: ".$sqlN." Number of found objects: ".$n);
- if ($this->searchId != 'dummysearch') { //searchId is not the default id! - it has been explicitly defined
- //check if cat file already exists:
- //filename to search for:
- $filename = $this->tempFolder."/".$this->searchId."_".$this->searchResources."_cat.json";
- if (!file_exists($filename) or $this->resultTarget == 'debug') { //TODO at the moment the cat file will be overwritten - change this in production system
- //open category file for wfs results
- $this->catJSON = new stdClass;
- $this->catJSON->searchMD = (object) array(
- 'searchId' => $this->searchId,
- 'n' => $n
- );
- //generate the list of category counts
- $sqlCat = array();
- //check if categories are defined for the resource
- if ($this->resourceClasses != NULL) {
- $this->catJSON->searchMD->category = array();
- for ($i = 0; $i < count($this->resourceClasses); $i++) {
- //TODO: not to set the classification?
- $this->catJSON->searchMD->category[$i]->title = $this->resourceClassifications[$i]['title'];
- $sqlCat[$i] = "SELECT ".$this->resourceClassifications[$i]['tablename'];
- $sqlCat[$i] .= ".".$this->resourceClassifications[$i]['tablename']."_id, ";
- $sqlCat[$i] .= " ".$this->resourceClassifications[$i]['tablename'].".";
- $sqlCat[$i] .= $this->resourceClassifications[$i]['tablename']."_code_";
- $sqlCat[$i] .= $this->languageCode.", COUNT(*) FROM ".$this->searchView;
+ $queryJSON->searchFilter->orderFilter->item[0]->title = $orderByTitle['title'];
+ $queryJSON->searchFilter->orderFilter->item[0]->url = $searchURL."&orderBy=title";
+ $queryJSON->searchFilter->orderFilter->item[1]->title = $orderByTitle['id'];
+ $queryJSON->searchFilter->orderFilter->item[1]->url = $searchURL."&orderBy=id";
+
+} else {
+//read out actual order filter
+switch ($orderBy) {
+ case "rank":
+ $queryJSON->searchFilter->orderFilter->title = $orderByTitle['header'];
+ $queryJSON->searchFilter->orderFilter->item[0]->title = $orderByTitle['id'];
- //first join for connection table
- $sqlCat[$i] .= " INNER JOIN ".$this->resourceClassifications[$i]['relation_'.$this->searchResources];
- $sqlCat[$i] .= " ON (";
- $sqlCat[$i] .= $this->resourceClassifications[$i]['relation_'.$this->searchResources].".fkey_";
- $sqlCat[$i] .= $this->resourceClassifications[$i]['id_'.$this->searchResources]."=".$this->searchView;
- $sqlCat[$i] .= ".".$this->resourceClassifications[$i]['id_'.$this->searchResources];
- $sqlCat[$i] .= ") INNER JOIN ";
- $sqlCat[$i] .= $this->resourceClassifications[$i]['tablename']." ON (";
- $sqlCat[$i] .= $this->resourceClassifications[$i]['tablename'].".";
- $sqlCat[$i] .= $this->resourceClassifications[$i]['tablename']."_id=";
- $sqlCat[$i] .= $this->resourceClassifications[$i]['relation_'.$this->searchResources].".fkey_";
- $sqlCat[$i] .= $this->resourceClassifications[$i]['tablename']."_id)";
- $sqlCat[$i] .= " WHERE ".$whereStr." GROUP BY ";
+ $queryJSON->searchFilter->orderFilter->item[0]->url = str_replace("orderBy=rank", "orderBy=id", $searchURL);
+ $queryJSON->searchFilter->orderFilter->item[1]->title = $orderByTitle['title'];
- $sqlCat[$i] .= $this->resourceClassifications[$i]['tablename'].".";
- $sqlCat[$i] .= $this->resourceClassifications[$i]['tablename']."_id,";
- $sqlCat[$i] .= $this->resourceClassifications[$i]['tablename'].".";
- $sqlCat[$i] .= $this->resourceClassifications[$i]['tablename']."_code_".$this->languageCode." ORDER BY ";
- $sqlCat[$i] .= $this->resourceClassifications[$i]['tablename']."_id";
- $sqlCategory = $sqlCat[$i];
+ $queryJSON->searchFilter->orderFilter->item[1]->url = str_replace("orderBy=rank", "orderBy=title", $searchURL);
+ break;
+ case "id":
+ $queryJSON->searchFilter->orderFilter->title = $orderByTitle['header'];
+ $queryJSON->searchFilter->orderFilter->item[0]->title = $orderByTitle['rank'];
- //call sql for count of category
- $res = db_prep_query($sqlCategory, $v, $t);
- $categoryCounts = db_fetch_all($res);
- //if none found: $categoryCounts=false
- #echo "<br>count sub categories :".$categoryCounts."<br>";
- if ($categoryCounts) {
- //write results in json object
- if (count($categoryCounts) > 0) {
- #echo "<br>count main categories".count($categoryCounts)."<br>";
- #echo "<br>vardump main categories".var_dump($categoryCounts)."<br>";
- $this->catJSON->searchMD->category[$i]->subcat = array();
- for ($j = 0; $j < count($categoryCounts); $j++) {
- $this->catJSON->searchMD->category[$i]->subcat[$j]->id = $categoryCounts[$j][$this->resourceClassifications[$i]['tablename']."_id"];
- $this->catJSON->searchMD->category[$i]->subcat[$j]->title = $categoryCounts[$j][$this->resourceClassifications[$i]['tablename']."_code_".$this->languageCode];
- $this->catJSON->searchMD->category[$i]->subcat[$j]->count = $categoryCounts[$j]['count'];
- //delete requestParam for this category and for id - cause a new search is started from searchURL
- $filteredSearchString = $this->delTotalFromQuery('searchId',$this->searchURL);
- $filteredSearchString = $this->delTotalFromQuery($this->resourceClassifications[$i]['requestName'],$filteredSearchString);
- //set filter for this categoryid
- $filteredSearchString .= "&".$this->resourceClassifications[$i]['requestName']."=".$categoryCounts[$j][$this->resourceClassifications[$i]['tablename']."_id"];
- $this->catJSON->searchMD->category[$i]->subcat[$j]->filterLink = $filteredSearchString;
- }
- }
- } else {
- #$this->catJSON->searchMD->category[$i]->subcat = array();
- }
- $e = new mb_notice("class_metadata: countsql: ".$sqlCat[$i]);
- }
- }
+ $queryJSON->searchFilter->orderFilter->item[0]->url = str_replace("orderBy=id", "orderBy=rank", $searchURL);
+ $queryJSON->searchFilter->orderFilter->item[1]->title = $orderByTitle['title'];
- $this->catJSON = $this->json->encode($this->catJSON);
- //write categories files only when file is requested and the searchid was not used before!
- if ($this->resultTarget == 'file') {
- if($catFileHandle = fopen($filename, "w")){
- fwrite($catFileHandle,$this->catJSON);
- fclose($catFileHandle);
- $e = new mb_notice("class_metadata: new ".$this->searchResources."_class_file created!");
- } else {
- $e = new mb_notice("class_metadata: cannot create ".$this->searchResources."_cat_file!");
- }
- }
- if ($this->resultTarget == 'debug') {
- echo "<br>DEBUG: show categories: <br>".$this->catJSON."<br><br>";
- }
- } else {
- $e = new mb_exception("class_metadata: ".$this->searchResources."_class_file: ".$filename." already exists - no new one is generated!");
- }
- } else {
- if ($this->resultTarget == 'debug') {
- echo "<br>DEBUG: Standard ID dummysearch was invoked - classifications won't be counted!<br>";
- }
- $e = new mb_exception("class_metadata: standard dummysearch was invoked - classifications won't be counted!");
- }
- return $n;
- }
+ $queryJSON->searchFilter->orderFilter->item[1]->url = str_replace("orderBy=id", "orderBy=title", $searchURL);
+ break;
+ case "title":
+ $queryJSON->searchFilter->orderFilter->title = $orderByTitle['header'];
+ $queryJSON->searchFilter->orderFilter->item[0]->title = $orderByTitle['rank'];
+ $queryJSON->searchFilter->orderFilter->item[0]->url = str_replace("orderBy=title", "orderBy=rank", $searchURL);
+ $queryJSON->searchFilter->orderFilter->item[1]->title = $orderByTitle['id'];
+ $queryJSON->searchFilter->orderFilter->item[1]->url = str_replace("orderBy=title", "orderBy=id", $searchURL);
+ break;
+
+}
+}
+//write out json to file or web
+
+$queryFilter = $classJSON->encode($queryJSON);
- private function generateWFSResultXML($wfsDoc, $res) {
- $c = $this->wfsDoc->createElement("category");
- $results = $this->wfsDoc->getElementsByTagName("result");
- foreach ($results as $result) {
- $result->appendChild($c);
- $c->setAttribute('name', "WFS");
- $c->setAttribute('count', "0");
- }
- $i = 0;
- while($row = db_fetch_array($res)){
- $m = $this->wfsDoc->createElement('member');
- $m->setAttribute('wfs_id', $row['wfs_id']);
- $m->setAttribute('layer_pos', "");
- $c->appendChild($m); // member categorie 1 (first member)
- // epsg - TODO adopt
- $epsg = $this->wfsDoc->createElement('epsg');
- $m->appendChild($epsg);
- $equalEPSG = $row['featuretype_srs'];
- $isequal = "false";
- if ($equalEPSG == $this->search_epsg){
- $isequal = "true";
- }
- //Insert end
- $epsg_text = $this->wfsDoc->createTextNode($isequal);
- $epsg->appendChild($epsg_text);
- // country codes
- $state = $this->wfsDoc->createElement('federalstate');
- $m->appendChild($state);
- $spatialSource = "";
- $stateorprovince = $row['administrativearea'];
- if ($stateorprovince == "NULL" || $stateorprovince == "") {
- $spatialSource = $row['country'];
- } else {
- $spatialSource = $row['administrativearea'];
- }
- $countr_code_text = $this->wfsDoc->createTextNode($spatialSource);
- $state->appendChild($countr_code_text);
- //type
- $type = $this->wfsDoc->createElement('type');
- $m->appendChild($type);
- $ttype = $this->wfsDoc->createTextNode("wfs");
- $type->appendChild($ttype);
- //wfs_id
- $wfsid = $this->wfsDoc->createElement('wfs_id');
- $m->appendChild($wfsid);
- $twfsid = $this->wfsDoc->createTextNode($row['wfs_id']);
- $wfsid->appendChild($twfsid);
- //id
- $id = $this->wfsDoc->createElement('featuretype_id');
- $m->appendChild($id);
- $tid = $this->wfsDoc->createTextNode($row['featuretype_id']);
- $id->appendChild($tid);
- //title
- $title = $this->wfsDoc->createElement('featuretype_title');
- $m->appendChild($title);
- $ttitle = $this->wfsDoc->createTextNode($row['featuretype_title']);
- $title->appendChild($ttitle);
- //abstract
- $abst = $this->wfsDoc->createElement('featuretype_abstract');
- $m->appendChild($abst);
- $tabst = $this->wfsDoc->createTextNode($row['featuretype_abstract']);
- $abst->appendChild($tabst);
- // accesscontraints
- $ac = $this->wfsDoc->createElement('accessconstraints');
- $m->appendChild($ac);
-// $myac = $this->getAccessConstraints($this->cat[$i]['member'][$ii]['wms_id'], $this->cat[$i]['member'][$ii]['accessconstraints'], $this->cat[$i]['member'][$ii]['layer_id']);
- $myac = $this->wfsDoc->createTextNode($row['accessconstraints']);
- $ac->appendChild($myac);
- // termsofuse
- $ter = $this->wfsDoc->createElement('termsofuse');
- $m->appendChild($ter);
- $myter = $this->wfsDoc->createTextNode($row['termsofuse']);
- $ter->appendChild($myter);
- //date
- $date = $this->wfsDoc->createElement('date');
- $m->appendChild($date);
- $tdate = $this->wfsDoc->createTextNode(date("d.m.Y",$row['wfs_timestamp']));
- $date->appendChild($tdate);
- // Geomtype
- $geo = $this->wfsDoc->createElement('geomtype');
- $m->appendChild($geo);
- //$geo_text = $this->getGeoType($row['wfs_id'], $row['featuretype_id']);
- $geo_text = $this->wfsDoc->createTextNode($row['element_type']);
- //$ge = $this->wfsDoc->createTextNode($geo_text);
- $geo->appendChild($geo_text);
- //department
- $dm = $this->wfsDoc->createElement('department');
- $m->appendChild($dm);
- $tdm = $this->wfsDoc->createTextNode($row['mb_group_name']);
- $dm->appendChild($tdm);
- //permission Leseberechtigung des Benutzers(true), sonst Email zur Beantragung(email)
- $per = $this->wfsDoc->createElement('permission');
- $m->appendChild($per);
- $per_text = $this->getPermissionValueForWFS($row['wfs_id'], $row['wfs_conf_id']);
- $pe = $this->wfsDoc->createTextNode($per_text);
- $per->appendChild($pe);
- //wfs_conf_id
- $conf_id = $this->wfsDoc->createElement('wfs_conf_id');
- $m->appendChild($conf_id);
- $c_id = $this->wfsDoc->createTextNode($row['wfs_conf_id']);
- $conf_id->appendChild($c_id);
- //wfs_conf_title
- $conf_title = $this->wfsDoc->createElement('wfs_conf_title');
- $m->appendChild($conf_title);
- $conf_title_text = $this->wfsDoc->createTextNode($row['wfs_conf_abstract']);
- $conf_title->appendChild($conf_title_text);
- //wfs_conf_abstract
- $conf_abstract = $this->wfsDoc->createElement('wfs_conf_abstract');
- $m->appendChild($conf_abstract);
- $c_abstract = $this->wfsDoc->createTextNode($row['wfs_conf_description']);
- $conf_abstract->appendChild($c_abstract);
- //wfs_conf_modul
- $conf_modul = $this->wfsDoc->createElement('wfs_conf_modul');
- $m->appendChild($conf_modul);
- $c_modul = $this->wfsDoc->createTextNode($row['modultype']);
- $conf_modul->appendChild($c_modul);
- $i++;
- }
- $c->setAttribute('count', $i);
- }
+if ($resultTarget == 'debug') {
+ echo "<br>DEBUG: filter: ".$queryFilter."<br>";
+ #echo "<br>DEBUG: searchTypeBbox: ".$searchTypeBbox."<br>";
+}
+if ($resultTarget == 'file') {
+ $filename = $tempFolder."/".$searchId."_filter.json";
+ if (file_exists($filename)) {
+ $e = new mb_notice("php/callMetdata.php: The file $filename exists - it will not be overwritten!");
- private function getPermissionValueForWFS($wfs_id, $wfs_conf_id){
- //TODO: Set Email of owner into view for ressource - so it don't have to be searched?
- $return_permission = "";
- //get permission
- $admin = new administration();
- $myWFSconfs = $admin->getWfsConfByPermission($this->userId);
- $this->myWFSConfs = $myWFSconfs;
- for ($index = 0; $index < sizeof($this->myWFSConfs); $index++) {
- $array_element = $this->myWFSConfs[$index];
- }
- if (in_array($wfs_conf_id, $this->myWFSConfs)){
- $return_permission = "true";
+ } else {
+ if($catFileHandle = fopen($filename, "w")){
+ fwrite($catFileHandle,$queryFilter);
+ fclose($catFileHandle);
+ $e = new mb_notice("php/callMetdata.php: new filter_file created!");
} else {
- $sql = "SELECT wfs.wfs_id, mb_user.mb_user_email as email FROM wfs, mb_user where wfs.wfs_owner=mb_user.mb_user_id "."and wfs.wfs_id=$1";
- $v = array($wfs_id);
- $t = array('i');
- $res = db_prep_query($sql, $v, $t);
- // get email
- $mail = "";
- while($row = db_fetch_array($res)){
- $mail = $row['email'];
- $return_permission = $mail;
- }
+ $e = new mb_notice("php/callMetdata.php: cannot create filter_file!");
}
- return $return_permission;
}
-
- private function getPermissionValueForLayer($layerId,$wmsId){
- //TODO: Set Email of owner into view for ressource - so it don't have to be searched?
- $return_permission="";
- #$admin = new administration();
- #$permission = $admin->getLayerPermission($wms_id, $layer_name, $this->userId);
- #echo "<br>wms_id: ".$wms_id."<br>";
- #echo "<br>layer_name: ".$layer_name."<br>";
- #echo "<br>user_id: ".$this->userId."<br>";
- #echo "<br>Permission: ".$permission."<br>";
- # var_dump($this->accessableLayers);
- if (in_array($layerId, $this->accessableLayers)){
- $return_permission = "true";
- return $return_permission;
- } else {
- $sql = "SELECT mb_user.mb_user_email as email FROM wms, mb_user WHERE wms.wms_owner=mb_user.mb_user_id";
- $sql .= " AND wms.wms_id=$1";
- $v = array($wmsId);
- $t = array('i');
- $res = db_prep_query($sql, $v, $t);
- // get email
- $mail="";
- while($row = db_fetch_array($res)){
- $mail = $row['email'];
- $return_permission = $mail;
- }
- return $return_permission;
- }
- }
-
+}
+//function to transpose a matrix - sometimes needed to do an array search
+function flipDiagonally($arr) {
+ $out = array();
+ foreach ($arr as $key => $subarr) {
+ foreach ($subarr as $subkey => $subvalue) {
+ $out[$subkey][$key] = $subvalue;
+ }
+ }
+ return $out;
+}
- private function generateSearchStringArray() {
- //'wfs test array' -> ('wfs' 'test' 'array')
- $asstr = array();
- if ($this->searchText != "false"){
- $asstr = split(",",$this->searchText);
+//function to delete one of the comma separated values from one get request
+function delFromQuery($paramName,$queryString,$string,$queryArray,$queryList) {
+ //check if if count searchArray = 1
+ if (count($queryArray) == 1){
+ //remove request parameter from url by regexpr or replace
+ $str2search = $paramName."=".$queryList;
+ $str2exchange = "";
+ $queryStringNew = str_replace($str2search, $str2exchange, $queryString);
+ $queryStringNew = str_replace("&&", "&", $queryStringNew);
+ } else {
+ //there are more than one filter - reduce the filter
+ $objectList = "";
+ for($i=0; $i < count($queryArray); $i++){
+ if ($queryArray[$i] != $string){
+ $objectList .= $queryArray[$i].",";
+ }
}
- return $asstr;
- }
-
- //out of php doc - test if it is faster than normal array_search
- private function fast_in_array($elem, $array) {
- $top = sizeof($array) -1;
- $bot = 0;
- while($top >= $bot) {
- $p = floor(($top + $bot) / 2);
- if ($array[$p] < $elem) $bot = $p + 1;
- elseif ($array[$p] > $elem) $top = $p - 1;
- else return TRUE;
- }
- return FALSE;
+ //remove last comma
+ $objectList = rtrim($objectList, ",");
+ $str2search = $paramName."=".$queryList;
+ $str2exchange = $paramName."=".$objectList;
+ $queryStringNew = str_replace($str2search, $str2exchange, $queryString);
}
- /*
- * filtering an array
- */
- private function filter_by_value ($array, $index, $value){
- if(is_array($array) && count($array)>0) {
- foreach(array_keys($array) as $key){
- $temp[$key] = $array[$key][$index];
- if ($temp[$key] == $value){
- $newarray[$key] = $array[$key];
- }
- }
- }
- return $newarray;
- }
+ return $queryStringNew;
+}
- //function to get the parent of the given layer by crawling the layertree upwards
- private function getLayerParent ($layerArray, $index){
- //only layers of one service should be in $layerArray
- #$parentExists = false;
- #var_dump($layerArray);
- $layerIDKey = $layerArray['layer_id'][$index];
- #echo ("layerIDKey= ".$layerIDKey."<br>");
- $layerParentPos = $layerArray['layer_parent'][$index];//get first parent object position
- #echo ("layerParentPos= ".$layerParentPos."<br>");
- #echo("<br>number of sublayers ".count(flipDiagonally($layerArray))."<br>");
- #echo("<br>size of layerArray['layer_pos']: ".count($layerArray['layer_pos'])."<br>");
- #var_dump($layerArray['layer_pos']);
- #echo "<br>flipped layerArray: <br> ";
- #var_dump(flipDiagonally($layerArray));
- #echo "<br>";
+//function to remove one complete get param out of the query
+function delTotalFromQuery($paramName,$queryString) {
+ //echo $paramName ."<br>";
+ $queryString = "&".$queryString;
+ $queryStringNew = preg_replace('/\b'.$paramName.'\=[^&]*&?/',"",$queryString); //TODO find empty get params
+ $queryStringNew = ltrim($queryStringNew,'&');
+ $queryStringNew = rtrim($queryStringNew,'&');
+ return $queryStringNew;
+}
- if ($layerParentPos == '') {
- //root layer directly found
- return $index;
- }
- #echo ("layerParentPos= ".$layerParentPos."<br>");
- //Initialize index of layer parent - first it references the layer itself
- $layerParentIndex = $index;
- //loop to search higher parent objects - maybe this can be faster if the loop is not used over all sublayer elements! Do a while loop instead!
- $highestParentLayerNotFound = true;
- while ($highestParentLayerNotFound) {
- #echo("<br>i= ".$i."<br>");
- #echo("<br>layerParentPosNew= ".$layerParentPos."<br>");
- $layerParentIndexNew = array_search((string)$layerParentPos, $layerArray['layer_pos']);
- #echo("<br>layerParentIndexNew= ".$layerParentIndexNew."<br>");
- if ($layerParentIndexNew != false) {
- //some parent has been found
- $layerParentIndex = $layerParentIndexNew;
- $layerParentPos = $layerArray['layer_parent'][$layerParentIndex];
- if ($layerParentPos == '') {
- $highestParentLayerNotFound = false;
- return $layerParentIndex; //a real root layer was found!
- }
-
- #$layerParentIndex = array_search($layerParentPos, $layerArray['layer_pos']);
- } else {
- $highestParentLayerNotFound = false; //no higher layer could be found
- return $layerParentIndex;
- }
- }
- return $layerParentIndex;
- }
- //function to write the child elements to the resulting wms object -> object is given by reference
- private function writeWMSChilds($layerIdArray, $rootLayerPos, $subLayers, &$servObject) {
- #echo "test";
- #echo "<br>subLayers:<br>";
- #var_dump($subLayers);
- #echo "<br>";
- $childLayers = $this->filter_by_value($subLayers, 'layer_parent', $rootLayerPos); //the root layer position in the sublayer array was located before. In this step, all layers will be pulled out of sublayer, where root layer position is parent object
- #echo "<br<childLayers:<br>";
- #var_dump($childLayers);
- #echo "<br>";
- #echo "test";
- #print_r($childLayers);
- #print_r($childLayers);
- $countsublayer = 0;
- //if child exists create a new layer array for these
- if (count($childLayers) != 0) {
- $servObject->layer = array();
- }
- foreach ($childLayers as $child){
- #echo "<br>countsublayer: ".$countsublayer."<br>";
- #echo "<br>Child id: ".$child['layer_id']."<br>";
- #echo "<br>Child pos: ".$child['layer_pos']."<br>";
- $servObject->layer[$countsublayer]->id = $child['layer_id'];
- $servObject->layer[$countsublayer]->title = $child['layer_title'];
- $servObject->layer[$countsublayer]->abstract = $child['layer_abstract'];
- $servObject->layer[$countsublayer]->mdLink = "http://".$_SERVER['HTTP_HOST']."/mapbender/x_geoportal/mod_layerMetadata.php?id=".$child['layer_id'];
- if ($child['layer_name'] == ''){
- $servObject->layer[$countsublayer]->loadable = 0;
- } else {
- $servObject->layer[$countsublayer]->loadable = 1;
- }
- //give info for inspire categories - not relevant for other services or instances of mapbender TODO: comment it if the mapbender installation is not used to generate inspire output
- if ($child['md_inspire_cats'] == ''){
- $servObject->layer[$countsublayer]->inspire = 0;
- }
- else {
- $servObject->layer[$countsublayer]->inspire = 1;
- }
- //get info about queryable or not
- if ($child['layer_queryable'] == 1){
- $servObject->layer[$countsublayer]->queryable = 1;
- }
- else {
- $servObject->layer[$countsublayer]->queryable = 0;
- }
-
- $servObject->layer[$countsublayer]->loadCount = $child['load_count'];
- $servObject->layer[$countsublayer]->bbox = $child['bbox'];
- $servObject->layer[$countsublayer]->permission = $this->getPermissionValueForLayer($child['layer_id'],$child['wms_id']); //TODO: make this much faster!!!! - is done by collecting all accessable resources once. Maybe this has to be adopted if the count of the resources become higher
- //call this function itself - search sublayers in the layer object.
- $layerIdArray = $this->writeWMSChilds($layerIdArray, $child['layer_pos'], $subLayers, $servObject->layer[$countsublayer]);//TODO create a timeout condition !
- array_push($layerIdArray, $child['layer_id']); //child have been identified and recursively written
- #var_dump($layerIdArray);#
- #echo "<br>";
- $countsublayer ++;
- }
- return $layerIdArray;
- }
+//call class_metadata - in case of file for all requested resources, in case of web only for one resource - cause there are different result files
- private function delTotalFromQuery($paramName,$queryString) {
- $queryString = "&".$queryString;
- #echo "<br>queryString: ".$queryString."<br>";
- $queryStringNew = preg_replace('/\b'.$paramName.'\=[^&]+&?/',"",$queryString);
- $queryStringNew = ltrim($queryStringNew,'&');
- $queryStringNew = rtrim($queryStringNew,'&');
- return $queryStringNew;
- }
-
+if ($resultTarget == 'file') {
+ for($i=0; $i<count($searchResources);$i++){
+ $str = "nohup php5 /data/mapbender/http/php/mod_metadataWrite.php ";
+ $str .= "'".$userId."' ";
+ $str .= "'".$searchId."' ";
+ $str .= "'".$searchText."' ";
+ $str .= "'".$registratingDepartments."' ";
+ $str .= "'".$isoCategories."' ";
+ $str .= "'".$inspireThemes."' ";
+ $str .= "'".$timeBegin."' ";
+ $str .= "'".$timeEnd."' ";
+ $str .= "'".$regTimeBegin."' ";
+ $str .= "'".$regTimeEnd."' ";
+ $str .= "'".$maxResults."' ";
+ $str .= "'".$searchBbox."' ";
+ $str .= "'".$searchTypeBbox."' ";
+ $str .= "'".$accessRestrictions."' ";
+ $str .= "'".$languageCode."' ";
+ $str .= "'".$searchEPSG."' ";
+ $str .= "'".$searchResources[$i]."' ";
+ $str .= "'".$searchPages[$i]."' ";
+ $str .= "'".$outputFormat."' ";
+ $str .= "'".$resultTarget."' ";
+ $str .= "'".$searchURL."' ";
+ $str .= "'".$customCategories."' ";
+ $str .= "'".$hostName."' ";
+ $str .= "'".$orderBy."' ";
+ $str .= " & ";
+ $e = new mb_exception($str);
+ exec($str);
+ }
}
+if ($resultTarget == 'web' or $resultTarget == 'debug') {
+ if (count($searchResources) == 1) {
+ $metadata = new searchMetadata($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResources[0], $searchPages[0], $outputFormat, $resultTarget, $searchURL, $customCategories, $hostName, $orderBy);
+ #if ($outputFormat == 'xml') {
+ # header("Content-type: application/xhtml+xml; charset=UTF-8");
+ #}
+ #echo "class initiated<br>";
+ }
+ else {
+ echo "Result for web can only requested for one type of resource (wms, wfs, wmc, georss)!";
+ }
+}
+/*
+How does the webservice look like?
+First request: Do search for all classes.
+Next request: Search only in the requested class and the numbered page.
+search.php?q=test&classes=wms,wfs,wmc,georss&pages=1,1,1,1&iso=1,2,3&inspire=1,2,3,4&department=1,2,3,4&bbox=123,123,123,123
+simple other request:
+search.php?q=test&classes=wms&pages=2&iso=1,2,3&inspire=1,2,3,4&department=1,2,3,4&beginDate=2009-10-10&endDate=2010-11-12&searchId=12hjxa31231
+There is a possibility to exchange some classes by other information - the id will be used to update the search result files - but this can only update the class infos. The pagenumber should be updated in the metadata file
+*/
+//
+//Name of searchMetadata file
+//searchid_classes.json
+//Name of searchCategories file
+//Name of searchResult files
+//searchid_wms_1.json
+//searchid_wfs_1.json
+//searchid_wmc_1.json - doesn't exists till now
+//searchid_georss_1.json - doesn't exists till now
+//categories files - will only be generated when the search is started and resultType = 'file'. if the categories files already exists it will not be updated! - Here we can spare a reasonable amount of calculating power. Another approach is to generate a md5 hash of an ordered searchURL. With this we can cache the requests!
+
+//searchid_wms_cat.json
+//searchid_wfs_cat.json
+//searchid_wmc_cat.json - doesn't exists till now
+//searchid_georss_cat.json - doesn't exists till now
+//searchid_filter.json
+
?>
\ No newline at end of file
Added: trunk/mapbender/http/javascripts/mod_deleteWfsConf_client.html
===================================================================
--- trunk/mapbender/http/javascripts/mod_deleteWfsConf_client.html (rev 0)
+++ trunk/mapbender/http/javascripts/mod_deleteWfsConf_client.html 2010-04-22 09:45:43 UTC (rev 5998)
@@ -0,0 +1,220 @@
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html;CHARSET=iso-8859-1">
+
+<link rel="stylesheet" type="text/css" media="screen,projection" href="../css/admin.screen.css" title="screen" />
+
+<script type='text/javascript'>
+
+
+/*
+ * services['action']: instructs the servercomponent
+ * services['services']: infos about the services (wfs)
+ * services['services']['id']: a list of ids
+ * services['service']['title']: a corresponding list of titles
+ *
+ */
+var services = {};
+/*
+ * wfsConf['action']: instructs the servercomponent
+ * wfsConf['wfs']: the ID of the selected wfs
+ * wfsConf['wfsConf']: infos about the wfs configurations
+ * wfsConf['wfsConf']['id']: a list of ids
+ * wfsConf['wfsConf']['abstract']: a corresponding list of descriptions
+ */
+var wfsConf = {};
+
+/*
+ * guis['action']: instructs the servercomponent
+ * guis['id']: a list of gui-IDs where the current user is owner
+ * guis['selectedGui']: the selected Gui
+ */
+var guis = {};
+
+/*
+ * handleAssignment['action']: instructs the servercomponent
+ * handleAssignment['selectedConf']: a list of wfs-conf Ids
+ * handleAssignment['selectedGui']: the selected Gui
+ */
+var handleAssignment = {}
+
+/*
+ * deleteWfsConf['action']: instructs the servercomponent
+ * deleteWfsConf['confs']: a list of wfs-conf Ids to delete
+ */
+ var deleteWfsConf = {};
+
+
+function getWfsList(){
+ services['action'] = 'getServices';
+ getData(services);
+}
+function getWfsConfData(){
+ wfsConf['action'] = 'getWfsConfData';
+ wfsConf['wfs'] = getSelectedWfs();
+ getData(wfsConf);
+}
+function getSelectedWfs(){
+ var w = document.wfsForm.wfsList;
+ var ind = w.selectedIndex;
+ if(ind == -1){
+ return false;
+ }
+// if(ind == w.options.length-1){
+// return "gui_confs";
+// }
+ return w.options[ind].value;
+}
+function getGuiConfs(){
+ guis['action'] = 'getAssignedGuis';
+ guis['selectedWfs'] = wfsConf['wfs'];
+ guis['selectedConf'] =getSelectedConfs();
+ getData(guis);
+}
+
+function deleteWfsConfs(){
+ deleteWfsConf['action'] = 'deleteSelectedConfs';
+ deleteWfsConf['confs'] = getSelectedConfs();
+ if(deleteWfsConf['confs']){
+ if(confirm("Do you really want to delete the Wfs conf with ID:"+deleteWfsConf['confs']+"?")){
+ getData(deleteWfsConf);
+ }
+ return true;
+ }
+ return false;
+}
+
+function setIndicator(){
+ var str = "<img src='../img/indicator_wheel.gif'>";
+ document.getElementById("indicator").innerHTML = str;
+}
+function removeIndicator(){
+ document.getElementById("indicator").innerHTML = "";
+}
+/*
+ * Ajax-function to get data from the server
+ */
+function getData(obj){
+//console.log(obj);
+ setIndicator();
+ var obj2json = parent.$.toJSON(obj);
+ parent.mb_ajax_post("../php/mod_deleteWfsConf_server.php",{"obj":obj2json}, function (json,status){
+ if(status == 'success'){
+ var dsJson = eval('(' + json + ')');
+ switch(obj['action']){
+ case "getServices":
+ appendServices(dsJson);
+ break;
+ case "getWfsConfData":
+ appendWfsConfData(dsJson);
+ break;
+ case "deleteSelectedConfs":
+ if(dsJson['success']){
+ alert("WFS conf deleted.");
+ getWfsConfData();
+ }
+ break;
+ case "getAssignedGuis":
+ checkGuiConfs(dsJson);
+ break;
+ case "remove":
+ getGuiConfs();
+ break;
+ default:
+ alert("No action specified.....");
+ break;
+ }
+ }
+ else{
+ alert("An error occured!");
+ }
+ removeIndicator();
+ });
+}
+
+function removeChildNodes(node) {
+ while (node.childNodes.length > 0) {
+ var childNode = node.firstChild;
+ node.removeChild(childNode);
+ }
+}
+
+function appendServices(dsJson){
+ services['services'] = dsJson.services;
+ var o = services['services'];
+ removeChildNodes(document.getElementById('wfsList'));
+ for(var i=0; i<o.id.length; i++){
+ appendOption(document.forms[0].wfsList, o.title[i], o.id[i], false);
+ }
+ //appendOption(document.forms[0].wfsList, "WFS Configurations", "-1", false);
+}
+
+function appendWfsConfData(dsJson){
+ wfsConf['wfsConf'] = {};
+ wfsConf['wfsConf'] = dsJson.wfsConf;
+ var o = wfsConf['wfsConf'];
+ document.forms[0].wfsConfList.innerHTML = '';
+ if(o.id){
+ for(var i=0; i<o.id.length; i++){
+ appendOption(document.forms[0].wfsConfList, o.abstract[i], o.id[i], false);
+ }
+ }
+}
+
+function checkGuiConfs(dsJson){
+ var checkedGuis = '';
+ for(var i=0; i<dsJson.assignedGuis.length; i++){
+ if(i>0){
+ checkedGuis += ", ";
+ }
+ checkedGuis += dsJson.assignedGuis[i];
+ //checkedGuis.push(dsJson.assignedGuis[i]);
+ }
+ if(dsJson.assignedGuis.length>0){
+ alert("Achtung: WFS-Konfiguration wird noch in den Guis "+checkedGuis+" verwendet.");
+ }
+}
+
+function getSelectedConfs(){
+ var list = document.forms[0].wfsConfList;
+ var confs = [];
+ for(var i=0; i<list.length; i++){
+ if(list.options[i].selected === true){
+ confs.push(list.options[i].value);
+ }
+ }
+ return confs;
+}
+
+function appendOption(boxObject, optionText, optionValue, selected){
+ var newOption = new Option(optionText,optionValue,false,selected);
+ boxObject.options[boxObject.length] = newOption;
+}
+
+</script>
+</head>
+<body onload='getWfsList();'>
+
+<h1>Delete WFS Configuration </h1>
+<form name='wfsForm'>
+ <div id='indicator'>ahh</div>
+
+ <fieldset class="leftContainer">
+ <legend>WFS List</legend>
+ <p>
+ <select size='4' name='wfsList' id='wfsList' class='wfsList' onchange='getWfsConfData();'></select>
+ </p>
+ </fieldset>
+
+ <fieldset class="leftContainer">
+ <legend>WFS Configuration List</legend>
+ <p>
+ <select size='4' name='wfsConfList' class='wfsConfList' onchange='' multiple="multiple"></select>
+ </p>
+ <input type='button' value='Delete WFS Conf' name='delete' id='deleteButton' onclick='getGuiConfs();deleteWfsConfs();' />
+ </fieldset>
+ <hr />
+</form>
+
+</body>
+</html>
\ No newline at end of file
Modified: trunk/mapbender/http/php/mod_callMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_callMetadata.php 2010-04-21 15:37:42 UTC (rev 5997)
+++ trunk/mapbender/http/php/mod_callMetadata.php 2010-04-22 09:45:43 UTC (rev 5998)
@@ -14,6 +14,7 @@
#http://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php?searchId=wa&searchText=e&outputFormat=json&languageCode=de&resultTarget=debug&searchResources=wms&maxResults=99®istratingDepartments=44,31,52&inspireThemes=11&isoCategories=5,10&searchBbox=7,48,9,51®TimeBegin=2001-12-24®TimeEnd=2020-10-10
#http://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php?searchId=wa&outputFormat=json&languageCode=de&resultTarget=debug&searchResources=wms&maxResults=99®istratingDepartments=44,31,52&inspireThemes=11&isoCategories=5,10&searchBbox=7,48,9,51®TimeBegin=2001-12-24®TimeEnd=2020-10-10
require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+require_once(dirname(__FILE__)."/../../conf/geoportal.conf");
require_once(dirname(__FILE__)."/../classes/class_metadata_new.php");
require_once(dirname(__FILE__)."/../classes/class_json.php");
session_start();
@@ -43,10 +44,31 @@
$resultTarget = "debug";
$searchEPSG = "EPSG:31466";
$classJSON = new Mapbender_JSON;
-$tempFolder = "/tmp";
+#$tempFolder = "/tmp";
+$tempFolder = TMPDIR;
+$orderBy = "rank"; //rank or title or id
+$hostName = $_SERVER['HTTP_HOST'];
+//read the whole query string:
+$searchURL = $_SERVER['QUERY_STRING'];
+//control if some request variables are not set and set them explicit to NULL
+
+$checkForNullRequests = array("registratingDepartments","isoCategories","inspireThemes","customCategories","regTimeBegin","regTimeEnd","timeBegin","timeEnd","searchBbox","searchTypeBbox","searchResources","orderBy","hostName");
+
+
+for($i=0; $i < count($checkForNullRequests); $i++){
+ if (!$_REQUEST[$checkForNullRequests[$i]] or $_REQUEST[$checkForNullRequests[$i]] == 'false' or $_REQUEST[$checkForNullRequests[$i]] == 'undefined') {
+ $_REQUEST[$checkForNullRequests[$i]] = "";
+ $searchURL = delTotalFromQuery($checkForNullRequests[$i],$searchURL);
+ }
+}
+
+
+
+
+
//Read out request Parameter:
if (isset($_REQUEST["searchId"]) & $_REQUEST["searchId"] != "") {
//gernerate md5 representation, cause the id is used as a filename later on! - no validation needed
@@ -123,7 +145,7 @@
}
if (isset($_REQUEST["timeEnd"]) & $_REQUEST["timeEnd"] != "") {
$testMatch = $_REQUEST["timeEnd"];
- $pattern = '/(19|20)[0-9]{2}[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])/';
+ $pattern = '/^(19|20)[0-9]{2}[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/';
if (!preg_match($pattern,$testMatch)){
echo 'timeEnd: <b>'.$testMatch.'</b> is not valid.<br/>';
die();
@@ -166,24 +188,28 @@
$testMatch = NULL;
}
if (isset($_REQUEST["searchBbox"]) & $_REQUEST["searchBbox"] != "") {
- //validate to csv integer list
+ //validate to float/integer
$testMatch = $_REQUEST["searchBbox"];
- $pattern = '/^[-\d,]*$/';
- if (!preg_match($pattern,$testMatch)){
- echo 'searchBbox: <b>'.$testMatch.'</b> is not valid.<br/>';
- die();
- }
- if (count(explode(',',$testMatch)) != 4) {
+ //$pattern = '/^[-\d,]*$/';
+ $pattern = '/^[-+]?([0-9]*\.[0-9]+|[0-9]+)*$/';
+ $testMatchArray = explode(',',$testMatch);
+ if (count($testMatchArray) != 4) {
echo 'searchBbox: <b>'.$testMatch.'</b> has a wrong amount of entries.<br/>';
die();
}
+ for($i=0; $i<count($testMatchArray);$i++){
+ if (!preg_match($pattern,$testMatchArray[$i])){
+ echo 'searchBbox: <b>'.$testMatchArray[$i].'</b> is not a valid coordinate value.<br/>';
+ die();
+ }
+ }
$searchBbox = $testMatch;
$testMatch = NULL;
}
if (isset($_REQUEST["searchTypeBbox"]) & $_REQUEST["searchTypeBbox"] != "") {
//validate to inside / outside - TODO implement other ones than intersects which is default
$testMatch = $_REQUEST["searchTypeBbox"];
- if (!($testMatch == 'inside' or $testMatch == 'outside')){
+ if (!($testMatch == 'inside' or $testMatch == 'outside' or $testMatch == 'intersects')){
echo 'searchTypeBbox: <b>'.$testMatch.'</b> is not valid.<br/>';
die();
}
@@ -213,6 +239,26 @@
$outputFormat = $testMatch;
$testMatch = NULL;
}
+if (isset($_REQUEST["hostName"]) & $_REQUEST["hostName"] != "") {
+ $testMatch = $_REQUEST["hostName"];
+ if (!($testMatch == 'www.geoportal.rlp' or $testMatch == 'www.geoportal.rlp.de' or $testMatch == 'geoportal.rlp' or $testMatch == '10.7.101.165' or $testMatch == 'localhost:16580' or $testMatch == 'localhost')){
+ echo 'hostName: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ $hostName = $testMatch;
+ $testMatch = NULL;
+}
+if (isset($_REQUEST["orderBy"]) & $_REQUEST["orderBy"] != "") {
+ $testMatch = $_REQUEST["orderBy"];
+ if (!($testMatch == 'rank' or $testMatch == 'title' or $testMatch == 'id')){
+ echo 'orderBy: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ $orderBy = $testMatch;
+ $testMatch = NULL;
+}// else {
+//$orderBy= 'rank';
+//}
if (isset($_REQUEST["searchResources"]) & $_REQUEST["searchResources"] != "") {
//validate to wms,wfs,wmc,georss
$testMatch = $_REQUEST["searchResources"];
@@ -262,15 +308,32 @@
$resultTarget = $testMatch;
$testMatch = NULL;
}
-//validate request parameters
-if (!isset($_SESSION['mb_user_id'])) {
- $userId = ANONYMOUS_USER;
+
+if (isset($_REQUEST["userId"]) & $_REQUEST["userId"] != "") {
+ //validate integer to 100 - not more
+ $testMatch = $_REQUEST["userId"];
+ //give max 99 entries - more will be to slow
+ $pattern = '/^[0-9]*$/';
+ if (!preg_match($pattern,$testMatch)){
+ echo 'userId: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ $userId = $testMatch;
+ $testMatch = NULL;
+} else {
+
+if (!isset($_SESSION['mb_user_id']) ) {
+ $userId = ANONYMOUS_USER;
}
else
{
- $userId = $_SESSION['mb_user_id'];
+ $userId = $_SESSION['mb_user_id'];
}
+}
+
+
+
#$searchResources = array('wms','wfs','wmc','georss');
#$searchPages = array(1,1,1,1);
@@ -278,8 +341,15 @@
-//read the whole query string:
-$searchURL = $_SERVER['QUERY_STRING'];
+
+
+
+
+
+
+
+
+
if ($resultTarget == 'debug') {
echo "<br>DEBUG: searchURL: ".$searchURL."<br>";
#echo "<br>DEBUG: languageCode: ".$languageCode."<br>";
@@ -489,6 +559,12 @@
$resourceCategories['wfs'] = 'Such- und Downloaddienste';
$resourceCategories['wmc'] = 'Kartenzusammenstellungen';
$resourceCategories['georss'] = 'Geokodierte Newsfeeds';
+
+ $orderByTitle['header'] = 'Sortierung nach:';
+ $orderByTitle['id'] = 'ID';
+ $orderByTitle['title'] = 'Titel';
+ $orderByTitle['rank'] = 'Relevanz';
+
break;
case 'en':
@@ -506,6 +582,11 @@
$resourceCategories['wmc'] = 'Combined Maps';
$resourceCategories['georss'] = 'Geocodet Newsfeeds';
+ $orderByTitle['header'] = 'Sort by:';
+ $orderByTitle['id'] = 'ID';
+ $orderByTitle['title'] = 'title';
+ $orderByTitle['rank'] = 'relevance';
+
break;
case 'fr':
$classificationElements[0]['name2show'] = 'Suchbegriff(e):';
@@ -522,6 +603,11 @@
$resourceCategories['wmc'] = 'Combined Maps';
$resourceCategories['georss'] = 'Geocodet Newsfeeds';
+ $orderByTitle['header'] = 'Sort by:';
+ $orderByTitle['id'] = 'identification';
+ $orderByTitle['title'] = 'title';
+ $orderByTitle['rank'] = 'relevance';
+
break;
default:
$classificationElements[0]['name2show'] = 'Suchbegriff(e):';
@@ -538,10 +624,16 @@
$resourceCategories['wmc'] = 'Kartenzusammenstellungen';
$resourceCategories['georss'] = 'Geokodierte Newsfeeds';
+ $orderByTitle['header'] = 'Sortierung nach:';
+ $orderByTitle['id'] = 'ID';
+ $orderByTitle['title'] = 'Titel';
+ $orderByTitle['rank'] = 'Relevanz';
+
}
$queryJSON = new stdClass;
$queryJSON->searchFilter = (object) array();
+$queryJSON->searchFilter->origURL = $searchURL;
#$queryJSON->searchFilter->classes = (object) array();
for($i=0; $i<count($searchResources);$i++){
//fill in the different search classes into the filter - the client can generate the headers out of this information
@@ -601,10 +693,56 @@
}
}
-//write out json to file or web
+//generate filter for different order possibilities
+//$queryJSON->searchFilter = (object) array();
+if ($_REQUEST["orderBy"] == '') {
+//echo "<br>orderBy:>".$_REQUEST["orderBy"]."<<br>";
+ $queryJSON->searchFilter->orderFilter->title = $orderByTitle['header'];
+
+ $queryJSON->searchFilter->orderFilter->item[0]->title = $orderByTitle['title'];
+ $queryJSON->searchFilter->orderFilter->item[0]->url = $searchURL."&orderBy=title";
+ $queryJSON->searchFilter->orderFilter->item[1]->title = $orderByTitle['id'];
+ $queryJSON->searchFilter->orderFilter->item[1]->url = $searchURL."&orderBy=id";
+
+} else {
+//read out actual order filter
+switch ($orderBy) {
+ case "rank":
+ $queryJSON->searchFilter->orderFilter->title = $orderByTitle['header'];
+ $queryJSON->searchFilter->orderFilter->item[0]->title = $orderByTitle['id'];
+
+ $queryJSON->searchFilter->orderFilter->item[0]->url = str_replace("orderBy=rank", "orderBy=id", $searchURL);
+ $queryJSON->searchFilter->orderFilter->item[1]->title = $orderByTitle['title'];
+
+ $queryJSON->searchFilter->orderFilter->item[1]->url = str_replace("orderBy=rank", "orderBy=title", $searchURL);
+ break;
+ case "id":
+ $queryJSON->searchFilter->orderFilter->title = $orderByTitle['header'];
+ $queryJSON->searchFilter->orderFilter->item[0]->title = $orderByTitle['rank'];
+
+ $queryJSON->searchFilter->orderFilter->item[0]->url = str_replace("orderBy=id", "orderBy=rank", $searchURL);
+ $queryJSON->searchFilter->orderFilter->item[1]->title = $orderByTitle['title'];
+
+ $queryJSON->searchFilter->orderFilter->item[1]->url = str_replace("orderBy=id", "orderBy=title", $searchURL);
+ break;
+ case "title":
+ $queryJSON->searchFilter->orderFilter->title = $orderByTitle['header'];
+ $queryJSON->searchFilter->orderFilter->item[0]->title = $orderByTitle['rank'];
+
+ $queryJSON->searchFilter->orderFilter->item[0]->url = str_replace("orderBy=title", "orderBy=rank", $searchURL);
+ $queryJSON->searchFilter->orderFilter->item[1]->title = $orderByTitle['id'];
+
+ $queryJSON->searchFilter->orderFilter->item[1]->url = str_replace("orderBy=title", "orderBy=id", $searchURL);
+ break;
+
+}
+}
+
+//write out json to file or web
+
$queryFilter = $classJSON->encode($queryJSON);
if ($resultTarget == 'debug') {
@@ -613,13 +751,19 @@
}
if ($resultTarget == 'file') {
$filename = $tempFolder."/".$searchId."_filter.json";
- if($catFileHandle = fopen($filename, "w")){
- fwrite($catFileHandle,$queryFilter);
- fclose($catFileHandle);
- $e = new mb_notice("php/callMetdata.php: new filter_file created!");
+ if (file_exists($filename)) {
+ $e = new mb_notice("php/callMetdata.php: The file $filename exists - it will not be overwritten!");
+
} else {
+ if($catFileHandle = fopen($filename, "w")){
+ fwrite($catFileHandle,$queryFilter);
+ fclose($catFileHandle);
+ $e = new mb_notice("php/callMetdata.php: new filter_file created!");
+ } else {
$e = new mb_notice("php/callMetdata.php: cannot create filter_file!");
+ }
}
+
}
//function to transpose a matrix - sometimes needed to do an array search
function flipDiagonally($arr) {
@@ -660,8 +804,9 @@
//function to remove one complete get param out of the query
function delTotalFromQuery($paramName,$queryString) {
+ //echo $paramName ."<br>";
$queryString = "&".$queryString;
- $queryStringNew = preg_replace('/\b'.$paramName.'\=[^&]+&?/',"",$queryString);
+ $queryStringNew = preg_replace('/\b'.$paramName.'\=[^&]*&?/',"",$queryString); //TODO find empty get params
$queryStringNew = ltrim($queryStringNew,'&');
$queryStringNew = rtrim($queryStringNew,'&');
return $queryStringNew;
@@ -697,6 +842,8 @@
$str .= "'".$resultTarget."' ";
$str .= "'".$searchURL."' ";
$str .= "'".$customCategories."' ";
+ $str .= "'".$hostName."' ";
+ $str .= "'".$orderBy."' ";
$str .= " & ";
$e = new mb_exception($str);
exec($str);
@@ -704,7 +851,7 @@
}
if ($resultTarget == 'web' or $resultTarget == 'debug') {
if (count($searchResources) == 1) {
- $metadata = new searchMetadata($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResources[0], $searchPages[0], $outputFormat, $resultTarget, $searchURL, $customCategories);
+ $metadata = new searchMetadata($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResources[0], $searchPages[0], $outputFormat, $resultTarget, $searchURL, $customCategories, $hostName, $orderBy);
#if ($outputFormat == 'xml') {
# header("Content-type: application/xhtml+xml; charset=UTF-8");
#}
Modified: trunk/mapbender/http/php/mod_deleteWFS.php
===================================================================
--- trunk/mapbender/http/php/mod_deleteWFS.php 2010-04-21 15:37:42 UTC (rev 5997)
+++ trunk/mapbender/http/php/mod_deleteWFS.php 2010-04-22 09:45:43 UTC (rev 5998)
@@ -17,10 +17,17 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#session_start();
+$e_id="deleteWFS";
import_request_variables("PG");
-$e_id="deleteWFS";
require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
-require_once(dirname(__FILE__)."/../classes/class_administration.php");
+#require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+#$con = db_connect($DBSERVER,$OWNER,$PW);
+#db_select_db(DB,$con);
+#require_once(dirname(__FILE__)."/../classes/class_administration.php");
+#$admin = new administration();
+#$ownguis = $admin->getGuisByOwner($_SESSION["mb_user_id"],true);
+$gui_id = Mapbender::session()->get("mb_user_gui");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
@@ -40,14 +47,61 @@
<script type="text/javascript">
function validate(){
var ind = document.form1.wfsList.selectedIndex;
+ var wfsData = document.form1.wfsList.options[ind].value.split("###");
if(ind > -1){
- var permission = confirm("delete: " + document.form1.wfsList.options[ind].text + " ?");
+ var permission = confirm("delete: " + wfsData[0] + " ?");
if(permission === true){
- document.form1.del.value = 1;
+ document.form1.del.value = wfsData[0];
document.form1.submit();
}
}
}
+
+
+
+
+
+
+function sel(){
+ var ind = document.form1.wfsList.selectedIndex;
+ var wfsData = document.form1.wfsList.options[ind].value.split("###");
+ var i,wfsConfList,wfsConfLinkList;
+ var wfsConfList = wfsData[1].split(",");
+ //document.form1.capURL.value = wmsData[1];
+ //document.form1.myWMS.value = wmsData[0];
+ //new for showing metadata - 30.05.2008 AR
+ document.getElementById("metadatalink").href = "mod_wfsMetadata.php?wfs_id="+wfsData[0];
+ document.getElementById("metadatatext").firstChild.nodeValue = "WFS-ID: "+wfsData[0];
+ //delete all childs of wfsconflist
+ var countChild = document.getElementById("wfsconflist").childNodes.length;
+ for (i = 0; i < countChild; ++i) {
+ document.getElementById("wfsconflist").removeChild(document.getElementById("wfsconflist").childNodes[0]);
+ }
+ //document.getElementById("wfsconflist").removeChild(document.getElementById("wfsconflist").firstChild);
+ if (wfsData[1] != "") {
+ for (i = 0; i < wfsConfList.length; ++i) {
+ //create anchors:
+ var newAnchor = document.createElement("a");
+ //var newBr = document.createElement("br");
+ var newSpace = document.createTextNode(" | ");
+ var newAnchorText = document.createTextNode("WFS-CONF: " + wfsConfList[i]);
+ //set anchor href
+ newAnchor.setAttribute("href", "mod_featuretypeMetadata.php?wfs_conf_id=" + wfsConfList[i]);
+ newAnchor.setAttribute("onclick","window.open(this.href,'Metadaten','width=500,height=600,left=100,top=200,scrollbars=yes ,dependent=yes'); return false");
+ newAnchor.appendChild(newAnchorText);
+ //newAnchor.appendChild(newSpace);
+ //append childs
+ document.getElementById("wfsconflist").appendChild(newAnchor);
+ document.getElementById("wfsconflist").appendChild(newSpace);
+ }
+ //delete last komma
+ }
+ document.getElementById("guilist").firstChild.nodeValue = wfsData[2];
+ //ggf. create child
+ //document.getElementById("wfsConfTable").firstChild.nodeValue = wfsConfLinkList;
+ //end ***
+}
+
</script>
<style type="text/css">
@@ -69,29 +123,94 @@
$logged_user_id=Mapbender::session()->get("mb_user_id");
###delete
-if($wfsList){
- $sql = "DELETE FROM wfs WHERE wfs_id = $1";
- $v = array($wfsList);
- $t = array("i");
- $res = db_prep_query($sql, $v, $t);
+if($_REQUEST['del']!='-1'){
+ $sql = "DELETE FROM wfs WHERE wfs_id = '".$_REQUEST['del']."'";
+ $res = db_query($sql);
}
-
-$sql_wfs = "SELECT * FROM wfs ORDER BY wfs_id";
+//adopted for owned wfs and not all!!!!!!
+$sql_wfs = "SELECT * FROM wfs ";
+$sql_wfs .= " where wfs_owner=".$_SESSION["mb_user_id"]." ORDER BY wfs_name";
$res_wfs = db_query($sql_wfs);
$cnt_wfs = 0;
-echo "<form name='form1' action='" . $self ."' method='post'>";
+echo "<form name='form1' action='" . $PHP_SELF . "?".SID."' method='post'>";
echo "<br><b>WFS List: <b><br><br>";
-echo "<select class='wfsList' size='20' name='wfsList' >";
+echo "<select class='wfsList' size='20' name='wfsList' onchange='sel();'>";
+//var wfsInfo = this.value.split(\"###\");document.form1.wfsList.value=wfsInfo[0];
+//morgen zu kontrollieren
-while($row = db_fetch_array($res_wfs)){
- echo "<option value='".$row["wfs_id"]."'>".$row["wfs_id"]." ".$row["wfs_name"]." - ".$row["wfs_title"]."</option>";
+while($row1 = db_fetch_array($res_wfs)){
+
+ $wfs_conf_gui=array();
+ //$wfs_conf_gui_single=array();
+ $wfs_conf_id=array();
+
+ //get wfs_conf information by wfs_id
+ $sql_wfs_conf = "SELECT wfs_conf_id, wfs_conf_abstract from wfs_conf where fkey_wfs_id=".$row1["wfs_id"]."";
+ $res_wfs_conf = db_query($sql_wfs_conf);
+ $cnt_wfs_conf=0;
+
+ while($row2 = db_fetch_array($res_wfs_conf)){
+ //$wfs_conf[$cnt_wfs_conf]=$row2["wfs_conf_id"];
+ array_push($wfs_conf_id,$row2["wfs_conf_id"]);
+ //get GUI list assigned to wfs_conf
+ $sql_wfs_conf_gui = "select fkey_gui_id from gui_element_vars where var_name = 'wfsConfIdString' and ',' || var_value || ',' like '%,".$row2["wfs_conf_id"].",%'";
+ $res_wfs_conf_gui = db_query($sql_wfs_conf_gui);
+ $cnt_wfs_gui=0;
+ while($row3 = db_fetch_array($res_wfs_conf_gui)){
+ array_push($wfs_conf_gui,$row3["fkey_gui_id"]);
+ //$wfs_conf_gui[$cnt_wfs_gui]=$row3["wfs_conf_id"];
+ $cnt_wfs_gui++;
+ }
+ $cnt_wfs_conf++;
+ }
+ //make the entries unique
+ $unique_wfs_conf=array_unique($wfs_conf_id);
+ $unique_wfs_gui=array_unique($wfs_conf_gui);
+ //create lists:
+ $str_wfs_conf="";
+ $str_wfs_gui="";
+
+ for ($i = 0; $i < count($unique_wfs_conf); $i++) {
+ $str_wfs_conf.=",".$unique_wfs_conf[$i];
+ }
+ $str_wfs_conf=ltrim($str_wfs_conf, ",");
+
+ for ($i = 0; $i < count($unique_wfs_gui); $i++) {
+ $str_wfs_gui.=",".$unique_wfs_gui[$i];
+ }
+ $str_wfs_gui=ltrim($str_wfs_gui, ",");
+
+ //output to table
+ echo "<option value='".$row1["wfs_id"]."###".$str_wfs_conf."###".$str_wfs_gui."'>".$row1["wfs_name"]." - ".$row1["wfs_title"]."</option>";
$cnt_wfs++;
}
echo "</select><br><br>";
+?>
+<!--Line for showing wfs metadata-->
+ View wfs metadata: <a id='metadatalink' href='' onclick="window.open(this.href,'Metadata','width=500,height=600,left=100,top=200,scrollbars=yes ,dependent=yes'); return false" target="_blank"><span id="metadatatext">no WFS selected</span></a><br><br>
+List of dependend wfs_conf:
+ <div id="wfsconflist"> no WFS selected</div><br><br>
+
+
+List of GUIs where dependend wfs_conf are used:<span id="guilist"> no WFS selected</span><br><br>
+<?php
+
+//kann ja nur beim neu laden passieren. Man sollte hier dynamisch was hineinsetzen lassen(javascript) dafuer muss es aber schon vorher ausgewaehlt worden sein, d.h. die options um titel_list, abstarct_list, wfs_conf_id_list, sowie GUI_list erweitern lassen. is aufwand!
+//Liste der wfs_conf's
+//SELECT wfs_conf_id, wfs_conf_abstract from wfs_conf where fkey_wfs_id=...
+//hier muss tabelle angezeigt werden
+//Liste der GUI's die eine WFS Conf des WFS enthalten
+//select fkey_gui_id from gui_element_vars where var_name = 'wfsConfIdString' and ',' || var_value || ',' like '%,54,%'
+//muss iterativ ueber or verknuepft werden!
+
+
+
echo "<input class='button_del' type='button' value='delete' onclick='validate()'>";
?>
-<input type='hidden' name='del'>
+<input type='hidden' name='del' value='-1'>
</form>
+
+
</body>
</html>
Added: trunk/mapbender/http/php/mod_deleteWfsConf_server.php
===================================================================
--- trunk/mapbender/http/php/mod_deleteWfsConf_server.php (rev 0)
+++ trunk/mapbender/http/php/mod_deleteWfsConf_server.php 2010-04-22 09:45:43 UTC (rev 5998)
@@ -0,0 +1,190 @@
+<?php
+session_start();
+include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
+require_once(dirname(__FILE__)."/../classes/class_wfs.php");
+include_once(dirname(__FILE__)."/../extensions/JSON.php");
+
+//db connection
+$con = db_connect(DBSERVER,OWNER,PW);
+db_select_db(DB,$con);
+
+$json = new Services_JSON();
+$obj = $json->decode(stripslashes($_REQUEST['obj']));
+
+//workflow:
+switch($obj->action){
+ case 'getServices':
+ $obj->services = getServices($obj);
+ sendOutput($obj);
+ break;
+ case 'getWfsConfData':
+ $obj->wfsConf = getWfsConfData($obj->wfs);
+ sendOutput($obj);
+ break;
+ case 'getAssignedGuis':
+ $obj->assignedGuis = getAssignedGuis($obj);
+ sendOutput($obj);
+ break;
+ case 'deleteSelectedConfs':
+ deleteWfsConf($obj);
+ sendOutput($obj);
+ break;
+ default:
+ sendOutput("no action specified...");
+}
+
+
+/*
+ * Get all services (ids and titles) where the current user is owner
+ *
+ * @return mixed[] services the ids and titles of the services
+ */
+function getServices(){
+ global $con;
+ $services = array();
+ $services['id'] = array();
+ $services['title'] = array();
+ $adm = new administration();
+ $serviceList = $adm->getWfsByOwner($_SESSION['mb_user_id']);
+ if(count($serviceList) == 0){
+ return false;
+ }
+ $sql = "SELECT * FROM wfs WHERE wfs_id IN(".join(",",$serviceList).") ORDER BY wfs_title";
+ $res = db_query($sql);
+ while($row = db_fetch_array($res)){
+ array_push($services['id'], $row['wfs_id']);
+ array_push($services['title'], $row['wfs_title']);
+ }
+ return $services;
+}
+
+/*
+ * Get all configurations of the selcted wfs if the current user is owner
+ *
+ * @return mixed[]
+ */
+function getWfsConfData($wfsID){
+ global $con;
+ // re-check permission
+ $adm = new administration();
+ $serviceList = $adm->getWfsByOwner($_SESSION['mb_user_id']);
+ if(in_array($wfsID, $serviceList)){
+ $wfsConf = array();
+ $wfsConf['id'] = array();
+ $wfsConf['abstract'] = array();
+ $sql = "SELECT * FROM wfs_conf WHERE fkey_wfs_id = $1 ORDER BY wfs_conf_abstract";
+ $v = array($wfsID);
+ $t = array('i');
+ $res = db_prep_query($sql,$v,$t);
+ $cnt = 0;
+ while($row = db_fetch_array($res)){
+ array_push($wfsConf['id'], $row['wfs_conf_id']);
+ array_push($wfsConf['abstract'], $row['wfs_conf_abstract']);
+ $cnt++;
+ }
+ if($cnt == 0){
+ return false;
+ }
+ else{
+ return $wfsConf;
+ }
+ }
+// else if($wfsID==="gui_confs"){
+// $wfsConf = array();
+// $wfsConf['id'] = array();
+// $wfsConf['abstract'] = array();
+// $wfsConf['id'] = $adm->getWfsConfByPermission($_SESSION['mb_user_id']);
+// $cnt = 0;
+// foreach($wfsConf['id'] as $wfscid){
+// $sql = "SELECT wfs_conf_abstract FROM wfs_conf WHERE wfs_conf_id = $1";
+// $v = array($wfscid);
+// $t = array('i');
+// $res = db_prep_query($sql,$v,$t);
+// while($row = db_fetch_array($res)){
+// array_push($wfsConf['abstract'], $row['wfs_conf_abstract']);
+// }
+// $cnt++;
+// }
+// if($cnt == 0){
+// return false;
+// }
+// else{
+// return $wfsConf;
+// }
+// }
+
+}
+
+/*
+ * get all guis which are assigned to the selected wfs conf
+ * @param
+ * @return mixed[]
+ */
+function getAssignedGuis($obj){
+ global $con;
+ $guis = array();
+ $wfsConf['id'] = array();
+ $wfsConf['id'] = $obj->selectedConf;
+ $confs = "";
+ foreach($wfsConf['id'] as $wfsConfId){
+ if($confs!=''){
+ $confs .= ",";
+ }
+ $confs .= $wfsConfId;
+ }
+
+ if($confs === false){
+ return false;
+ }
+ $sql = "SELECT * FROM gui_wfs_conf WHERE fkey_wfs_conf_id IN (".$confs.")";
+ $res = db_query($sql);
+ if(!$res){
+ $e = new mb_exception("Error: SQL: " . $sql . " -> WFS conf: " .$obj->selectedConf);
+ }
+ while($row = db_fetch_array($res)){
+ array_push($guis, $row['fkey_gui_id']);
+ }
+ return $guis;
+}
+
+/*
+ * deletes a WFS conf
+ *
+ * @param object the un-encoded object
+ * @return boolean success
+ */
+function deleteWfsConf($obj){
+ global $con;
+ $wfsConf['id'] = array();
+ $wfsConf['id'] = $obj->confs;
+ foreach($wfsConf['id'] as $wfsConfId){
+ $sql = "DELETE FROM gui_wfs_conf WHERE fkey_wfs_conf_id =$1";
+ $v = array($wfsConfId);
+ $t = array('i');
+ $res = db_prep_query($sql,$v,$t);
+
+ $sql1 = "DELETE FROM wfs_conf WHERE wfs_conf_id = $1";
+ $v1 = array($wfsConfId);
+ $t1 = array('i');
+ $res1 = db_prep_query($sql1,$v1,$t1);
+ }
+ $obj->success = true;
+ return true;
+}
+
+/*
+ * encodes and delivers the data
+ *
+ * @param object the un-encoded object
+ */
+function sendOutput($out){
+ global $json;
+ $output = $json->encode($out);
+ header("Content-Type: text/x-json");
+ echo $output;
+}
+
+
+?>
\ No newline at end of file
Modified: trunk/mapbender/http/php/mod_metadataWrite.php
===================================================================
--- trunk/mapbender/http/php/mod_metadataWrite.php 2010-04-21 15:37:42 UTC (rev 5997)
+++ trunk/mapbender/http/php/mod_metadataWrite.php 2010-04-22 09:45:43 UTC (rev 5998)
@@ -22,5 +22,8 @@
$resultTarget = $_SERVER["argv"][20];
$searchURL = $_SERVER["argv"][21];
$customCategories = $_SERVER["argv"][22];
-$metadata = new searchMetadata($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResources, $searchPages, $outputFormat, $resultTarget, $searchURL,$customCategories);
+$hostName = $_SERVER["argv"][23];
+$orderBy = $_SERVER["argv"][24];
+
+$metadata = new searchMetadata($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResources, $searchPages, $outputFormat, $resultTarget, $searchURL, $customCategories, $hostName, $orderBy);
?>
\ No newline at end of file
Modified: trunk/mapbender/http/php/mod_updateWMS.php
===================================================================
--- trunk/mapbender/http/php/mod_updateWMS.php 2010-04-21 15:37:42 UTC (rev 5997)
+++ trunk/mapbender/http/php/mod_updateWMS.php 2010-04-22 09:45:43 UTC (rev 5998)
@@ -26,6 +26,11 @@
$myWMS = $_POST["myWMS"];
$myURL = $_POST["myURL"];
+$secParams = SID."&guiID=".$_REQUEST["guiID"]."&elementID=".$_REQUEST["elementID"];
+$self = $PHP_SELF."?".$secParams;
+
+
+
?>
<html>
<head>
@@ -52,6 +57,11 @@
var wmsData = document.form1.selWMS.options[ind].value.split("###");
document.form1.capURL.value = wmsData[1];
document.form1.myWMS.value = wmsData[0];
+ //new for showing metadata - 30.05.2008 AR
+ document.getElementById("metadatalink").href = "mod_layerMetadata.php?id="+wmsData[2];
+ document.getElementById("metadatatext").firstChild.nodeValue = "WMS-ID: "+wmsData[0];
+ //end ***
+
}
</script>
</head>
@@ -71,7 +81,8 @@
$v = array();
$t = array();
$c = 1;
- $sql = "SELECT wms_id, wms_title, wms_getcapabilities, wms_upload_url FROM wms ";
+ //$sql = "SELECT wms_id, wms_title, wms_getcapabilities, wms_upload_url FROM wms ";
+ $sql = "SELECT wms.wms_id, wms.wms_title, wms.wms_getcapabilities, wms.wms_upload_url, layer.layer_id FROM wms, layer ";
$sql .= "WHERE wms_id IN(";
for($i=0; $i<count($wms_id_own); $i++){
if($wms_id_own[$i] != ''){
@@ -82,16 +93,24 @@
$c++;
}
}
- $sql .= ")";
+ //$sql .= ")";
+ //select has been adopted for showing metadata
+ $sql .= ") AND wms.wms_id=layer.fkey_wms_id and layer.layer_pos=0";
$sql .= " ORDER BY wms_title";
$res = db_prep_query($sql,$v,$t);
$cnt = 0;
echo "<select name='selWMS' size='15' onchange='sel()'>";
while($row = db_fetch_array($res)){
- echo "<option value='".$row['wms_id']."###".$row['wms_upload_url']."'>".$row['wms_title']."</option>";
+ //echo "<option value='".$row['wms_id']."###".$row['wms_upload_url']."'>".$row['wms_title']."</option>";
+ echo "<option value='".$row['wms_id']."###".$row['wms_upload_url']."###".$row['layer_id']."'>".$row['wms_title']."</option>";
$cnt++;
}
echo "</select><br /><br />";
+ ?>
+ <!--Line for showing wms metadata-->
+ view wms metadata: <a id='metadatalink' href='' onclick="window.open(this.href,'Metadaten','width=500,height=600,left=100,top=200,scrollbars=yes ,dependent=yes'); return false" target="_blank"><span id="metadatatext">no WMS selected</span></a><br><br>
+<?php
+
echo "Link to the last uploaded Online Resource URL:<br><input type='text' size='120' name='capURL'><br />";
echo "<input type='hidden' name='myWMS' value=''><br>";
echo "Add the following REQUEST to the Online Resource URL to obtain the Capabilities document:<br>";
@@ -110,6 +129,7 @@
$mywms->createObjFromXML($myURL);
$mywms->optimizeWMS();
echo "<br />";
+ //$mywms->overwrite=false; //TODO:this handling is used if the information should not be overwritten in the mapbender database. The owner has to explicitly overwrite them in the metadata editor - like geoportal.rlp
$mywms->updateObjInDB($myWMS);
$mywms->displayWMS();
More information about the Mapbender_commits
mailing list