[Mapbender-commits] r2507 - branches/beck_dev/mapbender/http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Jun 17 10:48:43 EDT 2008
Author: Greq
Date: 2008-06-17 10:48:42 -0400 (Tue, 17 Jun 2008)
New Revision: 2507
Added:
branches/beck_dev/mapbender/http/php/mod_editApplication_server.php
Modified:
branches/beck_dev/mapbender/http/php/mod_editApplication.php
Log:
save
button class
Modified: branches/beck_dev/mapbender/http/php/mod_editApplication.php
===================================================================
--- branches/beck_dev/mapbender/http/php/mod_editApplication.php 2008-06-17 10:26:31 UTC (rev 2506)
+++ branches/beck_dev/mapbender/http/php/mod_editApplication.php 2008-06-17 14:48:42 UTC (rev 2507)
@@ -42,10 +42,13 @@
<link rel='stylesheet' type='text/css' href='../css/popup.css'>
<script type='text/javascript' src='../extensions/jquery-1.2.6.min.js'></script>
<script type='text/javascript' src='../extensions/jquery-ui-personalized-1.5.min.js'></script>
+<script type='text/javascript' src='../extensions/jqjson.js'></script>
<script type='text/javascript' src='../javascripts/popup.js'></script>
<script language="JavaScript" type="text/javascript">
<?php
include("../../lib/event.js");
+
+ echo "var editApplicationId = '" . $editApplicationId . "';";
?>
var controlPopup;
@@ -95,6 +98,7 @@
saveButton.registerStart(selectButton.triggerStop);
saveButton.registerStart(dragButton.triggerStop);
+ saveButton.registerStart(updateDatabase);
controlPopup.show();
@@ -211,6 +215,30 @@
}
});
}
+
+ function updateDatabase (options) {
+ var data = [];
+ $(".collection").children().each(function() {
+ data.push({
+ name:this.name,
+ top:parseInt(this.style.top),
+ left:parseInt(this.style.left)
+ });
+ });
+ var queryObj = {
+ command:"update",
+ parameters:{
+ applicationId:editApplicationId,
+ data:data
+ }
+ };
+ $.post("mod_editApplication_server.php", {
+ queryObj:$.toJSON(queryObj)
+ }, function (json, status) {
+ var replyObj = eval('(' + json + ')');
+ alert(replyObj.success);
+ });
+ }
</script>
</head>
@@ -262,8 +290,8 @@
// echo "' >";
// echo "<".db_result($res,$i,"e_element")." ";
if(db_result($res,$i,"e_id") != ""){
- echo " id='".db_result($res,$i,"e_id")."'";
- echo " name='".db_result($res,$i,"e_id")."'";
+ echo " id='".db_result($res,$i,"e_id")."' ";
+ echo " name='".db_result($res,$i,"e_id")."' ";
}
if(db_result($res,$i,"e_attributes") != ""){
// echo " ".stripslashes(preg_replace($pattern,$replacement,db_result($res,$i,"e_attributes")));
Added: branches/beck_dev/mapbender/http/php/mod_editApplication_server.php
===================================================================
--- branches/beck_dev/mapbender/http/php/mod_editApplication_server.php (rev 0)
+++ branches/beck_dev/mapbender/http/php/mod_editApplication_server.php 2008-06-17 14:48:42 UTC (rev 2507)
@@ -0,0 +1,55 @@
+<?php
+require_once(dirname(__FILE__) . "/../php/mb_validateSession.php");
+require_once(dirname(__FILE__) . "/../classes/class_user.php");
+require_once(dirname(__FILE__) . "/../classes/class_json.php");
+
+/**
+ * encodes and delivers the data
+ *
+ * @param object the un-encoded object
+ */
+function sendOutput($out){
+ global $json;
+ $output = $json->encode($out);
+ header("Content-Type: text/x-json");
+ echo $output;
+}
+
+
+$json = new Mapbender_JSON();
+$queryObj = $json->decode(stripslashes($_REQUEST['queryObj']));
+$resultObj = array();
+
+$e = new mb_exception("command: " . $queryObj->command);
+
+$userId = $_SESSION[mb_user_id];
+
+switch($queryObj->command){
+
+ // gets available WMCs
+ case 'update':
+ $elementArray = $queryObj->parameters->data;
+ for ($i = 0; $i < count($elementArray); $i++) {
+ $currentElement = $elementArray[$i];
+ $id = $currentElement->name;
+ $top = $currentElement->top;
+ $left = $currentElement->left;
+ $app = $queryObj->parameters->applicationId;
+ $sql = "UPDATE gui_element SET e_left = $1, e_top = $2 " .
+ "WHERE e_id = $3 AND fkey_gui_id = $4";
+ $v = array($left, $top, $id, $app);
+ $t = array("i", "i", "s", "s");
+ $res = db_prep_query($sql, $v, $t);
+ $e = new mb_notice("updating element '" . $id . "'");
+ }
+ $resultObj["success"] = "Elements have been updated in the database.";
+ break;
+
+
+ // Invalid command
+ default:
+ $resultObj["error"] = "no action specified...";
+}
+
+sendOutput($resultObj);
+?>
\ No newline at end of file
More information about the Mapbender_commits
mailing list