[fusion-commits] r1351 - in sandbox/olcore: MapGuide MapServer lib text/en widgets widgets/SelectWithin

svn_fusion at osgeo.org svn_fusion at osgeo.org
Fri Mar 28 15:16:09 EDT 2008


Author: madair
Date: 2008-03-28 15:16:09 -0400 (Fri, 28 Mar 2008)
New Revision: 1351

Removed:
   sandbox/olcore/lib/utils.js
   sandbox/olcore/widgets/CTRLClick.js
Modified:
   sandbox/olcore/MapGuide/MapGuide.js
   sandbox/olcore/MapServer/MapServer.js
   sandbox/olcore/lib/ApplicationDefinition.js
   sandbox/olcore/lib/Error.js
   sandbox/olcore/lib/MGBroker.js
   sandbox/olcore/lib/Map.js
   sandbox/olcore/lib/MenuBase.js
   sandbox/olcore/lib/fusion.js
   sandbox/olcore/text/en/strings.json
   sandbox/olcore/widgets/MapMenu.js
   sandbox/olcore/widgets/Measure.js
   sandbox/olcore/widgets/SelectWithin/SelectWithinPanel.templ
Log:
re #5: all Ajax requests switched to use OpenLayers.AjaxRequest

Modified: sandbox/olcore/MapGuide/MapGuide.js
===================================================================
--- sandbox/olcore/MapGuide/MapGuide.js	2008-03-28 18:54:15 UTC (rev 1350)
+++ sandbox/olcore/MapGuide/MapGuide.js	2008-03-28 19:16:09 UTC (rev 1351)
@@ -117,7 +117,7 @@
             this.session[0] = this;
             var sl = Fusion.getScriptLanguage();
             var scriptURL = this.arch + '/' + sl + '/CreateSession.' + sl;
-            var options = {onComplete: this.createSessionCB.bind(this)};
+            var options = {onSuccess: this.createSessionCB.bind(this)};
             Fusion.ajaxRequest(scriptURL,options);  
         }
         if (this.session[0] instanceof Fusion.Maps.MapGuide) {
@@ -128,10 +128,10 @@
         }
     },
     
-    createSessionCB : function(r, json) {
-        if (r.status == 200 && json) {
+    createSessionCB : function(xhr) {
+        if (xhr.status == 200) {
             var o;
-            eval('o='+r.responseText);
+            eval('o='+xhr.responseText);
             this.session[0] = o.sessionId;
             this.triggerEvent(Fusion.Event.MAP_SESSION_CREATED);
         }
@@ -202,13 +202,12 @@
         
         var sessionid = this.getSessionID();
         
-        var params = 'mapid='+resourceId+"&session="+sessionid;
+        var params = {'mapid': resourceId, "session": sessionid};
         var options = {onSuccess: this.mapLoaded.bind(this), parameters:params};
         Fusion.ajaxRequest(loadmapScript, options);
     },
     
     mapLoaded: function(r, json) {
-        if (json) {
             var o;
             eval('o='+r.responseText);
             this._sResourceId = o.mapId;
@@ -313,10 +312,6 @@
               this.triggerEvent(Fusion.Event.MAP_LOADED);
             }
             this.bMapLoaded = true;
-        } else {
-            Fusion.reportError( new Fusion.Error(Fusion.Error.FATAL, 
-                OpenLayers.i18n('mapLoadError', {'error':r.responseText})));
-        }
         this.mapWidget._removeWorker();
     },
     
@@ -355,7 +350,7 @@
         
         var sessionid = this.getSessionID();
         
-        var params = 'mapname='+this._sMapname+"&session="+sessionid;
+        var params = {'mapname': this._sMapname, 'session': sessionid};
         var options = {onSuccess: this.mapReloaded.bind(this), 
                       onException: this.reloadFailed.bind(this),
                       parameters: params};
@@ -372,7 +367,6 @@
 
 //TBD: this function not yet converted for OL    
     mapReloaded: function(r,json) {
-        if (json) {
             var o;
             eval('o='+r.responseText);
             this.parseMapLayersAndGroups(o);
@@ -388,10 +382,6 @@
             this.oldLayers = null;
             this.mapWidget.triggerEvent(Fusion.Event.MAP_RELOADED);
             this.drawMap();
-        } else {
-            Fusion.reportError( new Fusion.Error(Fusion.Error.FATAL, 
-                OpenLayers.i18n('mapLoadError', {'error':r.responseText})));
-        }
         this.mapWidget._removeWorker();
     },
     
@@ -399,11 +389,12 @@
         var sl = Fusion.getScriptLanguage();
         var loadmapScript = this.arch + '/' + sl  + '/SetLayers.' + sl;
         
-        var sessionid = this.getSessionID();
+        var params = {
+            'mapname': this._sMapname, 
+            'session': this.getSessionID(),
+            'layerindex': aLayerIndex.join()
+        };
         
-        var params = 'mapname='+this._sMapname+"&session="+sessionid;
-        params += '&layerindex=' + aLayerIndex.join();
-        
         var options = {onSuccess: this.mapLayersReset.bind(this, aLayerIndex), 
                                      parameters: params};
         Fusion.ajaxRequest(loadmapScript, options);
@@ -643,10 +634,14 @@
       this.mapWidget._addWorker();
       var sl = Fusion.getScriptLanguage();
       var setSelectionScript = this.arch + '/' + sl  + '/SetSelection.' + sl;
-      var params = 'mapname='+this.getMapName()+"&session="+this.getSessionID();
-      params += '&selection=' + encodeURIComponent(selText);
-      params += '&seq=' + Math.random();
-      var options = {onSuccess: this.processQueryResults.bind(this, zoomTo), parameters:params, asynchronous:false};
+      var params = {
+          'mapname': this.getMapName(),
+          'session': this.getSessionID(),
+          'selection': encodeURIComponent(selText),
+          'seq': Math.random()
+      };
+      var options = {onSuccess: this.processQueryResults.bind(this, zoomTo), 
+                      parameters:params, asynchronous:false};
       Fusion.ajaxRequest(setSelectionScript, options);
     },
 
@@ -683,9 +678,14 @@
           //this.mapWidget._addWorker();
           // this._bSelectionIsLoading = true;
           var s = this.arch + '/' + Fusion.getScriptLanguage() + "/Selection." + Fusion.getScriptLanguage() ;
-          var params = {parameters:'session='+this.getSessionID()+'&mapname='+ this._sMapname +'&layers='+layers+'&startcount='+startcount, 
-                        onComplete: this.getSelectionCB.bind(this, userFunc, layers, startcount)};
-          Fusion.ajaxRequest(s, params);
+          var options = {
+              parameters: {'session': this.getSessionID(),
+                          'mapname': this._sMapname,
+                          'layers': layers,
+                          'startcount': startcount},
+              onSuccess: this.getSelectionCB.bind(this, userFunc, layers, startcount)
+          };
+          Fusion.ajaxRequest(s, options);
       }
     },
 
@@ -713,9 +713,13 @@
     */
     clearSelection : function() {
       if (this.hasSelection()) {
-        var s = this.arch + '/' + Fusion.getScriptLanguage() + "/ClearSelection." + Fusion.getScriptLanguage() ;
-        var params = {parameters:'session='+this.getSessionID()+'&mapname='+ this._sMapname, onComplete: this.selectionCleared.bind(this)};
-        Fusion.ajaxRequest(s, params);
+          var s = this.arch + '/' + Fusion.getScriptLanguage() + "/ClearSelection." + Fusion.getScriptLanguage() ;
+          var options = {
+              parameters: {'session': this.getSessionID(),
+                          'mapname': this._sMapname},
+              onSuccess: this.selectionCleared.bind(this)
+          };
+          Fusion.ajaxRequest(s, options);
       }
     },
 
@@ -784,24 +788,31 @@
           this.aLayers[j].selectedFeatureCount = 0;
         }
 
-        var geometry = options.geometry || '';
-        var maxFeatures = options.maxFeatures || 0; //zero means select all features
         var bPersistant = options.persistent || true;
-        var selectionType = options.selectionType || this.selectionType;
-        var filter = options.filter ? '&filter='+options.filter : '';
-        var layers = options.layers || '';
-        var extend = options.extendSelection ? '&extendselection=true' : '';
-        var computed = options.computedProperties ? '&computed=true' : '';
         var zoomTo = options.zoomTo ?  true : false;
         var sl = Fusion.getScriptLanguage();
         var loadmapScript = this.arch + '/' + sl  + '/Query.' + sl;
 
-        var sessionid = this.getSessionID();
-
-        var params = 'mapname='+this._sMapname+"&session="+sessionid+'&spatialfilter='+geometry+'&maxfeatures='+maxFeatures+filter+'&layers='+layers+'&variant='+selectionType+extend+computed;
-        var options = {onSuccess: this.processQueryResults.bind(this, zoomTo), 
-                                     parameters: params};
-        Fusion.ajaxRequest(loadmapScript, options);
+        var params = {
+            'mapname': this._sMapname,
+            'session': this.getSessionID(),
+            'spatialfilter': options.geometry || '',
+            'maxfeatures': options.maxFeatures || 0, //zero means select all features
+            'layers': options.layers || '',
+            'variant': options.selectionType || this.selectionType
+        }
+        if (options.filter) {
+            params.filter= options.filter;
+        }
+        if (options.extendSelection) {
+            params.extendselection = true;
+        }
+        if (options.computedProperties) {
+            params.computed = true;
+        }
+        var ajaxOptions = {onSuccess: this.processQueryResults.bind(this, zoomTo), 
+                      parameters: params};
+        Fusion.ajaxRequest(loadmapScript, ajaxOptions);
     },
     
     processLayerEvents: function(layer, isEnabling) {
@@ -946,18 +957,20 @@
                                                             this._sMapname,
                                                             sGeometry,
                                                             maxFeatures, persist, selection, layerNames);
-        Fusion.oBroker.dispatchRequest(r, this.crtlClickDisplay.bind(this));
+        var callback = this.crtlClickDisplay.bind(this);
+        Fusion.oBroker.dispatchRequest(r, Fusion.xml2json.bind(this, callback));
       }
     },
 
     /**
      * open a window if a URL is defined for the feature.
      **/
-    crtlClickDisplay: function(r) {
+    crtlClickDisplay: function(xhr) {
         //console.log('ctrlclcik  _display');
-        if (r.responseXML) {
-            var d = new DomNode(r.responseXML);
-            var h = d.getNodeText('Hyperlink');
+        if (xhr.status == 200) {
+            var o;
+            eval('o='+xhr.responseText);
+            var h = o['FeatureInformation']['Hyperlink'][0];
             if (h != '') {
                 window.open(h, "");
             }
@@ -967,7 +980,7 @@
     pingServer: function() {
         var s = this.arch + '/' + Fusion.getScriptLanguage() + "/Common." + Fusion.getScriptLanguage() ;
         var params = {};
-        params.parameters = 'session='+this.getSessionID();
+        params.parameters = {'session': this.getSessionID()};
         Fusion.ajaxRequest(s, params);
     },
     getGroupInfoUrl: function(groupName) {

Modified: sandbox/olcore/MapServer/MapServer.js
===================================================================
--- sandbox/olcore/MapServer/MapServer.js	2008-03-28 18:54:15 UTC (rev 1350)
+++ sandbox/olcore/MapServer/MapServer.js	2008-03-28 19:16:09 UTC (rev 1351)
@@ -111,7 +111,7 @@
             this.session[0] = this;
             var sl = Fusion.getScriptLanguage();
             var scriptURL = this.arch + '/' + sl + '/CreateSession.' + sl;
-            var options = {onComplete: this.createSessionCB.bind(this)};
+            var options = {onSuccess: this.createSessionCB.bind(this)};
             Fusion.ajaxRequest(scriptURL,options);
         }
         if (this.session[0] instanceof Fusion.Maps.MapServer) {
@@ -192,20 +192,17 @@
 
         var sl = Fusion.getScriptLanguage();
         var loadmapScript = this.arch + '/' + sl  + '/LoadMap.' + sl;
-
-        var sessionid = this.getSessionID();
-
-        var metadata = '';
+        var params = {
+            'mapfile': mapfile,
+            'session': this.getSessionID()
+        };
         if (this.mapMetadataKeys) {
-            metadata += '&map_metadata='+this.mapMetadataKeys;
+            params.map_metadata = this.mapMetadataKeys;
         }
         if (this.layerMetadataKeys) {
-            metadata += '&layer_metadata='+this.layerMetadataKeys;
+            params.layer_metadata = this.layerMetadataKeys;
         }
-
-        var params = 'mapfile='+mapfile+"&session="+sessionid+metadata;
-        var options = {onSuccess: this.mapLoaded.bind(this),
-                                     parameters: params};
+        var options = {onSuccess:this.mapLoaded.bind(this), parameters: params};
         Fusion.ajaxRequest(loadmapScript, options);
     },
 
@@ -328,16 +325,16 @@
         var sl = Fusion.getScriptLanguage();
         var loadmapScript = this.arch + '/' + sl  + '/LoadMap.' + sl;
 
-        var sessionid = this.getSessionID();
-        var metadata = '';
+        var params = {
+            'mapname': this._sMapname,
+            'session': this.getSessionID()
+        };
         if (this.mapMetadataKeys) {
-            metadata += '&map_metadata='+this.mapMetadataKeys;
+            params.map_metadata = this.mapMetadataKeys;
         }
         if (this.layerMetadataKeys) {
-            metadata += '&layer_metadata='+this.layerMetadataKeys;
+            params.layer_metadata = this.layerMetadataKeys;
         }
-
-        var params = 'mapname='+this._sMapname+"&session="+sessionid+metadata;
         var options = {onSuccess: this.mapReloaded.bind(this),
                                      parameters: params};
         Fusion.ajaxRequest(loadmapScript, options);
@@ -371,10 +368,11 @@
         var sl = Fusion.getScriptLanguage();
         var loadmapScript = this.arch + '/' + sl  + '/SetLayers.' + sl;
 
-        var sessionid = this.getSessionID();
-        var params = 'mapname='+this._sMapname+"&session="+sessionid;
-        params += '&layerindex=' + aLayerIndex.join();
-
+        var params = {
+            'mapname': this._sMapname,
+            'session': this.getSessionID(),
+            'layerindex': aLayerIndex.join()
+        };
         var options = {onSuccess: this.mapLayersReset.bind(this, aLayerIndex),
                                      parameters: params};
         Fusion.ajaxRequest(loadmapScript, options);
@@ -607,9 +605,18 @@
         if (userFunc)
         {
             var s = this.arch + '/' + Fusion.getScriptLanguage() + "/Selection." + Fusion.getScriptLanguage() ;
-            var params = {parameters:'session='+this.getSessionID()+'&mapname='+ this._sMapname+ '&layers='+layers+'&startcount='+startcount+'&queryfile='+this._sQueryfile,
-                          onComplete: this.getSelectionCB.bind(this, userFunc, layers, startcount)};
-            Fusion.ajaxRequest(s, params);
+            var params = {
+                'mapname': this._sMapname,
+                'session': this.getSessionID(),
+                'layers': layers,
+                'startcount': startcount,
+                'queryfile': this._sQueryfile
+            };
+            var options = {
+                parameters:params,
+                onSuccess: this.getSelectionCB.bind(this, userFunc, layers, startcount)
+            };
+            Fusion.ajaxRequest(s, options);
         }
 
     },
@@ -674,28 +681,38 @@
           this.aLayers[j].selectedFeatureCount = 0;
         }
 
-        var geometry = options.geometry || '';
-        var maxFeatures = options.maxFeatures || -1;
         var bPersistant = options.persistent || true;
-        var selectionType = options.selectionType || this.selectionType;
-        var filter = options.filter ? '&filter='+options.filter : '';
         var layers = options.layers || '';
         /* if no layes are given, query only visible layers. This is ususally the most common case*/
         if (layers == '') {
           layers = this.aVisibleLayers.join(',');
         }
-        var extend = options.extendSelection ? '&extendselection=true' : '';
-        var computed = options.computedProperties ? '&computed=true' : '';
         var zoomTo = options.zoomTo || false;
         var sl = Fusion.getScriptLanguage();
-        var loadmapScript = this.arch + '/' + sl  + '/Query.' + sl;
+        var queryScript = this.arch + '/' + sl  + '/Query.' + sl;
 
-        var sessionid = this.getSessionID();
-
-        var params = 'mapname='+this._sMapname+"&session="+sessionid+'&spatialfilter='+geometry+'&maxfeatures='+maxFeatures+filter+'&layers='+layers+'&variant='+selectionType+extend;
-        var options = {onSuccess: this.processQueryResults.bind(this, zoomTo),
-                                     parameters: params};
-        Fusion.ajaxRequest(loadmapScript, options);
+        var params = {
+            'mapname': this._sMapname,
+            'session': this.getSessionID(),
+            'spatialfilter': options.geometry || '',
+            'maxfeatures': options.maxFeatures || -1, //-1 means select all features
+            'layers': layers,
+            'variant': options.selectionType || this.selectionType
+        }
+        if (options.filter) {
+            params.filter = options.filter;
+        }
+        if (options.extendSelection) {
+            params.extendselection = true;
+        }
+        if (options.computedProperties) {
+            params.computed = true;
+        }
+        var ajaxOptions = {
+            onSuccess: this.processQueryResults.bind(this, zoomTo), 
+            parameters: params
+        };
+        Fusion.ajaxRequest(queryScript, ajaxOptions);
     },
 
     loadStart: function() {
@@ -709,7 +726,7 @@
     pingServer: function() {
         var s = this.arch + '/' + Fusion.getScriptLanguage() + "/Common." + Fusion.getScriptLanguage() ;
         var params = {};
-        params.parameters = 'session='+this.getSessionID();
+        params.parameters = {'session': this.getSessionID()};
         Fusion.ajaxRequest(s, params);
   },
 

Modified: sandbox/olcore/lib/ApplicationDefinition.js
===================================================================
--- sandbox/olcore/lib/ApplicationDefinition.js	2008-03-28 18:54:15 UTC (rev 1350)
+++ sandbox/olcore/lib/ApplicationDefinition.js	2008-03-28 19:16:09 UTC (rev 1351)
@@ -103,11 +103,6 @@
         this.parse();
     },
     
-    loadFailure: function() {
-      Fusion.reportError(new Fusion.Error(Fusion.Error.FATAL, 
-        OpenLayers.i18n('appDefLoadFailed',{'script':this.applicationDefinition})));
-    },
-
     /**
      * Function: parse
      *
@@ -129,11 +124,7 @@
         
         if ( (this.applicationDefinition.match('Library://') == null) &&
              (this.applicationDefinition.match('Session:') == null) ) {
-            var options = {};
-            options.method = 'get';
-            options.onSuccess = this.convertXML.bind(this);
-            options.onFailure = this.loadFailure.bind(this);
-            new Ajax.Request( this.applicationDefinition, options);
+            Fusion.getXmlAsJson(this.applicationDefinition, this.parseAppDef.bind(this));
         } else {
             //TODO: request as JSON format
             if (!this.sessionId) {
@@ -153,16 +144,15 @@
       }
       var r = new Fusion.Lib.MGRequest.MGGetResourceContent(this.applicationDefinition);
       r.parameters.session = this.sessionId;
-      this.oBroker.dispatchRequest(r, this.convertXML.bind(this));
+      this.oBroker.dispatchRequest(r, Fusion.xml2json.bind(this, this.parseAppDef.bind(this)));
     },
     
     /**
-     * Function: convertXML
+     * Function: parseAppDef
      *
-     * Optionally convert XML to JSON using a server-side script
-     * if the application definition wasn't available in JSON.
+     * parse the ApplicationDefinition file into the appropriate Fusion objects
      *
-     * Parameter: {XmlHttpRequest} r
+     * Parameter: {XmlHttpRequest} xhr
      *
      * the XmlHttpRequest object
      *
@@ -170,103 +160,68 @@
      *
      * boolean indicator if the content is JSON or not.
      */
-    convertXML: function(r, json) {
-      if (json) {
-        this.parseJSON(r, json);
-      } else {
-        //this check only works on Firefox - it is safely ignored in IE and IE
-        //will happily parse an invalid XML document
-        if (r.responseXML.documentElement.nodeName == 'parsererror') {
-          Fusion.reportError(new Fusion.Error(Fusion.Error.FATAL, 
-              'invalid XML document: ' + this.applicationDefinition));
+     parseAppDef: function(xhr) {
+        var o;
+        eval("o="+xhr.responseText);
+        var appDef = o.ApplicationDefinition;
+
+        /* Set the application title */
+        if (appDef.Title) {
+            var title = appDef.Title[0];
+            document.title = title;
         }
-          
-        var options = {};
-        options.onSuccess = this.parseJSON.bind(this);
-        options.parameters = 'xml='+encodeURIComponent(r.responseText.replace(/\\/g, '\\\\\\\\'))+'&ts='+((new Date()).getTime());
-        var sl = Fusion.getScriptLanguage();
-        Fusion.ajaxRequest('common/'+sl+'/Xml2JSON.'+sl, options);
-      }
-    },
-    
-    /**
-     * Function: parseJSON
-     *
-     * parse a JSON string into an ApplicationDefinition
-     *
-     * Parameter: {XmlHttpRequest} r
-     *
-     * the XmlHttpRequest object
-     *
-     * Parameter: json
-     *
-     * boolean indicator if the content is JSON or not.
-     */
-     parseJSON: function(r, json) {
-        if (json) {
-            var mainNode;
-            eval("mainNode="+r.responseText);
-            
-            var appDef = mainNode.ApplicationDefinition;
 
-            /* Set the application title */
-            if (appDef.Title) {
-                var title = appDef.Title[0];
-                document.title = title;
-            }
-
-            /* process Map nodes */
-            if (appDef.MapSet) {
-                var mapSet = appDef.MapSet[0];
-                if (mapSet.MapGroup instanceof Array) {
-                    for (var i=0; i<mapSet.MapGroup.length; i++) {
-                        var mapGroup = new Fusion.Lib.ApplicationDefinition.MapGroup(mapSet.MapGroup[i]);
-                        this.mapGroups.push(mapGroup);
-                    }
+        /* process Map nodes */
+        if (appDef.MapSet) {
+            var mapSet = appDef.MapSet[0];
+            if (mapSet.MapGroup instanceof Array) {
+                for (var i=0; i<mapSet.MapGroup.length; i++) {
+                    var mapGroup = new Fusion.Lib.ApplicationDefinition.MapGroup(mapSet.MapGroup[i]);
+                    this.mapGroups.push(mapGroup);
                 }
-            } else {
-              Fusion.reportError(new Fusion.Error(Fusion.Error.FATAL, 
-                            OpenLayers.i18n('appDefParseError')));
             }
-            
-            /* process WIDGET sets */
-            if (appDef.WidgetSet) {
-                for (var i=0; i<appDef.WidgetSet.length; i++) {
-                    var widgetSet = new Fusion.Lib.ApplicationDefinition.WidgetSet(appDef.WidgetSet[i]);
-                    this.widgetSets.push(widgetSet);
-                }
-            } else {
-              Fusion.reportError(new Fusion.Error(Fusion.Error.FATAL, 
-                          OpenLayers.i18n('widgetSetParseError')));
+        } else {
+          Fusion.reportError(new Fusion.Error(Fusion.Error.FATAL, 
+                        OpenLayers.i18n('appDefParseError')));
+        }
+        
+        /* process WIDGET sets */
+        if (appDef.WidgetSet) {
+            for (var i=0; i<appDef.WidgetSet.length; i++) {
+                var widgetSet = new Fusion.Lib.ApplicationDefinition.WidgetSet(appDef.WidgetSet[i]);
+                this.widgetSets.push(widgetSet);
             }
-            
-            /* process extensions */
-            if (appDef.Extension) {
-                var extension = appDef.Extension[0];
-                /* process search definitions */
-                if (extension.SearchDefinitions instanceof Array) {
-                    var categories = extension.SearchDefinitions[0];
-                    if (categories.SearchCategory instanceof Array) {
-                        for (var i=0; i<categories.SearchCategory.length; i++) {
-                            var oCategory = {};
-                            var category = categories.SearchCategory[i];
-                            oCategory.id = category['@id'];
-                            oCategory.name = category['@name'];
-                            oCategory.layer = category.Layer ? category.Layer[0] : '';
-                            oCategory.searchDefinitions = [];
-                            this.searchCategories[oCategory.id] = oCategory;
-                            var defns = category.SearchDefinition;
-                            for (var k=0; k<defns.length; k++) {
-                                var defn = new Fusion.Lib.ApplicationDefinition.SearchDefinition(defns[k]);
-                                defn.category = oCategory;
-                                oCategory.searchDefinitions[defn.id] = defn;
-                                this.searchDefinitions[defn.id] = defn;
-                            }
+        } else {
+          Fusion.reportError(new Fusion.Error(Fusion.Error.FATAL, 
+                      OpenLayers.i18n('widgetSetParseError')));
+        }
+        
+        /* process extensions */
+        if (appDef.Extension) {
+            var extension = appDef.Extension[0];
+            /* process search definitions */
+            if (extension.SearchDefinitions instanceof Array) {
+                var categories = extension.SearchDefinitions[0];
+                if (categories.SearchCategory instanceof Array) {
+                    for (var i=0; i<categories.SearchCategory.length; i++) {
+                        var oCategory = {};
+                        var category = categories.SearchCategory[i];
+                        oCategory.id = category['@id'];
+                        oCategory.name = category['@name'];
+                        oCategory.layer = category.Layer ? category.Layer[0] : '';
+                        oCategory.searchDefinitions = [];
+                        this.searchCategories[oCategory.id] = oCategory;
+                        var defns = category.SearchDefinition;
+                        for (var k=0; k<defns.length; k++) {
+                            var defn = new Fusion.Lib.ApplicationDefinition.SearchDefinition(defns[k]);
+                            defn.category = oCategory;
+                            oCategory.searchDefinitions[defn.id] = defn;
+                            this.searchDefinitions[defn.id] = defn;
                         }
                     }
                 }
-                
             }
+            
         }
         Fusion.setLoadState(Fusion.LOAD_WIDGETS);
     },

Modified: sandbox/olcore/lib/Error.js
===================================================================
--- sandbox/olcore/lib/Error.js	2008-03-28 18:54:15 UTC (rev 1350)
+++ sandbox/olcore/lib/Error.js	2008-03-28 19:16:09 UTC (rev 1351)
@@ -30,11 +30,6 @@
  */
 
 Fusion.Error = OpenLayers.Class({
-
-    FATAL: 0,
-    WARNING: 1,
-    NOTICE: 2,
-
     type: null,
     message: null,
     initialize: function(type, message) {
@@ -65,3 +60,9 @@
         }
     }
 });
+
+Fusion.Error.FATAL = 0;
+Fusion.Error.WARNING = 1;
+Fusion.Error.NOTICE = 2;
+
+

Modified: sandbox/olcore/lib/MGBroker.js
===================================================================
--- sandbox/olcore/lib/MGBroker.js	2008-03-28 18:54:15 UTC (rev 1350)
+++ sandbox/olcore/lib/MGBroker.js	2008-03-28 19:16:09 UTC (rev 1351)
@@ -75,8 +75,8 @@
         if (this.method) {
             r.options.method = this.method;
         }
-        var a = new Ajax.Request( this.mapAgentURL, 
-                 Object.extend({ parameters:r.parameters, onComplete:f }, r.options ) );
+        var a = new OpenLayers.Ajax.Request( this.mapAgentURL, 
+            Object.extend({parameters:r.parameters, onComplete:f }, r.options));
         a.originalRequest = r;
     },
     /**

Modified: sandbox/olcore/lib/Map.js
===================================================================
--- sandbox/olcore/lib/Map.js	2008-03-28 18:54:15 UTC (rev 1350)
+++ sandbox/olcore/lib/Map.js	2008-03-28 19:16:09 UTC (rev 1351)
@@ -926,9 +926,7 @@
  * Utility class to hold slection information
  *
  */
-var GxSelectionObject = Class.create();
-GxSelectionObject.prototype = 
-{
+var GxSelectionObject = OpenLayers.Class({
     aLayers : null,
 
     initialize: function(o) 
@@ -998,12 +996,10 @@
         }
             
     }
-};
+});
 
 
-var GxSelectionObjectLayer = Class.create();
-GxSelectionObjectLayer.prototype = {
-
+var GxSelectionObjectLayer = OpenLayers.Class({
     sName: null,
     nElements: null,
     aElements: null,
@@ -1121,4 +1117,4 @@
             return null;
         }
     }
-};
+});

Modified: sandbox/olcore/lib/MenuBase.js
===================================================================
--- sandbox/olcore/lib/MenuBase.js	2008-03-28 18:54:15 UTC (rev 1350)
+++ sandbox/olcore/lib/MenuBase.js	2008-03-28 19:16:09 UTC (rev 1351)
@@ -29,8 +29,7 @@
  * generic base class for implementing widgets that incorporate a menu
  * **********************************************************************/
  
-Fusion.Tool.MenuBase = Class.create();
-Fusion.Tool.MenuBase.prototype = {
+Fusion.Tool.MenuBase = OpenLayers.Class({
     /**
      * constructor
      */
@@ -58,4 +57,4 @@
     disable: function() {
         Fusion.Widget.prototype.disable.apply(this,[]);
     }
-};
+});

Modified: sandbox/olcore/lib/fusion.js
===================================================================
--- sandbox/olcore/lib/fusion.js	2008-03-28 18:54:15 UTC (rev 1350)
+++ sandbox/olcore/lib/fusion.js	2008-03-28 19:16:09 UTC (rev 1351)
@@ -48,7 +48,6 @@
     Fusion.coreScripts = ['lib/OpenLayers/OpenLayers.js',
                         'jx/lib/jx_combined.js',
                         'lib/excanvas/excanvas-compressed.js',
-                        'lib/utils.js',
                         'lib/Error.js',
                         'lib/ApplicationDefinition.js',
                         'lib/MGBroker.js',
@@ -630,7 +629,10 @@
         if (!options.onException) {
             options.onException = this.ajaxException.bind(this);
         }
-        new Ajax.Request( url, options);
+        if (!options.contentType) {
+          options.contentType = 'application/x-www-form-urlencoded';
+        }
+        new OpenLayers.Ajax.Request( url, options);
     },
     
     /**
@@ -644,9 +646,61 @@
      */
     ajaxException: function(r, e) {
         this.reportError(new Fusion.Error(Fusion.Error.WARNING, 
-          OpenLayers.i18n('ajaxError', {'exception':e, 'filename':e.filename, 'line':e.lineNumber})));
+            OpenLayers.i18n('ajaxError', {'exception':e.message, 
+                                          'filename':e.fileName, 
+                                          'line':e.lineNumber,
+                                          'response': r.transport.responseText
+                                          })));
     },
     
+     /**
+     * Function: convertXML
+     *
+     * Optionally convert XML to JSON using a server-side script
+     * for requests that aren't available in JSON.
+     *
+     * Parameter: {XmlHttpRequest} r
+     *
+     * the XmlHttpRequest object
+     *
+     * Parameter: json
+     *
+     * boolean indicator if the content is JSON or not.
+     *
+     * Parameter: callback
+     *
+     * callback method to be executed on success and will be passed a parsed json object
+    */
+    getXmlAsJson: function(url, callback) {
+        var options = {};
+        options.onSuccess = this.xml2json.bind(this, callback);
+        options.onFailure = this.ajaxException.bind(this);
+        new OpenLayers.Ajax.Request(url, options);
+    },
+    
+    xml2json: function(callback, r, json) {
+      if (json) {
+        var o;
+        eval("o="+r.responseText);
+        callback(o);
+      } else {
+        //this check only works on Firefox - it is safely ignored in IE and IE
+        //will happily parse an invalid XML document
+        if (r.responseXML.documentElement.nodeName == 'parsererror') {
+          Fusion.reportError(new Fusion.Error(Fusion.Error.FATAL, 
+              'invalid XML document: ' + r.url));
+        }
+          
+        var options = {
+          onSuccess: callback,
+          //parameters = 'xml='+encodeURIComponent(r.responseText.replace(/\\/g, '\\\\\\\\'));
+          parameters: {'xml': encodeURIComponent(r.responseText)}
+        };
+        var sl = Fusion.getScriptLanguage();
+        Fusion.ajaxRequest('common/'+sl+'/Xml2JSON.'+sl, options);
+      }
+    },
+    
     /**
      * Function: getMapByName
      *

Deleted: sandbox/olcore/lib/utils.js
===================================================================
--- sandbox/olcore/lib/utils.js	2008-03-28 18:54:15 UTC (rev 1350)
+++ sandbox/olcore/lib/utils.js	2008-03-28 19:16:09 UTC (rev 1351)
@@ -1,213 +0,0 @@
-/**
- * Utils
- *
- * $Id$
- *
- * Copyright (c) 2007, DM Solutions Group Inc.
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-var DomNode = OpenLayers.Class({
-    initialize: function( xmlNode /*, parent */ ) {
-        this.textContent = '';
-        this.nodeName = xmlNode?xmlNode.nodeName:'';
-        this.parentNode = arguments[1]?arguments[1]:null;
-        this.childNodes  = [];
-        this.attributes = [];
-        this.attributeNames = [];
-        if (xmlNode) {
-            if (xmlNode.attributes) {
-                for (var i=0; i<xmlNode.attributes.length; i++) {
-                    this.attributeNames.push(xmlNode.attributes[i].name);
-                    this.attributes[xmlNode.attributes[i].name] = xmlNode.attributes[i].nodeValue;
-                }
-            }
-            for (var i=0; i<xmlNode.childNodes.length; i++) {
-              if (xmlNode.childNodes[i].nodeType != 3) {
-                this.childNodes.push(new DomNode(xmlNode.childNodes[i], this));
-              } else {
-                this.textContent = this.textContent + xmlNode.childNodes[i].nodeValue;
-              }
-            }
-        }
-        this._currentNode = 0;
-    },
-    getAttribute: function(name) {
-        return typeof(this.attributes[name]) != 'undefined' ? this.attributes[name] : null;
-    },
-    removeChild: function(child) {
-        var result = null;
-        for(var i=0; i<this.childNodes.length; i++) {
-            if (this.childNodes[i] == child) {
-                this._currentNode = 0;
-                this.childNodes.splice(i,1);
-                child.parentNode = null;
-                result = child;
-                break;
-            }
-        }
-        return result;
-    },
-    appendChild: function(child) {
-        if (child.parentNode) {
-            child.parentNode.removeChild(child);
-        }
-        child.parentNode = this;
-        this.childNodes.push(child);
-    },
-    insertBefore: function(newChild,refChild) {
-        var bInserted = false;
-        if (refChild) {
-            for (var i=0; i<this.childNodes.length; i++) {
-                if (this.childNodes[i] == refChild) {
-                    if (newChild.parentNode) {
-                        newChild.parentNode.removeChild(child);
-                    }
-                    newChild.parentNode = this;
-                    this.childNodes.splice(i,0,newChild);
-                    bInserted = true;
-                    break;
-                }
-            }
-        }
-        if (!bInserted) {
-            this.appendChild(newChild);
-        }
-    },
-    toString: function(depth) {
-        var s = '';
-        var spacer = '';
-        for (i=0; i<depth; i++) {
-            spacer = spacer + '';
-        }
-        s = spacer + '&lt;' + this.nodeName;
-        if (this.attributes.length > 0) {
-            for (var name in this.attributes) {
-                if (typeof(this.attributes[name]) == 'String' ) {
-                    s = s + ' ' + name + '="' + this.attributes[name] + '"';
-                }
-            }
-        }
-        s = s + '&gt;';
-        if (this.childNodes.length == 0) {
-            s = s + this.textContent;
-            spacer = '';
-        } else {  
-            s = s + '\n';
-        }
-        for (var i=0; i<this.childNodes.length; i++) {
-            s = s + this.childNodes[i].toString( depth + 1 );
-        }
-        s = s + spacer + '&lt;/'+this.nodeName+'&gt;';
-        return s;
-    },
-    toXML: function() {
-        var s = this.parentNode?'':'<?xml version="1.0" encoding="UTF-8"?>\n';
-        s = s+ '<' + this.nodeName;
-        if (this.attributeNames.length > 0) {
-            for (var i=0; i<this.attributeNames.length; i++) {
-                var name = this.attributeNames[i];
-                s = s + ' ' + name + '="' + this.attributes[name] + '"';
-            }
-        }
-        s = s + '>';
-        if (this.childNodes.length == 0) {
-            var content = this.textContent + ''; //force string value if textContent was automatically made to a number
-            content = content.replace('&','&amp;');
-            content = content.replace(/</g, encodeURIComponent('&lt;'));
-            content = content.replace(/>/g, encodeURIComponent('&gt;'));
-            s = s + content;
-            
-        }
-        for (var i=0; i<this.childNodes.length; i++) {
-            s = s + this.childNodes[i].toXML();
-        }
-        s = s + '</'+this.nodeName+'>\n';
-        return s;
-    },
-    getNodeText: function(name) {
-        var s = '';
-        var n = this.findFirstNode(name);
-        if (n) {
-            s = n.textContent;
-        }
-        return s;
-    },
-    setNodeText: function(name, value) {
-        var n = this.findFirstNode(name);
-        if (n) {
-            n.setTextContent(value);
-        }
-    },
-    setTextContent: function(value) {
-        this.textContent = value;
-    },
-    setAttribute: function(name, value) {
-        if (typeof this.attributes[name] == 'undefined') {
-            this.attributeNames.push(name);
-        }
-        this.attributes[name] = value;
-    },
-    findFirstNode: function( name ) {
-        this._currentNode = 0;
-        if (this.nodeName == name) {
-            return this;
-        } else {
-            for (var i=0; i<this.childNodes.length; i++) {
-                var node = this.childNodes[i].findFirstNode(name);
-                if (node) {
-                    if (node.parentNode == this) {
-                        this._currentNode = i + 1;
-                    } else {
-                        this._currentNode = i;          
-                    }
-                    return node;
-                }
-            }
-            return false;
-        }
-    },
-    findNextNode: function( name ) {
-        if (this.nodeName == name) {
-            return this;
-        } else {
-            for (var i=this._currentNode; i<this.childNodes.length; i++) {
-                var node = this.childNodes[i].findNextNode(name);
-                if (node) {
-                    if (node.parentNode == this) {
-                        this._currentNode = i + 1;
-                    } else {
-                        this._currentNode = i;          
-                    }
-                    return node;
-                }
-            }
-            return false;
-        } 
-    }
-});
-
-var DomNodeFactory = {
-    create: function( name, value ) {
-        var node = new DomNode();
-        node.nodeName = name;
-        node.textContent = value || '';
-        return node;
-    }
-};
\ No newline at end of file

Modified: sandbox/olcore/text/en/strings.json
===================================================================
--- sandbox/olcore/text/en/strings.json	2008-03-28 18:54:15 UTC (rev 1350)
+++ sandbox/olcore/text/en/strings.json	2008-03-28 19:16:09 UTC (rev 1351)
@@ -2,7 +2,7 @@
 'scriptFailed': 'failed to load script: ${script}',
 'configParseError': 'Error parsing fusion configuration file, initialization aborted',
 'configLoadError': 'Error loading fusion configuration file, initialization aborted',
-'ajaxError': 'Exception occurred in AJAX callback.\n${exception}\nLocation: ${file} (${line}))',
+'ajaxError': 'Exception occurred in AJAX callback.\nMessage: ${exception}\nLocation: ${filename} (${line})\nResponse: ${response}',
 'importFailed': 'failed to import stylesheet: ${url}',
 'registerEventError': 'Error registering eventID, invalid (empty) eventID.',
 'appDefLoadFailed': 'failed to load: ${script}',

Deleted: sandbox/olcore/widgets/CTRLClick.js
===================================================================
--- sandbox/olcore/widgets/CTRLClick.js	2008-03-28 18:54:15 UTC (rev 1350)
+++ sandbox/olcore/widgets/CTRLClick.js	2008-03-28 19:16:09 UTC (rev 1351)
@@ -1,113 +0,0 @@
-/**
- * Fusion.Widget.CTRLClick
- *
- * $Id$
- *
- * Copyright (c) 2007, DM Solutions Group Inc.
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
- /********************************************************************
- * Class: Fusion.Widget.CTRLClick
- *
- * Launch a window with a CTRL click  if a URL expression is set on the layer
- * **********************************************************************/
-
-Fusion.Widget.CTRLClick = Class.create();
-Fusion.Widget.CTRLClick.prototype = 
-{
-    aLayers: null,
-
-    initialize : function(widgetTag)
-    {
-        //console.log('CTRLClick.initialize');
-        Object.inheritFrom(this, Fusion.Widget.prototype, [widgetTag, true]);
-        var json = widgetTag.extension;
-
-        this.aLayers = [];
-        if (json.Layer) {
-            for (var i=0; i<json.Layer.length; i++) {
-                this.aLayers.push(json.Layer[i]);
-            }
-        }
-
-        this.getMap().observeEvent('mouseup', this.mouseUpCRTLClick.bind(this));
-    },
-
-    /**
-     * called when there is a click on the map: query features at that postion.
-     **/
-    mouseUpCRTLClick: function(e) {
-        if (e.ctrlKey) 
-        {
-            var map = this.getMap();
-            var p = map.getEventPosition(e);
-            var min = map.pixToGeo(p.x, p.y);
-            var max = map.pixToGeo(p.x, p.y);
-            if (!min) {
-              return;
-            }   
-            var oBroker = Fusion.oBroker;
-            var cellSize = map._nCellSize;
-            //cell size not set in map file. Use default value
-            cellSize = 1e-6;
-
-            min.x -= cellSize;
-            min.y -= cellSize;
-
-            max.x += cellSize;
-            max.y += cellSize;
-
-            var sGeometry = 'POLYGON(('+ min.x + ' ' +  min.y + ', ' +  min.x + ' ' +  max.y + ', ' + max.x + ' ' +  max.y + ', ' + max.x + ' ' +  min.y + ', ' + min.x + ' ' +  min.y + '))';
-
-            //var sGeometry = 'POINT('+ min.x + ' ' +  min.y + ')';
-
-            var maxFeatures = 1;
-            var persist = 0;
-            var selection = 'INTERSECTS';
-            var maps = this.getMap().getAllMaps();
-            //TODO: possibly make the layer names configurable?
-            var layerNames = this.aLayers.toString();
-            var r = new Fusion.Lib.MGRequest.MGQueryMapFeatures(maps[0].getSessionID(),
-                                                                maps[0]._sMapname,
-                                                                sGeometry,
-                                                                maxFeatures, persist, selection, layerNames);
-            oBroker.dispatchRequest(r, 
-                                    this._display.bind(this));
-        }
-    },
-
-    /**
-     * open a window if a URL is defined for the feature.
-     **/
-    _display: function(r) {
-        //console.log('ctrlclcik  _display');
-        if (r.responseXML) 
-        {
-            var d = new DomNode(r.responseXML);
-            var h = d.getNodeText('Hyperlink');
-            if (h != '') 
-            {
-                window.open(h, "");
-            }
-        
-        }
-    }
-
-};

Modified: sandbox/olcore/widgets/MapMenu.js
===================================================================
--- sandbox/olcore/widgets/MapMenu.js	2008-03-28 18:54:15 UTC (rev 1350)
+++ sandbox/olcore/widgets/MapMenu.js	2008-03-28 19:16:09 UTC (rev 1351)
@@ -66,7 +66,7 @@
             this.sRootFolder = json.Folder ? json.Folder[0] : 'Library://';
             var s =       this.arch + '/' + Fusion.getScriptLanguage() +
                           '/MapMenu.' + Fusion.getScriptLanguage();
-            var params =  {parameters:'folder='+this.sRootFolder,
+            var params =  {parameters: {'folder': this.sRootFolder},
                           onComplete: this.processMapMenu.bind(this)};
             Fusion.ajaxRequest(s, params);
         };

Modified: sandbox/olcore/widgets/Measure.js
===================================================================
--- sandbox/olcore/widgets/Measure.js	2008-03-28 18:54:15 UTC (rev 1350)
+++ sandbox/olcore/widgets/Measure.js	2008-03-28 19:16:09 UTC (rev 1351)
@@ -375,16 +375,21 @@
     },
     
     measureSegment: function(segment, marker) {
-        var points = '&x1='+segment.from.x+'&y1='+segment.from.y+
-                     '&x2='+segment.to.x+'&y2='+segment.to.y;
-        var map = this.getMap();
-        var aMaps = map.getAllMaps();
+        var aMaps = this.getMap().getAllMaps();
         var s = aMaps[0].arch + '/' + Fusion.getScriptLanguage() + "/Measure." + Fusion.getScriptLanguage() ;
-        var sessionId = aMaps[0].getSessionID();
-        var params = {};
-        params.parameters = 'session='+sessionId+'&locale='+Fusion.locale+'&mapname='+ this.getMap().getMapName()+points;
-        params.onComplete = this.measureCompleted.bind(this, segment, marker);
-        Fusion.ajaxRequest(s, params);
+        var options = {
+            parameters: {
+                'session': aMaps[0].getSessionID(),
+                'locale': Fusion.locale,
+                'mapname': this.getMap().getMapName(),
+                'x1': segment.from.x,
+                'y1': segment.from.y,
+                'x2': segment.to.x,
+                'y2': segment.to.y
+            },
+            'onComplete': this.measureCompleted.bind(this, segment, marker)
+        };
+        Fusion.ajaxRequest(s, options);
     },
     
     measureCompleted: function(segment, marker, r, json) {

Modified: sandbox/olcore/widgets/SelectWithin/SelectWithinPanel.templ
===================================================================
--- sandbox/olcore/widgets/SelectWithin/SelectWithinPanel.templ	2008-03-28 18:54:15 UTC (rev 1350)
+++ sandbox/olcore/widgets/SelectWithin/SelectWithinPanel.templ	2008-03-28 19:16:09 UTC (rev 1351)
@@ -61,6 +61,7 @@
 {
     //build the destination layer set
     var layerSet = "";
+    var zoomTo = false;
     var list = document.getElementById("layers");
     var layerNames = document.getElementById("layerNames");
     var count = list.options.length;
@@ -83,8 +84,16 @@
 
     var mapWidget = GetParent().Fusion.getMapByName(mapName);
     var map = mapWidget.aMaps[0];
-    var params = "mapname=" + encodeURIComponent(mapName) + "&session=" + sessionId + "&layers=" + encodeURIComponent(layerSet);
-    var options = {onSuccess: map.processQueryResults.bind(map), onFailure: selectedError, parameters:params};
+    var params = {
+      "mapname": encodeURIComponent(mapName),
+      "session": sessionId,
+      "layers": encodeURIComponent(layerSet)
+    };
+    var options = {
+      onSuccess: map.processQueryResults.bind(map, zoomTo), 
+      onFailure: selectedError, 
+      parameters:params
+    };
     GetParent().Fusion.ajaxRequest(webAgent, options);
 }
 



More information about the fusion-commits mailing list