[mapguide-commits] r4658 - in sandbox/rfc71: localized mapviewerphp viewerfiles

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Mar 11 08:33:23 EST 2010


Author: jng
Date: 2010-03-11 08:33:23 -0500 (Thu, 11 Mar 2010)
New Revision: 4658

Added:
   sandbox/rfc71/mapviewerphp/getselectedfeatures.php
Modified:
   sandbox/rfc71/localized/en
   sandbox/rfc71/mapviewerphp/mapframe.php
   sandbox/rfc71/viewerfiles/ajaxmappane.templ
   sandbox/rfc71/viewerfiles/propertyctrl.templ
Log:
We're now finally back to where we started, a functional PHP implementation. This is r4125, r4137, r4138 and r4139 reapplied with a little code cleanup as well

Modified: sandbox/rfc71/localized/en
===================================================================
--- sandbox/rfc71/localized/en	2010-03-11 10:30:42 UTC (rev 4657)
+++ sandbox/rfc71/localized/en	2010-03-11 13:33:23 UTC (rev 4658)
@@ -247,3 +247,7 @@
 
 # Localized Icon Files
 POWEREDBYICON           = PoweredBy_en.gif
+
+# Property Pane Toolbar
+ZOOMSELECTEDFEATUREDESC = Zoom to this feature
+NOFEATSELECTRESPONSE    = No response from feature selection request

Added: sandbox/rfc71/mapviewerphp/getselectedfeatures.php
===================================================================
--- sandbox/rfc71/mapviewerphp/getselectedfeatures.php	                        (rev 0)
+++ sandbox/rfc71/mapviewerphp/getselectedfeatures.php	2010-03-11 13:33:23 UTC (rev 4658)
@@ -0,0 +1,456 @@
+<?php
+
+/*
+
+TODO:
+
+- Use the property mapping. This will have to be old-fashioned parsing the <PropertyMapping> elements 
+of the layer definition. I really wanted to use MgSelection::GetSelectedFeatures(layer, class, true) but realised
+that unless the geometry is mapped, you're not going to see it in the Feature Reader (ie. No zoom point). Right now 
+it is returning all properties.
+
+- I know of a few features in the Sheboygan Dataset that trip up the JSON response. Need to find out of addslashes() fixes this.
+
+- General cleanup of the code
+
+
+*/
+
+//require_once('FirePHPCore/fb.php');
+
+//
+// Used to model the JSON response.
+//
+class SelectionSet
+{
+    private $layers;
+    
+    public function __construct()
+    {
+        $this->layers = array();
+    }
+    
+    public function AddFeature($feat)
+    {
+        $layerName = $feat->layerName;
+        if(!array_key_exists($layerName, $this->layers))
+            $this->layers[$layerName] = array();
+            
+        array_push($this->layers[$layerName], $feat);
+    }
+    
+    public function GetLayers()
+    {
+        return array_keys($this->layers);
+    }
+    
+    public function GetFeatures($layerName)
+    {
+        if(array_key_exists($layerName, $this->layers))
+            return $this->layers[$layerName];
+        
+        return null;
+    }
+}
+
+class ZoomPoint
+{
+    public $x;
+    public $y;
+}
+
+//
+// Represents a selected feature property
+//
+class FeatureProperty
+{
+    public $name;
+    public $value;
+}
+
+//
+// Represents a selected feature
+//
+class Feature
+{
+    public $layerName;
+    public $zoom;
+    
+    private $properties;
+    
+    public function __construct($layerName)
+    {
+        $this->layerName = $layerName;
+        $this->properties = array();
+    }
+    
+    public function AddProperty($prop)
+    {
+        $this->properties[$prop->name] = $prop;
+    }
+    
+    public function GetProperties()
+    {
+        return $this->properties;
+    }
+}
+
+	include 'common.php';
+    include 'constants.php';
+
+    $mapName = "";
+    $sessionId = "";
+    //$selText = "";
+    $queryInfo = false;
+
+    GetRequestParameters();
+	
+	try
+	{
+		InitializeWebTier();
+		
+		$cred = new MgUserInformation($sessionId);
+        $cred->SetClientIp(GetClientIp());
+        $cred->SetClientAgent(GetClientAgent());
+
+        //connect to the site and get an instance of the resource and feature service
+        //
+        $site = new MgSiteConnection();
+        $site->Open($cred);
+        $resourceSrvc = $site->CreateService(MgServiceType::ResourceService);
+		$featureSrvc = $site->CreateService(MgServiceType::FeatureService);
+
+        //load the map runtime state
+        //
+        $map = new MgMap();
+        $map->Open($resourceSrvc, $mapName);
+		
+		// Create the selection set
+        $selection = new MgSelection($map);
+        $selection->Open($resourceSrvc, $mapName);
+        //if($selText != "") {
+        //    $selection->FromXml($selText);
+        //}
+		
+		$layers = $selection->GetLayers();
+        if($layers != null)
+        {
+            $nLayers = $layers->GetCount();
+            $agfRW = new MgAgfReaderWriter();
+            
+            $selectionSet = new SelectionSet();
+            
+            for ($i = 0; $i < $nLayers; $i++) {
+                $lyr = $layers->GetItem($i);
+                $layerName = $lyr->GetName();
+                
+                //FB::log("Layer Name: " . $lyr->GetName());
+                
+                $featResId = new MgResourceIdentifier($lyr->GetFeatureSourceId());
+                $class = $lyr->GetFeatureClassName();
+                
+                $queryOptions = new MgFeatureQueryOptions();
+                
+                $mappings = GetLayerPropertyMappings($resourceSrvc, $lyr);
+                //FB::log("Property Mappings for Layer: $layerName");
+                foreach($mappings as $name => $value) {
+                    $queryOptions->AddFeatureProperty($name);
+                    //FB::log("$name => $value");
+                }
+                $geomName = $lyr->GetFeatureGeometryName();
+                $queryOptions->AddFeatureProperty($geomName);
+                
+                $filter = $selection->GenerateFilter($lyr, $class);
+                $queryOptions->SetFilter($filter);
+                $fr = $featureSrvc->SelectFeatures($featResId, $class, $queryOptions);
+                
+                $clsDef = $fr->GetClassDefinition();
+                $props = $clsDef->GetProperties();
+                
+                //FB::log("Geometry: $geomName");
+                
+                while($fr->ReadNext())
+                {
+                    $feat = new Feature($layerName);
+                    $zoom = null;
+                    
+                    for ($k = 0; $k < $props->GetCount(); $k++)
+                    {
+                        $prop = $props->GetItem($k);
+                        $propName = $prop->GetName();
+                        $propType = $fr->GetPropertyType($propName);
+                        
+                        //We only care about mapped properties or geometry properties
+                        if (array_key_exists($propName, $mappings) || $propType == MgPropertyType::Geometry)
+                        {
+                            $value = "";
+                            if (!$fr->IsNull($propName))
+                            {
+                                if(strcmp($propName,$geomName) == 0)
+                                {
+                                    //We want the centroid so we have a zoom-to point
+                                    $agf = $fr->GetGeometry($propName);
+                                    $geom = $agfRW->Read($agf);
+                                    $pt = $geom->GetCentroid()->GetCoordinate();
+                                    
+                                    $zoom = new ZoomPoint();
+                                    $zoom->x = $pt->GetX();
+                                    $zoom->y = $pt->GetY();
+                                    
+                                    $feat->zoom = $zoom;
+                                    //FB::log("zoom: (".$zoom->x.",".$zoom->y.")");
+                                }
+                                else
+                                {
+                                    $value = GetPropertyValueFromFeatureReader($fr, $agfRW, $propType, $propName);
+                                }
+                            }
+                        
+                            if (array_key_exists($propName, $mappings))
+                            {
+                                $fp = new FeatureProperty();
+                                $fp->name = $mappings[$propName];
+                                $fp->value = $value;
+                                
+                                $feat->AddProperty($fp);
+                            }
+                        }
+                    }
+                    
+                    $c = count($feat->GetProperties());
+                    //FB::log("Selected feature processed ($c)");
+                    
+                    $selectionSet->AddFeature($feat);
+                }
+                $fr->Close();
+            }
+            
+            //Now output the selection set
+            
+            header("Content-Type: application/json");
+            header("X-JSON: true");
+            echo GetJson($selectionSet);
+        }
+    }
+	catch(MgException $e)
+    {
+        echo $e->GetDetails();
+    }
+
+function GetJson($selectionSet)
+{
+    if($selectionSet == null)
+        return "";
+        
+    //FB::log("Processing JSON response");
+    /*
+    A sample of the JSON output this method will produce:
+    
+    
+    {
+        "Layer1" : [ 
+            { 
+                'values' { "prop1" : "value1" , "prop2" : "value2" }, 
+                'zoom' : { x: num1, y: num2 } 
+            } , 
+            ..,
+            ..,
+            ..,
+        ],
+        "Layer2" : [ 
+            { 
+                'values' { "prop1" : "value1" , "prop2" : "value2" }, 
+                'zoom' : { x: num1, y: num2 } 
+            } , 
+            ..,
+            ..,
+            ..,
+        ]
+    }
+    */
+    
+    $layers = $selectionSet->GetLayers();
+    $totalLayers = array(); //The data portion of the JSON response
+    
+    //FB::log("Layers in selection set: ".count($layers));
+    
+    for ($i = 0; $i < count($layers); $i++)
+    {   
+        $layerName = $layers[$i];
+        $features = $selectionSet->GetFeatures($layerName);
+        
+        //FB::log("Features: ".$features);
+        
+        if($features != null)
+        {
+            //FB::log("Processing layer: $layerName");
+        
+            $totalFeaturesOnLayer = array();
+            
+            if (count($features) > 0)
+            {
+                for ($j = 0; $j < count($features); $j++)
+                {
+                    $feat = $features[$j];
+                    $featureProperties = array();
+                    
+                    $fps = $feat->GetProperties();
+                    foreach($fps as $fp)
+                    {
+                        $name = $fp->name;
+                        $value = $fp->value;
+                        //Add JSONified feature property
+                        array_push($featureProperties, "{\"name\" : \"$name\", \"value\" : \"$value\" }");
+                    }
+                    //Add JSONified feature
+                    if($feat->zoom != null)
+                        array_push($totalFeaturesOnLayer, "{\"values\" : [".join(",", $featureProperties)."], \"zoom\" : { \"x\": ".$feat->zoom->x.", \"y\": ".$feat->zoom->y." } }");
+                    else
+                        array_push($totalFeaturesOnLayer, "{\"values\" : [".join(",", $featureProperties)."], \"zoom\" : null }");
+                        
+                    //FB::log("Feature processed on layer: $layerName");
+                }
+            }
+            
+            array_push($totalLayers, "\"$layerName\" : [" . join(", ", $totalFeaturesOnLayer) . "]");
+            //FB::log("Selected features on layer added to final JSON response");
+        }
+    }
+    
+    //FB::log("Selection layer count: ".count($totalLayers));
+    
+    $result = "{" . join(",",$totalLayers) . "}";
+    //return json_encode($result);
+    return $result;
+}
+
+function GetPropertyValueFromFeatureReader($fr, $agfRW, $propType, $propName)
+{
+    $val = "";
+    $tStr = "";
+    switch($propType)
+    {
+        case MgPropertyType::Null:
+            $tStr = "Null";
+            $val = "";
+            break;
+        case MgPropertyType::Boolean:
+            $tStr = "Boolean";
+            $val = $fr->GetBoolean($propName);
+            break;
+        case MgPropertyType::Byte:
+            $tStr = "Byte";
+            $val = $fr->GetByte($propName);
+            break;
+        case MgPropertyType::DateTime:
+            $tStr = "DateTime";
+            $val = printDateTime($fr->GetDateTime($propName));
+            break;
+        case MgPropertyType::Single:
+            $tStr = "Single";
+            $val = $fr->GetSingle($propName);
+            break;
+        case MgPropertyType::Double:
+            $tStr = "Double";
+            $val = $fr->GetDouble($propName);
+            break;
+        case MgPropertyType::Int16:
+            $tStr = "Int16";
+            $val = $fr->GetInt16($propName);
+            break;
+        case MgPropertyType::Int32:
+            $tStr = "Int32";
+            $val = $fr->GetInt32($propName);
+            break;
+        case MgPropertyType::Int64:
+            $tStr = "Int64";
+            $val = $fr->GetInt64($propName);
+            break;
+        case MgPropertyType::String:
+            $tStr = "String";
+            $val = addslashes($fr->GetString($propName));
+            break;
+        case MgPropertyType::Blob: //NOT PRESENTABLE IN PROPERTY GRID
+            $tStr = "BLOB";
+            break;
+        case MgPropertyType::Clob: //NOT PRESENTABLE IN PROPERTY GRID
+            $tStr = "CLOB";
+            break;
+        case MgPropertyType::Feature: //NOT PRESENTABLE IN PROPERTY GRID
+            $tStr = "Feature";
+            break;
+        case MgPropertyType::Geometry: //NOT PRESENTABLE IN PROPERTY GRID
+            $tStr = "Geometry";
+            break;
+        case MgPropertyType::Raster: //NOT PRESENTABLE IN PROPERTY GRID
+            $tStr = "Raster";
+            break;
+    }
+    //FB::log("$propName ($tStr) = $val");
+    return $val;
+}
+
+/* retrieve the property mappings for a layer */
+function GetLayerPropertyMappings($resourceService, $layer) {
+    $mappings = array();
+    $byteReader = $resourceService->GetResourceContent($layer->GetLayerDefinition());
+    $xmldoc = DOMDocument::loadXML(ByteReaderToString($byteReader));
+    $mappingNodeList = $xmldoc->getElementsByTagName('PropertyMapping');
+    for ($i=0; $i<$mappingNodeList->length; $i++) {
+        $mapping = $mappingNodeList->item($i);
+        $nameElt = $mapping->getElementsByTagName('Name');
+        $name = $nameElt->item(0)->nodeValue;
+        $valueElt = $mapping->getElementsByTagName('Value');
+        $value = $valueElt->item(0)->nodeValue;
+        $mappings[$name] = $value;
+    }
+    return $mappings;
+}
+
+function ByteReaderToString($byteReader)
+{
+    return $byteReader->ToString();
+}
+
+function printDateTime($mgDateTime)
+{
+   $dayToday = $mgDateTime->GetDay();
+   $month = $mgDateTime->GetMonth();
+   $year = $mgDateTime->GetYear();
+   return $dayToday.".".$month.".".$year;
+}
+
+function GetParameters($params)
+{
+    global $mapName, $sessionId, $selText, $queryInfo;
+
+    $mapName = $params['MAPNAME'];
+    $sessionId = $params['SESSION'];
+	//$selText = UnescapeMagicQuotes($params['selection']);
+}
+
+
+function UnescapeMagicQuotes($str)
+{
+    if(ini_get("magic_quotes_sybase") == "1")
+        return str_replace("''", "'", $str);
+    else if(get_magic_quotes_gpc() == "1")
+    {
+        //Unescape double quotes
+        $str = str_replace('\\"', '"', $str);
+
+        //remove additional backslash
+        return str_replace("\\", "", $str);
+    }
+    return $str;
+}
+
+function GetRequestParameters()
+{
+    if($_SERVER['REQUEST_METHOD'] == "POST")
+        GetParameters($_POST);
+    else
+        GetParameters($_GET);
+}
+
+?>
\ No newline at end of file

Modified: sandbox/rfc71/mapviewerphp/mapframe.php
===================================================================
--- sandbox/rfc71/mapviewerphp/mapframe.php	2010-03-11 10:30:42 UTC (rev 4657)
+++ sandbox/rfc71/mapviewerphp/mapframe.php	2010-03-11 13:33:23 UTC (rev 4658)
@@ -145,6 +145,7 @@
                     $vpath . "setselection.php",
                     $showSlider? "true": "false",
                     $locale,
+                    $vpath . "getselectedfeatures.php",
                     $scaleCreationCode,
                     $vpath . "ajaxviewerabout.php",
                     $vpath . "legendctrl.php",

Modified: sandbox/rfc71/viewerfiles/ajaxmappane.templ
===================================================================
--- sandbox/rfc71/viewerfiles/ajaxmappane.templ	2010-03-11 10:30:42 UTC (rev 4657)
+++ sandbox/rfc71/viewerfiles/ajaxmappane.templ	2010-03-11 13:33:23 UTC (rev 4658)
@@ -334,6 +334,7 @@
 var openHlinkText = macOS ? "__#OPENHYPERLINKMAC#__" : "__#OPENHYPERLINK#__";
 var selectionColor = '0x0000FFFF'; // Blue
 var lastLegendScaleUpdate = curScale;
+var featureRequestUrl = '%s';
 %s
 
 
@@ -551,6 +552,9 @@
     cancelTgt = document.getElementById("KeyTarget");
 
     initTimer = setInterval(delayedInit, 200);
+    
+    var btn = document.getElementById("imgZoomFeature");
+    btn.title = "__#ZOOMSELECTEDFEATUREDESC#__";
 }
 
 function delayedInit()
@@ -2877,26 +2881,17 @@
     }
     if(which & 2)
     {
-        properties = new Array();
-        if(selection.count == 1)
+        if (IsPropertyCtrlVisible())
         {
-            try
+            if (selection.count > 0)
             {
-                var props = xmlIn.getElementsByTagName("Property");
-                if(props != null)
-                {
-                    for(var i=0; i < props.length; i++)
-                    {
-                        var name = props[i].getAttribute("name");
-                        var value = props[i].getAttribute("value");
-                        properties.push(new Property(name, value));
-                    }
-                }
+                RequestSelectedFeatureProperties();
             }
-            catch(e) {}
+            else
+            {
+                ResetPropertyPane();
+            }
         }
-        properties.sort(CompareProperties);
-        GetPropertyCtrl().SetProperties(selection.count, properties);
     }
     if(which & 4)
     {
@@ -3824,6 +3819,189 @@
     }
 }
 
+//--- Property Pane Toolbar ---//
+var selFeatureZoom = 200;
+var hovered = "";
+var active = "";
+var selFeatures = {};
+
+function RequestSelectedFeatureProperties()
+{
+    var mapname = GetMapName();
+    var session = GetSessionId();
+    var selRequest = CreateRequestHandler();
+    var reqParams = "MAPNAME="+mapname+"&SESSION="+session+"&SEQ="+Math.random();
+    selRequest.open("POST", featureRequestUrl, false);
+    selRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+    selRequest.send(reqParams);
+    
+    var respText = selRequest.responseText;
+    if (respText && respText.length > 0)
+    {
+        var resp = eval('(' + respText + ')');
+        ProcessSelectedFeatureSet(resp);
+    }
+    else
+        RequestFailed("__#NOFEATSELECTRESPONSE#__");
+}
+
+function ProcessSelectedFeatureSet(resp)
+{
+    selFeatures = {};
+    if (!resp)
+        return;
+        
+    var selLayers = document.getElementById("selLayers");
+    selLayers.length = 0;
+    GetPropertyCtrl().Clear();
+    
+    //Construct layer list
+    for(var layerName in resp)
+    {
+        var opt = new Option();
+        opt.text = layerName;
+        opt.value = layerName;
+        
+        if(msie)
+            selLayers.add(opt);
+        else
+            selLayers.add(opt, null);
+            
+        //Associates the selected features on layer
+        selFeatures[layerName] = resp[layerName];
+    }
+    
+    if (selLayers.length > 0)
+    {
+        SetPropertyPaneToolbarVisibility(true);
+        //Set to first result on the layer list
+        selLayers.selectedIndex = 0;
+        OnSelectedFeatureLayerChanged();
+    }
+}
+
+function IsPropertyCtrlVisible()
+{
+    return GetPropertyCtrl().width > 0;
+}
+
+function ResetPropertyPane()
+{
+    var selLayers = document.getElementById("selLayers");
+    selLayers.length = 0;
+    var selFeature = document.getElementById("selFeature");
+    selFeature.length = 0;
+    SetPropertyPaneToolbarVisibility(false);
+    GetPropertyCtrl().SetProperties(0);
+}
+
+function OnSelectedFeatureLayerChanged()
+{
+    var sLayer = document.getElementById("selLayers");
+    var layerIdx = sLayer.selectedIndex;
+    var layerName = sLayer.options[layerIdx].value;
+    var count = selFeatures[layerName].length;
+    
+    //Clear feature dropdown and repopulate by numerical index (offset by 1)
+    var sFeature = document.getElementById("selFeature");
+    sFeature.length = 0;
+    
+    for (var i = 1; i <= count; i++)
+    {
+        //This is just for display purposes. The selected index
+        //gives use the matching feature
+        var opt = new Option();
+        opt.text = i;
+        opt.value = 1;
+        
+        if (msie)
+            sFeature.add(opt);
+        else
+            sFeature.add(opt, null);
+    }
+    
+    if (count > 0)
+    {
+        sFeature.selectedIndex = 0;
+        OnSelectedFeatureChanged();
+    }
+}
+
+function OnSelectedFeatureChanged()
+{
+    var sLayer = document.getElementById("selLayers");
+    var layerIdx = sLayer.selectedIndex;
+    var sFeature = document.getElementById("selFeature");
+    var featureIdx = sFeature.selectedIndex;
+    
+    //Get matching selected feature from array
+    var layerName = sLayer.options[layerIdx].value;
+    var feat = selFeatures[layerName][featureIdx];
+    
+    //Show feature
+    GetPropertyCtrl().SetProperties(1, feat.values);
+}
+
+function GetFeatureZoomLevel()
+{
+    return selFeatureZoom;
+}
+
+function ZoomSelectedFeature()
+{
+    var sLayer = document.getElementById("selLayers");
+    var layerIdx = sLayer.selectedIndex;
+    var sFeature = document.getElementById("selFeature");
+    var featureIdx = sFeature.selectedIndex;
+    
+    //Get matching selected feature from array
+    var layerName = sLayer.options[layerIdx].value;
+    var feat = selFeatures[layerName][featureIdx];
+    
+    //Get the zoom component of the selected feature, and zoom to that view
+    if (feat.zoom)
+        ZoomToView(feat.zoom.x, feat.zoom.y, GetFeatureZoomLevel(), true);
+}
+
+function HoverButton(eltId, description)
+{
+    if (hovered != "")
+        document.getElementById(hovered).style.border = "solid #f0f0f0 1px";
+    
+    document.getElementById(eltId).style.border = "solid #99B5CA 1px";
+    hovered = eltId;
+    parent.SetStatusMsg(description);
+}
+
+function LeaveButton(eltId)
+{
+    if (eltId == active)
+        document.getElementById(eltId).style.border = "solid #99B5CA 1px";
+    else
+        document.getElementById(eltId).style.border = "solid #f0f0f0 1px";
+    hovered = "";
+    parent.SetStatusMsg('');
+}
+
+function SetPropertyPaneToolbarVisibility(visible)
+{
+    var tb = document.getElementById("PropertyPaneToolbar");
+    tb.style.display = visible ? "block" : "none";
+}
+
+function OnResizeToolbar(e)
+{
+    var tb = document.getElementById("PropertyPaneToolbar");
+    if (tb)
+    {
+        width = msie ? document.body.clientWidth : window.innerWidth - 2;
+        height = 32;
+        tb.style.width = width + "px";
+        tb.style.height = height + "px";
+    }
+    return true;
+}
+
 </script>
 
 </head>
@@ -3854,6 +4032,23 @@
            </table>
          </div>
          <div class="propertyCtrl" id="PropertyCtrlDiv"  style="visibility: hidden;">
+           <div id="PropertyPaneToolbar" class="Toolbar" style="display:none">
+             <table width=100 height=30 border=0 cellpadding=0 cellspacing=0>
+               <tr height=30>
+                 <td align=center valign=center>
+                   <select id="selLayers" onchange="OnSelectedFeatureLayerChanged()"></select>
+                 </td>
+                 <td align=center valign=center>
+                   <select id="selFeature" onchange="OnSelectedFeatureChanged()"></select>
+                 </td>
+                 <td align=right>
+                   <span class="btn" id="btnZoomSelectedFeature" style="position: absolute; right: 2px;" onmouseover="HoverButton('btnZoomSelectedFeature', '')" onmouseout="LeaveButton('btnZoomSelectedFeature', '')" onclick="ZoomSelectedFeature()">
+                     <img class="btnImg" id="imgZoomFeature" title="" src="../stdicons/icon_zoomselect.gif" width=16 height=16>
+                   </span>
+                 </td>
+               </tr>
+             </table>
+           </div>
            <iframe id="PropertyCtrl" name="PropertyCtrl" src="%s?LOCALE=%s" frameborder="0" width="0">
            </iframe>
          </div>

Modified: sandbox/rfc71/viewerfiles/propertyctrl.templ
===================================================================
--- sandbox/rfc71/viewerfiles/propertyctrl.templ	2010-03-11 10:30:42 UTC (rev 4657)
+++ sandbox/rfc71/viewerfiles/propertyctrl.templ	2010-03-11 13:33:23 UTC (rev 4658)
@@ -60,9 +60,15 @@
     {
         var text;
         if(count == 0)
+        {
             text = "__#PROPERTIESNONE#__";
+            GetMapFrame().SetPropertyPaneToolbarVisibility(false);
+        }
         else
+        {
             text = GetMainFrame().FormatMessage("__#PROPERTIESITEMSEL#__", new Array(count, "unused"));
+            GetMapFrame().SetPropertyPaneToolbarVisibility(true);
+        }
         code = '<table id="Grid" cellspacing=0 cellpadding=0 border=0><tr><td class="Info" align="center">' + text + '</td></tr></table>';
     }
     else
@@ -71,15 +77,26 @@
         for(var i=0; i < properties.length; i++)
             code += '<tr class="GridCell"><td><span style="font-family: __#@font#__; font-size: __#@fontsize#__;">&nbsp;' + properties[i].name + '</span></td><td></td><td><span style="font-family: __#@font#__; font-size: __#@fontsize#__;">' + properties[i].value + '</span></td></tr>';
         code += '</table>';
+        GetMapFrame().SetPropertyPaneToolbarVisibility(true);
     }
 
+    SetContent(code);
+}
+
+function Clear()
+{
+    SetContent("");
+}
+
+// private functions -----------------------------------------------
+//
+function SetContent(html)
+{
     var content = document.getElementById("Content");
-    content.innerHTML = code; //SAFARI
+    content.innerHTML = html; //SAFARI
     OnResizeGrid();
 }
 
-// private functions -----------------------------------------------
-//
 function InitDocument()
 {
     document.onmousedown = OnMouseDown;



More information about the mapguide-commits mailing list