[Mapbender-commits] r1830 - branches/mapbender_sld/http/php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Nov 23 08:20:10 EST 2007


Author: christoph
Date: 2007-11-23 08:20:10 -0500 (Fri, 23 Nov 2007)
New Revision: 1830

Added:
   branches/mapbender_sld/http/php/createImageFromText.php
   branches/mapbender_sld/http/php/mod_SelectKeyword.php
   branches/mapbender_sld/http/php/mod_button_tooltips.php
   branches/mapbender_sld/http/php/mod_featuretypeMetadata.php
   branches/mapbender_sld/http/php/mod_gazetteerSQL_server.php
   branches/mapbender_sld/http/php/mod_setLocale.php
   branches/mapbender_sld/http/php/mod_switchLocale.php
   branches/mapbender_sld/http/php/mod_switchLocale_noreload.php
   branches/mapbender_sld/http/php/mod_wfsSpatialRequest_messages.php
   branches/mapbender_sld/http/php/mod_wfs_server.php
Log:
new php files

Added: branches/mapbender_sld/http/php/createImageFromText.php
===================================================================
--- branches/mapbender_sld/http/php/createImageFromText.php	                        (rev 0)
+++ branches/mapbender_sld/http/php/createImageFromText.php	2007-11-23 13:20:10 UTC (rev 1830)
@@ -0,0 +1,38 @@
+<?php
+# $Id: createImageFromText.php 1631 2007-08-08 09:33:23Z christoph $
+# Modul Maintainer Christoph Baudson
+# http://www.mapbender.org/index.php/createImageFromText
+# 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.
+
+$text = $_GET["text"];
+$angle = intval($_GET["angle"]);
+
+$text_x = 4;
+$text_y = 0;
+$rect_w = 7 * mb_strlen($text) + $text_x;
+$rect_h = 14 + $text_y;
+
+$im = imagecreate($rect_w, $rect_h);
+$white = imagecolorallocate($im, 255, 255, 255);
+$black = imagecolorallocate($im, 0, 0, 0);
+imagestring($im, 2, $text_x, $text_y, $text, $black);
+$im = imagerotate($im, $angle, -1);
+
+Header("Content-type:image/png");
+imagepng($im);
+imagedestroy($im);
+?>

Added: branches/mapbender_sld/http/php/mod_SelectKeyword.php
===================================================================
--- branches/mapbender_sld/http/php/mod_SelectKeyword.php	                        (rev 0)
+++ branches/mapbender_sld/http/php/mod_SelectKeyword.php	2007-11-23 13:20:10 UTC (rev 1830)
@@ -0,0 +1,65 @@
+<?php
+# $Id: mod_SelectKeyword.php 1624 2007-08-08 07:47:37Z astrid_emde $
+# ttp://www.mapbender.org/index.php/mod_SelectKeyword
+# 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");
+$con = db_connect($DBSERVER,$OWNER,$PW);
+db_select_db(DB,$con);
+
+?>
+
+<html>
+<head>
+<title>Select Keyword</title>
+<meta http-equiv="cache-control" content="no-cache">
+<meta http-equiv="pragma" content="no-cache">
+<meta http-equiv="expires" content="0">
+<?php
+echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';	
+?>
+
+<script language='JavaScript'>
+<!--
+function insertValue(val){
+   window.opener.document.form1.search.value = val;
+   window.close();
+}
+-->
+</script>
+</head>
+
+<body  >
+
+<?php
+$sql = "Select keyword_id, ltrim(keyword) as keyword from keyword order by upper(ltrim(keyword));";
+$res = db_query($sql);
+
+echo "<select size='20' name='keywordlist' ondblClick='insertValue(this.value)' title='double click to select a keyword'>\n";
+ 
+$cnt = 0;
+while($row = db_fetch_array($res)){    
+	echo "<option value='". $row["keyword"]."' >";
+	echo $row["keyword"];
+	$cnt++;
+	echo "</option>";
+}
+echo "</select>";
+
+?>
+</body>
+</html>

Added: branches/mapbender_sld/http/php/mod_button_tooltips.php
===================================================================
--- branches/mapbender_sld/http/php/mod_button_tooltips.php	                        (rev 0)
+++ branches/mapbender_sld/http/php/mod_button_tooltips.php	2007-11-23 13:20:10 UTC (rev 1830)
@@ -0,0 +1,43 @@
+<?php
+#$Id: mod_insertWmcIntoDb.php 507 2006-11-20 10:55:57Z christoph $
+#$Header: /cvsroot/mapbender/mapbender/http/javascripts/mod_insertWmcIntoDb.php,v 1.19 2006/03/09 14:02:42 uli_rothstein Exp $
+# 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");
+require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
+
+session_start();
+$con = db_connect(DBSERVER,OWNER,PW);
+db_select_db(DB,$con);
+ 
+$buttonObj = array();
+
+$sql = "SELECT e_id, gettext($1, e_title) AS e_title FROM gui_element WHERE fkey_gui_id = $2 AND e_element = 'img'";
+$v = array($_SESSION["mb_lang"], $_SESSION["mb_user_gui"]); 
+$t = array("s", "s");
+$res = db_prep_query($sql, $v, $t);
+while ($row = db_fetch_array($res)) {
+	array_push($buttonObj, array("id" => $row["e_id"], "title" => $row["e_title"]));
+}
+
+$json = new Services_JSON();
+$output = $json->encode($buttonObj);
+
+header("Content-type:text/plain; Charset='UTF-8'");
+echo $output;
+?>
\ No newline at end of file

Added: branches/mapbender_sld/http/php/mod_featuretypeMetadata.php
===================================================================
--- branches/mapbender_sld/http/php/mod_featuretypeMetadata.php	                        (rev 0)
+++ branches/mapbender_sld/http/php/mod_featuretypeMetadata.php	2007-11-23 13:20:10 UTC (rev 1830)
@@ -0,0 +1,138 @@
+<?php
+# $Id: mod_featuretypeMetadata.php 235 2007-09-20 verenadiewald $
+# 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("../../conf/mapbender.conf");
+require_once("../../conf/geoportal.conf");
+$con = db_connect(DBSERVER,OWNER,PW);
+db_select_db(DB,$con);
+
+function display_text($string) {
+    $string = eregi_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\" target=_blank>\\0</a>", $string);   
+    $string = eregi_replace("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@([0-9a-z](-?[0-9a-z])*\.)+[a-z]{2}([zmuvtg]|fo|me)?$", "<a href=\"mailto:\\0\" target=_blank>\\0</a>", $string);   
+    $string = eregi_replace("\n", "<br>", $string);
+    return $string;
+}  
+
+?>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
+	<head>
+		<title>WFS Metadata</title>
+		<meta name="description" content="Metadata" xml:lang="en" />
+		<meta name="keywords" content="Metadaten" xml:lang="en" />		
+		<meta http-equiv="cache-control" content="no-cache">
+		<meta http-equiv="pragma" content="no-cache">
+		<meta http-equiv="expires" content="0">
+		<meta http-equiv="content-language" content="de" />
+		<meta http-equiv="content-style-type" content="text/css" />		
+<?php
+	echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';	
+?>
+	</head>
+	<body id="top">
+
+	
+	<div>
+<?php
+	$wfs_conf_id = $_GET['wfs_conf_id'];
+	//for testing only
+	#$wfs_conf_id = 1;
+	
+	$sql_id = "SELECT fkey_wfs_id, fkey_featuretype_id FROM wfs_conf WHERE wfs_conf_id = $1";
+	$v_id = array($wfs_conf_id);
+	$t_id = array('i');
+	$res_id = db_prep_query($sql_id,$v_id,$t_id);
+	$row_id = db_fetch_array($res_id);
+	$wfs_id = $row_id['fkey_wfs_id'];
+	$featuretype_id = $row_id['fkey_featuretype_id'];
+		
+	// retrieve the geometry type
+	$sql_geom = "SELECT a.element_type AS geom_type ";
+	$sql_geom .= "FROM wfs_element AS a, wfs_conf AS b, wfs_conf_element AS c ";
+	$sql_geom .= "WHERE a.fkey_featuretype_id = b.fkey_featuretype_id AND b.wfs_conf_id = $1 ";
+	$sql_geom .= "AND b.wfs_conf_id = c.fkey_wfs_conf_id AND c.f_geom = 1 AND c.f_id = a.element_id";
+	$v_geom = array($wfs_conf_id);
+	$t_geom = array('i');
+	$res_geom = db_prep_query($sql_geom, $v_geom, $t_geom);
+	$row_geom = db_fetch_array($res_geom);
+	$geomType = $row_geom['geom_type'];
+
+	$sql = "SELECT ";
+	$sql .= "ft.featuretype_id, ft.featuretype_title, ft.featuretype_srs, ft.featuretype_abstract, ";
+	$sql .= "wfs.wfs_title, wfs.wfs_abstract, wfs.wfs_id, wfs.fees, wfs.accessconstraints, wfs.individualname, ";
+	$sql .= "wfs.positionname, wfs.providername, wfs.deliverypoint, wfs.city, wfs.wfs_timestamp, wfs.wfs_owner, ";
+	$sql .= "wfs.country, wfs.postalcode, wfs.voice, wfs.facsimile, ";
+	$sql .= "wfs.electronicmailaddress, wfs.wfs_getcapabilities ";
+	$sql .= "FROM wfs, wfs_featuretype ft WHERE wfs.wfs_id = $1 AND ft.featuretype_id = $2 AND wfs.wfs_id = ft.fkey_wfs_id LIMIT 1";
+	$v = array($wfs_id,$featuretype_id);
+	$t = array('i','i');
+	$res = db_prep_query($sql,$v,$t);
+	echo db_error();
+	$wfs = array();
+	$row = db_fetch_array($res);
+	
+	$sql_dep = "SELECT mb_group_name FROM mb_group AS a, mb_user AS b, mb_user_mb_group AS c WHERE b.mb_user_id = $1  AND b.mb_user_id = c.fkey_mb_user_id AND c.fkey_mb_group_id = a.mb_group_id AND b.mb_user_department = a.mb_group_description LIMIT 1";
+	$v_dep = array($row['wfs_owner']);
+	$t_dep = array('i');
+	$res_dep = db_prep_query($sql_dep, $v_dep, $t_dep);
+	$row_dep = db_fetch_array($res_dep);
+	
+	$featuretype['ID'] = $featuretype_id;
+	$featuretype['Titel'] = $row['featuretype_title'];
+	$featuretype['Zusammenfassung'] = $row['featuretype_abstract'];
+	$featuretype['Koordinatensysteme'] = $row['featuretype_srs'];
+	$featuretype['Geometrietyp'] = $geomType;
+	$featuretype['Capabilities-Dokument'] = $row['wfs_getcapabilities'];
+	#$featuretype['Capabilities-Dokument'] = "<a href='".$row['wfs_getcapabilities']."' target=_blank>Capabilities-Dokument</a>";
+	if ($row['wfs_timestamp']) {
+		$layer['Datum der Registrierung'] = date("d.m.Y",$row['wfs_timestamp']); 
+	}
+	else {
+		$layer['Datum der Registrierung'] = "Keine Angabe"; 
+	}
+	$featuretype['Registrierende Stelle'] = $row_dep['mb_group_name'];
+	$featuretype['WFS ID'] = $row['wfs_id'];
+	$featuretype['WFS Titel'] = $row['wfs_title'];
+	$featuretype['WFS Zusammenfassung'] = $row['wfs_abstract'];
+	$featuretype['Geb&uuml;hren'] = $row['fees'];
+	$featuretype['Zugriffsbeschr&auml;nkung'] = $row['accessconstraints'];
+	$featuretype['Ansprechpartner'] = $row['individualname'];
+	$featuretype['Organisation'] = $row['providername'];
+	$featuretype['Adresse'] = $row['deliverypoint'];
+	$featuretype['Stadt'] = $row['city'];
+	$featuretype['PLZ'] = $row['postalcode'];
+	$featuretype['Telefon'] = $row['voice'];
+	$featuretype['Fax'] = $row['facsimile'];
+	$featuretype['E-Mail'] = $row['electronicmailaddress'];
+	$featuretype['Land'] = $row['country'];
+	
+	echo "<table class='contenttable-0-wide'>\n";
+	$t_a = "\t<tr>\n\t\t<th>\n\t\t\t";
+	$t_b = "\n\t\t</th>\n\t\t<td>\n\t\t\t";
+	$t_c = "\n\t\t</td>\n\t</tr>\n";
+
+	$keys = array_keys($featuretype);
+	for ($j=0; $j<count($featuretype); $j++) {
+		echo $t_a . utf8_encode($keys[$j]) . $t_b . display_text($featuretype[$keys[$j]]) . $t_c;
+	}
+	
+	echo "</td></tr></table>\n";
+?>
+	</div>
+	</body>
+</html>

Added: branches/mapbender_sld/http/php/mod_gazetteerSQL_server.php
===================================================================
--- branches/mapbender_sld/http/php/mod_gazetteerSQL_server.php	                        (rev 0)
+++ branches/mapbender_sld/http/php/mod_gazetteerSQL_server.php	2007-11-23 13:20:10 UTC (rev 1830)
@@ -0,0 +1,202 @@
+<?php
+session_start();
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
+require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+require_once(dirname(__FILE__)."/../../conf/gazetteerSQL.conf");
+
+$con = 	pg_connect($connstring);		
+
+$command = $_GET["command"];
+$communeId = $_GET["communeId"];
+$streetName = $_GET["streetName"];
+$districtId = $_GET["districtId"];
+$parcelNumber1 = $_GET["parcelNumber1"];
+$parcelNumber2 = $_GET["parcelNumber2"];
+$ownerQueryString = $_GET["ownerQueryString"];
+$numberOfResults = $_GET["numberOfResults"];
+
+if (isLimited($numberOfResults)) {
+	$limit = $numberOfResults + 1; 
+}
+else {
+	$limit = 0;
+}
+
+$obj = array();
+
+function isLimited($numberOfResults) {
+	if (isset($numberOfResults) && $numberOfResults > 0) {
+		return true;
+	}
+	return false;
+}
+
+function isUnderLimit($counter, $numberOfResults, $max) {
+	return (!isLimited($numberOfResults) || $counter <= $max);
+}
+
+function isOverLimit($counter, $numberOfResults, $max) {
+	return (isLimited($numberOfResults) && $counter > $max);
+}
+
+if ($command == "getCommunes") {
+	$obj["communes"] = array();
+
+	$sql = "SELECT DISTINCT gkz, name FROM public.gemeinden ORDER BY name";
+	$v = array();
+	$t = array();
+	$res = db_prep_query($sql, $v, $t);
+	while($row = db_fetch_array($res)){
+		$communeId = trim($row["gkz"]);
+		$communeName = trim($row["name"]);
+		$obj["communes"][$communeId] = $communeName;
+	}
+	$obj["limited"] = false;
+}
+else if ($command == "getStreets") {
+	$obj["streets"] = array();
+
+	if (!empty($communeId)) {
+		$sql = "SELECT DISTINCT strk_schl, str_name FROM alb.navigation WHERE gkz = $1 ORDER BY str_name";
+		$v = array($communeId);
+		$t = array("i");
+	}
+	else {
+		$sql = "SELECT DISTINCT strk_schl, str_name FROM alb.navigation ORDER BY str_name";
+		$v = array();
+		$t = array();
+	}
+	$res = db_prep_query($sql, $v, $t);
+	while($row = db_fetch_array($res)){
+		$streetId = trim($row["strk_schl"]);
+		$streetName = trim($row["str_name"]);
+		$obj["streets"][$streetId] = $streetName;
+	}
+	$obj["limited"] = false;
+}
+else if ($command == "getNumbers") {
+	$obj["houseNumbers"] = array();
+	$paramCounter = 0;
+	
+	if (!empty($communeId)) {
+		$sql = "SELECT DISTINCT hnr, hnrzu, rw, hw FROM alb.navigation WHERE gkz = $". ++$paramCount ." AND str_name ILIKE $". ++$paramCount ." ORDER BY hnr, hnrzu";
+		$v = array($communeId, $streetName."%");
+		$t = array("i", "s");
+	}
+	else {
+		$sql = "SELECT DISTINCT hnr, hnrzu, rw, hw FROM alb.navigation WHERE str_name ILIKE $". ++$paramCount ." ORDER BY hnr, hnrzu";
+		$v = array($streetName."%");
+		$t = array("s");
+	}
+
+	if (isLimited($numberOfResults)) {
+		$sql .= " LIMIT $". ++$paramCount;
+		array_push($v, $limit);
+		array_push($t, "i");
+	}
+
+	$res = db_prep_query($sql, $v, $t);
+
+	$counter = 0;
+	while($row = db_fetch_array($res)){
+		$counter++;
+		if (isUnderLimit($counter, $numberOfResults, $numberOfResults)) {
+			$houseNumber = trim($row["hnr"] . $row["hnrzu"]);
+			$x = trim(floatval($row["rw"]));
+			$y = trim(floatval($row["hw"]));
+			$obj["houseNumbers"][$houseNumber] = array("x" => $x, "y" => $y);
+		}
+	}
+	$obj["limited"] = isOverLimit($counter, $numberOfResults, $numberOfResults);
+}
+else if ($command == "getLandparcelsByOwner") {
+	$obj["landparcels"] = array();
+
+	$sql = "SELECT DISTINCT eig.e_name, flst.flst_kennz, flst.rechtsw, flst.hochw FROM alb.albflst AS flst JOIN alb.albeig AS eig ON (flst.gemschl = eig.gemschl AND flst.flur = eig.flur AND flst.flstz = eig.flstz AND flst.flstn = eig.flstn) JOIN public.gemarkungen AS gem ON (flst.gemschl = gem.gemschl) WHERE gem.gkz = $1 AND eig.e_name ILIKE $2 ORDER BY flst.flst_kennz";
+	$v = array($communeId, "%".$ownerQueryString."%");
+	$t = array("i", "s");
+
+	if (isLimited($numberOfResults)) {
+		$sql .= " LIMIT $3";
+		array_push($v, $limit);
+		array_push($t, "i");
+	}
+	$res = db_prep_query($sql, $v, $t);
+
+	$counter = 0;
+	while($row = db_fetch_array($res)){
+		$counter++;
+		if (isUnderLimit($counter, $numberOfResults, $numberOfResults)) {
+			$landparcelId = $row["flst_kennz"];
+			$x = trim(floatval($row["rechtsw"]));
+			$y = trim(floatval($row["hochw"]));
+			$owner = trim($row["e_name"]);
+			array_push($obj["landparcels"], array("landparcelId" => $landparcelId, "owner" => $owner, "x" => $x, "y" => $y));
+		}
+	}
+	$obj["limited"] = isOverLimit($counter, $numberOfResults, $numberOfResults);
+}
+else if ($command == "getLandparcelsByDistrict") {
+	$obj["landparcels"] = array();
+	$paramCounter = 0;
+
+	$sql = "SELECT DISTINCT flst_kennz, rechtsw, hochw FROM alb.albflst WHERE gemschl = $" . ++$paramCounter;
+	$v = array($districtId);
+	$t = array("i");
+	if (!empty($parcelNumber1)) {
+		$sql .= " AND flur = $" . ++$paramCounter;
+		array_push($v, $parcelNumber1);
+		array_push($t, "i");
+	}
+	if (!empty($parcelNumber2)) {
+		$sql .= " AND flstz = $" . ++$paramCounter;
+		array_push($v, $parcelNumber2);
+		array_push($t, "i");
+	}
+	$sql .= " ORDER BY flst_kennz";
+	if (isLimited($numberOfResults)) {
+		$sql .= " LIMIT $" . ++$paramCounter;
+		array_push($v, $limit);
+		array_push($t, "i");
+	}
+	$res = db_prep_query($sql, $v, $t);
+
+	$counter = 0;
+	while($row = db_fetch_array($res)){
+		$counter++;
+		if (isUnderLimit($counter, $numberOfResults, $numberOfResults)) {
+			$landparcelId = $row["flst_kennz"];
+			$x = trim(floatval($row["rechtsw"]));
+			$y = trim(floatval($row["hochw"]));
+
+			$obj["landparcels"][$landparcelId] = array("x" => $x, "y" => $y);
+		}
+	}
+	$obj["limited"] = isOverLimit($counter, $numberOfResults, $numberOfResults);
+}
+else if ($command == "getDistricts") {
+	$obj["districts"] = array();
+
+	$sql = "SELECT DISTINCT gemschl, name FROM public.gemarkungen WHERE gkz = $1 ORDER BY name";
+	$v = array($communeId);
+	$t = array("i");
+	$res = db_prep_query($sql, $v, $t);
+
+	while($row = db_fetch_array($res)){
+		$districtID = trim($row["gemschl"]);
+		$districtName = trim($row["name"]);
+		$obj["districts"][$districtID] = $districtName;
+	}
+	$obj["limited"] = false;
+}
+else {
+	// unknown command
+	$e = new mb_exception("unknown command: " . $command);
+}
+
+$json = new Services_JSON();
+$output = $json->encode($obj);
+echo $output;
+?>
\ No newline at end of file

Added: branches/mapbender_sld/http/php/mod_setLocale.php
===================================================================
--- branches/mapbender_sld/http/php/mod_setLocale.php	                        (rev 0)
+++ branches/mapbender_sld/http/php/mod_setLocale.php	2007-11-23 13:20:10 UTC (rev 1830)
@@ -0,0 +1,29 @@
+<?php
+# $Id$
+# http://www.mapbender.org/index.php/localeSwitch
+# 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("../classes/class_locale.php");
+require_once("../../conf/mapbender.conf");
+$_SESSION["mb_lang"] = $_REQUEST["lang"];
+$localeObj = new Mb_locale($_SESSION["mb_lang"]);
+session_write_close();
+
+header("Content-type='text/plain';Charset='utf-8'");
+echo $localeObj->name;
+?>

Added: branches/mapbender_sld/http/php/mod_switchLocale.php
===================================================================
--- branches/mapbender_sld/http/php/mod_switchLocale.php	                        (rev 0)
+++ branches/mapbender_sld/http/php/mod_switchLocale.php	2007-11-23 13:20:10 UTC (rev 1830)
@@ -0,0 +1,75 @@
+<?php
+# $Id$
+# http://www.mapbender.org/index.php/localeSwitch
+# 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"];
+$user_id = $_SESSION["mb_user_id"]; 
+
+require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+
+$con = db_connect($DBSERVER,$OWNER,$PW);
+db_select_db(DB,$con);
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta name="author" content="V. Diewald">
+<meta http-equiv="cache-control" content="no-cache">
+<meta http-equiv="pragma" content="no-cache">
+<meta http-equiv="expires" content="0">
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta name="DC.Rights" content="WhereGroup GmbH & Co.KG, Bonn">
+<title>Metadata search</title>
+<?
+include_once("../include/dyn_css.php");
+?>
+<script type="text/javascript">
+<!--
+
+function validate(){
+	var index = document.getElementById("language").selectedIndex;
+	var lang = document.getElementById("language").options[index].value;
+	parent.mb_ajax_post("../php/mod_setLocale.php", {"lang":lang}, function(status,result) {
+		parent.window.location.reload();	
+	});
+}
+
+// -->
+</script>
+</head>
+<body leftmargin="2" topmargin="0" bgcolor="#ffffff">
+<form name='form1' target='parent'>
+<p>
+<select id='language' name='language' onchange='validate()'>
+<?php
+$languageArray = explode(",", $languages);
+for ($i = 0; $i < count($languageArray); $i++) {
+	echo "<option";
+	if ($_SESSION["mb_lang"] == $languageArray[$i]) {
+		echo " selected";
+	}
+	echo ">" . $languageArray[$i] . "</option>";
+}
+?>
+</select>
+</p>
+</form>
+</body>
+</html>
\ No newline at end of file

Added: branches/mapbender_sld/http/php/mod_switchLocale_noreload.php
===================================================================
--- branches/mapbender_sld/http/php/mod_switchLocale_noreload.php	                        (rev 0)
+++ branches/mapbender_sld/http/php/mod_switchLocale_noreload.php	2007-11-23 13:20:10 UTC (rev 1830)
@@ -0,0 +1,76 @@
+<?php
+# $Id$
+# http://www.mapbender.org/index.php/localeSwitch
+# 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"];
+$user_id = $_SESSION["mb_user_id"]; 
+
+require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+
+$con = db_connect($DBSERVER,$OWNER,$PW);
+db_select_db(DB,$con);
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta name="author" content="V. Diewald">
+<meta http-equiv="cache-control" content="no-cache">
+<meta http-equiv="pragma" content="no-cache">
+<meta http-equiv="expires" content="0">
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta name="DC.Rights" content="WhereGroup GmbH & Co.KG, Bonn">
+<title>Metadata search</title>
+<?
+include_once("../include/dyn_css.php");
+?>
+<script type="text/javascript">
+<!--
+
+function validate(){
+	var index = document.getElementById("language").selectedIndex;
+	var lang = document.getElementById("language").options[index].value;
+	parent.mb_ajax_post("../php/mod_setLocale.php", {"lang":lang}, function(result, status) {
+		parent.mapbender.locale = result;
+		parent.localize();	
+	});
+}
+
+// -->
+</script>
+</head>
+<body leftmargin="2" topmargin="0" bgcolor="#ffffff">
+<form name='form1' target='parent'>
+<p>
+<select id='language' name='language' onchange='validate()'>
+<?php
+$languageArray = explode(",", $languages);
+for ($i = 0; $i < count($languageArray); $i++) {
+	echo "<option";
+	if ($_SESSION["mb_lang"] == $languageArray[$i]) {
+		echo " selected";
+	}
+	echo ">" . $languageArray[$i] . "</option>";
+}
+?>
+</select>
+</p>
+</form>
+</body>
+</html>
\ No newline at end of file

Added: branches/mapbender_sld/http/php/mod_wfsSpatialRequest_messages.php
===================================================================
--- branches/mapbender_sld/http/php/mod_wfsSpatialRequest_messages.php	                        (rev 0)
+++ branches/mapbender_sld/http/php/mod_wfsSpatialRequest_messages.php	2007-11-23 13:20:10 UTC (rev 1830)
@@ -0,0 +1,45 @@
+<?php
+#$Id: mod_insertWmcIntoDb.php 507 2006-11-20 10:55:57Z christoph $
+#$Header: /cvsroot/mapbender/mapbender/http/javascripts/mod_insertWmcIntoDb.php,v 1.19 2006/03/09 14:02:42 uli_rothstein Exp $
+# 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");
+require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
+
+session_start();
+
+$e = new mb_notice("locale: " . $_SESSION["mb_locale"] . "; lang: " . $_SESSION["mb_lang"]);
+setlocale(LC_ALL, $_SESSION["mb_locale"]);
+
+//
+// Messages
+//
+$msg_obj = array();
+$msg_obj["buttonLabelRectangle"] = _("select by rectangle");
+$msg_obj["buttonLabelPolygon"] = _("select by polygon");
+$msg_obj["buttonLabelPoint"] = _("select by point");
+$msg_obj["buttonLabelExtent"] = _("select by extent");
+$msg_obj["buttonLabelDialogue"] = _("open dialogue form");
+$msg_obj["errorMessageInvalidExtent"] = _("Invalid box!");
+
+$json = new Services_JSON();
+$output = $json->encode($msg_obj);
+
+header("Content-type:text/plain; Charset='UTF-8'");
+echo $output;
+?>
\ No newline at end of file

Added: branches/mapbender_sld/http/php/mod_wfs_server.php
===================================================================
--- branches/mapbender_sld/http/php/mod_wfs_server.php	                        (rev 0)
+++ branches/mapbender_sld/http/php/mod_wfs_server.php	2007-11-23 13:20:10 UTC (rev 1830)
@@ -0,0 +1,302 @@
+<?php
+session_start();
+include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
+require_once(dirname(__FILE__)."/../classes/class_wfs.php");
+include_once("../extensions/JSON.php");
+
+//db connection
+$con = db_connect(DBSERVER,OWNER,PW);
+db_select_db(DB,$con);
+
+$json = new Services_JSON();
+$obj = $json->decode(stripslashes($_REQUEST['obj']));
+
+//workflow:
+switch($obj->action){
+	case 'getServices':
+		$obj->services = getServices($obj);
+		sendOutput($obj);
+	break;
+	case 'getWfsConfData':
+		$obj->wfsConf = getWfsConfData($obj->wfs);
+		sendOutput($obj);
+	break;
+	case 'getGuis':
+		$obj->id = getGuis($obj);
+		sendOutput($obj);
+	break;
+	case 'getAssignedConfs':
+		$obj->assignedConfs = getAssignedConfs($obj);
+		sendOutput($obj);
+	break;
+	case 'getUpdateUrl':
+		$obj->url = getUpdateUrl($obj);
+		sendOutput($obj);	
+	break;
+		case 'add':
+		addConfsToGui($obj);
+		sendOutput($obj);
+	break;
+	case 'remove':
+		removeConfsFromGui($obj);
+		sendOutput($obj);
+	break;
+	case 'updateWfs':
+		updateWfs($obj);
+		sendOutput($obj);
+	break;
+	case 'deleteWfs':
+		deleteWfs($obj);
+		sendOutput($obj);
+	break;
+	case 'setOwsproxy':
+		$ows = array();
+		$ows['string'] = setOwsproxy($obj);
+		$ows['action'] = "owsproxy";
+		sendOutput($ows);
+	break;
+	case 'removeOwsproxy':
+		$ows = array();
+		$ows['string'] = removeOwsproxy($obj);
+		$ows['action'] = "owsproxy";
+		sendOutput($ows);
+	break;
+	case 'getOwsproxy':
+		$ows = array();
+		$ows['string'] = getOwsproxy($obj);
+		$ows['action'] = "owsproxy";
+		sendOutput($ows);
+	break;
+	default:
+		sendOutput("no action specified...");
+}
+
+
+/*
+ * Get all services (ids and titles) where the current user is owner
+ * 
+ * @return mixed[] services the ids and titles of the services
+ */
+function getServices(){
+	global $con;
+	$services = array();
+	$services['id'] = array();
+	$services['title'] = array();
+	$adm = new administration();
+	$serviceList = $adm->getWfsByOwner($_SESSION['mb_user_id']);
+	if(count($serviceList) == 0){
+		return false;	
+	}
+	$sql = "SELECT * FROM wfs WHERE wfs_id IN(".join(",",$serviceList).") ORDER BY wfs_title";
+	$res = db_query($sql);
+	while($row = db_fetch_array($res)){
+		array_push($services['id'], $row['wfs_id']);
+		array_push($services['title'], $row['wfs_title']);
+	}
+	return $services;
+}
+
+/*
+ * Get all configurations of the selcted wfs if the current user is owner 
+ * 
+ * @return mixed[] 
+ */
+function getWfsConfData($wfsID){
+	global $con;
+	// re-check permission 
+	$adm = new administration();
+	$serviceList = $adm->getWfsByOwner($_SESSION['mb_user_id']);
+	if(in_array($wfsID, $serviceList)){
+		$wfsConf = array();
+		$wfsConf['id'] = array();
+		$wfsConf['abstract'] = array();
+		$sql = "SELECT * FROM wfs_conf WHERE fkey_wfs_id = $1 ORDER BY wfs_conf_abstract";
+		$v = array($wfsID);
+		$t = array('i');
+		$res = db_prep_query($sql,$v,$t);
+		$cnt = 0;
+		while($row = db_fetch_array($res)){
+			array_push($wfsConf['id'], $row['wfs_conf_id']);
+			array_push($wfsConf['abstract'], $row['wfs_conf_abstract']);
+			$cnt++;
+		}
+		if($cnt == 0){
+			return false;	
+		}
+		else{
+			return $wfsConf;
+		}
+	}
+	else if($wfsID==="gui_confs"){
+		$wfsConf = array();
+		$wfsConf['id'] = array();
+		$wfsConf['abstract'] = array();
+		$wfsConf['id'] = $adm->getWfsConfByPermission($_SESSION['mb_user_id']);
+		$cnt = 0;
+		foreach($wfsConf['id'] as $wfscid){
+			$sql = "SELECT wfs_conf_abstract FROM wfs_conf WHERE wfs_conf_id = $1";
+			$v = array($wfscid);
+			$t = array('i');
+			$res = db_prep_query($sql,$v,$t);
+			while($row = db_fetch_array($res)){
+				array_push($wfsConf['abstract'], $row['wfs_conf_abstract']);
+			}	
+			$cnt++;
+		}
+		if($cnt == 0){
+			return false;	
+		}
+		else{
+			return $wfsConf;
+		}
+	}
+}
+/*
+ * Get all GUIs where the current user is owner. This are the GUIs where the user could publish his
+ * wfs configurations
+ * 
+ * @return mixed[] 
+ */
+function getGuis(){
+	$adm = new administration();
+	$guiList = $adm->getGuisByOwner($_SESSION['mb_user_id'],1);
+	if(count($guiList) > 0){
+		return $guiList;
+	}
+	return false;
+}
+
+
+/*
+ * get all wfs_confs of the selected WFS which are assigned to the selected gui
+ * @param 
+ * @return mixed[] 
+ */
+function getAssignedConfs($obj){
+	global $con;
+	$assignedConfs = array();
+	$confs = getWfsConfData($obj->selectedWfs);
+	if($confs === false){
+		return false;	
+	}
+	$sql = "SELECT * FROM gui_wfs_conf WHERE fkey_gui_id = $1 AND fkey_wfs_conf_id IN (".join(",",$confs['id']).")";
+	$v = array($obj->selectedGui);
+	$t = array('s');	
+	$res = db_prep_query($sql,$v,$t);
+	if(!$res){
+		$e = new mb_exception("Error: SQL: " . $sql . " -> Gui: " .$obj->selectedGui);
+	}
+	while($row = db_fetch_array($res)){
+		array_push($assignedConfs, $row['fkey_wfs_conf_id']);
+	}
+	return $assignedConfs;
+}
+
+
+function addConfsToGui($obj){
+	global $con;
+	for($i=0; $i<count($obj->confs); $i++){
+		$sql = "SELECT * FROM gui_wfs_conf WHERE fkey_gui_id = $1 AND fkey_wfs_conf_id = $2";
+		$v = array($obj->gui,$obj->confs[$i]);
+		$t = array('s','i');
+		$res = db_prep_query($sql,$v,$t);		
+		if(!$row = db_fetch_array($res)){
+			$sql1 = "INSERT INTO gui_wfs_conf (fkey_gui_id,fkey_wfs_conf_id) VALUES ($1,$2)";
+			$v1 = array($obj->gui, $obj->confs[$i]);
+			$t1 = array('s', 'i');
+			$res1 = db_prep_query($sql1,$v1,$t1);
+		}
+	}
+}
+
+function removeConfsFromGui($obj){
+	global $con;
+	for($i=0; $i<count($obj->confs); $i++){
+		$sql = "DELETE FROM gui_wfs_conf  WHERE fkey_gui_id = $1 AND fkey_wfs_conf_id = $2";
+		$v = array($obj->gui, $obj->confs[$i]);
+		$t = array('s', 'i');
+		$res = db_prep_query($sql,$v,$t);
+	}
+}
+/*
+ * updates an WFS
+ * 
+ * @param object the un-encoded object 
+ * @return boolean success
+ */
+function updateWfs($obj){
+	$obj->success = false;
+	$mywfs = new wfs();
+	$mywfs->createObjFromDB($obj->wfs);
+	if(!$mywfs->updateObjFromXML($obj->url)){
+		return false;
+	}
+	if(!$mywfs->wfs2db("")){
+		return false;
+	}		
+	$obj->success = true;
+	return true;
+}
+/*
+ * deletes an WFS
+ * 
+ * @param object the un-encoded object 
+ * @return boolean success
+ */
+function deleteWfs($obj){
+	//$obj->success = false;
+	$sql = "DELETE FROM wfs WHERE wfs_id = $1";
+	$v = array($obj->wfs);
+	$t = array('i');	
+	$res = db_prep_query($sql,$v,$t);
+	$obj->success = true;
+	return true;
+}
+
+/*
+ * gets the specified url column from db
+ * 
+ * @param object the un-encoded object
+ * @return string requested url
+ */
+
+function getUpdateUrl($obj){
+	global $con;
+	$sql = "SELECT * FROM wfs WHERE wfs_id = $1;";
+	$v = array($obj->wfs);
+	$t = array('i');
+	$res = db_prep_query($sql,$v,$t);
+	while($row = db_fetch_array($res)){
+		return $row[$obj->column];
+	}
+	return "";
+}
+
+function getOwsproxy($obj){
+	$n = new administration();
+	return $n->getWfsOwsproxyString($obj->wfs); 
+}
+function setOwsproxy($obj){
+	$n = new administration();
+	return $n->setWfsOwsproxyString($obj->wfs,true);
+}
+function removeOwsproxy($obj){
+	$n = new administration();
+	return $n->setWfsOwsproxyString($obj->wfs,false);
+}
+/*
+ * 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;
+}
+
+
+?>
\ No newline at end of file



More information about the Mapbender_commits mailing list