[Mapbender-commits] r1160 - trunk/mapbender/http/php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Mar 2 06:19:39 EST 2007


Author: christoph
Date: 2007-03-02 06:19:39 -0500 (Fri, 02 Mar 2007)
New Revision: 1160

Added:
   trunk/mapbender/http/php/mod_gazetteerMetadata.php
Log:


Added: trunk/mapbender/http/php/mod_gazetteerMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_gazetteerMetadata.php	                        (rev 0)
+++ trunk/mapbender/http/php/mod_gazetteerMetadata.php	2007-03-02 11:19:39 UTC (rev 1160)
@@ -0,0 +1,397 @@
+<?php
+# $Id:$
+# module maintainer: Verena Diewald
+# http://www.mapbender.org/index.php/gazetteerMetadata
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# 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();
+
+require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+
+///* user authorization */
+$user_id = $_SESSION["mb_user_id"]; 
+$n = new administration();
+$myguis = $n->getGuisByPermission($user_id,true);
+$mywms = $n->getWmsByOwnGuis($myguis);
+$mylayer = array();
+for($i=0; $i<count($mywms); $i++){
+  $mylayer = array_merge($mylayer,$n->getLayerByWms($mywms[$i]));
+}
+if($mywms == false){
+  $mywms = array();	
+}
+session_start();
+$con = db_connect($DBSERVER,$OWNER,$PW);
+db_select_db(DB,$con);
+
+?>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta name="author" content="V. Diewald">
+<meta http-equiv="cache-control" content="no-cache">
+<meta http-equiv="pragma" content="no-cache">
+<meta http-equiv="expires" content="0">
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta name="DC.Rights" content="WhereGroup GmbH & Co.KG, Bonn">
+<title>Suche</title>
+<?
+$gui_id = $_SESSION["mb_user_gui"];
+ include_once("../include/dyn_css.php");
+ $e_id_css = 'poi';
+?>
+
+
+<style type="text/css">
+<!--
+	body{
+		font-family : Arial, Helvetica, sans-serif;
+		font-size : 12px;
+		font-weight : bold;
+		color: #808080;
+		background-color: 'ffffff';
+	}
+	.header{
+		color: #cc3366;
+	}
+	a:link{
+		font-family : Arial, Helvetica, sans-serif;
+		text-decoration : none;
+		color: #808080;
+		font-size : 12px;
+		font-weight : normal;
+	}
+	a:visited{
+		font-family : Arial, Helvetica, sans-serif;
+		text-decoration : none;
+		color: #808080;
+		font-size : 12px;
+		font-weight : normal;
+	}
+	a:hover{
+		font-family : Arial, Helvetica, sans-serif;
+		color: white;
+		text-decoration : none;
+		font-weight : normal;
+		background-color : #999999;
+	}
+	a:active{
+		font-family : Arial, Helvetica, sans-serif;
+		color: black;
+		text-decoration : none;
+		font-weight : normal;
+	}
+
+	.textfield{
+		border : 2 solid #D3D3D3;
+		font-family : Arial, Helvetica, sans-serif;
+		font-size : 12px;
+		font-weight : normal;
+		color: #000000;
+		width: 100px;
+		position: absolute;
+		left: 75px
+	}
+	
+	.sbutton{
+	font-size : 10px;
+		width: 28px;
+		height: 22px;
+		position: absolute;
+		left: 192px;
+	}
+	
+	.resultFrame{
+	width: 480px;
+	height: 430px;
+	border: 1px;
+	position: absolute;
+	top: 25px;
+	left: 5px;
+	overflow-x : hidden;
+	}
+-->
+</style>
+
+<script type="text/javascript">
+<!--
+
+function validate(){
+
+   if(document.form1.search.value.length < 1){
+      alert("Bitte vervollständigen Sie die Angaben!");
+      document.form1.search.focus();
+      return false;
+   }
+   else{   
+      text = "mod_gazetteerMetadata.php?&search=" + document.form1.search.value;
+      window.frames["result"].location.href = text;
+      return false;
+   }
+}
+
+function showHighlight(wms_title){
+	parent.parent.mb_showHighlight("mapframe1",wms_title);
+	parent.parent.mb_showHighlight("overview",wms_title);
+	//alert (backlink);
+	
+}
+function hideHighlight(){
+
+	parent.parent.mb_hideHighlight("mapframe1");
+	parent.parent.mb_hideHighlight("overview");
+	
+}
+
+function handleLayer(sel_lay, wms_title){
+    
+	//var wms_title = document.forms[0].wmsTitle.value
+
+	var x = new Array();
+
+    x[0] = sel_lay;
+
+    var y = new Array();
+    
+    if (backlink =='parent'){
+		var wms_ID = parent.parent.getWMSIDByTitle('mapframe1',wms_title);
+	}
+	else{
+		var wms_ID = parent.getWMSIDByTitle('mapframe1',wms_title);
+	}
+
+    y[0] = wms_ID;
+    
+	//alert(wms_title + " -- X "+ x + "wms_id" + wms_ID);
+	
+	if (backlink =='parent'){
+		parent.parent.handleSelectedLayer_array('mapframe1',y,x,'querylayer',1);
+		parent.parent.handleSelectedLayer_array('mapframe1',y,x,'visible',1);
+	}
+	else{
+		parent.handleSelectedLayer_array('mapframe1',y,x,'querylayer',1);
+		parent.handleSelectedLayer_array('mapframe1',y,x,'visible',1);		
+	}
+
+}
+
+function mod_addWMSfromfilteredList(pointer_name,version){
+
+	pointer_name=pointer_name + parent.parent.mb_getConjunctionCharacter(pointer_name);
+	if (version == '1.0.0'){
+		var cap = pointer_name + "REQUEST=capabilities&WMTVER=1.0.0";
+		var load = cap;
+	}
+	else if (version == '1.1.0'){
+		var cap = pointer_name + "REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.1.0";
+		var load = cap;
+	}
+	else if (version == '1.1.1'){
+		var cap = pointer_name + "REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.1.1";
+		var load = cap;
+	}  
+	//alert (load);
+
+	if(load){
+		if(load.charAt(0) == '/' && load.charAt(1) == 'c'){
+			parent.parent.mod_addWMS_load('http://localhost' + load);
+		}
+		else{
+			parent.parent.mod_addWMS_load(load);
+		}  
+	}
+}
+
+function mod_addWMSLayerfromfilteredList(pointer_name,version,layer_name){
+
+	pointer_name=pointer_name + parent.parent.mb_getConjunctionCharacter(pointer_name);
+	if (version == '1.0.0'){
+		var cap = pointer_name + "REQUEST=capabilities&WMTVER=1.0.0";
+		var load = cap;
+		var layer_name = layer_name;
+	}
+	else if (version == '1.1.0'){
+		var cap = pointer_name + "REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.1.0";
+		var load = cap;
+		var layer_name = layer_name;
+	}
+	else if (version == '1.1.1'){
+		var cap = pointer_name + "REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.1.1";
+		var load = cap;
+		var layer_name = layer_name;
+	}  
+	//alert (load);
+
+	if(load){
+		if(load.charAt(0) == '/' && load.charAt(1) == 'c'){
+			parent.parent.mod_addLayer_load('http://localhost' + load, layer_name);
+		}
+		else{
+			parent.parent.mod_addLayer_load(load, layer_name);
+		}  
+	}
+}
+
+// -->
+</script>
+</head>
+<body leftmargin="2" topmargin="0" bgcolor="#ffffff">
+<?php
+function mb_utf8_encode($text) {
+	if(CHARSET=="UTF-8") return utf8_encode($text);
+	return $text;
+}
+function mb_utf8_decode($text) {
+	if(CHARSET=="UTF-8") return utf8_decode($text);
+	return $text;
+}
+
+$res_container_wms = array();
+$res_container_layer = array();
+
+if(!isset($_REQUEST["search"]) || $_REQUEST["search"] == ""){
+   echo "<form name='form1' target='result' onsubmit='return validate();'>";
+   echo "Suchen: &nbsp;&nbsp;&nbsp;<input class='textfield' name='search' type='text'> ";
+   echo "<input class='sbutton' type='submit' name='send'  value='ok'>";
+    echo "<iframe frameborder='1' name='result' src='../html/mod_blank.html' class='resultFrame' scrolling='auto'></iframe>";
+   echo "</form>";
+}
+else{
+   if(preg_match("/\*/",$_REQUEST["search"])){
+        $search = trim(preg_replace("/\*/i","", $_REQUEST["search"]));
+   }
+   
+
+	if (count($mywms) > 0) {
+		$v = array();   
+		$t = array();   
+		
+		// get wms_id, _title, _abstract, _getCapabilities, layer_id
+		$sql = "SELECT DISTINCT wms.wms_id, wms.wms_title, wms.wms_abstract, wms.wms_getcapabilities, wms.wms_version, l.layer_id FROM wms, layer AS l WHERE l.layer_pos = 0 AND wms.wms_id = l.fkey_wms_id AND wms.wms_id IN (";
+		for($i=0; $i<count($mywms); $i++){
+			if ($i > 0) {$sql .= ",";}
+			$sql .= "$".($i+1);
+			array_push($v, $mywms[$i]);
+			array_push($t, 'i');   
+		}
+		$sql .= ") ORDER BY wms.wms_title";
+		$res = db_prep_query($sql,$v,$t);
+	}
+	if (count($mylayer) > 0) {
+		$v = array();   
+		$t = array();   
+		$sql2 = "SELECT DISTINCT l.layer_id, l.layer_title, l.layer_abstract, l.layer_name, kw.keyword FROM layer l";
+		$sql2 .= " LEFT JOIN layer_keyword lkw ON lkw.fkey_layer_id=l.layer_id";
+		$sql2 .= " LEFT JOIN keyword kw ON kw.keyword_id=lkw.fkey_keyword_id WHERE l.layer_id IN (";
+		for($i = 0; $i < count($mylayer); $i++){
+			if ($i > 0) {$sql2 .= ",";}
+			$sql2 .= "$".($i+1);
+			array_push($v, $mylayer[$i]);
+			array_push($t, 'i');   
+		}
+		$sql2 .= ") ORDER BY l.layer_title";
+		$res2 = db_prep_query($sql2,$v,$t);
+	}
+
+   
+   $cnt = 0;
+   
+   while(db_fetch_row($res) || db_fetch_row($res2)){
+   	
+     //displayed result titles   	
+   	 $result_title1 = db_result($res,$cnt,"wms_title"); # Ergebnisspalte1
+   	 $result_title2 = db_result($res2,$cnt,"layer_title"); # Ergebnisspalte2
+   	 $result_title3 = db_result($res2,$cnt,"layer_name"); # Ergebnisspalte3
+   	 
+   	 //result_ids for identification of wms & layers
+   	 $result_id1 = db_result($res,$cnt,"wms_id"); # Ergebnis-ID 1
+   	 $result_id2 = db_result($res2,$cnt,"layer_id"); # Ergebnis-ID 2
+     $result_id3 = db_result($res,$cnt,"layer_id"); # Ergebnis-ID 3 --> layer_id des nullten Layers für wms-Metadatenaufruf per URL
+     
+     //wms_getcapabilities & wms_version for function add_wms
+     $result_column1 = db_result($res,$cnt,"wms_getcapabilities"); # Ergebnis-Spalte 1: wms_getcapabilities
+     $result_column2 = db_result($res,$cnt,"wms_version"); # Ergebnis-Spalte 2: wms_version
+     
+     //search columns 
+     $search_column1 = db_result($res,$cnt,"wms_abstract"); # Suchspalte1
+     $search_column2 = db_result($res,$cnt,"wms_title"); # Suchspalte2
+     $search_column3 = db_result($res2,$cnt,"layer_title"); # Suchspalte3
+     $search_column4 = db_result($res2,$cnt,"layer_abstract"); # Suchspalte4
+     $search_column5 = db_result($res2,$cnt,"keyword"); # Suchspalte5
+     
+     $num = 0;
+     
+     if($search_column1 != '' || $search_column2 != ''){ 
+     	//put search_columns db results in array 
+     	$array_search_keywords = array_merge(explode(",", $search_column1), explode(",", $search_column2));
+     	     	     	
+     	for ($p=0 ; $p<count($array_search_keywords);$p++){							
+     	 if(preg_match("/".$_REQUEST["search"]."/i",$array_search_keywords[$p]) && array_search($result_id1, $res_container_wms)==FALSE){
+     	 	 echo "<br><a href='#' onClick='mod_addWMSfromfilteredList(\"".$result_column1."\",\"".$result_column2."\")'>".
+	       	      "<img align='top' name='add_wms' src='../img/button_gray/add_off.png' border='1' style='width:24px; height:24px'></a> ".
+	       	      "<img align='top' name='wms_gif' src='../img/wms.gif' border='0'><a href='#' onmouseover='javascript:showHighlight();' ".
+	       	      "onmouseout='javascript:hideHighlight();' ".
+	       	      "onClick='javascript:window.open(\"mod_layerMetadata.php?id=".$result_id3."\", \"metadata\", \"width=450, height=600\");'> ".mb_utf8_decode($result_title1)."</a>"; #  = WMS-ID: ".$result_id1."
+	       	 $num++;
+	       	 $res_container_wms[$num] = $result_id1;
+	       	 
+       	 }
+       	}
+     }
+     elseif($search_column3 != '' || $search_column4 != ''|| $search_column5 != ''){
+     	
+     	//put search_columns db results in array 
+     	$array_search_keywords2 = array_merge(explode(",", $search_column3),explode(",", $search_column4), explode(",", $search_column5));
+     	
+     	for ($q=0 ; $q<count($array_search_keywords2);$q++){
+         if(preg_match("/".$_REQUEST["search"]."/i",$array_search_keywords2[$q]) && array_search($result_id2, $res_container_layer)==FALSE){
+             $sql_wms  = "SELECT DISTINCT wms.wms_getcapabilities, wms.wms_version FROM wms, gui_layer gl";
+		     $sql_wms .= " WHERE gl.fkey_layer_id = $1";
+		     $sql_wms .= " AND gl.gui_layer_wms_id = wms.wms_id";
+		     $v = array($result_id2);
+		     $t = array('i'); 
+		     $res_wms = db_prep_query($sql_wms,$v,$t);
+		     $row = db_fetch_array($res_wms);
+		     $wms_cap = $row['wms_getcapabilities'];
+		     $wms_version = $row['wms_version'];
+		   
+         	 echo "<br><a href='#' onClick='mod_addWMSLayerfromfilteredList(\"".$wms_cap."\",\"".$wms_version."\", \"".$result_title3."\")'>".
+	       	      "<img align='top' name='add_wms' src='../img/button_gray/add_off.png' border='1' style='width:24px; height:24px'></a> ".
+	       	      "<img align='top' name='layer_gif' src='../img/layer.gif' border='0'><a href='#' onmouseover='javascript:showHighlight();' ".
+	       	      "onmouseout='javascript:hideHighlight();' ".
+	       	      "onClick='javascript:window.open(\"mod_layerMetadata.php?id=".$result_id2."\", \"metadata\", \"width=450, height=600\");'> ".mb_utf8_decode($result_title2)."</a>";   #  = LAYER-ID (aus Suche layer_abstract): ".$result_id2."
+	       	 $num++;
+	       	 $res_container_layer[$num] = $result_id2;
+       	 }
+        }
+     } 
+     $cnt++;
+   }
+   //echo the message below if there is no search result for wms, layer & keywords 
+   if(count($res_container_wms)==0 && count($res_container_layer)==0){
+   	echo "Kein Ergebnis!";
+   }
+   
+   echo "<form action='" . $PHP_SELF . "?".SID."' method='post'>";
+        
+   echo "</form>";
+}
+?>
+</body>
+</html>



More information about the Mapbender_commits mailing list