[Mapbender-commits] r4477 - trunk/mapbender/http/include

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Aug 4 11:10:54 EDT 2009


Author: christoph
Date: 2009-08-04 11:10:54 -0400 (Tue, 04 Aug 2009)
New Revision: 4477

Modified:
   trunk/mapbender/http/include/dyn_js_object.php
Log:


Modified: trunk/mapbender/http/include/dyn_js_object.php
===================================================================
--- trunk/mapbender/http/include/dyn_js_object.php	2009-08-04 15:09:57 UTC (rev 4476)
+++ trunk/mapbender/http/include/dyn_js_object.php	2009-08-04 15:10:54 UTC (rev 4477)
@@ -28,13 +28,37 @@
 	$varArray = array();
 	while ($row = db_fetch_array($res)) {
 		if (mb_strpos($row["var_name"], "[")) {
+
+			//
+			// backwards compatibility for var names like name[0], name[1] etc
+			//
 			$arrayname = mb_substr($row["var_name"], 0, mb_strpos($row["var_name"], "["));
 			
 			if (!in_array($arrayname, $arrays)) {
-				$i++;
-				$arrays[$i] = $arrayname;
+				$arrays[]= $arrayname;
 				$varArray[]= $arrayname  . ": []";
 			}
+			else {
+				for ($i = 0; $i < count($varArray); $i++) {
+					if (mb_substr($varArray[$i], 0, mb_strlen($arrayname) + 1) === $arrayname . ":") {
+						if (is_numeric(stripslashes($row["var_value"]) || 
+							strpos(stripslashes($row["var_value"]), "[") === 0 || 
+							strpos(stripslashes($row["var_value"]), "{") === 0)) {
+							
+							$varArray[$i] = substr_replace(
+								$varArray[$i], 
+								$row["var_name"].": ".stripslashes($row["var_value"]) . "]",
+								-1);
+						}
+						else {
+							$varArray[$i] = substr_replace(
+								$varArray[$i], 
+								$row["var_name"].": '".stripslashes($row["var_value"]) . "']",
+								-1);
+						}
+					}
+				}
+			}
 		}
 		if (is_numeric(stripslashes($row["var_value"]))) {
 			$varArray[]= $row["var_name"].": ".stripslashes($row["var_value"]);



More information about the Mapbender_commits mailing list