[fusion-commits] r1240 - in sandbox/aboudreault: MapServer MapServer/php widgets

svn_fusion at osgeo.org svn_fusion at osgeo.org
Thu Mar 13 10:39:32 EDT 2008


Author: aboudreault
Date: 2008-03-13 10:39:32 -0400 (Thu, 13 Mar 2008)
New Revision: 1240

Modified:
   sandbox/aboudreault/MapServer/MapServer.js
   sandbox/aboudreault/MapServer/php/Search.php
   sandbox/aboudreault/widgets/MSSearch.js
Log:
A MapServer Search Widget (Commited to aboudreault's sandbox)


Modified: sandbox/aboudreault/MapServer/MapServer.js
===================================================================
--- sandbox/aboudreault/MapServer/MapServer.js	2008-03-13 14:38:34 UTC (rev 1239)
+++ sandbox/aboudreault/MapServer/MapServer.js	2008-03-13 14:39:32 UTC (rev 1240)
@@ -51,7 +51,7 @@
 
     //the map file
     sMapFile: null,
-    
+       
     //imagetype
     _sImageType : 'png',
     
@@ -145,6 +145,10 @@
         return this._sMapname;
     },
     
+    getMapTitle: function() {
+        return this._sMapTitle;
+    },
+    
     loadMap: function(mapfile, options) {
         while (this.mapWidget.isBusy()) {
 	        this.mapWidget._removeWorker(); 
@@ -333,7 +337,7 @@
             this.mapWidget.triggerEvent(Fusion.Event.MAP_RELOADED);
         } else {
             Fusion.reportError( new Fusion.Error(Fusion.Error.FATAL, 
-						'Failed to load requested map:\n'+r.responseText));
+                OpenLayers.String.translate('mapLoadError', r.responseText)));
         }
         this.mapWidget._removeWorker();
     },
@@ -371,7 +375,7 @@
   				this.drawMap();
   				this.triggerEvent(Fusion.Event.MAP_LAYER_ORDER_CHANGED);
   			} else {
-  				alert("setLayers failure:"+o.layerindex);
+          alert(OpenLayers.String.translate('setLayersError', o.layerindex));
   			}
       }
     },
@@ -421,7 +425,7 @@
     },
     
     drawMap: function() {
-        if (!this.bMapLoaded) {
+        if (!this.bMapLoaded || this.deferredDraw) {
             return;
         }
 
@@ -454,7 +458,12 @@
         this.oLayerOL.setVisibility(true);
       } else {
         this.aVisibleGroups.push(sGroup);
-        //TODO: manipulate aVisibleLayers based on layers in the group
+        var group = this.layerRoot.findGroup(sGroup);
+        this.deferredDraw = true;
+        for (var i=0; i<group.layers.length; ++i) {
+          group.layers[i].show();
+        }
+        this.deferredDraw = false;
         this.drawMap();
       }
     },
@@ -469,7 +478,12 @@
                 break;
             }
         }
-        //TODO: manipulate aVisibleLayers based on layers in the group
+        var group = this.layerRoot.findGroup(sGroup);
+        this.deferredDraw = true;
+        for (var i=0; i<group.layers.length; ++i) {
+          group.layers[i].hide();
+        }
+        this.deferredDraw = false;
         this.drawMap();
       }
     },
@@ -667,13 +681,13 @@
         var matchlimit = options.matchlimit || -1;
         var layer = options.layer || '';
         var attribute = options.attribute || '';
-        var value = options.value || '';
+        var pattern = options.pattern || '';
         var sl = Fusion.getScriptLanguage();
         var loadmapScript = this.arch + '/' + sl  + '/Search.' + sl;
 
         var sessionid = this.getSessionID();
 
-        var params = 'mapname='+this._sMapname+"&session="+sessionid+'&matchlimit='+matchlimit+'&layer='+layer+'&attribute='+attribute+'&value='+value;
+        var params = 'mapname='+this._sMapname+"&session="+sessionid+'&matchlimit='+matchlimit+'&layer='+layer+'&attribute='+attribute+'&pattern='+pattern;
         var options = {onSuccess: this.processQueryResults.bind(this), 
                                      parameters: params};
         Fusion.ajaxRequest(loadmapScript, options);

Modified: sandbox/aboudreault/MapServer/php/Search.php
===================================================================
--- sandbox/aboudreault/MapServer/php/Search.php	2008-03-13 14:38:34 UTC (rev 1239)
+++ sandbox/aboudreault/MapServer/php/Search.php	2008-03-13 14:39:32 UTC (rev 1240)
@@ -2,7 +2,7 @@
 /**
  * Search
  *
- * $Id: Query.php 1108 2007-12-11 00:27:33Z aboudreault at mapgears.com $
+ * $Id: Search.php 1108 2007-12-11 00:27:33Z aboudreault at mapgears.com $
  *
  * Copyright (c) 2007, DM Solutions Group Inc.
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -34,14 +34,14 @@
 include('../../common/php/Utilities.php');
 
 /* the name of the layer in the map to query */
-if ( ($_REQUEST['layer'] != '') && ($_REQUEST['attribute'] != '') && ($_REQUEST['value'] != ''))  {
+if ( ($_REQUEST['layer'] != '') && ($_REQUEST['attribute'] != '') && ($_REQUEST['pattern'] != ''))  {
     $szLayer = $_REQUEST['layer'];
     $szAttribute = $_REQUEST['attribute'];
-    $szValue = $_REQUEST['value'];
+    $szPattern = $_REQUEST['pattern'];
 } 
 else 
 {
-    die('layer, attribute or value not set'); //TODO this must be enabled
+    die('layer, attribute or value not set');
 }
 
 if (!isset($mapName)) {
@@ -59,7 +59,7 @@
 
 $oLayer = $oMap->GetLayerByName($szLayer);
 
-if (@$oLayer->queryByAttributes($szAttribute,"/".$szValue."/", MS_MULTIPLE) == MS_SUCCESS) //TODO the layer name must be configurable (OWNER, MATTSON..)
+if (@$oLayer->queryByAttributes($szAttribute,$szPattern, MS_MULTIPLE) == MS_SUCCESS)
 {
     if ( ($iMatchLimit != -1) && ($oLayer->getNumResults() > $iMatchLimit) )
         $numResults = $iMatchLimit;

Modified: sandbox/aboudreault/widgets/MSSearch.js
===================================================================
--- sandbox/aboudreault/widgets/MSSearch.js	2008-03-13 14:38:34 UTC (rev 1239)
+++ sandbox/aboudreault/widgets/MSSearch.js	2008-03-13 14:39:32 UTC (rev 1240)
@@ -37,14 +37,15 @@
     oTextBox : '',
     sMatchLimit: '',
     sAttribute: '',
-    bCaseSensitive: false, //TODO insensitive case search
+    bCaseSensitive: false,
     iBoxSize: 15,
 
     initialize : function(widgetTag){
         Object.inheritFrom(this,Fusion.Widget.prototype, [widgetTag, true]);
-        Object.inheritFrom(this, Fusion.Tool.ButtonBase.prototype, []);
+       
         
         this.enable = Fusion.Widget.MSSearch.prototype.enable;
+
         var json = widgetTag.extension;
 
         this.sLayerName = json.LayerName ? json.LayerName : '';
@@ -60,9 +61,10 @@
         this.oTextBox = document.createElement('input');
         this.oTextBox.type = 'text';
         this.oTextBox.size = this.iBoxSize; 
+        this.oTextBox.className = "searchBox";
      
         this.domObj.appendChild(this.oTextBox);
-           
+        Object.inheritFrom(this, Fusion.Tool.ButtonBase.prototype, []);
     },
 
   enable : function() {
@@ -74,7 +76,9 @@
       var options = {};
       options.queryType = 'search';
       options.attribute = this.sAttribute;
-      options.value = this.oTextBox.value;
+      options.pattern = "/"+this.oTextBox.value.trim()+"/";
+      if (!this.bCaseSensitive)
+          options.pattern += "i";
       options.matchlimit = this.sMatchLimit;
       options.layer = this.sLayerName;
       



More information about the fusion-commits mailing list