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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Apr 27 05:18:56 PDT 2018


Author: armin11
Date: 2018-04-27 05:18:56 -0700 (Fri, 27 Apr 2018)
New Revision: 9905

Modified:
   trunk/mapbender/http/classes/class_metadata_new.php
Log:
Show new organization facet in searchResults

Modified: trunk/mapbender/http/classes/class_metadata_new.php
===================================================================
--- trunk/mapbender/http/classes/class_metadata_new.php	2018-04-27 10:41:29 UTC (rev 9904)
+++ trunk/mapbender/http/classes/class_metadata_new.php	2018-04-27 12:18:56 UTC (rev 9905)
@@ -168,6 +168,18 @@
 		$this->resourceClassifications[2]['relation_wmc'] = 'wmc_custom_category';
 		$this->resourceClassifications[2]['relation_dataset'] = 'mb_metadata_custom_category';
 		//TODO: define this in mapbender
+		switch ($this->languageCode) {
+			case "de":
+				$this->resourceClassifications[3]['title'] = "Organisationen";
+				break;
+			case "en":
+				$this->resourceClassifications[3]['title'] = "Organizations";
+				break;
+			default:
+				$this->resourceClassifications[3]['title'] = "Organizations";
+				break;
+		}
+		$this->resourceClassifications[3]['requestName'] = "registratingDepartments";
 
 		//Defining of the different result categories		
 		$this->resourceCategories = array();
@@ -1611,6 +1623,84 @@
 						//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);
+									//uncomment the following line if a or category search is intended
+									//$filteredSearchString = $this->delTotalFromQuery($this->resourceClassifications[$i]['requestName'],$filteredSearchString);
+									//TODO: maybe adopt this to do a and search and not a or like it is done now
+									//check if category search was requested and rewrite the search url
+									//get the value of the param as string or false if not set!
+									$paramValue = $this->getValueForParam($this->resourceClassifications[$i]['requestName'], $filteredSearchString);
+									$paramValue = urldecode($paramValue);
+									if ($paramValue == false) {
+										//add new category to search
+
+									//set filter for this categoryid
+									$filteredSearchString .= "&".$this->resourceClassifications[$i]['requestName']."=".$categoryCounts[$j][$this->resourceClassifications[$i]['tablename']."_id"];
+								
+								
+									} else {
+										//rewrite the searchUrl
+										$filteredSearchString = $this->addToQuery($this->resourceClassifications[$i]['requestName'],$filteredSearchString,$categoryCounts[$j][$this->resourceClassifications[$i]['tablename']."_id"],$paramValue);
+									}
+
+									$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]);
+					}
+					//*********************************************************************
+					//create a facet for publishing organizations
+					$i = 3;
+					switch ($this->languageCode) {
+						case "de":
+							$this->catJSON->searchMD->category[$i]->title = "Organisationen";
+							break;
+						case "en":
+							$this->catJSON->searchMD->category[$i]->title = "Organizations";
+							break;
+						default:
+							$this->catJSON->searchMD->category[$i]->title = "Organizations";
+							break;
+					}
+					$sqlCat[$i] = "SELECT department AS id, COUNT(department) AS count, mb_group.mb_group_name AS title FROM ".$this->searchView." INNER JOIN mb_group ON department = mb_group.mb_group_id";
+					// GROUP BY department, mb_group.mb_group_name";
+					//$e = new mb_exception("test");
+						if ($this->resourceClassifications[$i]['title'] != $this->resourceClassifications[2]['title']){
+							if ($whereStr != '') {
+								$sqlCat[$i] .= " ".$whereStr." GROUP BY ";
+							} else {
+								$sqlCat[$i] .= " GROUP BY ";
+							}
+						} else {
+							if ($whereStr != '') {
+								$sqlCat[$i] .= " ".$whereStr.$this->whereStrCatExtension." GROUP BY ";
+							} else {
+								$sqlCat[$i] .= " WHERE ".$this->whereStrCatExtension." GROUP BY ";
+							}
+						}
+					$sqlCat[$i] .= "department, mb_group.mb_group_name";
+					$sqlCategory = $sqlCat[$i];
+					$e = new mb_exception("class_metadata: countOrgaSql: ".$sqlCategory);
+					//call sql for count of category
+					$res = db_prep_query($sqlCategory, $v, $t);
+					$e = new mb_notice("class_metadata: countCatsql: ".$sqlCategory);
+					$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>";
@@ -1617,8 +1707,8 @@
 							#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]->id = $categoryCounts[$j]["id"];
+								$this->catJSON->searchMD->category[$i]->subcat[$j]->title = $categoryCounts[$j]["title"];
 								$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);
@@ -1632,23 +1722,21 @@
 								if ($paramValue == false) {
 									//add new category to search
 
-								//set filter for this categoryid
-								$filteredSearchString .= "&".$this->resourceClassifications[$i]['requestName']."=".$categoryCounts[$j][$this->resourceClassifications[$i]['tablename']."_id"];
-								
-								
+									//set filter for this categoryid
+									$filteredSearchString .= "&".$this->resourceClassifications[$i]['requestName']."=".$categoryCounts[$j]["id"];
 								} else {
 									//rewrite the searchUrl
-									$filteredSearchString = $this->addToQuery($this->resourceClassifications[$i]['requestName'],$filteredSearchString,$categoryCounts[$j][$this->resourceClassifications[$i]['tablename']."_id"],$paramValue);
+									$filteredSearchString = $this->addToQuery($this->resourceClassifications[$i]['requestName'],$filteredSearchString,$categoryCounts[$j]["id"],$paramValue);
 								}
-
 								$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]);
+					} else {
+						#$this->catJSON->searchMD->category[$i]->subcat = array();
 					}
+					$e = new mb_notice("class_metadata: countsql: ".$sqlCat[$i]);
+
+					//*********************************************************************
 				}
 
 				$this->catJSON = $this->json->encode($this->catJSON);



More information about the Mapbender_commits mailing list