[fusion-commits] r2786 - in sandbox/redline_advanced_stylization: layers/MapGuide text widgets/Redline widgets/Redline/classes

svn_fusion at osgeo.org svn_fusion at osgeo.org
Wed Sep 18 21:49:28 PDT 2013


Author: jng
Date: 2013-09-18 21:49:27 -0700 (Wed, 18 Sep 2013)
New Revision: 2786

Modified:
   sandbox/redline_advanced_stylization/layers/MapGuide/MapGuideViewerApi.js
   sandbox/redline_advanced_stylization/text/en
   sandbox/redline_advanced_stylization/widgets/Redline/classes/markupeditor.php
   sandbox/redline_advanced_stylization/widgets/Redline/editmarkup.php
Log:
This submission includes the following changes:
 - #597: Allow multiple redline objects to be selected in a list box. Allowing for selection/text update/deletion to be done in a batch instead of one-by-one.
 - Add a new optional bDoNotZoom parameter to SetSelectionXML() in MapGuideViewerApi.js. Omission of this parameter retains existing behaviour (ie. zoom on selection), thus code calling this method as it is will behave the same way. The redline selection now just selects the objects and does not auto-zoom.

Modified: sandbox/redline_advanced_stylization/layers/MapGuide/MapGuideViewerApi.js
===================================================================
--- sandbox/redline_advanced_stylization/layers/MapGuide/MapGuideViewerApi.js	2013-09-19 03:03:06 UTC (rev 2785)
+++ sandbox/redline_advanced_stylization/layers/MapGuide/MapGuideViewerApi.js	2013-09-19 04:49:27 UTC (rev 2786)
@@ -51,11 +51,11 @@
     }
 }
 
-function SetSelectionXML(selectionXml) {
+function SetSelectionXML(selectionXml, bDoNotZoom) {
     //var Fusion = window.top.Fusion;
     var mapWidget = GetFusionMapWidget();
     if (mapWidget && mapWidget.isMapLoaded()) {
-        mapWidget.setSelection(selectionXml, true);
+        mapWidget.setSelection(selectionXml, !(bDoNotZoom || false));
     }
 }
 

Modified: sandbox/redline_advanced_stylization/text/en
===================================================================
--- sandbox/redline_advanced_stylization/text/en	2013-09-19 03:03:06 UTC (rev 2785)
+++ sandbox/redline_advanced_stylization/text/en	2013-09-19 04:49:27 UTC (rev 2786)
@@ -332,6 +332,8 @@
 REDLINEDELETEOBJECT     = Delete
 REDLINEUPDATETEXT       = Update Text
 REDLINEEDITCLOSE        = Close
+REDLINENOTEXT           = no text
+REDLINEMULTISELECTHELP  = To select multiple redline objects in the list above, hold down the SHIFT key while selecting
 
 # Redline Upload
 REDLINEUPLOAD           = Upload Redline

Modified: sandbox/redline_advanced_stylization/widgets/Redline/classes/markupeditor.php
===================================================================
--- sandbox/redline_advanced_stylization/widgets/Redline/classes/markupeditor.php	2013-09-19 03:03:06 UTC (rev 2785)
+++ sandbox/redline_advanced_stylization/widgets/Redline/classes/markupeditor.php	2013-09-19 04:49:27 UTC (rev 2786)
@@ -229,6 +229,20 @@
         $result = $featureService->UpdateFeatures($featureSourceId, $commands, false);
         MarkupEditor::CleanupReaders($result);
     }
+    
+    function BuildFeatureFilter($propName)
+    {
+        $ids = $this->args["MARKUPFEATURE"];
+        if (is_array($ids)) {
+            $filters = array();
+            foreach ($ids as $id) {
+                array_push($filters, "$propName = $id");
+            }
+            return join(" OR ", $filters);
+        } else {
+            return "$propName = $ids";
+        }
+    }
 
     function DeleteMarkup()
     {
@@ -242,7 +256,7 @@
         $idName = $keyProp->GetName();
 
         $commands = new MgFeatureCommandCollection();
-        $commands->Add(new MgDeleteFeatures('Markup', $idName . ' = ' . $this->args['MARKUPFEATURE']));
+        $commands->Add(new MgDeleteFeatures('Markup', $this->BuildFeatureFilter($idName)));
 
         $result = $featureService->UpdateFeatures($featureSourceId, $commands, false);
         MarkupEditor::CleanupReaders($result);
@@ -263,7 +277,7 @@
         $propertyValues->Add(new MgStringProperty('Text', trim($this->args['UPDATETEXT'])));
 
         $commands = new MgFeatureCommandCollection();
-        $commands->Add(new MgUpdateFeatures('Markup', $propertyValues, $idName . ' = ' . $this->args['MARKUPFEATURE']));
+        $commands->Add(new MgUpdateFeatures('Markup', $propertyValues, $this->BuildFeatureFilter($idName)));
 
         $result = $featureService->UpdateFeatures($featureSourceId, $commands, false);
         MarkupEditor::CleanupReaders($result);
@@ -278,8 +292,15 @@
         $markupLayer = $map->GetLayers()->GetItem('_' . $this->GetMarkupName());
 
         $selection = new MgSelection($map);
-        $selection->AddFeatureIdInt32($markupLayer, $markupLayer->GetFeatureClassName(), (int) $this->args['MARKUPFEATURE']);
-
+        $className = $markupLayer->GetFeatureClassName();
+        $ids = $this->args['MARKUPFEATURE'];
+        if (is_array($ids)) {
+            foreach ($ids as $id) {
+                $selection->AddFeatureIdInt32($markupLayer, $className, (int) $id);
+            }
+        } else {
+            $selection->AddFeatureIdInt32($markupLayer, $className, (int) $ids);
+        }
         return $selection->ToXML();
     }
 }

Modified: sandbox/redline_advanced_stylization/widgets/Redline/editmarkup.php
===================================================================
--- sandbox/redline_advanced_stylization/widgets/Redline/editmarkup.php	2013-09-19 03:03:06 UTC (rev 2785)
+++ sandbox/redline_advanced_stylization/widgets/Redline/editmarkup.php	2013-09-19 04:49:27 UTC (rev 2786)
@@ -118,6 +118,8 @@
         $closeLocal = GetLocalizedString('REDLINEEDITCLOSE', $locale );
         $promptLabelLocal = GetLocalizedString('REDLINEPROMPTLABEL', $locale);
         $promptRedlineLabelsLocal = GetLocalizedString('REDLINEPROMPTFORLABELS', $locale);
+        $noTextLocal = GetLocalizedString('REDLINENOTEXT', $locale);
+        $multiHelpLocal = GetLocalizedString('REDLINEMULTISELECTHELP', $locale);
         
         if (array_key_exists("REDLINEPROMPT", $args) && strcmp($args["REDLINEPROMPT"], "on") == 0) {
             $checkState = " checked='checked'";
@@ -330,14 +332,33 @@
             SubmitCommand(CMD_ADD_POLYGON);
         }
 
+        function TrimString(str)
+        {
+            return (typeof String.prototype.trim == 'undefined') ? str.replace(/^\s+|\s+$/g, '') : str.trim();
+        }
+
+        function GetSelectedMarkupIds(mkEl)
+        {
+            var ids = [];
+            for (var i = 0; i < mkEl.options.length; i++) {
+                if (mkEl.options[i].selected) {
+                    ids.push(mkEl.options[i].value);
+                }
+            }
+            return ids;
+        }
+
         function SelectMarkup()
         {
             markupFeatures = document.getElementById("markupFeatures");
-
+            var featIds = GetSelectedMarkupIds(markupFeatures);
             reqParams = "MAPNAME=" + encodeURIComponent(mapName);
             reqParams += "&SESSION=" + encodeURIComponent(session);
             reqParams += "&OPENMARKUP=" + encodeURIComponent('<?= $args['OPENMARKUP']; ?>');
-            reqParams += "&MARKUPFEATURE=" + markupFeatures.value;
+            //reqParams += "&MARKUPFEATURE=" + markupFeatures.value;
+            for (var i = 0; i < featIds.length; i++) {
+                reqParams += "&MARKUPFEATURE[]=" + featIds[i];
+            }
 
             if(msie)
                 reqHandler = new ActiveXObject("Microsoft.XMLHTTP");
@@ -350,7 +371,7 @@
             reqHandler.send(reqParams);
             if(reqHandler.responseXML)
             {
-                SetSelectionXML(reqHandler.responseText);
+                SetSelectionXML(reqHandler.responseText, true /*bDoNotZoom*/);
             }
         }
 
@@ -387,10 +408,16 @@
             if (markupFeatures.selectedIndex >= 0)
             {
                 value = markupFeatures.options[markupFeatures.selectedIndex].text;
-                if (value != '[no text]')
-                    updateTextInput.value = value;
-                else
+                if (value.indexOf('[<?= $noTextLocal ?>]') < 0) {
+                    var tokens = value.split(":");
+                    if (tokens.length == 2) {
+                        updateTextInput.value = TrimString(tokens[1]);
+                    } else {
+                        updateTextInput.value = value;
+                    }
+                } else {
                     updateTextInput.value = '';
+                }
 
                 selectBtn.disabled = false;
                 deleteBtn.disabled = false;
@@ -426,7 +453,6 @@
 </head>
 
 <body onLoad="OnLoad()" onUnload="OnUnload()" marginwidth=5 marginheight=5 leftmargin=5 topmargin=5 bottommargin=5 rightmargin=5>
-
 <form action="editmarkup.php" method="post" enctype="application/x-www-form-urlencoded" id="editForm" target="_self">
 <table class="RegText" border="0" cellspacing="0" width="100%">
     <tr>
@@ -479,12 +505,12 @@
     </tr>
     <tr>
         <td class="RegText">
-            <select name="MARKUPFEATURE" size="15" class="Ctrl" id="markupFeatures" onChange="OnMarkupFeatureChange()" style="width: 100%">
+            <select name="MARKUPFEATURE[]" size="15" class="Ctrl" id="markupFeatures" onChange="OnMarkupFeatureChange()" multiple="multiple" style="width: 100%">
                 <?php
                     $selected = 'selected';
                     foreach($markupFeatures as $markupId => $markupText) {
                 ?>
-                <option value="<?= $markupId ?>" <?=$selected ?> ><?= (strlen($markupText) > 0) ? htmlentities($markupText, ENT_COMPAT, 'UTF-8') : '[no text]' ?></option>
+                <option value="<?= $markupId ?>" <?=$selected ?> ><?= (strlen($markupText) > 0) ? "$markupId: ".htmlentities($markupText, ENT_COMPAT, 'UTF-8') : "$markupId: [$noTextLocal]" ?></option>
                 <?php
                         $selected = '';
                     }
@@ -494,6 +520,10 @@
     </tr>
     <tr><td colspan="2" height="2px"></td></tr>
     <tr>
+        <td class="InfoText" colspan="2"><?= $multiHelpLocal ?></td>
+    </tr>
+    <tr><td colspan="2" height="2px"></td></tr>
+    <tr>
         <td colspan="2">
             <input class="Ctrl" id="selectBtn" type="button" onClick="SelectMarkup()" value="<?=$selectLocal?>" style="width:85px">
             <input class="Ctrl" id="deleteBtn" type="button" onClick="DeleteMarkup()" value="<?=$deleteLocal?>" style="width:85px">



More information about the fusion-commits mailing list