[Mapbender-commits] r9518 - trunk/mapbender/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Jun 9 07:47:46 PDT 2016


Author: armin11
Date: 2016-06-09 07:47:46 -0700 (Thu, 09 Jun 2016)
New Revision: 9518

Modified:
   trunk/mapbender/http/classes/class_metadata_new.php
Log:
Add database search with wildcard * - disable like filter

Modified: trunk/mapbender/http/classes/class_metadata_new.php
===================================================================
--- trunk/mapbender/http/classes/class_metadata_new.php	2016-06-09 09:22:26 UTC (rev 9517)
+++ trunk/mapbender/http/classes/class_metadata_new.php	2016-06-09 14:47:46 UTC (rev 9518)
@@ -1185,15 +1185,13 @@
 		$e = new mb_notice("Wrote the MD_Dataset-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,wms,wmc view or table:
 		//1. textfield - all texts - searchText
@@ -1205,15 +1203,13 @@
 		$searchStringArray = $this->generateSearchStringArray();
 		$v = array();
 		$t = array();
-		$sql = "SELECT * from ".$this->searchView." where ";
-		#$sqlN = "SELECT count(".$this->searchResources."_id) from ".$this->searchView." where ";
+		$sql = "SELECT * from ".$this->searchView." ";
 		$whereStr = "";
 		$whereCondArray = array();
 		$isTextSearch = "false";
 		$e = new mb_notice("Number of used searchstrings: ".count($searchStringArray));
 		//textsearch
-		
-		if ($this->searchText != NULL) {
+		if ($this->searchText != NULL && trim($this->searchText) != '*') {
 			for($i=0; $i < count($searchStringArray); $i++){
 				$isTextSearch = "true";
 				if($i>0) {
@@ -1230,7 +1226,6 @@
 			}
 		}
 
-
 		// 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!
 		//check for postgis version
 		//sql for get version string
@@ -1425,6 +1420,9 @@
 			$whereStr .= $txt_whereCond;
 		}
 		//Add WHERE condition to search
+		if ($whereStr !== '') {
+			$whereStr = "WHERE ".$whereStr;
+		}
 		$sql .= $whereStr;
 		//TODO ORDER BY in SQL - not necessary for counting things:
 		$sql .= $this->orderBy;
@@ -1442,23 +1440,16 @@
 		return array($sql, $v, $t, $n);
 	}
 
-
-
-
-
-
-
-
-
-
 /** Function to write a json file which includes the categories of the search result for each searchResource - wms/wfs/wmc/georss, new: it should also count the keyword distribution of the searchResource ans save it as a special json file!
 
 **/
 	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;
+		$sqlN = "SELECT count(".$this->searchResources."_id) from ".$this->searchView." ";
+		if ($whereStr != '') {
+			$sqlN .= $whereStr;
+		}
 		//Get total number of results 
 		$count = db_prep_query($sqlN, $v, $t);
 		$n = db_fetch_all($count);



More information about the Mapbender_commits mailing list