[Mapbender-commits] r1353 - trunk/mapbender/http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu May 24 11:34:07 EDT 2007
Author: christoph
Date: 2007-05-24 11:34:07 -0400 (Thu, 24 May 2007)
New Revision: 1353
Removed:
trunk/mapbender/http/php/mod_wfs_gazetteer_ajax.php
trunk/mapbender/http/php/mod_wfs_gazetteer_conf_server.php
trunk/mapbender/http/php/mod_wfs_gazetteer_search.php
Modified:
trunk/mapbender/http/php/mod_wfs_gazetteer.php
trunk/mapbender/http/php/mod_wfs_gazetteer_server.php
Log:
new wfs gazetteer w/ ajax
Modified: trunk/mapbender/http/php/mod_wfs_gazetteer.php
===================================================================
--- trunk/mapbender/http/php/mod_wfs_gazetteer.php 2007-05-24 14:59:52 UTC (rev 1352)
+++ trunk/mapbender/http/php/mod_wfs_gazetteer.php 2007-05-24 15:34:07 UTC (rev 1353)
@@ -197,6 +197,7 @@
}
echo "<style type='text/css'>";
echo $g_style[$i];
+ echo $g_res_style[$i];
echo "</style>";
/* wfs_conf_element */
Deleted: trunk/mapbender/http/php/mod_wfs_gazetteer_ajax.php
===================================================================
--- trunk/mapbender/http/php/mod_wfs_gazetteer_ajax.php 2007-05-24 14:59:52 UTC (rev 1352)
+++ trunk/mapbender/http/php/mod_wfs_gazetteer_ajax.php 2007-05-24 15:34:07 UTC (rev 1353)
@@ -1,392 +0,0 @@
-<?php
-# $Id$
-# maintained by http://www.mapbender.org/index.php/User:Verena Diewald
-# http://www.mapbender.org/index.php/WFS_gazetteer
-# 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();
-$gui_id = $_SESSION["mb_user_gui"];
-
-$wfsConfIdString = $_REQUEST["wfs_conf"];
-$selectedConfId = $_REQUEST["selected_conf"];
-$target = $_REQUEST["target"];
-$resultFrame = $_REQUEST["resultFrame"];
-$e_id_css = $_REQUEST["e_id_css"];
-
-require_once("../../conf/mapbender.conf");
-
-$con = db_connect($DBSERVER,$OWNER,$PW);
-db_select_db($DB,$con);
-?>
-<!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>mod_wfs_gazetteer</title>
-<?php
-include '../include/dyn_css.php';
-
-function createWfsConfSelectBox($idArray, $labelArray, $selectedId) {
- $wfsConfSelectBox .= "<select name='wfs_conf_sel' size='1' onChange='conf_selection()'>\n";
-
- if (!isset($selectedId)) {$selectedId = 0;}
-
- for($i = 0; $i < count($idArray); $i++){
- $selected = "";
- if ($idArray[$i] == $selectedId) {$selected = "selected";}
-
- $wfsConfSelectBox .= "<option value='".$idArray[$i]."' " . $selected . ">" . $labelArray[$idArray[$i]] . "</option>\n";
- }
- $wfsConfSelectBox .= "</select>";
- return $wfsConfSelectBox;
-}
-
-if ($wfsConfIdString != "") {
- $wfsConfIdArray = split(",", $wfsConfIdString);
- $wfsConfCount = count($wfsConfIdArray);
-}
-else {
- if ($selectedConfId) {
- $wfsConfIdArray = array($selectedConfId);
- $wfsConfCount = 1;
- }
- else {
- $wfsConfIdArray = array();
- $wfsConfCount = 0;
- }
-}
-
-if ($wfsConfCount > 0) {
- // -------------------------------------------------------------------------------
- // WFS CONF
- //
- $sql = "SELECT * FROM wfs_conf ";
- $sql .= "JOIN wfs ON wfs_conf.fkey_wfs_id = wfs.wfs_id ";
- $sql .= "WHERE wfs_conf.wfs_conf_id IN (";
- $v = array();
- $t = array();
- for ($i = 0; $i < $wfsConfCount; $i++) {
- if ($i > 0) {$sql .= ", ";}
- $sql .= "$" . ($i+1);
- array_push($v, $wfsConfIdArray[$i]);
- array_push($t, 'i');
- }
- $sql .= ")";
-
- $res = db_prep_query($sql, $v, $t);
- while ($row = db_fetch_array($res)) {
- $id = $row["wfs_conf_id"];
- $g_label[$id] = $row["g_label"];
- $g_label_id[$id] = $row["g_label_id"];
- $g_style[$id] = $row["g_style"];
- $g_button[$id] = $row["g_button"];
- $g_button_id[$id] = $row["g_button_id"];
- $g_buffer[$id] = $row["g_buffer"];
- $g_res_style[$id] = $row["g_res_style"];
- $g_use_wzgraphics[$id] = $row["g_use_wzgraphics"];
- $wfs_id[$id] = $row["fkey_wfs_id"];
- $featuretype_id[$id] = $row["fkey_featuretype_id"];
- $wfs_getfeature[$id] = $row["wfs_getfeature"];
- }
-
- // if more than one wfs is available, add a select box
- if ($wfsConfCount > 1) {
- $wfsConfForm = "<form name='sel_wfs_conf_form' method='POST' action='mod_wfs_gazetteer.php'>\n";
- $wfsConfForm .= createWfsConfSelectBox($wfsConfIdArray, $g_label, $selectedConfId);
- $wfsConfForm .= "<input type='hidden' name='wfs_conf' value='".$wfsConfIdString."'>\n";
- $wfsConfForm .= "<input type='hidden' name='selected_conf' value='".$selectedConfId."'>\n";
- $wfsConfForm .= "<input type='hidden' name='target' value='".$target."'>\n";
- $wfsConfForm .= "<input type='hidden' name='resultFrame' value='".$resultFrame."'>\n";
- $wfsConfForm .= "</form>";
-
- echo $wfsConfForm;
-
- if (!isset($selectedConfId)) {
- $selectedConfId = $wfsConfIdArray[0];
- }
- }
- // if only one wfs is available, use it
- else {
- $selectedConfId = $wfsConfIdArray[0];
- }
-
- $sql = "SELECT * FROM wfs_featuretype WHERE fkey_wfs_id = $1 AND featuretype_id = $2";
- $v = array($wfs_id[$selectedConfId], $featuretype_id[$selectedConfId]);
- $t = array('i', 'i');
- $res = db_prep_query($sql, $v, $t);
-
- if ($row = db_fetch_array($res)) {
- $featuretype_name = $row["featuretype_name"];
- $featuretype_srs = $row["featuretype_srs"];
- }
- else{
- die("Please add the wfs_conf to the src-Parameter");
- }
-
- // Style
- echo "<style type='text/css'>" . $g_style[$selectedConfId] . "</style>";
-
-
-
- // -------------------------------------------------------------------------------
- // WFS CONF ELEMENTS
- //
-
- $sql = "SELECT * FROM wfs_conf_element ";
- $sql .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
- $sql .= "WHERE wfs_conf_element.fkey_wfs_conf_id = $1 ";
- $sql .= "AND wfs_conf_element.f_search = 1 ORDER BY wfs_conf_element.f_pos";
- $v = array($selectedConfId);
- $t = array('i');
- $res = db_prep_query($sql, $v, $t);
-
-
- echo "<script type='text/javascript'>";
- echo "var el = new Array();";
- $cnt = 0;
- while($row = db_fetch_array($res)){
- echo "el[".$cnt."] = [];";
- echo "el[".$cnt."]['f_search'] = ".$row["f_search"].";";
- echo "el[".$cnt."]['f_style_id'] = '".$row["f_style_id"]."';";
- echo "el[".$cnt."]['f_toupper'] = '".$row["f_toupper"]."';";
- echo "el[".$cnt."]['f_label'] = '".$row["f_label"]."';";
- echo "el[".$cnt."]['f_label_id'] = '".$row["f_label_id"]."';";
- echo "el[".$cnt."]['element_name'] = '".$row["element_name"]."';";
- echo "el[".$cnt."]['element_type'] = '".$row["element_type"]."';";
- $cnt++;
- }
- if($cnt == 0){
- die("Please add the wfs_conf to the src-Parameter");
- }
-
- echo "var g_label = '".$g_label[$selectedConfId]."';";
- echo "var g_label_id = '".$g_label_id[$selectedConfId]."';";
- echo "var g_button = '".$g_button[$selectedConfId]."';";
- echo "var g_button_id = '".$g_button_id[$selectedConfId]."';";
- echo "var g_buffer = ".$g_buffer[$selectedConfId].";";
- echo "var g_res_style = '".urlencode($g_res_style[$selectedConfId])."';";
- echo "var g_use_wzgraphics = ".$g_use_wzgraphics[$selectedConfId].";";
- echo "var featuretype_name= '".$featuretype_name."';";
- echo "var featuretype_srs = '".$featuretype_srs."';";
- echo "var wfs_getfeature = '".$wfs_getfeature[$selectedConfId]."';";
-
- echo "var wfs_conf_id = '".$selectedConfId."';";
- echo "var targets = '".$target."';";
- echo "var targetArray = targets.split(',');";
- echo "var resultFrame = '".$resultFrame."';";
- echo "var selectedConfId = ".$selectedConfId.";";
- echo "</script>";
- // -------------------------------------------------------------------------------
-}
-else {
- die("problem.");
-}
-?>
-
-<script type="text/javascript">
-//var res = true;
-var wfs_conf_color = "255,0,0";
-
-/**
- * Sets the wfs conf ID that was selected in the select box as default and reloads.
- */
-function conf_selection(){
- document.sel_wfs_conf_form.selected_conf.value = document.sel_wfs_conf_form.wfs_conf_sel.value;
- document.sel_wfs_conf_form.submit();
-}
-
-/**
- * displays the form where the search criteria may be entered
- */
-function init_mod_wfs_gazetteer(){
-
- var s = "";
- s += "<form onsubmit='return validate()'>";
- s += "<div class='"+g_label_id+"'>"+g_label+"</div>";
- for(var i=0; i<el.length; i++){
- s += "<span class='"+el[i]["f_label_id"]+"'>"+el[i]["f_label"]+"</span>";
- s += "<input type='text' class='"+el[i]["f_style_id"]+"' id='"+el[i]["element_name"]+"'><br>";
- }
- s += "<input type='submit' class='"+g_button_id+"' value='"+g_button+"' >";
- s += "</form>";
- document.getElementById("gaz").innerHTML = s;
-
- return true;
-}
-
-function validate(){
- var filterParameterCount = getNumberOfFilterParameters();
-
- if(filterParameterCount == 0){
- return false;
- }
- else{
- var andConditions = "";
- for (var i = 0; i < el.length; i++) {
- if (el[i]['f_search'] == 1 && document.getElementById(el[i]['element_name']).value != '') {
-
- var a = new Array();
- a = document.getElementById(el[i]['element_name']).value.split(",");
- var orConditions = "";
- for (var j=0; j < a.length; j++) {
-
- orConditions += "<ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
- orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
- orConditions += "<ogc:Literal>*";
- if(el[i]['f_toupper'] == 1){
- orConditions += a[j].toUpperCase();
- }
- else{
- orConditions += a[j];
- }
- orConditions += "*</ogc:Literal>";
- orConditions += "</ogc:PropertyIsLike>";
- }
- if(a.length > 1){
- andConditions += "<Or>" + orConditions + "</Or>";
- }
- else {
- andConditions += orConditions;
- }
- }
- }
-
- var u = wfs_getfeature + parent.mb_getConjunctionCharacter(wfs_getfeature);
- u += "REQUEST=getFeature&Typename="+featuretype_name+"&Version=1.0.0&service=WFS";
- u += "&filter=";
-
- if (filterParameterCount > 1) {
- andConditions = "<And>" + andConditions + "</And>";
- }
-
- var filter = "<ogc:Filter xmlns:ogc='http://ogc.org' xmlns:gml='http://www.opengis.net/gml'>"+andConditions+"</ogc:Filter>";
-
- document.getElementById("res").innerHTML = "<table><tr><td><img src='../img/indicator_wheel.gif'></td><td>Searching...</td></tr></table>";
- var parameters = {"wfs_conf_id":wfs_conf_id, "frame":this.name, "url":u, "filter":filter, "backlink":""};
- parent.mb_ajax_get("../php/mod_wfs_gazetteer_search.php", parameters, function (jsCode, status) {
- eval(jsCode);
-
- for (var i=0; i < parent.wms.length; i++) {
- for (var j=0; j < parent.wms[i].objLayer.length; j++) {
- var currentLayer = parent.wms[i].objLayer[j];
- var wms_id = parent.wms[i].wms_id;
- if (currentLayer.gui_layer_wfs_featuretype == selectedConfId) {
- var layer_name = currentLayer.layer_name;
- parent.handleSelectedLayer_array(targetArray[0],[wms_id],[layer_name],'querylayer',1);
- parent.handleSelectedLayer_array(targetArray[0],[wms_id],[layer_name],'visible',1);
- }
- }
- }
-
- var body = "";
- if (typeof(geom) == 'object') {
- resultGeom = geom; // set the global variable
- for (var i=0; i < geom.count(); i++) {
- body += "<div id='geom"+i+"'style='cursor:pointer;' ";
- if ((i % 2) === 0) {
- body += "class='even'";
- }
- else {
- body += "class='uneven'";
- }
- body += " onmouseover=\"setResult('over', this.id)\" ";
- body += " onmouseout=\"setResult('out', this.id)\" ";
- body += " onclick=\"setResult('click', this.id)\">";
- for (var j=0; j < geom.get(i).e.count(); j++) {
- body += geom.get(i).e.getValue(j) + " ";
- }
- body += "</div>";
- }
- }
- else {
- body = "Kein Ergebnis.";
- }
- document.getElementById('res').innerHTML = body;
- });
- }
- return false;
-}
-
-function getNumberOfFilterParameters(){
- var cnt = 0;
- for (var i = 0; i < el.length; i++){
- if( el[i]['f_search'] == 1){
- if (document.getElementById(el[i]['element_name']).value != '') {
- cnt++;
- }
- }
- }
- return cnt;
-}
-/*
-* event -> {over || out || click}
-* geom -> commaseparated coordinates x1,y1,x2,y2 ...
-*/
-function setResult(event, id){
- var index = parseInt(id.slice(4));
-
- if (event == "over") {
- if(g_use_wzgraphics == 1){
- global_resultHighlight.add(resultGeom.get(index), cw_fillcolor);
- }
- }
- else if (event == "out"){
- if(g_use_wzgraphics == 1){
- global_resultHighlight.del(resultGeom.get(index), cw_fillcolor);
- }
- }
- else if (event == "click"){
- if(g_use_wzgraphics == 1){
- global_resultHighlight.del(resultGeom.get(index), cw_fillcolor);
- }
- var bbox = resultGeom.get(index).getBBox();
- var buffer = new parent.Point(1,1);
- bbox[0] = bbox[0].minus(buffer);
- bbox[1] = bbox[1].plus(buffer);
- parent.mb_calculateExtent(targetArray[0], bbox[0].x, bbox[0].y, bbox[1].x, bbox[1].y);
- parent.zoom(targetArray[0], 'true', 1.0);
- if(g_use_wzgraphics == 1){
- global_resultHighlight.add(resultGeom.get(index), cw_fillcolor);
- }
- }
- return true;
-}
-
-
-/* Opacity for hilighting */
- parent.cw_opacity = 1.5;
-/* Color for polygon boundary */
- var cw_bndcolor = "#cc33cc";
-/* Color for polygon fill */
- var cw_fillcolor = "#cc33cc";
-
-var point_px = 10;
-var resultGeom = null;
-var global_resultHighlight;
-
-parent.mb_registerInitFunctions("window.frames['"+this.name+"'].initWfsGazetteerHighlight()");
-
-function initWfsGazetteerHighlight() {
- global_resultHighlight = new parent.Highlight(targetArray, "wfs_gazetteer_highlight", {"position":"absolute", "top":"0px", "left":"0px", "z-index":100}, 2);
-}
-</script>
-</head>
-<body leftmargin='0' topmargin='10' bgcolor='#ffffff' onload='init_mod_wfs_gazetteer()'>
-<div id='gaz'></div>
-<div name='res' id='res' frameborder='0' style='width:180px;height:200px'></div>
-</body>
-</html>
\ No newline at end of file
Deleted: trunk/mapbender/http/php/mod_wfs_gazetteer_conf_server.php
===================================================================
--- trunk/mapbender/http/php/mod_wfs_gazetteer_conf_server.php 2007-05-24 14:59:52 UTC (rev 1352)
+++ trunk/mapbender/http/php/mod_wfs_gazetteer_conf_server.php 2007-05-24 15:34:07 UTC (rev 1353)
@@ -1,111 +0,0 @@
-<?php
-# $Id: mod_wfsrequest.php 1008 2007-01-16 11:26:56Z christoph $
-# http://www.mapbender.org/index.php/Administration
-# 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");
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
-
-$wfsConfIdString = $_GET["wfsConfIdString"];
-
-$con = db_connect($DBSERVER,$OWNER,$PW);
-db_select_db($DB,$con);
-
-if ($wfsConfIdString != "") {
- $wfsConfIdArray = split(",", $wfsConfIdString);
-}
-else {
- echo "please specify wfs conf id.";
- die();
-}
-
-$sql = "SELECT * FROM wfs_conf ";
-$sql .= "JOIN wfs ON wfs_conf.fkey_wfs_id = wfs.wfs_id ";
-$sql .= "WHERE wfs_conf.wfs_conf_id IN (";
-
-$v = array();
-$t = array();
-for ($i = 0; $i < count($wfsConfIdArray); $i++) {
- if ($i > 0) {$sql .= ", ";}
- $sql .= "$" . ($i+1);
- array_push($v, $wfsConfIdArray[$i]);
- array_push($t, 'i');
-}
-$sql .= ")";
-
-$res = db_prep_query($sql, $v, $t);
-
-$obj = array();
-while ($row = db_fetch_array($res)) {
- $id = $row["wfs_conf_id"];
-
- $sql_conf_element = "SELECT * FROM wfs_conf_element ";
- $sql_conf_element .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
- $sql_conf_element .= "WHERE wfs_conf_element.fkey_wfs_conf_id = $1 ";
- $sql_conf_element .= "AND wfs_conf_element.f_search = 1 ORDER BY wfs_conf_element.f_pos";
- $v_conf_element = array($id);
- $t_conf_element = array('i');
- $res_conf_element = db_prep_query($sql_conf_element, $v_conf_element, $t_conf_element);
-
- $elementArray = array();
- while ($row_conf_element = db_fetch_array($res_conf_element)) {
- $currentElement = array("f_search" => $row_conf_element["f_search"],
- "f_style_id" => $row_conf_element["f_style_id"],
- "f_toupper" => $row_conf_element["f_toupper"],
- "f_label" => $row_conf_element["f_label"],
- "f_label_id" => $row_conf_element["f_label_id"],
- "element_name" => $row_conf_element["element_name"],
- "element_type" => $row_conf_element["element_type"]
- );
- array_push($elementArray, $currentElement);
- }
-
- $sql_feature_type = "SELECT * FROM wfs_featuretype WHERE fkey_wfs_id = $1 AND featuretype_id = $2";
- $v_feature_type = array($row["fkey_wfs_id"], $row["fkey_featuretype_id"]);
- $t_feature_type = array("i", "i");
-
- $res_feature_type = db_prep_query($sql_feature_type, $v_feature_type, $t_feature_type);
- if($row_feature_type = db_fetch_array($res_feature_type)){
- $featuretype_name = $row_feature_type["featuretype_name"];
- $featuretype_srs = $row_feature_type["featuretype_srs"];
- }
-
- $currentRow = array("g_label" => $row["g_label"],
- "g_label_id" => $row["g_label_id"],
- "g_style" => $row["g_style"],
- "g_button" => $row["g_button"],
- "g_button_id" => $row["g_button_id"],
- "g_buffer" => $row["g_buffer"],
- "g_res_style" => $row["g_res_style"],
- "g_use_wzgraphics" => $row["g_use_wzgraphics"],
- "wfs_id" => $row["fkey_wfs_id"],
- "featuretype_id" => $row["fkey_featuretype_id"],
- "featuretype_name" => $featuretype_name,
- "featuretype_id" => $featuretype_srs,
- "wfs_getfeature" => $row["wfs_getfeature"],
- "element" => $elementArray
- );
-
- $obj[$id] = $currentRow;
-
-
-
-}
-$json = new Services_JSON();
-$output = $json->encode($obj);
-echo $output;
-?>
\ No newline at end of file
Deleted: trunk/mapbender/http/php/mod_wfs_gazetteer_search.php
===================================================================
--- trunk/mapbender/http/php/mod_wfs_gazetteer_search.php 2007-05-24 14:59:52 UTC (rev 1352)
+++ trunk/mapbender/http/php/mod_wfs_gazetteer_search.php 2007-05-24 15:34:07 UTC (rev 1353)
@@ -1,82 +0,0 @@
-<?php
-# $Id: mod_wfsrequest.php 1008 2007-01-16 11:26:56Z christoph $
-# http://www.mapbender.org/index.php/Administration
-# 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");
-include(dirname(__FILE__)."/../classes/class_gml2.php");
-
-$backlink = $_REQUEST["backlink"];
-$wfs_conf_id = $_REQUEST["wfs_conf_id"];
-$frame = $_REQUEST["frame"];
-$filter = $_REQUEST["filter"];
-$url = $_REQUEST["url"];
-
-$con = db_connect($DBSERVER,$OWNER,$PW);
-db_select_db($DB,$con);
-
-/* wfs_conf */
-$sql = "SELECT * FROM wfs_conf JOIN wfs ON wfs_conf.fkey_wfs_id = wfs.wfs_id ";
-$sql .= "WHERE wfs_conf.wfs_conf_id = $1";
-$v = array($wfs_conf_id);
-$t = array('i');
-
-$res = db_prep_query($sql,$v,$t);
-if ($row = db_fetch_array($res)) {
- $g_res_style = $row["g_res_style"];
-}
-else {
- die("wfs_conf data not available");
-}
-
-/* wfs_conf_element */
-$sql = "SELECT * FROM wfs_conf_element ";
-$sql .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
-$sql .= "WHERE wfs_conf_element.fkey_wfs_conf_id = $1 ";
-$sql .= "AND wfs_conf_element.f_show = 1 ORDER BY wfs_conf_element.f_respos;";
-$v = array($wfs_conf_id);
-$t = array('i');
-
-$res = db_prep_query($sql,$v,$t);
-$col = array();
-while ($row = db_fetch_array($res)) {
- array_push($col, $row["element_name"]);
-}
-if (count($col) == 0) {
- die("wfs_conf_element data not available");
-}
-
-$req = urldecode($url).urlencode(stripslashes($filter));
-
-$mygml = new gml2();
-$mygml->parsegml($req);
-
-// generates JavaScript code that will add a geometry array containing
-// all the result geometries and their attributes (wfs_conf_elements)
-
-$js = "";
-if ($mygml->getMemberCount() > 0) {
- $js .= $mygml->exportGeometriesToJS(true);
-
- for ($i = 0; $i < $mygml->getMemberCount(); $i++) {
- for ($j = 0; $j < count($col); $j++){
- $js .= "geom.get(".$i.").e.setElement('".$j."', '".$mygml->getValueBySeparatedKey($i, $col[$j]) . "');\n";
- }
- }
-}
-echo $js;
-?>
\ No newline at end of file
Modified: trunk/mapbender/http/php/mod_wfs_gazetteer_server.php
===================================================================
--- trunk/mapbender/http/php/mod_wfs_gazetteer_server.php 2007-05-24 14:59:52 UTC (rev 1352)
+++ trunk/mapbender/http/php/mod_wfs_gazetteer_server.php 2007-05-24 15:34:07 UTC (rev 1353)
@@ -19,64 +19,157 @@
require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
include(dirname(__FILE__)."/../classes/class_gml2.php");
+require_once(dirname(__FILE__)."/../extensions/JSON.php");
-$backlink = $_REQUEST["backlink"];
-$wfs_conf_id = $_REQUEST["wfs_conf_id"];
-$frame = $_REQUEST["frame"];
-$filter = $_REQUEST["filter"];
-$url = $_REQUEST["url"];
-
$con = db_connect($DBSERVER,$OWNER,$PW);
db_select_db($DB,$con);
-/* wfs_conf */
-$sql = "SELECT * FROM wfs_conf JOIN wfs ON wfs_conf.fkey_wfs_id = wfs.wfs_id ";
-$sql .= "WHERE wfs_conf.wfs_conf_id = $1";
-$v = array($wfs_conf_id);
-$t = array('i');
+$command = $_REQUEST["command"];
-$res = db_prep_query($sql,$v,$t);
-if ($row = db_fetch_array($res)) {
- $g_res_style = $row["g_res_style"];
+if ($command == "getWfsConf") {
+
+ $wfsConfIdString = $_GET["wfsConfIdString"];
+
+ if ($wfsConfIdString != "") {
+ $wfsConfIdArray = split(",", $wfsConfIdString);
+ }
+ else {
+ echo "please specify wfs conf id.";
+ die();
+ }
+
+ $sql = "SELECT * FROM wfs_conf ";
+ $sql .= "JOIN wfs ON wfs_conf.fkey_wfs_id = wfs.wfs_id ";
+ $sql .= "WHERE wfs_conf.wfs_conf_id IN (";
+
+ $v = array();
+ $t = array();
+ for ($i = 0; $i < count($wfsConfIdArray); $i++) {
+ if ($i > 0) {$sql .= ", ";}
+ $sql .= "$" . ($i+1);
+ array_push($v, $wfsConfIdArray[$i]);
+ array_push($t, 'i');
+ }
+ $sql .= ")";
+
+ $res = db_prep_query($sql, $v, $t);
+
+ $obj = array();
+ while ($row = db_fetch_array($res)) {
+ $id = $row["wfs_conf_id"];
+
+ $sql_conf_element = "SELECT * FROM wfs_conf_element ";
+ $sql_conf_element .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
+ $sql_conf_element .= "WHERE wfs_conf_element.fkey_wfs_conf_id = $1 ";
+ $sql_conf_element .= "AND wfs_conf_element.f_search = 1 ORDER BY wfs_conf_element.f_pos";
+ $v_conf_element = array($id);
+ $t_conf_element = array('i');
+ $res_conf_element = db_prep_query($sql_conf_element, $v_conf_element, $t_conf_element);
+
+ $elementArray = array();
+ while ($row_conf_element = db_fetch_array($res_conf_element)) {
+ $currentElement = array("f_search" => $row_conf_element["f_search"],
+ "f_style_id" => $row_conf_element["f_style_id"],
+ "f_toupper" => $row_conf_element["f_toupper"],
+ "f_label" => $row_conf_element["f_label"],
+ "f_label_id" => $row_conf_element["f_label_id"],
+ "element_name" => $row_conf_element["element_name"],
+ "element_type" => $row_conf_element["element_type"]
+ );
+ array_push($elementArray, $currentElement);
+ }
+
+ $sql_feature_type = "SELECT * FROM wfs_featuretype WHERE fkey_wfs_id = $1 AND featuretype_id = $2";
+ $v_feature_type = array($row["fkey_wfs_id"], $row["fkey_featuretype_id"]);
+ $t_feature_type = array("i", "i");
+
+ $res_feature_type = db_prep_query($sql_feature_type, $v_feature_type, $t_feature_type);
+ if($row_feature_type = db_fetch_array($res_feature_type)){
+ $featuretype_name = $row_feature_type["featuretype_name"];
+ $featuretype_srs = $row_feature_type["featuretype_srs"];
+ }
+
+ $currentRow = array("g_label" => $row["g_label"],
+ "g_label_id" => $row["g_label_id"],
+ "g_style" => $row["g_style"],
+ "g_button" => $row["g_button"],
+ "g_button_id" => $row["g_button_id"],
+ "g_buffer" => $row["g_buffer"],
+ "g_res_style" => $row["g_res_style"],
+ "g_use_wzgraphics" => $row["g_use_wzgraphics"],
+ "wfs_id" => $row["fkey_wfs_id"],
+ "featuretype_id" => $row["fkey_featuretype_id"],
+ "featuretype_name" => $featuretype_name,
+ "featuretype_id" => $featuretype_srs,
+ "wfs_getfeature" => $row["wfs_getfeature"],
+ "element" => $elementArray
+ );
+
+ $obj[$id] = $currentRow;
+ }
+ $json = new Services_JSON();
+ $output = $json->encode($obj);
+ echo $output;
}
-else {
- die("wfs_conf data not available");
-}
+else if ($command == "getSearchResults") {
+ $wfs_conf_id = $_REQUEST["wfs_conf_id"];
+ $backlink = $_REQUEST["backlink"];
+ $frame = $_REQUEST["frame"];
+ $filter = $_REQUEST["filter"];
+ $url = $_REQUEST["url"];
-/* wfs_conf_element */
-$sql = "SELECT * FROM wfs_conf_element ";
-$sql .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
-$sql .= "WHERE wfs_conf_element.fkey_wfs_conf_id = $1 ";
-$sql .= "AND wfs_conf_element.f_show = 1 ORDER BY wfs_conf_element.f_respos;";
-$v = array($wfs_conf_id);
-$t = array('i');
-
-$res = db_prep_query($sql,$v,$t);
-$col = array();
-while ($row = db_fetch_array($res)) {
- array_push($col, $row["element_name"]);
-}
-if (count($col) == 0) {
- die("wfs_conf_element data not available");
-}
-
-$req = urldecode($url).urlencode(stripslashes($filter));
-
-$mygml = new gml2();
-$mygml->parsegml($req);
-
-// generates JavaScript code that will add a geometry array containing
-// all the result geometries and their attributes (wfs_conf_elements)
-
-$js = "";
-if ($mygml->getMemberCount() > 0) {
- $js .= $mygml->exportGeometriesToJS(true);
-
- for ($i = 0; $i < $mygml->getMemberCount(); $i++) {
- for ($j = 0; $j < count($col); $j++){
- $js .= "geom.get(".$i.").e.setElement('".$j."', '".$mygml->getValueBySeparatedKey($i, $col[$j]) . "');\n";
+ /* wfs_conf */
+ $sql = "SELECT * FROM wfs_conf JOIN wfs ON wfs_conf.fkey_wfs_id = wfs.wfs_id ";
+ $sql .= "WHERE wfs_conf.wfs_conf_id = $1";
+ $v = array($wfs_conf_id);
+ $t = array('i');
+
+ $res = db_prep_query($sql,$v,$t);
+ if ($row = db_fetch_array($res)) {
+ $g_res_style = $row["g_res_style"];
+ }
+ else {
+ die("wfs_conf " . $wfs_conf_id . "data not available");
+ }
+
+ /* wfs_conf_element */
+ $sql = "SELECT * FROM wfs_conf_element ";
+ $sql .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
+ $sql .= "WHERE wfs_conf_element.fkey_wfs_conf_id = $1 ";
+ $sql .= "AND wfs_conf_element.f_show = 1 ORDER BY wfs_conf_element.f_respos;";
+ $v = array($wfs_conf_id);
+ $t = array('i');
+
+ $res = db_prep_query($sql,$v,$t);
+ $col = array();
+ while ($row = db_fetch_array($res)) {
+ array_push($col, $row["element_name"]);
+ }
+ if (count($col) == 0) {
+ die("wfs_conf_element data not available");
+ }
+
+ $req = urldecode($url).urlencode(stripslashes($filter));
+
+ $mygml = new gml2();
+ $mygml->parsegml($req);
+
+ // generates JavaScript code that will add a geometry array containing
+ // all the result geometries and their attributes (wfs_conf_elements)
+
+ $js = "";
+ if ($mygml->getMemberCount() > 0) {
+ $js .= $mygml->exportGeometriesToJS(true);
+
+ for ($i = 0; $i < $mygml->getMemberCount(); $i++) {
+ for ($j = 0; $j < count($col); $j++){
+ $js .= "geom.get(".$i.").e.setElement('".$j."', '".$mygml->getValueBySeparatedKey($i, $col[$j]) . "');\n";
+ }
}
}
+ echo $js;
}
-echo $js;
+else {
+ echo "please enter a valid command.";
+}
?>
\ No newline at end of file
More information about the Mapbender_commits
mailing list