[Mapbender-commits] r1730 - branches/mapbender_sld/http/sld
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Oct 15 10:30:05 EDT 2007
Author: mschulz
Date: 2007-10-15 10:30:05 -0400 (Mon, 15 Oct 2007)
New Revision: 1730
Modified:
branches/mapbender_sld/http/sld/sld_function_handler.php
Log:
added new function to construct sld document, column name changes
Modified: branches/mapbender_sld/http/sld/sld_function_handler.php
===================================================================
--- branches/mapbender_sld/http/sld/sld_function_handler.php 2007-10-15 14:28:15 UTC (rev 1729)
+++ branches/mapbender_sld/http/sld/sld_function_handler.php 2007-10-15 14:30:05 UTC (rev 1730)
@@ -27,7 +27,7 @@
{
$con = db_connect($DBSERVER,$OWNER,$PW);
db_select_db($DB,$con);
- $sql = "UPDATE sld_user_layer SET sld_xml='".$data."' WHERE layer_id=".$_SESSION["sld_layer_id"]." AND mb_user_id=".$_SESSION["mb_user_id"].";";
+ $sql = "UPDATE sld_user_layer SET sld_xml='".$data."' WHERE fkey_gui_id='".$_SESSION["sld_gui_id"]."' AND fkey_layer_id=".$_SESSION["sld_layer_id"]." AND fkey_mb_user_id=".$_SESSION["mb_user_id"].";";
$res = db_query($sql);
}
@@ -55,11 +55,11 @@
// the function "getusersld" is called by the mapserver to get the user's sld
else if ($_REQUEST["function"] == "getusersld")
{
- if ( isset($_REQUEST["layer_id"]) && isset($_REQUEST["user_id"]) )
+ if ( isset($_REQUEST["layer_id"]) && isset($_REQUEST["gui_id"]) && isset($_REQUEST["user_id"]) )
{ //Used for the preview
$con = db_connect($DBSERVER,$OWNER,$PW);
db_select_db($DB,$con);
- $sql = "SELECT * FROM sld_user_layer WHERE layer_id=".$_REQUEST["layer_id"]." AND mb_user_id=".$_REQUEST["user_id"].";";
+ $sql = "SELECT * FROM sld_user_layer WHERE fkey_gui_id='".$_REQUEST["gui_id"]."' AND fkey_layer_id=".$_REQUEST["layer_id"]." AND fkey_mb_user_id=".$_REQUEST["user_id"].";";
$res = db_query($sql);
if ( db_fetch_row($res, 0) )
{
@@ -69,15 +69,16 @@
echo db_result($res, 0, "sld_xml");
}
}
- } //Used for mapbender integration
- else if ( isset($_REQUEST["layer_names"]) && isset($_REQUEST["user_id"]) )
+ } //Used for mapbender integration - old deprecated
+ else if ( isset($_REQUEST["layer_names"]) && isset($_REQUEST["user_id"]) )
{
$layer_names = split(",", urldecode($_REQUEST["layer_names"]));
$con = db_connect($DBSERVER,$OWNER,$PW);
db_select_db($DB,$con);
- $sld_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<StyledLayerDescriptor version=\"1.0.0\">\n";
+ /*$sld_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<StyledLayerDescriptor version=\"1.0.0\">\n";*/
+ $sld_xml = "<StyledLayerDescriptor version=\"1.0.0\">\n";
foreach ($layer_names as $layer_name)
{
@@ -87,8 +88,8 @@
$layer_id = "";
if ( db_fetch_row($res, 0) )
{
- $layer_id = db_result($res, 0, "layer_id");
- $sql = "SELECT * FROM sld_user_layer WHERE layer_id=".$layer_id." AND mb_user_id=".$_REQUEST["user_id"].";";
+ $layer_id = db_result($res, 0, "fkey_layer_id");
+ $sql = "SELECT * FROM sld_user_layer WHERE fkey_layer_id=".$layer_id." AND fkey_mb_user_id=".$_REQUEST["user_id"].";";
$res = db_query($sql);
if ( db_fetch_row($res, 0) )
{
@@ -103,6 +104,34 @@
}
$sld_xml .= "</StyledLayerDescriptor>";
echo $sld_xml;
+ } //Used for mapbender integration
+ else if ( isset($_REQUEST["wms_id"]) && isset($_REQUEST["gui_id"]) )
+ {
+
+ $con = db_connect($DBSERVER,$OWNER,$PW);
+ db_select_db($DB,$con);
+ $sql = "SELECT fkey_layer_id FROM gui_layer WHERE fkey_gui_id='".$_REQUEST["gui_id"]."' AND gui_layer_wms_id=".$_REQUEST["wms_id"].";";
+ $res = db_query($sql);
+
+ $sld_xml = "<StyledLayerDescriptor version=\"1.0.0\">\n";
+
+ while ($row = db_fetch_row($res))
+ {
+ $layer_id = $row[0];
+ $sql = "SELECT * FROM sld_user_layer WHERE fkey_layer_id=".$layer_id." AND fkey_gui_id='".$_REQUEST["gui_id"]."';";
+ $res2 = db_query($sql);
+ if ( db_fetch_row($res2, 0) )
+ {
+ if ( db_result($res2, 0, "use_sld") == "1" )
+ {
+ $data = db_result($res2, 0, "sld_xml");
+ $styledlayerdescriptor = parseSld($data);
+ $sld_xml .= $styledlayerdescriptor->layers[0]->generateXml(" ");
+ }
+ }
+ }
+ $sld_xml .= "</StyledLayerDescriptor>";
+ echo $sld_xml;
}
}
// sets whether the user wishes to use a sld for this layer
@@ -112,8 +141,16 @@
{
$con = db_connect($DBSERVER,$OWNER,$PW);
db_select_db($DB,$con);
- $sql = "UPDATE sld_user_layer SET use_sld=".$_REQUEST["use_sld"]." WHERE layer_id='".$_SESSION["sld_layer_id"]."' AND mb_user_id='".$_SESSION["mb_user_id"]."';";
+ $sql = "UPDATE sld_user_layer SET use_sld=".$_REQUEST["use_sld"]." WHERE fkey_layer_id='".$_SESSION["sld_layer_id"]."' AND fkey_mb_user_id='".$_SESSION["mb_user_id"]."';";
$res = db_query($sql);
+
+ # update gui_wms_sldurl
+ if ($_REQUEST["use_sld"]=="1")
+ $sld_url = $_REQUEST["mb_sld_url"];
+ else
+ $sld_url = "";
+ $sql = "UPDATE gui_wms SET gui_wms_sldurl='".$sld_url."' WHERE fkey_gui_id='".$_SESSION["sld_gui_id"]."' AND fkey_wms_id=".$_SESSION["sld_wms_id"];
+ $res = db_query($sql);
}
}
More information about the Mapbender_commits
mailing list