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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu May 9 02:43:10 PDT 2019


Author: armin11
Date: 2019-05-09 02:43:10 -0700 (Thu, 09 May 2019)
New Revision: 10117

Modified:
   trunk/mapbender/http/classes/class_metadata.php
   trunk/mapbender/http/php/mod_callMetadata.php
Log:
Fix for calling search interface via https - set urls for metadata and preview to https

Modified: trunk/mapbender/http/classes/class_metadata.php
===================================================================
--- trunk/mapbender/http/classes/class_metadata.php	2019-05-08 14:44:04 UTC (rev 10116)
+++ trunk/mapbender/http/classes/class_metadata.php	2019-05-09 09:43:10 UTC (rev 10117)
@@ -61,8 +61,10 @@
 	var $restrictToOpenData;
 	var $originFromHeader;
 	var $resolveCoupledResources; //only for class of dataset metadata - it pulls the coupled ressources (ogc-services : wms-layer/wfs-featuretypes)
+	var $https;
+	var $protocol;
 
-	function __construct($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResources, $searchPages, $outputFormat, $resultTarget, $searchURL, $customCategories, $hostName, $orderBy, $resourceIds, $restrictToOpenData, $originFromHeader, $resolveCoupledResources = false){
+	function __construct($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResources, $searchPages, $outputFormat, $resultTarget, $searchURL, $customCategories, $hostName, $orderBy, $resourceIds, $restrictToOpenData, $originFromHeader, $resolveCoupledResources = false, $https = false){
 		$this->userId = (integer)$userId;
 		$this->searchId = $searchId;
 		$this->searchText = $searchText;
@@ -98,6 +100,12 @@
 		$this->internalResult = null; //will only be filled, if resultTarget = 'internal', includes json for wms or wfs
 		$this->resolveCoupledResources = $resolveCoupledResources;
 		//definitions for generating tagClouds
+		$this->https = $https;
+		if ($this->https == true) {
+			$this->protocol = "https";
+		} else {
+			$this->protocol = "http";
+		}
 		$this->maxObjects = 15;
 		$this->maxFontSize = 30;
 		$this->maxWeight = 0;
@@ -427,7 +435,7 @@
 				$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]->logoUrl = $wfsMatrix[$i]['mb_group_logo_path'];
-				$this->wfsJSON->wfs->srv[$i-$j]->mdLink = "http://".$this->hostName."/mapbender/php/mod_showMetadata.php?resource=wfs&id=".$wfsMatrix[$i]['wfs_id'];
+				$this->wfsJSON->wfs->srv[$i-$j]->mdLink = $this->protocol."://".$this->hostName."/mapbender/php/mod_showMetadata.php?resource=wfs&id=".$wfsMatrix[$i]['wfs_id'];
 				//TODO: Capabilities link
 				$spatialSource = "";
 				$stateOrProvince = $wfsMatrix[$i]['administrativearea']; 
@@ -464,7 +472,7 @@
 				$this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->name = $otherInformation['featuretypeName'];
 				//TODO featuretype schema
 				$this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->schema = $otherInformation['describeFeaturetypeUrl'];
-				$this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->mdLink = "http://".$this->hostName."/mapbender/php/mod_showMetadata.php?resource=featuretype&id=".$wfsMatrix[$i]['featuretype_id'];
+				$this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->mdLink = $this->protocol."://".$this->hostName."/mapbender/php/mod_showMetadata.php?resource=featuretype&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 = $wfsMatrix[$i]['bbox'];//TODO: $wfsMatrix[$i]['bbox'];
 				//wfs capabilities url:
@@ -510,7 +518,7 @@
 		        		}	
 					$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 = "http://".$this->hostName."/mapbender/php/mod_showMetadata.php?resource=featuretype&id=".$wfsMatrix[$i]['featuretype_id'];
+					$this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->modul[$m]->mdLink = $this->protocol."://".$this->hostName."/mapbender/php/mod_showMetadata.php?resource=featuretype&id=".$wfsMatrix[$i]['featuretype_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;
 				}
@@ -561,8 +569,8 @@
 			$this->wmcJSON->wmc->srv[$i]->loadCount = $wmcMatrix[$i]['load_count'];
 			$this->wmcJSON->wmc->srv[$i]->respOrg = $wmcMatrix[$i]['mb_group_name'];
 			$this->wmcJSON->wmc->srv[$i]->logoUrl = $wmcMatrix[$i]['mb_group_logo_path'];
-			$this->wmcJSON->wmc->srv[$i]->mdLink = "http://".$this->hostName."/mapbender/php/mod_showMetadata.php?languageCode=".$this->languageCode."&resource=wmc&layout=tabs&id=".$wmcMatrix[$i]['wmc_id'];
-			$this->wmcJSON->wmc->srv[$i]->previewURL = "http://".$this->hostName."/mapbender/geoportal/mod_showPreview.php?resource=wmc&id=".$wmcMatrix[$i]['wmc_id'];
+			$this->wmcJSON->wmc->srv[$i]->mdLink = $this->protocol."://".$this->hostName."/mapbender/php/mod_showMetadata.php?languageCode=".$this->languageCode."&resource=wmc&layout=tabs&id=".$wmcMatrix[$i]['wmc_id'];
+			$this->wmcJSON->wmc->srv[$i]->previewURL = $this->protocol."://".$this->hostName."/mapbender/geoportal/mod_showPreview.php?resource=wmc&id=".$wmcMatrix[$i]['wmc_id'];
 			$spatialSource = "";
 			$stateOrProvince = $wmcMatrix[$i]['mb_group_stateorprovince']; 
 			if ($stateOrProvince == "NULL" || $stateOrProvince == "") {
@@ -623,7 +631,7 @@
 			$this->datasetJSON->dataset->srv[$i]->isopen = $datasetMatrix[$i]['isopen'];
 			$this->datasetJSON->dataset->srv[$i]->symbolLink = $symbolLink;
 			//TODO: other url - to metadata uuid!
-			$this->datasetJSON->dataset->srv[$i]->mdLink = "http://".$this->hostName."/mapbender/php/mod_iso19139ToHtml.php?url=".urlencode("http://".$this->hostName."/mapbender/php/mod_dataISOMetadata.php?outputFormat=iso19139&id=").$datasetMatrix[$i]['fileidentifier'];
+			$this->datasetJSON->dataset->srv[$i]->mdLink = $this->protocol."://".$this->hostName."/mapbender/php/mod_iso19139ToHtml.php?url=".urlencode($this->protocol."://".$this->hostName."/mapbender/php/mod_dataISOMetadata.php?outputFormat=iso19139&id=").$datasetMatrix[$i]['fileidentifier'];
 			//TODO: preview?
 			$this->datasetJSON->dataset->srv[$i]->previewURL = $datasetMatrix[$i]['preview_url'];
 			$spatialSource = "";
@@ -882,14 +890,14 @@
 				$this->wmsJSON->wms->srv[$j]->layer[0]->title = $subLayers[$rootIndex]['layer_title'];
 				$this->wmsJSON->wms->srv[$j]->layer[0]->name = $subLayers[$rootIndex]['layer_name'];
 				$this->wmsJSON->wms->srv[$j]->layer[0]->abstract = $subLayers[$rootIndex]['layer_abstract'];
-				$this->wmsJSON->wms->srv[$j]->layer[0]->mdLink = "http://".$this->hostName."/mapbender/php/mod_showMetadata.php?languageCode=".$this->languageCode."&resource=layer&layout=tabs&id=".(integer)$subLayers[$rootIndex]['layer_id'];
-				$this->wmsJSON->wms->srv[$j]->layer[0]->previewURL = "http://".$this->hostName."/mapbender/geoportal/mod_showPreview.php?resource=layer&id=".(integer)$subLayers[$rootIndex]['layer_id'];
+				$this->wmsJSON->wms->srv[$j]->layer[0]->mdLink = $this->protocol."://".$this->hostName."/mapbender/php/mod_showMetadata.php?languageCode=".$this->languageCode."&resource=layer&layout=tabs&id=".(integer)$subLayers[$rootIndex]['layer_id'];
+				$this->wmsJSON->wms->srv[$j]->layer[0]->previewURL = $this->protocol."://".$this->hostName."/mapbender/geoportal/mod_showPreview.php?resource=layer&id=".(integer)$subLayers[$rootIndex]['layer_id'];
 				$legendInfo = $this->getInfofromLayerId($this->wmsJSON->wms->srv[$j]->layer[0]->id);
 				$this->wmsJSON->wms->srv[$j]->layer[0]->getLegendGraphicUrl = $legendInfo['getLegendGraphicUrl'];
 				$this->wmsJSON->wms->srv[$j]->layer[0]->getLegendGraphicUrlFormat = $legendInfo['getLegendGraphicUrlFormat'];
 				$this->wmsJSON->wms->srv[$j]->layer[0]->legendUrl = $legendInfo['legendUrl'];
 				//get capabilities
-				$this->wmsJSON->wms->srv[$j]->layer[0]->getCapabilitiesUrl =  "http://".$this->hostName."/mapbender/php/wms.php?layer_id=".(integer)$subLayers[$rootIndex]['layer_id']."&INSPIRE=1&REQUEST=GetCapabilities&VERSION=1.1.1&SERVICE=WMS";
+				$this->wmsJSON->wms->srv[$j]->layer[0]->getCapabilitiesUrl =  $this->protocol."://".$this->hostName."/mapbender/php/wms.php?layer_id=".(integer)$subLayers[$rootIndex]['layer_id']."&INSPIRE=1&REQUEST=GetCapabilities&VERSION=1.1.1&SERVICE=WMS";
 
 				$this->wmsJSON->wms->srv[$j]->layer[0]->minScale = $legendInfo['minScale'];
 				$this->wmsJSON->wms->srv[$j]->layer[0]->maxScale = $legendInfo['maxScale'];
@@ -1810,7 +1818,7 @@
 			if ($owsProxy != null && $owsProxy != '') {
 				//create dummy session - no one knows the user which requests this metadata!
 				$sessionId = "00000000000000000000000000000000";
-				$getMap = "http://".$this->hostName."/owsproxy/".$sessionId."/".$owsProxy."?";
+				$getMap = $this->protocol."://".$this->hostName."/owsproxy/".$sessionId."/".$owsProxy."?";
 			}
 			return $getMap; 
 
@@ -1833,7 +1841,7 @@
 			//hostname does not exist! - use hostname from parameter instead
 			if ($owsProxy != null && $owsProxy != '' && $getLegendUrl != '' && $getLegendUrl != null) {
 				$sessionId = "00000000000000000000000000000000";
-				$getLegendUrlNew = "http://".$this->hostName."/owsproxy/".$sessionId."/".$owsProxy."?";
+				$getLegendUrlNew = $this->protocol."://".$this->hostName."/owsproxy/".$sessionId."/".$owsProxy."?";
 				//also let go legendurl thru owsproxy exchange first legendurl part with owsproxy part!
 				$legendUrl = str_replace($getLegendUrl,$getLegendUrlNew,$legendUrl);
 				$getLegendUrl = $getLegendUrlNew;
@@ -1863,8 +1871,8 @@
 			}
 			//if proxy is activated change request urls
 			if ($owsProxy != null && $owsProxy != '') {
-				$getCapabilitiesUrl = "http://".$this->hostName."/registry/wfs/".$wfsId."?SERVICE=WFS&VERSION=".$wfsVersion."&REQUEST=GetCapabilities";
-				$describeFeaturetypeUrl = "http://".$this->hostName."/registry/wfs/".$wfsId."?SERVICE=WFS&VERSION=".$wfsVersion."&REQUEST=DescribeFeaturetype&typename=".$featuretypeName;
+				$getCapabilitiesUrl = $this->protocol."://".$this->hostName."/registry/wfs/".$wfsId."?SERVICE=WFS&VERSION=".$wfsVersion."&REQUEST=GetCapabilities";
+				$describeFeaturetypeUrl = $this->protocol."://".$this->hostName."/registry/wfs/".$wfsId."?SERVICE=WFS&VERSION=".$wfsVersion."&REQUEST=DescribeFeaturetype&typename=".$featuretypeName;
 			} else {
 				$getCapabilitiesUrl = $admin->checkURL($getCapabilitiesUrl)."SERVICE=WFS&VERSION=".$wfsVersion."&REQUEST=GetCapabilities";
 				$describeFeaturetypeUrl = $admin->checkURL($describeFeaturetypeUrl)."SERVICE=WFS&VERSION=".$wfsVersion."&REQUEST=DescribeFeaturetype&typename=".$featuretypeName;
@@ -2032,7 +2040,7 @@
 			$servObject->layer[$countsublayer]->title = $child['layer_title'];
 			$servObject->layer[$countsublayer]->name = $child['layer_name'];
 			$servObject->layer[$countsublayer]->abstract = $child['layer_abstract'];
-			$servObject->layer[$countsublayer]->previewURL = "http://".$this->hostName."/mapbender/geoportal/mod_showPreview.php?resource=layer&id=".$child['layer_id'];
+			$servObject->layer[$countsublayer]->previewURL = $this->protocol."://".$this->hostName."/mapbender/geoportal/mod_showPreview.php?resource=layer&id=".$child['layer_id'];
 			$legendInfo = $this->getInfofromLayerId($servObject->layer[$countsublayer]->id);
 			$servObject->layer[$countsublayer]->getLegendGraphicUrl = $legendInfo['getLegendGraphicUrl'];
 			$servObject->layer[$countsublayer]->getLegendGraphicUrlFormat = $legendInfo['getLegendGraphicUrlFormat'];
@@ -2044,7 +2052,7 @@
 			$downloadOptions = json_decode(getDownloadOptions(explode(',',$downloadOptionsCs)));
 			//$e = new mb_exception("class_metadata.php: downloadOptions as string: ".json_encode($downloadOptions));
 			$servObject->layer[$countsublayer]->downloadOptions = $downloadOptions;
-			$servObject->layer[$countsublayer]->mdLink = "http://".$this->hostName."/mapbender/php/mod_showMetadata.php?languageCode=".$this->languageCode."&resource=layer&layout=tabs&id=".$child['layer_id'];
+			$servObject->layer[$countsublayer]->mdLink = $this->protocol."://".$this->hostName."/mapbender/php/mod_showMetadata.php?languageCode=".$this->languageCode."&resource=layer&layout=tabs&id=".$child['layer_id'];
 			if ($child['layer_name'] == ''){
 				$servObject->layer[$countsublayer]->loadable = 0;
 			} else {
@@ -2113,7 +2121,7 @@
 			if (isset($row['termsofuse_id']) & $row['symbollink'] != "") {
  				$symbolLink = $row['symbollink'];
 			} else {
-				$symbolLink = "http://".$this->hostName."/portal/fileadmin/design/icn_warn.png";
+				$symbolLink = $this->protocol."://".$this->hostName."/portal/fileadmin/design/icn_warn.png";
 			}
 			$hasConstraints = true;
 			#$disclaimerLink = $_SERVER['HTTP_HOST']."/mapbender/php/mod_getServiceDisclaimer.php?type=".$type."&id=".$id;
@@ -2122,7 +2130,7 @@
 		} else {
 		//give symbol and false
 		//green symbol
-			$symbolLink = "http://".$this->hostName."/portal/fileadmin/design/icn_ok.png";
+			$symbolLink = $this->protocol."://".$this->hostName."/portal/fileadmin/design/icn_ok.png";
        			#$disclaimerLink = "";
 			$hasConstraints = false;
 			#$symbolMouseOver = "Frei zugänglich"; //TODO internationalize it

Modified: trunk/mapbender/http/php/mod_callMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_callMetadata.php	2019-05-08 14:44:04 UTC (rev 10116)
+++ trunk/mapbender/http/php/mod_callMetadata.php	2019-05-09 09:43:10 UTC (rev 10117)
@@ -61,6 +61,11 @@
 }
 $orderBy = "rank"; //rank or title or id or date
 $hostName = $_SERVER['HTTP_HOST'];
+//https
+$https = false;
+if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
+    $https = true;
+}
 $headers = apache_request_headers();
 $originFromHeader = false;
 foreach ($headers as $header => $value) {
@@ -512,7 +517,6 @@
 
 //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 (";
@@ -1082,13 +1086,13 @@
 		$e = new mb_notice($str);
 		exec($str);*/
 		
-		$metadata = new searchMetadata($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResourcesArray[$i], $searchPages[$i], $outputFormat, $resultTarget, $searchURL, $customCategories, $hostName, $orderBy, $resourceIds, $restrictToOpenData, $originFromHeader, $resolveCoupledResources);
+		$metadata = new searchMetadata($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResourcesArray[$i], $searchPages[$i], $outputFormat, $resultTarget, $searchURL, $customCategories, $hostName, $orderBy, $resourceIds, $restrictToOpenData, $originFromHeader, $resolveCoupledResources, $https);
 	}
 }
 if ($resultTarget == 'web' or $resultTarget == 'debug' or $resultTarget == 'webclient' or $resultTarget == 'categories') {
 	if (count($searchResourcesArray) == 1) {
 		//$e = new mb_exception("originFromHeader: ".$originFromHeader);
-		$metadata = new searchMetadata($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResourcesArray[0], $searchPages[0], $outputFormat, $resultTarget, $searchURL, $customCategories, $hostName, $orderBy, $resourceIds, $restrictToOpenData, $originFromHeader, $resolveCoupledResources);
+		$metadata = new searchMetadata($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResourcesArray[0], $searchPages[0], $outputFormat, $resultTarget, $searchURL, $customCategories, $hostName, $orderBy, $resourceIds, $restrictToOpenData, $originFromHeader, $resolveCoupledResources, $https);
 		#if ($outputFormat == 'xml') {
 		#	header("Content-type: application/xhtml+xml; charset=UTF-8");		
 		#}



More information about the Mapbender_commits mailing list