[Mapbender-commits] r4861 - branches/2.6/http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Oct 23 07:33:36 EDT 2009
Author: christoph
Date: 2009-10-23 07:33:35 -0400 (Fri, 23 Oct 2009)
New Revision: 4861
Modified:
branches/2.6/http/php/mod_customTree.php
branches/2.6/http/php/mod_customTree_server.php
Log:
Modified: branches/2.6/http/php/mod_customTree.php
===================================================================
--- branches/2.6/http/php/mod_customTree.php 2009-10-23 10:18:04 UTC (rev 4860)
+++ branches/2.6/http/php/mod_customTree.php 2009-10-23 11:33:35 UTC (rev 4861)
@@ -7,16 +7,11 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET;?>" />
<title>Untitled Document</title>
+ <link rel="stylesheet" type="text/css" href="../css/customTree.css">
<style type="text/css">
.ui-selecting {
color:red;
}
- .treeNode {
- color:green;
- }
- .treeLeaf {
- color:blue;
- }
.ui-selected {
border-width:thin;
border-style:solid;
@@ -57,23 +52,7 @@
var applicationId;
- var findAllWmsInTree = function (aTree) {
- return findAllWmsInNode(aTree.root).sort();
- };
- findAllWmsInNode = function (aNode) {
- if (!aNode.isFolder) {
- return [aNode.wmsId];
- }
- var wmsIdArray = [];
- for (var i = 0; i < aNode.childNodeList.count(); i++) {
- var child = aNode.childNodeList.get(i);
- var newArray = findAllWmsInNode(child);
- wmsIdArray = wmsIdArray.concat(newArray);
- }
- return wmsIdArray;
- };
-
var saveTreeOnUnloadOrChange = function (myTree) {
if (myTree.hasChanged) {
var saveChanges = confirm("You have changed the tree. All changes will be lost. Save changes?");
@@ -86,89 +65,18 @@
}
};
- var addMissingWmsToCustomTree = function (aTree, anApplicationId) {
- // get available WMS ...
- var queryObj = {
- command:"getWmsByApplication",
- parameters: {
- "applicationId": anApplicationId
- }
- };
- $.post("../php/mod_customTree_server.php", {
- queryObj:$.toJSON(queryObj)
- }, function (json, status) {
- var replyObj = eval('(' + json + ')');
-
- var root = aTree.root;
-
- var wmsIdArray = findAllWmsInTree(aTree);
-
- for (var index in replyObj.data.wmsArray) {
- var found = false;
- for (var j = 0; j < wmsIdArray.length; j++) {
- if (wmsIdArray[j] == index) {
- found = true;
- break;
- }
- }
- if (!found) {
- var wmsNode = new CustomTreeNode();
- wmsNode.name = replyObj.data.wmsArray[index];
- wmsNode.wmsId = index;
- myTree.root.append(wmsNode);
- }
- }
-
- myTree.hasChanged = false;
-
- displayMyTree = new customTreeController(myTree, {
- contextMenu: true,
- droppable: true,
- id: "myTree"
- });
-
- });
- };
-
- var getCustomTreeByApplication = function (applicationName) {
- // load a previously saved
- // customized tree from the database
- var queryObj = {
- command:"getCustomTreeByApplication",
- parameters: {
- "applicationId":applicationName
- }
- };
-
- $.post("../php/mod_customTree_server.php", {
- queryObj:$.toJSON(queryObj)
- }, function (json, status) {
- var replyObj = eval('(' + json + ')');
-
- myTree = new CustomTree();
- var root = myTree.root;
- root.name = "(" + applicationId + ")";
-
- var nodeArray = replyObj.data.nodeArray;
-
- myTree.importNestedSets(nodeArray);
-
- addMissingWmsToCustomTree(myTree, applicationId);
-
- displayMyTree = new customTreeController(myTree, {
- contextMenu: true,
- droppable: true,
- id: "myTree"
- });
- });
- };
-
var selectApplication = function (applicationName) {
applicationId = applicationName;
- getCustomTreeByApplication(applicationId);
+ myTree = new CustomTree({
+ loadFromApplication: applicationName,
+ draggable: true,
+ droppable: true,
+ id: "myTree",
+ contextMenu: true
+ });
}
var getApplications = function () {
@@ -253,11 +161,13 @@
$.post("../php/mod_customTree_server.php", {
queryObj: $.toJSON(queryObj)
}, function(json, status){
- myTree = new CustomTree();
- var root = myTree.root;
- root.name = "(" + applicationId + ")";
-
- addMissingWmsToCustomTree(myTree, applicationId);
+ myTree = new CustomTree({
+ loadFromApplication: applicationName,
+ draggable: true,
+ droppable: true,
+ id: "myTree",
+ contextMenu: true
+ });
});
}
@@ -288,7 +198,7 @@
// dialogue: save changes on unload
$(window).unload(function () {
- saveTreeOnUnloadOrChange(myTree);
+// saveTreeOnUnloadOrChange(myTree);
})
});
Modified: branches/2.6/http/php/mod_customTree_server.php
===================================================================
--- branches/2.6/http/php/mod_customTree_server.php 2009-10-23 10:18:04 UTC (rev 4860)
+++ branches/2.6/http/php/mod_customTree_server.php 2009-10-23 11:33:35 UTC (rev 4861)
@@ -14,7 +14,6 @@
echo $output;
}
-
$json = new Mapbender_JSON();
$queryObj = $json->decode(stripslashes($_REQUEST['queryObj']));
$resultObj = array();
@@ -49,8 +48,8 @@
$allowedApplicationArray = $user->getApplicationsByPermission(0);
// get all of the users applications that contain treeGDE
- $sql = "SELECT fkey_gui_id FROM gui_element WHERE " .
- "e_id = 'treeGDE' AND fkey_gui_id IN (";
+ $sql = "SELECT DISTINCT gui_id FROM gui WHERE " .
+ "gui_id IN (";
$v = array();
$t = array();
@@ -130,8 +129,8 @@
}
}
$currentNode = array(
- "left" => $row["lft"],
- "right" => $row["rgt"],
+ "left" => intval($row["lft"]),
+ "right" => intval($row["rgt"]),
"name" => $row["my_layer_title"],
"wms" => $wmsArray
);
@@ -155,6 +154,7 @@
$t = array("s");
$res = db_prep_query($sql, $v, $t);
+ $rowArray = array();
for ($i = 0; $i < count($elementArray); $i++) {
$currentElement = $elementArray[$i];
@@ -170,8 +170,9 @@
);
$t = array("s", "i", "i", "s", "s");
$res = db_prep_query($sql, $v, $t);
+ $rowArray[]= $v;
}
- $data = array("sql" => $sql, "data" => $v);
+ $data = array("sql" => $sql, "data" => $rowArray);
$resultObj["data"] = $data;
$resultObj["success"] = "Elements have been updated in the database.";
break;
@@ -183,4 +184,4 @@
}
sendOutput($resultObj);
-?>
\ No newline at end of file
+?>
More information about the Mapbender_commits
mailing list