[Mapbender-commits] r4001 - in branches/dynamic_printframe_dev: . classes javascripts php print_dynamic print_dynamic/img

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Jun 4 09:50:53 EDT 2009


Author: christoph
Date: 2009-06-04 09:50:53 -0400 (Thu, 04 Jun 2009)
New Revision: 4001

Added:
   branches/dynamic_printframe_dev/classes/
   branches/dynamic_printframe_dev/classes/class_weldMaps2PNG_rotate.php
   branches/dynamic_printframe_dev/classes/class_weldOverview2PNG_rotate.php
   branches/dynamic_printframe_dev/javascripts/
   branches/dynamic_printframe_dev/javascripts/map_obj.js
   branches/dynamic_printframe_dev/php/
   branches/dynamic_printframe_dev/php/mod_map1.php
   branches/dynamic_printframe_dev/print_dynamic.sql
   branches/dynamic_printframe_dev/print_dynamic/
   branches/dynamic_printframe_dev/print_dynamic/img/
   branches/dynamic_printframe_dev/print_dynamic/img/mapbender_logo.png
   branches/dynamic_printframe_dev/print_dynamic/img/northarrow.png
   branches/dynamic_printframe_dev/print_dynamic/img/northarrow_plain.png
   branches/dynamic_printframe_dev/print_dynamic/mod_printPDF.php
   branches/dynamic_printframe_dev/print_dynamic/mod_printPDF_pdf.php
   branches/dynamic_printframe_dev/print_dynamic/printPDF_b.conf
   branches/dynamic_printframe_dev/print_dynamic/printbox.js
Log:


Added: branches/dynamic_printframe_dev/classes/class_weldMaps2PNG_rotate.php
===================================================================
--- branches/dynamic_printframe_dev/classes/class_weldMaps2PNG_rotate.php	                        (rev 0)
+++ branches/dynamic_printframe_dev/classes/class_weldMaps2PNG_rotate.php	2009-06-04 13:50:53 UTC (rev 4001)
@@ -0,0 +1,95 @@
+<?php
+# $Id: class_weldMaps2PNG_rotate.php 2684 2008-07-22 07:26:19Z christoph $
+# http://www.mapbender.org/index.php/class_weldMaps2PNG_rotate.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.
+
+/*
+* class_weldMaps2PNG_rotate
+* @version 1.0.0
+* get/post '___' separated maprequests
+*
+**/
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/class_stripRequest.php");
+require_once(dirname(__FILE__)."/class_connector.php");
+require_once(dirname(__FILE__)."/class_weldMaps2PNG.php");
+
+class weldMaps2PNG_rotate extends weldMaps2PNG{
+
+    function weldMaps2PNG_rotate($urls,$filename, $angle){
+        if(!$urls || $urls == ""){
+            $e = new mb_exception("weldMaps2PNG_rotate: no maprequests delivered");
+        }
+        $url = explode("___", $urls);
+        $obj1 = new stripRequest($url[0]);
+        $width = $obj1->get("width");
+        $height = $obj1->get("height");
+        	
+        //calculate rotated dimensions
+        $neededWidth = round(abs(sin(deg2rad($angle))*$height)+abs(cos(deg2rad($angle))*$width));
+        $neededHeight = round(abs(sin(deg2rad($angle))*$width)+abs(cos(deg2rad($angle))*$height));
+    
+        //modify requests
+        for($i=0; $i<count($url); $i++){
+            $obj = new stripRequest($url[$i]);
+            $obj->set("width", $neededWidth);
+            $obj->set("height", $neededHeight);
+                
+            $map_extent = $obj->get("BBOX");
+            $coord = split(",",$map_extent);
+            $coord = $this->enlargeExtent($coord, $width, $height, $neededWidth, $neededHeight);
+            
+            $obj->set("BBOX", implode(",", $coord));
+            $url[$i] = $obj->url;
+        }
+
+        //get image
+        $urls = implode("___", $url);
+        $this->weldMaps2PNG($urls, $filename);
+        
+
+        //rotate image
+        $imagick = new Imagick();
+        $imagick->readImage($filename);
+        $imagick->rotateImage(new ImagickPixel(), $angle);
+        
+        //get the new dimensions
+        $imgWidth = $imagick->getImageWidth();
+        $imgHeight = $imagick->getImageHeight();
+            
+        //crop empty areas
+        $imagick->cropImage($width, $height, ($imgWidth-$width)/2, ($imgHeight-$height)/2);
+        
+        //write modified image
+        $imagick->writeImage();
+        $image = imagecreatefrompng($filename);
+        imagepng($image,$filename);
+    }
+ 
+    function enlargeExtent($coordArray, $oldWidth, $oldHeight, $newWidth, $newHeight){
+         $extentx = ($coordArray[2] - $coordArray[0]);
+         $extenty = ($coordArray[3] - $coordArray[1]);
+         $coordArray[0]+=($extentx/$oldWidth)*($oldWidth-$newWidth)/2;
+         $coordArray[2]+=($extentx/$oldWidth)*($newWidth-$oldWidth)/2;
+         $coordArray[1]+=($extenty/$oldHeight)*($oldHeight-$newHeight)/2;
+         $coordArray[3]+=($extenty/$oldHeight)*($newHeight-$oldHeight)/2;
+        return $coordArray;
+    }
+    
+}
+
+?>
\ No newline at end of file

Added: branches/dynamic_printframe_dev/classes/class_weldOverview2PNG_rotate.php
===================================================================
--- branches/dynamic_printframe_dev/classes/class_weldOverview2PNG_rotate.php	                        (rev 0)
+++ branches/dynamic_printframe_dev/classes/class_weldOverview2PNG_rotate.php	2009-06-04 13:50:53 UTC (rev 4001)
@@ -0,0 +1,148 @@
+<?php
+# $Id: class_weldOverview2PNG.php 1584 2007-08-06 07:56:11Z christoph $
+# $Header: /cvsroot/mapbender/mapbender/http/classes/class_weldOverview2PNG.php,v 1.3 2006/02/22 11:56:22 astrid_emde Exp $
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/*
+* class_weldOverview2PNG
+* @version 1.0.0
+* get/post '___' separated maprequests
+*
+**/
+require_once(dirname(__FILE__)."/class_stripRequest.php");
+require_once(dirname(__FILE__)."/class_mb_exception.php");
+require_once(dirname(__FILE__)."/class_connector.php");
+
+class weldOverview2PNG_rotate{
+
+	function weldOverview2PNG_rotate($url_overview,$url_extent,$filename, $rotatedExtent){
+
+		if(!$url_overview || $url_overview == ""){
+			$e = new mb_exception("weldOverview2PNG: no maprequests delivered");
+		}
+		$url = $url_overview;
+		$obj1 = new stripRequest($url);
+		$width = $obj1->get("width");
+		$height = $obj1->get("height");
+		
+		/*
+		$e = new mb_exception("--------overview-----------------");
+		$e = new mb_exception("-----width ".$width." / height: ".$height."--------------------");
+		$e = new mb_exception("url_overview: ".$url_overview);
+		$e = new mb_exception("url_extent: ".$url_extent);
+		*/	
+		$image = imagecreatetruecolor($width, $height);
+		$white = ImageColorAllocate($image,255,255, 255); 
+		ImageFilledRectangle($image,0,0,$width,$height,$white); 
+		
+		//overview
+		$obj = new stripRequest($url_overview);
+		$xurl_overview = $obj->setPNG();
+		$xurl_overview = $obj->encodeGET();
+		$img = $this->loadpng($xurl_overview);		
+		if($img != false){
+			imagecopy($image, $img, 0, 0, 0, 0, $width, $height);
+		}
+		else{
+			$e = new mb_exception("weldMaps2PNG: unable to load image: " . $url_overview);
+		}
+		
+		
+		// rectangle - position of the map in the overview
+		$objx = new stripRequest($url_extent);
+		$ex_width = $objx->get("width");
+		$ex_height = $objx->get("height");
+		$extent = explode(",",$objx->get("BBOX"));
+
+		$p1 = $this->makeRealWorld2mapPos($url_overview, round($rotatedExtent[0][0]), round($rotatedExtent[0][1]));
+		$p2 = $this->makeRealWorld2mapPos($url_overview, round($rotatedExtent[1][0]), round($rotatedExtent[1][1]));
+		$p3 = $this->makeRealWorld2mapPos($url_overview, round($rotatedExtent[2][0]), round($rotatedExtent[2][1]));
+		$p4 = $this->makeRealWorld2mapPos($url_overview, round($rotatedExtent[3][0]), round($rotatedExtent[3][1]));
+		
+		/*
+		$e = new mb_exception("ex_width: " .$ex_width);
+		$e = new mb_exception("ex_height: " . $ex_height);
+		$e = new mb_exception("bbox:".$extent[0]."--".$extent[1]."--".$extent[2]."--------".$extent[3]);
+		$e = new mb_exception("ll: " . $lowerleft[0]." / ".$lowerleft[1]);
+		$e = new mb_exception("ur: " . $upperright[0]." / ".$upperright[1]);
+		*/
+		
+		$red = ImageColorAllocate($image,255,0,0); 
+		imageline ( $image, $p1[0], $p1[1], $p2[0], $p2[1], $red);
+		imageline ( $image, $p2[0], $p2[1], $p3[0], $p3[1], $red);
+		imageline ( $image, $p3[0], $p3[1], $p4[0], $p4[1], $red);
+		imageline ( $image, $p4[0], $p4[1], $p1[0], $p1[1], $red);
+		
+		
+		// black frame - size of the overview
+		$black = ImageColorAllocate($image,0,0,0); 
+		imageline ( $image, 0, 0, $width-1, 0, $black);
+		imageline ( $image, $width-1, 0, $width-1, $height-1, $black);
+		imageline ( $image, $width-1, $height-1, 0, $height-1, $black);
+		imageline ( $image, 0, $height-1, 0, 0, $black);
+		
+		imagepng($image,$filename);
+		imagedestroy($image); 
+		
+	}
+	
+	
+	function loadpng ($imgurl) {
+		$obj = new stripRequest($imgurl);
+		$x = new connector($imgurl);
+			
+		$f = $obj->get("format");
+		$im = @imagecreatefromstring($x->file);
+
+		if(!$im){
+			$im = false;
+			$e = new mb_exception("weldOverview2PNG: unable to load image: ".$imgurl);
+		}  
+		return $im;
+	}
+	
+	function makeRealWorld2mapPos($url, $rw_posx, $rw_posy){
+	   	$obj = new stripRequest($url);
+		$width = $obj->get("width");
+		$height = $obj->get("height");
+		
+		
+		#$e = new mb_exception("weld_url: ".$url);
+		#$e = new mb_exception("w: ".$width."height".$height);
+
+	   $arrayBBox = explode(",",$obj->get("BBOX"));
+	   $minX = $arrayBBox[0];
+	   $minY = $arrayBBox[1];
+	   $maxX = $arrayBBox[2];
+	   $maxY = $arrayBBox[3];
+
+	#$e = new mb_exception("------- minx: ".$minX." miny:".$minY." maxx:".$maxX." maxy:".$maxY."----------");
+
+	   $xtentx = $maxX - $minX ; 
+	   $xtenty = $maxY - $minY ;  
+
+	   $pixPos_x = round((($rw_posx - $minX)/$xtentx)*$width);
+	   $pixPos_y = round((($maxY - $rw_posy)/$xtenty)*$height);
+
+	   $pixPos = array($pixPos_x, $pixPos_y);
+	   
+	   return $pixPos;
+	}
+	
+}
+
+?>
\ No newline at end of file

Added: branches/dynamic_printframe_dev/javascripts/map_obj.js
===================================================================
--- branches/dynamic_printframe_dev/javascripts/map_obj.js	                        (rev 0)
+++ branches/dynamic_printframe_dev/javascripts/map_obj.js	2009-06-04 13:50:53 UTC (rev 4001)
@@ -0,0 +1,790 @@
+/* 
+* $Id: map_obj.js 3237 2008-11-12 15:09:33Z christoph $
+* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
+* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
+*/
+
+//global variables
+var wms = [];
+var wms_layer_count = 0;
+
+/*
+ * global function to add wms to the wms-object
+ * 
+ * @param {String} wms_id the unique id of the wms 
+ * @param {String} wms_version the version assumed from capabilities
+ * @param {String} wms_title the title of the wms
+ * @param {String} wms_abstract the abstract of the wms
+ * @param {String} wms_getmap the url for map requests
+ * @param {String} wms_getfeatureinfo the url for featureInof requests
+ * @param {String} wms_getlegendurl the url for legend requests
+ * @param {String} wms_filter a filter (deprecated)
+ * @param {String} gui_wms_mapformat the image-format in the actual gui
+ * @param {String} gui_wms_featureinfoformat the current format for featureInfos
+ * @param {String} gui_wms_exceptionformat the exceptionformat for map requests
+ * @param {String} gui_wms_epsg the current srs
+ * @param {Integer} gui_wms_visible the visibility of this service
+ * @param {Integer} gui_wms_opacity the initial display opacity in percent
+ * @param {String} gui_wms_sldurl url to an actual sld
+ */
+function add_wms(
+			wms_id,
+			wms_version,
+			wms_title,
+			wms_abstract,
+			wms_getmap,
+			wms_getfeatureinfo,
+			wms_getlegendurl,
+			wms_filter,
+			gui_wms_mapformat,
+			gui_wms_featureinfoformat,
+			gui_wms_exceptionformat,
+			gui_wms_epsg,
+			gui_wms_visible,
+			gui_wms_opacity,
+			gui_wms_sldurl){
+					wms[wms.length] = new wms_const( 
+					wms_id,
+					wms_version,
+					wms_title,
+					wms_abstract,
+					wms_getmap,
+					wms_getfeatureinfo,
+					wms_getlegendurl,
+					wms_filter,
+					gui_wms_mapformat,
+					gui_wms_featureinfoformat,
+					gui_wms_exceptionformat,
+					gui_wms_epsg,
+					parseInt(gui_wms_visible, 10),
+					parseInt(gui_wms_opacity),
+					gui_wms_sldurl);
+					wms_layer[wms.length - 1] = [];
+}
+/**
+ * @class A class representing the wms
+ *
+ * @constructor
+ * @param {String} wms_id the unique id of the wms 
+ * @param {String} wms_version the version assumed from capabilities
+ * @param {String} wms_title the title of the wms
+ * @param {String} wms_abstract the abstract of the wms
+ * @param {String} wms_getmap the url for map requests
+ * @param {String} wms_getfeatureinfo the url for featureInof requests
+ * @param {String} wms_getlegendurl the url for legend requests
+ * @param {String} wms_filter a filter (deprecated)
+ * @param {String} gui_wms_mapformat the image-format in the actual gui
+ * @param {String} gui_wms_featureinfoformat the current format for featureInfos
+ * @param {String} gui_wms_exceptionformat the exceptionformat for map requests
+ * @param {String} gui_wms_epsg the current srs
+ * @param {String} gui_wms_visible the visibility of this service
+ * @param {Integer} gui_wms_opacity the initial display opacity in percent
+ * @param {String} gui_wms_sldurl url to an actual sld
+ * 
+ */
+function wms_const(  
+			wms_id,
+			wms_version,
+			wms_title,
+			wms_abstract,
+			wms_getmap,
+			wms_getfeatureinfo,
+		    wms_getlegendurl,
+			wms_filter,
+			gui_wms_mapformat,
+			gui_wms_featureinfoformat,
+			gui_wms_exceptionformat,
+			gui_wms_epsg,
+			gui_wms_visible,
+			gui_wms_opacity,
+			gui_wms_sldurl){
+   
+	if (!wms_id) {
+		var id_ok = false;
+		while (id_ok === false) {
+			wms_id = "a"+Math.round(10000*Math.random());
+			id_ok = true;
+			for (var i=0; i < wms.length && id_ok === true; i++) {
+				if (wms_id == wms[i].wms_id) { 
+					id_ok = false;
+				}
+			}
+		}
+	}
+	
+	this.wms_id = wms_id;
+	this.wms_version = wms_version;
+	this.wms_title = wms_title;
+	this.wms_abstract = wms_abstract;
+	this.wms_getmap = wms_getmap;
+	this.wms_getfeatureinfo = wms_getfeatureinfo;
+	this.wms_getlegendurl = wms_getlegendurl;
+	this.wms_filter = wms_filter;
+	this.data_type = [];
+	this.data_format = [];
+	this.objLayer = [];
+	this.gui_wms_mapformat = gui_wms_mapformat;
+	this.gui_wms_featureinfoformat = gui_wms_featureinfoformat;
+	this.gui_wms_exceptionformat = gui_wms_exceptionformat;
+	this.gui_wms_epsg = gui_wms_epsg;
+	this.gui_wms_visible = gui_wms_visible;
+	this.gui_epsg = [];
+	this.gui_minx = [];
+	this.gui_miny = [];
+	this.gui_maxx = [];
+	this.gui_maxy = [];
+
+	// opacity version 
+	this.gui_wms_mapopacity = gui_wms_opacity/100;
+	// sld version
+	this.gui_wms_sldurl = gui_wms_sldurl;      
+}
+
+/**
+ * rephrases the mapRequest
+ *
+ * @param {Object} mapObj the mapbender mapObject of the wms  
+ * @return mapRequest, i.e. onlineresource + params
+ * @type String
+ */
+wms_const.prototype.getMapRequest = function(mapObj){	
+	//check visible layers first
+	var layers = this.getLayers(mapObj);
+	if(!layers){
+		return false;
+	}
+	
+	var rq = this.wms_getmap;
+	rq += mb_getConjunctionCharacter(this.wms_getmap);
+	if(this.wms_version === "1.0.0"){
+		rq += "WMTVER=" + this.wms_version + "&REQUEST=map";
+	}
+	else{
+		rq += "VERSION=" + this.wms_version + "&REQUEST=getMap&SERVICE=WMS";
+	}
+	
+	rq += "&LAYERS=" + layers.join(",");
+	rq += "&WIDTH=" + mapObj.getWidth();
+	rq += "&HEIGHT=" + mapObj.getHeight();
+	rq += "&SRS=" + mapObj.getSRS();
+	rq += "&BBOX=" + mapObj.getExtent();
+	rq += "&STYLES=" + this.getLayerstyles(mapObj).join(",");
+	rq += "&FORMAT=" + this.gui_wms_mapformat;
+	rq += "&EXCEPTIONS=" + this.gui_wms_exceptionformat;
+	//Todo: error occurs:
+	//var throwNotice = new Mb_notice("getMapRequest: " + rq);
+	//window.console.log("getMapRequest: " + rq);
+	return rq;
+};
+
+
+/**
+ * rephrases the featureInfoRequest
+ *
+ * @param {Object} mapObj the mapbender mapObject of the wms  
+ * @param {Point} clickPoint map-click position {@link Point}
+ * @return featureInfoRequest, onlineresource + params
+ * @type string
+ */
+wms_const.prototype.getFeatureInfoRequest = function(mapObj, clickPoint){	
+	
+	//check layers and querylayers first 
+	var layers = this.getLayers(mapObj);
+	var querylayers = this.getQuerylayers(mapObj);
+	
+	if(!layers || !querylayers){
+		return false;
+	}
+	
+	var rq = this.wms_getfeatureinfo;
+	rq += mb_getConjunctionCharacter(this.wms_getfeatureinfo);
+	if(this.wms_version === "1.0.0"){
+		rq += "WMTVER=" + this.wms_version + "&REQUEST=feature_info";
+	}
+	else{
+		rq += "VERSION=" + this.wms_version + "&REQUEST=GetFeatureInfo&SERVICE=WMS";
+	}
+	
+	rq += "&LAYERS=" + layers.join(",");
+	if(mb_feature_count > 0){             
+		rq += "&FEATURE_COUNT="+mb_feature_count;
+	}	
+	rq += "&QUERY_LAYERS=" + querylayers.join(",");
+	rq += "&WIDTH=" + mapObj.getWidth();
+	rq += "&HEIGHT=" + mapObj.getHeight();
+	rq += "&SRS=" + mapObj.getSRS();
+	rq += "&BBOX=" + mapObj.getExtent();
+	rq += "&STYLES=" + this.getLayerstyles(mapObj).join(",");
+	rq += "&FORMAT=" + this.gui_wms_mapformat;
+	rq += "&INFO_FORMAT=" + this.gui_wms_featureinfoformat;
+	rq += "&EXCEPTIONS=application/vnd.ogc.se_xml";
+	rq += "&X=" + clickPoint.x;
+	rq += "&Y=" + clickPoint.y;
+	//console.log(rq);
+	return rq;
+};
+
+/**
+ * sets Opacity of WMS
+ * 
+ * @param {Integer} new opacity percentage value
+ */
+wms_const.prototype.setOpacity = function(opacity){
+	//calc new opacity
+	this.gui_wms_mapopacity = parseInt(opacity)/100;
+	if(this.gui_wms_mapopacity>1||isNaN(this.gui_wms_mapopacity))
+		this.gui_wms_mapopacity=1;
+	if(this.gui_wms_mapopacity<0)
+		this.gui_wms_mapopacity=0;
+		
+	if (this.gui_wms_visible > 0) {
+
+		//get div id
+		var divId = null;
+		for (var i=0; i < wms.length; i++) {
+			if (this.wms_id == wms[i].wms_id) { 
+				var divId = 'div_'+i;
+				break;
+			}
+		}
+		if(!divId)
+			return;	
+		
+		//TODO: check if mapframe1 is the right mapframe
+		wmsImage = parent.mapframe1.document.getElementById(divId);
+		if (wmsImage != null) {
+			wmsImage.style.opacity = this.gui_wms_mapopacity;
+			wmsImage.style.MozOpacity = this.gui_wms_mapopacity;
+			wmsImage.style.KhtmlOpacity = this.gui_wms_mapopacity;
+			wmsImage.style.filter = "alpha(opacity=" + this.gui_wms_mapopacity*100 + ")";
+		}
+	}
+}
+
+/**
+ * get all visible layers
+ *
+ * @return array of layernames 
+ * @type string[]
+ */
+wms_const.prototype.getLayers = function(mapObj){
+	
+	try {
+	//visibility of the wms
+	var wmsIsVisible = (this.gui_wms_visible > 0);
+	if(!wmsIsVisible){
+		return false;
+	}
+	visibleLayers = [];
+	for(var i=0; i< this.objLayer.length; i++){
+		var isVisible = (this.objLayer[i].gui_layer_visible === 1);
+		var hasNoChildren = (!this.objLayer[i].has_childs);
+		if (isVisible && hasNoChildren){
+			if(this.objLayer[i].checkScale(mapObj)){
+				//console.log("checkLayer: " + this.objLayer[i].layer_name);
+				visibleLayers.push(this.objLayer[i].layer_name);
+			}
+		}
+	}
+	if(visibleLayers.length === 0){
+		return false;
+	}
+	return visibleLayers;
+	}
+	catch (e) {
+		alert(e);
+	}
+};
+
+/**
+ * get the actual style of all visible layers
+ *
+ * @return commaseparated list of actual layerstyles
+ * @type string
+ */
+wms_const.prototype.getLayerstyles = function(mapObj){
+	var layers = this.getLayers(mapObj);
+	var layerstyles = '';
+	var styles = [];
+	if(layers){
+		for(i = 0; i < layers.length; i++){
+			var style = this.getCurrentStyleByLayerName(layers[i]);
+			if(!style){
+				style = '';
+			}
+			styles.push(style);
+		}
+		return styles;
+	}
+	return false;
+};
+
+/**
+ * check if layer is parentLayer
+ *
+ * @param layername
+ * @return the parent value of the given layer
+ * @type integer
+ */
+wms_const.prototype.checkLayerParentByLayerName = function(layername){
+	for(var i=0; i< this.objLayer.length; i++){
+		if(this.objLayer[i].layer_name == layername){
+			return this.objLayer[i].layer_parent;
+		}
+	}
+};
+
+/**
+ * get the title of the current layer
+ *
+ * @param layername
+ * @return the title of the given layer
+ * @type string
+ */
+wms_const.prototype.getTitleByLayerName = function(layername){
+	for(var i=0; i< this.objLayer.length; i++){
+		if(this.objLayer[i].layer_name == layername){
+			return this.objLayer[i].layer_title;
+		}
+	}
+};
+
+/**
+ * get the current style of the layer
+ *
+ * @param layername
+ * @return the stylename of the given layer
+ * @type string
+ */
+wms_const.prototype.getCurrentStyleByLayerName = function(layername){
+	for(var i=0; i< this.objLayer.length; i++){
+		if(this.objLayer[i].layer_name == layername){
+			if(this.objLayer[i].gui_layer_style === '' || this.objLayer[i].gui_layer_style === null){
+				return false;
+			}
+			else{
+				return this.objLayer[i].gui_layer_style;	
+			}
+		}
+	}
+};
+
+/**
+ * get the legendurl of the gui layer style
+ *
+ * @param stylename
+ * @return the legendurl of the given style
+ * @type string
+ */
+wms_const.prototype.getLegendUrlByGuiLayerStyle = function(layername,guiLayerStyle){
+	for(var i=0; i< this.objLayer.length; i++){
+		if(this.objLayer[i].layer_name == layername){
+			if(this.objLayer[i].layer_style.length === 0){
+				return false;
+			}
+			for(var k=0; k< this.objLayer[i].layer_style.length; k++){
+				if(this.objLayer[i].layer_style[k].name == guiLayerStyle){
+					var legendUrl = this.objLayer[i].layer_style[k].legendurl;
+					if (this.gui_wms_sldurl !== "") {
+					 		legendUrl += "&SLD="+escape(this.gui_wms_sldurl);
+					}				
+					if(legendUrl !=='' && legendUrl !== null && typeof(legendUrl) != 'undefined'){
+						return legendUrl;
+					}
+					else {
+						return false;
+					}
+				}
+			}
+		}
+	}
+	return false;
+};
+
+/**
+ * get all querylayers
+ *
+ * @return array of layernames
+ * @type string[]
+ */
+wms_const.prototype.getQuerylayers = function(mapObj){
+	queryLayers = [];
+	for(var i=0; i< this.objLayer.length; i++){
+		if(this.objLayer[i].gui_layer_querylayer === 1 && ! this.objLayer[i].has_childs ){
+			if(this.objLayer[i].checkScale(mapObj)){
+				queryLayers.push(this.objLayer[i].layer_name);
+			}
+		}
+	}
+	if(queryLayers.length === 0){
+		return false;
+	}
+	return queryLayers;
+};
+
+/**
+ * get a layer Object by layer_pos
+ * 
+ * @param int payer_pos layer_pos of layer you want to get
+ * @return object layer
+ */
+
+wms_const.prototype.getLayerByLayerPos = function(layer_pos){
+	for(var i=0;i<this.objLayer.length;i++){
+		if(this.objLayer[i].layer_pos == layer_pos) {
+			return this.objLayer[i];
+		}
+	}
+	return null;
+};
+/**
+ * get the state of sublayers from a specified layer
+ * 
+ * @param int layer_id of the parent layer
+ * @param String type "visible" or "querylayer"
+ * @return int -1 if state differs else the state
+ */
+
+wms_const.prototype.getSublayerState = function(layer_id, type){
+	var i;
+	var state=-1,value;
+	for(i = 0; i < this.objLayer.length; i++){
+		if(this.objLayer[i].layer_id==layer_id) {
+			break;
+		}
+	}
+	
+	//go throught sublayers
+	for(var j = i+1; j < this.objLayer.length; j++){
+		if(this.objLayer[i].parent_layer == this.objLayer[j].parent_layer) {
+			break;
+		}
+		if(type == "visible") {
+			value = this.objLayer[j].gui_layer_visible;
+		}
+		else if(type == "querylayer") {
+			value = this.objLayer[j].gui_layer_querylayer;
+		}
+		if(state == -1) {
+			state = value;
+		}
+		if(state != value) {
+			return -1;
+		}
+	}
+	
+	return state;
+};
+/**
+ * handle change of visibility / quaryability of a layer
+ * 
+ * @param string layer_name of layer to handle
+ * @param string type of change ("visible" or "querylayer")
+ * @param int value of the change
+ */
+wms_const.prototype.handleLayer = function(layer_name, type, value){
+	var i;
+	for(i = 0; i < this.objLayer.length; i++){
+		if(this.objLayer[i].layer_name==layer_name) {
+			break;
+		}
+	}
+	
+	//Set visibility/queryability of Layer and Sublayers
+	for(var j = i; j < this.objLayer.length; j++){
+		if (i != j && this.objLayer[i].layer_parent >= this.objLayer[j].layer_parent) {
+			break;
+		}
+		if(type == "visible") {
+			this.objLayer[j].gui_layer_visible = parseInt(value, 10);
+		}
+		else if(type=="querylayer" && this.objLayer[j].gui_layer_queryable) {
+			this.objLayer[j].gui_layer_querylayer = parseInt(value, 10);
+		}
+	}
+
+	//Update visibility/queryability of parent layer
+	var parentLayer = this.getLayerByLayerPos(this.objLayer[i].layer_parent);
+	if(parentLayer){
+		var state = this.getSublayerState(parentLayer.layer_id, type);
+		if(state!=-1){
+			if(type == "visible") {
+				this.objLayer[j].gui_layer_visible = state;
+			}
+			else if(type=="querylayer" && this.objLayer[j].gui_layer_queryable) {
+				this.objLayer[j].gui_layer_querylayer = state;
+			}
+		}
+	}
+};
+
+
+/**
+ * move a layer (with his sublayers) up or down
+ * 
+ * @param int layerId layer_id of layer to move
+ * @param boolean moveUp true to move up or false to move down
+ * @return boolean success
+ */
+
+wms_const.prototype.moveLayer = function(layerId, moveUp){
+	var iLayer=-1;
+	var i;
+	
+	//find layer to move
+	for(i=0;i<this.objLayer.length;i++){
+		if(this.objLayer[i].layer_id==layerId){
+			iLayer=i;
+			break;
+		}
+	}
+	if(iLayer==-1) {
+		return false;
+	}
+	
+	var upperLayer = -1;
+	var lowerLayer = -1;
+	
+	//find layer to swap position with
+	var parentLayer = this.objLayer[iLayer].layer_parent;	
+	if(moveUp){
+		lowerLayer = iLayer;
+		
+		//find previous layer on same level
+		for(i=iLayer-1;i>0;i--){
+			if(parentLayer == this.objLayer[i].layer_parent){
+				upperLayer = i;
+				break;
+			}
+		}
+		if(upperLayer == -1){
+			//alert("The Layer you selected is already on top of parent Layer/WMS");
+			return false;
+		}
+	}
+	else{
+		upperLayer = iLayer;
+		
+		//find next layer on same level
+		for(i=iLayer+1;i<this.objLayer.length;i++){
+			if(parentLayer == this.objLayer[i].layer_parent){
+				lowerLayer = i;
+				break;
+			}
+		}
+		if(lowerLayer == -1){
+			//alert("The Layer you selected is already on bottom of parent Layer/WMS");
+			return false;
+		}
+	}
+	
+	//calc number of layers to move down
+	var layersDown = lowerLayer - upperLayer;
+	
+	//get number of layers to move up
+	for(i=lowerLayer+1; i<this.objLayer.length; i++){
+		if(parentLayer == this.objLayer[i].layer_parent){
+			break;
+		}
+	}
+	var layersUp = i - lowerLayer;
+	
+	//do moving
+	var temp = [];
+	for(i=0;i<layersDown+layersUp;i++){
+		temp[temp.length]=this.objLayer[upperLayer+i];
+	}
+	for(i=0;i<layersUp;i++){
+		this.objLayer[upperLayer+i]=temp[i+layersDown];
+	}
+	for(i=0;i<layersDown;i++){
+		this.objLayer[upperLayer+layersUp+i]=temp[i];
+	}
+
+	return true;
+};
+
+function wms_add_data_type_format(datatype,dataformat){
+	var insertDataFormat = true;
+	for (var i = 0 ; i < wms[wms.length-1].data_type.length ; i ++) {
+		if (wms[wms.length-1].data_type[i] == datatype && wms[wms.length-1].data_format[i] == dataformat) {
+			insertDataFormat = false;
+		}
+	}
+	if (insertDataFormat === true) {
+		wms[wms.length-1].data_type[wms[wms.length-1].data_type.length] = datatype;
+		wms[wms.length-1].data_format[wms[wms.length-1].data_format.length] = dataformat;
+	}
+}
+function wms_addSRS(epsg,minx,miny,maxx,maxy){
+	wms[wms.length-1].gui_epsg[wms[wms.length-1].gui_epsg.length] = epsg;
+	wms[wms.length-1].gui_minx[wms[wms.length-1].gui_minx.length] = minx;
+	wms[wms.length-1].gui_miny[wms[wms.length-1].gui_miny.length] = miny;
+	wms[wms.length-1].gui_maxx[wms[wms.length-1].gui_maxx.length] = maxx;
+	wms[wms.length-1].gui_maxy[wms[wms.length-1].gui_maxy.length] = maxy;
+}
+function wms_addLayerStyle(styleName, styleTitle, count, layerCount, styleLegendUrl, styleLegendUrlFormat){
+	var currentLayer = wms[wms.length-1].objLayer[layerCount]; 
+	if (currentLayer) {
+		currentLayer.layer_style[count] = {};
+		currentLayer.layer_style[count].name = styleName;
+		currentLayer.layer_style[count].title = styleTitle;
+		currentLayer.layer_style[count].legendurl = styleLegendUrl;
+		currentLayer.layer_style[count].legendurlformat = styleLegendUrlFormat;
+	}
+}
+//TODO: add layerstyle handling....
+//layer
+function wms_add_layer(
+			layer_parent,
+			layer_uid,
+			layer_name,
+			layer_title,
+			layer_dataurl_href,
+			layer_pos,
+			layer_queryable,
+			layer_minscale,
+			layer_maxscale,
+			layer_metadataurl,
+			gui_layer_wms_id,
+			gui_layer_status,
+			gui_layer_style,
+			gui_layer_selectable,
+			gui_layer_visible,
+			gui_layer_queryable,
+			gui_layer_querylayer,
+			gui_layer_minscale,
+			gui_layer_maxscale,
+			gui_layer_wfs_featuretype){
+                      
+	wms[wms.length-1].objLayer[wms[wms.length-1].objLayer.length] = new wms_layer(
+											layer_parent,
+											layer_uid,
+											layer_name,
+											layer_title,
+											layer_dataurl_href,
+											layer_pos,
+											layer_queryable,
+											layer_minscale,
+											layer_maxscale,
+											layer_metadataurl,
+											gui_layer_wms_id,
+											gui_layer_status,
+											gui_layer_style,
+											parseInt(gui_layer_selectable, 10),
+											parseInt(gui_layer_visible, 10),
+											parseInt(gui_layer_queryable, 10),
+											parseInt(gui_layer_querylayer, 10),
+											parseInt(gui_layer_minscale, 10),
+											parseInt(gui_layer_maxscale, 10),
+											gui_layer_wfs_featuretype );
+	var parentLayer = wms[wms.length-1].getLayerByLayerPos(parseInt(layer_parent, 10));
+	if(parentLayer) {
+		parentLayer.has_childs = true;
+	}
+}
+function layer_addEpsg(epsg,minx,miny,maxx,maxy){
+	var j = wms[wms.length-1].objLayer.length-1;
+	var k = wms[wms.length-1].objLayer[j].layer_epsg.length;
+	var currentLayer = wms[wms.length-1].objLayer[j];
+	currentLayer.layer_epsg[k]={};
+	currentLayer.layer_epsg[k].epsg = epsg;
+	currentLayer.layer_epsg[k].minx = minx;
+	currentLayer.layer_epsg[k].miny = miny;
+	currentLayer.layer_epsg[k].maxx = maxx;
+	currentLayer.layer_epsg[k].maxy = maxy;
+}
+function wms_layer(
+			layer_parent,
+			wms_layer_uid,
+			layer_name,
+			layer_title,
+			layer_dataurl_href,
+			layer_pos,
+			layer_queryable,
+			layer_minscale,
+			layer_maxscale,
+			layer_metadataurl,
+			gui_layer_wms_id,
+			gui_layer_status,
+			gui_layer_style,
+			gui_layer_selectable,
+			gui_layer_visible,
+			gui_layer_queryable,
+			gui_layer_querylayer,
+			gui_layer_minscale,
+			gui_layer_maxscale,
+			gui_layer_wfs_featuretype){
+	this.layer_id = wms_layer_count;
+	this.layer_uid = wms_layer_uid;
+	this.layer_parent = layer_parent;
+	this.layer_name = layer_name;
+	this.layer_title = layer_title;
+	this.layer_dataurl_href = layer_dataurl_href;
+	this.layer_pos = layer_pos;
+	this.layer_queryable = layer_queryable;
+	this.layer_minscale = layer_minscale;
+	this.layer_maxscale = layer_maxscale;
+	this.layer_metadataurl = layer_metadataurl;
+	this.layer_epsg = [];
+	this.gui_layer_wms_id = gui_layer_wms_id;
+	this.gui_layer_status = gui_layer_status;
+	this.gui_layer_selectable = gui_layer_selectable;
+	this.gui_layer_visible = gui_layer_visible;
+	this.gui_layer_queryable = gui_layer_queryable;
+	this.gui_layer_querylayer = gui_layer_querylayer;
+	this.gui_layer_minscale = gui_layer_minscale;
+	this.gui_layer_maxscale = gui_layer_maxscale;
+	this.gui_layer_style = gui_layer_style;
+	this.gui_layer_wfs_featuretype = gui_layer_wfs_featuretype;
+//	this.gui_layer_style = null;
+	this.has_childs = false;
+	this.layer_style = [];
+	wms_layer_count++;
+}
+/**
+ * check the scale of the layer
+ *
+ * @param Object mapObj the mapbender mapObject of the layer
+ * @param Integer scale [optional] a scale given by the user, 
+ * 					if not given, use the map's current scale
+ * @return boolean if the layer is in scale or not
+ * @type boolean
+ */
+wms_layer.prototype.checkScale = function(mapObj, scale){
+	var minScale = parseInt(this.gui_layer_minscale, 10);
+	var maxScale = parseInt(this.gui_layer_maxscale, 10);
+
+	var currentScale;
+	if (typeof(scale) === "number") {
+		currentScale = scale;
+	}
+	else {
+		currentScale = parseInt(mapObj.getScale(), 10);
+	}
+	if(minScale === 0 && maxScale === 0){
+		return true;
+	}
+	if(minScale > currentScale || (maxScale !== 0 && maxScale < currentScale)) {
+		return false;
+	}	
+	return true;
+};
+/**
+ * set visibility of the layer
+ * @param boolean visible visibility on/off
+ */
+wms_layer.prototype.setVisible = function(visible){
+	this.gui_layer_visible = parseInt(visible, 10);
+	//console.log("setVisible(%i) for Layer %s",visible, this.layer_name);
+};
+
+/**
+ * set queryability of the layer
+ * @param boolean queryable queryability on/off
+ */
+
+wms_layer.prototype.setQueryable = function(queryable){
+	this.gui_layer_querylayer = parseInt(queryable, 10);
+	//console.log("setQueryable(%i) for Layer %s",queryable, this.layer_name);
+};

Added: branches/dynamic_printframe_dev/php/mod_map1.php
===================================================================
--- branches/dynamic_printframe_dev/php/mod_map1.php	                        (rev 0)
+++ branches/dynamic_printframe_dev/php/mod_map1.php	2009-06-04 13:50:53 UTC (rev 4001)
@@ -0,0 +1,97 @@
+<?php
+# $Id: mod_map1.php 2144 2008-02-26 23:16:14Z christoph $
+# http://www.mapbender.org/index.php/Administration
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+?>
+<!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>mod_map1</title>
+<?php
+$sql = "SELECT e_width, e_height FROM gui_element WHERE e_id = 'mapframe1' AND fkey_gui_id = $1";
+$v = array($_SESSION["mb_user_gui"]);
+$t = array("s");
+$res = db_prep_query($sql, $v, $t);
+$cnt = 0;
+while($row = db_fetch_array($res)){
+   $e_width = $row["e_width"];
+   $e_height = $row["e_height"];
+   $cnt++;
+}
+if($cnt > 1){ echo "alert('mapframe1: ID not unique!');";}
+echo '<script type="text/javascript">';
+echo "\n";
+echo "var mod_map1_width = '".$e_width."';\n";
+echo "var mod_map1_height = '".$e_height."';\n";
+echo "</script>\n";
+?>
+<script type="text/javascript">
+<!--
+
+function init () {
+	parent.eventInitMap.register(function init_mod_map1(){
+		parent.mb_registerMapObj('mapframe1', 'maps', null,mod_map1_width, mod_map1_height);
+		document.getElementById("maps").style.width = mod_map1_width;
+		document.getElementById("maps").style.height = mod_map1_height;
+	});
+}
+
+// -->
+</script>
+</head>
+<body leftmargin='0' topmargin='0' onload="init()" bgcolor='#ffffff'>
+<div id='markResult' name='maps' style ='position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index:26'> </div>
+<div id='maps' name='maps' style ='position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index:2;'> </div>
+
+<div id='highlight' style="position:absolute;top:-10px;left:-10px;width:14px;height:14px;z-index:3;visibility:visible"><img src="../img/redball.gif"/></div>
+<div id='l_right' name='l_right' style="position:absolute;top:0px;left:0px;width:0px;height:0px;overflow:hidden;z-index:10;visibility:hidden;background-color:#ff0000;cursor: crosshair;"></div>
+<div id='l_bottom'  name='l_bottom' style="position:absolute;top:0px;left:0px;width:0px;height:0px;overflow:hidden;z-index:11;visibility:hidden;background-color:#ff0000;cursor: crosshair;"></div>
+<div id='l_left' name='l_left' style="position:absolute;top:0px;left:0px;width:0px;height:0px;overflow:hidden;z-index:12;visibility:hidden;background-color:#ff0000;cursor: crosshair;"></div>
+<div id='l_top' name='l_top' style="position:absolute;top:0px;left:0px;width:0px;height:0px;overflow:hidden;z-index:13;visibility:hidden;background-color:#ff0000;cursor: crosshair;"></div>
+<div id="sandclock" style="position:absolute; top:0px; left:0px; z-index:14;"></div>
+<div id="scalebar" style="position:absolute; top:0px; left:0px; z-index:15;"></div>
+<div id="measuring" style="position:absolute; top:0px; left:0px; z-index:16; font-size:10px"></div>
+<div id="measure_display" style="position:absolute; top:0px; left:0px; z-index:17;"></div>
+<div id="copyright" style="position:absolute; top:0px; left:0px; z-index:18;"></div>
+<div id="measure_sub" style="position:absolute; top:0px; left:0px; z-index:19;"></div>
+<div id='permanent' style="position:absolute;top:-10px;left:-10px;width:14px;height:14px;z-index:13;visibility:hidden"><img src="../img/redball.gif"/></div>
+<div id="digitize_sub" style="position:absolute; top:0px; left:0px; z-index:24;"></div>
+<div id="digitize_display" style="position:absolute; top:0px; left:0px; z-index:25;"></div>
+<div id='um_title' name='um_title' style="font-family: Arial, Helvetica, sans-serif; DISPLAY:none; OVERFLOW:visible; POSITION:absolute; DISPLAY:none; BACKGROUND:#BEC1C4;border:1px solid black; z-index:98;"></div>
+<div id='um_draw' name='um_draw' style="LEFT:0px;OVERFLOW:visible;POSITION:absolute;TOP:0px;z-index:99;"></div>
+<img id='um_img' name='um_img' style ='position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; border:0;z-index:100' src='../img/transparent.gif' useMap='#um'>
+<map name='um' id='um'></map>
+<script type="text/javascript">
+<?php
+	require_once "../javascripts/point.js";
+	require_once "../extensions/jquery.js";
+	require_once "../extensions/jqjson.js";
+	require_once "../extensions/wz_jsgraphics.js";
+	require_once "../print_dynamic/printbox.js";
+?>
+</script>
+</body>
+</html>

Added: branches/dynamic_printframe_dev/print_dynamic/img/mapbender_logo.png
===================================================================
(Binary files differ)


Property changes on: branches/dynamic_printframe_dev/print_dynamic/img/mapbender_logo.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: branches/dynamic_printframe_dev/print_dynamic/img/northarrow.png
===================================================================
(Binary files differ)


Property changes on: branches/dynamic_printframe_dev/print_dynamic/img/northarrow.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: branches/dynamic_printframe_dev/print_dynamic/img/northarrow_plain.png
===================================================================
(Binary files differ)


Property changes on: branches/dynamic_printframe_dev/print_dynamic/img/northarrow_plain.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: branches/dynamic_printframe_dev/print_dynamic/mod_printPDF.php
===================================================================
--- branches/dynamic_printframe_dev/print_dynamic/mod_printPDF.php	                        (rev 0)
+++ branches/dynamic_printframe_dev/print_dynamic/mod_printPDF.php	2009-06-04 13:50:53 UTC (rev 4001)
@@ -0,0 +1,475 @@
+<?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.
+
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+	<meta http-equiv="cache-control" content="no-cache" />
+	<meta http-equiv="pragma" content="no-cache" />
+	<meta http-equiv="expires" content="0" />
+	<?php printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\" />",CHARSET);	?>
+	<title>Print PDF</title>
+
+	<?php
+	//FIXME:
+	//setlocale(LC_ALL, "de_DE.utf8");
+
+	require_once(dirname(__FILE__)."/".$_REQUEST["conf"]);
+
+	printf("
+	<script type=\"text/javascript\">
+		var target = '%s';
+		var comment1 = '%s';
+		var comment1_length = %s;
+		var comment2 = '%s';
+		var comment2_length = %s;
+		var label_button = '%s';
+		var type = '%s';
+	</script>",
+	$_REQUEST["target"],$label_comment1,$comment1_length,$label_comment2,$comment2_length,$label_button,$type
+	);
+	?>
+
+	<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;
+	}
+
+	var printBox;
+	
+	function createPrintBox () {
+		size = "A4";
+		document.form1.size.value = size;
+		format = "portrait";
+		var w, h;
+		validate();
+		printBox = pt.window.frames[target].createBox({
+			target:target,
+			width : w/parent.mb_resolution,
+			height : h/parent.mb_resolution,
+			scale : 1000000,
+			afterChangeAngle : function (obj) {
+				if (typeof(obj) == "object") {
+					if (typeof(obj.angle) == "number") {
+						document.form1.angle.value = obj.angle;
+					}
+					if (obj.coordinates) {
+						document.form1.coordinates.value = String(obj.coordinates);
+					}
+				}
+			},
+			afterChangeSize : function (obj) {
+				if (typeof(obj) == "object") {
+					if (obj.scale) {
+						document.form1.scale.value = obj.scale;
+					}
+					if (obj.coordinates) {
+						document.form1.coordinates.value = String(obj.coordinates);
+					}
+				}
+			}
+		});
+		
+		pt.eventAfterMapRequest.register(function () {
+			if (typeof(printBox) !== "undefined") {
+				printBox.repaint();
+			}
+		});
+	}
+
+	function destroyPrintBox () {
+		if (printBox) {
+			printBox.destroy();
+		}
+	}
+
+	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.getElementById('size').options[document.getElementById('size').selectedIndex].value;
+		format = document.getElementById('format').options[document.getElementById('format').selectedIndex].value;
+
+		if(size != "false" && format != "false"){
+			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; ?>;
+			}
+			if (typeof printbox !== "undefined") {
+				printBox.setPrintWidthAndHeight(map_width, map_height);
+			}
+		}
+	}
+	
+	function updateLayerVisibilityInMapUrl (map, wmsIndex, scale) {
+		var thisLayer;
+
+		var url = map.mapURL[wmsIndex];
+		var pattern = /LAYERS=([^&]*)/i;
+		var layerList = pattern.exec(url);
+		if (layerList.length > 0) {
+			thisLayer = layerList[1].split(",");
+		}
+		else {
+			return url;
+		}
+
+		var newUrl = "";
+
+		// this code is copied from mb_checkScale
+		var thisScale = scale;  
+		var str_layer = "";
+		var cnt_layer = 0;
+		for(var i=0; i < map.wms[wmsIndex].objLayer.length; i++){  
+			var currentLayer = map.wms[wmsIndex].objLayer[i];
+			var myLayername = currentLayer.layer_name;
+			var myMinscale = currentLayer.gui_layer_minscale;
+			var myMaxscale = currentLayer.gui_layer_maxscale;
+			for (var ii=0; ii<thisLayer.length; ii++){
+				var minscaleOK = false;
+				var maxscaleOK = false;   
+				if(thisLayer[ii] == myLayername){
+					if(myMinscale === 0 || thisScale >= myMinscale){minscaleOK = true;}
+					if(myMaxscale === 0 || thisScale <= myMaxscale){maxscaleOK = true;}
+					if (maxscaleOK === true && 
+						minscaleOK === true  && 
+						!currentLayer.has_childs){
+							if(cnt_layer > 0) {
+								str_layer += ","; 
+							}
+							str_layer += thisLayer[ii];
+							cnt_layer++;
+					}
+				}
+			}
+		}
+		newUrl = url.replace(pattern, "LAYERS=" + str_layer);
+		return newUrl;
+	}
+	 
+	
+	function refreshParams(){
+//		validate();
+		var f = document.forms[0];
+		size = document.getElementById('size').options[document.getElementById('size').selectedIndex].value;
+		format = document.getElementById('format').options[document.getElementById('format').selectedIndex].value;
+		scale = parseInt(document.getElementById('scale').value, 10);
+		
+		if(size != "" && format != ""){
+			var ind = pt.getMapObjIndexByName(target);
+
+			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].mapURL[i] != false && 
+						pt.mb_mapObj[ind].mapURL[i] != 'false' && 
+						pt.mb_mapObj[ind].mapURL[i] != '') {   
+
+						if(f.map_url.value != ""){
+							f.map_url.value += "___";
+						}
+						// set layer visibility according to scale of the box
+						
+						var mapUrl = updateLayerVisibilityInMapUrl(pt.mb_mapObj[ind], i, scale);
+						         
+						f.map_url.value += mapUrl;
+					}
+				}
+			}
+			
+			//overview_url
+			var ind_overview = pt.getMapObjIndexByName('overview');
+	
+			if(pt.mb_mapObj[ind_overview].mapURL != false ){
+				f.overview_url.value = pt.mb_mapObj[ind_overview].mapURL;
+			}
+		}
+	
+		f.map_scale.value = scale;
+		f.epsg.value = pt.mb_mapObj[ind].epsg;
+		
+		mod_legend_print();
+	}
+	function printMap(){
+		if(size != "false" && (format == "portrait" || format == "landscape")){
+			refreshParams();
+			if(document.form1.c1.value != comment1){
+				document.form1.comment1.value = document.form1.c1.value;
+			}
+			if(document.form1.c2.value != comment2){
+				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;
+			}
+
+			if (format == "portrait") {
+				document.form1.mapwidth.value = parseInt(map_width, 10);
+				document.form1.mapheight.value = parseInt(map_height, 10);
+			}
+			else if (format == "landscape") {
+				document.form1.mapwidth.value = parseInt(map_height, 10);
+				document.form1.mapheight.value = parseInt(map_width, 10);
+			}
+
+			document.form1.submit();
+		}
+		else{
+			alert('<?php echo _mb("No format selected")."!"?>');
+		}
+	}
+
+	function checkCommentLength(obj,maxLength){
+		if(obj.value.length > maxLength){
+			obj.value = obj.value.substr(0,maxLength);
+		}
+	}
+	-->
+	</script>
+	<?php include("../include/dyn_css.php"); ?>
+</head>
+
+<body onload="createPrintBox()" onunload="destroyPrintBox()">
+<form name="form1" method="post" action="mod_printPDF_pdf.php?<?php echo SID; ?>" target="_blank">
+<p id="container_size">
+	<label for="size"><?php echo $label_format ?></label>
+	<select id="size" name="size" onchange="validate();">
+		<option value="false">-</option>
+		<?php
+		for($i = 4; $i >= 0; $i--) {
+			if(${"a".$i}) {
+				printf("<option value=\"A%s\">%s</option>",$i,${"label_format_a".$i});
+			}
+		}
+		?>
+	</select>
+</p>
+
+<p id="container_orientation">
+	<label for="format"><?php echo $label_orientation; ?></label>
+	<select id="format" name="format" onchange="if (this.value == 'portrait') printBox.setPortrait(); else printBox.setLandscape();">
+		<option value="portrait"><?php echo $label_portrait; ?></option>
+		<option value="landscape"><?php echo $label_landscape; ?></option>
+	</select>
+</p>
+
+<?php if($highquality === TRUE): ?>
+	<p id="container_quality">
+		<label for="quality"><?php echo $label_quality; ?></label>
+		<input type="radio" id="quality" name="quality" value="1" checked="checked" /> <?php echo $label_72dpi; ?>
+		<input type="radio" id="quality" name="quality" value="2" /> <?php echo $label_288dpi; ?>
+	</p>
+<?php endif; ?>
+
+<?php
+ini_set("error_reporting",E_ALL);
+ini_set("display_errors","on");
+	for($i = 1; $i <= 2; $i++) {
+		$max_comment_length = ${"comment".$i."_length"};
+		$label_hint         = ($max_comment_length > -1) ? sprintf(" <em>("._mb("max.")." %s)</em>",$max_comment_length) : NULL;
+		$javascript         = ($max_comment_length > -1) ? sprintf(" onblur=\"checkCommentLength(this,%s)\"",$max_comment_length) : NULL;
+
+		$html  = sprintf("<p id=\"container_comment%s\">",$i);
+		$html .= sprintf("<label for=\"c%s\">%s%s</label> ",$i,${"label_comment".$i},$label_hint);
+		$html .= sprintf("<textarea id=\"c%s\" name=\"c%s\" cols=\"20\" rows=\"2\"%s></textarea> ",$i,$i,$javascript);
+		$html .= "</p>";
+
+		echo $html;
+	}
+?>
+	<p id="container_angle">
+		<label for="angle"><?php echo $label_angle; ?></label>
+		<input type="text" id="angle" name="angle" value="0" onchange="printBox.setAngle(parseInt(this.value))"/>
+	</p>
+
+	<p id="container_scale">
+		<label for="scale"><?php echo $label_scale; ?></label>
+		<input type="text" id="scale" name="scale" value="0" onchange="printBox.setScale(parseInt(this.value))"/>
+	</p>
+	<input type="hidden" id="coordinates" name="coordinates" value="0" />
+	<input type="hidden" id="mapwidth" name="mapwidth" value="0" />
+	<input type="hidden" id="mapheight" name="mapheight" value="0" />
+
+<?php if($legend === TRUE): ?>
+	<p id="container_legend">
+		<label for="mylegendcheckbox"><?php echo $label_legend; ?></label>
+		<input type="checkbox" id="mylegendcheckbox" name="mylegendcheckbox" value="false" />
+	</p>
+<?php else: ?>
+	<input type="hidden" name="mylegendcheckbox" value="false" />
+<?php endif; ?>
+
+<input type="hidden" name="map_url" />
+<input type="hidden" name="overview_url" />
+<input type="hidden" name="wms_title" />
+<input type="hidden" name="wms_id" />
+<input type="hidden" name="layers" />
+<input type="hidden" name="legendurl" />
+<input type="hidden" name="map_scale" />
+<input type="hidden" name="epsg" />
+<input type="hidden" name="conf" value="<?php echo $_REQUEST["conf"]; ?>" />
+<input type="hidden" name="comment1" />
+<input type="hidden" name="comment2" />
+<input type="hidden" name="mylegend" value="true" >
+<input type="hidden" name="measured_x_values" />
+<input type="hidden" name="measured_y_values" />
+
+<p>
+	<input type="button" id="print" name="print" value="<?php echo $label_button; ?>" onclick="printMap();" />
+</p>
+</form>
+</body>
+
+</html>

Added: branches/dynamic_printframe_dev/print_dynamic/mod_printPDF_pdf.php
===================================================================
--- branches/dynamic_printframe_dev/print_dynamic/mod_printPDF_pdf.php	                        (rev 0)
+++ branches/dynamic_printframe_dev/print_dynamic/mod_printPDF_pdf.php	2009-06-04 13:50:53 UTC (rev 4001)
@@ -0,0 +1,936 @@
+<?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(dirname(__FILE__)."/../php/mb_validateSession.php");
+
+include (dirname(__FILE__)."/../classes/class.ezpdf.php");
+include (dirname(__FILE__)."/../classes/class_stripRequest.php");
+include (dirname(__FILE__)."/../classes/class_weldMaps2PNG_rotate.php");
+include (dirname(__FILE__)."/../classes/class_weldOverview2PNG_rotate.php");
+include (dirname(__FILE__)."/".$_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;
+
+function rotate($point, $center, $angle) {
+	if ($angle === 0) {
+		return $point;
+	}
+	// first, calculate point around 0
+	// then rotate
+	// then add center vector again
+	
+	$pNew = array(
+		$point[0] - $center[0],
+		$point[1] - $center[1]
+	);
+	
+	$angle = deg2rad(-$angle);
+	return array(
+		($pNew[0] * cos($angle) + $pNew[1] * sin($angle)) + $center[0],
+		($pNew[0] * -sin($angle) + $pNew[1] * cos($angle)) + $center[1]
+	);
+}
+
+function rotatePoints($coordArray, $angle) {
+	$center = array(
+		($coordArray[2] + $coordArray[0]) / 2,
+		($coordArray[3] + $coordArray[1]) / 2,
+	);
+	
+	$p1 = array(
+		$coordArray[0],
+		$coordArray[1]
+	);
+	$p2 = array(
+		$coordArray[2],
+		$coordArray[1]
+	);
+	$p3 = array(
+		$coordArray[2],
+		$coordArray[3]
+	);
+	$p4 = array(
+		$coordArray[0],
+		$coordArray[3]
+	);
+	
+	$newCoordArray = array(
+		rotate($p1, $center, $angle),
+		rotate($p2, $center, $angle),
+		rotate($p3, $center, $angle),
+		rotate($p4, $center, $angle)
+	);
+	return $newCoordArray;
+}
+
+
+/* -------------------------------------- */
+
+$size = $_REQUEST["size"];
+$format = $_REQUEST["format"];
+$map_scale = $_REQUEST["map_scale"];
+$overview_url = $_REQUEST["overview_url"];
+$epsg = $_REQUEST["epsg"];
+if($overview_url=='false'){
+	$overview = false;	
+}
+
+
+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_width = $_REQUEST["mapwidth"];
+//$map_height = round($myURL->get("height"));
+$map_height = $_REQUEST["mapheight"];
+//$map_extent = $myURL->get("BBOX");
+$map_extent = $_REQUEST["coordinates"];
+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/LiberationSans-Regular.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();
+
+
+//
+// Set correct width, height and coordinates
+//
+foreach ($array_urls as &$url) {
+	$coordPattern = "\d+(\.\d+)?";
+	$pattern = "/BBOX=$coordPattern,$coordPattern,$coordPattern,$coordPattern&/";
+	$url = preg_replace($pattern, "BBOX=" . $_REQUEST["coordinates"] . "&", $url);
+
+	$pattern = "/WIDTH=\d+&/";
+	$url = preg_replace($pattern, "WIDTH=" . $_REQUEST["mapwidth"] . "&", $url);
+
+	$pattern = "/HEIGHT=\d+&/";
+	$url = preg_replace($pattern, "HEIGHT=" . $_REQUEST["mapheight"] . "&", $url);
+}
+
+$i = new weldMaps2PNG_rotate(implode("___",$array_urls),$filename, $_REQUEST["angle"]);
+
+$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 = 6;
+   $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, $myMiny, -90);
+$pdf->addText($mapOffset_left, $mapOffset_bottom  - ($pdf->getFontHeight($mySize)), $mySize, $myMinx);
+$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);
+	$rotatedExtent = rotatePoints($coord, intval($_REQUEST["angle"]));
+	if($size == "A4" && $format == "portrait"){
+		$i = new weldOverview2PNG_rotate($overview_url,$array_urls[0] ,$filename,$rotatedExtent);
+
+		$pdf->addPngFromFile($filename, $overview_left,$overview_bottom, $overview_width, $overview_height);
+		if($unlink == true){
+			unlink($filename);
+		}
+	}
+	else{
+		$i = new weldOverview2PNG_rotate($overview_url,$array_urls[0],$filename,$rotatedExtent);
+
+		//$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){
+    //rotate image
+    $imagick = new Imagick();
+    $imagick->readImage($northarrowImage);
+    $imagick->rotateImage(new ImagickPixel(), intval($_REQUEST["angle"]));
+
+    //get the new dimensions
+    $imgWidth = $imagick->getImageWidth();
+    $imgHeight = $imagick->getImageHeight();
+    
+    //write modified image
+	$newNorthArrowFilename = "../tmp/northarrow" . $_REQUEST["angle"] . ".png";
+    $imagick->writeImage($newNorthArrowFilename);
+    $image = imagecreatefrompng($newNorthArrowFilename);
+    imagepng($image,$newNorthArrowFilename);
+
+	$pdf->addPngFromFile($newNorthArrowFilename, $northarrow_left, $northarrow_bottom , $imgWidth, $imgHeight);
+//	$pdf->addPngFromFile($northarrowImage, $northarrow_left, $northarrow_bottom , $northarrowImage_width, $northarrowImage_height);
+}
+
+if($epsg == "EPSG:4326"){
+
+	$scalebar = false;
+}
+
+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>";
+}
+?>

Added: branches/dynamic_printframe_dev/print_dynamic/printPDF_b.conf
===================================================================
--- branches/dynamic_printframe_dev/print_dynamic/printPDF_b.conf	                        (rev 0)
+++ branches/dynamic_printframe_dev/print_dynamic/printPDF_b.conf	2009-06-04 13:50:53 UTC (rev 4001)
@@ -0,0 +1,389 @@
+<?php
+include_once(dirname(__FILE__)."/../../core/globalSettings.php");
+include_once(dirname(__FILE__)."/../classes/class_administration.php");
+$admin = new administration();
+
+# 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 = _mb("Download: Map as PDF...");
+
+/*
+*run print as iframe or window
+*/
+$type = 'window';
+
+
+
+/*
+* Legend
+*/
+$legend=true;
+$label_legend = _mb('print legend');
+$legendFilename = TMPDIR."/legend_".substr(md5(uniqid(rand())),0,7).".png";
+$legendFilenameUserPolygon = TMPDIR."/legend_".substr(md5(uniqid(rand())),0,7).".png";
+$legendText = $admin->char_decode(_mb("Legend"));
+$legendFooter = $admin->char_decode(_mb("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
+$new_comment1 = $admin->char_decode($_REQUEST["comment1"]);
+$new_comment2 = $admin->char_decode($_REQUEST["comment2"]);
+
+$text1 = $admin->char_decode(_mb("Print preview"));
+$text2 = "Mapbender";
+$text3 = "";
+$text4 = $admin->char_decode(_mb("Scale 1:")). " ".$_REQUEST["map_scale"];
+$text5 = $admin->char_decode(_mb("Date")) . ": ".date("d.m.Y",strtotime("now"));
+
+$text6 = $admin->char_decode(_mb("Notes")).":";
+$text7 = "";
+$text8 = $new_comment1;
+$text9 = $new_comment2;
+$text10 = "";
+
+
+$text11 = $admin->char_decode(_mb("This copy has been generated automatically and is valid without signature."));
+
+$text12 = $admin->char_decode(_mb("This copy is protected by law (Par. 3 Abs. 1 VermKatG NW). It can be duplicated, modified, published or be passed to third parties only in agreement with"));
+$text13 = $admin->char_decode(_mb("the publisher, except duplicates and modifications aimed at internal use of government agencies or private use."));
+
+$text14 = $admin->char_decode(_mb("This copy is protected by law (Par. 3 Abs. 1 VermKatG NW)."));
+$text15 = $admin->char_decode(_mb("It can be duplicated, modified, published or be passed to third parties only in"));
+$text16 = $admin->char_decode(_mb("agreement with the publisher except duplicates and modifications"));
+$text17 = $admin->char_decode(_mb("aimed at internal use of government agencies or private use."));
+
+/*
+* Labeling for buttons, textfields ...
+*/
+
+$label_format = _mb("Format");
+$label_format_a4 = "A4";
+$label_format_a3 = "A3";
+$label_format_a2 = "A2";
+$label_format_a1 = "A1";
+$label_format_a0 = "A0";
+
+$label_orientation = _mb("Orientation");
+$label_portrait = _mb("portrait");
+$label_landscape = _mb("landscape");
+
+$label_angle = _mb("Angle ccw");
+$label_scale = _mb("Scale 1:");
+
+$label_quality = _mb("Quality");
+$label_72dpi = sprintf(_mb("Quality: %d dpi"), 72);
+$label_288dpi = sprintf(_mb("Quality: %d dpi"), 288);
+
+$label_comment1 = _mb("Comment")." 1:";
+$label_comment2 = _mb("Comment")." 2:";
+$comment1_length = 30;
+$comment2_length = 30;
+
+$label_button = _mb("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";
+$northarrowImage = "./img/northarrow_plain.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;
+ 
+
+?>

Added: branches/dynamic_printframe_dev/print_dynamic/printbox.js
===================================================================
--- branches/dynamic_printframe_dev/print_dynamic/printbox.js	                        (rev 0)
+++ branches/dynamic_printframe_dev/print_dynamic/printbox.js	2009-06-04 13:50:53 UTC (rev 4001)
@@ -0,0 +1,703 @@
+function createBox (options) {
+	myPrintBox = new PrintBox(options);
+	myPrintBox.paintPoints();
+	myPrintBox.paintBox();	
+	return myPrintBox;
+}
+
+function PrintBox (options) {
+	if (!options) {
+		options = {};
+	}
+
+	var target = options.target || "mapframe1";
+	var mapObj = parent.getMapObjByName(target);
+
+	// Default is portrait, A4
+	var printWidth = options.printWidth || 21;
+	var printHeight = options.printHeight || 29.7;
+
+	// initialised in setScale()
+	var boxWidth, boxHeight; 
+
+	var scale = options.scale || 100000;
+
+	// behaviour
+	var afterChangeAngle = options.afterChangeAngle || function (obj) {};
+	var afterChangeSize = options.afterChangeSize || function (obj) {};
+	
+	// styles
+	var opacity = options.boxOpacity || 0.6;
+	var boxColour = options.boxColour || "#9999FF";
+	var frameColour = options.frameColour || "#000000";
+	var pointColour = options.pointColour || "#DD0000";
+	var circleColour = options.circleColour || "#DD0000";
+	var circleWidth = options.circleWidth || 4;
+
+	// attributes
+	this.id = "printbox";
+	var angle = 0;
+	var totalAngle = 0;
+
+	// the four points of the box as pixel coordinates (incl rotation),
+	// with (0,0) as center. This is important for angle calculations.
+	var pointArray = [];
+
+	// The pointArray is moved by the center vector.
+	// default: place box in the center of the map
+	var center = options.center || new Point(mapObj.width/2,mapObj.height/2);
+
+	// the center in real world coordinates
+	var centerMap = null;
+
+	// the four points of the box as pixel coordinates (NO ROTATION)
+	var startPointPixArray = [];
+
+	// the four points of the box as real world coordinates (NO ROTATION)
+	var startPointMapArray = [];
+	var that = this;
+
+	// if the box is smaller than this, the circle will not be drawn
+	var MIN_BOX_WIDTH_OR_HEIGHT = 10;
+
+	// if the box is larger than this, the box will not be filled
+	var MAX_BOX_WIDTH_OR_HEIGHT = 800;
+
+	this.toString = function () {
+		var str = "";
+		str += "Center: " + getCenter() + "\n";
+		str += "Radius: " + radius + "\n";
+		str += "StartRadius: " + startRadius + "\n";
+		str += "Pixelpos: " + String(pointArray) + "\n";
+		str += "StartPixelpos: " + String(startPointPixArray) + "\n";
+		str += "Mappos: " + String(startPointMapArray) + "\n";
+		return str;
+	};
+	
+	var initBehaviour = function () {
+		initMoveBehaviour();
+		initResizeBehaviour();
+		initRotateBehaviour();
+	};
+
+	var initRotateBehaviour = function () {
+		$circleCanvas.css("z-index", "110").mousedown(function (e) {
+			circleCanvas.clear();	
+	
+			var newCenter = getCenter();
+	
+			var mouseMoveStart = getMousePos(e);
+			var vectorA = pointArray[0].minus(newCenter);
+			
+			var currentPos = getMousePos(e);
+			var vectorCurrent = currentPos.minus(newCenter);
+			
+			angle = Math.ceil(getAngle(vectorA, vectorCurrent));
+			
+			$(document).mousemove(function (e) {
+				var currentPos = getMousePos(e);
+				var vectorCurrent = currentPos.minus(newCenter);
+				var currentAngle = Math.ceil(getAngle(vectorA, vectorCurrent));
+				var diffAngle = currentAngle - angle;
+				if (Math.abs(diffAngle) >= 1) {
+					angle = currentAngle;
+					totalAngle = ((totalAngle + diffAngle) +360 )% 360;
+					that.rotate(totalAngle);
+				}
+				return false;
+			}).mouseup(function (e) {
+				angle = 0;
+				$(document).unbind("mousemove");
+				$(document).unbind("mouseup");
+				afterChangeAngle({
+					angle: totalAngle,
+					coordinates: that.getStartCoordinates()
+				});
+				that.paintBox();
+				return false;
+			});	
+			return false;
+		}).css("cursor", "move");
+	};
+
+	var initMoveBehaviour = function () {
+		$boxCanvas.mousedown(function (e) {
+			circleCanvas.clear();	
+	
+			var mouseMoveStart = getMousePos(e);
+	
+			var containerStart = new Point(
+				parseInt($container.css("left"), 10),
+				parseInt($container.css("top"), 10)
+			);
+
+			var diff;
+	
+			$(document).mousemove(function (e) {
+				diff = (getMousePos(e)).minus(mouseMoveStart);
+	
+				$container.css({
+					"top": (containerStart.y + diff.y) + "px",
+					"left": (containerStart.x + diff.x) + "px"
+				});
+				return false;
+	
+			}).mouseup(function (e) {
+				$(document).unbind("mousemove");
+				$(document).unbind("mouseup");
+				recalculateMapPositions();
+				that.rotate(totalAngle);
+				that.paintBox();
+				return false;
+			});	
+			return false;
+		});
+	};
+
+	var initResizeBehaviour = function () {
+		$pointCanvas.css("z-index", "120").mousedown(function (e) {
+			circleCanvas.clear();	
+
+			var vectorA = getCenter();
+	
+			resizeRatio = 1;
+			mouseMoveStart = getMousePos(e);
+			$(document).mousemove(function (e) {
+				var newRadius = vectorA.dist(getMousePos(e));
+				var resizeRatio = newRadius / radius;
+				if (resizeRatio < 0.98 || resizeRatio > 1.02) {
+					for (var i = 0; i < pointArray.length; i++) {
+						pointArray[i].x *= resizeRatio;
+						pointArray[i].y *= resizeRatio;
+						startPointPixArray[i].x *= resizeRatio;
+						startPointPixArray[i].y *= resizeRatio;
+					}
+					radius *= resizeRatio;
+					that.paintPoints();
+				}
+				return false;
+			});
+			$(document).mouseup(function (e) {
+				$(document).unbind("mousemove");
+				$(document).unbind("mouseup");
+
+				recalculateMapPositions();
+				recalculatePixPositions();
+				afterChangeSize({
+					scale: that.getScale(),
+					coordinates: that.getStartCoordinates()
+				});
+				that.rotate(totalAngle);
+				that.paintBox();
+				return false;
+			});
+			return false;
+		}).css("cursor", "move");
+	};
+
+	var setCenter = function (inputCenter) {
+		center = inputCenter.minus(
+			new Point(
+				parseInt($container.css("left"), 10), 
+				parseInt($container.css("top"), 10)
+			)
+		);
+	};
+	
+	var getCenter = function () {
+		var c = center.plus(
+			new Point(
+				parseInt($container.css("left"), 10), 
+				parseInt($container.css("top"), 10)
+			)
+		);
+		return c;
+	};
+
+	/**
+	 * Calculates the angle (-180 < angle <= 180) between two vectors.
+	 * 
+	 * @param {Point} a
+	 * @param {Point} b
+	 */
+	var getAngle = function (a, b) {
+		var undirectedAngle = 180 * Math.acos(
+				(a.x * b.x + a.y * b.y) 
+				/
+				(
+					Math.sqrt(
+						a.x * a.x
+					+ 
+					 	a.y * a.y
+					) * 
+					Math.sqrt(
+						b.x * b.x
+					+ 
+						b.y * b.y
+					)
+				)
+			) / Math.PI;
+
+		if ((a.x*b.y - a.y*b.x) > 0) {
+			return -1 * undirectedAngle;
+		}
+		return undirectedAngle;
+		
+	};
+	
+	/**
+	 * To be replaced by the map objects native getMousePosition
+	 * 
+	 * @param {Event} e
+	 */
+	var getMousePos = function (e) {
+		if ($.msie) {
+			return new Point(event.clientX, event.clientY);
+		}
+		return new Point(e.pageX, e.pageY);
+	};
+
+	var recalculateMapPositions = function () {
+		for (var i = 0; i < pointArray.length; i++) {
+			startPointMapArray[i] = convertPixelToMap(startPointPixArray[i].plus(getCenter()));
+		}
+		centerMap = convertPixelToMap(getCenter());
+		
+	};
+
+	var recalculatePixPositions = function () {
+		setCenter(convertMapToPixel(centerMap));
+		for (var i = 0; i < startPointMapArray.length; i++) {
+			pointArray[i] = convertMapToPixel(startPointMapArray[i]).minus(getCenter());
+			startPointPixArray[i] = convertMapToPixel(startPointMapArray[i]).minus(getCenter());
+		}
+		radius = pointArray[0].dist(new Point(0,0));
+		startRadius = radius;
+		boxWidth = pointArray[2].x - pointArray[0].x;
+		boxHeight = pointArray[0].y - pointArray[2].y;
+	};
+
+	var initPoints = function () {
+		var w = parseInt((boxWidth/2), 10);
+		var h = parseInt((boxHeight/2), 10);
+
+		pointArray[0] = new Point(-w,  h);
+		pointArray[1] = new Point( w,  h);
+		pointArray[2] = new Point( w, -h);
+		pointArray[3] = new Point(-w, -h);
+
+		startPointPixArray[0] = (new Point(-w,  h));
+		startPointPixArray[1] = (new Point( w,  h));
+		startPointPixArray[2] = (new Point( w, -h));
+		startPointPixArray[3] = (new Point(-w, -h));
+
+		radius = pointArray[0].dist(new Point(0,0));
+		startRadius = radius;
+
+		recalculateMapPositions();
+
+		scale = that.getScale();
+	};
+
+	var switchBoxDimensions = function () {
+		setBoxDimensions(boxHeight, boxWidth);
+		afterChangeSize({
+			scale: that.getScale(),
+			coordinates: that.getStartCoordinates()
+		});
+	};
+
+	this.setPortrait = function () {
+		this.setAngle(0);
+		if (boxWidth > boxHeight) {
+			switchBoxDimensions();
+		}
+	};
+	
+	this.setLandscape = function () {
+		this.setAngle(0);
+		if (boxWidth < boxHeight) {
+			switchBoxDimensions();
+		}
+	};
+	
+	this.setPrintWidthAndHeight = function (width, height) {
+		var currentScale = this.getScale();
+		printWidth = width;
+		printHeight = height;
+		this.setScale(currentScale);
+	};
+	
+	var convertMapToPixel = function (aPoint) {
+		var pArray = parent.makeRealWorld2mapPos(mapObj.frameName, aPoint.x, aPoint.y);
+		return new Point(pArray[0], pArray[1]);
+	};
+	
+	var convertPixelToMap = function (aPoint) {
+		var pArray = parent.makeClickPos2RealWorldPos(mapObj.frameName, aPoint.x, aPoint.y);
+		return new Point(pArray[0], pArray[1]);
+	};
+	
+	/**
+	 * Sets the box width and box height (calculated in setScale)
+	 * 
+	 * @param {Integer} inputWidth
+	 * @param {Integer} inputHeight
+	 */
+	var setBoxDimensions = function (inputWidth, inputHeight) {
+		boxWidth = inputWidth;
+		boxHeight = inputHeight;
+		
+		initPoints();
+		that.rotate(totalAngle);
+
+		afterChangeSize({
+			scale: that.getScale(),
+			coordinates: that.getStartCoordinates()
+		});
+
+		that.paintBox();
+	};
+
+	/**
+	 * Returns an array of two points, the lower left and upper right of the initial box
+	 */
+	this.getStartCoordinates = function () {
+		var a = startPointMapArray[0];
+		var b = startPointMapArray[2];
+		if (!a || !b) {
+			return null;
+		}
+		var returnString =  a.x + "," + a.y + "," + b.x + "," + b.y;
+		return returnString;
+	};
+
+	/**
+	 * Returns the current scale of the print box
+	 */
+	this.getScale = function () {
+/*
+		var coords = this.getStartCoordinates();
+		var coordsArray = coords.split(",");		
+
+		var ext = mapObj.getExtentInfos();
+		var extMinX = ext.minx;
+		var extMaxX = ext.maxx;
+		
+		var x = (ext.minx + ext.maxx)/2;
+		var y = (ext.miny + ext.maxy)/2;
+		var scale1 = (x - coordsArray[0]) * (parent.mb_resolution * 100 *2) / mapObj.width;
+		var scale2 = (coordsArray[2] - x) * (parent.mb_resolution * 100 *2) / mapObj.width;
+		scale = Math.round(scale1/2 + scale2/2);
+		return scale;
+*/
+		var coords = this.getStartCoordinates();
+		var coordsArray = coords.split(",");		
+	
+		xtentx =  coordsArray[2] - coordsArray[0];
+		scale = parseInt(Math.ceil(xtentx / (printWidth / 100)), 10);
+		return scale;
+	};
+
+	/**
+	 * Repaints the Box with the current scale. Can be called from outside, 
+	 * for example after zoom in.
+	 */
+	this.repaint = function () {
+		recalculatePixPositions();
+		this.rotate(totalAngle);
+		this.paintBox();
+	};
+	
+	/**
+	 * Sets the current scale, and repaints the box
+	 * 
+	 * @param {Integer} inputScale
+	 */
+	this.setScale = function (inputScale) {
+		if (typeof(inputScale) == "number") {
+/*			
+			var arrayBBox = mapObj.extent.split(",");
+			x = parseFloat(arrayBBox[0]) + ((parseFloat(arrayBBox[2]) - parseFloat(arrayBBox[0]))/2);
+			y = parseFloat(arrayBBox[1]) + ((parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1]))/2);
+			
+			var minx = parseFloat(x) - (mapObj.width / (parent.mb_resolution * 100 *2) * inputScale);
+			var miny = parseFloat(y) -  (mapObj.height / (parent.mb_resolution * 100 *2) * inputScale);
+			var maxx = parseFloat(x) + (mapObj.width / (parent.mb_resolution * 100 *2) * inputScale);
+			var maxy = parseFloat(y) +  (mapObj.height / (parent.mb_resolution * 100 *2) * inputScale);
+
+			var newMinPos = parent.makeRealWorld2mapPos(mapObj.frameName, minx, miny);
+			var newMaxPos = parent.makeRealWorld2mapPos(mapObj.frameName, maxx, maxy);
+			var newBoxWidth = newMaxPos[0] - newMinPos[0];
+			var newBoxHeight = newBoxWidth * (printHeight / printWidth);
+*/
+			var mapWidthInM = printWidth / 100;
+			var realWidthInM = inputScale * mapWidthInM;
+			var mapHeightInM = printHeight / 100;
+			var realHeightInM = inputScale * mapHeightInM;
+			
+			var coords = this.getStartCoordinates();
+			if (coords !== null) {
+				var coordsArray = coords.split(",");
+				var oldMin = new Point(parseFloat(coordsArray[0]), parseFloat(coordsArray[1]));
+				var oldMax = new Point(parseFloat(coordsArray[2]), parseFloat(coordsArray[3]));
+				centerMap = (oldMin.times(0.5)).plus(oldMax.times(0.5));
+				
+			}
+			else {
+				centerMap = convertPixelToMap(getCenter());
+			}
+			var newMin = new Point(centerMap.x - 0.5 * realWidthInM, centerMap.y - 0.5 * realHeightInM);
+			var newMax = new Point(centerMap.x + 0.5 * realWidthInM, centerMap.y + 0.5 * realHeightInM);
+
+			startPointMapArray[0] = new Point(newMin.x, newMin.y);
+			startPointMapArray[1] = new Point(newMax.x, newMin.y);
+			startPointMapArray[2] = new Point(newMax.x, newMax.y);
+			startPointMapArray[3] = new Point(newMin.x, newMax.y);
+
+			this.getStartCoordinates();
+			var newMinPos = convertMapToPixel(newMin);
+			var newMaxPos = convertMapToPixel(newMax);
+			boxWidth = newMaxPos.x - newMinPos.x;
+			boxHeight = newMinPos.y - newMaxPos.y;
+
+			var w = parseInt(0.5 * boxWidth, 10);
+			var h = parseInt(0.5 * boxHeight, 10);
+
+			pointArray[0] = new Point(-w,  h);
+			pointArray[1] = new Point( w,  h);
+			pointArray[2] = new Point( w, -h);
+			pointArray[3] = new Point(-w, -h);
+	
+			startPointPixArray[0] = (new Point(-w,  h));
+			startPointPixArray[1] = (new Point( w,  h));
+			startPointPixArray[2] = (new Point( w, -h));
+			startPointPixArray[3] = (new Point(-w, -h));
+	
+			radius = pointArray[0].dist(new Point(0,0));
+			startRadius = radius;
+	
+			this.rotate(totalAngle);
+	
+	
+			afterChangeSize({
+				scale: that.getScale(),
+				coordinates: that.getStartCoordinates()
+			});
+	
+			that.paintBox();
+
+			return true;
+		}
+		return false;
+	};
+
+	/**
+	 * Sets the angle of the box to a specific angle.
+	 * 
+	 * @param {Integer} angle
+	 */
+	this.setAngle = function (angle) {
+		if (typeof(angle) == "number" && angle >= -360) {
+			totalAngle = (360 + angle) % 360;
+			this.rotate(totalAngle);
+			this.paintBox();
+			afterChangeAngle({
+				angle: totalAngle,
+				coordinates: that.getStartCoordinates()
+			});
+			return true;
+		}
+		return false;
+	};
+
+
+	//
+	//
+	// VIEW
+	//
+	//
+
+	/**
+	 * Rotates the box by a given degree (0 <= degree < 360), 
+	 * and paints the corner points.
+	 * 
+	 * @param {Integer} degree
+	 */
+	this.rotate = function (degree) {
+		var rotationAngle = (Math.PI * parseFloat(degree))/180;
+		var resizeRatio = radius / startRadius;
+
+		for (var i = 0; i < pointArray.length; i++) {
+			var p = (convertMapToPixel(startPointMapArray[i])).minus(getCenter());
+			var newx = p.x * Math.cos(rotationAngle) + p.y * Math.sin(rotationAngle);
+			var newy = p.x * -Math.sin(rotationAngle) + p.y * Math.cos(rotationAngle);
+			pointArray[i] = (new Point(newx, newy)).times(resizeRatio);
+		}
+		afterChangeAngle({
+			angle: degree,
+			coordinates: this.getStartCoordinates()
+		});
+		this.paintPoints();
+	};
+
+	/**
+	 * Paints the four corner points of the print box.
+	 */
+	this.paintPoints = function () {
+
+		switchActiveCanvas();
+		var c = center;
+		for (var i = 0; i < pointArray.length; i++) {
+			activeCanvas.fillEllipse(
+				pointArray[i].x + c.x - 4,
+				pointArray[i].y + c.y - 4,
+				8,
+				8
+			);
+		}
+		activeCanvas.paint();
+		passiveCanvas.clear();
+	};
+
+	var boxTooBig = function () {
+		if (boxWidth > MAX_BOX_WIDTH_OR_HEIGHT || boxHeight > MAX_BOX_WIDTH_OR_HEIGHT) {
+			return true;
+		}
+		return false;
+	}
+
+	var boxTooSmall = function () {
+		if (boxWidth < MIN_BOX_WIDTH_OR_HEIGHT || boxHeight < MIN_BOX_WIDTH_OR_HEIGHT) {
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Paints the box itself. Plus the circle.
+	 */
+	this.paintBox = function () {
+		var r = Math.round(0.75 * radius);
+		var c = center;
+		circleCanvas.clear();	
+		if (!boxTooSmall() && !boxTooBig()) {
+			circleCanvas.drawEllipse(c.x-r, c.y-r, 2*r, 2*r);
+		}
+		else {
+			new parent.Mb_warning("The print box is too small or too big. The rotate circle is not shown.");
+		}
+		circleCanvas.paint();
+
+		boxCanvas.clear();
+		if (!boxTooBig()) {
+			boxCanvas.fillPolygon([
+				pointArray[0].x + c.x,
+				pointArray[1].x + c.x,
+				pointArray[2].x + c.x,
+				pointArray[3].x + c.x
+			], 
+			[
+				pointArray[0].y + c.y,
+				pointArray[1].y + c.y,
+				pointArray[2].y + c.y,
+				pointArray[3].y + c.y
+			]);
+		}
+		else {
+			new parent.Mb_warning("The print box is too big. The box is not filled.");
+		}
+		
+		// frame
+		boxCanvas.setColor(frameColour);	
+		for (var i = 0; i < pointArray.length; i++) {
+			var indexA = i % 4;
+			var a = pointArray[indexA].plus(center);
+			var indexB = (i + 1) % 4;
+			var b = pointArray[indexB].plus(center);
+			boxCanvas.drawLine(a.x, a.y, b.x, b.y);
+		}
+		
+		boxCanvas.setColor(boxColour);	
+		boxCanvas.paint();
+	};
+	
+	/**
+	 * Clears all canvases, to be performed onunload.
+	 */
+	this.destroy = function () {
+		circleCanvas.clear();	
+		boxCanvas.clear();
+		activeCanvas.clear();
+		passiveCanvas.clear();
+	};
+
+	var switchActiveCanvas = function () {
+		if (canvasNr == 1) {
+			canvasNr = 2;
+			activeCanvas = jg[2];
+			passiveCanvas = jg[1];
+		}
+		else {
+			canvasNr = 1;
+			activeCanvas = jg[1];
+			passiveCanvas = jg[2];
+		}
+	};
+
+
+	var $container = $("<div id='" + this.id + "' style='position:relative;top:0px;left:0px;" + 
+		"'></div>");
+		
+	var $superContainer = $("<div id='container_" + this.id + "' style='position:absolute;z-index:1000;'></div>");
+	$superContainer.append($container);
+	$("body").append($superContainer);
+	
+	var canvasName = [
+		this.id + "_canvas_box",
+		this.id + "_canvas_points1",
+		this.id + "_canvas_points2",
+		this.id + "_canvas_circle"
+	];
+
+	var jg = [];
+	
+	var canvasNr = 1;
+
+	for (var i = 0; i < canvasName.length; i++) {
+		$container.append(
+			$("<div id='" + canvasName[i] + "'></div>")
+		);
+		jg[i] = new jsGraphics(canvasName[i]);
+	}
+
+	$circleCanvas = $("#" + canvasName[3]);
+	$pointCanvas = $("#" + canvasName[1] +  ", #" + canvasName[2]);
+	$boxCanvas = $("#" + canvasName[0]);
+	$boxCanvas.css({
+		"opacity" : opacity, 
+		"filter" : "alpha(opacity=" + (opacity * 100) + ")"
+	});
+		
+	
+
+	var boxCanvas = jg[0];
+	boxCanvas.setColor(boxColour);	
+	var activeCanvas = jg[1];
+	activeCanvas.setColor(pointColour);
+	var passiveCanvas = jg[2];
+	passiveCanvas.setColor(pointColour);
+	var circleCanvas = jg[3];
+	circleCanvas.setColor(circleColour);
+	circleCanvas.setStroke(circleWidth);	
+
+	var mouseMoveStart = [];	
+
+	var radius = 0;
+	var startRadius = 0;
+
+	// "constructor" functions
+	initBehaviour();
+	this.setScale(scale);
+	parent.mb_registerPanSubElement($superContainer.get(0).id);
+}
\ No newline at end of file

Added: branches/dynamic_printframe_dev/print_dynamic.sql
===================================================================
--- branches/dynamic_printframe_dev/print_dynamic.sql	                        (rev 0)
+++ branches/dynamic_printframe_dev/print_dynamic.sql	2009-06-04 13:50:53 UTC (rev 4001)
@@ -0,0 +1 @@
+INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) VALUES('gui1','printPDF_dynamic',2,1,'start print GUI','Print','img','../img/button_blink_red/print_off.png','onclick=''window.open("../print_dynamic/mod_printPDF.php?target=mapframe1&sessionID&conf=printPDF_b.conf","printWin","width=260, height=500, resizable=yes ")''  onmouseover=''this.src = this.src.replace(/_off/,"_over");''  onmouseout=''this.src = this.src.replace(/_over/, "_off");'' ',555,60,24,24,1,'','','','','','mapframe1','','http://www.mapbender.org/index.php/Print');



More information about the Mapbender_commits mailing list