svn commit: r755 - trunk/mapbender/http: classes javascripts php
christoph at osgeo.org
christoph at osgeo.org
Wed Aug 16 11:21:36 EDT 2006
Author: christoph
Date: 2006-08-16 15:21:35+0000
New Revision: 755
Modified:
trunk/mapbender/http/classes/class_wmc.php
trunk/mapbender/http/javascripts/mod_initWmc.php
trunk/mapbender/http/javascripts/mod_insertWmcIntoDb.php
trunk/mapbender/http/javascripts/mod_loadwmc.php
trunk/mapbender/http/javascripts/mod_savewmc.php
trunk/mapbender/http/php/mb_listWMCs.php
Log:
when the client is unloaded, the current workspace is saved as a wmc in the session variable mb_wmc.
Modified: trunk/mapbender/http/classes/class_wmc.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/classes/class_wmc.php?view=diff&rev=755&p1=trunk/mapbender/http/classes/class_wmc.php&p2=trunk/mapbender/http/classes/class_wmc.php&r1=754&r2=755
==============================================================================
--- trunk/mapbender/http/classes/class_wmc.php (original)
+++ trunk/mapbender/http/classes/class_wmc.php 2006-08-16 15:21:35+0000
@@ -110,7 +110,7 @@
return $this->wmc_wms_count;
}
-function createObjFromWMC($wmc_id){
+function createObjFromWMC_id($wmc_id){
global $DBSERVER,$DB,$OWNER,$PW;
$con = db_connect($DBSERVER,$OWNER,$PW);
@@ -119,10 +119,13 @@
$sql = "SELECT wmc FROM mb_user_wmc WHERE wmc_id = '" . $wmc_id . "'";
$res = db_query($sql);
$wmc = db_fetch_row($res);
- $verbose = "<pre>" . htmlentities($wmc[0]) . "</pre>";
+ $this->createObjFromWMC_xml($wmc[0]);
- $data = str_replace("&", "&", $wmc[0]);
-
+}
+function createObjFromWMC_xml($data){
+ $data = str_replace("&", "&", $data);
+ $values = NULL;
+ $tags = NULL;
$parser = xml_parser_create(CHARSET);
xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
@@ -134,20 +137,13 @@
}
xml_parser_free($parser);
- /* echo "Index array\n";
- * print_r($tags);
- * echo "\nVals array\n";
- * print_r($values);
- */
-
-
- $section;
- $format;
+ $section = NULL;
+ $format = NULL;
$cnt_format = 0;
$parent = array();
$myParent = array();
$cnt_layer = -1;
- $request;
+ $request = NULL;
$layer_style = array();
$cnt_styles = -1;
Modified: trunk/mapbender/http/javascripts/mod_initWmc.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/mod_initWmc.php?view=diff&rev=755&p1=trunk/mapbender/http/javascripts/mod_initWmc.php&p2=trunk/mapbender/http/javascripts/mod_initWmc.php&r1=754&r2=755
==============================================================================
--- trunk/mapbender/http/javascripts/mod_initWmc.php (original)
+++ trunk/mapbender/http/javascripts/mod_initWmc.php 2006-08-16 15:21:35+0000
@@ -77,7 +77,7 @@
echo "var wmc_id = false;";
echo "wmc_id = '".$wmc_id."';";
$wmc = new wmc();
- $wmc->createObjFromWMC($wmc_id);
+ $wmc->createObjFromWMC_id($wmc_id);
$js_wmc .= $wmc->createJsObjFromWMC("", $e_target[0], "load");
if ($x && $y && $icon) {
Modified: trunk/mapbender/http/javascripts/mod_insertWmcIntoDb.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/mod_insertWmcIntoDb.php?view=diff&rev=755&p1=trunk/mapbender/http/javascripts/mod_insertWmcIntoDb.php&p2=trunk/mapbender/http/javascripts/mod_insertWmcIntoDb.php&r1=754&r2=755
==============================================================================
--- trunk/mapbender/http/javascripts/mod_insertWmcIntoDb.php (original)
+++ trunk/mapbender/http/javascripts/mod_insertWmcIntoDb.php 2006-08-16 15:21:35+0000
@@ -18,7 +18,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
include("../../conf/mapbender.conf");
-
+session_start();
$gui_id = $_REQUEST["gui_id"];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
@@ -36,7 +36,7 @@
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="0">
<?php
-echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';
+echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';
?>
<title>MB2 - <?php echo $_REQUEST["gui_id"];?></title>
<?php
@@ -54,21 +54,32 @@
// Display WMC
//echo "<pre>" . stripslashes($d[2]) . "</pre>";
$alert = $d[4];
+ $session = $d[5];
- $sql = "INSERT INTO mb_user_wmc VALUES ('" . $d[3] . "', '" . $d[0] . "', '" . str_replace("&", "&" , html_entity_decode($d[2])) . "', '" . $d[1] . "', '" . time() . "')";
-
-
- $res = db_query($sql);
- if ($d[1]) {
- $wmc_title = "'" . $d[1] . "' ";
- }
- if (db_error()) {
- echo "<script>var title = \"" . $wmc_title . "\";alert(\"Error while saving WMC document \" + title + \"!\");</script>";
+ if ($session) {
+ echo "<script>document.write('<b>saving workspace...</b>');</script>";
+// $sql = "INSERT INTO mb_user_wmc VALUES ('" . $d[3] . "', '" . $d[0] . "', '" . str_replace("&", "&" , html_entity_decode($d[2])) . "', '" . $d[1] . "', '" . time() . "')";
+// $res = db_query($sql);
+ $_SESSION['mb_wmc'] = str_replace("&", "&" , html_entity_decode($d[2]));
+ echo "<script>function obsolete(){window.close();} window.setTimeout('obsolete()', 1000);</script>";
}
else {
- if ($alert) {
- echo "<script>var title = \"" . $wmc_title . "\";alert(\"WMC document \" + title + \"has been saved!\")</script>";
+ $sql = "INSERT INTO mb_user_wmc VALUES ('" . $d[3] . "', '" . $d[0] . "', '" . str_replace("&", "&" , html_entity_decode($d[2])) . "', '" . $d[1] . "', '" . time() . "')";
+
+
+ $res = db_query($sql);
+ if ($d[1]) {
+ $wmc_title = "'" . $d[1] . "' ";
+ }
+ if (db_error()) {
+ echo "<script>var title = \"" . $wmc_title . "\";alert(\"Error while saving WMC document \" + title + \"!\");</script>";
+ }
+ else {
+ if ($alert) {
+ echo "<script>var title = \"" . $wmc_title . "\";alert(\"WMC document \" + title + \"has been saved!\")</script>";
+ }
}
}
+
}
?>
\ No newline at end of file
Modified: trunk/mapbender/http/javascripts/mod_loadwmc.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/mod_loadwmc.php?view=diff&rev=755&p1=trunk/mapbender/http/javascripts/mod_loadwmc.php&p2=trunk/mapbender/http/javascripts/mod_loadwmc.php&r1=754&r2=755
==============================================================================
--- trunk/mapbender/http/javascripts/mod_loadwmc.php (original)
+++ trunk/mapbender/http/javascripts/mod_loadwmc.php 2006-08-16 15:21:35+0000
@@ -18,6 +18,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require_once("../../conf/mapbender.conf");
+require_once("../classes/class_wmc.php");
$gui_id = $_REQUEST["gui_id"];
@@ -38,8 +39,23 @@
}
echo "mod_loadwmc_target = '".$e_target."';";
+
?>
+function load_wmc_session() {
+ <?php
+ if ($_SESSION['mb_wmc']) {
+ $wmc = new wmc();
+ $wmc->createObjFromWMC_xml($_SESSION['mb_wmc']);
+
+ $js = $wmc->createJsObjFromWMC("", $e_target, "load");
+ echo $js;
+
+ }
+ ?>
+}
+mb_registerInitFunctions('load_wmc_session()');
+
var mod_loadwmc_img = new Image(); mod_loadwmc_img.src = "<?php echo $e_src; ?>";
//var mod_loadwmc_img_over = new Image(); mod_loadwmc_img_over.src = "<?php echo preg_replace("/_off/","_over",$e_src); ?>";
Modified: trunk/mapbender/http/javascripts/mod_savewmc.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/mod_savewmc.php?view=diff&rev=755&p1=trunk/mapbender/http/javascripts/mod_savewmc.php&p2=trunk/mapbender/http/javascripts/mod_savewmc.php&r1=754&r2=755
==============================================================================
--- trunk/mapbender/http/javascripts/mod_savewmc.php (original)
+++ trunk/mapbender/http/javascripts/mod_savewmc.php 2006-08-16 15:21:35+0000
@@ -38,6 +38,11 @@
echo "mod_savewmc_target = '".$e_target."';";
?>
+function setOnUnload() {
+ document.getElementsByTagName('body')[0].setAttribute("onUnload", "mod_savewmc('session');");
+}
+
+mb_registerInitFunctions('setOnUnload()');
var mod_savewmc_img = new Image(); mod_savewmc_img.src = "<?php echo $e_src; ?>";
//var mod_savewmc_img_over = new Image(); mod_savewmc_img_over.src = "<?php echo preg_replace("/_off/","_over",$e_src); ?>";
@@ -45,9 +50,13 @@
function mod_savewmc(title){
var user = "<?php echo $_SESSION["mb_user_id"]; ?>";
var ind = getMapObjIndexByName(mod_savewmc_target);
+ var session = 0;
if (title) {
var generalTitle = title;
title_alert = 0;
+ if (title == 'session') {
+ session = 1;
+ }
}
else {
var generalTitle = prompt("Save WMC as...");
@@ -380,9 +389,14 @@
wmc += "\t</LayerList>\n";
wmc += "</ViewContext>\n";
- //document.sendData.target = "_blank";
+ if (session == true) {
+ var wmc_win = window.open('about:blank', 'wmc_confirm', 'width=200,height=10,left='+Math.round(0.5*screen.width)+',top='+Math.round(0.5*screen.height));
+ document.sendData.target = 'wmc_confirm';
+// document.sendData.target = '_blank';
+
+ }
document.sendData.action = "../javascripts/mod_insertWmcIntoDb.php";
- document.sendData.data.value = user + "____" + generalTitle + "____" + wmc + "____" + id + "____" + title_alert;
+ document.sendData.data.value = user + "____" + generalTitle + "____" + wmc + "____" + id + "____" + title_alert + "____" + session;
document.sendData.submit();
}
return id;
Modified: trunk/mapbender/http/php/mb_listWMCs.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/php/mb_listWMCs.php?view=diff&rev=755&p1=trunk/mapbender/http/php/mb_listWMCs.php&p2=trunk/mapbender/http/php/mb_listWMCs.php&r1=754&r2=755
==============================================================================
--- trunk/mapbender/http/php/mb_listWMCs.php (original)
+++ trunk/mapbender/http/php/mb_listWMCs.php 2006-08-16 15:21:35+0000
@@ -130,7 +130,7 @@
}
$target = explode(",", $e_target);
$wmc = new wmc();
- $wmc->createObjFromWMC($_GET["wmc_id"]);
+ $wmc->createObjFromWMC_id($_GET["wmc_id"]);
if ($_GET["action"] == "append" || $_GET["action"] == "merge" || $_GET["action"] == "load") {
$js = $wmc->createJsObjFromWMC("window.opener.", trim($target[1]), $_GET["action"]);
}
More information about the Mapbender_commits
mailing list