+ var xml = new OpenLayers.Format.XML().read(data);
+
+ switch (xml.documentElement.nodeName.toLowerCase()) {
+ case "error":
+ switch (xml.documentElement.getAttribute("reason")) {
+ case "unauthorized":
+ pwdMgr.reset();
+ $("#cookie_warning").show();
+ this.reset();
+ Admin.cancelCurrentFeature();
+ Admin.reset();
+ userMgr.uninit();
+ break;
+ case "server":
+ this.commError(SypStrings.ServerError);
+ $("title").focus();
+ break;
+ case "unreferenced":
+ this.commError(SypStrings.UnreferencedError);
+ Admin.reloadLayer(Admin.dataLayer);
+ Admin.closeEditor();
+ break;
+ case "nochange":
+ this.commError(SypStrings.NochangeError);
+ Admin.closeEditor();
+ break;
+ case "request":
+ this.commError(SypStrings.RequestError);
+ $("title").focus();
+ break;
+ case "toobig":
+ this.commError(SypStrings.ToobigError);
+ $("#image_file").parent().html($("#image_file").parent().html());
+ $("#image_file").focus();
+ break;
+ case "notimage":
+ this.commError(SypStrings.NotimageError);
+ $("#image_file").parent().html($("#image_file").parent().html());
+ $("#image_file").focus();
+ break;
+ default:
+ this.commError(SypStrings.UnconsistentError);
+ $("title").focus();
+ break;
+ }
+ break;
+ case "success":
+ switch (xml.documentElement.getAttribute("request")) {
+ case "del":
+ this.commSuccess(SypStrings.DelSucces);
+ var someFeature = false;
+ var self = this;
+ $.each($(xml).find("FEATURE,feature"), function () {
+ someFeature = true;
+ var id = parseFloat($(this).find("ID:first,id:first").text());
+ if ((id === null) || isNaN (id)) {
+ return;;
+ }
+ var features = Admin.dataLayer.features;
+ for (var idx = 0; idx < features.length; idx++) {
+ if (features[idx].fid == id) {
+ Admin.dataLayer.removeFeatures([features[idx]]);
+ }
+ }
+ });
+ if (someFeature == false) {
+ this.commError(SypStrings.UnconsistentError);
+ } else {
+ Admin.closeEditor();
+ }
+ break;
+ case "update":
+ case "add":
+ var someFeature = false;
+ var self = this;
+ $.each($(xml).find("FEATURE,feature"), function () {
+ someFeature = true;
+ var id = parseFloat($(this).find("ID:first,id:first").text());
+ if ((id === null) || isNaN (id)) {
+ return;;
+ }
+
+ var lon = parseFloat($(this).find("LON:first,lon:first").text());
+ if ((typeof (lon) != "number") || isNaN (lon) ||
+ (lon < -180) || (lon > 180)) {
+ return;;
+ }
+
+ var lat = parseFloat($(this).find("LAT:first,lat:first").text());
+ if ((typeof (lat) != "number") || isNaN (lat) ||
+ (lat < -90) || (lat > 90)) {
+ return;;
+ }
+
+ var mapProj = Admin.map.getProjectionObject();
+ var lonlat = new OpenLayers.LonLat (lon, lat).
+ transform( new OpenLayers.Projection("EPSG:4326"), mapProj);
+
+ var imgurl = $(this).find("IMGURL:first,imgurl:first").text();
+ var title = $(this).find("HEADING:first,heading:first").text();
+ var description = $(this).find("DESCRIPTION:first,description:first").text();
+
+ feature = self.update (Admin.currentFeature, lonlat, imgurl, title, description);
+ feature.fid = id;
+ });
+
+ if (someFeature == false) {
+ this.commError(SypStrings.UnconsistentError);
+ } else {
+ this.commSuccess(SypStrings.UpdateSucces);
+ Admin.closeEditor();
+ }
+
+ break;
+ default:
+ this.commError(SypStrings.UnconsistentError);
+ break;
+ }
+ break;