[Mapbender-commits] r1829 - in branches/mapbender_sld: http/print http/print/img http/tools http/tools/datepicker http/tools/wms_extent owsproxy/http owsproxy/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Nov 23 08:14:53 EST 2007


Author: christoph
Date: 2007-11-23 08:14:53 -0500 (Fri, 23 Nov 2007)
New Revision: 1829

Added:
   branches/mapbender_sld/http/print/print_functions.php
   branches/mapbender_sld/owsproxy/http/classes/
   branches/mapbender_sld/owsproxy/http/classes/class_QueryHandler.php
Modified:
   branches/mapbender_sld/http/print/img/northarrow.png
   branches/mapbender_sld/http/print/mod_printPDF.php
   branches/mapbender_sld/http/print/mod_printPDF_pdf.php
   branches/mapbender_sld/http/print/printPDF.conf
   branches/mapbender_sld/http/print/printPDF_b.conf
   branches/mapbender_sld/http/tools/datepicker/datepicker.php
   branches/mapbender_sld/http/tools/mapbender_setup.php
   branches/mapbender_sld/http/tools/send_post.php
   branches/mapbender_sld/http/tools/wms_extent/mapbender_wms.map
   branches/mapbender_sld/owsproxy/http/index.php
Log:
more from trunk

Modified: branches/mapbender_sld/http/print/img/northarrow.png
===================================================================
(Binary files differ)

Modified: branches/mapbender_sld/http/print/mod_printPDF.php
===================================================================
--- branches/mapbender_sld/http/print/mod_printPDF.php	2007-11-23 13:08:46 UTC (rev 1828)
+++ branches/mapbender_sld/http/print/mod_printPDF.php	2007-11-23 13:14:53 UTC (rev 1829)
@@ -1,377 +1,395 @@
-<?php
-# $Id: mod_printPDF.php
-# http://www.mapbender.org/index.php/mod_printPDF.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");
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-
-<html>
-<head>
-<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>Print PDF</title>
-</head>
-<style type="text/css">
-<!-- 
-select{
-   width:150px;
-} 
-input{
-	width:150px;
-}
-.mycheck{
-	width:15px;
-}
-div{
-	font-family : Arial, Helvetica, sans-serif;
-	font-size: 12px;
-}
--->
-</style>
-<?php
-
-
-require_once(dirname(__FILE__)."/../print/".$_REQUEST["conf"]);
-echo "<script type='text/javascript'>";
-echo "var target = '".$_REQUEST["target"]."';";
-echo "var comment = '".$label_comment."';";
-echo "var comment_length = ".$comment_length.";";
-echo "var label_button = '".$label_button."';";
-echo "var type = '".$type."';";
-echo "</script>";
-?>
-<script type="text/javascript">
-<!--
-
-
-var size;
-var format;
-var map_width;
-var map_height;
-
-if(type=='window'){
-	var pt = window.opener;
-}
-else if(type == 'iframe'){
-	var pt = parent;
-}
-
-function mod_legend_print(){
-	var mod_legend_target = target;
-	var ind = pt.getMapObjIndexByName(mod_legend_target);
-	var layers;
-
-	document.forms[0].layers.value = "";
-	document.forms[0].wms_id.value = "";
-	document.forms[0].wms_title.value = "";
-	document.forms[0].legendurl.value = "";
-	
-
-	
-	for(var i=0; i<pt.mb_mapObj[ind].wms.length; i++){
-		if(pt.mb_mapObj[ind].wms[i].gui_wms_visible != 0){
-			layers = pt.mb_checkScale(mod_legend_target,ind,i);
-			var layer = layers[0].split(",");
-			var title = layers[2].split(",");
-			var temp_legendurl = layers[3].split(",");
-			var layerparent= layers[4].split(",");
-	
-			if( pt.mb_mapObj[ind].layers[i] != "" && pt.mb_mapObj[ind].layers[i]){
-	
-			   if(i>0 && document.forms[0].wms_id.value!=''){
-			    document.forms[0].layers.value += "___";
-			    document.forms[0].wms_id.value += "___";
-			    document.forms[0].wms_title.value += "___";
-			    document.forms[0].legendurl.value += "___";
-				}
-				
-				//document.forms[0].layers.value += pt.mb_mapObj[ind].wms[i].objLayer[ii].layer_title; //pt.mb_mapObj[ind].layers[i]	;
-				
-				document.forms[0].wms_id.value += pt.mb_mapObj[ind].wms[i].wms_id;   
-				document.forms[0].wms_title.value += pt.mb_mapObj[ind].wms[i].wms_title;
-				
-				//---------- legendurl ----------
-				tmp_name = "";
-				for(var j=0; j<layer.length; j++){
-				 if(layerparent[j] == 0){
-					if(j>0){
-						document.forms[0].layers.value += ",";
-					}
-	
-					var l = pt.mb_getchildsbyname(ind,i,layer[j]);
-	
-				 	if (l) {
-				 		document.forms[0].layers.value += title[j];
-	
-				 		if(j>0){
-							document.forms[0].legendurl.value += ",";
-						}
-						for (var k=0; k<l["name"].length; k++){
-					 		if (tmp_name != l["title"][k]) {
-					 		    document.forms[0].layers.value += "*"
-					 			if(k>0){
-					 				 document.forms[0].legendurl.value += "*";
-					 			}else{
-					 				 document.forms[0].legendurl.value += '1*';
-					 			}
-	
-								if (l["legendurl"][k] != '' || !l["legendurl"][k]==true){
-									document.forms[0].layers.value += l["name"][k];
-					  				document.forms[0].legendurl.value += l["legendurl"][k];
-								}else{
-									document.forms[0].layers.value += '0';
-									document.forms[0].legendurl.value += '0';
-								}
-								tmp_name = l["title"][k];
-					 		}	// if
-						 } // for var k=0
-	
-					} // if (l) 
-					else{
-						//prompt (!temp_legendurl[j] ,temp_legendurl[j] + !temp_legendurl[j]);
-	
-							document.forms[0].layers.value += title[j];
-							if(j>0){
-								document.forms[0].legendurl.value += ",";
-							}
-							if (temp_legendurl[j]!= '' || !temp_legendurl[j] == 'true'){
-								document.forms[0].legendurl.value += temp_legendurl[j];
-							}else{
-								document.forms[0].legendurl.value +='0';
-							}
-						
-					}// else (l) 
-				   }//check parent==0
-				}//for var j=0
-				
-				//-------------------
-	
-				//document.forms[0].legendurl.value += layers[3];
-		
-			} else{
-				 if(i>0 && document.forms[0].wms_id.value!=''){
-			    document.forms[0].layers.value += "___";
-			    document.forms[0].wms_id.value += "___";
-			    document.forms[0].wms_title.value += "___";
-			    document.forms[0].legendurl.value += "___";
-				}
-				
-				document.forms[0].layers.value += "0";
-			    document.forms[0].wms_id.value += "0";
-			    document.forms[0].wms_title.value += "0";
-			    document.forms[0].legendurl.value += "0";
-			}
-		}//if
-	}//for
-}
-
-function validate(){
-	size = document.form1.size.options[document.form1.size.selectedIndex].value;
-	format = document.form1.format.options[document.form1.format.selectedIndex].value;
-	if(size != "" && format != ""){
-		var ind = pt.getMapObjIndexByName(target);
-		var coord = pt.mb_mapObj[ind].extent.split(",");
-		var centerX = parseFloat(coord[0]) + (parseFloat(coord[2]) - parseFloat(coord[0]))/2
-		var centerY = parseFloat(coord[1]) + (parseFloat(coord[3]) - parseFloat(coord[1]))/2
-		if(size == "A4" && format == "portrait"){
-			map_width = <?php echo $a4p_map_width; ?>; 
-			map_height = <?php echo $a4p_map_height; ?>; 
-		}
-		if(size == "A4" && format == "landscape"){
-			map_width = <?php echo $a4l_map_width; ?>;
-			map_height = <?php echo $a4l_map_height; ?>; 
-		}
-		if(size == "A3" && format == "portrait"){
-			map_width = <?php echo $a3p_map_width; ?>;
-			map_height = <?php echo $a3p_map_height; ?>;
-		}
-		if(size == "A3" && format == "landscape"){
-			map_width = <?php echo $a3l_map_width; ?>;
-			map_height = <?php echo $a3l_map_height; ?>;
-		}  
-		if(size == "A2" && format == "portrait"){
-			map_width = <?php echo $a2p_map_width; ?>;
-			map_height = <?php echo $a2p_map_height; ?>;
-		}
-		if(size == "A2" && format == "landscape"){
-			map_width = <?php echo $a2l_map_width; ?>;
-			map_height = <?php echo $a2l_map_height; ?>;
-		}     
-		var pos = pt.makeClickPos2RealWorldPos(target, map_width , map_height);
-		pt.mb_mapObj[ind].extent = coord[0] + "," + pos[1] + "," + pos[0] + "," +  coord[3];
-
-		pt.mb_mapObj[ind].width = Math.round(map_width);
-		pt.mb_mapObj[ind].height = Math.round(map_height);
-		pt.document.getElementById(target).style.width = Math.round(map_width);
-		pt.document.getElementById(target).style.height = Math.round(map_height);
-		pt.window.frames[target].document.getElementById("maps").style.width = Math.round(map_width);
-		pt.window.frames[target].document.getElementById("maps").style.height = Math.round(map_height);
-
-		//pt.setMapRequest(target);		
-		pt.mb_repaintScale(target, null, null, pt.mb_getScale(target));
-      	document.form1.map_url.value = '';
-		for(var i=0; i<pt.mb_mapObj[ind].wms.length; i++){
-			if(pt.mb_mapObj[ind].wms[i].gui_wms_visible > 0){
-				if(pt.mb_mapObj[ind].wms[i].mapURL != false && pt.mb_mapObj[ind].wms[i].mapURL != 'false' && pt.mb_mapObj[ind].wms[i].mapURL != ''){   
-					if(document.form1.map_url.value != ""){
-						document.form1.map_url.value += "___";
-					}         
-					document.form1.map_url.value += pt.mb_mapObj[ind].wms[i].mapURL;
-				}
-			}
-		}
-		
-		//overview_url
-		var ind_overview = pt.getMapObjIndexByName('overview');
-
-		//alert ("länge: " + length+ " - " + ind_overview + name + pt.mb_mapObj[ind_overview].wms.length);
-		if(pt.mb_mapObj[ind_overview].mapURL != false ){
-			document.forms[0].overview_url.value = pt.mb_mapObj[ind_overview].mapURL;
-		}
-	}
-}
-function refreshParams(){
-	var ind = pt.getMapObjIndexByName(target);
-	var f = document.form1;
-	f.map_url.value = "";
-	for(var i=0; i<pt.mb_mapObj[ind].wms.length; i++){
-		if(pt.mb_mapObj[ind].wms[i].gui_wms_visible > 0){
-			if(pt.mb_mapObj[ind].wms[i].mapURL != false && pt.mb_mapObj[ind].wms[i].mapURL != 'false' && pt.mb_mapObj[ind].wms[i].mapURL != ''){
-				if(f.map_url.value != ""){
-					f.map_url.value += "___";
-				}      
-				f.map_url.value += pt.mb_mapObj[ind].wms[i].mapURL;
-			}
-		}
-	}
-	f.map_scale.value = pt.mb_getScale(target);
-	mod_legend_print();
-}
-function printMap(){
-	if(size != "" && (format == "portrait" || format == "landscape")){
-		refreshParams();
-		if(document.form1.c1.value != comment){
-			document.form1.comment1.value = document.form1.c1.value;
-		}
-		if(document.form1.c2.value != comment){
-			document.form1.comment2.value = document.form1.c2.value;
-		}
-		if(document.form1.mylegendcheckbox.checked == 0){
-			document.form1.mylegend.value = 'false';
-		}else{
-			document.form1.mylegend.value = 'true';
-		}
-		
-		document.form1.submit();
-	}
-	else{
-		alert("Das Format ist noch nicht ausgewählt.");
-	}
-}
-function valCom(obj){
-	if(obj.value.length > comment_length){
-		obj.value = obj.value.substr(0,comment_length);
-	}
-}
-// -->
-</script>
-<body>
-<form name='form1' method='POST' action='../print/mod_printPDF_pdf.php?<?php echo SID; ?>' target="_blank">
-<table border='0'>
-<tr>
-	<td>
-	<select name='size' onchange='validate()'>
-<?php
-	if($a4 == true && $a3 == true){
-		echo "<option value=''>".$label_format."</option>";
-	}
-	if($a4 == true){
-		echo "<option value='A4'>".$label_format_a4."</option>";
-	}
-	if($a3 == true){
-		echo "<option value='A3'>".$label_format_a3."</option>";
-	}
-	if($a2 == true){
-		echo "<option value='A2'>".$label_format_a2."</option>";
-	}
-?>
-	</select>
-	</td>   
-</tr>
-<tr>
-	<td>
-	<select name='format' onchange='validate()'>
-	<option value=''><?php echo $label_orientation; ?></option>
-	<option value='portrait'><?php echo $label_portrait; ?></option>
-	<option value='landscape'><?php echo $label_landscape; ?></option>
-	</select>
-	</td>
-</tr>
-<?php
-if($highquality == true){
-	echo "<tr>";
-		echo "<td>";
-		echo "<select name='quality'>";
-		echo "<option value='1'>".$label_72dpi."</option>";
-		echo "<option value='2'>".$label_288dpi."</option>";
-		echo "</select>";
-		echo "</td>";
-	echo "</tr>";
-}
-?>
-<tr>
-	<td>
-		<input type='text' name='c1' value='<?php echo $label_comment; ?>' onkeydown="valCom(this)">
-	</td>
-</tr>
-<tr>
-	<td>
-		<input type='text' name='c2' value='<?php echo $label_comment; ?>' onkeydown="valCom(this)">
-	</td>
-</tr>
-<?php
-if($legend == true){
-	echo "<tr>";
-		echo "<td>";
-		echo "<div><input type='checkbox' class='mycheck' name='mylegendcheckbox' value='false'>".$label_legend."</div>";
-		echo "</td>";
-	echo "</tr>";
-}
-?>
-<table>  
-<input type='hidden' name='map_url' value=''>
-<input type='hidden' name='overview_url' value=''>
-<input type='hidden' name='wms_title' value=''>
-<input type='hidden' name='wms_id' value=''>
-<input type='hidden' name='layers' value=''>
-<input type='hidden' name='legendurl' value=''>
-<input type='hidden' name='map_scale' value=''>
-<input type='button' name='print' value="<?php echo $label_button; ?>" onclick='printMap()'>
-<input type='hidden' name='conf' value='<?php echo $_REQUEST["conf"]; ?>'>
-<input type='hidden' name='comment1' value=''>
-<input type='hidden' name='comment2' value=''>
-<input type='hidden' name='mylegend' value='true'>
-
-</form>
-</body>
-</html>
+<?php
+# $Id: mod_printPDF.php
+# http://www.mapbender.org/index.php/mod_printPDF.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");
+
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+<head>
+<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>Print PDF</title>
+</head>
+<style type="text/css">
+<!-- 
+select{
+   width:150px;
+} 
+input{
+	width:150px;
+}
+.mycheck{
+	width:15px;
+}
+div{
+	font-family : Arial, Helvetica, sans-serif;
+	font-size: 12px;
+}
+-->
+</style>
+<?php
+
+//FIXME:
+//setlocale(LC_ALL, "de_DE.utf8");
+
+require_once(dirname(__FILE__)."/../print/".$_REQUEST["conf"]);
+echo "<script type='text/javascript'>";
+echo "var target = '".$_REQUEST["target"]."';";
+echo "var comment = '".$label_comment."';";
+echo "var comment_length = ".$comment_length.";";
+echo "var label_button = '".$label_button."';";
+echo "var type = '".$type."';";
+echo "</script>";
+?>
+<script type="text/javascript">
+<!--
+
+
+var size;
+var format;
+var map_width;
+var map_height;
+
+if(type=='window'){
+	var pt = window.opener;
+}
+else if(type == 'iframe'){
+	var pt = parent;
+}
+
+function mod_legend_print(){
+	var mod_legend_target = target;
+	var ind = pt.getMapObjIndexByName(mod_legend_target);
+	var layers;
+
+	document.forms[0].layers.value = "";
+	document.forms[0].wms_id.value = "";
+	document.forms[0].wms_title.value = "";
+	document.forms[0].legendurl.value = "";
+	
+	for(var i=0; i<pt.mb_mapObj[ind].wms.length; i++){
+		layers = pt.mb_mapObj[ind].wms[i].getLayers(pt.mb_mapObj[ind]);
+		if(layers != "" && layers){
+		
+			if(i>0 && document.forms[0].wms_id.value!=''){
+			    document.forms[0].layers.value += "___";
+			    document.forms[0].wms_id.value += "___";
+			    document.forms[0].wms_title.value += "___";
+			    document.forms[0].legendurl.value += "___";
+			}
+					
+			document.forms[0].wms_id.value += pt.mb_mapObj[ind].wms[i].wms_id;   
+			document.forms[0].wms_title.value += pt.mb_mapObj[ind].wms[i].wms_title;
+				
+			for(var j=0; j<layers.length; j++){			
+				var layer = layers[j];
+				var title = pt.mb_mapObj[ind].wms[i].getTitleByLayerName(layers[j]);
+				var layerStyle = pt.mb_mapObj[ind].wms[i].getCurrentStyleByLayerName(layers[j]);
+				if(layerStyle==false){
+					var temp_legendurl = pt.mb_mapObj[ind].wms[i].getLegendUrlByGuiLayerStyle(layers[j],"default");	
+				}
+				else{
+					var temp_legendurl = pt.mb_mapObj[ind].wms[i].getLegendUrlByGuiLayerStyle(layers[j],layerStyle);
+				}
+				
+				//---------- legendurl ----------
+				tmp_name = "";	
+				if(j>0){
+					document.forms[0].layers.value += ",";
+				}
+					document.forms[0].layers.value += title;
+				if(j>0){
+					document.forms[0].legendurl.value += ",";
+				}
+				if (temp_legendurl!= '' || !temp_legendurl == 'true'){
+					document.forms[0].legendurl.value += temp_legendurl;
+				}else{
+					document.forms[0].legendurl.value +='0';
+				}	
+			}	
+		}
+		else{
+			if(i>0 && document.forms[0].wms_id.value!=''){
+			    document.forms[0].layers.value += "___";
+			    document.forms[0].wms_id.value += "___";
+			    document.forms[0].wms_title.value += "___";
+			    document.forms[0].legendurl.value += "___";
+		    }
+			
+			document.forms[0].layers.value += "0";
+		    document.forms[0].wms_id.value += "0";
+		    document.forms[0].wms_title.value += "0";
+		    document.forms[0].legendurl.value += "0";
+		}
+	}//for
+	//alert(document.forms[0].layers.value+"---"+document.forms[0].wms_id.value+"---"+document.forms[0].wms_title.value+"---"+document.forms[0].legendurl.value);	
+		
+}
+
+function validate(){
+	size = document.form1.size.options[document.form1.size.selectedIndex].value;
+	format = document.form1.format.options[document.form1.format.selectedIndex].value;
+	if(size != "" && format != ""){
+		var ind = pt.getMapObjIndexByName(target);
+		var coord = pt.mb_mapObj[ind].extent.split(",");
+		var centerX = parseFloat(coord[0]) + (parseFloat(coord[2]) - parseFloat(coord[0]))/2
+		var centerY = parseFloat(coord[1]) + (parseFloat(coord[3]) - parseFloat(coord[1]))/2
+		if(size == "A4" && format == "portrait"){
+			map_width = <?php echo $a4p_map_width; ?>; 
+			map_height = <?php echo $a4p_map_height; ?>; 
+		}
+		if(size == "A4" && format == "landscape"){
+			map_width = <?php echo $a4l_map_width; ?>;
+			map_height = <?php echo $a4l_map_height; ?>; 
+		}
+		if(size == "A3" && format == "portrait"){
+			map_width = <?php echo $a3p_map_width; ?>;
+			map_height = <?php echo $a3p_map_height; ?>;
+		}
+		if(size == "A3" && format == "landscape"){
+			map_width = <?php echo $a3l_map_width; ?>;
+			map_height = <?php echo $a3l_map_height; ?>;
+		}  
+		if(size == "A2" && format == "portrait"){
+			map_width = <?php echo $a2p_map_width; ?>;
+			map_height = <?php echo $a2p_map_height; ?>;
+		}
+		if(size == "A2" && format == "landscape"){
+			map_width = <?php echo $a2l_map_width; ?>;
+			map_height = <?php echo $a2l_map_height; ?>;
+		}
+		if(size == "A1" && format == "portrait"){
+			map_width = <?php echo $a1p_map_width; ?>;
+			map_height = <?php echo $a1p_map_height; ?>;
+		}
+		if(size == "A1" && format == "landscape"){
+			map_width = <?php echo $a1l_map_width; ?>;
+			map_height = <?php echo $a1l_map_height; ?>;
+		}
+		if(size == "A0" && format == "portrait"){
+			map_width = <?php echo $a0p_map_width; ?>;
+			map_height = <?php echo $a0p_map_height; ?>;
+		}
+		if(size == "A0" && format == "landscape"){
+			map_width = <?php echo $a0l_map_width; ?>;
+			map_height = <?php echo $a0l_map_height; ?>;
+		}     
+		var pos = pt.makeClickPos2RealWorldPos(target, map_width , map_height);
+		pt.mb_mapObj[ind].extent = coord[0] + "," + pos[1] + "," + pos[0] + "," +  coord[3];
+
+		pt.mb_mapObj[ind].width = Math.round(map_width);
+		pt.mb_mapObj[ind].height = Math.round(map_height);
+		pt.document.getElementById(target).style.width = Math.round(map_width);
+		pt.document.getElementById(target).style.height = Math.round(map_height);
+		pt.window.frames[target].document.getElementById("maps").style.width = Math.round(map_width);
+		pt.window.frames[target].document.getElementById("maps").style.height = Math.round(map_height);
+
+		//pt.setMapRequest(target);		
+		pt.mb_repaintScale(target, null, null, pt.mb_getScale(target));
+      	document.form1.map_url.value = '';
+		for(var i=0; i<pt.mb_mapObj[ind].wms.length; i++){
+			if(pt.mb_mapObj[ind].wms[i].gui_wms_visible > 0){
+				if(pt.mb_mapObj[ind].wms[i].mapURL != false && pt.mb_mapObj[ind].wms[i].mapURL != 'false' && pt.mb_mapObj[ind].wms[i].mapURL != ''){   
+					if(document.form1.map_url.value != ""){
+						document.form1.map_url.value += "___";
+					}         
+					document.form1.map_url.value += pt.mb_mapObj[ind].wms[i].mapURL;
+				}
+			}
+		}
+		
+		//overview_url
+		var ind_overview = pt.getMapObjIndexByName('overview');
+
+		//alert ("l�nge: " + length+ " - " + ind_overview + name + pt.mb_mapObj[ind_overview].wms.length);
+		if(pt.mb_mapObj[ind_overview].mapURL != false ){
+			document.forms[0].overview_url.value = pt.mb_mapObj[ind_overview].mapURL;
+		}
+	}
+}
+function refreshParams(){
+	var ind = pt.getMapObjIndexByName(target);
+	var f = document.form1;
+	f.map_url.value = "";
+	for(var i=0; i<pt.mb_mapObj[ind].wms.length; i++){
+		if(pt.mb_mapObj[ind].wms[i].gui_wms_visible > 0){
+			if(pt.mb_mapObj[ind].wms[i].mapURL != false && pt.mb_mapObj[ind].wms[i].mapURL != 'false' && pt.mb_mapObj[ind].wms[i].mapURL != ''){
+				if(f.map_url.value != ""){
+					f.map_url.value += "___";
+				}      
+				f.map_url.value += pt.mb_mapObj[ind].wms[i].mapURL;
+			}
+		}
+	}
+	f.map_scale.value = pt.mb_getScale(target);
+	f.epsg.value = pt.mb_mapObj[ind].epsg;
+	mod_legend_print();
+}
+function printMap(){
+	if(size != "" && (format == "portrait" || format == "landscape")){
+		refreshParams();
+		if(document.form1.c1.value != comment){
+			document.form1.comment1.value = document.form1.c1.value;
+		}
+		if(document.form1.c2.value != comment){
+			document.form1.comment2.value = document.form1.c2.value;
+		}
+		if(document.form1.mylegendcheckbox.checked == 0){
+			document.form1.mylegend.value = 'false';
+		}else{
+			document.form1.mylegend.value = 'true';
+		}
+		
+		// write the measured coordinates
+		
+		if (pt.mod_measure_RX != undefined && pt.mod_measure_RY != undefined) {
+			var tmp_x = '';
+			var tmp_y = '';
+			for(i = 0; i<pt.mod_measure_RX.length; i++) {
+				if(tmp_x != '') {
+					tmp_x += ','
+				}
+				tmp_x += pt.mod_measure_RX[i];
+			}
+			for(i = 0; i<pt.mod_measure_RY.length; i++) {
+				if(tmp_y != '') {
+					tmp_y += ','
+				}
+				tmp_y += pt.mod_measure_RY[i];
+			}
+			document.forms['form1'].elements['measured_x_values'].value = tmp_x;
+			document.forms['form1'].elements['measured_y_values'].value = tmp_y;
+		}
+		
+		document.form1.submit();
+	}
+	else{
+		alert("<?php echo _("No format selected.")?>");
+	}
+}
+function valCom(obj){
+	if(obj.value.length > comment_length){
+		obj.value = obj.value.substr(0,comment_length);
+	}
+}
+// -->
+</script>
+<body>
+<form name='form1' method='POST' action='../print/mod_printPDF_pdf.php?<?php echo SID; ?>' target="_blank">
+<table border='0'>
+<tr>
+	<td>
+	<select name='size' onchange='validate()'>
+<?php
+	if($a4 == true && $a3 == true){
+		echo "<option value=''>".$label_format."</option>";
+	}
+	if($a4 == true){
+		echo "<option value='A4'>".$label_format_a4."</option>";
+	}
+	if($a3 == true){
+		echo "<option value='A3'>".$label_format_a3."</option>";
+	}
+	if($a2 == true){
+		echo "<option value='A2'>".$label_format_a2."</option>";
+	}
+	if($a1 == true){
+		echo "<option value='A1'>".$label_format_a1."</option>";
+	}
+	if($a0 == true){
+		echo "<option value='A0'>".$label_format_a0."</option>";
+	}
+?>
+	</select>
+	</td>   
+</tr>
+<tr>
+	<td>
+	<select name='format' onchange='validate()'>
+	<option value=''><?php echo $label_orientation; ?></option>
+	<option value='portrait'><?php echo $label_portrait; ?></option>
+	<option value='landscape'><?php echo $label_landscape; ?></option>
+	</select>
+	</td>
+</tr>
+<?php
+if($highquality == true){
+	echo "<tr>";
+		echo "<td>";
+		echo "<select name='quality'>";
+		echo "<option value='1'>".$label_72dpi."</option>";
+		echo "<option value='2'>".$label_288dpi."</option>";
+		echo "</select>";
+		echo "</td>";
+	echo "</tr>";
+}
+?>
+<tr>
+	<td>
+		<input type='text' name='c1' value='<?php echo $label_comment; ?>' onkeydown="valCom(this)">
+	</td>
+</tr>
+<tr>
+	<td>
+		<input type='text' name='c2' value='<?php echo $label_comment; ?>' onkeydown="valCom(this)">
+	</td>
+</tr>
+<?php
+if($legend == true){
+	echo "<tr>";
+		echo "<td>";
+		echo "<div><input type='checkbox' class='mycheck' name='mylegendcheckbox' value='false'>".$label_legend."</div>";
+		echo "</td>";
+	echo "</tr>";
+}else {
+	echo "<tr>";
+	echo "<td>";
+	echo "<input type='hidden' name='mylegendcheckbox' value='false'>";
+	echo "</td>";
+	echo "</tr>";
+}
+
+
+?>
+<table>  
+<input type='hidden' name='map_url' value=''>
+<input type='hidden' name='overview_url' value=''>
+<input type='hidden' name='wms_title' value=''>
+<input type='hidden' name='wms_id' value=''>
+<input type='hidden' name='layers' value=''>
+<input type='hidden' name='legendurl' value=''>
+<input type='hidden' name='map_scale' value=''>
+<input type='hidden' name='epsg' value=''>
+<input type='button' name='print' value="<?php echo $label_button; ?>" onclick='printMap()'>
+<input type='hidden' name='conf' value='<?php echo $_REQUEST["conf"]; ?>'>
+<input type='hidden' name='comment1' value=''>
+<input type='hidden' name='comment2' value=''>
+<input type='hidden' name='mylegend' value='true'>
+<input type='hidden' name='measured_x_values' value=''>
+<input type='hidden' name='measured_y_values' value=''>
+
+</form>
+</body>
+</html>

Modified: branches/mapbender_sld/http/print/mod_printPDF_pdf.php
===================================================================
--- branches/mapbender_sld/http/print/mod_printPDF_pdf.php	2007-11-23 13:08:46 UTC (rev 1828)
+++ branches/mapbender_sld/http/print/mod_printPDF_pdf.php	2007-11-23 13:14:53 UTC (rev 1829)
@@ -1,753 +1,853 @@
-<?php
-# $Id:
-# http://www.mapbender.org/index.php/mod_printPDF_pdf.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("../php/mb_validateSession.php");
-ob_start();
-session_start();
-ini_set('error_reporting', 'E_ALL & ~ E_NOTICE');
-require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
-
-include (dirname(__FILE__)."/../classes/class.ezpdf.php");
-include (dirname(__FILE__)."/../classes/class_stripRequest.php");
-include (dirname(__FILE__)."/../classes/class_weldMaps2PNG.php");
-include (dirname(__FILE__)."/../classes/class_weldOverview2PNG.php");
-include (dirname(__FILE__)."/../print/".$_REQUEST["conf"]);
-include (dirname(__FILE__)."/../classes/class_SaveLegend.php");
-if($log == true){
-	include (dirname(__FILE__)."/../classes/class_log.php");
-}
-
-#Globals
-
-$factor = intval($_REQUEST["quality"]);
-
-#$date = date("d.m.Y",strtotime("now"));
-$linewidth_dashed = 0.5;
-$linewidth = 0.5;
-
-// DURATION TIME:
-function microtime_float(){
-   list($usec, $sec) = explode(" ", microtime());
-   return ((float)$usec + (float)$sec);
-}
-$time_start = microtime_float();
-// END DURATION TIME
-
-$time_end = microtime_float();
-$time = $time_end - $time_start;
-
-/* -------------------------------------- */
-
-$size = $_REQUEST["size"];
-$format = $_REQUEST["format"];
-$map_scale = $_REQUEST["map_scale"];
-$overview_url = $_REQUEST["overview_url"];
-
-function setscalebar($scale){
-    	$mb_resolution = 28.35;
-        
-		if($scale < 16){
-	      $value = "10";
-	      $unit = "cm";
-	      $scalefactor = 10/$scale;
-	      $img_width = round($scalefactor * $mb_resolution);
-	   }
-	   if($scale >= 16 && $scale < 151){
-	      $value = "1";	      
-	      $unit = "Meter";
-	      $scalefactor = 100/$scale;
-	      $img_width = round($scalefactor * $mb_resolution);
-	   }
-	   if($scale >= 151 && $scale < 1550 ){
-	      $value = "10";	      
-	      $unit = "Meter";
-	      $scalefactor = 1000/$scale;
-	      $img_width = round($scalefactor * $mb_resolution);
-	   }
-	   if($scale >= 1550 && $scale < 15050){
-	      $value = "100";	      
-	      $unit = "Meter";
-	      $scalefactor = 10000/$scale;
-	      $img_width = round($scalefactor * $mb_resolution);
-	   }
-	   if($scale < 150050 && $scale >= 15050){
-	      $value = "1";	      
-	      $unit = "Kilometer";
-	      $scalefactor = 100000/$scale;
-	      $img_width = round($scalefactor * $mb_resolution);
-	   }
-	   if($scale < 1500050 && $scale >= 150050){
-	      $value = "10";	      
-	      $unit = "Kilometer";
-	      $scalefactor = 1000000/$scale;
-	      $img_width = round($scalefactor * $mb_resolution);
-	   }
-	   if($scale < 15000050 && $scale >= 1500050){
-	      $value = "100";	      
-	      $unit = "Kilometer";
-	      $scalefactor = 10000000/$scale;
-	      $img_width = round($scalefactor * $mb_resolution);
-	   }
-	   if($scale < 150000001 && $scale >= 15000001){
-	      $value = "1000";	      
-	      $unit = "Kilometer";
-	      $scalefactor = 100000000/$scale;
-	      $img_width = round($scalefactor * $mb_resolution);
-	   }
-	   if($scale >= 150000001){
-	      $value = "1000";	      
-	      $unit = "Kilometer";
-	      $scalefactor = 100000000/$scale;
-	      $img_width = round($scalefactor * $mb_resolution);
-	   }   
-	   $array_scale[0] = $unit;
-	   $array_scale[1] = $img_width;
-		$array_scale[2] = $value;	   
-	   
-	   return  $array_scale; 
-}
-
-
-$border = 0.8 * $DPC;
-
-if($matching == true){
-   $urls = str_replace($pattern,$replacement,$_REQUEST["map_url"]);  
-}
-else{
-   $urls = $_REQUEST["map_url"];
-}
-
-
-$array_urls = explode("___", $urls);
-
-$myURL = new stripRequest($array_urls[0]);
-$map_width = round($myURL->get("width"));
-$map_height = round($myURL->get("height"));
-$map_extent = $myURL->get("BBOX");
-if($factor>1){
-	for($i=0; $i<count($array_urls); $i++){
-		$m = new stripRequest($array_urls[$i]);
-		$m->set('width',(intval($m->get('width'))*4));
-		$m->set('height',(intval($m->get('height'))*4));
-		if(in_array($m->get('map'),$highqualitymapfiles)){	
-			$m->set('map',str_replace(".map","_4.map",$m->get('map')));			
-		}
-		$array_urls[$i] = $m->url;
-	}
-}
-$coord = split(",",$map_extent);
-
-// analyse overview url and draw rectangle with position
-$o_url = new stripRequest($overview_url);
-$overview_width = round($o_url->get("width"));
-$overview_height = round($o_url->get("height"));
-
-if($factor>1){
-	$o_url->set('width',(intval($o_url->get('width'))*4));
-	$o_url->set('height',(intval($o_url->get('height'))*4));
-	if(in_array($o_url->get('map'),$highqualitymapfiles)){	
-			$o_url->set('map',str_replace(".map","_4.map",$o_url->get('map')));		
-			$overview_url = $o_url->url;	
-	}
-}
-
-if($matching == true){
-	$overview_url = str_replace($pattern,$replacement,$overview_url);  
-}
-
-
-if ($size == "A4" && $format == "portrait"){
-	$overview_left = $a4p_overviewOffset_left;
-	$overview_bottom =$a4p_overviewOffset_bottom;
-}elseif ($size == "A4" && $format == "landscape"){
-	$overview_left = $a4l_overviewOffset_left;
-	$overview_bottom =$a4l_overviewOffset_bottom;
-}elseif ($size == "A3" && $format == "portrait"){
-	$overview_left = $a3p_overviewOffset_left;
-	$overview_bottom =$a3p_overviewOffset_bottom;
-}elseif ($size == "A3" && $format == "landscape"){
-	$overview_left = $a3l_overviewOffset_left;
-	$overview_bottom = $a3l_overviewOffset_bottom;
-}elseif ($size == "A2" && $format == "portrait"){
-	$overview_left = $a2p_overviewOffset_left;
-	$overview_bottom =$a2p_overviewOffset_bottom;
-}elseif ($size == "A2" && $format == "landscape"){
-	$overview_left = $a2l_overviewOffset_left;
-	$overview_bottom = $a2l_overviewOffset_bottom;
-}
-
-$o_extent = $o_url->get("BBOX");
-
-$array_overview_url[0] = $overview_url;
-if($log == true){
-	$l = new log("printPDF_overview",$array_overview_url);
-}
-
-/*
-$o_new = new stripRequest($overview_url);
-$o_new->set('width',50);
-$o_new->set('height',50);
-//$o->set('BBOX',$overview_extent);
-$o_url_new =$o_new->url;
-$array_overview[0] = $overview_url;
-$array_overview[1] = $o_url;
-*/
-
-/*
- * north arrow
- */
-if($size == "A4" && $format == "portrait"){
-	$northarrow_left = $a4p_northarrow_left;
-	$northarrow_bottom = $a4p_northarrow_bottom;
-}elseif ($size == "A4" && $format == "landscape"){
-	$northarrow_left = $a4l_northarrow_left;
-	$northarrow_bottom = $a4l_northarrow_bottom;
-}elseif ($size == "A3" && $format == "portrait"){
-	$northarrow_left = $a3p_northarrow_left;
-	$northarrow_bottom = $a3p_northarrow_bottom;
-}elseif ($size == "A3" && $format == "landscape"){
-	$northarrow_left = $a3l_northarrow_left;
-	$northarrow_bottom = $a3l_northarrow_bottom;
-}elseif ($size == "A2" && $format == "portrait"){
-	$northarrow_left = $a2p_northarrow_left;
-	$northarrow_bottom = $a2p_northarrow_bottom;
-}elseif ($size == "A2" && $format == "landscape"){
-	$northarrow_left = $a2l_northarrow_left;
-	$northarrow_bottom = $a2l_northarrow_bottom;
-}
-
-/*
- * special image
- */
-if ($size == "A4" && $format == "portrait"){
-	$specialImage_left = $a4p_special_left;
-	$specialImage_bottom = $a4p_special_bottom;
-}elseif ($size == "A4" && $format == "landscape"){
-	$specialImage_left = $a4l_special_left;
-	$specialImage_bottom = $a4l_special_bottom;
-}elseif ($size == "A3" && $format == "portrait"){
-	$specialImage_left = $a3p_special_left;
-	$specialImage_bottom = $a3p_special_bottom;
-}elseif ($size == "A3" && $format == "landscape"){
-	$specialImage_left = $a3l_special_left;
-	$specialImage_bottom = $a3l_special_bottom;
-}elseif ($size == "A2" && $format == "portrait"){
-	$specialImage_left = $a2p_special_left;
-	$specialImage_bottom = $a2p_special_bottom;
-}elseif ($size == "A2" && $format == "landscape"){
-	$specialImage_left = $a2l_special_left;
-	$specialImage_bottom = $a2l_special_bottom;
-}
-
-if($log == true){
-	$l = new log("printPDF",$array_urls);
-}
-$pdf = new Cezpdf();
-
-$pdf->Cezpdf(strtolower($size),$format);
-$diff=array(196=>'Adieresis',228=>'adieresis',
-   214=>'Odieresis',246=>'odieresis',
-   220=>'Udieresis',252=>'udieresis',
-   223=>'germandbls');
-$pdf->selectFont('../classes/fonts/Helvetica.afm', array('encoding'=>'WinAnsiEncoding','differences'=>$diff));
-if($size == "A4" && $format == "portrait"){
-	$mapOffset_left = $a4p_mapOffset_left;
-	$mapOffset_bottom = $a4p_mapOffset_bottom;
-	$header_height = $a4p_header_height;
-	$footer_height = $a4p_footer_height;
-}
-else{
-	$mapOffset_left = $a4l_mapOffset_left;
-	$mapOffset_bottom = $a4l_mapOffset_bottom;
-	$header_height = $a4l_header_height;
-	$header_width = $a4l_header_width;
-}
-session_write_close();
-$i = new weldMaps2PNG(implode("___",$array_urls),$filename);
-
-$pdf->addPngFromFile($filename, $mapOffset_left, $mapOffset_bottom, $map_width, $map_height);
-if($unlink == true){
-	unlink($filename);
-}
-
-
-# dashed line
-$pdf->setLineStyle($linewidth_dashed, '','', array(2,2));
-$pdf->line($mapOffset_left - $linewidth_dashed, $mapOffset_bottom - $linewidth_dashed, $mapOffset_left - $linewidth_dashed, $mapOffset_bottom  + $map_height + $linewidth_dashed);
-$pdf->line($mapOffset_left - $linewidth_dashed, $mapOffset_bottom  + $map_height + $linewidth_dashed, $mapOffset_left + $map_width + $linewidth_dashed, $mapOffset_bottom + $map_height + $linewidth_dashed);
-$pdf->line($mapOffset_left + $map_width + $linewidth_dashed, $mapOffset_bottom + $map_height + $linewidth_dashed, $mapOffset_left + $map_width + $linewidth_dashed, $mapOffset_bottom -$linewidth_dashed);
-$pdf->line($mapOffset_left + $map_width + $linewidth_dashed, $mapOffset_bottom -$linewidth_dashed, $mapOffset_left - $linewidth_dashed, $mapOffset_bottom - $linewidth_dashed);
-
-
-#line
-$pdf->setLineStyle($linewidth, '', '', array());
-$pdf->line($mapOffset_left - $border, $mapOffset_bottom - $border, $mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border);
-$pdf->line($mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border, $mapOffset_left + $map_width + $border, $mapOffset_bottom + $map_height + $border);
-$pdf->line($mapOffset_left + $map_width + $border, $mapOffset_bottom + $map_height + $border, $mapOffset_left + $map_width + $border, $mapOffset_bottom -$border);
-$pdf->line($mapOffset_left + $map_width + $border, $mapOffset_bottom -$border, $mapOffset_left - $border, $mapOffset_bottom - $border);
-
-
-if($size == "A4" && $format == "portrait"){
-   #header:
-   $pdf->line($mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border, $mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border + $header_height);
-   $pdf->line($mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border + $header_height, $mapOffset_left + $map_width + $border, $mapOffset_bottom  + $map_height + $border + $header_height);
-   $pdf->line($mapOffset_left + $map_width + $border, $mapOffset_bottom  + $map_height + $border + $header_height, $mapOffset_left + $map_width + $border, $mapOffset_bottom  + $map_height + $border);
-   $pdf->line( $mapOffset_left + $map_width/2, $mapOffset_bottom  + $map_height + $border, $mapOffset_left + $map_width/2, $mapOffset_bottom  + $map_height + $border + $header_height);
-   #header-text
-   $mySize = 9;
-   $length = $pdf->getTextWidth($mySize, $text1);
-   $pdf->addText($mapOffset_left - ($border/2) + ($map_width/4) - ($length/2),$mapOffset_bottom + $map_height + $border + 60,$mySize,$text1);
-
-   $mySize = 8;
-   $length = $pdf->getTextWidth($mySize, $text2);   
-   $pdf->addText($mapOffset_left - ($border/2) + ($map_width/4) - ($length/2),$mapOffset_bottom + $map_height + $border + 45,$mySize,$text2);
-   
-   $length = $pdf->getTextWidth($mySize, $text3);
-   $pdf->addText($mapOffset_left - ($border/2) + ($map_width/4) - ($length/2),$mapOffset_bottom + $map_height + $border + 35,$mySize,$text3);
-
-   $mySize = 9;
-   $length = $pdf->getTextWidth($mySize, $text4);   
-   $pdf->addText($mapOffset_left - ($border/2) + ($map_width/4) - ($length/2),$mapOffset_bottom + $map_height + $border + 20,$mySize,$text4);
-
-   $mySize = 8;
-   $length = $pdf->getTextWidth($mySize, $text5);   
-   $pdf->addText($mapOffset_left - ($border/2) + ($map_width/4) - ($length/2),$mapOffset_bottom + $map_height + $border + 10,$mySize,$text5);
-   
-   $mySize = 9;
-   $length = $pdf->getTextWidth($mySize, $text6);   
-   $pdf->addText($mapOffset_left + ($border/2) + ($map_width/4*3) - ($length/2),$mapOffset_bottom + $map_height + $border + 60,$mySize,$text6);
-   $length = $pdf->getTextWidth($mySize, $text7);   
-   $pdf->addText($mapOffset_left + ($border/2) + ($map_width/4*3) - ($length/2),$mapOffset_bottom + $map_height + $border + 50,$mySize,$text7);
-   $length = $pdf->getTextWidth($mySize, $text8);   
-   $pdf->addText($mapOffset_left + ($border/2) + ($map_width/4*3) - ($length/2),$mapOffset_bottom + $map_height + $border + 30,$mySize,$text8);
-   $length = $pdf->getTextWidth($mySize, $text9);   
-   $pdf->addText($mapOffset_left + ($border/2) + ($map_width/4*3) - ($length/2),$mapOffset_bottom + $map_height + $border + 20,$mySize,$text9);
-   $length = $pdf->getTextWidth($mySize, $text10);   
-   $pdf->addText($mapOffset_left + ($border/2) + ($map_width/4*3) - ($length/2),$mapOffset_bottom + $map_height + $border + 10,$mySize,$text10);
-   
-   //special image on the map-page
-   if ($special == true){
-   	$pdf->addPngFromFile($specialImage, $specialImage_left, $specialImage_bottom , $specialImage_width, $specialImage_height);
-   }
-   
-   #footer
-   $pdf->line($mapOffset_left - $border, $mapOffset_bottom - $border, $mapOffset_left - $border, $mapOffset_bottom - $border - $footer_height);
-   $pdf->line($mapOffset_left - $border, $mapOffset_bottom - $border - $footer_height, $mapOffset_left + $map_width + $border, $mapOffset_bottom - $border - $footer_height);
-   $pdf->line($mapOffset_left + $map_width + $border, $mapOffset_bottom - $border - $footer_height, $mapOffset_left + $map_width + $border, $mapOffset_bottom - $border);
-   
-   $mySize = 8;
-   $length = $pdf->getTextWidth($mySize, $text11);   
-   $pdf->addText( $mapOffset_left + $map_width/2 - ($length/2),$mapOffset_bottom - $border - 10,$mySize,$text11);
-   $mySize = 6;
-   $length = $pdf->getTextWidth($mySize, $text12);   
-   $pdf->addText( $mapOffset_left + $map_width/2 - ($length/2),$mapOffset_bottom - $border - 18,$mySize,$text12);
-   $length = $pdf->getTextWidth($mySize, $text13);
-   $pdf->addText( $mapOffset_left + $map_width/2 - ($length/2),$mapOffset_bottom - $border - 25,$mySize,$text13);
-}
-else{
-   $pdf->setColor(1,1,1);
-   $ll = array($mapOffset_left + $map_width - $header_width + $border - $linewidth, $mapOffset_bottom - $border + 1);
-   $pdf->filledRectangle($ll[0], $ll[1], $header_width,$header_height);
-   $pdf->line($ll[0], $ll[1], $ll[0], $ll[1] + $header_height);
-   $pdf->line($ll[0], $ll[1] + $header_height, $ll[0] + $header_width, $ll[1] + $header_height);
-
-   $pdf->line($ll[0] + 2, $ll[1] + 2, $ll[0] + 2,  $ll[1] + $header_height - 2);
-   $pdf->line($ll[0] + 2,  $ll[1] + $header_height - 2, $ll[0] - 2 + $header_width, $ll[1] + $header_height - 2);
-   $pdf->line($ll[0] - 2 + $header_width, $ll[1] + $header_height - 2, $ll[0] - 2 + $header_width, $ll[1] + 2);
-   $pdf->line($ll[0] - 2 + $header_width, $ll[1] + 2, $ll[0] + 2, $ll[1] + 2);
-   
-   $pdf->line($ll[0] + 2, $ll[1] + 110 , $ll[0] - 2 + $header_width, $ll[1] + 110);
-   $pdf->line($ll[0] + 2, $ll[1] + 40 , $ll[0] - 2 + $header_width, $ll[1] + 40);
-   
-   
-   //special image on the map-page
-   if ($special == true){
-   	$pdf->addPngFromFile($specialImage, $specialImage_left, $specialImage_bottom , $specialImage_width, $specialImage_height);
-   }
-   
-   $pdf->setColor(0,0,0);
-   $mySize = 9;
-   $length = $pdf->getTextWidth($mySize, $text1);   
-   $pdf->addText($ll[0] + $header_width/2 - $length/2,185,$mySize,$text1);
-   
-   $mySize = 8;
-   $length = $pdf->getTextWidth($mySize, $text2);   
-   $pdf->addText($ll[0] + $header_width/2 - $length/2,175,$mySize,$text2);
-   $length = $pdf->getTextWidth($mySize, $text3);   
-   $pdf->addText($ll[0] + $header_width/2 - $length/2,165,$mySize,$text3);
-   $mySize = 9;
-   $length = $pdf->getTextWidth($mySize, $text4);   
-   $pdf->addText($ll[0] + $header_width/2 - $length/2,155,$mySize,$text4);
-   $mySize = 8;
-   $length = $pdf->getTextWidth($mySize, $text5);   
-   $pdf->addText($ll[0] + $header_width/2 - $length/2,145,$mySize,$text5);   
-   
-   $mySize = 9;
-   $length = $pdf->getTextWidth($mySize, $text6);   
-   $pdf->addText($ll[0] + $header_width/2 - $length/2,125,$mySize,$text6);
-   $length = $pdf->getTextWidth($mySize, $text7);   
-   $pdf->addText($ll[0] + $header_width/2 - $length/2,115,$mySize,$text7);
-   $length = $pdf->getTextWidth($mySize, $text8);   
-   $pdf->addText($ll[0] + $header_width/2 - $length/2,95,$mySize,$text8);
-   $length = $pdf->getTextWidth($mySize, $text9);   
-   $pdf->addText($ll[0] + $header_width/2 - $length/2,85,$mySize,$text9);
-   $length = $pdf->getTextWidth($mySize, $text10);   
-   $pdf->addText($ll[0] + $header_width/2 - $length/2,75,$mySize,$text10);
-   
-   $mySize = 8;
-   $length = $pdf->getTextWidth($mySize, $text11);   
-   $pdf->addText($ll[0] + $header_width/2 - $length/2,60,$mySize,$text11); 
-   $mySize = 6;
-   $length = $pdf->getTextWidth($mySize, $text14);   
-   $pdf->addText($ll[0] + $header_width/2 - $length/2,53,$mySize,$text14);
-   $length = $pdf->getTextWidth($mySize, $text15);   
-   $pdf->addText($ll[0] + $header_width/2 - $length/2,47,$mySize,$text15);
-   $length = $pdf->getTextWidth($mySize, $text16);   
-   $pdf->addText($ll[0] + $header_width/2 - $length/2,41,$mySize,$text16);
-   $length = $pdf->getTextWidth($mySize, $text17);   
-   $pdf->addText($ll[0] + $header_width/2 - $length/2,35,$mySize,$text17);                             
-}
-#Coordinates
-$myMinx = "R ".substr(round($coord[0]), 0, 4)." ".substr(round($coord[0]), 4, 3)."";
-$myMiny = "H ".substr(round($coord[1]), 0, 4)." ".substr(round($coord[1]), 4, 3)."";
-$myMaxx = "R ".substr(round($coord[2]), 0, 4)." ".substr(round($coord[2]), 4, 3)."";
-$myMaxy = "H ".substr(round($coord[3]), 0, 4)." ".substr(round($coord[3]), 4, 3)."";
-
-$mySize = 9;
-$pdf->addText($mapOffset_left - 3, $mapOffset_bottom, $mySize, $myMinx, -90);
-$pdf->addText($mapOffset_left, $mapOffset_bottom  - ($pdf->getFontHeight($mySize)), $mySize, $myMiny);
-$pdf->addText($mapOffset_left  + $map_width - ($pdf->getTextWidth($mySize, $myMaxx)), $mapOffset_bottom + $map_height  + 3, $mySize, $myMaxx);
-$pdf->addText($mapOffset_left + $map_width + 3, $mapOffset_bottom + $map_height, $mySize, $myMaxy, 90);
-
-if ($overview==true){
-	// analyse request, draw rectancle
-	$filename = str_replace("map_","overview_",$filename);
-	if($size == "A4" && $format == "portrait"){
-		$i = new weldOverview2PNG($overview_url,$array_urls[0] ,$filename);
-
-		$pdf->addPngFromFile($filename, $overview_left,$overview_bottom, $overview_width, $overview_height);
-		if($unlink == true){
-			unlink($filename);
-		}
-	}
-	else{
-		$i = new weldOverview2PNG($overview_url,$array_urls[0],$filename);
-
-		//$pdf->addPngFromFile($filename, $mapOffset_left,$mapOffset_bottom, $overview_width, $overview_height);
-		$pdf->addPngFromFile($filename, $overview_left,$overview_bottom, $overview_width, $overview_height);
-		if($unlink == true){
-			unlink($filename);
-		}
-	}
-}
-
-if ($northarrow==true){
-	$pdf->addPngFromFile($northarrowImage, $northarrow_left, $northarrow_bottom , $northarrowImage_width, $northarrowImage_height);
-}
-
-if($scalebar == true){
-	if ($size == "A4" && $format == "portrait"){
-		$scalebar_left = $a4p_scalebar_left;
-		$scalebar_bottom = $a4p_scalebar_bottom;
-	}elseif ($size == "A4" && $format == "landscape"){
-		$scalebar_left = $a4l_scalebar_left;
-		$scalebar_bottom = $a4l_scalebar_bottom;
-	}elseif ($size == "A3" && $format == "portrait"){
-		$scalebar_left = $a3p_scalebar_left;
-		$scalebar_bottom = $a3p_scalebar_bottom;
-	}elseif ($size == "A3" && $format == "landscape"){
-		$scalebar_left = $a3l_scalebar_left;
-		$scalebar_bottom = $a3l_scalebar_bottom;
-	}elseif ($size == "A2" && $format == "portrait"){
-		$scalebar_left = $a2p_scalebar_left;
-		$scalebar_bottom = $a2p_scalebar_bottom;
-	}elseif ($size == "A2" && $format == "landscape"){
-		$scalebar_left = $a2l_scalebar_left;
-		$scalebar_bottom = $a2l_scalebar_bottom;
-	}
-	
-	$array_scalebar = setscalebar($map_scale);
-	
-	$scalebar_left = $scalebar_left + $header_width/2 - $array_scalebar[1]/2;
-	$pdf->setLineStyle($scalebar_height, '','', array());
-   	$pdf->setColor(0,0,0);
-	#$pdf->line($scalebar_left, $scalebar_bottom , $scalebar_left - 200 + $array_scalebar[1], $scalebar_bottom);
-	$pdf->filledRectangle($scalebar_left, $scalebar_bottom, $array_scalebar[1],$scalebar_height);
-	
-	$pdf->setColor(1,1,1);
-	$pdf->filledRectangle($scalebar_left + $array_scalebar[1]/4 + 1 , $scalebar_bottom + 1, $array_scalebar[1]/4 - 1 ,$scalebar_height-2);	
-	$pdf->setColor(1,1,1);
-	$pdf->filledRectangle($scalebar_left + 3*($array_scalebar[1]/4) + 1 , $scalebar_bottom + 1, $array_scalebar[1]/4 - 2 ,$scalebar_height-2);	
-		
-		
-	#$pdf->setColor(1,0,1);
-	#$pdf->filledRectangle($scalebar_left  , $scalebar_bottom - 20, 1 * $DPC ,$scalebar_height-2);	
-	
-	
-	# value - Einheiten 
-	$pdf->setColor(0,0,0);	
-   $mySize = 8;
-   $scalebar_height_half = 0.5 * $scalebar_height;  
-    
-	$myText = 0;
-   $length = $pdf->getTextWidth($mySize, $myText);  
-   $pdf->addText($scalebar_left - $length/2 ,$scalebar_bottom + 9 ,$mySize,$myText);
-   
-	$myText = $array_scalebar[2]/2;
-   $length = $pdf->getTextWidth($mySize, $myText);     
-   $pdf->addText($scalebar_left + $array_scalebar[1]/2 - $length/2 ,$scalebar_bottom + 9 ,$mySize,$myText);
-	
-	$myText = $array_scalebar[2];
-   $length = $pdf->getTextWidth($mySize, $myText);  
-   $pdf->addText($scalebar_left + $array_scalebar[1] - $length/2 - $length/4 ,$scalebar_bottom + 9 ,$mySize,$myText);
- 
-	
-	$pdf->setColor(0,0,0);	
-   $mySize = 8;
-   $scalebar_height_half = 0.5 * $scalebar_height;   
-   $myText = $array_scalebar[0];
-
-   #$pdf->addText($scalebar_left + $scalebar_width + 5,$scalebar_bottom - $scalebar_height_half ,$mySize,$myText);
-  
-
-	#units  
-   $length = $pdf->getTextWidth($mySize, $myText);
-   $pdf->addText($scalebar_left + $array_scalebar[1]/2 - $length/2 ,$scalebar_bottom - 12 ,$mySize,$myText);
- 
-}
-
-
-/* ------------------------ 
-    new page for legend
-   ------------------------ */
-if ($legend == true && $_REQUEST["mylegend"]=='true'){
-
-	$pdf->ezNewPage();
-
-	//Pageborder (top, bottom, left, right)
-	
-	if($size == "A4" && $format == "portrait"){
-	  $pdf->ezSetMargins(50,50,80,30);
-	} else {
-	  $pdf->ezSetMargins(60,35,60,60);
-	}
-	
-	//Requests
-	if(CHARSET=="UTF-8"){
-		$new_wms_title=utf8_decode($_REQUEST["wms_title"]);
-	}else{
-		$new_wms_title=$_REQUEST["wms_title"];
-	}
-	
-	if(CHARSET=="UTF-8"){
-		$new_layers=utf8_decode($_REQUEST["layers"]);
-	}else{
-		$new_layers=$_REQUEST["layers"];
-	}
-	
-	$my_wms_id = explode("___",$_REQUEST["wms_id"]);
-	$my_wms_title = explode("___",$new_wms_title);
-	$my_layers = explode("___",$new_layers);
-	if($matching == true){
-        $my_legend = str_replace($pattern,$replacement,$_REQUEST["legendurl"]);  
-    }
-    else{
-        $my_legend = $_REQUEST["legendurl"];
-    }
-    $my_legend = explode("___",$my_legend);
-
-	//frames (x1, y1, x2, y2)
-	if($size == "A4" && $format == "portrait"){
-		#line  
-		$pdf->setLineStyle($linewidth, '', '', array());
-		//left
-		$pdf->line($mapOffset_left - $border, $mapOffset_bottom - $border - $footer_height, $mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border + $header_height);
-		//right
-		$pdf->line($mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border + $header_height, $mapOffset_left + $map_width + $border, $mapOffset_bottom + $map_height + $border + $header_height);
-		//top
-		$pdf->line($mapOffset_left + $map_width + $border, $mapOffset_bottom + $map_height + $border + $header_height, $mapOffset_left + $map_width + $border, $mapOffset_bottom - $border - $footer_height);
-		//bottom
-		$pdf->line($mapOffset_left + $map_width + $border, $mapOffset_bottom -$border - $footer_height, $mapOffset_left - $border, $mapOffset_bottom - $border - $footer_height);
-		
-		if ($legendImage!=''){
-			//image on top of page
-			$pdf->addPngFromFile($legendImage, $mapOffset_left + $map_width + $border - $legendImage_width -6, $mapOffset_bottom + $map_height + $border + $header_height - $legendImage_height - 4 , $legendImage_width, $legendImage_height);
-		}
-		    
-	} else {
-	  $pdf->setLineStyle($linewidth, '', '', array());
-	  //left
-	  $pdf->line($mapOffset_left - $border, $mapOffset_bottom - $border, $mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border);
-	  //right
-	  $pdf->line($mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border , $mapOffset_left + $map_width + $border, $mapOffset_bottom + $map_height + $border);
-	  //top
-	   $pdf->line($mapOffset_left + $map_width + $border, $mapOffset_bottom + $map_height + $border , $mapOffset_left + $map_width + $border, $mapOffset_bottom - $border);
-	   //bottom
-	   $pdf->line($mapOffset_left + $map_width + $border, $mapOffset_bottom -$border , $mapOffset_left - $border, $mapOffset_bottom - $border);
-	   
-		if ($legendImage!=''){
-			//image on top of page
-			$pdf->addPngFromFile($legendImage, $mapOffset_left + $map_width + $border - $legendImage_width -6, $mapOffset_bottom + $map_height + $border - $legendImage_height -4 , $legendImage_width, $legendImage_height);
-			//line under legend (only landscape)
-			//$pdf->line($mapOffset_left - $border, $mapOffset_bottom + $map_height + $border  - $legendImage_height - 4 , $mapOffset_left + $map_width + $border, $mapOffset_bottom + $map_height + $border - $legendImage_height - 6);
-		}
-	}
-
-
-	//columns
-	if($size == "A4" && $format == "portrait"){
-	  $pdf->ezColumnsStart(array ('num'=>2, 'gap'=>10));
-	} else {
-	  $pdf->ezColumnsStart(array ('num'=>3, 'gap'=>10));
-	}
-
-	//header from printPDF.conf
-	//$pdf->ezText("<b>".$titel."</b>", 13);
-	$pdf->ezText("<b><u>".$legendText."</u></b>", 13);
-
-	
-	//Seitenr�nder (top, bottom, left, right)
-	if($size == "A4" && $format == "portrait"){
-	  $pdf->ezSetMargins(70,35,80,30);
-	} else {
-	  $pdf->ezSetMargins(100,35,60,60);
-	}
-	
-	//generate the legend---------------------------------------------
-	
-	// gesamth�he Legende / height of the legend
-	$sum_legend_height = 0;
-
-
-	for($i=0; $i<count($my_wms_id); $i++){
-		if ($my_wms_id[$i] != '0'){  //wms_id not 0
-			$layer = explode(",",$my_layers[$i]);
-			$my_legendurls = explode(",",$my_legend[$i]);
-			
-			$wms_y_position = $pdf->ezText("<b>".$my_wms_title[$i]."</b>", 12, array('spacing'=>1.2));
-			$wms_zeilenhoehe   =  $pdf->getFontHeight(12);
-				 
-			// add this to the height of the legend /addiere dies zur Gesamth�he Legende
-			$sum_legend_height += $wms_zeilenhoehe;
-			
-			//Layer
-			$l = 0;		#l temporary parameter to count the layer /Hilfvariable zum durchz�hlen der angezeigten Layer
-			for($j=0; $j<count($my_legendurls); $j++){
-				// url with grouped layers------------------
-				$temp_url = explode('*',$my_legendurls[$j]);
-				$temp_layers = explode('*',$layer[$j]);
-	
-				for ($q=0; $q <count($temp_url);$q++){  
-					if($temp_url[$q] == '1' ){			// Layertitle for the parent of grouped layers	 
-						// add this to the height of the legend /addiere dies zur Gesamth�he Legende		
-						$layer_y_position = $pdf->ezText($temp_layers[$q], 11, array('spacing'=>1.2));
-						$layer_zeilenhoehe   =  $pdf->getFontHeight(12);
-						$sum_legend_height += $layer_zeilenhoehe;
-						
-					}elseif($temp_url[$q] != '0' ){
-						$funktionsaufruf = new SaveLegend($temp_url[$q],$legendFilename);
-						$imgsize = getimagesize($legendFilename);
-						// add this to the height of the legend /addiere dies zur Gesamth�he der Legende
-						$sum_legend_height += $imgsize[1];
-	
-						//calculate text + picture / Berechnung Gr��e Schrift + Bild
-						if($l == 0){
-						       $y_position = $wms_y_position;
-						       $wms_y_position = '';
-						}else{
-							 $y_position = $pdf->ezText("", 1, array('spacing'=>1.2));
-						}
-						$layer_zeilenhoehe = $pdf->getFontHeight(11);
-						$next_position = $y_position - $layer_zeilenhoehe - $imgsize[1];
-						
-						// add this to the height of the legend / addiere dies zur Gesamth�he Legende
-						$sum_legend_height += $layer_zeilenhoehe;
-							
-						$l = $l+1;
-		
-		     			// if text + picture are smaler then the lower margin + textsize, then set a space
-						//wenn Schrift + Bild kleiner der unteren Margin + Zeilenh�he, dann Abstand setzen
-						 if($size == "A4" && $format == "portrait" && $next_position <= 35 +$layer_zeilenhoehe){ //90 $layer_zeilenhoehe
-							$space = $layer_zeilenhoehe + $imgsize[1];
-						  $pdf->ezSetDy(-$space);
-						} 
-						if($size == "A4" && $format == "landscape" && $next_position <= 35+$layer_zeilenhoehe){//50
-							$space = $layer_zeilenhoehe + $imgsize[1];
-						  $pdf->ezSetDy(-$space);
-						}
-				
-						//write the header layername / �berschrift schreiben
-						$legend = $temp_layers[$q]."\n";  //$layer[$j]."\n"; 
-						$pdf->ezText($legend, 11, array('spacing'=>1.2));
-						
-						//$pdf->ezText($url, 9, array('spacing'=>1.2));
-						//print the picture / Bild schreiben
-						$pdf->ezImage($legendFilename, 0, 'width', 'none', 'left');
-						unlink($legendFilename);
-						
-					} //if legendurl
-				}// for legendurl
-	
-			  	//frames (x1, y1, x2, y2)
-				if($size == "A4" && $format == "portrait"){
-					#line  
-					$pdf->setLineStyle($linewidth, '', '', array());
-					//left
-					$pdf->line($mapOffset_left - $border, $mapOffset_bottom - $border - $footer_height, $mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border + $header_height);
-					//right
-					$pdf->line($mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border + $header_height, $mapOffset_left + $map_width + $border, $mapOffset_bottom + $map_height + $border + $header_height);
-					//top
-					$pdf->line($mapOffset_left + $map_width + $border, $mapOffset_bottom + $map_height + $border + $header_height, $mapOffset_left + $map_width + $border, $mapOffset_bottom - $border - $footer_height);
-					//bottom
-					$pdf->line($mapOffset_left + $map_width + $border, $mapOffset_bottom -$border - $footer_height, $mapOffset_left - $border, $mapOffset_bottom - $border - $footer_height);    
-				} else {
-				  $pdf->setLineStyle($linewidth, '', '', array());
-				  //left
-				  $pdf->line($mapOffset_left - $border, $mapOffset_bottom - $border, $mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border);
-				  //right
-				  $pdf->line($mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border , $mapOffset_left + $map_width + $border, $mapOffset_bottom + $map_height + $border);
-				  //top
-				  $pdf->line($mapOffset_left + $map_width + $border, $mapOffset_bottom + $map_height + $border , $mapOffset_left + $map_width + $border, $mapOffset_bottom - $border);
-				   //bottom
-				   $pdf->line($mapOffset_left + $map_width + $border, $mapOffset_bottom -$border , $mapOffset_left - $border, $mapOffset_bottom - $border);
-				}
-			}// for layers
-		} //if wms_id not 0
-	}// for wms
-
-
-$pdf->ezText($legendFooter, 11);
-}//legend true
-/* ------------------------ 
-    end of legend  
-   ------------------------ */
-
-ob_clean();
-if($download == false){
-	$pdf->ezStream();
-}
-else{
-	$content = $pdf->ezOutput();
-
-	$fp = fopen($downloadFile,'w');
-	fwrite($fp,$content);
-	fclose($fp);
-	echo "<html><head></head><body><a href='".$downloadFile."'>".$downloadText."</a></body></html>";
-}
-?>
+<?php
+# $Id:
+# http://www.mapbender.org/index.php/mod_printPDF_pdf.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("../php/mb_validateSession.php");
+ob_start();
+session_start();
+ini_set('error_reporting', 'E_ALL & ~ E_NOTICE');
+require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+
+include (dirname(__FILE__)."/../classes/class.ezpdf.php");
+include (dirname(__FILE__)."/../classes/class_stripRequest.php");
+include (dirname(__FILE__)."/../classes/class_weldMaps2PNG.php");
+include (dirname(__FILE__)."/../classes/class_weldOverview2PNG.php");
+include (dirname(__FILE__)."/../print/".$_REQUEST["conf"]);
+include (dirname(__FILE__)."/../classes/class_SaveLegend.php");
+include (dirname(__FILE__)."/../print/print_functions.php");
+
+if($log == true){
+	include (dirname(__FILE__)."/../classes/class_log.php");
+}
+
+#Globals
+
+$factor = intval($_REQUEST["quality"]);
+
+#$date = date("d.m.Y",strtotime("now"));
+$linewidth_dashed = 0.5;
+$linewidth = 0.5;
+
+// DURATION TIME:
+function microtime_float(){
+   list($usec, $sec) = explode(" ", microtime());
+   return ((float)$usec + (float)$sec);
+}
+$time_start = microtime_float();
+// END DURATION TIME
+
+$time_end = microtime_float();
+$time = $time_end - $time_start;
+
+/* -------------------------------------- */
+
+$size = $_REQUEST["size"];
+$format = $_REQUEST["format"];
+$map_scale = $_REQUEST["map_scale"];
+$overview_url = $_REQUEST["overview_url"];
+$epsg = $_REQUEST["epsg"];
+
+function setscalebar($scale){
+    	$mb_resolution = 28.35;
+        
+		if($scale < 16){
+	      $value = "10";
+	      $unit = "cm";
+	      $scalefactor = 10/$scale;
+	      $img_width = round($scalefactor * $mb_resolution);
+	   }
+	   if($scale >= 16 && $scale < 151){
+	      $value = "1";	      
+	      $unit = "Meter";
+	      $scalefactor = 100/$scale;
+	      $img_width = round($scalefactor * $mb_resolution);
+	   }
+	   if($scale >= 151 && $scale < 1550 ){
+	      $value = "10";	      
+	      $unit = "Meter";
+	      $scalefactor = 1000/$scale;
+	      $img_width = round($scalefactor * $mb_resolution);
+	   }
+	   if($scale >= 1550 && $scale < 15050){
+	      $value = "100";	      
+	      $unit = "Meter";
+	      $scalefactor = 10000/$scale;
+	      $img_width = round($scalefactor * $mb_resolution);
+	   }
+	   if($scale < 150050 && $scale >= 15050){
+	      $value = "1";	      
+	      $unit = "Kilometer";
+	      $scalefactor = 100000/$scale;
+	      $img_width = round($scalefactor * $mb_resolution);
+	   }
+	   if($scale < 1500050 && $scale >= 150050){
+	      $value = "10";	      
+	      $unit = "Kilometer";
+	      $scalefactor = 1000000/$scale;
+	      $img_width = round($scalefactor * $mb_resolution);
+	   }
+	   if($scale < 15000050 && $scale >= 1500050){
+	      $value = "100";	      
+	      $unit = "Kilometer";
+	      $scalefactor = 10000000/$scale;
+	      $img_width = round($scalefactor * $mb_resolution);
+	   }
+	   if($scale < 150000001 && $scale >= 15000001){
+	      $value = "1000";	      
+	      $unit = "Kilometer";
+	      $scalefactor = 100000000/$scale;
+	      $img_width = round($scalefactor * $mb_resolution);
+	   }
+	   if($scale >= 150000001){
+	      $value = "1000";	      
+	      $unit = "Kilometer";
+	      $scalefactor = 100000000/$scale;
+	      $img_width = round($scalefactor * $mb_resolution);
+	   }   
+	   $array_scale[0] = $unit;
+	   $array_scale[1] = $img_width;
+		$array_scale[2] = $value;	   
+	   
+	   return  $array_scale; 
+}
+
+
+$border = 0.8 * $DPC;
+
+if($matching == true){
+   $urls = preg_replace($pattern,$replacement,$_REQUEST["map_url"]);  
+}
+else{
+   $urls = $_REQUEST["map_url"];
+}
+
+
+$array_urls = explode("___", $urls);
+
+$myURL = new stripRequest($array_urls[0]);
+$map_width = round($myURL->get("width"));
+$map_height = round($myURL->get("height"));
+$map_extent = $myURL->get("BBOX");
+if($factor>1){
+	for($i=0; $i<count($array_urls); $i++){
+		$m = new stripRequest($array_urls[$i]);
+		$m->set('width',(intval($m->get('width'))*4));
+		$m->set('height',(intval($m->get('height'))*4));
+		if(in_array($m->get('map'),$highqualitymapfiles)){	
+			$m->set('map',preg_replace("/\.map/","_4.map",$m->get('map')));			
+		}
+		$array_urls[$i] = $m->url;
+	}
+}
+$coord = mb_split(",",$map_extent);
+
+// analyse overview url and draw rectangle with position
+$o_url = new stripRequest($overview_url);
+$overview_width = round($o_url->get("width"));
+$overview_height = round($o_url->get("height"));
+
+if($factor>1){
+	$o_url->set('width',(intval($o_url->get('width'))*4));
+	$o_url->set('height',(intval($o_url->get('height'))*4));
+	if(in_array($o_url->get('map'),$highqualitymapfiles)){	
+			$o_url->set('map',preg_replace("/\.map/","_4.map",$o_url->get('map')));		
+			$overview_url = $o_url->url;	
+	}
+}
+
+if($matching == true){
+	$overview_url = preg_replace($pattern,$replacement,$overview_url);  
+}
+
+
+if ($size == "A4" && $format == "portrait"){
+	$overview_left = $a4p_overviewOffset_left;
+	$overview_bottom =$a4p_overviewOffset_bottom;
+}elseif ($size == "A4" && $format == "landscape"){
+	$overview_left = $a4l_overviewOffset_left;
+	$overview_bottom =$a4l_overviewOffset_bottom;
+}elseif ($size == "A3" && $format == "portrait"){
+	$overview_left = $a3p_overviewOffset_left;
+	$overview_bottom =$a3p_overviewOffset_bottom;
+}elseif ($size == "A3" && $format == "landscape"){
+	$overview_left = $a3l_overviewOffset_left;
+	$overview_bottom = $a3l_overviewOffset_bottom;
+}elseif ($size == "A2" && $format == "portrait"){
+	$overview_left = $a2p_overviewOffset_left;
+	$overview_bottom =$a2p_overviewOffset_bottom;
+}elseif ($size == "A2" && $format == "landscape"){
+	$overview_left = $a2l_overviewOffset_left;
+	$overview_bottom = $a2l_overviewOffset_bottom;
+}elseif ($size == "A1" && $format == "portrait"){
+	$overview_left = $a1p_overviewOffset_left;
+	$overview_bottom =$a1p_overviewOffset_bottom;
+}elseif ($size == "A1" && $format == "landscape"){
+	$overview_left = $a1l_overviewOffset_left;
+	$overview_bottom = $a1l_overviewOffset_bottom;
+}elseif ($size == "A0" && $format == "portrait"){
+	$overview_left = $a0p_overviewOffset_left;
+	$overview_bottom =$a0p_overviewOffset_bottom;
+}elseif ($size == "A0" && $format == "landscape"){
+	$overview_left = $a0l_overviewOffset_left;
+	$overview_bottom = $a0l_overviewOffset_bottom;
+}
+
+$o_extent = $o_url->get("BBOX");
+
+$array_overview_url[0] = $overview_url;
+if($log == true){
+	$l = new log("printPDF_overview",$array_overview_url);
+}
+
+/*
+$o_new = new stripRequest($overview_url);
+$o_new->set('width',50);
+$o_new->set('height',50);
+//$o->set('BBOX',$overview_extent);
+$o_url_new =$o_new->url;
+$array_overview[0] = $overview_url;
+$array_overview[1] = $o_url;
+*/
+
+/*
+ * north arrow
+ */
+if($size == "A4" && $format == "portrait"){
+	$northarrow_left = $a4p_northarrow_left;
+	$northarrow_bottom = $a4p_northarrow_bottom;
+}elseif ($size == "A4" && $format == "landscape"){
+	$northarrow_left = $a4l_northarrow_left;
+	$northarrow_bottom = $a4l_northarrow_bottom;
+}elseif ($size == "A3" && $format == "portrait"){
+	$northarrow_left = $a3p_northarrow_left;
+	$northarrow_bottom = $a3p_northarrow_bottom;
+}elseif ($size == "A3" && $format == "landscape"){
+	$northarrow_left = $a3l_northarrow_left;
+	$northarrow_bottom = $a3l_northarrow_bottom;
+}elseif ($size == "A2" && $format == "portrait"){
+	$northarrow_left = $a2p_northarrow_left;
+	$northarrow_bottom = $a2p_northarrow_bottom;
+}elseif ($size == "A2" && $format == "landscape"){
+	$northarrow_left = $a2l_northarrow_left;
+	$northarrow_bottom = $a2l_northarrow_bottom;
+}elseif ($size == "A1" && $format == "portrait"){
+	$northarrow_left = $a1p_northarrow_left;
+	$northarrow_bottom = $a1p_northarrow_bottom;
+}elseif ($size == "A1" && $format == "landscape"){
+	$northarrow_left = $a1l_northarrow_left;
+	$northarrow_bottom = $a1l_northarrow_bottom;
+}elseif ($size == "A0" && $format == "portrait"){
+	$northarrow_left = $a0p_northarrow_left;
+	$northarrow_bottom = $a0p_northarrow_bottom;
+}elseif ($size == "A0" && $format == "landscape"){
+	$northarrow_left = $a0l_northarrow_left;
+	$northarrow_bottom = $a0l_northarrow_bottom;
+}
+
+/*
+ * special image
+ */
+if ($size == "A4" && $format == "portrait"){
+	$specialImage_left = $a4p_special_left;
+	$specialImage_bottom = $a4p_special_bottom;
+}elseif ($size == "A4" && $format == "landscape"){
+	$specialImage_left = $a4l_special_left;
+	$specialImage_bottom = $a4l_special_bottom;
+}elseif ($size == "A3" && $format == "portrait"){
+	$specialImage_left = $a3p_special_left;
+	$specialImage_bottom = $a3p_special_bottom;
+}elseif ($size == "A3" && $format == "landscape"){
+	$specialImage_left = $a3l_special_left;
+	$specialImage_bottom = $a3l_special_bottom;
+}elseif ($size == "A2" && $format == "portrait"){
+	$specialImage_left = $a2p_special_left;
+	$specialImage_bottom = $a2p_special_bottom;
+}elseif ($size == "A2" && $format == "landscape"){
+	$specialImage_left = $a2l_special_left;
+	$specialImage_bottom = $a2l_special_bottom;
+}elseif ($size == "A1" && $format == "portrait"){
+	$specialImage_left = $a1p_special_left;
+	$specialImage_bottom = $a1p_special_bottom;
+}elseif ($size == "A1" && $format == "landscape"){
+	$specialImage_left = $a1l_special_left;
+	$specialImage_bottom = $a1l_special_bottom;
+}elseif ($size == "A0" && $format == "portrait"){
+	$specialImage_left = $a0p_special_left;
+	$specialImage_bottom = $a0p_special_bottom;
+}elseif ($size == "A0" && $format == "landscape"){
+	$specialImage_left = $a0l_special_left;
+	$specialImage_bottom = $a0l_special_bottom;
+}
+
+if($log == true){
+	$l = new log("printPDF",$array_urls);
+}
+$pdf = new Cezpdf();
+
+$pdf->Cezpdf(mb_strtolower($size),$format);
+$diff=array(196=>'Adieresis',228=>'adieresis',
+   214=>'Odieresis',246=>'odieresis',
+   220=>'Udieresis',252=>'udieresis',
+   223=>'germandbls');
+$pdf->selectFont('../classes/fonts/Helvetica.afm', array('encoding'=>'WinAnsiEncoding','differences'=>$diff));
+if($size == "A4" && $format == "portrait"){
+	$mapOffset_left = $a4p_mapOffset_left;
+	$mapOffset_bottom = $a4p_mapOffset_bottom;
+	$header_height = $a4p_header_height;
+	$footer_height = $a4p_footer_height;
+}
+else{
+	$mapOffset_left = $a4l_mapOffset_left;
+	$mapOffset_bottom = $a4l_mapOffset_bottom;
+	$header_height = $a4l_header_height;
+	$header_width = $a4l_header_width;
+}
+session_write_close();
+$i = new weldMaps2PNG(implode("___",$array_urls),$filename);
+
+$pdf->addPngFromFile($filename, $mapOffset_left, $mapOffset_bottom, $map_width, $map_height);
+if($unlink == true){
+	unlink($filename);
+}
+
+/** ******************************************************************
+* user drawn elements
+*/
+
+$theMeasureConfigArray = array(
+   "do_fill" => FALSE,
+     "fill_color" => array(
+     "r" => 128 / 255,
+     "g" => 128 / 255,
+     "b" => 128 / 255
+   ),
+   "do_stroke" => FALSE,
+     "stroke_color" => array(
+     "r" => 254 / 255,
+     "g" => 1 / 255,
+     "b" => 1 / 255
+   ),
+   "line_style" => array(
+       "width" => 2,
+       "cap" => 'butt',
+       "join" => 'miter',
+       "dash" => array(10, 6)
+       )
+   );
+
+if ($_REQUEST["measured_x_values"]!=''){
+	addMeasuredItem($pdf, $_REQUEST["measured_x_values"], $_REQUEST["measured_y_values"], $theMeasureConfigArray);
+	hideElementsOutsideMapframe($pdf);
+}
+
+# dashed line
+$pdf->setLineStyle($linewidth_dashed, '','', array(2,2));
+$pdf->line($mapOffset_left - $linewidth_dashed, $mapOffset_bottom - $linewidth_dashed, $mapOffset_left - $linewidth_dashed, $mapOffset_bottom  + $map_height + $linewidth_dashed);
+$pdf->line($mapOffset_left - $linewidth_dashed, $mapOffset_bottom  + $map_height + $linewidth_dashed, $mapOffset_left + $map_width + $linewidth_dashed, $mapOffset_bottom + $map_height + $linewidth_dashed);
+$pdf->line($mapOffset_left + $map_width + $linewidth_dashed, $mapOffset_bottom + $map_height + $linewidth_dashed, $mapOffset_left + $map_width + $linewidth_dashed, $mapOffset_bottom -$linewidth_dashed);
+$pdf->line($mapOffset_left + $map_width + $linewidth_dashed, $mapOffset_bottom -$linewidth_dashed, $mapOffset_left - $linewidth_dashed, $mapOffset_bottom - $linewidth_dashed);
+
+
+#line
+$pdf->setLineStyle($linewidth, '', '', array());
+$pdf->line($mapOffset_left - $border, $mapOffset_bottom - $border, $mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border);
+$pdf->line($mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border, $mapOffset_left + $map_width + $border, $mapOffset_bottom + $map_height + $border);
+$pdf->line($mapOffset_left + $map_width + $border, $mapOffset_bottom + $map_height + $border, $mapOffset_left + $map_width + $border, $mapOffset_bottom -$border);
+$pdf->line($mapOffset_left + $map_width + $border, $mapOffset_bottom -$border, $mapOffset_left - $border, $mapOffset_bottom - $border);
+
+if($epsg == "EPSG:4326"){
+
+	$text4 = "";
+}
+
+if($size == "A4" && $format == "portrait"){
+   #header:
+   $pdf->line($mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border, $mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border + $header_height);
+   $pdf->line($mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border + $header_height, $mapOffset_left + $map_width + $border, $mapOffset_bottom  + $map_height + $border + $header_height);
+   $pdf->line($mapOffset_left + $map_width + $border, $mapOffset_bottom  + $map_height + $border + $header_height, $mapOffset_left + $map_width + $border, $mapOffset_bottom  + $map_height + $border);
+   $pdf->line( $mapOffset_left + $map_width/2, $mapOffset_bottom  + $map_height + $border, $mapOffset_left + $map_width/2, $mapOffset_bottom  + $map_height + $border + $header_height);
+   #header-text
+   $mySize = 9;
+   $length = $pdf->getTextWidth($mySize, $text1);
+   $pdf->addText($mapOffset_left - ($border/2) + ($map_width/4) - ($length/2),$mapOffset_bottom + $map_height + $border + 60,$mySize,$text1);
+
+   $mySize = 8;
+   $length = $pdf->getTextWidth($mySize, $text2);   
+   $pdf->addText($mapOffset_left - ($border/2) + ($map_width/4) - ($length/2),$mapOffset_bottom + $map_height + $border + 45,$mySize,$text2);
+   
+   $length = $pdf->getTextWidth($mySize, $text3);
+   $pdf->addText($mapOffset_left - ($border/2) + ($map_width/4) - ($length/2),$mapOffset_bottom + $map_height + $border + 35,$mySize,$text3);
+
+   $mySize = 9;
+   $length = $pdf->getTextWidth($mySize, $text4);   
+   $pdf->addText($mapOffset_left - ($border/2) + ($map_width/4) - ($length/2),$mapOffset_bottom + $map_height + $border + 20,$mySize,$text4);
+
+   $mySize = 8;
+   $length = $pdf->getTextWidth($mySize, $text5);   
+   $pdf->addText($mapOffset_left - ($border/2) + ($map_width/4) - ($length/2),$mapOffset_bottom + $map_height + $border + 10,$mySize,$text5);
+   
+   $mySize = 9;
+   $length = $pdf->getTextWidth($mySize, $text6);   
+   $pdf->addText($mapOffset_left + ($border/2) + ($map_width/4*3) - ($length/2),$mapOffset_bottom + $map_height + $border + 60,$mySize,$text6);
+   $length = $pdf->getTextWidth($mySize, $text7);   
+   $pdf->addText($mapOffset_left + ($border/2) + ($map_width/4*3) - ($length/2),$mapOffset_bottom + $map_height + $border + 50,$mySize,$text7);
+   $length = $pdf->getTextWidth($mySize, $text8);   
+   $pdf->addText($mapOffset_left + ($border/2) + ($map_width/4*3) - ($length/2),$mapOffset_bottom + $map_height + $border + 30,$mySize,$text8);
+   $length = $pdf->getTextWidth($mySize, $text9);   
+   $pdf->addText($mapOffset_left + ($border/2) + ($map_width/4*3) - ($length/2),$mapOffset_bottom + $map_height + $border + 20,$mySize,$text9);
+   $length = $pdf->getTextWidth($mySize, $text10);   
+   $pdf->addText($mapOffset_left + ($border/2) + ($map_width/4*3) - ($length/2),$mapOffset_bottom + $map_height + $border + 10,$mySize,$text10);
+   
+   //special image on the map-page
+   if ($special == true){
+   	$pdf->addPngFromFile($specialImage, $specialImage_left, $specialImage_bottom , $specialImage_width, $specialImage_height);
+   }
+   
+   #footer
+   $pdf->line($mapOffset_left - $border, $mapOffset_bottom - $border, $mapOffset_left - $border, $mapOffset_bottom - $border - $footer_height);
+   $pdf->line($mapOffset_left - $border, $mapOffset_bottom - $border - $footer_height, $mapOffset_left + $map_width + $border, $mapOffset_bottom - $border - $footer_height);
+   $pdf->line($mapOffset_left + $map_width + $border, $mapOffset_bottom - $border - $footer_height, $mapOffset_left + $map_width + $border, $mapOffset_bottom - $border);
+   
+   $mySize = 8;
+   $length = $pdf->getTextWidth($mySize, $text11);   
+   $pdf->addText( $mapOffset_left + $map_width/2 - ($length/2),$mapOffset_bottom - $border - 10,$mySize,$text11);
+   $mySize = 6;
+   $length = $pdf->getTextWidth($mySize, $text12);   
+   $pdf->addText( $mapOffset_left + $map_width/2 - ($length/2),$mapOffset_bottom - $border - 18,$mySize,$text12);
+   $length = $pdf->getTextWidth($mySize, $text13);
+   $pdf->addText( $mapOffset_left + $map_width/2 - ($length/2),$mapOffset_bottom - $border - 25,$mySize,$text13);
+}
+else{
+   $pdf->setColor(1,1,1);
+   $ll = array($mapOffset_left + $map_width - $header_width + $border - $linewidth, $mapOffset_bottom - $border + 1);
+   $pdf->filledRectangle($ll[0], $ll[1], $header_width,$header_height);
+   $pdf->line($ll[0], $ll[1], $ll[0], $ll[1] + $header_height);
+   $pdf->line($ll[0], $ll[1] + $header_height, $ll[0] + $header_width, $ll[1] + $header_height);
+
+   $pdf->line($ll[0] + 2, $ll[1] + 2, $ll[0] + 2,  $ll[1] + $header_height - 2);
+   $pdf->line($ll[0] + 2,  $ll[1] + $header_height - 2, $ll[0] - 2 + $header_width, $ll[1] + $header_height - 2);
+   $pdf->line($ll[0] - 2 + $header_width, $ll[1] + $header_height - 2, $ll[0] - 2 + $header_width, $ll[1] + 2);
+   $pdf->line($ll[0] - 2 + $header_width, $ll[1] + 2, $ll[0] + 2, $ll[1] + 2);
+   
+   $pdf->line($ll[0] + 2, $ll[1] + 110 , $ll[0] - 2 + $header_width, $ll[1] + 110);
+   $pdf->line($ll[0] + 2, $ll[1] + 40 , $ll[0] - 2 + $header_width, $ll[1] + 40);
+   
+   
+   //special image on the map-page
+   if ($special == true){
+   	$pdf->addPngFromFile($specialImage, $specialImage_left, $specialImage_bottom , $specialImage_width, $specialImage_height);
+   }
+   
+    if($epsg == "EPSG:4326"){
+
+	$text4 = "";
+	}
+	
+   $pdf->setColor(0,0,0);
+   $mySize = 9;
+   $length = $pdf->getTextWidth($mySize, $text1);   
+   $pdf->addText($ll[0] + $header_width/2 - $length/2,185,$mySize,$text1);
+   
+   $mySize = 8;
+   $length = $pdf->getTextWidth($mySize, $text2);   
+   $pdf->addText($ll[0] + $header_width/2 - $length/2,175,$mySize,$text2);
+   $length = $pdf->getTextWidth($mySize, $text3);   
+   $pdf->addText($ll[0] + $header_width/2 - $length/2,165,$mySize,$text3);
+   $mySize = 9;
+   $length = $pdf->getTextWidth($mySize, $text4);   
+   $pdf->addText($ll[0] + $header_width/2 - $length/2,155,$mySize,$text4);
+   $mySize = 8;
+   $length = $pdf->getTextWidth($mySize, $text5);   
+   $pdf->addText($ll[0] + $header_width/2 - $length/2,145,$mySize,$text5);   
+   
+   $mySize = 9;
+   $length = $pdf->getTextWidth($mySize, $text6);   
+   $pdf->addText($ll[0] + $header_width/2 - $length/2,125,$mySize,$text6);
+   $length = $pdf->getTextWidth($mySize, $text7);   
+   $pdf->addText($ll[0] + $header_width/2 - $length/2,115,$mySize,$text7);
+   $length = $pdf->getTextWidth($mySize, $text8);   
+   $pdf->addText($ll[0] + $header_width/2 - $length/2,95,$mySize,$text8);
+   $length = $pdf->getTextWidth($mySize, $text9);   
+   $pdf->addText($ll[0] + $header_width/2 - $length/2,85,$mySize,$text9);
+   $length = $pdf->getTextWidth($mySize, $text10);   
+   $pdf->addText($ll[0] + $header_width/2 - $length/2,75,$mySize,$text10);
+   
+   $mySize = 8;
+   $length = $pdf->getTextWidth($mySize, $text11);   
+   $pdf->addText($ll[0] + $header_width/2 - $length/2,60,$mySize,$text11); 
+   $mySize = 6;
+   $length = $pdf->getTextWidth($mySize, $text14);   
+   $pdf->addText($ll[0] + $header_width/2 - $length/2,53,$mySize,$text14);
+   $length = $pdf->getTextWidth($mySize, $text15);   
+   $pdf->addText($ll[0] + $header_width/2 - $length/2,47,$mySize,$text15);
+   $length = $pdf->getTextWidth($mySize, $text16);   
+   $pdf->addText($ll[0] + $header_width/2 - $length/2,41,$mySize,$text16);
+   $length = $pdf->getTextWidth($mySize, $text17);   
+   $pdf->addText($ll[0] + $header_width/2 - $length/2,35,$mySize,$text17);                             
+}
+#Coordinates
+$myMinx = "R ".substr(round($coord[0]), 0, 4)." ".substr(round($coord[0]), 4, 3)."";
+$myMiny = "H ".substr(round($coord[1]), 0, 4)." ".substr(round($coord[1]), 4, 3)."";
+$myMaxx = "R ".substr(round($coord[2]), 0, 4)." ".substr(round($coord[2]), 4, 3)."";
+$myMaxy = "H ".substr(round($coord[3]), 0, 4)." ".substr(round($coord[3]), 4, 3)."";
+
+$mySize = 9;
+$pdf->addText($mapOffset_left - 3, $mapOffset_bottom, $mySize, $myMinx, -90);
+$pdf->addText($mapOffset_left, $mapOffset_bottom  - ($pdf->getFontHeight($mySize)), $mySize, $myMiny);
+$pdf->addText($mapOffset_left  + $map_width - ($pdf->getTextWidth($mySize, $myMaxx)), $mapOffset_bottom + $map_height  + 3, $mySize, $myMaxx);
+$pdf->addText($mapOffset_left + $map_width + 3, $mapOffset_bottom + $map_height, $mySize, $myMaxy, 90);
+
+
+
+
+
+
+if ($overview==true){
+	// analyse request, draw rectancle
+	$filename = preg_replace("/map_/","overview_",$filename);
+	if($size == "A4" && $format == "portrait"){
+		$i = new weldOverview2PNG($overview_url,$array_urls[0] ,$filename);
+
+		$pdf->addPngFromFile($filename, $overview_left,$overview_bottom, $overview_width, $overview_height);
+		if($unlink == true){
+			unlink($filename);
+		}
+	}
+	else{
+		$i = new weldOverview2PNG($overview_url,$array_urls[0],$filename);
+
+		//$pdf->addPngFromFile($filename, $mapOffset_left,$mapOffset_bottom, $overview_width, $overview_height);
+		$pdf->addPngFromFile($filename, $overview_left,$overview_bottom, $overview_width, $overview_height);
+		if($unlink == true){
+			unlink($filename);
+		}
+	}
+}
+
+if ($northarrow==true){
+	$pdf->addPngFromFile($northarrowImage, $northarrow_left, $northarrow_bottom , $northarrowImage_width, $northarrowImage_height);
+}
+
+if($epsg == "EPSG:4326"){
+
+	$scalebar = false;
+}
+else{
+
+	$scalebar = true;
+}
+
+if($scalebar == true){
+	if ($size == "A4" && $format == "portrait"){
+		$scalebar_left = $a4p_scalebar_left;
+		$scalebar_bottom = $a4p_scalebar_bottom;
+	}elseif ($size == "A4" && $format == "landscape"){
+		$scalebar_left = $a4l_scalebar_left;
+		$scalebar_bottom = $a4l_scalebar_bottom;
+	}elseif ($size == "A3" && $format == "portrait"){
+		$scalebar_left = $a3p_scalebar_left;
+		$scalebar_bottom = $a3p_scalebar_bottom;
+	}elseif ($size == "A3" && $format == "landscape"){
+		$scalebar_left = $a3l_scalebar_left;
+		$scalebar_bottom = $a3l_scalebar_bottom;
+	}elseif ($size == "A2" && $format == "portrait"){
+		$scalebar_left = $a2p_scalebar_left;
+		$scalebar_bottom = $a2p_scalebar_bottom;
+	}elseif ($size == "A2" && $format == "landscape"){
+		$scalebar_left = $a2l_scalebar_left;
+		$scalebar_bottom = $a2l_scalebar_bottom;
+	}elseif ($size == "A1" && $format == "portrait"){
+		$scalebar_left = $a1p_scalebar_left;
+		$scalebar_bottom = $a1p_scalebar_bottom;
+	}elseif ($size == "A1" && $format == "landscape"){
+		$scalebar_left = $a1l_scalebar_left;
+		$scalebar_bottom = $a1l_scalebar_bottom;
+	}elseif ($size == "A0" && $format == "portrait"){
+		$scalebar_left = $a0p_scalebar_left;
+		$scalebar_bottom = $a0p_scalebar_bottom;
+	}elseif ($size == "A0" && $format == "landscape"){
+		$scalebar_left = $a0l_scalebar_left;
+		$scalebar_bottom = $a0l_scalebar_bottom;
+	}
+	
+	$array_scalebar = setscalebar($map_scale);
+	
+	$scalebar_left = $scalebar_left + $header_width/2 - $array_scalebar[1]/2;
+	$pdf->setLineStyle($scalebar_height, '','', array());
+   	$pdf->setColor(0,0,0);
+	#$pdf->line($scalebar_left, $scalebar_bottom , $scalebar_left - 200 + $array_scalebar[1], $scalebar_bottom);
+	$pdf->filledRectangle($scalebar_left, $scalebar_bottom, $array_scalebar[1],$scalebar_height);
+	
+	$pdf->setColor(1,1,1);
+	$pdf->filledRectangle($scalebar_left + $array_scalebar[1]/4 + 1 , $scalebar_bottom + 1, $array_scalebar[1]/4 - 1 ,$scalebar_height-2);	
+	$pdf->setColor(1,1,1);
+	$pdf->filledRectangle($scalebar_left + 3*($array_scalebar[1]/4) + 1 , $scalebar_bottom + 1, $array_scalebar[1]/4 - 2 ,$scalebar_height-2);	
+		
+		
+	#$pdf->setColor(1,0,1);
+	#$pdf->filledRectangle($scalebar_left  , $scalebar_bottom - 20, 1 * $DPC ,$scalebar_height-2);	
+	
+	
+	# value - Einheiten 
+	$pdf->setColor(0,0,0);	
+   $mySize = 8;
+   $scalebar_height_half = 0.5 * $scalebar_height;  
+    
+	$myText = 0;
+   $length = $pdf->getTextWidth($mySize, $myText);  
+   $pdf->addText($scalebar_left - $length/2 ,$scalebar_bottom + 9 ,$mySize,$myText);
+   
+	$myText = $array_scalebar[2]/2;
+   $length = $pdf->getTextWidth($mySize, $myText);     
+   $pdf->addText($scalebar_left + $array_scalebar[1]/2 - $length/2 ,$scalebar_bottom + 9 ,$mySize,$myText);
+	
+	$myText = $array_scalebar[2];
+   $length = $pdf->getTextWidth($mySize, $myText);  
+   $pdf->addText($scalebar_left + $array_scalebar[1] - $length/2 - $length/4 ,$scalebar_bottom + 9 ,$mySize,$myText);
+ 
+	
+	$pdf->setColor(0,0,0);	
+   $mySize = 8;
+   $scalebar_height_half = 0.5 * $scalebar_height;   
+   $myText = $array_scalebar[0];
+
+   #$pdf->addText($scalebar_left + $scalebar_width + 5,$scalebar_bottom - $scalebar_height_half ,$mySize,$myText);
+  
+
+	#units  
+   $length = $pdf->getTextWidth($mySize, $myText);
+   $pdf->addText($scalebar_left + $array_scalebar[1]/2 - $length/2 ,$scalebar_bottom - 12 ,$mySize,$myText);
+ 
+}
+
+
+/* ------------------------ 
+    new page for legend
+   ------------------------ */
+if ($legend == true && $_REQUEST["mylegend"]=='true'){
+
+	$pdf->ezNewPage();
+
+	//Pageborder (top, bottom, left, right)
+	
+	if($size == "A4" && $format == "portrait"){
+	  $pdf->ezSetMargins(50,50,80,30);
+	} else {
+	  $pdf->ezSetMargins(60,35,60,60);
+	}
+	
+	//Requests
+	if(CHARSET=="UTF-8"){
+		$new_wms_title=utf8_decode($_REQUEST["wms_title"]);
+	}else{
+		$new_wms_title=$_REQUEST["wms_title"];
+	}
+	
+	if(CHARSET=="UTF-8"){
+		$new_layers=utf8_decode($_REQUEST["layers"]);
+	}else{
+		$new_layers=$_REQUEST["layers"];
+	}
+	
+	$my_wms_id = explode("___",$_REQUEST["wms_id"]);
+	$my_wms_title = explode("___",$new_wms_title);
+	$my_layers = explode("___",$new_layers);
+	if($matching == true){
+        $my_legend = preg_replace($pattern,$replacement,$_REQUEST["legendurl"]);  
+    }
+    else{
+        $my_legend = $_REQUEST["legendurl"];
+    }
+    $my_legend = explode("___",$my_legend);
+
+	//columns
+	if($size == "A4" && $format == "portrait"){
+	  $pdf->ezColumnsStart(array ('num'=>2, 'gap'=>10));
+	} else {
+	  $pdf->ezColumnsStart(array ('num'=>3, 'gap'=>10));
+	}
+
+	//header from printPDF.conf
+	//$pdf->ezText("<b>".$titel."</b>", 13);
+	$pdf->ezText("<b><u>".$legendText."</u></b>", 13);
+
+	
+	//Seitenraender (top, bottom, left, right)
+	if($size == "A4" && $format == "portrait"){
+	  $pdf->ezSetMargins(70,35,80,30);
+	} else {
+	  $pdf->ezSetMargins(100,35,60,60);
+	}
+	
+	//generate the legend---------------------------------------------
+	
+	// Gesamthoehe Legende / height of the legend
+	$sum_legend_height = 0;
+
+
+	for($i=0; $i<count($my_wms_id); $i++){
+		if ($my_wms_id[$i] != '0'){  //wms_id not 0
+			$layer = explode(",",$my_layers[$i]);
+			$my_legendurls = explode(",",$my_legend[$i]);
+			
+			$wms_y_position = $pdf->ezText("<b>".$my_wms_title[$i]."</b>", 12, array('spacing'=>1.2));
+			$wms_zeilenhoehe   =  $pdf->getFontHeight(12);
+				 
+			// add this to the height of the legend /addiere dies zur Gesamthoehe Legende
+			$sum_legend_height += $wms_zeilenhoehe;
+			
+			//Layer
+			$l = 0;		#l temporary parameter to count the layer /Hilfvariable zum durchz�hlen der angezeigten Layer
+			for($j=0; $j<count($my_legendurls); $j++){
+				// url with grouped layers------------------
+				$temp_url = explode('*',$my_legendurls[$j]);
+				$temp_layers = explode('*',$layer[$j]);
+	
+				for ($q=0; $q <count($temp_url);$q++){  
+					if($temp_url[$q] == '1' ){			// Layertitle for the parent of grouped layers	 
+						// add this to the height of the legend /addiere dies zur Gesamth�he Legende		
+						$layer_y_position = $pdf->ezText($temp_layers[$q], 11, array('spacing'=>1.2));
+						$layer_zeilenhoehe   =  $pdf->getFontHeight(12);
+						$sum_legend_height += $layer_zeilenhoehe;
+						
+					}elseif($temp_url[$q] != '0' ){
+						$funktionsaufruf = new SaveLegend($temp_url[$q],$legendFilename);
+						$imgsize = getimagesize($legendFilename);
+						// add this to the height of the legend /addiere dies zur Gesamthoehe der Legende
+						$sum_legend_height += $imgsize[1];
+	
+						//calculate text + picture / Berechnung Groesse Schrift + Bild
+						if($l == 0){
+						       $y_position = $wms_y_position;
+						       $wms_y_position = '';
+						}else{
+							 $y_position = $pdf->ezText("", 1, array('spacing'=>1.2));
+						}
+						$layer_zeilenhoehe = $pdf->getFontHeight(11);
+						$next_position = $y_position - $layer_zeilenhoehe - $imgsize[1];
+						
+						// add this to the height of the legend / addiere dies zur Gesamth�he Legende
+						$sum_legend_height += $layer_zeilenhoehe;
+							
+						$l = $l+1;
+		
+		     			// if text + picture are smaler then the lower margin + textsize, then set a space
+						//wenn Schrift + Bild kleiner der unteren Margin + Zeilenhoehe, dann Abstand setzen
+						 if($size == "A4" && $format == "portrait" && $next_position <= 35 +$layer_zeilenhoehe){ //90 $layer_zeilenhoehe
+							$space = $layer_zeilenhoehe + $imgsize[1];
+						  $pdf->ezSetDy(-$space);
+						} 
+						if($size == "A4" && $format == "landscape" && $next_position <= 35+$layer_zeilenhoehe){//50
+							$space = $layer_zeilenhoehe + $imgsize[1];
+						  $pdf->ezSetDy(-$space);
+						}
+				
+						//write the header layername / Ueberschrift schreiben
+						$legend = $temp_layers[$q]."\n";  //$layer[$j]."\n"; 
+						$pdf->ezText($legend, 11, array('spacing'=>1.2));
+						
+						//$pdf->ezText($url, 9, array('spacing'=>1.2));
+						//print the picture / Bild schreiben
+						$pdf->ezImage($legendFilename, 0, 'width', 'none', 'left');
+						if($unlink == true){
+							unlink($legendFilename);
+						}
+						
+					} //if legendurl
+				}// for legendurl
+	
+			  	//frames (x1, y1, x2, y2)
+				if($size == "A4" && $format == "portrait"){
+					#line  
+					$pdf->setLineStyle($linewidth, '', '', array());
+					//left
+					$pdf->line($mapOffset_left - $border, $mapOffset_bottom - $border - $footer_height, $mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border + $header_height);
+					//right
+					$pdf->line($mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border + $header_height, $mapOffset_left + $map_width + $border, $mapOffset_bottom + $map_height + $border + $header_height);
+					//top
+					$pdf->line($mapOffset_left + $map_width + $border, $mapOffset_bottom + $map_height + $border + $header_height, $mapOffset_left + $map_width + $border, $mapOffset_bottom - $border - $footer_height);
+					//bottom
+					$pdf->line($mapOffset_left + $map_width + $border, $mapOffset_bottom -$border - $footer_height, $mapOffset_left - $border, $mapOffset_bottom - $border - $footer_height);
+					
+					if ($legendImage!=''){
+						//image on top of page
+						$pdf->addPngFromFile($legendImage, $mapOffset_left + $map_width + $border - $legendImage_width -6, $mapOffset_bottom + $map_height + $border + $header_height - $legendImage_height - 4 , $legendImage_width, $legendImage_height);
+					}    
+				} else {
+				  $pdf->setLineStyle($linewidth, '', '', array());
+				  //left
+				  $pdf->line($mapOffset_left - $border, $mapOffset_bottom - $border, $mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border);
+				  //right
+				  $pdf->line($mapOffset_left - $border, $mapOffset_bottom  + $map_height + $border , $mapOffset_left + $map_width + $border, $mapOffset_bottom + $map_height + $border);
+				  //top
+				  $pdf->line($mapOffset_left + $map_width + $border, $mapOffset_bottom + $map_height + $border , $mapOffset_left + $map_width + $border, $mapOffset_bottom - $border);
+				   //bottom
+				   $pdf->line($mapOffset_left + $map_width + $border, $mapOffset_bottom -$border , $mapOffset_left - $border, $mapOffset_bottom - $border);
+				   
+					if ($legendImage!=''){
+						//image on top of page
+						$pdf->addPngFromFile($legendImage, $mapOffset_left + $map_width + $border - $legendImage_width -6, $mapOffset_bottom + $map_height + $border - $legendImage_height -4 , $legendImage_width, $legendImage_height);
+						//line under legend (only landscape)
+						//$pdf->line($mapOffset_left - $border, $mapOffset_bottom + $map_height + $border  - $legendImage_height - 4 , $mapOffset_left + $map_width + $border, $mapOffset_bottom + $map_height + $border - $legendImage_height - 6);
+					}
+				}
+			}// for layers
+		} //if wms_id not 0
+	}// for wms
+	
+	/****
+    * USER POLYGON:
+    */
+   if($_REQUEST["measured_x_values"] != ""
+      && $_REQUEST["measured_y_values"] != ""
+        && is_file($legendFilenameUserPolygon)) {
+     // load image
+       $myY = $pdf->ezText("<b>temporary Object</b>", 11);
+       $pdf->ezSetDy(-15);
+       $pdf->ezImage($legendFilenameUserPolygon, 5, 17, 'none', 'left');
+       if($unlink == true){
+       		unlink($legendFilenameUserPolygon);
+       }
+       $pdf->ezSetY($myY - 7);
+       
+        $pdf->ezText("Element", 11, array("left" => 25));
+             // deletes image
+	    
+	    $pdf->ezSetDy(-15);             
+                    
+   } 
+	
+$pdf->ezText($legendFooter, 11);
+}//legend true
+/* ------------------------ 
+    end of legend  
+   ------------------------ */
+
+ob_clean();
+if($download == false){
+	$pdf->ezStream();
+}
+else{
+	$content = $pdf->ezOutput();
+
+	$fp = fopen($downloadFile,'w');
+	fwrite($fp,$content);
+	fclose($fp);
+	echo "<html><head></head><body><a href='".$downloadFile."'>".$downloadText."</a></body></html>";
+}
+?>

Modified: branches/mapbender_sld/http/print/printPDF.conf
===================================================================
--- branches/mapbender_sld/http/print/printPDF.conf	2007-11-23 13:08:46 UTC (rev 1828)
+++ branches/mapbender_sld/http/print/printPDF.conf	2007-11-23 13:14:53 UTC (rev 1829)
@@ -1,296 +1,385 @@
-<?php
-
-include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
-# filename for temporary imagefiles
-$filename = TMPDIR."/map_".substr(md5(uniqid(rand())),0,7).".png";
-
-/*
-* DOWNLOAD
-*/
-$download = false;
-$downloadFile = TMPDIR."/map_".substr(md5(uniqid(rand())),0,7).".pdf";
-$downloadText = "Download: Karte als PDF...";
-
-/*
-*run print as iframe or window
-*/
-$type = 'iframe';
-
-
-
-/*
-* Legend
-*/
-$legend=true;
-$label_legend = 'Legende drucken';
-$legendFilename = TMPDIR."/legend_".substr(md5(uniqid(rand())),0,7).".png";
-$legendText = "Legende";
-$legendFooter = "powered by Mapbender";
-$legendImage = "./img/mapbender_logo.png";
-$legendImage_width = 90;
-$legendImage_height = 13;
-
-
-# log requests, class 'class_log.php' required
-$log = false;
-
-# delete images:
-$unlink = true;
-
-# labeling
-if(CHARSET=="UTF-8"){ 
-	$new_comment1 = utf8_decode($_REQUEST["comment1"]);
-	$new_comment2 = utf8_decode($_REQUEST["comment2"]);
-}
-else{
-	$new_comment1 = $_REQUEST["comment1"];
-	$new_comment2 = $_REQUEST["comment2"];
-}
-
-$text1 = "Druckansicht";
-$text2 = "- Mapbender -";
-$text3 = "";
-$text4 = "Maßstab 1 : " . $_REQUEST["map_scale"];
-$text5 = "Datum: " . date("d.m.Y",strtotime("now"));;
-
-$text6 = "Notizen:";
-$text7 = "";
-
-$text8 = $new_comment1;
-$text9 = $new_comment2;
-$text10 = "";
-
-
-$text11 = "Der Auszug ist maschinell erzeugt, er ist ohne Unterschrift gültig.";
-$text12 = "Dieser Auszug ist gesetzlich geschützt (§ 3 Abs. 1 VermKatG NW). Vervielfältigungen, Umarbeitungen, Veröffentlichungen oder die Weitergabe an Dritte nur mit Zustimmung des";
-$text13 = "Herausgebers, ausgenommen Vervielfältigungen und Umarbeitungen zur innerdienstlichen Verwendung bei Behörden oder zum eigenen Gebrauch.";
-
-$text14 = "Dieser Auszug ist gesetzlich geschützt (§ 3 Abs. 1 VermKatG NW). Vervielfältigungen,";
-$text15 = "Umarbeitungen, Veröffentlichungen oder die Weitergabe an Dritte nur mit Zustimmung";
-$text16 = "des Herausgebers, ausgenommen Vervielfältigungen und Umarbeitungen zur inner-";
-$text17 = "dienstlichen Verwendung bei Behörden oder zum eigenen Gebrauch.";
-
-/*
-* Labeling for buttons, textfields ...
-*/
-
-$label_format = "Format:";
-$label_format_a4 = "A4";
-$label_format_a3 = "A3";
-$label_format_a2 = "A2";
-
-$label_orientation = "Orientation: ";
-$label_portrait = "portrait";
-$label_landscape = "landscape";
-
-$label_72dpi = "Quality: 72 dpi";
-$label_288dpi = "Quality: 288 dpi";
-
-$label_comment = "Comment (max. 30)";
-$comment_length = 30;
-
-$label_button = 'drucken';
-
-/*
-* default
-* url string matching and replacement
-*/
-$matching = false;
-$pattern =  "192.168.2.113";
-$replacement = "192.168.2.5";
-
-/*
-* high quality printing 288dpi
-* highquality mapfiles will be supplemented with "_4"
-* example: germany.map -> germany_4.map
-*/
-
-
-$highquality = true;
-$highqualitymapfiles = array(
-	"/data/umn/germany/germany_demo.map",
-	"/data/umn/mapbender_user/mapbender_user.map"
-);
-
-# Dots per cm (72 dpi):
-# 28.346456692913385826771653543307 
-$DPC = 28.35;
-
-# available formats:
-$a4 = true;
-$a3 = true;
-$a2 = true;
-
-
-# dimensions of the map:
-
-# A4 portrait
-$a4p_mapOffset_left = 3.3 * $DPC;
-$a4p_mapOffset_bottom = 3 * $DPC;
-$a4p_map_width = 15.7 * $DPC; 
-$a4p_map_height = 22 * $DPC; 
-$a4p_page_width = 21 * $DPC;
-$a4p_page_height = 29.7 * $DPC;
-$a4p_header_height = 2.6 * $DPC;
-$a4p_footer_height = 1.12 * $DPC;
-        
-# A4 landscape
-$a4l_mapOffset_left = 2.3 * $DPC;
-$a4l_mapOffset_bottom = 1.8 * $DPC;
-$a4l_map_width = 25.2 * $DPC;
-$a4l_map_height = 16.4 * $DPC; 
-$a4l_page_width = 29.7 * $DPC;
-$a4l_page_height = 21 * $DPC;   
-$a4l_header_width = 8.5 * $DPC;
-$a4l_header_height = 6 * $DPC;
-        
-# A3 protrait
-$a3p_mapOffset_left = 3.3 * $DPC;
-$a3p_mapOffset_bottom = 3 * $DPC;
-$a3p_map_width = 24.1 * $DPC;
-$a3p_map_height = 36.7 * $DPC;
-$a3p_page_width = 29.7 * $DPC;
-$a3p_page_height = 42 * $DPC;
-$a3p_header_width =  8.5 * $DPC;
-$a3p_header_height = 6 * $DPC;
-
-# A3 landscape        
-$a3l_mapOffset_left = 2.3 * $DPC;
-$a3l_mapOffset_bottom = 1.8 * $DPC;
-$a3l_map_width = 37.4 * $DPC;
-$a3l_map_height = 25.4 * $DPC; 
-$a3l_page_width = 42 * $DPC;
-$a3l_page_height = 29.7 * $DPC;
-$a3l_header_width =  8.5 * $DPC;
-$a3l_header_height = 6 * $DPC;
-
-# a2 protrait
-$a2p_mapOffset_left = 3.2 * $DPC;
-$a2p_mapOffset_bottom = 2.3 * $DPC;
-$a2p_map_width = 37.3 * $DPC;
-$a2p_map_height = 54.8 * $DPC;
-$a2p_page_width = 42 * $DPC;
-$a2p_page_height = 59.4 * $DPC;
-$a2p_header_width =  8.5 * $DPC;
-$a2p_header_height = 6 * $DPC;
-
-# a2 landscape        
-$a2l_mapOffset_left = 3.2 * $DPC;
-$a2l_mapOffset_bottom = 2.3 * $DPC;
-$a2l_map_width = 54.1 * $DPC;
-$a2l_map_height = 37.3 * $DPC; 
-$a2l_page_width = 59.4 * $DPC;
-$a2l_page_height = 42 * $DPC;
-$a2l_header_width =  8.5 * $DPC;
-$a2l_header_height = 6 * $DPC;
-
-
-/*
-* Overview
-*/
-$overview = true;
-$a4p_overviewOffset_left = $a4p_mapOffset_left;
-$a4p_overviewOffset_bottom = $a4p_mapOffset_bottom;
-
-$a4l_overviewOffset_left = $a4l_mapOffset_left;
-$a4l_overviewOffset_bottom = $a4l_mapOffset_bottom;
-
-$a3p_overviewOffset_left = $a3p_mapOffset_left;
-$a3p_overviewOffset_bottom = $a3p_mapOffset_bottom;
-
-$a3l_overviewOffset_left = $a3l_mapOffset_left;
-$a3l_overviewOffset_bottom = $a3l_mapOffset_bottom;
-
-$a2p_overviewOffset_left = $a2p_mapOffset_left;
-$a2p_overviewOffset_bottom = $a2p_mapOffset_bottom;
-
-$a2l_overviewOffset_left = $a2l_mapOffset_left;
-$a2l_overviewOffset_bottom = $a2l_mapOffset_bottom;
-
-
-
-/*
-* Northarrow
-*/
-$northarrow = true;
-$northarrowImage = "./img/northarrow.png";
-
-$a4p_northarrow_left = $a4p_mapOffset_left + 160;
-$a4p_northarrow_bottom = $a4p_mapOffset_bottom +2 ;
-
-$a4l_northarrow_left = $a4l_mapOffset_left + 5;
-$a4l_northarrow_bottom = $a4l_mapOffset_bottom + $a4l_map_height - 40;
-
-$a3p_northarrow_left = $a3p_mapOffset_left +5;
-$a3p_northarrow_bottom = $a3p_mapOffset_bottom + $a3p_map_height - 80;
-
-$a3l_northarrow_left = $a3l_mapOffset_left + 5;
-$a3l_northarrow_bottom = $a3l_mapOffset_bottom + $a3l_map_height - 40;
-
-$a2p_northarrow_left = $a2p_mapOffset_left +5;
-$a2p_northarrow_bottom = $a2p_mapOffset_bottom + $a2p_map_height - 80;
-
-$a2l_northarrow_left = $a2l_mapOffset_left + 5;
-$a2l_northarrow_bottom = $a2l_mapOffset_bottom + $a2l_map_height - 80;
-
-$northarrowImage_width = 15; 
-$northarrowImage_height = 35; 
-
-/*
-* special image for the map-page
-*/
-$special = true;
-$specialImage = "../img/mapbender_oo.png";
-
-$a4p_special_left = $a4p_mapOffset_left + $a4p_map_width - 50 ;
-$a4p_special_bottom = $a4p_mapOffset_bottom + $a4p_map_height + 80; 
-
-$a4l_special_left = $a4l_mapOffset_left + $a4l_map_width - $a4l_header_width + 0.8 * $DPC + 10 ;
-$a4l_special_bottom = $a4l_mapOffset_bottom + 54; 
-
-$a3p_special_left = $a3p_mapOffset_left + $a3p_map_width - $a3p_header_width ;
-$a3p_special_bottom = $a3p_mapOffset_bottom + 30; 
-
-$a3l_special_left = $a3l_mapOffset_left + $a3l_map_width - $a3l_header_width + 0.8 * $DPC + 10;
-$a3l_special_bottom = $a3l_mapOffset_bottom + 60; 
-
-$a2p_special_left = $a2p_mapOffset_left + $a2p_map_width - $a2p_header_width + 0.1 *$DPC ;
-$a2p_special_bottom = $a2p_mapOffset_bottom + 110; 
-
-$a2l_special_left = $a2l_mapOffset_left + $a2l_map_width - $a2l_header_width + 0.2 * $DPC ;
-$a2l_special_bottom = $a2l_mapOffset_bottom + 110; 
-
-
-$specialImage_width = 65; 
-$specialImage_height = 15; 
-
-
-/*
-* dynamic scalebar
-*/
-$scalebar = true;
-$units = "Meter";
-
-$a4p_scalebar_left = $a4p_mapOffset_left + 2 * $a4p_map_width/3;
-$a4p_scalebar_bottom = $a4p_mapOffset_bottom  + 0.5 * $DPC;
-
-$a4l_scalebar_left = $a4l_mapOffset_left + $a4l_map_width/4 ;
-$a4l_scalebar_bottom = $a4l_mapOffset_bottom +  + 0.5 * $DPC;
-
-$a3p_scalebar_left = $a3p_mapOffset_left  + $a3p_map_width/4 ;
-$a3p_scalebar_bottom = $a3p_mapOffset_bottom + 0.5 * $DPC;
-
-$a3l_scalebar_left = $a3l_mapOffset_left  + $a3l_map_width/4 ;
-$a3l_scalebar_bottom = $a3l_mapOffset_bottom +  + 0.5 * $DPC;
-
-$a2p_scalebar_left = $a2p_mapOffset_left  + $a2p_map_width/4 ;
-$a2p_scalebar_bottom = $a2p_mapOffset_bottom + 0.5 * $DPC;
-
-$a2l_scalebar_left = $a2l_mapOffset_left  + $a2l_map_width/4 ;
-$a2l_scalebar_bottom = $a2l_mapOffset_bottom +  + 0.5 * $DPC;
-
-$scalebar_width = 3 * $DPC;
-$scalebar_height = 0.18 * $DPC;
- 
-
-?>
+<?php
+
+include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+# filename for temporary imagefiles
+$filename = TMPDIR."/map_".substr(md5(uniqid(rand())),0,7).".png";
+
+/*
+* DOWNLOAD
+*/
+$download = true;
+$downloadFile = TMPDIR."/map_".substr(md5(uniqid(rand())),0,7).".pdf";
+$downloadText = _("Download: Map as PDF...");
+
+/*
+*run print as iframe or window
+*/
+$type = 'iframe';
+
+
+
+/*
+* Legend
+*/
+$legend=true;
+$label_legend = _('print legend');
+$legendFilename = TMPDIR."/legend_".substr(md5(uniqid(rand())),0,7).".png";
+$legendFilenameUserPolygon = TMPDIR."/legend_".substr(md5(uniqid(rand())),0,7).".png";
+$legendText = _("Legend");
+$legendFooter = _("powered by Mapbender");
+$legendImage = "./img/mapbender_logo.png";
+$legendImage_width = 90;
+$legendImage_height = 13;
+
+
+# log requests, class 'class_log.php' required
+$log = false;
+
+# delete images:
+$unlink = true;
+
+# labeling
+if(CHARSET=="UTF-8"){ 
+	$new_comment1 = utf8_decode($_REQUEST["comment1"]);
+	$new_comment2 = utf8_decode($_REQUEST["comment2"]);
+}
+else{
+	$new_comment1 = $_REQUEST["comment1"];
+	$new_comment2 = $_REQUEST["comment2"];
+}
+
+$text1 = _("Print preview");
+$text2 = "- Mapbender -";
+$text3 = "";
+$text4 = _("Scale 1:"). " ".$_REQUEST["map_scale"];
+$text5 = _("Date:") . " ".date("d.m.Y",strtotime("now"));
+
+$text6 = _("Notes:");
+$text7 = "";
+$text8 = $new_comment1;
+$text9 = $new_comment2;
+$text10 = "";
+
+
+$text11 = _("This copy has been automatically generated and is thus not valid without signature.");
+$text12 = _("This copy is protected by law (Par. 3 Abs. 1 VermKatG NW). It can be duplicaedted, modified, published or be passed to third parties only in agreement with");
+$text13 = _("the publisher, except duplicates and modifications aimed at internal use of government agencies or private use.");
+
+$text14 = _("This copy is protected,");
+$text15 = _("ask me!!!!");
+$text16 = _("or the publisher");
+$text17 = _("or use is internally.");
+
+/*
+* Labeling for buttons, textfields ...
+*/
+
+$label_format = _("Format:");
+$label_format_a4 = "A4";
+$label_format_a3 = "A3";
+$label_format_a2 = "A2";
+$label_format_a1 = "A1";
+$label_format_a0 = "A0";
+
+$label_orientation = _("Orientation:");
+$label_portrait = _("portrait");
+$label_landscape = _("landscape");
+
+$label_72dpi = sprintf(_("Quality: %d dpi"), 72);
+$label_288dpi = sprintf(_("Quality: %d dpi"), 288);
+
+$label_comment = _("Comment (max. 30)");
+$comment_length = 30;
+
+$label_button = _('print');
+
+/*
+* default
+* url string matching and replacement
+*/
+$matching = false;
+$pattern =  "/192\.168\.2\.113/";
+$replacement = "192.168.2.5";
+
+/*
+* high quality printing 288dpi
+* highquality mapfiles will be supplemented with "_4"
+* example: germany.map -> germany_4.map
+*/
+
+
+$highquality = true;
+$highqualitymapfiles = array(
+	"/data/umn/germany/germany_demo.map",
+	"/data/umn/mapbender_user/mapbender_user.map"
+);
+
+# Dots per cm (72 dpi):
+# 28.346456692913385826771653543307 
+$DPC = 28.35;
+
+# available formats:
+$a4 = true;
+$a3 = true;
+$a2 = true;
+$a1 = false;
+$a0 = false;
+
+# dimensions of the map:
+
+# A4 portrait
+$a4p_mapOffset_left = 3.3 * $DPC;
+$a4p_mapOffset_bottom = 3 * $DPC;
+$a4p_map_width = 15.7 * $DPC; 
+$a4p_map_height = 22 * $DPC; 
+$a4p_page_width = 21 * $DPC;
+$a4p_page_height = 29.7 * $DPC;
+$a4p_header_height = 2.6 * $DPC;
+$a4p_footer_height = 1.12 * $DPC;
+        
+# A4 landscape
+$a4l_mapOffset_left = 2.3 * $DPC;
+$a4l_mapOffset_bottom = 1.8 * $DPC;
+$a4l_map_width = 25.2 * $DPC;
+$a4l_map_height = 16.4 * $DPC; 
+$a4l_page_width = 29.7 * $DPC;
+$a4l_page_height = 21 * $DPC;   
+$a4l_header_width = 8.5 * $DPC;
+$a4l_header_height = 6 * $DPC;
+        
+# A3 protrait
+$a3p_mapOffset_left = 3.3 * $DPC;
+$a3p_mapOffset_bottom = 3 * $DPC;
+$a3p_map_width = 24.1 * $DPC;
+$a3p_map_height = 36.7 * $DPC;
+$a3p_page_width = 29.7 * $DPC;
+$a3p_page_height = 42 * $DPC;
+$a3p_header_width =  8.5 * $DPC;
+$a3p_header_height = 6 * $DPC;
+
+# A3 landscape        
+$a3l_mapOffset_left = 2.3 * $DPC;
+$a3l_mapOffset_bottom = 1.8 * $DPC;
+$a3l_map_width = 37.4 * $DPC;
+$a3l_map_height = 25.4 * $DPC; 
+$a3l_page_width = 42 * $DPC;
+$a3l_page_height = 29.7 * $DPC;
+$a3l_header_width =  8.5 * $DPC;
+$a3l_header_height = 6 * $DPC;
+
+# a2 protrait
+$a2p_mapOffset_left = 3.2 * $DPC;
+$a2p_mapOffset_bottom = 2.3 * $DPC;
+$a2p_map_width = 37.3 * $DPC;
+$a2p_map_height = 54.8 * $DPC;
+$a2p_page_width = 42 * $DPC;
+$a2p_page_height = 59.4 * $DPC;
+$a2p_header_width =  8.5 * $DPC;
+$a2p_header_height = 6 * $DPC;
+
+# a2 landscape        
+$a2l_mapOffset_left = 3.2 * $DPC;
+$a2l_mapOffset_bottom = 2.3 * $DPC;
+$a2l_map_width = 54.1 * $DPC;
+$a2l_map_height = 37.3 * $DPC; 
+$a2l_page_width = 59.4 * $DPC;
+$a2l_page_height = 42 * $DPC;
+$a2l_header_width =  8.5 * $DPC;
+$a2l_header_height = 6 * $DPC;
+
+# a1 portrait
+$a1p_mapOffset_left = 3.2 * $DPC;
+$a1p_mapOffset_bottom = 2.3 * $DPC;
+$a1p_map_width = 54.5 * $DPC;
+$a1p_map_height = 79.5 * $DPC;
+$a1p_page_width = 59.4 * $DPC;
+$a1p_page_height = 84 * $DPC;
+$a1p_header_width =  8.5 * $DPC;
+$a1p_header_height = 6 * $DPC;
+
+# a1 landscape        
+$a1l_mapOffset_left = 3.2 * $DPC;
+$a1l_mapOffset_bottom = 2.3 * $DPC;
+$a1l_map_width = 79.5 * $DPC;
+$a1l_map_height = 55.5 * $DPC; 
+$a1l_page_width = 84 * $DPC;
+$a1l_page_height = 59.4 * $DPC;
+$a1l_header_width =  8.5 * $DPC;
+$a1l_header_height = 6 * $DPC;
+
+# a0 portrait
+$a0p_mapOffset_left = 3.2 * $DPC;
+$a0p_mapOffset_bottom = 2.3 * $DPC;
+$a0p_map_width = 79 * $DPC;
+$a0p_map_height = 115 * $DPC;
+$a0p_page_width = 84 * $DPC;
+$a0p_page_height = 118.8 * $DPC;
+$a0p_header_width =  8.5 * $DPC;
+$a0p_header_height = 6 * $DPC;
+
+# a0 landscape        
+$a0l_mapOffset_left = 3.2 * $DPC;
+$a0l_mapOffset_bottom = 2.3 * $DPC;
+$a0l_map_width = 113 * $DPC;
+$a0l_map_height = 80.5 * $DPC; 
+$a0l_page_width = 118.8 * $DPC;
+$a0l_page_height = 84 * $DPC;
+$a0l_header_width =  8.5 * $DPC;
+$a0l_header_height = 6 * $DPC;
+
+/*
+* Overview
+*/
+$overview = true;
+$a4p_overviewOffset_left = $a4p_mapOffset_left;
+$a4p_overviewOffset_bottom = $a4p_mapOffset_bottom;
+
+$a4l_overviewOffset_left = $a4l_mapOffset_left;
+$a4l_overviewOffset_bottom = $a4l_mapOffset_bottom;
+
+$a3p_overviewOffset_left = $a3p_mapOffset_left;
+$a3p_overviewOffset_bottom = $a3p_mapOffset_bottom;
+
+$a3l_overviewOffset_left = $a3l_mapOffset_left;
+$a3l_overviewOffset_bottom = $a3l_mapOffset_bottom;
+
+$a2p_overviewOffset_left = $a2p_mapOffset_left;
+$a2p_overviewOffset_bottom = $a2p_mapOffset_bottom;
+
+$a2l_overviewOffset_left = $a2l_mapOffset_left;
+$a2l_overviewOffset_bottom = $a2l_mapOffset_bottom;
+
+$a1p_overviewOffset_left = $a1p_mapOffset_left;
+$a1p_overviewOffset_bottom = $a1p_mapOffset_bottom;
+
+$a1l_overviewOffset_left = $a1l_mapOffset_left;
+$a1l_overviewOffset_bottom = $a1l_mapOffset_bottom;
+
+$a0p_overviewOffset_left = $a0p_mapOffset_left;
+$a0p_overviewOffset_bottom = $a0p_mapOffset_bottom;
+
+$a0l_overviewOffset_left = $a0l_mapOffset_left;
+$a0l_overviewOffset_bottom = $a0l_mapOffset_bottom;
+
+
+
+/*
+* Northarrow
+*/
+$northarrow = true;
+$northarrowImage = "./img/northarrow.png";
+
+$a4p_northarrow_left = $a4p_mapOffset_left + 160;
+$a4p_northarrow_bottom = $a4p_mapOffset_bottom +2 ;
+
+$a4l_northarrow_left = $a4l_mapOffset_left + 5;
+$a4l_northarrow_bottom = $a4l_mapOffset_bottom + $a4l_map_height - 40;
+
+$a3p_northarrow_left = $a3p_mapOffset_left +5;
+$a3p_northarrow_bottom = $a3p_mapOffset_bottom + $a3p_map_height - 80;
+
+$a3l_northarrow_left = $a3l_mapOffset_left + 5;
+$a3l_northarrow_bottom = $a3l_mapOffset_bottom + $a3l_map_height - 40;
+
+$a2p_northarrow_left = $a2p_mapOffset_left +5;
+$a2p_northarrow_bottom = $a2p_mapOffset_bottom + $a2p_map_height - 80;
+
+$a2l_northarrow_left = $a2l_mapOffset_left + 5;
+$a2l_northarrow_bottom = $a2l_mapOffset_bottom + $a2l_map_height - 80;
+
+$a1p_northarrow_left = $a1p_mapOffset_left +5;
+$a1p_northarrow_bottom = $a1p_mapOffset_bottom + $a1p_map_height - 80;
+
+$a1l_northarrow_left = $a1l_mapOffset_left + 5;
+$a1l_northarrow_bottom = $a1l_mapOffset_bottom + $a1l_map_height - 160;
+
+$a0p_northarrow_left = $a0p_mapOffset_left +5;
+$a0p_northarrow_bottom = $a0p_mapOffset_bottom + $a0p_map_height - 80;
+
+$a0l_northarrow_left = $a0l_mapOffset_left + 5;
+$a0l_northarrow_bottom = $a0l_mapOffset_bottom + $a0l_map_height - 160;
+
+$northarrowImage_width = 15; 
+$northarrowImage_height = 35; 
+
+/*
+* special image for the map-page
+*/
+$special = true;
+$specialImage = "../img/mapbender_oo.png";
+
+$a4p_special_left = $a4p_mapOffset_left + $a4p_map_width - 50 ;
+$a4p_special_bottom = $a4p_mapOffset_bottom + $a4p_map_height + 80; 
+
+$a4l_special_left = $a4l_mapOffset_left + $a4l_map_width - $a4l_header_width + 0.8 * $DPC + 10 ;
+$a4l_special_bottom = $a4l_mapOffset_bottom + 54; 
+
+$a3p_special_left = $a3p_mapOffset_left + $a3p_map_width - $a3p_header_width ;
+$a3p_special_bottom = $a3p_mapOffset_bottom + 30; 
+
+$a3l_special_left = $a3l_mapOffset_left + $a3l_map_width - $a3l_header_width + 0.8 * $DPC + 10;
+$a3l_special_bottom = $a3l_mapOffset_bottom + 60; 
+
+$a2p_special_left = $a2p_mapOffset_left + $a2p_map_width - $a2p_header_width + 0.1 *$DPC ;
+$a2p_special_bottom = $a2p_mapOffset_bottom + 110; 
+
+$a2l_special_left = $a2l_mapOffset_left + $a2l_map_width - $a2l_header_width + 0.2 * $DPC ;
+$a2l_special_bottom = $a2l_mapOffset_bottom + 110; 
+
+$a1p_special_left = $a1p_mapOffset_left + $a1p_map_width - $a1p_header_width + 0.1 *$DPC ;
+$a1p_special_bottom = $a1p_mapOffset_bottom + 110; 
+
+$a1l_special_left = $a1l_mapOffset_left + $a1l_map_width - $a1l_header_width + 0.2 * $DPC ;
+$a1l_special_bottom = $a1l_mapOffset_bottom + 110; 
+
+$a0p_special_left = $a0p_mapOffset_left + $a0p_map_width - $a0p_header_width + 0.1 *$DPC ;
+$a0p_special_bottom = $a0p_mapOffset_bottom + 110; 
+
+$a0l_special_left = $a0l_mapOffset_left + $a0l_map_width - $a0l_header_width + 0.2 * $DPC ;
+$a0l_special_bottom = $a0l_mapOffset_bottom + 110; 
+
+$specialImage_width = 65; 
+$specialImage_height = 15;  
+
+
+/*
+* dynamic scalebar
+*/
+$scalebar = true;
+$units = "Meter";
+
+$a4p_scalebar_left = $a4p_mapOffset_left + 2 * $a4p_map_width/3;
+$a4p_scalebar_bottom = $a4p_mapOffset_bottom  + 0.5 * $DPC;
+
+$a4l_scalebar_left = $a4l_mapOffset_left + $a4l_map_width/4 ;
+$a4l_scalebar_bottom = $a4l_mapOffset_bottom +  + 0.5 * $DPC;
+
+$a3p_scalebar_left = $a3p_mapOffset_left  + $a3p_map_width/4 ;
+$a3p_scalebar_bottom = $a3p_mapOffset_bottom + 0.5 * $DPC;
+
+$a3l_scalebar_left = $a3l_mapOffset_left  + $a3l_map_width/4 ;
+$a3l_scalebar_bottom = $a3l_mapOffset_bottom +  + 0.5 * $DPC;
+
+$a2p_scalebar_left = $a2p_mapOffset_left  + $a2p_map_width/4 ;
+$a2p_scalebar_bottom = $a2p_mapOffset_bottom + 0.5 * $DPC;
+
+$a2l_scalebar_left = $a2l_mapOffset_left  + $a2l_map_width/4 ;
+$a2l_scalebar_bottom = $a2l_mapOffset_bottom +  + 0.5 * $DPC;
+
+$a1p_scalebar_left = $a1p_mapOffset_left  + $a1p_map_width/4 ;
+$a1p_scalebar_bottom = $a1p_mapOffset_bottom + 0.5 * $DPC;
+
+$a1l_scalebar_left = $a1l_mapOffset_left  + $a1l_map_width/4 ;
+$a1l_scalebar_bottom = $a1l_mapOffset_bottom +  + 0.5 * $DPC;
+
+$a0p_scalebar_left = $a0p_mapOffset_left  + $a0p_map_width/4 ;
+$a0p_scalebar_bottom = $a0p_mapOffset_bottom + 0.5 * $DPC;
+
+$a0l_scalebar_left = $a0l_mapOffset_left  + $a0l_map_width/4 ;
+$a0l_scalebar_bottom = $a0l_mapOffset_bottom +  + 0.5 * $DPC;
+
+$scalebar_width = 3 * $DPC;
+$scalebar_height = 0.18 * $DPC;
+ 
+
+?>

Modified: branches/mapbender_sld/http/print/printPDF_b.conf
===================================================================
--- branches/mapbender_sld/http/print/printPDF_b.conf	2007-11-23 13:08:46 UTC (rev 1828)
+++ branches/mapbender_sld/http/print/printPDF_b.conf	2007-11-23 13:14:53 UTC (rev 1829)
@@ -7,7 +7,7 @@
 /*
 * DOWNLOAD
 */
-$download = false;
+$download = true;
 $downloadFile = TMPDIR."/map_".substr(md5(uniqid(rand())),0,7).".pdf";
 $downloadText = "Download: Karte als PDF...";
 
@@ -24,6 +24,7 @@
 $legend=true;
 $label_legend = 'print legend';
 $legendFilename = TMPDIR."/legend_".substr(md5(uniqid(rand())),0,7).".png";
+$legendFilenameUserPolygon = TMPDIR."/legend_".substr(md5(uniqid(rand())),0,7).".png";
 $legendText = "Legende";
 $legendFooter = "powered by Mapbender";
 $legendImage = "./img/mapbender_logo.png";
@@ -77,6 +78,8 @@
 $label_format_a4 = "A4";
 $label_format_a3 = "A3";
 $label_format_a2 = "A2";
+$label_format_a1 = "A1";
+$label_format_a0 = "A0";
 
 $label_orientation = "Orientation: ";
 $label_portrait = "portrait";
@@ -88,14 +91,14 @@
 $label_comment = "Comment (max. 30)";
 $comment_length = 30;
 
-$label_button = 'drucken';
+$label_button = 'print';
 
 /*
 * default
 * url string matching and replacement
 */
 $matching = false;
-$pattern =  "192.168.2.113";
+$pattern =  "/192\.168\.2\.113/";
 $replacement = "192.168.2.5";
 
 /*
@@ -119,8 +122,9 @@
 $a4 = true;
 $a3 = true;
 $a2 = true;
+$a1 = true;
+$a0 = true;
 
-
 # dimensions of the map:
 
 # A4 portrait
@@ -183,7 +187,46 @@
 $a2l_header_width =  8.5 * $DPC;
 $a2l_header_height = 6 * $DPC;
 
+# a1 portrait
+$a1p_mapOffset_left = 3.2 * $DPC;
+$a1p_mapOffset_bottom = 2.3 * $DPC;
+$a1p_map_width = 54.5 * $DPC;
+$a1p_map_height = 79.5 * $DPC;
+$a1p_page_width = 59.4 * $DPC;
+$a1p_page_height = 84 * $DPC;
+$a1p_header_width =  8.5 * $DPC;
+$a1p_header_height = 6 * $DPC;
 
+# a1 landscape        
+$a1l_mapOffset_left = 3.2 * $DPC;
+$a1l_mapOffset_bottom = 2.3 * $DPC;
+$a1l_map_width = 79.5 * $DPC;
+$a1l_map_height = 55.5 * $DPC; 
+$a1l_page_width = 84 * $DPC;
+$a1l_page_height = 59.4 * $DPC;
+$a1l_header_width =  8.5 * $DPC;
+$a1l_header_height = 6 * $DPC;
+
+# a0 portrait
+$a0p_mapOffset_left = 3.2 * $DPC;
+$a0p_mapOffset_bottom = 2.3 * $DPC;
+$a0p_map_width = 79 * $DPC;
+$a0p_map_height = 115 * $DPC;
+$a0p_page_width = 84 * $DPC;
+$a0p_page_height = 118.8 * $DPC;
+$a0p_header_width =  8.5 * $DPC;
+$a0p_header_height = 6 * $DPC;
+
+# a0 landscape        
+$a0l_mapOffset_left = 3.2 * $DPC;
+$a0l_mapOffset_bottom = 2.3 * $DPC;
+$a0l_map_width = 113 * $DPC;
+$a0l_map_height = 80.5 * $DPC; 
+$a0l_page_width = 118.8 * $DPC;
+$a0l_page_height = 84 * $DPC;
+$a0l_header_width =  8.5 * $DPC;
+$a0l_header_height = 6 * $DPC;
+
 /*
 * Overview
 */
@@ -206,8 +249,20 @@
 $a2l_overviewOffset_left = $a2l_mapOffset_left;
 $a2l_overviewOffset_bottom = $a2l_mapOffset_bottom;
 
+$a1p_overviewOffset_left = $a1p_mapOffset_left;
+$a1p_overviewOffset_bottom = $a1p_mapOffset_bottom;
 
+$a1l_overviewOffset_left = $a1l_mapOffset_left;
+$a1l_overviewOffset_bottom = $a1l_mapOffset_bottom;
 
+$a0p_overviewOffset_left = $a0p_mapOffset_left;
+$a0p_overviewOffset_bottom = $a0p_mapOffset_bottom;
+
+$a0l_overviewOffset_left = $a0l_mapOffset_left;
+$a0l_overviewOffset_bottom = $a0l_mapOffset_bottom;
+
+
+
 /*
 * Northarrow
 */
@@ -232,6 +287,18 @@
 $a2l_northarrow_left = $a2l_mapOffset_left + 5;
 $a2l_northarrow_bottom = $a2l_mapOffset_bottom + $a2l_map_height - 80;
 
+$a1p_northarrow_left = $a1p_mapOffset_left +5;
+$a1p_northarrow_bottom = $a1p_mapOffset_bottom + $a1p_map_height - 80;
+
+$a1l_northarrow_left = $a1l_mapOffset_left + 5;
+$a1l_northarrow_bottom = $a1l_mapOffset_bottom + $a1l_map_height - 160;
+
+$a0p_northarrow_left = $a0p_mapOffset_left +5;
+$a0p_northarrow_bottom = $a0p_mapOffset_bottom + $a0p_map_height - 80;
+
+$a0l_northarrow_left = $a0l_mapOffset_left + 5;
+$a0l_northarrow_bottom = $a0l_mapOffset_bottom + $a0l_map_height - 160;
+
 $northarrowImage_width = 15; 
 $northarrowImage_height = 35; 
 
@@ -259,7 +326,18 @@
 $a2l_special_left = $a2l_mapOffset_left + $a2l_map_width - $a2l_header_width + 0.2 * $DPC ;
 $a2l_special_bottom = $a2l_mapOffset_bottom + 110; 
 
+$a1p_special_left = $a1p_mapOffset_left + $a1p_map_width - $a1p_header_width + 0.1 *$DPC ;
+$a1p_special_bottom = $a1p_mapOffset_bottom + 110; 
 
+$a1l_special_left = $a1l_mapOffset_left + $a1l_map_width - $a1l_header_width + 0.2 * $DPC ;
+$a1l_special_bottom = $a1l_mapOffset_bottom + 110; 
+
+$a0p_special_left = $a0p_mapOffset_left + $a0p_map_width - $a0p_header_width + 0.1 *$DPC ;
+$a0p_special_bottom = $a0p_mapOffset_bottom + 110; 
+
+$a0l_special_left = $a0l_mapOffset_left + $a0l_map_width - $a0l_header_width + 0.2 * $DPC ;
+$a0l_special_bottom = $a0l_mapOffset_bottom + 110; 
+
 $specialImage_width = 65; 
 $specialImage_height = 15;  
 
@@ -288,6 +366,18 @@
 $a2l_scalebar_left = $a2l_mapOffset_left  + $a2l_map_width/4 ;
 $a2l_scalebar_bottom = $a2l_mapOffset_bottom +  + 0.5 * $DPC;
 
+$a1p_scalebar_left = $a1p_mapOffset_left  + $a1p_map_width/4 ;
+$a1p_scalebar_bottom = $a1p_mapOffset_bottom + 0.5 * $DPC;
+
+$a1l_scalebar_left = $a1l_mapOffset_left  + $a1l_map_width/4 ;
+$a1l_scalebar_bottom = $a1l_mapOffset_bottom +  + 0.5 * $DPC;
+
+$a0p_scalebar_left = $a0p_mapOffset_left  + $a0p_map_width/4 ;
+$a0p_scalebar_bottom = $a0p_mapOffset_bottom + 0.5 * $DPC;
+
+$a0l_scalebar_left = $a0l_mapOffset_left  + $a0l_map_width/4 ;
+$a0l_scalebar_bottom = $a0l_mapOffset_bottom +  + 0.5 * $DPC;
+
 $scalebar_width = 3 * $DPC;
 $scalebar_height = 0.18 * $DPC;
  

Added: branches/mapbender_sld/http/print/print_functions.php
===================================================================
--- branches/mapbender_sld/http/print/print_functions.php	                        (rev 0)
+++ branches/mapbender_sld/http/print/print_functions.php	2007-11-23 13:14:53 UTC (rev 1829)
@@ -0,0 +1,375 @@
+<?php
+/**
+ * converts the coordinates created via the JavaScript
+ * functions in 'mod_measure.php' into an array which 
+ * then holds both X- ans Y-values for each point in
+ * the formats 'realworld coordinate' and 'pdf_coordinate' 
+ * 
+ * @param string commaseperated X-values of the points (realworld coordinate)
+ * @param string commaseperated Y-values of the points (realworld coordinate)
+ * 
+ * @return array Array looking like 0 => array(
+ *                                         'real_x' => 1234567,
+ *                                         'real_y' => 7654321,
+ *                                         'pdf_x'  => 451.12,
+ *                                         'pdf_y'  => 254.7          
+ *                                       )
+ * 
+ * @see transformForPDF
+ *
+ * @author M. Jansen <jansen at terrestris.de>, 2006-05-26
+ */
+function makeCoordPairs($x_values, $y_values) {
+  $arr_x = explode(",", $x_values);
+	$arr_y = explode(",", $y_values);
+	$x_elems = count($arr_x);
+	$y_elems = count($arr_y);
+	
+	$the_return_arr = array();
+	
+	if ($x_elems == $y_elems) {
+	  for ($i = 0; $i < $x_elems; $i ++) {
+		  $the_return_arr[$i] = array(
+			                        "real_x" => $arr_x[$i],
+															"real_y" => $arr_y[$i],
+															"pdf_x"  => transformForPDF($arr_x[$i], "x"),
+															"pdf_y"  => transformForPDF($arr_y[$i], "y")
+															);
+		}
+	}
+	
+	return $the_return_arr;
+} // end of function makeCoordPairs
+
+
+
+/**
+ * Transforms given realworld-coordinate according to its type (X or Y) 
+ * into a pdf-coordinate. Needs the variables $mapOffset_left, $mapOffset_bottom,
+ * $map_height, $map_width, $coord to be defined in a global scope.
+ *
+ * @param float the realworld coordinate
+ * @param string type of coordinate either 'X' or 'Y'
+ *   
+ * @see makeCoordPairs [needs this function]
+ *
+ * @return float the pdf-coordinate
+ *
+ * @author M. Jansen <jansen at terrestris.de>, 2006-05-26
+ */
+function transformForPDF ($theRealCoord, $theType) {
+  global $mapOffset_left, $mapOffset_bottom, $map_height, $map_width, $coord;
+	
+	$thePDFvalue = "";
+	
+	switch (mb_strtolower($theType)) {
+	  case 'x':
+		  // calculate pdf x-pos:
+			$real_shown_width = $coord[2] - $coord[0];
+			$ratio_to_display = $map_width / $real_shown_width;
+			$target_width     = $theRealCoord - $coord[0];
+			$thePDFvalue      = $mapOffset_left + ($target_width * $ratio_to_display);
+			break;
+		case 'y':
+		  // calculate pdf y-pos:
+			$real_shown_height = $coord[3] - $coord[1];
+			$ratio_to_display  = $map_height / $real_shown_height;
+			$target_height     = $theRealCoord - $coord[1];
+			$thePDFvalue       = $mapOffset_bottom + ($target_height * $ratio_to_display);
+		  break;
+		default:
+		  // a non valid parameter was given
+		  $thePDFvalue = $theRealCoord;
+      break;
+	}
+	return $thePDFvalue;
+} // end of function transformForPDF
+
+
+
+
+/**
+ * extracts PDF-relevant information from a full coordinates array 
+ * and returns a transformed array
+ * 
+ * @param array the Array containing all infos about single coordinates
+ *              created via makeCoordPairs()
+ * 
+ * @return array the array containing PDF-Values for a polygon
+ *
+ * @see makeCoordPairs
+ *
+ * @author M. Jansen <jansen at terrestris.de>, 2006-05-26
+ */
+function makePolyFromCoord($theFullCoordinatesArray) {
+  $theRetArr = array();
+	foreach($theFullCoordinatesArray as $singlePoint) {
+	  $theRetArr[] = $singlePoint['pdf_x'];
+		$theRetArr[] = $singlePoint['pdf_y'];
+	}
+	return $theRetArr;
+} // end of function makePolyFromCoord
+
+
+
+
+/**
+ * converts an array of coordinates (created e.g. by makeCoordPairs()) into
+ * an array thats needed to draw lines via line(x0, y0, x1, y1)
+ *
+ * @param array the Array containing all infos about single coordinates
+ *              created via makeCoordPairs()
+ * 
+ * @return array the array containing PDF-Values for single lines
+ *
+ * @see makeCoordPairs
+ *
+ * @author M. Jansen <jansen at terrestris.de>, 2006-05-26
+ */
+function makeStrokePointPairs($thePointArray) {
+  $cnt = count($thePointArray);
+	$theRetArray = array();
+  for($i = 0; $i < $cnt; $i++) {
+	  if($i != $cnt - 1) {
+		  $theRetArray[] = array(
+		    $thePointArray[$i]['pdf_x'],
+				$thePointArray[$i]['pdf_y'],
+				$thePointArray[$i+1]['pdf_x'],
+				$thePointArray[$i+1]['pdf_y'],
+				);
+		} else {
+		  $theRetArray[] = array(
+		    $thePointArray[$i]['pdf_x'],
+				$thePointArray[$i]['pdf_y'],
+				$thePointArray[0]['pdf_x'],
+				$thePointArray[0]['pdf_y'],
+				);
+		}
+	}
+	return $theRetArray;
+} // end of function makeStrokePointPairs
+
+
+
+
+/**
+ * test whether the coordinates in an array form a closed polygon
+ * meaning that first an last point of polygon are equal
+ *
+ * @param array the Array containing all infos about single coordinates
+ *              created via makeCoordPairs()
+ * 
+ * @return bool is it closed (TRUE || FALSE)
+ *
+ * @see makeCoordPairs
+ *
+ * @author M. Jansen <jansen at terrestris.de>, 2006-05-26
+ */
+function isClosedPolygon($coord_arr) {
+  $nr_of = count($coord_arr);
+	if ($coord_arr[0]['pdf_x'] == $coord_arr[$nr_of-1]['pdf_x']
+	    && $coord_arr[0]['pdf_y'] == $coord_arr[$nr_of-1]['pdf_y']
+			&& $nr_of != 1) {
+	  return TRUE; 
+	} else {
+	  return FALSE;
+	}
+}  // end of function isClosedPolygon
+
+
+
+
+/**
+ * Adds the measured item to the PDF output.
+ * 
+ * @param object reference (!) to the current ezPDF-Object
+ * @param string commaseperated X-Values of polygon / line
+ * @param string commaseperated Y-Values of polygon / line
+ * @param array configuration settings.
+ *
+ * @return void nothing
+ *
+ * @see makeCoordPairs
+ * @see isClosedPolygon
+ * @see makeStrokePointPairs
+ * @see makePolyFromCoord
+ * @see transformForPDF
+ * @see makeCoordPairs
+ *
+ * @author M. Jansen <jansen at terrestris.de>, 2006-05-26
+ */
+function addMeasuredItem($thePDF, $x_value_str, $y_value_str, $theConfArray = array()) {
+  // get global variable:
+  global $legendFilenameUserPolygon;
+	// create legend image:
+	$legend_width = 17;
+	$leg_img = imagecreate($legend_width, $legend_width);
+	// save previous state:
+	$thePDF->saveState();
+	
+	// save colors for legend:
+	if(!defined("MAP_HAS_USER_POLYGON")) {
+	  define("MAP_HAS_USER_POLYGON", "test");
+	}
+
+	// get the arrays
+	$theFullArr = makeCoordPairs($x_value_str, $y_value_str);
+    $thePolyArr = makePolyFromCoord($theFullArr);
+	
+	if (isClosedPolygon($theFullArr)) {
+	  $nr_of_points = count($theFullArr);
+		$isClosed = TRUE;
+	} else {
+	  $nr_of_points = count($theFullArr) - 1;
+		$isClosed = FALSE;
+	}
+	
+	// is fill option set?
+	// wenn der erste und letzte punkt nicht �bereinstimmen,
+	// so muss in jedem Falle dofill auf 0 gesetzt werden
+	if($theConfArray['do_fill'] != '' && $isClosed) {
+	  $doFill = 1;
+	  // which color to use for filling?
+	  if (is_array($theConfArray['fill_color']) 
+	      && $theConfArray['fill_color']['r'] != ''
+			  && $theConfArray['fill_color']['g'] != ''
+			  && $theConfArray['fill_color']['b'] != '') {
+	    $thePDF->setColor($theConfArray['fill_color']['r'], $theConfArray['fill_color']['g'], $theConfArray['fill_color']['b']);
+			$legend_image_fill = $theConfArray['fill_color']['r'] . "," . $theConfArray['fill_color']['g'] . "," . $theConfArray['fill_color']['b'];
+			// color to legend file
+			$bg_color = imagecolorallocate($leg_img, round($theConfArray['fill_color']['r'] * 255), round($theConfArray['fill_color']['g'] * 255), round($theConfArray['fill_color']['b'] * 255));
+	  } else {
+	    $thePDF->setColor(0, 0, 0);
+			// color to legend file
+			$bg_color = imagecolorallocate($leg_img, 0, 0, 0);
+	  }
+	} else {
+	  $doFill = 0;
+		// color to legend file
+	  $bg_color = imagecolorallocate($leg_img, -1, -1, -1);
+	}
+	
+	// Do we need to stroke (outline)?
+	if($theConfArray['do_stroke'] != '') {
+	  // which color to use for filling?
+	  if (is_array($theConfArray['stroke_color']) 
+	      && $theConfArray['stroke_color']['r'] != ''
+			  && $theConfArray['stroke_color']['g'] != ''
+			  && $theConfArray['stroke_color']['b'] != '') {
+	    $thePDF->setStrokeColor($theConfArray['stroke_color']['r'], $theConfArray['stroke_color']['g'], $theConfArray['stroke_color']['b']);
+			$thePDF->setLineStyle($theConfArray['line_style']['width'], $theConfArray['line_style']['cap'], $theConfArray['line_style']['join'], $theConfArray['line_style']['dash']);
+			$theStrokePointPairs = makeStrokePointPairs($theFullArr);
+			for($i = 0; $i < count($theStrokePointPairs); $i++) {
+			  $line = $theStrokePointPairs[$i];
+				if ($i != count($theStrokePointPairs) - 1
+				    || $isClosed) {
+			    $thePDF->line($line[0], $line[1], $line[2], $line[3]);
+					
+					$stroke_color_legend_image = imagecolorallocate($leg_img, round($theConfArray['stroke_color']['r'] * 255), round($theConfArray['stroke_color']['g'] * 255), round($theConfArray['stroke_color']['b'] * 255));
+					if (is_array($theConfArray['line_style']['dash'])
+					    && $theConfArray['line_style']['dash'][1] != ""
+							&& $theConfArray['line_style']['dash'][1] != 0) {
+						imagedashedline($leg_img, 0, 0, $legend_width-1, 0, $stroke_color_legend_image);
+						imagedashedline($leg_img, $legend_width-1, 1, $legend_width-1, $legend_width-1, $stroke_color_legend_image);
+						imagedashedline($leg_img, 0, 0, 0, $legend_width-1, $stroke_color_legend_image);
+						imagedashedline($leg_img, 0, $legend_width-1, $legend_width-1,$legend_width-1, $stroke_color_legend_image);
+					} else {
+					  imageline($leg_img, 0, 0, $legend_width-1, 0, $stroke_color_legend_image);
+						imageline($leg_img, $legend_width-1, 0, $legend_width-1, $legend_width-1, $stroke_color_legend_image);
+						imageline($leg_img, $legend_width-1, $legend_width-1, 0, $legend_width-1, $stroke_color_legend_image);
+						imageline($leg_img, 0, $legend_width-1, 0, 0, $stroke_color_legend_image);
+					}		
+				} 
+			}
+	  } 
+	}
+	
+  $thePDF->polygon($thePolyArr, $nr_of_points, $doFill);
+  // eventually create the file:
+	imagepng($leg_img, $legendFilenameUserPolygon);
+	
+	$thePDF->restoreState();
+} // end of function addMeasuredItem
+
+/**
+ * Konvertiert einen Text in ein array aus einzelnen Zeilen. Parameter wie Zeichen pro
+ * zeile etc. k�nnen in der Funktion ge�ndert werden.
+ */
+function convert2lines($the_text) {
+    $words = explode(' ', $the_text);
+	$maxlines                 = 6;
+	$available_chars_per_line = 35;
+	$total_number_of_lines    = 0;
+	$chars_current_line       = 0;
+	$the_return_array         = array();
+
+    foreach($words as $word) {
+    	// trimme wort auf maximal erlaubte zeichenzahl
+        $word_fit = mb_substr($word, 0, $available_chars_per_line);
+	    $chars = preg_split('//', $word_fit, -1, PREG_SPLIT_NO_EMPTY);
+	    
+	    if(count($chars) + $chars_current_line + 1 < $available_chars_per_line && $total_number_of_lines < $maxlines) {
+		    $chars_current_line += count($chars) + 1;
+			$the_return_array[$total_number_of_lines]  .= " " . $word_fit;
+		} elseif($total_number_of_lines < $maxlines) {
+	      $chars_current_line = count($chars) + 1;
+		  $the_return_array[$total_number_of_lines + 1] = " " . $word_fit;
+		  $total_number_of_lines++;
+		}
+	}
+  return $the_return_array;
+} // end of function convert2lines
+
+/**
+ * Adds two white polygons to hide any user elements outside the mapframe:
+ * First all A-Areas are filled, then all B-Areas. This is a rather grumpy
+ * way out of having user edited stuff flying outside the mapframe.
+ * 
+ * @example <pre>
+ * BBBBBBBBBBBBBBBBBBBBBBBBBBBBAAA
+ * BBBBBBBBBBBBBBBBBBBBBBBBBBBBAAA
+ * BBB                                                  AAA
+ * BBB                                                  AAA
+ * BBB       Mapframe                              AAA
+ * BBB                                                  AAA
+ * BBB                                                  AAA
+ * BBB                                                  AAA
+ * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ * </pre>
+ * 
+ * @param reference (!, pass over with '&') to the pdf-file
+ * @author M. Jansen <jansen at terrestris.de>
+ */
+function hideElementsOutsideMapframe($pdf) {
+  // get globals
+  global $mapOffset_left, $map_width, $mapOffset_bottom, $map_height;
+  $pdf->saveState();
+  $pdf->setColor(1, 1, 1);
+	// The AAA-Part
+  $allOutside = array(
+    0                              , 0,                       // 1st coord-pair
+    $pdf->ez['pageWidth']          , 0,                       // 2nd coord-pair
+    $pdf->ez['pageWidth']          , $pdf->ez['pageHeight'],  // ...
+    $mapOffset_left + $map_width   , $pdf->ez['pageHeight'],
+    $mapOffset_left + $map_width   , $mapOffset_bottom,
+    0                              , $mapOffset_bottom,
+    0                              , 0
+  );
+	// draw polygon
+  $pdf->polygon($allOutside, 7, 1);    
+  // The BBB-part
+  $allOutside = array(
+    0                              , $mapOffset_bottom,       // 1st coord-pair
+    $mapOffset_left                , $mapOffset_bottom,       // 2nd coord-pair
+    $mapOffset_left                , $mapOffset_bottom + $map_height, // ...
+    $mapOffset_left + $map_width   , $mapOffset_bottom + $map_height,
+    $mapOffset_left + $map_width   , $pdf->ez['pageHeight'],
+    0                              , $pdf->ez['pageHeight'],
+    0                              , $mapOffset_bottom,  
+  );
+	// draw polygon
+  $pdf->polygon($allOutside, 7, 1);
+  $pdf->restoreState();
+}
+?>
\ No newline at end of file

Modified: branches/mapbender_sld/http/tools/datepicker/datepicker.php
===================================================================
--- branches/mapbender_sld/http/tools/datepicker/datepicker.php	2007-11-23 13:08:46 UTC (rev 1828)
+++ branches/mapbender_sld/http/tools/datepicker/datepicker.php	2007-11-23 13:14:53 UTC (rev 1829)
@@ -1,50 +1,73 @@
-<?php
-
-$name_month = explode("_",$_REQUEST["m"]);
-$name_day2 = explode("_",$_REQUEST["d"]);
-$today = $HTTP_GET_VARS["t"];
- 
-echo"<html><head><title>_______________________________</title>
-<script src='datepicker.js' type='text/javascript'></script>
-<style type=text/css>
-body { font-size: 8pt; font-family: Arial, helvetica, sans-serif; text-decoration:none; }
-input{width: 30px; background-color: #F5F5F5;	border: none;}
-input.std {	border: thin outset; background-color: Silver; width: 28px;	height: 24px}
-#cal { background-color: #006699; color: #cccccc; font-size: 10pt; font-weight: bold; text-align: center; }
-</style>
-
-</head>
-<body topmargin='0' leftmargin='0' >
-<center>         
-<form name=frm>
-<table cellSpacing=0 cellPadding=0 width=200 border=2>
-<tr align=center bgcolor=silver>
-<td><input name=previous class=std onclick=prevMonth() type=button value='<'></td>
-<td><select name=lMonths style='left: 2px; width: 80px; TOP: 2px; height: 22px' onchange=selMonth(this.selectedIndex)>\n";
-for($i=0; $i<13; $i++) {
-	echo"<option value=".$i.">".$name_month[$i]."</option>\n";
-}
-echo"</select></td>
-<td><select name=lYears style='width: 80px; height: 22px' onchange=selYear(this.selectedIndex)>\n";
-for($i=2000; $i<2021; $i++){
-	echo"<option value=".$i.">".$i."</option>\n";
-}
-echo"</select></td> 
-<td><input name=next class=std onclick=nextMonth() type=button value='>'> 
-</td></tr></table>
-<table cellSpacing=0 cellPadding=0 width=200 border=2>
-<tr id=cal>\n";
-for ($i=0; $i<7; $i++){
-	echo "<td>".$name_day2[$i]."</td>\n";
-}
-echo"</tr><tr>\n";
-for ($i=1; $i<43; $i++){
-	echo"<td><input name=btn".$i." onclick=go(this.value) type=button></td>\n";
-	echo ($i % 7)?(""):("</tr><tr>\n");
-} 
-echo"<td colspan=7 align=center><input name=today class=std style='width: 100px' value=".$today." onclick=go('x') type=button></td></tr>
-</table></form></center>
-<script language=JavaScript>picker();</script>
-</body></html>
-";
-?>
+<?php
+
+$name_month = explode("_",$_REQUEST["m"]);
+$name_day2 = explode("_",$_REQUEST["d"]);
+$today = $_REQUEST["t"];
+
+echo "<html>
+<head>
+<title>Datepicker</title>
+
+<script src='datepicker.js' type='text/javascript'></script>
+
+<style type=text/css>
+	body { font-size: 8pt; font-family: Arial, helvetica, sans-serif; text-decoration:none; }
+	input{width: 30px; background-color: #F5F5F5;	border: none;}
+	input.std {	border: thin outset; background-color: Silver; width: 28px;	height: 24px}
+	#cal { background-color: #006699; color: #cccccc; font-size: 10pt; font-weight: bold; text-align: center; }
+</style>
+
+</head>
+
+<body topmargin='0' leftmargin='0' >
+<center>         
+<form name=frm>
+<table cellSpacing=0 cellPadding=0 width=200 border=2>
+<tr align='center' bgcolor='silver'>
+<td>
+	<input name='previous' class='std' onclick='prevMonth();' type='button' value='<'>
+</td>
+<td>
+	<select name='lMonths' style='left: 2px; width: 80px; TOP: 2px; height: 22px' onchange='selMonth(this.selectedIndex);'>\n";
+	for($i=0; $i<12; $i++) {
+		echo "<option value=".$i.">".$name_month[$i]."</option>\n";
+	}
+echo "</select>
+</td>
+<td>
+	<select name='lYears' style='width: 80px; height: 22px' onchange='selYear(this.selectedIndex);'>\n";
+	for($i=2000; $i<2021; $i++){
+		echo "<option value=".$i.">".$i."</option>\n";
+	}
+echo "</select>
+</td> 
+<td>
+	<input name='next' class='std' onclick='nextMonth();' type='button' value='>'> 
+</td>
+</tr>
+</table>
+
+<table cellSpacing=0 cellPadding=0 width=200 border=2>
+<tr id=cal>\n";
+for ($i=0; $i<7; $i++){
+	echo "<td>".$name_day2[$i]."</td>\n";
+}
+echo "</tr><tr>\n";
+for ($i=1; $i<43; $i++){
+	echo "<td><input name='btn".$i."' onclick='go(this.value);' type='button'>
+	      </td>\n";
+	echo ($i % 7)?(""):("</tr><tr>\n");
+} 
+echo "<td colspan=7 align='center'>
+	<input name='today' class='std' style='width: 100px' value='".$today."' onclick='go(\"x\");' type='button'>
+</td>
+</tr>
+</table>
+</form>
+</center>
+<script language='JavaScript'>
+	picker();
+</script>
+</body>
+</html>";
+?>

Modified: branches/mapbender_sld/http/tools/mapbender_setup.php
===================================================================
--- branches/mapbender_sld/http/tools/mapbender_setup.php	2007-11-23 13:08:46 UTC (rev 1828)
+++ branches/mapbender_sld/http/tools/mapbender_setup.php	2007-11-23 13:14:53 UTC (rev 1829)
@@ -21,7 +21,8 @@
  # along with this program; if not, write to the Free Software
  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  
- include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+include_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
  
 ?>
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
@@ -31,11 +32,11 @@
 	<meta http-equiv="pragma" content="no-cache">
 	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
 	<meta name="robots" content="noindex,nofollow">
-	<title>Mapbender Setupchecker</title>
+	<title>Mapbender Setup-Checker</title>
 </head>
 <link rel="stylesheet" type="text/css" href="../css/mapbender.css">
 <body>
-<table  BGCOLOR="#ffffff" width="70%" height="70%" ALIGN="top" CELLSPACING="0" CELLPADDING="10" STYLE="-moz-border-radius:8px; border:2px #000000 solid;">
+<table  BGCOLOR="#ffffff" width="95%" height="95%" ALIGN="center" CELLSPACING="0" CELLPADDING="10" STYLE="-moz-border-radius:8px; border:2px #000000 solid;">
 <tr><td VALIGN="center" STYLE="margin-bottom:0px; padding-bottom:0px;">
 <H1 style="padding:0px; margin:0px; font:32px/32px bold Arial,Helvetica,sans-serif; font-stretch:extra-expanded;font-weight:bold">
 <font align="left"" style="font-weight:bold" color="#000000">&nbsp;Ma</font><font color="#0000CE" style="font-weight:bold">p</font><font color="#C00000">b</font><font color="#000000" style="font-weight:bold">ender</font>
@@ -53,11 +54,11 @@
 ###########################################
 #phpversion
 	$check ="<tr ><td  width=\"25%\">php Version</td>";
-	if (phpversion()>'4.3.0'){
-		if (phpversion()<'5.1.0') $check .="<td width=\"10\"></td><td><font color=#0000FF>Version: " . phpversion() . "! you should think about upgrade to >=php5.1!</td></tr>";
+	if (phpversion()>='5.1.0'){
+		if (phpversion()<'5.2.0') $check .="<td width=\"10\"></td><td><font color=#0000FF>Version: " . phpversion() . "! You should think about upgrade to the current php version (get it <a href='http://www.php.net/downloads.php' target='_blank'>here</a>)</td></tr>";
 		else $check .="<td width=\"10\">X</td><td><font color=#00D000>Version: " . phpversion() . "</td></tr>";
 	}
-	else $check .="<td width=\"10\"></td><td><font color=#FF0000>Version: " . phpversion() . "! your PHP is very old, think about upgrade to >=php5.1!</td></tr>";
+	else $check .="<td width=\"10\"></td><td><font color=#FF0000>Version: " . phpversion() . "! Your PHP Version is very old, please upgrade to version >=5.1.0 to use full mapbender functionality and reduce problems!</td></tr>";
 #php-schnittstelle 
 	if(php_sapi_name() == 'cgi') $check.="<tr><td >interface</td><td>X</td><td><font color=#00D000>CGI-PHP</td></tr>";
 	else $check.="<tr><td >interface</td><td>X</td><td><font color=#00D000>Modul-PHP</td></tr>";
@@ -74,9 +75,14 @@
 	if (get_cfg_var('memory_limit')) $check .="<tr ><td>memory Limit</td><td>X</td><td><font color=#00D000>" . get_cfg_var('memory_limit') . "</font><font color='#0000FF'> (running in memory-trouble with printing? Perhaps raise your memory limit)</font></td></tr>";
 	else $check .="<tr ><td>memory Limit</td><td></td><td><font color=#FF0000>memory_limit must be set (30M will be enough for the moment)</font></td></tr>";
 # error_reporting
+#Error Reporting: 6135 =>error_reporting  =  E_ALL & ~E_NOTICE (6135-8(E_NOTICE))
+#Error Reporting: 1 => error_reporting  =  E_ERROR
+#Error Reporting: 6143 => error_reporting  =  E_ALL
 	$check .="<tr ><td>error-reporting</td>";
-	 if (get_cfg_var('error_reporting')!=2039) $check .="<td></td><td><font color=#FF0000>please set error_reporting to 'E_ALL & ~E_NOTICE' except for testing</td></tr>";
-	 else $check .="<td>X</td><td><font color=#00D000>ok, error_reporting = E_ALL & ~E_NOTICE </td></tr>";
+	 if (get_cfg_var('error_reporting')==6143||get_cfg_var('error_reporting')==8) $check .="<td></td><td><font color=#FF0000>please set error_reporting to 'E_ALL & ~E_NOTICE' or 'E_ERROR' except for debugging</td></tr>";
+	elseif  (get_cfg_var('error_reporting')==6135)$check .="<td>X</td><td><font color=#00D000>ok, error_reporting = E_ALL & ~E_NOTICE</td></tr>";
+	elseif  (get_cfg_var('error_reporting')==1)$check .="<td>X</td><td><font color=#00D000>ok, error_reporting = E_ERROR</td></tr>";
+	else $check .="<td></td><td><font color=#0000FF>(Your error_reporting configuration is not implementet into this test yet. You shoul know what you are doing or set it to E_ALL & ~E_NOTICE)</td></tr>";
 # session.save_handler
 	if (!get_cfg_var('session.save_handler')||get_cfg_var('session.save_handler')!='files') $check .="<tr ><td>session.save_handler</td><td></td><td><font color=#FF0000>session.save_handler must be set to 'session.save_handler = files'!</font></td></tr>";
 	else $check .="<tr ><td>session.save_handler</td><td>X</td><td><font color=#00D000>session.save_handler = " . get_cfg_var('session.save_handler') . "</font></td></tr>"; 
@@ -88,17 +94,18 @@
 	$check .="<tr ><td>allow_url_fopen</td>"; 
 	if (get_cfg_var('allow_url_fopen')=='1') $check .= "<td>X</td><td><font color=#00D000>On</font></td></tr>";
 	else $check .= "<td></td><td><font color=#FF0000>Off =>allow_url_fopen must be on read <a href='http://www.mapbender.org/index.php/Allow_url_fopen' target=_blank>this</a></font></td></tr>";
+# short_open_tag 
+	$check .="<tr ><td>short_open_tag</td>"; 
+	if (get_cfg_var('short_open_tag')!='1') $check .= "<td>X</td><td><font color=#00D000>Off</font></td></tr>";
+	else $check .= "<td></td><td><font color=#FF0000>On => Displaying XML files will not work properly</font></td></tr>";
 	echo $check;
 #################################################
 #PHP Extensioncheck
 #################################################
-#MYSQL
 	?>
-	</table>
-	<br><br>
-	<table style="border: 2px solid rgb(128, 128, 128); -moz-border-radius-topleft: 8px; -moz-border-radius-topright: 8px; -moz-border-radius-bottomright: 8px; -moz-border-radius-bottomleft: 8px;" bgcolor=#dddddd cellspacing=0 cellpadding=0 width="95%">
 	<th colspan="3" bgcolor=#F0F0F0>PHP Extensioncheck</th>
 	<?php
+#MYSQL	
 	if(!extension_loaded('mysql')) $check="<tr ><td width=\"25%\">MySQL check</td><td width=\"10\"></td><td><font color=#FF0000 >MySQL not installed! (You have to include mysql-extension if you want to use MySQL as MB-Database!)</font></td></tr>";
 	else $check="<tr ><td width=\"25%\">MySQL check</td><td width=\"10\">X</td><td><font color=#00D000 >MySQL installed</font></td></tr>";
 #PGSQL
@@ -107,7 +114,16 @@
 #GD
 	if(extension_loaded('gd')) $check.="<tr ><td>GD2 check</td><td>X</td><td><font color=#00D000>GD installed</font></td></tr>";
 	else $check.="<tr ><td>GD2 check</td><td></td><td><font color=#FF0000>GD not installed (no printing possible)</font></td></tr>";
-	echo $check;
+
+#mbstring
+	if(extension_loaded('mbstring')) $check.="<tr ><td>mbstring check</td><td>X</td><td><font color=#00D000>mbstring installed</font></td></tr>";
+	else $check.="<tr ><td>mbstring check</td><td></td><td><font color=#FF0000>PHP extension mbstring is not installed</font></td></tr>";
+
+#gettext
+	if(extension_loaded('gettext')) $check.="<tr ><td>gettext check</td><td>X</td><td><font color=#00D000>gettext installed</font></td></tr>";
+	else $check.="<tr ><td>gettext check</td><td></td><td><font color=#FF0000>PHP extension gettext is not installed</font></td></tr>";
+
+echo $check;	    
 ####################################
 # Database check
 ####################################
@@ -130,22 +146,22 @@
 			$con_postgis = pg_connect($con_string);
 			$sql = "Select postgis_full_version();";
 			$res = pg_query($con_postgis,$sql);
-			if(!$res) $check .="<tr width=\"20%\><td>PostGIS support</td><td></td><td><font color=#FF0000>no PostGIS function available</tr>";
+			if(!$res) $check .="<tr width=\"20%\><td>PostGIS support</td><td></td><td><font color=#FF0000>no PostGIS function available</td></tr>";
 			else{
 				$cnt=0;
 				while(pg_fetch_row($res)){
-					$check .="<tr><td>PostGIS support</td><td>X</td><td><font color=#00D000>PostGIS function available</tr>";
+					$check .="<tr><td>PostGIS support</td><td>X</td><td><font color=#00D000>PostGIS function available</td></tr>";
 					$check .="<tr><td>Version</td><td>X</td><td><font color=#00D000>" . pg_fetch_result($res,$cnt,0). "</td></tr>";
 		  		  	$cnt++;
 		  		}
-				if ($cnt==0) $check .="<tr><td>PostGIS support</td><td></td><td><font color=#FF0000>no PostGIS function available</tr>";
+				if ($cnt==0) $check .="<tr><td>PostGIS support</td><td></td><td><font color=#FF0000>no PostGIS function available</td></tr>";
 			}
 		}
-		else $check .="<tr><td>Postgis support</td><td></td><td><font color=#FF0000>no PostGIS function available</font></tr>";
+		else $check .="<tr><td>Postgis support</td><td></td><td><font color=#FF0000>no PostGIS function available</font></td></tr>";
 		echo $check;
 	}
 	else{
-		$check = "<tr><td width=\"25%\">Administration Database</td><td>X</td><td><font color=#00D000>PostgreSQL</td><tr>";
+		$check = "<tr><td width=\"25%\">Administration Database</td><td>X</td><td><font color=#00D000>PostgreSQL</td></tr>";
 		$check .= "<tr><td>Connect to Database</td>";
 		if($con) $check .="<td width=\"10\">X</td><td><font color=#00D000>connected</font></td></tr>";
 		else $check .="<td width=\"10\"></td><td><font color=#FF0000>not connected</font></td></tr>";
@@ -163,9 +179,6 @@
 # PostGIS check
 ######################################	
 	?>
-	</table>
-	<br><br>
-	<table style="border: 2px solid rgb(128, 128, 128); -moz-border-radius-topleft: 8px; -moz-border-radius-topright: 8px; -moz-border-radius-bottomright: 8px; -moz-border-radius-bottomleft: 8px;" bgcolor=#dddddd cellspacing=0 cellpadding=0 width="95%">
 	<th colspan="3" bgcolor=#F0F0F0>PostGIS check</th>
 	<?php
 		$check ="";
@@ -173,18 +186,18 @@
 			$sql = "select postgis_full_version();";
 			if (pg_query($con,$sql))$res = pg_query($con,$sql);
 			else echo "<tr><td><font>pg_query($con,$sql)";
-			if(!$res) $check .="<tr><td width=\"25%\">PostGIS support</td><td width=\"10\"></td><td><font color=#FF0000>no PostGIS function available</tr>";
+			if(!$res) $check .="<tr><td width=\"25%\">PostGIS support</td><td width=\"10\"></td><td><font color=#FF0000>no PostGIS function available</td></tr>";
 			else{
 				$cnt=0;
 				while(pg_fetch_row($res)){
-					$check .="<tr><td width=\"25%\">PostGIS support</td><td width=\"10\">X</td><td><font color=#00D000>PostGIS function available</tr>";
+					$check .="<tr><td width=\"25%\">PostGIS support</td><td width=\"10\">X</td><td><font color=#00D000>PostGIS function available</td></tr>";
 					$check .="<tr><td>Version</td><td width=\"10\">X</td><td><font color=#00D000>" . pg_fetch_result($res,$cnt,0). "</td></tr>";
 		  		  	$cnt++; 	
 		  		}
-				if ($cnt==0) $check .="<tr><td width=\"25%\">PostGIS support</td><td width=\"10\"></td><td><font color=#FF0000>no PostGIS function available</tr>";
+				if ($cnt==0) $check .="<tr><td width=\"25%\">PostGIS support</td><td width=\"10\"></td><td><font color=#FF0000>no PostGIS function available</td></tr>";
 			}
 		}
-		else $check .="<tr><td width=\"25%\">Postgis support</td><td width=\"10\"></td><td><font color=#FF0000>no PostGIS function available</font></tr>";
+		else $check .="<tr><td width=\"25%\">Postgis support</td><td width=\"10\"></td><td><font color=#FF0000>no PostGIS function available</font></td></tr>";
 		echo $check;
 	} 
 #################################
@@ -194,7 +207,7 @@
 	</table>
 	<br><br>
 	<table style="border: 2px solid rgb(128, 128, 128); -moz-border-radius-topleft: 8px; -moz-border-radius-topright: 8px; -moz-border-radius-bottomright: 8px; -moz-border-radius-bottomleft: 8px;" bgcolor=#dddddd cellspacing=0 cellpadding=0 width="95%">
-	<th colspan="3" bgcolor=#F0F0F0>mapbender.conf check</th>
+	<th colspan="4" bgcolor=#F0F0F0>Mapbender Configuration Check</th>
 	<?php 
 # SYS_DBTYPE
 	if ((SYS_DBTYPE == 'mysql' || SYS_DBTYPE == 'pgsql') && defined('SYS_DBTYPE')) $check ="<tr><td>Administration Database</td><td >X</td><td><font color=#00D000>" . SYS_DBTYPE . "</font></td></tr>";
@@ -211,29 +224,64 @@
 # PREPAREDSTATEMENTS
 	if (defined('PREPAREDSTATEMENTS')){
 		if (PREPAREDSTATEMENTS == true){
-			if (phpversion()<'5.1.0') $check.="<tr><td width=\"25%\">PREPAREDSTATEMENTS-<br>compatibility</td><td width=\"10\"></td><td><font color=\"#ff0000\">PREPAREDSTATEMENTS =set to 'true' and php version " . phpversion() . " is incompatible<br>set PREPAREDSTATEMENTS to false or update php to >=5.1</td></tr>";
-			else $check .="<tr><td width=\"25%\">PREPAREDSTATEMENTS-<br>compatibility</td><td width=\"10\">X</td><td><font color=#00D000>set to 'true' and php " . phpversion() . " should work</td><tr/>";
+			if (phpversion()<'5.1.0') $check.="<tr><td width=\"25%\">PREPAREDSTATEMENTS</td><td width=\"10\"></td><td><font color=\"#ff0000\">PREPAREDSTATEMENTS =set to 'true' and php version " . phpversion() . " is incompatible<br>set PREPAREDSTATEMENTS to false or update php to >=5.1</td></tr>";
+			else $check .="<tr><td width=\"25%\">PREPAREDSTATEMENTS</td><td width=\"10\">X</td><td><font color=#00D000>set to 'true' and php " . phpversion() . " should work</td></tr>";
 		}
 		else{
-			if (phpversion()<'5.1.0') $check .="<tr><td width=\"25%\">PREPAREDSTATEMENTS-<br>compatibility</td><td width=\"10\">X</td><td><font color=#00D000>set to 'false' and php " . phpversion() . " should work </font><font color='#0000FF'> (but think about upgrading to php 5.1)</td><tr/>";
-			else $check .="<tr><td width=\"25%\">PREPAREDSTATEMENTS-<br>compatibility</td><td width=\"10\">X</td><td><font color=#00D000>set to 'false' and php " . phpversion() . " should work <font color=#0000FF>(but you can set PREPAREDSTATEMENTS to 'true')</font></td><tr/>";
+			if (phpversion()<'5.1.0') $check .="<tr><td width=\"25%\">PREPAREDSTATEMENTS-<br>compatibility</td><td width=\"10\">X</td><td><font color=#00D000>set to 'false' and php " . phpversion() . " should work </font><font color='#0000FF'> (but think about upgrading to php 5.1)</td></tr>";
+			else $check .="<tr><td width=\"25%\">PREPAREDSTATEMENTS-<br>compatibility</td><td width=\"10\">X</td><td><font color=#00D000>set to 'false' and php " . phpversion() . " should work <font color=#0000FF>(but you can set PREPAREDSTATEMENTS to 'true')</font></td></tr>";
 		}
 	}
-    else $check .="<tr><td width=\"25%\">PREPAREDSTATEMENTS-<br>compatibility</td><td width=\"10\"></td><td><font color=#FF0000>PREPAREDSTATEMENTS is not defined</td><tr/>";
+    else $check .="<tr><td width=\"25%\">PREPAREDSTATEMENTS-<br>compatibility</td><td width=\"10\"></td><td><font color=#FF0000>PREPAREDSTATEMENTS is not defined</td></tr>";
 # CHARSET
 	if (CHARSET != "" && defined('CHARSET')) $check .="<tr><td>CHARSET</td><td>X</td><td><font color=#00D000>" . CHARSET . "</font><font color='#0000FF'></font></td></tr>";
 	else $check .="<tr><td>CHARSET</td><td></td><td><font color=#FF0000>CHARSET is not defined</font></td></tr>";
 # TMPDIR
 	if (TMPDIR != "" && defined('TMPDIR')) $check .="<tr><td>TMPDIR</td><td>X</td><td><font color=#00D000>" . TMPDIR . "</font><font color='#0000FF'></font></td></tr>";
 	else $check .="<tr><td>TMPDIR</td><td></td><td><font color=#FF0000>TMPDIR is not defined</font></td></tr>";
+# OWSPROXY
+	if (OWSPROXY != "" && defined('OWSPROXY')) $check .="<tr><td>OWSPROXY</td><td>X</td><td><font color=#00D000>" . OWSPROXY . "</font><font color=#0000FF> (Is this the right URL to your OWSPROXY?)</font></td></tr>";
+	else $check .="<tr><td>OWSPROXY</td><td></td><td><font color=#FF0000>OWSPROXY not defined</font><font color=#0000FF>(if you want to camouflage your WMS, you should think about OWSPROXY!)</font></td></tr>";
+#AUTO_UPDATE
+	if (AUTO_UPDATE != "" && defined('AUTO_UPDATE')){
+		if (AUTO_UPDATE == '1'){ 
+			$check .="<tr><td>AUTO_UPDATE</td><td>X</td><td>set to 1: will update all out-of-date WMS automatically<td></tr>";
+			if (!TIME_LIMIT || TIME_LIMIT == "")$check .="<tr><td>TIME_LIMIT</td><td></td><td><font color=#FF0000>you should define a TIME_LIMIT for the AUTO_UPDATE funtionallity</font><td></tr>";
+		}
+		elseif (AUTO_UPDATE == '0') $check .="<tr><td>AUTO_UPDATE</td><td>X</td><td><font color=#00D000>set to 0:</font> <font color=#0000FF>(see the result of the test and update WMS manually)</font></td></tr>";
+		else $check .="<tr><td>AUTO_UPDATE</td><td></td><td><font color=#FF0000>set to " . AUTO_UPDATE . ": this configuration value is not supported(as yet!)</td></tr>";
+	} 			    	
+	else $check .="<tr><td>AUTO_UPDATE</td><td></td><td><font color=#FF0000>AUTO_UPDATE not defined </font><font color=#0000FF>(for the wms monitoring 	functionality you have to define this constant)</font></td></tr>";
+# ERROR LOGGING
+	$testLog = new mb_notice("This is a test run by the Mapbender setup script.");
+	if ($testLog->result) {
+		$check .="<tr><td>ERROR LOGGING</td><td>X</td><td><font color=#00D000>" . $testLog->message . "</font></td></tr>";		
+	}
+	else {
+		$check .="<tr><td>ERROR LOGGING</td><td></td><td><font color=#FF0000>" . $testLog->message . "</font></td></tr>";		
+	}
+#LOG_LEVEL (off,error,warning,all)
+	if (LOG_LEVEL !="" && defined('LOG_LEVEL')){
+		if (LOG_LEVEL =='off') $check .="<tr><td>LOG_LEVEL</td><td>X</td><td>switched off: <font color=#FF0000>-no Mapbender-errors logging</font><td></tr>"; 
+		elseif (LOG_LEVEL =='error') $check .="<tr><td>LOG_LEVEL</td><td>X</td><td><font color=#00D000>set to 'error': </font><font color=#0000FF>-Mapbender-errors will be logged</font><td></tr>";
+		elseif (LOG_LEVEL =='warning') $check .="<tr><td>LOG_LEVEL</td><td>X</td><td><font color=#00D000>set to 'warning: </font><font color=#0000FF>- Mapbender-errors and -warnings will be logged</font><td></tr>";
+		elseif (LOG_LEVEL =='all') $check .="<tr><td>LOG_LEVEL</td><td>X</td><td><font color=#00D000>set to 'all': </font><font color=#0000FF>-really every little notice will be logged!!</font><td></tr>";
+		else $check .="<tr><td>LOG_LEVEL</td><td></td><td><font color=#FF0000>set to " . LOG_LEVEL . ": this configuration value is not supported (as yet!)</font></td></tr>";		
+	}	
+# PORTAL
+	if (defined('PORTAL')){
+		if (PORTAL == true) $check .="<tr><td width=\"25%\">PORTAL</td><td width=\"10\">X</td><td><font color=#00D000>true</font><font color='#0000FF'> (Users can create theirs own accounts)</font></td></tr>";
+		else $check .="<tr><td width=\"25%\">PORTAL</td><td width=\"10\">X</td><td><font color=#00D000>false<font color=#0000FF> (Users can't create their own accounts at the moment)</font></td></tr>";
+	}
+    else $check .="<tr><td width=\"25%\">PORTAL</td><td width=\"10\"></td><td><font color=#FF0000>PORTAL is not defined<font color=#0000FF>(Maybe an old configuration file?)</font></td></tr>";
 # MAXLOGIN
 	if (MAXLOGIN != "" && defined('MAXLOGIN')) $check .="<tr><td>MAXLOGIN</td><td>X</td><td><font color=#00D000>" . MAXLOGIN . "</font><font color='#0000FF'></font></td></tr>";
-	else $check .="<tr><td>MAXLOGIN</td><td></td><td><font color=#FF0000>MAXLOGIN is not defined</font></td></tr>";		    	
+	else $check .="<tr><td>MAXLOGIN</td><td></td><td><font color=#0000FF>MAXLOGIN is not defined</font></td></tr>";		    	
 # LOGIN
-	if (defined('LOGIN')) $check .= "<tr height=10/><tr><td>Login-Path</td><td colspan=2><a href='" . LOGIN . "' target='_blank'>" . LOGIN . "</a><br><font color=#0000FF> (if this link doesn't work, check out your 'URL to Login' in your mapbender.conf<br>Perhaps an alias in your httpd.conf will solve the prob')</td>";
+	if (defined('LOGIN')) $check .= "<tr height=10/><tr><td>Login-Path</td><td colspan=2><a href='" . LOGIN . "' target='_blank'>" . LOGIN . "</a><br><font color=#0000FF> (If this link doesn't work, check your url to 'Login' in your mapbender.conf<br>Perhaps an alias in your httpd.conf will solve the problem, too)</td>";
 	else $check .= "<tr height=10/><tr><td>Login-Path</td><td colspan=2><font color=#FF0000>LOGIN is not defined</font></td>";
 	echo $check;	
-	echo "<tr height=10/><tr bgcolor=#F0F0F0><td colspan=3>Legend:<br><font color=#FF0000>red = maybe your Mapbender will run into trouble</font><br><font color=#0000FF>blue = just a tip</font><br><font color=#00D000>green = seems to be alright</font></td></tr>";
+	echo "<tr height=10/><tr bgcolor=#F0F0F0><td colspan=4>Legend:<br><font color=#FF0000>red = maybe your Mapbender will run into trouble</font><br><font color=#0000FF>blue = just a tip</font><br><font color=#00D000>green = seems to be alright</font></td></tr>";
 	echo "</table>";
 	echo "<tr><td colspan=3 align=right>for further informations visit <a href=\"http://www.mapbender.org/index.php/Installation_en\" target=\"_blank\"><font align=\"left\" style=\"font-weight:bold\" color=\"#000000\">&nbsp;Ma</font><font color=\"#0000CE\" style=\"font-weight:bold\">p</font><font color=\"#C00000\" style=\"font-weight:bold\">b</font><font color=\"#000000\" style=\"font-weight:bold\">ender</font> installation instructions</a></td></tr>";
 	?>

Modified: branches/mapbender_sld/http/tools/send_post.php
===================================================================
--- branches/mapbender_sld/http/tools/send_post.php	2007-11-23 13:08:46 UTC (rev 1828)
+++ branches/mapbender_sld/http/tools/send_post.php	2007-11-23 13:14:53 UTC (rev 1829)
@@ -51,7 +51,7 @@
     if (empty($method)) {
         $method = 'POST';
     }
-    $method = strtoupper($method);
+    $method = mb_strtoupper($method);
     $fp = fsockopen($host, $port);
     fputs($fp, "$method $path HTTP/1.1\r\n");
     fputs($fp, "Host: $host\r\n");

Modified: branches/mapbender_sld/http/tools/wms_extent/mapbender_wms.map
===================================================================
--- branches/mapbender_sld/http/tools/wms_extent/mapbender_wms.map	2007-11-23 13:08:46 UTC (rev 1828)
+++ branches/mapbender_sld/http/tools/wms_extent/mapbender_wms.map	2007-11-23 13:14:53 UTC (rev 1829)
@@ -22,19 +22,25 @@
       "WMS_TITLE"    "WMS Extent"
       "WMS_FEATURE_INFO_MIME_TYPE"    "text/html"
       "WMS_ABSTRACT"    "Overview over the WMS loaded in Mapbender"
-      
+
+      "ows_keywordlist" "Mapbender"
+      "ows_fees" "none"
+      "ows_accessconstraints" "none"
+              
       "ows_addresstype" "postal"
-      "ows_address" "Siemensstraße 8"
+      "ows_address" "Siemensstr. 8"
       "ows_city" "Bonn"
       "ows_stateorprovince" "NRW"
       "ows_postcode" "53121"
-      "ows_country" "Germany"        
-      "ows_contactperson" "Astrid Emde" 
-      "ows_contactorganization" "CCGIS"
-      "ows_contactposition" "CCGIS"
-      "ows_contactelectronicmailaddress" "astrid_emde at osgeo.org"
+      "ows_country" "Germany"
             
-      "ows_keywordlist" "Mapbender,OSGEO,Client Suite"
+      "ows_contactperson" "A. Emde" 
+      "ows_contactinformation" "Wheregroup"
+      "ows_contactorganization" "WhereGroup"
+      "ows_contactposition" "WhereGroup"
+      "ows_contactelectronicmailaddress" "astrid.emde at whergroup.com"
+      "wms_contactfacsimiletelephone" "0228 90903811"
+      "wms_contactvoicetelephone" "0228 9090380"
     END
   END
   
@@ -74,9 +80,11 @@
    END
    
    METADATA
-      "WMS_SRS"    "epsg:4326"
-      "WMS_TITLE"    "WMS Extent"
-      "WMS_FEATURE_INFO_MIME_TYPE"    "text/html"
+	"WMS_SRS"    "epsg:4326"
+	"WMS_TITLE"    "WMS Extent"
+	"WMS_FEATURE_INFO_MIME_TYPE"    "text/html"
+	"ows_keywordlist" "WMS Extent"
+	"ows_abstract" "Extent,WMS"
    END
    
    SYMBOLSCALE 100000

Added: branches/mapbender_sld/owsproxy/http/classes/class_QueryHandler.php
===================================================================
--- branches/mapbender_sld/owsproxy/http/classes/class_QueryHandler.php	                        (rev 0)
+++ branches/mapbender_sld/owsproxy/http/classes/class_QueryHandler.php	2007-11-23 13:14:53 UTC (rev 1829)
@@ -0,0 +1,159 @@
+<?php
+# $Id: $
+# http://www.mapbender.org/index.php/class_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("../../../http/classes/class_mb_exception.php");
+
+/**
+ * class to handle the querystring and the params
+ */
+ 
+class QueryHandler{
+	
+	private $reqParams = array();
+	private $reqParamsToLower = array();
+	private $owsproxyServiceKey = 'wms';
+	private $owsproxyServiceId;
+	private $onlineResource;
+	/**
+	 * Constructor of the QueryHandler
+	 * 
+	 */
+	function __construct(){
+		$this->setRequestParams(array_keys($_REQUEST));
+		$notice = new mb_notice("const: querystring: ".$this->getQueryString());
+	}
+	
+	/**
+	 * set all query parameter-keys and -values to lowerCase
+	 * so that they could be handled caseinsensitive
+	 * 
+	 * set another array with original keys and values
+	 *
+	 * @param string[] the keys of all query parameters
+	 * @return string[] an associative array with request parameters keys (tolowercase) and values (tolower)
+	 */
+	function setRequestParams($keys){
+		for($i=0; $i<count($keys); $i++){
+			$this->reqParams[strtolower($keys[$i])] = $_REQUEST[$keys[$i]];
+			$this->reqParamsToLower[strtolower($keys[$i])] = $_REQUEST[$keys[$i]];
+			if($keys[$i] == $this->owsproxyServiceKey){
+				$this->owsproxyServiceId = $_REQUEST[$keys[$i]];
+				$notice = new mb_notice("owsId: ".$this->owsproxyServiceId);
+			}
+		}
+	}
+	/**
+	 * checks is a request param is part of the original request
+	 * 
+	 * @param string request key
+	 * @return boolean true if it is part of original request
+	 */
+	function isValidParam($key){
+		if($key == 'sid'){
+			return false;
+		}
+		else if($key == $this->owsproxyServiceKey){
+			return false;
+		}
+		else if($key == ini_get("session.name")){
+			return false;
+		}
+		else if($key == 'request' && $this->reqParams[$key] == 'external'){
+			return false;
+		}
+		else{
+			return true;
+		}
+	}
+	/** 
+	 * gets the request params
+	 * 
+	 * @return request params
+	 */
+	function getRequestParams(){
+		return $this->reqParamsToLower;
+	}
+	/**
+	 * modifies the layers
+	 */
+	 function setParam($param,$value){
+		$mykeys = array_keys($this->reqParams);
+		for($i=0; $i<count($mykeys);$i++){
+			if(strtolower($mykeys[$i]) == strtolower($param)){
+				$this->reqParams[$mykeys[$i]] = $value;
+				$n = new mb_notice("QueryHandler: setParam: ".serialize($this->reqParams));
+			}
+		}
+	 }
+	 /**
+	  * gets the original query string
+	  * 
+	  * @return string original query string
+	  */
+	  function getQueryString(){
+		$mykeys = array_keys($this->reqParams);
+		$cnt = 0;
+		for($i=0; $i<count($mykeys);$i++){
+			if($this->isValidParam($mykeys[$i])){	
+				if($cnt > 0){ 
+					$qstring .= "&"; 
+				}
+				$qstring .= $mykeys[$i]."=".rawurlencode(stripslashes($this->reqParams[$mykeys[$i]]));
+				$cnt++;
+			}
+		}
+		$notice = new mb_notice("getQueryString() : " . $qstring);
+		return $qstring;
+	  }
+	  /**
+	   * gets the original request with url and query string
+	   * 
+	   * @return string request
+	   */
+	   function getRequest(){
+	   		$req = $this->onlineResource.$this->getConjunctionCharacter($this->onlineResource).$this->getQueryString();
+	   		$notice = new mb_notice("onlineResource:". $req);
+	   		return $req;	
+	   }
+	   /**
+	    * gets the conjunction character between url and query string
+	    */
+	    function getConjunctionCharacter($url){
+			if(strpos($url,"?")){ 
+				if(strpos($url,"?") == strlen($url)){ 
+				$cchar = "";
+				}else if(strpos($url,"&") == strlen($url)){
+					$cchar = "";
+				}else{
+					$cchar = "&";
+				}
+			}
+			if(strpos($url,"?") === false){
+				$cchar = "?";
+			} 
+			return $cchar;  
+		}
+		function getOwsproxyServiceId(){
+			return $this->owsproxyServiceId;
+		}
+		function setOnlineResource($url){
+			$this->onlineResource = $url;
+		}
+}
+
+?>
\ No newline at end of file

Modified: branches/mapbender_sld/owsproxy/http/index.php
===================================================================
--- branches/mapbender_sld/owsproxy/http/index.php	2007-11-23 13:08:46 UTC (rev 1828)
+++ branches/mapbender_sld/owsproxy/http/index.php	2007-11-23 13:14:53 UTC (rev 1829)
@@ -22,89 +22,99 @@
 require("../../http/classes/class_administration.php");
 require("../../http/classes/class_connector.php");
 require_once("../../http/classes/class_mb_exception.php");
+require("./classes/class_QueryHandler.php");
+
 /***** conf *****/
 $imageformats = array("image/png","image/gif","image/jpeg", "image/jpg");
-$mbkeys = array("sid",strtolower(ini_get("session.name")),"wms");
 /***** conf *****/
 
-$reqParams = array();
-$myKeys = array_keys($_REQUEST);
-// create an associative array with request parameters (get)
-for($i=0; $i<count($myKeys); $i++){
-	$tmp[$i] = removeQM(strtolower($myKeys[$i]));
-	$$tmp[$i]  = $_REQUEST[$myKeys[$i]];
-	if(!in_array(removeQM(strtolower($myKeys[$i])),$mbkeys)){
-		$reqParams[removeQM(strtolower($myKeys[$i]))] = $_REQUEST[$myKeys[$i]];
-	}
-}
+$con = db_connect(DBSERVER,OWNER,PW);
+db_select_db(DB,$con);
+
+$postdata = $HTTP_RAW_POST_DATA;
 
+$owsproxyService = $_REQUEST['wms']; //ToDo: change this to 'service' in the apache url-rewriting
+$query = new QueryHandler();
+
+// an array with keys and values toLoserCase -> caseinsensitiv
+$reqParams = $query->getRequestParams();
+
+$notice = new mb_notice("owsproxy id:".$query->getOwsproxyServiceId());
+
 // check session
 session_id($_REQUEST["sid"]);
 session_start();
+if(!$_SESSION['mb_user_id']){
+	$notice = new mb_notice("Permission denied");
+	throwE("Permission denied");
+	die();
+}
 
 //if($_SESSION['mb_user_ip'] != $_SERVER['REMOTE_ADDR']){
 //	throwE(array("No session data available.","Permission denied.","Please authenticate."));
 //	die();	
 //}
 
-// permission 
-$con = db_connect(DBSERVER,OWNER,PW);
-db_select_db(DB,$con);
-
-$n = new administration();
-$myguis = $n->getGuisByPermission($_SESSION["mb_user_id"],true);
-$mywms = $n->getWmsByOwnGuis($myguis);
-
-$sql = "SELECT * FROM wms WHERE wms_owsproxy = $1";
-$v = array($wms);
-$t = array("s");
-$res = db_prep_query($sql, $v, $t);
-if($row = db_fetch_array($res)){
-	$wms_id = $row["wms_id"];
-	$wms_getcapabilities = $row["wms_getcapabilities"];	
-	$wms_getmap = $row["wms_getmap"];
-	$wms_getfeatureinfo = $row["wms_getfeatureinfo"];
-	$wms_getcapabilities_doc = $row["wms_getcapabilities_doc"];
-}
-else{
-	throwE(array("No wms data available."));
-	die();	
-}
-
-if(!in_array($wms_id, $mywms)){
-	throwE(array("Permission denied."," -> ".$wms_id, implode(",", $mywms)));
-	die();
-}
-
-/*************  prepare and send the response ************/
-
-switch (strtolower($request)) {
+/*************  workflow ************/
+$n = new administration();
+switch (strtolower($reqParams['request'])) {
 	case 'getcapabilities':
-		$or = $n->checkURL($row["wms_getcapabilities"]);
-		$or = completeURL($or);
-		getCapabilities($or);
+		$arrayOnlineresources = checkWmsPermission($query->getOwsproxyServiceId());
+		$query->setOnlineResource($arrayOnlineresources['wms_getcapabilities']);
+		$request = $query->getRequest();
+		getCapabilities($request);
 		break;
 	case 'getfeatureinfo':
-		$or = $n->checkURL($row["wms_getfeatureinfo"]);
-		$or = completeURL($or);
-		getFeatureInfo($or);
+		$arrayOnlineresources = checkWmsPermission($query->getOwsproxyServiceId());
+		$query->setOnlineResource($arrayOnlineresources['wms_getfeatureinfo']);
+		$request = $query->getRequest();
+		getFeatureInfo($request);
 		break;
+	case 'getmap':
+		$arrayOnlineresources = checkWmsPermission($owsproxyService);
+		$query->setOnlineResource($arrayOnlineresources['wms_getmap']);
+		$layers = checkLayerPermission($arrayOnlineresources['wms_id'],$reqParams['layers']);
+		$query->setParam("layers",$layers);
+		$request = $query->getRequest();
+		getImage($request);
+		break;
+	case 'getlegendgraphic':
+		$url = getLegendUrl($query->getOwsproxyServiceId());
+		getImage($url);
+		break;
+	case 'external':
+		getExternalRequest($query->getOwsproxyServiceId());
+		break; 
+	case 'getfeature':
+		$arrayFeatures = array($reqParams['typename']);
+		$arrayOnlineresources = checkWfsPermission($query->getOwsproxyServiceId(), $arrayFeatures);
+		$query->setOnlineResource($arrayOnlineresources['wfs_getfeature']);
+		$request = $query->getRequest();
+		$request = stripslashes($request);
+		getFeature($request);
+		break;
+	// case wfs transaction (because of raw POST the request param is empty)
+	case '':
+		$arrayFeatures = getWfsFeaturesFromTransaction($HTTP_RAW_POST_DATA);
+		$arrayOnlineresources = checkWfsPermission($query->getOwsproxyServiceId(), $arrayFeatures);
+		$query->setOnlineResource($arrayOnlineresources['wfs_transaction']);
+		$request = $query->getRequest();
+		doTransaction($request, $HTTP_RAW_POST_DATA);
+		break;
 	default:
-		$or = $n->checkURL($row["wms_getcapabilities"]);
-		$reqParams["layers"] = checkLayerPermission($layers);
-		$or = completeURL($or);
-		getMap($or);
+		
 }
 /*********************************************************/
 function throwE($e){
-	global $format, $imageformats;
-	if(in_array($format,$imageformats)){
+	global $reqParams, $imageformats;
+	if(in_array($reqParams['format'],$imageformats)){
 		throwImage($e);
 	}
 	else{
 		throwText($e);	
-	}	
-}
+	}
+}
+
 function throwImage($e){
 	global $width,$height;
 	$image = imagecreate($width,$height);
@@ -121,7 +131,8 @@
 	echo join(" ", $e);
 }
 function responseImage($im){
-	global $format;
+	global $reqParams;
+	$format = $reqParams['format'];
 	if($format == 'image/png'){header("Content-Type: image/png");}
 	if($format == 'image/jpeg' || $format == 'image/jpg'){header("Content-Type: image/jpeg");}
 	if($format == 'image/gif'){header("Content-Type: image/gif");}
@@ -135,39 +146,384 @@
 	$mykeys = array_keys($reqParams);
 	for($i=0; $i<count($mykeys);$i++){
 		if($i > 0){ $url .= "&"; }
-		$url .= $mykeys[$i]."=".$reqParams[$mykeys[$i]];
+		$url .= $mykeys[$i]."=".urlencode($reqParams[$mykeys[$i]]);
 	}
 	return $url;
 }
-function removeQM($t){
-	if(strpos($t,"?") === 0){
-		$t = substr($t,1);	
-	}	
-	return $t;
-}
-function getMap($or){
-	global $format;
-	if($format == 'image/png'){header("Content-Type: image/png");}
-	if($format == 'image/jpeg' || $format == 'image/jpg'){header("Content-Type: image/jpeg");}
-	if($format == 'image/gif'){header("Content-Type: image/gif");}
+
+/**
+ * fetch and returns an image to client
+ * 
+ * @param string the original url of the image to send
+ */
+
+function getImage($or){
+	global $reqParams;
+	header("Content-Type: ".$reqParams['format']);
 	echo getDocumentContent($or);
 }
+
+/**
+ * fetchs and returns the content of the FeatureInfo Response
+ * 
+ * @param string the url of the FeatureInfoRequest
+ * @return string the content of the FeatureInfo document
+ */
 function getFeatureInfo($url){
 	global $info_format;
+	//$e = new mb_notice("owsproxy: Try to fetch FeatureInfoRequest: ".$url);
 	header("Content-Type: ".$info_format);
-	echo getDocumentContent($url);
+	$content = getDocumentContent($url);
+	$content = matchUrls($content);
+	echo $content;
+}
+
+/**
+ * fetchs and returns the content of WFS GetFeature response
+ * 
+ * @param string the url of the GetFeature request
+ * @return echo the content of the GetFeature document
+ */
+function getFeature($url){
+	global $info_format;
+
+	header("Content-Type: ".$info_format);
+	$content = getDocumentContent($url);
+	$content = matchUrls($content);
+	echo $content;
+}
+
+/**
+ * simulates a post request to host
+ * 
+ * @param string host to send the request to
+ * @param string port of host to send the request to
+ * @param string method to send data (should be "POST")
+ * @param string path on host
+ * @param string data to send to host
+ * @return string hosts response
+ */
+
+function sendToHost($host,$port,$method,$path,$data){
+	$buf = '';
+    if (empty($method)) $method = 'POST';
+    $method = mb_strtoupper($method);
+    $fp = fsockopen($host, $port);
+    fputs($fp, "$method $path HTTP/1.1\r\n");
+    fputs($fp, "Host: $host\r\n");
+    fputs($fp,"Content-type: application/xml\r\n");
+    fputs($fp, "Content-length: " . strlen($data) . "\r\n");
+    fputs($fp, "Connection: close\r\n\r\n");
+    if ($method == 'POST') fputs($fp, $data);
+    while (!feof($fp)) $buf .= fgets($fp,4096);
+    fclose($fp);
+    return $buf;
+}
+
+/**
+ * get wfs featurenames that are touched by a tansaction request defined in XML $data
+ * 
+ * @param string XML that contains the tansaction request
+ * @return array array of touched feature names
+ */
+
+function getWfsFeaturesFromTransaction($data){
+	$features = array();
+	$values = NULL;
+	$tags = NULL;
+	$parser = xml_parser_create();
+	xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
+	xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
+	xml_parse_into_struct($parser,$data,$values,$tags);
+
+	$code = xml_get_error_code ($parser);
+	if ($code) {
+		$line = xml_get_current_line_number($parser);
+		$col = xml_get_current_column_number($parser);
+		$mb_exception = new mb_exception("OWSPROXY invalid Tansaction XML: ".xml_error_string($code) .  " in line " . $line. " at character ". $col);
+		die();
+	}
+	xml_parser_free($parser);
+	
+	$insert = false;
+	$insertlevel = 0;
+	foreach ($values as $element) {
+		//features touched by insert
+		if(strtoupper($element[tag]) == "WFS:INSERT" && $element[type] == "open"){
+			$insert = true;
+			$insertlevel = $element[level];
+		}
+		if($insert && $element[level] == $insertlevel + 1 && $element[type] == "open"){
+			array_push($features, $element[tag]);
+		}
+		if(strtoupper($element[tag]) == "WFS:INSERT" && $element[type] == "close"){
+			$insert = false;
+		}
+		//updated features
+		if(strtoupper($element[tag]) == "WFS:UPDATE" && $element[type] == "open"){
+			array_push($features, $element[attributes]["typeName"]);
+		}
+		//deleted features
+		if(strtoupper($element[tag]) == "WFS:DELETE" && $element[type] == "open"){
+			array_push($features, $element[attributes]["typeName"]);
+		}
+	}
+	return $features;
+}
+
+/**
+ * sends the data of WFS Transaction and echos the response
+ * 
+ *  @param string url to send the WFS Transaction to
+ *  @param string WFS Transaction data
+ */
+
+function doTransaction($url, $data){
+	$arURL = parse_url($url);
+	$host = $arURL["host"];
+	$port = $arURL["port"]; 
+	if($port == '') $port = 80;	
+
+	$path = $arURL["path"];
+	$method = "POST";
+	$result = sendToHost($host,$port,$method,html_entity_decode($path),$data);
+	
+	//delete header from result
+	$result = mb_eregi_replace("^[^<]*", "", $result);
+	$result = mb_eregi_replace("[^>]*$", "", $result);
+	
+	echo $result;
 }
+
+function matchUrls($content){
+	if(!session_is_registered("owsproxyUrls")){
+		$_SESSION["owsproxyUrls"] = array();
+		$_SESSION["owsproxyUrls"]["id"] = array();
+		$_SESSION["owsproxyUrls"]["url"] = array();
+	}
+	$pattern = "/[\"|\'](https*:\/\/[^\"|^\']*)[\"|\']/";
+	preg_match_all($pattern,$content,$matches);
+	for($i=0; $i<count($matches[1]); $i++){
+		$req = $matches[1][$i];
+		$id = registerURL($req);
+		$extReq = setExternalRequest($id);
+		$content = str_replace($req,$extReq,$content);
+	}
+	return $content;
+}
+
+function setExternalRequest($id){
+	global $reqParams,$query;
+	$extReq = OWSPROXY ."/". $reqParams['sid'] ."/".$id."?request=external";
+	return $extReq;
+}
+function getExternalRequest($id){
+	for($i=0; $i<count($_SESSION["owsproxyUrls"]["url"]); $i++){
+		if($id == $_SESSION["owsproxyUrls"]["id"][$i]){
+			$cUrl = $_SESSION["owsproxyUrls"]["url"][$i];
+			$query_string = removeOWSGetParams($_SERVER["QUERY_STRING"]);
+			if($query_string != ''){
+				$cUrl .= getConjunctionCharacter($cUrl).$query_string;
+			}	
+			$metainfo = get_headers($cUrl,1);
+			// just for the stupid InternetExplorer
+			header('Pragma: private');
+			header('Cache-control: private, must-revalidate');
+			
+			header("Content-Type: ".$metainfo['Content-Type']);
+			
+			$content = getDocumentContent($cUrl);
+			$content = matchUrls($content);			
+			echo $content; 
+		}	
+	} 
+}
+function removeOWSGetParams($query_string){
+	$r = preg_replace("/.*request=external&/","",$query_string);
+	return $r;
+}
+function getConjunctionCharacter($url){
+	if(strpos($url,"?")){ 
+		if(strpos($url,"?") == strlen($url)){ 
+			$cchar = "";
+		}else if(strpos($url,"&") == strlen($url)){
+			$cchar = "";
+		}else{
+			$cchar = "&";
+		}
+	}
+	if(strpos($url,"?") === false){
+		$cchar = "?";
+	} 
+	return $cchar;  
+}
+function registerUrl($url){	
+	if(!in_array($url,$_SESSION["owsproxyUrls"]["url"])){
+		$id = md5($url);
+		array_push($_SESSION["owsproxyUrls"]["url"],$url);
+		array_push($_SESSION["owsproxyUrls"]["id"], $id);
+	}
+	else{
+		for($i=0; $i<count($_SESSION["owsproxyUrls"]["url"]); $i++){
+			if($url == $_SESSION["owsproxyUrls"]["url"][$i]){
+				$id = $_SESSION["owsproxyUrls"]["id"][$i];
+			}			
+		}
+	}
+	return $id;
+}
 function getCapabilities($url){
-	global $wms_getcapabilities,$wms_getmap,$wms_getfeatureinfo,$wms_getcapabilities_doc;
+	global $arrayOnlineresources;
 	global $sid,$wms;
-	$t = array(htmlentities($wms_getcapabilities),htmlentities($wms_getmap),htmlentities($wms_getfeatureinfo));
+	$t = array(htmlentities($arrayOnlineresources["wms_getcapabilities"]),htmlentities($arrayOnlineresources["wms_getmap"]),htmlentities($arrayOnlineresources["$wms_getfeatureinfo"]));
 	$new = OWSPROXY ."/". $sid ."/".$wms."?";
-	$r = str_replace($t,$new,$wms_getcapabilities_doc);
+	$r = str_replace($t,$new,$arrayOnlineresources["wms_getcapabilities_doc"]);
 	header("Content-Type: application/xml");
 	echo $r;
-}
-function checkLayerPermission($l){
-	global $n,$wms_id;
+}
+
+/**
+ * gets the original url of the requested legend graphic
+ * 
+ * @param string owsproxy md5
+ * @return string url to legend graphic
+ */
+function getLegendUrl($wms){
+	global $reqParams;
+	
+	//get wms id
+	$sql = "SELECT * FROM wms WHERE wms_owsproxy = $1";
+	$v = array($wms);
+	$t = array("s");
+	$res = db_prep_query($sql, $v, $t);	
+	if($row = db_fetch_array($res))
+		$wmsid = $row["wms_id"];
+	else{
+		throwE(array("No wms data available."));
+		die();	
+	}
+	
+	//get the url
+	$sql = "SELECT layer_style.legendurl ";
+	$sql .= "FROM layer_style JOIN layer ";
+	$sql .= "ON layer_style.fkey_layer_id = layer.layer_id ";
+	$sql .= "WHERE layer.layer_name = $2 AND layer.fkey_wms_id = $1 ";
+	$sql .= "AND layer_style.name = $3 AND layer_style.legendurlformat = $4";
+	
+	$v = array($wmsid, $reqParams['layer'], $reqParams['style'], $reqParams['format']);
+	$t = array("i", "s", "s", "s");
+	
+	$res = db_prep_query($sql, $v, $t);
+	if($row = db_fetch_array($res))
+		return $row["legendurl"];
+	else{
+		throwE(array("No legend available."));
+		die();
+	}
+}
+/**
+ * validated access permission on requested wms
+ * 
+ * @param string OWSPROXY md5
+ * @return array array with detailed information about requested wms
+ */
+function checkWmsPermission($wms){
+	global $con, $n;
+	$myguis = $n->getGuisByPermission($_SESSION["mb_user_id"],true);
+	$mywms = $n->getWmsByOwnGuis($myguis);
+
+	$sql = "SELECT * FROM wms WHERE wms_owsproxy = $1";
+	$v = array($wms);
+	$t = array("s");
+	$res = db_prep_query($sql, $v, $t);
+	$service = array();
+	if($row = db_fetch_array($res)){
+		$service["wms_id"] = $row["wms_id"];
+		$service["wms_getcapabilities"] = $row["wms_getcapabilities"];	
+		$service["wms_getmap"] = $row["wms_getmap"];
+		$service["wms_getfeatureinfo"] = $row["wms_getfeatureinfo"];
+		$service["wms_getcapabilities_doc"] = $row["wms_getcapabilities_doc"];
+	}
+	if(!$row || count($mywms) == 0){
+		throwE(array("No wms data available."));
+		die();	
+	}
+	
+	if(!in_array($service["wms_id"], $mywms)){
+		throwE(array("Permission denied."," -> ".$service["wms_id"], implode(",", $mywms)));
+		die();
+	}
+	return $service;
+}
+/**
+ * validates the access permission by getting the appropriate wfs_conf
+ * to each feature requested and check the wfs_conf permission
+ * 
+ * @param string owsproxy md5
+ * @param array array of requested featuretype names
+ * @return array array with detailed information on reqested wfs
+ */
+function checkWfsPermission($wfsOws, $features){
+	global $con, $n;
+	$myconfs = $n->getWfsConfByPermission($_SESSION["mb_user_id"]);
+	
+	//check if we know the features requested
+	if(count($features) == 0){
+		throwE(array("No wfs_feature data available."));
+		die();
+	}
+	
+	//get wfs
+	$sql = "SELECT * FROM wfs WHERE wfs_owsproxy = $1";
+	$v = array($wfsOws);
+	$t = array("s");
+	$res = db_prep_query($sql, $v, $t);
+	$service = array();
+	if($row = db_fetch_array($res)){
+		$service["wfs_id"] = $row["wfs_id"];
+		$service["wfs_getcapabilities"] = $row["wfs_getcapabilities"];	
+		$service["wfs_getfeature"] = $row["wfs_getfeature"];
+		$service["wfs_describefeaturetype"] = $row["wfs_describefeaturetype"];
+		$service["wfs_transaction"] = $row["wfs_transaction"];
+		$service["wfs_getcapabilities_doc"] = $row["wfs_getcapabilities_doc"];
+	}
+	else{
+		throwE(array("No wfs data available."));
+		die();	
+	}
+	
+	foreach($features as $feature){
+	
+		//get appropriate wfs_conf
+		$sql = "SELECT wfs_conf.wfs_conf_id FROM wfs_conf ";
+		$sql.= "JOIN wfs_featuretype ";
+		$sql.= "ON wfs_featuretype.featuretype_id = wfs_conf.fkey_featuretype_id ";
+		$sql.= "WHERE wfs_featuretype.featuretype_name = $2 ";
+		$sql.= "AND wfs_featuretype.fkey_wfs_id = $1";
+		$v = array($service["wfs_id"], $feature);
+		$t = array("i","s");
+		$res = db_prep_query($sql, $v, $t);
+		if(!($row = db_fetch_array($res))){
+			$notice = new mb_notice("Permissioncheck failed no wfs conf for wfs ".$service["wfs_id"]." with feturetype ".$feature);
+			throwE(array("No wfs_conf data for featuretype ".$feature));
+			die();	
+		}
+		$conf_id = $row["wfs_conf_id"];
+		
+		//check permission
+		if(!in_array($conf_id, $myconfs)){
+			$notice = new mb_notice("Permissioncheck failed:".$conf_id." not in ".implode(",", $myconfs));
+			throwE(array("Permission denied."," -> ".$conf_id, implode(",", $myconfs)));
+			die();
+		}
+	}
+
+	return $service;
+}
+
+function checkLayerPermission($wms_id,$l){
+	global $n, $owsproxyService;
+//	$notice = new mb_notice("owsproxy: checkLayerpermission: wms: ".$wms_id.", layer: ".$l);
 	$myl = split(",",$l);
 	$r = array();
 	foreach($myl as $mysl){
@@ -182,5 +538,4 @@
 	$d = new connector($url);
 	return $d->file;
 }
-
 ?>
\ No newline at end of file



More information about the Mapbender_commits mailing list