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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Jan 20 11:29:21 EST 2011


Author: armin11
Date: 2011-01-20 08:29:20 -0800 (Thu, 20 Jan 2011)
New Revision: 7464

Modified:
   trunk/mapbender/http/classes/class_metadata_new.php
   trunk/mapbender/http/php/mod_callMetadata.php
Log:
Extent search interface for returning a link list with different maxResults parameters. The parameters are defined in mod_callMetadata.php as array(5,10,15,20).

Modified: trunk/mapbender/http/classes/class_metadata_new.php
===================================================================
--- trunk/mapbender/http/classes/class_metadata_new.php	2011-01-20 14:46:09 UTC (rev 7463)
+++ trunk/mapbender/http/classes/class_metadata_new.php	2011-01-20 16:29:20 UTC (rev 7464)
@@ -90,6 +90,7 @@
 		$this->maxWeight = 0;
 		$this->scale = 'linear';
 		$this->minFontSize = 10;
+	
 
 
 
@@ -236,7 +237,7 @@
 						$this->orderBy = " ORDER BY load_count DESC";
 						break;
 					case "id":
-						$this->orderBy = " ORDER BY wms_id,layer_pos DESC";
+						$this->orderBy = " ORDER BY wms_id,layer_pos ASC";
 						break;
 					case "title":
 						$this->orderBy = " ORDER BY layer_title ";
@@ -260,10 +261,10 @@
 
 				switch ($this->orderBy) {
 					case "rank":
-						$this->orderBy = " ORDER BY wmc_id ";
+						$this->orderBy = " ORDER BY load_count DESC ";
 						break;
 					case "id":
-						$this->orderBy = " ORDER BY wmc_id ";
+						$this->orderBy = " ORDER BY wmc_id";
 						break;
 					case "title":
 						$this->orderBy = " ORDER BY wmc_title ";
@@ -735,22 +736,6 @@
 				echo $this->wfsJSON;
 			}
 		}
-		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);
-				}
-			}
-			if ($this->resultTarget == 'web') {
-				header("Content-type: application/xhtml+xml; charset=UTF-8");
-				echo $xmlDoc->saveXML();
-			}
-		}
 		
 		$e = new mb_notice("Time to generate WFS-Metadata: ".$usedTime);
 		$e = new mb_notice("Wrote the MD_WFS-File");
@@ -1243,129 +1228,6 @@
 	}
 
 
-
-
-	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);
-	}
-
 	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 = "";
@@ -1647,7 +1509,7 @@
 		#echo $returnJSON;
 		return array($hasConstraints, $symbolLink);
 	}
-	//function to delete one of the comma separated values from one get request
+	//function to delete one of the comma separated values from a HTTP-GET request
 	//
 	//
 	//
@@ -1715,8 +1577,9 @@
 				die();
 			}
 		}*/
-	}	
-
+	}
+	
+// function to add a new variable or complete parameter to a GET parameter query url 
 	private function addToQuery($paramName,$queryString,$string,$queryList) {
 		//test if string was part of query before, if so, don't extent the query
 		//TODO: the strings come from json and so they are urlencoded! maybe we have to decode them to find the commata
@@ -1742,7 +1605,8 @@
 			return $queryString;
 		}
 	}
-	//for debugging purposes
+
+//for debugging purposes only
 	private function logit($text){
 	 	if($h = fopen("/tmp/class_metadata_new.log","a")){
 					$content = $text .chr(13).chr(10);
@@ -1754,9 +1618,7 @@
 	 	
 	 }
 
-
-
-
+// function to delete one GET parameter totally from a query url 
 	private function delTotalFromQuery($paramName,$queryString) {
 		$queryString = "&".$queryString;
 		#echo "<br>queryString: ".$queryString."<br>";

Modified: trunk/mapbender/http/php/mod_callMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_callMetadata.php	2011-01-20 14:46:09 UTC (rev 7463)
+++ trunk/mapbender/http/php/mod_callMetadata.php	2011-01-20 16:29:20 UTC (rev 7464)
@@ -42,6 +42,7 @@
 #$searchResources = "wms";
 $searchPages = "1";
 $resultTarget = "debug";
+$preDefinedMaxResults = array(5,10,15,20);
 $searchEPSG = "EPSG:31466";
 $classJSON = new Mapbender_JSON;
 #$tempFolder = "/tmp";
@@ -564,6 +565,8 @@
 		$orderByTitle['rank'] = 'Nachfrage';
 		$orderByTitle['date'] = 'Letzte Änderung';
 
+		$maxResultsTitle['header'] = 'Treffer pro Seite:'; 
+
 	
        	break;
         case 'en':
@@ -587,6 +590,8 @@
 		$orderByTitle['rank'] = 'demand';
 		$orderByTitle['date'] = 'last change';
 
+		$maxResultsTitle['header'] = 'Results per page:';
+
         break;
         case 'fr':
         	$classificationElements[0]['name2show'] = 'Suchbegriff(e):';
@@ -609,6 +614,8 @@
 		$orderByTitle['rank'] = 'demand';
 		$orderByTitle['date'] = 'last change';
 
+		$maxResultsTitle['header'] = 'Results per page:';
+
        	break;
      	default:
         	$classificationElements[0]['name2show'] = 'Suchbegriff(e):';
@@ -631,6 +638,8 @@
 		$orderByTitle['rank'] = 'Relevanz';
 		$orderByTitle['date'] = 'Letzte Änderung';
 
+		$maxResultsTitle['header'] = 'Results per page:';
+
 }	
 
 $queryJSON = new stdClass;
@@ -704,15 +713,43 @@
 	}	
 }
 
+//generate filter for different maxResults entries
+//$preDefinedMaxResults
+if ($_REQUEST["maxResults"] == '') {
+	$queryJSON->searchFilter->maxResults->title = $preDefinedMaxResults[0];
+	for ($i=0; $i<(count($preDefinedMaxResults)-1); $i++) {
+		$queryJSON->searchFilter->maxResults->item[$i]->title = $preDefinedMaxResults[$i+1];
+		$queryJSON->searchFilter->maxResults->item[$i]->url = $searchURL."&maxResults=".$preDefinedMaxResults[$i+1];
+	}
+} else {
+	if (in_array($maxResults, $preDefinedMaxResults)) { //is part of preDefined array
+		$queryJSON->searchFilter->maxResults->title = $maxResults;
+		//delete entry from array
+		//$preDefinedMaxResultsRed = deleteEntry($preDefinedMaxResults, $maxResults);
+		for ($i=0; $i<(count($preDefinedMaxResults)); $i++) {
+			$queryJSON->searchFilter->maxResults->item[$i]->title = $preDefinedMaxResults[$i];
+			$queryJSON->searchFilter->maxResults->item[$i]->url = $searchURL."&maxResults=".$preDefinedMaxResults[$i];
+		} 
+	} else { // is some other value 
+		$queryJSON->searchFilter->maxResults->title = $maxResults;
+		for ($i=0; $i<(count($preDefinedMaxResults)); $i++) {
+			$queryJSON->searchFilter->maxResults->item[$i]->title = $preDefinedMaxResults[$i];
+			$queryJSON->searchFilter->maxResults->item[$i]->url = $searchURL."&maxResults=".$preDefinedMaxResults[$i];
+		} 
+	}
+}
 
+
+
+
+
+
 //generate filter for different order possibilities
 
 //$queryJSON->searchFilter = (object) array();
 if ($_REQUEST["orderBy"] == '') {
 //echo "<br>orderBy:>".$_REQUEST["orderBy"]."<<br>";
 	$queryJSON->searchFilter->orderFilter->title = $orderByTitle['rank'];
-	
-
 	$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'];
@@ -852,9 +889,17 @@
 	$queryStringNew = rtrim($queryStringNew,'&');
 	return $queryStringNew;
 }
+//delete all string entries from array
+function deleteEntry($arrayname, $entry) {
+	$n = $arrayname.length;
+	for($i=0; $i<($n+1); $i++){
+		if ($arrayname[$i] == $entry) {
+			$arrayname.splice($i, 1);
+		}
+	}
+	return $arrayname;
+} 
 
-
-
 //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
 
 



More information about the Mapbender_commits mailing list