[Mapbender-commits] r1285 - in trunk/mapbender/http: javascripts php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Apr 27 11:16:32 EDT 2007
Author: christoph
Date: 2007-04-27 11:16:31 -0400 (Fri, 27 Apr 2007)
New Revision: 1285
Added:
trunk/mapbender/http/javascripts/mod_addWMSfromfilteredList_ajax.php
trunk/mapbender/http/php/mod_addWMSfromfilteredList_server.php
Log:
addwmsfromfilteredlist ajax version for MB 2.5
Added: trunk/mapbender/http/javascripts/mod_addWMSfromfilteredList_ajax.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_addWMSfromfilteredList_ajax.php (rev 0)
+++ trunk/mapbender/http/javascripts/mod_addWMSfromfilteredList_ajax.php 2007-04-27 15:16:31 UTC (rev 1285)
@@ -0,0 +1,287 @@
+<?php
+# $Id: mod_addWMSfromfilteredList.php 830 2006-11-20 13:39:10Z christoph $
+# http://www.mapbender.org/index.php/mod_addWMSfromfilteredList.php
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset='<?php echo CHARSET;?>'>
+<title>Add WMS from Filtered Catalog</title>
+<link rel="stylesheet" type="text/css" href="../css/administration_alloc.css">
+<STYLE TYPE="text/css">
+<!--
+body{
+ font-family:Verdana, Geneva, Arial, Helvetica, sans-serif;
+ font-size:10pt
+}
+
+table{
+ font-family:Verdana, Geneva, Arial, Helvetica, sans-serif;
+ font-size:11;
+}
+
+.wms_button{
+ color: black;
+ border: solid thin;
+ height:22px;
+ width:60px;
+}
+-->
+</STYLE>
+<?php
+include '../include/dyn_css.php';
+?>
+<script type="text/javascript">
+<!--
+var global_source = "capabilities"; // "capabilities" || "db"
+var phpUrl = "../php/mod_addWMSfromfilteredList_server.php";
+
+// ----------------- Load service --------------------
+
+function mod_addWMSfromDB(gui_id, wms_id) {
+ window.opener.mod_addWMSById_load(gui_id, wms_id);
+}
+
+function mod_addWMSfromfilteredList(pointer_name,version){
+
+ var load = false;
+ var conjunctionCharacter = window.opener.mb_getConjunctionCharacter(pointer_name);
+
+ if (version == '1.0.0') {
+ load = pointer_name + conjunctionCharacter + "REQUEST=capabilities&WMTVER=1.0.0";
+ }
+ else if (version == '1.1.0' || version == '1.1.1') {
+ load = pointer_name + conjunctionCharacter + "REQUEST=GetCapabilities&SERVICE=WMS&VERSION=" + version;
+ }
+ if (load !== false) {
+ window.opener.mod_addWMS_load(load);
+ }
+}
+
+// ----------------- Display results --------------------
+
+function createTable(id, titleLeft, titleRight) {
+ document.getElementById("titleLeft").innerHTML = titleLeft;
+ document.getElementById("titleRight").innerHTML = titleRight;
+ return tableNode;
+}
+
+function addRow(tableId, leftText, rightText, onClick) {
+
+ var leftDivNode = createDiv(leftText, onClick);
+ var rightDivNode = createDiv(rightText, onClick);
+
+ var leftNode = document.createElement("td");
+ leftNode.appendChild(leftDivNode);
+
+ var rightNode = document.createElement("td");
+ rightNode.appendChild(rightDivNode);
+
+ var rowNode = document.createElement("tr");
+ rowNode.setAttribute("class", "Farbe");
+ rowNode.setAttribute("onmouseover", "this.style.backgroundColor = \"#F08080\"");
+ rowNode.setAttribute("onmouseout", "this.style.backgroundColor = \"#FFFFFF\"");
+ rowNode.appendChild(leftNode);
+ rowNode.appendChild(rightNode);
+ console.log("addRow");
+ document.getElementById(tableId).appendChild(rowNode);
+}
+
+function createDiv(text, onClick) {
+ var divNode = document.createElement("div");
+ divNode.style.cursor = "pointer";
+ divNode.setAttribute("onclick", onClick);
+ divNode.innerHTML = text;
+
+ return divNode;
+}
+
+function removeChildNodes(node) {
+ while (node.childNodes.length > 0) {
+ var childNode = node.firstChild;
+ node.removeChild(childNode);
+ }
+}
+
+function imageOn() {
+ var imgNode = document.createElement("img");
+ imgNode.setAttribute("src", "../img/indicator_wheel.gif");
+ document.getElementById("searchImageTable").firstChild.firstChild.appendChild(imgNode);
+// document.getElementById("searchImageTable").firstChild.firstChild.appendChild(imgNode);
+ document.getElementById("searchImageTable").style.visibility = "visible";
+ document.getElementById("resultTable").style.visibility = "hidden";
+ document.getElementById("resultString").style.visibility = "hidden";
+}
+
+function imageOff() {
+ document.getElementById("searchImageTable").style.visibility = "hidden";
+ document.getElementById("resultTable").style.visibility = "visible";
+ document.getElementById("resultString").style.visibility = "visible";
+}
+
+function setTitle (text) {
+ document.getElementById("resultString").innerHTML = text;
+}
+
+function setSource(sourceValue) {
+ global_source = sourceValue;
+}
+
+function setButtons() {
+ if (typeof(option_all) != "undefined" && option_all == '0') {
+ var child = document.getElementById("button_all");
+ child.parentNode.removeChild(child);
+ }
+ if (typeof(option_group) != "undefined" && option_group == '0') {
+ var child = document.getElementById("button_group");
+ child.parentNode.removeChild(child);
+ }
+ if (typeof(option_gui) != "undefined" && option_gui == '0') {
+ var child = document.getElementById("button_gui");
+ child.parentNode.removeChild(child);
+ }
+ if (typeof(option_db) != "undefined" && option_db == '0') {
+ var child = document.getElementById("button_db");
+ child.parentNode.removeChild(child);
+ }
+}
+// ----------------- Retrieve data --------------------
+
+
+function getGroups() {
+ imageOn();
+ window.opener.mb_ajax_json(phpUrl, {"command":"getGroups"}, function (json, status) {
+ imageOff();
+ displayGroups(json.group);
+ });
+}
+
+function getGUIs() {
+ imageOn();
+ window.opener.mb_ajax_json(phpUrl, {"command":"getGUIs"}, function (json, status) {
+ imageOff();
+ displayGUIs(json.gui);
+ });
+}
+
+function getWMSByGUI(guiId) {
+ imageOn();
+ window.opener.mb_ajax_json(phpUrl, {"command":"getWMSByGUI", "guiId":guiId}, function (json, status) {
+ imageOff();
+ displayWMS(json.wms, guiId);
+ });
+}
+
+function getWMSByGroup(groupId) {
+ imageOn();
+ window.opener.mb_ajax_json(phpUrl, {"command":"getWMSByGroup", "groupId":groupId}, function (json, status) {
+ imageOff();
+ displayWMS(json.wms);
+ });
+}
+
+function getAllWMS() {
+ imageOn();
+ window.opener.mb_ajax_json(phpUrl, {"command":"getAllWMS"}, function (json, status) {
+ imageOff();
+ displayWMS(json.wms);
+ });
+}
+
+function displayGroups (groupArray) {
+ setTitle(selectGroupText);
+
+ var newTable = createTable("groupList", groupNameText, groupAbstractText);
+
+ for (var i = 0; i < groupArray.length; i++) {
+ var onClick = "getWMSByGroup('" + groupArray[i].id + "')";
+ addRow("resultTable", groupArray[i].name, groupArray[i].description, onClick);
+ }
+}
+
+function displayGUIs (guiArray) {
+ setTitle(selectGuiText);
+ var newTable = createTable("guiList", guiNameText, guiAbstractText);
+
+ for (var i = 0; i < guiArray.length; i++) {
+ var onClick = "getWMSByGUI('" + guiArray[i].id + "')";
+ addRow("resultTable", guiArray[i].name, guiArray[i].description, onClick);
+ }
+}
+
+function displayWMS (wmsArray, guiId) {
+ if (wmsArray.length) {
+ setTitle(selectWmsText);
+ var newTable = createTable("wmsList", wmsTitleText, wmsAbstractText);
+
+ for (var i = 0; i < wmsArray.length; i++) {
+
+ if (global_source == "db" && typeof(guiId) !== "undefined" ) {
+ var onClick = "mod_addWMSfromDB('" + guiId + "', '" + wmsArray[i].id + "')";
+ }
+ else {
+ var onClick = "mod_addWMSfromfilteredList('" + wmsArray[i].getCapabilitiesUrl + "', '" + wmsArray[i].version + "')";
+ }
+ addRow("resultTable", wmsArray[i].title, wmsArray[i].abstract, onClick);
+ }
+ }
+ else {
+ document.getElementById("divResults").innerHTML = "No result.";
+ }
+}
+
+// -->
+</script>
+</head>
+<body onLoad="window.focus();setButtons();">
+
+<form name='addWMSForm'>
+ <table border='0' cellpadding='3' rules='rows'>
+ <tr>
+ <td><input type='button' class='wms_button' name='button_all' id='button_all' value='all wms' onclick='setSource("capabilities");getAllWMS()'></td>
+ <td><input type='button' class='wms_button' name='button_group' id='button_group' value='group' onclick = 'setSource("capabilities");getGroups()'></td>
+ <td><input type='button' class='wms_button' name='button_gui' id='button_gui' value='gui' onclick = 'setSource("capabilities");getGUIs()'></td>
+ <td><input type='button' class='wms_button' name='button_db' id='button_db' value='db' onclick = 'setSource("db");getGUIs()'></td>
+ </tr>
+ </table>
+</form>
+
+<div class='divResults' id='divResults'>
+
+<table id='searchImageTable' name='searchImageTable'>
+ <tr>
+ <td></td>
+ <td></td>
+ </tr>
+</table>
+
+<div id='resultString' name='resultString'></div>
+
+<table id='resultTable' name='resultTable' border=1 width="98%" cellpadding=3>
+ <thead bgcolor="#FAEBD7">
+ <tr>
+ <td id='titleLeft' name='titleLeft' width=200 height=10></td>
+ <td id='titleRight' name='titleRight' align=left class=fieldnames_s></td>
+ </tr>
+ </thead>
+</table>
+</div>
+</body>
+</html>
\ No newline at end of file
Added: trunk/mapbender/http/php/mod_addWMSfromfilteredList_server.php
===================================================================
--- trunk/mapbender/http/php/mod_addWMSfromfilteredList_server.php (rev 0)
+++ trunk/mapbender/http/php/mod_addWMSfromfilteredList_server.php 2007-04-27 15:16:31 UTC (rev 1285)
@@ -0,0 +1,141 @@
+<?php
+# $Id: mod_addWMSfromfilteredList.php 830 2006-11-20 13:39:10Z christoph $
+# http://www.mapbender.org/index.php/mod_addWMSfromfilteredList.php
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+session_start();
+
+require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+require_once(dirname(__FILE__)."/../classes/class_wms.php");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+require_once(dirname(__FILE__)."/../extensions/JSON.php");
+
+$userId = $_SESSION["mb_user_id"];
+$command = $_GET["command"];
+$guiId = $_GET["guiId"];
+$groupId = $_GET["groupId"];
+
+$con = db_connect($DBSERVER,$OWNER,$PW);
+db_select_db(DB,$con);
+
+$admin = new administration();
+$guiIdArray = $admin->getGuisByPermission($userId, false);
+
+$resultObj = array();
+
+if ($command == "getGroups") {
+ $resultObj["group"] = array();
+
+ $sql = "SELECT mb_group_id, mb_group_name, mb_group_description ";
+ $sql .= "FROM mb_group, mb_user_mb_group ";
+ $sql .= "WHERE fkey_mb_group_id = mb_group_id AND fkey_mb_user_id = $1 ";
+ $sql .= "ORDER BY mb_group_name";
+ $v = array($userId);
+ $t = array("i");
+ $res = db_prep_query($sql, $v, $t);
+
+ while($row = db_fetch_array($res)){
+ $resultArray = array("description" => $row["mb_group_description"], "name" => $row["mb_group_name"], "id" => $row["mb_group_id"]);
+ array_push($resultObj["group"], $resultArray);
+ }
+}
+else if ($command == "getGUIs") {
+
+ $resultObj["gui"] = array();
+
+ $sql = "SELECT * FROM gui WHERE gui_id IN (";
+ $v = array();
+ $t = array();
+
+ for ($i = 0; $i < count($guiIdArray); $i++) {
+ if ($i > 0) {
+ $sql .= ",";
+ }
+ $sql .= "$" . strval($i + 1);
+ array_push($v, $guiIdArray[$i]);
+ array_push($t, "s");
+ }
+ $sql .= ") ORDER BY gui_name";
+
+ $res = db_prep_query($sql,$v,$t);
+
+ while ($row = db_fetch_array($res)) {
+ $resultArray = array("description" => $row["gui_description"], "name" => $row["gui_name"], "id" => $row["gui_id"]);
+ array_push($resultObj["gui"], $resultArray);
+ }
+}
+else if ($command == "getAllWMS") {
+ $resultObj["wms"] = array();
+
+ $sql = "SELECT DISTINCT wms.wms_id, wms.wms_title, wms.wms_abstract, wms.wms_getcapabilities, wms.wms_version ";
+ $sql .= "FROM wms, gui_wms ";
+ $sql .= "WHERE wms.wms_id = gui_wms.fkey_wms_id AND gui_wms.fkey_gui_id IN (";
+ $v = array();
+ $t = array();
+
+ for ($i = 0; $i < count($guiIdArray); $i++) {
+ if ($i > 0) {
+ $sql .= ",";
+ }
+ $sql .= "$" . strval($i + 1);
+ array_push($v, $guiIdArray[$i]);
+ array_push($t, "s");
+ }
+ $sql .= ") ORDER BY wms_title";
+
+ $res = db_prep_query($sql,$v,$t);
+
+ while ($row = db_fetch_array($res)) {
+ $resultArray = array("id" => $row["wms_id"], "title" => $row["wms_title"], "abstract" => $row["wms_abstract"], "getCapabilitiesUrl" => $row["wms_getcapabilities"], "version" => $row["wms_version"]);
+ array_push($resultObj["wms"], $resultArray);
+ }
+}
+else if ($command == "getWMSByGroup") {
+ $resultObj["wms"] = array();
+
+ $sql = "SELECT DISTINCT wms_id, wms_title, wms_abstract, wms_getcapabilities, wms_version ";
+ $sql .= "FROM wms, gui_wms, gui_mb_group ";
+ $sql .= "WHERE wms.wms_id = gui_wms.fkey_wms_id AND gui_wms.fkey_gui_id = gui_mb_group.fkey_gui_id AND gui_mb_group.fkey_mb_group_id = $1";
+ $v = array($groupId);
+ $t = array("i");
+ $res = db_prep_query($sql, $v, $t);
+
+ while ($row = db_fetch_array($res)) {
+ $resultArray = array("id" => $row["wms_id"], "title" => $row["wms_title"], "abstract" => $row["wms_abstract"], "getCapabilitiesUrl" => $row["wms_getcapabilities"], "version" => $row["wms_version"]);
+ array_push($resultObj["wms"], $resultArray);
+ }
+}
+else if ($command == "getWMSByGUI") {
+ $resultObj["wms"] = array();
+
+ $sql = "SELECT DISTINCT wms_id, wms_title, wms_abstract, wms_getcapabilities, wms_version ";
+ $sql .= "FROM wms, gui_wms WHERE wms.wms_id = gui_wms.fkey_wms_id AND fkey_gui_id = $1";
+ $v = array($guiId);
+ $t = array("s");
+ $res = db_prep_query($sql, $v, $t);
+
+ while ($row = db_fetch_array($res)) {
+ $resultArray = array("id" => $row["wms_id"], "title" => $row["wms_title"], "abstract" => $row["wms_abstract"], "getCapabilitiesUrl" => $row["wms_getcapabilities"], "version" => $row["wms_version"]);
+ array_push($resultObj["wms"], $resultArray);
+ }
+}
+
+$json = new Services_JSON();
+$output = $json->encode($resultObj);
+echo $output;
+?>
\ No newline at end of file
More information about the Mapbender_commits
mailing list