svn commit: r741 - trunk/mapbender/http: classes frames javascripts

christoph at osgeo.org christoph at osgeo.org
Thu Aug 3 08:51:45 EDT 2006


Author: christoph
Date: 2006-08-03 12:51:45+0000
New Revision: 741

Added:
   trunk/mapbender/http/classes/class_kml.php
   trunk/mapbender/http/frames/cleanurl.php
   trunk/mapbender/http/javascripts/mod_insertKmlIntoDb.php
   trunk/mapbender/http/javascripts/mod_saveWmcKml.php

Log:
additional files for meetingpoint functionality

Added: trunk/mapbender/http/classes/class_kml.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/classes/class_kml.php?view=auto&rev=741
==============================================================================
--- (empty file)
+++ trunk/mapbender/http/classes/class_kml.php	2006-08-03 12:51:45+0000
@@ -0,0 +1,178 @@
+<?php
+# $Id: class_wmc.php,v 1.31 2006/03/16 14:49:30 c_baudson Exp $
+# http://www.mapbender.org/index.php/class_wmc.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("../../conf/mapbender.conf");
+
+class kml {
+
+		var $kml_id;
+		var $lookAt_range = 5000;
+		var $lookAt_heading = 0;
+		var $lookAt_tilt = 0;
+		var $description;
+		var $title;
+		var $icon;
+		var $x;
+		var $y;
+		var $kml;
+					
+	function kml($title, $description, $x, $y, $icon) {
+  		$this->kml_id = md5(microtime());
+  		$this->x = $x;
+  		$this->y = $y;
+  		$this->icon = $icon;
+  		$this->title = $title;
+  		$this->description = $description;
+	} 
+
+	function setLookAt($range, $heading) {
+		$this->lookAt_range = $range;
+		$this->lookAt_heading = $heading;
+	}
+	
+	function createObjFromKML($kml_doc) {
+		$data = $kml_doc;
+		
+		if(!$data){
+			echo "document empty.";
+			return false;
+		}
+		
+		$this->kml = $this->char_encode($data);
+
+		$parser = xml_parser_create(CHARSET);
+		xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
+		xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
+		xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING,CHARSET);
+		xml_parse_into_struct($parser,$data,$values,$tags);
+		xml_parser_free($parser);
+		
+		$section;
+		$cnt_format = 0;
+		$parent = array();
+		$myParent = array();
+		$cnt_layer = -1;
+		$layer_style = array();
+		$cnt_styles = -1;
+		
+		foreach ($values as $element) {
+			if(strtoupper($element[tag]) == "KML" && $element[type] == "open"){
+				$section = "kml";
+			}
+			if ($section == "kml" && strtoupper($element[tag]) == "PLACEMARK" && $element[type] == "open") {
+				$section = "placemark";
+			}
+			if ($section == "placemark" && strtoupper($element[tag]) == "DESCRIPTION" && $element[type] == "complete") {
+				$this->description = $element[value];
+			}
+			if ($section == "placemark" && strtoupper($element[tag]) == "NAME" && $element[type] == "complete") {
+				$this->title = $element[value];
+			}
+			if ($section == "placemark" && strtoupper($element[tag]) == "LOOKAT" && $element[type] == "open") {
+				$section = "lookat";
+			}
+			if ($section == "lookat") {
+				
+				if (strtoupper($element[tag]) == "RANGE" && $element[type] == "complete") {
+					$this->lookAt_range = $element[value]; 
+				}
+				if (strtoupper($element[tag]) == "HEADING" && $element[type] == "complete") {
+					$this->lookAt_heading = $element[value]; 
+				}
+				if (strtoupper($element[tag]) == "TILT" && $element[type] == "complete") {
+					$this->lookAt_tilt = $element[value]; 
+				}
+			}
+			if (strtoupper($element[tag]) == "STYLE" && $element[type] == "open") {
+				$section = "style";
+			}
+			if ($section == "style" && strtoupper($element[tag]) == "ICONSTYLE" && $element[type] == "open") {
+				$section = "iconstyle";
+			}
+			if ($section == "iconstyle" && strtoupper($element[tag]) == "ICON" && $element[type] == "open") {
+				$section = "icon";
+			}
+			if ($section == "icon" && strtoupper($element[tag]) == "HREF" && $element[type] == "complete") {
+				$this->icon = $element[value];
+			}
+			if (strtoupper($element[tag]) == "POINT" && $element[type] == "open") {
+				$section = "point";
+			}
+			if ($section == "point" && strtoupper($element[tag]) == "COORDINATES" && $element[type] == "complete") {
+				$array = explode(",", $element[value]);
+				$this->x = $array[0];
+				$this->y = $array[1];
+			}
+		}
+		return true;
+	}
+
+	function createObjFromDB($kml_id) {
+		$this->kml_id = $kml_id;
+
+		$sql = "SELECT kml FROM mb_meetingpoint WHERE mb_meetingpoint_id = $1";
+		$v = array($kml_id);
+		$t = array('s');
+		$res = db_prep_query($sql, $v, $t);
+		$row = db_fetch_array($res);
+		return $this->createObjFromKML($row['kml']);
+	}
+
+	function createKMLFromObj(){
+		$kml = "";
+		$kml .= "<?xml version=\"1.0\" encoding=\"".CHARSET."\"?>\n";
+		$kml .= "<kml xmlns=\"http://earth.google.com/kml/2.0\">\n";
+		$kml .= "<Placemark>\n";
+		$kml .= "\t<description>" . $this->description . "</description>\n";
+		$kml .= "\t<name>" . $this->title . "</name>\n";
+		$kml .= "\t<LookAt>\n";
+		$kml .= "\t\t<longitude>" . $this->x . "</longitude>\n";
+		$kml .= "\t\t<latitude>" . $this->y . "</latitude>\n";
+		$kml .= "\t\t<range>" . $this->lookAt_range . "</range>\n";
+		$kml .= "\t\t<tilt>" . $this->lookAt_tilt . "</tilt>\n";
+		$kml .= "\t\t<heading>" . $this->lookAt_heading . "</heading>\n";
+		$kml .= "\t</LookAt>\n";
+		$kml .= "\t<visibility>0</visibility>\n";
+		$kml .= "\t<Style>\n";
+		$kml .= "\t\t<IconStyle>\n";
+		$kml .= "\t\t\t<Icon>\n";
+		$kml .= "\t\t\t\t<href>" . $this->icon . "</href>\n";
+		$kml .= "\t\t\t</Icon>\n";
+		$kml .= "\t\t</IconStyle>\n";
+		$kml .= "\t</Style>\n";
+		$kml .= "\t<Point>\n";
+		$kml .= "\t\t<extrude>1</extrude>\n";
+		$kml .= "\t\t<coordinates>" . $this->x . "," . $this->y . "</coordinates>\n";
+		$kml .= "\t</Point>\n";
+		$kml .= "</Placemark>\n";
+		$kml .= "</kml>";
+		
+		$this->kml = $kml;
+		
+		return $kml;
+	}
+
+	function char_encode($s){
+		if(CHARSET == 'UTF-8'){
+			$s = utf8_encode($s);	
+		}
+		return $s;
+	}
+} 
+// end class
+?>
\ No newline at end of file

Added: trunk/mapbender/http/frames/cleanurl.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/frames/cleanurl.php?view=auto&rev=741
==============================================================================
--- (empty file)
+++ trunk/mapbender/http/frames/cleanurl.php	2006-08-03 12:51:45+0000
@@ -0,0 +1,50 @@
+<?php
+# $Id$
+# 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.
+
+ob_start(); 
+include_once("../../conf/mapbender.conf");
+include("../classes/class_administration.php");
+
+
+$adm = new administration();
+
+$con = db_connect(DBSERVER,OWNER,PW);
+db_select_db(DB,$con);
+
+$id = $_GET['id'];
+
+$sql = "SELECT * FROM mb_meetingpoint WHERE mb_meetingpoint_id = $1";
+$v = array($id);
+$t = array('s');
+$res = db_prep_query($sql,$v,$t);
+if($row = db_fetch_array($res)){
+	$user = $adm->getUserNameByUserId($row['fkey_mb_user_id']);
+	$password = $row['mb_user_password'];
+	$gui_id = $row['fkey_gui_id'];
+}
+else {
+	exit();
+}
+$url = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/login.php?";
+$url .= "name=".$user."&password=".urlencode($password)."&mb_user_myGui=".$gui_id."&kml_id=".$id;
+		
+header ("Location: ".$url);
+ob_end_flush();
+?>
+</body>
+</html>

Added: trunk/mapbender/http/javascripts/mod_insertKmlIntoDb.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/mod_insertKmlIntoDb.php?view=auto&rev=741
==============================================================================
--- (empty file)
+++ trunk/mapbender/http/javascripts/mod_insertKmlIntoDb.php	2006-08-03 12:51:45+0000
@@ -0,0 +1,83 @@
+<?php
+#$Id: mod_insertWmcIntoDb.php,v 1.19 2006/03/09 14:02:42 uli_rothstein Exp $
+#$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.
+
+include("../../conf/mapbender.conf");
+include("../classes/class_kml.php");
+session_start();
+$gui_id = $_REQUEST["gui_id"];
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+<head>
+<!-- 
+Licensing: See the GNU General Public License for more details.
+http://www.gnu.org/copyleft/gpl.html
+or:
+mapbender/licence/ 
+-->
+
+<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.'">';	
+?>
+<title>MB2 - <?php  echo  $_REQUEST["gui_id"];?></title>
+<?php
+
+$con = db_connect($DBSERVER,$OWNER,$PW);
+db_select_db(DB,$con);
+?>
+</head>
+<body>
+<?php
+if ($_POST["data"]) {
+	
+	$d = explode("____", $_POST["data"]);	
+	$wmc_id = $d[0];
+	$x = $d[1];
+	$y = $d[2];
+	$icon = $d[3];
+	$gui_id = $d[4];
+	$title = $_POST['name'] . ", " . $_POST['street'] . ", " . $_POST['postcode']. " " .$_POST['city'] . ", " . $_POST['website'];
+	$description = $_POST['description']; 
+	
+	$kml = new kml($title, $description, $x, $y, $icon);
+	$kml->createKMLFromObj();
+	
+	$sql = "INSERT INTO mb_meetingpoint VALUES ($1, $2, $3, $4, $5, $6)";
+	$v = array($kml->kml_id, $wmc_id, str_replace("&", "&#38;" , html_entity_decode($kml->kml)), $_SESSION["mb_user_id"], $_SESSION["mb_user_password"], $gui_id);
+	$t = array('s', 's', 's', 'i', 's', 's');
+	$res = db_prep_query($sql, $v, $t);
+	
+	if (db_error()) {
+		echo "<script>var title = \"" . $title . "\";alert(\"Error while saving KML document \" + title + \"!\");</script>";
+	}
+	else {
+		if ($alert) {
+			 echo "<script>var title = \"" . $title . "\";alert(\"KML document \" + title + \"has been saved!\")</script>";
+		}
+	}
+	echo "<a href = 'http://wms1.ccgis.de/mburl/".$kml->kml_id."'>link</a>";
+}
+?>
+
+</body>
+</html>

Added: trunk/mapbender/http/javascripts/mod_saveWmcKml.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/mod_saveWmcKml.php?view=auto&rev=741
==============================================================================
--- (empty file)
+++ trunk/mapbender/http/javascripts/mod_saveWmcKml.php	2006-08-03 12:51:45+0000
@@ -0,0 +1,141 @@
+<?php
+# $Id: mod_savewmc.php 264 2006-05-12 11:07:19Z vera_schulze 
+# http://www.mapbender.org/index.php/mod_savewmc.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();
+$gui_id = $_REQUEST["gui_id"];
+require_once("../../conf/mapbender.conf");
+require_once("point.js");
+require_once("mod_savewmc.php");
+$con = db_connect($DBSERVER,$OWNER,$PW);
+db_select_db(DB,$con);
+$sql = "SELECT e_src, e_target FROM gui_element WHERE e_id = 'savewmc' AND fkey_gui_id = $1";
+$v = array($gui_id);
+$t = array('s');
+$res = db_prep_query($sql, $v, $t);
+$cnt = 0;
+while($row = db_fetch_array($res)){
+	$e_src = $row["e_src"];
+	$e_target = $row["e_target"];
+	$cnt++;
+}
+if($cnt > 1){
+	echo "alert('savewmc: ID not unique!');";
+}
+
+echo "mod_savewmc_target = '".$e_target."';";
+?>
+
+var mod_savewmc_img = new Image(); mod_savewmc_img.src = "<?php  echo $e_src;  ?>";
+//var mod_savewmc_img_over = new Image(); mod_savewmc_img_over.src = "<?php  echo preg_replace("/_off/","_over",$e_src);  ?>";
+
+function mod_saveWmcKml(obj){
+	current_user = "<?php echo $_SESSION["mb_user_id"]; ?>";
+	current_password = "<?php echo $_SESSION["mb_user_password"];?>";
+	current_gui = "<?php echo $gui_id;?>";
+	
+	var ind = getMapObjIndexByName(mod_savewmc_target);
+	
+	var el = frames[mod_savewmc_target].document;
+	el.onmousedown = mod_getMousePos;
+	el.onmouseup = null;
+	el.onmousemove = null;
+	el.onmouseover = null;
+}
+
+function mod_getMousePos(e) {
+	mb_getMousePos(e,mod_savewmc_target);
+	var q = new Point(clickX,clickY);
+	var realWorldPos = mapToReal(mod_savewmc_target,q);
+
+	var el = frames[mod_savewmc_target].document;
+	el.onmousedown = null;
+	//alert(realWorldPos);
+	//document.sendData.target = "_blank";
+	//document.sendData.action = "../javascripts/mod_insertWmcIntoDb.php";
+	//document.sendData.data.value = user + "____" + generalTitle + "____" + wmc + "____" + id;
+	//document.sendData.submit();
+
+	saveWindow = open("", "save", "width=400, height=300, resizable, dependent=yes, scrollbars=yes");
+	saveWindow.document.open("text/html");
+/*
+	var cssLink = saveWindow.document.createElement("link");
+	cssLink.setAttribute("href", wfsCssUrl); 
+	cssLink.setAttribute("type", "text/css"); 
+	cssLink.setAttribute("rel", "stylesheet"); 
+	var cssTmp = saveWindow.document.getElementsByTagName("head")[0];
+	cssTmp.appendChild(cssLink);
+*/
+	var wmc_title = "meetingpoint";
+	var icon = "http://www.eracareers-germany.de/drmp_de/image/rote_stecknadel.gif";
+	
+	var str = "";
+	var onclick = "wmcid=window.opener.mod_savewmc('"+wmc_title+"');";
+	onclick += "document.sendData.action = '../javascripts/mod_insertKmlIntoDb.php?<?php echo SID;?>';";
+	onclick += "document.sendData.data.value = wmcid + '____" + realWorldPos.x + "____" + realWorldPos.y + "____"+ icon + "____<?php echo $gui_id;?>';";
+	onclick += "document.sendData.submit();" 
+	str += "<form name='sendData' method='post'>\n";
+	str += "<table>\n";
+	str += "<tr>\n";
+	str += "<td>Name</td>\n";
+	str += "<td><input type='text' name='name'></td>\n";
+	str += "</tr>\n";
+	str += "<tr>\n";
+	str += "<td>Strasse</td>\n";
+	str += "<td><input type='text' name='street'></td>\n";
+	str += "</tr>\n";
+	str += "<tr>\n";
+	str += "<td>PLZ</td>\n";
+	str += "<td><input type='text' name='postcode'></td>\n";
+	str += "</tr>\n";
+	str += "<tr>\n";
+	str += "<td>Ort</td>\n";
+	str += "<td><input type='text' name='city'></td>\n";
+	str += "</tr>\n";
+	str += "<tr>\n";
+	str += "<td>Webseite</td>\n";
+	str += "<td><input type='text' name='website'></td>\n";
+	str += "</tr>\n";
+	str += "<tr>\n";
+	str += "<td>Beschreibung</td>\n";
+	str += "<td><textarea name='description'></textarea></td>\n";
+	str += "</tr>\n";
+	str += "<tr>\n";
+	str += "<td colspan=2><input type='button' value='URL generieren' name='generateUrl' onclick=\""+onclick+"\"></td>\n";
+	str += "</tr>\n";
+	str += "</table>\n";
+	str += "<input type=hidden name=data>\n";
+	str += "</form>";
+	saveWindow.document.write(str);
+	saveWindow.document.close();
+}
+
+function mod_savewmc_init(obj){
+	//document.getElementById("savewmc").src = mod_zoom1_img_over.src;
+	//obj.onmouseover = new Function("mod_zoomIn1_over()");
+	//obj.onmouseout = new Function("mod_zoomIn1_out()");
+}
+function mod_zoomIn1_over(){
+	//document.getElementById("zoomIn1").src = mod_zoom1_img_over.src;
+}
+function mod_zoomIn1_out(){
+	//document.getElementById("zoomIn1").src = mod_zoom1_img.src;
+}
+
+
+




More information about the Mapbender_commits mailing list