[Mapbender-commits] r2878 - in branches/nimix_dev: . http/classes http/extensions http/javascripts http/php http/sld http/sld/classes lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Aug 18 14:20:45 EDT 2008


Author: nimix
Date: 2008-08-18 14:20:44 -0400 (Mon, 18 Aug 2008)
New Revision: 2878

Added:
   branches/nimix_dev/documents/
   branches/nimix_dev/http/classes/class_json.php
   branches/nimix_dev/http/classes/class_user.php
   branches/nimix_dev/http/extensions/jquery.ajaxmanager.js
   branches/nimix_dev/http/sld/sld_function_getusersld.php
   branches/nimix_dev/lib/
   branches/nimix_dev/lib/ajax.js
   branches/nimix_dev/lib/alignButton.js
   branches/nimix_dev/lib/basic.js
   branches/nimix_dev/lib/button.js
   branches/nimix_dev/lib/buttonNew.js
   branches/nimix_dev/lib/core.js
   branches/nimix_dev/lib/database-mysql.php
   branches/nimix_dev/lib/database-mysqli.php
   branches/nimix_dev/lib/database-pgsql.php
   branches/nimix_dev/lib/div.js
   branches/nimix_dev/lib/draggableButton.js
   branches/nimix_dev/lib/event.js
   branches/nimix_dev/lib/exception.js
   branches/nimix_dev/lib/i18n.php
   branches/nimix_dev/lib/list.js
   branches/nimix_dev/lib/point.js
   branches/nimix_dev/lib/resizableButton.js
   branches/nimix_dev/lib/saveButton.js
   branches/nimix_dev/lib/selectableButton.js
   branches/nimix_dev/lib/style.js
Modified:
   branches/nimix_dev/http/classes/class_weldMaps2Image.php
   branches/nimix_dev/http/extensions/geom2wfst.php
   branches/nimix_dev/http/javascripts/geometry.js
   branches/nimix_dev/http/javascripts/mod_resize_mapsize.php
   branches/nimix_dev/http/javascripts/mod_switchLocale_noreload.php
   branches/nimix_dev/http/javascripts/mod_tab.php
   branches/nimix_dev/http/javascripts/wfs.js
   branches/nimix_dev/http/php/mod_addWMSfromfilteredList_server.php
   branches/nimix_dev/http/php/mod_button_tooltips.php
   branches/nimix_dev/http/php/mod_digitize_messages.php
   branches/nimix_dev/http/php/mod_editWMS_Metadata.php
   branches/nimix_dev/http/php/mod_exportMapImage_server.php
   branches/nimix_dev/http/php/mod_layerMetadata.php
   branches/nimix_dev/http/php/mod_switchLocale.php
   branches/nimix_dev/http/php/mod_switchLocale_noreload.php
   branches/nimix_dev/http/php/mod_tab_messages.php
   branches/nimix_dev/http/php/mod_wfs.php
   branches/nimix_dev/http/php/mod_wfsSpatialRequest_messages.php
   branches/nimix_dev/http/php/mod_wfs_server.php
   branches/nimix_dev/http/php/system.php
   branches/nimix_dev/http/sld/classes/Rule.php
   branches/nimix_dev/http/sld/classes/StyledLayerDescriptor.php
   branches/nimix_dev/http/sld/sld_config.php
   branches/nimix_dev/http/sld/sld_edit_filter.php
   branches/nimix_dev/http/sld/sld_filter_parse.php
   branches/nimix_dev/http/sld/sld_function_handler.php
   branches/nimix_dev/http/sld/sld_main.php
   branches/nimix_dev/http/sld/sld_parse.php
Log:
merge final

Added: branches/nimix_dev/http/classes/class_json.php
===================================================================
--- branches/nimix_dev/http/classes/class_json.php	                        (rev 0)
+++ branches/nimix_dev/http/classes/class_json.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,78 @@
+<?php
+# $Id:class_json.php 2406 2008-04-23 15:59:31Z christoph $
+# http://www.mapbender.org/index.php/JSON
+# 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("JSON_PEAR", "json_pear");
+define("JSON_NATIVE", "json_native");
+
+if (!function_exists("json_encode")) {
+	require_once(dirname(__FILE__)."/../extensions/JSON.php");
+}
+
+/**
+ * A wrapper class for PHP JSON encoding/decoding.
+ * Uses native PHP functions if available.
+ * 
+ * @class
+ */
+class Mapbender_JSON {
+	
+	/**
+	 * Either JSON_PEAR or JSON_NATIVE
+	 */
+	private $library = JSON_PEAR;
+
+	/**
+	 * Determines which JSON lib to use.
+	 * @constructor
+	 */
+	public function __construct(){
+		if (function_exists("json_encode")) {
+			$this->library = JSON_NATIVE;
+		}
+	}
+	
+	/**
+	 * Encodes an object to JSON
+	 */
+	public function encode($anObject) {
+		if ($this->library == JSON_PEAR) {
+			$pear = new Services_JSON();
+			$e = new mb_notice("using PEAR JSON");
+			return $pear->encode($anObject);
+		}
+		$e = new mb_notice("using native JSON");
+		return json_encode($anObject);
+	}
+
+	/**
+	 * Decodes a JSON string
+	 */
+	public function decode($aString) {
+		if ($this->library == JSON_PEAR) {
+			$pear = new Services_JSON();
+			$e = new mb_notice("using PEAR JSON");
+			return $pear->decode($aString);
+		}
+		$e = new mb_notice("using native JSON");
+		return json_decode($aString);
+	}
+}
+?>

Added: branches/nimix_dev/http/classes/class_user.php
===================================================================
--- branches/nimix_dev/http/classes/class_user.php	                        (rev 0)
+++ branches/nimix_dev/http/classes/class_user.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,159 @@
+<?php
+# $Id: class_kml_geometry.php 1966 2008-01-15 08:25:15Z christoph $
+# 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");
+
+/**
+ * A Mapbender user as described in the table mb_user.
+ */
+class User {
+	/**
+	 * @var Integer The user ID
+	 */
+	var $id;
+	
+	/**
+	 * Constructor
+	 * @param $userId Integer 	the ID of the user that	is represented by 
+	 * 							this object.
+	 */
+	public function __construct ($userId) {
+		$this->id = $userId;
+	}	
+	
+	/**
+	 * @return String the ID of this user
+	 */
+	public function __toString () {
+		return (string) $this->id;	
+	}
+	
+	/**
+	 * Returns an array of application IDs that the user is allowed to access.
+	 * 
+	 * @return Array an array of application IDs
+	 * @param $ignorepublic boolean whether or not to ignore 
+	 * 								public applications (?)
+	 */
+	public function getApplicationsByPermission ($ignorepublic) {
+		$mb_user_id = $this->id;
+		$arrayGuis = array();
+		$mb_user_groups = array();
+		$sql_groups = "SELECT fkey_mb_group_id FROM mb_user_mb_group WHERE fkey_mb_user_id = $1 ";
+		$v = array($mb_user_id);
+		$t = array("i");
+		$res_groups = db_prep_query($sql_groups,$v,$t);
+		$cnt_groups = 0;
+		while($row = db_fetch_array($res_groups)){
+			$mb_user_groups[$cnt_groups] = $row["fkey_mb_group_id"];
+			$cnt_groups++;
+		}
+		if($cnt_groups > 0){
+			$v = array();
+			$t = array();
+			$sql_g = "SELECT gui.gui_id FROM gui JOIN gui_mb_group ";
+			$sql_g .= " ON gui.gui_id = gui_mb_group.fkey_gui_id WHERE gui_mb_group.fkey_mb_group_id IN (";
+			for($i=0; $i<count($mb_user_groups);$i++){
+				if($i > 0){$sql_g .= ",";}
+				$sql_g .= "$".strval($i+1);
+				array_push($v,$mb_user_groups[$i]);
+				array_push($t,"i");
+			}
+			$sql_g .= ") GROUP BY gui.gui_id";
+			$res_g = db_prep_query($sql_g,$v,$t);
+			while($row = db_fetch_array($res_g)){
+				array_push($arrayGuis,$row["gui_id"]);
+			}
+		}
+		$sql_guis = "SELECT gui.gui_id FROM gui JOIN gui_mb_user ON gui.gui_id = gui_mb_user.fkey_gui_id";
+		$sql_guis .= " WHERE (gui_mb_user.fkey_mb_user_id = $1) ";
+		if (!isset($ignore_public) OR $ignore_public== false){
+			$sql_guis .= " AND gui.gui_public = 1 ";
+		}
+		$sql_guis .= " GROUP BY gui.gui_id";
+		$v = array($mb_user_id);
+		$t = array("i");
+		$res_guis = db_prep_query($sql_guis,$v,$t);
+		$guis = array();
+		while($row = db_fetch_array($res_guis)){
+			if(!in_array($row['gui_id'],$arrayGuis)){
+				array_push($arrayGuis,$row["gui_id"]);
+			}
+		}
+		return $arrayGuis;
+	}	
+	
+	/** identifies the IDs of WFS confs where the user is owner
+	 * 
+	 * @param integer userid the user-ID of the current user
+	 * @return integer[] the IDs of the wfs_conf-table
+	 */
+	public function getWfsConfByPermission(){
+		$userid = $this->id;
+	 	$guisByPer = array();
+//	 	1.
+		$adm = new administration();
+	 	$guisByPer = $adm->getGuisByPermission($userid, true);
+//	 	2. 
+		$ownWFSconfs = array();
+		if(count($guisByPer)>0){
+			$v = array();
+			$t = array();
+			$sql = "SELECT wfs_conf.wfs_conf_id  FROM gui_wfs_conf, wfs_conf " .
+					"where wfs_conf.wfs_conf_id = gui_wfs_conf.fkey_wfs_conf_id " .
+					"and gui_wfs_conf.fkey_gui_id IN(";
+			for($i=0; $i<count($guisByPer); $i++){
+				if($i>0){ $sql .= ",";}
+				$sql .= "$".strval($i+1);
+				
+				array_push($v, $guisByPer[$i]);
+				array_push($t, "s");
+			}
+			$sql .= ") GROUP BY wfs_conf.wfs_conf_id ORDER BY wfs_conf.wfs_conf_id";
+			
+			$res = db_prep_query($sql,$v,$t);
+			$i=0;
+			while($row = db_fetch_array($res)){
+				$ownWFSconfs[$i] = $row['wfs_conf_id'];
+				$i++;
+			}
+		}
+		return $ownWFSconfs;
+	}
+	
+	/**
+	 * Returns all WMCs that this user owns
+	 * 
+	 * @return integer[] an array of WMC ids; ids from table mb_user_wmc
+	 */
+	public function getWmcByOwner () {
+		$sql = "SELECT wmc_id FROM mb_user_wmc ";
+		$sql .= "WHERE fkey_user_id = $1 GROUP BY wmc_id";
+		$v = array($this->id);
+		$t = array("i");
+		$res_wmc = db_prep_query($sql, $v, $t);
+
+  		$wmcArray = array();
+		while($row = db_fetch_array($res_wmc)){
+			array_push($wmcArray, $row["wmc_id"]);
+		}
+		return $wmcArray;
+	}
+}
+?>

Modified: branches/nimix_dev/http/classes/class_weldMaps2Image.php
===================================================================
--- branches/nimix_dev/http/classes/class_weldMaps2Image.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/classes/class_weldMaps2Image.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -117,12 +117,15 @@
 			$wms_bbox = str_replace(',', ' ', $wms_bbox);
 			$filename_tif = str_replace($wms_format, 'tif', $filenameOnly);
 
-			$tmp_dir = $this->array_file['dir'];
+			$tmp_dir = $this->array_file['dir']."/";
+			
+			$array_bbox = explode(" ", $wms_bbox);	
+			$wms_bbox = $array_bbox[0]." ".$array_bbox[3]." ".$array_bbox[2]." ".$array_bbox[1];
+
 			$cmd = "gdal_translate -a_srs ".$wms_srs." -a_ullr ".$wms_bbox." ".$tmp_dir.$filenameOnly." ".$tmp_dir.$filename_tif;
 			exec($cmd);
 			
-			echo "<br>";
-			$this->downloadLink($filenameOnly);
+			$this->downloadLink($filename_tif);
 					
 		}else {
 			

Modified: branches/nimix_dev/http/extensions/geom2wfst.php
===================================================================
--- branches/nimix_dev/http/extensions/geom2wfst.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/extensions/geom2wfst.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -27,7 +27,7 @@
 
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
 require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
 
 function isValidVarName ($varname) {
 	if (preg_match("/[\$]{1}_[a-z]+\[\"[a-z_]+\"\]/i", $varname) != 0) {
@@ -155,6 +155,6 @@
 $notice = new mb_notice("response:".$response);
 
 header("Content-Type:application/x-json");
-$json = new Services_JSON();
+$json = new Mapbender_JSON();
 echo $json->encode($resObj);
 ?>
\ No newline at end of file

Added: branches/nimix_dev/http/extensions/jquery.ajaxmanager.js
===================================================================
--- branches/nimix_dev/http/extensions/jquery.ajaxmanager.js	                        (rev 0)
+++ branches/nimix_dev/http/extensions/jquery.ajaxmanager.js	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,165 @@
+/**
+ * @author Administrator
+ */
+(function($) {
+    $.extend({
+        manageAjax: function(o){
+          o = $.extend({manageType: 'normal',maxReq: 0, blockSameRequest: false},o);
+          return new $.ajaxManager(o);
+        },
+        ajaxManager: function(o){
+            this.opt = o;
+            this.queue = [];
+        }
+	});
+    $.extend(
+        $.ajaxManager.prototype,
+        {
+            add: function(o){
+                 var quLen = this.queue.length, s = this.opt, q = this.queue, self = this,i,j;
+                 var cD = (o.data && typeof o.data != "string")?$.param(o.data):o.data;
+                 if(s.blockSameRequest){
+                    var toPrevent = false;
+                    for (var i = 0;i<quLen; i++){
+                        if(q[i] && q[i].data === cD && q[i].url === o.url && q[i].type === o.type) {
+                            toPrevent = true;
+                            break;
+                        }
+                    }
+                    if(toPrevent)
+                        return false;
+                 }
+                 q[ quLen ] = {
+            		fnError: o.error,
+            		fnSuccess: o.success,
+            		fnComplete: o.complete,
+                    fnAbort: o.abort,
+            		error: [],
+            		success: [],
+            		complete: [],
+            		done: false,
+            		queued: false,
+                    data: cD,
+                    url: o.url,
+                    type: o.type,
+                    xhr: null
+            	};
+                
+                o.error = function(){if(q[ quLen ]) q[ quLen ].error = arguments; };
+            	o.success = function(){if(q[ quLen ]) q[ quLen ].success = arguments; };
+                o.abort = function(){if(q[ quLen ]) q[ quLen ].abort = arguments; };
+                function startCallbacks(num){
+                    if ( q[ num ].fnError ) q[ num ].fnError.apply( $, q[ num ].error );
+        			if ( q[ num ].fnSuccess ) q[ num ].fnSuccess.apply( $, q[ num ].success );
+        			if ( q[ num ].fnComplete ) q[ num ].fnComplete.apply( $, q[ num ].complete );
+        			self.abort(num,true);
+                }
+                
+            	o.complete = function(){
+            		if(!q[ quLen ])
+                        return;
+                    q[ quLen ].complete = arguments;
+            		q[ quLen ].done = true;
+                    switch (s.manageType) {
+                      case 'sync':
+                        if (quLen === 0 || !q[ quLen-1 ]){
+                            var curQLen = q.length;
+                			for ( i = quLen; i < curQLen; i++ ) {
+                                if(q[i]){
+                                    if(q[i].done) 
+                                        startCallbacks(i)
+                                    else
+                                        break;
+                                }
+                                
+                			}
+                        }
+                        break;
+                        case 'queue':
+                        if (quLen === 0 || !q[ quLen-1 ]){
+                            var curQLen = q.length;
+                			for ( i = 0, j = 0; i < curQLen; i++ ) {
+                                if(q[i] && q[i].queued){
+                                    q[i].xhr = jQuery.ajax(q[i].xhr);
+                                    q[i].queued = false;
+                                    break;
+                                }
+                			}
+                        }
+                        startCallbacks(quLen);
+                        break;
+                      case 'abortOld':
+                        startCallbacks(quLen);
+                        for ( i = quLen; i >= 0; i-- ) {
+                            if(q[i]){
+                                self.abort(i);
+                            }
+            			}
+                        break;
+                      default:
+                        startCallbacks(quLen);
+                        break;
+                    }
+            	};
+                
+                if(s.maxReq){
+                    if(s.manageType != 'queue') {
+                        for (i = quLen, j = 0; i >= 0; i--) {
+            				if(j >= s.maxReq)
+                                this.abort(i);   
+                            if(q[i]){
+                                j++;
+                            }   
+            			}
+                    } else {
+                        for (i = 0, j = 0; i <= quLen && !q[quLen].queued; i++) {
+                            if(q[i] && !q[i].queued)
+                                j++;
+                            if(j > s.maxReq)
+                                q[quLen].queued = true;
+            			}
+                    }
+                }
+                q[ quLen ].xhr = (q[quLen].queued)?o:jQuery.ajax(o);
+                return quLen;
+            },
+            cleanUp: function(){
+               this.queue = [];
+            },
+            abort: function(num,completed){
+               var qLen = this.queue.length, s = this.opt, q = this.queue, self = this,i;
+               function del(num){
+                   if(!q[num])
+                       return;
+                   (!completed && q[num].fnAbort) && q[num].fnAbort.apply($,[num]);
+                   if(!q[num])
+                       return;
+                   if(q[num].xhr){
+                      if (typeof q[num].xhr.abort != 'undefined') 
+                          q[num].xhr.abort();
+                      if (typeof q[num].xhr.close != 'undefined') 
+                          q[num].xhr.close();
+                      q[num].xhr = null;
+                   }  
+                    q[num] = null;
+               }
+               if(!num && num !== 0){
+                   for (i = 0; i < qLen; i++){
+                       del(i);
+                   }
+                   this.cleanUp();
+               } else {
+                   del(num);
+                   var allowCleaning = true;
+                   for (i = qLen; i >= 0; i--){
+                       if(q[i]){
+                            allowCleaning = false;
+                            break;
+                       }
+                   }
+                   if (allowCleaning) this.cleanUp(); 
+               }
+            }
+        }
+	);
+})(jQuery);
\ No newline at end of file

Modified: branches/nimix_dev/http/javascripts/geometry.js
===================================================================
--- branches/nimix_dev/http/javascripts/geometry.js	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/javascripts/geometry.js	2008-08-18 18:20:44 UTC (rev 2878)
@@ -1404,6 +1404,12 @@
 		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.
 	 *
@@ -1420,6 +1426,7 @@
 	 *
 	 */	
 	this.paint = function() {
+		this.hide();
 		for (var i=0; i < canvas.length; i++) {
 			if (typeof(canvas[i]) == "object") {canvas[i].clean();}
 		}
@@ -1431,6 +1438,14 @@
 		}
 	};
 
+	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') {

Modified: branches/nimix_dev/http/javascripts/mod_resize_mapsize.php
===================================================================
--- branches/nimix_dev/http/javascripts/mod_resize_mapsize.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/javascripts/mod_resize_mapsize.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -121,5 +121,7 @@
     }
 }
 if (resize_option == 'auto'){
-    window.setTimeout('control()', 3000);
+	eventInit.register(function() {
+		control();
+	});
 }

Modified: branches/nimix_dev/http/javascripts/mod_switchLocale_noreload.php
===================================================================
--- branches/nimix_dev/http/javascripts/mod_switchLocale_noreload.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/javascripts/mod_switchLocale_noreload.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -18,8 +18,13 @@
 # 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_locale.php");
 
 include(dirname(__FILE__) . "/../include/dyn_js.php");
+
+if (!USE_I18N) {
+	echo "var languages = '" . $_SESSION["mb_lang"] . "';";
+}
 ?>
 
 function validate_locale(){

Modified: branches/nimix_dev/http/javascripts/mod_tab.php
===================================================================
--- branches/nimix_dev/http/javascripts/mod_tab.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/javascripts/mod_tab.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -20,7 +20,7 @@
 /********** Configuration*************************************************/
 
 require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
 include(dirname(__FILE__)."/../include/dyn_js.php");
 
 $tab_ids = array();
@@ -37,7 +37,7 @@
 	echo "tab_titles[" . $i . "] = '" . $row["e_title"] . "';\n";	
 }
 
-$json = new Services_JSON();
+$json = new Mapbender_JSON();
 $output = $json->encode($tab_ids);
 
 echo "var tab_ids = " . $output . ";";	

Modified: branches/nimix_dev/http/javascripts/wfs.js
===================================================================
--- branches/nimix_dev/http/javascripts/wfs.js	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/javascripts/wfs.js	2008-08-18 18:20:44 UTC (rev 2878)
@@ -24,7 +24,6 @@
 $con = db_connect(DBSERVER,OWNER,PW);
 db_select_db(DB,$con);
 
-$gui_id = $_REQUEST["gui_id"];
 $e_id_css = "wfs";
 include '../include/dyn_js.php';
 require_once(dirname(__FILE__) . "/wfs_usemap.js");
@@ -177,11 +176,11 @@
 
 	var wfs_conf = window.frames["wfs_conf"].get_wfs_conf();
 	if(type=='over') {
-		highlight.add(m, '#0000ff');
+		highlight.add(m, '#ff0000');
 		highlight.paint();
 	}
 	else if (type == 'out') {
-		highlight.del(m, '#0000ff');
+		highlight.del(m, '#ff0000');
 		highlight.paint();
 	}
 	else 

Modified: branches/nimix_dev/http/php/mod_addWMSfromfilteredList_server.php
===================================================================
--- branches/nimix_dev/http/php/mod_addWMSfromfilteredList_server.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/php/mod_addWMSfromfilteredList_server.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -20,7 +20,7 @@
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
 require_once(dirname(__FILE__)."/../classes/class_wms.php"); 
 require_once(dirname(__FILE__)."/../classes/class_administration.php"); 
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
 
 $userId = $_SESSION["mb_user_id"];
 $command = $_GET["command"];
@@ -140,7 +140,7 @@
 	}		
 }
 
-$json = new Services_JSON();
+$json = new Mapbender_JSON();
 $output = $json->encode($resultObj);
 echo $output;
 ?>
\ No newline at end of file

Modified: branches/nimix_dev/http/php/mod_button_tooltips.php
===================================================================
--- branches/nimix_dev/http/php/mod_button_tooltips.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/php/mod_button_tooltips.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -18,7 +18,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
 require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
 
 $buttonObj = array();
@@ -31,7 +31,7 @@
 	array_push($buttonObj, array("id" => $row["e_id"], "title" => $row["e_title"]));
 }
 
-$json = new Services_JSON();
+$json = new Mapbender_JSON();
 $output = $json->encode($buttonObj);
 
 header("Content-type:text/plain; charset=utf-8");

Modified: branches/nimix_dev/http/php/mod_digitize_messages.php
===================================================================
--- branches/nimix_dev/http/php/mod_digitize_messages.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/php/mod_digitize_messages.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -18,7 +18,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-require_once(dirname(__FILE__)."/../extensions/JSON.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"]));
@@ -27,47 +27,47 @@
 // Messages
 //
 $msg_obj = array();
-$msg_obj["messageDescriptionPolygon"] = _("polygon");
-$msg_obj["messageDescriptionLine"] = _("line");
-$msg_obj["messageDescriptionPoint"] = _("point");
-$msg_obj["messageErrorNotAnInteger"] = _("Not an integer value.");
-$msg_obj["messageErrorNotAFloat"] = _("Not a double value.");
-$msg_obj["messageErrorFieldIsEmpty"] = _("This field may not be empty.");
-$msg_obj["messageErrorFormEvaluation"] = _("Failure during form evaluation.");
-$msg_obj["messageErrorWfsWrite"] = _("An error occured.");
-$msg_obj["messageSuccessWfsWrite"] = _("Success.");
-$msg_obj["messageConfirmDeleteGeomFromDb"] = _("Delete geometry from database?");
-$msg_obj["messageConfirmDeleteAllGeomFromList"] = _("Clear list of geometries?");
-$msg_obj["messageSelectAnOption"] = _("Please select an entry.");
-$msg_obj["buttonLabelSaveGeometry"] = _("Save");
-$msg_obj["buttonLabelUpdateGeometry"] = _("Update");
-$msg_obj["buttonLabelDeleteGeometry"] = _("Delete");
-$msg_obj["buttonLabelAbort"] = _("Abort");
-$msg_obj["errorMessageEpsgMismatch"] = _("Fatal error: EPSG mismatch. ");
-$msg_obj["errorMessageNoGeometrySelected"] = _("No geometry selected!");
-$msg_obj["buttonLabelPointOff"] = _("add point");
-$msg_obj["buttonLabelPointOn"] = _("cancel editing");
-$msg_obj["buttonLabelLineOff"] = _("add line");
-$msg_obj["buttonLabelLineOn"] = _("finish line");
-$msg_obj["buttonLabelPolygonOff"] = _("add polygon");
-$msg_obj["buttonLabelPolygonOn"] = _("close polygon");
-$msg_obj["buttonLabelMoveBasepointOff"] = _("move basepoint");
-$msg_obj["buttonLabelMoveBasepointOn"] = _("move basepoint");
-$msg_obj["buttonLabelInsertBasepointOff"] = _("Insert basepoint");
-$msg_obj["buttonLabelInsertBasepointOn"] = _("Insert basepoint");
-$msg_obj["buttonLabelDeleteBasepointOff"] = _("Delete basepoint");
-$msg_obj["buttonLabelDeleteBasepointOn"] = _("Delete basepoint");
-$msg_obj["buttonLabelClearListOff"] = _("clear list of geometries");
-$msg_obj["buttonLabelClearListOn"] = _("clear list of geometries");
-$msg_obj["buttonDig_wfs_title"] = _("save / update / delete");
-$msg_obj["buttonDig_remove_title"] = _("remove from workspace");
-$msg_obj["buttonDig_removeDb_title"] = _("remove from database");
-$msg_obj["closePolygon_title"] = _("click the first basepoint to close the polygon");
-$msg_obj["measureTagLabelCurrent"] = _("Current: ");
-$msg_obj["measureTagLabelTotal"] = _("Total: ");
-$msg_obj["digitizeDefaultGeometryName"] = _("new");
+$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["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["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 Services_JSON();
+$json = new Mapbender_JSON();
 $output = $json->encode($msg_obj);
 
 header("Content-type:application/x-json; charset=utf-8");

Modified: branches/nimix_dev/http/php/mod_editWMS_Metadata.php
===================================================================
--- branches/nimix_dev/http/php/mod_editWMS_Metadata.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/php/mod_editWMS_Metadata.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -19,78 +19,60 @@
 
 require_once(dirname(__FILE__)."/mb_validatePermission.php");
 require_once(dirname(__FILE__)."/../classes/class_administration.php");
-?>
 
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-<title>Edit WMS Metadata</title>
-
-<?php
-echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';   
 include_once '../include/dyn_css.php';
-#Error reporting 
-error_reporting(E_ALL);
-ini_set('display_errors', TRUE);
-$con = db_connect(DBSERVER,OWNER,PW);
-db_select_db(DB,$con);
 
 $adm = new administration();
-
 ?>
-
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>Edit WMS Metadata</title>
+<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">   
 <script language="JavaScript">
 var dTarget;
-function save()
-{
+function save() {
    document.forms[0].update_content.value=1;
    document.forms[0].submit();
 }
 
-function deletepreview(layer_id)
-{
+function deletepreview(layer_id) {
 	var url = String(document.location);
 	url = url.substr(0, url.indexOf('?'));
-	window.open(url+"?<?php echo strip_tags(SID);?>&guiID=<?php echo $_REQUEST["guiID"]?>&elementID=<?php echo $_REQUEST["elementID"];?>&delete_preview=1&layer_id="+layer_id,'delete preview', 'height=50, width=150, dependent=yes');
+	window.open(url+"?<?php echo $urlParameters; ?>&delete_preview=1&layer_id="+layer_id,'delete preview', 'height=50, width=150, dependent=yes');
 	document.getElementById(layer_id+"_dp").style.display="none";
 }
 
-function pick_the_date(obj)
-{
+function pick_the_date(obj) {
     dTarget = obj;
-    var dp =
-window.open('../extensions/datepicker/datepicker.php?m=Jan_Feb_Mrz_Apr_Mai_Jun_Jul_Aug_Sep_Okt_Nov_Dez&d=Mo_Di_Mi_Do_Fr_Sa_So&t=heute','dp','left=200,top=200,width=230,height=210,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0');
+	var datePickerParameters = "m=Jan_Feb_Mrz_Apr_Mai_Jun_Jul_Aug_Sep_Okt_Nov_Dez&d=Mo_Di_Mi_Do_Fr_Sa_So&t=heute";
+	var datePickerStyle = "left=200,top=200,width=230,height=210,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0"
+    var dp = window.open('../extensions/datepicker/datepicker.php?' + datePickerParameters,'dp',datePickerStyle);
     dp.focus();
-    return false
+    return false;
 }
 </script>
 </head>
 <body>
 <?php
 
-function guessTimestamp($timestr) 
-{
+function guessTimestamp($timestr) {
 	
-     if (mb_strpos($timestr, '.'))
-     {
+     if (mb_strpos($timestr, '.')) {
         list($day, $month, $year) = explode(".", $timestr);
      }
-     elseif (mb_strpos($timestr, '/'))
-     {
+     elseif (mb_strpos($timestr, '/')) {
         list($month, $day, $year) = explode("/", $timestr);
      }
-     elseif (mb_strpos($timestr, '-'))
-     {
+     elseif (mb_strpos($timestr, '-')) {
         list($year, $month, $day) = explode("-", $timestr);
      }
-     else
-     {
+     else {
      	$year = 0;
         $month = 0;
         $day = 0;
      }
      return mktime(0, 0, 0, $month, $day, intval($year));
-
 }
 
 #Update handling
@@ -140,10 +122,8 @@
 
     $res_update_wms_sql = db_prep_query($update_wms_sql, $v, $t);
 
-    while(list($key,$val) = each($_REQUEST))
-    {
-        if(preg_match("/___/", $key))
-        {
+    while(list($key,$val) = each($_REQUEST)) {
+        if(preg_match("/___/", $key)) {
             $myKey = explode("___", $key);
             $layer_id = preg_replace("/L_/","",$myKey[0]);
             if($myKey[1]=="layer_abstract") {
@@ -290,7 +270,7 @@
     die("Preview has been deleted!</body></html>");
 }
 ?>
-<form name='form1' action='<?php echo $self; ?>' method='post'>
+<form name='form1' action='<?php echo $self . "&show_wms_list=true"; ?>' method='post'>
 
 <table border='0'>
 <tr>
@@ -498,15 +478,10 @@
 <?php }*/?>
         </td>
         </tr>
-                    
-    
     <?php
     }
-
-
     #editWMSByWMSID(961);
     ?>
-    
     </table>
     <input type='hidden' name='update_content' value=''/>
     <input type='hidden' name='wms_id' value='<?php echo $wms_id ?>'/>
@@ -519,4 +494,4 @@
     </html>
 <?php
 }
-?>
+?>
\ No newline at end of file

Modified: branches/nimix_dev/http/php/mod_exportMapImage_server.php
===================================================================
--- branches/nimix_dev/http/php/mod_exportMapImage_server.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/php/mod_exportMapImage_server.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -39,7 +39,15 @@
 $array_file["filename"] = "image"; 
 
 $array_urls = explode("___", $wms_urls);
-$image = new weldMaps2Image($array_urls, $array_file);
+foreach ($array_urls as $key => $value) {
+      if (is_null($value) || $value=="") {
+        unset($array_urls[$key]);
+      }
+}
+
+$new_array = array_values($array_urls); 
+		
+$image = new weldMaps2Image($new_array, $array_file);
 $image->getImage($imageType, 'file');
 
  

Modified: branches/nimix_dev/http/php/mod_layerMetadata.php
===================================================================
--- branches/nimix_dev/http/php/mod_layerMetadata.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/php/mod_layerMetadata.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -19,6 +19,8 @@
 
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
 
+$redirectToMetadataUrl = $_GET["redirectToMetadataUrl"];
+
 function display_text($string) {
     $string = mb_eregi_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\" target=_blank>\\0</a>", $string);   
     $string = mb_eregi_replace("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@([0-9a-z](-?[0-9a-z])*\.)+[a-z]{2}([zmuvtg]|fo|me)?$", "<a href=\"mailto:\\0\" target=_blank>\\0</a>", $string);   
@@ -37,24 +39,21 @@
 	}
 	return trim($epsg_list);
 }
-?>
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
-	<head>
-		<title>Metadaten</title>
-		<meta name="description" content="Metadaten" xml:lang="de" />
-		<meta name="keywords" content="Metadaten" xml:lang="de" />		
-		<meta http-equiv="cache-control" content="no-cache">
-		<meta http-equiv="pragma" content="no-cache">
-		<meta http-equiv="expires" content="0">
-		<meta http-equiv="content-language" content="de" />
-		<meta http-equiv="content-style-type" content="text/css" />	
-		<link rel="stylesheet" type="text/css" href="../css/metadata.css" />	
-<?php
-	echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';	
-?>
-	</head>
-	<body>
-<?php
+$metadataStr = "";
+$metadataStr .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">' . 
+	'<head>' . 
+		'<title>Metadaten</title>' . 
+		'<meta name="description" content="Metadaten" xml:lang="de" />'.
+		'<meta name="keywords" content="Metadaten" xml:lang="de" />'	.	
+		'<meta http-equiv="cache-control" content="no-cache">'.
+		'<meta http-equiv="pragma" content="no-cache">'.
+		'<meta http-equiv="expires" content="0">'.
+		'<meta http-equiv="content-language" content="de" />'.
+		'<meta http-equiv="content-style-type" content="text/css" />'.
+		'<link rel="stylesheet" type="text/css" href="../css/metadata.css" />' .
+		'<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">' . 	
+	'</head>'.
+	'<body>';
 	$layer_id = $_GET['id'];
 	$wms_getmap = urldecode($_GET['wms']); 
 	$layer_name = urldecode($_GET['name']); 
@@ -85,7 +84,7 @@
 	}
 	else die("layer not specified!");
 	$res = db_prep_query($sql,$v,$t);
-	echo db_error();
+	$metadataStr .=  db_error();
 	$layer = array();
 	$row = db_fetch_array($res);
 	$layer_id = $row['layer_id'];
@@ -101,8 +100,18 @@
 	$layer['Titel'] = $row['layer_title'];
 	$layer['Zusammenfassung'] = $row['layer_abstract'];
 	if ($row['layer_pos'] || $row['layer_parent']) {
-		$layer['Minscale'] = $row['layer_minscale'];
-		$layer['Maxscale'] = $row['layer_maxscale'];
+	  if ($row['layer_minscale'] > 0)
+		{
+		$layer['Minscale'] = "1 : ". $row['layer_minscale'];
+		}
+		else
+		{$layer['Minscale'] = "-";}
+		if ($row['layer_maxscale'] > 0)
+		{
+		$layer['Maxscale'] = "1 : ". $row['layer_maxscale'];
+		}
+		else
+		{$layer['Maxscale'] = "-";}
 	}
 	$layer['Koordinatensysteme'] = preg_replace("/ /", ", ", getEpsgByLayerId($row['layer_id']));
 //	$layer['Capabilities-Dokument'] = "<a href = '../x_geoportal/getCapabilities_document.php?wms_request=".$row['wms_id']."&layer_request=".$row['layer_pos']."' target=_blank>Capabilities-Dokument</a>";
@@ -128,39 +137,45 @@
 	$layer['Fax'] = $row['contactfacsimiletelephone'];
 	$layer['E-Mail'] = $row['contactelectronicmailaddress'];
 	$layer['Land'] = $row['country'];
+	$layer['Metadaten'] = $row['layer_metadataurl'];
+	$metadataUrl = $row['layer_metadataurl'];
 
-	echo "<table >\n";
-	$t_a = "\t<tr>\n\t\t<th>\n\t\t\t";
-	$t_b = "\n\t\t</th>\n\t\t<td>\n\t\t\t";
-	$t_c = "\n\t\t</td>\n\t</tr>\n";
-
-	$keys = array_keys($layer);
-	for ($j=0; $j<count($layer); $j++) {
-		echo $t_a . $keys[$j] . $t_b . display_text($layer[$keys[$j]]) . $t_c;
+	if ($layer['Metadaten'] && $redirectToMetadataUrl) {
+		header("Location: " . $layer['Metadaten']);		
+	}	
+	else {
+		$metadataStr .=  "<table >\n";
+		$t_a = "\t<tr>\n\t\t<th>\n\t\t\t";
+		$t_b = "\n\t\t</th>\n\t\t<td>\n\t\t\t";
+		$t_c = "\n\t\t</td>\n\t</tr>\n";
+	
+		$keys = array_keys($layer);
+		for ($j=0; $j<count($layer); $j++) {
+			$metadataStr .=  $t_a . $keys[$j] . $t_b . display_text($layer[$keys[$j]]) . $t_c;
+		}
+	
+		if (!$row['layer_pos'] && !$row['layer_parent']) {
+			$wms_id = $row['wms_id'];
+			$sql = "SELECT layer.layer_title, layer.layer_id FROM layer WHERE fkey_wms_id = $1 AND layer_pos <> 0";
+			$v = array($wms_id);
+			$t = array('i');
+			$res = db_prep_query($sql,$v,$t);
+			$i=0;
+			$layer = array();
+			while ($row = db_fetch_array($res)) {
+				$layer[$i] = array();
+				$layer[$i]['Titel'] = $row['layer_title'];
+				$layer[$i]['id'] = $row['layer_id'];
+				$i++;
+			}
+			$metadataStr .=  "<tr><th>Ebenen</th><td>";
+			for ($i=0; $i<count($layer); $i++) {
+				if ($i >0) $metadataStr .=  ", ";
+				$metadataStr .=  "<a href='mod_layerMetadata.php?id=".$layer[$i]['id']."'>" . $layer[$i]['Titel'] . "</a>";
+			}
+		}	
+		$metadataStr .=  "</td></tr></table>\n";
+		$metadataStr .=  '</div></body></html>';
+		echo $metadataStr;
 	}
-
-	if (!$row['layer_pos'] && !$row['layer_parent']) {
-		$wms_id = $row['wms_id'];
-		$sql = "SELECT layer.layer_title, layer.layer_id FROM layer WHERE fkey_wms_id = $1 AND layer_pos <> 0";
-		$v = array($wms_id);
-		$t = array('i');
-		$res = db_prep_query($sql,$v,$t);
-		$i=0;
-		$layer = array();
-		while ($row = db_fetch_array($res)) {
-			$layer[$i] = array();
-			$layer[$i]['Titel'] = $row['layer_title'];
-			$layer[$i]['id'] = $row['layer_id'];
-			$i++;
-		}
-		echo "<tr><th>Ebenen</th><td>";
-		for ($i=0; $i<count($layer); $i++) {
-			if ($i >0) echo ", ";
-			echo "<a href='mod_layerMetadata.php?id=".$layer[$i]['id']."'>" . $layer[$i]['Titel'] . "</a>";
-		}
-	}	
-	echo "</td></tr></table>\n";
 ?>
-	</div>
-	</body>
-</html>
\ No newline at end of file

Modified: branches/nimix_dev/http/php/mod_switchLocale.php
===================================================================
--- branches/nimix_dev/http/php/mod_switchLocale.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/php/mod_switchLocale.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -1,69 +0,0 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/localeSwitch
-# Copyright (C) 2002 CCGIS 
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-require_once(dirname(__FILE__)."/../classes/class_administration.php");
-
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-<meta name="author" content="V. Diewald">
-<meta http-equiv="cache-control" content="no-cache">
-<meta http-equiv="pragma" content="no-cache">
-<meta http-equiv="expires" content="0">
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<meta name="DC.Rights" content="WhereGroup GmbH & Co.KG, Bonn">
-<title>Metadata search</title>
-<?
-include_once(dirname(__FILE__) . "/../include/dyn_css.php");
-?>
-<script type="text/javascript">
-<!--
-
-function validate(){
-	var index = document.getElementById("language").selectedIndex;
-	var lang = document.getElementById("language").options[index].value;
-	parent.mb_ajax_post("../php/mod_setLocale.php", {"lang":lang}, function(status,result) {
-		parent.window.location.reload();	
-	});
-}
-
-// -->
-</script>
-</head>
-<body leftmargin="2" topmargin="0" bgcolor="#ffffff">
-<form name='form1' target='parent'>
-<p>
-<select id='language' name='language' onchange='validate()'>
-<?php
-$languageArray = explode(",", $languages);
-for ($i = 0; $i < count($languageArray); $i++) {
-	echo "<option";
-	if ($_SESSION["mb_lang"] == $languageArray[$i]) {
-		echo " selected";
-	}
-	echo ">" . $languageArray[$i] . "</option>";
-}
-?>
-</select>
-</p>
-</form>
-</body>
-</html>
\ No newline at end of file

Modified: branches/nimix_dev/http/php/mod_switchLocale_noreload.php
===================================================================
--- branches/nimix_dev/http/php/mod_switchLocale_noreload.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/php/mod_switchLocale_noreload.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -1,62 +0,0 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/localeSwitch
-# Copyright (C) 2002 CCGIS 
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-require_once(dirname(__FILE__)."/../classes/class_administration.php");
-
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-<title>Metadata search</title>
-<?php
-include(dirname(__FILE__) . "/../include/dyn_css.php");
-?>
-<script type="text/javascript">
-<!--
-
-function validate(){
-	var index = document.getElementById("language").selectedIndex;
-	var lang = document.getElementById("language").options[index].value;
-	parent.mb_ajax_post("../php/mod_setLocale.php", {"lang":lang}, function(result, status) {
-		parent.mapbender.locale = result;
-		parent.localize();	
-	});
-}
-
-// -->
-</script>
-</head>
-<body leftmargin="2" topmargin="0" bgcolor="#ffffff">
-<form name='form1' target='parent'>
-<select id='language' name='language' onchange='validate()'>
-<?php
-$languageArray = explode(",", $languages);
-for ($i = 0; $i < count($languageArray); $i++) {
-	echo "<option";
-	if ($_SESSION["mb_lang"] == $languageArray[$i]) {
-		echo " selected";
-	}
-	echo ">" . $languageArray[$i] . "</option>";
-}
-?>
-</select>
-</form>
-</body>
-</html>
\ No newline at end of file

Modified: branches/nimix_dev/http/php/mod_tab_messages.php
===================================================================
--- branches/nimix_dev/http/php/mod_tab_messages.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/php/mod_tab_messages.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -18,7 +18,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
 require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
 
 $buttonObj = array();
@@ -38,7 +38,7 @@
 	array_push($buttonObj, array("id" => $row["e_id"], "title" => $row["e_title"]));
 }
 
-$json = new Services_JSON();
+$json = new Mapbender_JSON();
 $output = $json->encode($buttonObj);
 
 header("Content-type:text/plain; charset=utf-8");

Modified: branches/nimix_dev/http/php/mod_wfs.php
===================================================================
--- branches/nimix_dev/http/php/mod_wfs.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/php/mod_wfs.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -165,6 +165,7 @@
 			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'] = '".$row["f_auth_varname"]."';";
+			echo "wfs_conf[".$i."]['element'][".$cnt."]['f_operator'] = '".$row["f_operator"]."';";
 			$cnt++;
 		}
 		if($cnt == 0){die("wfs_conf data not available");}		

Modified: branches/nimix_dev/http/php/mod_wfsSpatialRequest_messages.php
===================================================================
--- branches/nimix_dev/http/php/mod_wfsSpatialRequest_messages.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/php/mod_wfsSpatialRequest_messages.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -18,7 +18,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
 
 $e = new mb_notice("locale: " . $_SESSION["mb_locale"] . "; lang: " . $_SESSION["mb_lang"]);
 setlocale(LC_ALL, $_SESSION["mb_locale"]);
@@ -27,14 +27,14 @@
 // Messages
 //
 $msg_obj = array();
-$msg_obj["buttonLabelRectangle"] = _("select by rectangle");
-$msg_obj["buttonLabelPolygon"] = _("select by polygon");
-$msg_obj["buttonLabelPoint"] = _("select by point");
-$msg_obj["buttonLabelExtent"] = _("select by extent");
-$msg_obj["buttonLabelDialogue"] = _("open dialogue form");
-$msg_obj["errorMessageInvalidExtent"] = _("Invalid box!");
+$msg_obj["buttonLabelRectangle"] = _mb("select by rectangle");
+$msg_obj["buttonLabelPolygon"] = _mb("select by polygon");
+$msg_obj["buttonLabelPoint"] = _mb("select by point");
+$msg_obj["buttonLabelExtent"] = _mb("select by extent");
+$msg_obj["buttonLabelDialogue"] = _mb("open dialogue form");
+$msg_obj["errorMessageInvalidExtent"] = _mb("Invalid box!");
 
-$json = new Services_JSON();
+$json = new Mapbender_JSON();
 $output = $json->encode($msg_obj);
 
 header("Content-type:application/x-json; charset=utf-8");

Modified: branches/nimix_dev/http/php/mod_wfs_server.php
===================================================================
--- branches/nimix_dev/http/php/mod_wfs_server.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/php/mod_wfs_server.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -2,9 +2,9 @@
 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__) . "/../extensions/JSON.php");
+require_once(dirname(__FILE__) . "/../classes/class_json.php");
 
-$json = new Services_JSON();
+$json = new Mapbender_JSON();
 $obj = $json->decode(stripslashes($_REQUEST['obj']));
 
 //workflow:

Modified: branches/nimix_dev/http/php/system.php
===================================================================
--- branches/nimix_dev/http/php/system.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/php/system.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -20,8 +20,8 @@
 # mapbender version
 #
 define("MB_VERSION_NUMBER", "2.5.0");
-define("MB_VERSION_APPENDIX", "RC1");
-define("MB_RELEASE_DATE", mktime(0,0,0,3,6,2008));//h, min,sec,month,day,year
+define("MB_VERSION_APPENDIX", "RC2");
+define("MB_RELEASE_DATE", mktime(0,0,0,4,21,2008));//h, min,sec,month,day,year
 
 #
 # constants from map.js

Modified: branches/nimix_dev/http/sld/classes/Rule.php
===================================================================
--- branches/nimix_dev/http/sld/classes/Rule.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/sld/classes/Rule.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -158,7 +158,7 @@
 			$temp .= $offset."   <td>\n";
 			$temp .= $offset."    <input type=\"hidden\" name=\"".$id."_filter\" value=\"".htmlspecialchars($this->filter)."\">\n";
 			$temp .= $offset."    	<img src='./img/lightning.png' class='hand' border='0' alt='Filter bearbeiten'";
-			$temp .= "onClick=\"window.open('sld_edit_filter.php?sld_form_element_id=".$id."_filter&sld_objects_rule_id=".$this->id."','editFilter',";
+			$temp .= "onClick=\"window.open('sld_edit_filter.php?".$urlParameters."&sld_form_element_id=".$id."_filter&sld_objects_rule_id=".$this->id."','editFilter',";
 			$temp .= " 'width=1000, height=800, resizable=yes');\">\n";
 			$temp .= $offset."   </td>\n";
 			$temp .= $offset."  </tr>\n";

Modified: branches/nimix_dev/http/sld/classes/StyledLayerDescriptor.php
===================================================================
--- branches/nimix_dev/http/sld/classes/StyledLayerDescriptor.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/sld/classes/StyledLayerDescriptor.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -83,7 +83,6 @@
 	 */
 	function generateXml($offset = "")
 	{
-		#$temp = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
 		$temp = $offset."<StyledLayerDescriptor";
 		if ($this->version != "") $temp .= " version=\"".htmlspecialchars($this->version)."\"";
 		$temp .= " xsi:schemaLocation=\"http://www.opengis.net/sld StyledLayerDescriptor.xsd\"";

Modified: branches/nimix_dev/http/sld/sld_config.php
===================================================================
--- branches/nimix_dev/http/sld/sld_config.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/sld/sld_config.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -25,14 +25,12 @@
  */
 
 include_once(dirname(__FILE__)."/classes/StyledLayerDescriptor.php");
-
-session_start();
-
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
 include_once(dirname(__FILE__)."/sld_parse.php");
 
 // this should come from mapbender.conf
-$SLD_MAIN = "sld_main.php?".SID;
-$SLD_FUNCTION_HANDLER = "sld_function_handler.php";
+$SLD_MAIN = "sld_main.php?".$urlParameters;
+$SLD_FUNCTION_HANDLER = "sld_function_handler.php?".$urlParameters;
 $MAPBENDER_URL = "http://".$_SERVER["HTTP_HOST"].dirname($_SERVER['PHP_SELF']);
 
 function char_encode($s){
@@ -42,15 +40,15 @@
 	return $s;
 }
 
-if (isset($_REQUEST["wms_id"]) && isset($_REQUEST["gui_id"]))
+if (isset($_REQUEST["sld_wms_id"]) && isset($_REQUEST["sld_gui_id"]))
 {
-	$_SESSION["sld_wms_id"] = $_REQUEST["wms_id"];
-	$_SESSION["sld_gui_id"] = $_REQUEST["gui_id"];
+	$_SESSION["sld_wms_id"] = $_REQUEST["sld_wms_id"];
+	$_SESSION["sld_gui_id"] = $_REQUEST["sld_gui_id"];
 }
 
-if (isset($_REQUEST["layer_name"]))
+if (isset($_REQUEST["sld_layer_name"]))
 {
-	$_SESSION["sld_layer_name"] = $_REQUEST["layer_name"];
+	$_SESSION["sld_layer_name"] = $_REQUEST["sld_layer_name"];
 }
 
 if (isset($_SESSION["sld_wms_id"]) && isset($_SESSION["sld_layer_name"]))
@@ -62,8 +60,11 @@
 	require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
 	$con = db_connect($DBSERVER,$OWNER,$PW);
 	db_select_db($DB,$con);
-	$sql = "SELECT * FROM wms WHERE wms_id = ".$wms_id.";"; 
-	$res = db_query($sql);
+	$sql = "SELECT * FROM wms WHERE wms_id = $1"; 
+	$v = array($wms_id);
+	$t = array('i');
+	$res = db_prep_query($sql,$v,$t);
+	
 	$mapfileUrl = "";
 	if ( db_fetch_row($res, 0) )
 	{

Modified: branches/nimix_dev/http/sld/sld_edit_filter.php
===================================================================
--- branches/nimix_dev/http/sld/sld_edit_filter.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/sld/sld_edit_filter.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -31,7 +31,7 @@
 
 
 include_once(dirname(__FILE__)."/classes/StyledLayerDescriptor.php");
-session_start();
+require_once(dirname(__FILE__)."/sld_config.php");
 include_once(dirname(__FILE__)."/sld_filter_parse.php");
 
 //get the neccessary variables from the request or from the session
@@ -91,22 +91,22 @@
 					$_SESSION["sld_filter_objects"][$_REQUEST["id"]]->operations[] = new UnaryLogicOp("Not");
 					break;
 				case "PROPERTYISEQUALTO":
-					$_SESSION["sld_filter_objects"][$_REQUEST["id"]]->operations[] = new BinaryComparisonOp("ogc:PropertyIsEqualTo");
+					$_SESSION["sld_filter_objects"][$_REQUEST["id"]]->operations[] = new BinaryComparisonOp("PropertyIsEqualTo");
 					break;
 				case "PROPERTYISNOTEQUALTO":
-					$_SESSION["sld_filter_objects"][$_REQUEST["id"]]->operations[] = new BinaryComparisonOp("ogc:PropertyIsNotEqualTo");
+					$_SESSION["sld_filter_objects"][$_REQUEST["id"]]->operations[] = new BinaryComparisonOp("PropertyIsNotEqualTo");
 					break;
 				case "PROPERTYISGREATERTHAN":
-					$_SESSION["sld_filter_objects"][$_REQUEST["id"]]->operations[] = new BinaryComparisonOp("ogc:PropertyIsGreaterThan");
+					$_SESSION["sld_filter_objects"][$_REQUEST["id"]]->operations[] = new BinaryComparisonOp("PropertyIsGreaterThan");
 					break;
 				case "PROPERTYISGREATERTHANOREQUALTO":
-					$_SESSION["sld_filter_objects"][$_REQUEST["id"]]->operations[] = new BinaryComparisonOp("ogc:PropertyIsGreaterThanOrEqualTo");
+					$_SESSION["sld_filter_objects"][$_REQUEST["id"]]->operations[] = new BinaryComparisonOp("PropertyIsGreaterThanOrEqualTo");
 					break;
 				case "PROPERTYISLESSTHAN":
-					$_SESSION["sld_filter_objects"][$_REQUEST["id"]]->operations[] = new BinaryComparisonOp("ogc:PropertyIsLessThan");
+					$_SESSION["sld_filter_objects"][$_REQUEST["id"]]->operations[] = new BinaryComparisonOp("PropertyIsLessThan");
 					break;
 				case "PROPERTYISLESSTHANOREQUALTO":
-					$_SESSION["sld_filter_objects"][$_REQUEST["id"]]->operations[] = new BinaryComparisonOp("ogc:PropertyIsLessThanOrEqualTo");
+					$_SESSION["sld_filter_objects"][$_REQUEST["id"]]->operations[] = new BinaryComparisonOp("PropertyIsLessThanOrEqualTo");
 					break;
 				case "PROPERTYISLIKE":
 					$_SESSION["sld_filter_objects"][$_REQUEST["id"]]->operations[] = new PropertyIsLike();
@@ -175,7 +175,7 @@
 	}
 	
 	
-	header("Location: sld_edit_filter.php");
+	header("Location: sld_edit_filter.php?".$urlParameters);
 	exit();
 }
 else
@@ -221,7 +221,7 @@
 	if ($first_load != 1) echo " onLoad=\"setFilter();\"";
 	echo ">\n";
 	
-	echo "<form name=\"editFilter\" action=\"sld_edit_filter.php\" method=\"post\">\n";
+	echo "<form name=\"editFilter\" action=\"sld_edit_filter.php?".$urlParameters."\" method=\"post\">\n";
 	
 	echo "<table cellspacing=\"0\" cellpadding=\"0\">\n";
 	echo "<tr align=\"center\"><td class=\"bg2 text3\">Filter bearbeiten</td></tr>\n";

Modified: branches/nimix_dev/http/sld/sld_filter_parse.php
===================================================================
--- branches/nimix_dev/http/sld/sld_filter_parse.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/sld/sld_filter_parse.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -27,7 +27,6 @@
 
 
 include_once(dirname(__FILE__)."/classes/StyledLayerDescriptor.php");
-session_start();
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
 
 /**

Added: branches/nimix_dev/http/sld/sld_function_getusersld.php
===================================================================
--- branches/nimix_dev/http/sld/sld_function_getusersld.php	                        (rev 0)
+++ branches/nimix_dev/http/sld/sld_function_getusersld.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,140 @@
+<?php
+# $Id: sld_function_getusersld.php 2412 2008-04-23 16:14:30Z christoph $
+# http://www.mapbender.org/index.php/SLD
+# 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.
+
+/**
+ * This file realizes the function handling for the sld editor.
+ * Requests from the sld_edit_form are forwarded to this page.
+ * After processing the requested function this file forwards to the
+ * sld_main.php.
+ * Only if the request is to get the sld it will not forward to sld_main.php - 
+ * in this case this file will return the requested sld-document instead.
+ * 
+ * @package sld_function_handler
+ * @author Markus Krzyzanowski
+ */
+
+include_once(dirname(__FILE__)."/classes/StyledLayerDescriptor.php");
+include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+include_once(dirname(__FILE__)."/sld_parse.php");
+
+/**
+ * This function saves the data into the database
+ * @param string $data the content of the sld-document to be stored inside the database
+ */
+
+if (isset($_REQUEST["function"]))
+{
+	// the function "getusersld" is called by the mapserver to get the user's sld
+	if ($_REQUEST["function"] == "getusersld")
+	{
+		if ( isset($_REQUEST["sld_layer_id"]) && isset($_REQUEST["sld_gui_id"]) && isset($_REQUEST["user_id"]) )
+		{ //Used for the preview
+			$con = db_connect($DBSERVER,$OWNER,$PW);
+			db_select_db($DB,$con);
+			$sql = "SELECT * FROM sld_user_layer WHERE fkey_gui_id=$1 AND fkey_layer_id=$2 AND fkey_mb_user_id=$3";
+			$v = array($_REQUEST["sld_gui_id"], $_REQUEST["sld_layer_id"], $_REQUEST["user_id"]);
+			$t = array('s', 'i', 'i');
+			$res = db_prep_query($sql,$v,$t);			
+
+			if ( db_fetch_row($res, 0) )
+			{
+				//forcesld is used for the preview image to force the sld
+				if ( db_result($res, 0, "use_sld") == "1" || $_REQUEST["forcesld"] == "1" )
+				{
+					echo db_result($res, 0, "sld_xml");
+				}
+			}
+		} //Used for mapbender integration - old deprecated
+		else if ( isset($_REQUEST["sld_layer_names"]) && isset($_REQUEST["user_id"]) )
+		{
+			$layer_names = split(",", urldecode($_REQUEST["sld_layer_names"]));
+			
+			$con = db_connect($DBSERVER,$OWNER,$PW);
+			db_select_db($DB,$con);
+			
+			/*$sld_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<StyledLayerDescriptor version=\"1.0.0\">\n";*/
+			$sld_xml = "<StyledLayerDescriptor version=\"1.0.0\" xmlns=\"http://www.opengis.net/sld\" xmlns:ogc=\"http://www.opengis.net/ogc\">\n";
+			
+			foreach ($layer_names as $layer_name)
+			{
+				$sql = "SELECT * FROM layer WHERE layer_name=$1";
+				$v = array($layer_name);
+				$t = array('s');
+				$res = db_prep_query($sql,$v,$t);				
+
+				$layer_id = "";
+				if ( db_fetch_row($res, 0) )
+				{
+					$layer_id = db_result($res, 0, "fkey_layer_id");
+					$sql = "SELECT * FROM sld_user_layer WHERE fkey_layer_id=$1 AND fkey_mb_user_id=$2";
+					$v = array($layer_id, $_REQUEST["user_id"]);
+					$t = array('i', 'i');
+					$res = db_prep_query($sql,$v,$t);
+					
+					if ( db_fetch_row($res, 0) )
+					{
+						if ( db_result($res, 0, "use_sld") == "1" )
+						{
+							$data = db_result($res, 0, "sld_xml");
+							$styledlayerdescriptor = parseSld($data);
+							$sld_xml .= $styledlayerdescriptor->layers[0]->generateXml(" ");
+						}
+					}
+				}
+			}
+			$sld_xml .= "</StyledLayerDescriptor>";
+			echo $sld_xml;
+		} //Used for mapbender integration
+		else if ( isset($_REQUEST["sld_wms_id"]) && isset($_REQUEST["sld_gui_id"]) )
+		{
+		
+			$con = db_connect($DBSERVER,$OWNER,$PW);
+			db_select_db($DB,$con);
+			$sql = "SELECT fkey_layer_id FROM gui_layer WHERE fkey_gui_id=$1 AND gui_layer_wms_id=$2";
+			$v = array($_REQUEST["sld_gui_id"], $_REQUEST["sld_wms_id"]);
+			$t = array('s', 'i');
+			$res = db_prep_query($sql,$v,$t);
+			
+			$sld_xml = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
+			$sld_xml .= "<StyledLayerDescriptor version=\"1.0.0\" xmlns=\"http://www.opengis.net/sld\" xmlns:ogc=\"http://www.opengis.net/ogc\">\n";			
+
+			while ($row = db_fetch_row($res))
+			{
+				$layer_id = $row[0];
+				$sql = "SELECT * FROM sld_user_layer WHERE fkey_layer_id=$1 AND fkey_gui_id=$2";
+				$v = array($layer_id, $_REQUEST["sld_gui_id"]);
+				$t = array('i', 's');
+				$res2 = db_prep_query($sql,$v,$t);
+
+				if ( db_fetch_row($res2, 0) )
+				{
+					if ( db_result($res2, 0, "use_sld") == "1" )
+					{
+						$data = db_result($res2, 0, "sld_xml");
+						$styledlayerdescriptor = parseSld($data);
+						$sld_xml .= $styledlayerdescriptor->layers[0]->generateXml(" ");
+					}
+				}
+			}
+			$sld_xml .= "</StyledLayerDescriptor>";
+			echo $sld_xml;
+		}
+	}
+}
+?>

Modified: branches/nimix_dev/http/sld/sld_function_handler.php
===================================================================
--- branches/nimix_dev/http/sld/sld_function_handler.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/sld/sld_function_handler.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -29,14 +29,9 @@
  * @author Markus Krzyzanowski
  */
 
-
-//session_start();
 include_once(dirname(__FILE__)."/sld_config.php");
-
 include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
 
-
-
 /**
  * This function saves the data into the database
  * @param string $data the content of the sld-document to be stored inside the database
@@ -45,15 +40,13 @@
 {	
 	$con = db_connect($DBSERVER,$OWNER,$PW);
 	db_select_db($DB,$con);
-	$sql = "UPDATE sld_user_layer SET sld_xml='".$data."' WHERE fkey_gui_id='".$_SESSION["sld_gui_id"]."' AND fkey_layer_id=".$_SESSION["sld_layer_id"]." AND fkey_mb_user_id=".$_SESSION["mb_user_id"].";";
-	$res = db_query($sql);
+	$sql = "UPDATE sld_user_layer SET sld_xml=$1 WHERE fkey_gui_id=$2 AND fkey_layer_id=$3 AND fkey_mb_user_id=$4";
+	$v = array($data, $_SESSION["sld_gui_id"], $_SESSION["sld_layer_id"], $_SESSION["mb_user_id"]);
+	$t = array('s', 's', 'i', 'i');
+	$res = db_prep_query($sql,$v,$t);
 }
 
 
-
-
-
-
 if (isset($_REQUEST["function"]))
 {
 	//MAIN FUNCTIONS:
@@ -70,15 +63,17 @@
 		$styledlayerdescriptor->generateObjectFromPost();
 		saveSld($styledlayerdescriptor->generateXml());
 	}
-	// the function "getusersld" is called by the mapserver to get the user's sld
+	/* the function "getusersld" is called by the mapserver to get the user's sld
 	else if ($_REQUEST["function"] == "getusersld")
 	{
-		if ( isset($_REQUEST["layer_id"]) && isset($_REQUEST["gui_id"]) && isset($_REQUEST["user_id"]) )
+		if ( isset($_REQUEST["sld_layer_id"]) && isset($_REQUEST["sld_gui_id"]) && isset($_REQUEST["user_id"]) )
 		{ //Used for the preview
 			$con = db_connect($DBSERVER,$OWNER,$PW);
 			db_select_db($DB,$con);
-			$sql = "SELECT * FROM sld_user_layer WHERE fkey_gui_id='".$_REQUEST["gui_id"]."' AND fkey_layer_id=".$_REQUEST["layer_id"]." AND fkey_mb_user_id=".$_REQUEST["user_id"].";";
-			$res = db_query($sql);
+			$sql = "SELECT * FROM sld_user_layer WHERE fkey_gui_id=$1 AND fkey_layer_id=$2 AND fkey_mb_user_id=$3";
+			$v = array($_REQUEST["sld_gui_id"], $_REQUEST["sld_layer_id"], $_REQUEST["user_id"]);
+			$t = array('s', 'i', 'i');
+			$res = db_prep_query($sql,$v,$t);
 			if ( db_fetch_row($res, 0) )
 			{
 				//forcesld is used for the preview image to force the sld
@@ -95,20 +90,24 @@
 			$con = db_connect($DBSERVER,$OWNER,$PW);
 			db_select_db($DB,$con);
 			
-			/*$sld_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<StyledLayerDescriptor version=\"1.0.0\">\n";*/
+			#$sld_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<StyledLayerDescriptor version=\"1.0.0\">\n";
 			$sld_xml = "<StyledLayerDescriptor version=\"1.0.0\" xmlns=\"http://www.opengis.net/sld\" xmlns:ogc=\"http://www.opengis.net/ogc\">\n";
 			
 			foreach ($layer_names as $layer_name)
 			{
-				$sql = "SELECT * FROM layer WHERE layer_name='".$layer_name."';";
-				$res = db_query($sql);
+				$sql = "SELECT * FROM layer WHERE layer_name=$1";
+				$v = array($layer_name);
+				$t = array('s');
+				$res = db_prep_query($sql,$v,$t);
 
 				$layer_id = "";
 				if ( db_fetch_row($res, 0) )
 				{
 					$layer_id = db_result($res, 0, "fkey_layer_id");
-					$sql = "SELECT * FROM sld_user_layer WHERE fkey_layer_id=".$layer_id." AND fkey_mb_user_id=".$_REQUEST["user_id"].";";
-					$res = db_query($sql);
+					$sql = "SELECT * FROM sld_user_layer WHERE fkey_layer_id=$1 AND fkey_mb_user_id=$2";
+					$v = array($layer_id, $_REQUEST["user_id"]);
+					$t = array('i', 'i');
+					$res = db_prep_query($sql,$v,$t);
 					if ( db_fetch_row($res, 0) )
 					{
 						if ( db_result($res, 0, "use_sld") == "1" )
@@ -123,13 +122,15 @@
 			$sld_xml .= "</StyledLayerDescriptor>";
 			echo $sld_xml;
 		} //Used for mapbender integration
-			else if ( isset($_REQUEST["wms_id"]) && isset($_REQUEST["gui_id"]) )
+			else if ( isset($_REQUEST["sld_wms_id"]) && isset($_REQUEST["sld_gui_id"]) )
 		{
 		
 			$con = db_connect($DBSERVER,$OWNER,$PW);
 			db_select_db($DB,$con);
-			$sql = "SELECT fkey_layer_id FROM gui_layer WHERE fkey_gui_id='".$_REQUEST["gui_id"]."' AND gui_layer_wms_id=".$_REQUEST["wms_id"].";";
-			$res = db_query($sql);
+			$sql = "SELECT fkey_layer_id FROM gui_layer WHERE fkey_gui_id=$1 AND gui_layer_wms_id=$2";
+			$v = array($_REQUEST["sld_gui_id"], $_REQUEST["sld_wms_id"]);
+			$t = array('s', 'i');
+			$res = db_prep_query($sql,$v,$t);
 			
 			$sld_xml = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
 			$sld_xml .= "<StyledLayerDescriptor version=\"1.0.0\" xmlns=\"http://www.opengis.net/sld\" xmlns:ogc=\"http://www.opengis.net/ogc\">\n";			
@@ -137,8 +138,10 @@
 			while ($row = db_fetch_row($res))
 			{
 				$layer_id = $row[0];
-				$sql = "SELECT * FROM sld_user_layer WHERE fkey_layer_id=".$layer_id." AND fkey_gui_id='".$_REQUEST["gui_id"]."';";
-				$res2 = db_query($sql);
+				$sql = "SELECT * FROM sld_user_layer WHERE fkey_layer_id=$1 AND fkey_gui_id=$2";
+				$v = array($layer_id, $_REQUEST["sld_gui_id"]);
+				$t = array('i', 's');
+				$res2 = db_prep_query($sql,$v,$t);
 				if ( db_fetch_row($res2, 0) )
 				{
 					if ( db_result($res2, 0, "use_sld") == "1" )
@@ -152,7 +155,7 @@
 			$sld_xml .= "</StyledLayerDescriptor>";
 			echo $sld_xml;
 		}
-	}
+	} */
 	// sets whether the user wishes to use a sld for this layer
 	else if ($_REQUEST["function"] == "usesld")
 	{
@@ -160,14 +163,18 @@
 		{
 			$con = db_connect($DBSERVER,$OWNER,$PW);
 			db_select_db($DB,$con);
-			$sql = "UPDATE sld_user_layer SET use_sld=".$_REQUEST["use_sld"]." WHERE fkey_gui_id='".$_SESSION["sld_gui_id"]."' AND fkey_layer_id='".$_SESSION["sld_layer_id"]."' AND fkey_mb_user_id='".$_SESSION["mb_user_id"]."';";
-			$res = db_query($sql);
+			$sql = "UPDATE sld_user_layer SET use_sld=$1 WHERE fkey_gui_id=$2 AND fkey_layer_id=$3 AND fkey_mb_user_id=$4";
+			$v = array($_REQUEST["use_sld"], $_SESSION["sld_gui_id"], $_SESSION["sld_layer_id"], $_SESSION["mb_user_id"]);
+			$t = array('i', 's', 'i', 'i');
+			$res = db_prep_query($sql,$v,$t);
 			
 			# update gui_wms_sldurl
 			if ($_REQUEST["use_sld"]=="1") {
 				$sld_url = $_REQUEST["mb_sld_url"];
-				$sql = "UPDATE gui_wms SET gui_wms_sldurl='".$sld_url."' WHERE fkey_gui_id='".$_SESSION["sld_gui_id"]."' AND fkey_wms_id=".$_SESSION["sld_wms_id"];
-				$res = db_query($sql); 
+				$sql = "UPDATE gui_wms SET gui_wms_sldurl=$1 WHERE fkey_gui_id=$2 AND fkey_wms_id=$3";
+				$v = array($sld_url, $_SESSION["sld_gui_id"], $_SESSION["sld_wms_id"]);
+				$t = array('s', 's', 'i');
+				$res = db_prep_query($sql,$v,$t); 
 			}
 		}
 	}

Modified: branches/nimix_dev/http/sld/sld_main.php
===================================================================
--- branches/nimix_dev/http/sld/sld_main.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/sld/sld_main.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -25,33 +25,17 @@
  * @package sld_main
  * @author Markus Krzyzanowski
  */
-require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+
+require_once(dirname(__FILE__)."/sld_config.php");
 require_once(dirname(__FILE__)."/../classes/class_wfs_conf.php");
 $classWfsConf = new wfs_conf();
 
-include_once(dirname(__FILE__)."/sld_config.php");
-include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
-
-if (isset($_REQUEST["wms_id"]) && isset($_REQUEST["gui_id"]))
-{
-	$_SESSION["sld_wms_id"] = $_REQUEST["wms_id"];
-	$_SESSION["sld_gui_id"] = $_REQUEST["gui_id"];
-}
-
-if (isset($_REQUEST["layer_name"]))
-{
-	$_SESSION["sld_layer_name"] = $_REQUEST["layer_name"];
-}
-
 //read custom sld for this user&wms&layer&gui from the db instead using sld.xml
 
 $con = db_connect($DBSERVER,$OWNER,$PW);
 db_select_db($DB,$con);
 
 //Read the layer_id from the DB
-//$sql = "SELECT * FROM layer WHERE fkey_wms_id=".$_SESSION["sld_wms_id"]." AND layer_name='".$_SESSION["sld_layer_name"]."';";
-//$res = db_query($sql);
-
 $dbutils = new DbUtils();
 $layer_id = $dbutils->getLayerIdFromLayerName($_SESSION["sld_wms_id"], $_SESSION["sld_layer_name"]);
 if ( $layer_id )
@@ -72,8 +56,10 @@
 else
 {
 	//Try to read sld from the DB
-	$sql = "SELECT * FROM sld_user_layer WHERE fkey_gui_id='".$_SESSION["sld_gui_id"]."' AND fkey_layer_id='".$layer_id."' AND fkey_mb_user_id='".$mb_user_id."';";
-	$res = db_query($sql);
+	$sql = "SELECT * FROM sld_user_layer WHERE fkey_gui_id = $1 AND fkey_layer_id = $2 AND fkey_mb_user_id = $3";
+	$v = array($_SESSION["sld_gui_id"], $layer_id, $mb_user_id);
+	$t = array('s', 'i', 'i');
+	$res = db_prep_query($sql,$v,$t);
 	if (!$res || db_numrows($res)== 0)
 	{
 		//No user specific sld found in DB -> get it from the mapserver
@@ -81,8 +67,10 @@
 		$data = readSld($file);
 		$data = char_encode($data);
 		//write the sld to the DB
-		$sql = "INSERT INTO sld_user_layer(fkey_mb_user_id, fkey_layer_id, sld_xml, use_sld, fkey_gui_id) VALUES('".$mb_user_id."','".$layer_id."','".$data."',0,'".$_SESSION["sld_gui_id"]."' );";
-		$res = @db_query($sql);
+		$sql = "INSERT INTO sld_user_layer(fkey_mb_user_id, fkey_layer_id, sld_xml, use_sld, fkey_gui_id) VALUES ($1, $2, $3, 0, $4);";
+		$v = array($mb_user_id, $layer_id, $data, $_SESSION["sld_gui_id"]);
+		$t = array('i', 'i', 's', 's');
+		$res = @db_prep_query($sql,$v,$t);
 		//Use the new sld
 	}
 	else
@@ -144,8 +132,8 @@
 $sld_url = "";
 $mb_sld_url = "";
 //$sld_url = "http://".$_SERVER["HTTP_HOST"]."/mapbender/sld/sld_function_handler.php?function=getusersld&layer_id=".$layer_id."&user_id=".$mb_user_id."&forcesld=1";
-$sld_url = $MAPBENDER_URL."/sld_function_handler.php?function=getusersld&gui_id=".$_SESSION["sld_gui_id"]."&layer_id=".$layer_id."&user_id=".$mb_user_id."&forcesld=1";
-$mb_sld_url = $MAPBENDER_URL."/sld_function_handler.php?function=getusersld&gui_id=".$_SESSION["sld_gui_id"]."&wms_id=".$_SESSION["sld_wms_id"]."&user_id=".$mb_user_id;
+$sld_url = $MAPBENDER_URL."/sld_function_getusersld.php?function=getusersld&sld_gui_id=".$_SESSION["sld_gui_id"]."&sld_layer_id=".$layer_id."&user_id=".$mb_user_id."&forcesld=1";
+$mb_sld_url = $MAPBENDER_URL."/sld_function_getusersld.php?function=getusersld&sld_gui_id=".$_SESSION["sld_gui_id"]."&sld_wms_id=".$_SESSION["sld_wms_id"]."&user_id=".$mb_user_id;
 echo "<!-- $sld_url -->";
 echo "<!-- $previewMapUrl -->";
 ## - 2.Zeile
@@ -258,11 +246,11 @@
 //echo "      <form id=\"sld_editor_form\" action=\"http://".$_SERVER["HTTP_HOST"]."/mapbender/sld/".$SLD_FUNCTION_HANDLER."\" method=post >\n";
 echo "      <form id=\"sld_editor_form\" action=\"".$MAPBENDER_URL."/".$SLD_FUNCTION_HANDLER."\" method=post >\n";
 
-echo "      <a href='".$SLD_FUNCTION_HANDLER."?function=getdefaultsld' onclick='if(!confirm(\"Aktuelle SLD-Definition ersetzen?\")) return false;'>\n";
+echo "      <a href='".$SLD_FUNCTION_HANDLER."&function=getdefaultsld' onclick='if(!confirm(\"Aktuelle SLD-Definition ersetzen?\")) return false;'>\n";
 echo "      <img src='./img/script.png' border='0' alt='Standard SLD aus WMS auslesen'>\n";
 echo "      </a> Standard &ouml;ffnen<br /><br />\n";
 
-echo "      <input type='image' src='./img/script_save.png' border='0' alt='�nderungen an die Map senden'>\n";
+echo "      <input type='image' src='./img/script_save.png' border='0' alt='nderungen an die Map senden'>\n";
 echo "      SLD speichern<br>\n";
 echo "      <input type='hidden' name='function' value='save'>\n";
 echo "      <br /><a href=\"".$sld_url."\" target=_new>";	

Modified: branches/nimix_dev/http/sld/sld_parse.php
===================================================================
--- branches/nimix_dev/http/sld/sld_parse.php	2008-08-18 17:41:05 UTC (rev 2877)
+++ branches/nimix_dev/http/sld/sld_parse.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -33,8 +33,7 @@
  * @author Markus Krzyzanowski
  */
 
-session_start();
-require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+//require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
 
 /**
  *  Creates a empty SLD object up to the rule object
@@ -904,4 +903,4 @@
 	
 	return $styledlayerdescriptor;
 }
-?>
\ No newline at end of file
+?>

Added: branches/nimix_dev/lib/ajax.js
===================================================================
--- branches/nimix_dev/lib/ajax.js	                        (rev 0)
+++ branches/nimix_dev/lib/ajax.js	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,63 @@
+/* 
+* $Id: map_obj.js 2413 2008-04-23 16:21:04Z christoph $
+* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
+* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
+*/
+
+
+/*
+ ***************************************************************************************
+ *   AJAX wrapper functions
+ ***************************************************************************************
+ */
+/**
+ * A wrapper for an AJAX request via GET 
+ *
+ * @param {String} url the URL of a (presumably a server side) script.
+ * @param {Object} param An object containing parameters, f.e. {name1:value1, name2:value2}
+ * @param {Function} callback A function that is called when the server side script has been processed. The function is called with two parameters, result and status. Result is the output of the server side script (XML, HTML, whatever), status is a {String}, either "success" or "error". 
+ */
+function mb_ajax_get(url, param, callback) {
+	try {
+//		$.ajaxSetup({async:false}); 
+		$.get(url, param, callback);
+	}
+	catch(e) {
+		var error = new Mb_exception('map.php: mb_ajax_get:'+e);
+	}
+}	
+
+/**
+ * A wrapper for an AJAX request via POST 
+ *
+ * @param {String} url the URL of a (presumably a server side) script.
+ * @param {Object} param An object containing parameters, f.e. {name1:value1, name2:value2}
+ * @param {Function} callback A function that is called when the server side script has been processed. The function is called with two parameters, result and status. Result is the output of the server side script (XML, HTML, whatever), status is a {String}, either "success" or "error". 
+ */
+function mb_ajax_post(url, param, callback) {
+	try {
+//		$.ajaxSetup({async:false}); 
+		$.post(url, param, callback);
+	}
+	catch(e) {
+		var error = new Mb_exception('map.php: mb_ajax_post:'+e);
+	}
+}	
+	
+/**
+ * A wrapper for an AJAX request via GET 
+ *
+ * @param {String} url the URL of a (presumably a server side) script.
+ * @param {Object} param An object containing parameters, f.e. {name1:value1, name2:value2}
+ * @param {Function} callback A function that is called when the server side script has been processed. The function is called with two parameters, result and status. Result is the output of the server side script (a JavaScript Object, not a String!), status is a {String}, either "success" or "error". 
+ */
+function mb_ajax_json(url, param, callback) {
+	try {
+//		window.frames['ajax'].$.ajaxSetup({async:false}); //TODO: find out why async doesn't work sometimes
+		$.getJSON(url, param, callback);
+	}
+	catch(e) {
+		var error = new Mb_exception('map.php: mb_ajax_json:'+e);
+	}
+}	
+

Added: branches/nimix_dev/lib/alignButton.js
===================================================================
--- branches/nimix_dev/lib/alignButton.js	                        (rev 0)
+++ branches/nimix_dev/lib/alignButton.js	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,99 @@
+var Align = {
+	top : {
+		buttonParameters : {
+			on:"../img/button_blink_red/up_on.png",
+			over:"../img/button_blink_red/up_on.png",
+			off:"../img/button_blink_red/up_off.png",
+			type:"singular"
+		},
+		align : function () {
+			if ($(".ui-selected").size() < 2) {
+				return false;
+			}
+			var minY;
+			$(".ui-selected").each(function() {
+				var currentMinY = parseInt(this.style.top);
+				if ((!minY && minY !== 0 ) || currentMinY < minY) {
+					minY = currentMinY;
+				}
+			});
+			$(".ui-selected").each(function() {
+				this.style.top = minY + "px";
+			});
+		}
+	},
+	left : {
+		buttonParameters : {
+			on:"../img/button_blink_red/back_on.png",
+			over:"../img/button_blink_red/back_on.png",
+			off:"../img/button_blink_red/back_off.png",
+			type:"singular"
+		},		
+		align : function () {
+			if ($(".ui-selected").size() < 2) {
+				return false;
+			}
+			var minX;
+			$(".ui-selected").each(function() {
+				var currentMinX = parseInt(this.style.left);
+				if ((!minX && minX !== 0 ) || currentMinX < minX) {
+					minX = currentMinX;
+				}
+			});
+	
+			$(".ui-selected").each(function() {
+				this.style.left = minX + "px";
+			});
+		}
+	},
+	bottom : {
+		buttonParameters : {
+			on:"../img/button_blink_red/down_on.png",
+			over:"../img/button_blink_red/down_on.png",
+			off:"../img/button_blink_red/down_off.png",
+			type:"singular"
+		},
+		align : function () {
+			if ($(".ui-selected").size() < 2) {
+				return false;
+			}
+			var maxY;
+			$(".ui-selected").each(function() {
+				var currentMaxY = parseInt(this.style.top) + parseInt(this.style.height);
+				if ((!maxY && maxY !== 0) || currentMaxY > maxY) {
+					maxY = currentMaxY;
+				}
+			});
+	
+			$(".ui-selected").each(function() {
+				var newY = maxY - parseInt(this.style.height);
+				this.style.top = newY + "px";
+			});
+		}
+	},
+	right : {
+		buttonParameters : {
+			on:"../img/button_blink_red/forward_on.png",
+			over:"../img/button_blink_red/forward_on.png",
+			off:"../img/button_blink_red/forward_off.png",
+			type:"singular"
+		},
+		align : function () {
+			if ($(".ui-selected").size() < 2) {
+				return false;
+			}
+			var maxX;
+			$(".ui-selected").each(function() {
+				var currentMaxX = parseInt(this.style.left) + parseInt(this.style.width);
+				if ((!maxX && maxX !== 0) || currentMaxX > maxX) {
+					maxX = currentMaxX;
+				}
+			});
+	
+			$(".ui-selected").each(function() {
+				var newX = maxX - parseInt(this.style.width);
+				this.style.left = newX + "px";
+			});
+		}
+	}
+}
\ No newline at end of file

Added: branches/nimix_dev/lib/basic.js
===================================================================
--- branches/nimix_dev/lib/basic.js	                        (rev 0)
+++ branches/nimix_dev/lib/basic.js	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,117 @@
+var ie = document.all?1:0;
+var n6 = document.getElementById&&!document.all?1:0;
+var n4 = document.layers?1:0;
+
+var clickX;
+var clickY;
+
+var mb_log = null;
+
+
+// transparent GIF
+var mb_trans = new Image(); 
+mb_trans.src = "../img/transparent.gif";
+
+/*
+ * get the conjunction character of an URL
+ * @param {String} onlineresource
+ * @return the character & or ?
+ * @type String
+ */
+function mb_getConjunctionCharacter(onlineresource){
+	var conChar;
+	if(onlineresource.indexOf("?") > -1){ 
+		if(onlineresource.charAt(onlineresource.length-1) == "?"){ 
+			conChar = "";
+		}else if(onlineresource.charAt(onlineresource.length-1) == "&"){
+			conChar = "";
+		}else{
+			conChar = "&";
+		}
+	}
+	if(onlineresource.indexOf("?") == -1){
+		conChar = "?";
+	} 
+	return conChar;  
+}
+
+function mb_showHighlight(frameName,x,y){
+   var pos = makeRealWorld2mapPos(frameName,x, y);
+   mb_arrangeElement(frameName,"highlight",pos[0]-7, pos[1]-7);
+   window.frames[frameName].document.getElementById("highlight").style.visibility = 'visible';
+}
+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';
+}
+
+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 mb_timestamp(){
+	var d = new Date();
+	var ts = Math.round(Date.parse(d)/1000);
+	return ts;
+}
+
+function mb_getMousePos(e,fName){
+if(fName){
+     if(ie){
+        clickX = window.frames[fName].event.clientX;
+        clickY = window.frames[fName].event.clientY;
+     }
+     else{
+        clickX = e.pageX;
+        clickY = e.pageY;
+     }
+  }
+  else{
+       if(ie){
+        clickX = event.clientX;
+        clickY = event.clientY;
+     }
+     else{
+        clickX = e.pageX;
+        clickY = e.pageY;
+     }
+  }
+  var pos = [clickX,clickY];
+  return pos;
+}
+
+function mb_arrangeElement(frameName, elName, left, top) {
+   if(frameName !== ""){
+      window.frames[frameName].document.getElementById(elName).style.top = top;
+      window.frames[frameName].document.getElementById(elName).style.left = left;
+   }
+   else{
+      document.getElementById(elName).style.top = top;
+      document.getElementById(elName).style.left = left;   
+   }
+}
+

Added: branches/nimix_dev/lib/button.js
===================================================================
--- branches/nimix_dev/lib/button.js	                        (rev 0)
+++ branches/nimix_dev/lib/button.js	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,150 @@
+/*
+ ***************************************************************************************
+ *   button handling
+ ***************************************************************************************
+ */
+ 
+var mb_button = [];
+
+function mb_regButton_frame(wii, frameName, param){
+	var ind = mb_button.length;
+	mb_button[ind] = new mb_conButton(wii, ind);
+	if (frameName === null) {
+		if (param === null) {
+			eval(wii+"("+ind+")");
+		}
+		else {
+			eval(wii+"("+ind+", "+param+")");
+		}
+	}
+	else if (param === null) {
+		eval("window.frames['" + frameName + "']."+wii+"("+ind+")");
+	}
+	else {
+		eval("window.frames['" + frameName + "']."+wii+"("+ind+", "+param+")");
+	}
+	mb_button[ind].prev = mb_button[ind].src;
+	mb_button[ind].src = mb_button[ind].img_off;
+	mb_button[ind].onmouseover = function () {
+		mb_button_over(ind);
+	};
+	mb_button[ind].onmouseout = function(){
+		mb_button_out(ind);
+	};
+	mb_button[ind].onclick = function(){
+		mb_button_click(ind);
+	};
+	if (frameName === null) {
+		mb_button[ind].frameName = "";
+	}
+	else {
+		mb_button[ind].frameName = frameName;
+	}
+}
+
+function mb_regButton(wii){
+	mb_regButton_frame(wii, null, null);
+}
+
+function mb_conButton(wii, ind){
+   this.wii = wii;
+   return true;
+}
+function mb_button_over(ind){
+   if(mb_button[ind].status === 0){
+      mb_button[ind].prev = mb_button[ind].src;
+      mb_button[ind].src = mb_button[ind].img_over;
+   }
+}
+function mb_button_out(ind){
+   if(mb_button[ind].status === 0){
+   		mb_button[ind].src = mb_button[ind].img_off;
+   }
+}
+function mb_button_click(ind){
+   var mbStatus = mb_button[ind].status;
+   if(mbStatus === 0){
+      mb_disableButton(mb_button[ind].elName);
+      mb_button[ind].prev = mb_button[ind].img_on;
+      mb_button[ind].src = mb_button[ind].img_on;
+      mb_button[ind].status = 1;
+      if (mb_button[ind].frameName !== "") {
+          window.frames[mb_button[ind].frameName].document.getElementById(mb_button[ind].elName).go();
+      }
+      else {
+	      document.getElementById(mb_button[ind].elName).go();
+      }
+   }
+   else{
+      mb_button[ind].prev = mb_button[ind].img_off;
+      mb_button[ind].src = mb_button[ind].img_off;
+      mb_button[ind].status = 0;      
+      if (mb_button[ind].frameName !== "") {
+          window.frames[mb_button[ind].frameName].document.getElementById(mb_button[ind].elName).stop();
+      }
+      else {
+	      document.getElementById(mb_button[ind].elName).stop();
+      }
+   }
+}
+function mb_disableButton(elName){
+   for(var i=0; i<mb_button.length; i++){
+      if(mb_button[i].elName != elName && mb_button[i].status == 1){
+            mb_button[i].status = 0;
+		      if (mb_button[i].frameName !== "") {
+    	        window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
+	            window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).stop();
+		      }
+		      else {
+    	        document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
+	            document.getElementById(mb_button[i].elName).stop();
+		      }
+            return true;
+       
+      }
+   }
+}
+function mb_disableThisButton(elName){
+   for(var i=0; i<mb_button.length; i++){
+      if(mb_button[i].elName == elName && mb_button[i].status == 1){
+      		//alert(mb_button[i].elName);
+            mb_button[i].status = 0;
+		      if (mb_button[i].frameName !== "") {
+    	        window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
+	            window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).stop();
+		      }
+		      else {
+        	    document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
+		        document.getElementById(mb_button[i].elName).stop();
+		      }
+            return true;
+       
+      }
+   }
+}
+function updateButtonTooltips(obj) {
+	// this one only changes those in the main frame
+	var imageArray = document.getElementsByTagName("img");
+	for (var i = 0; i < imageArray.length; i++) {
+		for(var j=0; j<obj.length; j++){
+			if (imageArray[i].id == obj[j].id) {
+				document.getElementById(imageArray[i].id).title = obj[j].title;
+			}
+		}
+	}
+}
+
+function mb_localizeButtons(){
+	mb_ajax_json("../php/mod_button_tooltips.php", function(obj, status){
+		updateButtonTooltips(obj);
+	});
+}
+
+eventLocalize.register(function () {
+	mb_localizeButtons();
+});
+
+eventInit.register(function () {
+	mb_localizeButtons();
+});
+

Added: branches/nimix_dev/lib/buttonNew.js
===================================================================
--- branches/nimix_dev/lib/buttonNew.js	                        (rev 0)
+++ branches/nimix_dev/lib/buttonNew.js	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,129 @@
+
+/**
+ * A group of buttons. 
+ */
+function ButtonGroup (nodeId) {
+	var buttonArray = [];
+	var node = "#" + nodeId;
+	
+	this.add = function (button) {
+		if (!button.constructor == "Button") {
+			console.log("not a button, but a %s", button.constructor);
+			return false;
+		}
+		if (button.type == "toggle") {
+			for (var i = 0; i < buttonArray.length; i++) {
+				var currentButton = buttonArray[i];
+				currentButton.registerPush(button.triggerStop);
+				button.registerPush(currentButton.triggerStop);
+			}
+		}
+		else if (button.type == "singular") {
+			button.registerPush(button.triggerStop);	
+		}
+		buttonArray.push(button);
+		$(node).append(button.getNode());
+	}
+}
+	
+	
+function Button (options) {
+	//
+	// API
+	//
+	this.registerStart = function (func) {
+		start.register(func);
+	};
+	
+	this.registerStop = function (func) {
+		stop.register(func);
+	};
+	
+	this.registerPush = function (func) {
+		push.register(func);
+	};
+	
+	this.registerRelease = function (func) {
+		release.register(func);
+	};
+
+	this.triggerStart = function () {
+		start.trigger();
+	};
+	
+	this.triggerStop = function () {
+		stop.trigger();
+	};
+
+	this.triggerPush = function () {
+		push.trigger();
+	};
+	
+	this.triggerRelease = function () {
+		release.trigger();
+	};
+
+	this.getNode = function () {
+		return $node;
+	};
+	
+	//
+	// constructor
+	//
+	/**
+	 * Is triggered if the button is pushed, may
+	 * also be triggered by other actions.
+	 * Changes the button image source.
+	 */
+	var start = new MapbenderEvent();
+	/**
+	 * Is triggered if the button is released, may
+	 * also be triggered by other actions.
+	 * Changes the button image source.
+	 */
+	var stop = new MapbenderEvent();
+	/**
+	 * Is only called after the button has been 
+	 * manually pushed by the user.
+	 * Triggers "start".
+	 */
+	var push = new MapbenderEvent();
+
+	/**
+	 * Is only called after the button has been 
+	 * manually released by the user.
+	 * Triggers "stop".
+	 */
+	var release = new MapbenderEvent();
+	
+	start.register(function() {
+		isOn = true;
+		$node.attr("src", srcOn);
+	});
+	
+	stop.register(function() {
+		$node.attr("src", srcOff);
+		isOn = false;
+	});
+	
+	push.register(function() {
+		start.trigger();
+	});
+	
+	release.register(function() {
+		stop.trigger();
+	});
+	
+	var srcOn = (options.on) ? options.on : null;
+	var srcOff = (options.off) ? options.off : null;
+	var srcOver = (options.over) ? options.over : null;
+	this.type = (options.type) ? options.type : "default";
+		 
+	var $node = $("<img style='padding:5px' src='" + srcOff + "'/>");
+	var isOn = false;
+	
+	$node.click(function() {
+		(!isOn) ? push.trigger() : release.trigger();	
+	});
+}
+

Added: branches/nimix_dev/lib/core.js
===================================================================
--- branches/nimix_dev/lib/core.js	                        (rev 0)
+++ branches/nimix_dev/lib/core.js	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,205 @@
+var currentWmcExtensionData = {};
+var restoredWmcExtensionData = {};
+
+//var mb_MapRequestSubFunctions = [];
+//var mb_MapRequestPreFunctions = [];
+//var mb_MapObjectSubFunctions = [];
+//var mb_GetScalePreFunctions = [];
+//var mb_FeatureInfoPreFunctions = [];
+//var mb_loadWmsSubFunctions = [];
+//var mb_InitFunctions = [];
+var mb_WfsReadSubFunctions = [];
+var mb_WfsWriteSubFunctions = [];
+var mb_l10nFunctions = [];
+
+/**
+ * Triggered after a map is requested.
+ */
+var eventAfterMapRequest = new MapbenderEvent();
+
+/**
+ * Triggered after aall map images have been loaded.
+ */
+var eventAfterMapImagesReady = new MapbenderEvent();
+
+/**
+ * Triggered before a map is requested.
+ */
+var eventBeforeMapRequest = new MapbenderEvent();
+
+/**
+ * Triggered before the scale is calculated.
+ */
+var eventBeforeGetScale = new MapbenderEvent();
+
+/**
+ * Triggered before a feature info is requested.
+ */
+var eventBeforeFeatureInfo = new MapbenderEvent();
+/**
+ * Triggered after a WMS has been loaded.
+ */
+var eventAfterLoadWMS = new MapbenderEvent();
+
+/**
+ * Triggered when Mapbender is loaded and after the map object has been initialised.
+ */
+var eventInit = new MapbenderEvent();
+
+/**
+ * Triggered after Mapbender is loaded and has been initialised.
+ * Used to trigger initial map requests
+ */
+var eventAfterInit = new MapbenderEvent();
+
+/**
+ * Initializes the map object. Triggered when Mapbender is loaded. 
+ */
+var eventInitMap = new MapbenderEvent();
+
+eventInit.register(function() {
+	$lm = $("#loading_mapbender");
+	$cm = $("#complete_mapbender");
+	$lm.empty();
+	$cm.show();
+});
+
+/**
+ * Switches the locale. Triggered by module switch_locale or onload(?) 
+ */
+var eventLocalize = new MapbenderEvent();
+
+/**
+ * Triggered after the map object has been created. 
+ */
+var eventAfterMapObjectConstruction = new MapbenderEvent(); // possibly obsolete!
+
+/**
+ * Triggered after the map has been resized
+ */
+var eventResizeMap = new MapbenderEvent();
+
+/**
+ * deprecated wrapped function
+ * @deprecated
+ */
+function mb_registerInitFunctions(stringFunction){
+//	mb_InitFunctions[mb_InitFunctions.length] = stringFunction;
+	eventInit.register(stringFunction);
+}
+
+/**
+ * deprecated wrapped function
+ * @deprecated
+ */
+function mb_registerPreFunctions(stringFunction){
+//	mb_MapRequestPreFunctions[mb_MapRequestPreFunctions.length] = stringFunction;
+	eventBeforeMapRequest.register(stringFunction);
+}
+
+/**
+ * deprecated wrapped function
+ * @deprecated
+ */
+function mb_registerFeatureInfoPreFunctions(stringFunction){
+//	mb_FeatureInfoPreFunctions[mb_FeatureInfoPreFunctions.length] = stringFunction;
+	eventBeforeFeatureInfo.register(stringFunction);
+}
+
+/**
+ * deprecated wrapped function
+ * @deprecated
+ */
+function mb_registerSubFunctions(stringFunction){
+//	mb_MapRequestSubFunctions[mb_MapRequestSubFunctions.length] = stringFunction;
+	eventAfterMapRequest.register(stringFunction);
+}
+
+/**
+ * deprecated wrapped function
+ * @deprecated
+ */
+function mb_registerMapObjectSubFunctions(stringFunction){
+//	mb_MapObjectSubFunctions[mb_MapObjectSubFunctions.length] = stringFunction;
+	eventAfterMapObjectConstruction.register(stringFunction);
+}
+
+/**
+ * deprecated wrapped function
+ * @deprecated
+ */
+function mb_registerGetScalePreFunctions(stringFunction){
+//	mb_GetScalePreFunctions[mb_GetScalePreFunctions.length] = stringFunction;
+	eventBeforeGetScale.register(stringFunction);
+}
+
+/**
+ * deprecated wrapped function
+ * @deprecated
+ */
+function mb_registerloadWmsSubFunctions(stringFunction){
+//	mb_loadWmsSubFunctions[mb_loadWmsSubFunctions.length] = stringFunction;
+	eventAfterLoadWMS.register(stringFunction);
+}
+
+/**
+ * deprecated wrapped function
+ * @deprecated
+ */
+function mb_registerWfsReadSubFunctions(stringFunction){
+	mb_WfsReadSubFunctions[mb_WfsReadSubFunctions.length] = stringFunction;
+}
+
+/**
+ * deprecated wrapped function
+ * @deprecated
+ */
+function mb_registerWfsWriteSubFunctions(stringFunction){
+	mb_WfsWriteSubFunctions[mb_WfsWriteSubFunctions.length] = stringFunction;
+}
+
+/**
+ * deprecated wrapped function
+ * @deprecated
+ */
+function mb_registerL10nFunctions(stringFunction) {
+	eventLocalize.register(stringFunction)
+//	mb_l10nFunctions[mb_l10nFunctions.length] = stringFunction;
+}
+
+var mb_PanSubElements = [];
+function mb_registerPanSubElement(elName){
+	var ind = mb_PanSubElements.length;
+	mb_PanSubElements[ind] = elName;
+}
+
+var mb_vendorSpecific = [];
+function mb_registerVendorSpecific(stringFunction){
+	mb_vendorSpecific[mb_vendorSpecific.length] = stringFunction;
+}
+
+/**
+ * Called in index.php on body onload
+ */
+function init() {
+	// creates the map objects (mapframe1, overview...)
+	eventInitMap.trigger();
+
+	// initialisation
+	eventInit.trigger();
+	
+	eventAfterInit.trigger();
+}
+
+/**
+ * deprecated function for writing content within a tag via innerHTML
+ * @deprecated
+ */
+function writeTag(frameName, elName, tagSource) {
+  if(frameName && frameName !== ""){
+     window.frames[frameName].document.getElementById(elName).innerHTML = tagSource;
+  }
+  else if(!frameName || frameName === ""){
+       document.getElementById(elName).innerHTML = tagSource;
+  }
+}

Added: branches/nimix_dev/lib/database-mysql.php
===================================================================
--- branches/nimix_dev/lib/database-mysql.php	                        (rev 0)
+++ branches/nimix_dev/lib/database-mysql.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,411 @@
+<?php
+# $Id: database-mysql.php 2739 2008-08-05 11:54:58Z christoph $
+# http://www.mapbender.org/index.php/database-mysql.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.
+
+/**
+ * \file
+ * \brief MySQL database connection/querying layer
+ * 
+ * MySQL database connection/querying layer
+ *
+ * example:
+ * \code
+ * include_once(dirname(__FILE__)."/afwphp/database-mysql.php");  
+ * $sys_dbhost=...                            
+ * $sys_dbuser=...                            
+ * $sys_dbpasswd=...                           
+ * $sys_dbname=...                            
+ *                                             
+ * db_connect();                               
+ * ...                                         
+ * $rs = db_query("select * from table");      
+ * while($row = db_fetch_array($rs));
+ *  ...
+ * \endcode
+ */
+
+/**
+ * System-wide database type
+ *
+ * @var	constant		$sys_database_type
+ */
+$sys_database_type='mysql';
+
+/**
+ *  Connect to the database
+ *
+ *  Notice the global vars that must be set up
+ *  Notice the global vars $sys_dbhost,$sys_dbuser,$sys_dbpasswd,$sys_dbname that must be set up 
+ *  in other functions in this library
+ */
+include_once(dirname(__FILE__)."/../../http/classes/class_mb_exception.php");
+include_once(dirname(__FILE__)."/../../http/classes/class_checkInput.php");
+function db_escapestring($unescaped_string){
+	return @mysql_escape_string($unescaped_string);
+}
+function db_escape_string($unescaped_string){
+	return @mysql_escape_string($unescaped_string);
+}
+
+
+function db_connect($DBSERVER="",$OWNER="",$PW="") {
+	global $sys_dbhost,$sys_dbuser,$sys_dbpasswd,$sys_dbname,
+		$conn,$conn_update,$sys_db_use_replication,$sys_dbreadhost;
+
+	
+	if ($DBSERVER)
+		$sys_dbhost = $DBSERVER; 
+	if ($OWNER)
+		$sys_dbuser = $OWNER; 
+	if ($PW)
+		$sys_dbpasswd = $PW; 
+	if (PORT!=''){
+		$sys_dbport = ':'.PORT;
+	}
+	else{
+		$sys_dbport = '';
+	} 
+		
+	if ($sys_db_use_replication) {
+		//
+		//  if configured for replication, $conn is the read-only host
+		//  we do not connect to update server until needed
+		//
+		$conn = @mysql_pconnect($sys_dbreadhost,$sys_dbuser,$sys_dbpasswd);
+		$conn_update=@mysql_pconnect($sys_dbhost,$sys_dbuser,$sys_dbpasswd);
+	} else {
+		$conn = @mysql_pconnect($sys_dbhost.$sys_dbport,$sys_dbuser,$sys_dbpasswd);
+		#echo "@mysql_pconnect($sys_dbhost.$sys_dbport,$sys_dbuser,$sys_dbpasswd)";
+	}
+	if ($sys_dbname)
+		@mysql_select_db($sys_dbname);
+	return $conn;
+}
+
+function db_select_db($DB,$con="") {
+	global $conn,$sys_dbname; 
+	$sys_dbname = $DB;	
+	$_con = $con ? $con : $conn;
+	$ret = @mysql_select_db($sys_dbname,$_con);
+	if ($ret){
+		return true;
+	}
+	else {
+		return false;
+	}
+//	echo "$ret=@mysql_select_db($sys_dbname,$_con);";
+}
+
+/**
+ *  Query the database
+ *
+ *  @param		$qstring (string)	SQL statement
+ *  @param		$limit (int)		How many rows do you want returned
+ *  @param		$offset (int)		Of matching rows, return only rows starting here
+ */
+function db_query($qstring,$limit='-1',$offset=0) {
+	global $QUERY_COUNT,$sys_db_use_replication,$sys_db_is_dirty,$DB,
+		$sys_dbname,$conn,$conn_update,$sys_dbhost,$sys_dbuser,$sys_dbpasswd;
+
+	$QUERY_COUNT++;
+	if(!$sys_dbname && $DB)
+	$sys_dbname = $DB;
+	db_select_db($sys_dbname,$conn);
+	
+	if ($limit > 0) {
+		if (!$offset || $offset < 0) {
+			$offset=0;
+		}
+		$qstring=$qstring." LIMIT $offset,$limit";
+	}
+//	if ($GLOBALS['IS_DEBUG'])
+		$GLOBALS['G_DEBUGQUERY'] .= $qstring . "<P><BR>\n";
+
+	//
+	//are we configured to try to use replication?
+	//
+	if ($sys_db_use_replication) {
+		//
+		//if we haven't yet done an insert/update, 
+		//read from the read-only db
+		//
+		if (!$sys_db_is_dirty && mb_eregi("^( )*(select)",$qstring)) {
+			if ($QUERY_COUNT%3==0) {
+				// 1/3rd of read queries go to master for now
+				return @mysql_db_query($sys_dbname,$qstring,$conn_update);
+			} else {
+				return @mysql_db_query($sys_dbname,$qstring,$conn);
+			}
+		} else {
+			//must be an update/insert/delete query - go to master server
+			$sys_db_is_dirty=true;
+			return @mysql_db_query($sys_dbname,$qstring,$conn_update);
+		}
+	} else {
+		$ret = @mysql_db_query($sys_dbname,$qstring,$conn);
+//		echo "@mysql_db_query($sys_dbname,$qstring,$conn); ret=$ret<br>";
+		if(!$ret){
+			$e = new mb_exception("db_query($qstring)=$ret db_error=".db_error());
+		}
+		return $ret;
+	}
+	//echo "SQL__".$qstring;
+}
+/**
+ *  prepare and query the database
+ *
+ *  @param		$qstring (string)	SQL statement
+ *  @param		$params (array string params)		
+ *  @param		$types (array string types)		
+ */
+function db_prep_query($qstring, $params, $types){
+	$ci = new checkInput($qstring,$params,$types);
+	$params = $ci->v; 
+	for ($i=0; $i<count($params); $i++){
+		$needle = "$".strval($i+1);
+		$tmp = '';
+		if($params[$i] !== NULL){
+			if($types[$i] == 's'){ $tmp .= "'"; }
+			$tmp .= $params[$i];
+			if($types[$i] == 's'){ $tmp .= "'"; }
+		}
+		else{
+			$tmp .= "NULL";
+		}
+		$posa = mb_strpos($qstring, $needle);
+		$posb = mb_strlen($needle);
+		$qstring = mb_substr($qstring,0,$posa).$tmp.mb_substr($qstring,($posa + $posb));	
+	}
+	$r = db_query($qstring);
+	return $r;
+}
+/**
+ *	Begin a transaction
+ *
+ *	Begin a transaction for databases that support them
+ *	may cause unexpected behavior in databases that don't
+ */
+function db_begin() {
+	return db_query("BEGIN WORK");
+}
+
+/**
+ * Commit a transaction
+ *
+ * Commit a transaction for databases that support them
+ * may cause unexpected behavior in databases that don't
+ */
+function db_commit() {
+	return db_query("COMMIT");
+}
+
+/**
+ * Roll back a transaction
+ *
+ * Rollback a transaction for databases that support them
+ * may cause unexpected behavior in databases that don't
+ */
+function db_rollback() {
+	$str = db_error();
+	db_query("ROLLBACK");
+	die('sql error: ' . $str . " ROLLBACK performed....");
+}
+
+/**
+ * Returns the number of rows in this result set
+ *
+ *  @param		$qhandle (string)	Query result set handle
+ * (!!! Deprecated? Changed the MySQL-Command to match the current syntax)
+ */
+function db_numrows($qhandle) {
+	// return only if qhandle exists, otherwise 0
+	if ($qhandle) {
+		return @mysql_num_rows($qhandle);
+	} else {
+		return 0;
+	}
+}
+/**
+ * Returns the number of rows in this result set
+ *
+ *  @param		$qhandle (string)	Query result set handle
+ * php 3,4,5
+ */
+function db_num_rows($qhandle) {
+	// return only if qhandle exists, otherwise 0
+	if ($qhandle) {
+		return @mysql_num_rows($qhandle);
+	} else {
+		return 0;
+	}
+}
+
+/**
+ *  Frees a database result properly 
+ *
+ *  @param	$qhandle (string)	Query result set handle
+ */
+function db_free_result($qhandle) {
+	return @mysql_free_result($qhandle);
+}
+
+/**
+ *  Reset a result set.
+ *
+ *  Reset is useful for db_fetch_array sometimes you need to start over
+ *
+ *  @param		$qhandle (string)	Query result set handle
+ *  @param		$row (int)		Row number
+ */
+function db_reset_result($qhandle,$row=0) {
+	return mysql_data_seek($qhandle,$row);
+}
+
+/**
+ *  Returns a field from a result set
+ *
+ *  @param		$qhandle (string)	Query result set handle
+ *  @param		$row (int)		Row number
+ *  @param		$field (string)	Field name
+ */
+function db_result($qhandle,$row,$field) {
+	return @mysql_result($qhandle,$row,$field);
+}
+
+/**
+ *  Returns the number of fields in this result set
+ *
+ *  @param		$lhandle (string)	Query result set handle
+ *  (!!! Deprecated? Changed the MySQL-Command to match the current syntax)
+ */
+function db_numfields($lhandle) {
+	return @mysql_num_fields($lhandle);
+}
+
+/**
+ *  Returns the number of fields in this result set
+ *
+ *  @param		$lhandle (string)	Query result set handle
+ * php 3,4,5
+ */
+function db_num_fields($lhandle) {
+	return @mysql_num_fields($lhandle);
+}
+
+/**
+ *  Returns the number of rows changed in the last query
+ *
+ *  @param		$lhandle	(string) Query result set handle
+ *  @param		$fnumber (int)	Column number
+ */
+function db_fieldname($lhandle,$fnumber) {
+	   return @mysql_fieldname($lhandle,$fnumber);
+}
+
+/**
+ *  Returns the number of rows changed in the last query
+ *
+ *  @param		$qhandle (string)	Query result set handle
+ */
+function db_affected_rows($qhandle) {
+	return @mysql_affected_rows();
+}
+
+/**
+ *  Fetch an array
+ *
+ *  Returns an associative array from 
+ *  the current row of this database result
+ *  Use db_reset_result to seek a particular row
+ *
+ *  @param		$qhandle (string)	Query result set handle
+ */
+function db_fetch_array($qhandle) {
+	return @mysql_fetch_array($qhandle);
+}
+
+/**                                                       
+ * fetch a row into an array 
+ * 
+ *  @param		$qhandle (string)	Query result set handle
+ *  @param		$fnumber (int)	Column number
+ */
+function db_fetch_row($qhandle,$fnumber=0) {
+	  return @mysql_fetch_row($qhandle);
+}
+
+/**
+ *  Returns the last primary key from an insert
+ *
+ *  @param		$qhandle (string)	Query result set handle
+ *  @param		$table_name (string)	Is the name of the table you inserted into
+ *  @param		$pkey_field_name (string)	Is the field name of the primary key
+ */
+function db_insertid($qhandle="",$table_name="",$pkey_field_name="") {
+	return @mysql_insert_id();
+}
+
+function db_insert_id($qhandle="",$table_name="",$pkey_field_name="") {
+	return @mysql_insert_id();
+}
+
+/**
+ * Returns the last error from the database
+ */
+function db_error() {
+	return @mysql_error();
+}
+
+/**
+ * Get the flags associated with the specified field in a result 
+ *
+ *  @param		$lhandle	(string) Query result set handle
+ *  @param		$fnumber (int)	Column number
+ *
+ * 					Examples: "not_null", "primary_key", "unique_key", "multiple_key",					 
+ *                    "blob", "unsigned", "zerofill","binary", "enum",                  
+ *                    "auto_increment", "timestamp"                                     
+ */
+
+function db_field_flags($lhandle,$fnumber) {
+	   return @mysql_field_flags($lhandle,$fnumber);
+}
+
+/**                                                       
+ * Get the type of the specified field  
+ *
+ *  @param		$lhandle	(string) Query result set handle
+ *  @param		$fnumber (int)	Column number
+ */                                                       
+                                                          
+function db_field_type($lhandle,$fnumber) {               
+	   return @mysql_field_type($lhandle,$fnumber);         
+}                                                         
+
+/**                                                       
+ * Get the length of the specified field                                                            
+ *
+ *  @param		$lhandle	(string) Query result set handle
+ *  @param		$fnumber (int)	Column number
+ */                                                       
+                                                          
+function db_field_len($lhandle,$fnumber) {               
+	   return @mysql_field_len($lhandle,$fnumber);         
+} 
+
+?>

Added: branches/nimix_dev/lib/database-mysqli.php
===================================================================
--- branches/nimix_dev/lib/database-mysqli.php	                        (rev 0)
+++ branches/nimix_dev/lib/database-mysqli.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,481 @@
+<?php
+/**
+ * System-wide database type
+ *
+ * @var	constant		$sys_database_type
+ */
+$sys_database_type='mysqli';
+
+/**
+ *  Connect to the database
+ *
+ *  Notice the global vars that must be set up
+ *  Notice the global vars $sys_dbhost,$sys_dbuser,$sys_dbpasswd,$sys_dbname that must be set up 
+ *  in other functions in this library
+ */
+include_once(dirname(__FILE__)."/../../http/classes/class_mb_exception.php");
+include_once(dirname(__FILE__)."/../../http/classes/class_checkInput.php");
+function db_escapestring($unescaped_string){
+	global $conn;
+	return mysqli_escape_string($conn, $unescaped_string);
+}
+function db_escape_string($unescaped_string){
+	global $conn;
+	return mysqli_escape_string($conn, $unescaped_string);
+}
+
+function db_connect($DBSERVER="",$OWNER="",$PW="") {
+	global $sys_dbhost,$sys_dbuser,$sys_dbpasswd,$sys_dbname,
+		$conn,$conn_update,$sys_db_use_replication,$sys_dbreadhost;
+
+	
+	if ($DBSERVER)
+		$sys_dbhost = $DBSERVER; 
+	if ($OWNER)
+		$sys_dbuser = $OWNER; 
+	if ($PW)
+		$sys_dbpasswd = $PW; 
+	if (PORT!=''){
+		$sys_dbport = ':'.PORT;
+	}
+	else{
+		$sys_dbport = '';
+	} 
+		
+	if ($sys_db_use_replication) {
+		//
+		//  if configured for replication, $conn is the read-only host
+		//  we do not connect to update server until needed
+		//
+		$conn = mysqli_connect($sys_dbreadhost,$sys_dbuser,$sys_dbpasswd);
+		$conn_update=mysqli_connect($sys_dbhost,$sys_dbuser,$sys_dbpasswd);
+	} else {
+		$conn = mysqli_connect($sys_dbhost,$sys_dbuser,$sys_dbpasswd,$sys_dbname,intval($sys_dbport));
+		#echo "@mysql_pconnect($sys_dbhost.$sys_dbport,$sys_dbuser,$sys_dbpasswd)";
+	}
+	if ($sys_dbname)
+		mysqli_select_db($conn, $sys_dbname);
+	return $conn;
+}
+
+function db_select_db($DB,$con="") {
+	global $conn,$sys_dbname; 
+	$sys_dbname = $DB;	
+	$_con = $con ? $con : $conn;
+	$ret = mysqli_select_db($_con, $sys_dbname);
+	if ($ret){
+		return true;
+	}
+	else {
+		return false;
+	}
+//	echo "$ret=@mysql_select_db($sys_dbname,$_con);";
+}
+
+/**
+ *  Query the database
+ *
+ *  @param		$qstring (string)	SQL statement
+ *  @param		$limit (int)		How many rows do you want returned
+ *  @param		$offset (int)		Of matching rows, return only rows starting here
+ */
+function db_query($qstring,$limit='-1',$offset=0) {
+	/* Ausmisten! Der Code ist unübersichtlich, und bei manchen Zweigen ist nicht klar,
+	 * ob sie überhaupt ausgeführt werden...
+	 */
+	global $QUERY_COUNT,$sys_db_use_replication,$sys_db_is_dirty,$DB,
+		$sys_dbname,$conn,$conn_update,$sys_dbhost,$sys_dbuser,$sys_dbpasswd;
+
+	$QUERY_COUNT++;
+	if(!$sys_dbname && $DB)
+	$sys_dbname = $DB;
+	db_select_db($sys_dbname,$conn);
+	
+	if ($limit > 0) {
+		if (!$offset || $offset < 0) {
+			$offset=0;
+		}
+		$qstring=$qstring." LIMIT $offset,$limit";
+	}
+//	if ($GLOBALS['IS_DEBUG'])
+		$GLOBALS['G_DEBUGQUERY'] .= $qstring . "<P><BR>\n";
+
+	//
+	//are we configured to try to use replication?
+	//
+	if ($sys_db_use_replication) {
+		//
+		//if we haven't yet done an insert/update, 
+		//read from the read-only db
+		//
+		if (!$sys_db_is_dirty && mb_eregi("^( )*(select)",$qstring)) {
+			if ($QUERY_COUNT%3==0) {
+				// 1/3rd of read queries go to master for now
+				return mysqli_query($sys_dbname,$qstring,$conn_update);
+			} else {
+				return mysqli_query($sys_dbname,$qstring,$conn);
+			}
+		} else {
+			//must be an update/insert/delete query - go to master server
+			$sys_db_is_dirty=true;
+			return mysqli_query($sys_dbname,$qstring,$conn_update);
+		}
+	} else {
+		$ret = mysqli_query($conn, $qstring);
+//		echo "@mysql_db_query($sys_dbname,$qstring,$conn); ret=$ret<br>";
+		if(!$ret){
+			$e = new mb_exception("db_query($qstring)=$ret db_error=".db_error());
+		}
+		return $ret;
+	}
+	//echo "SQL__".$qstring;
+}
+
+function db_prepare_typestr($types) {
+	$result = '';
+	foreach ($types as $current_type) {
+		$result .= $current_type;
+	}
+	return $result;
+}
+	
+/**
+ *  prepare and query the database
+ *
+ *  @param		$qstring (string)	SQL statement
+ *  @param		$params (array string params)		
+ *  @param		$types (array string types)		
+ */
+function db_prep_query($qstring, $params, $types){
+	// Beim Umschreiben an der PostGreSQL-Bibliothek orientieren
+	global $conn, $stmt;
+
+	@mysqli_stmt_close($stmt);
+
+	$ci = new checkInput($qstring,$params,$types);
+	$params = $ci->v; 
+	if(PREPAREDSTATEMENTS == false){
+		for ($i=0; $i<count($params); $i++){
+			$needle = "$".strval($i+1);
+			$tmp = '';
+			if($params[$i] !== NULL){
+				if($types[$i] == 's'){ $tmp .= "'"; }
+				$tmp .= $params[$i];
+				if($types[$i] == 's'){ $tmp .= "'"; }
+			}
+			else{
+				$tmp .= "NULL";
+			}
+			$posa = mb_strpos($qstring, $needle);
+			$posb = mb_strlen($needle);
+			$qstring = mb_substr($qstring,0,$posa).$tmp.mb_substr($qstring,($posa + $posb));	
+		}
+		$r = db_query($qstring);
+		if(!$r){
+			$e = new mb_exception("Error while executing sql statement in ".$_SERVER['SCRIPT_FILENAME'].": Sql: ".$qstring.", Error: ".db_error());
+		}
+	}
+	else{
+		if (!$conn) {
+			$e = new mb_exception("Error while connecting to the database in ".$_SERVER['SCRIPT_FILENAME'].", Error: ".db_error());
+		}
+		echo $qstring;
+		$qstring = preg_replace('/\$[0-9]+/', '?', $qstring);
+		echo $qstring;
+		$stmt = mysqli_prepare($conn, $qstring);
+		//echo $result;
+		if(!$stmt){
+			echo "Error while preparing statement in ".$_SERVER['SCRIPT_FILENAME'].": Sql: ".$qstring.", Error: ".db_error();
+			$e = new mb_exception("Error while preparing statement in ".$_SERVER['SCRIPT_FILENAME'].": Sql: ".$qstring.", Error: ".db_error());
+		}
+		$type_string = '"';
+		$param_string = '';
+		$val_def_string = '';
+		$val_string = '';
+		/*for ($i = 0; $i < count($params); $i++) {
+			if ($params[$i] !== NULL) {
+				$type_string .= $types[$i];
+				if ($i > 0) {
+					$param_string .= ', ';
+					$val_string .= ', ';
+				}
+				
+				$param_string .= '"'.$params[$i].'"';
+				if ($types[$i] == 's')
+					$val_def_string .= '$val'.$i.'="'.$params[$i].'";';
+				else
+					$val_def_string .= '$val'.$i.'='.$params[$i].';';
+				$val_string .= '$val'.$i;
+				
+				//mysqli_stmt_bind_param($result, $types[$i], $params[$i]);
+			}
+		}*/
+		
+
+		for( $i = 0; $i < count($params); ++$i ) {
+			$thisVar = "v$i";
+			$variadicParams .= '$' . $thisVar;
+			if( $i != count($params) - 1 ) // don't append a comma on the last variable
+				$variadicParams .= ', ';
+			
+			$variadicExtVars[ $thisVar ] = $params[ $i ];
+		}
+		echo $variadicParams;
+		
+		$bindParamFunc = create_function( '$vars, &$stmt','extract( $vars ); $stmt->bind_param( \'' . implode($types) . '\', ' . $variadicParams . ' );' );
+		$bindParamFunc( $variadicExtVars, $stmt );
+		
+		/* $typeStr = call_user_func_array( 'db_prepare_typestr', $types );
+      	array_unshift( $params, $typeStr );
+      	call_user_func_array( array( 'mysqli_bind_param', $qstring  ), $params ); */		
+		
+		/*$type_string .= '"';
+		$eval_string = $val_def_string.'mysqli_stmt_bind_param($result,'.$type_string.','.$val_string.');';
+		$xyz=1;
+		//$eval_string = 'eead results, this function cancelcho $result;';
+		//$eval_string = 'return mysqli_stmt_bind_param($result,'.$type_string.',$xyz);';
+		echo $eval_string;
+		//echo "mysqli_stmt_bind_param($result,$type_string,$param_string)";
+		eval($eval_string);*/
+		$r = mysqli_stmt_execute($stmt);
+		if(!$r){
+			$e = new mb_exception("Error while executing prepared statement in ".$_SERVER['SCRIPT_FILENAME'].": Sql: ".$qstring.", Error: ".db_error());
+		}
+		$result2 = $stmt;
+	}	
+		
+	return $stmt;
+}
+/**
+ *	Begin a transaction
+ *
+ *	Begin a transaction for databases that support them
+ *	may cause unexpected behavior in databases that don't
+ */
+function db_begin() {
+	return db_query("BEGIN WORK");
+}
+
+/**
+ * Commit a transaction
+ *
+ * Commit a transaction for databases that support them
+ * may cause unexpected behavior in databases that don't
+ */
+function db_commit() {
+	return db_query("COMMIT");
+}
+
+/**
+ * Roll back a transaction
+ *
+ * Rollback a transaction for databases that support them
+ * may cause unexpected behavior in databases that don't
+ */
+function db_rollback() {
+	$str = db_error();
+	db_query("ROLLBACK");
+	die('sql error: ' . $str . " ROLLBACK performed....");
+}
+
+/**
+ * Returns the number of rows in this result set
+ *
+ *  @param		$qhandle (string)	Query result set handle
+ */
+function db_num_rows($qhandle) {
+	// return only if qhandle exists, otherwise 0
+	if ($qhandle) {
+		return mysqli_num_rows($qhandle);
+	} else {
+		return 0;
+	}
+}
+
+/**
+ *  Frees a database result properly 
+ *
+ *  @param	$qhandle (string)	Query result set handle
+ */
+function db_free_result($qhandle) {
+	return mysqli_free_result($qhandle);
+}
+
+/**
+ *  Reset a result set.
+ *
+ *  Reset is useful for db_fetch_array sometimes you need to start over
+ *
+ *  @param		$qhandle (string)	Query result set handle
+ *  @param		$row (int)		Row number
+ */
+function db_reset_result($qhandle,$row=0) {
+	return mysqli_data_seek($qhandle,$row);
+}
+
+/**
+ *  Returns a field from a result set
+ *
+ *  @param		$qhandle (string)	Query result set handle
+ *  @param		$row (int)		Row number
+ *  @param		$field (string)	Field name
+ */
+function db_result($qhandle,$row,$field) {
+	//return mysqli_result($qhandle,$row,$field);
+	if( mysqli_num_rows( $qhandle ) ) {
+		$x = 0;
+		while( $array = mysqli_fetch_array( $qhandle, MYSQLI_NUM ) ) {
+			if( $row == $x++ ) {
+				return isset( $array[ $field ] ) ? $array[ $field ] : '';
+			}
+		}
+	}	
+}
+
+/**
+ *  Returns the number of fields in this result set
+ *
+ *  @param		$lhandle (string)	Query result set handle
+ *  (!!! Deprecated? Changed the MySQL-Command to match the current syntax)
+ */
+function db_numfields($lhandle) {
+	return mysqli_num_fields($lhandle);
+}
+
+/**
+ *  Returns the number of fields in this result set
+ *
+ *  @param		$lhandle (string)	Query result set handle
+ * php 3,4,5
+ */
+function db_num_fields($lhandle) {
+	return mysqli_num_fields($lhandle);
+}
+
+/**
+ *  Returns the number of rows changed in the last query
+ *
+ *  @param		$lhandle	(string) Query result set handle
+ *  @param		$fnumber (int)	Column number
+ */
+function db_fieldname($lhandle,$fnumber) {
+	   return mysql_field_name($lhandle,$fnumber);
+}
+
+/**
+ *  Returns the number of rows changed in the last query
+ *
+ *  @param		$qhandle (string)	Query result set handle
+ */
+function db_affected_rows($qhandle) {
+	return mysqli_affected_rows($qhandle);
+}
+
+/**
+ *  Fetch an array
+ *
+ *  Returns an associative array from 
+ *  the current row of this database result
+ *  Use db_reset_result to seek a particular row
+ *
+ *  @param		$qhandle (string)	Query result set handle
+ */
+function db_fetch_array($qhandle) {
+	global $conn;
+
+	$data = mysqli_stmt_result_metadata($qhandle);
+        $fields = array();
+        $out = array();
+
+        $fields[0] = &$qhandle;
+        $count = 1;
+
+        while($field = mysqli_fetch_field($data)) {
+            $fields[$count] = &$out[$field->name];
+            $count++;
+        }
+       
+        call_user_func_array(mysqli_stmt_bind_result, $fields);
+        mysqli_stmt_fetch($qhandle);
+        return (count($out) == 0) ? false : $out;
+        
+	/*if (!$qhandle)
+		return NULL;
+	else
+		return mysqli_fetch_array($conn); */
+}
+
+/**                                                       
+ * fetch a row into an array 
+ * 
+ *  @param		$qhandle (string)	Query result set handle
+ *  @param		$fnumber (int)	Column number
+ */
+function db_fetch_row($qhandle,$fnumber=0) {
+	  global $stmt;
+	  if ($qhandle)
+	  	return mysqli_fetch_row($stmt);
+	  else
+	  	return NULL;
+}
+
+/**
+ *  Returns the last primary key from an insert
+ *
+ *  @param		$qhandle (string)	Query result set handle
+ *  @param		$table_name (string)	Is the name of the table you inserted into
+ *  @param		$pkey_field_name (string)	Is the field name of the primary key
+ */
+function db_insertid($qhandle="",$table_name="",$pkey_field_name="") {
+	return mysqli_insert_id();
+}
+
+function db_insert_id($qhandle="",$table_name="",$pkey_field_name="") {
+	return mysqli_insert_id();
+}
+
+/**
+ * Returns the last error from the database
+ */
+function db_error() {
+	global $conn;
+	return mysqli_error($conn);
+}
+
+/**
+ * Get the flags associated with the specified field in a result 
+ *
+ *  @param		$lhandle	(string) Query result set handle
+ *  @param		$fnumber (int)	Column number
+ *
+ * 					Examples: "not_null", "primary_key", "unique_key", "multiple_key",					 
+ *                    "blob", "unsigned", "zerofill","binary", "enum",                  
+ *                    "auto_increment", "timestamp"                                     
+ */
+
+function db_field_flags($lhandle,$fnumber) {
+	   return mysqli_field_flags($lhandle,$fnumber);
+}
+
+/**                                                       
+ * Get the type of the specified field  
+ *
+ *  @param		$lhandle	(string) Query result set handle
+ *  @param		$fnumber (int)	Column number
+ */                                                       
+                                                          
+function db_field_type($lhandle,$fnumber) {               
+	   return mysqli_field_type($lhandle,$fnumber);         
+}                                                         
+
+/**                                                       
+ * Get the length of the specified field                                                            
+ *
+ *  @param		$lhandle	(string) Query result set handle
+ *  @param		$fnumber (int)	Column number
+ */                                                       
+                                                          
+function db_field_len($lhandle,$fnumber) {               
+	   return mysqli_field_len($lhandle,$fnumber);         
+} 
+?>
\ No newline at end of file

Added: branches/nimix_dev/lib/database-pgsql.php
===================================================================
--- branches/nimix_dev/lib/database-pgsql.php	                        (rev 0)
+++ branches/nimix_dev/lib/database-pgsql.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,436 @@
+<?php
+# $Id:database-pgsql.php 2619 2008-07-08 15:46:11Z christoph $
+# http://www.mapbender.org/index.php/database-pgsql.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.
+
+/**
+ * \file
+ * \brief MySQL database connection/querying layer
+ * 
+ * MySQL database connection/querying layer
+ *
+ * example:
+ * \code
+ * include_once(dirname(__FILE__)."/afwphp/database-mysql.php");  
+ * $sys_dbhost=...                            
+ * $sys_dbuser=...                            
+ * $sys_dbpasswd=...                           
+ * $sys_dbname=...                            
+ *                                             
+ * db_connect();                               
+ * ...                                         
+ * $rs = db_query("select * from table");      
+ * while($row = db_fetch_array($rs));
+ *  ...
+ * \endcode
+ */
+
+/**
+ * System-wide database type
+ *
+ * @var	constant		$sys_database_type
+ */
+$sys_database_type='pgsql';
+
+/**
+ *  Connect to the database
+ *
+ *  Notice the global vars that must be set up
+ *  Notice the global vars $sys_dbhost,$sys_dbuser,$sys_dbpasswd,$sys_dbname that must be set up 
+ *  in other functions in this library
+ */
+include_once(dirname(__FILE__)."/../http/classes/class_mb_exception.php");
+include_once(dirname(__FILE__)."/../http/classes/class_checkInput.php");
+function db_escape_string($unescaped_string){
+	return @pg_escape_string(stripslashes($unescaped_string));
+}
+$DB = DB;
+
+
+function db_connect($DBSERVER="",$OWNER="",$PW="") {
+	global $sys_dbhost,$sys_dbuser,$sys_dbpasswd,$sys_dbname,$db_debug;
+	global $conn,$conn_update,$DB;	
+
+	
+	$db_debug=0;
+	if ($DBSERVER)
+		$sys_dbhost = $DBSERVER; 
+	if ($OWNER)
+		$sys_dbuser = $OWNER; 
+	if ($PW && $PW != null)
+		$sys_dbpasswd = $PW; 
+	
+	$sys_dbport = PORT; 	
+		
+	if($GLOBALS['DB'])
+		$sys_dbname = $DB;
+			
+	$connstring = "";
+	if ($sys_dbuser)		
+		$connstring.=" user=$sys_dbuser";
+	if ($sys_dbname)		
+		$connstring.=" dbname=$sys_dbname";		
+	if ($sys_dbhost)		
+		$connstring.=" host=$sys_dbhost";	
+	if ($sys_dbport)		
+		$connstring.=" port=$sys_dbport";		
+	if ($sys_dbpasswd)		
+		$connstring.=" password=$sys_dbpasswd";		
+	
+	if ($db_debug)
+		echo $connstring." ";		
+
+	$conn = pg_connect($connstring);		
+
+		#if(isset($sys_db_clientencoding) && $sys_db_clientencoding > "")
+		#{
+		#pg_set_client_encoding ( $conn, $sys_db_clientencoding);
+		#}
+	#return $conn;
+	if ($db_debug)
+		echo "conn=".$conn;
+#echo $connstring;
+#if(!$conn)
+#{echo "FEHLER in Connection";
+#pg_error($conn);}	
+	
+	return $conn;
+}
+
+function db_select_db($DB,$con="") {
+	global $conn,$sys_dbname; 
+#	$sys_dbname = DB;	
+#	$_con = $con ? $con : $conn;
+#	$ret = @mysql_select_db($sys_dbname,$_con);
+//	echo "$ret=@mysql_select_db($sys_dbname,$_con);";
+}
+
+/**
+ *  Query the database
+ *
+ *  @param		$qstring (string)	SQL statement
+ *  @param		$limit (int)		How many rows do you want returned
+ *  @param		$offset (int)		Of matching rows, return only rows starting here
+ */
+function db_query($qstring) {
+	global $sys_dbhost,$sys_dbuser,$sys_dbpasswd,$sys_dbname,$db_debug,
+		$conn,$conn_update,$QUERY_COUNT,$DBSERVER,$OWNER,$PW,$DB;
+	$QUERY_COUNT++;
+	$ret = pg_exec($qstring);
+//	$e = new mb_exception("not ps:  ".$_SERVER['SCRIPT_FILENAME']." : ".$qstring);
+	if(!$ret){
+		$e = new mb_exception("db_query($qstring)=$ret db_error=".db_error());
+	}
+	return $ret;	
+}
+/**
+ *  prepare and query the database
+ *
+ *  @param		$qstring (string)	SQL statement
+ *  @param		$params (array params as strings)		
+ *  @param		$types (array types as strings)		
+ */
+function db_prep_query($qstring, $params, $types){
+	$ci = new checkInput($qstring,$params,$types);
+	$params = $ci->v; 
+	if(PREPAREDSTATEMENTS == false){
+		for ($i=0; $i<count($params); $i++){
+			$needle = "$".strval($i+1);
+			$tmp = '';
+			if($params[$i] !== NULL){
+				if($types[$i] == 's'){ $tmp .= "'"; }
+				$tmp .= $params[$i];
+				if($types[$i] == 's'){ $tmp .= "'"; }
+			}
+			else{
+				$tmp .= "NULL";
+			}
+			$posa = mb_strpos($qstring, $needle);
+			$posb = mb_strlen($needle);
+			$qstring = mb_substr($qstring,0,$posa).$tmp.mb_substr($qstring,($posa + $posb));	
+		}
+		$r = db_query($qstring);
+		if(!$r){
+			$e = new mb_exception("Error while executing sql statement in ".$_SERVER['SCRIPT_FILENAME'].": Sql: ".$qstring.", Error: ".db_error());
+		}
+	}
+	else{
+		$result = pg_prepare("", $qstring);
+		if(!$result){
+			$e = new mb_exception("Error while preparing statement in ".$_SERVER['SCRIPT_FILENAME'].": Sql: ".$qstring.", Error: ".db_error());
+		}
+		$r = pg_execute("", $params);
+		if(!$r){
+			$e = new mb_exception("Error while executing prepared statement in ".$_SERVER['SCRIPT_FILENAME'].": Sql: ".$qstring.", Error: ".db_error());
+		}
+	}	
+	return $r;
+}
+/**
+ *	Begin a transaction
+ *
+ *	Begin a transaction for databases that support them
+ *	may cause unexpected behavior in databases that don't
+ */
+function db_begin() {
+	return db_query("BEGIN WORK");
+}
+
+/**
+ * Commit a transaction
+ *
+ * Commit a transaction for databases that support them
+ * may cause unexpected behavior in databases that don't
+ */
+function db_commit() {
+	return db_query("COMMIT");
+}
+
+/**
+ * Roll back a transaction
+ *
+ * Rollback a transaction for databases that support them
+ * may cause unexpected behavior in databases that don't
+ */
+function db_rollback() {
+	$str = db_error();
+	db_query("ROLLBACK");
+	die('sql error: ' . $str . " ROLLBACK performed....");
+}
+
+/**
+ * Returns the number of rows in this result set
+ *
+ *  @param		$qhandle (string)	Query result set handle
+ */
+function db_numrows($qhandle) {
+	// return only if qhandle exists, otherwise 0
+	if ($qhandle) {
+		return @pg_numrows($qhandle);
+	} else {
+		return 0;
+	}
+}
+/**
+ * Returns the number of rows in this result set
+ *
+ *  @param		$qhandle (string)	Query result set handle
+ *	php > 4.2
+ */ 
+function db_num_rows($qhandle) {
+	// return only if qhandle exists, otherwise 0
+	if ($qhandle) {
+		return @pg_num_rows($qhandle);
+	} else {
+		return 0;
+	}
+}
+
+/**
+ *  Frees a database result properly 
+ *
+ *  @param	$qhandle (string)	Query result set handle
+ */
+function db_free_result($qhandle) {
+	return @pg_freeresult($qhandle);
+}
+
+/**
+ *  Reset a result set.
+ *
+ *  Reset is useful for db_fetch_array sometimes you need to start over
+ *
+ *  @param		$qhandle (string)	Query result set handle
+ *  @param		$row (int)		Row number
+ */
+function db_reset_result($qhandle,$row=0) {
+#dummy
+	return 0;#mysql_data_seek($qhandle,$row);
+	
+}
+
+/**
+ *  Returns a field from a result set
+ *
+ *  @param		$qhandle (string)	Query result set handle
+ *  @param		$row (int)		Row number
+ *  @param		$field (string)	Field name
+ */
+function db_result($qhandle,$row,$field) {
+	return @pg_result($qhandle,$row,$field);
+}
+
+/**
+ *  Returns the number of fields in this result set
+ *
+ *  @param		$lhandle (string)	Query result set handle
+ */
+function db_numfields($lhandle) {
+	return @pg_numfields($lhandle);
+}
+
+/**
+ *  Returns the number of fields in this result set
+ *
+ *  @param		$lhandle (string)	Query result set handle
+ *	php >4.2
+ */
+function db_num_fields($lhandle) {
+	return @pg_num_fields($lhandle);
+}
+
+/**
+ *  Returns the number of rows changed in the last query
+ *
+ *  @param		$lhandle	(string) Query result set handle
+ *  @param		$fnumber (int)	Column number
+ */
+function db_fieldname($lhandle,$fnumber) {
+	   return @pg_fieldname($lhandle,$fnumber);
+}
+
+/**
+ *  Returns the number of rows changed in the last query
+ *
+ *  @param		$qhandle (string)	Query result set handle
+ */
+function db_affected_rows($qhandle) {
+	
+	return @pg_cmdtuples($qhandle);
+}
+
+/**
+ *  Fetch an array
+ *
+ *  Returns an associative array from 
+ *  the current row of this database result
+ *  Use db_reset_result to seek a particular row
+ *
+ *  @param		$qhandle (string)	Query result set handle
+ */
+function db_fetch_array($qhandle) {
+	return @pg_fetch_array($qhandle);
+}
+
+function db_fetch_all($qhandle){
+		return @pg_fetch_all($qhandle);
+}
+/**                                                       
+ * fetch a row into an array 
+ * 
+ *  @param		$qhandle (string)	Query result set handle
+ *  @param		$fnumber (int)	Column number
+ */
+function db_fetch_row($qhandle,$fnumber=0) {
+	  return pg_fetch_row($qhandle);
+}
+
+/**
+ *  Returns the last primary key from an insert
+ *
+ *  @param		$qhandle (string)	Query result set handle
+ *  @param		$table_name (string)	Is the name of the table you inserted into
+ *  @param		$pkey_field_name (string)	Is the field name of the primary key
+ */
+function db_insertid($qhandle="",$table_name="",$pkey_field_name="") {
+	$res=db_query("SELECT max($pkey_field_name) AS id FROM $table_name");
+    if ($res && db_numrows($res) > 0) {
+        return @db_result($res,0,'id');
+    } else {
+        return 0;
+    }
+}
+
+
+
+
+function db_insert_id($qhandle="",$table_name="",$pkey_field_name="") {
+		global $sys_dbhost,$sys_dbuser,$sys_dbpasswd,$sys_dbname,$db_debug,
+		$conn,$conn_update,$QUERY_COUNT,$DBSERVER,$OWNER,$PW,$DB;
+	/*	
+	$oid =pg_last_oid($qhandle);
+	echo $oid;
+	
+	$res=db_query("SELECT ".$pkey_field_name." FROM ".$table_name." WHERE oid =".$oid );
+    if ($res && db_numrows($res) > 0) {
+        return @db_result($res,0,0);
+    } else {
+        return 0;
+    }*/
+    $res=db_query("SELECT max($pkey_field_name) AS id FROM $table_name");
+    if ($res && db_numrows($res) > 0) {
+        return db_result($res,0,'id');
+    } else {
+        return 0;
+    }
+}
+
+function db_last_oid()
+      {
+      	global $sys_dbhost,$sys_dbuser,$sys_dbpasswd,$sys_dbname,$db_debug,
+		$conn,$conn_update,$QUERY_COUNT;
+        global $DBSERVER,$OWNER,$PW,$DB	;
+             return pg_getlastoid($conn);
+      }
+
+
+/**
+ * Returns the last error from the database
+ */
+function db_error() {
+	return @pg_last_error();
+}
+
+/**
+ * Get the flags associated with the specified field in a result 
+ *
+ *  @param		$lhandle	(string) Query result set handle
+ *  @param		$fnumber (int)	Column number
+ *
+ * 					Examples: "not_null", "primary_key", "unique_key", "multiple_key",					 
+ *                    "blob", "unsigned", "zerofill","binary", "enum",                  
+ *                    "auto_increment", "timestamp"                                     
+ */
+
+function db_field_flags($lhandle,$fnumber) {
+	   print "db_field_flags()	isn't implemented";
+	   
+}
+
+/**                                                       
+ * Get the type of the specified field  
+ *
+ *  @param		$lhandle	(string) Query result set handle
+ *  @param		$fnumber (int)	Column number
+ */                                                       
+                                                          
+function db_field_type($lhandle,$fnumber) {               
+	   return @pg_fieldtype($lhandle,$fnumber);         
+}                                                         
+
+/**                                                       
+ * Get the length of the specified field                                                            
+ *
+ *  @param		$lhandle	(string) Query result set handle
+ *  @param		$fnumber (int)	Column number
+ */                                                       
+                                                          
+function db_field_len($lhandle,$fnumber) {               
+	   return @pg_fieldlen($lhandle,$fnumber);         
+} 
+
+?>
\ No newline at end of file

Added: branches/nimix_dev/lib/div.js
===================================================================
--- branches/nimix_dev/lib/div.js	                        (rev 0)
+++ branches/nimix_dev/lib/div.js	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,126 @@
+/* 
+* $Id: map_obj.js 2413 2008-04-23 16:21:04Z christoph $
+* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
+* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
+*/
+
+/**
+ * @class Represents a div tag. May be located in any frame of Mapbender.
+ * 
+ * @constructor
+ * @param aTagName {String} the name of the tag
+ * @param aFrameName {String} the name of frame where the div tag is being created
+ * @param aStyle {Object} an object containing a set of name value pairs, like
+ *                        {position:absolute,top:30,z-Index:30}
+ */
+function DivTag (aTagName, aFrameName, aStyle) {
+	/**
+	 * @ignore
+	 */
+	this.exists = function () { 
+		return (rootNode.getElementById(tagName)) ? true : false;
+	};
+	
+	/**
+	 * @ignore
+	 */
+	this.getTag = function() {
+		return rootNode.getElementById(tagName);
+	};
+	
+	/**
+	 * @private
+	 */
+	var determineRootNode = function () {
+		node = document;
+		if (frameName !== "") {
+			if (checkFrame()) {node = window.frames[frameName].document;}
+			else {var e = new Mb_exception("frame "+frameName+" doesn't exist.");}
+		}
+		return node;	
+	};
+	
+	/**
+	 * @private
+	 */
+	var toCamelCase = function(aString) {
+		var newString = "";
+		for (var i = 0; i < aString.length; i++) {
+			if (aString.substr(i,1) != "-") {
+				newString += aString.substr(i,1); 
+			}
+			else {
+				i++;
+				newString += aString.substr(i,1).toUpperCase();
+			}
+		}
+		return newString;
+	};
+	
+	/**
+	 * @private
+	 */
+	var setStyle = function () {
+		if (that.exists()) {
+			var node = rootNode.getElementById(tagName);
+			node.setAttribute("style", "");
+			
+			for (var attr in tagStyle) {
+				if (typeof(tagStyle[attr]) != "function" && typeof(tagStyle[attr]) != "object") {
+					var evalString = "node.style."+toCamelCase(attr)+" = \"" + tagStyle[attr] + "\";"; 
+					eval(evalString);				
+				}
+			}
+		}
+	};
+	
+	/**
+	 * @private
+	 */
+	var create = function () {
+		if (!that.exists()) {
+			var divTag = rootNode.createElement("div");
+			var divTagAppended = rootNode.getElementsByTagName("body")[0].appendChild(divTag);
+			divTagAppended.id = tagName;
+		}
+		else {
+			that.clean();
+		}
+		setStyle();
+	};
+
+	/**
+	 * @private
+	 */
+	var checkFrame = function () {
+		if (frameName !== "") {
+			return (typeof(window.frames[frameName]) != 'undefined');
+		}
+		return true;
+	};
+	
+	var that = this;
+	var tagName = aTagName;
+	var frameName = aFrameName;
+	var rootNode = determineRootNode();
+	var tagStyle = aStyle;
+
+	create();
+}
+/**
+ * Writes a text into the div tag, while removing existing content.
+ * 
+ * @param {String} someText the text that is inserted into the tag.
+ */
+DivTag.prototype.write = function (someText) {
+	if (this.exists()) {
+		this.getTag().innerHTML = someText;
+	}
+};
+
+/**
+ * Deletes the div tag content.
+ */
+DivTag.prototype.clean = function () {
+	this.write("");
+};

Added: branches/nimix_dev/lib/draggableButton.js
===================================================================
--- branches/nimix_dev/lib/draggableButton.js	                        (rev 0)
+++ branches/nimix_dev/lib/draggableButton.js	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,98 @@
+var Draggable = {
+	buttonParameters : {
+		on:"../img/button_blink_red/pan_on.png",
+		over:"../img/button_blink_red/pan_over.png",
+		off:"../img/button_blink_red/pan_off.png",
+		type:"toggle"
+	},
+	grid : [7,7],
+	makeDraggable : function() {
+
+		var $selection = $(".ui-selected");
+		if ($selection.size() > 0) {
+
+			// if elements have been selected, we want to drag 
+			// them together, not individually. So we move these
+			// elements into a new div tag, and make that tag 
+			// draggable
+			
+			Draggable.moveSelectionToDiv();
+			
+			$(".div-draggable").draggable({
+				grid:Draggable.grid
+			});
+		}
+		else {
+			$(".collection").children().draggable({
+				grid:Draggable.grid
+			});
+		}
+	},
+	removeDraggable : function () {
+		if ($(".ui-selected").size() > 0) {
+			Draggable.moveSelectionFromDiv();			
+		}
+		$(".collection").children().draggable("destroy");
+	},
+	moveSelectionFromDiv : function () {
+		var divX, divY;
+		var $draggableDiv = $(".div-draggable");
+		$draggableDiv.each(function() {
+			divX = parseInt(this.style.left);
+			divY = parseInt(this.style.top);
+		});
+		$draggableDiv.children().each(function() {
+			var newX = parseInt(this.style.left) + divX;
+			var newY = parseInt(this.style.top) + divY;
+			this.style.left = newX + "px";
+			this.style.top = newY + "px";
+			$(this).removeClass("ui-selectee");
+			$(this).removeClass("ui-selected");
+			$(this).addClass("div-border");
+			$clone = $(this).clone();
+			$(".collection").append($clone);
+		});
+		$draggableDiv.remove();
+	},
+	moveSelectionToDiv : function () {
+		// first, put all selected elements inside a 
+		// single div tag; then, make that div tag 
+		// draggable
+		
+		// the coordinates of the new div tag need
+		// to be computed first
+		var minX, minY;
+		$(".ui-selected").each(function() {
+			var currentLeft = parseInt(this.style.left);
+			if ((!minX && minX !== 0) || currentLeft < minX) {
+				minX = currentLeft;
+			}
+			var currentTop = parseInt(this.style.top);
+			if ((!minY && minY !== 0) || currentTop < minY) {
+				minY = currentTop;
+			}
+		});
+		
+		var $div = $("<div class='div-draggable'></div>");
+		$div.css("position", "absolute");
+		$div.css("top", minY);
+		$div.css("left", minX);
+
+		// to move the selected nodes, we clone them and attach
+		// them to the new div. the old tags are removed 
+		$(".ui-selected").each(function() {
+			var newX = parseInt(this.style.left) - minX;
+			var newY = parseInt(this.style.top) - minY;
+
+			$clone = $(this).clone();
+			$clone.css("position", "absolute");
+			$clone.css("top", newY + "px");
+			$clone.css("left", newX + "px");
+
+			$div.append($clone);
+			$(this).remove();
+		});
+		
+		$div.appendTo($(".collection"));
+	}
+}

Added: branches/nimix_dev/lib/event.js
===================================================================
--- branches/nimix_dev/lib/event.js	                        (rev 0)
+++ branches/nimix_dev/lib/event.js	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,193 @@
+/**
+ * An event. What happens, when the event occurs, depends on which functions have been
+ * registered with the event. 
+ * 
+ * usage:
+ * 
+ * // create a new Event
+ * var eventAfterMapRequest = new MapbenderEvent(); 
+ * 
+ * // register a function with that event
+ * eventAfterMapRequest.register(function () {
+ * 	...
+ * })
+ * 
+ * // trigger the event
+ * eventAfterMapRequest.trigger();
+ * 
+ */
+var MapbenderEvent = function () {
+	
+	// public methods
+	/**
+	 * A function that needs to be executed, when the event occurs, has to be 
+	 * registered via this function.
+	 */
+	this.register = function(aFunction) {
+
+		var mpbnFunction = new MapbenderFunction(aFunction);
+		functionArray.push(mpbnFunction);
+	};
+
+	/**
+	 * Exclude a previously registered function from the event
+	 */
+	this.unregister = function(aFunction) {
+		for (var i = 0, len = functionArray.length; i < len; i++) {
+			if (functionArray[i].getFunction() === aFunction) {
+				for (var j = i + 1; j < len; j++) {
+					functionArray[j-1] = functionArray[j];
+				}
+				delete functionArray[len - 1];
+				len = len - 1;
+			}
+		}
+		functionArray.length = len;
+	};
+
+	/**
+	 * Checks if a function is already registered with this event
+	 */
+	this.isRegistered = function (aFunction) {
+		for (var i = 0, len = functionArray.length; i < len; i++) {
+			if (functionArray[i].getFunction() === aFunction) {
+				return true;
+			}
+		}
+		return false;
+	};
+	
+	/**
+	 * This function triggers the event
+	 */
+	this.trigger = function(properties, booleanOperator) {
+		if (!(functionArray.length > 0)) {
+			return true;
+		}
+		//
+		// check arguments
+		//
+		// properties
+		if (typeof(properties) != "object") {
+			// maybe properties is missing, and so 
+			// properties represents booleanOperator
+			if (typeof(booleanOperator) == "undefined") {
+				booleanOperator = properties;
+				properties = undefined;
+			}
+			else {
+//				var e = new Mb_exception("MapbenderEvent.trigger: invalid properties: %s", properties);
+			}
+		}		
+
+		// booleanOperator
+		if (typeof(booleanOperator) == "string") {
+			if (booleanOperator != "AND" && booleanOperator != "OR") {
+//				var e = new Mb_exception("MapbenderEvent.trigger: invalid booleanOperator: %s", booleanOperator);
+			}
+		}		
+		else if (typeof(booleanOperator) != "undefined") {
+//			var e = new Mb_exception("MapbenderEvent.trigger: invalid booleanOperator, must be a string, but is %s", typeof(booleanOperator));
+		}
+		
+		var result;
+
+		// the optional boolean operator allows to combine the return values of the functions
+		// into a single result value.
+		switch (booleanOperator) {
+			case "AND":
+				result = true;
+				break;
+			case "OR":
+				result = false;
+				break;
+			default:
+				result = true;
+				break;
+		}
+
+		if (log) {
+			var e = new Mb_notice("functions (after sort): " + functionArray.join(","));
+		}
+
+		for (var i = 0; i < functionArray.length; i++) {
+			// executes the function at position i
+			// and determines the return value based on the (optional) boolean operator
+			switch (booleanOperator) {
+				case "AND":
+					result = result && functionArray[i].execute(properties);
+					break;
+				case "OR":
+					result = result || functionArray[i].execute(properties);
+					break;
+				default:
+					result = functionArray[i].execute(properties);
+					break;
+			}
+		}
+		return result;
+	};	
+	
+	this.getProperties = function () {
+		return propertiesObj;
+	};
+
+	// private
+	/**
+	 * these functions will be executed once the event is triggered
+	 */
+	var functionArray = [];
+	
+	var propertiesObj;
+	var log = false;
+};
+
+/**
+ * A MapbenderFunction is a function with a priority.
+ */
+var MapbenderFunction = function (aFunction) {
+	
+	// public
+	/**
+	 * Returns the function itself
+	 */
+	this.getFunction = function () {
+		return func;
+	};
+	
+	/**
+	 * Executes the function
+	 */
+	this.execute = function (argumentObj) {
+		if (typeof(aFunction) == "function") {
+			return func(argumentObj);
+		}
+
+		// this branch is for backwards compatibility with the 
+		// pre-2.5 event system that is based on strings.
+		else {
+			var argumentNames = [];
+			var argumentValues = [];
+			for (var i in argumentObj) {
+				if (typeof(argumentObj[i]) == "number" || typeof(argumentObj[i]) == "boolean") {
+					argumentNames.push(i);
+					argumentValues.push(argumentObj[i]);
+				}
+				else if (typeof(argumentObj[i]) == "string") {
+					argumentNames.push(i);
+					argumentValues.push("'" + argumentObj[i] + "'");
+				}
+			}
+			var str = "";
+			str += "(function (" + argumentNames.join(", ") + ") {";
+			str += "return " + aFunction;
+			str += "}";
+			str += "(" + argumentValues.join(", ") + "));";
+			var returnValue = eval(str);
+			return returnValue;
+		}	
+	};
+	
+	// private
+	var func = aFunction;
+};
\ No newline at end of file

Added: branches/nimix_dev/lib/exception.js
===================================================================
--- branches/nimix_dev/lib/exception.js	                        (rev 0)
+++ branches/nimix_dev/lib/exception.js	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,103 @@
+/* 
+* $Id: map_obj.js 2413 2008-04-23 16:21:04Z christoph $
+* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
+* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
+*/
+
+
+/*
+ ***************************************************************************************
+ *   Javascript exception handling
+ ***************************************************************************************
+ */
+
+/**
+ * @class An abstract class, logs JavaScript events like errors, warnings etc.
+ *
+ * @constructor
+ */
+var Mb_log = function() {
+	var that = this;
+	
+	var levelArray = global_log_levels.split(",");
+	var log_level = global_mb_log_level;
+	var log_js = global_mb_log_js;
+	
+	var indexOfLevel = function(aLevel) {
+		for (var i = 0; i < levelArray.length; i++) {
+			if (aLevel == levelArray[i])  {
+				return i;
+			}
+		}
+		return false;
+	};
+	var isValidLevel = function(aLevel) {
+		var isNotOff = typeof(log_js) != 'undefined' && log_js != "off";
+		var levelIndex = indexOfLevel(aLevel);
+		var isAppropriate = (typeof(levelIndex)=='number' && levelIndex < indexOfLevel(log_level));
+		return (isNotOff && isAppropriate);
+	};
+	this.throwException = function (message, level) {
+		if (isValidLevel(level)) {
+			if (log_js == "on") {
+				try {
+					mb_ajax_post('../php/mb_js_exception.php', {level:level,text:message});
+				}
+				catch(e) {
+					alert(e + ": " + message);
+				}
+			}
+			else if (log_js == "alert") {
+				alert(message);
+			}
+			else if (log_js == "console") {
+				if (level == "warning") {
+					console.warn("%s", message);
+				}
+				else if (level == "error") {
+					console.error("%s", message);
+				}
+				else {
+					console.log("%s", message);
+				}
+			}
+		}
+	};
+};	
+
+/**
+ *  class for exception logging
+ *
+ * @extends {@link Mb_log}
+ * @param message the message that is being logged
+ */	
+function Mb_exception(message) {
+	 var level = "error";
+	this.throwException(message, level);
+}
+Mb_exception.prototype = new Mb_log();
+
+/**
+ *  class for warning logging
+ *
+ * @extends {@link Mb_log}
+ * @param message the message that is being logged
+ */
+function Mb_warning(message) {
+	var level = "warning";
+	this.throwException(message, level);
+}
+Mb_warning.prototype = new Mb_log();
+ 
+/**
+ *  class for notice logging
+ *
+ * @extends {@link Mb_log}
+ * @param message the message that is being logged
+ */	
+ 
+function Mb_notice(message) {
+	var level = "notice";
+	this.throwException(message, level);
+}
+Mb_notice.prototype = new Mb_log();
\ No newline at end of file

Added: branches/nimix_dev/lib/i18n.php
===================================================================
--- branches/nimix_dev/lib/i18n.php	                        (rev 0)
+++ branches/nimix_dev/lib/i18n.php	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,8 @@
+<?php
+	function _mb ($someString) {
+		if (USE_I18N) {
+			return _($someString);
+		}
+		return $someString;
+	}
+?>
\ No newline at end of file

Added: branches/nimix_dev/lib/list.js
===================================================================
--- branches/nimix_dev/lib/list.js	                        (rev 0)
+++ branches/nimix_dev/lib/list.js	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,117 @@
+/* 
+* $Id: map_obj.js 2413 2008-04-23 16:21:04Z christoph $
+* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
+* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
+*/
+
+/**
+ * @class A List object is an array of arbitrary objects with additional methods. 
+ *
+ * @constructor
+ */
+var List = function() {
+	
+	/**
+	 * gets the number of elements in this {@link List}
+	 *
+	 * @returns number of elements in this {@link List}
+	 * @type Integer
+	 */
+	this.count = function() {
+		return this.list.length;
+	};
+
+	/**
+	 * deletes the object at index i; -1 refers to the last object in this {@link List}
+	 *
+	 * @param {Integer} i index
+	 */
+	this.del = function(i){
+		i = this.getIndex(i);
+		if (i !== false) {
+			for(var z = i; z < this.count() - 1; z++){
+				this.list[z] = this.list[z+1];
+			}
+			this.list.length -= 1;
+			return true;
+		}
+		return false;
+	};
+
+	/**
+	 * empties this {@link List}
+	 */
+	this.empty = function() {
+		while (this.list !== null && this.count() > 0) {
+			this.list.pop();
+		}
+	};
+	
+	/**
+	 * @param {Integer} i index
+	 * @returns the object at index i; -1 refers to the last object in this {@link List}
+	 * @type Integer or false
+	 */
+	this.get = function(i) {
+		i = this.getIndex(i);
+		if (i !== false) {return this.list[i];}
+		return false;		
+	};
+	/**
+	 * adds a reference to item to this {@link List}.
+	 *
+	 * @param {Object} item an object
+	 */
+	this.add = function(item) {
+		var i = this.list.length;
+		this.list[i] = item;
+	};
+	/**
+	 * adds a copy of item to this {@link List}.
+	 *
+	 * @param {Object} item an object
+	 */
+	this.addCopy = function(item) {
+		this.add(cloneObject(item));
+	};
+	/**
+	 * attaches the {@link List} aList to this {@link List}
+	 *
+	 * @param {List} aList another list
+	 */
+	this.union = function(aList) {
+		for (var i=0; i < aList.count(); i++) {this.addCopy(aList.get(i));}
+	};
+	/**
+	 * checks if the index is valid and returns it if it is; if i == -1, the correct index is retrieved.
+	 *
+	 * @private
+	 * @return Integer or false
+	 * @type Integer
+	 */
+	this.getIndex = function(i){ 
+		var len = this.list.length;
+		if (i<0 && len + i > -1) {
+			return len + i;			
+		}
+		else if (i > -1 && i < len){
+			return i;
+		}
+		var e = new Mb_exception("class List: function getIndex: member index " + i + " is not valid");
+		return false;
+	};
+	/**
+	 * @returns a {String} representation of this List
+	 * @type String
+	 */
+	this.toString = function(){
+		var str = "";
+		for (var i =0 ; i < this.count() ; i++){
+			str += this.get(i).toString();
+		}
+		return str;	
+	};	
+	
+	this.list = null;
+};
+

Added: branches/nimix_dev/lib/point.js
===================================================================
--- branches/nimix_dev/lib/point.js	                        (rev 0)
+++ branches/nimix_dev/lib/point.js	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,192 @@
+/* 
+* $Id:point.js 2476 2008-05-28 15:03:41Z christoph $
+* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
+* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
+*/
+//http://www.mapbender.org/index.php/point.js
+
+/**
+ * @class A class representing a two-dimensional point.
+ *
+ * @constructor
+ * @param {Float} x x value of the {@link Point}
+ * @param {Float} y y value of the {@link Point}
+ */
+ function Point(x, y, z){
+ 	/**
+ 	 * x value of the {@link Point}
+ 	 *
+	 * @type Float
+	 */
+//	this.x = parseFloat(x);
+	this.x = x;
+ 	/**
+ 	 * y value of the {@link Point}
+	 *
+	 * @type Float
+	 */
+//	this.y = parseFloat(y);
+	this.y = y;
+	
+	this.z = z;
+	
+}
+/**
+ * computes the distance between a {@link Point} p and this {@link Point}
+ *
+ * @param {Point} p the distance between this {@link Point} and the {@link Point} p is computed.
+ * @return {Float} the distance between the two {@link Point} objects.
+ */
+Point.prototype.dist = function(p){
+	return Math.sqrt(Math.pow(this.y-p.y,2) + Math.pow(this.x-p.x,2)) ;
+};
+/**
+ * checks if the coordinates of this {@link Point} match the coordinates of a {@link Point} p
+ *
+ * @param {Point} p 
+ * @return {Boolean} true if the two points are equal; elso false
+ */
+Point.prototype.equals = function(p){
+	if (this.x == p.x && this.y == p.y) {return true;}
+	return false;
+};
+/**
+ * subtracts a {@link Point} p from this {@link Point}
+ *
+ * @param {Point} p 
+ * @return a new {@link Point} with the difference of the two points
+ */
+Point.prototype.minus = function(p){
+	return new Point(this.x-p.x, this.y-p.y);
+};
+/**
+ * adds this {@link Point} to a {@link Point} p
+ *
+ * @param {Point} p 
+ * @return a new {@link Point} with the sum of the two points
+ */
+Point.prototype.plus = function(p){
+	return new Point(this.x+p.x, this.y+p.y);
+};
+/**
+ * divides this {@link Point} by a scalar c
+ *
+ * @param {Float} c divisor
+ * @return a new {@link Point} divided by c
+ */
+Point.prototype.dividedBy = function(c){
+	if (c !== 0) {
+		return new Point(this.x/c, this.y/c);
+	}
+	var e = new Mb_exception("Point.dividedBy: Division by zero");
+	return false;
+};
+/**
+ * multiplies this {@link Point} by a scalar c
+ *
+ * @param {Float} c factor
+ * @return a new {@link Point} multiplied by c
+ */
+Point.prototype.times = function(c){
+	return new Point(this.x*c, this.y*c);
+};
+/**
+ * rounds the coordinates to numOfDigits digits
+ *
+ * @param numOfDigits the coordinate will be rounded to numOfDigits digits
+ * @return a new {@link Point} rounded to numOfDigits digits
+ * @type Point
+ */
+Point.prototype.round = function(numOfDigits){
+	return new Point(roundToDigits(this.x, numOfDigits), roundToDigits(this.y, numOfDigits));
+};
+/**
+ * @returns a {String} representation of this Point
+ * @type String
+ */
+Point.prototype.toString = function(){
+	if (typeof(this.z == "undefined")) {
+		return "[" + this.x + ", " + this.y + "]";
+	}
+	else {
+		return "[" + this.x + ", " + this.y + ", " + this.z + "]";
+	}
+};
+
+
+//------------------------------------------------------------------------
+// possible improvement: point has flag: map OR real. additional functions: toReal, toMap
+/**
+ * @ignore
+ */
+function mapToReal(frameName, aPoint){
+	var v;
+	if (typeof(mb_mapObj) == 'object') {
+		v = makeClickPos2RealWorldPos(frameName, aPoint.x, aPoint.y);
+	}
+	else {
+		if (typeof(parent.mb_mapObj) == 'object') {
+			v = parent.makeClickPos2RealWorldPos(frameName, aPoint.x, aPoint.y);
+		}
+		else {
+			alert('where am i?');
+		}
+	}
+	return new Point(v[0], v[1]);
+}
+/**
+ * @ignore
+ */
+function realToMap(frameName, aPoint) {
+	var v;
+	if (typeof(mb_mapObj) == 'object') {
+		v = makeRealWorld2mapPos(frameName, aPoint.x, aPoint.y);
+	}
+	else if (typeof(parent.mb_mapObj) == 'object') {
+		v = parent.makeRealWorld2mapPos(frameName, aPoint.x, aPoint.y);
+	}
+	else {
+		var e = new Mb_exception('Point.realToMap:where am i?');
+	}
+	return new Point(v[0], v[1]);
+}
+/**
+ * @ignore
+ */
+function mb_calcExtent(frameName, min, max) {
+	var ind;
+	if (typeof(mb_mapObj) == 'object') {
+		ind = getMapObjIndexByName(frameName);
+	}
+	else if (typeof(parent.mb_mapObj) == 'object') {
+		ind = parent.getMapObjIndexByName(frameName);
+	}
+	else {
+		var e = new Mb_exception('Point.mb_calcExtent: function getMapObjIndexByName not found');
+	}
+	var extent = max.minus(min);
+	var center = extent.dividedBy(2).plus(min);
+	
+	var relation_px_x = mb_mapObj[ind].width / mb_mapObj[ind].height;
+	var relation_px_y = mb_mapObj[ind].height / mb_mapObj[ind].width;
+	var relation_bbox_x = extent.x / extent.y;     
+	
+	var new_min;
+	var new_max;
+	
+	if(relation_bbox_x <= relation_px_x){                
+		new_min = new Point(center.x - relation_px_x * extent.y / 2, min.y);
+		new_max = new Point(center.x + relation_px_x * extent.y / 2, max.y);
+	}
+	else if(relation_bbox_x > relation_px_x){                
+		new_min = new Point(min.x, center.y - relation_px_y * extent.x / 2);
+		new_max = new Point(max.x, center.y + relation_px_y * extent.x / 2);
+	}
+	mb_mapObj[ind].extent = new_min.x +","+ new_min.y +","+ new_max.x  +","+ new_max.y;
+}
+/**
+ * @ignore
+ */
+function roundToDigits(aFloat, numberOfDigits) {
+	return Math.round(aFloat*Math.pow(10, parseInt(numberOfDigits, 10)))/Math.pow(10, parseInt(numberOfDigits, 10));
+}

Added: branches/nimix_dev/lib/resizableButton.js
===================================================================
--- branches/nimix_dev/lib/resizableButton.js	                        (rev 0)
+++ branches/nimix_dev/lib/resizableButton.js	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,18 @@
+var Resizable = {
+	buttonParameters : {
+		on:"../img/button_blink_red/select_rectangle_on.png",
+		over:"../img/button_blink_red/select_rectangle_over.png",
+		off:"../img/button_blink_red/select_rectangle_off.png",
+		type:"toggle"
+	},
+	makeResizable : function () {
+		var selector = ".collection > div";
+		$all = $(selector);
+		$all.resizable();	
+	},
+	removeResizable : function () {
+		var selector = ".collection > div";
+		$all = $(selector);
+		$all.resizable("destroy");	
+	}
+};

Added: branches/nimix_dev/lib/saveButton.js
===================================================================
--- branches/nimix_dev/lib/saveButton.js	                        (rev 0)
+++ branches/nimix_dev/lib/saveButton.js	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,34 @@
+var Save = {
+	buttonParameters : {
+		on:"../img/button_blink_red/wmc_save_on.png",
+		over:"../img/button_blink_red/wmc_save_over.png",
+		off:"../img/button_blink_red/wmc_save_off.png",
+		type:"toggle"
+	},
+	updateDatabase : function (callback) {
+		var data = [];
+		$(".collection").children().each(function() {
+			data.push({
+				id:this.id,
+				top:parseInt(this.style.top),
+				left:parseInt(this.style.left),
+				width:parseInt(this.style.width),
+				height:parseInt(this.style.height)	
+			});
+		});
+		var queryObj = {
+			command:"update",
+			parameters:{
+				applicationId:editApplicationId,
+				data:data	
+			}
+		};
+		$.post("mod_editApplication_server.php", {
+			queryObj:$.toJSON(queryObj)	
+		}, function (json, status) {
+			var replyObj = eval('(' + json + ')');
+			alert(replyObj.success);
+			callback();
+		});
+	}
+};

Added: branches/nimix_dev/lib/selectableButton.js
===================================================================
--- branches/nimix_dev/lib/selectableButton.js	                        (rev 0)
+++ branches/nimix_dev/lib/selectableButton.js	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,32 @@
+var Selectable = {
+	buttonParameters : {
+		on:"../img/button_blink_red/selArea_on.png",
+		over:"../img/button_blink_red/selArea_over.png",
+		off:"../img/button_blink_red/selArea_off.png",
+		type:"toggle"
+	},
+	makeSelectable : function () {
+		// if a selection has been made, remove it
+		if ($(".ui-selected").size() > 0) {
+			Selectable.removeSelection();
+		}
+
+		$all = $(".collection");
+		$all.selectable({
+			selecting:function() {
+				$(".ui-selecting").removeClass("div-border");
+			},
+			unselecting:function() {
+				$(".ui-selectee").addClass("div-border");
+				$(".ui-selecting").removeClass("div-border");
+			}
+		});
+	},
+	removeSelection : function () {
+		$(".ui-selected").addClass("div-border");
+		$(".collection").selectable("destroy");
+		$(".ui-selected").removeClass("ui-selected");
+		$(".ui-selectee").removeClass("ui-selectee");
+		$(".ui-selectable").removeClass("ui-selectable");
+	}
+}
\ No newline at end of file

Added: branches/nimix_dev/lib/style.js
===================================================================
--- branches/nimix_dev/lib/style.js	                        (rev 0)
+++ branches/nimix_dev/lib/style.js	2008-08-18 18:20:44 UTC (rev 2878)
@@ -0,0 +1,54 @@
+/**
+ * creates a style tag in the head of the document.
+ *
+ */
+var StyleTag = function() {
+
+	/**
+	 * Creates the style tag in the head of the document. Something like a constructor. 
+	 *
+	 */
+	var createStyleTag = function() {
+		// TODO: Internet Explorer routine seems a little buggy
+		if (top.ie) {
+			// create a Style Sheet object (IE only)
+			//styleSheetObj=document.createStyleSheet();
+			// get the DOM node of the style sheet object, set the type
+			//styleObj=styleSheetObj.owningElement || styleSheetObj.ownerNode;
+			//styleObj.setAttribute("type","text/css");
+			
+			// alternative way for IE: take existing styleSheet with index 0 instead of creating a new one
+			styleSheetObj=document.styleSheets[0];
+		}
+		else {
+			// create the style node, set the style
+			styleObj=document.createElement("style");
+			styleObj.setAttribute("type","text/css");
+			// append the node to the head
+			document.getElementsByTagName("head")[0].appendChild(styleObj);
+		}
+	};
+	
+	/**
+	 * Adds a class className with the CSS in cssString
+	 */
+	this.addClass = function(className,cssString) {
+		// TODO: Internet Explorer routine seems a little buggy
+		if (top.ie) {
+			//add new style declaration to chosen styleSheet 
+			var cssRules = cssString.split(";");
+			for (i=0; i<cssRules.length-1; i++){
+				styleSheetObj.addRule("."+className,cssRules[i]);
+			}
+		}
+		else {
+			// insert the content via createTextNode
+			styleObj.appendChild(document.createTextNode("."+className+"{\n\t"+cssString+"\n}\n"));				
+		}
+	};
+	
+	var styleObj;
+	var styleSheetObj; //IE only...
+	
+	createStyleTag();
+};
\ No newline at end of file



More information about the Mapbender_commits mailing list