[Mapbender-commits] r2853 - branches/nimix_dev/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Aug 18 10:34:12 EDT 2008
Author: nimix
Date: 2008-08-18 10:34:12 -0400 (Mon, 18 Aug 2008)
New Revision: 2853
Added:
branches/nimix_dev/http/javascripts/mod_loadwmc.js
branches/nimix_dev/http/javascripts/mod_loadwmc_list.php
Modified:
branches/nimix_dev/http/javascripts/mod_displayWmc.php
branches/nimix_dev/http/javascripts/mod_initWmc.php
branches/nimix_dev/http/javascripts/mod_loadwmc.php
branches/nimix_dev/http/javascripts/mod_measure.php
Log:
merge
Modified: branches/nimix_dev/http/javascripts/mod_displayWmc.php
===================================================================
--- branches/nimix_dev/http/javascripts/mod_displayWmc.php 2008-08-18 14:32:27 UTC (rev 2852)
+++ branches/nimix_dev/http/javascripts/mod_displayWmc.php 2008-08-18 14:34:12 UTC (rev 2853)
@@ -22,9 +22,9 @@
$wmc_id = $_GET["wmc_id"];
if ($wmc_id){
- require_once(dirname(__FILE__)."/../classes/class_administration.php");
- $admin = new administration();
- $wmc_gml = $admin->getWmcById($wmc_id);
+ require_once(dirname(__FILE__)."/../classes/class_wmc.php");
+ $wmc = new wmc();
+ $wmc_gml = $wmc->getDocument($wmc_id);
if ($wmc_gml){
//Display WMC
Modified: branches/nimix_dev/http/javascripts/mod_initWmc.php
===================================================================
--- branches/nimix_dev/http/javascripts/mod_initWmc.php 2008-08-18 14:32:27 UTC (rev 2852)
+++ branches/nimix_dev/http/javascripts/mod_initWmc.php 2008-08-18 14:34:12 UTC (rev 2853)
@@ -68,7 +68,7 @@
echo "var wmc_id = false;";
echo "wmc_id = '".$wmc_id."';";
$wmc = new wmc();
- $wmc->createObjFromWMC_id($wmc_id);
+ $wmc->createFromDb($wmc_id);
$js_wmc .= $wmc->createJsObjFromWMC("", $e_target[0], $action);
if (!empty($x) && !empty($y) && !empty($icon)) {
Copied: branches/nimix_dev/http/javascripts/mod_loadwmc.js (from rev 2653, trunk/mapbender/http/javascripts/mod_loadwmc.js)
===================================================================
--- branches/nimix_dev/http/javascripts/mod_loadwmc.js (rev 0)
+++ branches/nimix_dev/http/javascripts/mod_loadwmc.js 2008-08-18 14:34:12 UTC (rev 2853)
@@ -0,0 +1,284 @@
+// checks if element var loadFromSession exists
+try {
+ if (loadFromSession) {
+ }
+}
+catch(e) {
+ loadFromSession = 0;
+}
+
+if (loadFromSession) {
+ // function load_wmc_session() is generated by mod_loadwmc.php
+ mb_registerInitFunctions('load_wmc_session()');
+}
+var wmcPopup = null;
+var wmcDisplayPopup = null;
+
+var serverSideFileName = "../php/mod_loadwmc_server.php";
+
+function mod_importWmc(id){
+ alert(id);
+}
+
+/**
+ * is called when the load WMC button is pressed
+ */
+function mod_loadwmc(){
+
+ var initialHtml = "<div>" +
+ "<h2 style='font-family: Arial, Helvetica, sans-serif; color: #808080;'><font align='left' color='#000000'>load WMC from list</font></h2>" +
+ "<table id='loadwmc_list' width='90%' style='font-family: Arial, Helvetica, sans-serif;font-size : 12px;color: #808080;' border='1' cellpadding='3' rules='rows'>" +
+ "<tr style='background-color:#F0F0F0;' width='80px'>" +
+ "<td><b>WMC name</b></td>" +
+ "<td><b>last update</b></td>" +
+ "<td colspan=5></td>" +
+ "</tr>" +
+ "</table>" +
+ "</div>";
+
+ // creates a new pop up (if it doesn't already exist)
+ // the pop up allows you to load, append, merge,
+ // display and delete WMC documents
+ if (wmcPopup === null) {
+ wmcPopup = new mb_popup({
+ title:"Load WMC",
+ width:500,
+ height:600,
+ top:100,
+ left:100,
+ html:initialHtml
+ });
+ }
+
+ // display the pop up
+ if (!wmcPopup.isVisible()) {
+ wmcPopup.setHtml(initialHtml);
+ wmcPopup.show();
+
+ }
+
+ // get WMC data from server
+ var queryObj = {command:"getWmc"};
+ $.post(serverSideFileName, {queryObj:$.toJSON(queryObj)}, function(json, status) {
+ var loadWmcDataError = false;
+ if (json && status == "success") {
+ loadWmcDataError = displayWmcList(json, status);
+ }
+ if (loadWmcDataError) {
+ alert("An error has occured. WMC list could not be loaded.");
+ }
+ });
+}
+
+/**
+ * Displays available WMC documents
+ */
+function displayWmcList (json, status) {
+ var wmcObj = eval("(" + json + ")");
+
+ //
+ // for each wmc, add a row to the table
+ //
+ for (var i=0; i < wmcObj.wmc.length; i++) {
+ (function () {
+ var currentId = wmcObj.wmc[i].id;
+ var $tr = $("<tr onmouseover='this.style.backgroundColor = \"#F08080\"' onmouseout='this.style.backgroundColor = \"#ffffff\"'></tr>").appendTo($("#loadwmc_list"));
+ $tr.hide();
+ var $td;
+
+ $tr.append($("<td>" + wmcObj.wmc[i].title + "</td>"));
+ $tr.append($("<td>" + wmcObj.wmc[i].timestamp + "</td>"));
+
+ //
+ // Load WMC
+ //
+ $loadWmc = $("<img src='../img/button_gray/wmc_load.png' title='load this WMC'>");
+ $loadWmc.click(function() {
+ var queryObj = {command:"loadWmc", parameters:{id:currentId}};
+ $.post(serverSideFileName, {queryObj: $.toJSON(queryObj)}, function (json, status) {
+ var loadWmcError = false;
+ if (json && status == "success") {
+ var resultObj = eval("(" + json + ")");
+ try {
+ if (resultObj.javascript && typeof(resultObj.javascript) == "object") {
+ for (var j=0; j < resultObj.javascript.length; j++) {
+// console.log("Statement: %s", resultObj.javascript[j]);
+ eval(resultObj.javascript[j]);
+ }
+ }
+ }
+ catch (e) {
+ alert(e);
+ loadWmcError = true;
+ }
+ }
+ if (loadWmcError) {
+ alert("An error has occured while loading this WMC.");
+ }
+ else {
+ // close the Pop up
+ if (wmcDisplayPopup !== null && wmcDisplayPopup.isVisible()) {
+ wmcDisplayPopup.hide();
+ }
+ wmcPopup.hide();
+ alert("WMC has been loaded successfully.");
+ }
+ });
+ });
+ $td = $("<td></td>").append($loadWmc);
+ $tr.append($td);
+
+ //
+ // Merge WMC
+ //
+ $mergeWmc = $("<img src='../img/button_gray/wmc_merge.png' title='merge WMC'>");
+ $mergeWmc.click(function() {
+ var extensionDataString = null;
+ if (currentWmcExtensionData !== null) {
+ extensionDataString = currentWmcExtensionData;
+ }
+ var queryObj = {
+ command:"mergeWmc",
+ parameters:{
+ id:currentId,
+ extensionData:extensionDataString,
+ mapObject:mb_mapObj,
+ generalTitle:"currentState"
+ }
+ };
+ $.post(serverSideFileName, {queryObj: $.toJSON(queryObj)}, function (json, status) {
+ var loadWmcError = false;
+ if (json && status == "success") {
+ var resultObj = eval("(" + json + ")");
+ try {
+ if (resultObj.javascript && typeof(resultObj.javascript) == "object") {
+ for (var j=0; j < resultObj.javascript.length; j++) {
+ eval(resultObj.javascript[j]);
+ }
+ }
+ }
+ catch (e) {
+ alert(e);
+ loadWmcError = true;
+ }
+ }
+ if (loadWmcError) {
+ alert("An error has occured while loading this WMC.");
+ }
+ else {
+ // close the Pop up
+ if (wmcDisplayPopup !== null && wmcDisplayPopup.isVisible()) {
+ wmcDisplayPopup.hide();
+ }
+ wmcPopup.hide();
+ alert("WMC has been loaded successfully.");
+ }
+ });
+ });
+ $td = $("<td></td>").append($mergeWmc);
+ $tr.append($td);
+
+ //
+ // Append WMC
+ //
+ $appendWmc = $("<img src='../img/button_gray/wmc_append.png' title='append WMC'>");
+ $appendWmc.click(function() {
+ var extensionDataString = null;
+ if (currentWmcExtensionData !== null) {
+ extensionDataString = currentWmcExtensionData;
+ }
+ var queryObj = {
+ command:"appendWmc",
+ parameters:{
+ id:currentId,
+ extensionData:extensionDataString,
+ mapObject:mb_mapObj,
+ generalTitle:"currentState"
+ }
+ };
+ $.post(serverSideFileName, {queryObj: $.toJSON(queryObj)}, function (json, status) {
+ var loadWmcError = false;
+ if (json && status == "success") {
+ var resultObj = eval("(" + json + ")");
+ try {
+ if (resultObj.javascript && typeof(resultObj.javascript) == "object") {
+ for (var j=0; j < resultObj.javascript.length; j++) {
+ eval(resultObj.javascript[j]);
+ }
+ }
+ }
+ catch (e) {
+ alert(e);
+ loadWmcError = true;
+ }
+ }
+ if (loadWmcError) {
+ alert("An error has occured while loading this WMC.");
+ }
+ else {
+ // close the Pop up
+ if (wmcDisplayPopup !== null && wmcDisplayPopup.isVisible()) {
+ wmcDisplayPopup.hide();
+ }
+ wmcPopup.hide();
+ alert("WMC has been loaded successfully.");
+ }
+ });
+ });
+ $td = $("<td></td>").append($appendWmc);
+ $tr.append($td);
+
+ //
+ // Display WMC
+ //
+ $displayWmc = $("<img src='../img/button_gray/wmc_xml.png' title='display WMC XML'>");
+ $displayWmc.click(function() {
+ // create Popup
+ if (wmcDisplayPopup === null) {
+ wmcDisplayPopup = new mb_popup({
+ title:"WMC Document",
+ width:600,
+ height:500,
+ top:100,
+ left:300,
+ url:"../javascripts/mod_displayWmc.php?wmc_id=" + currentId
+ });
+ }
+ // set correct URL
+ if (wmcDisplayPopup.isVisible()) {
+ wmcDisplayPopup.setUrl("../javascripts/mod_displayWmc.php?wmc_id=" + currentId);
+ }
+ // display the pop up
+ wmcDisplayPopup.show();
+ });
+ $td = $("<td></td>").append($displayWmc);
+ $tr.append($td);
+
+ $deleteWmc = $("<img src='../img/button_gray/del.png' title='delete this WMC'>");
+ $deleteWmc.click(function() {
+ var queryObj = {command:"deleteWmc", parameters:{id:currentId}};
+ $.post(serverSideFileName, {queryObj: $.toJSON(queryObj)}, function (json, status) {
+ var deleteWmcError = false;
+ if (json && status == "success") {
+ var resultObj = eval("(" + json + ")");
+ try {
+ if (resultObj.success) {
+ $tr.remove();
+ }
+ }
+ catch (e) {
+ deleteWmcError = true;
+ }
+ }
+ if (deleteWmcError) {
+ alert("An error has occured while deleting this WMC.");
+ }
+ });
+ });
+ $td = $("<td></td>").append($deleteWmc);
+ $tr.append($td);
+
+ $tr.fadeIn("slow");
+ }());
+ }
+}
\ No newline at end of file
Modified: branches/nimix_dev/http/javascripts/mod_loadwmc.php
===================================================================
--- branches/nimix_dev/http/javascripts/mod_loadwmc.php 2008-08-18 14:32:27 UTC (rev 2852)
+++ branches/nimix_dev/http/javascripts/mod_loadwmc.php 2008-08-18 14:34:12 UTC (rev 2853)
@@ -22,8 +22,6 @@
include(dirname(__FILE__) . "/../include/dyn_js.php");
-echo "mod_loadwmc_target = '".$e_target[0]."';";
-
/*
// this may be added at a later stage
if ($new_wmc == 1) {
@@ -46,53 +44,50 @@
}
}
*/
-?>
-function load_wmc_session() {
- <?php
- if (isset($_SESSION['mb_wmc'])) {
- $wmc = new wmc();
- if ($wmc->createObjFromWMC_xml($_SESSION['mb_wmc'])) {
- $js = "";
- if ($_SESSION['layer_preview']) {
-// echo "var e = new Mb_notice('mod_loadwmc: load_wmc_session: layer preview');";
- $js = $wmc->createJsObjFromWMC("", $e_target, "load");
- }
- else if ($startup == true) {
-// echo "var e = new Mb_notice('mod_loadwmc: load_wmc_session: load new wmc');";
- $js = $wmc->createJsObjFromWMC("", $e_target, "merge");
- $startup = false;
- }
- else {
-// echo "var e = new Mb_notice('mod_loadwmc: load_wmc_session: load old wmc');";
- $js = $wmc->createJsObjFromWMC("", $e_target, "load");
- }
- echo $js;
- }
- else {
- echo "var e = new Mb_notice('mod_loadwmc: load_wmc_session: error parsing wmc');";
- }
- }
- else {
- echo "var e = new Mb_warning('mod_loadwmc: load_wmc_session: no wmc set!');";
- }
- ?>
+
+//
+// Creates the function load_wmc_session.
+// This function loads a WMC from the session, if the element var
+// "loadFromSession" is set to true.
+//
+echo "function load_wmc_session() {";
+if (isset($_SESSION['mb_wmc'])) {
+ $wmc = new wmc();
+ if ($wmc->createFromXml($_SESSION['mb_wmc'])) {
+ $jsArray = array();
+// if ($_SESSION['layer_preview']) {
+// $js = $wmc->createJsObjFromWMC("", $e_target, "load");
+// }
+// else if ($startup == true) {
+// $js = $wmc->createJsObjFromWMC("", $e_target, "merge");
+// $startup = false;
+// }
+// else {
+ $jsArray = $wmc->toJavaScript();
+// }
+ echo implode("", $jsArray);
+
+ // test wmc from app
+ $newWmc = new wmc();
+ $newWmc->createFromApplication($_SESSION["mb_user_gui"]);
+
+
+ }
+ else {
+ echo "var e = new Mb_notice('mod_loadwmc: load_wmc_session: error parsing wmc');";
+ }
}
+else {
+ echo "var e = new Mb_warning('mod_loadwmc: load_wmc_session: no wmc set!');";
+}
+echo "}";
-try {if (loadFromSession) {}}catch(e) {loadFromSession = 0;}
-if (loadFromSession) {
- mb_registerInitFunctions('load_wmc_session()');
-}
+echo "var mod_loadwmc_img = new Image(); mod_loadwmc_img.src = '" . $e_src . "';";
-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); ?>";
-function mod_importWmc(id){
- alert(id);
-}
-function mod_loadwmc(obj){
- windowWmc = window.open("../php/mb_listWMCs.php?<?php echo SID;?>","displayWmc","width=500, height=600, scrollbars=yes, dependent=yes");
-}
-function mod_loadwmc_init(obj){
- //document.getElementById("loadwmc").src = mod_zoom1_img_over.src;
-}
\ No newline at end of file
+//
+// Creates a pop up with a dialogue to load, view or delete WMC documents
+//
+include("mod_loadwmc.js");
+?>
\ No newline at end of file
Copied: branches/nimix_dev/http/javascripts/mod_loadwmc_list.php (from rev 2653, trunk/mapbender/http/javascripts/mod_loadwmc_list.php)
===================================================================
--- branches/nimix_dev/http/javascripts/mod_loadwmc_list.php (rev 0)
+++ branches/nimix_dev/http/javascripts/mod_loadwmc_list.php 2008-08-18 14:34:12 UTC (rev 2853)
@@ -0,0 +1,3 @@
+<?php
+ echo "fisch";
+?>
\ No newline at end of file
Modified: branches/nimix_dev/http/javascripts/mod_measure.php
===================================================================
--- branches/nimix_dev/http/javascripts/mod_measure.php 2008-08-18 14:32:27 UTC (rev 2852)
+++ branches/nimix_dev/http/javascripts/mod_measure.php 2008-08-18 14:34:12 UTC (rev 2853)
@@ -143,10 +143,10 @@
function drawDashedLine(){
//check if epsg has changed
var ind = getMapObjIndexByName(mod_measure_target);
+ mod_measure_width = mb_mapObj[ind].width;
+ mod_measure_height = mb_mapObj[ind].height;
if(mod_measure_epsg != mb_mapObj[ind].epsg){
mod_measure_delete();
- mod_measure_width = mb_mapObj[ind].width;
- mod_measure_height = mb_mapObj[ind].height;
mod_measure_epsg = mb_mapObj[ind].epsg;
}
var str_mPoints = "<div style='position:absolute;left:0px;top:0px' ><img src='"+mb_trans.src+"' width='"+mod_measure_width+"' height='0'></div>";
More information about the Mapbender_commits
mailing list