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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Jan 24 04:01:35 EST 2007


Author: astrid_emde
Date: 2007-01-24 04:01:34 -0500 (Wed, 24 Jan 2007)
New Revision: 1021

Modified:
   trunk/mapbender/http/php/mod_wfs_gazetteer.php
Log:
extended functionality by verena diewald.
handling of multiple wfs configuration. choose a wfs by selectbox

Modified: trunk/mapbender/http/php/mod_wfs_gazetteer.php
===================================================================
--- trunk/mapbender/http/php/mod_wfs_gazetteer.php	2007-01-23 14:59:46 UTC (rev 1020)
+++ trunk/mapbender/http/php/mod_wfs_gazetteer.php	2007-01-24 09:01:34 UTC (rev 1021)
@@ -1,5 +1,6 @@
 <?php
 # $Id$
+# maintained by http://www.mapbender.org/index.php/User:Verena Diewald
 # http://www.mapbender.org/index.php/WFS_gazetteer
 # Copyright (C) 2002 CCGIS 
 #
@@ -18,7 +19,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 session_start();
-require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+require_once("../../conf/mapbender.conf");
 ?>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 
@@ -38,78 +39,300 @@
 $sql = "SELECT * FROM wfs_conf ";
 $sql .= "JOIN wfs ON wfs_conf.fkey_wfs_id = wfs.wfs_id ";
 $sql .= "WHERE wfs_conf.wfs_conf_id = $1";
-$v = array($_REQUEST["wfs_conf"]);
+
+//get wfs_conf as array
+$v1 = array($_REQUEST["wfs_conf"]);
+//split array $v1 (comma-separated) to get all chosen wfs_confs
+$v2 = split(",", $v1[0]);
+//get number of chosen wfs_confs
+if(strlen($v2[0])==NULL){
+  $cnt_confs = NULL; 
+}
+else{
+  $cnt_confs = count($v2);
+}
 $t = array('i');
-$res = db_prep_query($sql,$v,$t);
-if($row = db_fetch_array($res)){
-	$g_label  = $row["g_label"];
-	$g_label_id  = $row["g_label_id"];
-	$g_style  = $row["g_style"];
-	$g_button = $row["g_button"];
-	$g_button_id = $row["g_button_id"];
-	$g_buffer  = $row["g_buffer"];
-	$g_res_style  = $row["g_res_style"];
-	$g_use_wzgraphics = $row["g_use_wzgraphics"];
-	$wfs_id  = $row["fkey_wfs_id"];
-	$featuretype_id  = $row["fkey_featuretype_id"];
-	$wfs_getfeature = $row["wfs_getfeature"];
-}else{die("wfs_conf data not available");}
 
-$sql = "SELECT * FROM wfs_featuretype ";
-$sql .= "WHERE fkey_wfs_id = $1 AND featuretype_id = $2";
-$v = array($wfs_id,$featuretype_id);
-$t = array('i','i');
-$res = db_prep_query($sql,$v,$t);
-if($row = db_fetch_array($res)){
-	$featuretype_name  = $row["featuretype_name"];
-	$featuretype_srs  = $row["featuretype_srs"];
-}else{die("wfs_conf data not available");}
+//do this if there is more than 1 wfs_conf
+if($cnt_confs>1){
+  for($i=0; $i < $cnt_confs; $i++){
+  	 $res = db_prep_query($sql,$v2[$i],$t);
+  	 if($row = db_fetch_array($res)){
+     	$g_label[$v2[$i]] = $row["g_label"];
+     	$g_label_id[$v2[$i]]  = $row["g_label_id"];
+		$g_style[$v2[$i]]  = $row["g_style"];
+		$g_button[$v2[$i]] = $row["g_button"];
+		$g_button_id[$v2[$i]] = $row["g_button_id"];
+		$g_buffer[$v2[$i]]  = $row["g_buffer"];
+		$g_res_style[$v2[$i]]  = $row["g_res_style"];
+		$g_use_wzgraphics[$v2[$i]] = $row["g_use_wzgraphics"];
+		$wfs_id[$v2[$i]]  = $row["fkey_wfs_id"];
+		$featuretype_id[$v2[$i]]  = $row["fkey_featuretype_id"];
+		$wfs_getfeature[$v2[$i]] = $row["wfs_getfeature"];
+	}
+  }	
+ 
+  echo "<script type='text/javascript' language='javascript'>
+    
+  function conf_selection(){
+    
+    //alert(document.sel_wfs_conf_form.wfs_conf_sel.value);
+    document.sel_wfs_conf_form.selected_conf.value = document.sel_wfs_conf_form.wfs_conf_sel.value;
+    document.sel_wfs_conf_form.submit();
+  }
+  
+  </script>";
+  
+  //display select box for different wfs_confs
+  echo "<form name='sel_wfs_conf_form' method='POST' action='mod_wfs_gazetteer.php'>\n" .
+  	   "<select name='wfs_conf_sel' size='1' onChange='conf_selection()'>\n";
+  for($i=0; $i < $cnt_confs; $i++){
+  	if(empty($_REQUEST["selected_conf"])){
+  	  if($i==0){	
+  	    echo "<option value='".$v2[$i]."' selected>".$g_label[$v2[$i]]."</option>\n";	
+  	  }
+  	  else{
+  	    echo "<option value='".$v2[$i]."'>".$g_label[$v2[$i]]."</option>\n";
+  	  }
+  	}
+  	else{	
+  	  if($v2[$i]==$_REQUEST["selected_conf"]){
+  	    $selected = "selected";
+  	  }
+  	  else{
+  	    $selected= "";
+  	  }	
+  	  echo "<option value='".$v2[$i]."' $selected>".$g_label[$v2[$i]]."</option>\n";
+  	}  
+  }
+  echo "</select>".
+  	   "<input type='hidden' name='wfs_conf' value='".$_REQUEST["wfs_conf"]."'>\n".
+  	   "<input type='hidden' name='selected_conf' value='".$_REQUEST["selected_conf"]."'>\n".
+  	   "<input type='hidden' name='target' value='".$_REQUEST["target"]."'>\n".
+  	   "<input type='hidden' name='resultFrame' value='".$_REQUEST["resultFrame"]."'>\n";
+ echo  "</form>";
+  	
+  
+  $sql = "SELECT * FROM wfs_featuretype ";
+  $sql .= "WHERE fkey_wfs_id = $1 AND featuretype_id = $2";
+ 
+  //if first value of select box is active and there was not yet a selection of another value, take index 0 for the
+  //following steps	
+  if(!isset($_REQUEST["selected_conf"])){
+  	  $v = array($wfs_id[$v2[0]],$featuretype_id[$v2[0]]);
+	  $t = array('i','i');
+	  $res = db_prep_query($sql,$v,$t);
+	  if($row = db_fetch_array($res)){
+	    $featuretype_name  = $row["featuretype_name"];
+	    $featuretype_srs  = $row["featuretype_srs"];
+	  }
+	  else{
+	   die("Please add the wfs_conf to the src-Parameter");
+	  }
+	  
+	  echo "<style type='text/css'>";
+	  echo $g_style[$v2[0]];
+	  echo "</style>";
+	
+	  /* wfs_conf_element */
+	  $sql = "SELECT * FROM wfs_conf_element ";
+	  $sql .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
+	  $sql .= "WHERE wfs_conf_element.fkey_wfs_conf_id = $1 ";
+	  $sql .= "AND wfs_conf_element.f_search = 1 ORDER BY wfs_conf_element.f_search;";
+	
+	  $v1 = array($_REQUEST["wfs_conf"]);
+	  $t = array('i');
+	  
+	  //split array $v1 (comma-separated) to get all chosen wfs_confs
+	  $v2 = split(",", $v1[0]);
+	  $res = db_prep_query($sql,$v2[0],$t);
+	
+	  echo '<script type="text/javascript">';
+	  echo "var el = new Array();";
+	  $cnt = 0;
+	  while($row = db_fetch_array($res)){
+		echo "el[".$cnt."] = new Array();";
+		echo "el[".$cnt."]['f_search'] = ".$row["f_search"].";";
+		echo "el[".$cnt."]['f_style_id'] = '".$row["f_style_id"]."';";
+		echo "el[".$cnt."]['f_toupper'] = '".$row["f_toupper"]."';";
+		echo "el[".$cnt."]['f_label'] = '".$row["f_label"]."';";
+		echo "el[".$cnt."]['f_label_id'] = '".$row["f_label_id"]."';";
+		echo "el[".$cnt."]['element_name'] = '".$row["element_name"]."';";
+		echo "el[".$cnt."]['element_type'] = '".$row["element_type"]."';";
+		$cnt++;
+	  }
+	  if($cnt == 0){
+	  	die("Please add the wfs_conf to the src-Parameter");
+	  }
+	
+	  echo "var g_label = '".$g_label[$v2[0]]."';";
+	  echo "var g_label_id = '".$g_label_id[$v2[0]]."';";
+	  echo "var g_button = '".$g_button[$v2[0]]."';";
+	  echo "var g_button_id = '".$g_button_id[$v2[0]]."';";
+	  echo "var g_buffer = ".$g_buffer[$v2[0]].";";
+	  echo "var g_res_style = '".urlencode($g_res_style[$v2[0]])."';";
+	  echo "var g_use_wzgraphics = ".$g_use_wzgraphics[$v2[0]].";";
+	  echo "var featuretype_name= '".$featuretype_name."';";
+	  echo "var featuretype_srs = '".$featuretype_srs."';";
+	  echo "var wfs_getfeature = '".$wfs_getfeature[$v2[0]]."';";
+	  
+	  echo "var wfs_conf_id = '".$v2[0]."';";
+	  echo "var targets = '".$_REQUEST["target"]."';";
+	  echo "var resultFrame = '".$_REQUEST["resultFrame"]."';";
+	  echo "</script>";
+  }
+  //if value of select box changed through new selection, do the following
+  else{
+  	  //set $i as selected_conf value
+   	  $i = $_REQUEST["selected_conf"];
+   	  $v = array($wfs_id[$i],$featuretype_id[$i]);
+	  $t = array('i','i');
+	  $res = db_prep_query($sql,$v,$t);
+	  if($row = db_fetch_array($res)){
+	    $featuretype_name  = $row["featuretype_name"];
+	    $featuretype_srs  = $row["featuretype_srs"];
+	  }
+	  else{
+	   die("Please add the wfs_conf to the src-Parameter");
+	  }
+	  echo "<style type='text/css'>";
+	  echo $g_style[$i];
+	  echo "</style>";
+	
+	  /* wfs_conf_element */
+	  $sql = "SELECT * FROM wfs_conf_element ";
+	  $sql .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
+	  $sql .= "WHERE wfs_conf_element.fkey_wfs_conf_id = $1 ";
+	  $sql .= "AND wfs_conf_element.f_search = 1 ORDER BY wfs_conf_element.f_search;";
+	
+	  #$v1 = array($_REQUEST["wfs_conf"]);
+	  $t = array('i');
+	  
+	  //split array $v1 (comma-separated) to get all chosen wfs_confs
+	  #$v2 = split(",", $v1[0]);
+	  $res = db_prep_query($sql,$i,$t);
+	
+	  echo '<script type="text/javascript">';
+	  echo "var el = new Array();";
+	  $cnt = 0;
+	  while($row = db_fetch_array($res)){
+	  	echo "el[".$cnt."] = new Array();";
+		echo "el[".$cnt."]['f_search'] = ".$row["f_search"].";";
+		echo "el[".$cnt."]['f_style_id'] = '".$row["f_style_id"]."';";
+		echo "el[".$cnt."]['f_toupper'] = '".$row["f_toupper"]."';";
+		echo "el[".$cnt."]['f_label'] = '".$row["f_label"]."';";
+		echo "el[".$cnt."]['f_label_id'] = '".$row["f_label_id"]."';";
+		echo "el[".$cnt."]['element_name'] = '".$row["element_name"]."';";
+		echo "el[".$cnt."]['element_type'] = '".$row["element_type"]."';";
+		$cnt++;
+	  }
+	  if($cnt == 0){
+	  	die("Please add the wfs_conf to the src-Parameter");
+	  }
+	
+	  echo "var g_label = '".$g_label[$i]."';";
+	  echo "var g_label_id = '".$g_label_id[$i]."';";
+	  echo "var g_button = '".$g_button[$i]."';";
+	  echo "var g_button_id = '".$g_button_id[$i]."';";
+	  echo "var g_buffer = ".$g_buffer[$i].";";
+	  echo "var g_res_style = '".urlencode($g_res_style[$i])."';";
+	  echo "var g_use_wzgraphics = ".$g_use_wzgraphics[$i].";";
+	  echo "var featuretype_name= '".$featuretype_name."';";
+	  echo "var featuretype_srs = '".$featuretype_srs."';";
+	  echo "var wfs_getfeature = '".$wfs_getfeature[$i]."';";
+	  
+	  echo "var wfs_conf_id = '".$i."';";
+	  echo "var targets = '".$_REQUEST["target"]."';";
+	  echo "var resultFrame = '".$_REQUEST["resultFrame"]."';";
+	  echo "</script>";
+  }
 
-echo "<style type='text/css''>";
-echo $g_style;
-echo "</style>";
+}
+//do this if there is 1 wfs_conf
+elseif($cnt_confs>0 && $cnt_confs==1){
+   $res = db_prep_query($sql,$v1,$t);
+   if($row = db_fetch_array($res)){
+		$g_label  = $row["g_label"];
+		$g_label_id  = $row["g_label_id"];
+		$g_style  = $row["g_style"];
+		$g_button = $row["g_button"];
+		$g_button_id = $row["g_button_id"];
+		$g_buffer  = $row["g_buffer"];
+		$g_res_style  = $row["g_res_style"];
+		$g_use_wzgraphics = $row["g_use_wzgraphics"];
+		$wfs_id  = $row["fkey_wfs_id"];
+		$featuretype_id  = $row["fkey_featuretype_id"];
+		$wfs_getfeature = $row["wfs_getfeature"];
+		
+   }
+   
+   $sql = "SELECT * FROM wfs_featuretype ";
+   $sql .= "WHERE fkey_wfs_id = $1 AND featuretype_id = $2";
+   //get wfs_id & featuretype_id as array
+   $v = array($wfs_id,$featuretype_id);
+   $t = array('i','i');
+   $res = db_prep_query($sql,$v,$t);
+   if($row = db_fetch_array($res)){
+     $featuretype_name  = $row["featuretype_name"];
+     $featuretype_srs  = $row["featuretype_srs"];
+   }
+   else{
+	   die("Please add the wfs_conf to the src-Parameter");
+   }
+   
+   echo "<style type='text/css'>";
+   echo $g_style;
+   echo "</style>";
 
-/* wfs_conf_element */
-$sql = "SELECT * FROM wfs_conf_element ";
-$sql .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
-$sql .= "WHERE wfs_conf_element.fkey_wfs_conf_id = $1 ";
-$sql .= "AND wfs_conf_element.f_search = 1 ORDER BY wfs_conf_element.f_search;";
+   /* wfs_conf_element */
+   $sql = "SELECT * FROM wfs_conf_element ";
+   $sql .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
+   $sql .= "WHERE wfs_conf_element.fkey_wfs_conf_id = $1 ";
+   $sql .= "AND wfs_conf_element.f_search = 1 ORDER BY wfs_conf_element.f_search;";
 
-$v = array($_REQUEST["wfs_conf"]);
-$t = array('i');
-$res = db_prep_query($sql,$v,$t);
+   $v = array($_REQUEST["wfs_conf"]);
+   $t = array('i');
+   $res = db_prep_query($sql,$v,$t);
 
-echo '<script type="text/javascript">';
-echo "var el = new Array();";
-$cnt = 0;
-while($row = db_fetch_array($res)){
-	echo "el[".$cnt."] = new Array();";
-	echo "el[".$cnt."]['f_search'] = ".$row["f_search"].";";
-	echo "el[".$cnt."]['f_style_id'] = '".$row["f_style_id"]."';";
-	echo "el[".$cnt."]['f_toupper'] = '".$row["f_toupper"]."';";
-	echo "el[".$cnt."]['f_label'] = '".$row["f_label"]."';";
-	echo "el[".$cnt."]['f_label_id'] = '".$row["f_label_id"]."';";
-	echo "el[".$cnt."]['element_name'] = '".$row["element_name"]."';";
-	echo "el[".$cnt."]['element_type'] = '".$row["element_type"]."';";
-	$cnt++;
+   echo '<script type="text/javascript">';
+   echo "var el = new Array();";
+   $cnt = 0;
+   while($row = db_fetch_array($res)){
+	 echo "el[".$cnt."] = new Array();";
+	 echo "el[".$cnt."]['f_search'] = ".$row["f_search"].";";
+	 echo "el[".$cnt."]['f_style_id'] = '".$row["f_style_id"]."';";
+	 echo "el[".$cnt."]['f_toupper'] = '".$row["f_toupper"]."';";
+	 echo "el[".$cnt."]['f_label'] = '".$row["f_label"]."';";
+	 echo "el[".$cnt."]['f_label_id'] = '".$row["f_label_id"]."';";
+	 echo "el[".$cnt."]['element_name'] = '".$row["element_name"]."';";
+	 echo "el[".$cnt."]['element_type'] = '".$row["element_type"]."';";
+	 $cnt++;
+   }
+   if($cnt == 0){
+   	die("Please add the wfs_conf to the src-Parameter");
+   	}
+
+   echo "var g_label = '".$g_label."';";
+   echo "var g_label_id = '".$g_label_id."';";
+   echo "var g_button = '".$g_button."';";
+   echo "var g_button_id = '".$g_button_id."';";
+   echo "var g_buffer = ".$g_buffer.";";
+   echo "var g_res_style = '".urlencode($g_res_style)."';";
+   echo "var g_use_wzgraphics = ".$g_use_wzgraphics.";";
+   echo "var featuretype_name= '".$featuretype_name."';";
+   echo "var featuretype_srs = '".$featuretype_srs."';";
+   echo "var wfs_getfeature = '".$wfs_getfeature."';";
+
+   echo "var wfs_conf_id = '".$_REQUEST["wfs_conf"]."';";
+   echo "var targets = '".$_REQUEST["target"]."';";
+   echo "var resultFrame = '".$_REQUEST["resultFrame"]."';";
+   echo "</script>";
 }
-if($cnt == 0){die("wfs_conf data not available");}
+//do this if wfs_conf is missing 
+else{
+	die("Please add the wfs_conf to the src-Parameter!");
+}
 
-echo "var g_label = '".$g_label."';";
-echo "var g_label_id = '".$g_label_id."';";
-echo "var g_button = '".$g_button."';";
-echo "var g_button_id = '".$g_button_id."';";
-echo "var g_buffer = ".$g_buffer.";";
-echo "var g_res_style = '".urlencode($g_res_style)."';";
-echo "var g_use_wzgraphics = ".$g_use_wzgraphics.";";
-echo "var featuretype_name= '".$featuretype_name."';";
-echo "var featuretype_srs = '".$featuretype_srs."';";
-echo "var wfs_getfeature = '".$wfs_getfeature."';";
-
-echo "var wfs_conf_id = '".$_REQUEST["wfs_conf"]."';";
-echo "var targets = '".$_REQUEST["target"]."';";
-echo "var resultFrame = '".$_REQUEST["resultFrame"]."';";
-echo "</script>";
 ?>
 
 <script type="text/javascript">



More information about the Mapbender_commits mailing list