[Mapbender-commits] r5885 - in trunk/mapbender/http: javascripts php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Sat Apr 10 07:27:42 EDT 2010


Author: verenadiewald
Date: 2010-04-10 07:27:42 -0400 (Sat, 10 Apr 2010)
New Revision: 5885

Added:
   trunk/mapbender/http/javascripts/mod_wfsLayerObj_conf.js
Modified:
   trunk/mapbender/http/php/mod_editGuiWms.php
   trunk/mapbender/http/php/mod_wfsLayerObj_conf.php
Log:
new layout (jquery ui dialog) for setting wfs conf for layer 

Added: trunk/mapbender/http/javascripts/mod_wfsLayerObj_conf.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_wfsLayerObj_conf.js	                        (rev 0)
+++ trunk/mapbender/http/javascripts/mod_wfsLayerObj_conf.js	2010-04-10 11:27:42 UTC (rev 5885)
@@ -0,0 +1,79 @@
+function getWfsConfs(myGui,myWms,myLayer,myWfsConfId,layerButton) {
+	$("#setWfsDialog").dialog('close').remove();
+	var req = new parent.Mapbender.Ajax.Request({
+		url: "../php/mod_wfsLayerObj_conf.php",
+		method: "getWfsConfs",
+		parameters : {
+			gui : myGui,
+			wms : myWms,
+			layer : myLayer	
+		},
+		callback: (function(result,success,message){ 
+			var selectHtml = "<select id='wfsConfSelect'>";
+			selectHtml += "<option value=''><?php echo _mb("none"); ?></option>";
+			for (var wfsConfId in result) {
+				selectHtml += "<option value='" + result[wfsConfId].wfs_conf_id + "'";
+				if(myWfsConfId != "" && myWfsConfId == result[wfsConfId].wfs_conf_id) {
+					selectHtml += " selected='selected'";	
+				}
+				selectHtml += ">";
+				selectHtml += result[wfsConfId].wfs_conf_abstract;
+				selectHtml += "(ID: " + result[wfsConfId].wfs_conf_id + ")";
+				selectHtml += "</option>";
+			}
+			selectHtml += "</select>";
+			
+			$("<div id='setWfsDialog'>" + selectHtml + "</div>").dialog({
+				autoOpen: true,
+				height: 170,
+				width: 300,
+				title: '<?php echo _mb("Set WFS for layer"); ?>',
+				draggable: true,
+				buttons: {
+					"OK": function(){
+						saveLayerWfsConnection($("#wfsConfSelect").val(), myGui, myWms, myLayer, layerButton);
+					},
+					"<?php echo _mb("Cancel"); ?>": function(){
+						$(this).dialog('close').remove();
+					}
+				}
+			});			
+		})
+	}); 
+	req.send();
+}
+
+function saveLayerWfsConnection(wfsConf, gui, wms, layer, layerButton) {
+	var req = new parent.Mapbender.Ajax.Request({
+		url: "../php/mod_wfsLayerObj_conf.php",
+		method: "saveLayerWfsConnection",
+		parameters : {
+			wfsConf : wfsConf,
+			gui : gui,
+			wms : wms,
+			layer : layer	
+		},
+		callback: (function(result,success,message){ 
+			if(success) {
+				$("#setWfsDialog").dialog('close');
+				if (wfsConf == "") {
+					var layerButtonVal = "setWFS";
+					
+				}
+				else {
+					var layerButtonVal = "wfs " + wfsConf
+					
+					//$("#" + layerButton).attr("onclick", "getWfsConfs(gui,wms,layer,wfsConf,'buttonLayerWfs_' + layer)");
+				}
+				$("#" + layerButton).replaceWith("<input type='button' value='" + layerButtonVal + "' " + 
+											"onclick='getWfsConfs(\"" + gui + "\"," + 
+											wms + "," + layer + ",\"" + wfsConf + "\",\"buttonLayerWfs_" + layer + "\")' " + 
+											"name='gui_layer_gaz' id='buttonLayerWfs_" + layer + "' class='button_wfs'>");
+			}
+			else {
+				$("#setWfsDialog").append("<div>" + message + "</div>");
+			} 
+		})
+	}); 
+	req.send();
+}
\ No newline at end of file

Modified: trunk/mapbender/http/php/mod_editGuiWms.php
===================================================================
--- trunk/mapbender/http/php/mod_editGuiWms.php	2010-04-10 11:19:06 UTC (rev 5884)
+++ trunk/mapbender/http/php/mod_editGuiWms.php	2010-04-10 11:27:42 UTC (rev 5885)
@@ -28,12 +28,12 @@
 <head>
 <?php
 echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';
+echo '<link rel="stylesheet" type="text/css" href="../extensions/jquery-ui-1.7.2.custom/css/smoothness/jquery-ui-1.7.2.custom.css">';
 ?>
 <title>Edit GUI WMS</title>
 <?php
 include_once '../include/dyn_css.php';
 
-
 function toImage($text) {
 	$angle = 90;
 	if (extension_loaded("gd2")) {
@@ -45,10 +45,14 @@
 
 <script language="JavaScript">
 
+<?php
+	require_once(dirname(__FILE__) . "/../extensions/jquery-ui-1.7.2.custom/js/jquery-1.3.2.min.js");
+	require_once(dirname(__FILE__) . "/../extensions/jquery-ui-1.7.2.custom/js/jquery-ui-1.7.2.custom.min.js");
+	require_once(dirname(__FILE__) . "/../extensions/jquery-ui-1.7.2.custom/development-bundle/ui/min.ui.dialog.js");
+	require_once(dirname(__FILE__) . "/../javascripts/mod_wfsLayerObj_conf.js");
+	header('Content-type: text/html');
+?>
 
-function edit_gaz(gui,wms,layer){
-	window.open("../php/mod_wfsLayerObj_conf.php?gui="+gui+"&wms="+wms+"&layer="+layer);
-}
 function validate(wert){
 	if(wert == 'delete_wms'){
 		if(document.form1.wmsList.selectedIndex == -1){
@@ -710,7 +714,7 @@
   /* wfs configuration */
 	echo "<td>";
 	if ($i > 0) {
-		echo "<input class='button_wfs'name='gui_layer_gaz' type='button' onclick='edit_gaz(\"".$guiList."\",".$wmsList.",".$layer_id[$i].")' value='";
+		echo "<input class='button_wfs' id='buttonLayerWfs_".$layer_id[$i]."' name='gui_layer_gaz' type='button' onclick='getWfsConfs(\"".$guiList."\",".$wmsList.",".$layer_id[$i].",\"".$gui_layer_wfs_featuretype[$i]."\",\"buttonLayerWfs_".$layer_id[$i]."\")' value='";
 		if($gui_layer_wfs_featuretype[$i] == ""){
 			echo "setWFS";
 		}

Modified: trunk/mapbender/http/php/mod_wfsLayerObj_conf.php
===================================================================
--- trunk/mapbender/http/php/mod_wfsLayerObj_conf.php	2010-04-10 11:19:06 UTC (rev 5884)
+++ trunk/mapbender/http/php/mod_wfsLayerObj_conf.php	2010-04-10 11:27:42 UTC (rev 5885)
@@ -1,107 +1,74 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/Administration
-# 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.
+<?php 
+# License:
+# Copyright (c) 2009, Open Source Geospatial Foundation
+# This program is dual licensed under the GNU General Public License 
+# and Simplified BSD license.  
+# http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
 
-require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-require(dirname(__FILE__)."/../classes/class_wfs_conf.php");
-?>
-<html>
-<head>
-<?php
-echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';	
-?>
-<title>wfs_conf</title>
-<script language="JavaScript" type="text/javascript">
-  function selectWFS(){
-          if(document.forms[0].featuretype){
-                  if(document.forms[0].featuretype.length){
-                          for(var i=0; i<document.forms[0].featuretype.length;i++){
-                                  document.forms[0].featuretype[i].checked = false;
-                          }
-                  }
-                  else{
-                          document.forms[0].featuretype.checked = false;
-                  }
-          }
-          document.forms[0].submit();
-  }
-  function validate(){
-           for(var i=0; i<document.forms[0].length; i++){
-                  if(document.forms[0].elements[i].type == 'checkbox'){
-                           if(document.forms[0].elements[i].checked){
-                                  document.forms[0].elements[i].value = 1;
-                          }
-                          else{
-                                  document.forms[0].elements[i].value = 0;
-                          }
-                          document.forms[0].elements[i].checked = true;
-                  }
-          }
-          return true;
-  }
-</script>
+require_once(dirname(__FILE__) . "/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+require_once(dirname(__FILE__)."/../classes/class_wfs_conf.php");
 
-</head>
-<body>
-wfs_conf Configuration<br>
-<br>
-<form method='POST' onsubmit='return validate()'>
+$ajaxResponse = new AjaxResponse($_POST);
 
-<?php
-if(isset($_REQUEST["save"])){        
-        $sql = "UPDATE gui_layer SET gui_layer_wfs_featuretype = $1 ";
-        $sql .= "WHERE fkey_gui_id = $2 AND fkey_layer_id = $3";
-        $v = array($_REQUEST["wfs_conf"],$_REQUEST["gui"],$_REQUEST["layer"]);
-		$t = array('s','s','i');
-		$res = db_prep_query($sql,$v,$t);
-        echo "layer is connected with wfs_conf: ".$_REQUEST["wfs_conf"]."<br><br>";
+$myGui = $ajaxResponse->getParameter('gui');
+$myWms = $ajaxResponse->getParameter('wms');
+$myLayer = $ajaxResponse->getParameter('layer');
+$myWfsConf = $ajaxResponse->getParameter('wfsConf');
+
+try{
+	switch($ajaxResponse->getMethod()) {
+		case "getWfsConfs":
+			$result = getWfsConfs($myGui);
+			$ajaxResponse->setSuccess(true);
+			$ajaxResponse->setResult($result);
+		break;
+		case "saveLayerWfsConnection":
+			$result = saveLayerWfsConnection($myWfsConf, $myGui, $myLayer);
+			if($result === true) {
+				$ajaxResponse->setSuccess(true);
+			}
+			else {
+				$ajaxResponse->setSuccess(false);
+				$ajaxResponse->setMessage("An error occured performing UPDATE");
+			}
+		break;
+		default:
+			$ajaxResponse->setSuccess(false);
+			$ajaxResponse->setMessage("method invalid");
+	}	
 }
-else if(isset($_REQUEST["del"])){
-        
-        $sql = "UPDATE gui_layer SET gui_layer_wfs_featuretype = '' ";
-        $sql .= "WHERE fkey_gui_id = $1 AND fkey_layer_id = $2";
-        $v = array($_REQUEST["gui"],$_REQUEST["layer"]);
-		$t = array('s','i');
-		$res = db_prep_query($sql,$v,$t);
-        echo "layer connection removed<br><br>";
+catch(Exception $E) {
+	$ajaxResponse->setSuccess(false);
+	$ajaxResponse->setMessage("An error occured");
+	$e = new mb_exception("mod_wfsLayerObj_conf.php: ".$E->getMessage());
 }
-echo "<input type='hidden' name='gui' value='".$_REQUEST["gui"]."'>";
-echo "<input type='hidden' name='wms' value='".$_REQUEST["wms"]."'>";
-echo "<input type='hidden' name='layer' value='".$_REQUEST["layer"]."'>";
+$ajaxResponse->send();
 
-/* select wfs */
+function getWfsConfs($myGui) {
+	$user = new User($_SESSION["mb_user_id"]);
 
-$sql = "SELECT * FROM wfs_conf";
-$res = db_query($sql);
-echo "<select size='20' name='wfs_conf' onchange='submit()'>";
-$cnt = 0;
-while($row = db_fetch_array($res)){
-        echo "<option value='".$row["wfs_conf_id"]."' ";
-        if(isset($_REQUEST["wfs_conf"]) && $row["wfs_conf_id"] == $_REQUEST["wfs_conf"]){
-                echo "selected";
-        }
-        echo ">".$row["wfs_conf_abstract"]."</option>";
-        $cnt++;
+	// get all WFS conf IDs for this application
+	$availableWfsConfIds = $user->getWfsConfByPermission($myGui);
+	
+	$wfsConfObj = new WfsConf();
+	$result = $wfsConfObj->load($availableWfsConfIds);	
+	
+	return $result;
 }
-echo "</select>";
 
-echo "<br><br><input type='submit' name='save' value='save'><br><br>";
-echo "<input name='del' type='submit' value='delete'>";
-?>
-</form>
-</body>
\ No newline at end of file
+function saveLayerWfsConnection($myWfsConf, $myGui, $myLayer) {
+	$sql = "UPDATE gui_layer SET gui_layer_wfs_featuretype = $1 ";
+	$sql .= "WHERE fkey_gui_id = $2 AND fkey_layer_id = $3";
+    $v = array($myWfsConf,$myGui,$myLayer);
+	$t = array('s','s','i');
+	$res = db_prep_query($sql,$v,$t);
+	
+	if($res) {
+		return true;
+	}
+	else {
+		return false;
+	}
+}
+?>
\ No newline at end of file



More information about the Mapbender_commits mailing list