[Mapbender-commits] r1809 - branches/mapbender_sld/http/sld

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Nov 15 11:00:48 EST 2007


Author: mschulz
Date: 2007-11-15 11:00:48 -0500 (Thu, 15 Nov 2007)
New Revision: 1809

Modified:
   branches/mapbender_sld/http/sld/sld_main.php
Log:
Added copyright and license, cleanup menu

Modified: branches/mapbender_sld/http/sld/sld_main.php
===================================================================
--- branches/mapbender_sld/http/sld/sld_main.php	2007-11-15 15:52:00 UTC (rev 1808)
+++ branches/mapbender_sld/http/sld/sld_main.php	2007-11-15 16:00:48 UTC (rev 1809)
@@ -1,4 +1,22 @@
 <?php
+# $Id$
+# http://www.mapbender.org/index.php/SLD
+# 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.
+
 /**
  * This is the main page of the sld-editor.
  * It displays the preview images and creates the sld_edit_form
@@ -7,38 +25,37 @@
  * @package sld_main
  * @author Markus Krzyzanowski
  */
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+require_once(dirname(__FILE__)."/../classes/class_wfs_conf.php");
+$classWfsConf = new wfs_conf();
 
 include_once(dirname(__FILE__)."/sld_config.php");
-//session_start();
 include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
 
-if (isset($_REQUEST["wms_id"]) && isset($_REQUEST["layer_name"]) && isset($_REQUEST["gui_id"]))
+if (isset($_REQUEST["wms_id"]) && isset($_REQUEST["gui_id"]))
 {
 	$_SESSION["sld_wms_id"] = $_REQUEST["wms_id"];
-	$_SESSION["sld_layer_name"] = $_REQUEST["layer_name"];
 	$_SESSION["sld_gui_id"] = $_REQUEST["gui_id"];
 }
 
+if (isset($_REQUEST["layer_name"]))
+{
+	$_SESSION["sld_layer_name"] = $_REQUEST["layer_name"];
+}
 
-
-
-//include_once($SLD_CLASSES);
-//include_once($SLD_PARSE);
-
-
 //read custom sld for this user&wms&layer&gui from the db instead using sld.xml
 
 $con = db_connect($DBSERVER,$OWNER,$PW);
 db_select_db($DB,$con);
 
 //Read the layer_id from the DB
-$sql = "SELECT * FROM layer WHERE fkey_wms_id=".$_SESSION["sld_wms_id"]." AND layer_name='".$_SESSION["sld_layer_name"]."';";
-$res = db_query($sql);
+//$sql = "SELECT * FROM layer WHERE fkey_wms_id=".$_SESSION["sld_wms_id"]." AND layer_name='".$_SESSION["sld_layer_name"]."';";
+//$res = db_query($sql);
 
-$layer_id = "";
-if ( db_fetch_row($res, 0) )
+$dbutils = new DbUtils();
+$layer_id = $dbutils->getLayerIdFromLayerName($_SESSION["sld_wms_id"], $_SESSION["sld_layer_name"]);
+if ( $layer_id )
 {
-	$layer_id = db_result($res, 0, "layer_id");
 	$_SESSION["sld_layer_id"] = $layer_id;
 }
 
@@ -47,7 +64,7 @@
 
 
 //if layer is not found in DB
-if ($layer_id == "")
+if (!$layer_id)
 {
 	echo "layer existiert nicht in Datenbank";
 	exit();
@@ -60,12 +77,12 @@
 	if (!$res || db_numrows($res)== 0)
 	{
 		//No user specific sld found in DB -> get it from the mapserver
-		$file = $mapfileUrl."VERSION=1.1.1&REQUEST=GetStyles&LAYERS=".urlencode($layer_name);
+		$file = $mapfileUrl."SERVICE=WMS&VERSION=1.1.1&REQUEST=GetStyles&LAYERS=".urlencode($layer_name);
 		$data = readSld($file);
 		$data = char_encode($data);
 		//write the sld to the DB
 		$sql = "INSERT INTO sld_user_layer(fkey_mb_user_id, fkey_layer_id, sld_xml, use_sld, fkey_gui_id) VALUES('".$mb_user_id."','".$layer_id."','".$data."',0,'".$_SESSION["sld_gui_id"]."' );";
-		$res = db_query($sql);
+		$res = @db_query($sql);
 		//Use the new sld
 	}
 	else
@@ -75,15 +92,28 @@
 	}
 }
 
-
-
 //$file = "sld.xml";
 //$data = readSld($file);
 
 $styledlayerdescriptor = parseSld($data);
 $_SESSION["sld"] = $data;
 
+/* Check for a related WFS featuretype */
+$wfs_conf_id = $dbutils->getLayerWfsConfId($_SESSION["sld_gui_id"], $layer_id);
+if ( $wfs_conf_id ) {
+	$featuretype_id = $dbutils->getWfsConfFeatureTypeId($wfs_conf_id);
+	$classWfsConf->getelements($featuretype_id);
+	$wfs_element = $classWfsConf->elements;
+	$fts = $styledlayerdescriptor->layers[0]->styles[0]->featuretypestyles[0];
+	$fts->setElementArray("element_id",$wfs_element->element_id);
+	$fts->setElementArray("element_name",$wfs_element->element_name);
+} else {
+	$wfs_element = false;
+}
 
+/* create getMap-Url for preview with/without sld */
+$previewMapUrl = $dbutils->getPreviewMapUrl($_SESSION["sld_gui_id"], $layer_id, $_SESSION["sld_wms_id"]);
+
 echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n";
 echo "<html>\n";
 echo "<head>\n";
@@ -114,10 +144,12 @@
 $sld_url = "";
 $mb_sld_url = "";
 //$sld_url = "http://".$_SERVER["HTTP_HOST"]."/mapbender/sld/sld_function_handler.php?function=getusersld&layer_id=".$layer_id."&user_id=".$mb_user_id."&forcesld=1";
-$sld_url = $MAPBENDER_URL."/sld/sld_function_handler.php?function=getusersld&gui_id=".$_SESSION["sld_gui_id"]."&layer_id=".$layer_id."&user_id=".$mb_user_id."&forcesld=1";
-$mb_sld_url = $MAPBENDER_URL."/sld/sld_function_handler.php?function=getusersld&gui_id=".$_SESSION["sld_gui_id"]."&wms_id=".$_SESSION["sld_wms_id"]."&user_id=".$mb_user_id;
+$sld_url = $MAPBENDER_URL."/sld_function_handler.php?function=getusersld&gui_id=".$_SESSION["sld_gui_id"]."&layer_id=".$layer_id."&user_id=".$mb_user_id."&forcesld=1";
+$mb_sld_url = $MAPBENDER_URL."/sld_function_handler.php?function=getusersld&gui_id=".$_SESSION["sld_gui_id"]."&wms_id=".$_SESSION["sld_wms_id"]."&user_id=".$mb_user_id;
 echo "<!-- $sld_url -->";
+echo "<!-- $previewMapUrl -->";
 ## - 2.Zeile
+/*
 echo " <tr align='right'>\n";
 echo "  <td class='line_left2 text4'>\n";
 echo "   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Karte";
@@ -135,6 +167,7 @@
 echo "   <img src='./img/map_magnify.png' border='0' alt='Originalgr&ouml;&szlig;e im neuen Fenster anzeigen' onClick=\"window.open('map_original.php','','fullsreen=yes,resizable=no,scrollbars=yes');\">\n";
 echo "  </td>\n";
 echo " </tr>\n";
+*/
 
 ## - 3.Zeile
 echo " <tr align='center'>\n";
@@ -142,7 +175,7 @@
 
 ## - Map with SLD
 //Added rand(...) to force a reload of the image because the url should be different
-echo "   <img src=\"".$mapfileUrl."VERSION=1.1.1&REQUEST=GetMap&SERVICE=WMS&LAYERS=".urlencode($layer_name)."&WIDTH=320&HEIGHT=240&FORMAT=image/png&sld=".urlencode($sld_url)."&".rand(0,10000)."\" border=\"0\" width=\"320\" height=\"240\">";
+echo "   <img src=\"".$previewMapUrl."&WIDTH=320&HEIGHT=240&sld=".urlencode($sld_url)."&".rand(0,10000)."\" border=\"0\" width=\"320\" height=\"240\">";
 echo "  </td>\n";
 
 echo "  <td>\n";
@@ -152,7 +185,7 @@
 echo "  <td class='line_left2 line_right2' colspan='2'>\n";
 
 ## - Map without SLD
-echo "   <img src=\"".$mapfileUrl."VERSION=1.1.1&REQUEST=GetMap&SERVICE=WMS&LAYERS=".urlencode($layer_name)."&WIDTH=320&HEIGHT=240&FORMAT=image/png\" border=\"0\" width=\"320\" height=\"240\">";
+echo "   <img src=\"".$previewMapUrl."&WIDTH=320&HEIGHT=240\" border=\"0\" width=\"320\" height=\"240\">";
 echo "  </td>\n";
 
 #4.Zeile
@@ -198,10 +231,10 @@
 echo "     <td class=\"bg2 text3\">MENU</td>\n";
 echo "    </tr>\n";
 echo "    <tr>\n";
-echo "     <td class=\"line_left2 line_right2 text4 bg_menu\">\n";
+echo "     <td class=\"line_left2 line_down2 line_right2 text4 bg_menu\">\n";
 
 //echo "      <form name=\"use_sld\" action=\"http://".$_SERVER["HTTP_HOST"]."/mapbender/sld/".$SLD_FUNCTION_HANDLER."\" method=post >\n";
-echo "      <form name=\"use_sld\" action=\"".$MAPBENDER_URL."/sld/".$SLD_FUNCTION_HANDLER."\" method=post >\n";
+echo "      <form name=\"use_sld\" action=\"".$MAPBENDER_URL.$SLD_FUNCTION_HANDLER."\" method=post >\n";
 echo "      <input type=\"hidden\" name=\"function\" value=\"usesld\">\n";
 echo "      <input type=\"hidden\" name=\"sld_url\" value=\"".$sld_url."\">\n";
 echo "      <input type=\"hidden\" name=\"mb_sld_url\" value=\"".$mb_sld_url."\">\n";
@@ -219,23 +252,23 @@
 echo "      </form>\n";
 echo "     </td>\n";
 echo "    </tr>\n";
-echo "    <tr align=\"center\">\n";
-echo "     <td class=\"line_left2 line_right2 line_down2 text1 bg_menu\">\n";
+echo "    <tr align=\"left\">\n";
+echo "     <td class=\"line_left2 line_down2 line_right2 text1 bg_menu\" style=\"padding:3px;\">\n";
 
 //echo "      <form id=\"sld_editor_form\" action=\"http://".$_SERVER["HTTP_HOST"]."/mapbender/sld/".$SLD_FUNCTION_HANDLER."\" method=post >\n";
-echo "      <form id=\"sld_editor_form\" action=\"".$MAPBENDER_URL."/sld/".$SLD_FUNCTION_HANDLER."\" method=post >\n";
+echo "      <form id=\"sld_editor_form\" action=\"".$MAPBENDER_URL.$SLD_FUNCTION_HANDLER."\" method=post >\n";
 
-echo "      Standard �ffnen<br>\n";
-echo "      <a href='".$SLD_FUNCTION_HANDLER."?function=getdefaultsld'>\n";
-echo "      <img src='./img/script_link.png' border='0' alt='Standard SLD aus WMS auslesen'>\n";
-echo "      </a><br>\n";
+echo "      <a href='".$SLD_FUNCTION_HANDLER."?function=getdefaultsld' onclick='if(!confirm(\"Aktuelle SLD-Definition ersetzen?\")) return false;'>\n";
+echo "      <img src='./img/script.png' border='0' alt='Standard SLD aus WMS auslesen'>\n";
+echo "      </a> Standard &ouml;ffnen<br /><br />\n";
 
+echo "      <input type='image' src='./img/script_save.png' border='0' alt='�nderungen an die Map senden'>\n";
 echo "      SLD speichern<br>\n";
-echo "      <input type='image' src='./img/script_save.png' border='0' alt='�nderungen an die Map senden'>\n";
 echo "      <input type='hidden' name='function' value='save'>\n";
 echo "      <br /><a href=\"".$sld_url."\" target=_new>";	
+echo "      <img src='./img/script_code_red.png' border='0' alt='SLD anzeigen'>\n";
+echo "      </a>";
 echo "      SLD anzeigen";
-echo "      </a>";
 
 echo "     </td>\n";
 echo "    </tr>\n";
@@ -266,7 +299,8 @@
 echo " </tr>\n";
 echo "</table>\n";
 echo "<!-- ";
-print_r ($_SESSION);
+print_r ($wfs_element);
+print_r ($_SESSION["sld_objects"][3]);
 echo "-->";
 echo "</body>\n";
 echo "</html>\n";


Property changes on: branches/mapbender_sld/http/sld/sld_main.php
___________________________________________________________________
Name: svn:keywords
   + Id



More information about the Mapbender_commits mailing list