[Mapbender-commits] r3956 - in branches/print_dev: conf core http/classes http/css http/html http/img/button_digitize http/include http/javascripts http/php http/print lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri May 22 07:46:02 EDT 2009


Author: mschulz
Date: 2009-05-22 07:46:01 -0400 (Fri, 22 May 2009)
New Revision: 3956

Modified:
   branches/print_dev/conf/digitize_default.conf
   branches/print_dev/conf/mapbender.conf-dist
   branches/print_dev/conf/wfs_additional_spatial_search.conf
   branches/print_dev/conf/wfs_default.conf
   branches/print_dev/core/globalSettings.php
   branches/print_dev/core/system.php
   branches/print_dev/http/classes/class.ezpdf.php
   branches/print_dev/http/classes/class_administration.php
   branches/print_dev/http/classes/class_bbox.php
   branches/print_dev/http/classes/class_checkInput.php
   branches/print_dev/http/classes/class_connector.php
   branches/print_dev/http/classes/class_element.php
   branches/print_dev/http/classes/class_gml_2_factory.php
   branches/print_dev/http/classes/class_gml_3_factory.php
   branches/print_dev/http/classes/class_gml_factory.php
   branches/print_dev/http/classes/class_gml_line.php
   branches/print_dev/http/classes/class_gml_multiline.php
   branches/print_dev/http/classes/class_gml_multipolygon.php
   branches/print_dev/http/classes/class_gml_point.php
   branches/print_dev/http/classes/class_gml_polygon.php
   branches/print_dev/http/classes/class_kml.php
   branches/print_dev/http/classes/class_kml_ows.php
   branches/print_dev/http/classes/class_kml_parser_ows.php
   branches/print_dev/http/classes/class_layer_monitor.php
   branches/print_dev/http/classes/class_locale.php
   branches/print_dev/http/classes/class_ows.php
   branches/print_dev/http/classes/class_point.php
   branches/print_dev/http/classes/class_wfs.php
   branches/print_dev/http/classes/class_wfsToDb.php
   branches/print_dev/http/classes/class_wfs_1_0.php
   branches/print_dev/http/classes/class_wfs_1_0_factory.php
   branches/print_dev/http/classes/class_wfs_1_1.php
   branches/print_dev/http/classes/class_wfs_1_1_factory.php
   branches/print_dev/http/classes/class_wfs_conf.php
   branches/print_dev/http/classes/class_wfs_configuration.php
   branches/print_dev/http/classes/class_wfs_deprecated.php
   branches/print_dev/http/classes/class_wfs_factory.php
   branches/print_dev/http/classes/class_wfs_featuretype.php
   branches/print_dev/http/classes/class_wmc.php
   branches/print_dev/http/classes/class_wmcToXml.php
   branches/print_dev/http/classes/class_wms.php
   branches/print_dev/http/css/admin.css
   branches/print_dev/http/css/admin.screen.css
   branches/print_dev/http/css/admin_service.css
   branches/print_dev/http/css/admin_user.css
   branches/print_dev/http/css/digitize.css
   branches/print_dev/http/css/edit_gui.css
   branches/print_dev/http/css/gazetteerSQL_ALB.css
   branches/print_dev/http/css/gazetteerSQL_ALK.css
   branches/print_dev/http/css/gazetteerSQL_Address.css
   branches/print_dev/http/css/login.css
   branches/print_dev/http/css/mapbender.css
   branches/print_dev/http/css/meetingPoint.css
   branches/print_dev/http/css/metadata.css
   branches/print_dev/http/html/mod_treefolder2.php
   branches/print_dev/http/html/mod_treefolderPlain.php
   branches/print_dev/http/img/button_digitize/mergePolygons_off.png
   branches/print_dev/http/img/button_digitize/mergePolygons_on.png
   branches/print_dev/http/img/button_digitize/mergePolygons_over.png
   branches/print_dev/http/img/button_digitize/punchPolygon_off.png
   branches/print_dev/http/img/button_digitize/punchPolygon_on.png
   branches/print_dev/http/img/button_digitize/punchPolygon_over.png
   branches/print_dev/http/include/dyn_css.php
   branches/print_dev/http/include/dyn_js.php
   branches/print_dev/http/include/gui1_splash.php
   branches/print_dev/http/include/template_splash.php
   branches/print_dev/http/javascripts/geometry.js
   branches/print_dev/http/javascripts/map.php
   branches/print_dev/http/javascripts/map_obj.js
   branches/print_dev/http/javascripts/mapnf.php
   branches/print_dev/http/javascripts/mod_addWMSfromfilteredList_ajax.php
   branches/print_dev/http/javascripts/mod_back.php
   branches/print_dev/http/javascripts/mod_box1.js
   branches/print_dev/http/javascripts/mod_digitize_tab.php
   branches/print_dev/http/javascripts/mod_dynamicOverview.php
   branches/print_dev/http/javascripts/mod_exportMapImage.php
   branches/print_dev/http/javascripts/mod_featureInfo.php
   branches/print_dev/http/javascripts/mod_forward.php
   branches/print_dev/http/javascripts/mod_help.php
   branches/print_dev/http/javascripts/mod_highlightPOI.php
   branches/print_dev/http/javascripts/mod_legend.php
   branches/print_dev/http/javascripts/mod_measure.php
   branches/print_dev/http/javascripts/mod_navFrame.php
   branches/print_dev/http/javascripts/mod_pan.php
   branches/print_dev/http/javascripts/mod_sandclock.php
   branches/print_dev/http/javascripts/mod_scaleHint.php
   branches/print_dev/http/javascripts/mod_scaleSel.php
   branches/print_dev/http/javascripts/mod_scalebar.php
   branches/print_dev/http/javascripts/mod_selArea1.php
   branches/print_dev/http/javascripts/mod_setBBOX1.php
   branches/print_dev/http/javascripts/mod_tab.js
   branches/print_dev/http/javascripts/mod_tooltip.php
   branches/print_dev/http/javascripts/mod_wfs_SpatialRequest.php
   branches/print_dev/http/javascripts/mod_wfs_client.html
   branches/print_dev/http/javascripts/mod_wfs_gazetteer_client.php
   branches/print_dev/http/javascripts/popup.js
   branches/print_dev/http/javascripts/wfs.php
   branches/print_dev/http/javascripts/wms.js
   branches/print_dev/http/php/mod_digitize_messages.php
   branches/print_dev/http/php/mod_editApplication.php
   branches/print_dev/http/php/mod_editElements.php
   branches/print_dev/http/php/mod_editGuiWms.php
   branches/print_dev/http/php/mod_exportElement.php
   branches/print_dev/http/php/mod_loadwmc_server.php
   branches/print_dev/http/php/mod_meetingPoint.php
   branches/print_dev/http/php/mod_savewmc_server.php
   branches/print_dev/http/php/mod_wfs.php
   branches/print_dev/http/php/mod_wfs_edit.php
   branches/print_dev/http/php/mod_wfs_server.php
   branches/print_dev/http/print/mod_printPDF.php
   branches/print_dev/http/print/mod_printPDF_pdf.php
   branches/print_dev/lib/ajax.js
   branches/print_dev/lib/ajax.php
   branches/print_dev/lib/basic.js
   branches/print_dev/lib/event.js
Log:
merged from trunk

Modified: branches/print_dev/conf/digitize_default.conf
===================================================================
--- branches/print_dev/conf/digitize_default.conf	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/conf/digitize_default.conf	2009-05-22 11:46:01 UTC (rev 3956)
@@ -20,6 +20,7 @@
 var buttonDig_wfs_src = "geomInfo.png";
 var buttonDig_remove_src = "geomRemove.png";
 var buttonDig_removeDb_src = "geomRemoveDb.png";
+var buttonDig_clone_src = "geomClone.png";
 
 var dotDistance = 7;
 var linepointColor = "#ffff00";
@@ -27,6 +28,8 @@
 var snappingColor = "#ff0000";
 var snappingTolerance = 12;
 
+var geomHighlightColour = "#ff0000";
+
 var snappingHighlightZIndex = 120;
 var digitizeTransactionalZIndex = 80;
 var digitizeNonTransactionalZIndex = 20;
@@ -55,6 +58,8 @@
 var nonTransactionalColor = "#ff66cc"; 
 var nonTransactionalLineWidth = 2; 
 
+var addCloneGeometryButton = false;
+
 var wfsWindowWidth = 400;
 var wfsWindowHeight = 300;
 

Modified: branches/print_dev/conf/mapbender.conf-dist
===================================================================
--- branches/print_dev/conf/mapbender.conf-dist	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/conf/mapbender.conf-dist	2009-05-22 11:46:01 UTC (rev 3956)
@@ -150,7 +150,7 @@
 define("USE_I18N", false);  // requires gettext for PHP. 
 							// If "false", LANGUAGE is set to english
 define("LANGUAGE", "en");   // only available if USE_I18N is "true". 
-							// "en", "de", "bg", "gr", "nl", "it", "es","fr","pt"
+							// "en", "de", "bg", "gr", "nl", "hu", "it", "es","fr","pt"
 
 ###HACK for GLOBALS
 $DBSERVER=DBSERVER;

Modified: branches/print_dev/conf/wfs_additional_spatial_search.conf
===================================================================
--- branches/print_dev/conf/wfs_additional_spatial_search.conf	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/conf/wfs_additional_spatial_search.conf	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,3 +1,9 @@
+// --------------------------------------------------------
+//
+// Settings of spatial request buttons
+//
+// --------------------------------------------------------
+
 /**
  * definition of buttons for spatialRequest
  *
@@ -2,2 +8,4 @@
  * [@param {integer} status show this button (value is 1 or 0)
+ * [@param {integer} x position left
+ * [@param {integer} y position top
  * [@param {string} img image for the button
@@ -7,35 +15,104 @@
  * [@param {string} filteroption type of filter for search (values: "intersects" or "within"), used for buttons buttonRectangle and buttonPolygon 
  */
  
-var buttonRectangle = {"status":1,"img":"select_rectangle_off.png","title":"select by rectangle","filteroption":"intersects"};
-var buttonPolygon = {"status":1,"img":"select_polygon_off.png","title":"select by polygon","filteroption":"intersects"};
-var buttonPoint = {"status":1, "img":"select_point_off.png","title":"select by point"};
-var buttonExtent = {"status":1,"img":"select_extent_off.png","title":"select by extent"};
+var buttonRectangle = {"status":1,"img":"select_rectangle_off.png","title":"<?php echo _mb("select by rectangle");?>","filteroption":"intersects"};
+var buttonPolygon = {"status":1,"img":"select_polygon_off.png","title":"<?php echo _mb("select by polygon");?>","filteroption":"intersects"};
+var buttonPoint = {"status":1, "img":"select_point_off.png","title":"<?php echo _mb("select by point");?>"};
+var buttonExtent = {"status":1,"img":"select_extent_off.png","title":"<?php echo _mb("select by extent");?>"};
 
+/**
+ * directory that contains the buttons mentioned above
+ */
+var buttonWfs_imgdir = "../img/button_gray/";
+
+/**
+ * z-Index of the buttons mentioned above
+ */
+var buttonWfs_zIndex = 10;
+
+// --------------------------------------------------------
+//
+// General WFS request settings
+//
+// --------------------------------------------------------
+
+/**
+ * This is the buffer around query points for spatial requests (in pixel)
+ */
 var mb_wfs_tolerance = 8;
 
-var spatialRequestIsSetMessage = "Spatial filter is set.";
-var clearFilterButtonLabel = "New";
+/**
+ * If spatialRequest is set, show this message
+ */
+var spatialRequestIsSetMessage = '<?php echo _mb("Spatial filter is set.");?>';
 
-var noResultMsg = "No result";
+/**
+ * Label of the clearFilter-Button
+ */
+var clearFilterButtonLabel = '<?php echo _mb("new");?>';
 
-var buttonWfs_imgdir = "../img/button_gray/";
-var buttonWfs_zIndex = 10;
+/**
+ * If no results are found, show this message
+ */
+var noResultMsg = '<?php _mb("No result");?>';
 
+/**
+ * Path to the server-side module that performs the WFS request
+ */
+var wfsResultModulePath = "php/";
+
+/**
+ * File name of the server-side module that performs the WFS request
+ */
+var wfsResultModuleFilename = "mod_wfs_result.php";
+
+
+// --------------------------------------------------------
+//
+// Result geometry highlight settings
+//
+// --------------------------------------------------------
+
+/**
+ * z-Index of the highlighted geometries
+ */
 var generalHighlightZIndex = 90;
+
+/**
+ * Line width of the highlighted geometries in pixel
+ */
 var generalHighlightLineWidth = 2;
 
-var wfsResultModulePath = "php/";
-var wfsResultModuleFilename = "mod_wfs_result.php";
+/**
+ * Title of the result popup
+ */
+var searchPopupTitle = '<?php echo _mb("Search results");?>';
 
-var searchPopupTitle = "Search results";
+/**
+ * Width and height of the result popup (in pixel)
+ */
 var searchPopupWidth = 400;
-var searchPopupHeight =250;
+var searchPopupHeight = 250;
+
+/**
+ * Absolute position of the result popup (in pixel)
+ */
 var searchPopupX = 750; 
 var searchPopupY = 80; 
 
-var detailPopupTitle = "Details";
+/**
+ * Title of the result details popup
+ */
+var detailPopupTitle = '<?php echo _mb("Details");?>';
+
+/**
+ * Width and height of the result details popup (in pixel)
+ */
 var detailPopupWidth = 400;
 var detailPopupHeight = 200;
+
+/**
+ * Absolute position of the result details popup (in pixel)
+ */
 var detailPopupX = 750; 
 var detailPopupY = 410;

Modified: branches/print_dev/conf/wfs_default.conf
===================================================================
--- branches/print_dev/conf/wfs_default.conf	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/conf/wfs_default.conf	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,3 +1,9 @@
+// --------------------------------------------------------
+//
+// Settings of spatial request buttons
+//
+// --------------------------------------------------------
+
 /**
  * definition of buttons for spatialRequest
  *
@@ -7,38 +13,143 @@
  * [@param {string} img image for the button
  * [@param {string} filteroption type of filter for search (values: "intersects" or "within"), used for buttons buttonRectangle and buttonPolygon 
  */
- 
 var buttonRectangle = {"status":1, "x":750, "y":10, "img":"select_rectangle_off.png","filteroption":"intersects"};
 var buttonPolygon = {"status":1, "x":780, "y":10, "img":"select_polygon_off.png","filteroption":"intersects"};
 var buttonPoint = {"status":1, "x":810, "y":10, "img":"select_point_off.png"};
 var buttonExtent = {"status":1, "x":840, "y":10, "img":"select_extent_off.png"};
 var buttonDialogue = {"status":1, "x":870, "y":10, "img":"select_choose_off.png"};
 
-var mb_wfs_tolerance = 8;
+/**
+ * directory that contains the buttons mentioned above
+ */
+var buttonWfs_imgdir = "../img/button_gray/";
 
-var buttonWfs_imgdir = "../img/button_gray/";
+/**
+ * z-Index of the buttons mentioned above
+ */
 var buttonWfs_zIndex = 10;
 
-// if wfsResultToPopupDiv is 0, this is automatically 1
+
+// --------------------------------------------------------
+//
+// General WFS request settings
+//
+// --------------------------------------------------------
+
+/**
+ * This is the buffer around query points for spatial requests (in pixel)
+ */
+var mb_wfs_tolerance = 8;
+
+/**
+ * if features found via WFS request do not match 
+ * the current client SRS, a warning with a 
+ * confirmation prompt is displayed. Useful
+ * in applications with switchEPSG
+ */
+var displaySrsWarning = false;
+
+/**
+ * Path to the server-side module that performs the WFS request
+ */
+var wfsResultModulePath = "php/";
+
+/**
+ * File name of the server-side module that performs the WFS request
+ */
+var wfsResultModuleFilename = "mod_wfs_result.php";
+
+
+// --------------------------------------------------------
+//
+// Result geometry highlight settings
+//
+// --------------------------------------------------------
+
+/**
+ * z-Index of the highlighted geometries
+ */
+var generalHighlightZIndex = 90;
+
+/**
+ * Line width of the highlighted geometries in pixel
+ */
+var generalHighlightLineWidth = 2;
+
+/**
+ * Colour of the highlighted geometries in RGB, 
+ * f.e. "#FF0000" for red.
+ */
+var resultHighlightColour = "#FF0000";
+
+
+
+// --------------------------------------------------------
+//
+// Setting for an optional popup div that contains the
+// result geometries from the request
+//
+// --------------------------------------------------------
+
+/**
+ * Displays a popup div that contains the result geometries.
+ * If you want to add a button that exports these geometries
+ * to the digitizing tool, also set the variable "buttonWfs_toDigitize_on"
+ */
+var wfsResultToPopupDiv = 1;
+
+/**
+ * This setting depends on wfsResultToPopupDiv:
+ * if wfsResultToPopupDiv is 1, this setting determines whether
+ * a button appears within the div, that allows to export the
+ * geometries to the digitizing tool.
+ * if wfsResultToPopupDiv is 0, this is setting is ignored,
+ * and geometries will be automatically exported to
+ * the digitizing tool
+ */
 var buttonWfs_toDigitize_on = 1; 
+
+/**
+ * Element ID of the digitizing tool
+ */
 var buttonWfs_toDigitize_target = "digitize";
+
+/**
+ * Path and file name of the button, that exports the
+ * geometries to the digitizing tool
+ */
 var buttonWfs_toDigitize_src = "../img/pencil.png";
 
-var generalHighlightZIndex = 90;
-var generalHighlightLineWidth = 2;
+/**
+ * Title of the result popup
+ */
+var searchPopupTitle = '<?php echo _mb("Search results");?>';
 
-var wfsResultModulePath = "php/";
-var wfsResultModuleFilename = "mod_wfs_result.php";
+/**
+ * Width and height of the result popup (in pixel)
+ */
+var searchPopupWidth = 300;
+var searchPopupHeight = 250;
 
-var wfsResultToPopupDiv = 0;
-var searchPopupTitle = "Search results";
-var searchPopupWidth = 300;
-var searchPopupHeight =250;
+/**
+ * Absolute position of the result popup (in pixel)
+ */
 var searchPopupX = 800; 
 var searchPopupY = 100; 
 
-var detailPopupTitle = "Details";
+/**
+ * Title of the result details popup
+ */
+var detailPopupTitle = '<?php echo _mb("Details");?>';
+
+/**
+ * Width and height of the result details popup (in pixel)
+ */
 var detailPopupWidth = 300;
 var detailPopupHeight = 250;
+
+/**
+ * Absolute position of the result details popup (in pixel)
+ */
 var detailPopupX = 800; 
 var detailPopupY = 400;
\ No newline at end of file

Modified: branches/print_dev/core/globalSettings.php
===================================================================
--- branches/print_dev/core/globalSettings.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/core/globalSettings.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -22,6 +22,11 @@
 session_start();
 
 //
+// define LC_MESSAGES if unknown
+// 
+if (!defined('LC_MESSAGES')) define('LC_MESSAGES', LC_CTYPE);
+
+//
 // All data Mapbender handles internally are UTF-8
 //
 mb_internal_encoding("UTF-8");

Modified: branches/print_dev/core/system.php
===================================================================
--- branches/print_dev/core/system.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/core/system.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -20,8 +20,8 @@
 # mapbender version
 #
 define("MB_VERSION_NUMBER", "2.6");
-define("MB_VERSION_APPENDIX", "trunk");
-define("MB_RELEASE_DATE", mktime(0,0,0,7,22,2008));//h, min,sec,month,day,year
+define("MB_VERSION_APPENDIX", "rc1");
+define("MB_RELEASE_DATE", mktime(0,0,0,3,17,2009));//h, min,sec,month,day,year
 
 #
 # constants from map.js
@@ -36,4 +36,4 @@
 
 define("ZOOM_MOUSEWHEEL", "1.1");
 
-define("MODULES_NOT_RELYING_ON_GLOBALS", "back,forward,zoomIn1,copyright,dependentDiv,dragMapSize,FeatureInfoRedirect,highlightPOI,navFrame,sandclock,scaleBar,scaleSel,setBBOX,setPOI2Scale");
+define("MODULES_NOT_RELYING_ON_GLOBALS", "featureInfo1,gazetteerWFS,back,forward,zoomIn1,zoomOut1,selArea1,pan1,copyright,dependentDiv,dragMapSize,dynamicOverview,FeatureInfoRedirect,highlightPOI,navFrame,sandclock,scaleBar,scaleSel,setBBOX,setPOI2Scale");

Modified: branches/print_dev/http/classes/class.ezpdf.php
===================================================================
--- branches/print_dev/http/classes/class.ezpdf.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class.ezpdf.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,1555 +1,1555 @@
-<?php
-
-include_once(dirname(__FILE__).'/class.pdf.php');
-
-class Cezpdf extends Cpdf {
-//==============================================================================
-// this class will take the basic interaction facilities of the Cpdf class
-// and make more useful functions so that the user does not have to 
-// know all the ins and outs of pdf presentation to produce something pretty.
-//
-// IMPORTANT NOTE
-// there is no warranty, implied or otherwise with this software.
-// 
-// version 009 (versioning is linked to class.pdf.php)
-//
-// released under a public domain licence.
-//
-// Wayne Munro, R&OS Ltd, http://www.ros.co.nz/pdf
-//==============================================================================
-
-var $ez=array('fontSize'=>10); // used for storing most of the page configuration parameters
-var $y; // this is the current vertical positon on the page of the writing point, very important
-var $ezPages=array(); // keep an array of the ids of the pages, making it easy to go back and add page numbers etc.
-var $ezPageCount=0;
-
-// ------------------------------------------------------------------------------
-
-function Cezpdf($paper='a4',$orientation='portrait'){
-	// Assuming that people don't want to specify the paper size using the absolute coordinates
-	// allow a couple of options:
-	// orientation can be 'portrait' or 'landscape'
-	// or, to actually set the coordinates, then pass an array in as the first parameter.
-	// the defaults are as shown.
-	// 
-	// -------------------------
-	// 2002-07-24 - Nicola Asuni (info at tecnick.com):
-	// Added new page formats (45 standard ISO paper formats and 4 american common formats)
-	// paper cordinates are calculated in this way: (inches * 72) where 1 inch = 2.54 cm
-	// 
-	// Now you may also pass a 2 values array containing the page width and height in centimeters
-	// -------------------------
-
-	if (!is_array($paper)){
-		switch (strtoupper($paper)){
-			case '4A0': {$size = array(0,0,4767.87,6740.79); break;}
-			case '2A0': {$size = array(0,0,3370.39,4767.87); break;}
-			case 'A0': {$size = array(0,0,2383.94,3370.39); break;}
-			case 'A1': {$size = array(0,0,1683.78,2383.94); break;}
-			case 'A2': {$size = array(0,0,1190.55,1683.78); break;}
-			case 'A3': {$size = array(0,0,841.89,1190.55); break;}
-			case 'A4': default: {$size = array(0,0,595.28,841.89); break;}
-			case 'A5': {$size = array(0,0,419.53,595.28); break;}
-			case 'A6': {$size = array(0,0,297.64,419.53); break;}
-			case 'A7': {$size = array(0,0,209.76,297.64); break;}
-			case 'A8': {$size = array(0,0,147.40,209.76); break;}
-			case 'A9': {$size = array(0,0,104.88,147.40); break;}
-			case 'A10': {$size = array(0,0,73.70,104.88); break;}
-			case 'B0': {$size = array(0,0,2834.65,4008.19); break;}
-			case 'B1': {$size = array(0,0,2004.09,2834.65); break;}
-			case 'B2': {$size = array(0,0,1417.32,2004.09); break;}
-			case 'B3': {$size = array(0,0,1000.63,1417.32); break;}
-			case 'B4': {$size = array(0,0,708.66,1000.63); break;}
-			case 'B5': {$size = array(0,0,498.90,708.66); break;}
-			case 'B6': {$size = array(0,0,354.33,498.90); break;}
-			case 'B7': {$size = array(0,0,249.45,354.33); break;}
-			case 'B8': {$size = array(0,0,175.75,249.45); break;}
-			case 'B9': {$size = array(0,0,124.72,175.75); break;}
-			case 'B10': {$size = array(0,0,87.87,124.72); break;}
-			case 'C0': {$size = array(0,0,2599.37,3676.54); break;}
-			case 'C1': {$size = array(0,0,1836.85,2599.37); break;}
-			case 'C2': {$size = array(0,0,1298.27,1836.85); break;}
-			case 'C3': {$size = array(0,0,918.43,1298.27); break;}
-			case 'C4': {$size = array(0,0,649.13,918.43); break;}
-			case 'C5': {$size = array(0,0,459.21,649.13); break;}
-			case 'C6': {$size = array(0,0,323.15,459.21); break;}
-			case 'C7': {$size = array(0,0,229.61,323.15); break;}
-			case 'C8': {$size = array(0,0,161.57,229.61); break;}
-			case 'C9': {$size = array(0,0,113.39,161.57); break;}
-			case 'C10': {$size = array(0,0,79.37,113.39); break;}
-			case 'RA0': {$size = array(0,0,2437.80,3458.27); break;}
-			case 'RA1': {$size = array(0,0,1729.13,2437.80); break;}
-			case 'RA2': {$size = array(0,0,1218.90,1729.13); break;}
-			case 'RA3': {$size = array(0,0,864.57,1218.90); break;}
-			case 'RA4': {$size = array(0,0,609.45,864.57); break;}
-			case 'SRA0': {$size = array(0,0,2551.18,3628.35); break;}
-			case 'SRA1': {$size = array(0,0,1814.17,2551.18); break;}
-			case 'SRA2': {$size = array(0,0,1275.59,1814.17); break;}
-			case 'SRA3': {$size = array(0,0,907.09,1275.59); break;}
-			case 'SRA4': {$size = array(0,0,637.80,907.09); break;}
-			case 'LETTER': {$size = array(0,0,612.00,792.00); break;}
-			case 'LEGAL': {$size = array(0,0,612.00,1008.00); break;}
-			case 'EXECUTIVE': {$size = array(0,0,521.86,756.00); break;}
-			case 'FOLIO': {$size = array(0,0,612.00,936.00); break;}
-		}
-		switch (strtolower($orientation)){
-			case 'landscape':
-				$a=$size[3];
-				$size[3]=$size[2];
-				$size[2]=$a;
-				break;
-		}
-	} else {
-		if (count($paper)>2) {
-			// then an array was sent it to set the size
-			$size = $paper;
-		}
-		else { //size in centimeters has been passed
-			$size[0] = 0;
-			$size[1] = 0;
-			$size[2] = ( $paper[0] / 2.54 ) * 72;
-			$size[3] = ( $paper[1] / 2.54 ) * 72;
-		}
-	}
-	$this->Cpdf($size);
-	$this->ez['pageWidth']=$size[2];
-	$this->ez['pageHeight']=$size[3];
-	
-	// also set the margins to some reasonable defaults
-	$this->ez['topMargin']=30;
-	$this->ez['bottomMargin']=30;
-	$this->ez['leftMargin']=30;
-	$this->ez['rightMargin']=30;
-	
-	// set the current writing position to the top of the first page
-	$this->y = $this->ez['pageHeight']-$this->ez['topMargin'];
-	// and get the ID of the page that was created during the instancing process.
-	$this->ezPages[1]=$this->getFirstPageId();
-	$this->ezPageCount=1;
-}
-
-// ------------------------------------------------------------------------------
-// 2002-07-24: Nicola Asuni (info at tecnick.com)
-// Set Margins in centimeters
-function ezSetCmMargins($top,$bottom,$left,$right){
-	$top = ( $top / 2.54 ) * 72;
-	$bottom = ( $bottom / 2.54 ) * 72;
-	$left = ( $left / 2.54 ) * 72;
-	$right = ( $right / 2.54 ) * 72;
-	$this->ezSetMargins($top,$bottom,$left,$right);
-}
-// ------------------------------------------------------------------------------
-
-
-function ezColumnsStart($options=array()){
-  // start from the current y-position, make the set number of columne
-  if (isset($this->ez['columns']) && $this->ez['columns']==1){
-    // if we are already in a column mode then just return.
-    return;
-  }
-  $def=array('gap'=>10,'num'=>2);
-  foreach($def as $k=>$v){
-    if (!isset($options[$k])){
-      $options[$k]=$v;
-    }
-  }
-  // setup the columns
-  $this->ez['columns']=array('on'=>1,'colNum'=>1);
-
-  // store the current margins
-  $this->ez['columns']['margins']=array(
-     $this->ez['leftMargin']
-    ,$this->ez['rightMargin']
-    ,$this->ez['topMargin']
-    ,$this->ez['bottomMargin']
-  );
-  // and store the settings for the columns
-  $this->ez['columns']['options']=$options;
-  // then reset the margins to suit the new columns
-  // safe enough to assume the first column here, but start from the current y-position
-  $this->ez['topMargin']=$this->ez['pageHeight']-$this->y;
-  $width=($this->ez['pageWidth']-$this->ez['leftMargin']-$this->ez['rightMargin']-($options['num']-1)*$options['gap'])/$options['num'];
-  $this->ez['columns']['width']=$width;
-  $this->ez['rightMargin']=$this->ez['pageWidth']-$this->ez['leftMargin']-$width;
-  
-}
-// ------------------------------------------------------------------------------
-function ezColumnsStop(){
-  if (isset($this->ez['columns']) && $this->ez['columns']['on']==1){
-    $this->ez['columns']['on']=0;
-    $this->ez['leftMargin']=$this->ez['columns']['margins'][0];
-    $this->ez['rightMargin']=$this->ez['columns']['margins'][1];
-    $this->ez['topMargin']=$this->ez['columns']['margins'][2];
-    $this->ez['bottomMargin']=$this->ez['columns']['margins'][3];
-  }
-}
-// ------------------------------------------------------------------------------
-function ezInsertMode($status=1,$pageNum=1,$pos='before'){
-  // puts the document into insert mode. new pages are inserted until this is re-called with status=0
-  // by default pages wil be inserted at the start of the document
-  switch($status){
-    case '1':
-      if (isset($this->ezPages[$pageNum])){
-        $this->ez['insertMode']=1;
-        $this->ez['insertOptions']=array('id'=>$this->ezPages[$pageNum],'pos'=>$pos);
-      }
-      break;
-    case '0':
-      $this->ez['insertMode']=0;
-      break;
-  }
-}
-// ------------------------------------------------------------------------------
-
-function ezNewPage(){
-  $pageRequired=1;
-  if (isset($this->ez['columns']) && $this->ez['columns']['on']==1){
-    // check if this is just going to a new column
-    // increment the column number
-//echo 'HERE<br>';
-    $this->ez['columns']['colNum']++;
-//echo $this->ez['columns']['colNum'].'<br>';
-    if ($this->ez['columns']['colNum'] <= $this->ez['columns']['options']['num']){
-      // then just reset to the top of the next column
-      $pageRequired=0;
-    } else {
-      $this->ez['columns']['colNum']=1;
-      $this->ez['topMargin']=$this->ez['columns']['margins'][2];
-    }
-
-    $width = $this->ez['columns']['width'];
-    $this->ez['leftMargin']=$this->ez['columns']['margins'][0]+($this->ez['columns']['colNum']-1)*($this->ez['columns']['options']['gap']+$width);
-    $this->ez['rightMargin']=$this->ez['pageWidth']-$this->ez['leftMargin']-$width;
-  }
-//echo 'left='.$this->ez['leftMargin'].'   right='.$this->ez['rightMargin'].'<br>';
-
-  if ($pageRequired){
-    // make a new page, setting the writing point back to the top
-    $this->y = $this->ez['pageHeight']-$this->ez['topMargin'];
-    // make the new page with a call to the basic class.
-    $this->ezPageCount++;
-    if (isset($this->ez['insertMode']) && $this->ez['insertMode']==1){
-      $id = $this->ezPages[$this->ezPageCount] = $this->newPage(1,$this->ez['insertOptions']['id'],$this->ez['insertOptions']['pos']);
-      // then manipulate the insert options so that inserted pages follow each other
-      $this->ez['insertOptions']['id']=$id;
-      $this->ez['insertOptions']['pos']='after';
-    } else {
-      $this->ezPages[$this->ezPageCount] = $this->newPage();
-    }
-  } else {
-    $this->y = $this->ez['pageHeight']-$this->ez['topMargin'];
-  }
-}
-
-// ------------------------------------------------------------------------------
-
-function ezSetMargins($top,$bottom,$left,$right){
-  // sets the margins to new values
-  $this->ez['topMargin']=$top;
-  $this->ez['bottomMargin']=$bottom;
-  $this->ez['leftMargin']=$left;
-  $this->ez['rightMargin']=$right;
-  // check to see if this means that the current writing position is outside the 
-  // writable area
-  if ($this->y > $this->ez['pageHeight']-$top){
-    // then move y down
-    $this->y = $this->ez['pageHeight']-$top;
-  }
-  if ( $this->y < $bottom){
-    // then make a new page
-    $this->ezNewPage();
-  }
-}  
-
-// ------------------------------------------------------------------------------
-
-function ezGetCurrentPageNumber(){
-  // return the strict numbering (1,2,3,4..) number of the current page
-  return $this->ezPageCount;
-}
-
-// ------------------------------------------------------------------------------
-
-function ezStartPageNumbers($x,$y,$size,$pos='left',$pattern='{PAGENUM} of {TOTALPAGENUM}',$num=''){
-  // put page numbers on the pages from here.
-  // place then on the 'pos' side of the coordinates (x,y).
-  // pos can be 'left' or 'right'
-  // use the given 'pattern' for display, where (PAGENUM} and {TOTALPAGENUM} are replaced
-  // as required.
-  // if $num is set, then make the first page this number, the number of total pages will
-  // be adjusted to account for this.
-  // Adjust this function so that each time you 'start' page numbers then you effectively start a different batch
-  // return the number of the batch, so that they can be stopped in a different order if required.
-  if (!$pos || !strlen($pos)){
-    $pos='left';
-  }
-  if (!$pattern || !strlen($pattern)){
-    $pattern='{PAGENUM} of {TOTALPAGENUM}';
-  }
-  if (!isset($this->ez['pageNumbering'])){
-    $this->ez['pageNumbering']=array();
-  }
-  $i = count($this->ez['pageNumbering']);
-  $this->ez['pageNumbering'][$i][$this->ezPageCount]=array('x'=>$x,'y'=>$y,'pos'=>$pos,'pattern'=>$pattern,'num'=>$num,'size'=>$size);
-  return $i;
-}
-
-// ------------------------------------------------------------------------------
-
-function ezWhatPageNumber($pageNum,$i=0){
-  // given a particular generic page number (ie, document numbered sequentially from beginning),
-  // return the page number under a particular page numbering scheme ($i)
-  $num=0;
-  $start=1;
-  $startNum=1;
-  if (!isset($this->ez['pageNumbering']))
-  {
-    $this->addMessage('WARNING: page numbering called for and wasn\'t started with ezStartPageNumbers');
-    return 0;
-  }
-  foreach($this->ez['pageNumbering'][$i] as $k=>$v){
-    if ($k<=$pageNum){
-      if (is_array($v)){
-        // start block
-        if (strlen($v['num'])){
-          // a start was specified
-          $start=$v['num'];
-          $startNum=$k;
-          $num=$pageNum-$startNum+$start;
-        }
-      } else {
-        // stop block
-        $num=0;
-      }
-    }
-  }
-  return $num;
-}
-
-// ------------------------------------------------------------------------------
-
-function ezStopPageNumbers($stopTotal=0,$next=0,$i=0){
-  // if stopTotal=1 then the totalling of pages for this number will stop too
-  // if $next=1, then do this page, but not the next, else do not do this page either
-  // if $i is set, then stop that particular pagenumbering sequence.
-  if (!isset($this->ez['pageNumbering'])){
-    $this->ez['pageNumbering']=array();
-  }
-  if ($next && isset($this->ez['pageNumbering'][$i][$this->ezPageCount]) && is_array($this->ez['pageNumbering'][$i][$this->ezPageCount])){
-    // then this has only just been started, this will over-write the start, and nothing will appear
-    // add a special command to the start block, telling it to stop as well
-    if ($stopTotal){
-      $this->ez['pageNumbering'][$i][$this->ezPageCount]['stoptn']=1;
-    } else {
-      $this->ez['pageNumbering'][$i][$this->ezPageCount]['stopn']=1;
-    }
-  } else {
-    if ($stopTotal){
-      $this->ez['pageNumbering'][$i][$this->ezPageCount]='stopt';
-    } else {
-      $this->ez['pageNumbering'][$i][$this->ezPageCount]='stop';
-    }
-    if ($next){
-      $this->ez['pageNumbering'][$i][$this->ezPageCount].='n';
-    }
-  }
-}
-
-// ------------------------------------------------------------------------------
-
-function ezPRVTpageNumberSearch($lbl,&$tmp){
-  foreach($tmp as $i=>$v){
-    if (is_array($v)){
-      if (isset($v[$lbl])){
-        return $i;
-      }
-    } else {
-      if ($v==$lbl){
-        return $i;
-      }
-    }
-  }
-  return 0;
-}
-
-// ------------------------------------------------------------------------------
-
-function ezPRVTaddPageNumbers(){
-  // this will go through the pageNumbering array and add the page numbers are required
-  if (isset($this->ez['pageNumbering'])){
-    $totalPages1 = $this->ezPageCount;
-    $tmp1=$this->ez['pageNumbering'];
-    $status=0;
-    foreach($tmp1 as $i=>$tmp){
-      // do each of the page numbering systems
-      // firstly, find the total pages for this one
-      $k = $this->ezPRVTpageNumberSearch('stopt',$tmp);
-      if ($k && $k>0){
-        $totalPages = $k-1;
-      } else {
-        $l = $this->ezPRVTpageNumberSearch('stoptn',$tmp);
-        if ($l && $l>0){
-          $totalPages = $l;
-        } else {
-          $totalPages = $totalPages1;
-        }
-      }
-      foreach ($this->ezPages as $pageNum=>$id){
-        if (isset($tmp[$pageNum])){
-          if (is_array($tmp[$pageNum])){
-            // then this must be starting page numbers
-            $status=1;
-            $info = $tmp[$pageNum];
-            $info['dnum']=$info['num']-$pageNum;
-            // also check for the special case of the numbering stopping and starting on the same page
-            if (isset($info['stopn']) || isset($info['stoptn']) ){
-              $status=2;
-            }
-          } else if ($tmp[$pageNum]=='stop' || $tmp[$pageNum]=='stopt'){
-            // then we are stopping page numbers
-            $status=0;
-          } else if ($status==1 && ($tmp[$pageNum]=='stoptn' || $tmp[$pageNum]=='stopn')){
-            // then we are stopping page numbers
-            $status=2;
-          }
-        }
-        if ($status){
-          // then add the page numbering to this page
-          if (strlen($info['num'])){
-            $num=$pageNum+$info['dnum'];
-          } else {
-            $num=$pageNum;
-          }
-          $total = $totalPages+$num-$pageNum;
-          $pat = str_replace('{PAGENUM}',$num,$info['pattern']);
-          $pat = str_replace('{TOTALPAGENUM}',$total,$pat);
-          $this->reopenObject($id);
-          switch($info['pos']){
-            case 'right':
-              $this->addText($info['x'],$info['y'],$info['size'],$pat);
-              break;
-            default:
-              $w=$this->getTextWidth($info['size'],$pat);
-              $this->addText($info['x']-$w,$info['y'],$info['size'],$pat);
-              break;
-          }
-          $this->closeObject();
-        }
-        if ($status==2){
-          $status=0;
-        }
-      }
-    }
-  }
-}
-
-// ------------------------------------------------------------------------------
-
-function ezPRVTcleanUp(){
-  $this->ezPRVTaddPageNumbers();
-}
-
-// ------------------------------------------------------------------------------
-
-function ezStream($options=''){
-  $this->ezPRVTcleanUp();
-  $this->stream($options);
-}
-
-// ------------------------------------------------------------------------------
-
-function ezOutput($options=0){
-  $this->ezPRVTcleanUp();
-  return $this->output($options);
-}
-
-// ------------------------------------------------------------------------------
-
-function ezSetY($y){
-  // used to change the vertical position of the writing point.
-  $this->y = $y;
-  if ( $this->y < $this->ez['bottomMargin']){
-    // then make a new page
-    $this->ezNewPage();
-  }
-}
-
-// ------------------------------------------------------------------------------
-
-function ezSetDy($dy,$mod=''){
-  // used to change the vertical position of the writing point.
-  // changes up by a positive increment, so enter a negative number to go
-  // down the page
-  // if $mod is set to 'makeSpace' and a new page is forced, then the pointed will be moved 
-  // down on the new page, this will allow space to be reserved for graphics etc.
-  $this->y += $dy;
-  if ( $this->y < $this->ez['bottomMargin']){
-    // then make a new page
-    $this->ezNewPage();
-    if ($mod=='makeSpace'){
-      $this->y += $dy;
-    }
-  }
-}
-
-// ------------------------------------------------------------------------------
-
-function ezPrvtTableDrawLines($pos,$gap,$x0,$x1,$y0,$y1,$y2,$col,$inner,$outer,$opt=1){
-  $x0=1000;
-  $x1=0;
-  $this->setStrokeColor($col[0],$col[1],$col[2]);
-  $cnt=0;
-  $n = count($pos);
-  foreach($pos as $x){
-    $cnt++;
-    if ($cnt==1 || $cnt==$n){
-      $this->setLineStyle($outer);
-    } else {
-      $this->setLineStyle($inner);
-    }
-    $this->line($x-$gap/2,$y0,$x-$gap/2,$y2);
-    if ($x>$x1){ $x1=$x; };
-    if ($x<$x0){ $x0=$x; };
-  }
-  $this->setLineStyle($outer);
-  $this->line($x0-$gap/2-$outer/2,$y0,$x1-$gap/2+$outer/2,$y0);
-  // only do the second line if it is different to the first, AND each row does not have
-  // a line on it.
-  if ($y0!=$y1 && $opt<2){
-    $this->line($x0-$gap/2,$y1,$x1-$gap/2,$y1);
-  }
-  $this->line($x0-$gap/2-$outer/2,$y2,$x1-$gap/2+$outer/2,$y2);
-}
-
-// ------------------------------------------------------------------------------
-
-function ezPrvtTableColumnHeadings($cols,$pos,$maxWidth,$height,$decender,$gap,$size,&$y,$optionsAll=array()){
-  // uses ezText to add the text, and returns the height taken by the largest heading
-  // this page will move the headings to a new page if they will not fit completely on this one
-  // transaction support will be used to implement this
-
-  if (isset($optionsAll['cols'])){
-    $options = $optionsAll['cols'];
-  } else {
-    $options = array();
-  }
-  
-  $mx=0;
-  $startPage = $this->ezPageCount;
-  $secondGo=0;
-
-  // $y is the position at which the top of the table should start, so the base
-  // of the first text, is $y-$height-$gap-$decender, but ezText starts by dropping $height
-  
-  // the return from this function is the total cell height, including gaps, and $y is adjusted
-  // to be the postion of the bottom line
-  
-  // begin the transaction
-  $this->transaction('start');
-  $ok=0;
-//  $y-=$gap-$decender;
-  $y-=$gap;
-  while ($ok==0){
-    foreach($cols as $colName=>$colHeading){
-      $this->ezSetY($y);
-      if (isset($options[$colName]) && isset($options[$colName]['justification'])){
-        $justification = $options[$colName]['justification'];
-      } else {
-        $justification = 'left';
-      }
-      $this->ezText($colHeading,$size,array('aleft'=> $pos[$colName],'aright'=>($maxWidth[$colName]+$pos[$colName]),'justification'=>$justification));
-      $dy = $y-$this->y;
-      if ($dy>$mx){
-        $mx=$dy;
-      }
-    }
-    $y = $y - $mx - $gap + $decender;
-//    $y -= $mx-$gap+$decender;
-    
-    // now, if this has moved to a new page, then abort the transaction, move to a new page, and put it there
-    // do not check on the second time around, to avoid an infinite loop
-    if ($this->ezPageCount != $startPage && $secondGo==0){
-      $this->transaction('rewind');
-      $this->ezNewPage();
-      $y = $this->y - $gap-$decender;
-      $ok=0;
-      $secondGo=1;
-//      $y = $store_y;
-      $mx=0;
-
-    } else {
-      $this->transaction('commit');
-      $ok=1;
-    }
-  }
-
-  return $mx+$gap*2-$decender;
-}
-
-// ------------------------------------------------------------------------------
-
-function ezPrvtGetTextWidth($size,$text){
-  // will calculate the maximum width, taking into account that the text may be broken
-  // by line breaks.
-  $mx=0;
-  $lines = explode("\n",$text);
-  foreach ($lines as $line){
-    $w = $this->getTextWidth($size,$line);
-    if ($w>$mx){
-      $mx=$w;
-    }
-  }
-  return $mx;
-}
-
-// ------------------------------------------------------------------------------
-
-function ezTable(&$data,$cols='',$title='',$options=''){
-  // add a table of information to the pdf document
-  // $data is a two dimensional array
-  // $cols (optional) is an associative array, the keys are the names of the columns from $data
-  // to be presented (and in that order), the values are the titles to be given to the columns
-  // $title (optional) is the title to be put on the top of the table
-  //
-  // $options is an associative array which can contain:
-  // 'showLines'=> 0,1,2, default is 1 (show outside and top lines only), 2=> lines on each row
-  // 'showHeadings' => 0 or 1
-  // 'shaded'=> 0,1,2,3 default is 1 (1->alternate lines are shaded, 0->no shading, 2-> both shaded, second uses shadeCol2)
-  // 'shadeCol' => (r,g,b) array, defining the colour of the shading, default is (0.8,0.8,0.8)
-  // 'shadeCol2' => (r,g,b) array, defining the colour of the shading of the other blocks, default is (0.7,0.7,0.7)
-  // 'fontSize' => 10
-  // 'textCol' => (r,g,b) array, text colour
-  // 'titleFontSize' => 12
-  // 'rowGap' => 2 , the space added at the top and bottom of each row, between the text and the lines
-  // 'colGap' => 5 , the space on the left and right sides of each cell
-  // 'lineCol' => (r,g,b) array, defining the colour of the lines, default, black.
-  // 'xPos' => 'left','right','center','centre',or coordinate, reference coordinate in the x-direction
-  // 'xOrientation' => 'left','right','center','centre', position of the table w.r.t 'xPos' 
-  // 'width'=> <number> which will specify the width of the table, if it turns out to not be this
-  //    wide, then it will stretch the table to fit, if it is wider then each cell will be made
-  //    proportionalty smaller, and the content may have to wrap.
-  // 'maxWidth'=> <number> similar to 'width', but will only make table smaller than it wants to be
-  // 'options' => array(<colname>=>array('justification'=>'left','width'=>100,'link'=>linkDataName),<colname>=>....)
-  //             allow the setting of other paramaters for the individual columns
-  // 'minRowSpace'=> the minimum space between the bottom of each row and the bottom margin, in which a new row will be started
-  //                  if it is less, then a new page would be started, default=-100
-  // 'innerLineThickness'=>1
-  // 'outerLineThickness'=>1
-  // 'splitRows'=>0, 0 or 1, whether or not to allow the rows to be split across page boundaries
-  // 'protectRows'=>number, the number of rows to hold with the heading on page, ie, if there less than this number of
-  //                rows on the page, then move the whole lot onto the next page, default=1
-  //
-  // note that the user will have had to make a font selection already or this will not 
-  // produce a valid pdf file.
-  
-  if (!is_array($data)){
-    return;
-  }
-  
-  if (!is_array($cols)){
-    // take the columns from the first row of the data set
-    reset($data);
-    list($k,$v)=each($data);
-    if (!is_array($v)){
-      return;
-    }
-    $cols=array();
-    foreach($v as $k1=>$v1){
-      $cols[$k1]=$k1;
-    }
-  }
-  
-  if (!is_array($options)){
-    $options=array();
-  }
-
-  $defaults = array(
-    'shaded'=>1,'showLines'=>1,'shadeCol'=>array(0.8,0.8,0.8),'shadeCol2'=>array(0.7,0.7,0.7),'fontSize'=>10,'titleFontSize'=>12
-    ,'titleGap'=>5,'lineCol'=>array(0,0,0),'gap'=>5,'xPos'=>'centre','xOrientation'=>'centre'
-    ,'showHeadings'=>1,'textCol'=>array(0,0,0),'width'=>0,'maxWidth'=>0,'cols'=>array(),'minRowSpace'=>-100,'rowGap'=>2,'colGap'=>5
-    ,'innerLineThickness'=>1,'outerLineThickness'=>1,'splitRows'=>0,'protectRows'=>1
-    );
-
-  foreach($defaults as $key=>$value){
-    if (is_array($value)){
-      if (!isset($options[$key]) || !is_array($options[$key])){
-        $options[$key]=$value;
-      }
-    } else {
-      if (!isset($options[$key])){
-        $options[$key]=$value;
-      }
-    }
-  }
-  $options['gap']=2*$options['colGap'];
-  
-  $middle = ($this->ez['pageWidth']-$this->ez['rightMargin'])/2+($this->ez['leftMargin'])/2;
-  // figure out the maximum widths of the text within each column
-  $maxWidth=array();
-  foreach($cols as $colName=>$colHeading){
-    $maxWidth[$colName]=0;
-  }
-  // find the maximum cell widths based on the data
-  foreach($data as $row){
-    foreach($cols as $colName=>$colHeading){
-      $w = $this->ezPrvtGetTextWidth($options['fontSize'],(string)$row[$colName])*1.01;
-      if ($w > $maxWidth[$colName]){
-        $maxWidth[$colName]=$w;
-      }
-    }
-  }
-  // and the maximum widths to fit in the headings
-  foreach($cols as $colName=>$colTitle){
-    $w = $this->ezPrvtGetTextWidth($options['fontSize'],(string)$colTitle)*1.01;
-    if ($w > $maxWidth[$colName]){
-      $maxWidth[$colName]=$w;
-    }
-  }
-  
-  // calculate the start positions of each of the columns
-  $pos=array();
-  $x=0;
-  $t=$x;
-  $adjustmentWidth=0;
-  $setWidth=0;
-  foreach($maxWidth as $colName => $w){
-    $pos[$colName]=$t;
-    // if the column width has been specified then set that here, also total the
-    // width avaliable for adjustment
-    if (isset($options['cols'][$colName]) && isset($options['cols'][$colName]['width']) && $options['cols'][$colName]['width']>0){
-      $t=$t+$options['cols'][$colName]['width'];
-      $maxWidth[$colName] = $options['cols'][$colName]['width']-$options['gap'];
-      $setWidth += $options['cols'][$colName]['width'];
-    } else {
-      $t=$t+$w+$options['gap'];
-      $adjustmentWidth += $w;
-      $setWidth += $options['gap'];
-    }
-  }
-  $pos['_end_']=$t;
-
-  // if maxWidth is specified, and the table is too wide, and the width has not been set,
-  // then set the width.
-  if ($options['width']==0 && $options['maxWidth'] && ($t-$x)>$options['maxWidth']){
-    // then need to make this one smaller
-    $options['width']=$options['maxWidth'];
-  }
-
-  if ($options['width'] && $adjustmentWidth>0 && $setWidth<$options['width']){
-    // first find the current widths of the columns involved in this mystery
-    $cols0 = array();
-    $cols1 = array();
-    $xq=0;
-    $presentWidth=0;
-    $last='';
-    foreach($pos as $colName=>$p){
-      if (!isset($options['cols'][$last]) || !isset($options['cols'][$last]['width']) || $options['cols'][$last]['width']<=0){
-        if (strlen($last)){
-          $cols0[$last]=$p-$xq -$options['gap'];
-          $presentWidth += ($p-$xq - $options['gap']);
-        }
-      } else {
-        $cols1[$last]=$p-$xq;
-      }
-      $last=$colName;
-      $xq=$p;
-    }
-    // $cols0 contains the widths of all the columns which are not set
-    $neededWidth = $options['width']-$setWidth;
-    // if needed width is negative then add it equally to each column, else get more tricky
-    if ($presentWidth<$neededWidth){
-      foreach($cols0 as $colName=>$w){
-        $cols0[$colName]+= ($neededWidth-$presentWidth)/count($cols0);
-      }
-    } else {
-    
-      $cnt=0;
-      while ($presentWidth>$neededWidth && $cnt<100){
-        $cnt++; // insurance policy
-        // find the widest columns, and the next to widest width
-        $aWidest = array();
-        $nWidest=0;
-        $widest=0;
-        foreach($cols0 as $colName=>$w){
-          if ($w>$widest){
-            $aWidest=array($colName);
-            $nWidest = $widest;
-            $widest=$w;
-          } else if ($w==$widest){
-            $aWidest[]=$colName;
-          }
-        }
-        // then figure out what the width of the widest columns would have to be to take up all the slack
-        $newWidestWidth = $widest - ($presentWidth-$neededWidth)/count($aWidest);
-        if ($newWidestWidth > $nWidest){
-          // then there is space to set them to this
-          foreach($aWidest as $colName){
-            $cols0[$colName] = $newWidestWidth;
-          }
-          $presentWidth=$neededWidth;
-        } else {
-          // there is not space, reduce the size of the widest ones down to the next size down, and we
-          // will go round again
-          foreach($aWidest as $colName){
-            $cols0[$colName] = $nWidest;
-          }
-          $presentWidth=$presentWidth-($widest-$nWidest)*count($aWidest);
-        }
-      }
-    }
-    // $cols0 now contains the new widths of the constrained columns.
-    // now need to update the $pos and $maxWidth arrays
-    $xq=0;
-    foreach($pos as $colName=>$p){
-      $pos[$colName]=$xq;
-      if (!isset($options['cols'][$colName]) || !isset($options['cols'][$colName]['width']) || $options['cols'][$colName]['width']<=0){
-        if (isset($cols0[$colName])){
-          $xq += $cols0[$colName] + $options['gap'];
-          $maxWidth[$colName]=$cols0[$colName];
-        }
-      } else {
-        if (isset($cols1[$colName])){
-          $xq += $cols1[$colName];
-        }
-      }
-    }
-
-    $t=$x+$options['width'];
-    $pos['_end_']=$t;
-  }
-
-  // now adjust the table to the correct location across the page
-  switch ($options['xPos']){
-    case 'left':
-      $xref = $this->ez['leftMargin'];
-      break;
-    case 'right':
-      $xref = $this->ez['pageWidth'] - $this->ez['rightMargin'];
-      break;
-    case 'centre':
-    case 'center':
-      $xref = $middle;
-      break;
-    default:
-      $xref = $options['xPos'];
-      break;
-  }
-  switch ($options['xOrientation']){
-    case 'left':
-      $dx = $xref-$t;
-      break;
-    case 'right':
-      $dx = $xref;
-      break;
-    case 'centre':
-    case 'center':
-      $dx = $xref-$t/2;
-      break;
-  }
-
-
-  foreach($pos as $k=>$v){
-    $pos[$k]=$v+$dx;
-  }
-  $x0=$x+$dx;
-  $x1=$t+$dx;
-
-  $baseLeftMargin = $this->ez['leftMargin'];
-  $basePos = $pos;
-  $baseX0 = $x0;
-  $baseX1 = $x1;
-  
-  // ok, just about ready to make me a table
-  $this->setColor($options['textCol'][0],$options['textCol'][1],$options['textCol'][2]);
-  $this->setStrokeColor($options['shadeCol'][0],$options['shadeCol'][1],$options['shadeCol'][2]);
-
-  $middle = ($x1+$x0)/2;
-
-  // start a transaction which will be used to regress the table, if there are not enough rows protected
-  if ($options['protectRows']>0){
-    $this->transaction('start');
-    $movedOnce=0;
-  }
-  $abortTable = 1;
-  while ($abortTable){
-  $abortTable=0;
-
-  $dm = $this->ez['leftMargin']-$baseLeftMargin;
-  foreach($basePos as $k=>$v){
-    $pos[$k]=$v+$dm;
-  }
-  $x0=$baseX0+$dm;
-  $x1=$baseX1+$dm;
-  $middle = ($x1+$x0)/2;
-
-
-  // if the title is set, then do that
-  if (strlen($title)){
-    $w = $this->getTextWidth($options['titleFontSize'],$title);
-    $this->y -= $this->getFontHeight($options['titleFontSize']);
-    if ($this->y < $this->ez['bottomMargin']){
-      $this->ezNewPage();
-        // margins may have changed on the newpage
-        $dm = $this->ez['leftMargin']-$baseLeftMargin;
-        foreach($basePos as $k=>$v){
-          $pos[$k]=$v+$dm;
-        }
-        $x0=$baseX0+$dm;
-        $x1=$baseX1+$dm;
-        $middle = ($x1+$x0)/2;
-      $this->y -= $this->getFontHeight($options['titleFontSize']);
-    }
-    $this->addText($middle-$w/2,$this->y,$options['titleFontSize'],$title);
-    $this->y -= $options['titleGap'];
-  }
-
-        // margins may have changed on the newpage
-        $dm = $this->ez['leftMargin']-$baseLeftMargin;
-        foreach($basePos as $k=>$v){
-          $pos[$k]=$v+$dm;
-        }
-        $x0=$baseX0+$dm;
-        $x1=$baseX1+$dm;
-  
-  $y=$this->y; // to simplify the code a bit
-  
-  // make the table
-  $height = $this->getFontHeight($options['fontSize']);
-  $decender = $this->getFontDecender($options['fontSize']);
-
-  
-  
-  $y0=$y+$decender;
-  $dy=0;
-  if ($options['showHeadings']){
-    // this function will move the start of the table to a new page if it does not fit on this one
-    $headingHeight = $this->ezPrvtTableColumnHeadings($cols,$pos,$maxWidth,$height,$decender,$options['rowGap'],$options['fontSize'],$y,$options);
-    $y0 = $y+$headingHeight;
-    $y1 = $y;
-
-
-    $dm = $this->ez['leftMargin']-$baseLeftMargin;
-    foreach($basePos as $k=>$v){
-      $pos[$k]=$v+$dm;
-    }
-    $x0=$baseX0+$dm;
-    $x1=$baseX1+$dm;
-
-  } else {
-    $y1 = $y0;
-  }
-  $firstLine=1;
-
-  
-  // open an object here so that the text can be put in over the shading
-  if ($options['shaded']){
-    $this->saveState();
-    $textObjectId = $this->openObject();
-    $this->closeObject();
-    $this->addObject($textObjectId);
-    $this->reopenObject($textObjectId);
-  }
-  
-  $cnt=0;
-  $newPage=0;
-  foreach($data as $row){
-    $cnt++;
-    // the transaction support will be used to prevent rows being split
-    if ($options['splitRows']==0){
-      $pageStart = $this->ezPageCount;
-      if (isset($this->ez['columns']) && $this->ez['columns']['on']==1){
-        $columnStart = $this->ez['columns']['colNum'];
-      }
-      $this->transaction('start');
-      $row_orig = $row;
-      $y_orig = $y;
-      $y0_orig = $y0;
-      $y1_orig = $y1;
-    }
-    $ok=0;
-    $secondTurn=0;
-    while(!$abortTable && $ok == 0){
-
-    $mx=0;
-    $newRow=1;
-    while(!$abortTable && ($newPage || $newRow)){
-      
-      $y-=$height;
-      if ($newPage || $y<$this->ez['bottomMargin'] || (isset($options['minRowSpace']) && $y<($this->ez['bottomMargin']+$options['minRowSpace'])) ){
-        // check that enough rows are with the heading
-        if ($options['protectRows']>0 && $movedOnce==0 && $cnt<=$options['protectRows']){
-          // then we need to move the whole table onto the next page
-          $movedOnce = 1;
-          $abortTable = 1;
-        }
-      
-        $y2=$y-$mx+2*$height+$decender-$newRow*$height;
-        if ($options['showLines']){
-          if (!$options['showHeadings']){
-            $y0=$y1;
-          }
-          $this->ezPrvtTableDrawLines($pos,$options['gap'],$x0,$x1,$y0,$y1,$y2,$options['lineCol'],$options['innerLineThickness'],$options['outerLineThickness'],$options['showLines']);
-        }
-        if ($options['shaded']){
-          $this->closeObject();
-          $this->restoreState();
-        }
-        $this->ezNewPage();
-        // and the margins may have changed, this is due to the possibility of the columns being turned on
-        // as the columns are managed by manipulating the margins
-
-        $dm = $this->ez['leftMargin']-$baseLeftMargin;
-        foreach($basePos as $k=>$v){
-          $pos[$k]=$v+$dm;
-        }
-//        $x0=$x0+$dm;
-//        $x1=$x1+$dm;
-        $x0=$baseX0+$dm;
-        $x1=$baseX1+$dm;
-  
-        if ($options['shaded']){
-          $this->saveState();
-          $textObjectId = $this->openObject();
-          $this->closeObject();
-          $this->addObject($textObjectId);
-          $this->reopenObject($textObjectId);
-        }
-        $this->setColor($options['textCol'][0],$options['textCol'][1],$options['textCol'][2],1);
-        $y = $this->ez['pageHeight']-$this->ez['topMargin'];
-        $y0=$y+$decender;
-        $mx=0;
-        if ($options['showHeadings']){
-          $this->ezPrvtTableColumnHeadings($cols,$pos,$maxWidth,$height,$decender,$options['rowGap'],$options['fontSize'],$y,$options);
-          $y1=$y;
-        } else {
-          $y1=$y0;
-        }
-        $firstLine=1;
-        $y -= $height;
-      }
-      $newRow=0;
-      // write the actual data
-      // if these cells need to be split over a page, then $newPage will be set, and the remaining
-      // text will be placed in $leftOvers
-      $newPage=0;
-      $leftOvers=array();
-
-      foreach($cols as $colName=>$colTitle){
-        $this->ezSetY($y+$height);
-        $colNewPage=0;
-        if (isset($row[$colName])){
-          if (isset($options['cols'][$colName]) && isset($options['cols'][$colName]['link']) && strlen($options['cols'][$colName]['link'])){
-            
-            $lines = explode("\n",$row[$colName]);
-            if (isset($row[$options['cols'][$colName]['link']]) && strlen($row[$options['cols'][$colName]['link']])){
-              foreach($lines as $k=>$v){
-                $lines[$k]='<c:alink:'.$row[$options['cols'][$colName]['link']].'>'.$v.'</c:alink>';
-              }
-            }
-          } else {
-            $lines = explode("\n",$row[$colName]);
-          }
-        } else {
-          $lines = array();
-        }
-        $this->y -= $options['rowGap'];
-        foreach ($lines as $line){
-          $line = $this->ezProcessText($line);
-          $start=1;
-
-          while (strlen($line) || $start){
-            $start=0;
-            if (!$colNewPage){
-              $this->y=$this->y-$height;
-            }
-            if ($this->y < $this->ez['bottomMargin']){
-  //            $this->ezNewPage();
-              $newPage=1;  // whether a new page is required for any of the columns
-              $colNewPage=1; // whether a new page is required for this column
-            }
-            if ($colNewPage){
-              if (isset($leftOvers[$colName])){
-                $leftOvers[$colName].="\n".$line;
-              } else {
-                $leftOvers[$colName] = $line;
-              }
-              $line='';
-            } else {
-              if (isset($options['cols'][$colName]) && isset($options['cols'][$colName]['justification']) ){
-                $just = $options['cols'][$colName]['justification'];
-              } else {
-                $just='left';
-              }
-
-              $line=$this->addTextWrap($pos[$colName],$this->y,$maxWidth[$colName],$options['fontSize'],$line,$just);
-            }
-          }
-        }
-  
-        $dy=$y+$height-$this->y+$options['rowGap'];
-        if ($dy-$height*$newPage>$mx){
-          $mx=$dy-$height*$newPage;
-        }
-      }
-      // set $row to $leftOvers so that they will be processed onto the new page
-      $row = $leftOvers;
-      // now add the shading underneath
-      if ($options['shaded'] && $cnt%2==0){
-        $this->closeObject();
-        $this->setColor($options['shadeCol'][0],$options['shadeCol'][1],$options['shadeCol'][2],1);
-        $this->filledRectangle($x0-$options['gap']/2,$y+$decender+$height-$mx,$x1-$x0,$mx);
-        $this->reopenObject($textObjectId);
-      }
-
-      if ($options['shaded']==2 && $cnt%2==1){
-        $this->closeObject();
-        $this->setColor($options['shadeCol2'][0],$options['shadeCol2'][1],$options['shadeCol2'][2],1);
-        $this->filledRectangle($x0-$options['gap']/2,$y+$decender+$height-$mx,$x1-$x0,$mx);
-        $this->reopenObject($textObjectId);
-      }
-
-      if ($options['showLines']>1){
-        // then draw a line on the top of each block
-//        $this->closeObject();
-        $this->saveState();
-        $this->setStrokeColor($options['lineCol'][0],$options['lineCol'][1],$options['lineCol'][2],1);
-//        $this->line($x0-$options['gap']/2,$y+$decender+$height-$mx,$x1-$x0,$mx);
-        if ($firstLine){
-          $this->setLineStyle($options['outerLineThickness']);
-          $firstLine=0;
-        } else {
-          $this->setLineStyle($options['innerLineThickness']);
-        }
-        $this->line($x0-$options['gap']/2,$y+$decender+$height,$x1-$options['gap']/2,$y+$decender+$height);
-        $this->restoreState();
-//        $this->reopenObject($textObjectId);
-      }
-    } // end of while 
-    $y=$y-$mx+$height;
-    
-    // checking row split over pages
-    if ($options['splitRows']==0){
-      if ( ( ($this->ezPageCount != $pageStart) || (isset($this->ez['columns']) && $this->ez['columns']['on']==1 && $columnStart != $this->ez['columns']['colNum'] ))  && $secondTurn==0){
-        // then we need to go back and try that again !
-        $newPage=1;
-        $secondTurn=1;
-        $this->transaction('rewind');
-        $row = $row_orig;
-        $y = $y_orig;
-        $y0 = $y0_orig;
-        $y1 = $y1_orig;
-        $ok=0;
-
-        $dm = $this->ez['leftMargin']-$baseLeftMargin;
-        foreach($basePos as $k=>$v){
-          $pos[$k]=$v+$dm;
-        }
-        $x0=$baseX0+$dm;
-        $x1=$baseX1+$dm;
-
-      } else {
-        $this->transaction('commit');
-        $ok=1;
-      }
-    } else {
-      $ok=1;  // don't go round the loop if splitting rows is allowed
-    }
-    
-    }  // end of while to check for row splitting
-    if ($abortTable){
-      if ($ok==0){
-        $this->transaction('abort');
-      }
-      // only the outer transaction should be operational
-      $this->transaction('rewind');
-      $this->ezNewPage();
-      break;
-    }
-    
-  } // end of foreach ($data as $row)
-  
-  } // end of while ($abortTable)
-
-  // table has been put on the page, the rows guarded as required, commit.
-  $this->transaction('commit');
-
-  $y2=$y+$decender;
-  if ($options['showLines']){
-    if (!$options['showHeadings']){
-      $y0=$y1;
-    }
-    $this->ezPrvtTableDrawLines($pos,$options['gap'],$x0,$x1,$y0,$y1,$y2,$options['lineCol'],$options['innerLineThickness'],$options['outerLineThickness'],$options['showLines']);
-  }
-
-  // close the object for drawing the text on top
-  if ($options['shaded']){
-    $this->closeObject();
-    $this->restoreState();
-  }
-  
-  $this->y=$y;
-  return $y;
-}
-
-// ------------------------------------------------------------------------------
-function ezProcessText($text){
-  // this function will intially be used to implement underlining support, but could be used for a range of other
-  // purposes
-  $search = array('<u>','<U>','</u>','</U>');
-  $replace = array('<c:uline>','<c:uline>','</c:uline>','</c:uline>');
-  return str_replace($search,$replace,$text);
-}
-
-// ------------------------------------------------------------------------------
-
-function ezText($text,$size=0,$options=array(),$test=0){
-  // this will add a string of text to the document, starting at the current drawing
-  // position.
-  // it will wrap to keep within the margins, including optional offsets from the left
-  // and the right, if $size is not specified, then it will be the last one used, or
-  // the default value (12 I think).
-  // the text will go to the start of the next line when a return code "\n" is found.
-  // possible options are:
-  // 'left'=> number, gap to leave from the left margin
-  // 'right'=> number, gap to leave from the right margin
-  // 'aleft'=> number, absolute left position (overrides 'left')
-  // 'aright'=> number, absolute right position (overrides 'right')
-  // 'justification' => 'left','right','center','centre','full'
-
-  // only set one of the next two items (leading overrides spacing)
-  // 'leading' => number, defines the total height taken by the line, independent of the font height.
-  // 'spacing' => a real number, though usually set to one of 1, 1.5, 2 (line spacing as used in word processing)
-  
-  // if $test is set then this should just check if the text is going to flow onto a new page or not, returning true or false
-  
-  // apply the filtering which will make the underlining function.
-  $text = $this->ezProcessText($text);
-  
-  $newPage=false;
-  $store_y = $this->y;
-  
-  if (is_array($options) && isset($options['aleft'])){
-    $left=$options['aleft'];
-  } else {
-    $left = $this->ez['leftMargin'] + ((is_array($options) && isset($options['left']))?$options['left']:0);
-  }
-  if (is_array($options) && isset($options['aright'])){
-    $right=$options['aright'];
-  } else {
-    $right = $this->ez['pageWidth'] - $this->ez['rightMargin'] - ((is_array($options) && isset($options['right']))?$options['right']:0);
-  }
-  if ($size<=0){
-    $size = $this->ez['fontSize'];
-  } else {
-    $this->ez['fontSize']=$size;
-  }
-  
-  if (is_array($options) && isset($options['justification'])){
-    $just = $options['justification'];
-  } else {
-    $just = 'left';
-  }
-  
-  // modifications to give leading and spacing based on those given by Craig Heydenburg 1/1/02
-  if (is_array($options) && isset($options['leading'])) { ## use leading instead of spacing
-    $height = $options['leading'];
-	} else if (is_array($options) && isset($options['spacing'])) {
-    $height = $this->getFontHeight($size) * $options['spacing'];
-	} else {
-		$height = $this->getFontHeight($size);
-	}
-
-  
-  $lines = explode("\n",$text);
-  foreach ($lines as $line){
-    $start=1;
-    while (strlen($line) || $start){
-      $start=0;
-      $this->y=$this->y-$height;
-      if ($this->y < $this->ez['bottomMargin']){
-        if ($test){
-          $newPage=true;
-        } else {
-          $this->ezNewPage();
-          // and then re-calc the left and right, in case they have changed due to columns
-        }
-      }
-      if (is_array($options) && isset($options['aleft'])){
-        $left=$options['aleft'];
-      } else {
-        $left = $this->ez['leftMargin'] + ((is_array($options) && isset($options['left']))?$options['left']:0);
-      }
-      if (is_array($options) && isset($options['aright'])){
-        $right=$options['aright'];
-      } else {
-        $right = $this->ez['pageWidth'] - $this->ez['rightMargin'] - ((is_array($options) && isset($options['right']))?$options['right']:0);
-      }
-      $line=$this->addTextWrap($left,$this->y,$right-$left,$size,$line,$just,0,$test);
-    }
-  }
-
-  if ($test){
-    $this->y=$store_y;
-    return $newPage;
-  } else {
-    return $this->y;
-  }
-}
-
-// ------------------------------------------------------------------------------
-
-function ezImage($image,$pad = 5,$width = 0,$resize = 'full',$just = 'center',$border = ''){
-	//beta ezimage function
-	if (stristr($image,'://'))//copy to temp file
-	{
-		$fp = @fopen($image,"rb");
-		while(!feof($fp))
-   		{
-      			$cont.= fread($fp,1024);
-   		}
-   		fclose($fp);
-		$image = tempnam ("/tmp", "php-pdf");
-		$fp2 = @fopen($image,"w");
-   		fwrite($fp2,$cont);
-  		fclose($fp2);
-		$temp = true;
-	}
-
-	if (!(file_exists($image))) return false; //return immediately if image file does not exist
-	$imageInfo = getimagesize($image);
-	switch ($imageInfo[2]){
-		case 2:
-			$type = "jpeg";
-			break;
-		case 3:
-			$type = "png";
-			break;
-		default:
-			return false; //return if file is not jpg or png
-	}
-	if ($width == 0) $width = $imageInfo[0]; //set width
-	$ratio = $imageInfo[0]/$imageInfo[1];
-
-	//get maximum width of image
-	if (isset($this->ez['columns']) && $this->ez['columns']['on'] == 1)
-	{
-		$bigwidth = $this->ez['columns']['width'] - ($pad * 2);
-	}
-	else
-	{
-		$bigwidth = $this->ez['pageWidth'] - ($pad * 2);
-	}
-	//fix width if larger than maximum or if $resize=full
-	if ($resize == 'full' || $resize == 'width' || $width > $bigwidth)
-	{
-		$width = $bigwidth;
-
-	}
-
-	$height = ($width/$ratio); //set height
-
-	//fix size if runs off page
-	if ($height > ($this->y - $this->ez['bottomMargin'] - ($pad * 2)))
-	{
-		if ($resize != 'full')
-		{
-			$this->ezNewPage();
-		}
-		else
-		{
-			$height = ($this->y - $this->ez['bottomMargin'] - ($pad * 2)); //shrink height
-			$width = ($height*$ratio); //fix width
-		}
-	}
-
-	//fix x-offset if image smaller than bigwidth
-	if ($width < $bigwidth)
-	{
-		//center if justification=center
-		if ($just == 'center')
-		{
-			$offset = ($bigwidth - $width) / 2;
-		}
-		//move to right if justification=right
-		if ($just == 'right')
-		{
-			$offset = ($bigwidth - $width);
-		}
-		//leave at left if justification=left
-		if ($just == 'left')
-		{
-			$offset = 0;
-		}
-	}
-
-
-	//call appropriate function
-	if ($type == "jpeg"){
-		$this->addJpegFromFile($image,$this->ez['leftMargin'] + $pad + $offset, $this->y + $this->getFontHeight($this->ez['fontSize']) - $pad - $height,$width);
-	}
-
-	if ($type == "png"){
-		$this->addPngFromFile($image,$this->ez['leftMargin'] + $pad + $offset, $this->y + $this->getFontHeight($this->ez['fontSize']) - $pad - $height,$width);
-	}
-	//draw border
-	if ($border != '')
-	{
-	if (!(isset($border['color'])))
-	{
-		$border['color']['red'] = .5;
-		$border['color']['blue'] = .5;
-		$border['color']['green'] = .5;
-	}
-	if (!(isset($border['width']))) $border['width'] = 1;
-	if (!(isset($border['cap']))) $border['cap'] = 'round';
-	if (!(isset($border['join']))) $border['join'] = 'round';
-	
-
-	$this->setStrokeColor($border['color']['red'],$border['color']['green'],$border['color']['blue']);
-	$this->setLineStyle($border['width'],$border['cap'],$border['join']);
-	$this->rectangle($this->ez['leftMargin'] + $pad + $offset, $this->y + $this->getFontHeight($this->ez['fontSize']) - $pad - $height,$width,$height);
-
-	}
-	// move y below image
-	$this->y = $this->y - $pad - $height;
-	//remove tempfile for remote images
-	if ($temp == true) unlink($image);
-
-}
-// ------------------------------------------------------------------------------
-
-// note that templating code is still considered developmental - have not really figured
-// out a good way of doing this yet.
-function loadTemplate($templateFile){
-  // this function will load the requested template ($file includes full or relative pathname)
-  // the code for the template will be modified to make it name safe, and then stored in 
-  // an array for later use
-  // The id of the template will be returned for the user to operate on it later
-  if (!file_exists($templateFile)){
-    return -1;
-  }
-
-  $code = implode('',file($templateFile));
-  if (!strlen($code)){
-    return;
-  }
-
-  $code = trim($code);
-  if (substr($code,0,5)=='<?php'){
-    $code = substr($code,5);
-  }
-  if (substr($code,-2)=='?>'){
-    $code = substr($code,0,strlen($code)-2);
-  }
-  if (isset($this->ez['numTemplates'])){
-    $newNum = $this->ez['numTemplates'];
-    $this->ez['numTemplates']++;
-  } else {
-    $newNum=0;
-    $this->ez['numTemplates']=1;
-    $this->ez['templates']=array();
-  }
-
-  $this->ez['templates'][$newNum]['code']=$code;
-
-  return $newNum;
-}
-
-// ------------------------------------------------------------------------------
-
-function execTemplate($id,$data=array(),$options=array()){
-  // execute the given template on the current document.
-  if (!isset($this->ez['templates'][$id])){
-    return;
-  }
-  eval($this->ez['templates'][$id]['code']);
-}
-
-// ------------------------------------------------------------------------------
-function ilink($info){
-  $this->alink($info,1);
-}
-
-function alink($info,$internal=0){
-  // a callback function to support the formation of clickable links within the document
-  $lineFactor=0.05; // the thickness of the line as a proportion of the height. also the drop of the line.
-  switch($info['status']){
-    case 'start':
-    case 'sol':
-      // the beginning of the link
-      // this should contain the URl for the link as the 'p' entry, and will also contain the value of 'nCallback'
-      if (!isset($this->ez['links'])){
-        $this->ez['links']=array();
-      }
-      $i = $info['nCallback'];
-      $this->ez['links'][$i] = array('x'=>$info['x'],'y'=>$info['y'],'angle'=>$info['angle'],'decender'=>$info['decender'],'height'=>$info['height'],'url'=>$info['p']);
-      if ($internal==0){
-        $this->saveState();
-        $this->setColor(0,0,1);
-        $this->setStrokeColor(0,0,1);
-        $thick = $info['height']*$lineFactor;
-        $this->setLineStyle($thick);
-      }
-      break;
-    case 'end':
-    case 'eol':
-      // the end of the link
-      // assume that it is the most recent opening which has closed
-      $i = $info['nCallback'];
-      $start = $this->ez['links'][$i];
-      // add underlining
-      if ($internal){
-        $this->addInternalLink($start['url'],$start['x'],$start['y']+$start['decender'],$info['x'],$start['y']+$start['decender']+$start['height']);
-      } else {
-        $a = deg2rad((float)$start['angle']-90.0);
-        $drop = $start['height']*$lineFactor*1.5;
-        $dropx = cos($a)*$drop;
-        $dropy = -sin($a)*$drop;
-        $this->line($start['x']-$dropx,$start['y']-$dropy,$info['x']-$dropx,$info['y']-$dropy);
-        $this->addLink($start['url'],$start['x'],$start['y']+$start['decender'],$info['x'],$start['y']+$start['decender']+$start['height']);
-        $this->restoreState();
-      }
-      break;
-  }
-}
-
-// ------------------------------------------------------------------------------
-
-function uline($info){
-  // a callback function to support underlining
-  $lineFactor=0.05; // the thickness of the line as a proportion of the height. also the drop of the line.
-  switch($info['status']){
-    case 'start':
-    case 'sol':
-    
-      // the beginning of the underline zone
-      if (!isset($this->ez['links'])){
-        $this->ez['links']=array();
-      }
-      $i = $info['nCallback'];
-      $this->ez['links'][$i] = array('x'=>$info['x'],'y'=>$info['y'],'angle'=>$info['angle'],'decender'=>$info['decender'],'height'=>$info['height']);
-      $this->saveState();
-      $thick = $info['height']*$lineFactor;
-      $this->setLineStyle($thick);
-      break;
-    case 'end':
-    case 'eol':
-      // the end of the link
-      // assume that it is the most recent opening which has closed
-      $i = $info['nCallback'];
-      $start = $this->ez['links'][$i];
-      // add underlining
-      $a = deg2rad((float)$start['angle']-90.0);
-      $drop = $start['height']*$lineFactor*1.5;
-      $dropx = cos($a)*$drop;
-      $dropy = -sin($a)*$drop;
-      $this->line($start['x']-$dropx,$start['y']-$dropy,$info['x']-$dropx,$info['y']-$dropy);
-      $this->restoreState();
-      break;
-  }
-}
-
-// ------------------------------------------------------------------------------
-
-}
+<?php
+
+include_once(dirname(__FILE__).'/class.pdf.php');
+
+class Cezpdf extends Cpdf {
+//==============================================================================
+// this class will take the basic interaction facilities of the Cpdf class
+// and make more useful functions so that the user does not have to 
+// know all the ins and outs of pdf presentation to produce something pretty.
+//
+// IMPORTANT NOTE
+// there is no warranty, implied or otherwise with this software.
+// 
+// version 009 (versioning is linked to class.pdf.php)
+//
+// released under a public domain licence.
+//
+// Wayne Munro, R&OS Ltd, http://www.ros.co.nz/pdf
+//==============================================================================
+
+var $ez=array('fontSize'=>10); // used for storing most of the page configuration parameters
+var $y; // this is the current vertical positon on the page of the writing point, very important
+var $ezPages=array(); // keep an array of the ids of the pages, making it easy to go back and add page numbers etc.
+var $ezPageCount=0;
+
+// ------------------------------------------------------------------------------
+
+function Cezpdf($paper='a4',$orientation='portrait'){
+	// Assuming that people don't want to specify the paper size using the absolute coordinates
+	// allow a couple of options:
+	// orientation can be 'portrait' or 'landscape'
+	// or, to actually set the coordinates, then pass an array in as the first parameter.
+	// the defaults are as shown.
+	// 
+	// -------------------------
+	// 2002-07-24 - Nicola Asuni (info at tecnick.com):
+	// Added new page formats (45 standard ISO paper formats and 4 american common formats)
+	// paper cordinates are calculated in this way: (inches * 72) where 1 inch = 2.54 cm
+	// 
+	// Now you may also pass a 2 values array containing the page width and height in centimeters
+	// -------------------------
+
+	if (!is_array($paper)){
+		switch (strtoupper($paper)){
+			case '4A0': {$size = array(0,0,4767.87,6740.79); break;}
+			case '2A0': {$size = array(0,0,3370.39,4767.87); break;}
+			case 'A0': {$size = array(0,0,2383.94,3370.39); break;}
+			case 'A1': {$size = array(0,0,1683.78,2383.94); break;}
+			case 'A2': {$size = array(0,0,1190.55,1683.78); break;}
+			case 'A3': {$size = array(0,0,841.89,1190.55); break;}
+			case 'A4': default: {$size = array(0,0,595.28,841.89); break;}
+			case 'A5': {$size = array(0,0,419.53,595.28); break;}
+			case 'A6': {$size = array(0,0,297.64,419.53); break;}
+			case 'A7': {$size = array(0,0,209.76,297.64); break;}
+			case 'A8': {$size = array(0,0,147.40,209.76); break;}
+			case 'A9': {$size = array(0,0,104.88,147.40); break;}
+			case 'A10': {$size = array(0,0,73.70,104.88); break;}
+			case 'B0': {$size = array(0,0,2834.65,4008.19); break;}
+			case 'B1': {$size = array(0,0,2004.09,2834.65); break;}
+			case 'B2': {$size = array(0,0,1417.32,2004.09); break;}
+			case 'B3': {$size = array(0,0,1000.63,1417.32); break;}
+			case 'B4': {$size = array(0,0,708.66,1000.63); break;}
+			case 'B5': {$size = array(0,0,498.90,708.66); break;}
+			case 'B6': {$size = array(0,0,354.33,498.90); break;}
+			case 'B7': {$size = array(0,0,249.45,354.33); break;}
+			case 'B8': {$size = array(0,0,175.75,249.45); break;}
+			case 'B9': {$size = array(0,0,124.72,175.75); break;}
+			case 'B10': {$size = array(0,0,87.87,124.72); break;}
+			case 'C0': {$size = array(0,0,2599.37,3676.54); break;}
+			case 'C1': {$size = array(0,0,1836.85,2599.37); break;}
+			case 'C2': {$size = array(0,0,1298.27,1836.85); break;}
+			case 'C3': {$size = array(0,0,918.43,1298.27); break;}
+			case 'C4': {$size = array(0,0,649.13,918.43); break;}
+			case 'C5': {$size = array(0,0,459.21,649.13); break;}
+			case 'C6': {$size = array(0,0,323.15,459.21); break;}
+			case 'C7': {$size = array(0,0,229.61,323.15); break;}
+			case 'C8': {$size = array(0,0,161.57,229.61); break;}
+			case 'C9': {$size = array(0,0,113.39,161.57); break;}
+			case 'C10': {$size = array(0,0,79.37,113.39); break;}
+			case 'RA0': {$size = array(0,0,2437.80,3458.27); break;}
+			case 'RA1': {$size = array(0,0,1729.13,2437.80); break;}
+			case 'RA2': {$size = array(0,0,1218.90,1729.13); break;}
+			case 'RA3': {$size = array(0,0,864.57,1218.90); break;}
+			case 'RA4': {$size = array(0,0,609.45,864.57); break;}
+			case 'SRA0': {$size = array(0,0,2551.18,3628.35); break;}
+			case 'SRA1': {$size = array(0,0,1814.17,2551.18); break;}
+			case 'SRA2': {$size = array(0,0,1275.59,1814.17); break;}
+			case 'SRA3': {$size = array(0,0,907.09,1275.59); break;}
+			case 'SRA4': {$size = array(0,0,637.80,907.09); break;}
+			case 'LETTER': {$size = array(0,0,612.00,792.00); break;}
+			case 'LEGAL': {$size = array(0,0,612.00,1008.00); break;}
+			case 'EXECUTIVE': {$size = array(0,0,521.86,756.00); break;}
+			case 'FOLIO': {$size = array(0,0,612.00,936.00); break;}
+		}
+		switch (strtolower($orientation)){
+			case 'landscape':
+				$a=$size[3];
+				$size[3]=$size[2];
+				$size[2]=$a;
+				break;
+		}
+	} else {
+		if (count($paper)>2) {
+			// then an array was sent it to set the size
+			$size = $paper;
+		}
+		else { //size in centimeters has been passed
+			$size[0] = 0;
+			$size[1] = 0;
+			$size[2] = ( $paper[0] / 2.54 ) * 72;
+			$size[3] = ( $paper[1] / 2.54 ) * 72;
+		}
+	}
+	$this->Cpdf($size);
+	$this->ez['pageWidth']=$size[2];
+	$this->ez['pageHeight']=$size[3];
+	
+	// also set the margins to some reasonable defaults
+	$this->ez['topMargin']=30;
+	$this->ez['bottomMargin']=30;
+	$this->ez['leftMargin']=30;
+	$this->ez['rightMargin']=30;
+	
+	// set the current writing position to the top of the first page
+	$this->y = $this->ez['pageHeight']-$this->ez['topMargin'];
+	// and get the ID of the page that was created during the instancing process.
+	$this->ezPages[1]=$this->getFirstPageId();
+	$this->ezPageCount=1;
+}
+
+// ------------------------------------------------------------------------------
+// 2002-07-24: Nicola Asuni (info at tecnick.com)
+// Set Margins in centimeters
+function ezSetCmMargins($top,$bottom,$left,$right){
+	$top = ( $top / 2.54 ) * 72;
+	$bottom = ( $bottom / 2.54 ) * 72;
+	$left = ( $left / 2.54 ) * 72;
+	$right = ( $right / 2.54 ) * 72;
+	$this->ezSetMargins($top,$bottom,$left,$right);
+}
+// ------------------------------------------------------------------------------
+
+
+function ezColumnsStart($options=array()){
+  // start from the current y-position, make the set number of columne
+  if (isset($this->ez['columns']) && $this->ez['columns']==1){
+    // if we are already in a column mode then just return.
+    return;
+  }
+  $def=array('gap'=>10,'num'=>2);
+  foreach($def as $k=>$v){
+    if (!isset($options[$k])){
+      $options[$k]=$v;
+    }
+  }
+  // setup the columns
+  $this->ez['columns']=array('on'=>1,'colNum'=>1);
+
+  // store the current margins
+  $this->ez['columns']['margins']=array(
+     $this->ez['leftMargin']
+    ,$this->ez['rightMargin']
+    ,$this->ez['topMargin']
+    ,$this->ez['bottomMargin']
+  );
+  // and store the settings for the columns
+  $this->ez['columns']['options']=$options;
+  // then reset the margins to suit the new columns
+  // safe enough to assume the first column here, but start from the current y-position
+  $this->ez['topMargin']=$this->ez['pageHeight']-$this->y;
+  $width=($this->ez['pageWidth']-$this->ez['leftMargin']-$this->ez['rightMargin']-($options['num']-1)*$options['gap'])/$options['num'];
+  $this->ez['columns']['width']=$width;
+  $this->ez['rightMargin']=$this->ez['pageWidth']-$this->ez['leftMargin']-$width;
+  
+}
+// ------------------------------------------------------------------------------
+function ezColumnsStop(){
+  if (isset($this->ez['columns']) && $this->ez['columns']['on']==1){
+    $this->ez['columns']['on']=0;
+    $this->ez['leftMargin']=$this->ez['columns']['margins'][0];
+    $this->ez['rightMargin']=$this->ez['columns']['margins'][1];
+    $this->ez['topMargin']=$this->ez['columns']['margins'][2];
+    $this->ez['bottomMargin']=$this->ez['columns']['margins'][3];
+  }
+}
+// ------------------------------------------------------------------------------
+function ezInsertMode($status=1,$pageNum=1,$pos='before'){
+  // puts the document into insert mode. new pages are inserted until this is re-called with status=0
+  // by default pages wil be inserted at the start of the document
+  switch($status){
+    case '1':
+      if (isset($this->ezPages[$pageNum])){
+        $this->ez['insertMode']=1;
+        $this->ez['insertOptions']=array('id'=>$this->ezPages[$pageNum],'pos'=>$pos);
+      }
+      break;
+    case '0':
+      $this->ez['insertMode']=0;
+      break;
+  }
+}
+// ------------------------------------------------------------------------------
+
+function ezNewPage(){
+  $pageRequired=1;
+  if (isset($this->ez['columns']) && $this->ez['columns']['on']==1){
+    // check if this is just going to a new column
+    // increment the column number
+//echo 'HERE<br>';
+    $this->ez['columns']['colNum']++;
+//echo $this->ez['columns']['colNum'].'<br>';
+    if ($this->ez['columns']['colNum'] <= $this->ez['columns']['options']['num']){
+      // then just reset to the top of the next column
+      $pageRequired=0;
+    } else {
+      $this->ez['columns']['colNum']=1;
+      $this->ez['topMargin']=$this->ez['columns']['margins'][2];
+    }
+
+    $width = $this->ez['columns']['width'];
+    $this->ez['leftMargin']=$this->ez['columns']['margins'][0]+($this->ez['columns']['colNum']-1)*($this->ez['columns']['options']['gap']+$width);
+    $this->ez['rightMargin']=$this->ez['pageWidth']-$this->ez['leftMargin']-$width;
+  }
+//echo 'left='.$this->ez['leftMargin'].'   right='.$this->ez['rightMargin'].'<br>';
+
+  if ($pageRequired){
+    // make a new page, setting the writing point back to the top
+    $this->y = $this->ez['pageHeight']-$this->ez['topMargin'];
+    // make the new page with a call to the basic class.
+    $this->ezPageCount++;
+    if (isset($this->ez['insertMode']) && $this->ez['insertMode']==1){
+      $id = $this->ezPages[$this->ezPageCount] = $this->newPage(1,$this->ez['insertOptions']['id'],$this->ez['insertOptions']['pos']);
+      // then manipulate the insert options so that inserted pages follow each other
+      $this->ez['insertOptions']['id']=$id;
+      $this->ez['insertOptions']['pos']='after';
+    } else {
+      $this->ezPages[$this->ezPageCount] = $this->newPage();
+    }
+  } else {
+    $this->y = $this->ez['pageHeight']-$this->ez['topMargin'];
+  }
+}
+
+// ------------------------------------------------------------------------------
+
+function ezSetMargins($top,$bottom,$left,$right){
+  // sets the margins to new values
+  $this->ez['topMargin']=$top;
+  $this->ez['bottomMargin']=$bottom;
+  $this->ez['leftMargin']=$left;
+  $this->ez['rightMargin']=$right;
+  // check to see if this means that the current writing position is outside the 
+  // writable area
+  if ($this->y > $this->ez['pageHeight']-$top){
+    // then move y down
+    $this->y = $this->ez['pageHeight']-$top;
+  }
+  if ( $this->y < $bottom){
+    // then make a new page
+    $this->ezNewPage();
+  }
+}  
+
+// ------------------------------------------------------------------------------
+
+function ezGetCurrentPageNumber(){
+  // return the strict numbering (1,2,3,4..) number of the current page
+  return $this->ezPageCount;
+}
+
+// ------------------------------------------------------------------------------
+
+function ezStartPageNumbers($x,$y,$size,$pos='left',$pattern='{PAGENUM} of {TOTALPAGENUM}',$num=''){
+  // put page numbers on the pages from here.
+  // place then on the 'pos' side of the coordinates (x,y).
+  // pos can be 'left' or 'right'
+  // use the given 'pattern' for display, where (PAGENUM} and {TOTALPAGENUM} are replaced
+  // as required.
+  // if $num is set, then make the first page this number, the number of total pages will
+  // be adjusted to account for this.
+  // Adjust this function so that each time you 'start' page numbers then you effectively start a different batch
+  // return the number of the batch, so that they can be stopped in a different order if required.
+  if (!$pos || !strlen($pos)){
+    $pos='left';
+  }
+  if (!$pattern || !strlen($pattern)){
+    $pattern='{PAGENUM} of {TOTALPAGENUM}';
+  }
+  if (!isset($this->ez['pageNumbering'])){
+    $this->ez['pageNumbering']=array();
+  }
+  $i = count($this->ez['pageNumbering']);
+  $this->ez['pageNumbering'][$i][$this->ezPageCount]=array('x'=>$x,'y'=>$y,'pos'=>$pos,'pattern'=>$pattern,'num'=>$num,'size'=>$size);
+  return $i;
+}
+
+// ------------------------------------------------------------------------------
+
+function ezWhatPageNumber($pageNum,$i=0){
+  // given a particular generic page number (ie, document numbered sequentially from beginning),
+  // return the page number under a particular page numbering scheme ($i)
+  $num=0;
+  $start=1;
+  $startNum=1;
+  if (!isset($this->ez['pageNumbering']))
+  {
+    $this->addMessage('WARNING: page numbering called for and wasn\'t started with ezStartPageNumbers');
+    return 0;
+  }
+  foreach($this->ez['pageNumbering'][$i] as $k=>$v){
+    if ($k<=$pageNum){
+      if (is_array($v)){
+        // start block
+        if (strlen($v['num'])){
+          // a start was specified
+          $start=$v['num'];
+          $startNum=$k;
+          $num=$pageNum-$startNum+$start;
+        }
+      } else {
+        // stop block
+        $num=0;
+      }
+    }
+  }
+  return $num;
+}
+
+// ------------------------------------------------------------------------------
+
+function ezStopPageNumbers($stopTotal=0,$next=0,$i=0){
+  // if stopTotal=1 then the totalling of pages for this number will stop too
+  // if $next=1, then do this page, but not the next, else do not do this page either
+  // if $i is set, then stop that particular pagenumbering sequence.
+  if (!isset($this->ez['pageNumbering'])){
+    $this->ez['pageNumbering']=array();
+  }
+  if ($next && isset($this->ez['pageNumbering'][$i][$this->ezPageCount]) && is_array($this->ez['pageNumbering'][$i][$this->ezPageCount])){
+    // then this has only just been started, this will over-write the start, and nothing will appear
+    // add a special command to the start block, telling it to stop as well
+    if ($stopTotal){
+      $this->ez['pageNumbering'][$i][$this->ezPageCount]['stoptn']=1;
+    } else {
+      $this->ez['pageNumbering'][$i][$this->ezPageCount]['stopn']=1;
+    }
+  } else {
+    if ($stopTotal){
+      $this->ez['pageNumbering'][$i][$this->ezPageCount]='stopt';
+    } else {
+      $this->ez['pageNumbering'][$i][$this->ezPageCount]='stop';
+    }
+    if ($next){
+      $this->ez['pageNumbering'][$i][$this->ezPageCount].='n';
+    }
+  }
+}
+
+// ------------------------------------------------------------------------------
+
+function ezPRVTpageNumberSearch($lbl,&$tmp){
+  foreach($tmp as $i=>$v){
+    if (is_array($v)){
+      if (isset($v[$lbl])){
+        return $i;
+      }
+    } else {
+      if ($v==$lbl){
+        return $i;
+      }
+    }
+  }
+  return 0;
+}
+
+// ------------------------------------------------------------------------------
+
+function ezPRVTaddPageNumbers(){
+  // this will go through the pageNumbering array and add the page numbers are required
+  if (isset($this->ez['pageNumbering'])){
+    $totalPages1 = $this->ezPageCount;
+    $tmp1=$this->ez['pageNumbering'];
+    $status=0;
+    foreach($tmp1 as $i=>$tmp){
+      // do each of the page numbering systems
+      // firstly, find the total pages for this one
+      $k = $this->ezPRVTpageNumberSearch('stopt',$tmp);
+      if ($k && $k>0){
+        $totalPages = $k-1;
+      } else {
+        $l = $this->ezPRVTpageNumberSearch('stoptn',$tmp);
+        if ($l && $l>0){
+          $totalPages = $l;
+        } else {
+          $totalPages = $totalPages1;
+        }
+      }
+      foreach ($this->ezPages as $pageNum=>$id){
+        if (isset($tmp[$pageNum])){
+          if (is_array($tmp[$pageNum])){
+            // then this must be starting page numbers
+            $status=1;
+            $info = $tmp[$pageNum];
+            $info['dnum']=$info['num']-$pageNum;
+            // also check for the special case of the numbering stopping and starting on the same page
+            if (isset($info['stopn']) || isset($info['stoptn']) ){
+              $status=2;
+            }
+          } else if ($tmp[$pageNum]=='stop' || $tmp[$pageNum]=='stopt'){
+            // then we are stopping page numbers
+            $status=0;
+          } else if ($status==1 && ($tmp[$pageNum]=='stoptn' || $tmp[$pageNum]=='stopn')){
+            // then we are stopping page numbers
+            $status=2;
+          }
+        }
+        if ($status){
+          // then add the page numbering to this page
+          if (strlen($info['num'])){
+            $num=$pageNum+$info['dnum'];
+          } else {
+            $num=$pageNum;
+          }
+          $total = $totalPages+$num-$pageNum;
+          $pat = str_replace('{PAGENUM}',$num,$info['pattern']);
+          $pat = str_replace('{TOTALPAGENUM}',$total,$pat);
+          $this->reopenObject($id);
+          switch($info['pos']){
+            case 'right':
+              $this->addText($info['x'],$info['y'],$info['size'],$pat);
+              break;
+            default:
+              $w=$this->getTextWidth($info['size'],$pat);
+              $this->addText($info['x']-$w,$info['y'],$info['size'],$pat);
+              break;
+          }
+          $this->closeObject();
+        }
+        if ($status==2){
+          $status=0;
+        }
+      }
+    }
+  }
+}
+
+// ------------------------------------------------------------------------------
+
+function ezPRVTcleanUp(){
+  $this->ezPRVTaddPageNumbers();
+}
+
+// ------------------------------------------------------------------------------
+
+function ezStream($options=''){
+  $this->ezPRVTcleanUp();
+  $this->stream($options);
+}
+
+// ------------------------------------------------------------------------------
+
+function ezOutput($options=0){
+  $this->ezPRVTcleanUp();
+  return $this->output($options);
+}
+
+// ------------------------------------------------------------------------------
+
+function ezSetY($y){
+  // used to change the vertical position of the writing point.
+  $this->y = $y;
+  if ( $this->y < $this->ez['bottomMargin']){
+    // then make a new page
+    $this->ezNewPage();
+  }
+}
+
+// ------------------------------------------------------------------------------
+
+function ezSetDy($dy,$mod=''){
+  // used to change the vertical position of the writing point.
+  // changes up by a positive increment, so enter a negative number to go
+  // down the page
+  // if $mod is set to 'makeSpace' and a new page is forced, then the pointed will be moved 
+  // down on the new page, this will allow space to be reserved for graphics etc.
+  $this->y += $dy;
+  if ( $this->y < $this->ez['bottomMargin']){
+    // then make a new page
+    $this->ezNewPage();
+    if ($mod=='makeSpace'){
+      $this->y += $dy;
+    }
+  }
+}
+
+// ------------------------------------------------------------------------------
+
+function ezPrvtTableDrawLines($pos,$gap,$x0,$x1,$y0,$y1,$y2,$col,$inner,$outer,$opt=1){
+  $x0=1000;
+  $x1=0;
+  $this->setStrokeColor($col[0],$col[1],$col[2]);
+  $cnt=0;
+  $n = count($pos);
+  foreach($pos as $x){
+    $cnt++;
+    if ($cnt==1 || $cnt==$n){
+      $this->setLineStyle($outer);
+    } else {
+      $this->setLineStyle($inner);
+    }
+    $this->line($x-$gap/2,$y0,$x-$gap/2,$y2);
+    if ($x>$x1){ $x1=$x; };
+    if ($x<$x0){ $x0=$x; };
+  }
+  $this->setLineStyle($outer);
+  $this->line($x0-$gap/2-$outer/2,$y0,$x1-$gap/2+$outer/2,$y0);
+  // only do the second line if it is different to the first, AND each row does not have
+  // a line on it.
+  if ($y0!=$y1 && $opt<2){
+    $this->line($x0-$gap/2,$y1,$x1-$gap/2,$y1);
+  }
+  $this->line($x0-$gap/2-$outer/2,$y2,$x1-$gap/2+$outer/2,$y2);
+}
+
+// ------------------------------------------------------------------------------
+
+function ezPrvtTableColumnHeadings($cols,$pos,$maxWidth,$height,$decender,$gap,$size,&$y,$optionsAll=array()){
+  // uses ezText to add the text, and returns the height taken by the largest heading
+  // this page will move the headings to a new page if they will not fit completely on this one
+  // transaction support will be used to implement this
+
+  if (isset($optionsAll['cols'])){
+    $options = $optionsAll['cols'];
+  } else {
+    $options = array();
+  }
+  
+  $mx=0;
+  $startPage = $this->ezPageCount;
+  $secondGo=0;
+
+  // $y is the position at which the top of the table should start, so the base
+  // of the first text, is $y-$height-$gap-$decender, but ezText starts by dropping $height
+  
+  // the return from this function is the total cell height, including gaps, and $y is adjusted
+  // to be the postion of the bottom line
+  
+  // begin the transaction
+  $this->transaction('start');
+  $ok=0;
+//  $y-=$gap-$decender;
+  $y-=$gap;
+  while ($ok==0){
+    foreach($cols as $colName=>$colHeading){
+      $this->ezSetY($y);
+      if (isset($options[$colName]) && isset($options[$colName]['justification'])){
+        $justification = $options[$colName]['justification'];
+      } else {
+        $justification = 'left';
+      }
+      $this->ezText($colHeading,$size,array('aleft'=> $pos[$colName],'aright'=>($maxWidth[$colName]+$pos[$colName]),'justification'=>$justification));
+      $dy = $y-$this->y;
+      if ($dy>$mx){
+        $mx=$dy;
+      }
+    }
+    $y = $y - $mx - $gap + $decender;
+//    $y -= $mx-$gap+$decender;
+    
+    // now, if this has moved to a new page, then abort the transaction, move to a new page, and put it there
+    // do not check on the second time around, to avoid an infinite loop
+    if ($this->ezPageCount != $startPage && $secondGo==0){
+      $this->transaction('rewind');
+      $this->ezNewPage();
+      $y = $this->y - $gap-$decender;
+      $ok=0;
+      $secondGo=1;
+//      $y = $store_y;
+      $mx=0;
+
+    } else {
+      $this->transaction('commit');
+      $ok=1;
+    }
+  }
+
+  return $mx+$gap*2-$decender;
+}
+
+// ------------------------------------------------------------------------------
+
+function ezPrvtGetTextWidth($size,$text){
+  // will calculate the maximum width, taking into account that the text may be broken
+  // by line breaks.
+  $mx=0;
+  $lines = explode("\n",$text);
+  foreach ($lines as $line){
+    $w = $this->getTextWidth($size,$line);
+    if ($w>$mx){
+      $mx=$w;
+    }
+  }
+  return $mx;
+}
+
+// ------------------------------------------------------------------------------
+
+function ezTable(&$data,$cols='',$title='',$options=''){
+  // add a table of information to the pdf document
+  // $data is a two dimensional array
+  // $cols (optional) is an associative array, the keys are the names of the columns from $data
+  // to be presented (and in that order), the values are the titles to be given to the columns
+  // $title (optional) is the title to be put on the top of the table
+  //
+  // $options is an associative array which can contain:
+  // 'showLines'=> 0,1,2, default is 1 (show outside and top lines only), 2=> lines on each row
+  // 'showHeadings' => 0 or 1
+  // 'shaded'=> 0,1,2,3 default is 1 (1->alternate lines are shaded, 0->no shading, 2-> both shaded, second uses shadeCol2)
+  // 'shadeCol' => (r,g,b) array, defining the colour of the shading, default is (0.8,0.8,0.8)
+  // 'shadeCol2' => (r,g,b) array, defining the colour of the shading of the other blocks, default is (0.7,0.7,0.7)
+  // 'fontSize' => 10
+  // 'textCol' => (r,g,b) array, text colour
+  // 'titleFontSize' => 12
+  // 'rowGap' => 2 , the space added at the top and bottom of each row, between the text and the lines
+  // 'colGap' => 5 , the space on the left and right sides of each cell
+  // 'lineCol' => (r,g,b) array, defining the colour of the lines, default, black.
+  // 'xPos' => 'left','right','center','centre',or coordinate, reference coordinate in the x-direction
+  // 'xOrientation' => 'left','right','center','centre', position of the table w.r.t 'xPos' 
+  // 'width'=> <number> which will specify the width of the table, if it turns out to not be this
+  //    wide, then it will stretch the table to fit, if it is wider then each cell will be made
+  //    proportionalty smaller, and the content may have to wrap.
+  // 'maxWidth'=> <number> similar to 'width', but will only make table smaller than it wants to be
+  // 'options' => array(<colname>=>array('justification'=>'left','width'=>100,'link'=>linkDataName),<colname>=>....)
+  //             allow the setting of other paramaters for the individual columns
+  // 'minRowSpace'=> the minimum space between the bottom of each row and the bottom margin, in which a new row will be started
+  //                  if it is less, then a new page would be started, default=-100
+  // 'innerLineThickness'=>1
+  // 'outerLineThickness'=>1
+  // 'splitRows'=>0, 0 or 1, whether or not to allow the rows to be split across page boundaries
+  // 'protectRows'=>number, the number of rows to hold with the heading on page, ie, if there less than this number of
+  //                rows on the page, then move the whole lot onto the next page, default=1
+  //
+  // note that the user will have had to make a font selection already or this will not 
+  // produce a valid pdf file.
+  
+  if (!is_array($data)){
+    return;
+  }
+  
+  if (!is_array($cols)){
+    // take the columns from the first row of the data set
+    reset($data);
+    list($k,$v)=each($data);
+    if (!is_array($v)){
+      return;
+    }
+    $cols=array();
+    foreach($v as $k1=>$v1){
+      $cols[$k1]=$k1;
+    }
+  }
+  
+  if (!is_array($options)){
+    $options=array();
+  }
+
+  $defaults = array(
+    'shaded'=>1,'showLines'=>1,'shadeCol'=>array(0.8,0.8,0.8),'shadeCol2'=>array(0.7,0.7,0.7),'fontSize'=>10,'titleFontSize'=>12
+    ,'titleGap'=>5,'lineCol'=>array(0,0,0),'gap'=>5,'xPos'=>'centre','xOrientation'=>'centre'
+    ,'showHeadings'=>1,'textCol'=>array(0,0,0),'width'=>0,'maxWidth'=>0,'cols'=>array(),'minRowSpace'=>-100,'rowGap'=>2,'colGap'=>5
+    ,'innerLineThickness'=>1,'outerLineThickness'=>1,'splitRows'=>0,'protectRows'=>1
+    );
+
+  foreach($defaults as $key=>$value){
+    if (is_array($value)){
+      if (!isset($options[$key]) || !is_array($options[$key])){
+        $options[$key]=$value;
+      }
+    } else {
+      if (!isset($options[$key])){
+        $options[$key]=$value;
+      }
+    }
+  }
+  $options['gap']=2*$options['colGap'];
+  
+  $middle = ($this->ez['pageWidth']-$this->ez['rightMargin'])/2+($this->ez['leftMargin'])/2;
+  // figure out the maximum widths of the text within each column
+  $maxWidth=array();
+  foreach($cols as $colName=>$colHeading){
+    $maxWidth[$colName]=0;
+  }
+  // find the maximum cell widths based on the data
+  foreach($data as $row){
+    foreach($cols as $colName=>$colHeading){
+      $w = $this->ezPrvtGetTextWidth($options['fontSize'],(string)$row[$colName])*1.01;
+      if ($w > $maxWidth[$colName]){
+        $maxWidth[$colName]=$w;
+      }
+    }
+  }
+  // and the maximum widths to fit in the headings
+  foreach($cols as $colName=>$colTitle){
+    $w = $this->ezPrvtGetTextWidth($options['fontSize'],(string)$colTitle)*1.01;
+    if ($w > $maxWidth[$colName]){
+      $maxWidth[$colName]=$w;
+    }
+  }
+  
+  // calculate the start positions of each of the columns
+  $pos=array();
+  $x=0;
+  $t=$x;
+  $adjustmentWidth=0;
+  $setWidth=0;
+  foreach($maxWidth as $colName => $w){
+    $pos[$colName]=$t;
+    // if the column width has been specified then set that here, also total the
+    // width avaliable for adjustment
+    if (isset($options['cols'][$colName]) && isset($options['cols'][$colName]['width']) && $options['cols'][$colName]['width']>0){
+      $t=$t+$options['cols'][$colName]['width'];
+      $maxWidth[$colName] = $options['cols'][$colName]['width']-$options['gap'];
+      $setWidth += $options['cols'][$colName]['width'];
+    } else {
+      $t=$t+$w+$options['gap'];
+      $adjustmentWidth += $w;
+      $setWidth += $options['gap'];
+    }
+  }
+  $pos['_end_']=$t;
+
+  // if maxWidth is specified, and the table is too wide, and the width has not been set,
+  // then set the width.
+  if ($options['width']==0 && $options['maxWidth'] && ($t-$x)>$options['maxWidth']){
+    // then need to make this one smaller
+    $options['width']=$options['maxWidth'];
+  }
+
+  if ($options['width'] && $adjustmentWidth>0 && $setWidth<$options['width']){
+    // first find the current widths of the columns involved in this mystery
+    $cols0 = array();
+    $cols1 = array();
+    $xq=0;
+    $presentWidth=0;
+    $last='';
+    foreach($pos as $colName=>$p){
+      if (!isset($options['cols'][$last]) || !isset($options['cols'][$last]['width']) || $options['cols'][$last]['width']<=0){
+        if (strlen($last)){
+          $cols0[$last]=$p-$xq -$options['gap'];
+          $presentWidth += ($p-$xq - $options['gap']);
+        }
+      } else {
+        $cols1[$last]=$p-$xq;
+      }
+      $last=$colName;
+      $xq=$p;
+    }
+    // $cols0 contains the widths of all the columns which are not set
+    $neededWidth = $options['width']-$setWidth;
+    // if needed width is negative then add it equally to each column, else get more tricky
+    if ($presentWidth<$neededWidth){
+      foreach($cols0 as $colName=>$w){
+        $cols0[$colName]+= ($neededWidth-$presentWidth)/count($cols0);
+      }
+    } else {
+    
+      $cnt=0;
+      while ($presentWidth>$neededWidth && $cnt<100){
+        $cnt++; // insurance policy
+        // find the widest columns, and the next to widest width
+        $aWidest = array();
+        $nWidest=0;
+        $widest=0;
+        foreach($cols0 as $colName=>$w){
+          if ($w>$widest){
+            $aWidest=array($colName);
+            $nWidest = $widest;
+            $widest=$w;
+          } else if ($w==$widest){
+            $aWidest[]=$colName;
+          }
+        }
+        // then figure out what the width of the widest columns would have to be to take up all the slack
+        $newWidestWidth = $widest - ($presentWidth-$neededWidth)/count($aWidest);
+        if ($newWidestWidth > $nWidest){
+          // then there is space to set them to this
+          foreach($aWidest as $colName){
+            $cols0[$colName] = $newWidestWidth;
+          }
+          $presentWidth=$neededWidth;
+        } else {
+          // there is not space, reduce the size of the widest ones down to the next size down, and we
+          // will go round again
+          foreach($aWidest as $colName){
+            $cols0[$colName] = $nWidest;
+          }
+          $presentWidth=$presentWidth-($widest-$nWidest)*count($aWidest);
+        }
+      }
+    }
+    // $cols0 now contains the new widths of the constrained columns.
+    // now need to update the $pos and $maxWidth arrays
+    $xq=0;
+    foreach($pos as $colName=>$p){
+      $pos[$colName]=$xq;
+      if (!isset($options['cols'][$colName]) || !isset($options['cols'][$colName]['width']) || $options['cols'][$colName]['width']<=0){
+        if (isset($cols0[$colName])){
+          $xq += $cols0[$colName] + $options['gap'];
+          $maxWidth[$colName]=$cols0[$colName];
+        }
+      } else {
+        if (isset($cols1[$colName])){
+          $xq += $cols1[$colName];
+        }
+      }
+    }
+
+    $t=$x+$options['width'];
+    $pos['_end_']=$t;
+  }
+
+  // now adjust the table to the correct location across the page
+  switch ($options['xPos']){
+    case 'left':
+      $xref = $this->ez['leftMargin'];
+      break;
+    case 'right':
+      $xref = $this->ez['pageWidth'] - $this->ez['rightMargin'];
+      break;
+    case 'centre':
+    case 'center':
+      $xref = $middle;
+      break;
+    default:
+      $xref = $options['xPos'];
+      break;
+  }
+  switch ($options['xOrientation']){
+    case 'left':
+      $dx = $xref-$t;
+      break;
+    case 'right':
+      $dx = $xref;
+      break;
+    case 'centre':
+    case 'center':
+      $dx = $xref-$t/2;
+      break;
+  }
+
+
+  foreach($pos as $k=>$v){
+    $pos[$k]=$v+$dx;
+  }
+  $x0=$x+$dx;
+  $x1=$t+$dx;
+
+  $baseLeftMargin = $this->ez['leftMargin'];
+  $basePos = $pos;
+  $baseX0 = $x0;
+  $baseX1 = $x1;
+  
+  // ok, just about ready to make me a table
+  $this->setColor($options['textCol'][0],$options['textCol'][1],$options['textCol'][2]);
+  $this->setStrokeColor($options['shadeCol'][0],$options['shadeCol'][1],$options['shadeCol'][2]);
+
+  $middle = ($x1+$x0)/2;
+
+  // start a transaction which will be used to regress the table, if there are not enough rows protected
+  if ($options['protectRows']>0){
+    $this->transaction('start');
+    $movedOnce=0;
+  }
+  $abortTable = 1;
+  while ($abortTable){
+  $abortTable=0;
+
+  $dm = $this->ez['leftMargin']-$baseLeftMargin;
+  foreach($basePos as $k=>$v){
+    $pos[$k]=$v+$dm;
+  }
+  $x0=$baseX0+$dm;
+  $x1=$baseX1+$dm;
+  $middle = ($x1+$x0)/2;
+
+
+  // if the title is set, then do that
+  if (strlen($title)){
+    $w = $this->getTextWidth($options['titleFontSize'],$title);
+    $this->y -= $this->getFontHeight($options['titleFontSize']);
+    if ($this->y < $this->ez['bottomMargin']){
+      $this->ezNewPage();
+        // margins may have changed on the newpage
+        $dm = $this->ez['leftMargin']-$baseLeftMargin;
+        foreach($basePos as $k=>$v){
+          $pos[$k]=$v+$dm;
+        }
+        $x0=$baseX0+$dm;
+        $x1=$baseX1+$dm;
+        $middle = ($x1+$x0)/2;
+      $this->y -= $this->getFontHeight($options['titleFontSize']);
+    }
+    $this->addText($middle-$w/2,$this->y,$options['titleFontSize'],$title);
+    $this->y -= $options['titleGap'];
+  }
+
+        // margins may have changed on the newpage
+        $dm = $this->ez['leftMargin']-$baseLeftMargin;
+        foreach($basePos as $k=>$v){
+          $pos[$k]=$v+$dm;
+        }
+        $x0=$baseX0+$dm;
+        $x1=$baseX1+$dm;
+  
+  $y=$this->y; // to simplify the code a bit
+  
+  // make the table
+  $height = $this->getFontHeight($options['fontSize']);
+  $decender = $this->getFontDecender($options['fontSize']);
+
+  
+  
+  $y0=$y+$decender;
+  $dy=0;
+  if ($options['showHeadings']){
+    // this function will move the start of the table to a new page if it does not fit on this one
+    $headingHeight = $this->ezPrvtTableColumnHeadings($cols,$pos,$maxWidth,$height,$decender,$options['rowGap'],$options['fontSize'],$y,$options);
+    $y0 = $y+$headingHeight;
+    $y1 = $y;
+
+
+    $dm = $this->ez['leftMargin']-$baseLeftMargin;
+    foreach($basePos as $k=>$v){
+      $pos[$k]=$v+$dm;
+    }
+    $x0=$baseX0+$dm;
+    $x1=$baseX1+$dm;
+
+  } else {
+    $y1 = $y0;
+  }
+  $firstLine=1;
+
+  
+  // open an object here so that the text can be put in over the shading
+  if ($options['shaded']){
+    $this->saveState();
+    $textObjectId = $this->openObject();
+    $this->closeObject();
+    $this->addObject($textObjectId);
+    $this->reopenObject($textObjectId);
+  }
+  
+  $cnt=0;
+  $newPage=0;
+  foreach($data as $row){
+    $cnt++;
+    // the transaction support will be used to prevent rows being split
+    if ($options['splitRows']==0){
+      $pageStart = $this->ezPageCount;
+      if (isset($this->ez['columns']) && $this->ez['columns']['on']==1){
+        $columnStart = $this->ez['columns']['colNum'];
+      }
+      $this->transaction('start');
+      $row_orig = $row;
+      $y_orig = $y;
+      $y0_orig = $y0;
+      $y1_orig = $y1;
+    }
+    $ok=0;
+    $secondTurn=0;
+    while(!$abortTable && $ok == 0){
+
+    $mx=0;
+    $newRow=1;
+    while(!$abortTable && ($newPage || $newRow)){
+      
+      $y-=$height;
+      if ($newPage || $y<$this->ez['bottomMargin'] || (isset($options['minRowSpace']) && $y<($this->ez['bottomMargin']+$options['minRowSpace'])) ){
+        // check that enough rows are with the heading
+        if ($options['protectRows']>0 && $movedOnce==0 && $cnt<=$options['protectRows']){
+          // then we need to move the whole table onto the next page
+          $movedOnce = 1;
+          $abortTable = 1;
+        }
+      
+        $y2=$y-$mx+2*$height+$decender-$newRow*$height;
+        if ($options['showLines']){
+          if (!$options['showHeadings']){
+            $y0=$y1;
+          }
+          $this->ezPrvtTableDrawLines($pos,$options['gap'],$x0,$x1,$y0,$y1,$y2,$options['lineCol'],$options['innerLineThickness'],$options['outerLineThickness'],$options['showLines']);
+        }
+        if ($options['shaded']){
+          $this->closeObject();
+          $this->restoreState();
+        }
+        $this->ezNewPage();
+        // and the margins may have changed, this is due to the possibility of the columns being turned on
+        // as the columns are managed by manipulating the margins
+
+        $dm = $this->ez['leftMargin']-$baseLeftMargin;
+        foreach($basePos as $k=>$v){
+          $pos[$k]=$v+$dm;
+        }
+//        $x0=$x0+$dm;
+//        $x1=$x1+$dm;
+        $x0=$baseX0+$dm;
+        $x1=$baseX1+$dm;
+  
+        if ($options['shaded']){
+          $this->saveState();
+          $textObjectId = $this->openObject();
+          $this->closeObject();
+          $this->addObject($textObjectId);
+          $this->reopenObject($textObjectId);
+        }
+        $this->setColor($options['textCol'][0],$options['textCol'][1],$options['textCol'][2],1);
+        $y = $this->ez['pageHeight']-$this->ez['topMargin'];
+        $y0=$y+$decender;
+        $mx=0;
+        if ($options['showHeadings']){
+          $this->ezPrvtTableColumnHeadings($cols,$pos,$maxWidth,$height,$decender,$options['rowGap'],$options['fontSize'],$y,$options);
+          $y1=$y;
+        } else {
+          $y1=$y0;
+        }
+        $firstLine=1;
+        $y -= $height;
+      }
+      $newRow=0;
+      // write the actual data
+      // if these cells need to be split over a page, then $newPage will be set, and the remaining
+      // text will be placed in $leftOvers
+      $newPage=0;
+      $leftOvers=array();
+
+      foreach($cols as $colName=>$colTitle){
+        $this->ezSetY($y+$height);
+        $colNewPage=0;
+        if (isset($row[$colName])){
+          if (isset($options['cols'][$colName]) && isset($options['cols'][$colName]['link']) && strlen($options['cols'][$colName]['link'])){
+            
+            $lines = explode("\n",$row[$colName]);
+            if (isset($row[$options['cols'][$colName]['link']]) && strlen($row[$options['cols'][$colName]['link']])){
+              foreach($lines as $k=>$v){
+                $lines[$k]='<c:alink:'.$row[$options['cols'][$colName]['link']].'>'.$v.'</c:alink>';
+              }
+            }
+          } else {
+            $lines = explode("\n",$row[$colName]);
+          }
+        } else {
+          $lines = array();
+        }
+        $this->y -= $options['rowGap'];
+        foreach ($lines as $line){
+          $line = $this->ezProcessText($line);
+          $start=1;
+
+          while (strlen($line) || $start){
+            $start=0;
+            if (!$colNewPage){
+              $this->y=$this->y-$height;
+            }
+            if ($this->y < $this->ez['bottomMargin']){
+  //            $this->ezNewPage();
+              $newPage=1;  // whether a new page is required for any of the columns
+              $colNewPage=1; // whether a new page is required for this column
+            }
+            if ($colNewPage){
+              if (isset($leftOvers[$colName])){
+                $leftOvers[$colName].="\n".$line;
+              } else {
+                $leftOvers[$colName] = $line;
+              }
+              $line='';
+            } else {
+              if (isset($options['cols'][$colName]) && isset($options['cols'][$colName]['justification']) ){
+                $just = $options['cols'][$colName]['justification'];
+              } else {
+                $just='left';
+              }
+
+              $line=$this->addTextWrap($pos[$colName],$this->y,$maxWidth[$colName],$options['fontSize'],$line,$just);
+            }
+          }
+        }
+  
+        $dy=$y+$height-$this->y+$options['rowGap'];
+        if ($dy-$height*$newPage>$mx){
+          $mx=$dy-$height*$newPage;
+        }
+      }
+      // set $row to $leftOvers so that they will be processed onto the new page
+      $row = $leftOvers;
+      // now add the shading underneath
+      if ($options['shaded'] && $cnt%2==0){
+        $this->closeObject();
+        $this->setColor($options['shadeCol'][0],$options['shadeCol'][1],$options['shadeCol'][2],1);
+        $this->filledRectangle($x0-$options['gap']/2,$y+$decender+$height-$mx,$x1-$x0,$mx);
+        $this->reopenObject($textObjectId);
+      }
+
+      if ($options['shaded']==2 && $cnt%2==1){
+        $this->closeObject();
+        $this->setColor($options['shadeCol2'][0],$options['shadeCol2'][1],$options['shadeCol2'][2],1);
+        $this->filledRectangle($x0-$options['gap']/2,$y+$decender+$height-$mx,$x1-$x0,$mx);
+        $this->reopenObject($textObjectId);
+      }
+
+      if ($options['showLines']>1){
+        // then draw a line on the top of each block
+//        $this->closeObject();
+        $this->saveState();
+        $this->setStrokeColor($options['lineCol'][0],$options['lineCol'][1],$options['lineCol'][2],1);
+//        $this->line($x0-$options['gap']/2,$y+$decender+$height-$mx,$x1-$x0,$mx);
+        if ($firstLine){
+          $this->setLineStyle($options['outerLineThickness']);
+          $firstLine=0;
+        } else {
+          $this->setLineStyle($options['innerLineThickness']);
+        }
+        $this->line($x0-$options['gap']/2,$y+$decender+$height,$x1-$options['gap']/2,$y+$decender+$height);
+        $this->restoreState();
+//        $this->reopenObject($textObjectId);
+      }
+    } // end of while 
+    $y=$y-$mx+$height;
+    
+    // checking row split over pages
+    if ($options['splitRows']==0){
+      if ( ( ($this->ezPageCount != $pageStart) || (isset($this->ez['columns']) && $this->ez['columns']['on']==1 && $columnStart != $this->ez['columns']['colNum'] ))  && $secondTurn==0){
+        // then we need to go back and try that again !
+        $newPage=1;
+        $secondTurn=1;
+        $this->transaction('rewind');
+        $row = $row_orig;
+        $y = $y_orig;
+        $y0 = $y0_orig;
+        $y1 = $y1_orig;
+        $ok=0;
+
+        $dm = $this->ez['leftMargin']-$baseLeftMargin;
+        foreach($basePos as $k=>$v){
+          $pos[$k]=$v+$dm;
+        }
+        $x0=$baseX0+$dm;
+        $x1=$baseX1+$dm;
+
+      } else {
+        $this->transaction('commit');
+        $ok=1;
+      }
+    } else {
+      $ok=1;  // don't go round the loop if splitting rows is allowed
+    }
+    
+    }  // end of while to check for row splitting
+    if ($abortTable){
+      if ($ok==0){
+        $this->transaction('abort');
+      }
+      // only the outer transaction should be operational
+      $this->transaction('rewind');
+      $this->ezNewPage();
+      break;
+    }
+    
+  } // end of foreach ($data as $row)
+  
+  } // end of while ($abortTable)
+
+  // table has been put on the page, the rows guarded as required, commit.
+  $this->transaction('commit');
+
+  $y2=$y+$decender;
+  if ($options['showLines']){
+    if (!$options['showHeadings']){
+      $y0=$y1;
+    }
+    $this->ezPrvtTableDrawLines($pos,$options['gap'],$x0,$x1,$y0,$y1,$y2,$options['lineCol'],$options['innerLineThickness'],$options['outerLineThickness'],$options['showLines']);
+  }
+
+  // close the object for drawing the text on top
+  if ($options['shaded']){
+    $this->closeObject();
+    $this->restoreState();
+  }
+  
+  $this->y=$y;
+  return $y;
+}
+
+// ------------------------------------------------------------------------------
+function ezProcessText($text){
+  // this function will intially be used to implement underlining support, but could be used for a range of other
+  // purposes
+  $search = array('<u>','<U>','</u>','</U>');
+  $replace = array('<c:uline>','<c:uline>','</c:uline>','</c:uline>');
+  return str_replace($search,$replace,$text);
+}
+
+// ------------------------------------------------------------------------------
+
+function ezText($text,$size=0,$options=array(),$test=0){
+  // this will add a string of text to the document, starting at the current drawing
+  // position.
+  // it will wrap to keep within the margins, including optional offsets from the left
+  // and the right, if $size is not specified, then it will be the last one used, or
+  // the default value (12 I think).
+  // the text will go to the start of the next line when a return code "\n" is found.
+  // possible options are:
+  // 'left'=> number, gap to leave from the left margin
+  // 'right'=> number, gap to leave from the right margin
+  // 'aleft'=> number, absolute left position (overrides 'left')
+  // 'aright'=> number, absolute right position (overrides 'right')
+  // 'justification' => 'left','right','center','centre','full'
+
+  // only set one of the next two items (leading overrides spacing)
+  // 'leading' => number, defines the total height taken by the line, independent of the font height.
+  // 'spacing' => a real number, though usually set to one of 1, 1.5, 2 (line spacing as used in word processing)
+  
+  // if $test is set then this should just check if the text is going to flow onto a new page or not, returning true or false
+  
+  // apply the filtering which will make the underlining function.
+  $text = $this->ezProcessText($text);
+  
+  $newPage=false;
+  $store_y = $this->y;
+  
+  if (is_array($options) && isset($options['aleft'])){
+    $left=$options['aleft'];
+  } else {
+    $left = $this->ez['leftMargin'] + ((is_array($options) && isset($options['left']))?$options['left']:0);
+  }
+  if (is_array($options) && isset($options['aright'])){
+    $right=$options['aright'];
+  } else {
+    $right = $this->ez['pageWidth'] - $this->ez['rightMargin'] - ((is_array($options) && isset($options['right']))?$options['right']:0);
+  }
+  if ($size<=0){
+    $size = $this->ez['fontSize'];
+  } else {
+    $this->ez['fontSize']=$size;
+  }
+  
+  if (is_array($options) && isset($options['justification'])){
+    $just = $options['justification'];
+  } else {
+    $just = 'left';
+  }
+  
+  // modifications to give leading and spacing based on those given by Craig Heydenburg 1/1/02
+  if (is_array($options) && isset($options['leading'])) { ## use leading instead of spacing
+    $height = $options['leading'];
+	} else if (is_array($options) && isset($options['spacing'])) {
+    $height = $this->getFontHeight($size) * $options['spacing'];
+	} else {
+		$height = $this->getFontHeight($size);
+	}
+
+  
+  $lines = explode("\n",$text);
+  foreach ($lines as $line){
+    $start=1;
+    while (strlen($line) || $start){
+      $start=0;
+      $this->y=$this->y-$height;
+      if ($this->y < $this->ez['bottomMargin']){
+        if ($test){
+          $newPage=true;
+        } else {
+          $this->ezNewPage();
+          // and then re-calc the left and right, in case they have changed due to columns
+        }
+      }
+      if (is_array($options) && isset($options['aleft'])){
+        $left=$options['aleft'];
+      } else {
+        $left = $this->ez['leftMargin'] + ((is_array($options) && isset($options['left']))?$options['left']:0);
+      }
+      if (is_array($options) && isset($options['aright'])){
+        $right=$options['aright'];
+      } else {
+        $right = $this->ez['pageWidth'] - $this->ez['rightMargin'] - ((is_array($options) && isset($options['right']))?$options['right']:0);
+      }
+      $line=$this->addTextWrap($left,$this->y,$right-$left,$size,$line,$just,0,$test);
+    }
+  }
+
+  if ($test){
+    $this->y=$store_y;
+    return $newPage;
+  } else {
+    return $this->y;
+  }
+}
+
+// ------------------------------------------------------------------------------
+
+function ezImage($image,$pad = 5,$width = 0,$resize = 'full',$just = 'center',$border = ''){
+	//beta ezimage function
+	if (stristr($image,'://'))//copy to temp file
+	{
+		$fp = @fopen($image,"rb");
+		while(!feof($fp))
+   		{
+      			$cont.= fread($fp,1024);
+   		}
+   		fclose($fp);
+		$image = tempnam ("/tmp", "php-pdf");
+		$fp2 = @fopen($image,"w");
+   		fwrite($fp2,$cont);
+  		fclose($fp2);
+		$temp = true;
+	}
+
+	if (!(file_exists($image))) return false; //return immediately if image file does not exist
+	$imageInfo = getimagesize($image);
+	switch ($imageInfo[2]){
+		case 2:
+			$type = "jpeg";
+			break;
+		case 3:
+			$type = "png";
+			break;
+		default:
+			return false; //return if file is not jpg or png
+	}
+	if ($width == 0) $width = $imageInfo[0]; //set width
+	$ratio = $imageInfo[0]/$imageInfo[1];
+
+	//get maximum width of image
+	if (isset($this->ez['columns']) && $this->ez['columns']['on'] == 1)
+	{
+		$bigwidth = $this->ez['columns']['width'] - ($pad * 2);
+	}
+	else
+	{
+		$bigwidth = $this->ez['pageWidth'] - ($pad * 2);
+	}
+	//fix width if larger than maximum or if $resize=full
+	if ($resize == 'full' || $resize == 'width' || $width > $bigwidth)
+	{
+		$width = $bigwidth;
+
+	}
+
+	$height = ($width/$ratio); //set height
+
+	//fix size if runs off page
+	if ($height > ($this->y - $this->ez['bottomMargin'] - ($pad * 2)))
+	{
+		if ($resize != 'full')
+		{
+			$this->ezNewPage();
+		}
+		else
+		{
+			$height = ($this->y - $this->ez['bottomMargin'] - ($pad * 2)); //shrink height
+			$width = ($height*$ratio); //fix width
+		}
+	}
+
+	//fix x-offset if image smaller than bigwidth
+	if ($width < $bigwidth)
+	{
+		//center if justification=center
+		if ($just == 'center')
+		{
+			$offset = ($bigwidth - $width) / 2;
+		}
+		//move to right if justification=right
+		if ($just == 'right')
+		{
+			$offset = ($bigwidth - $width);
+		}
+		//leave at left if justification=left
+		if ($just == 'left')
+		{
+			$offset = 0;
+		}
+	}
+
+
+	//call appropriate function
+	if ($type == "jpeg"){
+		$this->addJpegFromFile($image,$this->ez['leftMargin'] + $pad + $offset, $this->y + $this->getFontHeight($this->ez['fontSize']) - $pad - $height,$width);
+	}
+
+	if ($type == "png"){
+		$this->addPngFromFile($image,$this->ez['leftMargin'] + $pad + $offset, $this->y + $this->getFontHeight($this->ez['fontSize']) - $pad - $height,$width);
+	}
+	//draw border
+	if ($border != '')
+	{
+	if (!(isset($border['color'])))
+	{
+		$border['color']['red'] = .5;
+		$border['color']['blue'] = .5;
+		$border['color']['green'] = .5;
+	}
+	if (!(isset($border['width']))) $border['width'] = 1;
+	if (!(isset($border['cap']))) $border['cap'] = 'round';
+	if (!(isset($border['join']))) $border['join'] = 'round';
+	
+
+	$this->setStrokeColor($border['color']['red'],$border['color']['green'],$border['color']['blue']);
+	$this->setLineStyle($border['width'],$border['cap'],$border['join']);
+	$this->rectangle($this->ez['leftMargin'] + $pad + $offset, $this->y + $this->getFontHeight($this->ez['fontSize']) - $pad - $height,$width,$height);
+
+	}
+	// move y below image
+	$this->y = $this->y - $pad - $height;
+	//remove tempfile for remote images
+	if ($temp == true) unlink($image);
+
+}
+// ------------------------------------------------------------------------------
+
+// note that templating code is still considered developmental - have not really figured
+// out a good way of doing this yet.
+function loadTemplate($templateFile){
+  // this function will load the requested template ($file includes full or relative pathname)
+  // the code for the template will be modified to make it name safe, and then stored in 
+  // an array for later use
+  // The id of the template will be returned for the user to operate on it later
+  if (!file_exists($templateFile)){
+    return -1;
+  }
+
+  $code = implode('',file($templateFile));
+  if (!strlen($code)){
+    return;
+  }
+
+  $code = trim($code);
+  if (substr($code,0,5)=='<?php'){
+    $code = substr($code,5);
+  }
+  if (substr($code,-2)=='?>'){
+    $code = substr($code,0,strlen($code)-2);
+  }
+  if (isset($this->ez['numTemplates'])){
+    $newNum = $this->ez['numTemplates'];
+    $this->ez['numTemplates']++;
+  } else {
+    $newNum=0;
+    $this->ez['numTemplates']=1;
+    $this->ez['templates']=array();
+  }
+
+  $this->ez['templates'][$newNum]['code']=$code;
+
+  return $newNum;
+}
+
+// ------------------------------------------------------------------------------
+
+function execTemplate($id,$data=array(),$options=array()){
+  // execute the given template on the current document.
+  if (!isset($this->ez['templates'][$id])){
+    return;
+  }
+  eval($this->ez['templates'][$id]['code']);
+}
+
+// ------------------------------------------------------------------------------
+function ilink($info){
+  $this->alink($info,1);
+}
+
+function alink($info,$internal=0){
+  // a callback function to support the formation of clickable links within the document
+  $lineFactor=0.05; // the thickness of the line as a proportion of the height. also the drop of the line.
+  switch($info['status']){
+    case 'start':
+    case 'sol':
+      // the beginning of the link
+      // this should contain the URl for the link as the 'p' entry, and will also contain the value of 'nCallback'
+      if (!isset($this->ez['links'])){
+        $this->ez['links']=array();
+      }
+      $i = $info['nCallback'];
+      $this->ez['links'][$i] = array('x'=>$info['x'],'y'=>$info['y'],'angle'=>$info['angle'],'decender'=>$info['decender'],'height'=>$info['height'],'url'=>$info['p']);
+      if ($internal==0){
+        $this->saveState();
+        $this->setColor(0,0,1);
+        $this->setStrokeColor(0,0,1);
+        $thick = $info['height']*$lineFactor;
+        $this->setLineStyle($thick);
+      }
+      break;
+    case 'end':
+    case 'eol':
+      // the end of the link
+      // assume that it is the most recent opening which has closed
+      $i = $info['nCallback'];
+      $start = $this->ez['links'][$i];
+      // add underlining
+      if ($internal){
+        $this->addInternalLink($start['url'],$start['x'],$start['y']+$start['decender'],$info['x'],$start['y']+$start['decender']+$start['height']);
+      } else {
+        $a = deg2rad((float)$start['angle']-90.0);
+        $drop = $start['height']*$lineFactor*1.5;
+        $dropx = cos($a)*$drop;
+        $dropy = -sin($a)*$drop;
+        $this->line($start['x']-$dropx,$start['y']-$dropy,$info['x']-$dropx,$info['y']-$dropy);
+        $this->addLink($start['url'],$start['x'],$start['y']+$start['decender'],$info['x'],$start['y']+$start['decender']+$start['height']);
+        $this->restoreState();
+      }
+      break;
+  }
+}
+
+// ------------------------------------------------------------------------------
+
+function uline($info){
+  // a callback function to support underlining
+  $lineFactor=0.05; // the thickness of the line as a proportion of the height. also the drop of the line.
+  switch($info['status']){
+    case 'start':
+    case 'sol':
+    
+      // the beginning of the underline zone
+      if (!isset($this->ez['links'])){
+        $this->ez['links']=array();
+      }
+      $i = $info['nCallback'];
+      $this->ez['links'][$i] = array('x'=>$info['x'],'y'=>$info['y'],'angle'=>$info['angle'],'decender'=>$info['decender'],'height'=>$info['height']);
+      $this->saveState();
+      $thick = $info['height']*$lineFactor;
+      $this->setLineStyle($thick);
+      break;
+    case 'end':
+    case 'eol':
+      // the end of the link
+      // assume that it is the most recent opening which has closed
+      $i = $info['nCallback'];
+      $start = $this->ez['links'][$i];
+      // add underlining
+      $a = deg2rad((float)$start['angle']-90.0);
+      $drop = $start['height']*$lineFactor*1.5;
+      $dropx = cos($a)*$drop;
+      $dropy = -sin($a)*$drop;
+      $this->line($start['x']-$dropx,$start['y']-$dropy,$info['x']-$dropx,$info['y']-$dropy);
+      $this->restoreState();
+      break;
+  }
+}
+
+// ------------------------------------------------------------------------------
+
+}
 ?>
\ No newline at end of file

Modified: branches/print_dev/http/classes/class_administration.php
===================================================================
--- branches/print_dev/http/classes/class_administration.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_administration.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -135,7 +135,8 @@
 		// set parsing options
 		xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
 		xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
-		xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, CHARSET);
+		// internal encoding of Mapbender is UTF-8!!!
+		xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
 
 		// this is the actual parsing process
 		xml_parse_into_struct($parser, $someXml, $values, $tags);
@@ -1141,6 +1142,22 @@
 		return ($this->is_utf8_xml($data) || $this->is_utf8_string($data));
 	}
 	
+	public static function convertIncomingString ($str) {
+		if (CHARSET == "ISO-8859-1") {
+			$e = new mb_notice("Conversion to UTF-8: " . $str . " to " . utf8_encode($str));
+			return utf8_encode($str);
+		}
+		return $str;
+	}
+	
+	public static function convertOutgoingString ($str) {
+		if (CHARSET == "ISO-8859-1") {
+			$e = new mb_notice("Conversion to ISO-8859-1: " . $str . " to " . utf8_decode($str));
+			return utf8_decode($str);
+		}
+		return $str;
+	}
+	
 	function char_encode($data) {
 		if (CHARSET == "UTF-8") {
 			if (!$this->is_utf8($data)) {

Modified: branches/print_dev/http/classes/class_bbox.php
===================================================================
--- branches/print_dev/http/classes/class_bbox.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_bbox.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,171 +1,171 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.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");
-require_once(dirname(__FILE__)."/class_point.php");
-
-/**
- * A bounding box consisting of an lower left and an upper right point, and an EPSG.
- */
-class Mapbender_bbox {
-	var $min;
-	var $max;
-	var $epsg;
-	
-	/**
-	 * @constructor
-	 */
-	function __construct() {
-		if (func_num_args() == 5) {
-			$param0 = func_get_arg(0);
-			$param1 = func_get_arg(1);
-			$param2 = func_get_arg(2);
-			$param3 = func_get_arg(3);
-			$param4 = func_get_arg(4);
-		}
-		else if (func_num_args() == 3) {
-			$param0 = func_get_arg(0);
-			$param1 = func_get_arg(1);
-			$param2 = func_get_arg(2);
-		}
-		else {
-			return;
-		}
-		
-		// params are point, point, epsg
-		if (is_a($param0, "Mapbender_point") && is_a($param1, "Mapbender_point") && !$param3 && !$param4) {
-			$e = new mb_notice("Mapbender_bbox: constructor: point1, point2, epsg");
-			$min = $param0; // is a Mapbender_point
-			$max = $param1; // is a Mapbender_point
-			$epsg = $param2; // is an EPSG code like "EPSG:4326"
-			
-			if ($min->isWestOf($max) && $min->isSouthOf($max)) {
-				if ($min->epsg == $max->epsg && $min->epsg == $epsg) {
-					$this->min = $min;
-					$this->max = $max;
-					$this->epsg = $epsg;
-				}
-				else {
-					$e = new mb_exception("Mapbender_bbox: constructor: EPSG mismatch!");
-				}
-			}
-			else {
-				$e = new mb_exception("Mapbender_bbox: constructor: min (".$this->min.") is not southwest of max (".$this->max.")!");
-			}
-		}
-		// params are x1, y1, x2, xy, epsg
-		else {
-			$e = new mb_notice("Mapbender_bbox: constructor: x1, y1, x2, y2, epsg");
-			$min = new Mapbender_point($param0, $param1, $param4);
-			$max = new Mapbender_point($param2, $param3, $param4);
-			$epsg = $param4; // is an EPSG code like "EPSG:4326"
-			
-			if ($min->isWestOf($max) && $min->isSouthOf($max)) {
-				if ($min->epsg == $max->epsg && $min->epsg == $epsg) {
-					$this->min = $min;
-					$this->max = $max;
-					$this->epsg = $epsg;
-				}
-				else {
-					$e = new mb_exception("Mapbender_bbox: constructor: EPSG mismatch!");
-				}
-			}
-			else {
-				$e = new mb_exception("Mapbender_bbox: constructor: min (".$this->min.") is not southwest of max (".$this->max.")!");
-			}
-			
-		}
-	}
-	
-	/**
-	 * Computes a new bounding box, bbox1 UNION bbox2
-	 */
-	static function union ($bboxArray) {
-		if (count($bboxArray) == 1) {
-			return array_pop($bboxArray);
-		}
-		elseif (count($bboxArray) >= 2) {
-			
-			$bbox1 = array_pop($bboxArray);
-			$bbox2 = Mapbender_bbox::union($bboxArray);
-
-			if (!($bbox1 != null && $bbox1->isValid()) && !($bbox2 != null && $bbox2->isValid())) {
-				$e = new mb_exception("Mapbender_bbox: union: both parameters invalid!");
-				return null;
-			}
-			elseif (!($bbox1 != null && $bbox1->isValid()) && ($bbox2 != null && $bbox2->isValid())) {
-				$e = new mb_exception("Mapbender_bbox: union: first parameter invalid!");
-				return $bbox2;
-			}
-			elseif (($bbox1 != null && $bbox1->isValid()) && !($bbox2 != null && $bbox2->isValid())) {
-				$e = new mb_exception("Mapbender_bbox: union: second parameter invalid!");
-				return $bbox1;
-			}
-			else {
-				if ($bbox1->epsg == $bbox2->epsg) {
-					$e = new mb_notice("Mapbender_bbox: union: bbox1 is: " . $bbox1);
-					$e = new mb_notice("Mapbender_bbox: union: bbox2 is: " . $bbox2);
-					$e = new mb_notice("Mapbender_bbox: union: merging bbox1 and bbox2...");
-					return new Mapbender_bbox(Mapbender_point::min($bbox1->min, $bbox2->min), Mapbender_point::max($bbox1->max, $bbox2->max), $bbox1->epsg);
-				}
-				else {
-					$e = new mb_exception("Mapbender_bbox: cannot process union with different EPSG codes");
-				}
-			}
-		}
-		else {
-			$e = new mb_exception("Mapbender_bbox: Invalid parameter (Not an array)!");
-		}
-		return null;
-	}
-	
-	/**
-	 * transforms this bbox in another EPSG
-	 * @param toEpsg transform the bbox to this EPSG code, example: "EPSG:4326" 
-	 */
-	function transform($toEpsg) {
-		if ($this->isValid()) {
-			$this->epsg = $toEpsg;
-			$this->min->transform($toEpsg);
-			$this->max->transform($toEpsg);
-			return true;
-		}
-		return false;
-	}
-
-	/**
-	 * checks if lower left and upper right coordinate are set, as well as EPSG
-	 */
-	function isValid() {
-		if ($this->min != null && $this->max != null && $this->epsg != null) {
-			return true;
-		}
-		$e = new mb_exception("Mapbender_bbox: this is not a valid bbox!");
-		return false;
-	}
-	
-	function toHtml () {
-		return (string) $this->min->toHtml() . " | " . $this->max->toHtml(); 
-	}
-	
-	function __toString() {
-		return (string) "[" . $this->min . $this->max . " " . $this->epsg . "]"; 
-	}
-}
-?>
+<?php
+# $Id$
+# http://www.mapbender.org/index.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");
+require_once(dirname(__FILE__)."/class_point.php");
+
+/**
+ * A bounding box consisting of an lower left and an upper right point, and an EPSG.
+ */
+class Mapbender_bbox {
+	var $min;
+	var $max;
+	var $epsg;
+	
+	/**
+	 * @constructor
+	 */
+	function __construct() {
+		if (func_num_args() == 5) {
+			$param0 = func_get_arg(0);
+			$param1 = func_get_arg(1);
+			$param2 = func_get_arg(2);
+			$param3 = func_get_arg(3);
+			$param4 = func_get_arg(4);
+		}
+		else if (func_num_args() == 3) {
+			$param0 = func_get_arg(0);
+			$param1 = func_get_arg(1);
+			$param2 = func_get_arg(2);
+		}
+		else {
+			return;
+		}
+		
+		// params are point, point, epsg
+		if (is_a($param0, "Mapbender_point") && is_a($param1, "Mapbender_point") && !$param3 && !$param4) {
+			$e = new mb_notice("Mapbender_bbox: constructor: point1, point2, epsg");
+			$min = $param0; // is a Mapbender_point
+			$max = $param1; // is a Mapbender_point
+			$epsg = $param2; // is an EPSG code like "EPSG:4326"
+			
+			if ($min->isWestOf($max) && $min->isSouthOf($max)) {
+				if ($min->epsg == $max->epsg && $min->epsg == $epsg) {
+					$this->min = $min;
+					$this->max = $max;
+					$this->epsg = $epsg;
+				}
+				else {
+					$e = new mb_exception("Mapbender_bbox: constructor: EPSG mismatch!");
+				}
+			}
+			else {
+				$e = new mb_exception("Mapbender_bbox: constructor: min (".$this->min.") is not southwest of max (".$this->max.")!");
+			}
+		}
+		// params are x1, y1, x2, xy, epsg
+		else {
+			$e = new mb_notice("Mapbender_bbox: constructor: x1, y1, x2, y2, epsg");
+			$min = new Mapbender_point($param0, $param1, $param4);
+			$max = new Mapbender_point($param2, $param3, $param4);
+			$epsg = $param4; // is an EPSG code like "EPSG:4326"
+			
+			if ($min->isWestOf($max) && $min->isSouthOf($max)) {
+				if ($min->epsg == $max->epsg && $min->epsg == $epsg) {
+					$this->min = $min;
+					$this->max = $max;
+					$this->epsg = $epsg;
+				}
+				else {
+					$e = new mb_exception("Mapbender_bbox: constructor: EPSG mismatch!");
+				}
+			}
+			else {
+				$e = new mb_exception("Mapbender_bbox: constructor: min (".$this->min.") is not southwest of max (".$this->max.")!");
+			}
+			
+		}
+	}
+	
+	/**
+	 * Computes a new bounding box, bbox1 UNION bbox2
+	 */
+	static function union ($bboxArray) {
+		if (count($bboxArray) == 1) {
+			return array_pop($bboxArray);
+		}
+		elseif (count($bboxArray) >= 2) {
+			
+			$bbox1 = array_pop($bboxArray);
+			$bbox2 = Mapbender_bbox::union($bboxArray);
+
+			if (!($bbox1 != null && $bbox1->isValid()) && !($bbox2 != null && $bbox2->isValid())) {
+				$e = new mb_exception("Mapbender_bbox: union: both parameters invalid!");
+				return null;
+			}
+			elseif (!($bbox1 != null && $bbox1->isValid()) && ($bbox2 != null && $bbox2->isValid())) {
+				$e = new mb_exception("Mapbender_bbox: union: first parameter invalid!");
+				return $bbox2;
+			}
+			elseif (($bbox1 != null && $bbox1->isValid()) && !($bbox2 != null && $bbox2->isValid())) {
+				$e = new mb_exception("Mapbender_bbox: union: second parameter invalid!");
+				return $bbox1;
+			}
+			else {
+				if ($bbox1->epsg == $bbox2->epsg) {
+					$e = new mb_notice("Mapbender_bbox: union: bbox1 is: " . $bbox1);
+					$e = new mb_notice("Mapbender_bbox: union: bbox2 is: " . $bbox2);
+					$e = new mb_notice("Mapbender_bbox: union: merging bbox1 and bbox2...");
+					return new Mapbender_bbox(Mapbender_point::min($bbox1->min, $bbox2->min), Mapbender_point::max($bbox1->max, $bbox2->max), $bbox1->epsg);
+				}
+				else {
+					$e = new mb_exception("Mapbender_bbox: cannot process union with different EPSG codes");
+				}
+			}
+		}
+		else {
+			$e = new mb_exception("Mapbender_bbox: Invalid parameter (Not an array)!");
+		}
+		return null;
+	}
+	
+	/**
+	 * transforms this bbox in another EPSG
+	 * @param toEpsg transform the bbox to this EPSG code, example: "EPSG:4326" 
+	 */
+	function transform($toEpsg) {
+		if ($this->isValid()) {
+			$this->epsg = $toEpsg;
+			$this->min->transform($toEpsg);
+			$this->max->transform($toEpsg);
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * checks if lower left and upper right coordinate are set, as well as EPSG
+	 */
+	function isValid() {
+		if ($this->min != null && $this->max != null && $this->epsg != null) {
+			return true;
+		}
+		$e = new mb_exception("Mapbender_bbox: this is not a valid bbox!");
+		return false;
+	}
+	
+	function toHtml () {
+		return (string) $this->min->toHtml() . " | " . $this->max->toHtml(); 
+	}
+	
+	function __toString() {
+		return (string) "[" . $this->min . $this->max . " " . $this->epsg . "]"; 
+	}
+}
+?>

Modified: branches/print_dev/http/classes/class_checkInput.php
===================================================================
--- branches/print_dev/http/classes/class_checkInput.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_checkInput.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,56 +1,56 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/class_checkInput
-# 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");
-
-class checkInput{
-	var $v;
-	function checkInput($q,$v,$t){
-		if(is_array($v) == false){
-			$v = array($v);
-		}
-		if(is_array($t) == false){
-			$t = array($t);
-		}
-		if(count($v) != count($t)){
-			$e = new mb_exception("array params and array types have a different count  in ".$_SERVER['SCRIPT_FILENAME'].": Sql: ".$q);
-		}
-		if(PREPAREDSTATEMENTS == true && SYS_DBTYPE == "pgsql"){
-			$this->v = $v;
-		}
-		else{
-			for($i=0; $i<count($v); $i++){
-				if($t[$i] == 's'){
-					$v[$i] = db_escape_string($v[$i]);
-				}
-				else if($t[$i] == 'i'){
-					if(preg_match("/w/",$v[$i])){
-						$e = new mb_exception($_SERVER['SCRIPT_FILENAME'].": Unable to parse integer in: ".$q." with: param ".$i.",".$v[i]);
-						die("wrong data type in sql:".$q);
-					}					
-				}
-				else if($t[$i] == 'd'){
-					
-				}	
-			}
-			$this->v = $v;
-		}		
-	}	
-}
-?>
+<?php
+# $Id$
+# http://www.mapbender.org/index.php/class_checkInput
+# 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");
+
+class checkInput{
+	var $v;
+	function checkInput($q,$v,$t){
+		if(is_array($v) == false){
+			$v = array($v);
+		}
+		if(is_array($t) == false){
+			$t = array($t);
+		}
+		if(count($v) != count($t)){
+			$e = new mb_exception("array params and array types have a different count  in ".$_SERVER['SCRIPT_FILENAME'].": Sql: ".$q);
+		}
+		if(PREPAREDSTATEMENTS == true && SYS_DBTYPE == "pgsql"){
+			$this->v = $v;
+		}
+		else{
+			for($i=0; $i<count($v); $i++){
+				if($t[$i] == 's'){
+					$v[$i] = db_escape_string($v[$i]);
+				}
+				else if($t[$i] == 'i'){
+					if(preg_match("/w/",$v[$i])){
+						$e = new mb_exception($_SERVER['SCRIPT_FILENAME'].": Unable to parse integer in: ".$q." with: param ".$i.",".$v[i]);
+						die("wrong data type in sql:".$q);
+					}					
+				}
+				else if($t[$i] == 'd'){
+					
+				}	
+			}
+			$this->v = $v;
+		}		
+	}	
+}
+?>

Modified: branches/print_dev/http/classes/class_connector.php
===================================================================
--- branches/print_dev/http/classes/class_connector.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_connector.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -174,16 +174,29 @@
 			return @file_get_contents($url);
 	 	}
 		else {
+			$errno = 0;
+			$errstr = "";
 			$urlComponentArray = parse_url($url);
+			$scheme = $urlComponentArray["scheme"];
 			$host = $urlComponentArray["host"];
 			$port = $urlComponentArray["port"]; 
 			if ($port == "") {
-				$port = 80;		
+				if ($scheme == "https") {
+					$port = 443;
+				}
+				else {
+					$port = 80;		
+				}
 			}	
 			$path = $urlComponentArray["path"];
 			$query = $urlComponentArray["query"];
 			$buf = '';
-		    $fp = fsockopen($host, $port);
+			if ($scheme == "https") {
+				$fp = fsockopen("ssl://". $host, $port, $errno, $errstr);				
+			}
+			else {
+			    $fp = fsockopen($host, $port);
+			}
 			$postStr = "";
 			$postPath = "POST " . $path . "?" . $query . " HTTP/".$this->httpVersion . "\r\n";
 			$postStr .= $postPath;

Modified: branches/print_dev/http/classes/class_element.php
===================================================================
--- branches/print_dev/http/classes/class_element.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_element.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,260 +1,260 @@
-<?php
-# $Id: class_bbox.php 1965 2008-01-15 08:24:29Z christoph $
-# http://www.mapbender.org/index.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");
-
-define("ELEMENT_PATTERN", "/sessionID/");
-
-class Element {
-	
-	var $guiId;
-	var $id;
-	var $pos;
-	var $isPublic;
-	var $comment;
-	var $title;
-	var $element;
-	var $src;
-	var $attributes;
-	var $left;
-	var $top;
-	var $width;
-	var $height;
-	var $zIndex;
-	var $moreStyles;
-	var $content;
-	var $closeTag;
-	var $jsFile;
-	var $mbMod;
-	var $target;
-	var $requires;
-	var $helpUrl;
-	var $isBodyAndUsesSplashScreen = false;
-	
-	public function __contruct() {
-		
-	}
-	
-	public function select ($id, $applicationId) {
-		$sql = "SELECT fkey_gui_id, e_id, e_pos, e_public, e_comment, e_public, ".
-				"gettext($1, e_title) as 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 FROM gui_element WHERE e_id = $2 AND " .
-				"fkey_gui_id = $3 LIMIT 1";
-		$v = array ($_SESSION["mb_lang"], $id, $applicationId);
-		$t = array ("s", "s", "s");
-		$res = db_prep_query($sql, $v, $t);
-		$row = db_fetch_array($res);
-		if ($row) {
-			$this->guiId = $applicationId;
-			$this->id = $row["e_id"];
-			$this->pos = $row["e_pos"];
-			$this->isPublic = $row["e_public"];
-			$this->comment = $row["e_comment"];
-			$this->title = $row["e_title"];
-			$this->element = $row["e_element"];
-			$this->src = $row["e_src"];
-			$this->attributes = $row["e_attributes"];
-			$this->left = $row["e_left"];
-			$this->top = $row["e_top"];
-			$this->width = $row["e_width"];
-			$this->height = $row["e_height"];
-			$this->zIndex = $row["e_z_index"];
-			$this->moreStyles = $row["e_more_styles"];
-			$this->content = $row["e_content"];
-			$this->closeTag = $row["e_closetag"];
-			$this->jsFile = $row["e_js_file"];
-			$this->mbMod = $row["e_mb_mod"];
-			$this->target = $row["e_target"];
-			$this->requires = $row["e_requires"];
-			$this->helpUrl = $row["e_url"];
-			return true;
-		}
-		return false;		
-	}
-	
-	public function __toString () {
-		return $this->toHtml();
-	}
-	
-	public function getJavaScriptModules () {
-		$jsArray = array();
-		if ($this->mbMod != "") {
-			$moduleArray = explode(",", $this->mbMod);
-			for ($i = 0; $i < count($moduleArray); $i++) {
-				$currentFile = dirname(__FILE__) . "/../javascripts/" . trim($moduleArray[$i]);
-				if (file_exists($currentFile)) {
-					array_push($jsArray, $currentFile);
-				}
-				else {
-					$e = new mb_exception("Javascript module not found: " . $currentFile);
-				}
-			}
-		}
-		return $jsArray;
-	}
-	
-	public function toHtmlArray () {
-		if ($this->isPublic) {
-			return array($this->getHtmlOpenTag(), $this->getHtmlContent(), $this->getHtmlCloseTag());	
-		}
-		return array("", "", "");
-	}
-	
-	public function toHtml () {
-		if ($this->isPublic) {
-			return implode("", $this->toHtmlArray());
-		}
-		return "";
-	}
-
-	private function getHtmlOpenTag () {
-		$openTag = "";
-	
-		if ($this->id) {
-			// tag name
-			$openTag .= "<" . $this->element . " ";
-			
-			// id and name
-			$openTag .= "id='" . $this->id . "' name='" . $this->id . "' ";
-			
-			// attributes
-			if ($this->attributes) {
-				$openTag .= stripslashes($this->replaceSessionStringByUrlParameters($this->attributes)) . " ";
-			}
-			
-			// title
-			if ($this->title) {
-				$openTag .= "title='" . $this->title . "' ";
-			}
-			
-			// src
-			if ($this->src) {
-   				$openTag .= "src = '" . $this->replaceSessionStringByUrlParameters($this->src);
-
-				// for iframes which are not "loadData", 
-				// add additional parameters
-				if ($this->closeTag == "iframe" && $this->id != "loadData") {
-					if(mb_strpos($this->src, "?")) {
-						$openTag .= "&";
-					}
-					else {
-	      				$openTag .= "?";
-      				}
-	      			$openTag .= "e_id_css=" . $this->id . "&" .
-	      					 "e_id= " . $this->id . "&" .
-	      					 "e_target=" . $this->target . "&" .
-	      					 $this->getUrlParameters();
-				}
-   				$openTag .= "' ";
-			}
-			
-			// style
-			$openTag .= " style = '";
-			if ($this->top != "" && $this->left != "") {
-				$openTag .= "position:absolute;" .
-						 "left:" . $this->left . ";" .
-						 "top:" . $this->top . ";";
-			}
-			if ($this->width != "" && $this->height != "") {
-				$openTag .= "width:" . $this->width . ";" .
-						 "height:" . $this->height . ";";
-			}
-			if ($this->zIndex) {
-		    	$openTag .= "z-index:" . $this->zIndex . ";";
-			}
-			if ($this->moreStyles) {
-		    	$openTag .= $this->moreStyles;
-			}
-			$openTag .= "'>";
-
-			if ($this->element == "body") {
-				$e_id = "body";
-				$gui_id = $this->guiId;
-				include(dirname(__FILE__)."/../include/dyn_php.php");
-				
-				$splashScreen = "";
-				
-				if ($use_load_message) {
-					$this->isBodyAndUsesSplashScreen = true;
-					if (isset($htmlWhileLoading) && $htmlWhileLoading != '') {
-						$splashScreen .= $htmlWhileLoading; 
-					} elseif (isset($includeWhileLoading) && $includeWhileLoading != '' && file_exists(dirname(__FILE__)."/".$includeWhileLoading)) { 
-						ob_start();
-						include(dirname(__FILE__)."/".$includeWhileLoading);
-						$splashScreen .= ob_get_contents();
-						ob_end_clean();
-					}
-					else {
-						$splashScreen .= "<img src='../img/indicator_wheel.gif'>&nbsp;" . 
-							"<b>Ma<font color='#0000CE'>p</font><font color='#C00000'>b</font>ender " . 
-							MB_VERSION_NUMBER . " " . strtolower(MB_VERSION_APPENDIX) . "</b>..." .
-							"loading application '" . $this->guiId . "'";
-					}
-				}	
-				$openTag .= "<p id='loading_mapbender' " .
-								"style='margin:0px;padding:0px;width:100%;height:100%;'>" . 
-								$splashScreen . "</p>" . 
-								"<p id='complete_mapbender' " .
-								"style='display:none'>";
-				unset ($e_id, $gui_id);
-			}
-		}
-		return $openTag;
-	}
-	
-	private function getHtmlContent () {
-		$htmlContent = "";
-		if ($this->content != "") {
-			$htmlContent .= stripslashes($this->content);
-		}
-		return $htmlContent;
-	}
-	
-	private function getHtmlCloseTag () {
-		if ($this->element == "body" && $this->isBodyAndUsesSplashScreen) {
-			return "</p></body>";
-		}
-		if ($this->closeTag != "") {
-			return "</" . $this->closeTag . ">";
-		}
-		return "";
-	}
-	
-	private function getUrlParameters () {
-		$urlParameters = SID;
-		if (isset($this->guiId)) {
-			$urlParameters .= "&guiID=" . $this->guiId;
-		}
-		if (isset($this->id)) {
-			$urlParameters .= "&elementID=" . $this->id;
-		}
-		return $urlParameters;
-	}
-	
-	private function replaceSessionStringByUrlParameters ($string) {
-		$urlParameters = $this->getUrlParameters();
-		return preg_replace(ELEMENT_PATTERN, $urlParameters, $string);
-	}
-	
-}
-
-
+<?php
+# $Id: class_bbox.php 1965 2008-01-15 08:24:29Z christoph $
+# http://www.mapbender.org/index.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");
+
+define("ELEMENT_PATTERN", "/sessionID/");
+
+class Element {
+	
+	var $guiId;
+	var $id;
+	var $pos;
+	var $isPublic;
+	var $comment;
+	var $title;
+	var $element;
+	var $src;
+	var $attributes;
+	var $left;
+	var $top;
+	var $width;
+	var $height;
+	var $zIndex;
+	var $moreStyles;
+	var $content;
+	var $closeTag;
+	var $jsFile;
+	var $mbMod;
+	var $target;
+	var $requires;
+	var $helpUrl;
+	var $isBodyAndUsesSplashScreen = false;
+	
+	public function __contruct() {
+		
+	}
+	
+	public function select ($id, $applicationId) {
+		$sql = "SELECT fkey_gui_id, e_id, e_pos, e_public, e_comment, e_public, ".
+				"gettext($1, e_title) as 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 FROM gui_element WHERE e_id = $2 AND " .
+				"fkey_gui_id = $3 LIMIT 1";
+		$v = array ($_SESSION["mb_lang"], $id, $applicationId);
+		$t = array ("s", "s", "s");
+		$res = db_prep_query($sql, $v, $t);
+		$row = db_fetch_array($res);
+		if ($row) {
+			$this->guiId = $applicationId;
+			$this->id = $row["e_id"];
+			$this->pos = $row["e_pos"];
+			$this->isPublic = $row["e_public"];
+			$this->comment = $row["e_comment"];
+			$this->title = $row["e_title"];
+			$this->element = $row["e_element"];
+			$this->src = $row["e_src"];
+			$this->attributes = $row["e_attributes"];
+			$this->left = $row["e_left"];
+			$this->top = $row["e_top"];
+			$this->width = $row["e_width"];
+			$this->height = $row["e_height"];
+			$this->zIndex = $row["e_z_index"];
+			$this->moreStyles = $row["e_more_styles"];
+			$this->content = $row["e_content"];
+			$this->closeTag = $row["e_closetag"];
+			$this->jsFile = $row["e_js_file"];
+			$this->mbMod = $row["e_mb_mod"];
+			$this->target = $row["e_target"];
+			$this->requires = $row["e_requires"];
+			$this->helpUrl = $row["e_url"];
+			return true;
+		}
+		return false;		
+	}
+	
+	public function __toString () {
+		return $this->toHtml();
+	}
+	
+	public function getJavaScriptModules () {
+		$jsArray = array();
+		if ($this->mbMod != "") {
+			$moduleArray = explode(",", $this->mbMod);
+			for ($i = 0; $i < count($moduleArray); $i++) {
+				$currentFile = dirname(__FILE__) . "/../javascripts/" . trim($moduleArray[$i]);
+				if (file_exists($currentFile)) {
+					array_push($jsArray, $currentFile);
+				}
+				else {
+					$e = new mb_exception("Javascript module not found: " . $currentFile);
+				}
+			}
+		}
+		return $jsArray;
+	}
+	
+	public function toHtmlArray () {
+		if ($this->isPublic) {
+			return array($this->getHtmlOpenTag(), $this->getHtmlContent(), $this->getHtmlCloseTag());	
+		}
+		return array("", "", "");
+	}
+	
+	public function toHtml () {
+		if ($this->isPublic) {
+			return implode("", $this->toHtmlArray());
+		}
+		return "";
+	}
+
+	private function getHtmlOpenTag () {
+		$openTag = "";
+	
+		if ($this->id) {
+			// tag name
+			$openTag .= "<" . $this->element . " ";
+			
+			// id and name
+			$openTag .= "id='" . $this->id . "' name='" . $this->id . "' ";
+			
+			// attributes
+			if ($this->attributes) {
+				$openTag .= stripslashes($this->replaceSessionStringByUrlParameters($this->attributes)) . " ";
+			}
+			
+			// title
+			if ($this->title) {
+				$openTag .= "title='" . $this->title . "' ";
+			}
+			
+			// src
+			if ($this->src) {
+   				$openTag .= "src = '" . $this->replaceSessionStringByUrlParameters($this->src);
+
+				// for iframes which are not "loadData", 
+				// add additional parameters
+				if ($this->closeTag == "iframe" && $this->id != "loadData") {
+					if(mb_strpos($this->src, "?")) {
+						$openTag .= "&";
+					}
+					else {
+	      				$openTag .= "?";
+      				}
+	      			$openTag .= "e_id_css=" . $this->id . "&" .
+	      					 "e_id= " . $this->id . "&" .
+	      					 "e_target=" . $this->target . "&" .
+	      					 $this->getUrlParameters();
+				}
+   				$openTag .= "' ";
+			}
+			
+			// style
+			$openTag .= " style = '";
+			if ($this->top != "" && $this->left != "") {
+				$openTag .= "position:absolute;" .
+						 "left:" . $this->left . ";" .
+						 "top:" . $this->top . ";";
+			}
+			if ($this->width != "" && $this->height != "") {
+				$openTag .= "width:" . $this->width . ";" .
+						 "height:" . $this->height . ";";
+			}
+			if ($this->zIndex) {
+		    	$openTag .= "z-index:" . $this->zIndex . ";";
+			}
+			if ($this->moreStyles) {
+		    	$openTag .= $this->moreStyles;
+			}
+			$openTag .= "'>";
+
+			if ($this->element == "body") {
+				$e_id = "body";
+				$gui_id = $this->guiId;
+				include(dirname(__FILE__)."/../include/dyn_php.php");
+				
+				$splashScreen = "";
+				
+				if ($use_load_message) {
+					$this->isBodyAndUsesSplashScreen = true;
+					if (isset($htmlWhileLoading) && $htmlWhileLoading != '') {
+						$splashScreen .= $htmlWhileLoading; 
+					} elseif (isset($includeWhileLoading) && $includeWhileLoading != '' && file_exists(dirname(__FILE__)."/".$includeWhileLoading)) { 
+						ob_start();
+						include(dirname(__FILE__)."/".$includeWhileLoading);
+						$splashScreen .= ob_get_contents();
+						ob_end_clean();
+					}
+					else {
+						$splashScreen .= "<img src='../img/indicator_wheel.gif'>&nbsp;" . 
+							"<b>Ma<font color='#0000CE'>p</font><font color='#C00000'>b</font>ender " . 
+							MB_VERSION_NUMBER . " " . strtolower(MB_VERSION_APPENDIX) . "</b>..." .
+							"loading application '" . $this->guiId . "'";
+					}
+				}	
+				$openTag .= "<div id='loading_mapbender' " .
+								"style='margin:0px;padding:0px;width:100%;height:100%;'>" . 
+								$splashScreen . "</div>" . 
+								"<div id='complete_mapbender' " .
+								"style='display:none'>";
+				unset ($e_id, $gui_id);
+			}
+		}
+		return $openTag;
+	}
+	
+	private function getHtmlContent () {
+		$htmlContent = "";
+		if ($this->content != "") {
+			$htmlContent .= stripslashes($this->content);
+		}
+		return $htmlContent;
+	}
+	
+	private function getHtmlCloseTag () {
+		if ($this->element == "body" && $this->isBodyAndUsesSplashScreen) {
+			return "</div></body>";
+		}
+		if ($this->closeTag != "") {
+			return "</" . $this->closeTag . ">";
+		}
+		return "";
+	}
+	
+	private function getUrlParameters () {
+		$urlParameters = SID;
+		if (isset($this->guiId)) {
+			$urlParameters .= "&guiID=" . $this->guiId;
+		}
+		if (isset($this->id)) {
+			$urlParameters .= "&elementID=" . $this->id;
+		}
+		return $urlParameters;
+	}
+	
+	private function replaceSessionStringByUrlParameters ($string) {
+		$urlParameters = $this->getUrlParameters();
+		return preg_replace(ELEMENT_PATTERN, $urlParameters, $string);
+	}
+	
+}
+
+
 ?>
\ No newline at end of file

Modified: branches/print_dev/http/classes/class_gml_2_factory.php
===================================================================
--- branches/print_dev/http/classes/class_gml_2_factory.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_gml_2_factory.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -48,16 +48,21 @@
 		return $nodeName;
 	}
 
-	private function parsePoint ($domNode, $gmlPoint) {
+	public static function parsePoint ($domNode) {
+		$gmlPoint = new GmlPoint();
+		
 		$currentSibling = $domNode->firstChild;
 		while ($currentSibling) {
 			list($x, $y, $z) = explode(",", $currentSibling->nodeValue);
 			$gmlPoint->setPoint($x, $y);
 			$currentSibling = $currentSibling->nextSibling;
 		}
+		return $gmlPoint;
 	}
 
-	private function parseLine ($domNode, $gmlLine) {
+	public static function parseLine ($domNode) {
+		$gmlLine = new GmlLine();
+		
 		$currentSibling = $domNode->firstChild;
 		while ($currentSibling) {
 			
@@ -67,9 +72,12 @@
 			}
 			$currentSibling = $currentSibling->nextSibling;
 		}
+		return $gmlLine;
 	}
 
-	private function parsePolygon ($domNode, $gmlPolygon) {
+	public static function parsePolygon ($domNode) {
+		$gmlPolygon = new GmlPolygon();
+		
 		$simpleXMLNode = simplexml_import_dom($domNode);
 
 		$simpleXMLNode->registerXPathNamespace('gml', 'http://www.opengis.net/gml');
@@ -106,9 +114,12 @@
 				$ringCount++;
 			}
 		}
+		return $gmlPolygon;
 	}
 
-	private function parseMultiLine ($domNode, $gmlMultiLine) {
+	public static function parseMultiLine ($domNode) {
+		$gmlMultiLine = new GmlMultiLine();
+		
 		$simpleXMLNode = simplexml_import_dom($domNode);
 
 		$simpleXMLNode->registerXPathNamespace('gml', 'http://www.opengis.net/gml');
@@ -133,10 +144,12 @@
 			
 			$cnt++;
 		}
+		return $gmlMultiLine;
 	}		
 	
-	private function parseMultiPolygon ($domNode, $gmlMultiPolygon) {
-//		echo $domNode->nodeName."<br>";
+	public static function parseMultiPolygon ($domNode) {
+		$gmlMultiPolygon = new GmlMultiPolygon();
+		
 		$simpleXMLNode = simplexml_import_dom($domNode);
 
 		$simpleXMLNode->registerXPathNamespace('gml', 'http://www.opengis.net/gml');
@@ -181,8 +194,8 @@
 				}
 			}
 			$cnt++;
-//			new mb_exception("create multipolygon " . serialize($gmlMultiPolygon->innerRingArray));
 		}		
+		return $gmlMultiPolygon;
 	}
 	
 	/**
@@ -260,29 +273,24 @@
 				$geomType = $geomNode->nodeName;
 				switch ($geomType) {
 					case "gml:Polygon" :
-						$feature->geometry = new GMLPolygon();
+						$feature->geometry = self::parsePolygon($geomNode);
 						$feature->geometry->srs = $srs;
-						$this->parsePolygon($geomNode, $feature->geometry);
 						break;
 					case "gml:LineString" :
-						$feature->geometry = new GMLLine();
+						$feature->geometry = self::parseLine($geomNode);
 						$feature->geometry->srs = $srs;
-						$this->parseLine($geomNode, $feature->geometry);
 						break;
 					case "gml:Point" :
-						$feature->geometry = new GMLPoint();
+						$feature->geometry = self::parsePoint($geomNode);
 						$feature->geometry->srs = $srs;
-						$this->parsePoint($geomNode, $feature->geometry);
 						break;
 					case "gml:MultiLineString" :
-						$feature->geometry = new GMLMultiLine();
+						$feature->geometry = self::parseMultiLine($geomNode);
 						$feature->geometry->srs = $srs;
-						$this->parseMultiLine($geomNode, $feature->geometry);
 						break;
 					case "gml:MultiPolygon" :
-						$feature->geometry = new GMLMultiPolygon();
+						$feature->geometry = self::parseMultiPolygon($geomNode);
 						$feature->geometry->srs = $srs;
-						$this->parseMultiPolygon($geomNode, $feature->geometry);
 						break;
 					default:
 						$feature->properties[$columnName] = $value;

Modified: branches/print_dev/http/classes/class_gml_3_factory.php
===================================================================
--- branches/print_dev/http/classes/class_gml_3_factory.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_gml_3_factory.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -53,7 +53,7 @@
 		return parent::createFromXml($xml, $wfsConf, $gml3);
 	}	
 
-	protected function getDimensionFromNode ($domNode) {
+	public static function getDimensionFromNode ($domNode) {
 		if (!$domNode->hasAttribute("srsDimension")) {
 			return 2;
 		}
@@ -70,20 +70,24 @@
 		return $nodeName;
 	}
 
-	private function parsePoint ($domNode, $gmlPoint) {
+	public static function parsePoint ($domNode) {
+		$gmlPoint = new GmlPoint();
 		$currentSibling = $domNode->firstChild;
 		while ($currentSibling) {
 			$coordArray = explode(" ", $currentSibling->nodeValue);
 			$gmlPoint->setPoint($coordArray[0], $coordArray[1]);
 			$currentSibling = $currentSibling->nextSibling;
 		}
+		return $gmlPoint;
 	}
 
-	private function parseLine ($domNode, $gmlLine) {
+	public static function parseLine ($domNode) {
+		$gmlLine = new GmlLine();
+		
 		$currentSibling = $domNode->firstChild;
 		while ($currentSibling) {
 
-			$dim = $this->getDimensionFromNode($currentSibling);
+			$dim = self::getDimensionFromNode($currentSibling);
 			$coordArray = explode(' ', trim($currentSibling->nodeValue));
 			for ($i = 0; $i < count($coordArray); $i += $dim) {
 				$x = $coordArray[$i];
@@ -92,9 +96,12 @@
 			}
 			$currentSibling = $currentSibling->nextSibling;
 		}
+		return $gmlLine;
 	}
 
-	private function parsePolygon ($domNode, $gmlPolygon) {
+	public static function parsePolygon ($domNode) {
+		$gmlPolygon = new GmlPolygon();
+		
 		$simpleXMLNode = simplexml_import_dom($domNode);
 
 		$simpleXMLNode->registerXPathNamespace('gml', 'http://www.opengis.net/gml');
@@ -105,7 +112,7 @@
 		foreach ($allCoords as $Coords) {
 			$coordsDom = dom_import_simplexml($Coords);
 			
-			$dim = $this->getDimensionFromNode($coordsDom);
+			$dim = self::getDimensionFromNode($coordsDom);
 			$coordArray = explode(' ', trim($coordsDom->nodeValue));
 			for ($i = 0; $i < count($coordArray); $i += $dim) {
 				$x = $coordArray[$i];
@@ -123,7 +130,7 @@
 				foreach ($coordinates as $coordinate) {
 					$coordsDom = dom_import_simplexml($coordinate);
 						
-					$dim = $this->getDimensionFromNode($coordsDom);
+					$dim = self::getDimensionFromNode($coordsDom);
 					$coordArray = explode(' ', trim($coordsDom->nodeValue));
 					for ($i = 0; $i < count($coordArray); $i += $dim) {
 						$x = $coordArray[$i];
@@ -134,9 +141,12 @@
 				$ringCount++;
 			}
 		}
+		return $gmlPolygon;
 	}
 
-	private function parseMultiLine ($domNode, $gmlMultiLine) {
+	public static function parseMultiLine ($domNode) {
+		$gmlMultiLine = new GmlMultiLine();
+		
 		$simpleXMLNode = simplexml_import_dom($domNode);
 
 		$simpleXMLNode->registerXPathNamespace('gml', 'http://www.opengis.net/gml');
@@ -150,7 +160,7 @@
 			
 			$coordsDom = dom_import_simplexml($Coords);
 
-			$dim = $this->getDimensionFromNode($coordsDom);
+			$dim = self::getDimensionFromNode($coordsDom);
 			$coordArray = explode(' ', trim($coordsDom->nodeValue));
 			for ($i = 0; $i < count($coordArray); $i += $dim) {
 				$x = $coordArray[$i];
@@ -159,9 +169,12 @@
 			}
 			$cnt++;
 		}
+		return $gmlMultiLine;
 	}		
 	
-	private function parseMultiPolygon ($domNode, $gmlMultiPolygon) {
+	public static function parseMultiPolygon ($domNode) {
+		$gmlMultiPolygon = new GmlMultiPolygon();
+		
 		$simpleXMLNode = simplexml_import_dom($domNode);
 
 		$simpleXMLNode->registerXPathNamespace('gml', 'http://www.opengis.net/gml');
@@ -177,7 +190,7 @@
 				
 				$coordsDom = dom_import_simplexml($Coords);
 
-				$dim = $this->getDimensionFromNode($coordsDom);
+				$dim = self::getDimensionFromNode($coordsDom);
 				$coordArray = explode(' ', trim($coordsDom->nodeValue));
 				for ($i = 0; $i < count($coordArray); $i += $dim) {
 					$x = $coordArray[$i];
@@ -197,7 +210,7 @@
 						foreach ($coordinates as $coordinate) {
 							$coordsDom = dom_import_simplexml($coordinate);
 								
-							$dim = $this->getDimensionFromNode($coordsDom);
+							$dim = self::getDimensionFromNode($coordsDom);
 							$coordArray = explode(' ', trim($coordsDom->nodeValue));
 							for ($i = 0; $i < count($coordArray); $i += $dim) {
 								$x = $coordArray[$i];
@@ -212,7 +225,8 @@
 			}
 			$cnt++;
 //			new mb_exception("create multipolygon " . serialize($gmlMultiPolygon->innerRingArray));
-		}		
+		}
+		return $gmlMultiPolygon;		
 	}
 	
 	/**
@@ -293,29 +307,39 @@
 				}
 				switch ($geomType) {
 					case "gml:Polygon" :// untested!
-						$feature->geometry = new GMLPolygon();
+						$feature->geometry = self::parsePolygon($geomNode);
+						if ($feature->geometry->isEmpty()) {
+							$feature->geometry = Gml_2_Factory::parsePolygon($geomNode);
+						}
 						$feature->geometry->srs = $srs;
-						$this->parsePolygon($geomNode, $feature->geometry);
 						break;
 					case "gml:LineString" :// untested!
-						$feature->geometry = new GMLLine();
+						$feature->geometry = self::parseLine($geomNode);
+						if ($feature->geometry->isEmpty()) {
+							$feature->geometry = Gml_2_Factory::parseLine($geomNode);
+						}
 						$feature->geometry->srs = $srs;
-						$this->parseLine($geomNode, $feature->geometry);
 						break;
 					case "gml:Point" :
-						$feature->geometry = new GMLPoint();
+						$feature->geometry = self::parsePoint($geomNode);
+						if ($feature->geometry->isEmpty()) {
+							$feature->geometry = Gml_2_Factory::parsePoint($geomNode);
+						}
 						$feature->geometry->srs = $srs;
-						$this->parsePoint($geomNode, $feature->geometry);
 						break;
 					case "gml:MultiCurve" :
-						$feature->geometry = new GMLMultiLine();
+						$feature->geometry = self::parseMultiLine($geomNode);
+						if ($feature->geometry->isEmpty()) {
+							$feature->geometry = Gml_2_Factory::parseMultiLine($geomNode);
+						}
 						$feature->geometry->srs = $srs;
-						$this->parseMultiLine($geomNode, $feature->geometry);
 						break;
 					case "gml:MultiSurface" : 
-						$feature->geometry = new GMLMultiPolygon();
+						$feature->geometry = self::parseMultiPolygon($geomNode);
+						if ($feature->geometry->isEmpty()) {
+							$feature->geometry = Gml_2_Factory::parseMultiPolygon($geomNode);
+						}
 						$feature->geometry->srs = $srs;
-						$this->parseMultiPolygon($geomNode, $feature->geometry);
 						break;
 					default:
 						$feature->properties[$columnName] = $value;

Modified: branches/print_dev/http/classes/class_gml_factory.php
===================================================================
--- branches/print_dev/http/classes/class_gml_factory.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_gml_factory.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -44,8 +44,6 @@
 		$jsonObj = $json->decode($geoJson);
 
 		// check if valid feature collection
-		new mb_exception("Is Array? " . is_array($jsonObj->features));
-		new mb_exception("Type? " . strtoupper($jsonObj->type));
 		if (strtoupper($jsonObj->type) != "FEATURECOLLECTION" || !is_array($jsonObj->features)) {
 			$e = new mb_exception("Not a valid GeoJSON Feature Collection.");
 			return null;

Modified: branches/print_dev/http/classes/class_gml_line.php
===================================================================
--- branches/print_dev/http/classes/class_gml_line.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_gml_line.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -64,6 +64,10 @@
 		return $str;
 	}
 
+	public function isEmpty () {
+		return !(count($this->pointArray) > 0);
+	}
+
 	public function toGeoJSON () {
 		$numberOfPoints = count($this->pointArray);
 		$str = "";

Modified: branches/print_dev/http/classes/class_gml_multiline.php
===================================================================
--- branches/print_dev/http/classes/class_gml_multiline.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_gml_multiline.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -65,6 +65,10 @@
 		
 	}
 
+	public function isEmpty () {
+		return !(count($this->lineArray) > 0);
+	}
+	
 	public function toGeoJSON () {
 		$numberlineArray = count($this->lineArray);
 		$str = "";

Modified: branches/print_dev/http/classes/class_gml_multipolygon.php
===================================================================
--- branches/print_dev/http/classes/class_gml_multipolygon.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_gml_multipolygon.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -125,6 +125,10 @@
 		return $str;		
 		
 	}
+
+	public function isEmpty () {
+		return !(count($this->polygonArray) > 0);
+	}
 	
 	public function toGeoJSON () {
 		$numberPolygonArray = count($this->polygonArray);

Modified: branches/print_dev/http/classes/class_gml_point.php
===================================================================
--- branches/print_dev/http/classes/class_gml_point.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_gml_point.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -48,6 +48,10 @@
 		return $str;		
 	}
 
+	public function isEmpty () {
+		return ($this->point ? false : true);
+	}
+
 	public function toGeoJSON () {
 		$str = "";
 		if ($this->point) {

Modified: branches/print_dev/http/classes/class_gml_polygon.php
===================================================================
--- branches/print_dev/http/classes/class_gml_polygon.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_gml_polygon.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -99,6 +99,10 @@
 		return $str;
 	}
 	
+	public function isEmpty () {
+		return !(count($this->pointArray) > 0);
+	}
+	
 	public function toGeoJSON () {
 		$numberOfPoints = count($this->pointArray);
 		$str = "";

Modified: branches/print_dev/http/classes/class_kml.php
===================================================================
--- branches/print_dev/http/classes/class_kml.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_kml.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,176 +1,176 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/class_wmc.php
-# Copyright (C) 2002 CCGIS 
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require_once(dirname(__FILE__)."/../../core/globalSettings.php");
-
-class kml {
-
-		var $kml_id;
-		var $lookAt_range = 5000;
-		var $lookAt_heading = 0;
-		var $lookAt_tilt = 0;
-		var $description;
-		var $title;
-		var $icon;
-		var $x;
-		var $y;
-		var $kml;
-					
-	function kml($title, $description, $x, $y, $icon) {
-  		$this->kml_id = md5(microtime());
-  		$this->x = $x;
-  		$this->y = $y;
-  		$this->icon = $icon;
-  		$this->title = $title;
-  		$this->description = $description;
-	} 
-
-	function setLookAt($range, $heading) {
-		$this->lookAt_range = $range;
-		$this->lookAt_heading = $heading;
-	}
-	
-	function createObjFromKML($kml_doc) {
-		$section = null;
-		$values = null;
-		$tags = null;
-
-		$data = $kml_doc;
-		
-		if(!$data){
-			echo "document empty.";
-			return false;
-		}
-		
-		$this->kml = $data;
-
-		$parser = xml_parser_create(CHARSET);
-		xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
-		xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
-		xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING,CHARSET);
-		xml_parse_into_struct($parser,$data,$values,$tags);
-		xml_parser_free($parser);
-		
-		$cnt_format = 0;
-		$parent = array();
-		$myParent = array();
-		$cnt_layer = -1;
-		$layer_style = array();
-		$cnt_styles = -1;
-		
-		foreach ($values as $element) {
-			if(mb_strtoupper($element[tag]) == "KML" && $element[type] == "open"){
-				$section = "kml";
-			}
-			if ($section == "kml" && mb_strtoupper($element[tag]) == "PLACEMARK" && $element[type] == "open") {
-				$section = "placemark";
-			}
-			if ($section == "placemark" && mb_strtoupper($element[tag]) == "DESCRIPTION" && $element[type] == "complete") {
-				$this->description = $element[value];
-			}
-			if ($section == "placemark" && mb_strtoupper($element[tag]) == "NAME" && $element[type] == "complete") {
-				$this->title = $element[value];
-			}
-			if ($section == "placemark" && mb_strtoupper($element[tag]) == "LOOKAT" && $element[type] == "open") {
-				$section = "lookat";
-			}
-			if ($section == "lookat") {
-				
-				if (mb_strtoupper($element[tag]) == "RANGE" && $element[type] == "complete") {
-					$this->lookAt_range = $element[value]; 
-				}
-				if (mb_strtoupper($element[tag]) == "HEADING" && $element[type] == "complete") {
-					$this->lookAt_heading = $element[value]; 
-				}
-				if (mb_strtoupper($element[tag]) == "TILT" && $element[type] == "complete") {
-					$this->lookAt_tilt = $element[value]; 
-				}
-			}
-			if (mb_strtoupper($element[tag]) == "STYLE" && $element[type] == "open") {
-				$section = "style";
-			}
-			if ($section == "style" && mb_strtoupper($element[tag]) == "ICONSTYLE" && $element[type] == "open") {
-				$section = "iconstyle";
-			}
-			if ($section == "iconstyle" && mb_strtoupper($element[tag]) == "ICON" && $element[type] == "open") {
-				$section = "icon";
-			}
-			if ($section == "icon" && mb_strtoupper($element[tag]) == "HREF" && $element[type] == "complete") {
-				$this->icon = $element[value];
-			}
-			if (mb_strtoupper($element[tag]) == "POINT" && $element[type] == "open") {
-				$section = "point";
-			}
-			if ($section == "point" && mb_strtoupper($element[tag]) == "COORDINATES" && $element[type] == "complete") {
-				$array = explode(",", $element[value]);
-				$this->x = $array[0];
-				$this->y = $array[1];
-			}
-		}
-		return true;
-	}
-
-	function createObjFromDB($kml_id) {
-		$this->kml_id = $kml_id;
-
-		$sql = "SELECT kml FROM mb_meetingpoint WHERE mb_meetingpoint_id = $1";
-		$v = array($kml_id);
-		$t = array('s');
-		$res = db_prep_query($sql, $v, $t);
-		$row = db_fetch_array($res);
-		return $this->createObjFromKML($row['kml']);
-	}
-
-	function createKMLFromObj(){
-		$kml = "";
-		$kml .= "<?xml version=\"1.0\" encoding=\"".CHARSET."\"?>\n";
-		$kml .= "<kml xmlns=\"http://earth.google.com/kml/2.0\">\n";
-		$kml .= "<Placemark>\n";
-		$kml .= "\t<description>" . $this->description . "</description>\n";
-		$kml .= "\t<name>" . $this->title . "</name>\n";
-		$kml .= "\t<LookAt>\n";
-		$kml .= "\t\t<longitude>" . $this->x . "</longitude>\n";
-		$kml .= "\t\t<latitude>" . $this->y . "</latitude>\n";
-		$kml .= "\t\t<range>" . $this->lookAt_range . "</range>\n";
-		$kml .= "\t\t<tilt>" . $this->lookAt_tilt . "</tilt>\n";
-		$kml .= "\t\t<heading>" . $this->lookAt_heading . "</heading>\n";
-		$kml .= "\t</LookAt>\n";
-		$kml .= "\t<visibility>0</visibility>\n";
-		$kml .= "\t<Style>\n";
-		$kml .= "\t\t<IconStyle>\n";
-		$kml .= "\t\t\t<Icon>\n";
-		$kml .= "\t\t\t\t<href>" . $this->icon . "</href>\n";
-		$kml .= "\t\t\t</Icon>\n";
-		$kml .= "\t\t</IconStyle>\n";
-		$kml .= "\t</Style>\n";
-		$kml .= "\t<Point>\n";
-		$kml .= "\t\t<extrude>1</extrude>\n";
-		$kml .= "\t\t<coordinates>" . $this->x . "," . $this->y . "</coordinates>\n";
-		$kml .= "\t</Point>\n";
-		$kml .= "</Placemark>\n";
-		$kml .= "</kml>";
-		
-		$this->kml = $kml;
-		
-		return $kml;
-	}
-
-} 
-// end class
-?>
+<?php
+# $Id$
+# http://www.mapbender.org/index.php/class_wmc.php
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+
+class kml {
+
+		var $kml_id;
+		var $lookAt_range = 5000;
+		var $lookAt_heading = 0;
+		var $lookAt_tilt = 0;
+		var $description;
+		var $title;
+		var $icon;
+		var $x;
+		var $y;
+		var $kml;
+					
+	function kml($title, $description, $x, $y, $icon) {
+  		$this->kml_id = md5(microtime());
+  		$this->x = $x;
+  		$this->y = $y;
+  		$this->icon = $icon;
+  		$this->title = $title;
+  		$this->description = $description;
+	} 
+
+	function setLookAt($range, $heading) {
+		$this->lookAt_range = $range;
+		$this->lookAt_heading = $heading;
+	}
+	
+	function createObjFromKML($kml_doc) {
+		$section = null;
+		$values = null;
+		$tags = null;
+
+		$data = $kml_doc;
+		
+		if(!$data){
+			echo "document empty.";
+			return false;
+		}
+		
+		$this->kml = $data;
+
+		$parser = xml_parser_create(CHARSET);
+		xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
+		xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
+		xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING,CHARSET);
+		xml_parse_into_struct($parser,$data,$values,$tags);
+		xml_parser_free($parser);
+		
+		$cnt_format = 0;
+		$parent = array();
+		$myParent = array();
+		$cnt_layer = -1;
+		$layer_style = array();
+		$cnt_styles = -1;
+		
+		foreach ($values as $element) {
+			if(mb_strtoupper($element[tag]) == "KML" && $element[type] == "open"){
+				$section = "kml";
+			}
+			if ($section == "kml" && mb_strtoupper($element[tag]) == "PLACEMARK" && $element[type] == "open") {
+				$section = "placemark";
+			}
+			if ($section == "placemark" && mb_strtoupper($element[tag]) == "DESCRIPTION" && $element[type] == "complete") {
+				$this->description = $element[value];
+			}
+			if ($section == "placemark" && mb_strtoupper($element[tag]) == "NAME" && $element[type] == "complete") {
+				$this->title = $element[value];
+			}
+			if ($section == "placemark" && mb_strtoupper($element[tag]) == "LOOKAT" && $element[type] == "open") {
+				$section = "lookat";
+			}
+			if ($section == "lookat") {
+				
+				if (mb_strtoupper($element[tag]) == "RANGE" && $element[type] == "complete") {
+					$this->lookAt_range = $element[value]; 
+				}
+				if (mb_strtoupper($element[tag]) == "HEADING" && $element[type] == "complete") {
+					$this->lookAt_heading = $element[value]; 
+				}
+				if (mb_strtoupper($element[tag]) == "TILT" && $element[type] == "complete") {
+					$this->lookAt_tilt = $element[value]; 
+				}
+			}
+			if (mb_strtoupper($element[tag]) == "STYLE" && $element[type] == "open") {
+				$section = "style";
+			}
+			if ($section == "style" && mb_strtoupper($element[tag]) == "ICONSTYLE" && $element[type] == "open") {
+				$section = "iconstyle";
+			}
+			if ($section == "iconstyle" && mb_strtoupper($element[tag]) == "ICON" && $element[type] == "open") {
+				$section = "icon";
+			}
+			if ($section == "icon" && mb_strtoupper($element[tag]) == "HREF" && $element[type] == "complete") {
+				$this->icon = $element[value];
+			}
+			if (mb_strtoupper($element[tag]) == "POINT" && $element[type] == "open") {
+				$section = "point";
+			}
+			if ($section == "point" && mb_strtoupper($element[tag]) == "COORDINATES" && $element[type] == "complete") {
+				$array = explode(",", $element[value]);
+				$this->x = $array[0];
+				$this->y = $array[1];
+			}
+		}
+		return true;
+	}
+
+	function createObjFromDB($kml_id) {
+		$this->kml_id = $kml_id;
+
+		$sql = "SELECT kml FROM mb_meetingpoint WHERE mb_meetingpoint_id = $1";
+		$v = array($kml_id);
+		$t = array('s');
+		$res = db_prep_query($sql, $v, $t);
+		$row = db_fetch_array($res);
+		return $this->createObjFromKML($row['kml']);
+	}
+
+	function createKMLFromObj(){
+		$kml = "";
+		$kml .= "<?xml version=\"1.0\" encoding=\"".CHARSET."\"?>\n";
+		$kml .= "<kml xmlns=\"http://earth.google.com/kml/2.0\">\n";
+		$kml .= "<Placemark>\n";
+		$kml .= "\t<description>" . $this->description . "</description>\n";
+		$kml .= "\t<name>" . $this->title . "</name>\n";
+		$kml .= "\t<LookAt>\n";
+		$kml .= "\t\t<longitude>" . $this->x . "</longitude>\n";
+		$kml .= "\t\t<latitude>" . $this->y . "</latitude>\n";
+		$kml .= "\t\t<range>" . $this->lookAt_range . "</range>\n";
+		$kml .= "\t\t<tilt>" . $this->lookAt_tilt . "</tilt>\n";
+		$kml .= "\t\t<heading>" . $this->lookAt_heading . "</heading>\n";
+		$kml .= "\t</LookAt>\n";
+		$kml .= "\t<visibility>0</visibility>\n";
+		$kml .= "\t<Style>\n";
+		$kml .= "\t\t<IconStyle>\n";
+		$kml .= "\t\t\t<Icon>\n";
+		$kml .= "\t\t\t\t<href>" . $this->icon . "</href>\n";
+		$kml .= "\t\t\t</Icon>\n";
+		$kml .= "\t\t</IconStyle>\n";
+		$kml .= "\t</Style>\n";
+		$kml .= "\t<Point>\n";
+		$kml .= "\t\t<extrude>1</extrude>\n";
+		$kml .= "\t\t<coordinates>" . $this->x . "," . $this->y . "</coordinates>\n";
+		$kml .= "\t</Point>\n";
+		$kml .= "</Placemark>\n";
+		$kml .= "</kml>";
+		
+		$this->kml = $kml;
+		
+		return $kml;
+	}
+
+} 
+// end class
+?>

Modified: branches/print_dev/http/classes/class_kml_ows.php
===================================================================
--- branches/print_dev/http/classes/class_kml_ows.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_kml_ows.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,626 +1,626 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/class_wmc.php
-# Copyright (C) 2002 CCGIS 
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require_once(dirname(__FILE__)."/../../core/globalSettings.php");
-
-require_once(dirname(__FILE__)."/../classes/class_json.php");
-require_once(dirname(__FILE__)."/../classes/class_point.php");
-
-require_once(dirname(__FILE__)."/../classes/class_kml_geometry.php");
-require_once(dirname(__FILE__)."/../classes/class_kml_placemark.php");
-require_once(dirname(__FILE__)."/../classes/class_kml_parser_ows.php");;
-
-/**
- * Allows parsing a KML file, extracting the placemarks.
- * 
- * @package KML
- */
-class KML {
-
-	//
-	//
-	// ------------------------------- public -----------------------------------------------
-	//
-	//
-
-	/**
-	 * The constructor function, currently empty.
-	 */				
-	public function __construct() {
-	} 
-
-	public function toSingleLineStringKml() {
-		//KML 2.2 output
-		$doc = new DOMDocument("1.0", CHARSET);
-		$doc->preserveWhiteSpace = false;
-	
-		// attach kml and Document tag
-		$e_kml = $doc->createElementNS("http://earth.google.com/kml/2.2", "kml");
-		$e_document = $doc->createElement("Document");
-		$e_kml->appendChild($e_document);
-		$doc->appendChild($e_kml);
-	
-		// attach placemarks
-		$e = new mb_notice("to string: #placemarks: " . count($this->placemarkArray));
-
-		$lineStyleNode = $doc->createElement("Style");
-		$lineStyleNode->setAttribute("id", "linestyleExample");
-		$lineStyleColorNode = $doc->createElement("color", "7f0000ff");
-		$lineStyleWidthNode = $doc->createElement("width", 4);
-		$lineStyleNode->appendChild($lineStyleColorNode);
-		$lineStyleNode->appendChild($lineStyleWidthNode);
-		$e_document->appendChild($lineStyleNode);
-		
-		//
-		// line segments first
-		//
-		$coordinates = "";
-
-		for ($i = 0; $i < count($this->placemarkArray); $i++) {
-			$currentPlacemark = $this->placemarkArray[$i];
-			$e = new mb_notice("now: " . $i . " of " . (count($this->placemarkArray)-1) . " (is a " . get_class($currentPlacemark) . ")");
-
-			switch ($currentPlacemark->getGeometryType()) {
-				case "KMLLine" :
-					$coordinatesArray = $currentPlacemark->getGeometry()->getPointArray();
-					for ($j = 0; $j < count($coordinatesArray); $j++) {
-						if (!($j == 0 && $i == 0)) {
-							$coordinates .= " ";
-						}
-						$coordinates .= $coordinatesArray[$j]["x"] . "," . $coordinatesArray[$j]["y"] . "," . $coordinatesArray[$j]["z"];
-						
-					}
-					break;
-			}
-		}
-		// create a placemark tag with a geometry and add it to the document
-		$e_coordinates = $doc->createElement("coordinates", $coordinates);
-		$e_geometry = $doc->createElement("LineString");
-		$e_geometry->appendChild($e_coordinates);
-		$e_placemark = $doc->createElement("Placemark");
-		$e_placemark->appendChild($e_geometry);
-		$e_pl_name = $doc->createElement("name", "Route");
-		$e_placemark->appendChild($e_pl_name);
-		$e_pl_style = $doc->createElement("styleUrl", "#linestyleExample");
-		$e_placemark->appendChild($e_pl_style);
-		$e_document->appendChild($e_placemark);
-		
-/*		
-		//
-		// now pois
-		//
-		// attach placemarks
-		$e = new mb_notice("to string: #placemarks: " . count($this->placemarkArray));
-		for ($i = 0; $i < count($this->placemarkArray); $i++) {
-			$currentPlacemark = $this->placemarkArray[$i];
-
-			$e = new mb_notice("now: " . $i . " of " . (count($this->placemarkArray)-1) . " (is a " . get_class($currentPlacemark) . ")");
-			
-			$pl_instructions = $currentPlacemark->getProperty("instruction");
-			$pl_name_array = array();
-			$pl_name = false;
-			$pl_description = false;
-			if ($pl_instructions != null) {
-				$pl_name_array = explode("|", $pl_instructions);
-			}
-
-			switch ($currentPlacemark->getGeometryType()) {
-				case "KMLPoint" :
-					if (count($pl_name_array) > 2) {
-						$pl_name = $pl_name_array[0];
-						$pl_description = $pl_name_array[1];
-					}
-					$e_geometry = $doc->createElement("Point");
-					$point = $currentPlacemark->getGeometry()->getPoint();
-					$coordinates = $point["x"] . "," . $point["y"];
-					$e_coordinates = $doc->createElement("coordinates", $coordinates);
-					$e_geometry->appendChild($e_coordinates);
-					break;
-
-			}
-			// create a placemark tag with a geometry and add it to the document
-			if ($e_geometry) {
-				$e_placemark = $doc->createElement("Placemark");
-				$e_placemark->appendChild($e_geometry);
-				if ($pl_name) {
-					$e_pl_name = $doc->createElement("name", $pl_name);
-					$e_placemark->appendChild($e_pl_name);
-				}
-				if ($pl_description) {
-					$e_pl_description = $doc->createElement("description", $pl_description);
-					$e_placemark->appendChild($e_pl_description);
-				}
-				$e_document->appendChild($e_placemark);
-			}
-		}
-*/
-		return $doc->saveXML();
-	}
-	
-	/**
-	 * @return string the KML document.
-	 */
-	public function __toString() {
-		
-	
-		if (!$this->kml) {
-			//KML 2.2 output
-			$doc = new DOMDocument("1.0", CHARSET);
-			$doc->preserveWhiteSpace = false;
-	
-			// attach kml and Document tag
-			$e_kml = $doc->createElementNS("http://earth.google.com/kml/2.2", "kml");
-			$e_document = $doc->createElement("Document");
-			$e_kml->appendChild($e_document);
-			$doc->appendChild($e_kml);
-	
-			// attach placemarks
-			$e = new mb_notice("to string: #placemarks: " . count($this->placemarkArray));
-			for ($i = 0; $i < count($this->placemarkArray); $i++) {
-				$currentPlacemark = $this->placemarkArray[$i];
-
-				$e = new mb_notice("now: " . $i . " of " . (count($this->placemarkArray)-1) . " (is a " . get_class($currentPlacemark) . ")");
-				
-				$pl_instructions = $currentPlacemark->getProperty("instruction");
-				$pl_name_array = array();
-				$pl_name = false;
-				$pl_description = false;
-				if ($pl_instructions != null) {
-					$pl_name_array = explode("|", $pl_instructions);
-				}
-
-				switch ($currentPlacemark->getGeometryType()) {
-					case "KMLPoint" :
-						if (count($pl_name_array) > 2) {
-							$pl_name = $pl_name_array[0];
-							$pl_description = $pl_name_array[1];
-						}
-						$e_geometry = $doc->createElement("Point");
-						$point = $currentPlacemark->getGeometry()->getPoint();
-						$coordinates = $point["x"] . "," . $point["y"];
-						$e_coordinates = $doc->createElement("coordinates", $coordinates);
-						$e_geometry->appendChild($e_coordinates);
-						break;
-					
-/* TODO:Polygons
-					case "KMLPolygon" :
-						$e_geometry = $doc->createElement("Polygon");
-						$e_outer = $doc->createElement("OuterBoundaryIs");
-						$e_outer_lr = $doc->createElement("LinearRing");
-						$outer_coordinates = ""; // TODO: get coords from placemark
-						$e_outer_coordinates = $doc->createElement("Coordinates", $outer_coordinates);
-						
-						$e_outer_lr->appendChild($e_outer_coordinates);
-						$e_outer->appendChild($e_outer_lr);
-						
-						for ($j = 0; $j < $currentPlacemark; $j++) {
-							
-						}
-						
-						$e_geometry->appendChild($e_coordinates);
-					outerBoundaryIs"}->{"LinearRing"}->{"coordinates
-					
-						break;
-*/					
-					case "KMLLine" :
-						if (count($pl_name_array) > 2) {
-							$pl_description = $pl_name_array[1];
-						}
-						$e_geometry = $doc->createElement("LineString");
-						$coordinatesArray = $currentPlacemark->getGeometry()->getPointArray();
-						$coordinates = "";
-						for ($j = 0; $j < count($coordinatesArray); $j++) {
-							if ($j > 0) {
-								$coordinates .= " ";
-							}
-							$coordinates .= $coordinatesArray[$j]["x"] . "," . $coordinatesArray[$j]["y"] . "," . $coordinatesArray[$j]["z"];
-							
-						}
-						$e_coordinates = $doc->createElement("coordinates", $coordinates);
-						$e_geometry->appendChild($e_coordinates);
-						break;
-
-/*	TODO: Multigeometries				
-					case "KMLMultiGeometry" :
-						break;
-*/
-				}
-				// create a placemark tag with a geometry and add it to the document
-				if ($e_geometry) {
-					$e_placemark = $doc->createElement("Placemark");
-					$e_placemark->appendChild($e_geometry);
-					if ($pl_name) {
-						$e_pl_name = $doc->createElement("name", $pl_name);
-						$e_placemark->appendChild($e_pl_name);
-					}
-					if ($pl_description) {
-						$e_pl_description = $doc->createElement("description", $pl_description);
-						$e_placemark->appendChild($e_pl_description);
-					}
-					$e_document->appendChild($e_placemark);
-				}
-			}
-			$this->kml = $doc->saveXML();
-		}
-		return $this->kml;
-	}
-	
-	/**
-	 * @return string the ID of this KML.
-	 */
-	public function getId () {
-		return $this->id;
-	}
-	
-	/**
-	 * parses an incoming KML, creates the object, 
-	 * stores the kml in the object and in the database.
-	 * 
-	 * @param  string  a KML document.
-	 * @return boolean true if the parsing succeded, else false.
-	 */
-	public function parseKml ($kml) {
-		$this->kml = $kml;
-
-		if (!$this->storeInDb()) {
-			return false;
-		}
-
-		$parser = new KmlOwsParser();
-		$parser->parseKML($kml, $this->id);
-		$this->placemarkArray = $parser->placemarkArray; 
-
-		return true;
-	}
-	
-	/**
-	 * parses an incoming GeoJSON, creates the object, 
-	 * stores the kml in the object and in the database.
-	 * 
-	 * @param string a geoJSON.
-	 * @return boolean true if the parsing succeded, else false.
-	 */
-	public function parseGeoJSON ($geoJSON) {
-		$this->kml = "";
-
-		if (!$this->storeInDb()) {
-			return false;
-		}
-
-		$parser = new KmlOwsParser();
-		$parser->parseGeoJSON($geoJSON, $this->id);
-		$e = new mb_notice("parsing finished...#placemarks: " . count($this->placemarkArray) . " (" . count($parser->placemarkArray) . ")");
-		$this->placemarkArray = $parser->placemarkArray; 
-
-//		print_r($this);
-		
-//		$this->kml = $this->__toString();
-
-//		$this->updateInDb($this->kml, $this->id);
-		return true;
-	}
-	
-	/**
-	 * @return string the geoJSON representation of the KML.
-	 */
-	public function toGeoJSON() {
-		$str = "";
-		$numberOfPlacemarks = count($this->placemarkArray);
-		if ($numberOfPlacemarks > 0) {
-			$str .= "{\"type\": \"FeatureCollection\", \"features\": [";
-			for ($i=0; $i < $numberOfPlacemarks; $i++) {
-				if ($i > 0) {
-					$str .= ",";
-				}	
-				$str .= $this->placemarkArray[$i]->toGeoJSON();
-			}
-			$str .= "]}";
-		}
-		else {
-			$e = new mb_exception("KML: toGeoJSON: this placemarkArray is empty!");
-		}
-		return $str;
-	}
-
-	private function updateInDb($kmlDoc, $kmlId) {
-		$sql = "UPDATE gui_kml SET kml_doc = $1 WHERE kml_id = $2";
-		$v = array($kmlDoc, $kmlId);
-		$t = array("s", "i");
-		$result = db_prep_query($sql, $v, $t);
-		if (!$result) {
-			$e = new mb_exception("class_kml: kml update failed! " . db_error());
-			return false;
-		}
-	}
-
-	public function updateKml ($kmlId, $placemarkId, $geoJSON) {
-		$kmlFromDb = $this->getKmlDocumentFromDB($kmlId);
-		 
-		if ($kmlFromDb !== NULL) {
-			// load the KML from the database in the DOM object
-			$kmlDoc_DOM = new DOMDocument("1.0");
-			$kmlDoc_DOM->encoding = CHARSET;
-			$kmlDoc_DOM->preserveWhiteSpace = false;
-			$kmlDoc_DOM->loadXML($kmlFromDb); 
-
-			//load the geoJSON
-			$json = new Mapbender_JSON();
-			$geoObj = $json->decode($geoJSON);
-
-			// construct an array that holds all metadata of the placemark
-			$metadataObj = $geoObj->properties;
-			
-			// construct an array that holds all geometries of the placemark
-			$geometryObj = $geoObj->geometry;
-			$geometryType = $geometryObj->type;
-			if ($geometryType == "GeometryCollection") {
-				$geometryArray = $geometryObj->geometries;
-			}
-			else if ($geometryType == "Point" || $geometryType == "LineString" || $geometryType == "Polygon") {
-				$geometryArray = array($geometryObj);
-			}
-			else {
-				$e = new mb_exception("class_kml: Invalid geometry type " . $geometryType);
-				return false;
-			}
-
-			//
-			// apply the changes
-			//
-			
-			$currentPlacemarkArray = $kmlDoc_DOM->getElementsByTagName("Placemark");
-			$currentPlacemark = $currentPlacemarkArray->item($placemarkId);
-
-			if ($currentPlacemark) {
-				$metadataUpdateSuccessful = $this->updateMetadata($currentPlacemark, $metadataObj);
-				$geometryUpdateSuccessful = $this->updateGeometries($currentPlacemark, $geometryArray);
-			}
-			else {
-				$e = new mb_exception("class_kml.php: updateKml: placemark " . $placemarkId . " not found in KML " . $kmlId . ".");
-				return false;
-			}
-
-			if ($metadataUpdateSuccessful && $geometryUpdateSuccessful) {
-				$updatedKml = $kmlDoc_DOM->saveXML();
-
-				$this->updateInDb($updatedKml, $kmlId);
-			}
-			else {
-				if (!$metadataUpdateSuccessful) {
-					$e = new mb_exception("class_kml: Updating the metadata failed, no database update.");
-				}
-				if (!$geometryUpdateSuccessful) {
-					$e = new mb_exception("class_kml: Updating the geometries failed, no database update.");
-				}
-				return false;
-			}
-		}
-		else {
-			$e = new mb_exception("class_kml: No KML found in database, no database update. " . db_error());
-			return false;
-		}
-		return true;
-	}
-
-	//
-	//
-	// ------------------------------- private -----------------------------------------------
-	//
-	//
-		
-	/**
-	 * Store this KML in the database, and sets the ID.
-	 * 
-	 * @return boolean true, if the KML could be stored in the database; else false.
-	 */
-	private function storeInDb () {
-		if ($_SESSION["mb_user_id"] && $_SESSION["mb_user_gui"]) {
-			$con = db_connect(DBSERVER,OWNER,PW);
-			db_select_db(DB,$con);
-	
-			$sql  = "INSERT INTO gui_kml ";
-			$sql .= "(fkey_mb_user_id, fkey_gui_id, kml_doc, kml_name, kml_description, kml_timestamp) ";
-			$sql .= "VALUES ";
-			$sql .= "($1, $2, $3, $4, $5, $6)";
-			$v = array ($_SESSION["mb_user_id"], $_SESSION["mb_user_gui"], $this->kml, "name", "description", time());
-			$t = array ("i", "s", "s", "s", "s", "s");
-			$res = db_prep_query($sql, $v, $t);
-			if (!$res) {
-				$e = new mb_exception("class_kml.php: storeInDb: failed to store KML in database: " . db_error());
-				return false;
-			}
-	
-			$this->id = db_insert_id($con, "gui_kml", "kml_id");
-			return true;
-		}
-		else {
-			// should be false, but code in caller has to be changed first.
-			return true;
-		}
-	}
-
-	/**
-	 * @param  integer  the ID of the KML.
-	 * @return string   the KML document with the given ID.
-	 */
-	public function getKmlDocumentFromDB ($kmlId) {
-		$con = db_connect(DBSERVER,OWNER,PW);
-		db_select_db(DB,$con);
-		//get KML from database (check if user is allowed to access)
-
-# for now, do not restrict access 
-#		$sql = "SELECT kml_doc FROM gui_kml WHERE kml_id = $1 AND fkey_mb_user_id = $2 AND fkey_gui_id = $3 LIMIT 1";
-#		$v = array($kmlId, $_SESSION["mb_user_id"], $_SESSION["mb_user_gui"]);
-#		$t = array("i", "i", "s");
-
-		$sql = "SELECT kml_doc FROM gui_kml WHERE kml_id = $1 LIMIT 1";
-		$v = array($kmlId);
-		$t = array("i");
-
-		$result = db_prep_query($sql, $v, $t);
-		$row = db_fetch_array($result);
-		if ($row) {
-			return $row["kml_doc"];
-		}
-		else {
-			$e = new mb_exception("class_kml.php: getKMLDocumentFromDB: no KML found for ID " . $kmlId);
-		}
-		return "";
-	}
-
-	/**
-	 * @param  string the tag name.
-	 * @return string the tag name without its namespace.
-	 */
-	private function sepNameSpace($s){
-		$c = mb_strpos($s, ":"); 
-		if ($c > 0) {
-			$s = mb_substr($s, $c+1);
-		}
-		return $s;
-	}
-
-	private function updateGeometries($currentPlacemark, $geometryArray) {
-		$cnt = 0; 
-		$childNodes = $currentPlacemark->childNodes;
-
-		foreach ($childNodes as $childNode) {
-			$name = $childNode->nodeName;
-			if ( in_array($name, array("Point","LineString","Polygon"))) {
-				$returnValue = $this->updateGeometry($childNode, $geometryArray[$cnt]);
-				if (!$returnValue) {
-					return false;
-				}
-				$cnt ++;
-			}
-			else if ($name == "MultiGeometry") {
-				return $this->updateGeometries($childNode, $geometryArray);
-			}
-		}
-		return true;
-	}
-	
-	private function updateGeometry ($currentNode, $geometry) {
-		$json = new Mapbender_JSON();
-		$currentNode_SimpleXML = simplexml_import_dom($currentNode);
-
-		$currentTypeXml = mb_strtoupper($currentNode->nodeName);
-		$currentTypeGeoJson = mb_strtoupper($geometry->type);  
-
-		if ($currentTypeGeoJson != $currentTypeXml) {
-			$e = new mb_exception("class_kml: geometry type mismatch: geoJSON: " . $currentTypeGeoJson . "; XML: " . $currentTypeXml);
-			return false;
-		}
-		if ($currentTypeXml == "POLYGON") {
-			// GML 3
-			$gmlNode = $currentNode_SimpleXML->{"exterior"}->{"LinearRing"}->{"posList"};
-			$kmlNode = $currentNode_SimpleXML->{"outerBoundaryIs"}->{"LinearRing"}->{"coordinates"};
-			if ($gmlNode && $gmlNode->asXML()) {
-				$currentNode_SimpleXML->{"exterior"}->{"LinearRing"}->{"posList"} = preg_replace("/,/", " ", preg_replace("/\[|\]/", "", $json->encode($geometry->coordinates)));
-			}
-			// KML 2.2
-			else if ($kmlNode && $kmlNode->asXML()) {
-				$currentNode_SimpleXML->{"outerBoundaryIs"}->{"LinearRing"}->{"coordinates"} = preg_replace("/\],/", " ", preg_replace("/\][^,]|\[/", "", $json->encode($geometry->coordinates)));
-			}
-		}
-		elseif ($currentTypeXml == "POINT") {
-			$gmlNode = $currentNode_SimpleXML->{"pos"};
-			$kmlNode = $currentNode_SimpleXML->{"coordinates"};
-
-			// GML 3
-			if ($gmlNode && $gmlNode->asXML()) {
-				$currentNode_SimpleXML->{"pos"} = preg_replace("/,/", " ", preg_replace("/\[|\]/", "", $json->encode($geometry->coordinates)));
-			}
-			// KML 2.2
-			else if ($kmlNode && $kmlNode->asXML()) {
-				$currentNode_SimpleXML->{"coordinates"} = preg_replace("/\[|\]/", "", $json->encode($geometry->coordinates));
-			}
-		}
-		elseif ($currentTypeXml == "LINESTRING") {
-			$gmlNode = $currentNode_SimpleXML->{"posList"};
-			$kmlNode = $currentNode_SimpleXML->{"coordinates"};
-
-			// GML 3
-			if ($gmlNode && $gmlNode->asXML()) {
-				$currentNode_SimpleXML->{"posList"} = preg_replace("/,/", " ", preg_replace("/\[|\]/", "", $json->encode($geometry->coordinates)));
-			}
-			// KML 2.2
-			else if ($kmlNode && $kmlNode->asXML()) {
-				$currentNode_SimpleXML->{"coordinates"} = preg_replace("/\[|\]/", "", $json->encode($geometry->coordinates));
-			}
-		}
-		return true;
-	}
-
-	private function updateMetadata($currentPlacemark, $metadataObj) {
-		$metadataExistsAndUpdateSucceeded = true;
-		
-		$currentPlacemark_SimpleXML = simplexml_import_dom($currentPlacemark);
-		$extendedDataNode = $currentPlacemark_SimpleXML->{"ExtendedData"};
-		if ($extendedDataNode) {
-			$metadataExistsAndUpdateSucceeded = false;
-
-			// Either, data is within a SCHEMADATA tag...
-			$simpleDataNodes = $extendedDataNode->{"SchemaData"}->{"SimpleData"};
-			if ($simpleDataNodes) {
-				foreach ($simpleDataNodes as $simpleDataNode) {
-					$tmp = dom_import_simplexml($simpleDataNode);					
-					$name = $tmp->getAttribute("name");
-					// if there is a metadata entry, update it
-					if (isset($metadataObj->$name)) {
-						$tmp->nodeValue = $metadataObj->$name;
-					}										
-				}
-
-				$metadataExistsAndUpdateSucceeded = true;
-			}
-
-			// ...or within a DATA tag
-			$dataNodes = $extendedDataNode->{"Data"};
-			if ($dataNodes && !$metadataExistsAndUpdateSucceeded) {
-				foreach ($dataNodes as $dataNode) {
-					$tmp = dom_import_simplexml($dataNode);
-					$name = $tmp->getAttribute("name");
-					// if there is a metadata entry, update it
-					if (isset($metadataObj->$name)) {
-						$tmp->nodeValue = $metadataObj->$name;
-					}										
-				}
-				$metadataExistsAndUpdateSucceeded = true;
-			}
-		}
-		return $metadataExistsAndUpdateSucceeded;
-	}
-
-	/**
-	 * The KML document.
-	 */
-	private $kml;
-	
-	/**
-	 * The ID of this KML in the database.
-	 */
-	private $id;
-	
-	/**
-	 * An array of {@link KMLPlacemark}
-	 */
-	private $placemarkArray = array();
-} 
-?>
+<?php
+# $Id$
+# http://www.mapbender.org/index.php/class_wmc.php
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+
+require_once(dirname(__FILE__)."/../classes/class_json.php");
+require_once(dirname(__FILE__)."/../classes/class_point.php");
+
+require_once(dirname(__FILE__)."/../classes/class_kml_geometry.php");
+require_once(dirname(__FILE__)."/../classes/class_kml_placemark.php");
+require_once(dirname(__FILE__)."/../classes/class_kml_parser_ows.php");;
+
+/**
+ * Allows parsing a KML file, extracting the placemarks.
+ * 
+ * @package KML
+ */
+class KML {
+
+	//
+	//
+	// ------------------------------- public -----------------------------------------------
+	//
+	//
+
+	/**
+	 * The constructor function, currently empty.
+	 */				
+	public function __construct() {
+	} 
+
+	public function toSingleLineStringKml() {
+		//KML 2.2 output
+		$doc = new DOMDocument("1.0", CHARSET);
+		$doc->preserveWhiteSpace = false;
+	
+		// attach kml and Document tag
+		$e_kml = $doc->createElementNS("http://earth.google.com/kml/2.2", "kml");
+		$e_document = $doc->createElement("Document");
+		$e_kml->appendChild($e_document);
+		$doc->appendChild($e_kml);
+	
+		// attach placemarks
+		$e = new mb_notice("to string: #placemarks: " . count($this->placemarkArray));
+
+		$lineStyleNode = $doc->createElement("Style");
+		$lineStyleNode->setAttribute("id", "linestyleExample");
+		$lineStyleColorNode = $doc->createElement("color", "7f0000ff");
+		$lineStyleWidthNode = $doc->createElement("width", 4);
+		$lineStyleNode->appendChild($lineStyleColorNode);
+		$lineStyleNode->appendChild($lineStyleWidthNode);
+		$e_document->appendChild($lineStyleNode);
+		
+		//
+		// line segments first
+		//
+		$coordinates = "";
+
+		for ($i = 0; $i < count($this->placemarkArray); $i++) {
+			$currentPlacemark = $this->placemarkArray[$i];
+			$e = new mb_notice("now: " . $i . " of " . (count($this->placemarkArray)-1) . " (is a " . get_class($currentPlacemark) . ")");
+
+			switch ($currentPlacemark->getGeometryType()) {
+				case "KMLLine" :
+					$coordinatesArray = $currentPlacemark->getGeometry()->getPointArray();
+					for ($j = 0; $j < count($coordinatesArray); $j++) {
+						if (!($j == 0 && $i == 0)) {
+							$coordinates .= " ";
+						}
+						$coordinates .= $coordinatesArray[$j]["x"] . "," . $coordinatesArray[$j]["y"] . "," . $coordinatesArray[$j]["z"];
+						
+					}
+					break;
+			}
+		}
+		// create a placemark tag with a geometry and add it to the document
+		$e_coordinates = $doc->createElement("coordinates", $coordinates);
+		$e_geometry = $doc->createElement("LineString");
+		$e_geometry->appendChild($e_coordinates);
+		$e_placemark = $doc->createElement("Placemark");
+		$e_placemark->appendChild($e_geometry);
+		$e_pl_name = $doc->createElement("name", "Route");
+		$e_placemark->appendChild($e_pl_name);
+		$e_pl_style = $doc->createElement("styleUrl", "#linestyleExample");
+		$e_placemark->appendChild($e_pl_style);
+		$e_document->appendChild($e_placemark);
+		
+/*		
+		//
+		// now pois
+		//
+		// attach placemarks
+		$e = new mb_notice("to string: #placemarks: " . count($this->placemarkArray));
+		for ($i = 0; $i < count($this->placemarkArray); $i++) {
+			$currentPlacemark = $this->placemarkArray[$i];
+
+			$e = new mb_notice("now: " . $i . " of " . (count($this->placemarkArray)-1) . " (is a " . get_class($currentPlacemark) . ")");
+			
+			$pl_instructions = $currentPlacemark->getProperty("instruction");
+			$pl_name_array = array();
+			$pl_name = false;
+			$pl_description = false;
+			if ($pl_instructions != null) {
+				$pl_name_array = explode("|", $pl_instructions);
+			}
+
+			switch ($currentPlacemark->getGeometryType()) {
+				case "KMLPoint" :
+					if (count($pl_name_array) > 2) {
+						$pl_name = $pl_name_array[0];
+						$pl_description = $pl_name_array[1];
+					}
+					$e_geometry = $doc->createElement("Point");
+					$point = $currentPlacemark->getGeometry()->getPoint();
+					$coordinates = $point["x"] . "," . $point["y"];
+					$e_coordinates = $doc->createElement("coordinates", $coordinates);
+					$e_geometry->appendChild($e_coordinates);
+					break;
+
+			}
+			// create a placemark tag with a geometry and add it to the document
+			if ($e_geometry) {
+				$e_placemark = $doc->createElement("Placemark");
+				$e_placemark->appendChild($e_geometry);
+				if ($pl_name) {
+					$e_pl_name = $doc->createElement("name", $pl_name);
+					$e_placemark->appendChild($e_pl_name);
+				}
+				if ($pl_description) {
+					$e_pl_description = $doc->createElement("description", $pl_description);
+					$e_placemark->appendChild($e_pl_description);
+				}
+				$e_document->appendChild($e_placemark);
+			}
+		}
+*/
+		return $doc->saveXML();
+	}
+	
+	/**
+	 * @return string the KML document.
+	 */
+	public function __toString() {
+		
+	
+		if (!$this->kml) {
+			//KML 2.2 output
+			$doc = new DOMDocument("1.0", CHARSET);
+			$doc->preserveWhiteSpace = false;
+	
+			// attach kml and Document tag
+			$e_kml = $doc->createElementNS("http://earth.google.com/kml/2.2", "kml");
+			$e_document = $doc->createElement("Document");
+			$e_kml->appendChild($e_document);
+			$doc->appendChild($e_kml);
+	
+			// attach placemarks
+			$e = new mb_notice("to string: #placemarks: " . count($this->placemarkArray));
+			for ($i = 0; $i < count($this->placemarkArray); $i++) {
+				$currentPlacemark = $this->placemarkArray[$i];
+
+				$e = new mb_notice("now: " . $i . " of " . (count($this->placemarkArray)-1) . " (is a " . get_class($currentPlacemark) . ")");
+				
+				$pl_instructions = $currentPlacemark->getProperty("instruction");
+				$pl_name_array = array();
+				$pl_name = false;
+				$pl_description = false;
+				if ($pl_instructions != null) {
+					$pl_name_array = explode("|", $pl_instructions);
+				}
+
+				switch ($currentPlacemark->getGeometryType()) {
+					case "KMLPoint" :
+						if (count($pl_name_array) > 2) {
+							$pl_name = $pl_name_array[0];
+							$pl_description = $pl_name_array[1];
+						}
+						$e_geometry = $doc->createElement("Point");
+						$point = $currentPlacemark->getGeometry()->getPoint();
+						$coordinates = $point["x"] . "," . $point["y"];
+						$e_coordinates = $doc->createElement("coordinates", $coordinates);
+						$e_geometry->appendChild($e_coordinates);
+						break;
+					
+/* TODO:Polygons
+					case "KMLPolygon" :
+						$e_geometry = $doc->createElement("Polygon");
+						$e_outer = $doc->createElement("OuterBoundaryIs");
+						$e_outer_lr = $doc->createElement("LinearRing");
+						$outer_coordinates = ""; // TODO: get coords from placemark
+						$e_outer_coordinates = $doc->createElement("Coordinates", $outer_coordinates);
+						
+						$e_outer_lr->appendChild($e_outer_coordinates);
+						$e_outer->appendChild($e_outer_lr);
+						
+						for ($j = 0; $j < $currentPlacemark; $j++) {
+							
+						}
+						
+						$e_geometry->appendChild($e_coordinates);
+					outerBoundaryIs"}->{"LinearRing"}->{"coordinates
+					
+						break;
+*/					
+					case "KMLLine" :
+						if (count($pl_name_array) > 2) {
+							$pl_description = $pl_name_array[1];
+						}
+						$e_geometry = $doc->createElement("LineString");
+						$coordinatesArray = $currentPlacemark->getGeometry()->getPointArray();
+						$coordinates = "";
+						for ($j = 0; $j < count($coordinatesArray); $j++) {
+							if ($j > 0) {
+								$coordinates .= " ";
+							}
+							$coordinates .= $coordinatesArray[$j]["x"] . "," . $coordinatesArray[$j]["y"] . "," . $coordinatesArray[$j]["z"];
+							
+						}
+						$e_coordinates = $doc->createElement("coordinates", $coordinates);
+						$e_geometry->appendChild($e_coordinates);
+						break;
+
+/*	TODO: Multigeometries				
+					case "KMLMultiGeometry" :
+						break;
+*/
+				}
+				// create a placemark tag with a geometry and add it to the document
+				if ($e_geometry) {
+					$e_placemark = $doc->createElement("Placemark");
+					$e_placemark->appendChild($e_geometry);
+					if ($pl_name) {
+						$e_pl_name = $doc->createElement("name", $pl_name);
+						$e_placemark->appendChild($e_pl_name);
+					}
+					if ($pl_description) {
+						$e_pl_description = $doc->createElement("description", $pl_description);
+						$e_placemark->appendChild($e_pl_description);
+					}
+					$e_document->appendChild($e_placemark);
+				}
+			}
+			$this->kml = $doc->saveXML();
+		}
+		return $this->kml;
+	}
+	
+	/**
+	 * @return string the ID of this KML.
+	 */
+	public function getId () {
+		return $this->id;
+	}
+	
+	/**
+	 * parses an incoming KML, creates the object, 
+	 * stores the kml in the object and in the database.
+	 * 
+	 * @param  string  a KML document.
+	 * @return boolean true if the parsing succeded, else false.
+	 */
+	public function parseKml ($kml) {
+		$this->kml = $kml;
+
+		if (!$this->storeInDb()) {
+			return false;
+		}
+
+		$parser = new KmlOwsParser();
+		$parser->parseKML($kml, $this->id);
+		$this->placemarkArray = $parser->placemarkArray; 
+
+		return true;
+	}
+	
+	/**
+	 * parses an incoming GeoJSON, creates the object, 
+	 * stores the kml in the object and in the database.
+	 * 
+	 * @param string a geoJSON.
+	 * @return boolean true if the parsing succeded, else false.
+	 */
+	public function parseGeoJSON ($geoJSON) {
+		$this->kml = "";
+
+		if (!$this->storeInDb()) {
+			return false;
+		}
+
+		$parser = new KmlOwsParser();
+		$parser->parseGeoJSON($geoJSON, $this->id);
+		$e = new mb_notice("parsing finished...#placemarks: " . count($this->placemarkArray) . " (" . count($parser->placemarkArray) . ")");
+		$this->placemarkArray = $parser->placemarkArray; 
+
+//		print_r($this);
+		
+//		$this->kml = $this->__toString();
+
+//		$this->updateInDb($this->kml, $this->id);
+		return true;
+	}
+	
+	/**
+	 * @return string the geoJSON representation of the KML.
+	 */
+	public function toGeoJSON() {
+		$str = "";
+		$numberOfPlacemarks = count($this->placemarkArray);
+		if ($numberOfPlacemarks > 0) {
+			$str .= "{\"type\": \"FeatureCollection\", \"features\": [";
+			for ($i=0; $i < $numberOfPlacemarks; $i++) {
+				if ($i > 0) {
+					$str .= ",";
+				}	
+				$str .= $this->placemarkArray[$i]->toGeoJSON();
+			}
+			$str .= "]}";
+		}
+		else {
+			$e = new mb_exception("KML: toGeoJSON: this placemarkArray is empty!");
+		}
+		return $str;
+	}
+
+	private function updateInDb($kmlDoc, $kmlId) {
+		$sql = "UPDATE gui_kml SET kml_doc = $1 WHERE kml_id = $2";
+		$v = array($kmlDoc, $kmlId);
+		$t = array("s", "i");
+		$result = db_prep_query($sql, $v, $t);
+		if (!$result) {
+			$e = new mb_exception("class_kml: kml update failed! " . db_error());
+			return false;
+		}
+	}
+
+	public function updateKml ($kmlId, $placemarkId, $geoJSON) {
+		$kmlFromDb = $this->getKmlDocumentFromDB($kmlId);
+		 
+		if ($kmlFromDb !== NULL) {
+			// load the KML from the database in the DOM object
+			$kmlDoc_DOM = new DOMDocument("1.0");
+			$kmlDoc_DOM->encoding = CHARSET;
+			$kmlDoc_DOM->preserveWhiteSpace = false;
+			$kmlDoc_DOM->loadXML($kmlFromDb); 
+
+			//load the geoJSON
+			$json = new Mapbender_JSON();
+			$geoObj = $json->decode($geoJSON);
+
+			// construct an array that holds all metadata of the placemark
+			$metadataObj = $geoObj->properties;
+			
+			// construct an array that holds all geometries of the placemark
+			$geometryObj = $geoObj->geometry;
+			$geometryType = $geometryObj->type;
+			if ($geometryType == "GeometryCollection") {
+				$geometryArray = $geometryObj->geometries;
+			}
+			else if ($geometryType == "Point" || $geometryType == "LineString" || $geometryType == "Polygon") {
+				$geometryArray = array($geometryObj);
+			}
+			else {
+				$e = new mb_exception("class_kml: Invalid geometry type " . $geometryType);
+				return false;
+			}
+
+			//
+			// apply the changes
+			//
+			
+			$currentPlacemarkArray = $kmlDoc_DOM->getElementsByTagName("Placemark");
+			$currentPlacemark = $currentPlacemarkArray->item($placemarkId);
+
+			if ($currentPlacemark) {
+				$metadataUpdateSuccessful = $this->updateMetadata($currentPlacemark, $metadataObj);
+				$geometryUpdateSuccessful = $this->updateGeometries($currentPlacemark, $geometryArray);
+			}
+			else {
+				$e = new mb_exception("class_kml.php: updateKml: placemark " . $placemarkId . " not found in KML " . $kmlId . ".");
+				return false;
+			}
+
+			if ($metadataUpdateSuccessful && $geometryUpdateSuccessful) {
+				$updatedKml = $kmlDoc_DOM->saveXML();
+
+				$this->updateInDb($updatedKml, $kmlId);
+			}
+			else {
+				if (!$metadataUpdateSuccessful) {
+					$e = new mb_exception("class_kml: Updating the metadata failed, no database update.");
+				}
+				if (!$geometryUpdateSuccessful) {
+					$e = new mb_exception("class_kml: Updating the geometries failed, no database update.");
+				}
+				return false;
+			}
+		}
+		else {
+			$e = new mb_exception("class_kml: No KML found in database, no database update. " . db_error());
+			return false;
+		}
+		return true;
+	}
+
+	//
+	//
+	// ------------------------------- private -----------------------------------------------
+	//
+	//
+		
+	/**
+	 * Store this KML in the database, and sets the ID.
+	 * 
+	 * @return boolean true, if the KML could be stored in the database; else false.
+	 */
+	private function storeInDb () {
+		if ($_SESSION["mb_user_id"] && $_SESSION["mb_user_gui"]) {
+			$con = db_connect(DBSERVER,OWNER,PW);
+			db_select_db(DB,$con);
+	
+			$sql  = "INSERT INTO gui_kml ";
+			$sql .= "(fkey_mb_user_id, fkey_gui_id, kml_doc, kml_name, kml_description, kml_timestamp) ";
+			$sql .= "VALUES ";
+			$sql .= "($1, $2, $3, $4, $5, $6)";
+			$v = array ($_SESSION["mb_user_id"], $_SESSION["mb_user_gui"], $this->kml, "name", "description", time());
+			$t = array ("i", "s", "s", "s", "s", "s");
+			$res = db_prep_query($sql, $v, $t);
+			if (!$res) {
+				$e = new mb_exception("class_kml.php: storeInDb: failed to store KML in database: " . db_error());
+				return false;
+			}
+	
+			$this->id = db_insert_id($con, "gui_kml", "kml_id");
+			return true;
+		}
+		else {
+			// should be false, but code in caller has to be changed first.
+			return true;
+		}
+	}
+
+	/**
+	 * @param  integer  the ID of the KML.
+	 * @return string   the KML document with the given ID.
+	 */
+	public function getKmlDocumentFromDB ($kmlId) {
+		$con = db_connect(DBSERVER,OWNER,PW);
+		db_select_db(DB,$con);
+		//get KML from database (check if user is allowed to access)
+
+# for now, do not restrict access 
+#		$sql = "SELECT kml_doc FROM gui_kml WHERE kml_id = $1 AND fkey_mb_user_id = $2 AND fkey_gui_id = $3 LIMIT 1";
+#		$v = array($kmlId, $_SESSION["mb_user_id"], $_SESSION["mb_user_gui"]);
+#		$t = array("i", "i", "s");
+
+		$sql = "SELECT kml_doc FROM gui_kml WHERE kml_id = $1 LIMIT 1";
+		$v = array($kmlId);
+		$t = array("i");
+
+		$result = db_prep_query($sql, $v, $t);
+		$row = db_fetch_array($result);
+		if ($row) {
+			return $row["kml_doc"];
+		}
+		else {
+			$e = new mb_exception("class_kml.php: getKMLDocumentFromDB: no KML found for ID " . $kmlId);
+		}
+		return "";
+	}
+
+	/**
+	 * @param  string the tag name.
+	 * @return string the tag name without its namespace.
+	 */
+	private function sepNameSpace($s){
+		$c = mb_strpos($s, ":"); 
+		if ($c > 0) {
+			$s = mb_substr($s, $c+1);
+		}
+		return $s;
+	}
+
+	private function updateGeometries($currentPlacemark, $geometryArray) {
+		$cnt = 0; 
+		$childNodes = $currentPlacemark->childNodes;
+
+		foreach ($childNodes as $childNode) {
+			$name = $childNode->nodeName;
+			if ( in_array($name, array("Point","LineString","Polygon"))) {
+				$returnValue = $this->updateGeometry($childNode, $geometryArray[$cnt]);
+				if (!$returnValue) {
+					return false;
+				}
+				$cnt ++;
+			}
+			else if ($name == "MultiGeometry") {
+				return $this->updateGeometries($childNode, $geometryArray);
+			}
+		}
+		return true;
+	}
+	
+	private function updateGeometry ($currentNode, $geometry) {
+		$json = new Mapbender_JSON();
+		$currentNode_SimpleXML = simplexml_import_dom($currentNode);
+
+		$currentTypeXml = mb_strtoupper($currentNode->nodeName);
+		$currentTypeGeoJson = mb_strtoupper($geometry->type);  
+
+		if ($currentTypeGeoJson != $currentTypeXml) {
+			$e = new mb_exception("class_kml: geometry type mismatch: geoJSON: " . $currentTypeGeoJson . "; XML: " . $currentTypeXml);
+			return false;
+		}
+		if ($currentTypeXml == "POLYGON") {
+			// GML 3
+			$gmlNode = $currentNode_SimpleXML->{"exterior"}->{"LinearRing"}->{"posList"};
+			$kmlNode = $currentNode_SimpleXML->{"outerBoundaryIs"}->{"LinearRing"}->{"coordinates"};
+			if ($gmlNode && $gmlNode->asXML()) {
+				$currentNode_SimpleXML->{"exterior"}->{"LinearRing"}->{"posList"} = preg_replace("/,/", " ", preg_replace("/\[|\]/", "", $json->encode($geometry->coordinates)));
+			}
+			// KML 2.2
+			else if ($kmlNode && $kmlNode->asXML()) {
+				$currentNode_SimpleXML->{"outerBoundaryIs"}->{"LinearRing"}->{"coordinates"} = preg_replace("/\],/", " ", preg_replace("/\][^,]|\[/", "", $json->encode($geometry->coordinates)));
+			}
+		}
+		elseif ($currentTypeXml == "POINT") {
+			$gmlNode = $currentNode_SimpleXML->{"pos"};
+			$kmlNode = $currentNode_SimpleXML->{"coordinates"};
+
+			// GML 3
+			if ($gmlNode && $gmlNode->asXML()) {
+				$currentNode_SimpleXML->{"pos"} = preg_replace("/,/", " ", preg_replace("/\[|\]/", "", $json->encode($geometry->coordinates)));
+			}
+			// KML 2.2
+			else if ($kmlNode && $kmlNode->asXML()) {
+				$currentNode_SimpleXML->{"coordinates"} = preg_replace("/\[|\]/", "", $json->encode($geometry->coordinates));
+			}
+		}
+		elseif ($currentTypeXml == "LINESTRING") {
+			$gmlNode = $currentNode_SimpleXML->{"posList"};
+			$kmlNode = $currentNode_SimpleXML->{"coordinates"};
+
+			// GML 3
+			if ($gmlNode && $gmlNode->asXML()) {
+				$currentNode_SimpleXML->{"posList"} = preg_replace("/,/", " ", preg_replace("/\[|\]/", "", $json->encode($geometry->coordinates)));
+			}
+			// KML 2.2
+			else if ($kmlNode && $kmlNode->asXML()) {
+				$currentNode_SimpleXML->{"coordinates"} = preg_replace("/\[|\]/", "", $json->encode($geometry->coordinates));
+			}
+		}
+		return true;
+	}
+
+	private function updateMetadata($currentPlacemark, $metadataObj) {
+		$metadataExistsAndUpdateSucceeded = true;
+		
+		$currentPlacemark_SimpleXML = simplexml_import_dom($currentPlacemark);
+		$extendedDataNode = $currentPlacemark_SimpleXML->{"ExtendedData"};
+		if ($extendedDataNode) {
+			$metadataExistsAndUpdateSucceeded = false;
+
+			// Either, data is within a SCHEMADATA tag...
+			$simpleDataNodes = $extendedDataNode->{"SchemaData"}->{"SimpleData"};
+			if ($simpleDataNodes) {
+				foreach ($simpleDataNodes as $simpleDataNode) {
+					$tmp = dom_import_simplexml($simpleDataNode);					
+					$name = $tmp->getAttribute("name");
+					// if there is a metadata entry, update it
+					if (isset($metadataObj->$name)) {
+						$tmp->nodeValue = $metadataObj->$name;
+					}										
+				}
+
+				$metadataExistsAndUpdateSucceeded = true;
+			}
+
+			// ...or within a DATA tag
+			$dataNodes = $extendedDataNode->{"Data"};
+			if ($dataNodes && !$metadataExistsAndUpdateSucceeded) {
+				foreach ($dataNodes as $dataNode) {
+					$tmp = dom_import_simplexml($dataNode);
+					$name = $tmp->getAttribute("name");
+					// if there is a metadata entry, update it
+					if (isset($metadataObj->$name)) {
+						$tmp->nodeValue = $metadataObj->$name;
+					}										
+				}
+				$metadataExistsAndUpdateSucceeded = true;
+			}
+		}
+		return $metadataExistsAndUpdateSucceeded;
+	}
+
+	/**
+	 * The KML document.
+	 */
+	private $kml;
+	
+	/**
+	 * The ID of this KML in the database.
+	 */
+	private $id;
+	
+	/**
+	 * An array of {@link KMLPlacemark}
+	 */
+	private $placemarkArray = array();
+} 
+?>

Modified: branches/print_dev/http/classes/class_kml_parser_ows.php
===================================================================
--- branches/print_dev/http/classes/class_kml_parser_ows.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_kml_parser_ows.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,313 +1,313 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/class_wmc.php
-# Copyright (C) 2002 CCGIS 
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require_once(dirname(__FILE__)."/../../core/globalSettings.php");
-require_once(dirname(__FILE__)."/../classes/class_json.php");
-require_once(dirname(__FILE__)."/../classes/class_point.php");
-require_once(dirname(__FILE__)."/../classes/class_kml_polygon.php");
-require_once(dirname(__FILE__)."/../classes/class_kml_linearring.php");
-require_once(dirname(__FILE__)."/../classes/class_kml_line.php");
-require_once(dirname(__FILE__)."/../classes/class_kml_point.php");
-require_once(dirname(__FILE__)."/../classes/class_kml_multigeometry.php");
-require_once(dirname(__FILE__)."/../classes/class_kml_placemark.php");
-
-/**
- * @package KML
- */
- class KmlOwsParser {
-	var $placemarkArray = array();
-	
-	public function __construct() {
-	}
-	
-	public function parseGeoJSON ($geoJSON, $kmlId) {
-		
-//		$e = new mb_notice("GEOJSON: " . $geoJSON);
-		$json = new Mapbender_JSON();
-		$geometryFromGeoJSON = $json->decode($geoJSON);
-		$id = 0;
-		
-		if (gettype($geometryFromGeoJSON) == "object" && $geometryFromGeoJSON->type == "FeatureCollection") {
-			if ($geometryFromGeoJSON->crs->type == "EPSG" && $geometryFromGeoJSON->crs->properties->code) {
-				$epsg = $geometryFromGeoJSON->crs->properties->code;	
-			}
-			// create Placemarks
-			for ($i = 0; $i < count($geometryFromGeoJSON->features); $i++) {
-				$e = new mb_notice("parsing plm #" . $i . "...length of placemarkArray: " . count($this->placemarkArray));
-				$feature = $geometryFromGeoJSON->features[$i];
-				if (gettype($feature) == "object" && $feature->type == "Feature") {
-					if ($feature->geometry->crs->type == "EPSG") {
-						$epsg = $feature->geometry->crs->properties->code;	
-					}
-					if (!$epsg) {
-						$e = new mb_notice("EPSG is not set! Aborting...(" . $epsg . ")");
-					}
-					$geometry = $feature->geometry;
-					
-					$currentGeometry = false;
-					//TODO: missing Polygon and MultiGeometry
-					switch ($geometry->type) {
-						case "LineString" :
-							$coordinateList = "";
-							for ($j = 0; $j < count($geometry->coordinates); $j++) {
-								if ($j > 0) {
-									$coordinateList .= " ";
-								}
-								$coordinateList .= implode(",", $geometry->coordinates[$j]);
-							}
-							$currentGeometry = new KMLLine($coordinateList, $epsg);
-							break;
-						case "Point" :
-							$coordinateList = implode(",", $geometry->coordinates);
-							$currentGeometry = new KMLPoint($coordinateList, $epsg);
-							break;
-					}
-					
-					if ($currentGeometry) {
-						$currentPlacemark = new KMLPlacemark($currentGeometry);
-
-						if (gettype($feature->properties) == "object") {
-							
-							foreach ($feature->properties as $key => $value) {
-								$currentPlacemark->setProperty($key, $value);
-							}
-							$currentPlacemark->setProperty("Mapbender:kml", true);
-							$currentPlacemark->setProperty("Mapbender:name", "unknown");
-							$currentPlacemark->setProperty("Mapbender:id", $kmlId);
-							$currentPlacemark->setProperty("Mapbender:placemarkId", $id);
-							$e = new mb_notice("adding to placemarkArray (current length: " . count($this->placemarkArray) . ")");
-							array_push($this->placemarkArray, $currentPlacemark);
-							$e = new mb_notice("added...new length: " . count($this->placemarkArray));
-							$id ++;
-						}
-					}
-				}
-			}
-		}
-		return true;
-	}
-		
-	public function parseKML ($kml, $kmlId) {
-		$doc = new DOMDocument("1.0");
-		$doc->preserveWhiteSpace = false;
-		$doc->loadXML($kml);
-
-		/*
-		 * Get geometry information only, store it in placemarkArray
-		 */
-		$placemarkTagArray = $doc->getElementsByTagName("Placemark");
-		
-		if (count($placemarkTagArray) > 0) {
-			$id = 0;
-			
-			foreach ($placemarkTagArray as $node) {
-	
-				$geometryArray = $this->getGeometryArrayFromPlacemarkOrMultigeometryNode($node);
-				$metadataArray = $this->getMetadataFromPlacemarkNode($node);
-				
-				/*
-				 * For a placemark, the geometryArray should only contain 1 geometry!
-				 */
-				for ($i=0; $i < count($geometryArray); $i++) {
-					$currentPlacemark = new KMLPlacemark($geometryArray[$i]);
-					
-					foreach ($metadataArray as $key => $value) {
-						$currentPlacemark->setProperty($key, $value);
-					}
-					$currentPlacemark->setProperty("Mapbender:kml", true);
-					$currentPlacemark->setProperty("Mapbender:name", "unknown");
-					$currentPlacemark->setProperty("Mapbender:id", $kmlId);
-					$currentPlacemark->setProperty("Mapbender:placemarkId", $id);
-					array_push($this->placemarkArray, $currentPlacemark);
-				}
-				$id ++;		    
-			}
-		}
-		else {
-			$e = new mb_exception("class_kml.php: KMLOWSParser: No placemarks found in KML.");
-			return false;
-		}
-		return true;
-	}
-
-	/**
-	 * Returns an associative array, containing metadata
-	 */
-	private function getMetadataFromPlacemarkNode ($node) {
-	    $children = $node->childNodes;
-	    
-	    $metadataArray = array();
-	    
-		// search "ExtendedData" tag
-		foreach ($children as $child) {
-			if (mb_strtoupper($this->sepNameSpace($child->nodeName)) == "EXTENDEDDATA") {  
-				$extendedDataNode = $child;
-				$extDataChildren = $extendedDataNode->childNodes; 
-				
-				// search "Data" or "SchemaData" tag
-				foreach ($extDataChildren as $extDataChild) {
-					if (mb_strtoupper($this->sepNameSpace($extDataChild->nodeName)) == "SCHEMADATA") {
-						$simpleDataNode = $extDataChild->firstChild;
-						while ($simpleDataNode !== NULL) {
-							if (mb_strtoupper($this->sepNameSpace($simpleDataNode->nodeName)) == "SIMPLEDATA") {
-								$name = $simpleDataNode->getAttribute("name");
-								$value = $simpleDataNode->nodeValue;
-								$metadataArray[$name] = $value;
-							}
-							$simpleDataNode = $simpleDataNode->nextSibling;
-						}
-					}
-					if (mb_strtoupper($this->sepNameSpace($extDataChild->nodeName)) == "DATA") {
-						$dataNode = $extDataChild;
-						$name = $dataNode->getAttribute("name");
-						$metadataArray[$name] = $dataNode->nodeValue;
-					}
-				}
-			}
-		}
-		return $metadataArray;		
-	}
-	
-	/**
-	 * Given a "Point" node, this function returns the geometry (KMLPoint)
-	 * from within the node.
-	 */
-	private function getGeometryFromPointNode ($node) {
-		$coordinatesNode = $this->getCoordinatesNode($node);
-		$geomString = $coordinatesNode->nodeValue;
-		return new KMLPoint($geomString, 4326);
-	}
-	
-	/**
-	 * Given a "LineString" node, this function returns the geometry (KMLLine)
-	 * from within the node.
-	 */
-	private function getGeometryFromLinestringNode ($node) {
-		$coordinatesNode = $this->getCoordinatesNode($node);
-		$geomString = $coordinatesNode->nodeValue;
-		return new KMLLine($geomString, 4326);
-	}
-	
-	/**
-	 * Given a "Polygon" node, this function returns the geometry (KMLPolygon)
-	 * from within the node.
-	 */
-	private function getGeometryFromPolygonNode ($node) {
-		$polygon = null;
-
-	    $children = $node->childNodes;
-	    
-		// create new KMLPolygon
-		foreach ($children as $child) {
-			if (mb_strtoupper($this->sepNameSpace($child->nodeName)) == "EXTERIOR" || 
-				mb_strtoupper($this->sepNameSpace($child->nodeName)) == "OUTERBOUNDARYIS") {
-				// create a new Linear Ring
-				$outerBoundary = $this->getGeometryFromLinearRingNode($child);
-				$polygon = new KMLPolygon($outerBoundary);
-			}
-		}
-		
-		if ($polygon !== null) {
-			// append inner boundaries to KMLPolygon
-			foreach ($children as $child) {
-				if (mb_strtoupper($this->sepNameSpace($child->nodeName)) == "INTERIOR" || 
-					mb_strtoupper($this->sepNameSpace($child->nodeName)) == "INNERBOUNDARYIS") {
-					// create a new Linear Ring
-					$innerBoundary = $this->getGeometryFromLinearRingNode($child);
-					$polygon->appendInnerBoundary($innerBoundary);
-				}
-			}
-		}
-		return $polygon;
-	}
-	
-	/**
-	 * Given a "OuterBoundaryIs" or "InnerBoundaryIs" node, this function 
-	 * returns the geometry (KMLLinearRing) within the child node named "linearring"
-	 */
-	private function getGeometryFromLinearRingNode ($node) {
-	    $children = $node->childNodes;
-		foreach($children as $child) {
-			if (mb_strtoupper($this->sepNameSpace($child->nodeName)) == "LINEARRING") {
-				$coordinatesNode = $this->getCoordinatesNode($child);
-				$geomString = $coordinatesNode->nodeValue;
-				return new KMLLinearRing($geomString);
-			}
-		}
-		return null;
-	}
-	
-	/**
-	 * Checks if the child nodes of a given KML node contains any geometries and
-	 * returns an array of geometries (KMLPoint, KMLPolygon, KMLLinestring and KMLMultigeometry)
-	 */
-	private function getGeometryArrayFromPlacemarkOrMultigeometryNode ($node) {
-	    $geometryArray = array();
-	    
-	    $children = $node->childNodes;
-		foreach($children as $child) {
-			if (mb_strtoupper($this->sepNameSpace($child->nodeName)) == "POINT") {
-				array_push($geometryArray, $this->getGeometryFromPointNode($child));
-			}
-			elseif (mb_strtoupper($this->sepNameSpace($child->nodeName)) == "POLYGON") {
-				array_push($geometryArray, $this->getGeometryFromPolygonNode($child));
-			}
-			elseif (mb_strtoupper($this->sepNameSpace($child->nodeName)) == "LINESTRING") {
-				array_push($geometryArray, $this->getGeometryFromLinestringNode($child));
-			}
-			elseif (mb_strtoupper($this->sepNameSpace($child->nodeName)) == "MULTIGEOMETRY") {
-				$geometryArray = $this->getGeometryArrayFromPlacemarkOrMultigeometryNode($child);
-				$multigeometry = new KMLMultiGeometry();
-				
-				for ($i=0; $i < count($geometryArray); $i++) {
-					$multigeometry->append($geometryArray[$i]);	
-				}
-				array_push($geometryArray, $multigeometry);
-			}
-		}
-		return $geometryArray;
-	}
-
-	/**
-	 * Returns the child node with node name "coordinates" of a given KML node.
-	 * If no node is found, null is returned.
-	 */
-	private function getCoordinatesNode ($node) {
-	    $children = $node->childNodes;
-		foreach($children as $child) {
-			if (mb_strtoupper($this->sepNameSpace($child->nodeName)) == "POSLIST" || 
-				mb_strtoupper($this->sepNameSpace($child->nodeName)) == "POS" || 
-				mb_strtoupper($this->sepNameSpace($child->nodeName)) == "COORDINATES") {
-				return $child;
-			}
-		}
-		return null;
-	}
-
-	private function sepNameSpace($s){
-		$c = mb_strpos($s,":"); 
-		if($c>0){
-			return mb_substr($s,$c+1);
-		}
-		else{
-			return $s;
-		}		
-	}
-}
-?>
+<?php
+# $Id$
+# http://www.mapbender.org/index.php/class_wmc.php
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
+require_once(dirname(__FILE__)."/../classes/class_point.php");
+require_once(dirname(__FILE__)."/../classes/class_kml_polygon.php");
+require_once(dirname(__FILE__)."/../classes/class_kml_linearring.php");
+require_once(dirname(__FILE__)."/../classes/class_kml_line.php");
+require_once(dirname(__FILE__)."/../classes/class_kml_point.php");
+require_once(dirname(__FILE__)."/../classes/class_kml_multigeometry.php");
+require_once(dirname(__FILE__)."/../classes/class_kml_placemark.php");
+
+/**
+ * @package KML
+ */
+ class KmlOwsParser {
+	var $placemarkArray = array();
+	
+	public function __construct() {
+	}
+	
+	public function parseGeoJSON ($geoJSON, $kmlId) {
+		
+//		$e = new mb_notice("GEOJSON: " . $geoJSON);
+		$json = new Mapbender_JSON();
+		$geometryFromGeoJSON = $json->decode($geoJSON);
+		$id = 0;
+		
+		if (gettype($geometryFromGeoJSON) == "object" && $geometryFromGeoJSON->type == "FeatureCollection") {
+			if ($geometryFromGeoJSON->crs->type == "EPSG" && $geometryFromGeoJSON->crs->properties->code) {
+				$epsg = $geometryFromGeoJSON->crs->properties->code;	
+			}
+			// create Placemarks
+			for ($i = 0; $i < count($geometryFromGeoJSON->features); $i++) {
+				$e = new mb_notice("parsing plm #" . $i . "...length of placemarkArray: " . count($this->placemarkArray));
+				$feature = $geometryFromGeoJSON->features[$i];
+				if (gettype($feature) == "object" && $feature->type == "Feature") {
+					if ($feature->geometry->crs->type == "EPSG") {
+						$epsg = $feature->geometry->crs->properties->code;	
+					}
+					if (!$epsg) {
+						$e = new mb_notice("EPSG is not set! Aborting...(" . $epsg . ")");
+					}
+					$geometry = $feature->geometry;
+					
+					$currentGeometry = false;
+					//TODO: missing Polygon and MultiGeometry
+					switch ($geometry->type) {
+						case "LineString" :
+							$coordinateList = "";
+							for ($j = 0; $j < count($geometry->coordinates); $j++) {
+								if ($j > 0) {
+									$coordinateList .= " ";
+								}
+								$coordinateList .= implode(",", $geometry->coordinates[$j]);
+							}
+							$currentGeometry = new KMLLine($coordinateList, $epsg);
+							break;
+						case "Point" :
+							$coordinateList = implode(",", $geometry->coordinates);
+							$currentGeometry = new KMLPoint($coordinateList, $epsg);
+							break;
+					}
+					
+					if ($currentGeometry) {
+						$currentPlacemark = new KMLPlacemark($currentGeometry);
+
+						if (gettype($feature->properties) == "object") {
+							
+							foreach ($feature->properties as $key => $value) {
+								$currentPlacemark->setProperty($key, $value);
+							}
+							$currentPlacemark->setProperty("Mapbender:kml", true);
+							$currentPlacemark->setProperty("Mapbender:name", "unknown");
+							$currentPlacemark->setProperty("Mapbender:id", $kmlId);
+							$currentPlacemark->setProperty("Mapbender:placemarkId", $id);
+							$e = new mb_notice("adding to placemarkArray (current length: " . count($this->placemarkArray) . ")");
+							array_push($this->placemarkArray, $currentPlacemark);
+							$e = new mb_notice("added...new length: " . count($this->placemarkArray));
+							$id ++;
+						}
+					}
+				}
+			}
+		}
+		return true;
+	}
+		
+	public function parseKML ($kml, $kmlId) {
+		$doc = new DOMDocument("1.0");
+		$doc->preserveWhiteSpace = false;
+		$doc->loadXML($kml);
+
+		/*
+		 * Get geometry information only, store it in placemarkArray
+		 */
+		$placemarkTagArray = $doc->getElementsByTagName("Placemark");
+		
+		if (count($placemarkTagArray) > 0) {
+			$id = 0;
+			
+			foreach ($placemarkTagArray as $node) {
+	
+				$geometryArray = $this->getGeometryArrayFromPlacemarkOrMultigeometryNode($node);
+				$metadataArray = $this->getMetadataFromPlacemarkNode($node);
+				
+				/*
+				 * For a placemark, the geometryArray should only contain 1 geometry!
+				 */
+				for ($i=0; $i < count($geometryArray); $i++) {
+					$currentPlacemark = new KMLPlacemark($geometryArray[$i]);
+					
+					foreach ($metadataArray as $key => $value) {
+						$currentPlacemark->setProperty($key, $value);
+					}
+					$currentPlacemark->setProperty("Mapbender:kml", true);
+					$currentPlacemark->setProperty("Mapbender:name", "unknown");
+					$currentPlacemark->setProperty("Mapbender:id", $kmlId);
+					$currentPlacemark->setProperty("Mapbender:placemarkId", $id);
+					array_push($this->placemarkArray, $currentPlacemark);
+				}
+				$id ++;		    
+			}
+		}
+		else {
+			$e = new mb_exception("class_kml.php: KMLOWSParser: No placemarks found in KML.");
+			return false;
+		}
+		return true;
+	}
+
+	/**
+	 * Returns an associative array, containing metadata
+	 */
+	private function getMetadataFromPlacemarkNode ($node) {
+	    $children = $node->childNodes;
+	    
+	    $metadataArray = array();
+	    
+		// search "ExtendedData" tag
+		foreach ($children as $child) {
+			if (mb_strtoupper($this->sepNameSpace($child->nodeName)) == "EXTENDEDDATA") {  
+				$extendedDataNode = $child;
+				$extDataChildren = $extendedDataNode->childNodes; 
+				
+				// search "Data" or "SchemaData" tag
+				foreach ($extDataChildren as $extDataChild) {
+					if (mb_strtoupper($this->sepNameSpace($extDataChild->nodeName)) == "SCHEMADATA") {
+						$simpleDataNode = $extDataChild->firstChild;
+						while ($simpleDataNode !== NULL) {
+							if (mb_strtoupper($this->sepNameSpace($simpleDataNode->nodeName)) == "SIMPLEDATA") {
+								$name = $simpleDataNode->getAttribute("name");
+								$value = $simpleDataNode->nodeValue;
+								$metadataArray[$name] = $value;
+							}
+							$simpleDataNode = $simpleDataNode->nextSibling;
+						}
+					}
+					if (mb_strtoupper($this->sepNameSpace($extDataChild->nodeName)) == "DATA") {
+						$dataNode = $extDataChild;
+						$name = $dataNode->getAttribute("name");
+						$metadataArray[$name] = $dataNode->nodeValue;
+					}
+				}
+			}
+		}
+		return $metadataArray;		
+	}
+	
+	/**
+	 * Given a "Point" node, this function returns the geometry (KMLPoint)
+	 * from within the node.
+	 */
+	private function getGeometryFromPointNode ($node) {
+		$coordinatesNode = $this->getCoordinatesNode($node);
+		$geomString = $coordinatesNode->nodeValue;
+		return new KMLPoint($geomString, 4326);
+	}
+	
+	/**
+	 * Given a "LineString" node, this function returns the geometry (KMLLine)
+	 * from within the node.
+	 */
+	private function getGeometryFromLinestringNode ($node) {
+		$coordinatesNode = $this->getCoordinatesNode($node);
+		$geomString = $coordinatesNode->nodeValue;
+		return new KMLLine($geomString, 4326);
+	}
+	
+	/**
+	 * Given a "Polygon" node, this function returns the geometry (KMLPolygon)
+	 * from within the node.
+	 */
+	private function getGeometryFromPolygonNode ($node) {
+		$polygon = null;
+
+	    $children = $node->childNodes;
+	    
+		// create new KMLPolygon
+		foreach ($children as $child) {
+			if (mb_strtoupper($this->sepNameSpace($child->nodeName)) == "EXTERIOR" || 
+				mb_strtoupper($this->sepNameSpace($child->nodeName)) == "OUTERBOUNDARYIS") {
+				// create a new Linear Ring
+				$outerBoundary = $this->getGeometryFromLinearRingNode($child);
+				$polygon = new KMLPolygon($outerBoundary);
+			}
+		}
+		
+		if ($polygon !== null) {
+			// append inner boundaries to KMLPolygon
+			foreach ($children as $child) {
+				if (mb_strtoupper($this->sepNameSpace($child->nodeName)) == "INTERIOR" || 
+					mb_strtoupper($this->sepNameSpace($child->nodeName)) == "INNERBOUNDARYIS") {
+					// create a new Linear Ring
+					$innerBoundary = $this->getGeometryFromLinearRingNode($child);
+					$polygon->appendInnerBoundary($innerBoundary);
+				}
+			}
+		}
+		return $polygon;
+	}
+	
+	/**
+	 * Given a "OuterBoundaryIs" or "InnerBoundaryIs" node, this function 
+	 * returns the geometry (KMLLinearRing) within the child node named "linearring"
+	 */
+	private function getGeometryFromLinearRingNode ($node) {
+	    $children = $node->childNodes;
+		foreach($children as $child) {
+			if (mb_strtoupper($this->sepNameSpace($child->nodeName)) == "LINEARRING") {
+				$coordinatesNode = $this->getCoordinatesNode($child);
+				$geomString = $coordinatesNode->nodeValue;
+				return new KMLLinearRing($geomString);
+			}
+		}
+		return null;
+	}
+	
+	/**
+	 * Checks if the child nodes of a given KML node contains any geometries and
+	 * returns an array of geometries (KMLPoint, KMLPolygon, KMLLinestring and KMLMultigeometry)
+	 */
+	private function getGeometryArrayFromPlacemarkOrMultigeometryNode ($node) {
+	    $geometryArray = array();
+	    
+	    $children = $node->childNodes;
+		foreach($children as $child) {
+			if (mb_strtoupper($this->sepNameSpace($child->nodeName)) == "POINT") {
+				array_push($geometryArray, $this->getGeometryFromPointNode($child));
+			}
+			elseif (mb_strtoupper($this->sepNameSpace($child->nodeName)) == "POLYGON") {
+				array_push($geometryArray, $this->getGeometryFromPolygonNode($child));
+			}
+			elseif (mb_strtoupper($this->sepNameSpace($child->nodeName)) == "LINESTRING") {
+				array_push($geometryArray, $this->getGeometryFromLinestringNode($child));
+			}
+			elseif (mb_strtoupper($this->sepNameSpace($child->nodeName)) == "MULTIGEOMETRY") {
+				$geometryArray = $this->getGeometryArrayFromPlacemarkOrMultigeometryNode($child);
+				$multigeometry = new KMLMultiGeometry();
+				
+				for ($i=0; $i < count($geometryArray); $i++) {
+					$multigeometry->append($geometryArray[$i]);	
+				}
+				array_push($geometryArray, $multigeometry);
+			}
+		}
+		return $geometryArray;
+	}
+
+	/**
+	 * Returns the child node with node name "coordinates" of a given KML node.
+	 * If no node is found, null is returned.
+	 */
+	private function getCoordinatesNode ($node) {
+	    $children = $node->childNodes;
+		foreach($children as $child) {
+			if (mb_strtoupper($this->sepNameSpace($child->nodeName)) == "POSLIST" || 
+				mb_strtoupper($this->sepNameSpace($child->nodeName)) == "POS" || 
+				mb_strtoupper($this->sepNameSpace($child->nodeName)) == "COORDINATES") {
+				return $child;
+			}
+		}
+		return null;
+	}
+
+	private function sepNameSpace($s){
+		$c = mb_strpos($s,":"); 
+		if($c>0){
+			return mb_substr($s,$c+1);
+		}
+		else{
+			return $s;
+		}		
+	}
+}
+?>

Modified: branches/print_dev/http/classes/class_layer_monitor.php
===================================================================
--- branches/print_dev/http/classes/class_layer_monitor.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_layer_monitor.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,57 +1,57 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.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");
-
-class Layer_load_count {
-
-	function __construct () {
-	}
-	
-	/**
-	 * increments the load count in table "layer_load_count" for
-	 * each layer in the WMC document by one. 
-	 */
-	function increment($layer_id) {
-
-		//check if an entry exists for the current layer id
-		$sql = "SELECT load_count FROM layer_load_count WHERE fkey_layer_id = $1";
-		$v = array($layer_id);
-		$t = array('i');
-		$res = db_prep_query($sql, $v, $t);
-		$row = db_fetch_array($res);
-
-		//if yes, increment the load counter
-		if ($row) {
-			$currentCount = $row["load_count"];
-			$sql = "UPDATE layer_load_count SET load_count = $1 WHERE fkey_layer_id = $2";
-			$v = array(intval($currentCount + 1), $layer_id);
-			$t = array('i', 'i');
-			$res = db_prep_query($sql, $v, $t);
-		}
-		//if no, insert a new row with current layer id and load_count = 1
-		else {
-			$sql = "INSERT INTO layer_load_count (fkey_layer_id, load_count) VALUES ($1, 1)";
-			$v = array($layer_id);
-			$t = array('i');
-			$res = db_prep_query($sql, $v, $t);
-		}
-	}
-}
-?>
+<?php
+# $Id$
+# http://www.mapbender.org/index.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");
+
+class Layer_load_count {
+
+	function __construct () {
+	}
+	
+	/**
+	 * increments the load count in table "layer_load_count" for
+	 * each layer in the WMC document by one. 
+	 */
+	function increment($layer_id) {
+
+		//check if an entry exists for the current layer id
+		$sql = "SELECT load_count FROM layer_load_count WHERE fkey_layer_id = $1";
+		$v = array($layer_id);
+		$t = array('i');
+		$res = db_prep_query($sql, $v, $t);
+		$row = db_fetch_array($res);
+
+		//if yes, increment the load counter
+		if ($row) {
+			$currentCount = $row["load_count"];
+			$sql = "UPDATE layer_load_count SET load_count = $1 WHERE fkey_layer_id = $2";
+			$v = array(intval($currentCount + 1), $layer_id);
+			$t = array('i', 'i');
+			$res = db_prep_query($sql, $v, $t);
+		}
+		//if no, insert a new row with current layer id and load_count = 1
+		else {
+			$sql = "INSERT INTO layer_load_count (fkey_layer_id, load_count) VALUES ($1, 1)";
+			$v = array($layer_id);
+			$t = array('i');
+			$res = db_prep_query($sql, $v, $t);
+		}
+	}
+}
+?>

Modified: branches/print_dev/http/classes/class_locale.php
===================================================================
--- branches/print_dev/http/classes/class_locale.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_locale.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,259 +1,269 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/class_locale.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");
-
-/**
- * sets the locale, depending on various settings:
- * 1) a language ID passed to the constructor
- * 2) the browser settings $_SERVER["HTTP_ACCEPT_LANGUAGE"]
- * 3) a default language ID
- *
- */
-class Mb_locale {
-	var $knownLanguages = null;
-	var $systemLocales = null;
-	var $browserLanguages = null;
-	var $os = null;
-	var $name = null;
-	var $defaultLanguage = "en";
-	var $status = "No locale set.";
-
-	function Mb_locale($languageId) {
-		if (!$languageId) {
-			$languageId = LANGUAGE;
-		}
-		$e = new Mb_notice("class_locale: setting locale to " . $languageId);
-		if (USE_I18N) {
-			if (!$this->setCurrentLocale($languageId)) {
-				$e = new Mb_exception("Locale could not be set. Language ID: '" . $languageId . "'");
-			}
-		}
-		else {
-			$this->setCurrentLocale($this->defaultLanguage);
-		}
-	}
-
-    /**
-	 * Get the current locale, evaluating GET/POST variables, browser languages
-     * and a default locale (in that preference)
-	 *
-	 * @returns current locale
-	 */
-	function setCurrentLocale($languageId) {
-
-		// try to set the locale to $languageId
-		if ($this->checkAndSetLocale($languageId)) {
-			return true;
-		}
-		else {
-			$e = new Mb_notice("class_locale: no input parameter specified.");
-		}
-
-		// determine the browser setting and try to set locale according to that
-		if ($this->browserLanguage == null) {
-			$this->setBrowserLanguages();
-		}
-		foreach ($this->browserLanguages as $lang) {
-			$e = new Mb_notice("trying browser setting " . $lang);
-			if ($this->checkAndSetLocale($lang)) {
-				return true;
-			}
-		}
-
-		// set to default language
-		$e = new Mb_notice("trying default language " . $this->defaultLanguage);
-		return $this->checkAndSetLocale($this->defaultLanguage);
-	}
-
-	/**
-	 * checks if a locale is available; if yes, it is set via setlocale
-	 *
-	 * @returns true if the the locale is set successfully; otherwise false
-	 */
-	function checkAndSetLocale($languageId) {
-		if ($this->os == null) {
-			$this->os = $this->guessHostOS();
-		}
-		
-		if (!USE_I18N || ($this->os != null && isset($languageId))) {
-			if ($this->isKnownLanguage($languageId)) {
-		
-				if ($this->systemLocales == null) {
-					$this->setSystemLocales();
-				}
-		
-				$locale = $this->systemLocales[$this->knownLanguages[$languageId]][$this->os];
-				$selectedLocale = setlocale(LC_MESSAGES, $locale);
-
-				if ($selectedLocale) {
-					$this->name = $selectedLocale;
-					$_SESSION["mb_lang"] = $languageId;
-					$_SESSION["mb_locale"] = $this->name;
-					$e = new Mb_notice("locale " . $this->name . " ok on " . $this->os);
-
-					// from http://de3.php.net/manual/de/function.gettext.php
-					$path = bindtextdomain("Mapbender", dirname(__FILE__)."/../../resources/locale/");
-					$enc = bind_textdomain_codeset("Mapbender", "UTF-8");
-					$dom = textdomain("Mapbender");
-					return true;
-				}
-			}
-		}
-		$e = new Mb_notice("locale " . $locale . " not found.");
-		return false;
-	}
-
-	/**
-	* Guess the operating system which on which this code is running
-	* multiple methods are tested for reliably guessing the os
-	*
-	* @private
-	* @returns string with os name
-	*/
-	function guessHostOS(){
-		if (strncasecmp(php_uname(), 'Windows', 7) == 0) {
-			return 'windows';
-		}
-		else if (strncasecmp(php_uname(), 'Linux', 5) == 0) {
-			return 'linux';
-		}
-		else if (strncasecmp(php_uname(), 'OpenBSD', 7) == 0) {
-			return 'bsd';
-		}
-		else if (strncasecmp(php_uname(), 'FreeBSD', 7) == 0) {
-			return 'bsd';
-		}
-		new mb_exception('unknown platform: could not interpret uname. php_uname() returned '. php_uname().'. Please report to MB developers');
-		return null;
-	}
-
-        /**
-         * checks if a language is supported
-         *
-         * @returns true if the language is supported; otherwise false
-         */
-        function isKnownLanguage($languageId) {
-                if ($this->knownLocales == null) {
-                        $this->setKnownLanguages();
-                }
-                if (array_key_exists($languageId, $this->knownLanguages)) {
-                        return true;
-                }
-                else {
-                        $e = new Mb_notice("language " . $languageId . " not supported.");
-                }
-                return false;
-        }
-
-
-
-        /**
-         * determines the available Locales on this system
-         */
-        function setSystemLocales() {
-			$this->systemLocales['pt_PT'] = array(
-				'linux' => 'pt_PT.utf8',
-				'windows' => 'Portuguese_Portugal.1252',
-				'bsd' => 'pt_PT',
-				'posix' => 'pt_PT'
-			);
-			$this->systemLocales['fr_FR'] = array(
-				'linux' => 'fr_FR.utf8',
-				'windows' => 'French_France.1252',
-				'bsd' => 'fr_FR',
-				'posix' => 'fr_FR'
-			);
-			$this->systemLocales['es_ES'] = array(
-				'linux' => 'es_ES.utf8',
-				'windows' => 'Spanish_Spain.1252',
-				'bsd' => 'es_ES',
-				'posix' => 'es_ES'
-			);
-			$this->systemLocales['it_IT'] = array(
-				'linux' => 'it_IT.utf8',
-				'windows' => 'Italian_Italy.1252',
-				'bsd' => 'it_IT',
-				'posix' => 'it_IT'
-			);
-			$this->systemLocales['de_DE'] = array(
-				'linux' => 'de_DE.utf8',
-				'windows' => 'German_Germany.1252',
-				'bsd' => 'de_DE',
-				'posix' => 'de_DE'
-			);
-			$this->systemLocales['en_US'] = array(
-				'linux' => 'en_US.utf8',
-				'windows' => 'English_United States.1252',
-				'bsd' => 'en_US',
-				'posix' => 'en_US'
-			);
-			$this->systemLocales['bg_BG'] = array(
-				'linux' => 'bg_BG.utf8',
-				'windows' => 'Bulgarian_Bulgaria.1251',
-				'bsd' => 'bg_BG',
-				'posix' => 'bg_BG'
-			);
-			$this->systemLocales['el_GR'] = array(
-				'linux' => 'el_GR.utf8',
-				'windows' => 'Greek_Greece.1253',
-				'bsd' => 'el_GR',
-				'posix' => 'el_GR'
-			);
-        }
-
-        /**
-         * set the known languages
-         */
-        function setKnownLanguages() {
-                $this->knownLanguages = array(
-						'en_US' => 'en_US',
-						'en' => 'en_US',
-						'de_DE' => 'de_DE',
-						'de' => 'de_DE',
-						'bg_BG' => 'bg_BG',
-						'bg' => 'bg_BG',
-						'es_ES' => 'es_ES',
-						'es' => 'es_ES',
-						'nl_NL' => 'nl_NL',
-						'nl' => 'nl_NL',
-						'fr_FR' => 'fr_FR',
-						'fr' => 'fr_FR',
-						'el_GR' => 'el_GR',
-						'gr' => 'el_GR',
-						'it_IT' => 'it_IT',
-						'it' => 'it_IT');
-        }
-
-        /**
-         * sets the languages accepted by the client browser
-         */
-        function setBrowserLanguages () {
-                $this->browserLanguages = array();
-
-            $bLangs = split(',', $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
-            foreach ($bLangs as $lang) {
-                        if (strpos($lang, ';') === false)
-                                array_push($this->browserLanguages, $lang);
-                        else
-                                array_push($this->browserLanguages, substr($lang, 0, strpos($lang, ';')));
-            }
-        }
-}
+<?php
+# $Id$
+# http://www.mapbender.org/index.php/class_locale.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");
+
+/**
+ * sets the locale, depending on various settings:
+ * 1) a language ID passed to the constructor
+ * 2) the browser settings $_SERVER["HTTP_ACCEPT_LANGUAGE"]
+ * 3) a default language ID
+ *
+ */
+class Mb_locale {
+	var $knownLanguages = null;
+	var $systemLocales = null;
+	var $browserLanguages = null;
+	var $os = null;
+	var $name = null;
+	var $defaultLanguage = "en";
+	var $status = "No locale set.";
+
+	function Mb_locale($languageId) {
+		if (!$languageId) {
+			$languageId = LANGUAGE;
+		}
+		$e = new Mb_notice("class_locale: setting locale to " . $languageId);
+		if (USE_I18N) {
+			if (!$this->setCurrentLocale($languageId)) {
+				$e = new Mb_exception("Locale could not be set. Language ID: '" . $languageId . "'");
+			}
+		}
+		else {
+			$this->setCurrentLocale($this->defaultLanguage);
+		}
+	}
+
+    /**
+	 * Get the current locale, evaluating GET/POST variables, browser languages
+     * and a default locale (in that preference)
+	 *
+	 * @returns current locale
+	 */
+	function setCurrentLocale($languageId) {
+
+		// try to set the locale to $languageId
+		if ($this->checkAndSetLocale($languageId)) {
+			return true;
+		}
+		else {
+			$e = new Mb_notice("class_locale: no input parameter specified.");
+		}
+
+		// determine the browser setting and try to set locale according to that
+		if ($this->browserLanguage == null) {
+			$this->setBrowserLanguages();
+		}
+		foreach ($this->browserLanguages as $lang) {
+			$e = new Mb_notice("trying browser setting " . $lang);
+			if ($this->checkAndSetLocale($lang)) {
+				return true;
+			}
+		}
+
+		// set to default language
+		$e = new Mb_notice("trying default language " . $this->defaultLanguage);
+		return $this->checkAndSetLocale($this->defaultLanguage);
+	}
+
+	/**
+	 * checks if a locale is available; if yes, it is set via setlocale
+	 *
+	 * @returns true if the the locale is set successfully; otherwise false
+	 */
+	function checkAndSetLocale($languageId) {
+		if ($this->os == null) {
+			$this->os = $this->guessHostOS();
+		}
+		
+		if (!USE_I18N || ($this->os != null && isset($languageId))) {
+			if ($this->isKnownLanguage($languageId)) {
+		
+				if ($this->systemLocales == null) {
+					$this->setSystemLocales();
+				}
+		
+				$locale = $this->systemLocales[$this->knownLanguages[$languageId]][$this->os];
+				$selectedLocale = setlocale(LC_MESSAGES, $locale);
+
+				if ($selectedLocale) {
+					$this->name = $selectedLocale;
+					$_SESSION["mb_lang"] = $languageId;
+					$_SESSION["mb_locale"] = $this->name;
+					$e = new Mb_notice("locale " . $this->name . " ok on " . $this->os);
+
+					// from http://de3.php.net/manual/de/function.gettext.php
+					$path = bindtextdomain("Mapbender", dirname(__FILE__)."/../../resources/locale/");
+					$enc = bind_textdomain_codeset("Mapbender", "UTF-8");
+					$dom = textdomain("Mapbender");
+					return true;
+				}
+			}
+		}
+		$e = new Mb_notice("locale " . $locale . " not found.");
+		return false;
+	}
+
+	/**
+	* Guess the operating system which on which this code is running
+	* multiple methods are tested for reliably guessing the os
+	*
+	* @private
+	* @returns string with os name
+	*/
+	function guessHostOS(){
+		if (strncasecmp(php_uname(), 'Windows', 7) == 0) {
+			return 'windows';
+		}
+		else if (strncasecmp(php_uname(), 'Linux', 5) == 0) {
+			return 'linux';
+		}
+		else if (strncasecmp(php_uname(), 'OpenBSD', 7) == 0) {
+			return 'bsd';
+		}
+		else if (strncasecmp(php_uname(), 'FreeBSD', 7) == 0) {
+			return 'bsd';
+		}
+		new mb_exception('unknown platform: could not interpret uname. php_uname() returned '. php_uname().'. Please report to MB developers');
+		return null;
+	}
+
+        /**
+         * checks if a language is supported
+         *
+         * @returns true if the language is supported; otherwise false
+         */
+        function isKnownLanguage($languageId) {
+                if ($this->knownLocales == null) {
+                        $this->setKnownLanguages();
+                }
+                if (array_key_exists($languageId, $this->knownLanguages)) {
+                        return true;
+                }
+                else {
+                        $e = new Mb_notice("language " . $languageId . " not supported.");
+                }
+                return false;
+        }
+
+
+
+        /**
+         * determines the available Locales on this system
+         */
+        function setSystemLocales() {
+			$this->systemLocales['pt_PT'] = array(
+				'linux' => 'pt_PT.utf8',
+				'windows' => 'Portuguese_Portugal.1252',
+				'bsd' => 'pt_PT',
+				'posix' => 'pt_PT'
+			);
+			$this->systemLocales['fr_FR'] = array(
+				'linux' => 'fr_FR.utf8',
+				'windows' => 'French_France.1252',
+				'bsd' => 'fr_FR',
+				'posix' => 'fr_FR'
+			);
+			$this->systemLocales['es_ES'] = array(
+				'linux' => 'es_ES.utf8',
+				'windows' => 'Spanish_Spain.1252',
+				'bsd' => 'es_ES',
+				'posix' => 'es_ES'
+			);
+			$this->systemLocales['it_IT'] = array(
+				'linux' => 'it_IT.utf8',
+				'windows' => 'Italian_Italy.1252',
+				'bsd' => 'it_IT',
+				'posix' => 'it_IT'
+			);
+			$this->systemLocales['de_DE'] = array(
+				'linux' => 'de_DE.utf8',
+				'windows' => 'German_Germany.1252',
+				'bsd' => 'de_DE',
+				'posix' => 'de_DE'
+			);
+			$this->systemLocales['en_US'] = array(
+				'linux' => 'en_US.utf8',
+				'windows' => 'English_United States.1252',
+				'bsd' => 'en_US',
+				'posix' => 'en_US'
+			);
+			$this->systemLocales['bg_BG'] = array(
+				'linux' => 'bg_BG.utf8',
+				'windows' => 'Bulgarian_Bulgaria.1251',
+				'bsd' => 'bg_BG',
+				'posix' => 'bg_BG'
+			);
+			$this->systemLocales['el_GR'] = array(
+				'linux' => 'el_GR.utf8',
+				'windows' => 'Greek_Greece.1253',
+				'bsd' => 'el_GR',
+				'posix' => 'el_GR'
+			);
+			$this->systemLocales['hu_HU'] = array(
+				'linux' => 'hu_HU.utf8',
+				'windows' => 'hu_HU.1250',
+				'bsd' => 'hu_HU',
+				'posix' => 'hu_HU'
+			);
+        }
+
+        /**
+         * set the known languages
+         */
+        function setKnownLanguages() {
+                $this->knownLanguages = array(
+						'en_US' => 'en_US',
+						'en' => 'en_US',
+						'de_DE' => 'de_DE',
+						'de' => 'de_DE',
+						'bg_BG' => 'bg_BG',
+						'bg' => 'bg_BG',
+						'es_ES' => 'es_ES',
+						'es' => 'es_ES',
+						'nl_NL' => 'nl_NL',
+						'nl' => 'nl_NL',
+						'fr_FR' => 'fr_FR',
+						'fr' => 'fr_FR',
+						'el_GR' => 'el_GR',
+						'gr' => 'el_GR',
+						'hu_HU' => 'hu_HU',
+						'hu' => 'hu_HU',
+						'pt_PT' => 'pt_PT',
+						'pt' => 'pt_PT',												
+						'it_IT' => 'it_IT',
+						'it' => 'it_IT');
+        }
+
+        /**
+         * sets the languages accepted by the client browser
+         */
+        function setBrowserLanguages () {
+                $this->browserLanguages = array();
+
+            $bLangs = split(',', $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
+            foreach ($bLangs as $lang) {
+                        if (strpos($lang, ';') === false)
+                                array_push($this->browserLanguages, $lang);
+                        else
+                                array_push($this->browserLanguages, substr($lang, 0, strpos($lang, ';')));
+            }
+        }
+}
 ?>
\ No newline at end of file

Modified: branches/print_dev/http/classes/class_ows.php
===================================================================
--- branches/print_dev/http/classes/class_ows.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_ows.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -84,7 +84,7 @@
 	 * @param String $url
 	 * @return String the character "&", "?", or ""
 	 */
-	final protected function getConjunctionCharacter ($url) {
+	final public function getConjunctionCharacter ($url) {
 		// does the URL contain "?"
 		$pos = strpos($url, "?");
 

Modified: branches/print_dev/http/classes/class_point.php
===================================================================
--- branches/print_dev/http/classes/class_point.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_point.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,202 +1,202 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.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");
-
-/**
- * A Mapbender_point is a 2- or 3-dimensional point with an EPSG. 
- */
-class Mapbender_point {
-	var $x;
-	var $y;
-	var $z;
-	var $epsg;
-	
-	/**
-	 * @constructor
-	 */
-	function __construct() {
-		if (func_num_args() == 4) {
-			$x = func_get_arg(0);
-			$y = func_get_arg(1);
-			$z = func_get_arg(2);
-			$epsg = func_get_arg(3);
-		}
-		else if (func_num_args() == 3) {
-			$x = func_get_arg(0);
-			$y = func_get_arg(1);
-			$z = false;
-			$epsg = func_get_arg(2);
-		}
-		else {
-			return;
-		}
-
-		if (!isset($x) || !isset($y) || !isset($epsg)) {
-			$e = new mb_exception("Mapbender_point: constructor: some parameters are not set (set (x: ".$x.", y: ".$y.", z: ".$z.", epsg:".$epsg.")!");
-		}
-		$this->x = $x;
-		$this->y = $y;
-		$this->z = $z;
-		$this->epsg = $epsg;
-	}
-	
-	/**
-	 * computes a new point with the minimal coordinates of this point and $point
-	 */
-	static function min ($point1, $point2) {
-		if ($point1->epsg == $point2->epsg) {
-			if ($point1->isWestOf($point2)) {
-				$minx = $point1->x;
-			}
-			else {
-				$minx = $point2->x;
-			}
-			if ($point1->isSouthOf($point2)) {
-				$miny = $point1->y;
-			}
-			else {
-				$miny = $point2->y;
-			}
-			return new Mapbender_point($minx, $miny, $point1->epsg);
-		}
-		else {
-			$e = new mb_exception("Mapbender_point: cannot process min with different EPSG codes");
-		}
-	}
-	
-	/**
-	 * computes a new point with the maximal coordinates of this point and $point
-	 */
-	static function max ($point1, $point2) {
-		if ($point1->epsg == $point2->epsg) {
-			if ($point1->isWestOf($point2)) {
-				$maxx = $point2->x;
-			}
-			else {
-				$maxx = $point1->x;
-			}
-			if ($point1->isSouthOf($point2)) {
-				$maxy = $point2->y;
-			}
-			else {
-				$maxy = $point1->y;
-			}
-			return new Mapbender_point($maxx, $maxy, $point1->epsg);
-		}
-		else {
-			$e = new mb_exception("Mapbender_point: cannot process min with different EPSG codes");
-		}
-	}
-	
-	function isWestOf($point) {
-		if ($this->x < $point->x) {
-			return true;
-		}
-	}
-
-	function isSouthOf($point) {
-		if ($this->y < $point->y) {
-			return true;
-		}
-	}
-	
-	/**
-	 * Addition
-	 * 
-	 * @param anotherPoint another Mapbender_point
-	 */
-	function plus ($anotherPoint) {
-		return new Mapbender_point($this->x + $anotherPoint->x, $this->y + $anotherPoint->y, $this->epsg);
-	}
-
-	/**
-	 * Subtraction
-	 * 
-	 * @param anotherPoint another Mapbender_point
-	 */
-	function minus ($anotherPoint) {
-		return $this->plus($anotherPoint->times(-1));
-	}
-	
-	/**
-	 * Scalar multiplication
-	 * 
-	 * @param aFloat a floating point number
-	 */
-	function times ($aFloat) {
-		return new Mapbender_point($this->x * $aFloat, $this->y * $aFloat, $this->epsg);
-	}
-
-	/**
-	 * transforms this point to another EPSG
-	 * 
-	 * @param {Integer} toEpsg the coordinates are transformed to this EPSG code.
-	 */
-	function transform($toEpsg) {
-		if(SYS_DBTYPE=='pgsql'){
-			$currentEpsg = preg_replace("/EPSG:/", "", $this->epsg);
-			$targetEpsg = preg_replace("/EPSG:/", "", $toEpsg);
-			$sql = "SELECT X(transform(GeometryFromText('POINT(".$this->x." ".$this->y.")',".$currentEpsg."),".$targetEpsg.")) as x, ";
-			$sql .= "Y(transform(GeometryFromText('POINT(".$this->x." ".$this->y.")',".$currentEpsg."),".$targetEpsg.")) as y, ";
-			if (isset($this->z)) {
-				$sql .= "Z(transform(GeometryFromText('POINT(".$this->x." ".$this->y." ".$this->z.")',".$currentEpsg."),".$targetEpsg.")) as z";
-			}
-			$res = db_query($sql);
-			if (isset($this->z)) {
-				$point = new Mapbender_point(db_result($res,0,"x"), db_result($res,0,"y"), db_result($res,0,"z"), $toEpsg);
-			}
-			else {
-				$point = new Mapbender_point(db_result($res,0,"x"), db_result($res,0,"y"), $toEpsg);
-			}
-			$this->x = $point->x;
-			$this->y = $point->y;
-			$this->z = $point->z;
-			$this->epsg = $point->epsg;
-		}
-		else {
-			$e = new mb_exception("transformCoordinates needs PostgreSQL");
-		}
-	}
-	
-	function toHtml () {
-		$str = "";
-
-		$xArray = explode(".", strval($this->x));
-		$str .= $xArray[0] . "°";
-		if ($xArray[1]) {
-			$str .= $xArray[1] . "'";
-		}
-		$str .= " O / ";
-		
-		$yArray = explode(".", strval($this->y));
-		$str .= $yArray[0] . "°";
-		if ($yArray[1]) {
-			$str .= $yArray[1] . "'";
-		}
-		$str .= " N";
-		return $str;
-		
-	}
-	
-	function __toString() {
-		return (string) "(" . $this->x . "," . $this->y . "," . $this->z . "," . $this->epsg . ")";
-	}
-}
-?>
+<?php
+# $Id$
+# http://www.mapbender.org/index.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");
+
+/**
+ * A Mapbender_point is a 2- or 3-dimensional point with an EPSG. 
+ */
+class Mapbender_point {
+	var $x;
+	var $y;
+	var $z;
+	var $epsg;
+	
+	/**
+	 * @constructor
+	 */
+	function __construct() {
+		if (func_num_args() == 4) {
+			$x = func_get_arg(0);
+			$y = func_get_arg(1);
+			$z = func_get_arg(2);
+			$epsg = func_get_arg(3);
+		}
+		else if (func_num_args() == 3) {
+			$x = func_get_arg(0);
+			$y = func_get_arg(1);
+			$z = false;
+			$epsg = func_get_arg(2);
+		}
+		else {
+			return;
+		}
+
+		if (!isset($x) || !isset($y) || !isset($epsg)) {
+			$e = new mb_exception("Mapbender_point: constructor: some parameters are not set (set (x: ".$x.", y: ".$y.", z: ".$z.", epsg:".$epsg.")!");
+		}
+		$this->x = $x;
+		$this->y = $y;
+		$this->z = $z;
+		$this->epsg = $epsg;
+	}
+	
+	/**
+	 * computes a new point with the minimal coordinates of this point and $point
+	 */
+	static function min ($point1, $point2) {
+		if ($point1->epsg == $point2->epsg) {
+			if ($point1->isWestOf($point2)) {
+				$minx = $point1->x;
+			}
+			else {
+				$minx = $point2->x;
+			}
+			if ($point1->isSouthOf($point2)) {
+				$miny = $point1->y;
+			}
+			else {
+				$miny = $point2->y;
+			}
+			return new Mapbender_point($minx, $miny, $point1->epsg);
+		}
+		else {
+			$e = new mb_exception("Mapbender_point: cannot process min with different EPSG codes");
+		}
+	}
+	
+	/**
+	 * computes a new point with the maximal coordinates of this point and $point
+	 */
+	static function max ($point1, $point2) {
+		if ($point1->epsg == $point2->epsg) {
+			if ($point1->isWestOf($point2)) {
+				$maxx = $point2->x;
+			}
+			else {
+				$maxx = $point1->x;
+			}
+			if ($point1->isSouthOf($point2)) {
+				$maxy = $point2->y;
+			}
+			else {
+				$maxy = $point1->y;
+			}
+			return new Mapbender_point($maxx, $maxy, $point1->epsg);
+		}
+		else {
+			$e = new mb_exception("Mapbender_point: cannot process min with different EPSG codes");
+		}
+	}
+	
+	function isWestOf($point) {
+		if ($this->x < $point->x) {
+			return true;
+		}
+	}
+
+	function isSouthOf($point) {
+		if ($this->y < $point->y) {
+			return true;
+		}
+	}
+	
+	/**
+	 * Addition
+	 * 
+	 * @param anotherPoint another Mapbender_point
+	 */
+	function plus ($anotherPoint) {
+		return new Mapbender_point($this->x + $anotherPoint->x, $this->y + $anotherPoint->y, $this->epsg);
+	}
+
+	/**
+	 * Subtraction
+	 * 
+	 * @param anotherPoint another Mapbender_point
+	 */
+	function minus ($anotherPoint) {
+		return $this->plus($anotherPoint->times(-1));
+	}
+	
+	/**
+	 * Scalar multiplication
+	 * 
+	 * @param aFloat a floating point number
+	 */
+	function times ($aFloat) {
+		return new Mapbender_point($this->x * $aFloat, $this->y * $aFloat, $this->epsg);
+	}
+
+	/**
+	 * transforms this point to another EPSG
+	 * 
+	 * @param {Integer} toEpsg the coordinates are transformed to this EPSG code.
+	 */
+	function transform($toEpsg) {
+		if(SYS_DBTYPE=='pgsql'){
+			$currentEpsg = preg_replace("/EPSG:/", "", $this->epsg);
+			$targetEpsg = preg_replace("/EPSG:/", "", $toEpsg);
+			$sql = "SELECT X(transform(GeometryFromText('POINT(".$this->x." ".$this->y.")',".$currentEpsg."),".$targetEpsg.")) as x, ";
+			$sql .= "Y(transform(GeometryFromText('POINT(".$this->x." ".$this->y.")',".$currentEpsg."),".$targetEpsg.")) as y, ";
+			if (isset($this->z)) {
+				$sql .= "Z(transform(GeometryFromText('POINT(".$this->x." ".$this->y." ".$this->z.")',".$currentEpsg."),".$targetEpsg.")) as z";
+			}
+			$res = db_query($sql);
+			if (isset($this->z)) {
+				$point = new Mapbender_point(db_result($res,0,"x"), db_result($res,0,"y"), db_result($res,0,"z"), $toEpsg);
+			}
+			else {
+				$point = new Mapbender_point(db_result($res,0,"x"), db_result($res,0,"y"), $toEpsg);
+			}
+			$this->x = $point->x;
+			$this->y = $point->y;
+			$this->z = $point->z;
+			$this->epsg = $point->epsg;
+		}
+		else {
+			$e = new mb_exception("transformCoordinates needs PostgreSQL");
+		}
+	}
+	
+	function toHtml () {
+		$str = "";
+
+		$xArray = explode(".", strval($this->x));
+		$str .= $xArray[0] . "°";
+		if ($xArray[1]) {
+			$str .= $xArray[1] . "'";
+		}
+		$str .= " O / ";
+		
+		$yArray = explode(".", strval($this->y));
+		$str .= $yArray[0] . "°";
+		if ($yArray[1]) {
+			$str .= $yArray[1] . "'";
+		}
+		$str .= " N";
+		return $str;
+		
+	}
+	
+	function __toString() {
+		return (string) "(" . $this->x . "," . $this->y . "," . $this->z . "," . $this->epsg . ")";
+	}
+}
+?>

Modified: branches/print_dev/http/classes/class_wfs.php
===================================================================
--- branches/print_dev/http/classes/class_wfs.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_wfs.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -18,7 +18,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 require_once(dirname(__FILE__)."/../../core/globalSettings.php");
-require_once(dirname(__FILE__)."/class_connector.php");
+require_once(dirname(__FILE__)."/class_connector.php");
 require_once(dirname(__FILE__)."/class_administration.php");
 require_once(dirname(__FILE__)."/class_gml.php");
 require_once(dirname(__FILE__)."/class_ows.php");

Modified: branches/print_dev/http/classes/class_wfsToDb.php
===================================================================
--- branches/print_dev/http/classes/class_wfsToDb.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_wfsToDb.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -18,7 +18,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 require_once(dirname(__FILE__)."/../../core/globalSettings.php");
-require_once(dirname(__FILE__)."/class_connector.php");
+require_once(dirname(__FILE__)."/class_connector.php");
 require_once(dirname(__FILE__)."/class_administration.php");
 require_once(dirname(__FILE__)."/class_wfs.php");
 
@@ -128,7 +128,7 @@
 		);
 			
 		$t = array('s', 's', 's', 's', 's', 's', 's', 's' ,'s' ,'s' ,'s' ,'s', 'i' ,'i');
-		$e = new mb_exception($sql . " " . print_r($v, true));
+		$e = new mb_exception("UPDATING WFS " . $aWfs->id);
 		$res = db_prep_query($sql, $v, $t);
 		if (!$res) {
 			$e = new mb_exception("Error while updating WFS in database.");
@@ -136,15 +136,27 @@
 			return false;
 		}
 		
-		// update existing WFS feature types
+		
 		$featureTypeNameArray = array();
 		for ($i = 0; $i < count($aWfs->featureTypeArray); $i++) {
 			$currentFeatureType = $aWfs->featureTypeArray[$i];
 			array_push($featureTypeNameArray, $currentFeatureType);
-			if (!WfsToDb::updateFeatureType($currentFeatureType)) {
-				db_rollback();
-				return false;
+			if (WfsToDb::featureTypeExists($currentFeatureType)) {
+				// update existing WFS feature types
+				$e = new mb_exception("FT exists");
+				if (!WfsToDb::updateFeatureType($currentFeatureType)) {
+					db_rollback();
+					return false;
+				}
 			}
+			else {
+				$e = new mb_exception("FT ne pas exists");
+				// insert new feature types
+				if (!WfsToDb::insertFeatureType($currentFeatureType)) {
+					db_rollback();
+					return false;
+				}
+			}
 		}		
 		
 		// delete obsolete WFS feature types
@@ -164,7 +176,6 @@
 			$sql .=  " AND featuretype_name NOT IN (" . $sql_in . ")";
 		}
 		
-		$e = new mb_exception($sql . " " . print_r($v, true));
 		$res = db_prep_query($sql,$v,$t);
 		if (!$res) {
 			$e = new mb_exception("Error while deleting obsolete WFS feature types in database.");
@@ -237,7 +248,7 @@
 			$aWfsFeatureTypeNamespace->value
 		);
 		$t = array("s", "s", "s", "s");
-		$e = new mb_exception($sql . " " . print_r($v, true));
+		$e = new mb_exception("INSERTING FT NS $aWfsId, FT: $aWfsFeatureTypeId, NS: $aWfsFeatureTypeNamespace->name");
 		$res = db_prep_query($sql, $v, $t);
 
 		if (!$res) {
@@ -265,6 +276,7 @@
 		);
 		$t = array("i", "s", "s");
 		
+		$e = new mb_exception("INSERTING FT EL (FT: $aWfsFeatureTypeId, NS: $aWfsFeatureTypeElement->name");
 		$res = db_prep_query($sql, $v, $t);
 		
 		if (!$res) {
@@ -274,6 +286,56 @@
 		
 		// set the WFS feature type element ID
 		$aWfsFeatureTypeElement->id = db_insert_id("", "wfs_element", "element_id");
+
+		//
+		//
+		//ADD THIS FEATURETYPE TO WFS CONFIGURATIONS THAT USE THIS FEATURETYPE
+		//
+		//
+		$sql = "SELECT wfs_conf_id FROM wfs_conf WHERE fkey_featuretype_id = $1";
+		$v = array($aWfsFeatureTypeId);
+		$t = array("i");
+		$res = db_prep_query($sql, $v, $t);
+		if (!$res) {
+			// no configuration exists for this featuretype, 
+			// which is fine
+			$e = new mb_notice("No WFS conf found for this featuretype (Couldn't insert new feature type element in wfs_conf_element!)");
+			return true;
+		}
+		while ($row = db_fetch_array($res)) {
+			$wfsConfId = $row["wfs_conf_id"];
+			
+			// check if wfs conf element exists for this
+			// featuretype element
+			$sqlConfElement = "SELECT COUNT(wfs_conf_element_id) AS cnt FROM " . 
+				"wfs_conf_element AS a, wfs_element AS b " . 
+				"WHERE a.f_id = b.element_id AND " .
+				"b.element_id = $1 AND a.fkey_wfs_conf_id = $2";
+			$v = array($aWfsFeatureTypeElement->id, $wfsConfId);
+			$t = array("i", "i");
+			$resConfElement = db_prep_query($sqlConfElement, $v, $t);
+			$rowConfElement = db_fetch_array($resConfElement);
+			$count = $rowConfElement["cnt"];
+			if ($count === "0") {
+				$e = new mb_notice("Inserting this feature type element (" . 
+					$aWfsFeatureTypeElement->id . ") into WFS conf ($wfsConfId)");
+				// Insert featuretype element in wfs_conf_element
+				$sqlInsertConfElement = "INSERT INTO wfs_conf_element " . 
+					"(fkey_wfs_conf_id, f_id) VALUES ($1, $2)";
+				$v = array($wfsConfId, $aWfsFeatureTypeElement->id);
+				$t = array("i", "i");
+				$resInsertConfElement = db_prep_query($sqlInsertConfElement, $v, $t);
+				if (!$res) {
+					$e = new mb_exception("Couldn't insert new feature type element in wfs_conf_element!");
+					return false;
+				}
+			}
+			else {
+				$e = new mb_notice("This feature type element (" . 
+					$aWfsFeatureTypeElement->id . ") already exists in WFS conf ($wfsConfId)");
+
+			}
+		}
 		
 		return true;
 	}
@@ -296,7 +358,7 @@
 		);
 		$t = array("s", "i", "i");
 
-		$e = new mb_exception($sql . " " . print_r($v, true));
+		$e = new mb_exception("UPDATING FT EL (FT: $aWfsFeatureTypeId, NS: $aWfsFeatureTypeElement->name");
 		$res = db_prep_query($sql, $v, $t);
 
 		if (!$res) {
@@ -327,6 +389,7 @@
 		);
 		$t = array('i','s','s','s','s');
 
+		$e = new mb_exception("INSERTING FT (FT: $aWfsFeatureType->name)");
 		$res = db_prep_query($sql,$v,$t);
 		if (!$res) {
 			$e = new mb_exception("Error while inserting WFS feature type into database.");
@@ -362,6 +425,8 @@
 	 */
 	private static function updateFeatureType ($aWfsFeatureType) {
 
+		$aWfsFeatureType->id = WfsToDb::getFeatureTypeId($aWfsFeatureType);
+
 		$sql = "UPDATE wfs_featuretype SET ";
 		$sql .= "featuretype_title = $1,";
 		$sql .= "featuretype_abstract = $2,";
@@ -375,7 +440,7 @@
 		);
 		$t = array('s','s','s','i');
 
-		$e = new mb_exception($sql . " " . print_r($v, true));
+		$e = new mb_exception("UPDATING FT (FT: $aWfsFeatureType->id)");
 
 		$res = db_prep_query($sql,$v,$t);
 		if (!$res) {
@@ -388,9 +453,16 @@
 		for ($i = 0; $i < count($aWfsFeatureType->elementArray); $i++) {
 			$currentElement = $aWfsFeatureType->elementArray[$i];
 			array_push($featureTypeElementNameArray, $currentElement);
-			if (!WfsToDb::updateFeatureTypeElement($aWfsFeatureType->id, $currentElement)) {
-				return false;
+			if (WfsToDb::featureTypeElementExists($aWfsFeatureType, $currentElement->name)) {
+				if (!WfsToDb::updateFeatureTypeElement($aWfsFeatureType->id, $currentElement)) {
+					return false;
+				}
 			}
+			else {
+				if (!WfsToDb::insertFeatureTypeElement($aWfsFeatureType->id, $currentElement)) {
+					return false;
+				}
+			}
 		}		
 		
 		// delete obsolete WFS feature type elements
@@ -410,7 +482,6 @@
 		if ($sql_in !== "")
 		$sql .= " AND element_name NOT IN (" . $sql_in . ")";
 
-		$e = new mb_exception($sql . " " . print_r($v, true));
 		$res = db_prep_query($sql,$v,$t);
 		if (!$res) {
 			$e = new mb_exception("Error while deleting obsolete WFS feature type element in database.");
@@ -425,7 +496,6 @@
 			$aWfsFeatureType->id
 		);
 		$t = array("i", "i");
-		$e = new mb_exception($sql . " " . print_r($v, true));
 		$res = db_prep_query($sql, $v, $t);
 		if (!$res) {
 			$e = new mb_exception("Error while deleting WFS feature type namespaces from the database.");
@@ -476,9 +546,10 @@
 			"fkey_wfs_id = $1 AND featuretype_name = $2";
 		$v = array(
 			$aWfsFeatureType->wfs->id,
-			$aWfsFeatureType->name,
+			$aWfsFeatureType->name
 		);
 		$t = array("i", "s");
+		$e = new mb_exception($sql . " " . print_r($v, true));
 		$res = db_prep_query($sql, $v, $t);
 		if ($row = db_fetch_array($res)) {
 			return $row["featuretype_id"];
@@ -498,5 +569,41 @@
 		}
 		return false;
 	}
+
+	/**
+	 * Gets the ID of a feature type element 
+	 * 
+	 * @return Integer
+	 * @param $aWfsFeatureType WfsFeatureType
+	 * @param $name WFS feature type element name
+	 */
+	private static function getFeatureTypeElementId ($aWfsFeatureType, $name) {
+		$sql = "SELECT element_id FROM wfs_element WHERE " . 
+			"fkey_featuretype_id = $1 AND element_name = $2";
+		$v = array(
+			$aWfsFeatureType->id,
+			$name,
+		);
+		$t = array("i", "s");
+		$res = db_prep_query($sql, $v, $t);
+		if ($row = db_fetch_array($res)) {
+			return $row["element_id"];
+		}
+		return null;
+	}
+	
+	/**
+	 * Checks if a featuretype element exists in the database. 
+	 * 
+	 * @return Boolean
+	 * @param $aWfsFeatureType WfsFeatureType
+	 * @param $name WFS feature type element name
+	 */
+	private static function featureTypeElementExists ($aWfsFeatureType, $name) {
+		if (WfsToDb::getFeatureTypeElementId($aWfsFeatureType, $name) !== null) {
+			return true;
+		}
+		return false;
+	}
 }
 ?>
\ No newline at end of file

Modified: branches/print_dev/http/classes/class_wfs_1_0.php
===================================================================
--- branches/print_dev/http/classes/class_wfs_1_0.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_wfs_1_0.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -18,7 +18,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 require_once(dirname(__FILE__)."/../../core/globalSettings.php");
-require_once(dirname(__FILE__)."/class_connector.php");
+require_once(dirname(__FILE__)."/class_connector.php");
 require_once(dirname(__FILE__)."/class_administration.php");
 require_once(dirname(__FILE__)."/class_wfs.php");
 

Modified: branches/print_dev/http/classes/class_wfs_1_0_factory.php
===================================================================
--- branches/print_dev/http/classes/class_wfs_1_0_factory.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_wfs_1_0_factory.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -31,6 +31,16 @@
  */
 class Wfs_1_0_Factory extends WfsFactory {
 
+	protected function createFeatureTypeFromUrl ($aWfs, $featureTypeName) {
+		$url = $aWfs->describeFeatureType . 
+			$aWfs->getConjunctionCharacter($aWfs->describeFeatureType) . 
+			"&SERVICE=WFS&VERSION=" . $aWfs->getVersion() . 
+			"&REQUEST=DescribeFeatureType&TYPENAME=" . $featureTypeName;
+		
+		$xml = $this->get($url);
+		return $this->createFeatureTypeFromXml ($xml, $aWfs);
+	}
+		
 	protected function createFeatureTypeFromXml ($xml, $myWfs) {
 		$newFeatureType = new WfsFeatureType($myWfs);
 
@@ -150,7 +160,6 @@
 				}
 				if($tag == "FEATURETYPE" && $element[type] == "open"){
 					$section = "featuretype";
-					$featureTypeNsArray = $element[attributes];
 				}
 				if($section == "featuretype" && $tag == "NAME"){
 					$featuretype_name = $element[value];
@@ -164,7 +173,7 @@
 				if($section == "featuretype" && $tag == "SRS"){
 					$featuretype_srs = $element[value];
 
-					$currentFeatureType = $this->createFeatureTypeFromUrl($myWfs, $featuretype_name, $featureTypeNsArray);
+					$currentFeatureType = $this->createFeatureTypeFromUrl($myWfs, $featuretype_name);
 					if ($currentFeatureType !== null) {
 						$currentFeatureType->name = $featuretype_name;
 						$currentFeatureType->title = $featuretype_title;

Modified: branches/print_dev/http/classes/class_wfs_1_1.php
===================================================================
--- branches/print_dev/http/classes/class_wfs_1_1.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_wfs_1_1.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -18,7 +18,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 require_once(dirname(__FILE__)."/../../core/globalSettings.php");
-require_once(dirname(__FILE__)."/class_connector.php");
+require_once(dirname(__FILE__)."/class_connector.php");
 require_once(dirname(__FILE__)."/class_administration.php");
 require_once(dirname(__FILE__)."/class_wfs.php");
 

Modified: branches/print_dev/http/classes/class_wfs_1_1_factory.php
===================================================================
--- branches/print_dev/http/classes/class_wfs_1_1_factory.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_wfs_1_1_factory.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -31,6 +31,22 @@
  */
 class Wfs_1_1_Factory extends WfsFactory {
 
+	protected function createFeatureTypeFromUrl ($aWfs, $featureTypeName, $featureTypeNsArray) {
+		$postData = "<?xml version=\"1.0\"?>\n".
+				"<DescribeFeatureType version=\"" . $aWfs->getVersion() . "\" " . 
+				"service=\"WFS\" xmlns=\"http://www.opengis.net/wfs\" ";
+				
+		if ($featuretype_name != $this->sepNameSpace($featureTypeName)) {
+			$key = "xmlns:" . $this->getNameSpace($featureTypeName);
+			$postData .= $key . "=\"" . $featureTypeNsArray[$key] . "\" ";
+		}
+		$postData .= "><TypeName>" . $featureTypeName . "</TypeName>" . 
+				"</DescribeFeatureType>";
+
+		$xml = $this->post($aWfs->describeFeatureType, $postData);
+		return $this->createFeatureTypeFromXml ($xml, $aWfs);
+	}
+		
 	protected function createFeatureTypeFromXml ($xml, $myWfs) {
 		$newFeatureType = new WfsFeatureType($myWfs);
 

Modified: branches/print_dev/http/classes/class_wfs_conf.php
===================================================================
--- branches/print_dev/http/classes/class_wfs_conf.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_wfs_conf.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,383 +1,383 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/class_wfs_conf.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");
-require_once(dirname(__FILE__)."/../classes/class_user.php");
-require_once(dirname(__FILE__)."/../classes/class_administration.php");
-require_once(dirname(__FILE__)."/../classes/class_json.php");
-
-class WfsConf {
-	var $confArray = array();
-
-	/**
-	 * Gets the configuration from the database
-	 */
-	function __construct () {
-
-	}
-	
-	function __toString () {
-		$json = new Mapbender_JSON();
-		return $json->encode($this->confArray);
-	}
-	
-	/**
-	 * Loads WFS conf data from the database
-	 * 
-	 * @return Object WFS conf data.
-	 * @param $idOrIdArray Object May be an integer or an array of integers representing WFS conf IDs.
-	 */
-	public function load ($idOrIdArray) {
-		// Check parameter and set idArray
-		if (isset($idOrIdArray)){
-			
-			// parameter is a number	
-			if (!is_array($idOrIdArray) && is_numeric($idOrIdArray)) {
-				$idOrIdArray = array(intval($idOrIdArray));
-			}
-
-			// parameter is an array of numbers
-			if (is_array($idOrIdArray)) {
-				$idArray = array();
-				for ($i=0; $i < count($idOrIdArray); $i++) {
-					if (!is_numeric($idOrIdArray[$i])) {
-						$e = new mb_exception("Wfs_conf: constructor: wrong parameter: ".$idOrIdArray[$i]." is not a number.");
-						return array();
-					}
-					array_push($idArray, intval($idOrIdArray[$i]));
-				}
-
-				// If a user ID is given, remove the ones the user has no access to
-				if ($_SESSION["mb_user_id"]) {
-					$user = new User($_SESSION["mb_user_id"]);
-					$idArray = array_intersect($idArray, $user->getWfsConfByPermission());
-				}
-
-				return $this->getWfsConfFromDb($idArray);
-			}
-			// parameter is invalid
-			else {
-				$e = new mb_exception("Wfs_conf: constructor: parameter must be number or an array of numbers.");
-				return array();
-			}
-		}
-		else {
-			$e = new mb_exception("Wfs_conf: constructor: parameter is not valid");
-			return null;
-		}
-	}
-	
-
-	// --------------------------- private -----------------------------------
-
-	/**
-	 * Gets the database content for a number of WFS configurations given by their IDs.
-	 * 
-	 * @return Array
-	 * @param $idArray Array an array of integer values representing WFS conf IDs.
-	 */
-	private static function getWfsConfFromDbByArray ($idArray) {
-		$rowArray = array();
-        foreach ($idArray as $id) {
-        		$sql = "SELECT * FROM wfs_conf ";
-                $sql .= "JOIN wfs ON wfs_conf.fkey_wfs_id = wfs.wfs_id ";
-                $sql .= "WHERE wfs_conf.wfs_conf_id = $1 LIMIT 1";
-        
-                $v = array($id);
-                $t = array("i");
-                $res = db_prep_query($sql, $v, $t);
-                $row = db_fetch_array($res);
-                array_push($rowArray, $row);
-        }
-        return $rowArray;
-	}
-	
-	public static function getGeomColumnNameByConfId ($confId) {
-		$elArray = self::getWfsConfElementFromDb($confId);
-		foreach ($elArray as $element) {
-			if ($element["f_geom"] == "1") {
-				return $element["element_name"];
-			}
-		}
-		return null;
-	}
-	
-	/**
-	 * Gets the database content of a WFS conf element given by a WFS conf ID.
-	 * 
-	 * @return Array
-	 * @param $id Integer the WFS conf ID.
-	 */
-	private static function getWfsConfElementFromDb ($id) {
-		$sql = "SELECT * FROM wfs_conf_element ";
-		$sql .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
-		$sql .= "WHERE wfs_conf_element.fkey_wfs_conf_id = $1 ";
-		#filtered on client side
-		#$sql .= "AND wfs_conf_element.f_search = 1 ";
-		$sql .= "ORDER BY wfs_conf_element.f_pos";
-		$v = array($id);
-		$t = array('i');
-		$res = db_prep_query($sql, $v, $t);
-	
-		$elementArray = array();
-		while ($row = db_fetch_array($res)) {
-			$currentElement = array("element_name" => $row["element_name"],
-									"element_type" => $row["element_type"],
-									"f_search" => $row["f_search"],
-									"f_style_id" => $row["f_style_id"],
-									"f_toupper" => $row["f_toupper"],
-									"f_label" => $row["f_label"],
-									"f_label_id" => $row["f_label_id"],
-									"f_geom" => $row["f_geom"],
-									"f_show" => $row["f_show"],
-									"f_mandatory" => $row["f_mandatory"],
-									"f_respos" => $row["f_respos"],
-									"f_min_input" => $row["f_min_input"],
-									"f_form_element_html" => $row["f_form_element_html"],
-									"f_auth_varname" => $row["f_auth_varname"],
-									"f_detailpos" => $row["f_detailpos"],
-									"f_operator" => $row["f_operator"],
-									"f_show_detail" => $row["f_show_detail"]
-									);
-			array_push($elementArray, $currentElement);
-		}
-		return $elementArray;
-	}
-
-	/**
-	 * Gets the database content of a WFS feature type given by a WFS ID and a featuretype ID.
-	 * 
-	 * @return Array
-	 * @param $wfsId Integer the WFS ID.
-	 * @param $featuretypeId Integer the WFS featuretype ID.
-	 */
-	private static function getWfsFeatureTypeFromDb($wfsId, $featuretypeId) {
-		$sql = "SELECT * FROM wfs_featuretype WHERE fkey_wfs_id = $1 AND featuretype_id = $2";
-		$v = array($wfsId, $featuretypeId);
-		$t = array("i", "i");
-	
-		$res = db_prep_query($sql, $v, $t);
-
-		$currentRow = array();
-		
-		if($row = db_fetch_array($res)){
-			$currentRow["featuretype_name"] = $row["featuretype_name"];
-			$currentRow["featuretype_srs"] = $row["featuretype_srs"];
-		}
-	
-		return $currentRow;
-	}
-	
-	/**
-	 * get WFS conf data from database
-	 */
-	private function getWfsConfFromDB ($idArray) {
-		
-		// if a user has access to some WFS confs...
-		if (count($idArray) > 0) {
-
-			// get WFS conf data from DB
-			$rowArray = self::getWfsConfFromDbByArray($idArray);
-			
-			for ($i=0; $i < count($rowArray); $i++) {
-	
-				// WFS conf data				
-				$currentRow = array("g_label" => $rowArray[$i]["g_label"], 
-			                        "g_label_id" => $rowArray[$i]["g_label_id"],
-									"g_style" => $rowArray[$i]["g_style"],
-									"g_button" => $rowArray[$i]["g_button"],
-									"g_button_id" => $rowArray[$i]["g_button_id"],
-									"g_buffer" => $rowArray[$i]["g_buffer"],
-									"g_res_style" => $rowArray[$i]["g_res_style"],
-									"g_use_wzgraphics" => $rowArray[$i]["g_use_wzgraphics"],
-									"wfs_id" => $rowArray[$i]["fkey_wfs_id"],
-									"featuretype_id" => $rowArray[$i]["fkey_featuretype_id"],
-									"wfs_getfeature" => $rowArray[$i]["wfs_getfeature"],
-									"wfs_describefeaturetype" => $rowArray[$i]["wfs_describefeaturetype"],
-									"wfs_transaction" => $rowArray[$i]["wfs_transaction"],
-									"element" => $elementArray
-									);
-
-				// get WFS conf element data of current WFS conf
-				$id = $rowArray[$i]["wfs_conf_id"];
-				$currentRow["element"] = self::getWfsConfElementFromDb($id);
-
-				// get WFS featuretype data of current WFS conf
-				$wfsId = $rowArray[$i]["fkey_wfs_id"];
-				$featuretypeId = $rowArray[$i]["fkey_featuretype_id"];
-				$currentRow = array_merge($currentRow , self::getWfsFeatureTypeFromDb($wfsId, $featuretypeId));
-
-				$this->confArray[$id] = $currentRow;
-			}
-			return $this->confArray;
-		}
-		else {
-			$e = new mb_warning("class_wfs_conf.php: getWfsConfFromDB: You don't have access to any WFS confs. Check EDIT WFS.");
-			return array();
-		}
-	}
-	
-}
-
-/**
- * @deprecated
- */
-class wfs_conf{
-	
-	var $wfs_id;
-	var $wfs_name;
-	var $wfs_title;
-	var $wfs_abstract;
-	var $wfs_getcapabilities;
-	var $wfs_describefeaturetype;
-	var $wfs_getfeature;
-	
-	var $features;
-	var $elements;
-	var $namespaces;
-		
-
-	function getallwfs($userid){
-		$this->wfs_id = array();
-		$this->wfs_name = array();
-		$this->wfs_title = array();
-		$this->wfs_abstract = array();
-		
-		global $DBSERVER,$DB,$OWNER,$PW;
-		$con = db_connect($DBSERVER,$OWNER,$PW);
-		db_select_db($DB,$con);
-		if($userid){
-		 	$sql = "SELECT * FROM wfs WHERE wfs_owner = $1";
-			$v = array($userid);
-			$t = array('i');
-			$res = db_prep_query($sql,$v,$t);
-		}
-		else{
-		 	$sql = "SELECT * FROM wfs";
-			$res = db_query($sql);
-		}
-		
-		$cnt = 0;
-		while ($row = db_fetch_array($res)){
-			$this->wfs_version[$cnt] = $row["wfs_version"];
-			$this->wfs_id[$cnt] = $row["wfs_id"];
-			$this->wfs_name[$cnt] = $row["wfs_name"];
-			$this->wfs_title[$cnt] = $row["wfs_title"];
-			$this->wfs_abstract[$cnt] = $row["wfs_abstract"];
-			$this->wfs_getcapabilities[$cnt] = $row["wfs_getcapabilities"];
-			$this->wfs_describefeaturetype[$cnt] = $row["wfs_describefeaturetype"];
-			$this->wfs_getfeature[$cnt] = $row["wfs_getfeature"];
-			$cnt++;
-		}	
-	}
-	function getfeatures($wfsid){
-		$this->features = new features($wfsid);
-	}
-	function getelements($feature){
-		$this->elements = new elements($feature);
-	}
-	function getnamespaces($feature){
-		$this->namespaces = new namespaces($feature);
-	}
-}
-class features extends wfs_conf{
-	
-	var $featuretype_id;
-	var $featuretype_name;
-	var $featuretype_title;
-	var $featuretype_srs;
-	
-	function features($id){		
-		
-		$featuretype_id = array();
-		$featuretype_name = array();
-		$featuretype_title = array();
-		$featuretype_srs = array();
-		
-		global $DBSERVER,$DB,$OWNER,$PW;
-		$con = db_connect($DBSERVER,$OWNER,$PW);
-		db_select_db($DB,$con);
-		$sql = "SELECT * FROM wfs_featuretype WHERE fkey_wfs_id = $1";
-		$v = array($id);
-		$t = array("i");
-		$res = db_prep_query($sql, $v, $t);
-		$cnt = 0;
-		while ($row = db_fetch_array($res)){
-			$this->featuretype_id[$cnt] = $row["featuretype_id"];
-			$this->featuretype_name[$cnt] = $row["featuretype_name"];
-			$this->featuretype_title[$cnt] = $row["featuretype_title"];
-			$this->featuretype_srs[$cnt] = $row["featuretype_srs"];
-			$cnt++;
-		}	
-	}	
-}
-class elements extends wfs_conf{
-	
-	var $element_id;
-	var $element_name;
-	var $element_type;
-	
-	function elements($fid){
-		
-		$element_id = array();
-		$element_name = array();
-		$element_type = array();
-		
-		global $DBSERVER,$DB,$OWNER,$PW;
-		$con = db_connect($DBSERVER,$OWNER,$PW);
-		db_select_db($DB,$con);
-		$sql = "SELECT * FROM wfs_element WHERE fkey_featuretype_id = $1";
-		$v = array($fid);
-		$t = array("s");
-		$res = db_prep_query($sql, $v, $t);
-		$cnt = 0;
-		while ($row = db_fetch_array($res)){
-			$this->element_id[$cnt] = $row["element_id"];
-			$this->element_name[$cnt] = $row["element_name"];
-			$this->element_type[$cnt] = $row["element_type"];
-			$cnt++;
-		}
-	}
-}
-class namespaces extends wfs_conf{
-	
-	var $namespace_name;
-	var $namespace_location;
-	
-	function namespaces($fid){
-		
-		$namespace_name = array();
-		$namespace_location = array();
-		
-		global $DBSERVER,$DB,$OWNER,$PW;
-		$con = db_connect($DBSERVER,$OWNER,$PW);
-		db_select_db($DB,$con);
-		$sql = "SELECT * FROM wfs_featuretype_namespace WHERE fkey_featuretype_id = $1";
-		$v = array($fid);
-		$t = array("s");
-		$res = db_prep_query($sql, $v, $t);
-		$cnt = 0;
-		while ($row = db_fetch_array($res)){
-			$this->namespace_name[$cnt] = $row["namespace"];
-			$this->namespace_location[$cnt] = $row["namespace_location"];
-			$cnt++;
-		}
-	}
-}
-?>
+<?php
+# $Id$
+# http://www.mapbender.org/index.php/class_wfs_conf.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");
+require_once(dirname(__FILE__)."/../classes/class_user.php");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
+
+class WfsConf {
+	var $confArray = array();
+
+	/**
+	 * Gets the configuration from the database
+	 */
+	function __construct () {
+
+	}
+	
+	function __toString () {
+		$json = new Mapbender_JSON();
+		return $json->encode($this->confArray);
+	}
+	
+	/**
+	 * Loads WFS conf data from the database
+	 * 
+	 * @return Object WFS conf data.
+	 * @param $idOrIdArray Object May be an integer or an array of integers representing WFS conf IDs.
+	 */
+	public function load ($idOrIdArray) {
+		// Check parameter and set idArray
+		if (isset($idOrIdArray)){
+			
+			// parameter is a number	
+			if (!is_array($idOrIdArray) && is_numeric($idOrIdArray)) {
+				$idOrIdArray = array(intval($idOrIdArray));
+			}
+
+			// parameter is an array of numbers
+			if (is_array($idOrIdArray)) {
+				$idArray = array();
+				for ($i=0; $i < count($idOrIdArray); $i++) {
+					if (!is_numeric($idOrIdArray[$i])) {
+						$e = new mb_exception("Wfs_conf: constructor: wrong parameter: ".$idOrIdArray[$i]." is not a number.");
+						return array();
+					}
+					array_push($idArray, intval($idOrIdArray[$i]));
+				}
+
+				// If a user ID is given, remove the ones the user has no access to
+				if ($_SESSION["mb_user_id"]) {
+					$user = new User($_SESSION["mb_user_id"]);
+					$idArray = array_intersect($idArray, $user->getWfsConfByPermission());
+				}
+
+				return $this->getWfsConfFromDb($idArray);
+			}
+			// parameter is invalid
+			else {
+				$e = new mb_exception("Wfs_conf: constructor: parameter must be number or an array of numbers.");
+				return array();
+			}
+		}
+		else {
+			$e = new mb_exception("Wfs_conf: constructor: parameter is not valid");
+			return null;
+		}
+	}
+	
+
+	// --------------------------- private -----------------------------------
+
+	/**
+	 * Gets the database content for a number of WFS configurations given by their IDs.
+	 * 
+	 * @return Array
+	 * @param $idArray Array an array of integer values representing WFS conf IDs.
+	 */
+	private static function getWfsConfFromDbByArray ($idArray) {
+		$rowArray = array();
+        foreach ($idArray as $id) {
+        		$sql = "SELECT * FROM wfs_conf ";
+                $sql .= "JOIN wfs ON wfs_conf.fkey_wfs_id = wfs.wfs_id ";
+                $sql .= "WHERE wfs_conf.wfs_conf_id = $1 LIMIT 1";
+        
+                $v = array($id);
+                $t = array("i");
+                $res = db_prep_query($sql, $v, $t);
+                $row = db_fetch_array($res);
+                array_push($rowArray, $row);
+        }
+        return $rowArray;
+	}
+	
+	public static function getGeomColumnNameByConfId ($confId) {
+		$elArray = self::getWfsConfElementFromDb($confId);
+		foreach ($elArray as $element) {
+			if ($element["f_geom"] == "1") {
+				return $element["element_name"];
+			}
+		}
+		return null;
+	}
+	
+	/**
+	 * Gets the database content of a WFS conf element given by a WFS conf ID.
+	 * 
+	 * @return Array
+	 * @param $id Integer the WFS conf ID.
+	 */
+	private static function getWfsConfElementFromDb ($id) {
+		$sql = "SELECT * FROM wfs_conf_element ";
+		$sql .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
+		$sql .= "WHERE wfs_conf_element.fkey_wfs_conf_id = $1 ";
+		#filtered on client side
+		#$sql .= "AND wfs_conf_element.f_search = 1 ";
+		$sql .= "ORDER BY wfs_conf_element.f_pos";
+		$v = array($id);
+		$t = array('i');
+		$res = db_prep_query($sql, $v, $t);
+	
+		$elementArray = array();
+		while ($row = db_fetch_array($res)) {
+			$currentElement = array("element_name" => $row["element_name"],
+									"element_type" => $row["element_type"],
+									"f_search" => $row["f_search"],
+									"f_style_id" => $row["f_style_id"],
+									"f_toupper" => $row["f_toupper"],
+									"f_label" => $row["f_label"],
+									"f_label_id" => $row["f_label_id"],
+									"f_geom" => $row["f_geom"],
+									"f_show" => $row["f_show"],
+									"f_mandatory" => $row["f_mandatory"],
+									"f_respos" => $row["f_respos"],
+									"f_min_input" => $row["f_min_input"],
+									"f_form_element_html" => $row["f_form_element_html"],
+									"f_auth_varname" => $row["f_auth_varname"],
+									"f_detailpos" => $row["f_detailpos"],
+									"f_operator" => $row["f_operator"],
+									"f_show_detail" => $row["f_show_detail"]
+									);
+			array_push($elementArray, $currentElement);
+		}
+		return $elementArray;
+	}
+
+	/**
+	 * Gets the database content of a WFS feature type given by a WFS ID and a featuretype ID.
+	 * 
+	 * @return Array
+	 * @param $wfsId Integer the WFS ID.
+	 * @param $featuretypeId Integer the WFS featuretype ID.
+	 */
+	private static function getWfsFeatureTypeFromDb($wfsId, $featuretypeId) {
+		$sql = "SELECT * FROM wfs_featuretype WHERE fkey_wfs_id = $1 AND featuretype_id = $2";
+		$v = array($wfsId, $featuretypeId);
+		$t = array("i", "i");
+	
+		$res = db_prep_query($sql, $v, $t);
+
+		$currentRow = array();
+		
+		if($row = db_fetch_array($res)){
+			$currentRow["featuretype_name"] = $row["featuretype_name"];
+			$currentRow["featuretype_srs"] = $row["featuretype_srs"];
+		}
+	
+		return $currentRow;
+	}
+	
+	/**
+	 * get WFS conf data from database
+	 */
+	private function getWfsConfFromDB ($idArray) {
+		
+		// if a user has access to some WFS confs...
+		if (count($idArray) > 0) {
+
+			// get WFS conf data from DB
+			$rowArray = self::getWfsConfFromDbByArray($idArray);
+			
+			for ($i=0; $i < count($rowArray); $i++) {
+	
+				// WFS conf data				
+				$currentRow = array("g_label" => $rowArray[$i]["g_label"], 
+			                        "g_label_id" => $rowArray[$i]["g_label_id"],
+									"g_style" => $rowArray[$i]["g_style"],
+									"g_button" => $rowArray[$i]["g_button"],
+									"g_button_id" => $rowArray[$i]["g_button_id"],
+									"g_buffer" => $rowArray[$i]["g_buffer"],
+									"g_res_style" => $rowArray[$i]["g_res_style"],
+									"g_use_wzgraphics" => $rowArray[$i]["g_use_wzgraphics"],
+									"wfs_id" => $rowArray[$i]["fkey_wfs_id"],
+									"featuretype_id" => $rowArray[$i]["fkey_featuretype_id"],
+									"wfs_getfeature" => $rowArray[$i]["wfs_getfeature"],
+									"wfs_describefeaturetype" => $rowArray[$i]["wfs_describefeaturetype"],
+									"wfs_transaction" => $rowArray[$i]["wfs_transaction"],
+									"element" => $elementArray
+									);
+
+				// get WFS conf element data of current WFS conf
+				$id = $rowArray[$i]["wfs_conf_id"];
+				$currentRow["element"] = self::getWfsConfElementFromDb($id);
+
+				// get WFS featuretype data of current WFS conf
+				$wfsId = $rowArray[$i]["fkey_wfs_id"];
+				$featuretypeId = $rowArray[$i]["fkey_featuretype_id"];
+				$currentRow = array_merge($currentRow , self::getWfsFeatureTypeFromDb($wfsId, $featuretypeId));
+
+				$this->confArray[$id] = $currentRow;
+			}
+			return $this->confArray;
+		}
+		else {
+			$e = new mb_warning("class_wfs_conf.php: getWfsConfFromDB: You don't have access to any WFS confs. Check EDIT WFS.");
+			return array();
+		}
+	}
+	
+}
+
+/**
+ * @deprecated
+ */
+class wfs_conf{
+	
+	var $wfs_id;
+	var $wfs_name;
+	var $wfs_title;
+	var $wfs_abstract;
+	var $wfs_getcapabilities;
+	var $wfs_describefeaturetype;
+	var $wfs_getfeature;
+	
+	var $features;
+	var $elements;
+	var $namespaces;
+		
+
+	function getallwfs($userid){
+		$this->wfs_id = array();
+		$this->wfs_name = array();
+		$this->wfs_title = array();
+		$this->wfs_abstract = array();
+		
+		global $DBSERVER,$DB,$OWNER,$PW;
+		$con = db_connect($DBSERVER,$OWNER,$PW);
+		db_select_db($DB,$con);
+		if($userid){
+		 	$sql = "SELECT * FROM wfs WHERE wfs_owner = $1";
+			$v = array($userid);
+			$t = array('i');
+			$res = db_prep_query($sql,$v,$t);
+		}
+		else{
+		 	$sql = "SELECT * FROM wfs";
+			$res = db_query($sql);
+		}
+		
+		$cnt = 0;
+		while ($row = db_fetch_array($res)){
+			$this->wfs_version[$cnt] = $row["wfs_version"];
+			$this->wfs_id[$cnt] = $row["wfs_id"];
+			$this->wfs_name[$cnt] = $row["wfs_name"];
+			$this->wfs_title[$cnt] = $row["wfs_title"];
+			$this->wfs_abstract[$cnt] = $row["wfs_abstract"];
+			$this->wfs_getcapabilities[$cnt] = $row["wfs_getcapabilities"];
+			$this->wfs_describefeaturetype[$cnt] = $row["wfs_describefeaturetype"];
+			$this->wfs_getfeature[$cnt] = $row["wfs_getfeature"];
+			$cnt++;
+		}	
+	}
+	function getfeatures($wfsid){
+		$this->features = new features($wfsid);
+	}
+	function getelements($feature){
+		$this->elements = new elements($feature);
+	}
+	function getnamespaces($feature){
+		$this->namespaces = new namespaces($feature);
+	}
+}
+class features extends wfs_conf{
+	
+	var $featuretype_id;
+	var $featuretype_name;
+	var $featuretype_title;
+	var $featuretype_srs;
+	
+	function features($id){		
+		
+		$featuretype_id = array();
+		$featuretype_name = array();
+		$featuretype_title = array();
+		$featuretype_srs = array();
+		
+		global $DBSERVER,$DB,$OWNER,$PW;
+		$con = db_connect($DBSERVER,$OWNER,$PW);
+		db_select_db($DB,$con);
+		$sql = "SELECT * FROM wfs_featuretype WHERE fkey_wfs_id = $1";
+		$v = array($id);
+		$t = array("i");
+		$res = db_prep_query($sql, $v, $t);
+		$cnt = 0;
+		while ($row = db_fetch_array($res)){
+			$this->featuretype_id[$cnt] = $row["featuretype_id"];
+			$this->featuretype_name[$cnt] = $row["featuretype_name"];
+			$this->featuretype_title[$cnt] = $row["featuretype_title"];
+			$this->featuretype_srs[$cnt] = $row["featuretype_srs"];
+			$cnt++;
+		}	
+	}	
+}
+class elements extends wfs_conf{
+	
+	var $element_id;
+	var $element_name;
+	var $element_type;
+	
+	function elements($fid){
+		
+		$element_id = array();
+		$element_name = array();
+		$element_type = array();
+		
+		global $DBSERVER,$DB,$OWNER,$PW;
+		$con = db_connect($DBSERVER,$OWNER,$PW);
+		db_select_db($DB,$con);
+		$sql = "SELECT * FROM wfs_element WHERE fkey_featuretype_id = $1";
+		$v = array($fid);
+		$t = array("s");
+		$res = db_prep_query($sql, $v, $t);
+		$cnt = 0;
+		while ($row = db_fetch_array($res)){
+			$this->element_id[$cnt] = $row["element_id"];
+			$this->element_name[$cnt] = $row["element_name"];
+			$this->element_type[$cnt] = $row["element_type"];
+			$cnt++;
+		}
+	}
+}
+class namespaces extends wfs_conf{
+	
+	var $namespace_name;
+	var $namespace_location;
+	
+	function namespaces($fid){
+		
+		$namespace_name = array();
+		$namespace_location = array();
+		
+		global $DBSERVER,$DB,$OWNER,$PW;
+		$con = db_connect($DBSERVER,$OWNER,$PW);
+		db_select_db($DB,$con);
+		$sql = "SELECT * FROM wfs_featuretype_namespace WHERE fkey_featuretype_id = $1";
+		$v = array($fid);
+		$t = array("s");
+		$res = db_prep_query($sql, $v, $t);
+		$cnt = 0;
+		while ($row = db_fetch_array($res)){
+			$this->namespace_name[$cnt] = $row["namespace"];
+			$this->namespace_location[$cnt] = $row["namespace_location"];
+			$cnt++;
+		}
+	}
+}
+?>

Modified: branches/print_dev/http/classes/class_wfs_configuration.php
===================================================================
--- branches/print_dev/http/classes/class_wfs_configuration.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_wfs_configuration.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,191 +1,191 @@
-<?php
-# $Id: class_wfs_conf.php 3510 2009-02-03 10:36:01Z christoph $
-# http://www.mapbender.org/index.php/class_wfs_conf.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");
-require_once(dirname(__FILE__)."/../classes/class_user.php");
-require_once(dirname(__FILE__)."/../classes/class_administration.php");
-require_once(dirname(__FILE__)."/../classes/class_json.php");
-
-class WfsConfigurationElement {
-	var $name;
-	var $type;
-	var $search;
-	var $styleId;
-	var $toUpper;
-	var $label;
-	var $labelId;
-	var $geom;
-	var $show;
-	var $mandatory;
-	var $respos;
-	var $minInput;
-	var $formElementHtml;
-	var $authVarname;
-	var $detailPos;
-	var $operator;
-	var $showDetail;
-}	
-
-
-class WfsConfiguration {
-	
-	var $id;
-	var $wfsId;
-	var $featureTypeId;
-	var $label; 
-	var $labelId;
-	var $style;
-	var $button;
-	var $buttonId;
-	var $buffer;
-	var $resStyle;
-	var $elementArray = array();
-
-	function __construct () {
-	}
-	
-	public function getGeometryColumnName () {
-		foreach ($this->elementArray as $element) {
-			if ($element->geom) {
-				return $element->name;
-			}
-		}
-		$e = new mb_warning("This WFS conf doesn't have a geometry column.");
-		return null;
-	}
-	
-	/**
-	 * Finds the featuretype element which stores the authentication data.
-	 * 
-	 * @return String 
-	 */
-	public function getAuthElement () {
-		foreach ($this->elementArray as $element) {
-			if (!empty($element->authVarname)) {
-				$validname = preg_match('/^\$_[a-zA-z]+(\[\"[a-zA-Z_]+\"\])?$/', $element->authVarname);
-
-				if ($validname === 1) {
-					return $element;
-				}
-				else {
-					$e = new mb_exception("Found auth element, but variable name is not valid: " . $element->authVarname);
-				}
-			}
-		}
-		return null;
-	}
-
-	/**
-	 * Checks if the user currently logged in is allowed to access
-	 * the WFS configuration
-	 * 
-	 * @return Boolean
-	 */
-	private function accessAllowed () {
-		if ($_SESSION["mb_user_id"]) {
-			$user = new User($_SESSION["mb_user_id"]);
-
-			$allowedWfsConfIds = $user->getWfsConfByPermission();
-
-			$idArray = array_intersect(array($this->id), $allowedWfsConfIds);
-
-			if (count($idArray) === 1) {
-				return true;
-			}
-		}
-		return false;
-	}
-	
-	/**
-	 * Creates an object from the database.
-	 * Maybe we could have a factory for this later...let's
-	 * keep it simple for now
-	 * 
-	 * @return WfsConfiguration
-	 * @param $id Integer
-	 */
-	public static function createFromDb ($id) {
-		if (!is_numeric($id)) {
-			return null;	
-		}
-		$wfsConf = new WfsConfiguration();
-		$wfsConf->id = intval($id);
-		
-		if (!$wfsConf->accessAllowed()) {
-			return null;
-		}
-		
-		$sql = <<<SQL
-SELECT * FROM wfs_conf JOIN wfs ON wfs_conf.fkey_wfs_id = wfs.wfs_id 
-WHERE wfs_conf.wfs_conf_id = $1 LIMIT 1
-SQL;
-
-        $v = array($wfsConf->id);
-        $t = array("i");
-        $res = db_prep_query($sql, $v, $t);
-        $row = db_fetch_array($res);
-		
-		$wfsConf->label = $row["g_label"];
-		$wfsConf->labelId = $row["g_label_id"];
-		$wfsConf->style = $row["g_style"];
-		$wfsConf->button = $row["g_button"];
-		$wfsConf->buttonId = $row["g_button_id"];
-		$wfsConf->buffer = $row["g_buffer"];
-		$wfsConf->resStyle = $row["g_res_style"];
-		$wfsConf->wfsId = $row["fkey_wfs_id"];
-		$wfsConf->featureTypeId = $row["fkey_featuretype_id"];
-
-		$sql = <<<SQL
-SELECT * FROM wfs_conf_element JOIN wfs_element 
-ON wfs_conf_element.f_id = wfs_element.element_id 
-WHERE wfs_conf_element.fkey_wfs_conf_id = $1
-SQL;
-		$v = array($wfsConf->id);
-		$t = array('i');
-		$res = db_prep_query($sql, $v, $t);
-	
-		
-		while ($row = db_fetch_array($res)) {
-			$element = new WfsConfigurationElement();
-
-			$element->name = $row["element_name"];
-			$element->type = $row["element_type"];
-			$element->search = $row["f_search"];
-			$element->styleId = $row["f_style_id"];
-			$element->toUpper = $row["f_toupper"];
-			$element->label = $row["f_label"];
-			$element->labelId = $row["f_label_id"];
-			$element->geom = $row["f_geom"];
-			$element->show = $row["f_show"];
-			$element->mandatory = $row["f_mandatory"];
-			$element->respos = $row["f_respos"];
-			$element->minInput = $row["f_min_input"];
-			$element->formElementHtml = $row["f_form_element_html"];
-			$element->authVarname = stripslashes($row["f_auth_varname"]);
-			$element->detailpos = $row["f_detailpos"];
-			$element->operator = $row["f_operator"];
-			$element->showDetail = $row["f_show_detail"];
-
-			array_push($wfsConf->elementArray, $element);
-		}
-		
-		return $wfsConf;
-	}
-}
+<?php
+# $Id: class_wfs_conf.php 3510 2009-02-03 10:36:01Z christoph $
+# http://www.mapbender.org/index.php/class_wfs_conf.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");
+require_once(dirname(__FILE__)."/../classes/class_user.php");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
+
+class WfsConfigurationElement {
+	var $name;
+	var $type;
+	var $search;
+	var $styleId;
+	var $toUpper;
+	var $label;
+	var $labelId;
+	var $geom;
+	var $show;
+	var $mandatory;
+	var $respos;
+	var $minInput;
+	var $formElementHtml;
+	var $authVarname;
+	var $detailPos;
+	var $operator;
+	var $showDetail;
+}	
+
+
+class WfsConfiguration {
+	
+	var $id;
+	var $wfsId;
+	var $featureTypeId;
+	var $label; 
+	var $labelId;
+	var $style;
+	var $button;
+	var $buttonId;
+	var $buffer;
+	var $resStyle;
+	var $elementArray = array();
+
+	function __construct () {
+	}
+	
+	public function getGeometryColumnName () {
+		foreach ($this->elementArray as $element) {
+			if ($element->geom) {
+				return $element->name;
+			}
+		}
+		$e = new mb_warning("This WFS conf doesn't have a geometry column.");
+		return null;
+	}
+	
+	/**
+	 * Finds the featuretype element which stores the authentication data.
+	 * 
+	 * @return String 
+	 */
+	public function getAuthElement () {
+		foreach ($this->elementArray as $element) {
+			if (!empty($element->authVarname)) {
+				$validname = preg_match('/^\$_[a-zA-z]+(\[\"[a-zA-Z_]+\"\])?$/', $element->authVarname);
+
+				if ($validname === 1) {
+					return $element;
+				}
+				else {
+					$e = new mb_exception("Found auth element, but variable name is not valid: " . $element->authVarname);
+				}
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * Checks if the user currently logged in is allowed to access
+	 * the WFS configuration
+	 * 
+	 * @return Boolean
+	 */
+	private function accessAllowed () {
+		if ($_SESSION["mb_user_id"]) {
+			$user = new User($_SESSION["mb_user_id"]);
+
+			$allowedWfsConfIds = $user->getWfsConfByPermission();
+
+			$idArray = array_intersect(array($this->id), $allowedWfsConfIds);
+
+			if (count($idArray) === 1) {
+				return true;
+			}
+		}
+		return false;
+	}
+	
+	/**
+	 * Creates an object from the database.
+	 * Maybe we could have a factory for this later...let's
+	 * keep it simple for now
+	 * 
+	 * @return WfsConfiguration
+	 * @param $id Integer
+	 */
+	public static function createFromDb ($id) {
+		if (!is_numeric($id)) {
+			return null;	
+		}
+		$wfsConf = new WfsConfiguration();
+		$wfsConf->id = intval($id);
+		
+		if (!$wfsConf->accessAllowed()) {
+			return null;
+		}
+		
+		$sql = <<<SQL
+SELECT * FROM wfs_conf JOIN wfs ON wfs_conf.fkey_wfs_id = wfs.wfs_id 
+WHERE wfs_conf.wfs_conf_id = $1 LIMIT 1
+SQL;
+
+        $v = array($wfsConf->id);
+        $t = array("i");
+        $res = db_prep_query($sql, $v, $t);
+        $row = db_fetch_array($res);
+		
+		$wfsConf->label = $row["g_label"];
+		$wfsConf->labelId = $row["g_label_id"];
+		$wfsConf->style = $row["g_style"];
+		$wfsConf->button = $row["g_button"];
+		$wfsConf->buttonId = $row["g_button_id"];
+		$wfsConf->buffer = $row["g_buffer"];
+		$wfsConf->resStyle = $row["g_res_style"];
+		$wfsConf->wfsId = $row["fkey_wfs_id"];
+		$wfsConf->featureTypeId = $row["fkey_featuretype_id"];
+
+		$sql = <<<SQL
+SELECT * FROM wfs_conf_element JOIN wfs_element 
+ON wfs_conf_element.f_id = wfs_element.element_id 
+WHERE wfs_conf_element.fkey_wfs_conf_id = $1
+SQL;
+		$v = array($wfsConf->id);
+		$t = array('i');
+		$res = db_prep_query($sql, $v, $t);
+	
+		
+		while ($row = db_fetch_array($res)) {
+			$element = new WfsConfigurationElement();
+
+			$element->name = $row["element_name"];
+			$element->type = $row["element_type"];
+			$element->search = $row["f_search"];
+			$element->styleId = $row["f_style_id"];
+			$element->toUpper = $row["f_toupper"];
+			$element->label = $row["f_label"];
+			$element->labelId = $row["f_label_id"];
+			$element->geom = $row["f_geom"];
+			$element->show = $row["f_show"];
+			$element->mandatory = $row["f_mandatory"];
+			$element->respos = $row["f_respos"];
+			$element->minInput = $row["f_min_input"];
+			$element->formElementHtml = $row["f_form_element_html"];
+			$element->authVarname = stripslashes($row["f_auth_varname"]);
+			$element->detailpos = $row["f_detailpos"];
+			$element->operator = $row["f_operator"];
+			$element->showDetail = $row["f_show_detail"];
+
+			array_push($wfsConf->elementArray, $element);
+		}
+		
+		return $wfsConf;
+	}
+}
 ?>
\ No newline at end of file

Modified: branches/print_dev/http/classes/class_wfs_deprecated.php
===================================================================
--- branches/print_dev/http/classes/class_wfs_deprecated.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_wfs_deprecated.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -22,7 +22,7 @@
 */
 
 require_once(dirname(__FILE__)."/../../core/globalSettings.php");
-require_once(dirname(__FILE__)."/class_connector.php");
+require_once(dirname(__FILE__)."/class_connector.php");
 require_once(dirname(__FILE__)."/class_administration.php");
 require_once(dirname(__FILE__)."/class_ows.php");
 
@@ -69,7 +69,7 @@
 	$values = null;
 	$tags = null;
 	$admin = new administration();
-	$this->wfs_getcapabilities_doc = $admin->char_encode($data);
+	$this->wfs_getcapabilities_doc = $admin->char_encode($data);
 	$this->wfs_upload_url = $url;
 	
 	# for temporary wfs a id has to be created...
@@ -80,7 +80,7 @@
 	xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING,CHARSET);
 	xml_parse_into_struct($parser,$this->wfs_getcapabilities_doc,$values,$tags);
 	//xml_parse_into_struct($parser,$data,$values,$tags);
-	
+	
 	xml_parser_free($parser);
 	
 	$section = false;
@@ -206,7 +206,7 @@
 	$this->wfs_featuretype[count($this->wfs_featuretype)] = new featuretype($name,$title,$abstract,$srs,$url,$version);
 }
 */
-/*
+/*
  function stripEndlineAndCarriageReturn($string) {
 	  	return preg_replace("/\n/", "", preg_replace("/\r/", " ", $string));
 	  }

Modified: branches/print_dev/http/classes/class_wfs_factory.php
===================================================================
--- branches/print_dev/http/classes/class_wfs_factory.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_wfs_factory.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -49,20 +49,7 @@
 		throw new Exception("WFS version could not be determined from XML.");
 	}
 
-	protected function createFeatureTypeFromUrl ($aWfs, $featureTypeName, $featureTypeNsArray) {
-		$postData = "<?xml version=\"1.0\"?>\n".
-				"<DescribeFeatureType version=\"" . $aWfs->getVersion() . "\" " . 
-				"service=\"WFS\" xmlns=\"http://www.opengis.net/wfs\" ";
-				
-		if ($featuretype_name != $this->sepNameSpace($featureTypeName)) {
-			$key = "xmlns:" . $this->getNameSpace($featureTypeName);
-			$postData .= $key . "=\"" . $featureTypeNsArray[$key] . "\" ";
-		}
-		$postData .= "><TypeName>" . $featureTypeName . "</TypeName>" . 
-				"</DescribeFeatureType>";
-
-		$xml = $this->post($aWfs->describeFeatureType, $postData);
-		return $this->createFeatureTypeFromXml ($xml, $aWfs);
+	protected function createFeatureTypeFromUrl () {
 	}
 		
 	/**

Modified: branches/print_dev/http/classes/class_wfs_featuretype.php
===================================================================
--- branches/print_dev/http/classes/class_wfs_featuretype.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_wfs_featuretype.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -18,7 +18,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 require_once(dirname(__FILE__)."/../../core/globalSettings.php");
-require_once(dirname(__FILE__)."/class_connector.php");
+require_once(dirname(__FILE__)."/class_connector.php");
 require_once(dirname(__FILE__)."/class_administration.php");
 require_once(dirname(__FILE__)."/class_wfs.php");
 

Modified: branches/print_dev/http/classes/class_wmc.php
===================================================================
--- branches/print_dev/http/classes/class_wmc.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_wmc.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -216,7 +216,7 @@
 		$result = array();
 		if ($this->userId && $this->xml && $this->wmc_title) {
 			$sql = "INSERT INTO mb_user_wmc VALUES ($1, $2, $3, $4, $5)";
-			$v = array($this->wmc_id, $this->userId, $this->xml, $this->wmc_title, time());
+			$v = array($this->wmc_id, $this->userId, $this->xml, administration::convertOutgoingString($this->wmc_title), time());
 			$t = array("s", "i", "s", "s", "s");
 			
 			$res = db_prep_query($sql, $v, $t);
@@ -502,7 +502,7 @@
 			$tagLowerCase = administration::sepNameSpace($element[tag]);
 			$type = $element[type];
 			$attributes = $element[attributes];
-			$value = mb_utf8_decode(html_entity_decode($element[value])); // TODO: not sure if utf decoding is necessary
+			$value = mb_utf8_decode(html_entity_decode($element[value]));
 			
 			if ($tag == "VIEWCONTEXT" && $type == "open") {
 				$this->wmc_id = $attributes["id"];
@@ -873,7 +873,6 @@
 				"maxy" => $currentBox->max->y
 			));
 		}
-		new mb_exception("NEW LAYER EPSG: " . serialize($this->mainMap->getWms(0)->objLayer[0]->layer_epsg));
 		return true;
 	}
 
@@ -916,6 +915,11 @@
 			$currentMapIsOverview = true;
 		}
 
+		if (is_null($currentMap)) {
+			$e = new mb_exception('class_wmc.php: setLayerData: $currentMap is null. Aborting.');
+			return null;
+		}
+
 		$wmsArray = $currentMap->getWmsArray();
 
 		//
@@ -983,7 +987,7 @@
 			$wms->gui_wms_featureinfoformat = "text/html"; // TODO : Add correct data
 			$wms->gui_wms_exceptionformat = "application/vnd.ogc.se_xml"; // TODO : Add correct data
 			$wms->gui_wms_epsg = $this->mainMap->getEpsg();
-			$wms->gui_wms_visible = 1; // TODO : Add correct data
+			$wms->gui_wms_visible = $currentLayer["extension"]["WMS_VISIBLE"];
 			$wms->gui_wms_opacity = 100; // TODO : Add correct data
 			$wms->gui_wms_sldurl = $currentLayer["style"][$styleIndex]["sld_url"];
 

Modified: branches/print_dev/http/classes/class_wmcToXml.php
===================================================================
--- branches/print_dev/http/classes/class_wmcToXml.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_wmcToXml.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -47,6 +47,12 @@
 	// ---------------------------------------------------------------------
 	
 	public function getXml () {
+		if (is_null($this->wmc)) {
+			return null;
+		}
+		if ($this->xml == "") {
+			$this->toXml();
+		}
 		return $this->xml;
 	}
 	
@@ -95,7 +101,6 @@
 		$currentMap = $this->wmc->mainMap;
 		for ($i = 0; $i < count($currentWmsArray); $i++) {
 			$currentWms = $currentWmsArray[$i];
-			
 			for ($j = 0; $j < count($currentWms->objLayer); $j++) {
 				$currentLayer = $currentWms->objLayer[$j];
 				
@@ -121,7 +126,10 @@
 		$e_view_context->appendChild($e_layer_list);
 
 		$this->doc->appendChild($e_view_context);
+//		$this->xml = $this->doc->saveXML($this->doc->documentElement);
 		$this->xml = $this->doc->saveXML();
+		
+//		$e = new mb_notice($this->xml);
 	}
 
 	private function createGeneralNode () {
@@ -280,11 +288,13 @@
 			$e_layer->appendChild($e_service);
 
 			// Name
-			$e_layer_name = $this->doc->createElement("Name", $currentLayer->layer_name);
+			$currentLayerName = $currentLayer->layer_name;
+			$e_layer_name = $this->doc->createElement("Name", $currentLayerName);
 			$e_layer->appendChild($e_layer_name);
 
 			// Title
-			$e_layer_title = $this->doc->createElement("Title", $currentLayer->layer_title);
+			$currentLayerTitle = $currentLayer->layer_title;
+			$e_layer_title = $this->doc->createElement("Title", $currentLayerTitle);
 			$e_layer->appendChild($e_layer_title);
 
 			// Abstract
@@ -401,6 +411,7 @@
 		$layerExtensionData["layer_id"] = $currentLayer->layer_uid;
 		$layerExtensionData["wms_layer_id"] = $currentWms->objLayer[0]->layer_uid;
 		$layerExtensionData["wms_selectable"] = $currentWms->objLayer[0]->gui_layer_selectable;
+		$layerExtensionData["wms_visible"] = $currentWms->gui_wms_visible;
 		$layerExtensionData["layer_pos"] = $currentLayer->layer_pos;
 		$layerExtensionData["layer_parent"] = $currentLayer->layer_parent;
 		$layerExtensionData["wms_id"] = $currentLayer->gui_layer_wms_id;

Modified: branches/print_dev/http/classes/class_wms.php
===================================================================
--- branches/print_dev/http/classes/class_wms.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/classes/class_wms.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -107,11 +107,11 @@
 						$add_wms_string .= ",";
 				}
 				$add_wms_string .= "', transparent: 'true'";
-				$add_wms_string .= ",format: '".$this->gui_wms_mapformat."'});\n";
+				$add_wms_string .= ",format: '".$this->gui_wms_mapformat."'});";
 				if($base)
-					$add_wms_string .= 	"wms_".$this->wms_id.".isBaseLayer=true;\n";
-				$add_wms_string .= 	"wms_".$this->wms_id.".setVisibility(".($this->gui_wms_visible=="1"?"true":"false").");\n";
-				$add_wms_string .= "ol_map.addLayer(wms_".$this->wms_id.");\n";
+					$add_wms_string .= 	"wms_".$this->wms_id.".isBaseLayer=true;";
+				$add_wms_string .= 	"wms_".$this->wms_id.".setVisibility(".($this->gui_wms_visible=="1"?"true":"false").");";
+				$add_wms_string .= "ol_map.addLayer(wms_".$this->wms_id.");";
 		echo $add_wms_string;
 	}	
 	
@@ -284,6 +284,9 @@
 		$layer_style = array();
 		$cnt_styles = -1;
 		
+		$this->wms_getfeatureinfo = "";
+		$this->gui_wms_featureinfoformat = "";
+
 		foreach ($values as $element) {
 			if(mb_strtoupper($element[tag]) == "WMT_MS_CAPABILITIES" && $element[type] == "open"){
 				$this->wms_version = $element[attributes][version];
@@ -979,7 +982,7 @@
 			if($parent){
 				$str .=  "parent.";
 			}		
-			$str .= "wms_add_data_type_format('". $this->data_type[$i] ."','". $this->data_format[$i] ."');\n";		
+			$str .= "wms_add_data_type_format('". $this->data_type[$i] ."','". $this->data_format[$i] ."');";		
 		}
 		for($i=0; $i<count($this->objLayer); $i++){
 			if($parent){
@@ -1005,7 +1008,7 @@
 				$this->objLayer[$i]->gui_layer_querylayer ."','". 
 				$this->objLayer[$i]->gui_layer_minscale ."','". 
 				$this->objLayer[$i]->gui_layer_maxscale ."','".
-				$this->objLayer[$i]->gui_layer_wfs_featuretype ."');\n";
+				$this->objLayer[$i]->gui_layer_wfs_featuretype ."');";
 				
 			for($j=0; $j<count($this->objLayer[$i]->layer_epsg);$j++){
 				if($i==0){
@@ -1017,7 +1020,7 @@
 						$this->objLayer[$i]->layer_epsg[$j]["minx"] ."','". 
 						$this->objLayer[$i]->layer_epsg[$j]["miny"] ."','". 
 						$this->objLayer[$i]->layer_epsg[$j]["maxx"] ."','". 
-						$this->objLayer[$i]->layer_epsg[$j]["maxy"] ."');\n";
+						$this->objLayer[$i]->layer_epsg[$j]["maxy"] ."');";
 				}
 				if($parent){
 					$str .=  "parent.";
@@ -1027,7 +1030,7 @@
 					$this->objLayer[$i]->layer_epsg[$j]["minx"] ."','". 
 					$this->objLayer[$i]->layer_epsg[$j]["miny"] ."','". 
 					$this->objLayer[$i]->layer_epsg[$j]["maxx"] ."','". 
-					$this->objLayer[$i]->layer_epsg[$j]["maxy"] ."');\n";
+					$this->objLayer[$i]->layer_epsg[$j]["maxy"] ."');";
 			}
 			for($j=0; $j<count($this->objLayer[$i]->layer_style);$j++){
 				if($parent){
@@ -1038,7 +1041,7 @@
 					"', ".$j.
 					",".$i.
 					",'".$this->objLayer[$i]->layer_style[$j]["legendurl"].
-					"', '".$this->objLayer[$i]->layer_style[$j]["legendformat"]."');\n";
+					"', '".$this->objLayer[$i]->layer_style[$j]["legendformat"]."');";
 			}
 		}
 		return $str;
@@ -1069,13 +1072,13 @@
 			$this->gui_wms_epsg ."','". 
 			$this->gui_wms_visible ."','".
 			$this->gui_wms_opacity ."','".
-			$this->gui_wms_sldurl ."');\n");
+			$this->gui_wms_sldurl ."');");
 			
 		for($i=0;$i<count($this->data_format);$i++){
 			if($parent){
 				echo "parent.";
 			}		
-			echo "wms_add_data_type_format('". $this->data_type[$i] ."','". $this->data_format[$i] ."');\n";		
+			echo "wms_add_data_type_format('". $this->data_type[$i] ."','". $this->data_format[$i] ."');";		
 		}
 		for($i=0; $i<count($this->objLayer); $i++){
 			if($this->objLayer[$i]->layer_name == $layer_name|| $this->objLayer[$i]->layer_pos == 0){
@@ -1103,7 +1106,7 @@
 				$this->objLayer[$i]->gui_layer_querylayer ."','". 
 				$this->objLayer[$i]->gui_layer_minscale ."','". 
 				$this->objLayer[$i]->gui_layer_maxscale ."','".
-				$this->objLayer[$i]->gui_layer_wfs_featuretype ."');\n");
+				$this->objLayer[$i]->gui_layer_wfs_featuretype ."');");
 			for($j=0; $j<count($this->objLayer[$i]->layer_epsg);$j++){
 				if($i==0){
 					if($parent){
@@ -1114,7 +1117,7 @@
 						$this->objLayer[$i]->layer_epsg[$j]["minx"] ."','". 
 						$this->objLayer[$i]->layer_epsg[$j]["miny"] ."','". 
 						$this->objLayer[$i]->layer_epsg[$j]["maxx"] ."','". 
-						$this->objLayer[$i]->layer_epsg[$j]["maxy"] ."');\n");
+						$this->objLayer[$i]->layer_epsg[$j]["maxy"] ."');");
 				}
 				if($parent){
 				echo "parent.";
@@ -1124,13 +1127,13 @@
 					$this->objLayer[$i]->layer_epsg[$j]["minx"] ."','". 
 					$this->objLayer[$i]->layer_epsg[$j]["miny"] ."','". 
 					$this->objLayer[$i]->layer_epsg[$j]["maxx"] ."','". 
-					$this->objLayer[$i]->layer_epsg[$j]["maxy"] ."');\n");
+					$this->objLayer[$i]->layer_epsg[$j]["maxy"] ."');");
 			}
 			for($j=0; $j<count($this->objLayer[$i]->layer_style);$j++){
 				if($parent){
 				echo "parent.";
 				}
-				print("wms_addLayerStyle('".$this->objLayer[$i]->layer_style[$j]["name"]."', '".$this->objLayer[$i]->layer_style[$j]["title"]."', ".$j.",".$i.",'".$this->objLayer[$i]->layer_style[$j]["legendurl"]."', '".$this->objLayer[$i]->layer_style[$j]["legendformat"]."');\n");
+				print("wms_addLayerStyle('".$this->objLayer[$i]->layer_style[$j]["name"]."', '".$this->objLayer[$i]->layer_style[$j]["title"]."', ".$j.",".$i.",'".$this->objLayer[$i]->layer_style[$j]["legendurl"]."', '".$this->objLayer[$i]->layer_style[$j]["legendformat"]."');");
 			}
 		   }	
 		}
@@ -1812,8 +1815,8 @@
 			while($row2 = db_fetch_array($res_wms)){
 				$this->wms_id = $row2["wms_id"];
 				$this->wms_version = $row2["wms_version"];
-				$this->wms_title = $this->stripEndlineAndCarriageReturn($row2["wms_title"]);
-				$this->wms_abstract = $this->stripEndlineAndCarriageReturn($row2["wms_abstract"]);
+				$this->wms_title = administration::convertIncomingString($this->stripEndlineAndCarriageReturn($row2["wms_title"]));
+				$this->wms_abstract = administration::convertIncomingString($this->stripEndlineAndCarriageReturn($row2["wms_abstract"]));
 				$wmsowsproxy = $row2["wms_owsproxy"];
 				#$wmsowsproxy = "test";
 				if($wmsowsproxy != ""){
@@ -1875,8 +1878,8 @@
 				$this->addLayer($row2["layer_pos"],$row2["layer_parent"]);
 				$layer_cnt=count($this->objLayer)-1;
 				$this->objLayer[$layer_cnt]->layer_uid = $layer_id;
-				$this->objLayer[$layer_cnt]->layer_name =$row2["layer_name"];
-				$this->objLayer[$layer_cnt]->layer_title =$row2["layer_title"];			
+				$this->objLayer[$layer_cnt]->layer_name = administration::convertIncomingString($row2["layer_name"]);
+				$this->objLayer[$layer_cnt]->layer_title = administration::convertIncomingString($row2["layer_title"]);			
 				$this->objLayer[$layer_cnt]->layer_dataurl_href =$row2["layer_dataurl"];
 				$this->objLayer[$layer_cnt]->layer_metadataurl =$row2["layer_metadataurl"];
 				$this->objLayer[$layer_cnt]->layer_pos =$row2["layer_pos"];						

Modified: branches/print_dev/http/css/admin.css
===================================================================
--- branches/print_dev/http/css/admin.css	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/css/admin.css	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,32 +1,33 @@
-body{
-	font-size: 11px;
-	line-height: 12px;
-	font-family: "Verdana","Arial",sans-serif;
-	overflow-x: hidden;
-	background: white;
-	color: ThreedDarkShadow;
-}
-/* links */
-a {
-  text-decoration:none;
-  color:black;
-}
-a:visited {
-	color: ThreedDarkShadow;
-}
-a:active {
-	color: Lime;
-}
-a:hover {
-	color: ThreedDarkShadow;
-	background-color: #DCDCDC;
-
-}
-div{
-	font-size: 12px;
-	font-weight: bold;
-	text-decoration: underline;
-	color: Red;
-	margin-left: 2px;
-	background-color:#FFEDED;
+body{
+	font-size: 11px;
+	line-height: 12px;
+	font-family: "Verdana","Arial",sans-serif;
+	overflow-x: hidden;
+	background: white;
+	color: ThreedDarkShadow;
+}
+/* links */
+a {
+  text-decoration:none;
+  color:black;
+}
+a:visited {
+	color: ThreedDarkShadow;
+}
+a:active {
+	color: Lime;
+}
+a:hover {
+	color: ThreedDarkShadow;
+	background-color: #DCDCDC;
+
+}
+#loading_mapbender div, 
+#complete_mapbender div{
+	font-size: 12px;
+	font-weight: bold;
+	text-decoration: underline;
+	color: Red;
+	margin-left: 2px;
+	background-color:#FFEDED;
 }
\ No newline at end of file

Modified: branches/print_dev/http/css/admin.screen.css
===================================================================
--- branches/print_dev/http/css/admin.screen.css	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/css/admin.screen.css	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,123 +1,123 @@
- at charset "utf8";
-
-/* ################################################## */
-
-* {
-	font-weight: normal;
-	font-style: normal;
+ at charset "utf8";
+
+/* ################################################## */
+
+* {
+	font-weight: normal;
+	font-style: normal;
+}
+
+body {
+	padding: 1em;
+	font-family: "Lucida Sans Unicode","Lucida Sans","Lucida Grande","Trebuchet MS",Verdana,Arial,Helvetica,sans-serif;
+	font-size: 12px;
+	line-height: 1.2em;
+	color: #000;
+	background-color: #FFF;
+}
+
+/* ################################################## */
+
+h1 {
+	margin-bottom: 1em;
+	font-size: 2em;
+	color: #600;
+}
+
+p {
+	margin-bottom: 1em;
 }
 
-body {
-	padding: 1em;
-	font-family: "Lucida Sans Unicode","Lucida Sans","Lucida Grande","Trebuchet MS",Verdana,Arial,Helvetica,sans-serif;
-	font-size: 12px;
-	line-height: 1.2em;
-	color: #000;
-	background-color: #FFF;
-}
-
-/* ################################################## */
-
-h1 {
-	margin-bottom: 1em;
-	font-size: 2em;
-	color: #600;
-}
-
-p {
-	margin-bottom: 1em;
-}
-
 a {
 	color: #09C;
 }
 
 a:hover {
 	text-decoration: none;
-}
-
-/* ################################################## */
-
-form {
-	clear: both;
-	margin-top: 1em;
-}
-
+}
+
+/* ################################################## */
+
+form {
+	clear: both;
+	margin-top: 1em;
+}
+
 fieldset {
 	padding: 0;
 	border: 0;
-}
-
-legend {
+}
+
+legend {
 	display: block;
 	margin: 0;
 	padding: 0;
-	font-weight: bold;
-	text-transform: uppercase;
+	font-weight: bold;
+	text-transform: uppercase;
 	color: #600;
-}
-
+}
+
 label {
-	margin-bottom: .5em;
-	white-space: nowrap;
-}
-
+	margin-bottom: .5em;
+	white-space: nowrap;
+}
+
 input, textarea, select {
-	font: inherit;
+	font: inherit;
 	background-color: #EEE;
-	border: 1px solid #CCC;
-}
+	border: 1px solid #CCC;
+}
 
-hr {
+hr {
 	clear: both;
 	height: 1px;
-	color: #FFF;
-	background-color: transparent;
-	border: 0;
-}
+	color: #FFF;
+	background-color: transparent;
+	border: 0;
+}
+
+/* ################################################## */
 
-/* ################################################## */
-
 input.wide {
 	width: 100%;
 }
 
-.rightContainer {
-	float: right;
+.rightContainer {
+	float: right;
 	width: 40%;
-	margin-left: -1%;
-}
-
-
-.leftContainer {
-	float: left;
+	margin-left: -1%;
+}
+
+
+.leftContainer {
+	float: left;
 	width: 40%;
 	margin-right: -1%;
-}
-
-.centerContainer {
+}
+
+.centerContainer {
 	float: left;
-	width: 20%;
-	text-align: center;
-}
-
-.centerContainer legend {
-	visibility: hidden;
-}
-
-.rightContainer select,
-.leftContainer select {
-	width: 100%;
-}
-
-.centerContainer input#add,
-.centerContainer input#remove {
+	width: 20%;
+	text-align: center;
+}
+
+.centerContainer legend {
+	visibility: hidden;
+}
+
+.rightContainer select,
+.leftContainer select {
+	width: 100%;
+}
+
+.centerContainer input#add,
+.centerContainer input#remove {
 	margin-top: .5em;
 	margin-bottom: .5em;
-	padding-right: 1em;
+	padding-right: 1em;
 	padding-left: 1em;
-}
-
+}
+
 #indicator img {
 	vertical-align: middle;
 }
\ No newline at end of file

Modified: branches/print_dev/http/css/admin_service.css
===================================================================
--- branches/print_dev/http/css/admin_service.css	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/css/admin_service.css	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,32 +1,33 @@
-body{
-	font-size: 11px;
-	line-height: 12px;
-	font-family: "Verdana","Arial",sans-serif;
-	overflow-x: hidden;
-	background: white;
-	color: ThreedDarkShadow;
-}
-/* links */
-a {
-  text-decoration:none;
-  color:black;
-}
-a:visited {
-	color: ThreedDarkShadow;
-}
-a:active {
-	color: Lime;
-}
-a:hover {
-	color: Navy;
-	background-color: #DCDCDC;
-	font-weight: bold;
-}
-div{
-	font-size: 12px;
-	font-weight: bold;
-	text-decoration: underline;
-	color: Navy;
-	margin-left: 2px;
-	background-color:#E5F9FD;
+body{
+	font-size: 11px;
+	line-height: 12px;
+	font-family: "Verdana","Arial",sans-serif;
+	overflow-x: hidden;
+	background: white;
+	color: ThreedDarkShadow;
+}
+/* links */
+a {
+  text-decoration:none;
+  color:black;
+}
+a:visited {
+	color: ThreedDarkShadow;
+}
+a:active {
+	color: Lime;
+}
+a:hover {
+	color: Navy;
+	background-color: #DCDCDC;
+	font-weight: bold;
+}
+#loading_mapbender div, 
+#complete_mapbender div{
+	font-size: 12px;
+	font-weight: bold;
+	text-decoration: underline;
+	color: Navy;
+	margin-left: 2px;
+	background-color:#E5F9FD;
 }
\ No newline at end of file

Modified: branches/print_dev/http/css/admin_user.css
===================================================================
--- branches/print_dev/http/css/admin_user.css	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/css/admin_user.css	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,32 +1,33 @@
-body{
-	font-size: 11px;
-	line-height: 12px;
-	font-family: "Verdana","Arial",sans-serif;
-	overflow-x: hidden;
-	background: white;
-	color: ThreedDarkShadow;
-}
-/* links */
-a {
-  text-decoration:none;
-  color:black;
-}
-a:visited {
-	color: ThreedDarkShadow;
-}
-a:active {
-	color: Lime;
-}
-a:hover {
-	color: green;
-	background-color: #DCDCDC;
-	font-weight: bold;
-}
-div{
-	font-size: 12px;
-	font-weight: bold;
-	text-decoration: underline;
-	color: Green;
-	margin-left: 2px;
-	background-color:#ECFFE7;
+body{
+	font-size: 11px;
+	line-height: 12px;
+	font-family: "Verdana","Arial",sans-serif;
+	overflow-x: hidden;
+	background: white;
+	color: ThreedDarkShadow;
+}
+/* links */
+a {
+  text-decoration:none;
+  color:black;
+}
+a:visited {
+	color: ThreedDarkShadow;
+}
+a:active {
+	color: Lime;
+}
+a:hover {
+	color: green;
+	background-color: #DCDCDC;
+	font-weight: bold;
+}
+#loading_mapbender div, 
+#complete_mapbender div{
+	font-size: 12px;
+	font-weight: bold;
+	text-decoration: underline;
+	color: Green;
+	margin-left: 2px;
+	background-color:#ECFFE7;
 }
\ No newline at end of file

Modified: branches/print_dev/http/css/digitize.css
===================================================================
--- branches/print_dev/http/css/digitize.css	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/css/digitize.css	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,27 +1,22 @@
-.bp{
-	position:absolute;
-	top: 0px;
-	left: 0px;
-	background-color: #8a2be2;
-	width: 5px;
-	height: 5px;
-	font-size:1px;
-	cursor:pointer;
+.lp, .bp, .t_img {
+	position: absolute;
+	top: 0;
+	left: 0;
 }
 
-.lp{
-	position:absolute;
-	top: 0px;
-	left: 0px;
-	background-color: #ff00ff;
-	width: 4px;
-	height: 4px;
-	font-size:1px;
-	cursor:pointer;
+.lp, .bp {
+	font-size: 1px;
+	cursor: pointer;
 }
 
-.t_img{
-	position:absolute;
-	left:0px;
-	top:0px;
+.lp {
+	width: 2px;
+	height: 2px;
+	background-color: #000;
+}
+
+.bp {
+	width: 5px;
+	height: 5px;
+	background-color: #F00;
 }
\ No newline at end of file

Modified: branches/print_dev/http/css/edit_gui.css
===================================================================
--- branches/print_dev/http/css/edit_gui.css	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/css/edit_gui.css	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,48 +1,48 @@
-body{
-	background-color : #ffffff;
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 14px;
-}
-
-table{
-	font-size: 12px;
-}
-
-.table_top{
-	font-size: 14px;
-}
-
-select {
-	font-size: 14;
-	width: 200px;
-	size: 12px;
-}
-
-.select_short{
-	width: auto;
-}
-
-.Lbutton{
-		font-size : 9pt;
-		width:56px;
-}
-
-.button2{
-		font-size : 9pt;
-		width: 30px;
-}
-
-.button_on_off{
-		font-size : 9pt;
-		width: 24px;
-}
-
-.button_wfs{
-		font-size : 9pt;
-		width: 48px;
-}
-
-.myButton{
-		font-size : 14;
-		width: 100px;
-}
+body{
+	background-color : #ffffff;
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 14px;
+}
+
+table{
+	font-size: 12px;
+}
+
+.table_top{
+	font-size: 14px;
+}
+
+select {
+	font-size: 14;
+	width: 200px;
+	size: 12px;
+}
+
+.select_short{
+	width: auto;
+}
+
+.Lbutton{
+		font-size : 9pt;
+		width:56px;
+}
+
+.button2{
+		font-size : 9pt;
+		width: 30px;
+}
+
+.button_on_off{
+		font-size : 9pt;
+		width: 24px;
+}
+
+.button_wfs{
+		font-size : 9pt;
+		width: 48px;
+}
+
+.myButton{
+		font-size : 14;
+		width: 100px;
+}

Modified: branches/print_dev/http/css/gazetteerSQL_ALB.css
===================================================================
--- branches/print_dev/http/css/gazetteerSQL_ALB.css	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/css/gazetteerSQL_ALB.css	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,81 +1,81 @@
-	    body{
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    }
-	    .selectCommune{
-	    	position:absolute;
-	    	top:10px;
-	    	left:5px;
-	    	width:150px;
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    }
-	    .selectStreet{
-			visibility:hidden;
-	    	position:absolute;
-	    	top:40px;
-	    	left:5px;
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    	width: 150px;
-	    }
-	    .selectDistrict{
-			visibility:hidden;
-	    	position:absolute;
-	    	top:40px;
-	    	left:5px;
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    	width: 150px;
-	    }
-	    .divOwner{
-	    	position:absolute;
-	    	top:40px;
-	    	left:5px;
-	    }
-	    .inputOwner{
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    	width: 55px;
-	    }
-	    .divParcel{
-			visibility:hidden;
-	    	position:absolute;
-	    	top:125px;
-	    	left:5px;
-	    }
-	    .inputParcel1{
-			visibility:hidden;
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    	width: 30px;
-	    }
-	    .inputParcel2{
-			visibility:hidden;
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    	width: 30px;
-	    }
-	    .divResults{
-	    	position:absolute;
-	    	top:90px;
-	    	left:5px;
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    	width: 150px;
-	    }
-	    a:link {
-	    	text-decoration: none;
-	    	font-family: Arial, Helvetica, sans-serif;
-	    	color: black;
-	    }
-	    a:visited {
-	    	text-decoration: none;
-	    	font-family: Arial, Helvetica, sans-serif;
-	    	color: black;
-	    }
-	    a:active {
-	    	text-decoration: none;
-	    	font-family: Arial, Helvetica, sans-serif;
-	    	color: black;
+	    body{
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    }
+	    .selectCommune{
+	    	position:absolute;
+	    	top:10px;
+	    	left:5px;
+	    	width:150px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    }
+	    .selectStreet{
+			visibility:hidden;
+	    	position:absolute;
+	    	top:40px;
+	    	left:5px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 150px;
+	    }
+	    .selectDistrict{
+			visibility:hidden;
+	    	position:absolute;
+	    	top:40px;
+	    	left:5px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 150px;
+	    }
+	    .divOwner{
+	    	position:absolute;
+	    	top:40px;
+	    	left:5px;
+	    }
+	    .inputOwner{
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 55px;
+	    }
+	    .divParcel{
+			visibility:hidden;
+	    	position:absolute;
+	    	top:125px;
+	    	left:5px;
+	    }
+	    .inputParcel1{
+			visibility:hidden;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 30px;
+	    }
+	    .inputParcel2{
+			visibility:hidden;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 30px;
+	    }
+	    .divResults{
+	    	position:absolute;
+	    	top:90px;
+	    	left:5px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 150px;
+	    }
+	    a:link {
+	    	text-decoration: none;
+	    	font-family: Arial, Helvetica, sans-serif;
+	    	color: black;
+	    }
+	    a:visited {
+	    	text-decoration: none;
+	    	font-family: Arial, Helvetica, sans-serif;
+	    	color: black;
+	    }
+	    a:active {
+	    	text-decoration: none;
+	    	font-family: Arial, Helvetica, sans-serif;
+	    	color: black;
 	    }
\ No newline at end of file

Modified: branches/print_dev/http/css/gazetteerSQL_ALK.css
===================================================================
--- branches/print_dev/http/css/gazetteerSQL_ALK.css	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/css/gazetteerSQL_ALK.css	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,79 +1,79 @@
-	    body{
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    }
-	    .selectCommune{
-	    	position:absolute;
-	    	top:10px;
-	    	left:5px;
-	    	width:150px;
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    }
-	    .selectStreet{
-			visibility:hidden;
-	    	position:absolute;
-	    	top:40px;
-	    	left:5px;
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    	width: 150px;
-	    }
-	    .selectDistrict{
-	    	position:absolute;
-	    	top:40px;
-	    	left:5px;
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    	width: 150px;
-	    }
-	    .divOwner{
-			visibility:hidden;
-	    	position:absolute;
-	    	top:125px;
-	    	left:5px;
-	    }
-	    .inputOwner{
-			visibility:hidden;
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    	width: 100px;
-	    }
-	    .divParcel{
-	    	position:absolute;
-	    	top:125px;
-	    	left:5px;
-	    }
-	    .inputParcel1{
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    	width: 30px;
-	    }
-	    .inputParcel2{
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    	width: 30px;
-	    }
-	    .divResults{
-	    	position:absolute;
-	    	top:160px;
-	    	left:5px;
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    	width: 150px;
-	    }
-	    a:link {
-	    	text-decoration: none;
-	    	font-family: Arial, Helvetica, sans-serif;
-	    	color: black;
-	    }
-	    a:visited {
-	    	text-decoration: none;
-	    	font-family: Arial, Helvetica, sans-serif;
-	    	color: black;
-	    }
-	    a:active {
-	    	text-decoration: none;
-	    	font-family: Arial, Helvetica, sans-serif;
-	    	color: black;
+	    body{
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    }
+	    .selectCommune{
+	    	position:absolute;
+	    	top:10px;
+	    	left:5px;
+	    	width:150px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    }
+	    .selectStreet{
+			visibility:hidden;
+	    	position:absolute;
+	    	top:40px;
+	    	left:5px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 150px;
+	    }
+	    .selectDistrict{
+	    	position:absolute;
+	    	top:40px;
+	    	left:5px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 150px;
+	    }
+	    .divOwner{
+			visibility:hidden;
+	    	position:absolute;
+	    	top:125px;
+	    	left:5px;
+	    }
+	    .inputOwner{
+			visibility:hidden;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 100px;
+	    }
+	    .divParcel{
+	    	position:absolute;
+	    	top:125px;
+	    	left:5px;
+	    }
+	    .inputParcel1{
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 30px;
+	    }
+	    .inputParcel2{
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 30px;
+	    }
+	    .divResults{
+	    	position:absolute;
+	    	top:160px;
+	    	left:5px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 150px;
+	    }
+	    a:link {
+	    	text-decoration: none;
+	    	font-family: Arial, Helvetica, sans-serif;
+	    	color: black;
+	    }
+	    a:visited {
+	    	text-decoration: none;
+	    	font-family: Arial, Helvetica, sans-serif;
+	    	color: black;
+	    }
+	    a:active {
+	    	text-decoration: none;
+	    	font-family: Arial, Helvetica, sans-serif;
+	    	color: black;
 	    }
\ No newline at end of file

Modified: branches/print_dev/http/css/gazetteerSQL_Address.css
===================================================================
--- branches/print_dev/http/css/gazetteerSQL_Address.css	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/css/gazetteerSQL_Address.css	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,82 +1,82 @@
-	    body{
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    }
-	    .selectCommune{
-	    	position:absolute;
-	    	top:10px;
-	    	left:5px;
-	    	width:150px;
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    }
-	    .selectStreet{
-	    	position:absolute;
-	    	top:40px;
-	    	left:5px;
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    	width: 150px;
-	    }
-	    .selectDistrict{
-			visibility:hidden;
-	    	position:absolute;
-	    	top:40px;
-	    	left:5px;
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    	width: 150px;
-	    }
-	    .divOwner{
-			visibility:hidden;
-	    	position:absolute;
-	    	top:125px;
-	    	left:5px;
-	    }
-	    .inputOwner{
-			visibility:hidden;
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    	width: 100px;
-	    }
-	    .divParcel{
-			visibility:hidden;
-	    	position:absolute;
-	    	top:125px;
-	    	left:5px;
-	    }
-	    .inputParcel1{
-			visibility:hidden;
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    	width: 30px;
-	    }
-	    .inputParcel2{
-			visibility:hidden;
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    	width: 30px;
-	    }
-	    .divResults{
-	    	position:absolute;
-	    	top:120px;
-	    	left:5px;
-	    	font-family : Arial, Helvetica, sans-serif;
-	    	font-size: 11px;
-	    	width: 150px;
-	    }
-	    a:link {
-	    	text-decoration: none;
-	    	font-family: Arial, Helvetica, sans-serif;
-	    	color: black;
-	    }
-	    a:visited {
-	    	text-decoration: none;
-	    	font-family: Arial, Helvetica, sans-serif;
-	    	color: black;
-	    }
-	    a:active {
-	    	text-decoration: none;
-	    	font-family: Arial, Helvetica, sans-serif;
-	    	color: black;
+	    body{
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    }
+	    .selectCommune{
+	    	position:absolute;
+	    	top:10px;
+	    	left:5px;
+	    	width:150px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    }
+	    .selectStreet{
+	    	position:absolute;
+	    	top:40px;
+	    	left:5px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 150px;
+	    }
+	    .selectDistrict{
+			visibility:hidden;
+	    	position:absolute;
+	    	top:40px;
+	    	left:5px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 150px;
+	    }
+	    .divOwner{
+			visibility:hidden;
+	    	position:absolute;
+	    	top:125px;
+	    	left:5px;
+	    }
+	    .inputOwner{
+			visibility:hidden;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 100px;
+	    }
+	    .divParcel{
+			visibility:hidden;
+	    	position:absolute;
+	    	top:125px;
+	    	left:5px;
+	    }
+	    .inputParcel1{
+			visibility:hidden;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 30px;
+	    }
+	    .inputParcel2{
+			visibility:hidden;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 30px;
+	    }
+	    .divResults{
+	    	position:absolute;
+	    	top:120px;
+	    	left:5px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 150px;
+	    }
+	    a:link {
+	    	text-decoration: none;
+	    	font-family: Arial, Helvetica, sans-serif;
+	    	color: black;
+	    }
+	    a:visited {
+	    	text-decoration: none;
+	    	font-family: Arial, Helvetica, sans-serif;
+	    	color: black;
+	    }
+	    a:active {
+	    	text-decoration: none;
+	    	font-family: Arial, Helvetica, sans-serif;
+	    	color: black;
 	    }
\ No newline at end of file

Modified: branches/print_dev/http/css/login.css
===================================================================
--- branches/print_dev/http/css/login.css	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/css/login.css	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,14 +1,14 @@
 body{
 	font-family: Arial, Helvetica, sans-serif;
 	font-size : 12px;
-	color: #808080;
+	color: #909090;
 	background-color: White;
 }
 
 table{
 	font-family: Arial, Helvetica, sans-serif;
 	font-size : 12px;
-	color: #808080;
+	color: #909090;
 }
 
 
@@ -50,96 +50,79 @@
 .login_text{
 	width: 150px;
 }
-.logoutButton{
-position:relative;
-left:300px;
-top:-40px;
-}
-.logoutButton img{
-width:22px;
-height:22px;
-border:0px;
-}
-img {
-	border: 0;
-}
-/* BEGIN gui listing */
 
-
-/* defines Headings */
-h1{
-font-size:14pt;
+/* BEGIN gui listing */
+ul.gui_list {
+	width: 50%;
+	padding: 2px;
+	border: 0px solid #666;
 }
 
-h2{
-	font-size:12pt;
+h2.gui_category,
+p.gui_category_description{
+	width: 50%;
+	padding: 0px;
+	border: 0px solid #666;
 }
 
-/* defines the Background of the Zebra (default=gray #eee) */
 h2.gui_category,
-p.gui_category_description,
 ul.gui_list {
-  width:75%;
-	padding: 5px;
-	padding-left:3px;
-  border: 1px solid black;
-  margin:0px;
-  background-color: #eee;
+	/*background-color: #eee;*/
 }
 
+h2.gui_category {
+	font-size: 1.3em;
+}
 
-
-/* defines cathegory heading*/
-.gui_category h2{
-	font-size:1.25em;
-	margin-bottom:3px;
-	margin-top:6px;
-	text-decoration:underline;
+img {
+	border: 0;
 }
 
-/* removes list styles like circles from Zebra*/
-ul.gui_list,
-ul li ul li{
+ul.gui_list {
 	list-style: none;
 }
 
-/* defines inner border and normal listing background-colors*/
-ul.gui_list ul li {
+ul.gui_list li {
 	clear: both;
 	margin-top: -1px;
-  margin-left:-20px;
 	padding: .25em .5em;
-	background-color: #ffe;
-	border: 1px solid #666;
+	background-color: #fff;
+	border: 0px solid #666;
 	cursor: pointer;
 }
 
+ul.gui_list li.alternate {
+	background-color: #fff;
+}
 
-/* defines list background-colors (alternated listings)*/
-ul.gui_list li.alternate,
-ul.gui_list ul li.alternate ul li {
+ul.gui_list li.alternate {
 	background-color: #fff;
 }
 
-/* defines hover color*/
-ul.gui_list ul li:hover,
-ul.gui_list ul li:hover ul li {
-	background-color: #ff9;
+ul.gui_list li:hover {
+	background-color: #eee;
 }
 
-/* Gui descriptions*/
-ul.gui_list ul li ul li  {
-position:relative;
-font-style:italic;
-border:0px;
-cursor:pointer;
-font-size:0.9em;
+ul.gui_list li strong {
+	float: left;
+	width: 25%;
+	font-weight: bold;
 }
 
+ul.gui_list li em {
+	float: right;
+	width: 75%;
+	margin-top: -1.2em;
+	color: #666;
+}
 
-/* Hides WMS Container */
-
-#Container{
-display:none;
+.gui_list a:link, 
+.gui_list a:visited, 
+.gui_list a:active {
+	font-size: inherit;
+	font-weight: inherit;
+	text-decoration: none;
+	text-transform: none;
+	color: inherit;
 }
-/* END gui listing */
+/* END gui listing */
\ No newline at end of file

Modified: branches/print_dev/http/css/mapbender.css
===================================================================
--- branches/print_dev/http/css/mapbender.css	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/css/mapbender.css	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,59 +1,59 @@
-body, .body, td, form, input, select {
-  font-size: 12px;
-  font-family: "Verdana","Arial","Tahoma",sans-serif;
-}
-
-td h2, td h3, div h2, div h3, div h4 {
-  margin-top: 0px;
-}
-
-/* body colors */
-body, .body {
-  background-color:#F0F0F0;
-}
-body table, h1 {
-  margin:0px;
-  background-color:#ffffff;
-  margin-left: 15px;
-}
-body table tr td {
-  padding-left: 10px;
-  padding-right: 10px;
-}
-
-/* links */
-a {
-  text-decoration:underline;
-  color:#000099;
-}
-a:visited {
-  color:#555555;
-}
-a:active {
-  color:#4241DE;
-  background-color:#ce0000;
-}
-a:hover {
-  
-  color:#FF0000;
-}
-
-.mapbender_headline{
-	font-size: 32px; 
-	font-stretch:extra-expanded;
-	font-weight:bold;
-	margin-bottom:4px;
-}
-
-.mapbender_welcome{
-	font-size: 20px; 
-	font-weight:bold;
-	margin-top:3px;
-	margin-bottom:4px;
-}
-
-
-img{
-	border:0;
-	
+body, .body, td, form, input, select {
+  font-size: 12px;
+  font-family: "Verdana","Arial","Tahoma",sans-serif;
+}
+
+td h2, td h3, div h2, div h3, div h4 {
+  margin-top: 0px;
+}
+
+/* body colors */
+body, .body {
+  background-color:#F0F0F0;
+}
+body table, h1 {
+  margin:0px;
+  background-color:#ffffff;
+  margin-left: 15px;
+}
+body table tr td {
+  padding-left: 10px;
+  padding-right: 10px;
+}
+
+/* links */
+a {
+  text-decoration:underline;
+  color:#000099;
+}
+a:visited {
+  color:#555555;
+}
+a:active {
+  color:#4241DE;
+  background-color:#ce0000;
+}
+a:hover {
+  
+  color:#FF0000;
+}
+
+.mapbender_headline{
+	font-size: 32px; 
+	font-stretch:extra-expanded;
+	font-weight:bold;
+	margin-bottom:4px;
+}
+
+.mapbender_welcome{
+	font-size: 20px; 
+	font-weight:bold;
+	margin-top:3px;
+	margin-bottom:4px;
+}
+
+
+img{
+	border:0;
+	
 }
\ No newline at end of file

Modified: branches/print_dev/http/css/meetingPoint.css
===================================================================
--- branches/print_dev/http/css/meetingPoint.css	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/css/meetingPoint.css	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,44 +1,44 @@
-body{
-	font-family : Verdana, Arial, Helvetica, sans-serif;
-	font-size : 11px;
-	color: #000000;
-}
-
-.strinput{
-	font-family : Verdana, Arial, Helvetica, sans-serif;
-	font-size : 10px;
-	height: 40px;
-	width: 150px;
-	color: #000000;
-	background: #FFFFFF;   
-}
-
-.coord{
-	border: 0;
-	font-family: Verdana, Arial, Helvetica, sans-serif;
-	font-size: 10px;
-	height: 20px;
-	color: #888888;
-	background: #FFFFFF;
-	width: 80px;
-}
-
-.okbutton{
-	font-family : Verdana, Arial, Helvetica, sans-serif;
-	font-size : 10px;
-	font-weight: normal;
-	border : solid thin;
-	width: 26px;
-	height: 20px;
-	background: #c0c0c0;   
-}
-
-.ibutton{
-	font-family : Verdana, Arial, Helvetica, sans-serif;
-	font-size : 10px;
-	font-weight: normal;
-	border : solid thin;
-	width: 40px;
-	height: 20px;
-	background: #c0c0c0;   
+body{
+	font-family : Verdana, Arial, Helvetica, sans-serif;
+	font-size : 11px;
+	color: #000000;
+}
+
+.strinput{
+	font-family : Verdana, Arial, Helvetica, sans-serif;
+	font-size : 10px;
+	height: 40px;
+	width: 150px;
+	color: #000000;
+	background: #FFFFFF;   
+}
+
+.coord{
+	border: 0;
+	font-family: Verdana, Arial, Helvetica, sans-serif;
+	font-size: 10px;
+	height: 20px;
+	color: #888888;
+	background: #FFFFFF;
+	width: 80px;
+}
+
+.okbutton{
+	font-family : Verdana, Arial, Helvetica, sans-serif;
+	font-size : 10px;
+	font-weight: normal;
+	border : solid thin;
+	width: 26px;
+	height: 20px;
+	background: #c0c0c0;   
+}
+
+.ibutton{
+	font-family : Verdana, Arial, Helvetica, sans-serif;
+	font-size : 10px;
+	font-weight: normal;
+	border : solid thin;
+	width: 40px;
+	height: 20px;
+	background: #c0c0c0;   
 }
\ No newline at end of file

Modified: branches/print_dev/http/css/metadata.css
===================================================================
--- branches/print_dev/http/css/metadata.css	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/css/metadata.css	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,62 +1,62 @@
-body,td, form, input, select{
-	font-size: 12px;
-	line-height: 16px;
-	font-family: "Verdana","Arial",sans-serif;
-	color: black;
-}
-
-select{
-	color:black;
-	width:300px;
-}
-
-.sbutton{
-	width:100px;
-	height:40px;
-}
-
-
-table{
-	font-size: 12px;
-	border: 1px;
-	margin-right: 4px;
-	margin-left: 6px;
-	text-align: left;	
-}
-
-
-.table_top{
-	color:black;
-	font-size: 12px;
-	margin-right: 2px;
-	text-align: right;	
-}
-
-.table_layer{
-	border:1px;
-	font-size: 12px;
-	border: 1px;
-	margin-right: 2px;
-	text-align: left;	
-}
-
-a {
-  text-decoration:none;
-  color:black;
-	text-decoration: underline;
-}
-
-a:active {
-	color: red;
-}
-a:hover {
-	color: blue;
-	text-decoration: underline;
-}
-div{
-	font-weight: bold;
-	text-decoration: underline;
-	color: Red;
-	margin-left: 2px;
-	background-color:#FFEDED;
+body,td, form, input, select{
+	font-size: 12px;
+	line-height: 16px;
+	font-family: "Verdana","Arial",sans-serif;
+	color: black;
+}
+
+select{
+	color:black;
+	width:300px;
+}
+
+.sbutton{
+	width:100px;
+	height:40px;
+}
+
+
+table{
+	font-size: 12px;
+	border: 1px;
+	margin-right: 4px;
+	margin-left: 6px;
+	text-align: left;	
+}
+
+
+.table_top{
+	color:black;
+	font-size: 12px;
+	margin-right: 2px;
+	text-align: right;	
+}
+
+.table_layer{
+	border:1px;
+	font-size: 12px;
+	border: 1px;
+	margin-right: 2px;
+	text-align: left;	
+}
+
+a {
+  text-decoration:none;
+  color:black;
+	text-decoration: underline;
+}
+
+a:active {
+	color: red;
+}
+a:hover {
+	color: blue;
+	text-decoration: underline;
+}
+div{
+	font-weight: bold;
+	text-decoration: underline;
+	color: Red;
+	margin-left: 2px;
+	background-color:#FFEDED;
 }
\ No newline at end of file

Modified: branches/print_dev/http/html/mod_treefolder2.php
===================================================================
--- branches/print_dev/http/html/mod_treefolder2.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/html/mod_treefolder2.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -75,13 +75,83 @@
 var errors = 0;
 var state=Array();
 var treeState = "";
-var arrNodes =
-[
-	['root_id', ['Layer','javascript:_foo()']
+<?php
+//load structure
+$sql = "SELECT * FROM gui_treegde WHERE fkey_gui_id = $1 AND NOT lft = 1 ORDER BY lft;";
+$v = array($_SESSION["mb_user_gui"]);
+$t = array("s");
+$res = db_prep_query($sql, $v, $t);
 
+//init tree converting arrays
+$nr = array(); 			//array for nested sets numbers
+$str = array();			//array for js array elements
+$categories = array();	//array for wms folders
+$path = array();		//stack for actual path elements
+$rights = array();		//stack for rights of open elements
+
+//build javascript data array for jsTree
+while($row = db_fetch_array($res)){
+	//push javascript array elements to a single array with lefts and rights
+	$left = "['folder_".$row['id']."', ['".$row['my_layer_title']."', 'javascript:_foo()'],[";
+	$right = "]],";
+	array_push($nr, $row['lft']);
+	array_push($str, $left);
+	array_push($nr, $row['rgt']);
+	array_push($str, $right);
+	
+	//finish all nodes that have no further childs
+	while(count($rights) > 0 && $rights[count($rights)-1]<$row['lft']){
+		array_pop($rights);
+		array_pop($path);
+	}
+
+	//set path for each wms that is referenced in this folder
+	array_push($rights, $row['rgt']);
+	array_push($path, "folder_".$row['id']);
+	if($row['wms_id']!=""){
+		foreach(explode(",",$row['wms_id']) as $wms){
+			array_push($categories, "'wms_".$wms."':\"root_id|".implode("|", $path)."\"");
+		}
+	}
+}
+//if we have a configured structure output it
+if(count($str)>0){
+	//order js array elements
+	array_multisort($nr, $str);
+	
+	//output javascript vars
+	$arrNodesStr = "[['root_id', ['Layer','javascript:_foo()'],[".implode("",$str)."]]];";
+	$arrNodesStr = str_replace(array("[]", ",]"),array("","]"),$arrNodesStr);
+	echo "var arrNodesStr = \"".$arrNodesStr."\";\n";
+	echo "var categories = {".implode(",", $categories)."};\n";
+}
+else{
+//if there is no structure take default
+?>
+var arrNodesStr = "[['root_id', ['Layer','javascript:_foo()']]];";
+var categories = {};
+<?php
+}
+?>
+/*var arrNodesStr = "[['root_id', ['Layer','javascript:_foo()'], [['test1',['Einfach so','javascript:_foo()']],['test2',['Schönes Wetter','javascript:_foo()']],['test3',['Sonstiges','javascript:_foo()']]]]];"
+
+var categories = {"wms_407":arrNodes[0][0]+"|test1","wms_911":arrNodes[0][0]+"|test2", "wms_914":arrNodes[0][0]+"|test2"};
+var arrNodes = [
+  String: node id,
+  [
+    String: title,
+    String: href,
+    String: target,
+    String: image,
+    String: tooltip,
+    Folder definition: node context menu,
+    String: controls
+  ],
+  Folder definition: sub folder
 	]
-];
-function _foo(){}
+*/
+var arrNodes = eval(arrNodesStr);
+function _foo(){selectedMap=-1;selectedWMS=-1;selectedLayer=-1}
 
 // some defaults
 try{if (reverse){}}catch(e){reverse = 'false';}
@@ -153,21 +223,21 @@
 	var scale = parseInt(parent.mb_mapObj[selectedMap].getScale());
 	if(scale < parseInt(parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].gui_layer_minscale) && parseInt(parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].gui_layer_minscale) != 0){
 		if(selectedLayer==0)
-		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id, '#999999');
+		   	setNodeColor(arrNodes[0][0]+"|wms_"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id, '#999999');
 		else
-		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_id, '#999999');
+		   	setNodeColor(arrNodes[0][0]+"|wms_"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_id, '#999999');
 	}
 	else if(scale > parseInt(parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].gui_layer_maxscale) && parseInt(parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].gui_layer_maxscale) != 0){
 		if(selectedLayer==0)
-		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id, '#999999');
+		   	setNodeColor(arrNodes[0][0]+"|wms_"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id, '#999999');
 		else
-		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_id, '#999999');
+		   	setNodeColor(arrNodes[0][0]+"|wms_"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_id, '#999999');
 	}
 	else{
 		if(selectedLayer==0)
-		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id, '');
+		   	setNodeColor(arrNodes[0][0]+"|wms_"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id, '');
 		else
-		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_id, '');
+		   	setNodeColor(arrNodes[0][0]+"|wms_"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_id, '');
 	}
 
 	selectedMap=i;
@@ -184,26 +254,26 @@
 				for(var iii=1; iii<parent.mb_mapObj[i].wms[ii].objLayer.length; iii++){
 					if(scale < parseInt(parent.mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_minscale) && parseInt(parent.mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_minscale) != 0){
 						if(iii==0)
-						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id, '#999999');
+						   	setNodeColor(arrNodes[0][0]+"|wms_"+parent.mb_mapObj[i].wms[ii].wms_id, '#999999');
 						else
-						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id+"|"+parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_id, '#999999');
+						   	setNodeColor(arrNodes[0][0]+"|wms_"+parent.mb_mapObj[i].wms[ii].wms_id+"|"+parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_id, '#999999');
 					}
 					else if(scale > parseInt(parent.mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_maxscale) && parseInt(parent.mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_maxscale) != 0){
 						if(iii==0)
-						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id, '#999999');
+						   	setNodeColor(arrNodes[0][0]+"|wms_"+parent.mb_mapObj[i].wms[ii].wms_id, '#999999');
 						else
-						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id+"|"+parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_id, '#999999');
+						   	setNodeColor(arrNodes[0][0]+"|wms_"+parent.mb_mapObj[i].wms[ii].wms_id+"|"+parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_id, '#999999');
 					}
 					else{
 						if(iii==0)
-						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id, '');
+						   	setNodeColor(arrNodes[0][0]+"|wms_"+parent.mb_mapObj[i].wms[ii].wms_id, '');
 						else
-						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id+"|"+parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_id, '');
+						   	setNodeColor(arrNodes[0][0]+"|wms_"+parent.mb_mapObj[i].wms[ii].wms_id+"|"+parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_id, '');
 					}
 				}
 			}
 		}
-	}	
+	}
 }
 
 function updateCheckState(){
@@ -215,7 +285,7 @@
 			for(var ii=0; ii<parent.mb_mapObj[i].wms.length; ii++){
 				for(var iii=1; iii<parent.mb_mapObj[i].wms[ii].objLayer.length; iii++){
 					if(!parent.mb_mapObj[i].wms[ii].objLayer[iii].has_childs){
-						path = arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id+"|"+parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_id;
+						path = arrNodes[0][0]+"|wms_"+parent.mb_mapObj[i].wms[ii].wms_id+"|"+parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_id;
 						checkNode(path, 0, parent.mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_visible=='1', false);
 						if(ficheckbox == 'true')
 							checkNode(path, 1, parent.mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_querylayer=='1', false);	
@@ -250,7 +320,7 @@
 	selectedWMS=-1;
 	selectedLayer=-1;
 	init=false;
-	arrNodes = [['root_id', ['Layer','javascript:_foo()']]];
+	arrNodes = eval(arrNodesStr)
 	initArray();
 	if(showstatus=='true'||alerterror=='true')
 		init_mapcheck();
@@ -277,7 +347,7 @@
 	state[wms]=-1;
 	errors++;
 	if(showstatus=='true')
-		setNodeImage(arrNodes[0][0]+"|"+parent.mb_mapObj[map].wms[wms].wms_id, "error_folder.png");
+		setNodeImage(arrNodes[0][0]+"|wms_"+parent.mb_mapObj[map].wms[wms].wms_id, "error_folder.png");
 }
 
 function checkComplete(wms, map, img, first){
@@ -321,7 +391,7 @@
 	for(var wms=0;wms<parent.mb_mapObj[ind].wms.length;wms++){
 		var wmsimgid="map_"+wms;
 		if(parent.frames[mod_treeGDE_map].document.getElementById(wmsimgid)){
-			checkComplete(wms, wmsimgid, arrNodes[0][0]+'|'+parent.mb_mapObj[ind].wms[wms].wms_id, true);
+			checkComplete(wms, wmsimgid, arrNodes[0][0]+'|wms_'+parent.mb_mapObj[ind].wms[wms].wms_id, true);
 		}
 	}
 }
@@ -401,7 +471,7 @@
 				if(l!=0)
 					selectNode(String(lid));
 				else
-					selectNode(String(parent.mb_mapObj[j].wms[k].wms_id));
+					selectNode("wms_"+String(parent.mb_mapObj[j].wms[k].wms_id));
 			}
 		}
 	}
@@ -433,7 +503,7 @@
 				if(l!=0)
 					selectNode(String(lid));
 				else
-					selectNode(String(parent.mb_mapObj[j].wms[k].wms_id));
+					selectNode("wms_"+String(parent.mb_mapObj[j].wms[k].wms_id));
 			}
 		}
 	}
@@ -485,12 +555,14 @@
 function handleSelectedWMS(path){
 	if(lock_update)return;
 	var t = path.split("|");
+	var wms_id = t[t.length-1].substr(4);
 	var reset_lock=!lock_check;
 	var ind = parent.getMapObjIndexByName(mod_treeGDE_map);
-	var layername = parent.mb_mapObj[ind].wms[parent.getWMSIndexById(mod_treeGDE_map,t[t.length-1])].objLayer[0].layer_name;
+	var wms = parent.getWMSIndexById(mod_treeGDE_map,wms_id);
+	var layername = parent.mb_mapObj[ind].wms[wms].objLayer[0].layer_name;
 	var bChk = IsChecked(path, 0);
-	handleSelectedLayer(mod_treeGDE_map,t[t.length-1],layername,"visible",bChk?"1":"0");
-	handleSelectedLayer(mod_treeGDE_map,t[t.length-1],layername,"querylayer",bChk?"1":"0");
+	parent.mb_mapObj[ind].wms[wms].handleLayer(layername,"visible",bChk?"1":"0");
+	parent.mb_mapObj[ind].wms[wms].handleLayer(layername,"querylayer",bChk?"1":"0");
 	lock_check=true;
 	checkChildren(path, 0, bChk);
 	if(ficheckbox)checkChildren(path, 1, bChk);
@@ -498,8 +570,8 @@
 		setTimeout('setNodeImage("'+path+'", "error_folder.png");', 100);
 	if(reset_lock)
 	{
-		parent.mb_restateLayers(mod_treeGDE_map,t[t.length-1]);
-		parent.setSingleMapRequest(mod_treeGDE_map,t[t.length-1]);
+		parent.mb_restateLayers(mod_treeGDE_map,wms_id);
+		parent.setSingleMapRequest(mod_treeGDE_map,wms_id);
 		lock_check=false;
 	}
 }
@@ -512,10 +584,14 @@
 //	enableCheckbox(path, 0, true);
 	checkChildren(path, box, bChk);
 	if(reset_lock){
+		//find wms id from path
 		var t = path.split("|");
-		parent.mb_restateLayers(mod_treeGDE_map,t[1]);
+		for(var i=1;t[i].indexOf("wms_")!=0;i++){}
+		var wms_id = t[i].substr(4);
+		//set maprequest
+		parent.mb_restateLayers(mod_treeGDE_map,wms_id);
 		if(box==0)
-		parent.setSingleMapRequest(mod_treeGDE_map,t[1]);
+			parent.setSingleMapRequest(mod_treeGDE_map,wms_id);
 		lock_check=false;
 	}
 }
@@ -533,6 +609,12 @@
 							if(parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_parent == ""){
 								if(!temp.gui_layer_selectable == '1' && !temp.gui_layer_queryable == '1')
 									continue;
+								parentNode = arrNodes[0][0];
+								if(eval("categories.wms_"+parent.mb_mapObj[i].wms[ii].wms_id) !== undefined)
+									parentNode = eval("categories.wms_"+parent.mb_mapObj[i].wms[ii].wms_id);
+								else
+									eval("categories['wms_"+parent.mb_mapObj[i].wms[ii].wms_id+"'] = parentNode");
+
 								var c_menu="[";
 								if(reverse=="true"){
 									if(menu.indexOf("wms_down")!=-1 && ii!=parent.mb_mapObj[i].wms.length-1)c_menu+="menu_move_up,";
@@ -549,10 +631,10 @@
 								if(menu.indexOf("hide")!=-1)c_menu+="menu_hide";
 								c_menu+="]";
 								controls='';
-								if(switchwms=='true')controls='<INPUT type="checkbox" title="' + msgObj.tooltipHandleWms + '" checked onclick="handleSelectedWMS(\''+arrNodes[0][0]+'|'+parent.mb_mapObj[i].wms[ii].wms_id+'\');" />';
+								if(switchwms=='true')controls='<INPUT type="checkbox" title="' + msgObj.tooltipHandleWms + '" checked onclick="handleSelectedWMS(\''+parentNode+'|wms_'+parent.mb_mapObj[i].wms[ii].wms_id+'\');" />';
 								if(wmsbuttons == 'true'&&metadatalink == 'true')controls+='<a href="'+'javascript:openwindow(\''+ defaultMetadataUrl + '&id='+temp.layer_uid+'\');'+'"><img src="'+imagedir+'/info.png" /></a>';
-								addNode(arrNodes[0][0],[parent.mb_mapObj[i].wms[ii].wms_id,[temp.layer_title,((metadatalink=='true'&&wmsbuttons != 'true')?('javascript:openwindow(\"'+ defaultMetadataUrl + '&id='+temp.layer_uid+'\");'):"javascript:select("+i+","+ii+","+iii+");"),,,temp.layer_title,eval(c_menu),controls,[i,ii,iii]]],false,false,reverse=="true");
-								parentObj = arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id;
+								addNode(parentNode,["wms_"+parent.mb_mapObj[i].wms[ii].wms_id,[temp.layer_title,((metadatalink=='true'&&wmsbuttons != 'true')?('javascript:openwindow(\"'+ defaultMetadataUrl + '&id='+temp.layer_uid+'\");'):"javascript:select("+i+","+ii+","+iii+");"),,,temp.layer_title,eval(c_menu),controls,[i,ii,iii]]],false,false,reverse=="true");
+								parentObj = parentNode+"|wms_"+parent.mb_mapObj[i].wms[ii].wms_id;              
 							}
 							if(parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_parent && (handlesublayer=="true"||parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_parent=="0")){
 								var parentLayer = "";
@@ -583,7 +665,7 @@
 //									if(menu.indexOf("info_switch")!=-1)c_menu+="menu_info_switch,";
 									if(menu.indexOf("hide")!=-1)c_menu+="menu_hide";
 									c_menu+="]";
-									
+
 									controls = [];
 									controls.push('<input type="checkbox"  title="' + msgObj.tooltipLayerVisible + '" ');
 									if(temp.layer_name=="")
@@ -605,7 +687,7 @@
 											controls.push('disabled ');
 										controls.push("onclick=\"handleSelectedLayer('"+mod_treeGDE_map+"','"+parent.mb_mapObj[i].wms[ii].wms_id+"','"+temp.layer_name+"','querylayer',this.checked?1:0);");
 										controls.push("handleSelection('"+parentObj+parentLayer+"|"+temp.layer_id+"', 1);\" />");
-									}
+								}
 									if(wmsbuttons == 'true'&&metadatalink == 'true'){
 										controls.push('<a href="javascript:openwindow(\''+ defaultMetadataUrl + '&id='+temp.layer_uid+'\');"><img src="'+imagedir+'/info.png" /></a>');
 									}
@@ -647,18 +729,18 @@
 		}
 	}
 }
-//-->  
+//-->
   </SCRIPT>
 </HEAD>
 <BODY VLINK="#000000" ALINK="#000000" LINK="#000000" BGCOLOR="#ffffff" TEXT="#000000"
  MARGINHEIGHT="0" MARGINWIDTH="0" LEFTMARGIN="0" TOPMARGIN="0">
 <SCRIPT language="JavaScript" type="text/javascript">
 if(wmsbuttons=='true'){
-	document.writeln("<div>"); 
+	document.writeln("<div>");
 	document.writeln('<a href="javascript:move_up()"><img title="'+msgObj.tooltipMoveSelectionUp+'" src="'+imagedir+'/move_up.png" alt="move up" style="position:relative;top:0px;left:0px;"/></a>'); 
 	document.writeln('<a href="javascript:move_down()"><img title="'+msgObj.tooltipMoveSelectionDown+'" src="'+imagedir+'/move_down.png" alt="move down" style="position:relative;top:0px;left:-3px"/></a>'); 
 	document.writeln('<a href="javascript:remove_wms()"><img title="'+msgObj.tooltipRemoveWms+'" src="'+imagedir+'/delete_wms.png" alt="remove wms" style="position:relative;top:0px;left:-6px"/></a>'); 
-	document.writeln("</div>"); 
+	document.writeln("</div>");
 }
 </SCRIPT>
 <DIV id="treeContainer"></DIV>

Modified: branches/print_dev/http/html/mod_treefolderPlain.php
===================================================================
--- branches/print_dev/http/html/mod_treefolderPlain.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/html/mod_treefolderPlain.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -20,14 +20,13 @@
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
 include '../include/dyn_js.php';
 ?>
-function openwindow(Adresse) {
-Fenster1 = window.open(Adresse, "Informationen", "width=500,height=500,left=100,top=100,scrollbars=yes,resizable=no");
-Fenster1.focus();
+function openwindow (Adresse) {
+	Fenster1 = window.open(Adresse, "Informationen", "width=500,height=500,left=100,top=100,scrollbars=yes,resizable=no");
+	Fenster1.focus();
 }
 <?php
-
-   echo "mod_treeGDE_map = '".$e_target[0]."';";   
-session_write_close();
+	echo "mod_treeGDE_map = '".$e_target[0]."';";   
+	session_write_close();
 ?>
 var msgObj = {};
 msgObj.tooltipHandleWms = '<?php echo _mb("(De)activate this service");?>';
@@ -55,7 +54,7 @@
 var treeState = "";
 <?php
 //load structure
-$sql = "SELECT * FROM gui_treegde WHERE fkey_gui_id = $1 ORDER BY lft;";
+$sql = "SELECT * FROM gui_treegde WHERE fkey_gui_id = $1 AND NOT lft = 1 ORDER BY lft;";
 $v = array($_SESSION["mb_user_gui"]);
 $t = array("s");
 $res = db_prep_query($sql, $v, $t);
@@ -98,7 +97,9 @@
 	array_multisort($nr, $str);
 	
 	//output javascript vars
-	echo "var arrNodesStr = \"[['root_id', ['Layer','javascript:_foo()'],[".implode("",$str)."]]];\";\n";
+	$arrNodesStr = "[['root_id', ['Layer','javascript:_foo()'],[".implode("",$str)."]]];";
+	$arrNodesStr = str_replace(array("[]", ",]"),array("","]"),$arrNodesStr);
+	echo "var arrNodesStr = \"".$arrNodesStr."\";\n";
 	echo "var categories = {".implode(",", $categories)."};\n";
 }
 else{
@@ -139,15 +140,15 @@
 }
 
 //menu elements
-var menu_move_up = ['menu_move_up', ['Move up&nbsp;','javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];move_up(ids[0],ids[1],ids[2]);',,'move_up.png']];
-var menu_move_down = ['menu_move_down', ['Move down&nbsp;', 'javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];move_down(ids[0],ids[1],ids[2]);',,'move_down.png']];
-var menu_delete = ['menu_delete', ['Remove&nbsp;', 'javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];remove_wms(ids[0],ids[1],ids[2]);',,'delete_wms.png']];
-var menu_opacity_up = ['menu_opacity_up', ['Opacity up&nbsp;','javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];opacity_up(ids[0],ids[1],ids[2]);',,'move_up.png']];
-var menu_opacity_down = ['menu_opacity_down', ['Opacity down&nbsp;','javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];opacity_down(ids[0],ids[1],ids[2]);',,'move_down.png']];
-var menu_metalink = ['menu_metalink', ['Information&nbsp;', 'javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];openwindow(defaultMetadataUrl + "&id="+parent.mb_mapObj[ids[0]].wms[ids[1]].objLayer[ids[2]].layer_uid);',,'info.png']];
-var menu_zoom = ['menu_zoom', ['Zoom&nbsp;', 'javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];zoomToLayer(ids[0],ids[1],ids[2]);',,'zoom.png']];
-var menu_hide = ['menu_hide', ['Hide menu&nbsp;', 'javascript:hideMenu()',,'hide.png']];
-//var menu_wms_switch = ['menu_zoom', ['Zoom&nbsp;', 'javascript:var sd = "{@strData}";eval(eval(sd.substr(0, sd.length-6))[1][1]);openwindow(defaultMetadataUrl + "&id="+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_uid);',,'info.png']];
+var menu_move_up = ['menu_move_up', ['<?php echo _mb("Move up");?>&nbsp;','javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];move_up(ids[0],ids[1],ids[2]);',,'move_up.png']];
+var menu_move_down = ['menu_move_down', ['<?php echo _mb("Move down");?>&nbsp;', 'javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];move_down(ids[0],ids[1],ids[2]);',,'move_down.png']];
+var menu_delete = ['menu_delete', ['<?php echo _mb("Remove");?>&nbsp;', 'javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];remove_wms(ids[0],ids[1],ids[2]);',,'delete_wms.png']];
+var menu_opacity_up = ['menu_opacity_up', ['<?php echo _mb("Opacity up");?>&nbsp;','javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];opacity_up(ids[0],ids[1],ids[2]);',,'move_up.png']];
+var menu_opacity_down = ['menu_opacity_down', ['<?php echo _mb("Opacity down");?>&nbsp;','javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];opacity_down(ids[0],ids[1],ids[2]);',,'move_down.png']];
+var menu_metalink = ['menu_metalink', ['<?php echo _mb("Information");?>&nbsp;', 'javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];openwindow(defaultMetadataUrl + "&id="+parent.mb_mapObj[ids[0]].wms[ids[1]].objLayer[ids[2]].layer_uid);',,'info.png']];
+var menu_zoom = ['menu_zoom', ['<?php echo _mb("Zoom");?>&nbsp;', 'javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];zoomToLayer(ids[0],ids[1],ids[2]);',,'zoom.png']];
+var menu_hide = ['menu_hide', ['<?php echo _mb("Hide menu");?>&nbsp;', 'javascript:hideMenu()',,'hide.png']];
+//var menu_wms_switch = ['menu_zoom', ['<?php echo _mb("Zoom");?>&nbsp;', 'javascript:var sd = "{@strData}";eval(eval(sd.substr(0, sd.length-6))[1][1]);openwindow(defaultMetadataUrl + "&id="+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_uid);',,'info.png']];
 //var menu_layer_switch = ['menu_zoom', ['Zjjj&nbsp;', 'javascript:var sd = "{@strData}";eval(eval(sd.substr(0, sd.length-6))[1][1]);openwindow(defaultMetadataUrl + "&id="+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_uid);',,'info.png']];
 //var menu_info_switch = ['menu_zoom', ['Zmn&nbsp;', 'javascript:var sd = "{@strData}";eval(eval(sd.substr(0, sd.length-6))[1][1]);openwindow(defaultMetadataUrl + "&id="+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_uid);',,'info.png']];
 
@@ -416,16 +417,16 @@
 		l=selectedLayer;
 	}
 	if(j==-1||k==-1||l==-1){
-		alert("You have to select the WMS you want to move up!")		
+		alert("<?php echo _mb('You have to select the WMS you want to move up!');?> ")	
 		return;
 	}
 	var lid= mb_mapObj[j].wms[k].objLayer[l].layer_id;
 	if(! mb_mapObj[j].move( mb_mapObj[j].wms[k].wms_id,lid,(reverse=="true")?false:true)){
-		alert("Illegal move operation");
+		alert("<?php echo _mb('Illegal move operation');?>");
 		return;
 	}
 	treeState = getState();
-	 zoom( mb_mapObj[j].frameName, true, 1.0);
+	 mb_mapObj[j].zoom(true, 1.0);
 	 mb_execloadWmsSubFunctions();
 	//find layer and select
 	for(k=0;k< mb_mapObj[j].wms.length;k++){
@@ -448,16 +449,16 @@
 		l=selectedLayer;
 	}
 	if(j==-1||k==-1||l==-1){
-		alert("You have to select the WMS you want to move down!")		
+		alert("<?php echo _mb('You have to select the WMS you want to move down!');?>")	
 		return;
 	}
 	var lid= mb_mapObj[j].wms[k].objLayer[l].layer_id;
 	if(! mb_mapObj[j].move( mb_mapObj[j].wms[k].wms_id,lid,(reverse=="true")?true:false)){
-		alert("Illegal move operation");
+		alert("<?php echo _mb('Illegal move operation');?>");
 		return;
 	}
 	treeState = getState();
-	 zoom( mb_mapObj[j].frameName, true, 1.0);
+	 mb_mapObj[j].zoom(true, 1.0);
 	 mb_execloadWmsSubFunctions();	
 	//find layer and select
 	for(k=0;k< mb_mapObj[j].wms.length;k++){
@@ -480,11 +481,11 @@
 		l=selectedLayer;
 	}
 	if(j==-1||k==-1||l==-1){
-		alert("You have to select the WMS you want to delete!")		
+		alert("<?php echo _mb('You have to select the WMS you want to delete!');?>")	
 		return;
 	}
 	if(l!=0){
-		alert("It is not possible to delete a single layer, please select a WMS!")
+		alert("<?php echo _mb('It is not possible to delete a single layer, please select a WMS!');?>")
 		return;
 	}
 	var visibleWMS=0;
@@ -492,12 +493,12 @@
 		if( mb_mapObj[j].wms[i].gui_wms_visible=='1'|| mb_mapObj[j].wms[i].gui_wms_visible==1)
 			visibleWMS++;
 	if(visibleWMS<=1){
-		alert ("Last WMS can't be removed.\n(Der letzte WMS kann nicht entfernt werden.)");
+		alert ("<?php echo _mb('Last WMS can not be removed.');?>");
 		return;
 	}
-	if(confirm('Are you sure you want to remove "'+ mb_mapObj[j].wms[k].objLayer[l].layer_title+'"?')){
+	if(confirm('<?php echo _mb("Are you sure you want to remove");?>' + ' "'+ mb_mapObj[j].wms[k].objLayer[l].layer_title+'"?')){
   		 mb_mapObjremoveWMS(j,k); 
-		 zoom( mb_mapObj[j].frameName, true, 1.0);
+		 mb_mapObj[j].zoom(true, 1.0);
 		 mb_execloadWmsSubFunctions();	
 	}
 }

Modified: branches/print_dev/http/img/button_digitize/mergePolygons_off.png
===================================================================
(Binary files differ)

Modified: branches/print_dev/http/img/button_digitize/mergePolygons_on.png
===================================================================
(Binary files differ)

Modified: branches/print_dev/http/img/button_digitize/mergePolygons_over.png
===================================================================
(Binary files differ)

Modified: branches/print_dev/http/img/button_digitize/punchPolygon_off.png
===================================================================
(Binary files differ)

Modified: branches/print_dev/http/img/button_digitize/punchPolygon_on.png
===================================================================
(Binary files differ)

Modified: branches/print_dev/http/img/button_digitize/punchPolygon_over.png
===================================================================
(Binary files differ)

Modified: branches/print_dev/http/include/dyn_css.php
===================================================================
--- branches/print_dev/http/include/dyn_css.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/include/dyn_css.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -121,7 +121,15 @@
 		else {
 			echo "var ";
 		}
-		echo $row["var_name"]." = '".stripslashes($row["var_value"])."';\n";
+		if (is_numeric(stripslashes($row["var_value"]))) {
+			echo $row["var_name"]." = ".stripslashes($row["var_value"]).";\n";
+		}
+		elseif (strpos(stripslashes($row["var_value"]), "[") === 0 || strpos(stripslashes($row["var_value"]), "{") === 0) {
+			echo $row["var_name"]." = ".stripslashes($row["var_value"]).";\n";
+		}
+		else {
+			echo $row["var_name"]." = '".str_replace(array('"',"'", "\r", "\n", "\0"), array('\"','\\\'','\r', '\n', '\0'), stripslashes($row["var_value"]))."';\n";
+		}
 	}
 	echo "// -->\n";
 	echo "</script>\n";

Modified: branches/print_dev/http/include/dyn_js.php
===================================================================
--- branches/print_dev/http/include/dyn_js.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/include/dyn_js.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -44,6 +44,9 @@
 		if (is_numeric(stripslashes($row["var_value"]))) {
 			echo $row["var_name"]." = ".stripslashes($row["var_value"]).";\n";
 		}
+		elseif (strpos(stripslashes($row["var_value"]), "[") === 0 || strpos(stripslashes($row["var_value"]), "{") === 0) {
+			echo $row["var_name"]." = ".stripslashes($row["var_value"]).";\n";
+		}
 		else {
 			echo $row["var_name"]." = '".str_replace(array('"',"'", "\r", "\n", "\0"), array('\"','\\\'','\r', '\n', '\0'), stripslashes($row["var_value"]))."';\n";
 		}

Modified: branches/print_dev/http/include/gui1_splash.php
===================================================================
--- branches/print_dev/http/include/gui1_splash.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/include/gui1_splash.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,6 +1,6 @@
-<?php
-echo "<img src='../img/indicator_wheel.gif'>&nbsp;" . 
-	"<b>Ma<font color='#0000CE'>p</font><font color='#C00000'>b</font>ender " . 
-	MB_VERSION_NUMBER . " " . strtolower(MB_VERSION_APPENDIX) . "</b>..." .
-	"loading application '" . $gui_id . "'";
-?>
+<?php
+echo "<img src='../img/indicator_wheel.gif'>&nbsp;" . 
+	"<b>Ma<font color='#0000CE'>p</font><font color='#C00000'>b</font>ender " . 
+	MB_VERSION_NUMBER . " " . strtolower(MB_VERSION_APPENDIX) . "</b>..." .
+	"loading application '" . $gui_id . "'";
+?>

Modified: branches/print_dev/http/include/template_splash.php
===================================================================
--- branches/print_dev/http/include/template_splash.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/include/template_splash.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,6 +1,6 @@
-<?php
-echo "<img src='../img/indicator_wheel.gif'>&nbsp;" . 
-	"<b>Ma<font color='#0000CE'>p</font><font color='#C00000'>b</font>ender " . 
-	MB_VERSION_NUMBER . " " . strtolower(MB_VERSION_APPENDIX) . "</b>..." .
-	"loading application '" . $gui_id . "'";
-?>
+<?php
+echo "<img src='../img/indicator_wheel.gif'>&nbsp;" . 
+	"<b>Ma<font color='#0000CE'>p</font><font color='#C00000'>b</font>ender " . 
+	MB_VERSION_NUMBER . " " . strtolower(MB_VERSION_APPENDIX) . "</b>..." .
+	"loading application '" . $gui_id . "'";
+?>

Modified: branches/print_dev/http/javascripts/geometry.js
===================================================================
--- branches/print_dev/http/javascripts/geometry.js	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/geometry.js	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,2177 +1,2176 @@
-/* 
-* $Id$
-* 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. 
-*/
-// http://www.mapbender.org/index.php/GeometryArray.js
-
-
-var nameGeometryArray = "GeometryArray";
-var nameMultiGeometry = "MultiGeometry";
-var nameGeometry = "Geometry";
-
-/**
- * @class A class representing geometry types "polygon", "line" and "point".
- *
- * @constructor
- */
-function GeomType(){
-	/**
-	 * An identifier for polygons. If you want to check if a {@link MultiGeometry}
-	 * or {@link Geometry} is a polygon, write
-	 * if (someGeometry.geomType == geomType.polygon
-	 * 
-	 * @type String
-	 */
-	this.polygon = "polygon";
-
-	/**
-	 * An identifier for polygons. If you want to check if a {@link MultiGeometry}
-	 * or {@link Geometry} is a line, write
-	 * if (someGeometry.geomType == geomType.line
-	 * 
-	 * @type String
-	 */
-	this.line = "line";
-
-	/**
-	 * An identifier for polygons. If you want to check if a {@link MultiGeometry}
-	 * or {@link Geometry} is a point, write
-	 * if (someGeometry.geomType == geomType.point
-	 * 
-	 * @type String
-	 */
-	this.point = "point";
-}
-var geomType = new GeomType();
-
-
-/**
- * @class a {@link GeometryArray} is a {@link List} of {@link MultiGeometry} objects
- *
- * @ extends List
- * @ requires MultiGeometry 
- * @ requires Geometry
- * @ requires Point
- * @ constructor
- */
-function GeometryArray(){
-
-	/*
-	 * creates a new, empty Multigeometry and adds it to this GeometryArray
-	 *
-	 * @param {String} geomType a {@link GeomType}
-	 */
-	this.addMember = function(geomType){
-		this.add(new MultiGeometry(geomType));
-	};
-	
-	/**
-	 * @ignore
-	 */
-	this.name = nameGeometryArray;
-	
-	/**
-	 * A {@link List} of {@link MultiGeometry} objects.
-	 * 
-	 * @type List
-	 */
-	this.list = [];
-}
-
-GeometryArray.prototype = new List();
-	
-/**
- * gets the j-th {@link Geometry} object of the i-th {@link MultiGeometry} object
- *
- * @param {Integer} i index of the MultiGeometry
- * @param {Integer} j index of the Geometry
- * @type Geometry 
- */
-GeometryArray.prototype.getGeometry = function(i,j){
-	var tmp = this.get(i);
-	return tmp.get(j);
-};
-
-/**
- * gets the k-th Point of the j-th {@link Geometry} object of the i-th {@link MultiGeometry} object
- *
- * @param {Integer} i index of the MultiGeometry
- * @param {Integer} j index of the Geometry
- * @param {Integer} k index of the Point
- * @type Point
- * @returns the Point object at the given indices
- */
-GeometryArray.prototype.getPoint = function(i, j, k, l){
-	if (l == undefined) {
-		return this.get(i).get(j).get(k);
-	}
-	return this.get(i).get(j).innerRings.get(k).get(l);
-};
-
-/**
- * gets an Array of indices; the {@link MultiGeometry} objects at these indices are equal to geom
- *
- * @type Integer[]
- * @param {MultiGeometry} geom 
- * @returns an Array of indices
- */
-GeometryArray.prototype.findMultiGeometry = function(geom) {
-	var a = [];
-	for (var i=0; i < this.count(); i++) {
-		if (this.get(i).equals(geom)) {a.push(i);}
-	}
-	return a;
-};
-	
-/**
- * deletes the j-th {@link Geometry} object of the i-th {@link MultiGeometry} object
- *
- * @param {Integer} i index of the MultiGeometry
- * @param {Integer} j index of the Geometry
- */
-GeometryArray.prototype.delGeometry = function(i,j){
-	if (this.get(i).del(j) === false) {
-		this.del(i);
-	}
-};
-	
-/**
- * deletes the k-th {@link Point} of the j-th {@link Geometry} object of the i-th {@link MultiGeometry} object
- *
- * @param {Integer} i index of the MultiGeometry
- * @param {Integer} j index of the Geometry
- * @param {Integer} k index of the Point
- */
-GeometryArray.prototype.delPoint = function (i, j, k, l) {
-	var res = this.get(i).delPoint(j, k, l);
-	if (res === false) {
-		this.del(i);
-	}
-};
-	
-/**
- * closes the current {@link MultiGeometry}. Calls method close of the {@link Geometry} class.
- *
- */
-GeometryArray.prototype.close = function(){
-	if (!this.get(-1).get(-1).close()) {
-		this.delGeometry(-1, -1);
-	}
-	else {
-		if (this.get(-1).get(-1).count() === 0) {
-			this.get(-1).del(-1);
-		}
-		if (this.get(-1).count() === 0) {
-			this.del(-1);
-		}
-	}
-	
-};
-
-/**
- * deletes all {@link Point} objects of this {@link GeometryArray} that equal point
- *
- * @param {Point} point
- */
-GeometryArray.prototype.delAllPointsLike = function(point){
-	var finished = false;
-	while (finished === false){
-		finished = true;
-		for (var i = 0 ; finished === true && i < this.count() ; i++){
-			for (var j = 0 ; finished === true && j < this.get(i).count() ; j++){
-
-				var currentGeometry = this.get(i).get(j);
-				if (currentGeometry.geomType == geomType.polygon && currentGeometry.innerRings) {
-					for (var k = 0; finished === true && k < currentGeometry.innerRings.count(); k++) {
-						for (var l = 0; finished === true && l < currentGeometry.innerRings.get(k).count(); l++) {
-							if (this.getPoint(i, j, k, l).equals(point)) {
-								this.delPoint(i, j, k, l);
-								finished = false;
-							}
-						}
-					}
-				}
-				if (!finished) {
-					break;
-				}
-
-				for (var k = 0 ; finished === true && k < this.get(i).get(j).count() ; k++){
-					if (this.getPoint(i,j,k).equals(point)){
-						this.delPoint(i,j,k);
-						finished = false;
-					}
-				}
-			} 
-		}
-	}
-};
-	
-/**
- * updates all {@link Point} objects of this {@link GeometryArray} that equal oldP to newP
- *
- * @param {Point} oldP
- * @param {Point} newP
- */
-GeometryArray.prototype.updateAllPointsLike = function(oldP, newP){
-	for (var i = 0; i < this.count(); i++){
-		this.get(i).updateAllPointsLike(oldP, newP);
-	}
-};
-
-GeometryArray.prototype.placemarkToString = function (placemarkId) {
-	var str = "{\"type\": \"Feature\", \"geometry\": ";
-
-	// get geometries with placemarkId
-	var geometriesFromPlacemark = [];
-	for (var i = 0, len = this.count(); i < len; i++) {
-		if (this.get(i).isFromKml() && this.get(i).e.getElementValueByName("Mapbender:placemarkId") == placemarkId) {
-			geometriesFromPlacemark.push(i);
-		}
-	}	
-
-	if (geometriesFromPlacemark.length > 1) {
-		str += "{\"type\": \"GeometryCollection\", \"geometries\": [";
-		for (var i = 0; i < geometriesFromPlacemark.length; i++) {
-			if (i > 0) {
-				str += ",";
-			}	
-			str += this.get(geometriesFromPlacemark[i]).placemarkToString();
-		}
-		str += "]}";
-
-		// metadata is the same for all indices...get from index 0
-		var propString = this.get(geometriesFromPlacemark[0]).e.toString();
-		if (propString) {
-			str += "," + propString;
-		}
-	}
-	else if (geometriesFromPlacemark.length === 1) {
-		str += this.get(geometriesFromPlacemark[0]).placemarkToString();
-	}
-
-	str += "}";
-	return str;
-};
-
-GeometryArray.prototype.getBBox = function(){
-	var q = this.get(0).get(0).get(0);
-	var min = cloneObject(q);
-	var max = cloneObject(q);
-	for(var i=0; i < this.count();i++){
-		var pos = this.get(i).getBBox();
-		if (pos[0].x < min.x) {min.x = pos[0].x;}
-		if (pos[1].x > max.x) {max.x = pos[1].x;}
-		if (pos[1].y > max.y) {max.y = pos[1].y;}
-		if (pos[0].y < min.y) {min.y = pos[0].y;}
-	}
-	return [min, max];
-};
-
-GeometryArray.prototype.importGeometryFromText = function (text) {
-
-	var tmpArray = text.split("(");
-	var geometryType = tmpArray[0];
-
-	switch (geometryType) {
-		case "MULTIPOLYGON":
-			var text = text.replace(/\)/g, "");
-			var sepArray = text.split("(((");
-			var polyArray = sepArray[1].split(",((");
-			
-			this.addMember(geomType.polygon);
-			for (var i = 0; i < polyArray.length; i++) {
-				var ringArray = polyArray[i].split(",(");
-				for (var j = 0; j < ringArray.length; j++) {
-					var coordinatesArray = ringArray[j].split(",");
-					if (j === 0) {
-						// add outer ring
-						this.get(-1).addGeometry();
-						for (var m = 0; m < -1 + coordinatesArray.length; m++) {
-							var currentPoint = coordinatesArray[m].split(" ");
-							this.getGeometry(-1, -1).addPointByCoordinates(parseFloat(currentPoint[0]), parseFloat(currentPoint[1]));
-						}
-						this.close();
-					}		
-					else {
-						// add inner ring
-						var ring = new Geometry(geomType.polygon);
-						for (var m = 0; m < -1 + coordinatesArray.length; m++) {
-							var currentPoint = coordinatesArray[m].split(" ");
-							ring.addPointByCoordinates(parseFloat(currentPoint[0]), parseFloat(currentPoint[1]));
-						}
-						ring.close();
-						this.getGeometry(-1,-1).addInnerRing(ring);				
-					}
-				}
-			}
-			break;
-	}
-};
-
-GeometryArray.prototype.importGeoJSON = function (geoJSON) {
-	// you can pass either geoJSON or the evaluated geoJSON string
-	// for backwards compatibility
-	if (typeof(geoJSON) == 'string') {
-		var geoJSON = eval('(' + geoJSON + ')');
-	}
-
-	//
-	// FEATURE COLLECTION
-	//
-	var isFeatureCollection = (geoJSON.type == "FeatureCollection") ? true : false;
-	if (isFeatureCollection) {
-		//
-		// FEATURE
-		//
-		var featureArray = geoJSON.features;
-		for (var j = 0; j < featureArray.length; j++) {
-			var currentFeature = featureArray[j];
-			var isFeature = (currentFeature.type == "Feature") ? true : false;
-	
-			// add geometry ...
-			if (currentFeature.geometry && isFeature) {
-				var featureEpsg = "EPSG:4326";
-				if (!currentFeature.crs || currentFeature.crs.type !== "name" || !currentFeature.crs.properties.name) {
-					var e = new Mb_warning("SRS not set or unknown in GeoJSON. Using 'EPSG:4326'.");
-				}
-				else {
-					featureEpsg = currentFeature.crs.properties.name;
-				}
-
-				//
-				// GEOMETRY
-				//
-				var currentGeometry = currentFeature.geometry;
-				var geometrytype = currentGeometry.type;
-				var coordinates = currentGeometry.coordinates;
-				switch (geometrytype) {
-					case "Point":
-						//
-						// POINT
-						//
-						this.addMember(geomType.point);
-						
-						this.get(-1).addGeometry();
-						this.getGeometry(-1,-1).addPointByCoordinates(coordinates[0], coordinates[1], coordinates[2]);
-						this.getGeometry(-1,-1).setEpsg(featureEpsg);
-						this.close();
-						break;
-					
-					case "LineString":
-						//
-						// LINESTRING
-						//
-						this.addMember(geomType.line);
-						this.get(-1).addGeometry();
-						for (var m = 0; m < coordinates.length; m++) {
-							var currentPoint = coordinates[m];
-							this.getGeometry(-1,-1).addPointByCoordinates(currentPoint[0], currentPoint[1], currentPoint[2]);
-						}
-						this.getGeometry(-1,-1).setEpsg(featureEpsg);
-						this.close();
-						break;
-						
-					case "MultiLineString":
-						//
-						// MULTILINESTRING
-						//
-						this.addMember(geomType.line);
-						for (var m = 0; m < coordinates.length; m++) {
-							this.get(-1).addGeometry();
-							var currentLine = coordinates[m];
-							for (var n = 0; n < currentLine.length; n++) {
-								var currentPoint = currentLine[n];
-								this.getGeometry(-1,-1).addPointByCoordinates(currentPoint[0], currentPoint[1], currentPoint[2]);
-							}
-							this.getGeometry(-1,-1).setEpsg(featureEpsg);
-						}
-						this.close();
-						break;
-					
-					case "Polygon":
-						//
-						// POLYGON
-						//
-						this.addMember(geomType.polygon);
-						for (var m = 0; m < coordinates.length; m++) {
-							this.get(-1).addGeometry();
-							var currentPolygon = coordinates[m];
-							for (var n = 0; n < currentPolygon.length; n++) {
-								var currentPoint = currentPolygon[n];
-								this.getGeometry(-1,-1).addPointByCoordinates(currentPoint[0], currentPoint[1], currentPoint[2]);
-							}
-							this.getGeometry(-1,-1).setEpsg(featureEpsg);
-						}
-						this.close();
-						break;
-						
-					case "MultiPolygon":
-						//
-						// MULTIPOLYGON
-						//
-						this.addMember(geomType.polygon);
-						for (var m = 0; m < coordinates.length; m++) {
-							this.get(-1).addGeometry();
-							var currentPolygon = coordinates[m];
-							for (var n = 0; n < currentPolygon.length; n++) {
-								var currentRing = currentPolygon[n];
-								if (n == 0) {
-									for (var p = 0; p < currentRing.length; p++) {
-										var currentPoint = currentRing[p];
-										this.getGeometry(-1, -1).addPointByCoordinates(currentPoint[0], currentPoint[1], currentPoint[2]);
-									}
-								}
-								else {
-									var ring = new Geometry(geomType.polygon);
-									for (var p = 0; p < currentRing.length; p++) {
-										var currentPoint = currentRing[p];
-										ring.addPointByCoordinates(currentPoint[0], currentPoint[1], currentPoint[2]);
-									}
-									ring.close();
-									this.getGeometry(-1,-1).addInnerRing(ring);				
-								}
-							}
-							this.getGeometry(-1,-1).setEpsg(featureEpsg);
-						}
-						this.close();
-						break;
-	
-					case "GeometryCollection":
-						var exc = new Mb_exception("Geometry: GeometryCollections are not yet supported");
-						break;
-				}
-			}
-			
-			if (currentFeature.properties) {
-				var properties = currentFeature.properties;
-				// GeometryCollections are NOT YET IMPLEMENTED
-				if (geometrytype != "GeometryCollection") {
-					for (var l in properties) {
-						if (typeof(properties[l]) != "function") {
-							this.get(-1).e.setElement(l, properties[l]);
-						}
-					}
-					this.get(-1).e.setElement("fid", currentFeature.id);
-				}
-			}
-		}
-	}
-	return true;
-}
-
-GeometryArray.prototype.featureToString = function (i) {
-	var str = "{\"type\": \"FeatureCollection\", \"features\": [";
-	str += this.get(i).toString();
-	str += "]}";
-	return str;
-};
-
-
-GeometryArray.prototype.toString = function () {
-	var str = "{\"type\": \"FeatureCollection\", \"features\": [";
-
-	// separate: geometries that are from a KML and those which are not
-	var multiGeometriesFromKml = [];
-	var multiGeometriesNotFromKml = [];
-	for (var i = 0, len = this.count(); i < len; i++) {
-		if (this.get(i).isFromKml()) {
-			var placemarkId = this.get(i).e.getElementValueByName("Mapbender:placemarkId");
-
-			// only add placemark ids once!
-			var isFound = false;
-			for (var j = 0; j < multiGeometriesFromKml && isFound === false; j++) {
-				if (multiGeometriesFromKml == placemarkId) {
-					isFound = true;
-				}
-			}
-			if (!isFound) {
-				multiGeometriesFromKml.push(placemarkId);
-			}
-		}
-		else {
-			multiGeometriesNotFromKml.push(i);
-		}
-	}
-
-	// add geometries not from KML
-	for (var i = 0, len = multiGeometriesNotFromKml.length; i < len; i++) {
-		if (i > 0) {
-			str += ",";
-		}		
-		str += this.get(multiGeometriesNotFromKml[i]).toString();
-	}
-	
-	// add geometries from KML
-	if (multiGeometriesNotFromKml.length > 0 && multiGeometriesFromKml.length > 0) {
-		str += ",";
-	}
-
-	for (var i=0; i < multiGeometriesFromKml.length; i++) {
-		if (i > 0) {
-			str += ",";
-		}	
-		str += this.placemarkToString();
-	}
-
-	str += "]}";
-	return str;
-};
-	
-/**
- * @class a MultiGeometry is a List of Geometry objects
- *
- * @ extends List
- * @ requires Geometry
- * @ requires Point
- * @ constructor
- * @ param {String} geomType a geomType
- */
-function MultiGeometry(geomType){
-
-	/*
-	 * creates a new, empty {@link Geometry} object and adds it to this {@link MultiGeometry}
-	 *
-	 */
-	this.addGeometry = function(){
-		this.add(new Geometry(this.geomType));
-	};
-	
-	/**
-	 * deletes the {@link Geometry} object at index i; -1 refers to the last {@link Geometry object in the list
-	 * overwrites the del function of {@link List}.
-	 *
-	 * @param {Integer} i index
-	 */
-	this.del = function(i){
-		i = this.getIndex(i);
-		if (i !== false){
-			var tmpLength = this.count() - 1;
-			for (var z = i; z < tmpLength ; z ++){
-				this.list[z] = this.list[z+1];
-			}
-			this.list.length -= 1;
-			if (this.list.length === 0) {return false;}
-		}
-		return true;
-	};
-
-	this.list = [];
-	this.e = new Wfs_element();
-	this.geomType = geomType;
-	this.name = nameMultiGeometry;
-}
-
-MultiGeometry.prototype = new List();
-
-/**
- * updates all {@link Point} objects of this {@link MultiGeometry} that equal oldP to newP
- *
- * @param {Point} oldP
- * @param {Point} newP
- */
-MultiGeometry.prototype.updateAllPointsLike = function(oldP, newP){
-	for (var i = 0; i < this.count(); i++) {
-		this.get(i).updateAllPointsLike(oldP, newP);
-	}
-};
-
-/**
- * gets the bounding box of this {@link MultiGeometry} as an Array of 2 points
- *
- * @return the bounding box
- * @type Array of two Point objects
- */
-MultiGeometry.prototype.getBBox = function(){
-	var q = this.get(0).get(0);
-	var min = cloneObject(q);
-	var max = cloneObject(q);
-	for(var i=0; i<this.count();i++){
-		var pos = this.get(i).getBBox();
-		if (pos[0].x < min.x) {min.x = pos[0].x;}
-		if (pos[1].x > max.x) {max.x = pos[1].x;}
-		if (pos[1].y > max.y) {max.y = pos[1].y;}
-		if (pos[0].y < min.y) {min.y = pos[0].y;}
-	}
-	return [min, max];
-};
-
-/**
- * gets the bounding box of this {@link MultiGeometry} as a polygon of four points
- *  
- * @return the bounding box
- * @type MultiGeometry
- */
-MultiGeometry.prototype.getBBox4 = function() {
-	var bbox = this.getBBox();
-	var realBox = new MultiGeometry(geomType.polygon);
-	realBox.addGeometry(geomType.polygon);
-	realBox.get(-1).addPointByCoordinates(bbox[0].x, bbox[0].y);
-	realBox.get(-1).addPointByCoordinates(bbox[0].x, bbox[1].y);
-	realBox.get(-1).addPointByCoordinates(bbox[1].x, bbox[1].y);
-	realBox.get(-1).addPointByCoordinates(bbox[1].x, bbox[0].y);
-	realBox.get(-1).close();
-	return realBox;
-};
-
-/**
- * gets the center of the bounding box of this {@link MultiGeometry}.
- *
- * @return the center of the bounding box
- * @type Point
- */
-MultiGeometry.prototype.getCenter = function(){
-	var tmp = this.getBBox();
-	var x = parseFloat(tmp[0].x) + parseFloat((tmp[1].x - tmp[0].x)/2);
-	var y = parseFloat(tmp[0].y) + parseFloat((tmp[1].y - tmp[0].y)/2);
-	return new Point(x,y);
-};
-
-/**
- * gets the total number of {@link Point} objects of this {@link MultiGeometry}.
- *
- * @return number of points
- * @type Integer
- */
-MultiGeometry.prototype.getTotalPointCount = function(){ 
-	var c = 0;
-	for (var i = 0 ; i < this.count(); i++)	{
-		c += this.get(i).count();
-	}
-	return c;
-};
-
-/**
- * gets the total number of {@link Point} objects of this {@link MultiGeometry}.
- *
- * @return number of points
- * @type Integer
- */
-MultiGeometry.prototype.getPoint = function(j,k){
-	return this.get(j).get(k);
-};
-
-/**
- * compares this {@link MultiGeometry} object with the {@link MultiGeometry} object multigeom.
- *
- * @param {MultiGeometry} multigeom another multigeometry
- * @return true if he multigeometries match; else false 
- * @type Boolean
- */
-MultiGeometry.prototype.equals = function(multigeom) {
-	if (this.geomType != multigeom.geomType) {return false;}
-	if (this.count() != multigeom.count()) {return false;}
-	if (this.getTotalPointCount() != multigeom.getTotalPointCount()) {return false;}
-	for (var i=0; i<this.count(); i++) {
-		if (!this.get(i).equals(multigeom.get(i))) {return false;}
-	}
-	return true;
-};
-
-/**
- * deletes the j-th {@link Point} object of the i-th {@link Geometry} object of this {@link MultiGeometry} object.
- *
- * @param {Integer} i geometry index
- * @param {Integer} j point index
- * @return true if the deletion succeded; else false.
- * @type Boolean
- */
-MultiGeometry.prototype.delPoint = function(i, j, k){
-	var res;
-	if (k == undefined) {
-		res = this.get(i).del(j);
-		if (res === false) {
-			return this.del(i);
-		}
-	}
-	else {
-		res = this.get(i).innerRings.get(j).del(k);
-		if (res === false) {
-			this.get(i).innerRings.del(j);
-		}
-	}
-	return true;
-};
-
-MultiGeometry.prototype.isFromKml = function () {
-	if (this.e.getElementValueByName("Mapbender:kml")) {
-		return true;
-	}
-	return false;
-};
-
-MultiGeometry.prototype.toText = function () {
-	var text = "";
-	var numOfGeom = this.count();
-	if (numOfGeom >= 1) {
-		if (this.geomType == geomType.polygon) {
-			if (numOfGeom > 1) {
-				text += "MULTIPOLYGON (";
-				for (var i = 0; i < numOfGeom; i++) {
-					if (i > 0) {
-						text += ", ";
-					}
-					var currentPolygon = this.get(i);
-					text += "(" + currentPolygon.toText() + ")";
-				}
-				text += ")";
-			}
-			else {
-				text += "POLYGON (" + this.get(0).toText() + ")";
-			}
-		}
-		else if (this.geomType == geomType.line) {
-			text += "LINESTRING (";
-
-			var currentLine = this.get(0);
-			for (var j = 0; j < currentLine.count(); j++) {
-				if (j > 0) {
-					text += ", ";
-				}
-
-				var currentPoint = currentLine.get(j);
-				text += currentPoint.x + " " + currentPoint.y
-			}
-
-			text += ")";
-		}
-		
-	}
-	return text;		
-};
-
-MultiGeometry.prototype.toString = function () {
-	var str = this.toStringWithoutProperties();
-	
-	// properties
-	var propString = this.e.toString();
-	if (propString) {
-		str += "," + propString;
-	}
-
-	str += "}";
-	
-	return str;
-};
-
-MultiGeometry.prototype.placemarkToString = function () {
-	var str = "";
-	// geometries
-	for (var i = 0, len = this.count(); i < len; i++) {
-		if (i > 0) {
-			str += ",";
-		}		
-		str += this.get(i).toString();
-	}
-	return str;
-};
-
-MultiGeometry.prototype.toStringWithoutProperties = function () {
-	var str = "{\"type\": \"Feature\", ";
-
-	var epsg = this.getEpsg();
-	if (epsg) {
-		str += "\"crs\": {\"type\": \"name\", \"properties\": {\"name\": \"" + epsg + "\"}}, ";
-	}
-	str += "\"geometry\": {";
-
-	var len = this.count(); 
-	
-	switch (this.geomType) {
-		case geomType.polygon:
-			if (len > 1) {
-				str += "\"type\": \"MultiPolygon\", ";
-			}
-			else {
-				str += "\"type\": \"Polygon\", ";
-			}
-			break;
-		case geomType.line:
-			if (len > 1) {
-				str += "\"type\": \"MultiLineString\", ";
-			}
-			else {
-				str += "\"type\": \"LineString\", ";
-			}
-			break;
-		case geomType.point:
-			if (len > 1) {
-				str += "\"type\": \"MultiPoint\", ";
-			}
-			else {
-				str += "\"type\": \"Point\", ";
-			}
-			break;
-	}
-
-	str += "\"coordinates\": "
-	// geometries
-	if (len > 1) {
-		str += "[";
-		for (var i = 0; i < len; i++) {
-			if (i > 0) {
-				str += ",";
-			}		
-			str += this.get(i).toString();
-		}
-		str += "]";
-	}
-	else {
-		str += this.get(0).toString();
-	}
-
-	str += "}";
-
-// this closing curly bracket is added in toString()
-//	str += "}";
-	
-	return str;
-};
-
-/**
- * @return the EPSG code of this geometry.
- * @type integer
- */
-MultiGeometry.prototype.getEpsg = function () {
-	if (this.count() > 0) {
-		return this.get(0).getEpsg();
-	}
-	return false;
-};
-
-
-function InnerRings () {
-	this.list = [];	
-};
-
-InnerRings.prototype = new List();
-
-/**
- * @class a Geometry is a List of Point objects. If it is a polygon, the last point has 
- * to equal the first point.
- *
- * @extends List
- * @requires Point
- * @constructor
- * @param {String} a string representing a geometry type, see @see GeomType.
- */
-function Geometry(aGeomtype){
-
-	/**
-	 * deletes the {@link Point} object at index i; -1 refers to the last 
-	 * {@link Point} object in the list. Overwrites the del function of 
-	 * {@link List}.
-	 *
-	 * @param {Integer} i index
-	 * @return false if deletion is not yet finished. It is cascaded to 
-	 *         {@link MultiGeometry}. True if the deletion is finished.
-	 */
-	this.del = function(i){
-		i = this.getIndex(i);
-		if (i !== false) {
-			var tmpLength = this.count()-1;
-			
-			for (var z = i; z < tmpLength ; z ++){
-				this.list[z] = this.list[z+1];
-			}
-			this.list.length -= 1;
-		
-			if (this.geomType == geomType.polygon){
-				if (i == tmpLength) {this.list[0] = this.list[tmpLength-1];}
-				else if (i === 0) {this.list[tmpLength-1] = this.list[0];}
-				if (this.list.length == 1){return false;}
-			}
-			updateDist();
-			if(this.list.length === 0) {return false;}
-			return true;
-		}
-		return false;
-	};
-
-	/**
-	 * adds a {@link Point} object to this {@link Geometry} object.
-	 *
-	 * @param {Float} x x value of the point
-	 * @param {Float} y y value of the point
-	 */	
-	this.addPointByCoordinates = function(x,y,z){
-		var newPoint = new Point(x,y,z);
-		this.add(newPoint);
-//		updateDist();
-	};
-
-	/**
-	 * adds a {@link Point} object to this {@link Geometry} object.
-	 *
-	 * @param {Point} aPoint another point
-	 */	
-	this.addPoint = function(aPoint){
-		this.add(new Point(aPoint.x, aPoint.y, aPoint.z));
-		updateDist();
-	};
-
-	/**
-	 * inserts a {@link Point} object at index i of this {@link Geometry} object.
-	 *
-	 * @param {Point} p another point
-	 * @param {Integer} i index
-	 */	
-	this.addPointAtIndex = function(p,i){
-		i = this.getIndex(i);
-		if (i !== false){
-			for(var z = this.count(); z > i; z--){
-				this.list[z] = this.list[z-1];
-			}
-			this.list[i] = new Point(p.x, p.y, p.z);
-			updateDist();
-		}
-	};
-	
-	/**
-	 * Overwrites the {@link Point) object at index i with the {@link Point} object p.
-	 *
-	 * @private
-	 * @param {Point} p another point
-	 * @param {Integer} i index
-	 */	
-	this.updatePointAtIndex = function(p, i){
-		i = this.getIndex(i);
-		if ((i === 0 || i == this.count()-1) && this.geomType == geomType.polygon){
-			this.list[0] = p;
-			this.list[this.count()-1] = p;
-		}
-		else {this.list[i] = p;}
-		updateDist();
-	};
-	
-	/**
-	 * Updates the {@link Geometry#dist} and {@link Geometry#totaldist}
-	 *
-	 * @private
-	 */	
-	var updateDist = function(){
-/*
- * DISABLED BECAUSE IT IS TOO SLOW
-		dist[0] = 0;		
-		totaldist[0] = 0;		
-		for (var i = 1 ; i < that.count(); i++){
-			dist[i] = that.get(i-1).dist(that.get(i));
-			totaldist[i] = totaldist[i-1] + dist[i];
-		}
-*/
-	};
-	/**
-	 * gets the distance between the last and last but one point of this {@link Geometry}.
-	 *
-	 * @param {Integer} numberOfDigitis round to numberOfDigits (optional)
-	 * @return the distance
-	 * @type Float
-	 */	
-	this.getCurrentDist = function(numberOfDigits) {
-		if (typeof(numberOfDigits) == "number") {
-			return roundToDigits(dist[this.count()-1], numberOfDigits);
-		}
-		return dist[this.count()-1];
-		
-	};
-	/**
-	 * gets the length of the outer rim of this {@link Geometry}.
-	 *
-	 * @param {Integer} numberOfDigitis round to numberOfDigits (optional)
-	 * @return the distance
-	 * @type Float
-	 */	
-	this.getTotalDist = function(numberOfDigits) {
-		if (typeof(numberOfDigits) == "number") {
-			return roundToDigits(totaldist[this.count()-1], numberOfDigits);
-		}
-		return totaldist[this.count()-1];
-	};
-	/**
-	 * closes this {@link Geometry}. 
-	 *
-	 * @return true if the geometry could be closed; otherwise false
-	 * @type Boolean
-	 */	
-	this.close = function(){
-		complete = true;
-		if (this.geomType == geomType.polygon){
-			if (this.count() > 2){
-				if (!this.get(0).equals(this.get(-1))) {
-					this.addPoint(this.get(0));
-				}
-			}
-			else {return false;}
-		}
-		if (this.geomType == geomType.line){
-			if (this.count() < 2){return false;}
-		}
-		return true;
-	};
-	/**
-	 * checks if this {@link Geometry} has been closed. 
-	 *
-	 * @return true if the geometry is closed; otherwise false
-	 * @type Boolean
-	 */	
-	this.isComplete = function() { 
-		return complete;
-	};
-	
-	/**
-	 * Sets the EPSG of this geometry.
-	 * 
-	 * @param {Integer} someEpsg the EPSG of this geometry.
-	 * @return true if the EPSG could be set; else false
-	 * @type boolean
-	 */
-	this.setEpsg = function (someEpsg) {
-		// TODO: how to check if EPSG code is correct?
-		epsg = someEpsg;
-		return true;
-
-		var e = new Mb_exception("EPSG code not valid ("+someEpsg+")");
-		return false;
-	};
-	
-	/**
-	 * @return the EPSG code of this geometry.
-	 * @type integer
-	 */
-	this.getEpsg = function () {
-		return epsg;
-	};
-	
-	this.list = [];
-	var dist = [];
-	var totaldist = [];
-	var complete = false;
-
-	var epsg;
-
-	var that = this;
-
-	this.geomType = aGeomtype;
-	this.name = nameGeometry;
-
-	// add these members if the geometry is a polygon
-	if (this.geomType == geomType.polygon) {
-		this.innerRings = new InnerRings();
-		this.addInnerRing = function (somePolygon) {
-			this.innerRings.add(somePolygon);
-		};
-		this.delInnerRing = function (index) {
-			this.innerRings.del(index);
-		};
-	}
-}
-
-Geometry.prototype = new List();
-
-Geometry.prototype.toText = function () {
-	var text = "";
-	switch (this.geomType) {
-		case geomType.polygon:
-			text += "(";
-			for (var j = 0; j < this.count(); j++) {
-				if (j > 0) {
-					text += ", ";
-				}
-				var currentPoint = this.get(j);
-				text += currentPoint.x + " " + currentPoint.y
-			}
-			text += ")";
-			if (this.innerRings && this.innerRings.count() > 0) {
-				for (var k = 0; k < this.innerRings.count(); k++) {
-					text += ", ";
-					text += this.innerRings.get(k).toText();
-				}				
-			}
-			break;
-	}
-	return text;
-};
-/**
- * gets the bounding box of this {@link Geometry}
- *
- * @return the bounding box (array of two Point objects)
- * @type Point[]
- */
-Geometry.prototype.getBBox = function(){
-	var q = this.get(0);
-	var min = cloneObject(q);
-	var max = cloneObject(q);
-	
-	for (var j=0; j<this.count(); j++){
-		var pos = this.get(j);
-		if (pos.x < min.x) {min.x = pos.x;}
-		else if (pos.x > max.x) {max.x = pos.x;}
-		if (pos.y < min.y) {min.y = pos.y;}
-		else if (pos.y > max.y) {max.y = pos.y;}
-	}
-	if (this.geomType == geomType.polygon) {
-		for (var i = 0; i < this.innerRings.count(); i++) {
-			var currentRing = this.innerRings.get(i);
-			for (var j=0; j<currentRing.count(); j++){
-				var pos = currentRing.get(j);
-				if (pos.x < min.x) {min.x = pos.x;}
-				else if (pos.x > max.x) {max.x = pos.x;}
-				if (pos.y < min.y) {min.y = pos.y;}
-				else if (pos.y > max.y) {max.y = pos.y;}
-			}
-		}
-	}
-	
-	return [min, max];
-};
-
-/**
- * updates all {@link Point} objects of this {@link Geometry} that equal oldP to newP
- *
- * @param {Point} oldP
- * @param {Point} newP
- */
-Geometry.prototype.updateAllPointsLike = function(oldP, newP){
-	var len = this.count();
-	for (var i = 0; i < len ; i++){
-		if (oldP.equals(this.get(i))){
-			if (i>0 && newP.equals(this.get(i-1))){
-				this.del(i);
-				len--;
-				i--;
-			}
-			else {this.updatePointAtIndex(newP, i);}
-		}
-	}
-	if (this.geomType == geomType.polygon) {
-		for (var j = 0; j < this.innerRings.count(); j++) {
-			var len = this.innerRings.get(j).count();
-			for (var i = 0; i < len ; i++){
-				if (oldP.equals(this.innerRings.get(j).get(i))){
-					if (i>0 && newP.equals(this.innerRings.get(j).get(i-1))){
-						this.innerRings.get(j).del(i);
-						len--;
-						i--;
-					}
-					else {this.innerRings.get(j).updatePointAtIndex(newP, i);}
-				}
-			}
-			
-		}
-	}
-};
-
-/**
- * compares this {@link Geometry} object with the {@link Geometry} object geom point by point.
- *
- * @param {Geometry} geom another geometry
- * @return true if he geometries match; else false 
- * @type Boolean
- */
-Geometry.prototype.equals = function(geom) {
-	if (this.geomType != geom.geomType) {return false;}
-	if (this.count() != geom.count()) {return false;}
-	for (var i=0; i < this.count(); i++) {
-		if (!this.get(i).equals(geom.get(i))) {return false;}
-	}
-	if (!this.innerRings && !geom.innerRings) {
-		// no inner rings; fine
-	}
-	else if (this.innerRings && geom.innerRings) {
-		if (this.innerRings.count() != geom.innerRings.count()) {
-			return false;
-		}
-		for (var j = 0; j < this.innerRings.count(); j++) {
-			if (!this.innerRings.get(j).equals(geom.innerRings.get(j))) {
-				return false;
-			}
-		}
-	}
-	else {
-		// inner ring mismatch
-		return false;
-	}	
-	return true;
-};
-
-/**
- * creates a polygon geometry object which form a buffer around the line geometry
- * 
- * @param {float} real world units to buffer around the line
- * @param {float} (optional) units to buffer around the line in Y direction
- * 
- * @return linebuffer polygon
- * @type Geometry
- */
-Geometry.prototype.bufferLine = function(bufferX, bufferY){
-	if(typeof(bufferY)=='undefined')
-		bufferY = bufferX;
-	if(this.geomType!=geomType.line || this.count()<2)
-		return false;
-	
-	var ret = new Geometry(geomType.polygon)
-	
-	//get vector from point 0 to point 1
-	last_vec = this.get(1).minus(this.get(0));
-
-	//get 90° rotated vector
-	last_vec_o = new Point(-last_vec.y, last_vec.x);
-
-	//resize vectors with apropriate linebuffer length
-	last_vec_o = last_vec_o.dividedBy(last_vec_o.dist(new Point(0,0)));
-	last_vec_o.x*=bufferX; last_vec_o.y*=bufferY;
-	last_vec = last_vec.dividedBy(last_vec.dist(new Point(0,0)));
-	last_vec.x*=bufferX; last_vec.y*=bufferY;
-		
-	//add first pointsets
-	ret.list.unshift(this.get(0).plus(last_vec_o).minus(last_vec));
-	ret.list.push(this.get(0).minus(last_vec_o).minus(last_vec));
-		
-	for(var i=1;i<this.count()-1;i++){
-		//get vector from point n to point n+1
-		vec = this.get(i+1).minus(this.get(i));
-		//get orthogonal (90° rotated) vector		
-		vec_o = new Point(-vec.y, vec.x);
-
-		//resize vectors to linebuffer length
-		vec_o = vec_o.dividedBy(vec_o.dist(new Point(0,0)));
-		vec_o.x*=bufferX; vec_o.y*=bufferY;
-		vec = vec.dividedBy(vec.dist(new Point(0,0)));
-		vec.x*=bufferX; vec.y*=bufferY;
-			
-		//if direction is the same continue
-		if(vec.equals(last_vec))
-			continue;
-			
-		// calculate directed angle between the two vectors by 
-		// calculating the argument diffenrences between complex numbers
-		// arg(x + i*y) (because law of cosine can onlycalculate undirected angle)
-		var angle = (Math.atan2(vec.x,vec.y)-Math.atan2(last_vec.x,last_vec.y))
-		//ensure that angle is -180<=angle<=180
-		if(angle<-Math.PI)angle=2*Math.PI+angle;
-		if(angle>+Math.PI)angle=2*Math.PI-angle;
-		
-		//calculate the distance between the next points on boundary
-		//and the line point
-		//the point will be in the direction of angle/2 relative to last_vec_o
-		//since cosine is adjacent side / hypothenuse and we know that 
-		//the adjacent side is lineBuffer the hypothenus (our distance) is
-		var ndist = 1/(Math.cos(angle/2))
-		//direction of next points on boundary
-		var int_vec = vec_o.plus(last_vec_o);
-		//resize direction vector to our distance
-		int_vec = int_vec.times(ndist/int_vec.dist(new Point(0,0)));
-		int_vec.x*=bufferX; int_vec.y*=bufferY;
-		
-		//look if we have an outer sharp corner (>90°)
-		if(angle>Math.PI/2){
-			//push cutted edge points
-			ret.list.unshift(this.get(i).plus(last_vec_o).plus(last_vec));
-			ret.list.unshift(this.get(i).plus(vec_o).minus(vec));
-		}
-		else{
-			//push inner/light edge
-			ret.list.unshift(this.get(i).plus(int_vec));
-		}
-
-		//look if we have an inner sharp corner (<-90°)
-		if(angle<-Math.PI/2){
-			//push cutted edge points
-			ret.list.push(this.get(i).minus(last_vec_o).plus(last_vec));
-			ret.list.push(this.get(i).minus(vec_o).minus(vec));
-		}
-		else{
-			//push inner/light edge
-			ret.list.push(this.get(i).minus(int_vec));
-		}
-			
-		//copy for next point
-		last_vec = vec;
-		last_vec_o = vec_o;
-	}
-	//add last pointsets
-	ret.list.unshift(this.get(i).plus(last_vec_o).plus(last_vec));
-	ret.list.push(this.get(i).minus(last_vec_o).plus(last_vec));
-	
-	ret.close();
-
-	return ret;	
-}
-
-Geometry.prototype.toString = function () {
-	var str = "";
-	if (this.geomType == geomType.polygon) {
-		str += "[[";
-		for (var i = 0; i < this.count(); i++) {
-			if (i > 0) {
-				str += ", ";
-			}
-			str += this.get(i).toString();
-		}
-
-		if (typeof(this.innerRings) == "object" && this.innerRings.count() > 0) {
-			for (var j = 0; j < this.innerRings.count(); j++) {
-				var currentRing = this.innerRings.get(j);
-
-				str += "],[";
-				for (var i = 0; i < currentRing.count(); i++) {
-					if (i > 0) {
-						str += ", ";
-					}
-					str += currentRing.get(i).toString();
-				}
-			}
-		}
-		str += "]]";
-	}
-	else if (this.geomType == geomType.line) {
-		str += "[";
-		for (var i = 0; i < this.count(); i++) {
-			if (i > 0) {
-				str += ", ";
-			}
-			str += this.get(i).toString();
-		}
-		str += "]";
-	}
-	else if (this.geomType == geomType.point) {
-		str += this.get(0).toString();
-	}
-	
-	return str;
-};
-
-
-
-/**
- * @class an array of elements, each consisting of a name/value pair
- *
- * @ constructor
- */
-function Wfs_element(){
-
-	/**
-	 * returns the number of elements of this {@link Wfs_element} object.
-	 *
-	 * @return the number of elements
-	 * @type Integer
-	 */
-	this.count = function(){
-		return name.length;
-	};
-
-	/**
-	 * returns the name of the element at index i.
-	 *
-	 * @param {Integer} i index
-	 * @return the name
-	 * @type String
-	 */
-	this.getName = function(i){ 
-		if (isValidElementIndex(i)) {return name[i];}
-		return false;
-	};
-	
-	/**
-	 * returns the value of the element at index i.
-	 *
-	 * @param {Integer} i index
-	 * @return the value
-	 */
-	this.getValue = function(i){ 
-		if (isValidElementIndex(i)) {return value[i];}
-		return false;
-	};
-
-	/**
-	 * appends a new element with a given name. If an element with this name exists, it is overwritten.
-	 *
-	 * @param {String} aName the name of the new element
-	 * @param {String} aValue the value of the new element
-	 */
-	this.setElement = function(aName, aValue){ 
-		var i = this.getElementIndexByName(aName);
-		if (i === false) {i = this.count();}
-		name[i] = aName;
-		value[i] = aValue;
-	};
-
-	/**
-	 * removes an element with a given name. If an element with this name exists, it is removed.
-	 *
-	 * @param {String} aName the name of the element to delete
-	 */
-	this.delElement = function(aName){
-		var i = this.getElementIndexByName(aName);
-		if (i !== false) {
-			name.splice(i, 1);
-			value.splice(i, 1);
-		}
-	}
-	
-	/**
-	 * checks if an index is valid
-	 *
-	 * @private
-	 * @param {Integer} i an index
-	 * @return true if the index is valid; otherwise false
-	 * @type Boolean
-	 */
-	var isValidElementIndex = function(i){ 
-		if (i>=0 && i<name.length) {return true;}
-		var e = new Mb_exception("class Wfs_element: function isValidElementIndex: illegal element index");
-		return false;
-	};
-	
-	var name  = [];
-	var value = [];
-}
-
-/**
- * gets the index of the element with a given name.
- *
- * @param {String} elementName a name
- * @return the index of the element; if no element with this name exists, false
- * @type Integer, Boolean
- */
-Wfs_element.prototype.getElementIndexByName = function(elementName){
-	for (var j = 0, len = this.count() ; j < len ; j++){
-		if (this.getName(j) == elementName) {return j;}
-	}
-	return false;
-};
-
-/**
- * gets the value of the element with a given name.
- *
- * @param {String} elementName a name
- * @return the value of the element; if no element with this name exists, false
- * @type String, Boolean
- */
-Wfs_element.prototype.getElementValueByName = function(elementName){
-	var i = this.getElementIndexByName(elementName);
-	if (i === false) {return false;}
-	return this.getValue(i);
-};
-
-Wfs_element.prototype.toString = function () {
-	var str = "";
-	if (this.count() > 0) {
-		str += "\"properties\": {";
-		
-		for (i = 0, len = this.count(); i < len; i++) {
-			if (i > 0) {
-				str += ",";
-			}		
-			var key = this.getName(i);
-			var value = this.getValue(i);
-			str += "\"" + key + "\":\"" + value + "\"";
-		}
-		str += "}";
-	}
-	return str;
-};
-
-/**
- * @class a {@link Canvas} contains a {@link DivTag} that holds graphics rendered by {@link jsGraphics}
- *
- * @constructor
- * @requires DivTag
- * @requires jsGraphics
- * @requires GeometryArray
- * @requires MultiGeometry
- * @requires Geometry
- * @param {String} aMapFrame name of the target mapframe
- * @param {String} aTagName name of the target div tag
- * @param {String} aStyle style of the div tag
- * @param {Integer} aLineWidth the line width of the jsGraphics output
- */
-function Canvas(aMapframe, aTagName, aStyle, aLineWidth) {
-	
-	/**
-	 * draws the geometry of the canvas
-	 *
-	 * @param {String} t geometry type (@see GeomType)
-	 * @param {MultiGeometry} g a MultiGeometry object
-	 * @param {String} col a color
-	 * @private
-	 */
- 	this.drawGeometry = function(t,g,col){
-		if(t == geomType.point) {
-			var poiIcon = g.e.getElementValueByName("Mapbender:icon");
-			for(var i=0, ilen = g.count(); i < ilen; i++){
-				var currentGeom = g.get(i);
-				var p = realToMap(mapframe, currentGeom.get(0));
-				var px = p.x;
-				var py = p.y;
-				var radius = diameter/2;
-				if ((px - radius < mapframeWidth && px + radius > 0 &&
-					py - radius < mapframeHeight && py + radius > 0) ||
-					(p.dist(new Point(0,0)) < radius || 
-					 p.dist(new Point(mapframeWidth, mapframeHeight)) < radius ||
-					 p.dist(new Point(0,mapframeHeight)) < radius || 
-					 p.dist(new Point(mapframeWidth, 0)) < radius
-					)
-				) {
-					// if the point contains a link to an icon, display the icon
-					if (poiIcon) {
-						displayIcon(poiIcon, px, py);
-					}
-					else {
-						drawCircle(px-1, py-1, diameter,col);
-					}
-				}
-			}
-		}
-		else if(t == geomType.line || t==geomType.polygon) {
-			for(var i=0, ilen = g.count(); i < ilen; i++){
-				var currentGeom = g.get(i);
-				// paint inner rings
-				if (t==geomType.polygon && currentGeom.innerRings.count() > 0) {
-					for (var k = 0; k < currentGeom.innerRings.count(); k++) {
-						var currentRing = currentGeom.innerRings.get(k);
-						var previousPoint = realToMap(mapframe, currentRing.get(0));
-						for (var j=1, jlen = currentRing.count(); j < jlen; j++) {
-							(function () {
-								var currentPoint = realToMap(mapframe, currentRing.get(j));
-								
-								var pq = calculateVisibleDash(previousPoint, currentPoint, mapframeWidth, mapframeHeight);
-								if (pq) {
-									drawLine([pq[0].x-1, pq[1].x-1], [pq[0].y-1, pq[1].y-1], col);
-								}
-								previousPoint = currentPoint;
-							})();
-						}
-						
-					}					
-				}
-				// paint line or outer ring
-				var previousPoint = realToMap(mapframe, currentGeom.get(0));
-				for (var j=1, jlen = currentGeom.count(); j < jlen; j++) {
-					(function () {
-						var currentPoint = realToMap(mapframe, currentGeom.get(j));
-						
-						var pq = calculateVisibleDash(previousPoint, currentPoint, mapframeWidth, mapframeHeight);
-						if (pq) {
-							drawLine([pq[0].x-1, pq[1].x-1], [pq[0].y-1, pq[1].y-1], col);
-						}
-						previousPoint = currentPoint;
-					})();
-				}
-			}
-		}
-		else {
-			var e = new Mb_exception("class Canvas: function drawGeometry: unknown geomType " + t);
-		}
-	};
-
-	/**
-	 * checks if the MultiGeometry's bounding box width and height is smaller than minWidth
-	 *
-	 * @private
-	 * @param {MultiGeometry} g a MultiGeometry object
-	 */
-	this.isTooSmall = function(g){
-		// TODO switch between dot, original, circle
-//		return false;
-
-		var tmp = g.getBBox();
-		var min = realToMap(mapframe,tmp[0]);
-		var max = realToMap(mapframe,tmp[1]);
-		if((Math.abs(max.x - min.x) < minWidth) && (Math.abs(max.y - min.y) < minWidth)) {
-			return true;
-		}
-		return false;
-	};
-	
-	/**
-	 * gets the jsGraphics.
-	 *
-	 * @private
-	 * @return the jsGraphics
-	 * @type jsGraphics
-	 */
-	this.getCanvas = function(){
-		return canvas;
-	};
-	
-	this.setDiameter = function (px) {
-		diameter = px;
-	};
-	
-	/**
-	 * draws a circle with {@link jsGraphics}.
-	 *
-	 * @private
-	 * @param {Float} x x value of the center
-	 * @param {Float} y y value of the center
-	 * @param {Float} diameter diameter of the circle
-	 * @param {String} color the color of the circle in hex format
-	 */
-	var drawCircle = function(x, y, diameter, color) {
-		canvas.setColor(color);
-		canvas.drawEllipse(x-diameter/2,y-diameter/2,diameter,diameter);
-	};
-
-	/**
-	 * draws a polyline with {@link jsGraphics}.
-	 *
-	 * @private
-	 * @param {Array} x_array array of x values
-	 * @param {Array} y_array array of y values
-	 * @param {String} color the color of the polyline in hex format
-	 */
-	var drawLine = function(x_array, y_array, color) {
-		canvas.setColor(color);
-		canvas.drawPolyline(x_array, y_array);
-	};
-
-	/**
-	 * Displays an icon in the mapframe
-	 * 
-	 * @private
-	 * @param {String} url link to the image
-	 * @param {Float} x x coordinate within the map frame
-	 * @param {Float} y y coordinate within the map frame
-	 */
-	var displayIcon = function (url, x, y) {
-		if(ie){
-			var newImg = document.createElement("img");
-			var newImgTop = y - Math.round(80/2);
-			var newImgLeft = x - Math.round(80/2);
-			that.canvasDivTag.getTag().innerHTML = "<img src='" + url + "' style='position:absolute;top:"+newImgTop+";left:"+newImgLeft+";z-index:100'/>";
-		}
-		else{
-			var newImg = document.createElement("img");
-			newImg.src = url;
-			that.canvasDivTag.getTag().appendChild(newImg);	
-			//newImg.className = "mapsymbol";
-			//newImg.style.cursor = "help";
-			newImg.style.position = "absolute";
-			
-			// center the image at x, y
-			newImg.style.top = y - Math.round(80/2);
-			newImg.style.left = x - Math.round(80/2);
-	//		newImg.style.top = y - Math.round(80);
-	//		newImg.style.left = x;
-			newImg.style.zIndex = 100;
-		}
-	};
-	
-	/**
-	 * This is the {@link DivTag} that contains the output by {@link jsGraphics}.
-	 * 
-	 * @type DivTag
-	 */
-	var mapframe = aMapframe;
-	var mapObjInd = getMapObjIndexByName(mapframe);
-
-	if (mb_mapObj[mapObjInd].getDomElement().frameName) {
-		this.canvasDivTag = new DivTag(aTagName, mapName, aStyle);
-	}
-	else {
-		this.canvasDivTag = new DivTag(aTagName, "", aStyle, mb_mapObj[mapObjInd].getDomElement());
-	}
-
-	var that = this;
-
-	var diameter = 8;
-	var minWidth = 8;
-	var lineWidth = aLineWidth || 2;
-	var mapframeWidth = mb_mapObj[mapObjInd].width;
-	var mapframeHeight = mb_mapObj[mapObjInd].height;
-	eventResizeMap.register(function () {
-		mapframeWidth = mb_mapObj[mapObjInd].width;
-		mapframeHeight = mb_mapObj[mapObjInd].height;
-	});
-	var style = aStyle;
-	var canvas = new jsGraphics(aTagName, mb_mapObj[mapObjInd].getDomElement().frameName ? window.frames[mapframe] : window);
-	canvas.setStroke(lineWidth);
-	mb_registerPanSubElement(aTagName);
-}
-
-/**
- * cleans the canvas by emptying the canvas {@link DivTag}.
- */
-Canvas.prototype.clean = function () {
-	this.canvasDivTag.clean();
-};
-
-/**
- * paints all geometries.
- *
- * @param {GeometryArray} gA the geometries that will be drawn
- */
-Canvas.prototype.paint = function(gA) {
-	for (var q = 0; q < gA.count(); q++) {
-		var m = gA.get(q);
-		var t = m.geomType;
-		var col = m.color;
-		if (t == geomType.point) {
-			this.drawGeometry(t,m,col);
-		}
-		else {
-			if (this.isTooSmall(m)){
-				var newMember = new MultiGeometry(geomType.point);
-				newMember.addGeometry();
-				newMember.get(-1).addPoint(m.getCenter());
-				this.drawGeometry(geomType.point,newMember,col);
-			}
-			else{
-				if(t == geomType.line) {this.drawGeometry(t,m, col);}
-				else if(t == geomType.polygon) {this.drawGeometry(t,m,col);}
-				else {
-					var e = new Mb_exception("class Canvas: function paint: unknown geomType" + t);				
-				}
-			}
-		}
-	}
-	this.getCanvas().paint();
-};
-
-/**
- * @class a {@link Highlight} object is {@link jsGraphics} rendering of a {@link GeometryArray} in various mapframes.
- *
- * @constructor
- * @requires Canvas
- * @requires GeometryArray
- * @param {Array} aTargetArray an array of Strings referring to mapframes
- * @param {String} aTagName the name of the div tags
- * @param {Object} aStyle the style of the div tags
- * @param {Integer} the line width of the jsGraphics lines
- */
-function Highlight(aTargetArray, aTagName, aStyle, aLineWidth) {
-	/**
-	 * removes a {@link MultiGeometry} object from the geometry Array
-	 *
-	 * @param {MultiGeometry} m a MultiGeometry
-	 * @param {String} color a color
-	 */	
-	this.del = function(m, color) {
-		var newMultiGeom;
-		if (m.name == nameMultiGeometry) {
-			newMultiGeom = m;
-		}
-		else if (m.name == nameGeometry) {
-			var newMultiGeom = new MultiGeometry(m.geomType);
-			newMultiGeom.add(m);
-		}
-
-		var a = gA.findMultiGeometry(newMultiGeom);
-		var del = false;
-		for (var i=0; i<a.length && del === false; i++) {
-			if (gA.get(a[i]).color == color) {
-				gA.del(a[i]);
-				del = true;
-			}
-		}
-	};
-
-	/**
-	 * adds a {@link MultiGeometry} object to the geometry Array
-	 *
-	 * @param {MultiGeometry} m a MultiGeometry
-	 * @param {String} color the color of the highlight
-	 */	
-	this.add = function(m, color) {
-
-		if (m.name == nameMultiGeometry) {
-			gA.addCopy(m);
-		}
-		else if (m.name == nameGeometry) {
-			var newMultiGeom = new MultiGeometry(m.geomType);
-			newMultiGeom.add(m);
-			gA.addCopy(newMultiGeom);
-		}
-		if (typeof(color) != 'undefined') {gA.get(-1).color = color;} 
-		else {gA.get(-1).color = lineColor;}
-	};
-	
-	this.hide = function () {
-		for (var i=0; i < canvas.length; i++) {
-			if (typeof(canvas[i]) == "object") {canvas[i].clean();}
-		}
-	};
-
-	/**
-	 * removes all MultiGeometries.
-	 *
-	 */	
-	this.clean = function() {
-		if (gA.count() > 0) {
-			gA = new GeometryArray();
-			this.paint();
-		}
-	};
-
-	/**
-	 * displays the highlight
-	 *
-	 */	
-	this.paint = function() {
-		this.hide();
-		for (var i=0; i < canvas.length; i++) {
-			if (typeof(canvas[i]) == "object") {canvas[i].clean();}
-		}
-		for (var i=0; i<targets.length; i++){
-			if (typeof(canvas[i]) == 'undefined') {
-				canvas[i] = new Canvas(targets[i], tagname + i, style, lineWidth);
-			}
-			canvas[i].paint(gA);
-		}
-	};
-
-	this.setDiameter = function (radius) {
-		for (var i = 0; i < targets.length; i++) {
-			if (typeof(canvas[i]) != "undefined") {
-				canvas[i].setDiameter(radius);
-			}
-		}
-	}
-
-	this.setMouseOver = function (callback) {
-		for (var i=0; i<targets.length; i++){
-			if (typeof(canvas[i]) !== 'undefined') {
-				canvas[i].canvasDivTag.getTag().onmouseover = function (e) {
-					callback(e);
-				};
-			}
-		}
-	};
-	
-	this.setMouseOut = function (callback) {
-		for (var i=0; i<targets.length; i++){
-			if (typeof(canvas[i]) !== 'undefined') {
-				canvas[i].canvasDivTag.getTag().onmouseout = function (e) {
-					callback(e);
-				};
-			}
-		}
-	};
-	
-	this.setMouseClick = function (callback) {
-		for (var i=0; i<targets.length; i++){
-			if (typeof(canvas[i]) !== 'undefined') {
-				canvas[i].canvasDivTag.getTag().onclick = function (e) {
-					callback(e);
-				};
-			}
-		}
-	};
-	
-	var lineWidth = aLineWidth;
-	var tagname = 'mod_gaz_draw'+aTagName;
-	var style = aStyle;
-	var targets = aTargetArray; 
-	var canvas = []; 
-	var gA = new GeometryArray(); 
-	var lineColor = "#ff0000";
-	this.paint();
-}
-
-// ----------------------------------------------------------------------------------------------------
-// Snapping
-// ----------------------------------------------------------------------------------------------------
-/**
- * @class a {@link Snapping} object stores is {@link jsGraphics} rendering of a {@link GeometryArray} in various mapframes.
- *
- * @constructor
- * @requires GeometryArray
- * @requires Highlight
- * @param {String} aTarget name of the mapframe where snapping occurs
- * @param {String} aTolerance Snapping is activated if the mouse is 
- *                 within aTolerance pixel distance to the reference point.
- * @param {String} aColor apparently deprecated?
- * @param {Integer} aZIndex the z-Index of the {@link jsGraphics} generated by {@link Highlight}.
- */
-function Snapping(aTarget, aTolerance, aColor, aZIndex){
-
-	/**
-	 * draws a circle to highlight the snapped point.
-	 * 
-	 * @param {Point} center the snapped point.
-	 * @param {Integer} radius radius of the circular highlight.
-	 */
-	this.draw = function(center,radius){ 
-		mG = new MultiGeometry(geomType.point);
-		mG.addGeometry();
-		mG.get(-1).addPoint(center);
-		highlight.add(mG,snappingColor);
-		highlight.paint();
-	};
-	this.getTolerance = function() {
-		return tolerance;
-	};
-	this.getTarget = function() {
-		return target;
-	};
-	this.cleanHighlight = function() {
-		return highlight.clean();
-	};
-	this.addPoint = function(aPoint) {
-		coord.push(aPoint);
-	};
-	this.getPointCount = function() {
-		return coord.length;
-	};
-	this.getPoint = function(i) {
-		return coord[i];
-	};
-	this.resetPoints = function() {
-		coord = [];
-	};
-	this.getNearestNeighbour = function(){
-		if (min_i != -1) {return this.getPoint(min_i);}
-		return false;
-	};
-	this.setIndexOfNearestNeighbour = function(i){
-		min_i = i;
-	};
-	this.resetIndexOfNearestNeighbour = function(){
-		min_i = -1;
-	};
-	
-	/**
-	 * @private
-	 */
-	var tolerance = (typeof(aTolerance) == 'undefined') ? 10 : aTolerance;
-
-	/**
-	 * @private
-	 */
-	var zIndex = (typeof(aZIndex) == 'undefined') ? 50 : aZIndex;
-
-	/**
-	 * @private
-	 */
-	var coord = []; 
-
-	/**
-	 * @private
-	 */
-	var min_i = -1;
-
-	/**
-	 * @private
-	 */
-	var target = aTarget;
-
-	/**
-	 * @private
-	 */
-	var snappingColor = aColor;
-	
-	/**
-	 * @private
-	 */
-	var lineWidth = 2;
-
-	/**
-	 * @private
-	 */
-	var style = {"position":"absolute", "top":"0px", "left":"0px", "z-index":zIndex};
-
-	/**
-	 * @private
-	 */
-	var highlight = new Highlight([target], "snapping"+Math.round(Math.random()*Math.pow(10,10)), style, lineWidth);
-}
-
-Snapping.prototype.check = function(currPoint){
-	var minDist = false;
-	
-	for (var i = 0 ; i < this.getPointCount() ; i++) {
-
-		var currDist = currPoint.dist(realToMap(this.getTarget(), this.getPoint(i)));
-		if (minDist === false || currDist < minDist) {
-			minDist = currDist;
-			if (minDist < this.getTolerance()) {this.setIndexOfNearestNeighbour(i);}
-		}
-	}
-	if (this.getPointCount() > 0 && minDist > this.getTolerance()) {
-		this.resetIndexOfNearestNeighbour();
-	}
-	this.cleanHighlight();
-	if (this.isSnapped()) {
-		this.draw(this.getNearestNeighbour(), this.getTolerance());
-	}
-};
-
-/**
- * Stores the points which will have the snapping property. 
- * 
- * @param {GeometryArray} geom all points of geom will be stored. May also be a 
- *                             {@link MultiGeometry} or {@link Geometry}.
- * @param {Point} point this point is excluded. Useful when moving a point of a 
- *                      geometry; you don't want to snap against the point you
- *                      move. Optional.
- */
-Snapping.prototype.store = function(geom, point){
-	this.resetPoints();
-	this.resetIndexOfNearestNeighbour();
-
-	for (var i = 0 ; i < geom.count(); i++){
-		if (geom.name == nameGeometryArray || geom.name == nameMultiGeometry){
-			for (var j = 0 ; j < geom.get(i).count() ; j++){
-				if (geom.get(i).name == nameMultiGeometry){
-					// inner rings
-					if (geom.get(i).get(j).geomType == geomType.polygon && geom.get(i).get(j).innerRings && geom.get(i).get(j).innerRings.count() > 0) {
-						for (var l = 0; l < geom.get(i).get(j).innerRings.count(); l++) {
-							var currentRing = geom.get(i).get(j).innerRings.get(l);
-							for (var k = 0 ; k < currentRing.count() ; k++){
-								if ((currentRing.isComplete() === true && typeof(point) == 'undefined') || (typeof(point) != 'undefined' && !currentRing.get(k).equals(point))){
-									this.add(currentRing.get(k));
-								}
-							}
-							
-						}
-					}
-					// lines, points, outer rings
-					for (var k = 0 ; k < geom.get(i).get(j).count() ; k++){
-						if ((geom.get(i).get(j).isComplete() === true && typeof(point) == 'undefined') || (typeof(point) != 'undefined' && !geom.get(i).get(j).get(k).equals(point))){
-							this.add(geom.getPoint(i, j, k));
-						}
-					}
-				}
-				else {
-					if ((geom.get(i).isComplete() === true && typeof(point) == 'undefined') || (typeof(point) != 'undefined' && !geom.get(i).get(j).get(k).equals(point))){
-						this.add(geom.getPoint(i, j));
-					}
-				}
-			}
-		}
-		else {
-			if (typeof(point) != 'undefined' && !geom.get(i).get(j).get(k).equals(point)){
-				this.add(geom.get(i));
-			}
-		}
-	}
-};
-
-/**
- * Determines whether a point is within snapping distance to the mouse cursor
- * 
- * @return true if a point is within snapping distance; else false
- * @type Boolean
- */
-Snapping.prototype.isSnapped = function(){ 
-	if (this.getNearestNeighbour() !== false) {return true;}
-	return false;
-};
-
-/**
- * Returns the point that is within snapping distance and closest to the mouse cursor.
- * 
- * @return the point (if there is any); else false
- * @type Point
- */
-Snapping.prototype.getSnappedPoint = function(){
-	return this.getNearestNeighbour();
-};
-
-/**
- * Adds the point to the stored points with snapping property.
- * 
- * @param {Point} point which receives snapping property.
- */
-Snapping.prototype.add = function(aPoint){ 
-	this.addPoint(aPoint);
-};
-
-/**
- * Removes the highlight.
- */
-Snapping.prototype.clean = function(){
-	this.cleanHighlight();
-};
-
-
-
-// ----------------------------------------------------------------------------------------------------
-// misc. functions
-// ----------------------------------------------------------------------------------------------------
-
-/**
- * @ignore
- */
-function calculateVisibleDash (p0, p1, width, height) {
-	if (p0.x > p1.x) {var p_temp = p0; p0 = p1; p1 = p_temp; p_temp = null;}
-	var p = p0; var q = p1; var m; var ix; var iy;
-	if (p1.x != p0.x) {
-		m = -(p1.y-p0.y)/(p1.x-p0.x); 
-		if (p0.x < width && p1.x > 0 && !(p0.y < 0 && p1.y < 0) && !(p0.y > height && p1.y > height) ) {
-			if (p0.x < 0) {
-				iy = p0.y - m*(0-p0.x);
-				if (iy > 0 && iy < height) {p = new Point(0, iy);}
-				else if (iy > height) {
-				    ix = p0.x+((p0.y - height)/m);
-				    if (ix > 0 && ix < width) {p = new Point(ix, height);} else {return false;}
-				}
-				else if (iy < 0) {
-				    ix = p0.x+(p0.y/m);
-				    if (ix > 0 && ix < width) {p = new Point(ix, 0);} else {return false;}
-				}
-				else {return false;}
-			}
-			else if (p0.y >= 0 && p0.y <= height) {p = p0;}
-			else if (p0.y < 0) {
-			    ix = p0.x+(p0.y/m);
-			    if (ix > 0 && ix < width) {p = new Point(ix, 0);} else {return false;}
-			}
-			else if (p0.y > height && m > 0) {
-			    ix = p0.x+((p0.y - height)/m);
-			    if (ix > 0 && ix < width) {p = new Point(ix, height);} else {return false;}
-			}
-			else {return false;}
-			if (p1.x > width) {
-				iy = p1.y - m*(width-p1.x);
-				if (iy > 0 && iy < height) {q = new Point(width, iy);}
-				else if (iy < 0) {
-				    ix = p0.x+(p0.y/m);
-				    if (ix > 0 && ix < width) {q = new Point(ix, 0);} else {return false;}
-				}
-				else if (iy > height) {
-				    ix = p0.x+((p0.y - height)/m);
-				    if (ix > 0 && ix < width) {q = new Point(ix, height);} else {return false;}
-				}
-				else {return false;}
-			}
-			else if (p1.y >= 0 && p1.y <= height) {q = p1;}
-			else if (p1.y < 0) {
-			    ix = p1.x+(p1.y/m);
-			    if (ix > 0 && ix < width) {q = new Point(ix, 0);} else {return false;}
-			}
-			else if (p1.y > height) {
-			    ix = p1.x+((p1.y- height)/m);
-			    if (ix > 0 && ix < width) {q = new Point(ix, height);} else {return false;}
-			}
-		}
-		else {return false;}
-	}
-	else {
-		if (!(p0.y < 0 && p1.y < 0) && !(p0.y > height && p1.y > height)) {
-			if (p0.y < 0) {p = new Point(p0.x, 0);}
-			else if (p0.y > height) {p = new Point(p0.x, height);}
-			else {p = p0;}
-			if (p1.y < 0) {q = new Point(p0.x, 0);}
-			else if (p1.y > height) {q = new Point(p0.x, height);}
-			else {q = p1;}
-		}
-		else {return false;}
-	}
-	return [new Point(Math.round(q.x), Math.round(q.y)), new Point(Math.round(p.x), Math.round(p.y))];
-}
-
-/**
- * @ignore
- */
-function objString (a){
-	var z = "";
-	
-	for (attr in a) {
-		var b = a[attr];
-		if (typeof(b) == "object") {z += objString(b);}
-		else {z += attr + " " + b + "\n";}
-	}	
-	return z;
-}
+/* 
+* $Id$
+* 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. 
+*/
+// http://www.mapbender.org/index.php/GeometryArray.js
+
+
+var nameGeometryArray = "GeometryArray";
+var nameMultiGeometry = "MultiGeometry";
+var nameGeometry = "Geometry";
+
+/**
+ * @class A class representing geometry types "polygon", "line" and "point".
+ *
+ * @constructor
+ */
+function GeomType(){
+	/**
+	 * An identifier for polygons. If you want to check if a {@link MultiGeometry}
+	 * or {@link Geometry} is a polygon, write
+	 * if (someGeometry.geomType == geomType.polygon
+	 * 
+	 * @type String
+	 */
+	this.polygon = "polygon";
+
+	/**
+	 * An identifier for polygons. If you want to check if a {@link MultiGeometry}
+	 * or {@link Geometry} is a line, write
+	 * if (someGeometry.geomType == geomType.line
+	 * 
+	 * @type String
+	 */
+	this.line = "line";
+
+	/**
+	 * An identifier for polygons. If you want to check if a {@link MultiGeometry}
+	 * or {@link Geometry} is a point, write
+	 * if (someGeometry.geomType == geomType.point
+	 * 
+	 * @type String
+	 */
+	this.point = "point";
+}
+var geomType = new GeomType();
+
+
+/**
+ * @class a {@link GeometryArray} is a {@link List} of {@link MultiGeometry} objects
+ *
+ * @ extends List
+ * @ requires MultiGeometry 
+ * @ requires Geometry
+ * @ requires Point
+ * @ constructor
+ */
+function GeometryArray(){
+
+	/*
+	 * creates a new, empty Multigeometry and adds it to this GeometryArray
+	 *
+	 * @param {String} geomType a {@link GeomType}
+	 */
+	this.addMember = function(geomType){
+		this.add(new MultiGeometry(geomType));
+	};
+	
+	/**
+	 * @ignore
+	 */
+	this.name = nameGeometryArray;
+	
+	/**
+	 * A {@link List} of {@link MultiGeometry} objects.
+	 * 
+	 * @type List
+	 */
+	this.list = [];
+}
+
+GeometryArray.prototype = new List();
+	
+/**
+ * gets the j-th {@link Geometry} object of the i-th {@link MultiGeometry} object
+ *
+ * @param {Integer} i index of the MultiGeometry
+ * @param {Integer} j index of the Geometry
+ * @type Geometry 
+ */
+GeometryArray.prototype.getGeometry = function(i,j){
+	var tmp = this.get(i);
+	return tmp.get(j);
+};
+
+/**
+ * gets the k-th Point of the j-th {@link Geometry} object of the i-th {@link MultiGeometry} object
+ *
+ * @param {Integer} i index of the MultiGeometry
+ * @param {Integer} j index of the Geometry
+ * @param {Integer} k index of the Point
+ * @type Point
+ * @returns the Point object at the given indices
+ */
+GeometryArray.prototype.getPoint = function(i, j, k, l){
+	if (l == undefined) {
+		return this.get(i).get(j).get(k);
+	}
+	return this.get(i).get(j).innerRings.get(k).get(l);
+};
+
+/**
+ * gets an Array of indices; the {@link MultiGeometry} objects at these indices are equal to geom
+ *
+ * @type Integer[]
+ * @param {MultiGeometry} geom 
+ * @returns an Array of indices
+ */
+GeometryArray.prototype.findMultiGeometry = function(geom) {
+	var a = [];
+	for (var i=0; i < this.count(); i++) {
+		if (this.get(i).equals(geom)) {a.push(i);}
+	}
+	return a;
+};
+	
+/**
+ * deletes the j-th {@link Geometry} object of the i-th {@link MultiGeometry} object
+ *
+ * @param {Integer} i index of the MultiGeometry
+ * @param {Integer} j index of the Geometry
+ */
+GeometryArray.prototype.delGeometry = function(i,j){
+	if (this.get(i).del(j) === false) {
+		this.del(i);
+	}
+};
+	
+/**
+ * deletes the k-th {@link Point} of the j-th {@link Geometry} object of the i-th {@link MultiGeometry} object
+ *
+ * @param {Integer} i index of the MultiGeometry
+ * @param {Integer} j index of the Geometry
+ * @param {Integer} k index of the Point
+ */
+GeometryArray.prototype.delPoint = function (i, j, k, l) {
+	var res = this.get(i).delPoint(j, k, l);
+	if (res === false) {
+		this.del(i);
+	}
+};
+	
+/**
+ * closes the current {@link MultiGeometry}. Calls method close of the {@link Geometry} class.
+ *
+ */
+GeometryArray.prototype.close = function(){
+	if (!this.get(-1).get(-1).close()) {
+		this.delGeometry(-1, -1);
+	}
+	else {
+		if (this.get(-1).get(-1).count() === 0) {
+			this.get(-1).del(-1);
+		}
+		if (this.get(-1).count() === 0) {
+			this.del(-1);
+		}
+	}
+	
+};
+
+/**
+ * deletes all {@link Point} objects of this {@link GeometryArray} that equal point
+ *
+ * @param {Point} point
+ */
+GeometryArray.prototype.delAllPointsLike = function(point){
+	var finished = false;
+	while (finished === false){
+		finished = true;
+		for (var i = 0 ; finished === true && i < this.count() ; i++){
+			for (var j = 0 ; finished === true && j < this.get(i).count() ; j++){
+
+				var currentGeometry = this.get(i).get(j);
+				if (currentGeometry.geomType == geomType.polygon && currentGeometry.innerRings) {
+					for (var k = 0; finished === true && k < currentGeometry.innerRings.count(); k++) {
+						for (var l = 0; finished === true && l < currentGeometry.innerRings.get(k).count(); l++) {
+							if (this.getPoint(i, j, k, l).equals(point)) {
+								this.delPoint(i, j, k, l);
+								finished = false;
+							}
+						}
+					}
+				}
+				if (!finished) {
+					break;
+				}
+
+				for (var k = 0 ; finished === true && k < this.get(i).get(j).count() ; k++){
+					if (this.getPoint(i,j,k).equals(point)){
+						this.delPoint(i,j,k);
+						finished = false;
+					}
+				}
+			} 
+		}
+	}
+};
+	
+/**
+ * updates all {@link Point} objects of this {@link GeometryArray} that equal oldP to newP
+ *
+ * @param {Point} oldP
+ * @param {Point} newP
+ */
+GeometryArray.prototype.updateAllPointsLike = function(oldP, newP){
+	for (var i = 0; i < this.count(); i++){
+		this.get(i).updateAllPointsLike(oldP, newP);
+	}
+};
+
+GeometryArray.prototype.placemarkToString = function (placemarkId) {
+	var str = "{\"type\": \"Feature\", \"geometry\": ";
+
+	// get geometries with placemarkId
+	var geometriesFromPlacemark = [];
+	for (var i = 0, len = this.count(); i < len; i++) {
+		if (this.get(i).isFromKml() && this.get(i).e.getElementValueByName("Mapbender:placemarkId") == placemarkId) {
+			geometriesFromPlacemark.push(i);
+		}
+	}	
+
+	if (geometriesFromPlacemark.length > 1) {
+		str += "{\"type\": \"GeometryCollection\", \"geometries\": [";
+		for (var i = 0; i < geometriesFromPlacemark.length; i++) {
+			if (i > 0) {
+				str += ",";
+			}	
+			str += this.get(geometriesFromPlacemark[i]).placemarkToString();
+		}
+		str += "]}";
+
+		// metadata is the same for all indices...get from index 0
+		var propString = this.get(geometriesFromPlacemark[0]).e.toString();
+		if (propString) {
+			str += "," + propString;
+		}
+	}
+	else if (geometriesFromPlacemark.length === 1) {
+		str += this.get(geometriesFromPlacemark[0]).placemarkToString();
+	}
+
+	str += "}";
+	return str;
+};
+
+GeometryArray.prototype.getBBox = function(){
+	var q = this.get(0).get(0).get(0);
+	var min = cloneObject(q);
+	var max = cloneObject(q);
+	for(var i=0; i < this.count();i++){
+		var pos = this.get(i).getBBox();
+		if (pos[0].x < min.x) {min.x = pos[0].x;}
+		if (pos[1].x > max.x) {max.x = pos[1].x;}
+		if (pos[1].y > max.y) {max.y = pos[1].y;}
+		if (pos[0].y < min.y) {min.y = pos[0].y;}
+	}
+	return [min, max];
+};
+
+GeometryArray.prototype.importGeometryFromText = function (text, srs) {
+
+	var tmpArray = text.split("(");
+	var geometryType = tmpArray[0];
+
+	switch (geometryType) {
+		case "MULTIPOLYGON":
+			var text = text.replace(/\)/g, "");
+			var sepArray = text.split("(((");
+			var polyArray = sepArray[1].split(",((");
+			
+			this.addMember(geomType.polygon);
+			for (var i = 0; i < polyArray.length; i++) {
+				var ringArray = polyArray[i].split(",(");
+				for (var j = 0; j < ringArray.length; j++) {
+					var coordinatesArray = ringArray[j].split(",");
+					if (j === 0) {
+						// add outer ring
+						this.get(-1).addGeometry();
+						for (var m = 0; m < -1 + coordinatesArray.length; m++) {
+							var currentPoint = coordinatesArray[m].split(" ");
+							this.getGeometry(-1, -1).addPointByCoordinates(parseFloat(currentPoint[0]), parseFloat(currentPoint[1]));
+							this.getGeometry(-1,-1).setEpsg(srs);
+						}
+						this.close();
+					}		
+					else {
+						// add inner ring
+						var ring = new Geometry(geomType.polygon);
+						for (var m = 0; m < -1 + coordinatesArray.length; m++) {
+							var currentPoint = coordinatesArray[m].split(" ");
+							ring.addPointByCoordinates(parseFloat(currentPoint[0]), parseFloat(currentPoint[1]));
+						}
+						ring.close();
+						this.getGeometry(-1,-1).addInnerRing(ring);				
+						this.getGeometry(-1,-1).setEpsg(srs);
+					}
+				}
+			}
+			break;
+	}
+};
+
+GeometryArray.prototype.importGeoJSON = function (geoJSON) {
+	// you can pass either geoJSON or the evaluated geoJSON string
+	// for backwards compatibility
+	if (typeof(geoJSON) == 'string') {
+		var geoJSON = eval('(' + geoJSON + ')');
+	}
+
+	//
+	// FEATURE COLLECTION
+	//
+	var isFeatureCollection = (geoJSON.type == "FeatureCollection") ? true : false;
+	if (isFeatureCollection) {
+		//
+		// FEATURE
+		//
+		var featureArray = geoJSON.features;
+		for (var j = 0; j < featureArray.length; j++) {
+			var currentFeature = featureArray[j];
+			var isFeature = (currentFeature.type == "Feature") ? true : false;
+	
+			// add geometry ...
+			if (currentFeature.geometry && isFeature) {
+				var featureEpsg = "EPSG:4326";
+				if (!currentFeature.crs || currentFeature.crs.type !== "name" || !currentFeature.crs.properties.name) {
+					var e = new Mb_warning("SRS not set or unknown in GeoJSON. Using 'EPSG:4326'.");
+				}
+				else {
+					featureEpsg = currentFeature.crs.properties.name;
+				}
+
+				//
+				// GEOMETRY
+				//
+				var currentGeometry = currentFeature.geometry;
+				var geometrytype = currentGeometry.type;
+				var coordinates = currentGeometry.coordinates;
+				switch (geometrytype) {
+					case "Point":
+						//
+						// POINT
+						//
+						this.addMember(geomType.point);
+						
+						this.get(-1).addGeometry();
+						this.getGeometry(-1,-1).addPointByCoordinates(coordinates[0], coordinates[1], coordinates[2]);
+						this.getGeometry(-1,-1).setEpsg(featureEpsg);
+						this.close();
+						break;
+					
+					case "LineString":
+						//
+						// LINESTRING
+						//
+						this.addMember(geomType.line);
+						this.get(-1).addGeometry();
+						for (var m = 0; m < coordinates.length; m++) {
+							var currentPoint = coordinates[m];
+							this.getGeometry(-1,-1).addPointByCoordinates(currentPoint[0], currentPoint[1], currentPoint[2]);
+						}
+						this.getGeometry(-1,-1).setEpsg(featureEpsg);
+						this.close();
+						break;
+						
+					case "MultiLineString":
+						//
+						// MULTILINESTRING
+						//
+						this.addMember(geomType.line);
+						for (var m = 0; m < coordinates.length; m++) {
+							this.get(-1).addGeometry();
+							var currentLine = coordinates[m];
+							for (var n = 0; n < currentLine.length; n++) {
+								var currentPoint = currentLine[n];
+								this.getGeometry(-1,-1).addPointByCoordinates(currentPoint[0], currentPoint[1], currentPoint[2]);
+							}
+							this.getGeometry(-1,-1).setEpsg(featureEpsg);
+						}
+						this.close();
+						break;
+					
+					case "Polygon":
+						//
+						// POLYGON
+						//
+						this.addMember(geomType.polygon);
+						for (var m = 0; m < coordinates.length; m++) {
+							this.get(-1).addGeometry();
+							var currentPolygon = coordinates[m];
+							for (var n = 0; n < currentPolygon.length; n++) {
+								var currentPoint = currentPolygon[n];
+								this.getGeometry(-1,-1).addPointByCoordinates(currentPoint[0], currentPoint[1], currentPoint[2]);
+							}
+							this.getGeometry(-1,-1).setEpsg(featureEpsg);
+						}
+						this.close();
+						break;
+						
+					case "MultiPolygon":
+						//
+						// MULTIPOLYGON
+						//
+						this.addMember(geomType.polygon);
+						for (var m = 0; m < coordinates.length; m++) {
+							this.get(-1).addGeometry();
+							var currentPolygon = coordinates[m];
+							for (var n = 0; n < currentPolygon.length; n++) {
+								var currentRing = currentPolygon[n];
+								if (n == 0) {
+									for (var p = 0; p < currentRing.length; p++) {
+										var currentPoint = currentRing[p];
+										this.getGeometry(-1, -1).addPointByCoordinates(currentPoint[0], currentPoint[1], currentPoint[2]);
+									}
+								}
+								else {
+									var ring = new Geometry(geomType.polygon);
+									for (var p = 0; p < currentRing.length; p++) {
+										var currentPoint = currentRing[p];
+										ring.addPointByCoordinates(currentPoint[0], currentPoint[1], currentPoint[2]);
+									}
+									ring.close();
+									this.getGeometry(-1,-1).addInnerRing(ring);				
+								}
+							}
+							this.getGeometry(-1,-1).setEpsg(featureEpsg);
+						}
+						this.close();
+						break;
+	
+					case "GeometryCollection":
+						var exc = new Mb_exception("Geometry: GeometryCollections are not yet supported");
+						break;
+				}
+			}
+			
+			if (currentFeature.properties) {
+				var properties = currentFeature.properties;
+				// GeometryCollections are NOT YET IMPLEMENTED
+				if (geometrytype != "GeometryCollection") {
+					for (var l in properties) {
+						if (typeof(properties[l]) != "function") {
+							this.get(-1).e.setElement(l, properties[l]);
+						}
+					}
+					this.get(-1).e.setElement("fid", currentFeature.id);
+				}
+			}
+		}
+	}
+	return true;
+}
+
+GeometryArray.prototype.featureToString = function (i) {
+	var str = "{\"type\": \"FeatureCollection\", \"features\": [";
+	str += this.get(i).toString();
+	str += "]}";
+	return str;
+};
+
+
+GeometryArray.prototype.toString = function () {
+	var str = "{\"type\": \"FeatureCollection\", \"features\": [";
+
+	// separate: geometries that are from a KML and those which are not
+	var multiGeometriesFromKml = [];
+	var multiGeometriesNotFromKml = [];
+	for (var i = 0, len = this.count(); i < len; i++) {
+		if (this.get(i).isFromKml()) {
+			var placemarkId = this.get(i).e.getElementValueByName("Mapbender:placemarkId");
+
+			// only add placemark ids once!
+			var isFound = false;
+			for (var j = 0; j < multiGeometriesFromKml && isFound === false; j++) {
+				if (multiGeometriesFromKml == placemarkId) {
+					isFound = true;
+				}
+			}
+			if (!isFound) {
+				multiGeometriesFromKml.push(placemarkId);
+			}
+		}
+		else {
+			multiGeometriesNotFromKml.push(i);
+		}
+	}
+
+	// add geometries not from KML
+	for (var i = 0, len = multiGeometriesNotFromKml.length; i < len; i++) {
+		if (i > 0) {
+			str += ",";
+		}		
+		str += this.get(multiGeometriesNotFromKml[i]).toString();
+	}
+	
+	// add geometries from KML
+	if (multiGeometriesNotFromKml.length > 0 && multiGeometriesFromKml.length > 0) {
+		str += ",";
+	}
+
+	for (var i=0; i < multiGeometriesFromKml.length; i++) {
+		if (i > 0) {
+			str += ",";
+		}	
+		str += this.placemarkToString();
+	}
+
+	str += "]}";
+	return str;
+};
+	
+/**
+ * @class a MultiGeometry is a List of Geometry objects
+ *
+ * @ extends List
+ * @ requires Geometry
+ * @ requires Point
+ * @ constructor
+ * @ param {String} geomType a geomType
+ */
+function MultiGeometry(geomType){
+
+	/*
+	 * creates a new, empty {@link Geometry} object and adds it to this {@link MultiGeometry}
+	 *
+	 */
+	this.addGeometry = function(){
+		this.add(new Geometry(this.geomType));
+	};
+	
+	/**
+	 * deletes the {@link Geometry} object at index i; -1 refers to the last {@link Geometry object in the list
+	 * overwrites the del function of {@link List}.
+	 *
+	 * @param {Integer} i index
+	 */
+	this.del = function(i){
+		i = this.getIndex(i);
+		if (i !== false){
+			var tmpLength = this.count() - 1;
+			for (var z = i; z < tmpLength ; z ++){
+				this.list[z] = this.list[z+1];
+			}
+			this.list.length -= 1;
+			if (this.list.length === 0) {return false;}
+		}
+		return true;
+	};
+
+	this.list = [];
+	this.e = new Wfs_element();
+	this.geomType = geomType;
+	this.name = nameMultiGeometry;
+}
+
+MultiGeometry.prototype = new List();
+
+/**
+ * updates all {@link Point} objects of this {@link MultiGeometry} that equal oldP to newP
+ *
+ * @param {Point} oldP
+ * @param {Point} newP
+ */
+MultiGeometry.prototype.updateAllPointsLike = function(oldP, newP){
+	for (var i = 0; i < this.count(); i++) {
+		this.get(i).updateAllPointsLike(oldP, newP);
+	}
+};
+
+/**
+ * gets the bounding box of this {@link MultiGeometry} as an Array of 2 points
+ *
+ * @return the bounding box
+ * @type Array of two Point objects
+ */
+MultiGeometry.prototype.getBBox = function(){
+	var q = this.get(0).get(0);
+	var min = cloneObject(q);
+	var max = cloneObject(q);
+	for(var i=0; i<this.count();i++){
+		var pos = this.get(i).getBBox();
+		if (pos[0].x < min.x) {min.x = pos[0].x;}
+		if (pos[1].x > max.x) {max.x = pos[1].x;}
+		if (pos[1].y > max.y) {max.y = pos[1].y;}
+		if (pos[0].y < min.y) {min.y = pos[0].y;}
+	}
+	return [min, max];
+};
+
+/**
+ * gets the bounding box of this {@link MultiGeometry} as a polygon of four points
+ *  
+ * @return the bounding box
+ * @type MultiGeometry
+ */
+MultiGeometry.prototype.getBBox4 = function() {
+	var bbox = this.getBBox();
+	var realBox = new MultiGeometry(geomType.polygon);
+	realBox.addGeometry(geomType.polygon);
+	realBox.get(-1).addPointByCoordinates(bbox[0].x, bbox[0].y);
+	realBox.get(-1).addPointByCoordinates(bbox[0].x, bbox[1].y);
+	realBox.get(-1).addPointByCoordinates(bbox[1].x, bbox[1].y);
+	realBox.get(-1).addPointByCoordinates(bbox[1].x, bbox[0].y);
+	realBox.get(-1).close();
+	return realBox;
+};
+
+/**
+ * gets the center of the bounding box of this {@link MultiGeometry}.
+ *
+ * @return the center of the bounding box
+ * @type Point
+ */
+MultiGeometry.prototype.getCenter = function(){
+	var tmp = this.getBBox();
+	var x = parseFloat(tmp[0].x) + parseFloat((tmp[1].x - tmp[0].x)/2);
+	var y = parseFloat(tmp[0].y) + parseFloat((tmp[1].y - tmp[0].y)/2);
+	return new Point(x,y);
+};
+
+/**
+ * gets the total number of {@link Point} objects of this {@link MultiGeometry}.
+ *
+ * @return number of points
+ * @type Integer
+ */
+MultiGeometry.prototype.getTotalPointCount = function(){ 
+	var c = 0;
+	for (var i = 0 ; i < this.count(); i++)	{
+		c += this.get(i).count();
+	}
+	return c;
+};
+
+/**
+ * gets the total number of {@link Point} objects of this {@link MultiGeometry}.
+ *
+ * @return number of points
+ * @type Integer
+ */
+MultiGeometry.prototype.getPoint = function(j,k){
+	return this.get(j).get(k);
+};
+
+/**
+ * compares this {@link MultiGeometry} object with the {@link MultiGeometry} object multigeom.
+ *
+ * @param {MultiGeometry} multigeom another multigeometry
+ * @return true if he multigeometries match; else false 
+ * @type Boolean
+ */
+MultiGeometry.prototype.equals = function(multigeom) {
+	if (this.geomType != multigeom.geomType) {return false;}
+	if (this.count() != multigeom.count()) {return false;}
+	if (this.getTotalPointCount() != multigeom.getTotalPointCount()) {return false;}
+	for (var i=0; i<this.count(); i++) {
+		if (!this.get(i).equals(multigeom.get(i))) {return false;}
+	}
+	return true;
+};
+
+/**
+ * deletes the j-th {@link Point} object of the i-th {@link Geometry} object of this {@link MultiGeometry} object.
+ *
+ * @param {Integer} i geometry index
+ * @param {Integer} j point index
+ * @return true if the deletion succeded; else false.
+ * @type Boolean
+ */
+MultiGeometry.prototype.delPoint = function(i, j, k){
+	var res;
+	if (k == undefined) {
+		res = this.get(i).del(j);
+		if (res === false) {
+			return this.del(i);
+		}
+	}
+	else {
+		res = this.get(i).innerRings.get(j).del(k);
+		if (res === false) {
+			this.get(i).innerRings.del(j);
+		}
+	}
+	return true;
+};
+
+MultiGeometry.prototype.isFromKml = function () {
+	if (this.e.getElementValueByName("Mapbender:kml")) {
+		return true;
+	}
+	return false;
+};
+
+MultiGeometry.prototype.toText = function () {
+	var text = "";
+	var numOfGeom = this.count();
+	if (numOfGeom >= 1) {
+		if (this.geomType == geomType.polygon) {
+			if (numOfGeom > 1) {
+				text += "MULTIPOLYGON (";
+				for (var i = 0; i < numOfGeom; i++) {
+					if (i > 0) {
+						text += ", ";
+					}
+					var currentPolygon = this.get(i);
+					text += "(" + currentPolygon.toText() + ")";
+				}
+				text += ")";
+			}
+			else {
+				text += "POLYGON (" + this.get(0).toText() + ")";
+			}
+		}
+		else if (this.geomType == geomType.line) {
+			text += "LINESTRING (";
+
+			var currentLine = this.get(0);
+			for (var j = 0; j < currentLine.count(); j++) {
+				if (j > 0) {
+					text += ", ";
+				}
+
+				var currentPoint = currentLine.get(j);
+				text += currentPoint.x + " " + currentPoint.y
+			}
+
+			text += ")";
+		}
+		
+	}
+	return text;		
+};
+
+MultiGeometry.prototype.toString = function () {
+	var str = this.toStringWithoutProperties();
+	
+	// properties
+	var propString = this.e.toString();
+	if (propString) {
+		str += "," + propString;
+	}
+
+	str += "}";
+	
+	return str;
+};
+
+MultiGeometry.prototype.placemarkToString = function () {
+	var str = "";
+	// geometries
+	for (var i = 0, len = this.count(); i < len; i++) {
+		if (i > 0) {
+			str += ",";
+		}		
+		str += this.get(i).toString();
+	}
+	return str;
+};
+
+MultiGeometry.prototype.toStringWithoutProperties = function () {
+	var str = "{\"type\": \"Feature\", ";
+
+	var epsg = this.getEpsg();
+	if (epsg) {
+		str += "\"crs\": {\"type\": \"name\", \"properties\": {\"name\": \"" + epsg + "\"}}, ";
+	}
+	str += "\"geometry\": {";
+
+	var len = this.count(); 
+	
+	switch (this.geomType) {
+		case geomType.polygon:
+			if (len > 1) {
+				str += "\"type\": \"MultiPolygon\", ";
+			}
+			else {
+				str += "\"type\": \"Polygon\", ";
+			}
+			break;
+		case geomType.line:
+			if (len > 1) {
+				str += "\"type\": \"MultiLineString\", ";
+			}
+			else {
+				str += "\"type\": \"LineString\", ";
+			}
+			break;
+		case geomType.point:
+			if (len > 1) {
+				str += "\"type\": \"MultiPoint\", ";
+			}
+			else {
+				str += "\"type\": \"Point\", ";
+			}
+			break;
+	}
+
+	str += "\"coordinates\": "
+	// geometries
+	if (len > 1) {
+		str += "[";
+		for (var i = 0; i < len; i++) {
+			if (i > 0) {
+				str += ",";
+			}		
+			str += this.get(i).toString();
+		}
+		str += "]";
+	}
+	else {
+		str += this.get(0).toString();
+	}
+
+	str += "}";
+
+// this closing curly bracket is added in toString()
+//	str += "}";
+	
+	return str;
+};
+
+/**
+ * @return the EPSG code of this geometry.
+ * @type integer
+ */
+MultiGeometry.prototype.getEpsg = function () {
+	if (this.count() > 0) {
+		return this.get(0).getEpsg();
+	}
+	return false;
+};
+
+
+function InnerRings () {
+	this.list = [];	
+};
+
+InnerRings.prototype = new List();
+
+/**
+ * @class a Geometry is a List of Point objects. If it is a polygon, the last point has 
+ * to equal the first point.
+ *
+ * @extends List
+ * @requires Point
+ * @constructor
+ * @param {String} a string representing a geometry type, see @see GeomType.
+ */
+function Geometry(aGeomtype){
+
+	/**
+	 * deletes the {@link Point} object at index i; -1 refers to the last 
+	 * {@link Point} object in the list. Overwrites the del function of 
+	 * {@link List}.
+	 *
+	 * @param {Integer} i index
+	 * @return false if deletion is not yet finished. It is cascaded to 
+	 *         {@link MultiGeometry}. True if the deletion is finished.
+	 */
+	this.del = function(i){
+		i = this.getIndex(i);
+		if (i !== false) {
+			var tmpLength = this.count()-1;
+			
+			for (var z = i; z < tmpLength ; z ++){
+				this.list[z] = this.list[z+1];
+			}
+			this.list.length -= 1;
+		
+			if (this.geomType == geomType.polygon){
+				if (i == tmpLength) {this.list[0] = this.list[tmpLength-1];}
+				else if (i === 0) {this.list[tmpLength-1] = this.list[0];}
+				if (this.list.length == 1){return false;}
+			}
+			updateDist();
+			if(this.list.length === 0) {return false;}
+			return true;
+		}
+		return false;
+	};
+
+	/**
+	 * adds a {@link Point} object to this {@link Geometry} object.
+	 *
+	 * @param {Float} x x value of the point
+	 * @param {Float} y y value of the point
+	 */	
+	this.addPointByCoordinates = function(x,y,z){
+		var newPoint = new Point(x,y,z);
+		this.add(newPoint);
+//		updateDist();
+	};
+
+	/**
+	 * adds a {@link Point} object to this {@link Geometry} object.
+	 *
+	 * @param {Point} aPoint another point
+	 */	
+	this.addPoint = function(aPoint){
+		this.add(new Point(aPoint.x, aPoint.y, aPoint.z));
+		updateDist();
+	};
+
+	/**
+	 * inserts a {@link Point} object at index i of this {@link Geometry} object.
+	 *
+	 * @param {Point} p another point
+	 * @param {Integer} i index
+	 */	
+	this.addPointAtIndex = function(p,i){
+		i = this.getIndex(i);
+		if (i !== false){
+			for(var z = this.count(); z > i; z--){
+				this.list[z] = this.list[z-1];
+			}
+			this.list[i] = new Point(p.x, p.y, p.z);
+			updateDist();
+		}
+	};
+	
+	/**
+	 * Overwrites the {@link Point) object at index i with the {@link Point} object p.
+	 *
+	 * @private
+	 * @param {Point} p another point
+	 * @param {Integer} i index
+	 */	
+	this.updatePointAtIndex = function(p, i){
+		i = this.getIndex(i);
+		if ((i === 0 || i == this.count()-1) && this.geomType == geomType.polygon){
+			this.list[0] = p;
+			this.list[this.count()-1] = p;
+		}
+		else {this.list[i] = p;}
+		updateDist();
+	};
+	
+	/**
+	 * Updates the {@link Geometry#dist} and {@link Geometry#totaldist}
+	 *
+	 * @private
+	 */	
+	var updateDist = function(){
+/*
+ * DISABLED BECAUSE IT IS TOO SLOW
+		dist[0] = 0;		
+		totaldist[0] = 0;		
+		for (var i = 1 ; i < that.count(); i++){
+			dist[i] = that.get(i-1).dist(that.get(i));
+			totaldist[i] = totaldist[i-1] + dist[i];
+		}
+*/
+	};
+	/**
+	 * gets the distance between the last and last but one point of this {@link Geometry}.
+	 *
+	 * @param {Integer} numberOfDigitis round to numberOfDigits (optional)
+	 * @return the distance
+	 * @type Float
+	 */	
+	this.getCurrentDist = function(numberOfDigits) {
+		if (typeof(numberOfDigits) == "number") {
+			return roundToDigits(dist[this.count()-1], numberOfDigits);
+		}
+		return dist[this.count()-1];
+		
+	};
+	/**
+	 * gets the length of the outer rim of this {@link Geometry}.
+	 *
+	 * @param {Integer} numberOfDigitis round to numberOfDigits (optional)
+	 * @return the distance
+	 * @type Float
+	 */	
+	this.getTotalDist = function(numberOfDigits) {
+		if (typeof(numberOfDigits) == "number") {
+			return roundToDigits(totaldist[this.count()-1], numberOfDigits);
+		}
+		return totaldist[this.count()-1];
+	};
+	/**
+	 * closes this {@link Geometry}. 
+	 *
+	 * @return true if the geometry could be closed; otherwise false
+	 * @type Boolean
+	 */	
+	this.close = function(){
+		complete = true;
+		if (this.geomType == geomType.polygon){
+			if (this.count() > 2){
+				if (!this.get(0).equals(this.get(-1))) {
+					this.addPoint(this.get(0));
+				}
+			}
+			else {return false;}
+		}
+		if (this.geomType == geomType.line){
+			if (this.count() < 2){return false;}
+		}
+		return true;
+	};
+	/**
+	 * checks if this {@link Geometry} has been closed. 
+	 *
+	 * @return true if the geometry is closed; otherwise false
+	 * @type Boolean
+	 */	
+	this.isComplete = function() { 
+		return complete;
+	};
+	
+	/**
+	 * Sets the EPSG of this geometry.
+	 * 
+	 * @param {Integer} someEpsg the EPSG of this geometry.
+	 * @return true if the EPSG could be set; else false
+	 * @type boolean
+	 */
+	this.setEpsg = function (someEpsg) {
+		// TODO: how to check if EPSG code is correct?
+		epsg = someEpsg;
+		return true;
+
+		var e = new Mb_exception("EPSG code not valid ("+someEpsg+")");
+		return false;
+	};
+	
+	/**
+	 * @return the EPSG code of this geometry.
+	 * @type integer
+	 */
+	this.getEpsg = function () {
+		return epsg;
+	};
+	
+	this.list = [];
+	var dist = [];
+	var totaldist = [];
+	var complete = false;
+
+	var epsg;
+
+	var that = this;
+
+	this.geomType = aGeomtype;
+	this.name = nameGeometry;
+
+	// add these members if the geometry is a polygon
+	if (this.geomType == geomType.polygon) {
+		this.innerRings = new InnerRings();
+		this.addInnerRing = function (somePolygon) {
+			this.innerRings.add(somePolygon);
+		};
+		this.delInnerRing = function (index) {
+			this.innerRings.del(index);
+		};
+	}
+}
+
+Geometry.prototype = new List();
+
+Geometry.prototype.toText = function () {
+	var text = "";
+	switch (this.geomType) {
+		case geomType.polygon:
+			text += "(";
+			for (var j = 0; j < this.count(); j++) {
+				if (j > 0) {
+					text += ", ";
+				}
+				var currentPoint = this.get(j);
+				text += currentPoint.x + " " + currentPoint.y
+			}
+			text += ")";
+			if (this.innerRings && this.innerRings.count() > 0) {
+				for (var k = 0; k < this.innerRings.count(); k++) {
+					text += ", ";
+					text += this.innerRings.get(k).toText();
+				}				
+			}
+			break;
+	}
+	return text;
+};
+/**
+ * gets the bounding box of this {@link Geometry}
+ *
+ * @return the bounding box (array of two Point objects)
+ * @type Point[]
+ */
+Geometry.prototype.getBBox = function(){
+	var q = this.get(0);
+	var min = cloneObject(q);
+	var max = cloneObject(q);
+	
+	for (var j=0; j<this.count(); j++){
+		var pos = this.get(j);
+		if (pos.x < min.x) {min.x = pos.x;}
+		else if (pos.x > max.x) {max.x = pos.x;}
+		if (pos.y < min.y) {min.y = pos.y;}
+		else if (pos.y > max.y) {max.y = pos.y;}
+	}
+	if (this.geomType == geomType.polygon) {
+		for (var i = 0; i < this.innerRings.count(); i++) {
+			var currentRing = this.innerRings.get(i);
+			for (var j=0; j<currentRing.count(); j++){
+				var pos = currentRing.get(j);
+				if (pos.x < min.x) {min.x = pos.x;}
+				else if (pos.x > max.x) {max.x = pos.x;}
+				if (pos.y < min.y) {min.y = pos.y;}
+				else if (pos.y > max.y) {max.y = pos.y;}
+			}
+		}
+	}
+	
+	return [min, max];
+};
+
+/**
+ * updates all {@link Point} objects of this {@link Geometry} that equal oldP to newP
+ *
+ * @param {Point} oldP
+ * @param {Point} newP
+ */
+Geometry.prototype.updateAllPointsLike = function(oldP, newP){
+	var len = this.count();
+	for (var i = 0; i < len ; i++){
+		if (oldP.equals(this.get(i))){
+			if (i>0 && newP.equals(this.get(i-1))){
+				this.del(i);
+				len--;
+				i--;
+			}
+			else {this.updatePointAtIndex(newP, i);}
+		}
+	}
+	if (this.geomType == geomType.polygon) {
+		for (var j = 0; j < this.innerRings.count(); j++) {
+			var len = this.innerRings.get(j).count();
+			for (var i = 0; i < len ; i++){
+				if (oldP.equals(this.innerRings.get(j).get(i))){
+					if (i>0 && newP.equals(this.innerRings.get(j).get(i-1))){
+						this.innerRings.get(j).del(i);
+						len--;
+						i--;
+					}
+					else {this.innerRings.get(j).updatePointAtIndex(newP, i);}
+				}
+			}
+			
+		}
+	}
+};
+
+/**
+ * compares this {@link Geometry} object with the {@link Geometry} object geom point by point.
+ *
+ * @param {Geometry} geom another geometry
+ * @return true if he geometries match; else false 
+ * @type Boolean
+ */
+Geometry.prototype.equals = function(geom) {
+	if (this.geomType != geom.geomType) {return false;}
+	if (this.count() != geom.count()) {return false;}
+	for (var i=0; i < this.count(); i++) {
+		if (!this.get(i).equals(geom.get(i))) {return false;}
+	}
+	if (!this.innerRings && !geom.innerRings) {
+		// no inner rings; fine
+	}
+	else if (this.innerRings && geom.innerRings) {
+		if (this.innerRings.count() != geom.innerRings.count()) {
+			return false;
+		}
+		for (var j = 0; j < this.innerRings.count(); j++) {
+			if (!this.innerRings.get(j).equals(geom.innerRings.get(j))) {
+				return false;
+			}
+		}
+	}
+	else {
+		// inner ring mismatch
+		return false;
+	}	
+	return true;
+};
+
+/**
+ * creates a polygon geometry object which form a buffer around the line geometry
+ * 
+ * @param {float} real world units to buffer around the line
+ * @param {float} (optional) units to buffer around the line in Y direction
+ * 
+ * @return linebuffer polygon
+ * @type Geometry
+ */
+Geometry.prototype.bufferLine = function(bufferX, bufferY){
+	if(typeof(bufferY)=='undefined')
+		bufferY = bufferX;
+	if(this.geomType!=geomType.line || this.count()<2)
+		return false;
+	
+	var ret = new Geometry(geomType.polygon)
+	
+	//get vector from point 0 to point 1
+	last_vec = this.get(1).minus(this.get(0));
+
+	//get 90° rotated vector
+	last_vec_o = new Point(-last_vec.y, last_vec.x);
+
+	//resize vectors with apropriate linebuffer length
+	last_vec_o = last_vec_o.dividedBy(last_vec_o.dist(new Point(0,0)));
+	last_vec_o.x*=bufferX; last_vec_o.y*=bufferY;
+	last_vec = last_vec.dividedBy(last_vec.dist(new Point(0,0)));
+	last_vec.x*=bufferX; last_vec.y*=bufferY;
+		
+	//add first pointsets
+	ret.list.unshift(this.get(0).plus(last_vec_o).minus(last_vec));
+	ret.list.push(this.get(0).minus(last_vec_o).minus(last_vec));
+		
+	for(var i=1;i<this.count()-1;i++){
+		//get vector from point n to point n+1
+		vec = this.get(i+1).minus(this.get(i));
+		//get orthogonal (90° rotated) vector		
+		vec_o = new Point(-vec.y, vec.x);
+
+		//resize vectors to linebuffer length
+		vec_o = vec_o.dividedBy(vec_o.dist(new Point(0,0)));
+		vec_o.x*=bufferX; vec_o.y*=bufferY;
+		vec = vec.dividedBy(vec.dist(new Point(0,0)));
+		vec.x*=bufferX; vec.y*=bufferY;
+			
+		//if direction is the same continue
+		if(vec.equals(last_vec))
+			continue;
+			
+		// calculate directed angle between the two vectors by 
+		// calculating the argument diffenrences between complex numbers
+		// arg(x + i*y) (because law of cosine can onlycalculate undirected angle)
+		var angle = (Math.atan2(vec.x,vec.y)-Math.atan2(last_vec.x,last_vec.y))
+		//ensure that angle is -180<=angle<=180
+		if(angle<-Math.PI)angle=2*Math.PI+angle;
+		if(angle>+Math.PI)angle=2*Math.PI-angle;
+		
+		//calculate the distance between the next points on boundary
+		//and the line point
+		//the point will be in the direction of angle/2 relative to last_vec_o
+		//since cosine is adjacent side / hypothenuse and we know that 
+		//the adjacent side is lineBuffer the hypothenus (our distance) is
+		var ndist = 1/(Math.cos(angle/2))
+		//direction of next points on boundary
+		var int_vec = vec_o.plus(last_vec_o);
+		//resize direction vector to our distance
+		int_vec = int_vec.times(ndist/int_vec.dist(new Point(0,0)));
+		int_vec.x*=bufferX; int_vec.y*=bufferY;
+		
+		//look if we have an outer sharp corner (>90°)
+		if(angle>Math.PI/2){
+			//push cutted edge points
+			ret.list.unshift(this.get(i).plus(last_vec_o).plus(last_vec));
+			ret.list.unshift(this.get(i).plus(vec_o).minus(vec));
+		}
+		else{
+			//push inner/light edge
+			ret.list.unshift(this.get(i).plus(int_vec));
+		}
+
+		//look if we have an inner sharp corner (<-90°)
+		if(angle<-Math.PI/2){
+			//push cutted edge points
+			ret.list.push(this.get(i).minus(last_vec_o).plus(last_vec));
+			ret.list.push(this.get(i).minus(vec_o).minus(vec));
+		}
+		else{
+			//push inner/light edge
+			ret.list.push(this.get(i).minus(int_vec));
+		}
+			
+		//copy for next point
+		last_vec = vec;
+		last_vec_o = vec_o;
+	}
+	//add last pointsets
+	ret.list.unshift(this.get(i).plus(last_vec_o).plus(last_vec));
+	ret.list.push(this.get(i).minus(last_vec_o).plus(last_vec));
+	
+	ret.close();
+
+	return ret;	
+}
+
+Geometry.prototype.toString = function () {
+	var str = "";
+	if (this.geomType == geomType.polygon) {
+		str += "[[";
+		for (var i = 0; i < this.count(); i++) {
+			if (i > 0) {
+				str += ", ";
+			}
+			str += this.get(i).toString();
+		}
+
+		if (typeof(this.innerRings) == "object" && this.innerRings.count() > 0) {
+			for (var j = 0; j < this.innerRings.count(); j++) {
+				var currentRing = this.innerRings.get(j);
+
+				str += "],[";
+				for (var i = 0; i < currentRing.count(); i++) {
+					if (i > 0) {
+						str += ", ";
+					}
+					str += currentRing.get(i).toString();
+				}
+			}
+		}
+		str += "]]";
+	}
+	else if (this.geomType == geomType.line) {
+		str += "[";
+		for (var i = 0; i < this.count(); i++) {
+			if (i > 0) {
+				str += ", ";
+			}
+			str += this.get(i).toString();
+		}
+		str += "]";
+	}
+	else if (this.geomType == geomType.point) {
+		str += this.get(0).toString();
+	}
+	
+	return str;
+};
+
+
+
+/**
+ * @class an array of elements, each consisting of a name/value pair
+ *
+ * @ constructor
+ */
+function Wfs_element(){
+
+	/**
+	 * returns the number of elements of this {@link Wfs_element} object.
+	 *
+	 * @return the number of elements
+	 * @type Integer
+	 */
+	this.count = function(){
+		return this.name.length;
+	};
+
+	/**
+	 * returns the name of the element at index i.
+	 *
+	 * @param {Integer} i index
+	 * @return the name
+	 * @type String
+	 */
+	this.getName = function(i){ 
+		if (this.isValidElementIndex(i)) {return this.name[i];}
+		return false;
+	};
+	
+	/**
+	 * returns the value of the element at index i.
+	 *
+	 * @param {Integer} i index
+	 * @return the value
+	 */
+	this.getValue = function(i){ 
+		if (this.isValidElementIndex(i)) {return this.value[i];}
+		return false;
+	};
+
+	/**
+	 * appends a new element with a given name. If an element with this name exists, it is overwritten.
+	 *
+	 * @param {String} aName the name of the new element
+	 * @param {String} aValue the value of the new element
+	 */
+	this.setElement = function(aName, aValue){ 
+		var i = this.getElementIndexByName(aName);
+		if (i === false) {i = this.count();}
+		this.name[i] = aName;
+		this.value[i] = aValue;
+	};
+
+	/**
+	 * removes an element with a given name. If an element with this name exists, it is removed.
+	 *
+	 * @param {String} aName the name of the element to delete
+	 */
+	this.delElement = function(aName){
+		var i = this.getElementIndexByName(aName);
+		if (i !== false) {
+			this.name.splice(i, 1);
+			this.value.splice(i, 1);
+		}
+	}
+	
+	/**
+	 * checks if an index is valid
+	 *
+	 * @private
+	 * @param {Integer} i an index
+	 * @return true if the index is valid; otherwise false
+	 * @type Boolean
+	 */
+	this.isValidElementIndex = function(i){ 
+		if (i>=0 && i<this.name.length) {return true;}
+		var e = new Mb_exception("class Wfs_element: function isValidElementIndex: illegal element index");
+		return false;
+	};
+	
+	this.name  = [];
+	this.value = [];
+}
+
+/**
+ * gets the index of the element with a given name.
+ *
+ * @param {String} elementName a name
+ * @return the index of the element; if no element with this name exists, false
+ * @type Integer, Boolean
+ */
+Wfs_element.prototype.getElementIndexByName = function(elementName){
+	for (var j = 0, len = this.count() ; j < len ; j++){
+		if (this.getName(j) == elementName) {return j;}
+	}
+	return false;
+};
+
+/**
+ * gets the value of the element with a given name.
+ *
+ * @param {String} elementName a name
+ * @return the value of the element; if no element with this name exists, false
+ * @type String, Boolean
+ */
+Wfs_element.prototype.getElementValueByName = function(elementName){
+	var i = this.getElementIndexByName(elementName);
+	if (i === false) {return false;}
+	return this.getValue(i);
+};
+
+Wfs_element.prototype.toString = function () {
+	var str = "";
+	if (this.count() > 0) {
+		str += "\"properties\": {";
+		
+		for (i = 0, len = this.count(); i < len; i++) {
+			if (i > 0) {
+				str += ",";
+			}		
+			var key = this.getName(i);
+			var value = this.getValue(i);
+			str += "\"" + key + "\":\"" + value + "\"";
+		}
+		str += "}";
+	}
+	return str;
+};
+
+/**
+ * @class a {@link Canvas} contains a {@link DivTag} that holds graphics rendered by {@link jsGraphics}
+ *
+ * @constructor
+ * @requires DivTag
+ * @requires jsGraphics
+ * @requires GeometryArray
+ * @requires MultiGeometry
+ * @requires Geometry
+ * @param {String} aMapFrame name of the target mapframe
+ * @param {String} aTagName name of the target div tag
+ * @param {String} aStyle style of the div tag
+ * @param {Integer} aLineWidth the line width of the jsGraphics output
+ */
+function Canvas(aMapframe, aTagName, aStyle, aLineWidth) {
+	
+	/**
+	 * draws the geometry of the canvas
+	 *
+	 * @param {String} t geometry type (@see GeomType)
+	 * @param {MultiGeometry} g a MultiGeometry object
+	 * @param {String} col a color
+	 * @private
+	 */
+ 	this.drawGeometry = function(t,g,col){
+ 		var mapframeWidth = mb_mapObj[mapObjInd].width;
+		var mapframeHeight = mb_mapObj[mapObjInd].height;
+	
+		if(t == geomType.point) {
+			var poiIcon = g.e.getElementValueByName("Mapbender:icon");
+			for(var i=0, ilen = g.count(); i < ilen; i++){
+				var currentGeom = g.get(i);
+				var p = realToMap(mapframe, currentGeom.get(0));
+				var px = p.x;
+				var py = p.y;
+				var radius = diameter/2;
+				if ((px - radius < mapframeWidth && px + radius > 0 &&
+					py - radius < mapframeHeight && py + radius > 0) ||
+					(p.dist(new Point(0,0)) < radius || 
+					 p.dist(new Point(mapframeWidth, mapframeHeight)) < radius ||
+					 p.dist(new Point(0,mapframeHeight)) < radius || 
+					 p.dist(new Point(mapframeWidth, 0)) < radius
+					)
+				) {
+					// if the point contains a link to an icon, display the icon
+					if (poiIcon) {
+						displayIcon(poiIcon, px, py);
+					}
+					else {
+						drawCircle(px-1, py-1, diameter,col);
+					}
+				}
+			}
+		}
+		else if(t == geomType.line || t==geomType.polygon) {
+			for(var i=0, ilen = g.count(); i < ilen; i++){
+				var currentGeom = g.get(i);
+				// paint inner rings
+				if (t==geomType.polygon && currentGeom.innerRings.count() > 0) {
+					for (var k = 0; k < currentGeom.innerRings.count(); k++) {
+						var currentRing = currentGeom.innerRings.get(k);
+						var previousPoint = realToMap(mapframe, currentRing.get(0));
+						for (var j=1, jlen = currentRing.count(); j < jlen; j++) {
+							(function () {
+								var currentPoint = realToMap(mapframe, currentRing.get(j));
+								
+								var pq = calculateVisibleDash(previousPoint, currentPoint, mapframeWidth, mapframeHeight);
+								if (pq) {
+									drawLine([pq[0].x-1, pq[1].x-1], [pq[0].y-1, pq[1].y-1], col);
+								}
+								previousPoint = currentPoint;
+							})();
+						}
+						
+					}					
+				}
+				// paint line or outer ring
+				var previousPoint = realToMap(mapframe, currentGeom.get(0));
+				for (var j=1, jlen = currentGeom.count(); j < jlen; j++) {
+					(function () {
+						var currentPoint = realToMap(mapframe, currentGeom.get(j));
+						
+						var pq = calculateVisibleDash(previousPoint, currentPoint, mapframeWidth, mapframeHeight);
+						if (pq) {
+							drawLine([pq[0].x-1, pq[1].x-1], [pq[0].y-1, pq[1].y-1], col);
+						}
+						previousPoint = currentPoint;
+					})();
+				}
+			}
+		}
+		else {
+			var e = new Mb_exception("class Canvas: function drawGeometry: unknown geomType " + t);
+		}
+	};
+
+	/**
+	 * checks if the MultiGeometry's bounding box width and height is smaller than minWidth
+	 *
+	 * @private
+	 * @param {MultiGeometry} g a MultiGeometry object
+	 */
+	this.isTooSmall = function(g){
+		// TODO switch between dot, original, circle
+//		return false;
+
+		var tmp = g.getBBox();
+		var min = realToMap(mapframe,tmp[0]);
+		var max = realToMap(mapframe,tmp[1]);
+		if((Math.abs(max.x - min.x) < minWidth) && (Math.abs(max.y - min.y) < minWidth)) {
+			return true;
+		}
+		return false;
+	};
+	
+	/**
+	 * gets the jsGraphics.
+	 *
+	 * @private
+	 * @return the jsGraphics
+	 * @type jsGraphics
+	 */
+	this.getCanvas = function(){
+		return canvas;
+	};
+	
+	this.setDiameter = function (px) {
+		diameter = px;
+	};
+	
+	/**
+	 * draws a circle with {@link jsGraphics}.
+	 *
+	 * @private
+	 * @param {Float} x x value of the center
+	 * @param {Float} y y value of the center
+	 * @param {Float} diameter diameter of the circle
+	 * @param {String} color the color of the circle in hex format
+	 */
+	var drawCircle = function(x, y, diameter, color) {
+		canvas.setColor(color);
+		canvas.drawEllipse(x-diameter/2,y-diameter/2,diameter,diameter);
+	};
+
+	/**
+	 * draws a polyline with {@link jsGraphics}.
+	 *
+	 * @private
+	 * @param {Array} x_array array of x values
+	 * @param {Array} y_array array of y values
+	 * @param {String} color the color of the polyline in hex format
+	 */
+	var drawLine = function(x_array, y_array, color) {
+		canvas.setColor(color);
+		canvas.drawPolyline(x_array, y_array);
+	};
+
+	/**
+	 * Displays an icon in the mapframe
+	 * 
+	 * @private
+	 * @param {String} url link to the image
+	 * @param {Float} x x coordinate within the map frame
+	 * @param {Float} y y coordinate within the map frame
+	 */
+	var displayIcon = function (url, x, y) {
+		if(ie){
+			var newImg = document.createElement("img");
+			var newImgTop = y - Math.round(80/2);
+			var newImgLeft = x - Math.round(80/2);
+			that.canvasDivTag.getTag().innerHTML = "<img src='" + url + "' style='position:absolute;top:"+newImgTop+";left:"+newImgLeft+";z-index:100'/>";
+		}
+		else{
+			var newImg = document.createElement("img");
+			newImg.src = url;
+			that.canvasDivTag.getTag().appendChild(newImg);	
+			//newImg.className = "mapsymbol";
+			//newImg.style.cursor = "help";
+			newImg.style.position = "absolute";
+			
+			// center the image at x, y
+			newImg.style.top = y - Math.round(80/2);
+			newImg.style.left = x - Math.round(80/2);
+	//		newImg.style.top = y - Math.round(80);
+	//		newImg.style.left = x;
+			newImg.style.zIndex = 100;
+		}
+	};
+	
+	/**
+	 * This is the {@link DivTag} that contains the output by {@link jsGraphics}.
+	 * 
+	 * @type DivTag
+	 */
+	var mapframe = aMapframe;
+	var mapObjInd = getMapObjIndexByName(mapframe);
+
+	if (mb_mapObj[mapObjInd].getDomElement().frameName) {
+		this.canvasDivTag = new DivTag(aTagName, mapName, aStyle);
+	}
+	else {
+		this.canvasDivTag = new DivTag(aTagName, "", aStyle, mb_mapObj[mapObjInd].getDomElement());
+	}
+
+	var that = this;
+
+	var diameter = 8;
+	var minWidth = 8;
+	var lineWidth = aLineWidth || 2;
+	var style = aStyle;
+	var canvas = new jsGraphics(aTagName, mb_mapObj[mapObjInd].getDomElement().frameName ? window.frames[mapframe] : window);
+	canvas.setStroke(lineWidth);
+	mb_registerPanSubElement(aTagName);
+}
+
+/**
+ * cleans the canvas by emptying the canvas {@link DivTag}.
+ */
+Canvas.prototype.clean = function () {
+	this.canvasDivTag.clean();
+};
+
+/**
+ * paints all geometries.
+ *
+ * @param {GeometryArray} gA the geometries that will be drawn
+ */
+Canvas.prototype.paint = function(gA) {
+	for (var q = 0; q < gA.count(); q++) {
+		var m = gA.get(q);
+		var t = m.geomType;
+		var col = m.color;
+		if (t == geomType.point) {
+			this.drawGeometry(t,m,col);
+		}
+		else {
+			if (this.isTooSmall(m)){
+				var newMember = new MultiGeometry(geomType.point);
+				newMember.addGeometry();
+				newMember.get(-1).addPoint(m.getCenter());
+				this.drawGeometry(geomType.point,newMember,col);
+			}
+			else{
+				if(t == geomType.line) {this.drawGeometry(t,m, col);}
+				else if(t == geomType.polygon) {this.drawGeometry(t,m,col);}
+				else {
+					var e = new Mb_exception("class Canvas: function paint: unknown geomType" + t);				
+				}
+			}
+		}
+	}
+	this.getCanvas().paint();
+};
+
+/**
+ * @class a {@link Highlight} object is {@link jsGraphics} rendering of a {@link GeometryArray} in various mapframes.
+ *
+ * @constructor
+ * @requires Canvas
+ * @requires GeometryArray
+ * @param {Array} aTargetArray an array of Strings referring to mapframes
+ * @param {String} aTagName the name of the div tags
+ * @param {Object} aStyle the style of the div tags
+ * @param {Integer} the line width of the jsGraphics lines
+ */
+function Highlight(aTargetArray, aTagName, aStyle, aLineWidth) {
+	/**
+	 * removes a {@link MultiGeometry} object from the geometry Array
+	 *
+	 * @param {MultiGeometry} m a MultiGeometry
+	 * @param {String} color a color
+	 */	
+	this.del = function(m, color) {
+		var newMultiGeom;
+		if (m.name == nameMultiGeometry) {
+			newMultiGeom = m;
+		}
+		else if (m.name == nameGeometry) {
+			var newMultiGeom = new MultiGeometry(m.geomType);
+			newMultiGeom.add(m);
+		}
+
+		var a = gA.findMultiGeometry(newMultiGeom);
+		var del = false;
+		for (var i=0; i<a.length && del === false; i++) {
+			if (gA.get(a[i]).color == color) {
+				gA.del(a[i]);
+				del = true;
+			}
+		}
+	};
+
+	/**
+	 * adds a {@link MultiGeometry} object to the geometry Array
+	 *
+	 * @param {MultiGeometry} m a MultiGeometry
+	 * @param {String} color the color of the highlight
+	 */	
+	this.add = function(m, color) {
+
+		if (m.name == nameMultiGeometry) {
+			gA.addCopy(m);
+		}
+		else if (m.name == nameGeometry) {
+			var newMultiGeom = new MultiGeometry(m.geomType);
+			newMultiGeom.add(m);
+			gA.addCopy(newMultiGeom);
+		}
+		if (typeof(color) != 'undefined') {gA.get(-1).color = color;} 
+		else {gA.get(-1).color = lineColor;}
+	};
+	
+	this.hide = function () {
+		for (var i=0; i < canvas.length; i++) {
+			if (typeof(canvas[i]) == "object") {canvas[i].clean();}
+		}
+	};
+
+	/**
+	 * removes all MultiGeometries.
+	 *
+	 */	
+	this.clean = function() {
+		if (gA.count() > 0) {
+			gA = new GeometryArray();
+			this.paint();
+		}
+	};
+
+	/**
+	 * displays the highlight
+	 *
+	 */	
+	this.paint = function() {
+		this.hide();
+		for (var i=0; i < canvas.length; i++) {
+			if (typeof(canvas[i]) == "object") {canvas[i].clean();}
+		}
+		for (var i=0; i<targets.length; i++){
+			if (typeof(canvas[i]) == 'undefined') {
+				canvas[i] = new Canvas(targets[i], tagname + i, style, lineWidth);
+			}
+			canvas[i].paint(gA);
+		}
+	};
+
+	this.setDiameter = function (radius) {
+		for (var i = 0; i < targets.length; i++) {
+			if (typeof(canvas[i]) != "undefined") {
+				canvas[i].setDiameter(radius);
+			}
+		}
+	}
+
+	this.setMouseOver = function (callback) {
+		for (var i=0; i<targets.length; i++){
+			if (typeof(canvas[i]) !== 'undefined') {
+				canvas[i].canvasDivTag.getTag().onmouseover = function (e) {
+					callback(e);
+				};
+			}
+		}
+	};
+	
+	this.setMouseOut = function (callback) {
+		for (var i=0; i<targets.length; i++){
+			if (typeof(canvas[i]) !== 'undefined') {
+				canvas[i].canvasDivTag.getTag().onmouseout = function (e) {
+					callback(e);
+				};
+			}
+		}
+	};
+	
+	this.setMouseClick = function (callback) {
+		for (var i=0; i<targets.length; i++){
+			if (typeof(canvas[i]) !== 'undefined') {
+				canvas[i].canvasDivTag.getTag().onclick = function (e) {
+					callback(e);
+				};
+			}
+		}
+	};
+	
+	var lineWidth = aLineWidth;
+	var tagname = 'mod_gaz_draw'+aTagName;
+	var style = aStyle;
+	var targets = aTargetArray; 
+	var canvas = []; 
+	var gA = new GeometryArray(); 
+	var lineColor = "#ff0000";
+	this.paint();
+}
+
+// ----------------------------------------------------------------------------------------------------
+// Snapping
+// ----------------------------------------------------------------------------------------------------
+/**
+ * @class a {@link Snapping} object stores is {@link jsGraphics} rendering of a {@link GeometryArray} in various mapframes.
+ *
+ * @constructor
+ * @requires GeometryArray
+ * @requires Highlight
+ * @param {String} aTarget name of the mapframe where snapping occurs
+ * @param {String} aTolerance Snapping is activated if the mouse is 
+ *                 within aTolerance pixel distance to the reference point.
+ * @param {String} aColor apparently deprecated?
+ * @param {Integer} aZIndex the z-Index of the {@link jsGraphics} generated by {@link Highlight}.
+ */
+function Snapping(aTarget, aTolerance, aColor, aZIndex){
+
+	/**
+	 * draws a circle to highlight the snapped point.
+	 * 
+	 * @param {Point} center the snapped point.
+	 * @param {Integer} radius radius of the circular highlight.
+	 */
+	this.draw = function(center,radius){ 
+		mG = new MultiGeometry(geomType.point);
+		mG.addGeometry();
+		mG.get(-1).addPoint(center);
+		highlight.add(mG,snappingColor);
+		highlight.paint();
+	};
+	this.getTolerance = function() {
+		return tolerance;
+	};
+	this.getTarget = function() {
+		return target;
+	};
+	this.cleanHighlight = function() {
+		return highlight.clean();
+	};
+	this.addPoint = function(aPoint) {
+		coord.push(aPoint);
+	};
+	this.getPointCount = function() {
+		return coord.length;
+	};
+	this.getPoint = function(i) {
+		return coord[i];
+	};
+	this.resetPoints = function() {
+		coord = [];
+	};
+	this.getNearestNeighbour = function(){
+		if (min_i != -1) {return this.getPoint(min_i);}
+		return false;
+	};
+	this.setIndexOfNearestNeighbour = function(i){
+		min_i = i;
+	};
+	this.resetIndexOfNearestNeighbour = function(){
+		min_i = -1;
+	};
+	
+	/**
+	 * @private
+	 */
+	var tolerance = (typeof(aTolerance) == 'undefined') ? 10 : aTolerance;
+
+	/**
+	 * @private
+	 */
+	var zIndex = (typeof(aZIndex) == 'undefined') ? 50 : aZIndex;
+
+	/**
+	 * @private
+	 */
+	var coord = []; 
+
+	/**
+	 * @private
+	 */
+	var min_i = -1;
+
+	/**
+	 * @private
+	 */
+	var target = aTarget;
+
+	/**
+	 * @private
+	 */
+	var snappingColor = aColor;
+	
+	/**
+	 * @private
+	 */
+	var lineWidth = 2;
+
+	/**
+	 * @private
+	 */
+	var style = {"position":"absolute", "top":"0px", "left":"0px", "z-index":zIndex};
+
+	/**
+	 * @private
+	 */
+	var highlight = new Highlight([target], "snapping"+Math.round(Math.random()*Math.pow(10,10)), style, lineWidth);
+}
+
+Snapping.prototype.check = function(currPoint){
+	var minDist = false;
+	
+	for (var i = 0 ; i < this.getPointCount() ; i++) {
+
+		var currDist = currPoint.dist(realToMap(this.getTarget(), this.getPoint(i)));
+		if (minDist === false || currDist < minDist) {
+			minDist = currDist;
+			if (minDist < this.getTolerance()) {this.setIndexOfNearestNeighbour(i);}
+		}
+	}
+	if (this.getPointCount() > 0 && minDist > this.getTolerance()) {
+		this.resetIndexOfNearestNeighbour();
+	}
+	this.cleanHighlight();
+	if (this.isSnapped()) {
+		this.draw(this.getNearestNeighbour(), this.getTolerance());
+	}
+};
+
+/**
+ * Stores the points which will have the snapping property. 
+ * 
+ * @param {GeometryArray} geom all points of geom will be stored. May also be a 
+ *                             {@link MultiGeometry} or {@link Geometry}.
+ * @param {Point} point this point is excluded. Useful when moving a point of a 
+ *                      geometry; you don't want to snap against the point you
+ *                      move. Optional.
+ */
+Snapping.prototype.store = function(geom, point){
+	this.resetPoints();
+	this.resetIndexOfNearestNeighbour();
+
+	for (var i = 0 ; i < geom.count(); i++){
+		if (geom.name == nameGeometryArray || geom.name == nameMultiGeometry){
+			for (var j = 0 ; j < geom.get(i).count() ; j++){
+				if (geom.get(i).name == nameMultiGeometry){
+					// inner rings
+					if (geom.get(i).get(j).geomType == geomType.polygon && geom.get(i).get(j).innerRings && geom.get(i).get(j).innerRings.count() > 0) {
+						for (var l = 0; l < geom.get(i).get(j).innerRings.count(); l++) {
+							var currentRing = geom.get(i).get(j).innerRings.get(l);
+							for (var k = 0 ; k < currentRing.count() ; k++){
+								if ((currentRing.isComplete() === true && typeof(point) == 'undefined') || (typeof(point) != 'undefined' && !currentRing.get(k).equals(point))){
+									this.add(currentRing.get(k));
+								}
+							}
+							
+						}
+					}
+					// lines, points, outer rings
+					for (var k = 0 ; k < geom.get(i).get(j).count() ; k++){
+						if ((geom.get(i).get(j).isComplete() === true && typeof(point) == 'undefined') || (typeof(point) != 'undefined' && !geom.get(i).get(j).get(k).equals(point))){
+							this.add(geom.getPoint(i, j, k));
+						}
+					}
+				}
+				else {
+					if ((geom.get(i).isComplete() === true && typeof(point) == 'undefined') || (typeof(point) != 'undefined' && !geom.get(i).get(j).get(k).equals(point))){
+						this.add(geom.getPoint(i, j));
+					}
+				}
+			}
+		}
+		else {
+			if (typeof(point) != 'undefined' && !geom.get(i).get(j).get(k).equals(point)){
+				this.add(geom.get(i));
+			}
+		}
+	}
+};
+
+/**
+ * Determines whether a point is within snapping distance to the mouse cursor
+ * 
+ * @return true if a point is within snapping distance; else false
+ * @type Boolean
+ */
+Snapping.prototype.isSnapped = function(){ 
+	if (this.getNearestNeighbour() !== false) {return true;}
+	return false;
+};
+
+/**
+ * Returns the point that is within snapping distance and closest to the mouse cursor.
+ * 
+ * @return the point (if there is any); else false
+ * @type Point
+ */
+Snapping.prototype.getSnappedPoint = function(){
+	return this.getNearestNeighbour();
+};
+
+/**
+ * Adds the point to the stored points with snapping property.
+ * 
+ * @param {Point} point which receives snapping property.
+ */
+Snapping.prototype.add = function(aPoint){ 
+	this.addPoint(aPoint);
+};
+
+/**
+ * Removes the highlight.
+ */
+Snapping.prototype.clean = function(){
+	this.cleanHighlight();
+};
+
+
+
+// ----------------------------------------------------------------------------------------------------
+// misc. functions
+// ----------------------------------------------------------------------------------------------------
+
+/**
+ * @ignore
+ */
+function calculateVisibleDash (p0, p1, width, height) {
+	if (p0.x > p1.x) {var p_temp = p0; p0 = p1; p1 = p_temp; p_temp = null;}
+	var p = p0; var q = p1; var m; var ix; var iy;
+	if (p1.x != p0.x) {
+		m = -(p1.y-p0.y)/(p1.x-p0.x); 
+		if (p0.x < width && p1.x > 0 && !(p0.y < 0 && p1.y < 0) && !(p0.y > height && p1.y > height) ) {
+			if (p0.x < 0) {
+				iy = p0.y - m*(0-p0.x);
+				if (iy > 0 && iy < height) {p = new Point(0, iy);}
+				else if (iy > height) {
+				    ix = p0.x+((p0.y - height)/m);
+				    if (ix > 0 && ix < width) {p = new Point(ix, height);} else {return false;}
+				}
+				else if (iy < 0) {
+				    ix = p0.x+(p0.y/m);
+				    if (ix > 0 && ix < width) {p = new Point(ix, 0);} else {return false;}
+				}
+				else {return false;}
+			}
+			else if (p0.y >= 0 && p0.y <= height) {p = p0;}
+			else if (p0.y < 0) {
+			    ix = p0.x+(p0.y/m);
+			    if (ix > 0 && ix < width) {p = new Point(ix, 0);} else {return false;}
+			}
+			else if (p0.y > height && m > 0) {
+			    ix = p0.x+((p0.y - height)/m);
+			    if (ix > 0 && ix < width) {p = new Point(ix, height);} else {return false;}
+			}
+			else {return false;}
+			if (p1.x > width) {
+				iy = p1.y - m*(width-p1.x);
+				if (iy > 0 && iy < height) {q = new Point(width, iy);}
+				else if (iy < 0) {
+				    ix = p0.x+(p0.y/m);
+				    if (ix > 0 && ix < width) {q = new Point(ix, 0);} else {return false;}
+				}
+				else if (iy > height) {
+				    ix = p0.x+((p0.y - height)/m);
+				    if (ix > 0 && ix < width) {q = new Point(ix, height);} else {return false;}
+				}
+				else {return false;}
+			}
+			else if (p1.y >= 0 && p1.y <= height) {q = p1;}
+			else if (p1.y < 0) {
+			    ix = p1.x+(p1.y/m);
+			    if (ix > 0 && ix < width) {q = new Point(ix, 0);} else {return false;}
+			}
+			else if (p1.y > height) {
+			    ix = p1.x+((p1.y- height)/m);
+			    if (ix > 0 && ix < width) {q = new Point(ix, height);} else {return false;}
+			}
+		}
+		else {return false;}
+	}
+	else {
+		if (!(p0.y < 0 && p1.y < 0) && !(p0.y > height && p1.y > height)) {
+			if (p0.y < 0) {p = new Point(p0.x, 0);}
+			else if (p0.y > height) {p = new Point(p0.x, height);}
+			else {p = p0;}
+			if (p1.y < 0) {q = new Point(p0.x, 0);}
+			else if (p1.y > height) {q = new Point(p0.x, height);}
+			else {q = p1;}
+		}
+		else {return false;}
+	}
+	return [new Point(Math.round(q.x), Math.round(q.y)), new Point(Math.round(p.x), Math.round(p.y))];
+}
+
+/**
+ * @ignore
+ */
+function objString (a){
+	var z = "";
+	
+	for (attr in a) {
+		var b = a[attr];
+		if (typeof(b) == "object") {z += objString(b);}
+		else {z += attr + " " + b + "\n";}
+	}	
+	return z;
+}

Modified: branches/print_dev/http/javascripts/map.php
===================================================================
--- branches/print_dev/http/javascripts/map.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/map.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -131,13 +131,13 @@
 		for ($i = 0; $i < count($moduleArray); $i++) {
 			$currentFile = dirname(__FILE__) . "/../javascripts/" . trim($moduleArray[$i]);
 			if (file_exists($currentFile)) {
+				$e = new mb_notice("LOADING module : " . $currentFile);
 				require_once($currentFile);
 				echo "\n";
 			}
 			else {
 				$e = new mb_exception("Javascript module not found: " . $currentFile);
 				echo "var e = new Mb_exception('Javascript module not found: " . $currentFile . "');";
-				die;
 			}
 		}
 	}
@@ -168,21 +168,22 @@
 			$e_height = intval($row_js["e_height"]);
 			$currentFile = trim($jsArray[$i]);
 			if (file_exists($currentFile)) {
+				echo "Mapbender.Modules." . $e_id . " = {\n";
+				echo "id:'".$row_js["e_id"]."',";
+				echo "url:'".$row_js["e_url"]."',";
+				echo "top:'".$row_js["e_top"]."',";
+				echo "left:'".$row_js["e_left"]."',";
+				echo "width:'".$row_js["e_width"]."',";
+				echo "height:'".$row_js["e_height"]."'";
 				if (in_array($e_id, $modulesNotRelyingOnGlobalsArray)) {
-					echo "Mapbender.Modules." . $e_id . " = {
-						init : function () {\n";
-					require_once($currentFile);
-					echo "},\n";
-					echo "id:'".$row_js["e_id"]."',";
-					echo "url:'".$row_js["e_url"]."',";
-					echo "top:'".$row_js["e_top"]."',";
-					echo "left:'".$row_js["e_left"]."',";
-					echo "width:'".$row_js["e_width"]."',";
-					echo "height:'".$row_js["e_height"]."'";
+					echo ",\ninit : function () {\n";
+					require($currentFile);
+					echo "}\n";
 					echo "};\n";
 				}
 				else {
-					require_once($currentFile);
+					echo "};\n";
+					require($currentFile);
 				}
 			}
 			else {
@@ -196,6 +197,9 @@
 ?>
 eventBeforeInit.register(function () {
 	for (var module in Mapbender.Modules) {
-		Mapbender.Modules[module].init();
+		var initFunction = Mapbender.Modules[module].init;
+		if (typeof(initFunction) == "function") {
+			Mapbender.Modules[module].init();
+		}
 	}
 });

Modified: branches/print_dev/http/javascripts/map_obj.js
===================================================================
--- branches/print_dev/http/javascripts/map_obj.js	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/map_obj.js	2009-05-22 11:46:01 UTC (rev 3956)
@@ -14,6 +14,10 @@
 		this.extent = String(minx) + "," + String(miny) + "," + String(maxx) + "," + String(maxy);
 	};
 	
+	this.restrictedExtent = function (extent) {
+		this.restrictedExtent = extent;
+	};
+	
 	/**
 	 * get the width of the mapObj
 	 *
@@ -75,7 +79,23 @@
 	};
 	
 	this.getMousePosition = function (e) {
-		mb_getMousePos(e, this.frameName);
+		var clickX, clickY;
+
+		if ($.browser.msie) {
+			if (window.event) {
+				clickX = window.event.clientX;
+				clickY = window.event.clientY;
+			}
+			else {
+				clickX = e.clientX;
+				clickY = e.clientY;
+			}
+		}
+		else{
+			clickX = e.pageX;
+			clickY = e.pageY;
+		}
+
 		var currentPos = null;
 		if (this.type == "DIV") {
 			var mapDomElement = this.getDomElement();
@@ -83,6 +103,11 @@
 				clickX - parseInt(mapDomElement.style.left), 
 				clickY - parseInt(mapDomElement.style.top)
 			);
+			// if the mouse position is not on top of the map, return null
+			if (currentPos.x < 0 || currentPos.x > this.width || 
+				currentPos.y < 0 || currentPos.y > this.height) {
+				return null;
+			}
 		}
 		else {
 			currentPos = new Point(
@@ -108,10 +133,35 @@
 			ext.miny = ext.centery - relation_px_y * ext.extentx / 2;
 			ext.maxy = ext.centery + relation_px_y * ext.extentx / 2;
 		}
+		
+		// Check if ext is within restricted extent
+		// If not, calculate a new extent according
+		// to restricted extent.
+		/*
+		if ( this.restrictedExtent ) {
+			if ( ext.minx  < this.restrictedExtent.minx ) {  
+	            ext.minx = this.restrictedExtent.minx;
+	            ext.maxx = ext.minx + (relation_px_x * ext.extenty);
+	        }
+	        if ( ext.miny < this.restrictedExtent.miny ) {
+	            ext.miny = this.restrictedExtent.miny;
+	            ext.maxy = ext.miny + (relation_px_y * ext.extentx);
+	        }
+	        if ( ext.maxx > this.restrictedExtent.maxx ) {
+	            ext.maxx = this.restrictedExtent.maxx;
+	            ext.minx = ext.maxx - (relation_px_x * ext.extenty);
+	        }
+	        if ( ext.maxy > this.restrictedExtent.maxy ) {
+	            ext.maxy = this.restrictedExtent.maxy;
+	            ext.miny = ext.maxy - (relation_px_y * ext.extentx);
+	        }
+		}
+		*/
 		this.setExtent(ext.minx, ext.miny, ext.maxx, ext.maxy);
 		return ext;
 	};
 	
+	
 	this.width = width;
 	this.height = height;
 	this.frameName = frameName;
@@ -200,6 +250,7 @@
 	domElement.style.width = this.width;
 	domElement.style.height = this.height;   
    
+	this.afterMapRequest = new MapbenderEvent();
 	
 	/**
 	 * get the extent of the mapObj
@@ -320,21 +371,31 @@
 				break;
 		}
 		this.extent = minx + "," + miny + "," + maxx + "," + maxy;
+		
+		this.restrictedExtent;
 		this.setMapRequest();
 		
 	};
 	
 	this.zoomFull = function () {
 		
-		for (var i = 0; i < this.wms[0].gui_epsg.length; i++) {
-			if (this.epsg == this.wms[0].gui_epsg[i]) {
-				var bbox_minx = parseFloat(this.wms[0].gui_minx[i]);
-				var bbox_miny = parseFloat(this.wms[0].gui_miny[i]);
-				var bbox_maxx = parseFloat(this.wms[0].gui_maxx[i]);
-				var bbox_maxy = parseFloat(this.wms[0].gui_maxy[i]);
-				var wmsExtent = new Extent(bbox_minx, bbox_miny, bbox_maxx, bbox_maxy);
-				var newExtent = this.calculateExtent(wmsExtent);
-				this.repaint(new Point(newExtent.minx, newExtent.miny), new Point(newExtent.maxx, newExtent.maxy));
+		if (this.restrictedExtent) {
+			var newExtent = this.calculateExtent(this.restrictedExtent);
+			this.repaint(new Point(newExtent.minx, newExtent.miny), new Point(newExtent.maxx, newExtent.maxy));
+		}
+		else {
+			for (var i = 0; i < this.wms[0].gui_epsg.length; i++) {
+				if (this.epsg == this.wms[0].gui_epsg[i]) {
+					var bbox_minx = parseFloat(this.wms[0].gui_minx[i]);
+					var bbox_miny = parseFloat(this.wms[0].gui_miny[i]);
+					var bbox_maxx = parseFloat(this.wms[0].gui_maxx[i]);
+					var bbox_maxy = parseFloat(this.wms[0].gui_maxy[i]);
+	
+					var wmsExtent = new Extent(bbox_minx, bbox_miny, bbox_maxx, bbox_maxy);
+					var newExtent = this.calculateExtent(wmsExtent);
+					this.repaint(new Point(newExtent.minx, newExtent.miny), new Point(newExtent.maxx, newExtent.maxy));
+					break;
+				}
 			}
 		}
 	};
@@ -357,7 +418,6 @@
 		var distx = extent.maxx - extent.minx;
 		var disty = extent.maxy - extent.miny;
 		
-		
 		if (x && y) {
 			var centerx = parseFloat(x);
 			var centery = parseFloat(y);
@@ -373,6 +433,32 @@
 		var miny = centery - new_disty / 2;
 		var maxx = centerx + new_distx / 2;
 		var maxy = centery + new_disty / 2;
+		// Check if ext is within restricted extent
+		// If not, calculate a new extent according
+		// to restricted extent.
+		/*
+		var relation_px_x = this.getWidth() / this.getHeight();
+		var relation_px_y = this.getHeight() / this.getWidth();
+		if ( this.restrictedExtent ) {
+			if ( minx  < this.restrictedExtent.minx ) {  
+	            minx = this.restrictedExtent.minx;
+	            maxx = minx + (relation_px_x * new_disty);
+	        }
+	        if ( miny < this.restrictedExtent.miny ) {
+	            miny = this.restrictedExtent.miny;
+	            maxy = miny + (relation_px_y * new_distx);
+	        }
+	        if ( maxx > this.restrictedExtent.maxx ) {
+	            maxx = this.restrictedExtent.maxx;
+	            minx = maxx - (relation_px_x * new_distx);
+	        }
+	        if ( maxy > this.restrictedExtent.maxy ) {
+	            maxy = this.restrictedExtent.maxy;
+	            miny = maxy - (relation_px_y * new_disty);
+	        }
+		}
+		*/
+		
 		this.setExtent(minx, miny, maxx, maxy);
 
 		this.setMapRequest();
@@ -514,6 +600,7 @@
 		
 		// add vendor-specific
 		for (var v = 0; v < mb_vendorSpecific.length; v++) {
+			var functionName = 'setMapRequest';
 			var vendorSpecificString = eval(mb_vendorSpecific[v]);
 			// if eval doesn't evaluate a function, the result is undefined.
 			// Sometimes it is necessary not to evaluate a function, for
@@ -543,14 +630,25 @@
 	 * @return array of all featureInfoRequests of this map object
 	 * @type string[]
 	 */
-	this.getFeatureInfoRequests = function(clickPoint){
+	this.getFeatureInfoRequests = function(clickPoint, ignoreWms){
 		var allRequests = [];
 		//loop through all wms to get the FeatureInfoRequests
 		for (var i = 0; i < this.wms.length; i++) {
-			var currentRequest = this.wms[i].getFeatureInfoRequest(this, clickPoint);
-			if (currentRequest) {
-				allRequests.push(currentRequest);
+			var ignoreThisWms = false;
+			if (ignoreWms.constructor === Array) {
+				for (var j = 0; j < ignoreWms.length; j++) {
+					if (ignoreWms[j] == this.wms[i].wms_id) {
+						ignoreThisWms = true;
+						break;
+					}
+				}
 			}
+			if (!ignoreThisWms) {
+				var currentRequest = this.wms[i].getFeatureInfoRequest(this, clickPoint);
+				if (currentRequest) {
+					allRequests.push(currentRequest);
+				}
+			}
 		}
 		if (allRequests.length > 0) {
 			return allRequests;
@@ -646,7 +744,7 @@
 	};
 	
 	this.setSingleMapRequest = function (wms_id) {
-		eventBeforeMapRequest.trigger({frameName:this.frameName});
+		eventBeforeMapRequest.trigger({map:this});
 	
 		var ts = mb_timestamp();	
 	
@@ -663,7 +761,7 @@
 			var myDivId = this.elementName + "_div_" + ii;          
 			writeTag(this.frameName, myDivId, newMapRequest);
 			var myMapId = this.elementName + "_map_" + ii;
-			eventAfterMapRequest.trigger({"frameName":this.elementName, "myMapId":myMapId});
+			eventAfterMapRequest.trigger({"map":this, "myMapId":myMapId});
 			return true;
 		}  
 		return false; 
@@ -698,10 +796,8 @@
 	}
 	
 	this.setMapRequest = function(){
-		var functionName = 'setMapRequest';
-		
 		var ret = eventBeforeMapRequest.trigger({
-				frameName: this.frameName
+				map: this
 			}, "AND");
 		if (ret === false) {
 			return true;
@@ -725,9 +821,10 @@
 		writeTag(this.frameName, this.elementName+"_maps", newMapRequest);
 
 		eventAfterMapRequest.trigger({
-			"frameName": this.elementName,
+			"map": this,
 			"myMapId": myMapId.join(",")
 		});
+		this.afterMapRequest.trigger();
 	};
 
 	var that = this;
@@ -906,3 +1003,28 @@
 
 	eventAfterMapObjectConstruction.trigger();
 }
+
+mb_mapObj_const.prototype.getWfsConfIds = function (wfs_config) {
+	var db_wfs_conf_id = [];
+	var js_wfs_conf_id = [];
+	
+	//search configurations that are selected (and in scale)
+	for (var i=0; i < this.wms.length; i++){
+		for(var ii=0; ii < this.wms[i].objLayer.length; ii++){
+			var o = this.wms[i].objLayer[ii];
+			if(o.gui_layer_wfs_featuretype != '' && o.gui_layer_querylayer == '1'){
+				if(!checkscale || o.checkScale(this))
+					db_wfs_conf_id[db_wfs_conf_id.length] = o.gui_layer_wfs_featuretype;
+			}
+		}
+	}
+	for(var i=0; i < db_wfs_conf_id.length; i++){
+		for(var ii=0; ii < wfs_config.length; ii++){
+			if(wfs_config[ii]['wfs_conf_id'] == db_wfs_conf_id[i]){
+				js_wfs_conf_id[js_wfs_conf_id.length] = ii;
+				break;
+			}
+		}
+	}	
+	return js_wfs_conf_id;
+};
\ No newline at end of file

Modified: branches/print_dev/http/javascripts/mapnf.php
===================================================================
--- branches/print_dev/http/javascripts/mapnf.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mapnf.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -19,4 +19,79 @@
 
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
 ?>
-mb_registerMapObj('', 'mapframe1', null,<?php echo $e_width; ?>, <?php echo $e_height; ?>);
+
+(function () {
+
+<?php
+include(dirname(__FILE__) . "/../include/dyn_js.php");
+?>
+
+	var mapTimeout;
+	var	sum_delta = 0;
+	var lastTimestamp;
+	var lastScrollPosition;
+	var mapObject;
+	
+	eventInitMap.register(function init_mod_map1(){
+			
+		mapObject = mb_registerMapObj('', '<?php echo $e_id; ?>', null,<?php echo $e_width; ?>, <?php echo $e_height; ?>);
+		
+		
+		try {
+			if (restrictedExtent !== '') {
+				mapObject.setRestrictedExtent(restrictedExtent);
+			}
+		}
+		catch (e) {
+			new Mb_notice("Restricted extent not set via element variable.");
+		}
+		
+		$(document).mousewheel(function (e, delta) {
+			if (sum_delta == 0) {
+				mapTimeout = setTimeout(function () {
+						lastScrollPosition = mapObject.getMousePosition(e);
+						mousewheelZoom();	
+					}, 
+					100);
+			}
+			sum_delta = sum_delta + (delta);
+			var currentTime = new Date();
+			lastTimestamp = currentTime.getTime();
+			
+			return false;
+		});
+	});
+	
+	function mousewheelZoom () {
+		var currentTime = new Date();
+	
+		if (currentTime.getTime() - lastTimestamp > 200) {
+			if (lastScrollPosition !== null) {
+				var pos = mapObject.convertPixelToReal(lastScrollPosition);
+	
+				if (sum_delta > 0) {
+					mapObject.zoom(true, Math.pow(Mapbender.zoomMousewheel, sum_delta), pos.x, pos.y);
+				}
+				else {
+					mapObject.zoom(false, Math.pow(Mapbender.zoomMousewheel, -sum_delta), pos.x, pos.y);
+				}
+				
+				var newPos = new Point();
+				newPos.x = mapObject.width - lastScrollPosition.x;
+				newPos.y = mapObject.height - lastScrollPosition.y;
+						
+				var posAfterZoom = mapObject.convertPixelToReal(newPos);
+				mapObject.zoom(false, 1.0, posAfterZoom.x, posAfterZoom.y);
+			}			
+			sum_delta = 0;
+			clearTimeout(mapTimeout);
+		}
+		else {
+			mapTimeout = setTimeout(function () {
+					mousewheelZoom(sum_delta);	
+				}, 
+				100
+			);
+		}
+	}
+})();
\ No newline at end of file

Modified: branches/print_dev/http/javascripts/mod_addWMSfromfilteredList_ajax.php
===================================================================
--- branches/print_dev/http/javascripts/mod_addWMSfromfilteredList_ajax.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_addWMSfromfilteredList_ajax.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -33,13 +33,10 @@
 	<script type="text/javascript">
 	<!--
 	// Set default for element variables if they are undefined
-	option_all        = (typeof(option_all) !== 'undefined')        ? option_all        : '1';
-	option_group      = (typeof(option_group) !== 'undefined')      ? option_group      : '1';
-	option_gui        = (typeof(option_gui) !== 'undefined')        ? option_gui        : '1';
 	option_dball      = (typeof(option_dball) !== 'undefined')      ? option_dball      : '1';
-	option_dbgroup    = (typeof(option_dbgroup) !== 'undefined')    ? option_dbgroup    : '1';
-	option_dbgui      = (typeof(option_dbgui) !== 'undefined')      ? option_dbgui      : '1';
-	capabilitiesInput = (typeof(capabilitiesInput) !== 'undefined') ? capabilitiesInput : '0';
+	option_dbgroup    = (typeof(option_dbgroup) !== 'undefined')    ? option_dbgroup    : '0';
+	option_dbgui      = (typeof(option_dbgui) !== 'undefined')      ? option_dbgui      : '0';
+	capabilitiesInput = (typeof(capabilitiesInput) !== 'undefined') ? capabilitiesInput : '1';
 	gui_list          = (typeof(gui_list) !== 'undefined')          ? gui_list          : '';
 
 	var guis = gui_list.split(',');
@@ -159,7 +156,9 @@
 		tableRow.appendChild(leftTableCell);
 		tableRow.appendChild(rightTableCell);
 		
-		tableRow.setAttribute('onclick',onClick);
+		tableRow.onclick = function () {
+			eval(onClick);
+		}
 
 		if(resultTableBoy.childNodes.length % 2 !== 0) {
 			tableRow.className += tableRow.className + ' alternate';
@@ -198,22 +197,10 @@
 
 		// If only one is active load list imidiately
 		if(
-			parseInt(option_all) + 
-			parseInt(option_group) + 
-			parseInt(option_gui) + 
 			parseInt(option_dbgui) + 
 			parseInt(option_dbgroup) + 
 			parseInt(option_dball)
 		=== 1) {
-			if(option_all === '1') {
-				optionButton = document.getElementById('button_all');
-			}
-			if(option_group === '1') {
-				optionButton = document.getElementById('button_group');
-			}
-			if(option_gui === '1') {
-				optionButton = document.getElementById('button_gui');
-			}
 			if(option_dball === '1'){
 				optionButton = document.getElementById('button_dbAll');
 			}
@@ -232,18 +219,6 @@
 			}
 		}
 
-		if(typeof(option_all) !== 'undefined' && option_all === '0') {
-			optionButton = document.getElementById('button_all'); 
-			optionButton.parentNode.removeChild(optionButton);
-		}
-		if(typeof(option_group) !== 'undefined' && option_group === '0') {
-			optionButton = document.getElementById('button_group');
-			optionButton.parentNode.removeChild(optionButton);
-		}
-		if(typeof(option_gui) !== 'undefined' && option_gui === '0') {
-			optionButton = document.getElementById('button_gui');
-			optionButton.parentNode.removeChild(optionButton);
-		}
 		if(option_dball === '0') {
 			optionButton = document.getElementById('button_dbAll');
 			optionButton.parentNode.removeChild(optionButton);
@@ -341,7 +316,7 @@
 <body onLoad="setButtons();">
 <h1><?php echo _mb("Add WMS"); ?></h1>
 <p><?php echo _mb("Enter a Capabilities-URL of a WMS or select one or more WMS from list."); ?></p>
-<p><em><?php echo _mb("Hint: Possibly you need to zoom in for showing layers from external map service. The operator of the external service is responsible for the display ranges. PortalU does not have a stake in this behaviour."); ?></em></p>
+<p><em><?php echo _mb("Notice: Be aware of the scale hints. Possibly you need to zoom in to display the added service."); ?></em></p>
 
 <form id="capabilitiesForm" name="addURLForm" method="post" action="">
 <fieldset id="container_capabilities">
@@ -349,7 +324,7 @@
 	<p>
 		<label for="CapURL"><?php echo _mb("Capabilities-URL"); ?>:</label> 
 		<input type="text" id="CapURL" name="CapURL" /> 
-		<input type="button" id="addCapURL" name="addCapURL" value="<?php echo _mb("Add"); ?>" onclick="mod_addWmsfromURL();" />
+		<input type="button" id="addCapURL" name="addCapURL" value="<?php echo _mb("Add WMS"); ?>" onclick="mod_addWmsfromURL();" />
 	</p>
 </fieldset>
 </form>
@@ -358,13 +333,9 @@
 <fieldset id="container_buttons">
 <legend>WMS list(s)</legend>
 	<p>
-		<label><?php echo _mb("Available WMS list(s)"); ?>:</label> 
-		<input type="button" name="button_all"     id="button_all"     value="<?php echo _mb("All WMS"); ?>"            onclick="setSource('capabilities');getWMSByGUI(gui_list)"> 
-		<input type="button" name="button_group"   id="button_group"   value="<?php echo _mb("WMS by Group"); ?>"              onclick="setSource('capabilities');getGroups()"> 
-		<input type="button" name="button_gui"     id="button_gui"     value="<?php echo _mb("WMS by GUI"); ?>"                onclick="setSource('capabilities');getGUIs()"> 
-		<input type="button" name="button_dbAll"   id="button_dbAll"   value="<?php echo _mb("Database (All WMS)"); ?>" onclick="setSource('db');getWMSByGUI(gui_list)">
-		<input type="button" name="button_dbGroup" id="button_dbGroup" value="<?php echo _mb("Database (Group)"); ?>"   onclick="setSource('db');getGroups()"> 
-		<input type="button" name="button_dbGui"   id="button_dbGui"   value="<?php echo _mb("Database (GUI)"); ?>"     onclick="setSource('db');getGUIs()"> 
+		<input type="button" name="button_dbAll"   id="button_dbAll"   value="<?php echo _mb("List all WMS"); ?>" onclick="setSource('db');getWMSByGUI(gui_list)">
+		<input type="button" name="button_dbGroup" id="button_dbGroup" value="<?php echo _mb("List WMS by Group"); ?>"   onclick="setSource('db');getGroups()"> 
+		<input type="button" name="button_dbGui"   id="button_dbGui"   value="<?php echo _mb("List WMS by Application"); ?>"     onclick="setSource('db');getGUIs()"> 
 	</p>
 </fieldset>
 </form>

Modified: branches/print_dev/http/javascripts/mod_back.php
===================================================================
--- branches/print_dev/http/javascripts/mod_back.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_back.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -41,8 +41,8 @@
 });
 
 eventAfterMapRequest.register(function (obj) {
-	mb_setHistoryObj(obj.frameName);
-	mod_back_check(obj.frameName);
+	mb_setHistoryObj(obj.map.elementName);
+	mod_back_check(obj.map.elementName);
 });
 
 

Modified: branches/print_dev/http/javascripts/mod_box1.js
===================================================================
--- branches/print_dev/http/javascripts/mod_box1.js	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_box1.js	2009-05-22 11:46:01 UTC (rev 3956)
@@ -175,11 +175,13 @@
 }
 
 function mod_box_setValidClipping(coords){
-	if(coords.length > 2){
-		mb_calculateExtent(mb_zF,coords[0],coords[1],coords[2],coords[3]);
-		setMapRequest(mb_zF);
+	if (typeof(coords) !== "undefined") {
+		if(coords.length > 2){
+			mb_calculateExtent(mb_zF,coords[0],coords[1],coords[2],coords[3]);
+			setMapRequest(mb_zF);
+		}
+		else{
+			zoom(mb_zF,true,1.0,coords[0], coords[1]);
+		}
 	}
-	else{
-		zoom(mb_zF,true,1.0,coords[0], coords[1]);
-	}
 }

Modified: branches/print_dev/http/javascripts/mod_digitize_tab.php
===================================================================
--- branches/print_dev/http/javascripts/mod_digitize_tab.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_digitize_tab.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -129,7 +129,9 @@
 
 try {if(mod_digitize_elName){}}catch(e) {mod_digitize_elName = "digitize";}
 try {if(nonTransactionalEditable){}}catch(e) {nonTransactionalEditable = false;}
+try {if(addCloneGeometryButton){}}catch(e) {addCloneGeometryButton = false;}
 
+
 function getMousePosition(e) {
 	parent.mb_getMousePos(e, mod_digitize_target);
 	var currentPos = null;
@@ -201,12 +203,12 @@
 //		s.clean();
 	}
 
-	var el = mapWindow.document;
+	var el = mapDomElement;
 	el.onmousedown = mod_digitize_start;
 }
 
 function mod_digitize_timeout(){
-	var el = mapWindow.document;
+	var el = mapDomElement;
 	el.onmousedown = null;
 	el.onmouseup = null;
 	el.onmousemove = null;
@@ -475,11 +477,9 @@
 }
 
 function executeDigitizeSubFunctions(){
-//	console.profile();
 	for(var i=0; i<mod_digitizeSubFunctions.length; i++){
 		eval(mod_digitizeSubFunctions[i]);
 	}
-//	console.profileEnd();
 }
 
 function executeDigitizePreFunctions(){
@@ -718,7 +718,7 @@
 				obj.id == button_split || obj.id == button_merge ||
 				obj.id == button_difference){
 					
-		var el = mapWindow.document;
+		var el = mapDomElement;
 		el.onmousemove = mod_digitize_go;
 
 		mod_digitizeEvent = obj.id;
@@ -851,7 +851,8 @@
 			parent.mb_ajax_post("../php/mod_digitize_mergePolygon.php", {polygons: polygonTextArray.join(";")}, function(json, status) {
 				var response = eval('(' + json + ')');
 				var polygon = response.polygon;
-				d.importGeometryFromText(polygon);
+				var mapIndex = parent.getMapObjIndexByName(mod_digitize_target);
+				d.importGeometryFromText(polygon, parent.mb_mapObj[mapIndex].epsg);
 
 				// remove the original polygons
 				var len = d.count();
@@ -878,8 +879,9 @@
 				var response = eval('(' + json + ')');
 				var polygonArray = response.polygons;
 				var wfsConfId = d.get(0).wfs_conf;
+				var mapIndex = parent.getMapObjIndexByName(mod_digitize_target);
 				for (var i in polygonArray) {
-					d.importGeometryFromText(polygonArray[i]);
+					d.importGeometryFromText(polygonArray[i], parent.mb_mapObj[mapIndex].epsg);
 					d.get(-1).wfs_conf = wfsConfId;
 				}
 				// remove the original polygon and the temporary line
@@ -906,8 +908,9 @@
 				var polygonArray = response.polygons;
 				var wfsConfId = d.get(0).wfs_conf;
 				var wfsProperties = d.get(0).e;
+				var mapIndex = parent.getMapObjIndexByName(mod_digitize_target);
 				for (var i in polygonArray) {
-					d.importGeometryFromText(polygonArray[i]);
+					d.importGeometryFromText(polygonArray[i], parent.mb_mapObj[mapIndex].epsg);
 					d.get(-1).wfs_conf = wfsConfId;
 					d.get(-1).e = wfsProperties;
 				}
@@ -1213,15 +1216,20 @@
 
 					// button: remove this geometry
 					listOfGeom += "<img src = '"+buttonDig_imgdir+buttonDig_remove_src+"' title='"+msgObj.buttonDig_remove_title+"' onclick='parent.mb_disableThisButton(mod_digitizeEvent);d.del("+i+");executeDigitizeSubFunctions();'>";
+
+					// button clone this geometry
+					if (addCloneGeometryButton === true) {
+						listOfGeom += "<img src = '"+buttonDig_imgdir+buttonDig_clone_src+"' title='"+msgObj.buttonDig_clone_title+"' onclick='d.addCopy(d.get("+i+"));d.get(-1).e.delElement(\"fid\");executeDigitizeSubFunctions();'>";
+					}
 				}
 					
 				// button: remove geometry from database
 				if (d.get(i).e.getElementValueByName('fid')) {
 					listOfGeom += "<img src = '"+buttonDig_imgdir+buttonDig_removeDb_src+"' title='"+msgObj.buttonDig_removeDb_title+"' onclick=\"var deltrans = confirm('"+msgObj.messageConfirmDeleteGeomFromDb+"');if (deltrans) dbGeom('delete', "+i+")\">";
 				}
-				listOfGeom += "<div class='digitizeGeometryListItem' onmouseover='parent.mb_wfs_perform(\"over\",d.get("+i+"));' ";
-				listOfGeom += " onmouseout='parent.mb_wfs_perform(\"out\",d.get("+i+"))' ";
-				listOfGeom += " onclick='parent.mb_wfs_perform(\"click\",d.get("+i+"));' ";
+				listOfGeom += "<div class='digitizeGeometryListItem' onmouseover='parent.mb_wfs_perform(\"over\",d.get("+i+"),\""+geomHighlightColour+"\");' ";
+				listOfGeom += " onmouseout='parent.mb_wfs_perform(\"out\",d.get("+i+"),\""+geomHighlightColour+"\")' ";
+				listOfGeom += " onclick='parent.mb_wfs_perform(\"click\",d.get("+i+"),\""+geomHighlightColour+"\");' ";
 				var geomName = getName(d.get(i)); 
 				var currentGeomType;
 				if (d.get(i).geomType == parent.geomType.polygon) {
@@ -1248,9 +1256,9 @@
 						d.get(i).get(j).innerRings.count() > 0)) {
 						listOfGeom += "<li>";
 						listOfGeom += "<img src = '"+buttonDig_imgdir+buttonDig_remove_src+"' title='"+msgObj.buttonDig_remove_title+"' onclick='parent.mb_disableThisButton(mod_digitizeEvent);d.get("+i+").del(" + j + ");executeDigitizeSubFunctions();'>";
-						listOfGeom += "<div class='digitizeGeometryListItem' onmouseover='parent.mb_wfs_perform(\"over\",d.get("+i+").get("+j+"));' ";
-						listOfGeom += " onmouseout='parent.mb_wfs_perform(\"out\",d.get("+i+").get("+j+"))' ";
-						listOfGeom += " onclick='parent.mb_wfs_perform(\"click\",d.get("+i+").get("+j+"));' ";
+						listOfGeom += "<div class='digitizeGeometryListItem' onmouseover='parent.mb_wfs_perform(\"over\",d.get("+i+").get("+j+"),\""+geomHighlightColour+"\");' ";
+						listOfGeom += " onmouseout='parent.mb_wfs_perform(\"out\",d.get("+i+").get("+j+"),\""+geomHighlightColour+"\")' ";
+						listOfGeom += " onclick='parent.mb_wfs_perform(\"click\",d.get("+i+").get("+j+"),\""+geomHighlightColour+"\");' ";
 						listOfGeom += ">" + currentGeomType + "#" + (j+1) +"</div></li>";
 					}
 					if (d.get(i).geomType == geomType.polygon && 
@@ -1261,9 +1269,9 @@
 							var currentRing = d.get(i).get(j).innerRings.get(k);
 							listOfGeom += "<li>";
 							listOfGeom += "<img src = '"+buttonDig_imgdir+buttonDig_remove_src+"' title='"+msgObj.buttonDig_remove_title+"' onclick='parent.mb_disableThisButton(mod_digitizeEvent);d.get("+i+").get(" + j + ").innerRings.del(" + k + ");executeDigitizeSubFunctions();'>";
-							listOfGeom += "<div class='digitizeGeometryListItem' onmouseover='parent.mb_wfs_perform(\"over\",d.getGeometry("+i+","+j+").innerRings.get(" + k + "));' ";
-							listOfGeom += " onmouseout='parent.mb_wfs_perform(\"out\",d.getGeometry("+i+","+j+").innerRings.get(" + k + "))' ";
-							listOfGeom += " onclick='parent.mb_wfs_perform(\"click\",d.getGeometry("+i+","+j+").innerRings.get(" + k + "));' ";
+							listOfGeom += "<div class='digitizeGeometryListItem' onmouseover='parent.mb_wfs_perform(\"over\",d.getGeometry("+i+","+j+").innerRings.get(" + k + "),\""+geomHighlightColour+"\");' ";
+							listOfGeom += " onmouseout='parent.mb_wfs_perform(\"out\",d.getGeometry("+i+","+j+").innerRings.get(" + k + "),\""+geomHighlightColour+"\")' ";
+							listOfGeom += " onclick='parent.mb_wfs_perform(\"click\",d.getGeometry("+i+","+j+").innerRings.get(" + k + "),\""+geomHighlightColour+"\");' ";
 							listOfGeom += ">inner ring #" + (k+1) +"</div></li>";
 							
 						}
@@ -1298,9 +1306,10 @@
 	isCorrect = isCorrect && result.isCorrect;
 	errorMessage += result.errorMessage;
 
-	result = validBoxEntrySelected(form);
-	isCorrect = isCorrect && result.isCorrect;
-	errorMessage += result.errorMessage;
+	//select box is now checked within function mandatoryFieldsNotEmpty
+	//result = validBoxEntrySelected(form);
+	//isCorrect = isCorrect && result.isCorrect;
+	//errorMessage += result.errorMessage;
 
 	result = dataTypeIsCorrect(doc, form);
 	isCorrect = isCorrect && result.isCorrect;
@@ -1343,6 +1352,15 @@
 				}
 			}
 		}
+		if (nodeArray[i].nodeName.toUpperCase() == "SELECT" && nodeArray[i].type == "hidden" && nodeArray[i].id.substr(0,10) == "mandatory_") {
+			var nodeId = nodeArray[i].id.substr(10);
+			if (nodeArray[i].value == "true") {
+				if (parseInt(form.childNodes[i].selectedIndex) == 0) {
+					isCorrect = false;
+					errorMessage += "'"+ doc.getElementById(nodeId).name +"': "+ msgObj.messageErrorFieldIsEmpty +"\n";
+				}
+			}
+		}
 	}
 	return {"isCorrect":isCorrect, "errorMessage":errorMessage};
 }
@@ -1479,7 +1497,7 @@
 function showWfsKml (geometryIndex) {
 	wfsKmlWindow = open("", "wfsattributes", "width="+wfsWindowWidth+", height="+wfsWindowHeight+", resizable, dependent=yes, scrollbars=yes");
 	wfsKmlWindow.document.open("text/html");
-	wfsKmlWindow.document.writeln("<html><head></head><body><div id='linkToKml'></div><div id='elementForm'></div></body></html>");
+	wfsKmlWindow.document.writeln("<html><head><meta http-equiv='Content-Type' content='text/html; charset=<?php echo CHARSET;?>'></head><body><div id='linkToKml'></div><div id='elementForm'></div></body></html>");
 	wfsKmlWindow.document.close();
 	
 	str = "<form id = 'wmsKmlForm' onsubmit='return false;'><table>";
@@ -1562,13 +1580,13 @@
 	str += "<div id='elementForm'>\n</div>";
 	
 	if (defaultIndex != -1) {
-		wfsWindow.document.writeln("<html><head><style type='text/css'>"+wfsConf[defaultIndex]['g_style']+"</style></head><body></body></html>");
+		wfsWindow.document.writeln("<html><head><meta http-equiv='Content-Type' content='text/html; charset=<?php echo CHARSET;?>'><style type='text/css'>"+wfsConf[defaultIndex]['g_style']+"</style></head><body></body></html>");
 		wfsWindow.document.write(str);
 		wfsWindow.document.close();
 		wfsWindow.document.getElementById("elementForm").innerHTML = buildElementForm(defaultIndex, geometryIndex);
 	}
 	else {
-		wfsWindow.document.writeln("<html><head><style type='text/css'></style></head><body></body></html>");
+		wfsWindow.document.writeln("<html><head><meta http-equiv='Content-Type' content='text/html; charset=<?php echo CHARSET;?>'><style type='text/css'></style></head><body></body></html>");
 		wfsWindow.document.write(str);
 		wfsWindow.document.close();
 	}
@@ -1633,7 +1651,7 @@
 						}
 					}
 					var formElementHtml = featureTypeElement['f_form_element_html']; 
-					if (!formElementHtml || !formElementHtml.match(/<select/)) {
+					if (!formElementHtml || !formElementHtml.match(/&lt;select/)) {
 						str += "\t\t\t\t<input id = 'datatype_mb_digitize_form_" + elementName + "' name='datatype' type='hidden' value = '" + elementType + "'>\n";
 						str += "\t\t\t\t<input id = 'mandatory_mb_digitize_form_" + elementName + "' name='mandatory' type='hidden' value = '" + isMandatory + "'>\n";
 						str += "\t\t\t\t<input id = 'mb_digitize_form_" + elementName + "' name='" + elementLabel + "' type='text' class = '"+featureTypeElement['f_style_id']+"' size=20 value = '" + elementValue + "'>\n";
@@ -1642,11 +1660,17 @@
 							while (formElementHtml.match(/\\/)) {
 								formElementHtml = formElementHtml.replace(/\\/, "");
 							} 
+							str += "\t\t\t\t<input id = 'datatype_" + elementName + "' name='datatype' type='hidden' value = '" + elementType + "'>\n";
+							str += "\t\t\t\t<input id = 'mandatory_" + elementName + "' name='mandatory' type='hidden' value = '" + isMandatory + "'>\n";
 							// preselect the correct entry of the box
 							var patternString = "option value( )*=( )*'"+elementValue+"'";
 							var pattern = new RegExp(patternString);
 							var patternStringForReplace = "option value = '"+elementValue+"'";
 							formElementHtml = formElementHtml.replace(pattern, patternStringForReplace+" selected");
+							formElementHtml = formElementHtml.replace(/&lt;/g,'<');
+							formElementHtml = formElementHtml.replace(/&gt;/g,'>');
+							formElementHtml = formElementHtml.replace(/&#039;/g,'\'');
+							
 							str += formElementHtml;
 					}
 					str += "\t\t\t</td>\n\t\t</tr>\n";

Modified: branches/print_dev/http/javascripts/mod_dynamicOverview.php
===================================================================
--- branches/print_dev/http/javascripts/mod_dynamicOverview.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_dynamicOverview.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -52,35 +52,45 @@
 var mod_dynamicOverviewCount = 0;
 var mod_dynamicOverviewSwitch = false;
 
-mb_registerPreFunctions("mod_dynamicOverviewCalculateExtent(frameName)");
-mb_registerSubFunctions("mod_dynamicOverviewSetVisibility(frameName)");
+eventBeforeMapRequest.register(function (obj) {
+	mod_dynamicOverviewCalculateExtent(obj.map);
+});
 
-function mod_dynamicOverviewCalculateExtent(frameName){
+eventAfterMapRequest.register(function (obj) {
+	mod_dynamicOverviewSetVisibility(obj.map);
+});
+
+function mod_dynamicOverviewCalculateExtent (map) {
 	var arrayTargets = mod_dynamicOverview_target.split(",");
 	var disty = false;
 	var distx = false;
+
+	var map0 = getMapObjByName(arrayTargets[0]);
+	var map1 = getMapObjByName(arrayTargets[1]);
+	
 	//set extent for the main mapframe from configuration param element_var
-	if(mod_dynamicOverview_startExtent && mod_dynamicOverviewCount == 0){
+	if (mod_dynamicOverview_startExtent && mod_dynamicOverviewCount == 0){
 		mod_dynamicOverviewCount++;
 		var arrayCoords = mod_dynamicOverview_startExtent.split(",");
 		var minx = parseFloat(arrayCoords[0]);
 		var miny = parseFloat(arrayCoords[1]);
 		var maxx = parseFloat(arrayCoords[2]);
 		var maxy = parseFloat(arrayCoords[3]);
-		mb_calculateExtent(arrayTargets[0],minx,miny,maxx,maxy);
+		var newExtent = new Extent(minx, miny, maxx, maxy)
+		map0.calculateExtent(newExtent);
 	}
+
 	// read params from main-mapframe
-	if(frameName == arrayTargets[0]){
-		var ind = getMapObjIndexByName(frameName);
-		
+	if (map.elementName == map0.elementName) {
+
 		// get center in coords:
-		var coords = mb_mapObj[ind].extent.split(",");
+		var coords = map0.extent.split(",");
 		var minx = parseFloat(coords[0]);
 		var miny = parseFloat(coords[1]);
 		var maxx = parseFloat(coords[2]);
 		var maxy = parseFloat(coords[3]);
 		distx = maxx - minx;
-		disty   = maxy - miny;
+		disty = maxy - miny;
 		var centerx = minx + distx/2;
 		var centery = miny + disty/2;
 		
@@ -91,7 +101,7 @@
 			maxx = centerx + ((distx/2)*mod_dynamicOverview_zoomFactor);
 			maxy = centery + ((disty/2)*mod_dynamicOverview_zoomFactor);
 			distx = maxx - minx;
-		    disty   = maxy - miny; 
+		    disty = maxy - miny; 
 		}
 		
 		// check and set maxExtent for orverview 
@@ -120,19 +130,19 @@
 			}	
 		}
 		//check and set minExtent for overview
-		var newMinExt = mod_dynamicOverviewCheckDiagonal(arrayTargets[1], minx,miny, maxx, maxy);
+		var newMinExt = mod_dynamicOverviewCheckDiagonal(map1, minx,miny, maxx, maxy);
 		if(newMinExt){
-//			console.log("newMin: "+newMinExt);
 			var minCoords = newMinExt.split(",");
 			minx = 	parseFloat(minCoords[0]);	
 			miny = 	parseFloat(minCoords[1]);
 			maxx = 	parseFloat(minCoords[2]);
 			maxy = 	parseFloat(minCoords[3]);
 		}
-		mb_calculateExtent(arrayTargets[1],minx,miny,maxx,maxy)
-		zoom(arrayTargets[1],true, 1.0);
+		var newExtent = new Extent(minx, miny, maxx, maxy)
+		map1.calculateExtent(newExtent);
+		map1.zoom(true, 1.0);
 	}
-	else if(frameName == arrayTargets[1]){
+	else if(map.elementName == map1.elementName){
 		//switch hidden wms to visible
 		if(wms[mod_dynamicOverview_wmsIndex].gui_wms_visible != 1){
 			mod_dynamicOverviewSwitch = wms[mod_dynamicOverview_wmsIndex].gui_wms_visible;
@@ -140,19 +150,18 @@
 		}
 	}
 }
-function mod_dynamicOverviewCheckDiagonal(frameName, minx,miny, maxx, maxy){
+
+function mod_dynamicOverviewCheckDiagonal(map, minx,miny, maxx, maxy){
 	var r = false;
-	var ind = getMapObjIndexByName(frameName);
 	var distx = maxx-minx;
 	var disty = maxy-miny;
 	var centerx = minx + distx/2;
 	var centery = miny + distx/2;
-	var xPerPix = distx/mb_mapObj[ind].width;
-	var yPerPix = disty/mb_mapObj[ind].height;
+	var xPerPix = distx/map.width;
+	var yPerPix = disty/map.height;
 	var d = Math.sqrt(Math.pow(xPerPix,2)+Math.pow(yPerPix,2));
 	if(mod_dynamicOverview_minScale && mod_dynamicOverview_minScale > d){
-		var newDistx = Math.sqrt(Math.pow((mod_dynamicOverview_minScale),2)/2)*mb_mapObj[ind].width;
-//		console.log(newDistx);
+		var newDistx = Math.sqrt(Math.pow((mod_dynamicOverview_minScale),2)/2)*map.width;
 		minx = centerx - newDistx/2;
 		maxx = centerx + newDistx/2;
 		miny = centery - newDistx/2;
@@ -161,19 +170,20 @@
 	}
 	return r;
 }
-function mod_dynamicOverviewSetVisibility(frameName){
+
+function mod_dynamicOverviewSetVisibility(map){
 	var arrayTargets = mod_dynamicOverview_target.split(",");
-	if(mod_dynamicOverviewSwitch && frameName == arrayTargets[1]){
+	if(mod_dynamicOverviewSwitch && map.elementName == arrayTargets[1]){
 		wms[mod_dynamicOverview_wmsIndex].gui_wms_visible = mod_dynamicOverviewSwitch;
 		
 	}	
 }
+
 function mod_dynamicOverviewGetMaxExtent(wms, srs){
 	var re = false;
 	for(var i=0; i<wms.gui_epsg.length; i++){
 		if(srs == wms.gui_epsg[i]){
 			var re = wms.gui_minx[i] +","+ wms.gui_miny[i]  +","+ wms.gui_maxx[i] +","+ wms.gui_maxy[i];
-//			window.console.log(re);	
 		}
 	}
 	return re;

Modified: branches/print_dev/http/javascripts/mod_exportMapImage.php
===================================================================
--- branches/print_dev/http/javascripts/mod_exportMapImage.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_exportMapImage.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,166 +1,166 @@
-<?php
-# $Id$
-# http://www.mapbender.org/ExportMapimage
-# 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_validatePermission.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>Export Mapimage</title>
-<?php
- include '../include/dyn_css.php';
-?>
-</head>
-<style type="text/css">
-<!-- 
- 
-input{
-	width:50px;
-    font-family: Arial, Helvetica, sans-serif;
-	font-size: 12px;
-}
-div{
-	font-family : Arial, Helvetica, sans-serif;
-	font-size: 12px;
-}
-.imageformat{
-	width:50px;
-	font-family : Arial, Helvetica, sans-serif;
-	font-size: 14px;
-    font-weight: bold;
-}
-
--->
-</style>
-<?php
-
-
-
-echo "<script type='text/javascript'>";
-echo "var target = '".$_REQUEST["target"]."';";
-
-echo "</script>";
-?>
-<script type="text/javascript">
-
-
-// some defaults
-try{if (pngExport){}}catch(e){pngExport = 'true';}
-try{if (jpegExport){}}catch(e){jpegExport = 'true';}
-try{if (geotiffExport){}}catch(e){geotiffExport = 'true';}
-
-
-function generateExportOptions(){
-if (pngExport=='true'){
-	document.write('<tr><td><span class="imageformat"><input type="radio" name="imageformat" value="png">PNG</span></td></tr>');		
-}
-if (jpegExport=='true'){
-	document.write('<tr><td><span class="imageformat"><input type="radio" name="imageformat" value="jpeg">JPEG / JPG</span></td></tr>');		
-}
-if (geotiffExport=='true'){
-	document.write('<tr><td><span class="imageformat"><input type="radio" name="imageformat" value="geotiff">GeoTIFF</span></td></tr>');		
-}
-
-
-
-}
-
-function exportMapimage(){
-		
-	choosen = "";
-	len = document.form1.imageformat.length;
-	
-	for (i = 0; i <len; i++) {
-		if (document.form1.imageformat[i].checked) {
-			choosen = document.form1.imageformat[i].value;
-		}
-	}
-	
-	if (choosen == "") {
-		alert("Keine Wahl getroffen, per DEFAULT wird die Karte als PNG exportiert");
-		choosen = document.form1.imageformat[0].value;
-	}
-	else {
-		//alert(choosen)
-	}
-
-	
-	var idx = window.opener.getMapObjIndexByName(target);
-	
-    
-	var wms_string = "";
-    
-	for(var ii=0; ii<window.opener.mb_mapObj[idx].wms.length; ii++){
-
-    
-    if (window.opener.mb_mapObj[idx].mapURL[ii] == false || typeof(window.opener.mb_mapObj[idx].mapURL[ii]) == 'undefined' || window.opener.mb_mapObj[idx].mapURL[ii] == 'undefined'){
-				
-				//alert('Keine WMSe vorhanden.');
-			} else{
-
-   				if (ii==0){
-					wms_string = window.opener.mb_mapObj[idx].mapURL[ii];	
-				} else {
-					wms_string += "___"+window.opener.mb_mapObj[idx].mapURL[ii];
-				}
-			}		
-	}
-	wms_string = encodeURIComponent(wms_string);
-	var myLocation = "../php/mod_exportMapImage_server.php?target="+target+"&imagetype="+choosen+"&wms_urls="+wms_string;
-	//mynewwin = window.open("../php/mod_exportMapImage_server.php?target="+target+"&imagetype="+choosen+"&wms_urls="+wms_string+"","exportMapImage","width=180, height=200, resizable=yes ");
-	document.location.href = myLocation; 
-	
-//	alert('ImageExport done');
-//	window.close();
-	
-}
-
-function close_exportMapimage(){
-	window.close();
-}
-
-</script>
-<body>
-<form name='form1' method='POST' action='' target="_blank" onSubmit="return FormCheck()">
-<table border='0'>
-<div>Please select a format for the exported image!</div><br>
-
-<script type="text/javascript"> generateExportOptions();
-</script>
-
-<tr>
-<td> <br><br> </td>
-</tr>
-
-</table>  
-<div id="buttons" align='right'>
-		<input type='button' name='expImg_ok' value="OK" onclick='exportMapimage();'>
-		<input type='button' name='expImg_close' value="Close" onclick='close_exportMapimage();'>
-</div>
-</form>
-</body>
-</html>
+<?php
+# $Id$
+# http://www.mapbender.org/ExportMapimage
+# 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_validatePermission.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>Export Mapimage</title>
+<?php
+ include '../include/dyn_css.php';
+?>
+</head>
+<style type="text/css">
+<!-- 
+ 
+input{
+	width:50px;
+    font-family: Arial, Helvetica, sans-serif;
+	font-size: 12px;
+}
+div{
+	font-family : Arial, Helvetica, sans-serif;
+	font-size: 12px;
+}
+.imageformat{
+	width:50px;
+	font-family : Arial, Helvetica, sans-serif;
+	font-size: 14px;
+    font-weight: bold;
+}
+
+-->
+</style>
+<?php
+
+
+
+echo "<script type='text/javascript'>";
+echo "var target = '".$_REQUEST["target"]."';";
+
+echo "</script>";
+?>
+<script type="text/javascript">
+
+
+// some defaults
+try{if (pngExport){}}catch(e){pngExport = 'true';}
+try{if (jpegExport){}}catch(e){jpegExport = 'true';}
+try{if (geotiffExport){}}catch(e){geotiffExport = 'true';}
+
+
+function generateExportOptions(){
+if (pngExport=='true'){
+	document.write('<tr><td><span class="imageformat"><input type="radio" name="imageformat" value="png">PNG</span></td></tr>');		
+}
+if (jpegExport=='true'){
+	document.write('<tr><td><span class="imageformat"><input type="radio" name="imageformat" value="jpeg">JPEG / JPG</span></td></tr>');		
+}
+if (geotiffExport=='true'){
+	document.write('<tr><td><span class="imageformat"><input type="radio" name="imageformat" value="geotiff">GeoTIFF</span></td></tr>');		
+}
+
+
+
+}
+
+function exportMapimage(){
+		
+	choosen = "";
+	len = document.form1.imageformat.length;
+	
+	for (i = 0; i <len; i++) {
+		if (document.form1.imageformat[i].checked) {
+			choosen = document.form1.imageformat[i].value;
+		}
+	}
+	
+	if (choosen == "") {
+		alert("Keine Wahl getroffen, per DEFAULT wird die Karte als PNG exportiert");
+		choosen = document.form1.imageformat[0].value;
+	}
+	else {
+		//alert(choosen)
+	}
+
+	
+	var idx = window.opener.getMapObjIndexByName(target);
+	
+    
+	var wms_string = "";
+    
+	for(var ii=0; ii<window.opener.mb_mapObj[idx].wms.length; ii++){
+
+    
+    if (window.opener.mb_mapObj[idx].mapURL[ii] == false || typeof(window.opener.mb_mapObj[idx].mapURL[ii]) == 'undefined' || window.opener.mb_mapObj[idx].mapURL[ii] == 'undefined'){
+				
+				//alert('Keine WMSe vorhanden.');
+			} else{
+
+   				if (ii==0){
+					wms_string = window.opener.mb_mapObj[idx].mapURL[ii];	
+				} else {
+					wms_string += "___"+window.opener.mb_mapObj[idx].mapURL[ii];
+				}
+			}		
+	}
+	wms_string = encodeURIComponent(wms_string);
+	var myLocation = "../php/mod_exportMapImage_server.php?target="+target+"&imagetype="+choosen+"&wms_urls="+wms_string;
+	//mynewwin = window.open("../php/mod_exportMapImage_server.php?target="+target+"&imagetype="+choosen+"&wms_urls="+wms_string+"","exportMapImage","width=180, height=200, resizable=yes ");
+	document.location.href = myLocation; 
+	
+//	alert('ImageExport done');
+//	window.close();
+	
+}
+
+function close_exportMapimage(){
+	window.close();
+}
+
+</script>
+<body>
+<form name='form1' method='POST' action='' target="_blank" onSubmit="return FormCheck()">
+<table border='0'>
+<div>Please select a format for the exported image!</div><br>
+
+<script type="text/javascript"> generateExportOptions();
+</script>
+
+<tr>
+<td> <br><br> </td>
+</tr>
+
+</table>  
+<div id="buttons" align='right'>
+		<input type='button' name='expImg_ok' value="OK" onclick='exportMapimage();'>
+		<input type='button' name='expImg_close' value="Close" onclick='close_exportMapimage();'>
+</div>
+</form>
+</body>
+</html>

Modified: branches/print_dev/http/javascripts/mod_featureInfo.php
===================================================================
--- branches/print_dev/http/javascripts/mod_featureInfo.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_featureInfo.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -21,6 +21,14 @@
 include '../include/dyn_js.php';
 //defaults for element vars
 ?>
+try {
+	if (ignoreWms) {
+	}
+}
+catch (e) {
+	ignoreWms = [];
+}
+
 if(typeof(featureInfoLayerPopup)==='undefined')
 	var featureInfoLayerPopup = 'false';
 if(typeof(featureInfoPopupHeight)==='undefined')
@@ -28,7 +36,7 @@
 if(typeof(featureInfoPopupWidth)==='undefined')
 	var featureInfoPopupWidth = '270';
 
-var mod_featureInfo_elName = "featureInfo1";
+var mod_featureInfo_elName = "<?php echo $e_id;?>";
 var mod_featureInfo_frameName = "";
 var mod_featureInfo_target = "<?php echo $e_target[0]; ?>";
 var mod_featureInfo_mapObj = null;
@@ -37,19 +45,25 @@
 var mod_featureInfo_img_off = new Image(); mod_featureInfo_img_off.src ="<?php  echo $e_src;  ?>";
 var mod_featureInfo_img_over = new Image(); mod_featureInfo_img_over.src = "<?php  echo preg_replace("/_off/","_over",$e_src);  ?>";
 
-function init_featureInfo1(ind){
-	mod_featureInfo_mapObj = getMapObjByName(mod_featureInfo_target);
+eventInit.register(function () {
+	mb_regButton(function init_featureInfo1(ind){
+		mod_featureInfo_mapObj = getMapObjByName(mod_featureInfo_target);
 	
-	mb_button[ind] = document.getElementById(mod_featureInfo_elName);
-	mb_button[ind].img_over = mod_featureInfo_img_over.src;
-	mb_button[ind].img_on = mod_featureInfo_img_on.src;
-	mb_button[ind].img_off = mod_featureInfo_img_off.src;
-	mb_button[ind].status = 0;
-	mb_button[ind].elName = mod_featureInfo_elName;
-	mb_button[ind].fName = mod_featureInfo_frameName;
-	mb_button[ind].go = new Function ("mod_featureInfo_click()");
-	mb_button[ind].stop = new Function ("mod_featureInfo_disable()");
-}
+		mb_button[ind] = document.getElementById(mod_featureInfo_elName);
+		mb_button[ind].img_over = mod_featureInfo_img_over.src;
+		mb_button[ind].img_on = mod_featureInfo_img_on.src;
+		mb_button[ind].img_off = mod_featureInfo_img_off.src;
+		mb_button[ind].status = 0;
+		mb_button[ind].elName = mod_featureInfo_elName;
+		mb_button[ind].fName = mod_featureInfo_frameName;
+		mb_button[ind].go = function () {
+			mod_featureInfo_click();
+		};
+		mb_button[ind].stop = function () {
+			mod_featureInfo_disable();
+		};
+	});
+});
 function mod_featureInfo_click(){   
 	mod_featureInfo_mapObj.getDomElement().onclick = mod_featureInfo_event;
 }
@@ -71,7 +85,7 @@
 		}
 	}
 	else{
-		urls = mod_featureInfo_mapObj.getFeatureInfoRequests(point);
+		urls = mod_featureInfo_mapObj.getFeatureInfoRequests(point, ignoreWms);
 		if(urls){
 			for(var i=0;i<urls.length;i++){
 				if(featureInfoLayerPopup == 'true'){

Modified: branches/print_dev/http/javascripts/mod_forward.php
===================================================================
--- branches/print_dev/http/javascripts/mod_forward.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_forward.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -31,7 +31,7 @@
 var mod_forward_img_previous = mod_forward_img_off_disabled.src;
 
 eventAfterMapRequest.register(function (obj) {
-	mod_forward_check(obj.frameName);
+	mod_forward_check(obj.map.elementName);
 });
 
 $('#<?php echo $e_id;?>').mouseover(function () {

Modified: branches/print_dev/http/javascripts/mod_help.php
===================================================================
--- branches/print_dev/http/javascripts/mod_help.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_help.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -47,56 +47,61 @@
 });
 
 function mod_help_click(){
-		//create html tags
-		mod_help_set();
-		//request help string
-		var usemapHtml = "";
-		for (var module in Mapbender.Modules) {
-			var currentModule = Mapbender.Modules[module];
-			var top = parseInt(currentModule.top) || 0;
-			var left = parseInt(currentModule.left) || 0;
-			var width = parseInt(currentModule.width) || 0;
-			var height = parseInt(currentModule.height) || 0;
-			
-			usemapHtml += "<area id='helpArea_" + module + "' " + 
-				"shape='rect' coords='" + left + "," + 
-				top + "," + (parseInt(left + width)) + "," + 
-				parseInt(top + height) + "' href='#' " + 
-				"alt='" + ((currentModule.id == mod_help_elName) ? mod_help_text : "HELP: " + currentModule.url) + "' " +
-				"title='" + ((currentModule.id == mod_help_elName) ? mod_help_text : "HELP: " + currentModule.url) + "' " + 
-				"nohref />";
-
-		}		
-			
-		var transparentImgHtml = "<img src='../img/transparent.gif' style='cursor:help' " + 
-			"width='" + mod_help_width + "' height='" + mod_help_height + 
-			"' usemap='#mod_help_imagemap' border='0'>";
+	//create html tags
+	mod_help_set();
+	//request help string
+	var usemapHtml = "";
+	for (var module in Mapbender.Modules) {
+		var currentModule = Mapbender.Modules[module];
+		var top = parseInt(currentModule.top) || 0;
+		var left = parseInt(currentModule.left) || 0;
+		var width = parseInt(currentModule.width) || 0;
+		var height = parseInt(currentModule.height) || 0;
 		
-		var html = "<div id='helpMapContainer'>" + transparentImgHtml + "<map name='mod_help_imagemap'>" + usemapHtml + "</map></div>";
+		if (!currentModule.url) {
+			continue;
+		}
+		usemapHtml += "<area id='helpArea_" + module + "' " + 
+			"shape='rect' coords='" + left + "," + 
+			top + "," + (parseInt(left + width)) + "," + 
+			parseInt(top + height) + "' href='#' " + 
+			"alt='" + ((currentModule.id == mod_help_elName) ? mod_help_text : "HELP: " + currentModule.url) + "' " +
+			"title='" + ((currentModule.id == mod_help_elName) ? mod_help_text : "HELP: " + currentModule.url) + "' " + 
+			"nohref />";
 
-		$('#mod_help_img').empty().html(html);
+	}		
+	
+	var transparentImgHtml = "<img src='../img/transparent.gif' style='cursor:help' " + 
+		"width='" + mod_help_width + "' height='" + mod_help_height + 
+		"' usemap='#mod_help_imagemap' border='0'>";
+	
+	var html = "<div id='helpMapContainer'>" + transparentImgHtml + "<map name='mod_help_imagemap'>" + usemapHtml + "</map></div>";
 
-		for (var module in Mapbender.Modules) {
-			(function () {
-				var currentModule = Mapbender.Modules[module];
+	$('#mod_help_img').empty().html(html);
+
+	for (var module in Mapbender.Modules) {
+		(function () {
+			var currentModule = Mapbender.Modules[module];
+			if (currentModule.url) {
 				$("#helpArea_" + module).click(function () {
 					mod_help_disable();
 					var w = window.open(currentModule.url, "help");
 				});
-			}());
-		}
-			
-		mod_help_set_str();
-		return;
-	
+			}
+		}());
+	}
+		
 	mod_help_set_str();
+	return;
 }
 
 function mod_help_disable(){
-	document.getElementById('mod_help_img').innerHTML = '';
-	document.getElementById('mod_help_img').style.width = '0px';
-	document.getElementById('mod_help_img').style.height = '0px';
-	document.getElementById('mod_help_draw').innerHTML = '';
+	$('#mod_help_img').empty().css({
+		width: '0px',
+		height: '0px'
+	});
+	$('#mod_help_draw').empty();
+	
 	mb_disableThisButton(mod_help_elName);
 }
 function mod_help_set(){
@@ -145,7 +150,7 @@
 		}
 	}
 	catch(e){
-		console.log(e);
+		var e = new Mb_warning(e);
 	}
 }
 

Modified: branches/print_dev/http/javascripts/mod_highlightPOI.php
===================================================================
--- branches/print_dev/http/javascripts/mod_highlightPOI.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_highlightPOI.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,148 +1,152 @@
-<?php
-# $Id$ 
-# http://www.mapbender.org/index.php/mod_highlightPOI.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");
-
-echo "var mod_highlightPOI_target = '".$e_target[0]."';";
-
-include('../include/dyn_js.php');
-
-?>
-try{
-	if (poi_image){}
-}
-catch(e){
-	poi_image = '../img/redball.gif';
-}
-
-try{
-	if (poi_width){}
-}
-catch(e){
-	poi_width = 14;
-}
-
-try{
-	if (poi_height){}
-}
-catch(e){
-	poi_height = 14;
-}
-
-try{
-	if (poi_style){}
-}
-catch(e){
-	poi_style = 'background-color:white;font-weight: bold;color:black;font-family:Arial;';
-}
-
-eventInit.register(function () {
-	mod_highlightPOI_init();
-});
-eventAfterMapRequest.register(function () {
-	mod_highlightPOI_draw();
-});
-
-var mod_highlightPOI_minx;
-var mod_highlightPOI_miny;
-var mod_highlightPOI_maxx;
-var mod_highlightPOI_maxy;
-var mod_highlightPOI_name = new Array();
-var mod_highlightPOI_x = new Array();
-var mod_highlightPOI_y = new Array();
-var mod_highlightPOI_params = new Array();
-var myPOI;
-
-function mod_highlightPOI_init(){
-		var myPOI = "<?php if (CHARSET == 'UTF-8'){
-				echo preg_replace("/\n/", "<br>", $_SESSION['mb_myPOI']);
-			}else{
-				echo preg_replace("/\n/", "<br>", utf8_decode($_SESSION['mb_myPOI']));
-			} 
-			?>";
-
-	if(myPOI != ""){
- 		mod_highlightPOI_params = myPOI.split("|");
-
-	  
-  
-	  for(var i=0; i<mod_highlightPOI_params.length; i=i+3){
-	    if(i==0){
-	      mod_highlightPOI_name[i] = mod_highlightPOI_params[i];
-	      mod_highlightPOI_minx = parseInt(mod_highlightPOI_params[i+1]);
-	      mod_highlightPOI_miny = parseInt(mod_highlightPOI_params[i+2]);
-	      mod_highlightPOI_maxx = parseInt(mod_highlightPOI_params[i+1]);
-	      mod_highlightPOI_maxy = parseInt(mod_highlightPOI_params[i+2]);
-	    }  
-	    else{
-	      mod_highlightPOI_name[i] = mod_highlightPOI_params[i];
-	      if(mod_highlightPOI_params[i+1] < mod_highlightPOI_minx){
-	        mod_highlightPOI_minx = parseInt(mod_highlightPOI_params[i+1]);
-	      }
-	      if(mod_highlightPOI_params[i+2] < mod_highlightPOI_miny){
-	        mod_highlightPOI_miny = parseInt(mod_highlightPOI_params[i+2]);
-	      }
-	      if(mod_highlightPOI_params[i+1] > mod_highlightPOI_maxx){
-	        mod_highlightPOI_maxx = parseInt(mod_highlightPOI_params[i+1]);
-	      }
-	      if(mod_highlightPOI_params[i+2] > mod_highlightPOI_maxy){
-	        mod_highlightPOI_maxy = parseInt(mod_highlightPOI_params[i+2]);
-	      }  
-	    }
-	  }
-	  if((mod_highlightPOI_maxx - mod_highlightPOI_minx) < 100){
-	    mod_highlightPOI_minx -= 50;
-	    mod_highlightPOI_maxx += 50;
-	  }
-	  if((mod_highlightPOI_maxy - mod_highlightPOI_miny) < 100){
-	    mod_highlightPOI_miny -= 50;
-	    mod_highlightPOI_maxy += 50;
-	  }
-	  mod_highlightPOI_minx -= 50;
-	  mod_highlightPOI_maxx += 50;
-	  mod_highlightPOI_miny -= 50;
-	  mod_highlightPOI_maxy += 50;
-	  //mb_calculateExtent( mod_highlightPOI_target,mod_highlightPOI_minx,mod_highlightPOI_miny,mod_highlightPOI_maxx,mod_highlightPOI_maxy);
-  }
-}
-
-
-function mod_highlightPOI_draw(){
-  var ind = getMapObjIndexByName(mod_highlightPOI_target);
-  var div = new DivTag(mod_highlightPOI_target+'permanent', mb_mapObj[ind].frameName, 
-  	{
-		"position":"absolute",
-		"width":mb_mapObj[ind].width+"px",
-		"height":mb_mapObj[ind].height+"px",
-		"top":0,
-		"left":0,
-		"width":0,
-		"height":0,
-		"visibility":"visible"
-	});
-  var tagSource = "";
-  for(var i=0; i<mod_highlightPOI_params.length; i=i+3){
-    var pos = makeRealWorld2mapPos(mod_highlightPOI_target,mod_highlightPOI_params[i+1], mod_highlightPOI_params[i+2]);
-    tagSource += "<div style='z-index:13;position:absolute;left:"+(pos[0]-Math.round(0.5*poi_width))+"px;top:"+(pos[1]-Math.round(0.5*poi_height))+"px'>";
-    tagSource += "<img src='"+poi_image+"'>";
-    tagSource += "<span style='"+poi_style+"'>"+mod_highlightPOI_params[i]+"<span>";
-    tagSource += "</div>";
-  }
-  div.write(tagSource);
-}
+<?php
+# $Id$ 
+# http://www.mapbender.org/index.php/mod_highlightPOI.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");
+
+echo "var mod_highlightPOI_target = '".$e_target[0]."';";
+
+include('../include/dyn_js.php');
+
+?>
+try{
+	if (poi_image){}
+}
+catch(e){
+	poi_image = '../img/redball.gif';
+}
+
+try{
+	if (poi_width){}
+}
+catch(e){
+	poi_width = 14;
+}
+
+try{
+	if (poi_height){}
+}
+catch(e){
+	poi_height = 14;
+}
+
+try{
+	if (poi_style){}
+}
+catch(e){
+	poi_style = 'background-color:white;font-weight: bold;color:black;font-family:Arial;';
+}
+
+eventInit.register(function () {
+	mod_highlightPOI_init();
+});
+eventAfterMapRequest.register(function () {
+	mod_highlightPOI_draw();
+});
+
+var mod_highlightPOI_minx;
+var mod_highlightPOI_miny;
+var mod_highlightPOI_maxx;
+var mod_highlightPOI_maxy;
+var mod_highlightPOI_name = new Array();
+var mod_highlightPOI_x = new Array();
+var mod_highlightPOI_y = new Array();
+var mod_highlightPOI_params = new Array();
+var myPOI;
+
+function mod_highlightPOI_init(){
+		var myPOI = "<?php if (CHARSET == 'UTF-8'){
+				echo preg_replace("/\n/", "<br>", $_SESSION['mb_myPOI']);
+			}else{
+				echo preg_replace("/\n/", "<br>", utf8_decode($_SESSION['mb_myPOI']));
+			} 
+			?>";
+
+	if(myPOI != ""){
+ 		mod_highlightPOI_params = myPOI.split("|");
+
+	  
+  
+	  for(var i=0; i<mod_highlightPOI_params.length; i=i+3){
+	    if(i==0){
+	      mod_highlightPOI_name[i] = mod_highlightPOI_params[i];
+	      mod_highlightPOI_minx = parseInt(mod_highlightPOI_params[i+1]);
+	      mod_highlightPOI_miny = parseInt(mod_highlightPOI_params[i+2]);
+	      mod_highlightPOI_maxx = parseInt(mod_highlightPOI_params[i+1]);
+	      mod_highlightPOI_maxy = parseInt(mod_highlightPOI_params[i+2]);
+	    }  
+	    else{
+	      mod_highlightPOI_name[i] = mod_highlightPOI_params[i];
+	      if(mod_highlightPOI_params[i+1] < mod_highlightPOI_minx){
+	        mod_highlightPOI_minx = parseInt(mod_highlightPOI_params[i+1]);
+	      }
+	      if(mod_highlightPOI_params[i+2] < mod_highlightPOI_miny){
+	        mod_highlightPOI_miny = parseInt(mod_highlightPOI_params[i+2]);
+	      }
+	      if(mod_highlightPOI_params[i+1] > mod_highlightPOI_maxx){
+	        mod_highlightPOI_maxx = parseInt(mod_highlightPOI_params[i+1]);
+	      }
+	      if(mod_highlightPOI_params[i+2] > mod_highlightPOI_maxy){
+	        mod_highlightPOI_maxy = parseInt(mod_highlightPOI_params[i+2]);
+	      }  
+	    }
+	  }
+	  if((mod_highlightPOI_maxx - mod_highlightPOI_minx) < 100){
+	    mod_highlightPOI_minx -= 50;
+	    mod_highlightPOI_maxx += 50;
+	  }
+	  if((mod_highlightPOI_maxy - mod_highlightPOI_miny) < 100){
+	    mod_highlightPOI_miny -= 50;
+	    mod_highlightPOI_maxy += 50;
+	  }
+	  mod_highlightPOI_minx -= 50;
+	  mod_highlightPOI_maxx += 50;
+	  mod_highlightPOI_miny -= 50;
+	  mod_highlightPOI_maxy += 50;
+	  //mb_calculateExtent( mod_highlightPOI_target,mod_highlightPOI_minx,mod_highlightPOI_miny,mod_highlightPOI_maxx,mod_highlightPOI_maxy);
+  }
+}
+
+
+function mod_highlightPOI_draw(){
+	var mapObject = getMapObjByName(mod_highlightPOI_target);
+	var map_el = mapObject.getDomElement();
+	if (!map_el.ownerDocument.getElementById(mapObject.elementName + "_permanent")) {
+		//create Box Elements
+
+		var $div = parent.$("<div id='" + mapObject.elementName + "_permanent'><img src='../img/redball.gif'/></div>");
+		$div.css({
+			position: "absolute",
+			top: "0px",
+			left: "0px",
+			zIndex: 13
+		});
+		map_el.appendChild($div.get(0));
+	}
+	
+	var tagSource = "";
+	for (var i = 0; i < mod_highlightPOI_params.length; i = i + 3) {
+		var pointFromUrl = new Point(parseFloat(mod_highlightPOI_params[i+1]), parseFloat(mod_highlightPOI_params[i+2]));
+		var pos = mapObject.convertRealToPixel(pointFromUrl);
+		tagSource += "<div style='z-index:13;position:absolute;left:"+(pos.x-Math.round(0.5*poi_width))+"px;top:"+(pos.y-Math.round(0.5*poi_height))+"px'>";
+		tagSource += "<img src='"+poi_image+"'>";
+		tagSource += "<span style='"+poi_style+"'>"+mod_highlightPOI_params[i]+"<span>";
+		tagSource += "</div>";
+	}
+	$("#" + mapObject.elementName + "_permanent").html(tagSource);
+}

Modified: branches/print_dev/http/javascripts/mod_legend.php
===================================================================
--- branches/print_dev/http/javascripts/mod_legend.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_legend.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -79,8 +79,11 @@
 	stickylegend = 'false';
 }
 // Todo: return-value may change in the next version....
-parent.mb_registerSubFunctions("window.frames['legend'].mod_legend_pos(frameName)");
+parent.eventAfterMapRequest.register(function (obj) {
+	mod_legend_pos(obj.map.elementName)
+});
 
+
 function mod_legend_init(){
 	var obj = parent.document.getElementById("legend");
 	obj.style.top = mod_legend_target_top  + mod_legend_offsetTop;
@@ -131,11 +134,9 @@
 					else{
 						legendUrl = parent.mb_mapObj[ind].wms[i].getLegendUrlByGuiLayerStyle(layerNames[j],layerStyle);
 					}
-					//console.log("layer_infos : %s",layerNames[j],"---",layerParent,"---",layerTitle,"---",layerStyle,"---",legendUrl);
 			         
 					if (legendUrl !== false){
 						
-//						console.log("legendUrl: %s, typeof(legendUrl): %s", legendUrl, typeof(legendUrl));
 //	 					if(layerParent == 0){
 		 					if(showlayertitle == 'true'){
 								str_tmp += "<div><span class='titles'>" + layerTitle+ "</span></div>";
@@ -162,7 +163,6 @@
 				str_tmp ='';
 			}		
 		}
-		//console.log("ind =%s",ind,"str =",str);
 	    if(str != ""){
 			parent.writeTag("legend", "leg", str);
 		}

Modified: branches/print_dev/http/javascripts/mod_measure.php
===================================================================
--- branches/print_dev/http/javascripts/mod_measure.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_measure.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -294,6 +294,7 @@
 
 var mod_closePolygon_img = new Image();
 mod_closePolygon_img.src = "../img/button_gray/closePolygon_off.gif";
+mod_closePolygon_img.title = '<?php echo _mb("Close polygon");?>';
 
 eventAfterMeasure.register(function(){
 	return mod_closePolygon();
@@ -301,7 +302,7 @@
 
 function mod_closePolygon(){
 	var str =  "<div style='position:absolute;top:25px' onmouseup='parent.mod_closePolygon_go()' ";
-	str += "onmouseover='parent.mod_measure_timeout()' onmouseout='parent.mod_measure_disableTimeout()'><img src='"+mod_closePolygon_img.src+"'></div>";
+	str += "onmouseover='parent.mod_measure_timeout()' onmouseout='parent.mod_measure_disableTimeout()'><img src='"+mod_closePolygon_img.src+"' title='"+mod_closePolygon_img.title+"'></div>";
 	return str;
 }
 function mod_closePolygon_go(){
@@ -310,7 +311,7 @@
 
 var mod_rubber_img = new Image();
 mod_rubber_img.src = "../img/button_gray/rubber_off.gif";
-mod_rubber_img.title = "gemessene Strecke l&ouml;schen";
+mod_rubber_img.title = '<?php echo _mb("Rubber");?>';
 eventAfterMeasure.register(function () {
 	return mod_rubber();
 });
@@ -325,13 +326,14 @@
 
 var mod_getArea_img = new Image();
 mod_getArea_img.src = "../img/button_gray/getArea_off.gif";
+mod_getArea_img.title = '<?php echo _mb("Get area");?>';
 eventAfterMeasure.register(function () {
 	return mod_getArea();
 });
 
 function mod_getArea(){
 	var str =  "<div id='getAreaButton' style='position:absolute;top:50px' onmouseup='parent.mod_getArea_go()' ";
-	str += "onmouseover='parent.mod_measure_timeout()' onmouseout='parent.mod_measure_disableTimeout()'><img src='"+mod_getArea_img.src+"'></div>";
+	str += "onmouseover='parent.mod_measure_timeout()' onmouseout='parent.mod_measure_disableTimeout()'><img src='"+mod_getArea_img.src+"' title='"+mod_getArea_img.title+"'></div>";
 	return str;
 }
 function mod_getArea_go(){

Modified: branches/print_dev/http/javascripts/mod_navFrame.php
===================================================================
--- branches/print_dev/http/javascripts/mod_navFrame.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_navFrame.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -19,7 +19,12 @@
 
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
 include '../include/dyn_js.php';
+?>
+(function () {
+
+<?php
 echo "var mod_navFrame_target = '".$e_target[0]."';";
+echo "var mod_navFrame_id = '".$e_id."';";
 echo "var mod_navFrame_src = '".$e_src."';";
 ?>
 
@@ -30,19 +35,54 @@
 	mod_navFrame_ext = 10;
 }
 
+<?php
+$html = <<<HTML
+<div id="mbN_$e_id" style="position:absolute;width:0;height:0;top:0;left:0;background-color:#B8C1C7;">
+<img id="arrow_n_$e_id" style="position:relative;top:0;left:0" src="../img/arrows/arrow_n.gif" width="15" height="10">
+</div> 
+<div id="mbNE_$e_id" style="position:absolute;width:0;height:0;top:0;left:0;background-color:#B8C1C7;">
+<img id="arrow_ne_$e_id" style="position:relative;top:0;left:0" src="../img/arrows/arrow_ne.gif" width="10" height="10">
+</div> 
+<div id="mbE_$e_id" style="position:absolute;width:0;height:0;top:0;left:0;background-color:#B8C1C7;">
+<img id="arrow_e_$e_id" style="position:relative;top:0;left:0" src="../img/arrows/arrow_e.gif" width="10" height="15">
+</div> 
+<div id="mbSE_$e_id" style="position:absolute;width:0;height:0;top:0;left:0;background-color:#B8C1C7;">
+<img id="arrow_se_$e_id" style="position:relative;top:0;left:0" src="../img/arrows/arrow_se.gif" width="10" height="10">
+</div> 
+<div id="mbS_$e_id" style="position:absolute;width:0;height:0;top:0;left:0;background-color:#B8C1C7;">
+<img id="arrow_s_$e_id" style="position:relative;top:0;left:0" src="../img/arrows/arrow_s.gif" width="15" height="10">
+</div> 
+<div id="mbSW_$e_id" style="position:absolute;width:0;height:0;top:0;left:0;background-color:#B8C1C7;">
+<img id="arrow_sw_$e_id" style="position:relative;top:0;left:0" src="../img/arrows/arrow_sw.gif" width="10" height="10">
+</div>
+<div id="mbW_$e_id" style="position:absolute;width:0;height:0;top:0;left:0;background-color:#B8C1C7;">
+<img id="arrow_w_$e_id" style="position:relative;top:0;left:0" src="../img/arrows/arrow_w.gif" width="10" height="15">
+</div> 
+<div id="mbNW_$e_id" style="position:absolute;width:0;height:0;top:0;left:0;background-color:#B8C1C7;">
+<img id="arrow_nw_$e_id" style="position:relative;top:0;left:0" src="../img/arrows/arrow_nw.gif" width="10" height="10">
+</div>
+HTML;
+echo "var html = '" . str_replace("\n", "\\n", $html) . "';";
+?>
+	$("#" + mod_navFrame_id).html(html);
+	
+eventInit.register(function () {
+	var directionArray = ["N", "NE", "E", "SE", "S", "SW", "W", "NW"];
+	for (var i in directionArray) {
+		(function () {
+			var currentDirection = directionArray[i];
+//			$("#mb"+currentDirection+"_"+mod_navFrame_id).click(function () {
+			$("#arrow_"+currentDirection.toLowerCase()+"_"+mod_navFrame_id).click(function () {
+				mod_navFrame(currentDirection);
+			});
+		}());
+	}
+});
+
 eventAfterMapRequest.register(function () {
 	mod_navFrame_arrange();
 });
 
-var directionArray = ["N", "NE", "E", "SE", "S", "SW", "W", "NW"];
-for (var i in directionArray) {
-	(function () {
-		var currentDirection = directionArray[i];
-		$("#mb"+currentDirection).click(function () {
-			mod_navFrame(currentDirection);
-		});
-	}());
-}
 
 function  mod_navFrame_arrange(){
 	var el = document.getElementById(mod_navFrame_target).style;
@@ -53,26 +93,26 @@
 	var myHeight = parseInt(el.height);
 	
 	//left,top,width,height
-	mod_navFrame_pos("mbN",(myLeft),(myTop - ext),(myWidth),(ext));
-	document.getElementById("arrow_n").style.left = myWidth/2 - document.getElementById("arrow_n").width/2;   
-	mod_navFrame_pos("mbNE",(myLeft + myWidth),(myTop - ext),(ext),(ext));
-	mod_navFrame_pos("mbE",(myLeft + myWidth),(myTop),(ext),(myHeight));
-	document.getElementById("arrow_e").style.top = myHeight/2 - document.getElementById("arrow_n").height/2;
-	mod_navFrame_pos("mbSE",(myLeft + myWidth),(myTop + myHeight),(ext),(ext));
-	mod_navFrame_pos("mbS",(myLeft),(myTop + myHeight),(myWidth),(ext));
-	document.getElementById("arrow_s").style.left = myWidth/2 - document.getElementById("arrow_s").width/2;
-	mod_navFrame_pos("mbSW",(myLeft - ext),(myTop + myHeight),(ext),(ext));
-	mod_navFrame_pos("mbW",(myLeft - ext),(myTop),(ext),(myHeight));
-	document.getElementById("arrow_w").style.top = myHeight/2 - document.getElementById("arrow_w").height/2;
-	mod_navFrame_pos("mbNW",(myLeft - ext),(myTop -ext),(ext),(ext));   
+	mod_navFrame_pos("mbN_"+mod_navFrame_id,(myLeft),(myTop - ext),(myWidth),(ext));
+	document.getElementById("arrow_n_"+mod_navFrame_id).style.left = myWidth/2 - document.getElementById("arrow_n_"+mod_navFrame_id).width/2;   
+	mod_navFrame_pos("mbNE_"+mod_navFrame_id,(myLeft + myWidth),(myTop - ext),(ext),(ext));
+	mod_navFrame_pos("mbE_"+mod_navFrame_id,(myLeft + myWidth),(myTop),(ext),(myHeight));
+	document.getElementById("arrow_e_"+mod_navFrame_id).style.top = myHeight/2 - document.getElementById("arrow_n_"+mod_navFrame_id).height/2;
+	mod_navFrame_pos("mbSE_"+mod_navFrame_id,(myLeft + myWidth),(myTop + myHeight),(ext),(ext));
+	mod_navFrame_pos("mbS_"+mod_navFrame_id,(myLeft),(myTop + myHeight),(myWidth),(ext));
+	document.getElementById("arrow_s_"+mod_navFrame_id).style.left = myWidth/2 - document.getElementById("arrow_s_"+mod_navFrame_id).width/2;
+	mod_navFrame_pos("mbSW_"+mod_navFrame_id,(myLeft - ext),(myTop + myHeight),(ext),(ext));
+	mod_navFrame_pos("mbW_"+mod_navFrame_id,(myLeft - ext),(myTop),(ext),(myHeight));
+	document.getElementById("arrow_w_"+mod_navFrame_id).style.top = myHeight/2 - document.getElementById("arrow_w_"+mod_navFrame_id).height/2;
+	mod_navFrame_pos("mbNW_"+mod_navFrame_id,(myLeft - ext),(myTop -ext),(ext),(ext));   
 }
 function mod_navFrame(val){
 	mb_panMap(mod_navFrame_target,val);  
 }
 function mod_navFrame_pos(el,left,top,width,height){
-//alert(el + " , " +left + " , " +top + " , " +width + " , " +height)
 	document.getElementById(el).style.left = left;
 	document.getElementById(el).style.top = top;
 	document.getElementById(el).style.width = width;
 	document.getElementById(el).style.height = height;
 }
+}());
\ No newline at end of file

Modified: branches/print_dev/http/javascripts/mod_pan.php
===================================================================
--- branches/print_dev/http/javascripts/mod_pan.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_pan.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -20,7 +20,7 @@
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
 echo "var mod_pan_target = '".$e_target[0]."';";
 ?>
-var mod_pan_elName = "pan1";
+var mod_pan_elName = "<?php echo $e_id; ?>";
 var mod_pan_frameName = "";
 var mod_pan_MapObj = null;
 
@@ -31,49 +31,50 @@
 
 var mb_panActive = false;
 
-function init_mod_pan(ind){
-	mod_pan_MapObj = getMapObjByName(mod_pan_target);
-	mb_button[ind] = document.getElementById(mod_pan_elName);
-	mb_button[ind].img_over = mod_pan_img_over.src;
-	mb_button[ind].img_on = mod_pan_img_on.src;
-	mb_button[ind].img_off = mod_pan_img_off.src;
-	mb_button[ind].status = 0;
-	mb_button[ind].elName = mod_pan_elName;
-	mb_button[ind].fName = mod_pan_frameName;
-	mb_button[ind].go = new Function ("mod_pan_click()");
-	mb_button[ind].stop = new Function ("mod_pan_disable()");
-}
-function mod_pan_click(){   
-	var p = mod_pan_MapObj.getDomElement();
-	p.style.cursor = "pointer";
-	
-	p.onmousedown = mod_pan_start;
-	p.onmouseup = mod_pan_stop;
-	p.onmousemove = mod_pan_run;
-}
-function mod_pan_disable(){
-	var p = mod_pan_MapObj.getDomElement();
-	p.style.cursor = "pointer";
+eventInit.register(function () {
+	mb_regButton(function (ind){
+		mod_pan_MapObj = getMapObjByName(mod_pan_target);
+		mb_button[ind] = document.getElementById(mod_pan_elName);
+		mb_button[ind].img_over = mod_pan_img_over.src;
+		mb_button[ind].img_on = mod_pan_img_on.src;
+		mb_button[ind].img_off = mod_pan_img_off.src;
+		mb_button[ind].status = 0;
+		mb_button[ind].elName = mod_pan_elName;
+		mb_button[ind].fName = mod_pan_frameName;
+		mb_button[ind].go = function () {
+			var p = mod_pan_MapObj.getDomElement();
+			p.style.cursor = "pointer";
+			
+			p.onmousedown = mod_pan_start;
+			p.onmouseup = mod_pan_stop;
+			p.onmousemove = mod_pan_run;
+		};
+		mb_button[ind].stop = function () {
+			var p = mod_pan_MapObj.getDomElement();
+			p.style.cursor = "pointer";
+		
+			p.onmousedown = null;
+			p.onmouseup = null;
+			p.onmousemove = null;
+		};
+	});
+});
 
-	p.onmousedown = null;
-	p.onmouseup = null;
-	p.onmousemove = null;
-}
 function mod_pan_start(e){
 	mb_panActive = true;
-	mb_getMousePos(e,mod_pan_target);
+	var pos = mod_pan_MapObj.getMousePosition(e);
 	var el = mod_pan_MapObj.getDomElement();
-	mb_start_x=clickX;
-	mb_start_y=clickY;
-	mb_end_x = clickX;
-	mb_end_y = clickY; 
+	mb_start_x=pos.x;
+	mb_start_y=pos.y;
+	mb_end_x = pos.x;
+	mb_end_y = pos.y; 
 	return false;
 }
 function mod_pan_run(e){
 	if(mb_panActive){
-		mb_getMousePos(e,mod_pan_MapObj.frameName);
-		mb_end_x = clickX;
-		mb_end_y = clickY;
+		var pos = mod_pan_MapObj.getMousePosition(e);
+		mb_end_x = pos.x;
+		mb_end_y = pos.y;
 		mod_pan_move_map();
 		if(ie){
 			return false;
@@ -84,22 +85,24 @@
 	}
 }
 function mod_pan_stop(e){
-	mb_panActive = false;
-	var dif_x = mb_end_x - mb_start_x;
-	var dif_y = mb_end_y - mb_start_y;
-	var width = mod_pan_MapObj.width;
-	var height = mod_pan_MapObj.height;      
-
-	var el = mod_pan_MapObj.getDomElement();
-	var center_x = (width / 2)  - dif_x;
-	var center_y = (height / 2) - dif_y;
-	var real_center = makeClickPos2RealWorldPos(mod_pan_target,center_x, center_y);   
-
-	mb_arrangeElement(mod_pan_MapObj.frameName, mod_pan_target+"_maps", 0, 0);
-	for(var i=0; i<mb_PanSubElements.length; i++){
-		mb_arrangeElement(mod_pan_MapObj.frameName, mb_PanSubElements[i], 0, 0);
-	} 
-   zoom(mod_pan_target,false, 1.0, real_center[0], real_center[1]);   
+	if(mb_panActive){
+		mb_panActive = false;
+		var dif_x = mb_end_x - mb_start_x;
+		var dif_y = mb_end_y - mb_start_y;
+		var width = mod_pan_MapObj.width;
+		var height = mod_pan_MapObj.height;      
+	
+		var el = mod_pan_MapObj.getDomElement();
+		var center_x = (width / 2)  - dif_x;
+		var center_y = (height / 2) - dif_y;
+		var real_center = makeClickPos2RealWorldPos(mod_pan_target,center_x, center_y);   
+	
+		mb_arrangeElement(mod_pan_MapObj.frameName, mod_pan_target+"_maps", 0, 0);
+		for(var i=0; i<mb_PanSubElements.length; i++){
+			mb_arrangeElement(mod_pan_MapObj.frameName, mb_PanSubElements[i], 0, 0);
+		} 
+	   zoom(mod_pan_target,false, 1.0, real_center[0], real_center[1]);   
+	}
 }
 function mod_pan_move_map(){
 	var dif_x = mb_end_x - mb_start_x;

Modified: branches/print_dev/http/javascripts/mod_sandclock.php
===================================================================
--- branches/print_dev/http/javascripts/mod_sandclock.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_sandclock.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -47,35 +47,45 @@
 			el_top.style.position = "absolute";
 			el_top.style.top = "0px";
 			el_top.style.left = "0px";
-			el_top.style.width = "0px";
-			el_top.style.height = "0px";
 			el_top.style.overflow = "hidden";
 			el_top.style.zIndex = "10";
-			el_top.style.visibility = "hidden";
+			el_top.style.visibility = "visible";
 			el_top.style.cursor = "crosshair";
-			el_top.style.backgroundColor = "#ff0000";
 			el_top.id = mb_mapObj[ind].elementName+"_sandclock";
 			map_el.appendChild(el_top);
 		}
 		writeTag(mb_mapObj[ind].frameName, mb_mapObj[ind].elementName+"_sandclock", temp);
 		mb_arrangeElement("", mod_sandclock_target+"_sandclock", (mb_mapObj[ind].width/2 - 16), (mb_mapObj[ind].height/2 - 16));
 	}
-	aktiv = setTimeout(function () {
-		mod_sandclock('',myMapId);
-		},10);
-	var myMapIdArray = myMapId.split(",");
-	var complete = true;
-	var myMapId;
-	for (var i = 0; i < myMapIdArray.length && complete; i++) {
-		myMapId = myMapIdArray[i];
-		var myDoc = mb_mapObj[ind].getDomElement().ownerDocument;
-		if(myDoc.getElementById(myMapId) && 
-			!myDoc.getElementById(myMapId).complete) {
-			complete = false;
+
+	//
+	// if myMapId is nopt given, the sandclock has to be turned off manually
+	// by calling mod_sandclock_off. Usually this is done in a callback 
+	// function.
+	//
+	if (typeof myMapId !== "undefined") {
+		aktiv = setTimeout(function () {
+			mod_sandclock('',myMapId);
+			},10);
+		var myMapIdArray = myMapId.split(",");
+		var complete = true;
+		var myMapId;
+		for (var i = 0; i < myMapIdArray.length && complete; i++) {
+			myMapId = myMapIdArray[i];
+			var myDoc = mb_mapObj[ind].getDomElement().ownerDocument;
+			if(myDoc.getElementById(myMapId) && 
+				!myDoc.getElementById(myMapId).complete) {
+				complete = false;
+			}
 		}
+		if (complete) {
+			clearTimeout(aktiv);
+			mod_sandclock_off(mb_mapObj[ind]);
+		} 
 	}
-	if (complete) {
-		clearTimeout(aktiv);
-		writeTag(mb_mapObj[ind].frameName, mb_mapObj[ind].elementName+"_sandclock", "");
-	} 
 }
+
+function mod_sandclock_off() {
+	var mapObj = getMapObjByName(mod_sandclock_target);
+	writeTag(mapObj.frameName, mapObj.elementName+"_sandclock", "");
+}

Modified: branches/print_dev/http/javascripts/mod_scaleHint.php
===================================================================
--- branches/print_dev/http/javascripts/mod_scaleHint.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_scaleHint.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -25,7 +25,10 @@
 
 ?>
 
-mb_registerPreFunctions("mod_scaleHint_init(frameName)");
+eventBeforeMapRequest.register(function (obj) {
+	mod_scaleHint_init(obj.map.elementName);
+});
+
 function mod_scaleHint_init(frameName){
 	if(frameName == mod_scaleHint_target){
 		var ind = getMapObjIndexByName(frameName);

Modified: branches/print_dev/http/javascripts/mod_scaleSel.php
===================================================================
--- branches/print_dev/http/javascripts/mod_scaleSel.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_scaleSel.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -21,7 +21,7 @@
 echo "var mod_scaleSelect_target = '".$e_target[0]."';";
 ?>
 eventAfterMapRequest.register(function (obj) {
-	mod_scaleSelect_val(obj.frameName);
+	mod_scaleSelect_val(obj.map.elementName);
 });
 function mod_scaleSelect(obj){
 	var ind = obj.selectedIndex;

Modified: branches/print_dev/http/javascripts/mod_scalebar.php
===================================================================
--- branches/print_dev/http/javascripts/mod_scalebar.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_scalebar.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -93,13 +93,9 @@
 		el_top.style.position = "absolute";
 		el_top.style.top = "0px";
 		el_top.style.left = "0px";
-		el_top.style.width = "0px";
-		el_top.style.height = "0px";
+		el_top.style.width = "200px";
 		el_top.style.overflow = "hidden";
 		el_top.style.zIndex = "10";
-		el_top.style.visibility = "hidden";
-		el_top.style.cursor = "crosshair";
-		el_top.style.backgroundColor = "#ff0000";
 		el_top.id = mb_mapObj[ind].elementName+"_scalebar";
 		map_el.appendChild(el_top);
 	}

Modified: branches/print_dev/http/javascripts/mod_selArea1.php
===================================================================
--- branches/print_dev/http/javascripts/mod_selArea1.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_selArea1.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -19,7 +19,7 @@
 
 require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
 ?>
-var mod_selArea_elName = "selArea1";
+var mod_selArea_elName = "<?php echo $e_id;?>";
 var mod_selArea_frameName = "";
 var mod_selArea_target = "<?php echo $e_target[0]; ?>";
 
@@ -31,18 +31,25 @@
 var mod_selArea_img_over = new Image(); 
 mod_selArea_img_over.src = "<?php  echo preg_replace("/_off/","_over",$e_src);  ?>";
 
-function init_selArea1(ind){
-	mod_selArea_MapObj = getMapObjByName(mod_selArea_target);
-	mb_button[ind] = document.getElementById(mod_selArea_elName);
-	mb_button[ind].img_over = mod_selArea_img_over.src;
-	mb_button[ind].img_on = mod_selArea_img_on.src;
-	mb_button[ind].img_off = mod_selArea_img_off.src;
-	mb_button[ind].status = 0;
-	mb_button[ind].elName = mod_selArea_elName;
-	mb_button[ind].fName = mod_selArea_frameName;
-	mb_button[ind].go = new Function ("mod_selArea_click()");
-	mb_button[ind].stop = new Function ("mod_selArea_disable()");
-}
+eventInit.register(function () {
+	mb_regButton(function (ind) {
+		mod_selArea_MapObj = getMapObjByName(mod_selArea_target);
+		mb_button[ind] = document.getElementById(mod_selArea_elName);
+		mb_button[ind].img_over = mod_selArea_img_over.src;
+		mb_button[ind].img_on = mod_selArea_img_on.src;
+		mb_button[ind].img_off = mod_selArea_img_off.src;
+		mb_button[ind].status = 0;
+		mb_button[ind].elName = mod_selArea_elName;
+		mb_button[ind].fName = mod_selArea_frameName;
+		mb_button[ind].go = function () {
+			mod_selArea_click();
+		};
+		mb_button[ind].stop = function () {
+			mod_selArea_disable();
+		};
+	});
+});
+
 function mod_selArea_click(){
 	var el = mod_selArea_MapObj.getDomElement();
 	el.onmouseover = mod_selArea_init;

Modified: branches/print_dev/http/javascripts/mod_setBBOX1.php
===================================================================
--- branches/print_dev/http/javascripts/mod_setBBOX1.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_setBBOX1.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -28,8 +28,21 @@
 	var myBBOX = "<?php echo $_SESSION['mb_myBBOX'] ?>";
 	for(var i=0; i<my_target.length; i++){
 		if(myBBOX != ""){
-			var coord = myBBOX.split(","); 
-			mb_calculateExtent(my_target[i],parseFloat(coord[0]),parseFloat(coord[1]),parseFloat(coord[2]),parseFloat(coord[3]));
+			var mapObj = getMapObjByName(my_target);
+			if (mapObj) {
+				var coord = myBBOX.split(","); 
+				var newExtent = new Extent(parseFloat(coord[0]),parseFloat(coord[1]),parseFloat(coord[2]),parseFloat(coord[3]));
+
+				// if the restrictedExtent attribute exists, it has been 
+				// configured by the user in the element variable.
+				// This is an indicator, that the administrator wants to
+				// set the restricted extent coming from request variables.
+				if (mapObj.restrictedExtent) {
+					mapObj.setRestrictedExtent(newExtent);
+				}
+				mapObj.calculateExtent(newExtent);				
+
+			}
 		}
 	}
 }

Modified: branches/print_dev/http/javascripts/mod_tab.js
===================================================================
--- branches/print_dev/http/javascripts/mod_tab.js	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_tab.js	2009-05-22 11:46:01 UTC (rev 3956)
@@ -29,7 +29,7 @@
 		tabs.setTitles(obj);
 	});
 }
-
+ 
 function tab_init(){
 	var obj = document.getElementById("tabs").style;
 

Modified: branches/print_dev/http/javascripts/mod_tooltip.php
===================================================================
--- branches/print_dev/http/javascripts/mod_tooltip.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_tooltip.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -33,9 +33,13 @@
 
 include '../include/dyn_js.php';
 ?>
-//tolerance when we ask wfs
-var mb_wfs_tolerance = 8;
+//tolerance when we ask wfs (comes from conf file)
+if(typeof(mb_wfs_tolerance)==='undefined') {
+	var mb_wfs_tolerance = 8;
+}	
 
+var targetArray = tooltipTarget.split(",");
+
 //initialize Element Vars
 
 //destination frame for the request (creates Popup if empty)
@@ -51,6 +55,10 @@
 	var tooltip_height = 200;
 if(typeof(tooltip_styles_detail)==='undefined')
 	var tooltip_styles_detail = "";
+if(typeof(tooltip_disableWms)==='undefined')
+	var tooltip_disableWms = "0";
+if(typeof(tooltip_disableWfs)==='undefined')
+	var tooltip_disableWfs = "0";	
 try{
 	var no_result_text = eval(tooltip_noResultArray);
 }catch(e){
@@ -64,62 +72,77 @@
 var numberOfFinishedWfsRequests = 0;
 var numberOfFinishedWmsRequests = 0;
 var visibleRequest = 0;
-var TooltipMsg = {'title':"<?php echo _mb("Information");?>"};
+var tooltipMsg = {'title':"<?php echo _mb("Information");?>"};
 
-//buttonWfs_toDigitize_on ="0";
-
 function mod_tooltipInit(){
-var tooltip_map = getMapObjByName(tooltipTarget);
-var ind = getMapObjIndexByName(tooltipTarget);
-var myMapObj = mb_mapObj[ind];		
+	var tooltip_map = getMapObjByName(tooltipTarget);
+	var ind = getMapObjIndexByName(tooltipTarget);
+	var myMapObj = mb_mapObj[ind];		
 
-var map_el = myMapObj.getDomElement();
+	var map_el = myMapObj.getDomElement();
 
 	$(map_el.ownerDocument).mousemove(function(event){
-		var point = tooltip_map.getMousePos(event);
+		point = tooltip_map.getMousePosition(event);
 		//mb_getMousePos(event,myMapObj.getMousePosition(event));
-		mod_tooltip_run();
-	}).mouseout(function(){mouseMoves=0;});
+		mod_tooltip_run(point);
+	}).mouseout(function(){
+		mouseMoves=0;
+	});
 }
 
 eventInit.register(mod_tooltipInit);
 
-function mod_tooltip_run(){
+function mod_tooltip_run(point){
 	mouseMoves++;
-	setTimeout("if(mouseMoves=="+mouseMoves+"&&clickX=="+clickX+"&&clickY=="+clickY+")fireRequests();",tooltip_timeDelay);
+	var currentMouseMoves = mouseMoves;
+	setTimeout(function () {
+			if(point !== null && mouseMoves == currentMouseMoves) {
+				fireRequests(point);
+			}
+		}
+		,tooltip_timeDelay
+	);
 }
 
-function fireRequests(){
+function fireRequests(point){
 	var ind = getMapObjIndexByName(tooltipTarget);
-	point = new Point(clickX,clickY);
 	var point_geom = new Geometry(geomType.point);
 	point_geom.addPoint(mapToReal(tooltipTarget,point));
 	visibleRequest = 0;
-	
-	//FeatureInfo requests
-	urls = mb_mapObj[ind].getFeatureInfoRequests(point);
-	tooltipWmsRequestCount = urls.length;
-	numberOfFinishedWmsRequests	= 0;	
-	for(var j=0;j < urls.length;j++){
-		mb_ajax_post("../extensions/ext_featureInfoTunnel.php", {url:urls[j]}, 
-			checkFeatureInfoResults);
+
+	if(tooltip_disableWms != '1') {	
+		//FeatureInfo requests
+		urls = mb_mapObj[ind].getFeatureInfoRequests(point);
+		tooltipWmsRequestCount = urls.length;
+		numberOfFinishedWmsRequests	= 0;	
+		for(var j=0;j < urls.length;j++){
+			mb_ajax_post("../extensions/ext_featureInfoTunnel.php", {url:urls[j]}, 
+				checkFeatureInfoResults);
+		}
 	}
 	
-	//WFS requests
-	requests = getWfsRequests(tooltipTarget, point_geom, true);
-	tooltipWfsRequestCount = requests.length;
-	numberOfFinishedWfsRequests = 0;
-	resultGeomArray = new GeometryArray();
-	for(var j=0;j< requests.length;j++){
-		mb_ajax_post("../" + wfsResultModulePath + wfsResultModuleFilename,requests[j],function(js_code,status){
-			if (js_code) {
-				eval(js_code);
-			}
-			if (typeof(geom) == "undefined") {
-				var geom = new GeometryArray();
-			}
-			checkWfsResultsFinished(geom);
-		});
+	if(tooltip_disableWfs != '1') {	
+		//WFS requests
+		requests = getWfsRequests(tooltipTarget, point_geom, true);
+		tooltipWfsRequestCount = requests.length;
+		numberOfFinishedWfsRequests = 0;
+		resultGeomArray = new GeometryArray();
+		for(var j=0;j< requests.length;j++){
+			(function () {
+				var currentRequest = requests[j];
+				mb_ajax_post("../" + wfsResultModulePath + wfsResultModuleFilename,currentRequest,function(js_code,status){
+					var geom = new GeometryArray();
+					if (js_code && geom.importGeoJSON(js_code)) {
+						if (typeof(currentRequest) === "object" && typeof(currentRequest.js_wfs_conf_id) !== "undefined") {
+							for (var i = 0; i < geom.count(); i++) {
+								geom.get(i).wfs_conf = parseInt(currentRequest.js_wfs_conf_id);
+							}					
+						}
+					}
+					checkWfsResultsFinished(geom);
+				});
+			}());
+		}
 	}
 }
 
@@ -135,8 +158,9 @@
 	
 	for(var k=0;k < no_result_text.length;k++){
 		if(js_code.indexOf(no_result_text[k])!==-1){
-			if(!isFirstResult())
+			if(!isFirstResult()) {
 				displayResultDoc("");
+			}	
 			return;
 		}
 	}
@@ -154,10 +178,12 @@
 	if (numberOfFinishedWfsRequests == tooltipWfsRequestCount) {
 		if(resultGeomArray.count()>0){
 			//generate and output result
-			if(resultGeomArray.count()>1)
+			//if(resultGeomArray.count()>1) {
 				var html = createSimpleWfsResultHtml(resultGeomArray);
-			else
-				var html = createDetailedWfsResultHtml(resultGeomArray);
+			//}	
+			//else {
+			//	var html = createDetailedWfsResultHtml(resultGeomArray);
+			//}	
 			displayResultDoc(html);
 		}
 		else if(!isFirstResult())
@@ -175,8 +201,9 @@
 
 function displayResultDoc(html){
 	//test if we have a fixed destination and create popup otherwise
-	if(tooltip_destinationFrame=="")
+	if(tooltip_destinationFrame=="") {
 		return showBalloonFrame(html);
+	}
           	
 	//put the frame there
 	$("#"+tooltip_destinationFrame).each(function(){
@@ -185,7 +212,7 @@
 	        oDoc = oDoc.document;
 		}
 		if(isFirstResult())
-	  		oDoc.open();
+			oDoc.open();
 		oDoc.write(html);
 		if(isLastResult())
 			oDoc.close();
@@ -195,7 +222,8 @@
 
 function showBalloonFrame(html){
 	if(isFirstResult()){
-		//claculate Position
+		//calculate Position
+		
 		x=point.x+parseInt(document.getElementById(tooltipTarget).style.left);
 		y=point.y+parseInt(document.getElementById(tooltipTarget).style.top);
 		
@@ -204,7 +232,7 @@
 			tooltipWin.destroy();
 	
 		//create Popup and append document
-		tooltipWin = new mb_popup({html:'<iframe id="tooltipWin" name="tooltipWin" src="about:blank"/>',title:TooltipMsg.title,width:tooltip_width,height:tooltip_height,balloon:true,left:x,top:y});
+		tooltipWin = new mb_popup({html:'<iframe id="tooltipWin" name="tooltipWin" src="about:blank"/>',title:tooltipMsg.title,width:tooltip_width,height:tooltip_height,balloon:true,left:x,top:y});
 		//open document
 		tooltipWin.open();
 	}
@@ -216,6 +244,12 @@
 		
 	//finally display popup
 	tooltipWin.show();
+	visibleRequest++;
+
+	// destroy the popup if the mouse leaves the popup
+	$("#"+tooltipWin.id + " #tooltipWin").mouseout(function() {
+		tooltipWin.destroy();
+	});
 }
 
 function getWfsRequests(target, geom, checkscale, filteroption){
@@ -283,9 +317,9 @@
 	for (var i = 0 ; i < _geomArray.count(); i ++) {
 		if (_geomArray.get(i).get(-1).isComplete()) {
 			html += "\t<tr class='list_"+(i%2?"uneven":"even")+"'>\n\t\t<td \n";
-//			html += "\t\t\t onmouseover='mb_wfs_perform(\"over\",_geomArray.get("+i+"));' ";
-//			html += " onmouseout='mb_wfs_perform(\"out\",_geomArray.get("+i+"))' ";
-//			html += " onclick='mb_wfs_perform(\"click\",_geomArray.get("+i+"));' ";
+			html += "\t\t\t onmouseover='parent.setResult(\"over\","+i+");' ";
+			html += " onmouseout='parent.setResult(\"out\","+i+")' ";
+			html += " onclick='parent.setResult(\"click\","+i+");' ";
 			var geomName = getWfsListEntry(_geomArray.get(i)); 
 			html += ">" + geomName +"</td>";
 			html += "\t\t</tr>\n"; 
@@ -365,3 +399,30 @@
 	}
 }
 
+/*
+* event -> {over || out || click}
+* geom -> commaseparated coordinates x1,y1,x2,y2 ...
+*/
+function setResult(event, index){
+	var currentGeom = resultGeomArray.get(index);
+	var resultHighlight = new parent.Highlight(targetArray, "tooltipHighlight", {"position":"absolute", "top":"0px", "left":"0px", "z-index":100}, 2);
+	var cw_fillcolor = "#cc33cc";
+	
+	if (event == "over") {
+		resultHighlight.add(currentGeom, cw_fillcolor);
+		resultHighlight.paint();
+	}
+	else if (event == "out"){
+		resultHighlight.del(currentGeom, cw_fillcolor);
+		resultHighlight.paint();
+	}
+	else if (event == "click"){
+		resultHighlight.del(currentGeom, cw_fillcolor);
+		var bbox = currentGeom.getBBox();
+		//parent.mb_calculateExtent(tooltipTarget, bbox[0].x, bbox[0].y, bbox[1].x, bbox[1].y);
+		//parent.zoom(tooltipTarget, 'true', 1.0);
+		resultHighlight.add(currentGeom, cw_fillcolor);
+		resultHighlight.paint();
+	}
+	return true;
+}
\ No newline at end of file

Modified: branches/print_dev/http/javascripts/mod_wfs_SpatialRequest.php
===================================================================
--- branches/print_dev/http/javascripts/mod_wfs_SpatialRequest.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_wfs_SpatialRequest.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -105,6 +105,12 @@
 catch(e){
 	buttonWfs_toDigitize_on = 0;
 }
+try{
+	if (displaySrsWarning){}
+}
+catch(e){
+	displaySrsWarning = false;
+}
 if (wfsResultToPopupDiv == 1) {
 	mb_registerWfsReadSubFunctions(function (geom) {
 		displayPopup(geom);
@@ -114,7 +120,12 @@
 	if (buttonWfs_toDigitize_on == 1) {
 		mb_registerWfsReadSubFunctions(function(geom){
 			if (buttonWfs_toDigitize_target && window.frames[buttonWfs_toDigitize_target]) {
-				tab_open(buttonWfs_toDigitize_target);
+				try {
+					tab_open(buttonWfs_toDigitize_target);
+				}
+				catch (exc) {
+					new Mb_warning("Tab open failed, pssibly because you do not have tabs in your application."); 
+				}
 				appendGeometryArrayToDigitize(geom);
 			}
 			else {
@@ -565,12 +576,14 @@
 		var mapIndex = getMapObjIndexByName(mod_wfs_spatialRequest_target);
 		if (geom.count() === 0) {
 			var e = new Mb_exception("Result set is empty.");
-			return;
 		}
-		if (geom.get(0).getEpsg() !== mb_mapObj[mapIndex].epsg) {
-			var e = new Mb_warning("SRS mismatch. Geometry is in " + geom.get(0).getEpsg() + ", map is in " + mb_mapObj[mapIndex].epsg + ".");
+		else {
+		
+			if (geom.get(0).getEpsg() !== mb_mapObj[mapIndex].epsg) {
+				var e = new Mb_warning("SRS mismatch. Geometry is in " + geom.get(0).getEpsg() + ", map is in " + mb_mapObj[mapIndex].epsg + ".");
+			}
+			geomArray.union(geom);
 		}
-		geomArray.union(geom);
 	}
 	if (numberOfFinishedAjaxCalls == numberOfAjaxCalls) {
 		numberOfFinishedAjaxCalls = 0;
@@ -628,14 +641,21 @@
 		var msg = "SRS mismatch. Geometry is in " + geom.get(0).getEpsg() + 
 			", map is in " + mb_mapObj[mapIndex].epsg + ".";
 		var e = new Mb_warning(msg);
-		proceed = confirm(msg + " Proceed?");
+		if (displaySrsWarning) {
+			proceed = confirm(msg + " Proceed?");
+		}
 	}
 	if (!proceed) {
 		return;
 	}
 	try {
 		window.frames[mod_digitize_elName].appendGeometryArray(geom);
-		tab_open(mod_digitize_elName);
+		try {
+			tab_open(mod_digitize_elName);
+		}
+		catch (exc) {
+			new Mb_warning("Tab open failed, pssibly because you do not have tabs in your application."); 
+		}
 	}
 	catch (e) {
 		var e = new Mb_exception("The application element 'digitize' is missing.");
@@ -647,10 +667,12 @@
 
 	var proceed = true;
 	if (geomArray.get(i).getEpsg() !== mb_mapObj[mapIndex].epsg) {
-		var msg = "SRS mismatch. Geometry is in " + geom.get(0).getEpsg() + 
+		var msg = "SRS mismatch. Geometry is in " + geomArray.get(0).getEpsg() + 
 			", map is in " + mb_mapObj[mapIndex].epsg + ".";
 		var e = new Mb_warning(msg);
-		proceed = confirm(msg + " Proceed?");
+		if (displaySrsWarning) {
+			proceed = confirm(msg + " Proceed?");
+		}
 	}
 	if (!proceed) {
 		return;
@@ -659,7 +681,12 @@
 	digitizeArray.addCopy(geomArray.get(i));
 	try {
 		window.frames[mod_digitize_elName].appendGeometryArray(digitizeArray);
-		tab_open(mod_digitize_elName);
+		try {
+			tab_open(mod_digitize_elName);
+		}
+		catch (exc) {
+			new Mb_warning("Tab open failed, pssibly because you do not have tabs in your application."); 
+		}
 	}
 	catch (e) {
 		var e = new Mb_exception("The application element 'digitize' is missing.");
@@ -678,9 +705,9 @@
 		for (var i = 0 ; i < geomArray.count(); i ++) {
 			if (geomArray.get(i).get(-1).isComplete()) {
 				listOfGeom += "\t<tr>\n\t\t<td style = 'color:blue;font-size:12px;cursor:pointer;'\n";
-				listOfGeom += "\t\t\t onmouseover='mb_wfs_perform(\"over\",geomArray.get("+i+"));' ";
-				listOfGeom += " onmouseout='mb_wfs_perform(\"out\",geomArray.get("+i+"))' ";
-				listOfGeom += " onclick='mb_wfs_perform(\"click\",geomArray.get("+i+")); showWfs("+i+");' ";
+				listOfGeom += "\t\t\t onmouseover='mb_wfs_perform(\"over\",geomArray.get("+i+"),resultHighlightColour);' ";
+				listOfGeom += " onmouseout='mb_wfs_perform(\"out\",geomArray.get("+i+"),resultHighlightColour)' ";
+				listOfGeom += " onclick='mb_wfs_perform(\"click\",geomArray.get("+i+"),resultHighlightColour); showWfs("+i+");' ";
 				var geomName = getListTitle(geomArray.get(i));
 				//if (geomArray.get(i).geomType == geomType.polygon) {geomName += "(polygon)";}
 				//else if (geomArray.get(i).geomType == geomType.line) {geomName += "(line)";}
@@ -718,7 +745,6 @@
 	for (var i = 0 ; i <currentWfsConf.element.length; i ++) {
 	    if(currentWfsConf.element[i].f_show_detail==1){
 	    	if( geomArray.get(geometryIndex).e.getElementValueByName(currentWfsConf.element[i].element_name)!=false){
-				//console.log(currentWfsConf.element[i].element_name+"---"+currentWfsConf.element[i].f_respos);
 				resultHtml +="<tr><td>\n";
 				resultHtml += currentWfsConf.element[i].f_label;
 				resultHtml +="</td>\n";

Modified: branches/print_dev/http/javascripts/mod_wfs_client.html
===================================================================
--- branches/print_dev/http/javascripts/mod_wfs_client.html	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_wfs_client.html	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,453 +1,453 @@
-<html>
-<head>
-<meta http-equiv="content-type" content="text/html;CHARSET=iso-8859-1">
-
-<link rel="stylesheet" type="text/css" media="screen,projection" href="../css/admin.screen.css" title="screen" />
-
-<script type='text/javascript'>
-
-
-/*
- * services['action']: instructs the servercomponent
- * services['services']: infos about the services (wfs)
- * services['services']['id']: a list of ids
- * services['service']['title']: a corresponding list of titles
- *
- */
-var services = {};
-/*
- * wfsConf['action']: instructs the servercomponent
- * wfsConf['wfs']: the ID of the selected wfs
- * wfsConf['wfsConf']: infos about the wfs configurations
- * wfsConf['wfsConf']['id']: a list of ids
- * wfsConf['wfsConf']['abstract']: a corresponding list of descriptions
- */
-var wfsConf = {};
-
-/*
- * guis['action']: instructs the servercomponent
- * guis['id']: a list of gui-IDs where the current user is owner
- * guis['selectedGui']: the selected Gui
- */
-var guis = {};
-
-/*
- * handleAssignment['action']: instructs the servercomponent
- * handleAssignment['selectedConf']: a list of wfs-conf Ids
- * handleAssignment['selectedGui']: the selected Gui
- */
-var handleAssignment = {}
-
-/*
- * vupdateWfs['action']: instructs the servercomponent
- * vupdateWfs['wfs']: id of wfs to update
- * vupdateWfs['url']: capabilities url
- */
-var vupdateWfs = {};
-
-/*
- * deleteWfs_['action']: instructs the servercomponent
- * deleteWfs_['wfs']: id of wfs to update
- */
-var deleteWfs_ = {};
-
-/*
- * geturl['action']: instructs the servercomponent
- * geturl['wfs']: id of wfs to get the url for
- * geturl['column']: column of the url to get in table wfs
- */
-var geturl = {}
-
-var owsproxy = {}
-
-
-
-
-function getWfsList(){
-	services['action'] = 'getServices';
-	getData(services);
-}
-function getGuis(){
-	guis['action'] = 'getGuis';
-	getData(guis);
-}
-function getWfsConfData(){
-	wfsConf['action'] = 'getWfsConfData';
-	wfsConf['wfs'] = getSelectedWfs();
-	getData(wfsConf);
-}
-function getSelectedWfs(){
-	var w = document.wfsForm.wfsList;
-	var ind  = w.selectedIndex;
-	if(ind == -1){
-		return false;
-	}
-	if(ind == w.options.length-1)
-		return "gui_confs";
-	return w.options[ind].value;
-}
-function getGuiConfs(){
-	guis['action'] = 'getAssignedConfs';
-	var g = document.wfsForm.guiList;
-	var ind  = g.selectedIndex;
-	if(ind == -1){
-		return false;
-	}
-	guis['selectedGui'] = g.options[ind].value;
-	guis['selectedWfs'] = wfsConf['wfs'];
-	getData(guis);
-}
-/**
- * Sends an request to get the url to the capabilities doc of selected wfs
- *
- */
-
-function getUpdateUrl(column){
-	geturl['action'] = 'getUpdateUrl';
-	var w = document.wfsForm.wfsList;
-	var ind  = w.selectedIndex;
-	if(ind == -1){
-		alert("please select an WFS");
-		return;
-	}
-	geturl['wfs'] = w.options[ind].value;
-	geturl['column'] = column;
-	geturl['wfs_version'] = '';
-	getData(geturl);
-}
-
-function addConfsToGui(){
-	handleAssignment['action'] = 'add';
-	handleAssignment['confs'] = getSelectedConfs();
-	handleAssignment['gui'] = getSelectedGui();
-	getData(handleAssignment);
-}
-function removeConfsFromGui(){
-	handleAssignment['action'] = 'remove';
-	handleAssignment['confs'] = getSelectedAssignedConfs();
-	handleAssignment['gui'] = getSelectedGui();
-	getData(handleAssignment);
-}
-/**
- * Sends an update request to update the capabilities of selected wfs
- *
- * @return success
- * @type boolean
- */
-
-function updateWfs(){
-	vupdateWfs['action'] = 'updateWfs';
-	var w = document.wfsForm.wfsList;
-	var ind  = w.selectedIndex;
-	if(ind == -1){
-		alert("please select an WFS");
-		return false;
-	}
-	vupdateWfs['wfs'] = w.options[ind].value;
-	if(document.getElementById("updateUrl").value == ''){
-		alert("Please choose the link to the new WFS Capabilities URL.");
-		return false;
-	}
-
-	vupdateWfs['url'] = document.getElementById("updateUrl").value;
-	getData(vupdateWfs);
-	return true;
-}
-
-function deleteWfs(){
-	deleteWfs_['action'] = 'deleteWfs';
-	deleteWfs_['wfs'] = getSelectedWfs();
-	if(deleteWfs_['wfs']&&deleteWfs_['wfs']!="gui_confs"){
-		if(confirm("Do you really want to delete the Wfs with Wfs-id:"+deleteWfs_['wfs']+"?")){
-			getData(deleteWfs_);
-		}
-		return true;
-	}
-	return false;
-}
-
-function setIndicator(){
-	var str = "<img src='../img/indicator_wheel.gif'>";
-	document.getElementById("indicator").innerHTML = str;
-}
-function removeIndicator(){
-	document.getElementById("indicator").innerHTML = "";
-}
-function getOwsproxy(){
-	owsproxy['action'] = 'getOwsproxy';
-	owsproxy['wfs'] = getSelectedWfs();
-	getData(owsproxy);
-}
-function setOwsproxy(obj){
-	if(obj.checked == true){
-		owsproxy['action'] = 'setOwsproxy';
-	}
-	else{
-		owsproxy['action'] = 'removeOwsproxy';
-	}
-	owsproxy['wfs'] = getSelectedWfs();
-	if(owsproxy['wfs']){
-		getData(owsproxy);
-	}
-	else{
-		obj.checked = false;
-	}
-}
-/*
- * Ajax-function to get data from the server
- */
-function getData(obj){
-	setIndicator();
-	var obj2json = parent.$.toJSON(obj);
-	parent.$.post("../php/mod_wfs_server.php",{"obj":obj2json}, function (json,status){
-		if(status == 'success'){
-			var dsJson = eval('(' + json + ')');
-			switch(obj['action']){
-				case "getServices":
-					appendServices(dsJson);
-				break;
-				case "getWfsConfData":
-					getOwsproxy();
-					appendWfsConfData(dsJson);
-				break;
-				case "getGuis":
-					appendGuis(dsJson);
-				break;
-				case "getAssignedConfs":
-					appendGuiConfs(dsJson);
-				break;
-				case "getUpdateUrl":
-					setUpdateUrl(dsJson)
-				break;
-				case "add":
-					getGuiConfs();
-				break;
-				case "remove":
-					getGuiConfs();
-				break;
-				case "updateWfs":
-					if(dsJson['success'])
-						alert("Update performed.");
-					else
-						alert("An error occured, see log for details.");
-				break;
-				case "deleteWfs":
-					if(dsJson['success']){
-						clearList(document.forms[0].wfsList);
-						clearList(document.forms[0].guiList);
-						getWfsList();
-						getGuis();
-						alert("WFS deleted.");
-					}
-				break;
-				case "setOwsproxy":
-					displayOwsproxy(dsJson);
-				break;
-				case "removeOwsproxy":
-					displayOwsproxy(dsJson);
-				break;
-				case "getOwsproxy":
-					displayOwsproxy(dsJson);
-				break;
-				default:
-					alert("No action specified.....");
-				break;
-			}
-		}
-		else{
-			alert("An error occured!");
-		}
-		removeIndicator();
-	});
-}
-
-/**
- * Sets the update url comming from db in the html form
- *
- */
-
-function setUpdateUrl(dsJson){
-	document.getElementById("updateUrl").value = dsJson['url'];
-}
-
-function clearUpdateUrl(){
-	document.getElementById("updateUrl").value = '';
-}
-
-/*
- *
- */
-function displayOwsproxy(dsJson){
-	if(dsJson.string == "" || dsJson.string == false){
-		document.wfsForm.owsproxy.checked = false;
-	}
-	else{
-		document.wfsForm.owsproxy.checked = true;
-	}
-}
-
-function appendServices(dsJson){
-	services['services'] = dsJson.services;
-	var o = services['services'];
-	for(var i=0; i<o.id.length; i++){
-		appendOption(document.forms[0].wfsList, o.title[i], o.id[i], false);
-	}
-	appendOption(document.forms[0].wfsList, "all WFS Configurations", "-1", false);
-}
-
-function appendWfsConfData(dsJson){
-	wfsConf['wfsConf'] = {};
-	wfsConf['wfsConf'] = dsJson.wfsConf;
-	var o = wfsConf['wfsConf'];
-	document.forms[0].wfsConfList.innerHTML = '';
-	if(typeof(o.id)=="undefined")
-		return;
-	for(var i=0; i<o.id.length; i++){
-		appendOption(document.forms[0].wfsConfList, o.abstract[i], o.id[i], false);
-	}
-}
-
-function appendGuis(dsJson){
-	guis['id'] = {};
-	guis['id'] = dsJson.id;
-	var o = guis['id'];
-	for(var i=0; i<o.length; i++){
-		appendOption(document.forms[0].guiList, o[i], o[i], false);
-	}
-}
-function appendGuiConfs(dsJson){
-	var list = document.forms[0].guiConfList;
-	list.innerHTML = '';
-	for(var i=0; i<dsJson.assignedConfs.length; i++){
-		var confAbstract = getConfAbstract(dsJson.assignedConfs[i]);
-		appendOption(list, confAbstract, dsJson.assignedConfs[i], false);
-	}
-}
-function appendOption(boxObject, optionText, optionValue, selected){
-	var newOption = new Option(optionText,optionValue,false,selected);
-	boxObject.options[boxObject.length] = newOption;
-}
-function clearList(boxObject){
-	boxObject.length = 0;
-}
-
-/*
- * returns id and abstract from a wfs configuration
- */
-function getConfAbstract(confId){
-	var c = wfsConf['wfsConf'];
-	for(var i=0; i < c['id'].length; i++){
-		if(c['id'][i] == confId){
-			return c['abstract'][i];
-		}
-	}
-}
-function getSelectedConfs(){
-	var list = document.forms[0].wfsConfList;
-	var confs = [];
-	for(var i=0; i<list.length; i++){
-		if(list.options[i].selected === true){
-			confs.push(list.options[i].value);
-		}
-	}
-	return confs;
-}
-function getSelectedAssignedConfs(){
-	var list = document.forms[0].guiConfList;
-	var confs = [];
-	for(var i=0; i<list.length; i++){
-		if(list.options[i].selected === true){
-			confs.push(list.options[i].value);
-		}
-	}
-	return confs;
-}
-function getSelectedGui(){
-	var ind = document.forms[0].guiList.selectedIndex;
-	return document.forms[0].guiList.options[ind].value;
-}
-
-function previewWfsUrl(){
-				 var previewUrl = document.forms[0].updateUrl.value;
-				 if(previewUrl !=''){
-				 							 capabilitiesWin = window.open(previewUrl);
-				}else{
-							alert("Please select a WFS first");			
-				}			
-}
-</script>
-</head>
-<body onload='getWfsList();getGuis();'>
-
-<h1>Edit WFS</h1>
-<form name='wfsForm'>
-	<div id='indicator'>ahh</div>
-
-	<fieldset class="leftContainer">
-	<legend>WFS List</legend>
-		<p>
-			<select size='10' name='wfsList' class='wfsList' onchange='getWfsConfData();getGuiConfs();clearUpdateUrl();'></select>
-		</p>
-	</fieldset>
-
-	<fieldset class="rightContainer">
-		<legend>Options</legend>
-		<p>
-			<input type='checkbox' name='owsproxy' id='owsproxy' onclick='setOwsproxy(this)' />
-			<label for="owsproxy">enable OWSProxy for the selected WFS</label>
-			<br><br>
-			<input type='button' value='Delete WFS' name='delete' id='deleteButton' onclick='deleteWfs()' />
-		</p>
-	</fieldset>
-
-	<fieldset class="rightContainer">
-		<legend>Update WFS</legend>
-		<p>
-				Please choose the Link to the WFS Capabilities URL:
-				<br />
-				<a href='javascript:getUpdateUrl("wfs_getcapabilities")'>wfs_getcapabilities</a> or <a href='javascript:getUpdateUrl("wfs_upload_url")'>wfs_upload_url</a>
-			</label>
-			<input id='updateUrl' type='text' value='' name='updateUrl' class='updateUrl' />
-			<br />
-			<input type='button' value='Update WFS' name='update' id='updateButton' onclick='updateWfs()' />
-						<input type='button' value='Preview WFS Capabilities' name='preview' id='previewButton' onclick='previewWfsUrl();' />
-		</p>
-	</fieldset>
-<hr />
-
-	<fieldset class="rightContainer">
-	<legend>GUI List</legend>
-		<p>
-			<select size='6' name='guiList' class='guiList' onchange='getGuiConfs()'></select>
-		</p>
-	</fieldset>
-
-<hr />
-
-	<fieldset class="leftContainer">
-	<legend>WFS Configuration List</legend>
-		<p>
-			<select size='6' name='wfsConfList' class='wfsConfList' onchange='' multiple="multiple"></select>
-		</p>
-	</fieldset>
-
-	<fieldset class="centerContainer">
-	<legend>Action</legend>
-		<p>
-			<input type='button' value='&gt;' name ='add' id ='add' class='add' onclick='addConfsToGui()'><br />
-			<input type='button' value='&lt;' name ='remove' id ='remove' class='remove' onclick='removeConfsFromGui()'>
-		</p>
-	</fieldset>
-
-	<fieldset class="rightContainer">
-	<legend>GUI Configuration List</legend>
-		<p>
-			<select size='6' name='guiConfList' class='guiConfList' onchange='' multiple="multiple"></select>
-		</p>
-	</fieldset>
-
-<hr />
-</form>
-
-</body>
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html;CHARSET=utf-8">
+
+<link rel="stylesheet" type="text/css" media="screen,projection" href="../css/admin.screen.css" title="screen" />
+
+<script type='text/javascript'>
+
+
+/*
+ * services['action']: instructs the servercomponent
+ * services['services']: infos about the services (wfs)
+ * services['services']['id']: a list of ids
+ * services['service']['title']: a corresponding list of titles
+ *
+ */
+var services = {};
+/*
+ * wfsConf['action']: instructs the servercomponent
+ * wfsConf['wfs']: the ID of the selected wfs
+ * wfsConf['wfsConf']: infos about the wfs configurations
+ * wfsConf['wfsConf']['id']: a list of ids
+ * wfsConf['wfsConf']['abstract']: a corresponding list of descriptions
+ */
+var wfsConf = {};
+
+/*
+ * guis['action']: instructs the servercomponent
+ * guis['id']: a list of gui-IDs where the current user is owner
+ * guis['selectedGui']: the selected Gui
+ */
+var guis = {};
+
+/*
+ * handleAssignment['action']: instructs the servercomponent
+ * handleAssignment['selectedConf']: a list of wfs-conf Ids
+ * handleAssignment['selectedGui']: the selected Gui
+ */
+var handleAssignment = {}
+
+/*
+ * vupdateWfs['action']: instructs the servercomponent
+ * vupdateWfs['wfs']: id of wfs to update
+ * vupdateWfs['url']: capabilities url
+ */
+var vupdateWfs = {};
+
+/*
+ * deleteWfs_['action']: instructs the servercomponent
+ * deleteWfs_['wfs']: id of wfs to update
+ */
+var deleteWfs_ = {};
+
+/*
+ * geturl['action']: instructs the servercomponent
+ * geturl['wfs']: id of wfs to get the url for
+ * geturl['column']: column of the url to get in table wfs
+ */
+var geturl = {}
+
+var owsproxy = {}
+
+
+
+
+function getWfsList(){
+	services['action'] = 'getServices';
+	getData(services);
+}
+function getGuis(){
+	guis['action'] = 'getGuis';
+	getData(guis);
+}
+function getWfsConfData(){
+	wfsConf['action'] = 'getWfsConfData';
+	wfsConf['wfs'] = getSelectedWfs();
+	getData(wfsConf);
+}
+function getSelectedWfs(){
+	var w = document.wfsForm.wfsList;
+	var ind  = w.selectedIndex;
+	if(ind == -1){
+		return false;
+	}
+	if(ind == w.options.length-1)
+		return "gui_confs";
+	return w.options[ind].value;
+}
+function getGuiConfs(){
+	guis['action'] = 'getAssignedConfs';
+	var g = document.wfsForm.guiList;
+	var ind  = g.selectedIndex;
+	if(ind == -1){
+		return false;
+	}
+	guis['selectedGui'] = g.options[ind].value;
+	guis['selectedWfs'] = wfsConf['wfs'];
+	getData(guis);
+}
+/**
+ * Sends an request to get the url to the capabilities doc of selected wfs
+ *
+ */
+
+function getUpdateUrl(column){
+	geturl['action'] = 'getUpdateUrl';
+	var w = document.wfsForm.wfsList;
+	var ind  = w.selectedIndex;
+	if(ind == -1){
+		alert("please select an WFS");
+		return;
+	}
+	geturl['wfs'] = w.options[ind].value;
+	geturl['column'] = column;
+	geturl['wfs_version'] = '';
+	getData(geturl);
+}
+
+function addConfsToGui(){
+	handleAssignment['action'] = 'add';
+	handleAssignment['confs'] = getSelectedConfs();
+	handleAssignment['gui'] = getSelectedGui();
+	getData(handleAssignment);
+}
+function removeConfsFromGui(){
+	handleAssignment['action'] = 'remove';
+	handleAssignment['confs'] = getSelectedAssignedConfs();
+	handleAssignment['gui'] = getSelectedGui();
+	getData(handleAssignment);
+}
+/**
+ * Sends an update request to update the capabilities of selected wfs
+ *
+ * @return success
+ * @type boolean
+ */
+
+function updateWfs(){
+	vupdateWfs['action'] = 'updateWfs';
+	var w = document.wfsForm.wfsList;
+	var ind  = w.selectedIndex;
+	if(ind == -1){
+		alert("please select an WFS");
+		return false;
+	}
+	vupdateWfs['wfs'] = w.options[ind].value;
+	if(document.getElementById("updateUrl").value == ''){
+		alert("Please choose the link to the new WFS Capabilities URL.");
+		return false;
+	}
+
+	vupdateWfs['url'] = document.getElementById("updateUrl").value;
+	getData(vupdateWfs);
+	return true;
+}
+
+function deleteWfs(){
+	deleteWfs_['action'] = 'deleteWfs';
+	deleteWfs_['wfs'] = getSelectedWfs();
+	if(deleteWfs_['wfs']&&deleteWfs_['wfs']!="gui_confs"){
+		if(confirm("Do you really want to delete the Wfs with Wfs-id:"+deleteWfs_['wfs']+"?")){
+			getData(deleteWfs_);
+		}
+		return true;
+	}
+	return false;
+}
+
+function setIndicator(){
+	var str = "<img src='../img/indicator_wheel.gif'>";
+	document.getElementById("indicator").innerHTML = str;
+}
+function removeIndicator(){
+	document.getElementById("indicator").innerHTML = "";
+}
+function getOwsproxy(){
+	owsproxy['action'] = 'getOwsproxy';
+	owsproxy['wfs'] = getSelectedWfs();
+	getData(owsproxy);
+}
+function setOwsproxy(obj){
+	if(obj.checked == true){
+		owsproxy['action'] = 'setOwsproxy';
+	}
+	else{
+		owsproxy['action'] = 'removeOwsproxy';
+	}
+	owsproxy['wfs'] = getSelectedWfs();
+	if(owsproxy['wfs']){
+		getData(owsproxy);
+	}
+	else{
+		obj.checked = false;
+	}
+}
+/*
+ * Ajax-function to get data from the server
+ */
+function getData(obj){
+	setIndicator();
+	var obj2json = parent.$.toJSON(obj);
+	parent.$.post("../php/mod_wfs_server.php",{"obj":obj2json}, function (json,status){
+		if(status == 'success'){
+			var dsJson = eval('(' + json + ')');
+			switch(obj['action']){
+				case "getServices":
+					appendServices(dsJson);
+				break;
+				case "getWfsConfData":
+					getOwsproxy();
+					appendWfsConfData(dsJson);
+				break;
+				case "getGuis":
+					appendGuis(dsJson);
+				break;
+				case "getAssignedConfs":
+					appendGuiConfs(dsJson);
+				break;
+				case "getUpdateUrl":
+					setUpdateUrl(dsJson)
+				break;
+				case "add":
+					getGuiConfs();
+				break;
+				case "remove":
+					getGuiConfs();
+				break;
+				case "updateWfs":
+					if(dsJson['success'])
+						alert("Update performed.");
+					else
+						alert("An error occured, see log for details.");
+				break;
+				case "deleteWfs":
+					if(dsJson['success']){
+						clearList(document.forms[0].wfsList);
+						clearList(document.forms[0].guiList);
+						getWfsList();
+						getGuis();
+						alert("WFS deleted.");
+					}
+				break;
+				case "setOwsproxy":
+					displayOwsproxy(dsJson);
+				break;
+				case "removeOwsproxy":
+					displayOwsproxy(dsJson);
+				break;
+				case "getOwsproxy":
+					displayOwsproxy(dsJson);
+				break;
+				default:
+					alert("No action specified.....");
+				break;
+			}
+		}
+		else{
+			alert("An error occured!");
+		}
+		removeIndicator();
+	});
+}
+
+/**
+ * Sets the update url comming from db in the html form
+ *
+ */
+
+function setUpdateUrl(dsJson){
+	document.getElementById("updateUrl").value = dsJson['url'];
+}
+
+function clearUpdateUrl(){
+	document.getElementById("updateUrl").value = '';
+}
+
+/*
+ *
+ */
+function displayOwsproxy(dsJson){
+	if(dsJson.string == "" || dsJson.string == false){
+		document.wfsForm.owsproxy.checked = false;
+	}
+	else{
+		document.wfsForm.owsproxy.checked = true;
+	}
+}
+
+function appendServices(dsJson){
+	services['services'] = dsJson.services;
+	var o = services['services'];
+	for(var i=0; i<o.id.length; i++){
+		appendOption(document.forms[0].wfsList, o.title[i], o.id[i], false);
+	}
+	appendOption(document.forms[0].wfsList, "all assigned WFS Configurations", "-1", false);
+}
+
+function appendWfsConfData(dsJson){
+	wfsConf['wfsConf'] = {};
+	wfsConf['wfsConf'] = dsJson.wfsConf;
+	var o = wfsConf['wfsConf'];
+	document.forms[0].wfsConfList.innerHTML = '';
+	if(typeof(o.id)=="undefined")
+		return;
+	for(var i=0; i<o.id.length; i++){
+		appendOption(document.forms[0].wfsConfList, o.abstract[i], o.id[i], false);
+	}
+}
+
+function appendGuis(dsJson){
+	guis['id'] = {};
+	guis['id'] = dsJson.id;
+	var o = guis['id'];
+	for(var i=0; i<o.length; i++){
+		appendOption(document.forms[0].guiList, o[i], o[i], false);
+	}
+}
+function appendGuiConfs(dsJson){
+	var list = document.forms[0].guiConfList;
+	list.innerHTML = '';
+	for(var i=0; i<dsJson.assignedConfs.length; i++){
+		var confAbstract = getConfAbstract(dsJson.assignedConfs[i]);
+		appendOption(list, confAbstract, dsJson.assignedConfs[i], false);
+	}
+}
+function appendOption(boxObject, optionText, optionValue, selected){
+	var newOption = new Option(optionText,optionValue,false,selected);
+	boxObject.options[boxObject.length] = newOption;
+}
+function clearList(boxObject){
+	boxObject.length = 0;
+}
+
+/*
+ * returns id and abstract from a wfs configuration
+ */
+function getConfAbstract(confId){
+	var c = wfsConf['wfsConf'];
+	for(var i=0; i < c['id'].length; i++){
+		if(c['id'][i] == confId){
+			return c['abstract'][i];
+		}
+	}
+}
+function getSelectedConfs(){
+	var list = document.forms[0].wfsConfList;
+	var confs = [];
+	for(var i=0; i<list.length; i++){
+		if(list.options[i].selected === true){
+			confs.push(list.options[i].value);
+		}
+	}
+	return confs;
+}
+function getSelectedAssignedConfs(){
+	var list = document.forms[0].guiConfList;
+	var confs = [];
+	for(var i=0; i<list.length; i++){
+		if(list.options[i].selected === true){
+			confs.push(list.options[i].value);
+		}
+	}
+	return confs;
+}
+function getSelectedGui(){
+	var ind = document.forms[0].guiList.selectedIndex;
+	return document.forms[0].guiList.options[ind].value;
+}
+
+function previewWfsUrl(){
+				 var previewUrl = document.forms[0].updateUrl.value;
+				 if(previewUrl !=''){
+				 							 capabilitiesWin = window.open(previewUrl);
+				}else{
+							alert("Please select a WFS first");			
+				}			
+}
+</script>
+</head>
+<body onload='getWfsList();getGuis();'>
+
+<h1>Edit WFS</h1>
+<form name='wfsForm'>
+	<div id='indicator'>ahh</div>
+
+	<fieldset class="leftContainer">
+	<legend>WFS List</legend>
+		<p>
+			<select size='10' name='wfsList' class='wfsList' onchange='getWfsConfData();getGuiConfs();clearUpdateUrl();'></select>
+		</p>
+	</fieldset>
+
+	<fieldset class="rightContainer">
+		<legend>Options</legend>
+		<p>
+			<input type='checkbox' name='owsproxy' id='owsproxy' onclick='setOwsproxy(this)' />
+			<label for="owsproxy">enable OWSProxy for the selected WFS</label>
+			<br><br>
+			<input type='button' value='Delete WFS' name='delete' id='deleteButton' onclick='deleteWfs()' />
+		</p>
+	</fieldset>
+
+	<fieldset class="rightContainer">
+		<legend>Update WFS</legend>
+		<p>
+				Please choose the Link to the WFS Capabilities URL:
+				<br />
+				<a href='javascript:getUpdateUrl("wfs_getcapabilities")'>wfs_getcapabilities</a> or <a href='javascript:getUpdateUrl("wfs_upload_url")'>wfs_upload_url</a>
+			</label>
+			<input id='updateUrl' type='text' value='' name='updateUrl' class='updateUrl' />
+			<br />
+			<input type='button' value='Update WFS' name='update' id='updateButton' onclick='updateWfs()' />
+						<input type='button' value='Preview WFS Capabilities' name='preview' id='previewButton' onclick='previewWfsUrl();' />
+		</p>
+	</fieldset>
+<hr />
+
+	<fieldset class="rightContainer">
+	<legend>GUI List</legend>
+		<p>
+			<select size='6' name='guiList' class='guiList' onchange='getGuiConfs()'></select>
+		</p>
+	</fieldset>
+
+<hr />
+
+	<fieldset class="leftContainer">
+	<legend>WFS Configuration List</legend>
+		<p>
+			<select size='6' name='wfsConfList' class='wfsConfList' onchange='' multiple="multiple"></select>
+		</p>
+	</fieldset>
+
+	<fieldset class="centerContainer">
+	<legend>Action</legend>
+		<p>
+			<input type='button' value='&gt;' name ='add' id ='add' class='add' onclick='addConfsToGui()'><br />
+			<input type='button' value='&lt;' name ='remove' id ='remove' class='remove' onclick='removeConfsFromGui()'>
+		</p>
+	</fieldset>
+
+	<fieldset class="rightContainer">
+	<legend>GUI Configuration List</legend>
+		<p>
+			<select size='6' name='guiConfList' class='guiConfList' onchange='' multiple="multiple"></select>
+		</p>
+	</fieldset>
+
+<hr />
+</form>
+
+</body>
 </html>
\ No newline at end of file

Modified: branches/print_dev/http/javascripts/mod_wfs_gazetteer_client.php
===================================================================
--- branches/print_dev/http/javascripts/mod_wfs_gazetteer_client.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/mod_wfs_gazetteer_client.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -19,7 +19,6 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
-$gui_id = $_SESSION["mb_user_gui"];
 
 $target = $_REQUEST["e_target"];
 $isLoaded = $_REQUEST["isLoaded"];
@@ -28,7 +27,7 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset='<?php echo CHARSET;?>'">	
+<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET;?>">	
 <title>mod_wfs_gazetteer</title>
 
 <?php
@@ -130,8 +129,6 @@
 parent.mb_registerInitFunctions("window.frames['"+this.name+"'].init_wfsSpatialRequest()");
 
 function init_wfsSpatialRequest() {
-	//parent.mb_ajax_json("../php/mod_wfsSpatialRequest_messages.php", function(obj, status) {
-	//	msgObj = obj;
 		buttonWfs_id = [];
 		buttonWfs_on = [];
 		buttonWfs_src = [];
@@ -144,7 +141,6 @@
 		addButtonWfs("point", buttonPoint.status, buttonPoint.img, buttonPoint.title, buttonPoint.x, buttonPoint.y);
 		addButtonWfs("extent", buttonExtent.status, buttonExtent.img, buttonExtent.title, buttonExtent.x, buttonExtent.y);
 		displayButtons();
-	//});
 }
 
 function wfsInitFunction (j) {

Modified: branches/print_dev/http/javascripts/popup.js
===================================================================
--- branches/print_dev/http/javascripts/popup.js	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/popup.js	2009-05-22 11:46:01 UTC (rev 3956)
@@ -377,7 +377,7 @@
 		
 		//Insert content
 		if(settings.url)
-			html = ('<iframe name="'+settings.frameName+'" src="'+settings.url+'"></iframe>');
+			html = ('<iframe name="'+settings.frameName+'" width="' + settings.width + '" height="' +settings.height + '" src="'+settings.url+'"></iframe>');
 		else
 			html = ('<div class="scrollDiv">'+settings.html+'</div>');
 	

Modified: branches/print_dev/http/javascripts/wfs.php
===================================================================
--- branches/print_dev/http/javascripts/wfs.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/wfs.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,552 +1,555 @@
-<?php
-# $Id$
-# Copyright (C) 2002 CCGIS 
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require_once(dirname(__FILE__) . "/../php/mb_validateSession.php");
-
-?>
-// ---------------------------------------------------------------------------------------------------------------
-// --- usemap (begin) --------------------------------------------------------------------------------------------
-
-function mod_usemap(wfs_name) {
-	if (wfs_name == "") {
-		usemap = "";
-	}
-	var ind = getMapObjIndexByName(mb_wfs_targets[0]);
-	var myImg = window.frames[mb_wfs_targets[0]].document.getElementById("um_img").style; 
-	myImg.width = mb_mapObj[ind].width;
-	myImg.height = mb_mapObj[ind].height;
-
-	for (var i = 0 ; i < mb_wfs_fetch.count() ; i ++) {
-		if (mb_wfs_fetch.get(i).wfs_conf == wfs_name || wfs_name == "") {
-		
-			if (mb_wfs_fetch.get(i).geomType == geomType.polygon) {
-				usemap += mod_usemap_polygon(i);
-			}
-			else if (mb_wfs_fetch.get(i).geomType == geomType.point) {
-				usemap += mod_usemap_circle(i);
-			}
-			else if (mb_wfs_fetch.get(i).geomType == geomType.line) {
-				usemap += mod_usemap_line(i);
-			}
-		}
-	}
-	writeUsemap(usemap);
-}
-
-function mod_usemap_circle(ind){
-	var str = "";
-	var coord = "";
-	
-	var title = "";
-	for (var i = 0 ; i < mb_wfs_fetch.get(ind).e.count(); i++) {
-		if (i>0) title += "&#10;";
-		title += mb_wfs_fetch.get(ind).e.getName(i) + ": " + mb_wfs_fetch.get(ind).e.getValue(i);
-	}
-
-	for (var i = 0 ; i < mb_wfs_fetch.get(ind).count() ; i ++) {
-		var p = mb_wfs_fetch.getPoint(ind, i, 0);
-		var pos = realToMap(mb_wfs_targets[0],p);
-		coord += pos.x + ", " + pos.y;
-		
-		str += "<AREA title='"+title+"' onmouseover='parent.mb_wfs_perform(\"over\",parent.mb_wfs_fetch.get("+ind+"))' ";
-		str += "onmouseout='parent.mb_wfs_perform(\"out\",parent.mb_wfs_fetch.get("+ind+"))' shape='circle'  coords='";
-		str += coord + ", " + mod_usemap_radius + "' href='#'>";
-	}
-	
-	return str;
-}
-
-function mod_usemap_line_calculate (aGeometry, j, orientation, cnt) {
-	var coord = "";
-
-	var p1 = realToMap(mb_wfs_targets[0],aGeometry.get(j));
-	var p2 = realToMap(mb_wfs_targets[0],aGeometry.get(j+orientation));
-
-	var vec = p2.minus(p1);
-	
-	if (vec.x != 0 || vec.y != 0) {
-		var n_vec;
-		if (vec.x != 0) {
-			if (vec.x > 0) n_vec = new Point((-vec.y)/vec.x, -1);
-			else n_vec = new Point(vec.y/vec.x, 1);
-		}
-		else {
-			if (vec.y > 0) n_vec = new Point(1,0);
-			else n_vec = new Point(-1,0);
-		}
-		n_vec = n_vec.times(mod_usemap_line_tolerance).dividedBy(n_vec.dist(new Point(0,0)))
-
-		lp = new Point(p1.x + n_vec.x, p1.y - n_vec.y);
-
-		if (cnt > 0) coord += ", ";
-
-		coord += parseInt(lp.x) + ", " + parseInt(lp.y);
-		coord += ", " + parseInt(lp.x+vec.x) + ", " + parseInt(lp.y+vec.y);
-	}
-	return coord;
-}
-
-function mod_usemap_line(ind){
-	var str = "";
-	var title = "";
-	for (var i = 0 ; i < mb_wfs_fetch.get(ind).e.count(); i++) {
-		if (i>0) title += "&#10;";
-		title += mb_wfs_fetch.get(ind).e.getName(i) + ": " + mb_wfs_fetch.get(ind).e.getValue(i);
-	}
-	for (var i = 0 ; i < mb_wfs_fetch.get(ind).count() ; i ++) {
-		var coord = "";
-		var cnt = 0;
-
-		for (var j = 0 ; j < mb_wfs_fetch.getGeometry(ind,i).count() - 1  ; j ++) {
-			var result = mod_usemap_line_calculate(mb_wfs_fetch.getGeometry(ind,i), j, 1, cnt);
-			if (result != "") {
-				coord += result;
-				cnt++;
-			}
-		}
-		
-		for (var j = (mb_wfs_fetch.getGeometry(ind,i).count() - 1) ; j > 0 ; j--) {
-			var result = mod_usemap_line_calculate(mb_wfs_fetch.getGeometry(ind,i), j, -1, cnt);
-			if (result != "") {
-				coord += result;
-				cnt++;
-			}
-		}
-		
-		if (coord != "") {
-			str += "<AREA title='"+title+"'";
-			str += "onmouseover='parent.mb_wfs_perform(\"over\",parent.mb_wfs_fetch.get("+ind+"))' ";
-			str += "onmouseout='parent.mb_wfs_perform(\"out\",parent.mb_wfs_fetch.get("+ind+"))' ";
-			str += "shape='poly'  coords='";
-			str += coord + "' href='#'>";
-		}
-		else {
-			//display circle
-			var pos = realToMap(mb_wfs_targets[0],mb_wfs_fetch.getPoint(ind,i,0));
-			coord += pos.x + ", " + pos.y;
-			
-			str += "<AREA title='"+title+"' onmouseover='parent.mb_wfs_perform(\"over\",parent.mb_wfs_fetch["+ind+"])' ";
-			str += "onmouseout='parent.mb_wfs_perform(\"out\",parent.mb_wfs_fetch.get("+ind+"))' shape='circle'  coords='";
-			str += coord + ", " + mod_usemap_radius + "' href='#'>";
-		}
-	}
-	
-	return str;
-}
-
-function mod_usemap_polygon(ind){
-	var str = "";
-	var coord = "";
-	var title = "";
-	for (var i = 0 ; i < mb_wfs_fetch.get(ind).e.count(); i++) {
-		if (i>0) title += "&#10;";
-		title += mb_wfs_fetch.get(ind).e.getName(i) + ": " + mb_wfs_fetch.get(ind).e.getValue(i);
-	}
-
-	for (var i = 0 ; i < mb_wfs_fetch.get(ind).count() ; i ++) {
-		var pos = realToMap(mb_wfs_targets[0],mb_wfs_fetch.getPoint(ind, i, 0));
-		coord += pos.x + ", " + pos.y;
-		
-		for (var j = 1 ; j < mb_wfs_fetch.getGeometry(ind,i).count() ; j ++) {
-			pos = realToMap(mb_wfs_targets[0],mb_wfs_fetch.getPoint(ind, i, j));
-			coord += ", " + pos.x + ", " + pos.y;
-		}
-		
-		str += "<AREA title='"+title+"' onmouseover='parent.mb_wfs_perform(\"over\",parent.mb_wfs_fetch.get("+ind+"))' ";
-		str += "onmouseout='parent.mb_wfs_perform(\"out\",parent.mb_wfs_fetch.get("+ind+"))' shape='poly'  coords='";
-		str += coord + "' href='#'>";
-	}
-	
-	return str;
-}
-
-function writeUsemap(str) {
-	writeTag(mb_wfs_targets[0], 'um', str);
-}
-// --- usemap (end) ----------------------------------------------------------------------------------------------
-// ---------------------------------------------------------------------------------------------------------------
-
-
-var highlight_tag_id = "wfs_highlight_tag";
-var mb_wfs_fetched = [];
-
-var mb_wfs_objwin = null;
-var mb_wfs_objwin_left = 800;
-var mb_wfs_objwin_top = 200;
-var mb_wfs_objwin_width = 200;
-var mb_wfs_objwin_height = 200;
-var mb_wfs_targetString = "<?php echo implode(",", $e_target); ?>";
-var mb_wfs_targets = mb_wfs_targetString.split(",");
-var mb_wfs_fillColor = "#ff0000";
-var usemap = "";
-var mod_usemap_radius = 10;
-var mod_usemap_line_tolerance = 5;
-var useCheckboxForHighlighting = false;
-
-var mb_wfs_fetch = new GeometryArray();
-
-var highlight;
-
-try {if(generalHighlightZIndex){}}catch(e) {generalHighlightZIndex = 90;}
-try {if(generalHighlightLineWidth){}}catch(e) {generalHighlightLineWidth = 2;}
-try {if(useUsemap){}}catch(e) {useUsemap = 0;}
-
-mb_registerInitFunctions('initHighlight()');
-
-function initHighlight() {
-	var styleObj = {"position":"absolute", "top":"0px", "left":"0px", "z-index":generalHighlightZIndex};
-	highlight = new Highlight(mb_wfs_targets, highlight_tag_id, styleObj, generalHighlightLineWidth);
-}
-try {if(displayWfsResultList){}}catch(e) {displayWfsResultList = 0;};
-
-if (displayWfsResultList == 1) {
-	//mb_registerWfsReadSubFunctions(function(geom){mb_wfs_listMember(geom)});
-}
-
-
-if (parseInt(useUsemap) == 1) {
-	mb_registerSubFunctions('mod_usemap("")');
-}
-
-if (useCheckboxForHighlighting) {
-	eventInit.register(function() {
-		mb_registerSubFunctions('highlight.paint()');
-	});
-}
-
-/*
-if (useExtentIsSet()) {
-	mb_registerSubFunctions("mb_setwfsrequest_extent()");
-}
-function mb_setwfsrequest_extent() {
-
-	if (useExtentIsSet()) {
-		var ind = getMapObjIndexByName(mb_wfs_targets[0]);
-		var pos_a = makeClickPos2RealWorldPos(mb_wfs_targets[0],0,0);
-		var pos_b = makeClickPos2RealWorldPos(mb_wfs_targets[0],mb_mapObj[ind].width,mb_mapObj[ind].height);
-
-		var x = [];
-		var y = [];
-		x[0] = pos_a[0];
-		x[1] = pos_b[0];
-		y[0] = pos_a[1];
-		y[1] = pos_b[1];
-
-		mb_setwfsrequest(mb_wfs_targets[0],'rectangle',x,y);
-	}
-}
-*/
-
-function mb_wfs_listMember(geomArray){
-	mb_wfs_fetch.union(geomArray);
-	var wfs_conf = get_complete_wfs_conf();
-	var str = "<table>";
-	for(var i=0; i<mb_wfs_fetch.count(); i++){
-		var t = wfs_conf[mb_wfs_fetch.get(i).wfs_conf];
-		for(var j=0; j<t['element'].length; j++){
-			if(t['element'][j]['f_show'] > 0){
-				var k = mb_wfs_fetch.get(i).e.getElementIndexByName(t['element'][j]['element_name']);
-				//alert(k);
-				if(k != -1){
-					str += "<tr><td>";
-					if (useCheckboxForHighlighting) {
-						str += "<input type=checkbox id=highlightCheckbox" + i + " onChange='highlightGeometry(" + i + ")'></td><td>";
-					}
-					str += "<div";
-					if (!useCheckboxForHighlighting) {
-						str += " onmouseover='mb_wfs_perform(\"over\",mb_wfs_fetch.get("+i+"))' ";
-						str += " onmouseout='mb_wfs_perform(\"out\",mb_wfs_fetch.get("+i+"))' ";
-					}
-					str += " onclick='mb_wfs_perform(\"click\",mb_wfs_fetch.get("+i+"))' ";
-					str += ">" + mb_wfs_fetch.get(i).e.getValue(k)+ "</div></td></tr>";
-				}
-			}
-		}
-	}
-	str += "</table>";
-	mb_wfs_objwin.innerHTML = str;
-//	if (parseInt(useUsemap) == 1) mod_usemap(wfs_name);
-}
-
-function mb_wfs_reset(){
-	mb_wfs_fetch = new parent.GeometryArray();
-	usemap = "";
-
-	if(mb_wfs_objwin == null){
-		var iframe=document.createElement('div');
-		iframe.setAttribute("style","position:absolute;left:"+mb_wfs_objwin_left+"px;top:"+mb_wfs_objwin_top+"px;width:"+mb_wfs_objwin_width+"px;height:"+mb_wfs_objwin_height+"px");
-		mb_wfs_objwin = document.body.appendChild(iframe);
-		mb_wfs_objwin.id = "mb_wfs_objwin";
-		mb_wfs_objwin.name = "mb_wfs_objwin";
-		mb_wfs_objwin.style.position = 'absolute';
-		mb_wfs_objwin.style.left = mb_wfs_objwin_left+"px";
-		mb_wfs_objwin.style.top = mb_wfs_objwin_top+"px";
-		mb_wfs_objwin.style.width = mb_wfs_objwin_width+"px";
-		mb_wfs_objwin.style.height = mb_wfs_objwin_height+"px";
-	}
-	for(var i=0; i<mb_wfsreq; i++){
-		if(document.getElementById("mb_wfs_win_"+mb_wfsreq)){
-			document.removeChild("mb_wfs_win_"+mb_wfsreq);
-		}
-	}
-	mb_wfsreq = 0;
-	return true;
-}
-
-function get_complete_wfs_conf() {
-	var wfs_conf = window.frames["wfs_conf"].get_wfs_conf();
-	return wfs_conf;
-}
-
-function highlightGeometry(i) {
-	var id = "highlightCheckbox"+i;
-	if (document.getElementById(id).checked) {
-		highlight.add(mb_wfs_fetch.get(i), '#00ff00');
-		highlight.paint();
-	}
-	else {
-		highlight.del(mb_wfs_fetch.get(i), '#00ff00');
-		highlight.paint();
-	}
-}
-
-function mb_wfs_perform(type,m){
-
-	var wfs_conf = window.frames["wfs_conf"].get_wfs_conf();
-	if(type=='over') {
-		highlight.add(m, '#ff0000');
-		highlight.paint();
-	}
-	else if (type == 'out') {
-		highlight.del(m, '#ff0000');
-		highlight.paint();
-	}
-	else
-		if (type == 'click') {
-			var tmp = m.getBBox();
-			if (m.geomType == geomType.point) {
-				var b = 1;
-			}
-			else {
-				var b = 0;
-			}
-			if (typeof(m.wfs_conf) != "undefined") {
-				b = parseFloat(wfs_conf[m.wfs_conf]['g_buffer']);
-			}
-			var buffer = new Point(b, b);
-			var bbox_ll = tmp[0].minus(buffer);
-			var bbox_ru = tmp[1].plus(buffer);
-			mb_calcExtent(mb_wfs_targets[0], bbox_ll, bbox_ru);
-			highlight.del(m, '#ff0000');
-			zoom(mb_wfs_targets[0], 'true', 1.0);
-			highlight.add(m, '#ff0000');
-			highlight.paint();
-		}
-}
-
-function get_wfs_str(myconf, d, m, type, fid) {
-
-	var featureTypeArray = myconf['featuretype_name'].split(':')
-	var featureNS = featureTypeArray[0];
-
-	var str = '<wfs:Transaction version="1.0.0" service="WFS" ';
-
-	var ns_gml = false;	var ns_ogc = false;	var ns_xsi = false;	var ns_wfs = false;	var ns_featureNS = false;
-
-	for (var q = 0 ; q < myconf['namespaces'].length ; q++) {
-
-		if (myconf['namespaces'][q]['name'] == "gml"){
-			 ns_gml = true;
-			 str += 'xmlns:' + myconf['namespaces'][q]['name'] + '="' + myconf['namespaces'][q]['location'] + '" ';
-		} else if (myconf['namespaces'][q]['name'] == "ogc") {
-			ns_ogc = true;
-			str += 'xmlns:' + myconf['namespaces'][q]['name'] + '="' + myconf['namespaces'][q]['location'] + '" ';
-		} else if (myconf['namespaces'][q]['name'] == "xsi") {
-			ns_xsi = true;
-			str += 'xmlns:' + myconf['namespaces'][q]['name'] + '="' + myconf['namespaces'][q]['location'] + '" ';
-		} else if (myconf['namespaces'][q]['name'] == "wfs") {
-			ns_wfs = true;
-			str += 'xmlns:' + myconf['namespaces'][q]['name'] + '="' + myconf['namespaces'][q]['location'] + '" ';
-		} else if (myconf['namespaces'][q]['name'] == featureNS) {
-			ns_featureNS = true;
-			str += 'xmlns:' + myconf['namespaces'][q]['name'] + '="' + myconf['namespaces'][q]['location'] + '" '
-			strForSchemaLocation = myconf['namespaces'][q]['location'];
-		}
-	}
-
-	if (ns_gml == false) str += 'xmlns:gml="http://www.opengis.net/gml" ';
-	if (ns_ogc == false) str += 'xmlns:ogc="http://www.opengis.net/ogc" ';
-	if (ns_xsi == false) str += 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ';
-	if (ns_featureNS == false) str += 'xmlns:"+featureNS+"="http://www.someserver.com/"+featureNS+"" ';
-	if (ns_wfs == false) str += 'xmlns:wfs="http://www.opengis.net/wfs" ';
-
-	str += 'xsi:schemaLocation="http://www.opengis.net/wfs';
-	str += ' http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd';
-	str += ' ' + strForSchemaLocation;
-	str += ' '+ myconf['wfs_describefeaturetype'];
-	//str += mb_getConjunctionCharacter(myconf['wfs_describefeaturetype']);
-	//str += 'typename=' + myconf['featuretype_name'];
-	str += '">';
-
-	//
-	// ---------------------------------------- SAVE -------------------------------------------------
-	//
-	if (type == "save") {
-		str += '<wfs:Insert><'+ myconf['featuretype_name']+'>';
-		for(var i=0; i<d.get(m).e.count(); i++){
-			if(d.get(m).e.getValue(i) != "" && d.get(m).e.getName(i) != "fid"){
-				var tmp = d.get(m).e.getName(i);
-				str += '<' + tmp  + '><![CDATA[' + d.get(m).e.getValue(i) + ']]></' + tmp  + '>';
-			}
-		}
-		for(var j=0; j<myconf['element'].length; j++){
-			if(myconf['element'][j]['f_geom'] == 1){
-				var el_geom = myconf['element'][j]['element_name'];
-			}
-		}
-		str += '<' + el_geom + '>';
-		if(d.get(m).geomType == geomType.point){
-			str += '<gml:Point srsName="' + myconf['featuretype_srs'] + '">';
-			str += '<gml:coordinates>';
-			str += d.getPoint(m,0,0).x + "," + d.getPoint(m,0,0).y;
-			str += '</gml:coordinates>';
-			str += '</gml:Point>';
-		}
-		if(d.get(m).geomType == geomType.line){
-			str += '<gml:MultiLineString srsName="' + myconf['featuretype_srs'] + '">';
-			str += '<gml:lineStringMember><gml:LineString><gml:coordinates>';
-			for(var k=0; k<d.getGeometry(m,0).count(); k++){
-				if(k>0)	str += " ";
-				str += d.getPoint(m,0,k).x + "," + d.getPoint(m,0,k).y;
-			}
-			str += '</gml:coordinates></gml:LineString></gml:lineStringMember>';
-			str += '</gml:MultiLineString>';
-		}
-		if(d.get(m).geomType == geomType.polygon){
-			str += '<gml:MultiPolygon srsName="' + myconf['featuretype_srs'] + '">';
-			for (var k = 0; k < d.get(m).count(); k++) {
-				str += '<gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>';
-	
-				for(var l = 0; l < d.getGeometry(m, k).count(); l++){
-					if (l > 0) {
-						str += " ";
-					}	
-					str += d.getPoint(m,k,l).x + "," + d.getPoint(m,k,l).y;
-				}
-
-				str += '</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>';
-				
-				if (d.getGeometry(m, k).innerRings) {
-					for(var ii = 0; ii < d.getGeometry(m, k).innerRings.count(); ii++){
-						str += '<gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>';
-						for(var l = 0; l < d.getGeometry(m, k).innerRings.get(ii).count(); l++){
-							if (l > 0) {
-								str += " ";
-							}	
-							str += d.getPoint(m,k,ii,l).x + "," + d.getPoint(m,k,ii,l).y;
-						}
-						str += '</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs>';
-					}
-				}
-
-				str += '</gml:Polygon></gml:polygonMember>';
-			}
-			str += '</gml:MultiPolygon>';
-		}
-		str += '</' + el_geom + '></'+ myconf['featuretype_name']+'></wfs:Insert>';
-	}
-	//
-	// --------------------------------------- UPDATE ------------------------------------------------
-	//
-	else if (type == "update") {
-		str += '<wfs:Update typeName="'+ myconf['featuretype_name']+'">';
-		for(var i=0; i<d.get(m).e.count(); i++){
-			if(d.get(m).e.getValue(i) != "" && d.get(m).e.getName(i) != "fid"){
-				str += '<wfs:Property>';
-				str += '<wfs:Name>'+d.get(m).e.getName(i)+'</wfs:Name>';
-				str += '<wfs:Value><![CDATA['+d.get(m).e.getValue(i)+']]></wfs:Value>';
-				str += '</wfs:Property>';
-			}
-		}
-		for(var j=0; j<myconf['element'].length; j++){
-			if(myconf['element'][j]['f_geom'] == 1){
-				var el_geom = myconf['element'][j]['element_name'];
-			}
-		}
-		str += '<wfs:Property><wfs:Name>' + el_geom + '</wfs:Name><wfs:Value>';
-		if(d.get(m).geomType == geomType.point){
-			str += '<gml:Point srsName="' + myconf['featuretype_srs'] + '"><gml:coordinates>';
-			str += d.getPoint(m,0,0).x + "," + d.getPoint(m,0,0).y;
-			str += '</gml:coordinates></gml:Point>';
-		}
-		if(d.get(m).geomType == geomType.line){
-			str += '<gml:MultiLineString srsName="' + myconf['featuretype_srs'] + '">';
-			str += '<gml:lineStringMember><gml:LineString><gml:coordinates>';
-			for(var k=0; k<d.getGeometry(m,0).count(); k++){
-				if(k>0)	str += " ";
-				str += d.getPoint(m,0,k).x + "," + d.getPoint(m,0,k).y;
-			}
-			str += '</gml:coordinates></gml:LineString></gml:lineStringMember>';
-			str += '</gml:MultiLineString>';
-		}
-		if(d.get(m).geomType == geomType.polygon){
-			str += '<gml:MultiPolygon srsName="' + myconf['featuretype_srs'] + '">';
-			for (var l = 0; l < d.get(m).count(); l++) {
-				str += '<gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>';
-				for(var k=0; k<d.getGeometry(m,l).count(); k++){
-					if(k>0)	str += " ";
-					str += d.getPoint(m,l,k).x + "," + d.getPoint(m,l,k).y;
-				}
-				str += '</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>';
-				if (d.getGeometry(m, l).innerRings) {
-					for(var ii = 0; ii < d.getGeometry(m, l).innerRings.count(); ii++){
-						str += '<gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>';
-						for(var p = 0; p < d.getGeometry(m, l).innerRings.get(ii).count(); p++){
-							if (p > 0) {
-								str += " ";
-							}	
-							str += d.getPoint(m,l,ii,p).x + "," + d.getPoint(m,l,ii,p).y;
-						}
-						str += '</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs>';
-					}
-				}
-				str += '</gml:Polygon></gml:polygonMember>';
-			}
-		}
-		str += '</gml:MultiPolygon>';
-		str += '</wfs:Value></wfs:Property>';
-		str += '<ogc:Filter><ogc:FeatureId fid="'+fid+'"/></ogc:Filter>';
-		str += '</wfs:Update>';
-	}
-	//
-	// --------------------------------------- DELETE ------------------------------------------------
-	//
-	else if (type == "delete") {
-		str += '<wfs:Delete typeName="'+ myconf['featuretype_name']+'">';
-		for(var j=0; j<myconf['element'].length; j++){
-			if(myconf['element'][j]['f_geom'] == 1){
-				var el_geom = myconf['element'][j]['element_name'];
-			}
-		}
-		str += '<ogc:Filter><ogc:FeatureId fid="'+fid+'"/></ogc:Filter>';
-		str += '</wfs:Delete>';
-	}
-
-	str += '</wfs:Transaction>';
-	return str;
-}
+<?php
+# $Id$
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__) . "/../php/mb_validateSession.php");
+
+?>
+// ---------------------------------------------------------------------------------------------------------------
+// --- usemap (begin) --------------------------------------------------------------------------------------------
+
+function mod_usemap(wfs_name) {
+	if (wfs_name == "") {
+		usemap = "";
+	}
+	var ind = getMapObjIndexByName(mb_wfs_targets[0]);
+	var myImg = window.frames[mb_wfs_targets[0]].document.getElementById("um_img").style; 
+	myImg.width = mb_mapObj[ind].width;
+	myImg.height = mb_mapObj[ind].height;
+
+	for (var i = 0 ; i < mb_wfs_fetch.count() ; i ++) {
+		if (mb_wfs_fetch.get(i).wfs_conf == wfs_name || wfs_name == "") {
+		
+			if (mb_wfs_fetch.get(i).geomType == geomType.polygon) {
+				usemap += mod_usemap_polygon(i);
+			}
+			else if (mb_wfs_fetch.get(i).geomType == geomType.point) {
+				usemap += mod_usemap_circle(i);
+			}
+			else if (mb_wfs_fetch.get(i).geomType == geomType.line) {
+				usemap += mod_usemap_line(i);
+			}
+		}
+	}
+	writeUsemap(usemap);
+}
+
+function mod_usemap_circle(ind){
+	var str = "";
+	var coord = "";
+	
+	var title = "";
+	for (var i = 0 ; i < mb_wfs_fetch.get(ind).e.count(); i++) {
+		if (i>0) title += "&#10;";
+		title += mb_wfs_fetch.get(ind).e.getName(i) + ": " + mb_wfs_fetch.get(ind).e.getValue(i);
+	}
+
+	for (var i = 0 ; i < mb_wfs_fetch.get(ind).count() ; i ++) {
+		var p = mb_wfs_fetch.getPoint(ind, i, 0);
+		var pos = realToMap(mb_wfs_targets[0],p);
+		coord += pos.x + ", " + pos.y;
+		
+		str += "<AREA title='"+title+"' onmouseover='parent.mb_wfs_perform(\"over\",parent.mb_wfs_fetch.get("+ind+"))' ";
+		str += "onmouseout='parent.mb_wfs_perform(\"out\",parent.mb_wfs_fetch.get("+ind+"))' shape='circle'  coords='";
+		str += coord + ", " + mod_usemap_radius + "' href='#'>";
+	}
+	
+	return str;
+}
+
+function mod_usemap_line_calculate (aGeometry, j, orientation, cnt) {
+	var coord = "";
+
+	var p1 = realToMap(mb_wfs_targets[0],aGeometry.get(j));
+	var p2 = realToMap(mb_wfs_targets[0],aGeometry.get(j+orientation));
+
+	var vec = p2.minus(p1);
+	
+	if (vec.x != 0 || vec.y != 0) {
+		var n_vec;
+		if (vec.x != 0) {
+			if (vec.x > 0) n_vec = new Point((-vec.y)/vec.x, -1);
+			else n_vec = new Point(vec.y/vec.x, 1);
+		}
+		else {
+			if (vec.y > 0) n_vec = new Point(1,0);
+			else n_vec = new Point(-1,0);
+		}
+		n_vec = n_vec.times(mod_usemap_line_tolerance).dividedBy(n_vec.dist(new Point(0,0)))
+
+		lp = new Point(p1.x + n_vec.x, p1.y - n_vec.y);
+
+		if (cnt > 0) coord += ", ";
+
+		coord += parseInt(lp.x) + ", " + parseInt(lp.y);
+		coord += ", " + parseInt(lp.x+vec.x) + ", " + parseInt(lp.y+vec.y);
+	}
+	return coord;
+}
+
+function mod_usemap_line(ind){
+	var str = "";
+	var title = "";
+	for (var i = 0 ; i < mb_wfs_fetch.get(ind).e.count(); i++) {
+		if (i>0) title += "&#10;";
+		title += mb_wfs_fetch.get(ind).e.getName(i) + ": " + mb_wfs_fetch.get(ind).e.getValue(i);
+	}
+	for (var i = 0 ; i < mb_wfs_fetch.get(ind).count() ; i ++) {
+		var coord = "";
+		var cnt = 0;
+
+		for (var j = 0 ; j < mb_wfs_fetch.getGeometry(ind,i).count() - 1  ; j ++) {
+			var result = mod_usemap_line_calculate(mb_wfs_fetch.getGeometry(ind,i), j, 1, cnt);
+			if (result != "") {
+				coord += result;
+				cnt++;
+			}
+		}
+		
+		for (var j = (mb_wfs_fetch.getGeometry(ind,i).count() - 1) ; j > 0 ; j--) {
+			var result = mod_usemap_line_calculate(mb_wfs_fetch.getGeometry(ind,i), j, -1, cnt);
+			if (result != "") {
+				coord += result;
+				cnt++;
+			}
+		}
+		
+		if (coord != "") {
+			str += "<AREA title='"+title+"'";
+			str += "onmouseover='parent.mb_wfs_perform(\"over\",parent.mb_wfs_fetch.get("+ind+"))' ";
+			str += "onmouseout='parent.mb_wfs_perform(\"out\",parent.mb_wfs_fetch.get("+ind+"))' ";
+			str += "shape='poly'  coords='";
+			str += coord + "' href='#'>";
+		}
+		else {
+			//display circle
+			var pos = realToMap(mb_wfs_targets[0],mb_wfs_fetch.getPoint(ind,i,0));
+			coord += pos.x + ", " + pos.y;
+			
+			str += "<AREA title='"+title+"' onmouseover='parent.mb_wfs_perform(\"over\",parent.mb_wfs_fetch["+ind+"])' ";
+			str += "onmouseout='parent.mb_wfs_perform(\"out\",parent.mb_wfs_fetch.get("+ind+"))' shape='circle'  coords='";
+			str += coord + ", " + mod_usemap_radius + "' href='#'>";
+		}
+	}
+	
+	return str;
+}
+
+function mod_usemap_polygon(ind){
+	var str = "";
+	var coord = "";
+	var title = "";
+	for (var i = 0 ; i < mb_wfs_fetch.get(ind).e.count(); i++) {
+		if (i>0) title += "&#10;";
+		title += mb_wfs_fetch.get(ind).e.getName(i) + ": " + mb_wfs_fetch.get(ind).e.getValue(i);
+	}
+
+	for (var i = 0 ; i < mb_wfs_fetch.get(ind).count() ; i ++) {
+		var pos = realToMap(mb_wfs_targets[0],mb_wfs_fetch.getPoint(ind, i, 0));
+		coord += pos.x + ", " + pos.y;
+		
+		for (var j = 1 ; j < mb_wfs_fetch.getGeometry(ind,i).count() ; j ++) {
+			pos = realToMap(mb_wfs_targets[0],mb_wfs_fetch.getPoint(ind, i, j));
+			coord += ", " + pos.x + ", " + pos.y;
+		}
+		
+		str += "<AREA title='"+title+"' onmouseover='parent.mb_wfs_perform(\"over\",parent.mb_wfs_fetch.get("+ind+"))' ";
+		str += "onmouseout='parent.mb_wfs_perform(\"out\",parent.mb_wfs_fetch.get("+ind+"))' shape='poly'  coords='";
+		str += coord + "' href='#'>";
+	}
+	
+	return str;
+}
+
+function writeUsemap(str) {
+	writeTag(mb_wfs_targets[0], 'um', str);
+}
+// --- usemap (end) ----------------------------------------------------------------------------------------------
+// ---------------------------------------------------------------------------------------------------------------
+
+
+var highlight_tag_id = "wfs_highlight_tag";
+var mb_wfs_fetched = [];
+
+var mb_wfs_objwin = null;
+var mb_wfs_objwin_left = 800;
+var mb_wfs_objwin_top = 200;
+var mb_wfs_objwin_width = 200;
+var mb_wfs_objwin_height = 200;
+var mb_wfs_targetString = "<?php echo implode(",", $e_target); ?>";
+var mb_wfs_targets = mb_wfs_targetString.split(",");
+var mb_wfs_fillColor = "#ff0000";
+var usemap = "";
+var mod_usemap_radius = 10;
+var mod_usemap_line_tolerance = 5;
+var useCheckboxForHighlighting = false;
+
+var mb_wfs_fetch = new GeometryArray();
+
+var highlight;
+
+try {if(generalHighlightZIndex){}}catch(e) {generalHighlightZIndex = 90;}
+try {if(generalHighlightLineWidth){}}catch(e) {generalHighlightLineWidth = 2;}
+try {if(useUsemap){}}catch(e) {useUsemap = 0;}
+
+mb_registerInitFunctions('initHighlight()');
+
+function initHighlight() {
+	var styleObj = {"position":"absolute", "top":"0px", "left":"0px", "z-index":generalHighlightZIndex};
+	highlight = new Highlight(mb_wfs_targets, highlight_tag_id, styleObj, generalHighlightLineWidth);
+}
+try {if(displayWfsResultList){}}catch(e) {displayWfsResultList = 0;};
+
+if (displayWfsResultList == 1) {
+	//mb_registerWfsReadSubFunctions(function(geom){mb_wfs_listMember(geom)});
+}
+
+
+if (parseInt(useUsemap) == 1) {
+	mb_registerSubFunctions('mod_usemap("")');
+}
+
+if (useCheckboxForHighlighting) {
+	eventInit.register(function() {
+		mb_registerSubFunctions('highlight.paint()');
+	});
+}
+
+/*
+if (useExtentIsSet()) {
+	mb_registerSubFunctions("mb_setwfsrequest_extent()");
+}
+function mb_setwfsrequest_extent() {
+
+	if (useExtentIsSet()) {
+		var ind = getMapObjIndexByName(mb_wfs_targets[0]);
+		var pos_a = makeClickPos2RealWorldPos(mb_wfs_targets[0],0,0);
+		var pos_b = makeClickPos2RealWorldPos(mb_wfs_targets[0],mb_mapObj[ind].width,mb_mapObj[ind].height);
+
+		var x = [];
+		var y = [];
+		x[0] = pos_a[0];
+		x[1] = pos_b[0];
+		y[0] = pos_a[1];
+		y[1] = pos_b[1];
+
+		mb_setwfsrequest(mb_wfs_targets[0],'rectangle',x,y);
+	}
+}
+*/
+
+function mb_wfs_listMember(geomArray){
+	mb_wfs_fetch.union(geomArray);
+	var wfs_conf = get_complete_wfs_conf();
+	var str = "<table>";
+	for(var i=0; i<mb_wfs_fetch.count(); i++){
+		var t = wfs_conf[mb_wfs_fetch.get(i).wfs_conf];
+		for(var j=0; j<t['element'].length; j++){
+			if(t['element'][j]['f_show'] > 0){
+				var k = mb_wfs_fetch.get(i).e.getElementIndexByName(t['element'][j]['element_name']);
+				//alert(k);
+				if(k != -1){
+					str += "<tr><td>";
+					if (useCheckboxForHighlighting) {
+						str += "<input type=checkbox id=highlightCheckbox" + i + " onChange='highlightGeometry(" + i + ")'></td><td>";
+					}
+					str += "<div";
+					if (!useCheckboxForHighlighting) {
+						str += " onmouseover='mb_wfs_perform(\"over\",mb_wfs_fetch.get("+i+"))' ";
+						str += " onmouseout='mb_wfs_perform(\"out\",mb_wfs_fetch.get("+i+"))' ";
+					}
+					str += " onclick='mb_wfs_perform(\"click\",mb_wfs_fetch.get("+i+"))' ";
+					str += ">" + mb_wfs_fetch.get(i).e.getValue(k)+ "</div></td></tr>";
+				}
+			}
+		}
+	}
+	str += "</table>";
+	mb_wfs_objwin.innerHTML = str;
+//	if (parseInt(useUsemap) == 1) mod_usemap(wfs_name);
+}
+
+function mb_wfs_reset(){
+	mb_wfs_fetch = new parent.GeometryArray();
+	usemap = "";
+
+	if(mb_wfs_objwin == null){
+		var iframe=document.createElement('div');
+		iframe.setAttribute("style","position:absolute;left:"+mb_wfs_objwin_left+"px;top:"+mb_wfs_objwin_top+"px;width:"+mb_wfs_objwin_width+"px;height:"+mb_wfs_objwin_height+"px");
+		mb_wfs_objwin = document.body.appendChild(iframe);
+		mb_wfs_objwin.id = "mb_wfs_objwin";
+		mb_wfs_objwin.name = "mb_wfs_objwin";
+		mb_wfs_objwin.style.position = 'absolute';
+		mb_wfs_objwin.style.left = mb_wfs_objwin_left+"px";
+		mb_wfs_objwin.style.top = mb_wfs_objwin_top+"px";
+		mb_wfs_objwin.style.width = mb_wfs_objwin_width+"px";
+		mb_wfs_objwin.style.height = mb_wfs_objwin_height+"px";
+	}
+	for(var i=0; i<mb_wfsreq; i++){
+		if(document.getElementById("mb_wfs_win_"+mb_wfsreq)){
+			document.removeChild("mb_wfs_win_"+mb_wfsreq);
+		}
+	}
+	mb_wfsreq = 0;
+	return true;
+}
+
+function get_complete_wfs_conf() {
+	var wfs_conf = window.frames["wfs_conf"].get_wfs_conf();
+	return wfs_conf;
+}
+
+function highlightGeometry(i) {
+	var id = "highlightCheckbox"+i;
+	if (document.getElementById(id).checked) {
+		highlight.add(mb_wfs_fetch.get(i), '#00ff00');
+		highlight.paint();
+	}
+	else {
+		highlight.del(mb_wfs_fetch.get(i), '#00ff00');
+		highlight.paint();
+	}
+}
+
+function mb_wfs_perform(type,m, colour){
+	if (typeof(colour) == "undefined") {
+		colour = "#ff0000";
+	}
+
+	var wfs_conf = window.frames["wfs_conf"].get_wfs_conf();
+	if(type=='over') {
+		highlight.add(m, colour);
+		highlight.paint();
+	}
+	else if (type == 'out') {
+		highlight.del(m, colour);
+		highlight.paint();
+	}
+	else
+		if (type == 'click') {
+			var tmp = m.getBBox();
+			if (m.geomType == geomType.point) {
+				var b = 1;
+			}
+			else {
+				var b = 0;
+			}
+			if (typeof(m.wfs_conf) != "undefined") {
+				b = parseFloat(wfs_conf[m.wfs_conf]['g_buffer']);
+			}
+			var buffer = new Point(b, b);
+			var bbox_ll = tmp[0].minus(buffer);
+			var bbox_ru = tmp[1].plus(buffer);
+			mb_calcExtent(mb_wfs_targets[0], bbox_ll, bbox_ru);
+			highlight.del(m, colour);
+			zoom(mb_wfs_targets[0], 'true', 1.0);
+			highlight.add(m, colour);
+			highlight.paint();
+		}
+}
+
+function get_wfs_str(myconf, d, m, type, fid) {
+
+	var featureTypeArray = myconf['featuretype_name'].split(':')
+	var featureNS = featureTypeArray[0];
+
+	var str = '<wfs:Transaction version="1.0.0" service="WFS" ';
+
+	var ns_gml = false;	var ns_ogc = false;	var ns_xsi = false;	var ns_wfs = false;	var ns_featureNS = false;
+
+	for (var q = 0 ; q < myconf['namespaces'].length ; q++) {
+
+		if (myconf['namespaces'][q]['name'] == "gml"){
+			 ns_gml = true;
+			 str += 'xmlns:' + myconf['namespaces'][q]['name'] + '="' + myconf['namespaces'][q]['location'] + '" ';
+		} else if (myconf['namespaces'][q]['name'] == "ogc") {
+			ns_ogc = true;
+			str += 'xmlns:' + myconf['namespaces'][q]['name'] + '="' + myconf['namespaces'][q]['location'] + '" ';
+		} else if (myconf['namespaces'][q]['name'] == "xsi") {
+			ns_xsi = true;
+			str += 'xmlns:' + myconf['namespaces'][q]['name'] + '="' + myconf['namespaces'][q]['location'] + '" ';
+		} else if (myconf['namespaces'][q]['name'] == "wfs") {
+			ns_wfs = true;
+			str += 'xmlns:' + myconf['namespaces'][q]['name'] + '="' + myconf['namespaces'][q]['location'] + '" ';
+		} else if (myconf['namespaces'][q]['name'] == featureNS) {
+			ns_featureNS = true;
+			str += 'xmlns:' + myconf['namespaces'][q]['name'] + '="' + myconf['namespaces'][q]['location'] + '" '
+			strForSchemaLocation = myconf['namespaces'][q]['location'];
+		}
+	}
+
+	if (ns_gml == false) str += 'xmlns:gml="http://www.opengis.net/gml" ';
+	if (ns_ogc == false) str += 'xmlns:ogc="http://www.opengis.net/ogc" ';
+	if (ns_xsi == false) str += 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ';
+	if (ns_featureNS == false) str += 'xmlns:"+featureNS+"="http://www.someserver.com/"+featureNS+"" ';
+	if (ns_wfs == false) str += 'xmlns:wfs="http://www.opengis.net/wfs" ';
+
+	str += 'xsi:schemaLocation="http://www.opengis.net/wfs';
+	str += ' http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd';
+	str += ' ' + strForSchemaLocation;
+	str += ' '+ myconf['wfs_describefeaturetype'];
+	//str += mb_getConjunctionCharacter(myconf['wfs_describefeaturetype']);
+	//str += 'typename=' + myconf['featuretype_name'];
+	str += '">';
+
+	//
+	// ---------------------------------------- SAVE -------------------------------------------------
+	//
+	if (type == "save") {
+		str += '<wfs:Insert><'+ myconf['featuretype_name']+'>';
+		for(var i=0; i<d.get(m).e.count(); i++){
+			if(d.get(m).e.getValue(i) != "" && d.get(m).e.getName(i) != "fid"){
+				var tmp = d.get(m).e.getName(i);
+				str += '<' + tmp  + '><![CDATA[' + d.get(m).e.getValue(i) + ']]></' + tmp  + '>';
+			}
+		}
+		for(var j=0; j<myconf['element'].length; j++){
+			if(myconf['element'][j]['f_geom'] == 1){
+				var el_geom = myconf['element'][j]['element_name'];
+			}
+		}
+		str += '<' + el_geom + '>';
+		if(d.get(m).geomType == geomType.point){
+			str += '<gml:Point srsName="' + myconf['featuretype_srs'] + '">';
+			str += '<gml:coordinates>';
+			str += d.getPoint(m,0,0).x + "," + d.getPoint(m,0,0).y;
+			str += '</gml:coordinates>';
+			str += '</gml:Point>';
+		}
+		if(d.get(m).geomType == geomType.line){
+			str += '<gml:MultiLineString srsName="' + myconf['featuretype_srs'] + '">';
+			str += '<gml:lineStringMember><gml:LineString><gml:coordinates>';
+			for(var k=0; k<d.getGeometry(m,0).count(); k++){
+				if(k>0)	str += " ";
+				str += d.getPoint(m,0,k).x + "," + d.getPoint(m,0,k).y;
+			}
+			str += '</gml:coordinates></gml:LineString></gml:lineStringMember>';
+			str += '</gml:MultiLineString>';
+		}
+		if(d.get(m).geomType == geomType.polygon){
+			str += '<gml:MultiPolygon srsName="' + myconf['featuretype_srs'] + '">';
+			for (var k = 0; k < d.get(m).count(); k++) {
+				str += '<gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>';
+	
+				for(var l = 0; l < d.getGeometry(m, k).count(); l++){
+					if (l > 0) {
+						str += " ";
+					}	
+					str += d.getPoint(m,k,l).x + "," + d.getPoint(m,k,l).y;
+				}
+
+				str += '</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>';
+				
+				if (d.getGeometry(m, k).innerRings) {
+					for(var ii = 0; ii < d.getGeometry(m, k).innerRings.count(); ii++){
+						str += '<gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>';
+						for(var l = 0; l < d.getGeometry(m, k).innerRings.get(ii).count(); l++){
+							if (l > 0) {
+								str += " ";
+							}	
+							str += d.getPoint(m,k,ii,l).x + "," + d.getPoint(m,k,ii,l).y;
+						}
+						str += '</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs>';
+					}
+				}
+
+				str += '</gml:Polygon></gml:polygonMember>';
+			}
+			str += '</gml:MultiPolygon>';
+		}
+		str += '</' + el_geom + '></'+ myconf['featuretype_name']+'></wfs:Insert>';
+	}
+	//
+	// --------------------------------------- UPDATE ------------------------------------------------
+	//
+	else if (type == "update") {
+		str += '<wfs:Update typeName="'+ myconf['featuretype_name']+'">';
+		for(var i=0; i<d.get(m).e.count(); i++){
+			if(d.get(m).e.getValue(i) != "" && d.get(m).e.getName(i) != "fid"){
+				str += '<wfs:Property>';
+				str += '<wfs:Name>'+d.get(m).e.getName(i)+'</wfs:Name>';
+				str += '<wfs:Value><![CDATA['+d.get(m).e.getValue(i)+']]></wfs:Value>';
+				str += '</wfs:Property>';
+			}
+		}
+		for(var j=0; j<myconf['element'].length; j++){
+			if(myconf['element'][j]['f_geom'] == 1){
+				var el_geom = myconf['element'][j]['element_name'];
+			}
+		}
+		str += '<wfs:Property><wfs:Name>' + el_geom + '</wfs:Name><wfs:Value>';
+		if(d.get(m).geomType == geomType.point){
+			str += '<gml:Point srsName="' + myconf['featuretype_srs'] + '"><gml:coordinates>';
+			str += d.getPoint(m,0,0).x + "," + d.getPoint(m,0,0).y;
+			str += '</gml:coordinates></gml:Point>';
+		}
+		if(d.get(m).geomType == geomType.line){
+			str += '<gml:MultiLineString srsName="' + myconf['featuretype_srs'] + '">';
+			str += '<gml:lineStringMember><gml:LineString><gml:coordinates>';
+			for(var k=0; k<d.getGeometry(m,0).count(); k++){
+				if(k>0)	str += " ";
+				str += d.getPoint(m,0,k).x + "," + d.getPoint(m,0,k).y;
+			}
+			str += '</gml:coordinates></gml:LineString></gml:lineStringMember>';
+			str += '</gml:MultiLineString>';
+		}
+		if(d.get(m).geomType == geomType.polygon){
+			str += '<gml:MultiPolygon srsName="' + myconf['featuretype_srs'] + '">';
+			for (var l = 0; l < d.get(m).count(); l++) {
+				str += '<gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>';
+				for(var k=0; k<d.getGeometry(m,l).count(); k++){
+					if(k>0)	str += " ";
+					str += d.getPoint(m,l,k).x + "," + d.getPoint(m,l,k).y;
+				}
+				str += '</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>';
+				if (d.getGeometry(m, l).innerRings) {
+					for(var ii = 0; ii < d.getGeometry(m, l).innerRings.count(); ii++){
+						str += '<gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>';
+						for(var p = 0; p < d.getGeometry(m, l).innerRings.get(ii).count(); p++){
+							if (p > 0) {
+								str += " ";
+							}	
+							str += d.getPoint(m,l,ii,p).x + "," + d.getPoint(m,l,ii,p).y;
+						}
+						str += '</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs>';
+					}
+				}
+				str += '</gml:Polygon></gml:polygonMember>';
+			}
+		}
+		str += '</gml:MultiPolygon>';
+		str += '</wfs:Value></wfs:Property>';
+		str += '<ogc:Filter><ogc:FeatureId fid="'+fid+'"/></ogc:Filter>';
+		str += '</wfs:Update>';
+	}
+	//
+	// --------------------------------------- DELETE ------------------------------------------------
+	//
+	else if (type == "delete") {
+		str += '<wfs:Delete typeName="'+ myconf['featuretype_name']+'">';
+		for(var j=0; j<myconf['element'].length; j++){
+			if(myconf['element'][j]['f_geom'] == 1){
+				var el_geom = myconf['element'][j]['element_name'];
+			}
+		}
+		str += '<ogc:Filter><ogc:FeatureId fid="'+fid+'"/></ogc:Filter>';
+		str += '</wfs:Delete>';
+	}
+
+	str += '</wfs:Transaction>';
+	return str;
+}

Modified: branches/print_dev/http/javascripts/wms.js
===================================================================
--- branches/print_dev/http/javascripts/wms.js	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/javascripts/wms.js	2009-05-22 11:46:01 UTC (rev 3956)
@@ -173,7 +173,6 @@
 	rq += "&EXCEPTIONS=" + this.gui_wms_exceptionformat;
 	//Todo: error occurs:
 	//var throwNotice = new Mb_notice("getMapRequest: " + rq);
-	//window.console.log("getMapRequest: " + rq);
 	return rq;
 };
 
@@ -217,7 +216,6 @@
 	rq += "&EXCEPTIONS=application/vnd.ogc.se_xml";
 	rq += "&X=" + clickPoint.x;
 	rq += "&Y=" + clickPoint.y;
-	//console.log(rq);
 	return rq;
 };
 
@@ -280,7 +278,6 @@
 			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);
 				}
 			}
@@ -482,11 +479,17 @@
  */
 wms_const.prototype.handleLayer = function(layer_name, type, value){
 	var i;
+	var found = false;
 	for(i = 0; i < this.objLayer.length; i++){
 		if(this.objLayer[i].layer_name==layer_name) {
+			found = true;
 			break;
 		}
 	}
+	// layer not found
+	if (!found) {
+		return;
+	}
 	
 	//Set visibility/queryability of Layer and Sublayers
 	for(var j = i; j < this.objLayer.length; j++){
@@ -765,7 +768,6 @@
  */
 wms_layer.prototype.setVisible = function(visible){
 	this.gui_layer_visible = parseInt(visible, 10);
-	//console.log("setVisible(%i) for Layer %s",visible, this.layer_name);
 };
 
 /**
@@ -775,5 +777,4 @@
 
 wms_layer.prototype.setQueryable = function(queryable){
 	this.gui_layer_querylayer = parseInt(queryable, 10);
-	//console.log("setQueryable(%i) for Layer %s",queryable, this.layer_name);
 };

Modified: branches/print_dev/http/php/mod_digitize_messages.php
===================================================================
--- branches/print_dev/http/php/mod_digitize_messages.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/php/mod_digitize_messages.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,84 +1,85 @@
-<?php
-#$Id: mod_insertWmcIntoDb.php 507 2006-11-20 10:55:57Z christoph $
-#$Header: /cvsroot/mapbender/mapbender/http/javascripts/mod_insertWmcIntoDb.php,v 1.19 2006/03/09 14:02:42 uli_rothstein Exp $
-# Copyright (C) 2002 CCGIS 
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-require_once(dirname(__FILE__)."/../classes/class_json.php");
-
-$e = new mb_notice("locale: " . $_SESSION["mb_locale"] . "; lang: " . $_SESSION["mb_lang"]);
-$e = new mb_notice(setlocale(LC_ALL, $_SESSION["mb_locale"]));
-
-//
-// Messages
-//
-$msg_obj = array();
-$msg_obj["messageDescriptionPolygon"] = _mb("polygon");
-$msg_obj["messageDescriptionLine"] = _mb("line");
-$msg_obj["messageDescriptionPoint"] = _mb("point");
-$msg_obj["messageErrorNotAnInteger"] = _mb("Not an integer value.");
-$msg_obj["messageErrorNotAFloat"] = _mb("Not a double value.");
-$msg_obj["messageErrorFieldIsEmpty"] = _mb("This field may not be empty.");
-$msg_obj["messageErrorFormEvaluation"] = _mb("Failure during form evaluation.");
-$msg_obj["messageErrorWfsWrite"] = _mb("An error occured.");
-$msg_obj["messageErrorMergeNotApplicable"] = _mb("At least two geometries must be available. Only polygons are allowed in the geometry list.");
-$msg_obj["messageErrorSplitNotApplicable"] = _mb("Exactly two geometries must be available. The first geometry shall be a polygon, the second geometry shall be a line.");
-$msg_obj["messageErrorDifferenceNotApplicable"] = _mb("Exactly two polygons must be available.");
-$msg_obj["messageSuccessWfsWrite"] = _mb("Success.");
-$msg_obj["messageConfirmDeleteGeomFromDb"] = _mb("Delete geometry from database?");
-$msg_obj["messageConfirmDeleteAllGeomFromList"] = _mb("Clear list of geometries?");
-$msg_obj["messageSelectAnOption"] = _mb("Please select an entry.");
-$msg_obj["buttonLabelSaveGeometry"] = _mb("Save");
-$msg_obj["buttonLabelUpdateGeometry"] = _mb("Update");
-$msg_obj["buttonLabelDeleteGeometry"] = _mb("Delete");
-$msg_obj["buttonLabelAbort"] = _mb("Abort");
-$msg_obj["errorMessageEpsgMismatch"] = _mb("Fatal error: EPSG mismatch. ");
-$msg_obj["errorMessageNoGeometrySelected"] = _mb("No geometry selected!");
-$msg_obj["buttonLabelPointOff"] = _mb("add point");
-$msg_obj["buttonLabelPointOn"] = _mb("cancel editing");
-$msg_obj["buttonLabelLineOff"] = _mb("add line");
-$msg_obj["buttonLabelLineOn"] = _mb("finish line");
-$msg_obj["buttonLabelPolygonOff"] = _mb("add polygon");
-$msg_obj["buttonLabelPolygonOn"] = _mb("close polygon");
-$msg_obj["buttonLabelMoveBasepointOff"] = _mb("move basepoint");
-$msg_obj["buttonLabelMoveBasepointOn"] = _mb("move basepoint");
-$msg_obj["buttonLabelInsertBasepointOff"] = _mb("Insert basepoint");
-$msg_obj["buttonLabelInsertBasepointOn"] = _mb("Insert basepoint");
-$msg_obj["buttonLabelDeleteBasepointOff"] = _mb("Delete basepoint");
-$msg_obj["buttonLabelDeleteBasepointOn"] = _mb("Delete basepoint");
-$msg_obj["buttonLabelClearListOff"] = _mb("clear list of geometries");
-$msg_obj["buttonLabelClearListOn"] = _mb("clear list of geometries");
-$msg_obj["buttonLabelMergeOff"] = _mb("Merge two polygons into a single polygon (will be added to the geometry list)");
-$msg_obj["buttonLabelMergeOn"] = _mb("Merge two polygons into a single polygon (will be added to the geometry list)");
-$msg_obj["buttonLabelSplitOff"] = _mb("Split a polygon by a line (the new polygons will be added to the geometry list)");
-$msg_obj["buttonLabelSplitOn"] = _mb("Split a polygon by a line (the new polygons will be added to the geometry list)");
-$msg_obj["buttonLabelDifferenceOff"] = _mb("Combine two polygons (to create en- and exclave or to compute the difference)");
-$msg_obj["buttonLabelDifferenceOn"] = _mb("Split geometries");
-$msg_obj["buttonDig_wfs_title"] = _mb("save / update / delete");
-$msg_obj["buttonDig_remove_title"] = _mb("remove from workspace");
-$msg_obj["buttonDig_removeDb_title"] = _mb("remove from database");
-$msg_obj["closePolygon_title"] = _mb("click the first basepoint to close the polygon");
-$msg_obj["measureTagLabelCurrent"] = _mb("Current: ");
-$msg_obj["measureTagLabelTotal"] = _mb("Total: ");
-$msg_obj["digitizeDefaultGeometryName"] = _mb("new");
-
-$json = new Mapbender_JSON();
-$output = $json->encode($msg_obj);
-
-header("Content-type:application/x-json; charset=utf-8");
-echo $output;
+<?php
+#$Id: mod_insertWmcIntoDb.php 507 2006-11-20 10:55:57Z christoph $
+#$Header: /cvsroot/mapbender/mapbender/http/javascripts/mod_insertWmcIntoDb.php,v 1.19 2006/03/09 14:02:42 uli_rothstein Exp $
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
+
+$e = new mb_notice("locale: " . $_SESSION["mb_locale"] . "; lang: " . $_SESSION["mb_lang"]);
+$e = new mb_notice(setlocale(LC_ALL, $_SESSION["mb_locale"]));
+
+//
+// Messages
+//
+$msg_obj = array();
+$msg_obj["messageDescriptionPolygon"] = _mb("polygon");
+$msg_obj["messageDescriptionLine"] = _mb("line");
+$msg_obj["messageDescriptionPoint"] = _mb("point");
+$msg_obj["messageErrorNotAnInteger"] = _mb("Not an integer value.");
+$msg_obj["messageErrorNotAFloat"] = _mb("Not a double value.");
+$msg_obj["messageErrorFieldIsEmpty"] = _mb("This field may not be empty.");
+$msg_obj["messageErrorFormEvaluation"] = _mb("Failure during form evaluation.");
+$msg_obj["messageErrorWfsWrite"] = _mb("An error occured.");
+$msg_obj["messageErrorMergeNotApplicable"] = _mb("At least two geometries must be available. Only polygons are allowed in the geometry list.");
+$msg_obj["messageErrorSplitNotApplicable"] = _mb("Exactly two geometries must be available. The first geometry shall be a polygon, the second geometry shall be a line.");
+$msg_obj["messageErrorDifferenceNotApplicable"] = _mb("Exactly two polygons must be available.");
+$msg_obj["messageSuccessWfsWrite"] = _mb("Success.");
+$msg_obj["messageConfirmDeleteGeomFromDb"] = _mb("Delete geometry from database?");
+$msg_obj["messageConfirmDeleteAllGeomFromList"] = _mb("Clear list of geometries?");
+$msg_obj["messageSelectAnOption"] = _mb("Please select an entry.");
+$msg_obj["buttonLabelSaveGeometry"] = _mb("Save");
+$msg_obj["buttonLabelUpdateGeometry"] = _mb("Update");
+$msg_obj["buttonLabelDeleteGeometry"] = _mb("Delete");
+$msg_obj["buttonLabelAbort"] = _mb("Abort");
+$msg_obj["errorMessageEpsgMismatch"] = _mb("Fatal error: EPSG mismatch. ");
+$msg_obj["errorMessageNoGeometrySelected"] = _mb("No geometry selected!");
+$msg_obj["buttonLabelPointOff"] = _mb("add point");
+$msg_obj["buttonLabelPointOn"] = _mb("cancel editing");
+$msg_obj["buttonLabelLineOff"] = _mb("add line");
+$msg_obj["buttonLabelLineOn"] = _mb("finish line");
+$msg_obj["buttonLabelPolygonOff"] = _mb("add polygon");
+$msg_obj["buttonLabelPolygonOn"] = _mb("close polygon");
+$msg_obj["buttonLabelMoveBasepointOff"] = _mb("move basepoint");
+$msg_obj["buttonLabelMoveBasepointOn"] = _mb("move basepoint");
+$msg_obj["buttonLabelInsertBasepointOff"] = _mb("Insert basepoint");
+$msg_obj["buttonLabelInsertBasepointOn"] = _mb("Insert basepoint");
+$msg_obj["buttonLabelDeleteBasepointOff"] = _mb("Delete basepoint");
+$msg_obj["buttonLabelDeleteBasepointOn"] = _mb("Delete basepoint");
+$msg_obj["buttonLabelClearListOff"] = _mb("clear list of geometries");
+$msg_obj["buttonLabelClearListOn"] = _mb("clear list of geometries");
+$msg_obj["buttonLabelMergeOff"] = _mb("Merge two polygons into a single polygon (will be added to the geometry list)");
+$msg_obj["buttonLabelMergeOn"] = _mb("Merge two polygons into a single polygon (will be added to the geometry list)");
+$msg_obj["buttonLabelSplitOff"] = _mb("Split a polygon by a line (the new polygons will be added to the geometry list)");
+$msg_obj["buttonLabelSplitOn"] = _mb("Split a polygon by a line (the new polygons will be added to the geometry list)");
+$msg_obj["buttonLabelDifferenceOff"] = _mb("Combine two polygons (to create en- and exclave or to compute the difference)");
+$msg_obj["buttonLabelDifferenceOn"] = _mb("Split geometries");
+$msg_obj["buttonDig_wfs_title"] = _mb("save / update / delete");
+$msg_obj["buttonDig_remove_title"] = _mb("remove from workspace");
+$msg_obj["buttonDig_removeDb_title"] = _mb("remove from database");
+$msg_obj["buttonDig_clone_title"] = _mb("clone this geometry");
+$msg_obj["closePolygon_title"] = _mb("click the first basepoint to close the polygon");
+$msg_obj["measureTagLabelCurrent"] = _mb("Current: ");
+$msg_obj["measureTagLabelTotal"] = _mb("Total: ");
+$msg_obj["digitizeDefaultGeometryName"] = _mb("new");
+
+$json = new Mapbender_JSON();
+$output = $json->encode($msg_obj);
+
+header("Content-type:application/x-json; charset=utf-8");
+echo $output;
 ?>
\ No newline at end of file

Modified: branches/print_dev/http/php/mod_editApplication.php
===================================================================
--- branches/print_dev/http/php/mod_editApplication.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/php/mod_editApplication.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -193,13 +193,18 @@
 			echo " style = '";
 			if(db_result($res,$i,"e_left") != "" && db_result($res,$i,"e_top") != ""){
 				echo "position:absolute;";
-				echo "left:".db_result($res,$i,"e_left").";";
-				echo "top:".db_result($res,$i,"e_top").";";
+				echo "left:".db_result($res,$i,"e_left")."px;";
+				echo "top:".db_result($res,$i,"e_top")."px;";
 			}
 			if(db_result($res,$i,"e_width") != "" && db_result($res,$i,"e_height") != ""){
-				echo "width:".db_result($res,$i,"e_width").";";
-				echo "height:".db_result($res,$i,"e_height").";";
+				echo "width:".db_result($res,$i,"e_width")."px;";
+				echo "height:".db_result($res,$i,"e_height")."px;";
 			}
+			else {
+				echo "width:15px;";
+				echo "height:15px;";
+			}
+			
 			echo "' ";
 
 			//

Modified: branches/print_dev/http/php/mod_editElements.php
===================================================================
--- branches/print_dev/http/php/mod_editElements.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/php/mod_editElements.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -467,7 +467,9 @@
 	   echo "<input type='button' class='' name='' value='show' onclick='thisShow()'> \n";
 	   echo "<input type='button' class='' name='' value='sql' onclick='thisExport()'> \n";
 	   echo	"<input type='button' class='' name='' value='arrange' " .
-	   		"onclick='window.open(\"mod_editApplication.php?" . SID . "&" .
+	   		"onclick='if (confirm(\"" . 
+			_mb("Please make sure you have made a backup of your application before using this feature! Continue?") . 
+			"\")) window.open(\"mod_editApplication.php?" . SID . "&" .
 	   		"guiID=" . $_SESSION["mb_user_gui"] . "&" .
 	   		"editApplicationId=" . $guiList1 . "\", " .
 	   		"\"edit application\", " .

Modified: branches/print_dev/http/php/mod_editGuiWms.php
===================================================================
--- branches/print_dev/http/php/mod_editGuiWms.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/php/mod_editGuiWms.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,743 +1,743 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/mod_editGuiWms.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.
-
-import_request_variables("PG");
-require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
-require_once(dirname(__FILE__)."/../classes/class_wms.php");
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-
-<html>
-<head>
-<?php
-echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';
-?>
-<title>Edit GUI WMS</title>
-<?php
-include_once '../include/dyn_css.php';
-
-
-function toImage($text) {
-	$angle = 90;
-	if (extension_loaded("gd2")) {
-		return "<img src='../php/createImageFromText.php?text=" . urlencode($text) . "&angle=" . $angle . "'>";
-	}
-	return $text;
-}
-?>
-
-<script language="JavaScript">
-
-
-function edit_gaz(gui,wms,layer){
-	window.open("../php/mod_wfsLayerObj_conf.php?gui="+gui+"&wms="+wms+"&layer="+layer);
-}
-function validate(wert){
-	if(wert == 'delete_wms'){
-		if(document.form1.wmsList.selectedIndex == -1){
-			document.form1.wmsList.style.background = '#ff0000';
-		}else{
-
-			var secure = confirm("Remove WMS in this GUI ?");
-			if(secure == true){
-				document.form1.del.value='true';
-				document.form1.submit();
-			}
-		}
-	}
-
-	if(wert == 'up_wms'){
-		if(document.form1.wmsList.selectedIndex == -1){
-			document.form1.wmsList.style.background = '#ff0000';
-		}else{
-			if (document.form1.wmsList.selectedIndex>0){
-				document.form1.up.value='true';
-				document.form1.submit();
-			}
-		}
-	}
-
-	if(wert == 'down_wms'){
-		if(document.form1.wmsList.selectedIndex == -1){
-			document.form1.wmsList.style.background = '#ff0000';
-		}else{
-			if (document.form1.wmsList.selectedIndex<document.form1.wmsList.length-1){
-				document.form1.down.value='true';
-				document.form1.submit();
-			}
-		}
-	}
-}
-function checkBoxValue(){
-   for(var i=0; i<document.forms[0].elements.length; i++){
-      if(document.forms[0].elements[i].type == 'checkbox'){
-         if(document.forms[0].elements[i].checked == true){
-            document.forms[0].elements[i].value = '1';
-         }
-         else{
-            document.forms[0].elements[i].value = '0';
-            document.forms[0].elements[i].checked = true;
-         }
-      }
-      if(document.forms[0].elements[i].type == 'text' && ( document.forms[0].elements[i].name.indexOf("minscale") > -1 || document.forms[0].elements[i].name.indexOf("maxscale") > -1 )){
-         var nr = parseInt(document.forms[0].elements[i].value);
-         if(isNaN(nr) == true){document.forms[0].elements[i].value = 0;}
-         else{document.forms[0].elements[i].value = nr;}
-      }
-   }
-   document.forms[0].update_content.value=1;
-   document.forms[0].submit();
-}
-function getAllLayer(){
-   var arrayLayer = new Array();
-   var cntLayer = 0;
-   for(var i=0; i<document.forms[0].elements.length; i++){
-      if(document.forms[0].elements[i].name.indexOf("layer_id") > -1){
-         arrayLayer[cntLayer] = document.forms[0].elements[i].value;
-         cntLayer++;
-      }
-   }
-   return arrayLayer;
-}
-function setSubs(){
-   var arrayLayer = getAllLayer();
-   for(var i=0; i<arrayLayer.length; i++){
-      if(parseInt(eval("document.forms[0].L_" + arrayLayer[i] + "___layer_parent.value")) > 0){
-         eval("document.forms[0].L_" + arrayLayer[i] + "___gui_layer_status.checked = false");
-      }
-   }
-}
-function setLayer(def,status){
-   var arrayLayer = getAllLayer();
-   if(def == 'querylayer'){
-      for(var i=1; i<arrayLayer.length; i++){
-         if(eval("document.forms[0].L_" + arrayLayer[i] + "___gui_layer_querylayer.disabled == false")){
-            eval("document.forms[0].L_" + arrayLayer[i] + "___gui_layer_querylayer.checked = " + status);
-         }
-      }
-   }
-   if(def == 'visible'){
-      for(var i=1; i<arrayLayer.length; i++){
-         eval("document.forms[0].L_" + arrayLayer[i] + "___gui_layer_visible.checked = " + status);
-      }
-   }
-}
-function showSld(origUrl){
-	var url = document.getElementById("this_gui_wms_sldurl").value;
-	if(url==""){
-		if(origUrl=="")
-			return;
-		url=origUrl;
-	}
-	window.open(url);
-}
-</script>
-
-</head>
-<body>
-<?php
-
-require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
-$con = db_connect($DBSERVER,$OWNER,$PW);
-db_select_db(DB,$con);
-
-$mb_user_id=$_SESSION["mb_user_id"];
-
-#delete gui_wms from gui
-if($del && $del == 'true'){
-	$sql="SELECT DISTINCT gui_wms_position from gui_wms WHERE fkey_gui_id = $1 and fkey_wms_id = $2";
-	$v = array($guiList,$wmsList);
-	$t = array('s','i');
-	$res = db_prep_query($sql,$v,$t);
-	$cnt = 0;
-	while($row = db_fetch_array($res)){
-		$wms_position = $row["gui_wms_position"];
-		$cnt++;
-	}
-	#if($cnt > 1){die("Error: WMS (ID) not unique!");}
-		$sql = "Delete from gui_wms where fkey_gui_id = $1 and fkey_wms_id = $2 ";
-		$v = array($guiList,$wmsList);
-		$t = array('s','i');
-		$res = db_prep_query($sql,$v,$t);
-		$sql = "Delete from gui_layer where fkey_gui_id = $1 and gui_layer_wms_id = $2";
-		$v = array($guiList,$wmsList);
-		$t = array('s','i');
-		$res = db_prep_query($sql,$v,$t);
-		$del='false';
-		$sql = "UPDATE gui_wms SET gui_wms_position = (gui_wms_position - 1) WHERE gui_wms_position > $1";
-		$sql .= " AND fkey_gui_id = $2 ";
-		$v = array($wms_position,$guiList);
-		$t = array('i','s');
-		$res = db_prep_query($sql,$v,$t);
-
-	unset($wmsList);
-}
-
-#update gui_wms_position
-if($up && $up == 'true'){
-	if ($wmsList!=""){
-		$sql = "SELECT gui_wms_position ";
-		$sql .= "FROM gui_wms WHERE fkey_gui_id = $1 AND fkey_wms_id = $2";
-		$v = array($guiList,$wmsList);
-		$t = array('s','i');
-		$res = db_prep_query($sql,$v,$t);
-		if($row = db_fetch_array($res)){
-			$wms_position = $row["gui_wms_position"];
-		}
-	}
-	if($wms_position > 0){
-		$sql = "UPDATE gui_wms SET ";
-		$sql .= "gui_wms_position = $1";
-		$sql .= " WHERE fkey_gui_id = $2 AND fkey_wms_id = $3";
-		$v = array(($wms_position - 1),$guiList,$wmsList);
-		$t = array('i','s','i');
-		$res = db_prep_query($sql,$v,$t);
-		$sql = "UPDATE gui_wms SET ";
-		$sql .= "gui_wms_position = $1";
-		$sql .= " WHERE gui_wms_position = $2 AND fkey_gui_id = $3 AND fkey_wms_id <> $4 ";
-		$v = array($wms_position,($wms_position - 1),$guiList,$wmsList);
-		$t = array('i','i','s','i');
-		$res = db_prep_query($sql,$v,$t);
-	}
-}
-
-if($down && $down == 'true'){
-	$max = 0;
-	if ($wmsList!=""){
-		$sql = "SELECT gui_wms_position ";
-		$sql .= "FROM gui_wms WHERE fkey_gui_id = $1 AND fkey_wms_id = $2";
-		$v = array($guiList,$wmsList);
-		$t = array('s','i');
-		$res = db_prep_query($sql,$v,$t);
-		if($row = db_fetch_array($res)){
-			$wms_position = $row["gui_wms_position"];
-		}
-		$sql = "SELECT MAX(gui_wms_position) as max FROM gui_wms WHERE fkey_gui_id = $1 ";
-		$v = array($guiList);
-		$t = array('s');
-		$res = db_prep_query($sql,$v,$t);
-		if($row = db_fetch_array($res)){
-			$max = $row["max"];
-		}
-	}
-	if($wms_position < $max){
-		$sql = "UPDATE gui_wms SET ";
-		$sql .= "gui_wms_position = $1";
-		$sql .= " WHERE fkey_gui_id = $2 AND fkey_wms_id = $3";
-		$v = array(($wms_position + 1),$guiList,$wmsList);
-		$t = array('i','s','i');
-		$res = db_prep_query($sql,$v,$t);
-		$sql = "UPDATE gui_wms SET ";
-		$sql .= "gui_wms_position = $1";
-		$sql .= " WHERE gui_wms_position = $2 AND fkey_gui_id = $3 AND fkey_wms_id <> $4";
-		$v = array($wms_position,($wms_position + 1),$guiList,$wmsList);
-		$t = array('i','i','s','i');
-		$res = db_prep_query($sql,$v,$t);
-	}
-}
-
-/*handle Updates*/
-if(isset($update_content) && $update_content == "1"){
-   if(isset($this_gui_wms_epsg)){
-      $sql = "UPDATE gui_wms set gui_wms_epsg = $1, gui_wms_mapformat = $2, ";
-      $sql .= "gui_wms_featureinfoformat = $3, gui_wms_exceptionformat = $4, ";
-      $sql .= "gui_wms_visible = $5, gui_wms_opacity = $6, gui_wms_sldurl = $7 ";
-      $sql .= "WHERE fkey_gui_id = $8 AND fkey_wms_id = $9";
-		$v = array($this_gui_wms_epsg,$this_gui_wms_mapformat,$this_gui_wms_featureinfoformat,$this_gui_wms_exceptionformat,$this_gui_wms_visible,$this_gui_wms_opacity,$this_gui_wms_sldurl,$this_gui,$this_wms);
-		$t = array('s','s','s','s','i','i','s','s','i');
-		$res = db_prep_query($sql,$v,$t);
-   }
-   else{
-		$sql = "UPDATE gui_wms set gui_wms_mapformat = $1, ";
-		$sql .= "gui_wms_featureinfoformat = $2, gui_wms_exceptionformat = $3, ";
-		$sql .= "gui_wms_visible = $4, gui_wms_opacity = $5, gui_wms_sldurl = $6 ";
-		$sql .= "WHERE fkey_gui_id = $7 AND fkey_wms_id = $8";
-		$v = array($this_gui_wms_mapformat,$this_gui_wms_featureinfoformat,$this_gui_wms_exceptionformat,$this_gui_wms_visible,$this_gui_wms_opacity,$this_gui_wms_sldurl,$this_gui,$this_wms);
-		$t = array('s','s','s','i','i','s','s','i');
-		$res = db_prep_query($sql,$v,$t);
-   }
-
-   /**/
-
-   $cnt = 0;
-   while(list($key,$val) = each($_REQUEST)){
-		if(preg_match("/___/", $key)){
-			$myKey = explode("___", $key);
-			if($myKey[1]!="layer_parent" && $myKey[1]!='layer_id' ){
-				$sql = "UPDATE gui_layer SET ".$myKey[1]." = $1 WHERE fkey_gui_id = $2 AND fkey_layer_id = $3";
-				$v = array($val,$this_gui,preg_replace("/L_/","",$myKey[0]));
-				if($myKey[1]=='gui_layer_style'){
-					$t = array('s','s','i');
-				}
-				else{
-					$t = array('i','s','i');
-				}
-				if(!$res = db_prep_query($sql,$v,$t)){
-					echo "FEHLER in ZEILE 288";
-				}
-			}
-		}
-	}
-}
-
-echo "<form name='form1' action='" . $self ."' method='post'>";
-echo "<table cellpadding='3' cellspacing='3' border='0' class='table_top'>";
-
-echo "<tr>";
-echo "<td>";
-echo "GUI";
-echo "</td>";
-echo "<td>";
-echo "WMS-TITLE";
-echo "</td>";
-echo "<td>";
-echo "</td>";
-echo "<tr>";
-
-echo "<td>";
-
-require_once(dirname(__FILE__)."/../classes/class_administration.php");
-$admin = new administration();
-$ownguis = $admin->getGuisByOwner($_SESSION["mb_user_id"],true);
-
-$gui_id =array();
-if (count($ownguis)>0){
-	for($i=0; $i<count($ownguis); $i++){
-		$gui_id[$i]=$ownguis[$i];
-	}
-}
-
-echo"<select size='8' name='guiList' onchange='document.form1.wmsList.selectedIndex = -1;submit()'>";
-$selected_gui_id="";
-
-for ($i=0; $i<count($ownguis);$i++){
-   echo "<option value='".$gui_id[$i]."' ";
-   if($guiList && $guiList == $gui_id[$i]){
-      echo "selected";
-      $selected_gui_id=$gui_id[$i];
-   }
-   else{
-      if ($i==0){
-         echo "selected";
-         $selected_gui_id=$gui_id[$i];
-		}
-   }
-   echo ">".$gui_id[$i]."</option>";
-}
-
-echo "</select>";
-echo "</td>";
-echo "<td>";
-
-$sql = "SELECT * from gui_wms JOIN gui ON gui_wms.fkey_gui_id = gui.gui_id JOIN wms ON ";
-$sql .= "gui_wms.fkey_wms_id = wms.wms_id AND gui_wms.fkey_gui_id=gui.gui_id WHERE gui.gui_id = $1 ORDER BY gui_wms_position";
-$v = array($selected_gui_id);
-$t = array('s');
-$res = db_prep_query($sql,$v,$t);
-$count_wms = 0;
-echo "<select size='8' name='wmsList' style='width:200px' onchange='submit()'>";
-
-while($row = db_fetch_array($res)){
-	echo "<option value='".$row["wms_id"]."' ";
-	if(isset($wmsList) && $wmsList == $row["wms_id"]){
-		echo "selected";
-	}
-	echo ">".$row["gui_wms_position"]." - ".$row["wms_title"]."</option>";
-	$count_wms++;
-}
-echo "</select>";
-echo "</td><td>";
-echo "<input class='myButton' type='button' name='up_wms' value=' up ' onClick='validate(\"up_wms\")'>";
-echo "<input type='hidden' name='up' value=''><br><br>";
-
-echo "<input class='myButton' type='button' name='down_wms' value='down'  onClick='validate(\"down_wms\")'>";
-echo "<input type='hidden' name='down' value=''><br><br>";
-
-echo "<input class='myButton' type='button' name='delete_wms' value='remove'  onClick='validate(\"delete_wms\")'>";
-echo "<input type='hidden' name='del' value=''>";
-
-echo "</td>";
-echo "</tr>";
-echo "</table>";
-
-
-if(isset($wmsList)){
-#gui_wms
-$sql_gw = "SELECT * FROM gui_wms WHERE fkey_gui_id = $1 AND fkey_wms_id = $2";
-$v = array($guiList,$wmsList);
-$t = array('s','i');
-$res_gw = db_prep_query($sql_gw,$v,$t);
-$cnt_gw = 0;
-while($row = db_fetch_array($res_gw)){
-   $gui_wms_position[$cnt_gw] = $row["gui_wms_position"];
-   $gui_wms_mapformat[$cnt_gw] = $row["gui_wms_mapformat"];
-   $gui_wms_featureinfoformat[$cnt_gw] = $row["gui_wms_featureinfoformat"];
-   $gui_wms_exceptionformat[$cnt_gw] = $row["gui_wms_exceptionformat"];
-   $gui_wms_epsg[$cnt_gw] = $row["gui_wms_epsg"];
-   $gui_wms_visible[$cnt_gw] = $row["gui_wms_visible"];
-   $gui_wms_opacity[$cnt_gw] = $row["gui_wms_opacity"];
-   $gui_wms_sldurl[$cnt_gw] = $row["gui_wms_sldurl"]; # sld url
-   $cnt_gw++;
-}
-#wms
-$sql_w = "SELECT * FROM wms WHERE wms_id = $1";
-$v = array($wmsList);
-$t = array('i');
-$res_w = db_prep_query($sql_w,$v,$t);
-$cnt_w = 0;
-while($row = db_fetch_array($res_w)){
-   $wms_id[$cnt_w] = $row["wms_id"];
-   $wms_version[$cnt_w] = $row["wms_version"];
-   $wms_title[$cnt_w] = $row["wms_title"];
-   $wms_abstract[$cnt_w] = $row["wms_abstract"];
-   $wms_getcapabilities[$cnt_w] = $row["wms_getcapabilities"];
-   $wms_supportsld[$cnt_w] = $row["wms_supportsld"];  # Buttons zum sld support anzeigen?
-   $cnt_w++;
- }
-#wms_format
-$sql_wf = "SELECT * FROM  wms_format WHERE  fkey_wms_id = $1";
-$v = array($wmsList);
-$t = array('i');
-$res_wf = db_prep_query($sql_wf,$v,$t);
-$cnt_wf = 0;
-while($row = db_fetch_array($res_wf)){
-   $data_type[$cnt_wf] = $row["data_type"];
-   $data_format[$cnt_wf] = $row["data_format"];
-   $cnt_wf++;
- }
-#gui_layer
-$sql_gl = "SELECT l.*, gl.*, sld.sld_user_layer_id, sld.use_sld FROM layer AS l, gui_layer AS gl left outer join sld_user_layer AS sld on sld.fkey_layer_id = gl.fkey_layer_id WHERE l.layer_id = gl.fkey_layer_id AND gl.gui_layer_wms_id = $1 AND gl.fkey_gui_id = $2 AND (sld.fkey_gui_id = $3 or sld.fkey_gui_id is NULL) AND (sld.fkey_mb_user_id = $4 or sld.fkey_mb_user_id is NULL) ORDER BY l.layer_pos";
-$v = array($wmsList,$guiList,$guiList,$mb_user_id);
-$t = array('i','s','s','i');
-
-$res_gl = db_prep_query($sql_gl,$v,$t);
-$gui_layer_status = array();
-$gui_layer_selectable = array();
-$gui_layer_visible = array();
-$gui_layer_queryable = array();
-$gui_layer_querylayer = array();
-$gui_layer_minscale = array();
-$gui_layer_maxscale = array();
-$gui_layer_priority = array();
-$gui_layer_style = array();
-$gui_layer_wfs_featuretype = array();
-$layer_maxscale = array();
-$layer_id = array();
-$layer_parent = array();
-$layer_name = array();
-$layer_title = array();
-$layer_queryable = array();
-$layer_minscale = array();
-$layer_maxscale = array();
-$sld_user_layer_id = array();
-$use_sld = array();
-while($row = db_fetch_array($res_gl)){
-	array_push($gui_layer_status, $row["gui_layer_status"]);
-	array_push($gui_layer_selectable, $row["gui_layer_selectable"]);
-	array_push($gui_layer_visible, $row["gui_layer_visible"]);
-	array_push($gui_layer_queryable, $row["gui_layer_queryable"]);
-	array_push($gui_layer_querylayer, $row["gui_layer_querylayer"]);
-	array_push($gui_layer_minscale, $row["gui_layer_minscale"]);
-	array_push($gui_layer_maxscale, $row["gui_layer_maxscale"]);
-	array_push($gui_layer_priority, $row["gui_layer_priority"]);
-	array_push($gui_layer_style, $row["gui_layer_style"]);
-	array_push($gui_layer_wfs_featuretype, $row["gui_layer_wfs_featuretype"]);
-	array_push($layer_id, $row["layer_id"]);
-	array_push($layer_parent, $row["layer_parent"]);
-	array_push($layer_name, $row["layer_name"]);
-	array_push($layer_title, $row["layer_title"]);
-	array_push($layer_queryable, $row["layer_queryable"]);
-	array_push($layer_minscale, $row["layer_minscale"]);
-	array_push($layer_maxscale, $row["layer_maxscale"]);
-	array_push($sld_user_layer_id, $row["sld_user_layer_id"]);
-	array_push($use_sld, $row["use_sld"]);
-}
-
-#layer_epsg
-$sql_le = "SELECT * FROM layer_epsg WHERE  fkey_layer_id = $1";
-$v = array($layer_id[0]);
-$t = array('i');
-$res_le = db_prep_query($sql_le,$v,$t);
-$cnt_le = 0;
-while($row = db_fetch_array($res_le)){
-   $epsg[$cnt_le] = $row["epsg"];
-   $cnt_le++;
-}
-
-echo "<div style='position:absolute;left:590px; top:180px;' ><input type='button' style='width:100px;height:100px;background-color:#0066cc' value='save' onclick='checkBoxValue()'></div>";
-echo "<table class='table_top'>";
-echo "<tr>";
-echo "<td colspan='2'>";
-echo "<a href='".$wms_getcapabilities[0];
-echo wms::getConjunctionCharacter($wms_getcapabilities[0]);
-if ($wms_version[0] == "1.0.0") { 
-	echo "WMTVER=". $wms_version[0]."&REQUEST=capabilities";
-}
-else {
-	echo "VERSION=". $wms_version[0]."&REQUEST=GetCapabilities&SERVICE=WMS";
-}
-echo "' style='font-size:14px' target='_blank'>LINK: Capabilities</a>";
-echo "</td>";
-echo "<td align = right>WMS ID: " . $wms_id[0] . "</td>";
-echo "<tr>";
-#epsg
-if($gui_wms_position[0] == 0){
-  echo "<tr>";
-     echo "<td>EPSG: </td><td>";
-     echo "<select class='mySelect'  name='this_gui_wms_epsg'>";
-        for($i=0; $i<count($epsg); $i++){
-           echo "<option value='".$epsg[$i]."' ";
-           if($epsg[$i] == $gui_wms_epsg[0]){ echo "selected";}
-           echo ">".$epsg[$i]."</option>";
-        }
-     echo "</select>";
-     echo "</td>";
-  echo "</tr>";
-}
-#format
-echo "<tr>";
-   echo "<td>Mapformat: </td><td>";
-        echo "<select class='mySelect'  name='this_gui_wms_mapformat'>";
-        for($i=0; $i<count($data_format); $i++){
-           if($data_type[$i] == 'map'){
-              echo "<option value='".$data_format[$i]."' ";
-              if($data_format[$i] == $gui_wms_mapformat[0]){ echo "selected";}
-              echo ">".$data_format[$i]."</option>";
-           }
-        }
-     echo "</select>";
-   echo "</td>";
-
-echo "</tr>";
-
-echo "<tr>";
-   echo "<td>Infoformat: </td><td>";
-        echo "<select class='mySelect'  name='this_gui_wms_featureinfoformat'>";
-        echo "<option value='text/html'>text/html</option>";
-        for($i=0; $i<count($data_format); $i++){
-           if($data_type[$i] == 'featureinfo'){
-              echo "<option value='".$data_format[$i]."' ";
-              if($data_format[$i] == $gui_wms_featureinfoformat[0]){ echo "selected";}
-              echo ">".$data_format[$i]."</option>";
-           }
-        }
-     echo "</select>";
-   echo "</td>";
-echo "</tr>";
-
-echo "<tr>";
-   echo "<td>Exceptionformat: </td><td>";
-        echo "<select class='mySelect' name='this_gui_wms_exceptionformat'>";
-        for($i=0; $i<count($data_format); $i++){
-           if($data_type[$i] == 'exception'){
-              echo "<option value='".$data_format[$i]."' ";
-              if($data_format[$i] == $gui_wms_exceptionformat[0]){ echo "selected";}
-              echo ">".$data_format[$i]."</option>";
-           }
-        }
-     echo "</select>";
-   echo "</td>";
-echo "</tr><br>";
-
-# visibility
-echo "<tr>";
-	echo "<td>Visibility: </td><td>";
-	echo "<select class='mySelect' name='this_gui_wms_visible'>";
-	for($i=0; $i<3; $i++){
-		echo "<option value='".$i."' ";
-		if($i == $gui_wms_visible[0]){ echo "selected";}
-		echo ">";
-		if($i == '0'){
-			echo "hidden";
-		}
-		if($i == '1'){
-			echo "visible";
-		}
-		echo "</option>";
-	}
-	echo "</select>";
-	echo "</td>";
-echo "</tr>";
-
-# opacity
-echo "<tr>";
-	echo "<td>Opacity: </td><td>";
-	echo "<select class='mySelect' name='this_gui_wms_opacity'>";
-	for($i=0; $i<=100; $i+=10){
-		echo "<option value='".$i."' ";
-		if($i - $gui_wms_opacity[0]<=5&&$i - $gui_wms_opacity[0]>=-4){ echo "selected";}
-		echo ">";
-		echo $i."%";
-		echo "</option>";
-	}
-	echo "</select>";
-	echo "</td>";
-echo "</tr>";
-
-# sld support
-if($wms_supportsld[0]) {
-		echo "<tr>";
-		echo "<td>SLD-URL: </td><td>";
-		echo "<input type='text' class='myText' name='this_gui_wms_sldurl' id='this_gui_wms_sldurl' title='".$gui_wms_sldurl[0]."' value='".$gui_wms_sldurl[0]."'>";
-		#echo "<a href='' onclick='return window.open(\"editor-start.php\");'><img src='sld_editor.png' border=0></a>";
-		#$layer_names = implode(",", $layer_name);
-        echo " <a href='javascript:showSld(\"".$gui_wms_sldurl[0]."\");'>SLD laden/anzeigen</a>";
-		echo "</td>";
-	echo "</tr>";
-} else {
-	echo "<input type='hidden' value='' name='this_gui_wms_sldurl'>";
-}
-
-echo "</table><br>";
-
-echo "<table border='1' cellpadding='1'>";
-		echo "<tr>";
-
-                echo "<td>Nr.</td>";
-                echo "<td>ID</td>";
-                echo "<td>" . toImage('Parent') . "</td>";
-                echo "<td>Name</td>";
-                echo "<td>Title</td>";
-                echo "<td>" . toImage('on/off') . "</td>";
-                echo "<td>" . toImage('sel') . "</td>";
-                echo "<td>" . toImage('sel_default') . "</td>";
-                echo "<td>" . toImage('info') . "</td>";
-                echo "<td>" . toImage('info_default') . "</td>";
-                echo "<td>" . toImage('minScale 1:') . "</td>";
-                echo "<td>" . toImage('maxScale 1:') . "</td>";
-                echo "<td>" . toImage('Style') . "</td>";
-                echo "<td>" . toImage('Prio') . "</td>";
-                echo "<td>" . toImage('setWFS') . "</td>";
-                if($wms_supportsld[0]) {echo "<td>" . toImage('SLD') . "</td>";}
-        echo "</tr>";
-
-#echo "<tr><td>Nr.</td><td>ID</td><td>Parent</td><td>Name</td><td>Title</td><td>on/off</td><td>sel</td><td>sel_default</td><td>info</td><td>info_default</td><td>minScale 1:</td><td>maxScale 1:</td><td>Prio</td><td>setWFS</td></tr>";
-echo "<tr><td></td><td></td><td></td><td></td><td></td><td>";
-echo "<input type='button' class='LButton' value='Sublayer\noff' onclick='setSubs()'>";
-echo "</td><td></td><td>";
-echo "<nobr><input type='button' class='button_on_off' value='off' onclick='setLayer(\"visible\",false)'>&nbsp;";
-echo "<input type='button' class='button_on_off' value='on' onclick='setLayer(\"visible\",true)'></nobr>";
-echo"</td><td></td><td>";
-echo "<nobr><input type='button' class='button_on_off' value='off' onclick='setLayer(\"querylayer\",false)'>&nbsp;";
-echo "<input type='button' class='button_on_off' value='on' onclick='setLayer(\"querylayer\",true)'></nobr>";
-echo "</td><td></td><td></td><td></td></tr>";
-
-for($i=0; $i<count($layer_id); $i++){
-#layer_styles
-$sql_styles = "SELECT * FROM layer_style WHERE  fkey_layer_id = $1";
-$v = array($layer_id[$i]);
-$t = array('i');
-$res_styles = db_prep_query($sql_styles,$v,$t);
-$cnt_styles= 0;
-$style = array();
-while($row = db_fetch_array($res_styles)){
-   $style[$cnt_styles] = $row["name"];
-   $cnt_styles++;
-}
-
- echo "<tr align='center'>";
-  echo "<td><input type='text' size='1' name='L_".$layer_id[$i]."___layer_nr' disabled value='".$i."'></td>";
-  echo "<td style='background:lightgrey'><input type='text' size='2' name='L_".$layer_id[$i]."___layer_id' value='".$layer_id[$i]."' readonly></td>";
-  echo "<td><input type='text' size='1' name='L_".$layer_id[$i]."___layer_parent' value='".$layer_parent[$i]."' readonly></td>";
-  echo "<td style='background:lightgrey'><input type='text' size='7' value='".$layer_name[$i]."' readonly></td>";
-  echo "<td><input type='text' name='".$layer_title[$i]."' size='12' value='".$layer_title[$i]."' ></td>";
-
-  echo "<td style='background:lightgrey'><input name='L_".$layer_id[$i]."___gui_layer_status' type='checkbox' ";
-  if($gui_layer_status[$i] == 1){ echo "checked";}
-  echo "></td>";
-
-  echo "<td><input name='L_".$layer_id[$i]."___gui_layer_selectable' type='checkbox' ";
-  if($gui_layer_selectable[$i] == 1){ echo "checked";}
-  echo "></td>";
-
-  echo "<td style='background:lightgrey'><input name='L_".$layer_id[$i]."___gui_layer_visible' type='checkbox' ";
-  if($gui_layer_visible[$i] == 1){ echo "checked";}
-  echo "></td>";
-
-  echo "<td><input name='L_".$layer_id[$i]."___gui_layer_queryable' type='checkbox' ";
-  if($gui_layer_queryable[$i] == 1){ echo "checked";}
-  if($layer_queryable[$i] == 0){ echo "disabled";}
-  echo "></td>";
-
-  echo "<td style='background:lightgrey'><input name='L_".$layer_id[$i]."___gui_layer_querylayer' type='checkbox' ";
-  if($gui_layer_querylayer[$i] == 1){ echo "checked";}
-  if($layer_queryable[$i] == 0){ echo "disabled";}
-  echo "></td>";
-
-  echo "<td><input name='L_".$layer_id[$i]."___gui_layer_minscale' type='text' size='5' value='".$gui_layer_minscale[$i]."'></td>";
-  echo "<td style='background:lightgrey'><input name='L_".$layer_id[$i]."___gui_layer_maxscale' type='text' size='5' value='".$gui_layer_maxscale[$i]."'></td>";
-  /**/
-  echo "<td>\n";
-  echo "<select class='select_short' name='L_".$layer_id[$i]."___gui_layer_style'>\n";
-  	   echo "<option value=''";
-  	   if(count($style) ==0){ echo "selected";}
-  	   echo ">---</option>\n";
-  for($j=0;$j<count($style); $j++){
-       echo "<option value='".$style[$j]."'";
-       if($style[$j] == $gui_layer_style[$i]){ echo "selected";}
-       echo ">".$style[$j]."</option>\n";
- }
-  echo "</select></td>\n";
-  /**/
-  echo "<td><select class='select_auto' name='L_".$layer_id[$i]."___gui_layer_priority'>";
-  for($j=0; $j<count($gui_layer_priority); $j++){
-     echo "<option value='".$j."'";
-     if($j == $gui_layer_priority[$i]){echo "selected";}
-     echo ">".$j;
-     echo "</option>";
-  }
-  echo "</select></td>\n";
-  /* wfs configuration */
-	echo "<td>";
-	if ($i > 0) {
-		echo "<input class='button_wfs'name='gui_layer_gaz' type='button' onclick='edit_gaz(\"".$guiList."\",".$wmsList.",".$layer_id[$i].")' value='";
-		if($gui_layer_wfs_featuretype[$i] == ""){
-			echo "setWFS";
-		}
-		else{
-			echo "wfs ".$gui_layer_wfs_featuretype[$i];
-		}
-		echo "'>";
-	}
-	echo "</td>";
-	if($wms_supportsld[0]) {
-		echo "<td>";
-		if ($i > 0) {
-			echo "<input class='button3' name='gui_layer_sld' type='button' onclick='window.open(\"../sld/sld_main.php?".$urlParameters."&sld_gui_id=".$guiList."&sld_wms_id=".$wms_id[0]."&sld_layer_name=".$layer_name[$i]."\");' value='";
-			if ($sld_user_layer_id[$i] != "")
-				echo "sld:".$sld_user_layer_id[$i]."(".$use_sld[$i].")";
-			else
-				echo "SLD";
-			echo "'>";
-		}
-		echo "</td>";
-	}
- echo "</tr>\n";
- if($i == 0){ echo "<tr><td colspan='16'><hr></td></tr>";}
-}
-echo "</table>\n";
-echo "<input type='hidden' name='this_gui' value='".$guiList."'>\n";
-echo "<input type='hidden' name='this_wms' value='".$wmsList."'>\n";
-echo "<input type='hidden' name='this_layer_count' value='".$cnt_l."'>\n";
-echo "<input type='hidden' name='update_content' value=''>\n";
-echo "</form>\n";
-}
-?>
-</body>
-</html>
+<?php
+# $Id$
+# http://www.mapbender.org/index.php/mod_editGuiWms.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.
+
+import_request_variables("PG");
+require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
+require_once(dirname(__FILE__)."/../classes/class_wms.php");
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+<head>
+<?php
+echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';
+?>
+<title>Edit GUI WMS</title>
+<?php
+include_once '../include/dyn_css.php';
+
+
+function toImage($text) {
+	$angle = 90;
+	if (extension_loaded("gd2")) {
+		return "<img src='../php/createImageFromText.php?text=" . urlencode($text) . "&angle=" . $angle . "'>";
+	}
+	return $text;
+}
+?>
+
+<script language="JavaScript">
+
+
+function edit_gaz(gui,wms,layer){
+	window.open("../php/mod_wfsLayerObj_conf.php?gui="+gui+"&wms="+wms+"&layer="+layer);
+}
+function validate(wert){
+	if(wert == 'delete_wms'){
+		if(document.form1.wmsList.selectedIndex == -1){
+			document.form1.wmsList.style.background = '#ff0000';
+		}else{
+
+			var secure = confirm("Remove WMS in this GUI ?");
+			if(secure == true){
+				document.form1.del.value='true';
+				document.form1.submit();
+			}
+		}
+	}
+
+	if(wert == 'up_wms'){
+		if(document.form1.wmsList.selectedIndex == -1){
+			document.form1.wmsList.style.background = '#ff0000';
+		}else{
+			if (document.form1.wmsList.selectedIndex>0){
+				document.form1.up.value='true';
+				document.form1.submit();
+			}
+		}
+	}
+
+	if(wert == 'down_wms'){
+		if(document.form1.wmsList.selectedIndex == -1){
+			document.form1.wmsList.style.background = '#ff0000';
+		}else{
+			if (document.form1.wmsList.selectedIndex<document.form1.wmsList.length-1){
+				document.form1.down.value='true';
+				document.form1.submit();
+			}
+		}
+	}
+}
+function checkBoxValue(){
+   for(var i=0; i<document.forms[0].elements.length; i++){
+      if(document.forms[0].elements[i].type == 'checkbox'){
+         if(document.forms[0].elements[i].checked == true){
+            document.forms[0].elements[i].value = '1';
+         }
+         else{
+            document.forms[0].elements[i].value = '0';
+            document.forms[0].elements[i].checked = true;
+         }
+      }
+      if(document.forms[0].elements[i].type == 'text' && ( document.forms[0].elements[i].name.indexOf("minscale") > -1 || document.forms[0].elements[i].name.indexOf("maxscale") > -1 )){
+         var nr = parseInt(document.forms[0].elements[i].value);
+         if(isNaN(nr) == true){document.forms[0].elements[i].value = 0;}
+         else{document.forms[0].elements[i].value = nr;}
+      }
+   }
+   document.forms[0].update_content.value=1;
+   document.forms[0].submit();
+}
+function getAllLayer(){
+   var arrayLayer = new Array();
+   var cntLayer = 0;
+   for(var i=0; i<document.forms[0].elements.length; i++){
+      if(document.forms[0].elements[i].name.indexOf("layer_id") > -1){
+         arrayLayer[cntLayer] = document.forms[0].elements[i].value;
+         cntLayer++;
+      }
+   }
+   return arrayLayer;
+}
+function setSubs(){
+   var arrayLayer = getAllLayer();
+   for(var i=0; i<arrayLayer.length; i++){
+      if(parseInt(eval("document.forms[0].L_" + arrayLayer[i] + "___layer_parent.value")) > 0){
+         eval("document.forms[0].L_" + arrayLayer[i] + "___gui_layer_status.checked = false");
+      }
+   }
+}
+function setLayer(def,status){
+   var arrayLayer = getAllLayer();
+   if(def == 'querylayer'){
+      for(var i=1; i<arrayLayer.length; i++){
+         if(eval("document.forms[0].L_" + arrayLayer[i] + "___gui_layer_querylayer.disabled == false")){
+            eval("document.forms[0].L_" + arrayLayer[i] + "___gui_layer_querylayer.checked = " + status);
+         }
+      }
+   }
+   if(def == 'visible'){
+      for(var i=1; i<arrayLayer.length; i++){
+         eval("document.forms[0].L_" + arrayLayer[i] + "___gui_layer_visible.checked = " + status);
+      }
+   }
+}
+function showSld(origUrl){
+	var url = document.getElementById("this_gui_wms_sldurl").value;
+	if(url==""){
+		if(origUrl=="")
+			return;
+		url=origUrl;
+	}
+	window.open(url);
+}
+</script>
+
+</head>
+<body>
+<?php
+
+require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+$con = db_connect($DBSERVER,$OWNER,$PW);
+db_select_db(DB,$con);
+
+$mb_user_id=$_SESSION["mb_user_id"];
+
+#delete gui_wms from gui
+if($del && $del == 'true'){
+	$sql="SELECT DISTINCT gui_wms_position from gui_wms WHERE fkey_gui_id = $1 and fkey_wms_id = $2";
+	$v = array($guiList,$wmsList);
+	$t = array('s','i');
+	$res = db_prep_query($sql,$v,$t);
+	$cnt = 0;
+	while($row = db_fetch_array($res)){
+		$wms_position = $row["gui_wms_position"];
+		$cnt++;
+	}
+	#if($cnt > 1){die("Error: WMS (ID) not unique!");}
+		$sql = "Delete from gui_wms where fkey_gui_id = $1 and fkey_wms_id = $2 ";
+		$v = array($guiList,$wmsList);
+		$t = array('s','i');
+		$res = db_prep_query($sql,$v,$t);
+		$sql = "Delete from gui_layer where fkey_gui_id = $1 and gui_layer_wms_id = $2";
+		$v = array($guiList,$wmsList);
+		$t = array('s','i');
+		$res = db_prep_query($sql,$v,$t);
+		$del='false';
+		$sql = "UPDATE gui_wms SET gui_wms_position = (gui_wms_position - 1) WHERE gui_wms_position > $1";
+		$sql .= " AND fkey_gui_id = $2 ";
+		$v = array($wms_position,$guiList);
+		$t = array('i','s');
+		$res = db_prep_query($sql,$v,$t);
+
+	unset($wmsList);
+}
+
+#update gui_wms_position
+if($up && $up == 'true'){
+	if ($wmsList!=""){
+		$sql = "SELECT gui_wms_position ";
+		$sql .= "FROM gui_wms WHERE fkey_gui_id = $1 AND fkey_wms_id = $2";
+		$v = array($guiList,$wmsList);
+		$t = array('s','i');
+		$res = db_prep_query($sql,$v,$t);
+		if($row = db_fetch_array($res)){
+			$wms_position = $row["gui_wms_position"];
+		}
+	}
+	if($wms_position > 0){
+		$sql = "UPDATE gui_wms SET ";
+		$sql .= "gui_wms_position = $1";
+		$sql .= " WHERE fkey_gui_id = $2 AND fkey_wms_id = $3";
+		$v = array(($wms_position - 1),$guiList,$wmsList);
+		$t = array('i','s','i');
+		$res = db_prep_query($sql,$v,$t);
+		$sql = "UPDATE gui_wms SET ";
+		$sql .= "gui_wms_position = $1";
+		$sql .= " WHERE gui_wms_position = $2 AND fkey_gui_id = $3 AND fkey_wms_id <> $4 ";
+		$v = array($wms_position,($wms_position - 1),$guiList,$wmsList);
+		$t = array('i','i','s','i');
+		$res = db_prep_query($sql,$v,$t);
+	}
+}
+
+if($down && $down == 'true'){
+	$max = 0;
+	if ($wmsList!=""){
+		$sql = "SELECT gui_wms_position ";
+		$sql .= "FROM gui_wms WHERE fkey_gui_id = $1 AND fkey_wms_id = $2";
+		$v = array($guiList,$wmsList);
+		$t = array('s','i');
+		$res = db_prep_query($sql,$v,$t);
+		if($row = db_fetch_array($res)){
+			$wms_position = $row["gui_wms_position"];
+		}
+		$sql = "SELECT MAX(gui_wms_position) as max FROM gui_wms WHERE fkey_gui_id = $1 ";
+		$v = array($guiList);
+		$t = array('s');
+		$res = db_prep_query($sql,$v,$t);
+		if($row = db_fetch_array($res)){
+			$max = $row["max"];
+		}
+	}
+	if($wms_position < $max){
+		$sql = "UPDATE gui_wms SET ";
+		$sql .= "gui_wms_position = $1";
+		$sql .= " WHERE fkey_gui_id = $2 AND fkey_wms_id = $3";
+		$v = array(($wms_position + 1),$guiList,$wmsList);
+		$t = array('i','s','i');
+		$res = db_prep_query($sql,$v,$t);
+		$sql = "UPDATE gui_wms SET ";
+		$sql .= "gui_wms_position = $1";
+		$sql .= " WHERE gui_wms_position = $2 AND fkey_gui_id = $3 AND fkey_wms_id <> $4";
+		$v = array($wms_position,($wms_position + 1),$guiList,$wmsList);
+		$t = array('i','i','s','i');
+		$res = db_prep_query($sql,$v,$t);
+	}
+}
+
+/*handle Updates*/
+if(isset($update_content) && $update_content == "1"){
+   if(isset($this_gui_wms_epsg)){
+      $sql = "UPDATE gui_wms set gui_wms_epsg = $1, gui_wms_mapformat = $2, ";
+      $sql .= "gui_wms_featureinfoformat = $3, gui_wms_exceptionformat = $4, ";
+      $sql .= "gui_wms_visible = $5, gui_wms_opacity = $6, gui_wms_sldurl = $7 ";
+      $sql .= "WHERE fkey_gui_id = $8 AND fkey_wms_id = $9";
+		$v = array($this_gui_wms_epsg,$this_gui_wms_mapformat,$this_gui_wms_featureinfoformat,$this_gui_wms_exceptionformat,$this_gui_wms_visible,$this_gui_wms_opacity,$this_gui_wms_sldurl,$this_gui,$this_wms);
+		$t = array('s','s','s','s','i','i','s','s','i');
+		$res = db_prep_query($sql,$v,$t);
+   }
+   else{
+		$sql = "UPDATE gui_wms set gui_wms_mapformat = $1, ";
+		$sql .= "gui_wms_featureinfoformat = $2, gui_wms_exceptionformat = $3, ";
+		$sql .= "gui_wms_visible = $4, gui_wms_opacity = $5, gui_wms_sldurl = $6 ";
+		$sql .= "WHERE fkey_gui_id = $7 AND fkey_wms_id = $8";
+		$v = array($this_gui_wms_mapformat,$this_gui_wms_featureinfoformat,$this_gui_wms_exceptionformat,$this_gui_wms_visible,$this_gui_wms_opacity,$this_gui_wms_sldurl,$this_gui,$this_wms);
+		$t = array('s','s','s','i','i','s','s','i');
+		$res = db_prep_query($sql,$v,$t);
+   }
+
+   /**/
+
+   $cnt = 0;
+   while(list($key,$val) = each($_REQUEST)){
+		if(preg_match("/___/", $key)){
+			$myKey = explode("___", $key);
+			if($myKey[1]!="layer_parent" && $myKey[1]!='layer_id' ){
+				$sql = "UPDATE gui_layer SET ".$myKey[1]." = $1 WHERE fkey_gui_id = $2 AND fkey_layer_id = $3";
+				$v = array($val,$this_gui,preg_replace("/L_/","",$myKey[0]));
+				if($myKey[1]=='gui_layer_style'){
+					$t = array('s','s','i');
+				}
+				else{
+					$t = array('i','s','i');
+				}
+				if(!$res = db_prep_query($sql,$v,$t)){
+					echo "FEHLER in ZEILE 288";
+				}
+			}
+		}
+	}
+}
+
+echo "<form name='form1' action='" . $self ."' method='post'>";
+echo "<table cellpadding='3' cellspacing='3' border='0' class='table_top'>";
+
+echo "<tr>";
+echo "<td>";
+echo "GUI";
+echo "</td>";
+echo "<td>";
+echo "WMS-TITLE";
+echo "</td>";
+echo "<td>";
+echo "</td>";
+echo "<tr>";
+
+echo "<td>";
+
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+$admin = new administration();
+$ownguis = $admin->getGuisByOwner($_SESSION["mb_user_id"],true);
+
+$gui_id =array();
+if (count($ownguis)>0){
+	for($i=0; $i<count($ownguis); $i++){
+		$gui_id[$i]=$ownguis[$i];
+	}
+}
+
+echo"<select size='8' name='guiList' onchange='document.form1.wmsList.selectedIndex = -1;submit()'>";
+$selected_gui_id="";
+
+for ($i=0; $i<count($ownguis);$i++){
+   echo "<option value='".$gui_id[$i]."' ";
+   if($guiList && $guiList == $gui_id[$i]){
+      echo "selected";
+      $selected_gui_id=$gui_id[$i];
+   }
+   else{
+      if ($i==0){
+         echo "selected";
+         $selected_gui_id=$gui_id[$i];
+		}
+   }
+   echo ">".$gui_id[$i]."</option>";
+}
+
+echo "</select>";
+echo "</td>";
+echo "<td>";
+
+$sql = "SELECT * from gui_wms JOIN gui ON gui_wms.fkey_gui_id = gui.gui_id JOIN wms ON ";
+$sql .= "gui_wms.fkey_wms_id = wms.wms_id AND gui_wms.fkey_gui_id=gui.gui_id WHERE gui.gui_id = $1 ORDER BY gui_wms_position";
+$v = array($selected_gui_id);
+$t = array('s');
+$res = db_prep_query($sql,$v,$t);
+$count_wms = 0;
+echo "<select size='8' name='wmsList' style='width:200px' onchange='submit()'>";
+
+while($row = db_fetch_array($res)){
+	echo "<option value='".$row["wms_id"]."' ";
+	if(isset($wmsList) && $wmsList == $row["wms_id"]){
+		echo "selected";
+	}
+	echo ">".$row["gui_wms_position"]." - ".$row["wms_title"]."</option>";
+	$count_wms++;
+}
+echo "</select>";
+echo "</td><td>";
+echo "<input class='myButton' type='button' name='up_wms' value=' up ' onClick='validate(\"up_wms\")'>";
+echo "<input type='hidden' name='up' value=''><br><br>";
+
+echo "<input class='myButton' type='button' name='down_wms' value='down'  onClick='validate(\"down_wms\")'>";
+echo "<input type='hidden' name='down' value=''><br><br>";
+
+echo "<input class='myButton' type='button' name='delete_wms' value='remove'  onClick='validate(\"delete_wms\")'>";
+echo "<input type='hidden' name='del' value=''>";
+
+echo "</td>";
+echo "</tr>";
+echo "</table>";
+
+
+if(isset($wmsList)){
+#gui_wms
+$sql_gw = "SELECT * FROM gui_wms WHERE fkey_gui_id = $1 AND fkey_wms_id = $2";
+$v = array($guiList,$wmsList);
+$t = array('s','i');
+$res_gw = db_prep_query($sql_gw,$v,$t);
+$cnt_gw = 0;
+while($row = db_fetch_array($res_gw)){
+   $gui_wms_position[$cnt_gw] = $row["gui_wms_position"];
+   $gui_wms_mapformat[$cnt_gw] = $row["gui_wms_mapformat"];
+   $gui_wms_featureinfoformat[$cnt_gw] = $row["gui_wms_featureinfoformat"];
+   $gui_wms_exceptionformat[$cnt_gw] = $row["gui_wms_exceptionformat"];
+   $gui_wms_epsg[$cnt_gw] = $row["gui_wms_epsg"];
+   $gui_wms_visible[$cnt_gw] = $row["gui_wms_visible"];
+   $gui_wms_opacity[$cnt_gw] = $row["gui_wms_opacity"];
+   $gui_wms_sldurl[$cnt_gw] = $row["gui_wms_sldurl"]; # sld url
+   $cnt_gw++;
+}
+#wms
+$sql_w = "SELECT * FROM wms WHERE wms_id = $1";
+$v = array($wmsList);
+$t = array('i');
+$res_w = db_prep_query($sql_w,$v,$t);
+$cnt_w = 0;
+while($row = db_fetch_array($res_w)){
+   $wms_id[$cnt_w] = $row["wms_id"];
+   $wms_version[$cnt_w] = $row["wms_version"];
+   $wms_title[$cnt_w] = $row["wms_title"];
+   $wms_abstract[$cnt_w] = $row["wms_abstract"];
+   $wms_getcapabilities[$cnt_w] = $row["wms_getcapabilities"];
+   $wms_supportsld[$cnt_w] = $row["wms_supportsld"];  # Buttons zum sld support anzeigen?
+   $cnt_w++;
+ }
+#wms_format
+$sql_wf = "SELECT * FROM  wms_format WHERE  fkey_wms_id = $1";
+$v = array($wmsList);
+$t = array('i');
+$res_wf = db_prep_query($sql_wf,$v,$t);
+$cnt_wf = 0;
+while($row = db_fetch_array($res_wf)){
+   $data_type[$cnt_wf] = $row["data_type"];
+   $data_format[$cnt_wf] = $row["data_format"];
+   $cnt_wf++;
+ }
+#gui_layer
+$sql_gl = "SELECT l.*, gl.*, sld.sld_user_layer_id, sld.use_sld FROM layer AS l, gui_layer AS gl left outer join sld_user_layer AS sld on sld.fkey_layer_id = gl.fkey_layer_id WHERE l.layer_id = gl.fkey_layer_id AND gl.gui_layer_wms_id = $1 AND gl.fkey_gui_id = $2 AND (sld.fkey_gui_id = $3 or sld.fkey_gui_id is NULL) AND (sld.fkey_mb_user_id = $4 or sld.fkey_mb_user_id is NULL) ORDER BY l.layer_pos";
+$v = array($wmsList,$guiList,$guiList,$mb_user_id);
+$t = array('i','s','s','i');
+
+$res_gl = db_prep_query($sql_gl,$v,$t);
+$gui_layer_status = array();
+$gui_layer_selectable = array();
+$gui_layer_visible = array();
+$gui_layer_queryable = array();
+$gui_layer_querylayer = array();
+$gui_layer_minscale = array();
+$gui_layer_maxscale = array();
+$gui_layer_priority = array();
+$gui_layer_style = array();
+$gui_layer_wfs_featuretype = array();
+$layer_maxscale = array();
+$layer_id = array();
+$layer_parent = array();
+$layer_name = array();
+$layer_title = array();
+$layer_queryable = array();
+$layer_minscale = array();
+$layer_maxscale = array();
+$sld_user_layer_id = array();
+$use_sld = array();
+while($row = db_fetch_array($res_gl)){
+	array_push($gui_layer_status, $row["gui_layer_status"]);
+	array_push($gui_layer_selectable, $row["gui_layer_selectable"]);
+	array_push($gui_layer_visible, $row["gui_layer_visible"]);
+	array_push($gui_layer_queryable, $row["gui_layer_queryable"]);
+	array_push($gui_layer_querylayer, $row["gui_layer_querylayer"]);
+	array_push($gui_layer_minscale, $row["gui_layer_minscale"]);
+	array_push($gui_layer_maxscale, $row["gui_layer_maxscale"]);
+	array_push($gui_layer_priority, $row["gui_layer_priority"]);
+	array_push($gui_layer_style, $row["gui_layer_style"]);
+	array_push($gui_layer_wfs_featuretype, $row["gui_layer_wfs_featuretype"]);
+	array_push($layer_id, $row["layer_id"]);
+	array_push($layer_parent, $row["layer_parent"]);
+	array_push($layer_name, $row["layer_name"]);
+	array_push($layer_title, $row["layer_title"]);
+	array_push($layer_queryable, $row["layer_queryable"]);
+	array_push($layer_minscale, $row["layer_minscale"]);
+	array_push($layer_maxscale, $row["layer_maxscale"]);
+	array_push($sld_user_layer_id, $row["sld_user_layer_id"]);
+	array_push($use_sld, $row["use_sld"]);
+}
+
+#layer_epsg
+$sql_le = "SELECT * FROM layer_epsg WHERE  fkey_layer_id = $1";
+$v = array($layer_id[0]);
+$t = array('i');
+$res_le = db_prep_query($sql_le,$v,$t);
+$cnt_le = 0;
+while($row = db_fetch_array($res_le)){
+   $epsg[$cnt_le] = $row["epsg"];
+   $cnt_le++;
+}
+
+echo "<div style='position:absolute;left:590px; top:180px;' ><input type='button' style='width:100px;height:100px;background-color:#0066cc' value='save' onclick='checkBoxValue()'></div>";
+echo "<table class='table_top'>";
+echo "<tr>";
+echo "<td colspan='2'>";
+echo "<a href='".$wms_getcapabilities[0];
+echo wms::getConjunctionCharacter($wms_getcapabilities[0]);
+if ($wms_version[0] == "1.0.0") { 
+	echo "WMTVER=". $wms_version[0]."&REQUEST=capabilities";
+}
+else {
+	echo "VERSION=". $wms_version[0]."&REQUEST=GetCapabilities&SERVICE=WMS";
+}
+echo "' style='font-size:14px' target='_blank'>LINK: Capabilities</a>";
+echo "</td>";
+echo "<td align = right>WMS ID: " . $wms_id[0] . "</td>";
+echo "<tr>";
+#epsg
+if($gui_wms_position[0] == 0){
+  echo "<tr>";
+     echo "<td>EPSG: </td><td>";
+     echo "<select class='mySelect'  name='this_gui_wms_epsg'>";
+        for($i=0; $i<count($epsg); $i++){
+           echo "<option value='".$epsg[$i]."' ";
+           if($epsg[$i] == $gui_wms_epsg[0]){ echo "selected";}
+           echo ">".$epsg[$i]."</option>";
+        }
+     echo "</select>";
+     echo "</td>";
+  echo "</tr>";
+}
+#format
+echo "<tr>";
+   echo "<td>Mapformat: </td><td>";
+        echo "<select class='mySelect'  name='this_gui_wms_mapformat'>";
+        for($i=0; $i<count($data_format); $i++){
+           if($data_type[$i] == 'map'){
+              echo "<option value='".$data_format[$i]."' ";
+              if($data_format[$i] == $gui_wms_mapformat[0]){ echo "selected";}
+              echo ">".$data_format[$i]."</option>";
+           }
+        }
+     echo "</select>";
+   echo "</td>";
+
+echo "</tr>";
+
+echo "<tr>";
+   echo "<td>Infoformat: </td><td>";
+        echo "<select class='mySelect'  name='this_gui_wms_featureinfoformat'>";
+        echo "<option value='text/html'>text/html</option>";
+        for($i=0; $i<count($data_format); $i++){
+           if($data_type[$i] == 'featureinfo'){
+              echo "<option value='".$data_format[$i]."' ";
+              if($data_format[$i] == $gui_wms_featureinfoformat[0]){ echo "selected";}
+              echo ">".$data_format[$i]."</option>";
+           }
+        }
+     echo "</select>";
+   echo "</td>";
+echo "</tr>";
+
+echo "<tr>";
+   echo "<td>Exceptionformat: </td><td>";
+        echo "<select class='mySelect' name='this_gui_wms_exceptionformat'>";
+        for($i=0; $i<count($data_format); $i++){
+           if($data_type[$i] == 'exception'){
+              echo "<option value='".$data_format[$i]."' ";
+              if($data_format[$i] == $gui_wms_exceptionformat[0]){ echo "selected";}
+              echo ">".$data_format[$i]."</option>";
+           }
+        }
+     echo "</select>";
+   echo "</td>";
+echo "</tr><br>";
+
+# visibility
+echo "<tr>";
+	echo "<td>Visibility: </td><td>";
+	echo "<select class='mySelect' name='this_gui_wms_visible'>";
+	for($i=0; $i<3; $i++){
+		echo "<option value='".$i."' ";
+		if($i == $gui_wms_visible[0]){ echo "selected";}
+		echo ">";
+		if($i == '0'){
+			echo "hidden";
+		}
+		if($i == '1'){
+			echo "visible";
+		}
+		echo "</option>";
+	}
+	echo "</select>";
+	echo "</td>";
+echo "</tr>";
+
+# opacity
+echo "<tr>";
+	echo "<td>Opacity: </td><td>";
+	echo "<select class='mySelect' name='this_gui_wms_opacity'>";
+	for($i=0; $i<=100; $i+=10){
+		echo "<option value='".$i."' ";
+		if($i - $gui_wms_opacity[0]<=5&&$i - $gui_wms_opacity[0]>=-4){ echo "selected";}
+		echo ">";
+		echo $i."%";
+		echo "</option>";
+	}
+	echo "</select>";
+	echo "</td>";
+echo "</tr>";
+
+# sld support
+if($wms_supportsld[0]) {
+		echo "<tr>";
+		echo "<td>SLD-URL: </td><td>";
+		echo "<input type='text' class='myText' name='this_gui_wms_sldurl' id='this_gui_wms_sldurl' title='".$gui_wms_sldurl[0]."' value='".$gui_wms_sldurl[0]."'>";
+		#echo "<a href='' onclick='return window.open(\"editor-start.php\");'><img src='sld_editor.png' border=0></a>";
+		#$layer_names = implode(",", $layer_name);
+        echo " <a href='javascript:showSld(\"".$gui_wms_sldurl[0]."\");'>SLD laden/anzeigen</a>";
+		echo "</td>";
+	echo "</tr>";
+} else {
+	echo "<input type='hidden' value='' name='this_gui_wms_sldurl'>";
+}
+
+echo "</table><br>";
+
+echo "<table border='1' cellpadding='1'>";
+		echo "<tr>";
+
+                echo "<td>Nr.</td>";
+                echo "<td>ID</td>";
+                echo "<td>" . toImage('Parent') . "</td>";
+                echo "<td>Name</td>";
+                echo "<td>Title</td>";
+                echo "<td>" . toImage('on/off') . "</td>";
+                echo "<td>" . toImage('sel') . "</td>";
+                echo "<td>" . toImage('sel_default') . "</td>";
+                echo "<td>" . toImage('info') . "</td>";
+                echo "<td>" . toImage('info_default') . "</td>";
+                echo "<td>" . toImage('minScale 1:') . "</td>";
+                echo "<td>" . toImage('maxScale 1:') . "</td>";
+                echo "<td>" . toImage('Style') . "</td>";
+                echo "<td>" . toImage('Prio') . "</td>";
+                echo "<td>" . toImage('setWFS') . "</td>";
+                if($wms_supportsld[0]) {echo "<td>" . toImage('SLD') . "</td>";}
+        echo "</tr>";
+
+#echo "<tr><td>Nr.</td><td>ID</td><td>Parent</td><td>Name</td><td>Title</td><td>on/off</td><td>sel</td><td>sel_default</td><td>info</td><td>info_default</td><td>minScale 1:</td><td>maxScale 1:</td><td>Prio</td><td>setWFS</td></tr>";
+echo "<tr><td></td><td></td><td></td><td></td><td></td><td>";
+echo "<input type='button' class='LButton' value='Sublayer\noff' onclick='setSubs()'>";
+echo "</td><td></td><td>";
+echo "<nobr><input type='button' class='button_on_off' value='off' onclick='setLayer(\"visible\",false)'>&nbsp;";
+echo "<input type='button' class='button_on_off' value='on' onclick='setLayer(\"visible\",true)'></nobr>";
+echo"</td><td></td><td>";
+echo "<nobr><input type='button' class='button_on_off' value='off' onclick='setLayer(\"querylayer\",false)'>&nbsp;";
+echo "<input type='button' class='button_on_off' value='on' onclick='setLayer(\"querylayer\",true)'></nobr>";
+echo "</td><td></td><td></td><td></td></tr>";
+
+for($i=0; $i<count($layer_id); $i++){
+#layer_styles
+$sql_styles = "SELECT * FROM layer_style WHERE  fkey_layer_id = $1";
+$v = array($layer_id[$i]);
+$t = array('i');
+$res_styles = db_prep_query($sql_styles,$v,$t);
+$cnt_styles= 0;
+$style = array();
+while($row = db_fetch_array($res_styles)){
+   $style[$cnt_styles] = $row["name"];
+   $cnt_styles++;
+}
+
+ echo "<tr align='center'>";
+  echo "<td><input type='text' size='1' name='L_".$layer_id[$i]."___layer_nr' disabled value='".$i."'></td>";
+  echo "<td style='background:lightgrey'><input type='text' size='2' name='L_".$layer_id[$i]."___layer_id' value='".$layer_id[$i]."' readonly></td>";
+  echo "<td><input type='text' size='1' name='L_".$layer_id[$i]."___layer_parent' value='".$layer_parent[$i]."' readonly></td>";
+  echo "<td style='background:lightgrey'><input type='text' size='7' value='".$layer_name[$i]."' readonly></td>";
+  echo "<td><input type='text' name='".$layer_title[$i]."' size='12' value='".$layer_title[$i]."' ></td>";
+
+  echo "<td style='background:lightgrey'><input name='L_".$layer_id[$i]."___gui_layer_status' type='checkbox' ";
+  if($gui_layer_status[$i] == 1){ echo "checked";}
+  echo "></td>";
+
+  echo "<td><input name='L_".$layer_id[$i]."___gui_layer_selectable' type='checkbox' ";
+  if($gui_layer_selectable[$i] == 1){ echo "checked";}
+  echo "></td>";
+
+  echo "<td style='background:lightgrey'><input name='L_".$layer_id[$i]."___gui_layer_visible' type='checkbox' ";
+  if($gui_layer_visible[$i] == 1){ echo "checked";}
+  echo "></td>";
+
+  echo "<td><input name='L_".$layer_id[$i]."___gui_layer_queryable' type='checkbox' ";
+  if($gui_layer_queryable[$i] == 1){ echo "checked";}
+  if($layer_queryable[$i] == 0){ echo "disabled";}
+  echo "></td>";
+
+  echo "<td style='background:lightgrey'><input name='L_".$layer_id[$i]."___gui_layer_querylayer' type='checkbox' ";
+  if($gui_layer_querylayer[$i] == 1){ echo "checked";}
+  if($layer_queryable[$i] == 0){ echo "disabled";}
+  echo "></td>";
+
+  echo "<td><input name='L_".$layer_id[$i]."___gui_layer_minscale' type='text' size='5' value='".$gui_layer_minscale[$i]."'></td>";
+  echo "<td style='background:lightgrey'><input name='L_".$layer_id[$i]."___gui_layer_maxscale' type='text' size='5' value='".$gui_layer_maxscale[$i]."'></td>";
+  /**/
+  echo "<td>\n";
+  echo "<select class='select_short' name='L_".$layer_id[$i]."___gui_layer_style'>\n";
+  	   echo "<option value=''";
+  	   if(count($style) ==0){ echo "selected";}
+  	   echo ">---</option>\n";
+  for($j=0;$j<count($style); $j++){
+       echo "<option value='".$style[$j]."'";
+       if($style[$j] == $gui_layer_style[$i]){ echo "selected";}
+       echo ">".$style[$j]."</option>\n";
+ }
+  echo "</select></td>\n";
+  /**/
+  echo "<td><select class='select_short' name='L_".$layer_id[$i]."___gui_layer_priority'>";
+  for($j=0; $j<count($gui_layer_priority); $j++){
+     echo "<option value='".$j."'";
+     if($j == $gui_layer_priority[$i]){echo "selected";}
+     echo ">".$j;
+     echo "</option>";
+  }
+  echo "</select></td>\n";
+  /* wfs configuration */
+	echo "<td>";
+	if ($i > 0) {
+		echo "<input class='button_wfs'name='gui_layer_gaz' type='button' onclick='edit_gaz(\"".$guiList."\",".$wmsList.",".$layer_id[$i].")' value='";
+		if($gui_layer_wfs_featuretype[$i] == ""){
+			echo "setWFS";
+		}
+		else{
+			echo "wfs ".$gui_layer_wfs_featuretype[$i];
+		}
+		echo "'>";
+	}
+	echo "</td>";
+	if($wms_supportsld[0]) {
+		echo "<td>";
+		if ($i > 0) {
+			echo "<input class='button3' name='gui_layer_sld' type='button' onclick='window.open(\"../sld/sld_main.php?".$urlParameters."&sld_gui_id=".$guiList."&sld_wms_id=".$wms_id[0]."&sld_layer_name=".$layer_name[$i]."\");' value='";
+			if ($sld_user_layer_id[$i] != "")
+				echo "sld:".$sld_user_layer_id[$i]."(".$use_sld[$i].")";
+			else
+				echo "SLD";
+			echo "'>";
+		}
+		echo "</td>";
+	}
+ echo "</tr>\n";
+ if($i == 0){ echo "<tr><td colspan='16'><hr></td></tr>";}
+}
+echo "</table>\n";
+echo "<input type='hidden' name='this_gui' value='".$guiList."'>\n";
+echo "<input type='hidden' name='this_wms' value='".$wmsList."'>\n";
+echo "<input type='hidden' name='this_layer_count' value='".$cnt_l."'>\n";
+echo "<input type='hidden' name='update_content' value=''>\n";
+echo "</form>\n";
+}
+?>
+</body>
+</html>

Modified: branches/print_dev/http/php/mod_exportElement.php
===================================================================
--- branches/print_dev/http/php/mod_exportElement.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/php/mod_exportElement.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -89,6 +89,7 @@
       $insert .=  "'".$row["e_url"]."'";
    $insert .=  ");\n";
    $insert = preg_replace("/,,/", ",NULL ,", $insert);
+   $insert = preg_replace("/,,/", ",NULL ,", $insert);
 }
 
 	# export element vars
@@ -124,4 +125,4 @@
 
 ?>
 </body>
-</html>
\ No newline at end of file
+</html>

Modified: branches/print_dev/http/php/mod_loadwmc_server.php
===================================================================
--- branches/print_dev/http/php/mod_loadwmc_server.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/php/mod_loadwmc_server.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,174 +1,180 @@
-<?php
-require_once(dirname(__FILE__) . "/../php/mb_validateSession.php");
-require_once(dirname(__FILE__) . "/../classes/class_user.php");
-require_once(dirname(__FILE__) . "/../classes/class_wmc.php");
-require_once(dirname(__FILE__) . "/../classes/class_json.php");
-
-/**
- * encodes and delivers the data
- * 
- * @param object the un-encoded object 
- */
-function sendOutput($out){
-	global $json;
-	$output = $json->encode($out);
-	header("Content-Type: text/x-json");
-	echo $output;
-}
-
-/**
- * Get all available WMC documents from the database
- * 
- * @return mixed[] an array of wmcs 
- * 					(wmc = assoc. array of "id", "title", "timestamp")
- */
-function getWmc(){
-	global $con;
-	global $userId;
-	
-	$wmcArray = array();
-	
-	// get WMC ids 
-	$currentUser = new User($userId);
-	$wmcIdArray = $currentUser->getWmcByOwner();
-	
-	// get WMC data
-	$v = array();
-	$t = array();
-	$wmcIdList = "";
-
-	for ($i = 0; $i < count($wmcIdArray); $i++) {
-		if ($i > 0) { 
-			$wmcIdList .= ",";
-		}
-		$wmcIdList .= "$".($i+1);
-		array_push($v, $wmcIdArray[$i]);
-		array_push($t, 's');
-	}
-
-	$sql = "SELECT DISTINCT wmc_id, wmc_title, wmc_timestamp " . 
-		"FROM mb_user_wmc WHERE wmc_id IN (" . $wmcIdList . ") " .
-		"ORDER BY wmc_timestamp DESC";
-	
-	$res = db_prep_query($sql, $v, $t);
-	while($row = db_fetch_array($res)){
-		$currentResult = array();
-		$currentResult["id"] = $row["wmc_id"];
-		$currentResult["title"] = $row["wmc_title"];
-		$currentResult["timestamp"] = date("M d Y H:i:s", $row["wmc_timestamp"]); 
-		array_push($wmcArray, $currentResult);
-	}
-	return $wmcArray;
-}
-
-$json = new Mapbender_JSON();
-$queryObj = $json->decode(stripslashes($_REQUEST['queryObj']));
-$resultObj = array();
-
-$e = new mb_exception("command: " . $queryObj->command);
-
-$wmc = new wmc();
-$userId = $_SESSION[mb_user_id];
-
-switch($queryObj->command){
-
-	// gets available WMCs
-	case 'getWmc':
-		$resultObj["wmc"] = getWmc();
-	break;
-
-	// gets XML document of a WMC
-	case 'getWmcDocument':
-		$wmcId = $queryObj->parameters->id;
-		$doc = $wmc->getDocument($wmcId);
-		if (!$doc) {
-			$resultObj["error"] = "The WMC document could not be found.";
-		}
-		else {
-			$resultObj["wmc"] = array("document" => $doc);
-		}
-	break;
-
-	// deletes a WMC
-	case 'deleteWmc':
-		$wmcId = $queryObj->parameters->id;
-		if ($wmc->delete($wmcId)) {
-			$resultObj["success"] = "WMC has been deleted from the database.";
-		}
-		else {
-			$resultObj["error"] = "WMC could not be deleted.";
-		}
-	break;
-	
-	// loads a WMC (returns array of JS code)
-	case 'loadWmc':
-		$wmcId = $queryObj->parameters->id;
-		$wmc->createFromDb($wmcId);
-		$jsArray = $wmc->toJavaScript();
-		if ($jsArray) {
-			$resultObj["javascript"] = $jsArray;
-		}
-		else {
-			$resultObj["error"] = "WMC could not be loaded.";
-		}
-	break;
-
-	// merges data with WMC and loads it (returns array of JS code)
-	case 'mergeWmc':
-		$params = $queryObj->parameters;
-		
-		// generate a WMC for the current client state
-		$currentWmc = new wmc();
-		$currentWmc->createFromJs($params->mapObject, $params->generalTitle, $params->extensionData);
-
-		// get the desired WMC from the database
-		$wmcId = $queryObj->parameters->id;
-		$wmcXml = wmc::getDocument($wmcId);
-
-		// merge the two WMCs
-		$currentWmc->merge($wmcXml);
-		
-		// load the merged WMC
-		$jsArray = $currentWmc->toJavaScript();
-
-		if (is_array($jsArray) && count($jsArray) > 0) {
-			$resultObj["javascript"] = $jsArray;
-		}
-		else {
-			$resultObj["error"] = "WMC could not be loaded.";
-		}
-	break;
-	
-	// appends a WMC (returns JS code)
-	case 'appendWmc':
-		$params = $queryObj->parameters;
-		// generate a WMC for the current client state
-		$currentWmc = new wmc();
-		$currentWmc->createFromJs($params->mapObject, $params->generalTitle, $params->extensionData);
-
-		// get the desired WMC from the database
-		$wmcId = $queryObj->parameters->id;
-		$wmcXml = wmc::getDocument($wmcId);
-
-		// merge the two WMCs
-		$currentWmc->append($wmcXml);
-		
-		// load the merged WMC
-		$jsArray = $currentWmc->toJavaScript();
-
-		if (is_array($jsArray) && count($jsArray) > 0) {
-			$resultObj["javascript"] = $jsArray;
-		}
-		else {
-			$resultObj["error"] = "WMC could not be appended.";
-		}
-	break;
-	
-
-	// Invalid command
-	default:
-		$resultObj["error"] = "no action specified...";
-}
-
-sendOutput($resultObj);
-?>
\ No newline at end of file
+<?php
+require_once(dirname(__FILE__) . "/../php/mb_validateSession.php");
+require_once(dirname(__FILE__) . "/../classes/class_user.php");
+require_once(dirname(__FILE__) . "/../classes/class_wmc.php");
+require_once(dirname(__FILE__) . "/../classes/class_json.php");
+require_once(dirname(__FILE__) . "/../classes/class_administration.php");
+
+/**
+ * encodes and delivers the data
+ * 
+ * @param object the un-encoded object 
+ */
+function sendOutput($out){
+	global $json;
+	$output = $json->encode($out);
+	if (CHARSET == "ISO-8859-1") {
+		$output = utf8_decode($output);
+	}
+	header("Content-Type: text/x-json");
+	echo $output;
+}
+
+/**
+ * Get all available WMC documents from the database
+ * 
+ * @return mixed[] an array of wmcs 
+ * 					(wmc = assoc. array of "id", "title", "timestamp")
+ */
+function getWmc(){
+	global $con;
+	global $userId;
+	
+	$wmcArray = array();
+	
+	// get WMC ids 
+	$currentUser = new User($userId);
+	$wmcIdArray = $currentUser->getWmcByOwner();
+	
+	// get WMC data
+	$v = array();
+	$t = array();
+	$wmcIdList = "";
+
+	for ($i = 0; $i < count($wmcIdArray); $i++) {
+		if ($i > 0) { 
+			$wmcIdList .= ",";
+		}
+		$wmcIdList .= "$".($i+1);
+		array_push($v, $wmcIdArray[$i]);
+		array_push($t, 's');
+	}
+
+	if ($wmcIdList !== "") {
+		$sql = "SELECT DISTINCT wmc_id, wmc_title, wmc_timestamp FROM mb_user_wmc ";
+		$sql .= "WHERE wmc_id IN (" . $wmcIdList . ") ";
+		$sql .=	"ORDER BY wmc_timestamp DESC";
+	
+		$res = db_prep_query($sql, $v, $t);
+		while($row = db_fetch_array($res)){
+			$currentResult = array();
+			$currentResult["id"] = $row["wmc_id"];
+			$currentResult["title"] = administration::convertIncomingString($row["wmc_title"]);
+			$currentResult["timestamp"] = date("M d Y H:i:s", $row["wmc_timestamp"]); 
+			array_push($wmcArray, $currentResult);
+		}
+	}
+	return $wmcArray;
+}
+
+$json = new Mapbender_JSON();
+$queryObj = $json->decode(stripslashes($_REQUEST['queryObj']));
+$resultObj = array();
+
+$e = new mb_exception("command: " . $queryObj->command);
+
+$wmc = new wmc();
+$userId = $_SESSION[mb_user_id];
+
+switch($queryObj->command){
+
+	// gets available WMCs
+	case 'getWmc':
+		$resultObj["wmc"] = getWmc();
+	break;
+
+	// gets XML document of a WMC
+	case 'getWmcDocument':
+		$wmcId = $queryObj->parameters->id;
+		$doc = $wmc->getDocument($wmcId);
+		if (!$doc) {
+			$resultObj["error"] = "The WMC document could not be found.";
+		}
+		else {
+			$resultObj["wmc"] = array("document" => $doc);
+		}
+	break;
+
+	// deletes a WMC
+	case 'deleteWmc':
+		$wmcId = $queryObj->parameters->id;
+		if ($wmc->delete($wmcId)) {
+			$resultObj["success"] = "WMC has been deleted from the database.";
+		}
+		else {
+			$resultObj["error"] = "WMC could not be deleted.";
+		}
+	break;
+	
+	// loads a WMC (returns array of JS code)
+	case 'loadWmc':
+		$wmcId = $queryObj->parameters->id;
+		$wmc->createFromDb($wmcId);
+		$jsArray = $wmc->toJavaScript();
+		if ($jsArray) {
+			$resultObj["javascript"] = $jsArray;
+		}
+		else {
+			$resultObj["error"] = "WMC could not be loaded.";
+		}
+	break;
+
+	// merges data with WMC and loads it (returns array of JS code)
+	case 'mergeWmc':
+		$params = $queryObj->parameters;
+		
+		// generate a WMC for the current client state
+		$currentWmc = new wmc();
+		$currentWmc->createFromJs($params->mapObject, $params->generalTitle, $params->extensionData);
+
+		// get the desired WMC from the database
+		$wmcId = $queryObj->parameters->id;
+		$wmcXml = wmc::getDocument($wmcId);
+
+		// merge the two WMCs
+		$currentWmc->merge($wmcXml);
+		
+		// load the merged WMC
+		$jsArray = $currentWmc->toJavaScript();
+
+		if (is_array($jsArray) && count($jsArray) > 0) {
+			$resultObj["javascript"] = $jsArray;
+		}
+		else {
+			$resultObj["error"] = "WMC could not be loaded.";
+		}
+	break;
+	
+	// appends a WMC (returns JS code)
+	case 'appendWmc':
+		$params = $queryObj->parameters;
+		// generate a WMC for the current client state
+		$currentWmc = new wmc();
+		$currentWmc->createFromJs($params->mapObject, $params->generalTitle, $params->extensionData);
+
+		// get the desired WMC from the database
+		$wmcId = $queryObj->parameters->id;
+		$wmcXml = wmc::getDocument($wmcId);
+
+		// merge the two WMCs
+		$currentWmc->append($wmcXml);
+		
+		// load the merged WMC
+		$jsArray = $currentWmc->toJavaScript();
+
+		if (is_array($jsArray) && count($jsArray) > 0) {
+			$resultObj["javascript"] = $jsArray;
+		}
+		else {
+			$resultObj["error"] = "WMC could not be appended.";
+		}
+	break;
+	
+
+	// Invalid command
+	default:
+		$resultObj["error"] = "no action specified...";
+}
+
+sendOutput($resultObj);
+?>

Modified: branches/print_dev/http/php/mod_meetingPoint.php
===================================================================
--- branches/print_dev/http/php/mod_meetingPoint.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/php/mod_meetingPoint.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,291 +1,350 @@
-<?PHP
-# $Id$
-# http://www.mapbender.org/index.php/MeetingPoint
-# 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>
-<title>meetingPoint</title>
-<?php
-include '../include/dyn_css.php';
-?>
-<script language='JavaScript'>
-<!--
-<?php
-include('../include/dyn_js.php');
-echo "var mod_meetingPoint_target = '" . $_REQUEST["e_target"] . "';";
-echo "var meetingPoint_write_to = 'meetingPoint';";
-?>
-try{
-	if (meetingPoint_export_subject){}
-}
-catch(e){
-	meetingPoint_export_subject = 'Your meeting point. Follow the link!';
-}
-
-try{
-	if (meetingPoint_export_format){}
-}
-catch(e){
-	meetingPoint_export_format = 'prompt';
-}
-
-try{
-	if (meetingPoint_max_characters){}
-}
-catch(e){
-	meetingPoint_max_characters = 100;
-}
-
-try{
-	if (meetingPoint_image){}
-}
-catch(e){
-	meetingPoint_image = "../img/button_digitize/point_off.png";
-}
-
-try{
-	if (meetingPoint_icon){}
-}
-catch(e){
-	meetingPoint_icon = '../img/redball.gif';
-}
-
-try{
-	if (meetingPoint_width){}
-}
-catch(e){
-	meetingPoint_width = 14;
-}
-
-try{
-	if (meetingPoint_height){}
-}
-catch(e){
-	meetingPoint_height = 14;
-}
-
-try{
-	if (meetingPoint_style){}
-}
-catch(e){
-	meetingPoint_style = 'background-color:white;font-weight: bold;color:black;font-family:Arial;';
-}
-
-try{
-	if (meetingPoint_please_click){}
-}
-catch(e){
-	meetingPoint_please_click = 'Please click for the meeting point position!';
-}
-
-parent.mb_registerSubFunctions("window.frames['meetingPoint'].mod_meetingPoint_draw()");
-
-var ie = document.all?1:0;
-var mod_meetingPoint_win = null;
-var mod_meetingPoint_elName = "meetingPoint";
-var mod_meetingPoint_frameName = "meetingPoint";
-
-var mod_meetingPoint_img_on = new Image(); mod_meetingPoint_img_on.src = meetingPoint_image.replace(/_off/,"_on") ;
-var mod_meetingPoint_img_off = new Image(); mod_meetingPoint_img_off.src = meetingPoint_image;
-var mod_meetingPoint_img_over = new Image(); mod_meetingPoint_img_over.src = meetingPoint_image.replace(/_off/,"_over") ;
-var mod_meetingPoint_fix = "";
-
-
-function init_mod_meetingPoint(ind){
-	parent.mb_button[ind] = window.document.getElementById("my_getCoords");
-	parent.mb_button[ind].img_over = mod_meetingPoint_img_over.src;
-	parent.mb_button[ind].img_on = mod_meetingPoint_img_on.src;
-	parent.mb_button[ind].img_off = mod_meetingPoint_img_off.src;
-	parent.mb_button[ind].status = 0;
-	parent.mb_button[ind].elName = "my_getCoords";
-	parent.mb_button[ind].go = new Function ("mod_meetingPoint_run()");
-	parent.mb_button[ind].stop = new Function ("mod_meetingPoint_disable()");
-}
-
-function mod_meetingPoint_run(){   
-	parent.frames[mod_meetingPoint_target].document.onclick = mod_meetingPoint_click;
-}
-
-function mod_meetingPoint_disable(){
-	parent.frames[mod_meetingPoint_target].document.onclick = null;
-}
-
-function mod_meetingPoint_click(e){
-	if(ie){
-		clickX = parent.frames[mod_meetingPoint_target].event.clientX;
-		clickY = parent.frames[mod_meetingPoint_target].event.clientY;
-	}
-	else{
-		clickX = e.pageX;
-		clickY = e.pageY;
-	}
-	
-	var pos = parent.makeClickPos2RealWorldPos(mod_meetingPoint_target, clickX, clickY);
-    
-	mod_meetingPoint_write(pos[0],pos[1]);
-	mod_meetingPoint_draw();	
-}
-
-function mod_meetingPoint_write(x,y){	
-   document.forms[0].x.value =x;
-   document.forms[0].y.value =y;	   
-}
-
-function mod_meetingPoint_hide(){
-	var ind = parent.getMapObjIndexByName(mod_meetingPoint_target);
-	parent.frames[mod_meetingPoint_target].document.getElementById('permanent').style.visibility = 'hidden';
-}
-
-function mod_meetingPoint_draw(){
-	var ind = parent.getMapObjIndexByName(mod_meetingPoint_target);
-	if (document.forms[0].x.value!='' && document.forms[0].y.value != ''){
-		//alert(document.forms[0].x.value +" -- "+ document.forms[0].y.value + " - " + parent.mb_mapObj[ind].width +" iii: "+ ind);
-		parent.frames[mod_meetingPoint_target].document.getElementById('permanent').style.width = parent.mb_mapObj[ind].width;
-		parent.frames[mod_meetingPoint_target].document.getElementById('permanent').style.height = parent.mb_mapObj[ind].height;
-		parent.frames[mod_meetingPoint_target].document.getElementById('permanent').style.top = 0;
-		parent.frames[mod_meetingPoint_target].document.getElementById('permanent').style.left = 0;
-		parent.frames[mod_meetingPoint_target].document.getElementById('permanent').style.visibility = 'visible';
-		var tagSource = "";
-		var pos = parent.makeRealWorld2mapPos(mod_meetingPoint_target,document.forms[0].x.value, document.forms[0].y.value);
-		tagSource += "<div style='z-index:13;position:absolute;left:"+(pos[0]- Math.round(0.5*meetingPoint_width))+"px;top:"+(pos[1]-Math.round(0.5*meetingPoint_height))+"px'>";
-		tagSource += "<img src='"+meetingPoint_icon+"'>";
-		tagSource += "<span style='"+meetingPoint_style+"'>"+document.forms[0].mytext.value+"<span>";
-		tagSource += "</div>";
-		//prompt("meetingPoint",tagSource);
-	    parent.writeTag(mod_meetingPoint_target, "permanent", tagSource);
-	}	 
-}
--->
-</script>
-
-<script language='JavaScript'>
-<!--
-<?php
-echo "var used_charset = '".CHARSET ."';";
-?>
-
-function validate(){
-	var mycheck = true;
-	var checkObj= document.forms[0].mytext.value;
-	if(checkObj == '') {
-    	alert ("Bitte geben Sie einen Text an!");
-    	checkObj.focus();
-        mycheck=false;
-    }
-    
-    var checkObj= document.forms[0].x.value;
-    if(checkObj == '') {
-    	alert (meetingPoint_please_click);
-        mycheck = false;
-    }
-
-    if(mycheck == true){
-    	my_meetingPoint = document.forms[0].myurl.value + "?";
-    	my_meetingPoint += "name=" + encodeURIComponent(document.forms[0].myuser.value);
-    	my_meetingPoint += "&password=" + encodeURIComponent(document.forms[0].mypw.value);
-    	my_meetingPoint += "&mb_user_myGui=" + encodeURIComponent(document.forms[0].mygui.value);
-    	
-    	var ind = parent.getMapObjIndexByName('mapframe1');
-    	var coord = parent.mb_mapObj[ind].extent.split(",");
-    	
-    	my_meetingPoint += "&mb_myBBOX=" + parseFloat(coord[0]) + ",";
-		my_meetingPoint +=  parseFloat(coord[1]) + ",";
-		my_meetingPoint +=  parseFloat(coord[2]) + ",";
-		my_meetingPoint +=  parseFloat(coord[3]) ;
-
-    	my_meetingPoint += "&mb_myPOI=";
-    	
-    	var splitext  = document.forms[0].mytext.value;
-    	document.forms[0].mytext.value = splitext.substring(0, meetingPoint_max_characters);
-    	
-
-    	my_meetingPoint += encodeURIComponent(document.forms[0].mytext.value);
-
-    	
-    	my_meetingPoint += "|" + document.forms[0].x.value + "|";
-    	my_meetingPoint += document.forms[0].y.value;
-
-    	if(meetingPoint_export_format == 'email'){
-    		createEmail(my_meetingPoint,meetingPoint_export_subject);
-		}else{			
-			prompt(meetingPoint_export_subject,my_meetingPoint);			
-		}
-    }
-}
-
-function emptyfields(){
-	document.forms[0].mytext.value ='';
-	document.forms[0].x.value ='';
-	document.forms[0].y.value =  '';
-	 mod_meetingPoint_hide();
-}
-
-function createEmail (url,subject) {
-  var email = "mailto:"
-  email  += "";
-  email  += "?subject=";
-  email  += subject;
-  email  += "&body=";
-  email  += escape(url);
-
-  var win = window.open(email, 'email', 'top=120,left=120');
-  win.close();
-}
-
-function goBack(where){
-    document.location.href=where;
-}
-
-function init(){
-	parent.mb_regButton_frame("init_mod_meetingPoint","meetingPoint",null);
-}
-
--->
-</script>
-
-</head>
-<body>
-
-<form action="" >
-
-<img  id='my_getCoords' name='my_getCoords' onclick="mod_meetingPoint_run()" onmouseover ="parent.mb_regButton_frame('init_mod_meetingPoint','meetingPoint',null)"  title="Treffpunkt setzen"  src = '../img/button_digitize/point_off.png'>
-<br>
-<input class='strinput' type="hidden" name='myurl' value='<?php  echo LOGIN;  ?>'>
-
-<input class='strinput' type="hidden" name='mygui' value='<?php  echo $_SESSION["mb_user_gui"];  ?>'>
-
-<input class='strinput' type="hidden" name='myuser' value='<?php  echo $_SESSION["mb_user_name"];  ?>'>
-
-<input class='strinput' type="hidden" name='mypw' value='<?php  echo $_SESSION["mb_user_password"];  ?>'>
-<br>
-<!--<input class='strinput' type="textarea" size=2 name='mytext' value='' "maxlength=70" title="max. 70 Zeichen">-->
-<textarea class='strinput' rows="3" name='mytext' title='maximal 70 Zeichen'></textarea>
-<br>
-<input class="okbutton" name="Send"   type="button" value="ok" onclick="validate();">
-<input class="ibutton" type="button" value="cancel" onClick="emptyfields();">
-<br>
-<input class="coord" type="hidden" name='x' value='' readonly>
-<input class="coord" type="hidden" name='y' value='' readonly>
-<br>
-</form>
-</body>
+<?PHP
+# $Id$
+# http://www.mapbender.org/index.php/MeetingPoint
+# 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>
+<title>meetingPoint</title>
+<?php
+include '../include/dyn_css.php';
+?>
+<script language='JavaScript'>
+<!--
+<?php
+include('../include/dyn_js.php');
+echo "var mod_meetingPoint_target = '" . $_REQUEST["e_target"] . "';";
+echo "var meetingPoint_write_to = 'meetingPoint';";
+?>
+try{
+	if (meetingPoint_export_subject){}
+}
+catch(e){
+	meetingPoint_export_subject = 'Your meeting point. Follow the link!';
+}
+
+try{
+	if (meetingPoint_export_format){}
+}
+catch(e){
+	meetingPoint_export_format = 'prompt';
+}
+
+try{
+	if (meetingPoint_max_characters){}
+}
+catch(e){
+	meetingPoint_max_characters = 100;
+}
+
+try{
+	if (meetingPoint_image){}
+}
+catch(e){
+	meetingPoint_image = "../img/button_digitize/point_off.png";
+}
+
+try{
+	if (meetingPoint_icon){}
+}
+catch(e){
+	meetingPoint_icon = '../img/redball.gif';
+}
+
+try{
+	if (meetingPoint_width){}
+}
+catch(e){
+	meetingPoint_width = 14;
+}
+
+try{
+	if (meetingPoint_height){}
+}
+catch(e){
+	meetingPoint_height = 14;
+}
+
+try{
+	if (meetingPoint_style){}
+}
+catch(e){
+	meetingPoint_style = 'background-color:white;font-weight: bold;color:black;font-family:Arial;';
+}
+
+try{
+	if (meetingPoint_please_click){}
+}
+catch(e){
+	meetingPoint_please_click = 'Please click for the meeting point position!';
+}
+
+var mod_meetingPointRealPoint = null;
+//parent.mb_registerSubFunctions("window.frames['meetingPoint'].mod_meetingPoint_draw()");
+
+parent.eventAfterMapRequest.register(function () {
+	mod_meetingPoint_draw();
+});
+
+var ie = document.all?1:0;
+var mod_meetingPoint_win = null;
+var mod_meetingPoint_elName = "meetingPoint";
+var mod_meetingPoint_frameName = "meetingPoint";
+var mod_meetingPoint_button = "my_getCoords";
+var mod_meetingPoint_img_on = new Image(); mod_meetingPoint_img_on.src = meetingPoint_image.replace(/_off/,"_on") ;
+var mod_meetingPoint_img_off = new Image(); mod_meetingPoint_img_off.src = meetingPoint_image;
+var mod_meetingPoint_img_over = new Image(); mod_meetingPoint_img_over.src = meetingPoint_image.replace(/_off/,"_over") ;
+var mod_meetingPoint_fix = "";
+
+
+function init_mod_meetingPoint(ind){
+	parent.mb_button[ind] = window.document.getElementById(mod_meetingPoint_button);
+	parent.mb_button[ind].img_over = mod_meetingPoint_img_over.src;
+	parent.mb_button[ind].img_on = mod_meetingPoint_img_on.src;
+	parent.mb_button[ind].img_off = mod_meetingPoint_img_off.src;
+	parent.mb_button[ind].status = 0;
+	parent.mb_button[ind].elName = mod_meetingPoint_button;
+	parent.mb_button[ind].go = new Function ("mod_meetingPoint_run()");
+	parent.mb_button[ind].stop = new Function ("mod_meetingPoint_disable()");
+}
+
+function mod_meetingPoint_run(){   
+	var mapObject = parent.getMapObjByName(mod_meetingPoint_target);
+	if (mapObject) {
+		mapObject.getDomElement().ownerDocument.onclick = function (e) {
+			var clickPos = mapObject.getMousePosition(e);
+			mod_meetingPointRealPoint = mapObject.convertPixelToReal(clickPos);
+			mod_meetingPoint_write(mod_meetingPointRealPoint.x, mod_meetingPointRealPoint.y);
+			mod_meetingPoint_draw();	
+			parent.mb_disableThisButton(mod_meetingPoint_button);
+		};
+	}
+}
+
+function mod_meetingPoint_disable(){
+	var mapObject = parent.getMapObjByName(mod_meetingPoint_target);
+	if (mapObject) {
+		mapObject.getDomElement().ownerDocument.onclick = null;
+	}
+}
+/*
+function mod_meetingPoint_click(e){
+	
+
+	if(ie){
+		clickX = parent.frames[mod_meetingPoint_target].event.clientX;
+		clickY = parent.frames[mod_meetingPoint_target].event.clientY;
+	}
+	else{
+		clickX = e.pageX;
+		clickY = e.pageY;
+	}
+	
+	var pos = parent.makeClickPos2RealWorldPos(mod_meetingPoint_target, clickX, clickY);
+    
+	mod_meetingPoint_write(pos[0],pos[1]);
+	mod_meetingPoint_draw();	
+}
+*/
+function mod_meetingPoint_write(x,y){	
+   document.forms[0].x.value =x;
+   document.forms[0].y.value =y;	   
+}
+
+function mod_meetingPoint_hide(){
+	//var ind = parent.getMapObjIndexByName(mod_meetingPoint_target);
+	//parent.frames[mod_meetingPoint_target].document.getElementById('permanent').style.visibility = 'hidden';
+	var mapObject = parent.getMapObjByName(mod_meetingPoint_target);
+	parent.$("#" + mapObject.elementName + "_permanent").css({
+		visibility:"hidden"
+	});
+}
+
+
+function mod_meetingPoint_draw(){
+	var mapObject = parent.getMapObjByName(mod_meetingPoint_target);
+	if (mapObject) {
+		if (mod_meetingPointRealPoint !== null) {
+			//alert(document.forms[0].x.value +" -- "+ document.forms[0].y.value + " - " );
+	
+			var meetingPointClickPos = mapObject.convertRealToPixel(mod_meetingPointRealPoint);
+			var tagSource = "";
+			tagSource += "<div style='z-index:13;position:absolute;left:"+(meetingPointClickPos.x- Math.round(0.5*meetingPoint_width))+"px;top:"+(meetingPointClickPos.y-Math.round(0.5*meetingPoint_height))+"px'>";
+			tagSource += "<img src='"+meetingPoint_icon+"'>";
+			tagSource += "<span style='"+meetingPoint_style+"'>"+document.forms[0].mytext.value+"<span>";
+			tagSource += "</div>";
+
+			var map_el = mapObject.getDomElement();
+			if (!map_el.ownerDocument.getElementById(mapObject.elementName + "_permanent")) {
+				//create Box Elements
+
+				var $div = parent.$("<div id='" + mapObject.elementName + "_permanent'><img src='../img/redball.gif'/></div>");
+				$div.css({
+					position: "absolute",
+					top: "0px",
+					left: "0px",
+					zIndex: 13
+				});
+				map_el.appendChild($div.get(0));
+			}
+			parent.$("#" + mapObject.elementName + "_permanent").html(tagSource);
+			
+		}
+	}
+}
+
+/*
+function mod_meetingPoint_draw(){
+	var ind = parent.getMapObjIndexByName(mod_meetingPoint_target);
+	if (document.forms[0].x.value!='' && document.forms[0].y.value != ''){
+		//alert(document.forms[0].x.value +" -- "+ document.forms[0].y.value + " - " + parent.mb_mapObj[ind].width +" iii: "+ ind);
+		parent.frames[mod_meetingPoint_target].document.getElementById('permanent').style.width = parent.mb_mapObj[ind].width;
+		parent.frames[mod_meetingPoint_target].document.getElementById('permanent').style.height = parent.mb_mapObj[ind].height;
+		parent.frames[mod_meetingPoint_target].document.getElementById('permanent').style.top = 0;
+		parent.frames[mod_meetingPoint_target].document.getElementById('permanent').style.left = 0;
+		parent.frames[mod_meetingPoint_target].document.getElementById('permanent').style.visibility = 'visible';
+		var tagSource = "";
+		var pos = parent.makeRealWorld2mapPos(mod_meetingPoint_target,document.forms[0].x.value, document.forms[0].y.value);
+		tagSource += "<div style='z-index:13;position:absolute;left:"+(pos[0]- Math.round(0.5*meetingPoint_width))+"px;top:"+(pos[1]-Math.round(0.5*meetingPoint_height))+"px'>";
+		tagSource += "<img src='"+meetingPoint_icon+"'>";
+		tagSource += "<span style='"+meetingPoint_style+"'>"+document.forms[0].mytext.value+"<span>";
+		tagSource += "</div>";
+		//prompt("meetingPoint",tagSource);
+	    parent.writeTag(mod_meetingPoint_target, "permanent", tagSource);
+	}	 
+}
+
+*/
+-->
+</script>
+
+<script language='JavaScript'>
+<!--
+<?php
+echo "var used_charset = '".CHARSET ."';";
+?>
+
+function validate(){
+	var mycheck = true;
+	var checkObj= document.forms[0].mytext.value;
+	if(checkObj == '') {
+    	alert ("Bitte geben Sie einen Text an!");
+    	checkObj.focus();
+        mycheck=false;
+    }
+    
+    var checkObj= document.forms[0].x.value;
+    if(checkObj == '') {
+    	alert (meetingPoint_please_click);
+        mycheck = false;
+    }
+
+    if(mycheck == true){
+    	my_meetingPoint = document.forms[0].myurl.value + "?";
+    	my_meetingPoint += "name=" + encodeURIComponent(document.forms[0].myuser.value);
+    	my_meetingPoint += "&password=" + encodeURIComponent(document.forms[0].mypw.value);
+    	my_meetingPoint += "&mb_user_myGui=" + encodeURIComponent(document.forms[0].mygui.value);
+    	
+    	var ind = parent.getMapObjIndexByName('mapframe1');
+    	var coord = parent.mb_mapObj[ind].extent.split(",");
+    	
+    	my_meetingPoint += "&mb_myBBOX=" + parseFloat(coord[0]) + ",";
+		my_meetingPoint +=  parseFloat(coord[1]) + ",";
+		my_meetingPoint +=  parseFloat(coord[2]) + ",";
+		my_meetingPoint +=  parseFloat(coord[3]) ;
+
+    	my_meetingPoint += "&mb_myPOI=";
+    	
+    	var splitext  = document.forms[0].mytext.value;
+    	document.forms[0].mytext.value = splitext.substring(0, meetingPoint_max_characters);
+    	
+
+    	my_meetingPoint += encodeURIComponent(document.forms[0].mytext.value);
+
+    	
+    	my_meetingPoint += "|" + document.forms[0].x.value + "|";
+    	my_meetingPoint += document.forms[0].y.value;
+
+    	if(meetingPoint_export_format == 'email'){
+    		createEmail(my_meetingPoint,meetingPoint_export_subject);
+		}else{			
+			prompt(meetingPoint_export_subject,my_meetingPoint);			
+		}
+    }
+}
+
+function emptyfields(){
+	document.forms[0].mytext.value ='';
+	document.forms[0].x.value ='';
+	document.forms[0].y.value =  '';
+	 mod_meetingPoint_hide();
+}
+
+function createEmail (url,subject) {
+  var email = "mailto:"
+  email  += "";
+  email  += "?subject=";
+  email  += subject;
+  email  += "&body=";
+  email  += escape(url);
+
+  var win = window.open(email, 'email', 'top=120,left=120');
+  win.close();
+}
+
+function goBack(where){
+    document.location.href=where;
+}
+
+function init(){
+	parent.mb_regButton_frame("init_mod_meetingPoint","meetingPoint",null);
+}
+
+-->
+</script>
+
+</head>
+<body>
+
+<form action="" >
+
+<img  id='my_getCoords' name='my_getCoords' onclick="mod_meetingPoint_run()" onmouseover ="parent.mb_regButton_frame('init_mod_meetingPoint','meetingPoint',null)"  title="Treffpunkt setzen"  src = '../img/button_digitize/point_off.png'>
+<br>
+<input class='strinput' type="hidden" name='myurl' value='<?php  echo LOGIN;  ?>'>
+
+<input class='strinput' type="hidden" name='mygui' value='<?php  echo $_SESSION["mb_user_gui"];  ?>'>
+
+<input class='strinput' type="hidden" name='myuser' value='<?php  echo $_SESSION["mb_user_name"];  ?>'>
+
+<input class='strinput' type="hidden" name='mypw' value='<?php  echo $_SESSION["mb_user_password"];  ?>'>
+<br>
+<!--<input class='strinput' type="textarea" size=2 name='mytext' value='' "maxlength=70" title="max. 70 Zeichen">-->
+<textarea class='strinput' rows="3" name='mytext' title='maximal 70 Zeichen'></textarea>
+<br>
+<input class="okbutton" name="Send"   type="button" value="ok" onclick="validate();">
+<input class="ibutton" type="button" value="cancel" onClick="emptyfields();">
+<br>
+<input class="coord" type="hidden" name='x' value='' readonly>
+<input class="coord" type="hidden" name='y' value='' readonly>
+<br>
+</form>
+</body>
 </html>
\ No newline at end of file

Modified: branches/print_dev/http/php/mod_savewmc_server.php
===================================================================
--- branches/print_dev/http/php/mod_savewmc_server.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/php/mod_savewmc_server.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -27,7 +27,7 @@
 // get data from POST and SESSION
 $mapObject = $json->decode(stripslashes($_POST["mapObject"]));
 $userId = $_SESSION["mb_user_id"];
-$saveInSession = $_POST["saveInSession"];
+$saveInSession = intval($_POST["saveInSession"]);
 $generalTitle = $_POST["generalTitle"];
 $extensionData = $json->decode(stripslashes($_POST["extensionData"]));
 
@@ -35,6 +35,8 @@
 $wmc = new wmc();
 $wmc->createFromJs($mapObject, $generalTitle, $extensionData);
 
+header("Content-Type: text/x-json");
+
 if ($saveInSession === 1) {
 	// store XML in session
 	$_SESSION["mb_wmc"] = $wmc->xml;
@@ -47,4 +49,4 @@
 	$result = $wmc->insert();
 	echo $result["message"];
 }
-?>
\ No newline at end of file
+?>

Modified: branches/print_dev/http/php/mod_wfs.php
===================================================================
--- branches/print_dev/http/php/mod_wfs.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/php/mod_wfs.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,180 +1,180 @@
-<?php
-# $Id$
-# 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="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
-<title>mod_wfs</title>
-<script language='JavaScript' type='text/javascript'>
-var wfs_conf = new Array();
-/*
-function register(){
-	var isReg = false;
-	for(var i=0; i<parent.mb_InitFunctions.length; i++){
-		if(parent.mb_InitFunctions[i] == (window.name+".fetchInf()")){
-			isReg = true;
-		}
-	}
-	if(isReg == false){
-		parent.mb_registerInitFunctions(window.name+".fetchInf()");
-	}
-}
-*/
-function register() {
-	var functionStatement = window.name+".fetchInf()";
-	
-	if(!parent.eventInit.isRegistered(functionStatement)){
-		parent.mb_registerInitFunctions(functionStatement);
-	}
-}
-function fetchInf(){
-	var wfs = new Array();
-	var l;
-	var ind = parent.getMapObjIndexByName('mapframe1');
-	for(var i=0; i<parent.mb_mapObj[ind].wms.length; i++){
-		for(var j=0; j<parent.mb_mapObj[ind].wms[i].objLayer.length; j++){
-			l = parent.mb_mapObj[ind].wms[i].objLayer[j];			
-			if(l.gui_layer_wfs_featuretype != ""){
-				wfs[wfs.length] = l.gui_layer_wfs_featuretype; 
-			}
-		}	
-	}	
-	document.location.href = "../php/mod_wfs.php?id=" + wfs.join(",");
-}
-function get_wfs_conf(){
-	return wfs_conf;
-}
-var iamready = false;
-</script>
-<?php
-echo "<script language='JavaScript' type='text/javascript'>";
-if(isset($_REQUEST['id']) && $_REQUEST['id']!=""){
-	$wfs = mb_split(",",$_REQUEST['id']);
-	
-	$con = db_connect($DBSERVER,$OWNER,$PW);
-	db_select_db($DB,$con);
-	
-	for($i=0; $i<count($wfs); $i++){	
-		
-		/* wfs_conf */
-		$sql = "SELECT * FROM wfs_conf ";
-		$sql .= "JOIN wfs ON wfs_conf.fkey_wfs_id = wfs.wfs_id ";
-		$sql .= "WHERE wfs_conf.wfs_conf_id = $1";
-		
-		$v = array($wfs[$i]);
-		$t = array('i');
-		$res = db_prep_query($sql,$v,$t);
-	
-		if($row = db_fetch_array($res)){
-			$wfs_id  = $row["fkey_wfs_id"];
-			$featuretype_id  = $row["fkey_featuretype_id"];
-			echo "var len = wfs_conf.length;";
-			echo "wfs_conf[".$i."] = new Array();";
-			echo "wfs_conf[".$i."]['wfs_conf_id']  = '".$row["wfs_conf_id"]."';";
-			echo "wfs_conf[".$i."]['wfs_conf_abstract']  = '".$row["wfs_conf_abstract"]."';";
-			echo "wfs_conf[".$i."]['g_label']  = '".$row["g_label"]."';";
-			echo "wfs_conf[".$i."]['g_label_id']  = '".$row["g_label_id"]."';";
-			echo "wfs_conf[".$i."]['g_style']  = \"".preg_replace("/\n/", "", preg_replace("/\r/", "", $row["g_style"]))."\";";
-			echo "wfs_conf[".$i."]['g_button']  = '".$row["g_button"]."';";
-			echo "wfs_conf[".$i."]['g_button_id']  = '".$row["g_button_id"]."';";
-			echo "wfs_conf[".$i."]['g_buffer']  = '".$row["g_buffer"]."';";
-			echo "wfs_conf[".$i."]['g_res_style']  = \"".preg_replace("/\n/", "", preg_replace("/\r/", "", $row["g_res_style"]))."\";";
-			echo "wfs_conf[".$i."]['g_use_wzgraphics']  = '".$row["g_use_wzgraphics"]."';";
-			echo "wfs_conf[".$i."]['fkey_featuretype_id']  = '".$row["fkey_featuretype_id"]."';";
-			echo "wfs_conf[".$i."]['wfs_getfeature']  = '".$row["wfs_getfeature"]."';";
-			echo "wfs_conf[".$i."]['wfs_describefeaturetype']  = '".$row["wfs_describefeaturetype"]."';";
-			echo "wfs_conf[".$i."]['wfs_transaction']  = '".$row["wfs_transaction"]."';";
-			#wfs_describefeaturetype - wfs_describefeaturetype
-			
-		}else{die("wfs_conf data not available");}
-		
-		$sql = "SELECT * FROM wfs_featuretype_namespace";
-		$sql .= " WHERE fkey_wfs_id = $1 AND fkey_featuretype_id = $2";
-		$v = array($wfs_id,$featuretype_id);
-		$t = array('i','i');
-		$res = db_prep_query($sql,$v,$t);
-		echo "wfs_conf[".$i."]['namespaces'] = new Array();";
-		$counter = 0;
-		while($row = db_fetch_array($res)){
-			echo "wfs_conf[".$i."]['namespaces'][".$counter."] = new Array();";
-			echo "wfs_conf[".$i."]['namespaces'][".$counter."]['name']  = '".$row["namespace"]."';";
-			echo "wfs_conf[".$i."]['namespaces'][".$counter."]['location']  = '".$row["namespace_location"]."';";
-			$counter++;
-		}
-		
-		
-		$sql = "SELECT * FROM wfs_featuretype ";
-		$sql .= "WHERE fkey_wfs_id = $1 AND featuretype_id = $2";
-		$v = array($wfs_id,$featuretype_id);
-		$t = array('i','i');
-		$res = db_prep_query($sql,$v,$t);
-		if($row = db_fetch_array($res)){
-			echo "wfs_conf[".$i."]['featuretype_name']  = '".$row["featuretype_name"]."';";
-			echo "wfs_conf[".$i."]['featuretype_srs']  = '".$row["featuretype_srs"]."';";
-		}else{die("wfs_featuretype data not available");}
-		
-		/* wfs_conf_element */
-		$sql = "SELECT * FROM wfs_conf_element ";
-		$sql .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
-		$sql .= "WHERE wfs_conf_element.fkey_wfs_conf_id = $1";
-		$sql .= " ORDER BY wfs_conf_element.f_respos";
-		#$sql .= "AND wfs_conf_element.f_search = 1 ORDER BY wfs_conf_element.f_search;";
-				
-		$v = array($wfs[$i]);
-		$t = array('i');
-		$res = db_prep_query($sql,$v,$t);
-		
-		echo "wfs_conf[".$i."]['element']  = new Array();";
-		$cnt = 0;
-		
-		while($row = db_fetch_array($res)){
-			echo "wfs_conf[".$i."]['element'][".$cnt."] = new Array();";
-			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_search'] = ".$row["f_search"].";";
-			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_style_id'] = '".$row["f_style_id"]."';";
-			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_toupper'] = '".$row["f_toupper"]."';";
-			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_label'] = '".htmlentities($row["f_label"], ENT_QUOTES)."';";
-			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_label_id'] = '".$row["f_label_id"]."';";
-			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_show'] = '".$row["f_show"]."';";
-			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_show_detail'] = '".$row["f_show_detail"]."';";
-			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_respos'] = '".$row["f_respos"]."';";
-			echo "wfs_conf[".$i."]['element'][".$cnt."]['element_name'] = '".htmlentities($row["element_name"], ENT_QUOTES)."';";
-			echo "wfs_conf[".$i."]['element'][".$cnt."]['element_type'] = '".htmlentities($row["element_type"], ENT_QUOTES)."';";
-			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_geom'] = '".$row["f_geom"]."';";
-			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_gid'] = '".$row["f_gid"]."';";
-			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_form_element_html'] = \"".(preg_replace("/\n/", "", preg_replace("/\r/", "", $row["f_form_element_html"])))."\";";
-//			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_form_element_html'] = \"\";";
-			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_edit'] = '".$row["f_edit"]."';";
-			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_mandatory'] = '".$row["f_mandatory"]."';";
-			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_auth_varname'] = '".htmlentities($row["f_auth_varname"], ENT_QUOTES)."';";
-			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_operator'] = '".$row["f_operator"]."';";
-			$cnt++;
-		}
-		if($cnt == 0){die("wfs_conf data not available");}		
-	}
-	echo "iamready = true;";
-}
-?>
-</script>
-</head>
-<body leftmargin='0' topmargin='10'  bgcolor='#ffffff' onload='register()'>
-</body>
-</html>
+<?php
+# $Id$
+# 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="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
+<title>mod_wfs</title>
+<script language='JavaScript' type='text/javascript'>
+var wfs_conf = new Array();
+/*
+function register(){
+	var isReg = false;
+	for(var i=0; i<parent.mb_InitFunctions.length; i++){
+		if(parent.mb_InitFunctions[i] == (window.name+".fetchInf()")){
+			isReg = true;
+		}
+	}
+	if(isReg == false){
+		parent.mb_registerInitFunctions(window.name+".fetchInf()");
+	}
+}
+*/
+function register() {
+	var functionStatement = window.name+".fetchInf()";
+	
+	if(!parent.eventInit.isRegistered(functionStatement)){
+		parent.mb_registerInitFunctions(functionStatement);
+	}
+}
+function fetchInf(){
+	var wfs = new Array();
+	var l;
+	var ind = parent.getMapObjIndexByName('mapframe1');
+	for(var i=0; i<parent.mb_mapObj[ind].wms.length; i++){
+		for(var j=0; j<parent.mb_mapObj[ind].wms[i].objLayer.length; j++){
+			l = parent.mb_mapObj[ind].wms[i].objLayer[j];			
+			if(l.gui_layer_wfs_featuretype != ""){
+				wfs[wfs.length] = l.gui_layer_wfs_featuretype; 
+			}
+		}	
+	}	
+	document.location.href = "../php/mod_wfs.php?id=" + wfs.join(",");
+}
+function get_wfs_conf(){
+	return wfs_conf;
+}
+var iamready = false;
+</script>
+<?php
+echo "<script language='JavaScript' type='text/javascript'>";
+if(isset($_REQUEST['id']) && $_REQUEST['id']!=""){
+	$wfs = mb_split(",",$_REQUEST['id']);
+	
+	$con = db_connect($DBSERVER,$OWNER,$PW);
+	db_select_db($DB,$con);
+	
+	for($i=0; $i<count($wfs); $i++){	
+		
+		/* wfs_conf */
+		$sql = "SELECT * FROM wfs_conf ";
+		$sql .= "JOIN wfs ON wfs_conf.fkey_wfs_id = wfs.wfs_id ";
+		$sql .= "WHERE wfs_conf.wfs_conf_id = $1";
+		
+		$v = array($wfs[$i]);
+		$t = array('i');
+		$res = db_prep_query($sql,$v,$t);
+	
+		if($row = db_fetch_array($res)){
+			$wfs_id  = $row["fkey_wfs_id"];
+			$featuretype_id  = $row["fkey_featuretype_id"];
+			echo "var len = wfs_conf.length;";
+			echo "wfs_conf[".$i."] = new Array();";
+			echo "wfs_conf[".$i."]['wfs_conf_id']  = '".$row["wfs_conf_id"]."';";
+			echo "wfs_conf[".$i."]['wfs_conf_abstract']  = '".$row["wfs_conf_abstract"]."';";
+			echo "wfs_conf[".$i."]['g_label']  = '".$row["g_label"]."';";
+			echo "wfs_conf[".$i."]['g_label_id']  = '".$row["g_label_id"]."';";
+			echo "wfs_conf[".$i."]['g_style']  = \"".preg_replace("/\n/", "", preg_replace("/\r/", "", $row["g_style"]))."\";";
+			echo "wfs_conf[".$i."]['g_button']  = '".$row["g_button"]."';";
+			echo "wfs_conf[".$i."]['g_button_id']  = '".$row["g_button_id"]."';";
+			echo "wfs_conf[".$i."]['g_buffer']  = '".$row["g_buffer"]."';";
+			echo "wfs_conf[".$i."]['g_res_style']  = \"".preg_replace("/\n/", "", preg_replace("/\r/", "", $row["g_res_style"]))."\";";
+			echo "wfs_conf[".$i."]['g_use_wzgraphics']  = '".$row["g_use_wzgraphics"]."';";
+			echo "wfs_conf[".$i."]['fkey_featuretype_id']  = '".$row["fkey_featuretype_id"]."';";
+			echo "wfs_conf[".$i."]['wfs_getfeature']  = '".$row["wfs_getfeature"]."';";
+			echo "wfs_conf[".$i."]['wfs_describefeaturetype']  = '".$row["wfs_describefeaturetype"]."';";
+			echo "wfs_conf[".$i."]['wfs_transaction']  = '".$row["wfs_transaction"]."';";
+			#wfs_describefeaturetype - wfs_describefeaturetype
+			
+		}else{die("wfs_conf data not available");}
+		
+		$sql = "SELECT * FROM wfs_featuretype_namespace";
+		$sql .= " WHERE fkey_wfs_id = $1 AND fkey_featuretype_id = $2";
+		$v = array($wfs_id,$featuretype_id);
+		$t = array('i','i');
+		$res = db_prep_query($sql,$v,$t);
+		echo "wfs_conf[".$i."]['namespaces'] = new Array();";
+		$counter = 0;
+		while($row = db_fetch_array($res)){
+			echo "wfs_conf[".$i."]['namespaces'][".$counter."] = new Array();";
+			echo "wfs_conf[".$i."]['namespaces'][".$counter."]['name']  = '".$row["namespace"]."';";
+			echo "wfs_conf[".$i."]['namespaces'][".$counter."]['location']  = '".$row["namespace_location"]."';";
+			$counter++;
+		}
+		
+		
+		$sql = "SELECT * FROM wfs_featuretype ";
+		$sql .= "WHERE fkey_wfs_id = $1 AND featuretype_id = $2";
+		$v = array($wfs_id,$featuretype_id);
+		$t = array('i','i');
+		$res = db_prep_query($sql,$v,$t);
+		if($row = db_fetch_array($res)){
+			echo "wfs_conf[".$i."]['featuretype_name']  = '".$row["featuretype_name"]."';";
+			echo "wfs_conf[".$i."]['featuretype_srs']  = '".$row["featuretype_srs"]."';";
+		}else{die("wfs_featuretype data not available");}
+		
+		/* wfs_conf_element */
+		$sql = "SELECT * FROM wfs_conf_element ";
+		$sql .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
+		$sql .= "WHERE wfs_conf_element.fkey_wfs_conf_id = $1";
+		$sql .= " ORDER BY wfs_conf_element.f_respos";
+		#$sql .= "AND wfs_conf_element.f_search = 1 ORDER BY wfs_conf_element.f_search;";
+				
+		$v = array($wfs[$i]);
+		$t = array('i');
+		$res = db_prep_query($sql,$v,$t);
+		
+		echo "wfs_conf[".$i."]['element']  = new Array();";
+		$cnt = 0;
+		
+		while($row = db_fetch_array($res)){
+			echo "wfs_conf[".$i."]['element'][".$cnt."] = new Array();";
+			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_search'] = ".$row["f_search"].";";
+			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_style_id'] = '".$row["f_style_id"]."';";
+			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_toupper'] = '".$row["f_toupper"]."';";
+			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_label'] = '".htmlentities($row["f_label"], ENT_QUOTES, "UTF-8")."';";
+			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_label_id'] = '".$row["f_label_id"]."';";
+			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_show'] = '".$row["f_show"]."';";
+			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_show_detail'] = '".$row["f_show_detail"]."';";
+			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_respos'] = '".$row["f_respos"]."';";
+			echo "wfs_conf[".$i."]['element'][".$cnt."]['element_name'] = '".htmlentities($row["element_name"], ENT_QUOTES, "UTF-8")."';";
+			echo "wfs_conf[".$i."]['element'][".$cnt."]['element_type'] = '".htmlentities($row["element_type"], ENT_QUOTES, "UTF-8")."';";
+			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_geom'] = '".$row["f_geom"]."';";
+			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_gid'] = '".$row["f_gid"]."';";
+			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_form_element_html'] = \"".(preg_replace("/\n/", "", preg_replace("/\r/", "", htmlentities($row["f_form_element_html"], ENT_QUOTES, "UTF-8"))))."\";";
+//			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_form_element_html'] = \"\";";
+			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_edit'] = '".$row["f_edit"]."';";
+			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_mandatory'] = '".$row["f_mandatory"]."';";
+			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_auth_varname'] = '".htmlentities($row["f_auth_varname"], ENT_QUOTES, "UTF-8")."';";
+			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_operator'] = '".$row["f_operator"]."';";
+			$cnt++;
+		}
+		if($cnt == 0){die("wfs_conf data not available");}		
+	}
+	echo "iamready = true;";
+}
+?>
+</script>
+</head>
+<body leftmargin='0' topmargin='10'  bgcolor='#ffffff' onload='register()'>
+</body>
+</html>

Modified: branches/print_dev/http/php/mod_wfs_edit.php
===================================================================
--- branches/print_dev/http/php/mod_wfs_edit.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/php/mod_wfs_edit.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -313,8 +313,8 @@
                 echo "<td><input name='f_toupper".$cnt."' type='checkbox'";
                 if($row["f_toupper"] == 1){ echo " checked"; }
                 echo "></td>";
-                echo "<td><input name='f_label".$cnt."' type='text' size='4' value=\"".htmlentities($row["f_label"])."\"></td>";
-                echo "<td><input name='f_label_id".$cnt."' type='text' size='2' value=\"".htmlentities($row["f_label_id"])."\"></td>";
+                echo "<td><input name='f_label".$cnt."' type='text' size='4' value=\"".htmlentities($row["f_label"], ENT_QUOTES, "UTF-8")."\"></td>";
+                echo "<td><input name='f_label_id".$cnt."' type='text' size='2' value=\"".htmlentities($row["f_label_id"], ENT_QUOTES, "UTF-8")."\"></td>";
                 echo "<td><input name='f_show".$cnt."' type='checkbox'";
                 if($row["f_show"] == 1){ echo " checked"; }
                 echo "></td>";
@@ -329,8 +329,8 @@
                 echo "<td><input name='f_edit".$cnt."' type='checkbox'";
                 if($row["f_edit"] == 1){ echo " checked"; }
                 echo "></td>";
-                echo "<td><textarea name='f_form_element_html".$cnt."' cols='15' rows='1' >".htmlentities($row["f_form_element_html"])."</textarea></td>";
-                echo "<td><input name='f_auth_varname$cnt' type='text' size='8' value=\"" . htmlentities($row["f_auth_varname"]) . "\"></td>";
+                echo "<td><textarea name='f_form_element_html".$cnt."' cols='15' rows='1' >".htmlentities($row["f_form_element_html"], ENT_QUOTES, "UTF-8")."</textarea></td>";
+                echo "<td><input name='f_auth_varname$cnt' type='text' size='8' value=\"" . htmlentities($row["f_auth_varname"], ENT_QUOTES, "UTF-8") . "\"></td>";
                 echo "<td><select name='f_operator".$cnt."' id='f_operator".$cnt."' ";
                 if($row["f_search"] != 1){
                 	echo "disabled";

Modified: branches/print_dev/http/php/mod_wfs_server.php
===================================================================
--- branches/print_dev/http/php/mod_wfs_server.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/php/mod_wfs_server.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -1,324 +1,326 @@
-<?php
-require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-require_once(dirname(__FILE__)."/../classes/class_administration.php");
-require_once(dirname(__FILE__)."/../classes/class_wfs.php");
-require_once(dirname(__FILE__) . "/../classes/class_json.php");
-require_once(dirname(__FILE__) . "/../classes/class_universal_wfs_factory.php");
-
-$json = new Mapbender_JSON();
-$obj = $json->decode(stripslashes($_REQUEST['obj']));
-
-//workflow:
-switch($obj->action){
-	case 'getServices':
-		$obj->services = getServices($obj);
-		sendOutput($obj);
-	break;
-	case 'getWfsConfData':
-		$obj->wfsConf = getWfsConfData($obj->wfs);
-		sendOutput($obj);
-	break;
-	case 'getGuis':
-		$obj->id = getGuis($obj);
-		sendOutput($obj);
-	break;
-	case 'getAssignedConfs':
-		$obj->assignedConfs = getAssignedConfs($obj);
-		sendOutput($obj);
-	break;
-	case 'getUpdateUrl':
-		$obj->url = getUpdateUrl($obj);
-		sendOutput($obj);
-	break;
-		case 'add':
-		addConfsToGui($obj);
-		sendOutput($obj);
-	break;
-	case 'remove':
-		removeConfsFromGui($obj);
-		sendOutput($obj);
-	break;
-	case 'updateWfs':
-		updateWfs($obj);
-		sendOutput($obj);
-	break;
-	case 'deleteWfs':
-		deleteWfs($obj);
-		sendOutput($obj);
-	break;
-	case 'setOwsproxy':
-		$ows = array();
-		$ows['string'] = setOwsproxy($obj);
-		$ows['action'] = "owsproxy";
-		sendOutput($ows);
-	break;
-	case 'removeOwsproxy':
-		$ows = array();
-		$ows['string'] = removeOwsproxy($obj);
-		$ows['action'] = "owsproxy";
-		sendOutput($ows);
-	break;
-	case 'getOwsproxy':
-		$ows = array();
-		$ows['string'] = getOwsproxy($obj);
-		$ows['action'] = "owsproxy";
-		sendOutput($ows);
-	break;
-	default:
-		sendOutput("no action specified...");
-}
-
-
-/*
- * Get all services (ids and titles) where the current user is owner
- *
- * @return mixed[] services the ids and titles of the services
- */
-function getServices(){
-	global $con;
-	$services = array();
-	$services['id'] = array();
-	$services['title'] = array();
-	$adm = new administration();
-	$serviceList = $adm->getWfsByOwner($_SESSION['mb_user_id']);
-	if(count($serviceList) == 0){
-		return false;
-	}
-	$sql = "SELECT * FROM wfs WHERE wfs_id IN (";
-	$v = $serviceList;
-	$t = array();
-	for ($i = 1; $i <= count($serviceList); $i++) {
-		if ($i > 1) {
-			$sql .= ", ";
-		}
-		$sql .= "$" . $i;
-		array_push($t, "i");
-	}
-	$sql .= ") ORDER BY wfs_title";
-	$res = db_prep_query($sql, $v, $t);
-	while($row = db_fetch_array($res)){
-		array_push($services['id'], $row['wfs_id']);
-		array_push($services['title'], $row['wfs_title']);
-	}
-	return $services;
-}
-
-/*
- * Get all configurations of the selcted wfs if the current user is owner
- *
- * @return mixed[]
- */
-function getWfsConfData($wfsID){
-	global $con;
-	// re-check permission
-	$adm = new administration();
-	$serviceList = $adm->getWfsByOwner($_SESSION['mb_user_id']);
-	if(in_array($wfsID, $serviceList)){
-		$wfsConf = array();
-		$wfsConf['id'] = array();
-		$wfsConf['abstract'] = array();
-		$sql = "SELECT * FROM wfs_conf WHERE fkey_wfs_id = $1 ORDER BY wfs_conf_abstract";
-		$v = array($wfsID);
-		$t = array('i');
-		$res = db_prep_query($sql,$v,$t);
-		$cnt = 0;
-		while($row = db_fetch_array($res)){
-			array_push($wfsConf['id'], $row['wfs_conf_id']);
-			array_push($wfsConf['abstract'], $row['wfs_conf_abstract']);
-			$cnt++;
-		}
-		if($cnt == 0){
-			return false;
-		}
-		else{
-			return $wfsConf;
-		}
-	}
-	else if($wfsID==="gui_confs"){
-		$wfsConf = array();
-		$wfsConf['id'] = array();
-		$wfsConf['abstract'] = array();
-		$wfsConf['id'] = $adm->getWfsConfByPermission($_SESSION['mb_user_id']);
-		$cnt = 0;
-		foreach($wfsConf['id'] as $wfscid){
-			$sql = "SELECT wfs_conf_abstract FROM wfs_conf WHERE wfs_conf_id = $1";
-			$v = array($wfscid);
-			$t = array('i');
-			$res = db_prep_query($sql,$v,$t);
-			while($row = db_fetch_array($res)){
-				array_push($wfsConf['abstract'], $row['wfs_conf_abstract']);
-			}
-			$cnt++;
-		}
-		if($cnt == 0){
-			return false;
-		}
-		else{
-			return $wfsConf;
-		}
-	}
-}
-/*
- * Get all GUIs where the current user is owner. This are the GUIs where the user could publish his
- * wfs configurations
- *
- * @return mixed[]
- */
-function getGuis(){
-	$adm = new administration();
-	$guiList = $adm->getGuisByOwner($_SESSION['mb_user_id'],1);
-	if(count($guiList) > 0){
-		return $guiList;
-	}
-	return false;
-}
-
-
-/*
- * get all wfs_confs of the selected WFS which are assigned to the selected gui
- * @param
- * @return mixed[]
- */
-function getAssignedConfs($obj){
-	global $con;
-	$assignedConfs = array();
-	$confs = getWfsConfData($obj->selectedWfs);
-	if($confs === false){
-		return false;
-	}
-	$sql = "SELECT * FROM gui_wfs_conf WHERE fkey_gui_id = $1 AND fkey_wfs_conf_id IN (".join(",",$confs['id']).")";
-	$v = array($obj->selectedGui);
-	$t = array('s');
-	$res = db_prep_query($sql,$v,$t);
-	if(!$res){
-		$e = new mb_exception("Error: SQL: " . $sql . " -> Gui: " .$obj->selectedGui);
-	}
-	while($row = db_fetch_array($res)){
-		array_push($assignedConfs, $row['fkey_wfs_conf_id']);
-	}
-	return $assignedConfs;
-}
-
-
-function addConfsToGui($obj){
-	global $con;
-	for($i=0; $i<count($obj->confs); $i++){
-		$sql = "SELECT * FROM gui_wfs_conf WHERE fkey_gui_id = $1 AND fkey_wfs_conf_id = $2";
-		$v = array($obj->gui,$obj->confs->$i);
-		$t = array('s','i');
-		$res = db_prep_query($sql,$v,$t);
-		if(!$row = db_fetch_array($res)){
-			$sql1 = "INSERT INTO gui_wfs_conf (fkey_gui_id,fkey_wfs_conf_id) VALUES ($1,$2)";
-			$v1 = array($obj->gui, $obj->confs->$i);
-			$t1 = array('s', 'i');
-			$res1 = db_prep_query($sql1,$v1,$t1);
-		}
-	}
-}
-
-function removeConfsFromGui($obj){
-	global $con;
-	for($i=0; $i<count($obj->confs); $i++){
-		$sql = "DELETE FROM gui_wfs_conf  WHERE fkey_gui_id = $1 AND fkey_wfs_conf_id = $2";
-		$v = array($obj->gui, $obj->confs->$i);
-		$t = array('s', 'i');
-		$res = db_prep_query($sql,$v,$t);
-	}
-}
-/*
- * updates an WFS
- *
- * @param object the un-encoded object
- * @return boolean success
- */
-function updateWfs($obj){
-	$id = $obj->wfs;
-
-	$wfsFactory = new UniversalWfsFactory();
-	$myWfs = $wfsFactory->createFromDb($id);
-
-	if(is_null($myWfs) || !$myWfs->update()){
-		$obj->success = false;
-	}
-	else {
-		$obj->success = true;
-	}
-	return true;
-}
-/*
- * deletes an WFS
- *
- * @param object the un-encoded object
- * @return boolean success
- */
-function deleteWfs($obj){
-	$id = $obj->wfs;
-	
-	$wfsFactory = new UniversalWfsFactory();
-	$myWfs = $wfsFactory->createFromDb($id);
-	if (is_null($myWfs) || !$myWfs->delete()) {
-		$obj->success = false;
-	}
-	else {
-		$obj->success = true;
-	}
-	return true;
-}
-
-/*
- * gets the specified url column from db
- *
- * @param object the un-encoded object
- * @return string requested url
- */
-
-function getUpdateUrl($obj){
-	global $con;
-	$sql = "SELECT * FROM wfs WHERE wfs_id = $1;";
-	$v = array($obj->wfs);
-	$t = array('i');
-	$res = db_prep_query($sql,$v,$t);
-	while($row = db_fetch_array($res)){
-		$ContentOfColumn = $row[$obj->column];
-		if($obj->column == 'wfs_getcapabilities'){
-										$n = new administration();
-										$updateUrl = $n->checkURL($ContentOfColumn)."Version=".$row['wfs_version']."&Request=getCapabilities&SERVICE=WFS";
-		}else{
-					$updateUrl = $ContentOfColumn;
-		}
-			
-		return $updateUrl;
-	}
-	return "";
-}
-
-function getOwsproxy($obj){
-	$n = new administration();
-	if($obj->wfs=="gui_confs")
-		return false;
-	return $n->getWfsOwsproxyString($obj->wfs);
-}
-function setOwsproxy($obj){
-	$n = new administration();
-	if($obj->wfs=="gui_confs")
-		return false;
-	return $n->setWfsOwsproxyString($obj->wfs,true);
-}
-function removeOwsproxy($obj){
-	$n = new administration();
-	if($obj->wfs=="gui_confs")
-		return false;
-	return $n->setWfsOwsproxyString($obj->wfs,false);
-}
-/*
- * encodes and delivers the data
- *
- * @param object the un-encoded object
- */
-function sendOutput($out){
-	global $json;
-	$output = $json->encode($out);
-	header("Content-Type: text/x-json");
-	echo $output;
-}
-?>
+<?php
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+require_once(dirname(__FILE__)."/../classes/class_wfs.php");
+require_once(dirname(__FILE__) . "/../classes/class_json.php");
+require_once(dirname(__FILE__) . "/../classes/class_universal_wfs_factory.php");
+
+$json = new Mapbender_JSON();
+$obj = $json->decode(stripslashes($_REQUEST['obj']));
+
+//workflow:
+switch($obj->action){
+	case 'getServices':
+		$obj->services = getServices($obj);
+		sendOutput($obj);
+	break;
+	case 'getWfsConfData':
+		$obj->wfsConf = getWfsConfData($obj->wfs);
+		sendOutput($obj);
+	break;
+	case 'getGuis':
+		$obj->id = getGuis($obj);
+		sendOutput($obj);
+	break;
+	case 'getAssignedConfs':
+		$obj->assignedConfs = getAssignedConfs($obj);
+		sendOutput($obj);
+	break;
+	case 'getUpdateUrl':
+		$obj->url = getUpdateUrl($obj);
+		sendOutput($obj);
+	break;
+		case 'add':
+		addConfsToGui($obj);
+		sendOutput($obj);
+	break;
+	case 'remove':
+		removeConfsFromGui($obj);
+		sendOutput($obj);
+	break;
+	case 'updateWfs':
+		updateWfs($obj);
+		sendOutput($obj);
+	break;
+	case 'deleteWfs':
+		deleteWfs($obj);
+		sendOutput($obj);
+	break;
+	case 'setOwsproxy':
+		$ows = array();
+		$ows['string'] = setOwsproxy($obj);
+		$ows['action'] = "owsproxy";
+		sendOutput($ows);
+	break;
+	case 'removeOwsproxy':
+		$ows = array();
+		$ows['string'] = removeOwsproxy($obj);
+		$ows['action'] = "owsproxy";
+		sendOutput($ows);
+	break;
+	case 'getOwsproxy':
+		$ows = array();
+		$ows['string'] = getOwsproxy($obj);
+		$ows['action'] = "owsproxy";
+		sendOutput($ows);
+	break;
+	default:
+		sendOutput("no action specified...");
+}
+
+
+/*
+ * Get all services (ids and titles) where the current user is owner
+ *
+ * @return mixed[] services the ids and titles of the services
+ */
+function getServices(){
+	global $con;
+	$services = array();
+	$services['id'] = array();
+	$services['title'] = array();
+	$adm = new administration();
+	$serviceList = $adm->getWfsByOwner($_SESSION['mb_user_id']);
+	if(count($serviceList) == 0){
+		return false;
+	}
+	$sql = "SELECT * FROM wfs WHERE wfs_id IN (";
+	$v = $serviceList;
+	$t = array();
+	for ($i = 1; $i <= count($serviceList); $i++) {
+		if ($i > 1) {
+			$sql .= ", ";
+		}
+		$sql .= "$" . $i;
+		array_push($t, "i");
+	}
+	$sql .= ") ORDER BY wfs_title";
+	$res = db_prep_query($sql, $v, $t);
+	while($row = db_fetch_array($res)){
+		array_push($services['id'], $row['wfs_id']);
+		array_push($services['title'], $row['wfs_title']);
+	}
+	return $services;
+}
+
+/*
+ * Get all configurations of the selcted wfs if the current user is owner
+ *
+ * @return mixed[]
+ */
+function getWfsConfData($wfsID){
+	global $con;
+	// re-check permission
+	$adm = new administration();
+	$serviceList = $adm->getWfsByOwner($_SESSION['mb_user_id']);
+	if(in_array($wfsID, $serviceList)){
+		$wfsConf = array();
+		$wfsConf['id'] = array();
+		$wfsConf['abstract'] = array();
+		$sql = "SELECT * FROM wfs_conf WHERE fkey_wfs_id = $1 ORDER BY wfs_conf_abstract";
+		$v = array($wfsID);
+		$t = array('i');
+		$res = db_prep_query($sql,$v,$t);
+		$cnt = 0;
+		while($row = db_fetch_array($res)){
+			array_push($wfsConf['id'], $row['wfs_conf_id']);
+			array_push($wfsConf['abstract'], $row['wfs_conf_abstract']);
+			$cnt++;
+		}
+		if($cnt == 0){
+			return false;
+		}
+		else{
+			return $wfsConf;
+		}
+	}
+	else if($wfsID==="gui_confs"){
+		$wfsConf = array();
+		$wfsConf['id'] = array();
+		$wfsConf['abstract'] = array();
+		$wfsConf['id'] = $adm->getWfsConfByPermission($_SESSION['mb_user_id']);
+		$cnt = 0;
+		foreach($wfsConf['id'] as $wfscid){
+			$sql = "SELECT wfs_conf_abstract FROM wfs_conf WHERE wfs_conf_id = $1";
+			$v = array($wfscid);
+			$t = array('i');
+			$res = db_prep_query($sql,$v,$t);
+			while($row = db_fetch_array($res)){
+				array_push($wfsConf['abstract'], $row['wfs_conf_abstract']);
+			}
+			$cnt++;
+		}
+		if($cnt == 0){
+			return false;
+		}
+		else{
+			return $wfsConf;
+		}
+	}
+}
+/*
+ * Get all GUIs where the current user is owner. This are the GUIs where the user could publish his
+ * wfs configurations
+ *
+ * @return mixed[]
+ */
+function getGuis(){
+	$adm = new administration();
+	$guiList = $adm->getGuisByOwner($_SESSION['mb_user_id'],1);
+	if(count($guiList) > 0){
+		return $guiList;
+	}
+	return false;
+}
+
+
+/*
+ * get all wfs_confs of the selected WFS which are assigned to the selected gui
+ * @param
+ * @return mixed[]
+ */
+function getAssignedConfs($obj){
+	global $con;
+	$assignedConfs = array();
+	$confs = getWfsConfData($obj->selectedWfs);
+	if($confs === false){
+		return false;
+	}
+	$sql = "SELECT * FROM gui_wfs_conf WHERE fkey_gui_id = $1 AND fkey_wfs_conf_id IN (".join(",",$confs['id']).")";
+	$v = array($obj->selectedGui);
+	$t = array('s');
+	$res = db_prep_query($sql,$v,$t);
+	if(!$res){
+		$e = new mb_exception("Error: SQL: " . $sql . " -> Gui: " .$obj->selectedGui);
+	}
+	while($row = db_fetch_array($res)){
+		array_push($assignedConfs, $row['fkey_wfs_conf_id']);
+	}
+	return $assignedConfs;
+}
+
+
+function addConfsToGui($obj){
+	global $con;
+	for($i=0; $i<count($obj->confs); $i++){
+		$sql = "SELECT * FROM gui_wfs_conf WHERE fkey_gui_id = $1 AND fkey_wfs_conf_id = $2";
+		$v = array($obj->gui,$obj->confs->$i);
+		$t = array('s','i');
+		$res = db_prep_query($sql,$v,$t);
+		if(!$row = db_fetch_array($res)){
+			$sql1 = "INSERT INTO gui_wfs_conf (fkey_gui_id,fkey_wfs_conf_id) VALUES ($1,$2)";
+			$v1 = array($obj->gui, $obj->confs->$i);
+			$t1 = array('s', 'i');
+			$res1 = db_prep_query($sql1,$v1,$t1);
+		}
+	}
+}
+
+function removeConfsFromGui($obj){
+	global $con;
+	for($i=0; $i<count($obj->confs); $i++){
+		$sql = "DELETE FROM gui_wfs_conf  WHERE fkey_gui_id = $1 AND fkey_wfs_conf_id = $2";
+		$v = array($obj->gui, $obj->confs->$i);
+		$t = array('s', 'i');
+		$res = db_prep_query($sql,$v,$t);
+	}
+}
+/*
+ * updates an WFS
+ *
+ * @param object the un-encoded object
+ * @return boolean success
+ */
+function updateWfs($obj){
+	$id = $obj->wfs;
+	$url = $obj->url;
+
+	$wfsFactory = new UniversalWfsFactory();
+	$myWfs = $wfsFactory->createFromUrl($url);
+	$myWfs->id = $id;
+
+	if(is_null($myWfs) || !$myWfs->update()){
+		$obj->success = false;
+	}
+	else {
+		$obj->success = true;
+	}
+	return true;
+}
+/*
+ * deletes an WFS
+ *
+ * @param object the un-encoded object
+ * @return boolean success
+ */
+function deleteWfs($obj){
+	$id = $obj->wfs;
+	
+	$wfsFactory = new UniversalWfsFactory();
+	$myWfs = $wfsFactory->createFromDb($id);
+	if (is_null($myWfs) || !$myWfs->delete()) {
+		$obj->success = false;
+	}
+	else {
+		$obj->success = true;
+	}
+	return true;
+}
+
+/*
+ * gets the specified url column from db
+ *
+ * @param object the un-encoded object
+ * @return string requested url
+ */
+
+function getUpdateUrl($obj){
+	global $con;
+	$sql = "SELECT * FROM wfs WHERE wfs_id = $1;";
+	$v = array($obj->wfs);
+	$t = array('i');
+	$res = db_prep_query($sql,$v,$t);
+	while($row = db_fetch_array($res)){
+		$ContentOfColumn = $row[$obj->column];
+		if($obj->column == 'wfs_getcapabilities'){
+										$n = new administration();
+										$updateUrl = $n->checkURL($ContentOfColumn)."Version=".$row['wfs_version']."&Request=getCapabilities&SERVICE=WFS";
+		}else{
+					$updateUrl = $ContentOfColumn;
+		}
+			
+		return $updateUrl;
+	}
+	return "";
+}
+
+function getOwsproxy($obj){
+	$n = new administration();
+	if($obj->wfs=="gui_confs")
+		return false;
+	return $n->getWfsOwsproxyString($obj->wfs);
+}
+function setOwsproxy($obj){
+	$n = new administration();
+	if($obj->wfs=="gui_confs")
+		return false;
+	return $n->setWfsOwsproxyString($obj->wfs,true);
+}
+function removeOwsproxy($obj){
+	$n = new administration();
+	if($obj->wfs=="gui_confs")
+		return false;
+	return $n->setWfsOwsproxyString($obj->wfs,false);
+}
+/*
+ * encodes and delivers the data
+ *
+ * @param object the un-encoded object
+ */
+function sendOutput($out){
+	global $json;
+	$output = $json->encode($out);
+	header("Content-Type: text/x-json");
+	echo $output;
+}
+?>

Modified: branches/print_dev/http/print/mod_printPDF.php
===================================================================
--- branches/print_dev/http/print/mod_printPDF.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/print/mod_printPDF.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -185,7 +185,6 @@
 			}
 			var pos = pt.makeClickPos2RealWorldPos(target, map_width , map_height);
 			var prevscale= pt.mb_getScale(target);
-			console.log(prevscale);
 			pt.mb_mapObj[ind].extent = coord[0] + "," + pos[1] + "," + pos[0] + "," +  coord[3];
 
 			pt.mb_mapObj[ind].width = Math.round(map_width);

Modified: branches/print_dev/http/print/mod_printPDF_pdf.php
===================================================================
--- branches/print_dev/http/print/mod_printPDF_pdf.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/http/print/mod_printPDF_pdf.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -305,7 +305,7 @@
    214=>'Odieresis',246=>'odieresis',
    220=>'Udieresis',252=>'udieresis',
    223=>'germandbls');
-$pdf->selectFont('../classes/fonts/Helvetica.afm', array('encoding'=>'WinAnsiEncoding','differences'=>$diff));
+$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;

Modified: branches/print_dev/lib/ajax.js
===================================================================
--- branches/print_dev/lib/ajax.js	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/lib/ajax.js	2009-05-22 11:46:01 UTC (rev 3956)
@@ -202,6 +202,7 @@
 		// the ajax request reports success
 		if (resultObj.result && typeof(resultObj.result) == "object" &&
 			resultObj.result.data && typeof(resultObj.result.data) == "object") {
+
 			if (id != resultObj.id) {
 				message = Mapbender.Ajax.Messages.idMismatchError;
 				new Mb_warning(message);
@@ -211,9 +212,9 @@
 
 			success = true;
 
-			if (resultObj.result.data.message) {
-				message = resultObj.data.message;
-				status = resultObj.data.message;
+			if (resultObj.result.message) {
+				message = resultObj.result.message;
+				status = resultObj.result.message;
 			}
 			result = resultObj.result.data;
 		}

Modified: branches/print_dev/lib/ajax.php
===================================================================
--- branches/print_dev/lib/ajax.php	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/lib/ajax.php	2009-05-22 11:46:01 UTC (rev 3956)
@@ -48,7 +48,7 @@
 
 	protected function initializeFromArray ($requestArray) {
 		if ($requestArray["id"]) {
-			$this->id = $requestArray["id"];
+			$this->id = intval($requestArray["id"]);
 		}
 		
 		if ($requestArray["method"]) {

Modified: branches/print_dev/lib/basic.js
===================================================================
--- branches/print_dev/lib/basic.js	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/lib/basic.js	2009-05-22 11:46:01 UTC (rev 3956)
@@ -36,42 +36,43 @@
 }
 
 function mb_showHighlight(frameName,x,y){
-   var pos = makeRealWorld2mapPos(frameName,x, y);
-//TODO frame des Mapobjekts frameName nehmen
-   mb_arrangeElement(frameName,"highlight",pos[0]-7, pos[1]-7);
-   window.frames[frameName].document.getElementById("highlight").style.visibility = 'visible';
+	var map = getMapObjByName(frameName);
+	if (map !== null) {
+		var p = map.convertRealToPixel(new Point(x, y));
+		
+		var map_el = map.getDomElement();
+		var $highlight = $("#" + map.elementName + "_highlight");
+		if($highlight.size() === 0) {
+			//create Box Elements
+			$highlight = $("<div id='" + map.elementName+ "_highlight' style='position:absolute;top:-10px;left:-10px;width:14px;height:14px;z-index:3;visibility:visible'><img src='../img/redball.gif'/></div>");
+			$(map_el).append($highlight);
+		}
+		$highlight.css("visibility", "visible");
+	}
+	mb_arrangeElement(map.frameName, map.elementName+ "_highlight" ,p.x-7, p.y-7);
 }
+
 function mb_hideHighlight(frameName){
-   mb_arrangeElement(frameName,"highlight",-20, -20);
-   mb_arrangeElement(frameName,"highlight",-20, -20);
-   window.frames[frameName].document.getElementById("highlight").style.visibility = 'hidden';
+	var map = getMapObjByName(frameName);
+	if (map !== null) {
+		var map_el = map.getDomElement();
+		mb_arrangeElement(map.frameName, map.elementName + "_highlight", -20, -20);
+		$(map.elementName + "_highlight").css("visibility", "hidden");
+	}
 }
 
-function cloneObject(obj) { 
-    if (typeof obj !== 'object' || obj === null) {
-        return obj;
-    }
-    var c = obj instanceof Array ? [] : {};
-    for (var i in obj) {
-        var prop = obj[i];
-        if (typeof prop == 'object') {
-           if (prop instanceof Array) {
-               c[i] = [];
-               for (var j = 0; j < prop.length; j++) {
-                   if (typeof prop[j] != 'object') {
-                       c[i].push(prop[j]);
-                   } else {
-                       c[i].push(cloneObject(prop[j]));
-                   }
-               }
-           } else {
-               c[i] = cloneObject(prop);
-           }
-        } else {
-           c[i] = prop;
-        }
-    }
-    return c;
+function cloneObject (p, c) {
+	var c = c || {};
+	for (var i in p) {
+		if (typeof p[i] === 'object') {
+			c[i] = (p[i].constructor === Array) ? [] : {};
+			cloneObject(p[i], c[i]);
+		}
+		else {
+			c[i] = p[i];
+		}
+	}
+	return c;
 }
 
 function mb_timestamp(){
@@ -80,7 +81,15 @@
 	return ts;
 }
 
+/**
+ * @deprecated 
+ * @param {Object} e
+ * @param {Object} fName
+ */
 function mb_getMousePos(e,fName){
+
+	var warning = new Mb_warning("The function mb_getMousePos is deprecated, use the map objects getMousePosition.");
+
 	if(fName){
 		if(ie){
 			clickX = window.frames[fName].event.clientX;

Modified: branches/print_dev/lib/event.js
===================================================================
--- branches/print_dev/lib/event.js	2009-05-20 06:31:41 UTC (rev 3955)
+++ branches/print_dev/lib/event.js	2009-05-22 11:46:01 UTC (rev 3956)
@@ -165,9 +165,9 @@
 	 * Executes the function
 	 */
 	this.execute = function (argumentObj) {
-		if (typeof(aFunction) == "function") {
+		if (typeof(func) == "function" || typeof(func) == "object") {
 			if (scope) {
-				return aFunction.call(scope, argumentObj);
+				return func.call(scope, argumentObj);
 			}
 			return func(argumentObj);
 		}
@@ -200,4 +200,4 @@
 	// private
 	var func = aFunction;
 	var scope = aScope;
-};
\ No newline at end of file
+};



More information about the Mapbender_commits mailing list