[fusion-commits] r2513 - sandbox/adsk/2.4j/layers/MapGuide/php

svn_fusion at osgeo.org svn_fusion at osgeo.org
Tue Jan 10 00:35:11 EST 2012


Author: liuar
Date: 2012-01-09 21:35:11 -0800 (Mon, 09 Jan 2012)
New Revision: 2513

Modified:
   sandbox/adsk/2.4j/layers/MapGuide/php/Selection.php
   sandbox/adsk/2.4j/layers/MapGuide/php/Utilities.php
Log:
Fix ticket #511: Error message when layer name starting with number in MapGuide

When Fusion try to store selection set in session, it uses layer name as property name, but PHP doesn't allow property name beginning with number. That's why. The fix is adding a prefix "Layer" before the layer name when using it as property name. When fetching data from session, we remove the prefix so that there is no change to the result.


Modified: sandbox/adsk/2.4j/layers/MapGuide/php/Selection.php
===================================================================
--- sandbox/adsk/2.4j/layers/MapGuide/php/Selection.php	2012-01-10 05:33:26 UTC (rev 2512)
+++ sandbox/adsk/2.4j/layers/MapGuide/php/Selection.php	2012-01-10 05:35:11 UTC (rev 2513)
@@ -78,15 +78,16 @@
         for ($i=0; $i<count($aSelectedLayers); $i++)
         {
             $layerName =  $aSelectedLayers[$i];
+            $layerNameInProperties = GetLayerNameInProperties($layerName);
             if (($bAllLayers || in_array($layerName, $aLayers)) &&
-                isset($properties->$layerName) &&
-                $properties->$layerName->numelements > 0)
+                isset($properties->$layerNameInProperties) &&
+                $properties->$layerNameInProperties->numelements > 0)
             {
                 array_push($result->layers, $layerName);
-                $result->$layerName->propertynames = $properties->$layerName->propertynames;
-                $result->$layerName->propertyvalues = $properties->$layerName->propertyvalues;
-                $result->$layerName->propertytypes = $properties->$layerName->propertytypes;
-                $result->$layerName->metadatanames = $properties->$layerName->metadatanames;
+                $result->$layerName->propertynames = $properties->$layerNameInProperties->propertynames;
+                $result->$layerName->propertyvalues = $properties->$layerNameInProperties->propertyvalues;
+                $result->$layerName->propertytypes = $properties->$layerNameInProperties->propertytypes;
+                $result->$layerName->metadatanames = $properties->$layerNameInProperties->metadatanames;
 
                 /*if start and count are given, validate them. If valid return the valid elements.
                   if not return all elements. */
@@ -111,9 +112,9 @@
 
                     /*invalid entries*/
                     if ($start < 0 || $count <=0 ||
-                        $start >= $properties->$layerName->numelements ||
-                        $count > $properties->$layerName->numelements ||
-                        ($start + $count) > $properties->$layerName->numelements)
+                        $start >= $properties->$layerNameInProperties->numelements ||
+                        $count > $properties->$layerNameInProperties->numelements ||
+                        ($start + $count) > $properties->$layerNameInProperties->numelements)
                     {
                         $start = -1;
                         $count = -1;
@@ -124,9 +125,9 @@
                 if ($start < 0 || $count < 0)
                 {
                     $start =0;
-                    $count = $properties->$layerName->numelements;
+                    $count = $properties->$layerNameInProperties->numelements;
                 }
-                //print_r($properties->$layerName);
+                //print_r($properties->$layerNameInProperties);
                 $result->$layerName->numelements = $count;
 
                 $result->$layerName->values = array();
@@ -134,8 +135,8 @@
                 $iIndice = 0;
                 for ($j=$start; $j<($start+$count); $j++)
                 {
-                    $result->$layerName->values[$iIndice] = $properties->$layerName->values[$j];
-                    $result->$layerName->metadata[$iIndice] = $properties->$layerName->metadata[$j];
+                    $result->$layerName->values[$iIndice] = $properties->$layerNameInProperties->values[$j];
+                    $result->$layerName->metadata[$iIndice] = $properties->$layerNameInProperties->metadata[$j];
                     $iIndice++;
                 }
             }

Modified: sandbox/adsk/2.4j/layers/MapGuide/php/Utilities.php
===================================================================
--- sandbox/adsk/2.4j/layers/MapGuide/php/Utilities.php	2012-01-10 05:33:26 UTC (rev 2512)
+++ sandbox/adsk/2.4j/layers/MapGuide/php/Utilities.php	2012-01-10 05:35:11 UTC (rev 2513)
@@ -754,6 +754,11 @@
     return $val;
 }
 
+function GetLayerNameInProperties($layerName)
+{
+	return 'layer'.$layerName;    // Add prefix to avoid layer name beginning with number
+}
+
 /**
    keep all the attributes of selected features in an array
  */
@@ -762,6 +767,8 @@
 {
     $agf = new MgAgfReaderWriter();
     $srsFactory = new MgCoordinateSystemFactory();
+    
+    $layerName = GetLayerNameInProperties($layerName);    // Add prefix to avoid layer name beginning with number
 
     $properties->$layerName->propertynames = array();
     $properties->$layerName->propertyvalues = array();



More information about the fusion-commits mailing list