[Mapbender-commits] r7162 - trunk/mapbender/http/plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Nov 25 05:55:00 EST 2010


Author: verenadiewald
Date: 2010-11-25 02:55:00 -0800 (Thu, 25 Nov 2010)
New Revision: 7162

Added:
   trunk/mapbender/http/plugins/mb_metadata_saveWmcPreview.js
   trunk/mapbender/http/plugins/mb_metadata_wmcPreview.php
Log:
create wmc metadata editor preview images

Added: trunk/mapbender/http/plugins/mb_metadata_saveWmcPreview.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_saveWmcPreview.js	                        (rev 0)
+++ trunk/mapbender/http/plugins/mb_metadata_saveWmcPreview.js	2010-11-25 10:55:00 UTC (rev 7162)
@@ -0,0 +1,47 @@
+
+var $saveWmcPreview = $(this);
+
+var SaveWmcPreviewApi = function () {
+	var that = this;
+	var wmcId;
+	this.setWmc = function (wmc) {
+		wmcId = wmc;
+	};
+
+	this.save = function () {
+		var map = $("#mapframe1").mapbender();
+		var mapUrls = [];
+		for (var i = 0; i < map.wms.length; i++) {
+			mapUrls[i] = map.wms[i].mapURL;
+		}
+		
+		var req = new Mapbender.Ajax.Request({ 
+			url : "../plugins/mb_metadata_wmcPreview.php",
+			method: "saveWmcPreview",
+			parameters : { 
+				wmcId : wmcId,
+				mapUrls : mapUrls
+			},
+			callback: function(result, success, message) {
+				alert(message);
+			}
+		});
+		req.send();
+	};
+	
+	this.init = function () {
+		$saveWmcPreview.click(function () {
+			that.save();
+		}).mouseover(function () {
+			if (options.src) { this.src = options.src.replace(/_off/, "_over"); }
+		}).mouseout(function () {
+			if (options.src) { this.src = options.src; }
+		});
+		
+	};
+	
+	this.init();
+};
+
+$saveWmcPreview.mapbender(new SaveWmcPreviewApi());
+

Added: trunk/mapbender/http/plugins/mb_metadata_wmcPreview.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_wmcPreview.php	                        (rev 0)
+++ trunk/mapbender/http/plugins/mb_metadata_wmcPreview.php	2010-11-25 10:55:00 UTC (rev 7162)
@@ -0,0 +1,46 @@
+<?php
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/../classes/class_connector.php");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+require_once(dirname(__FILE__)."/../classes/class_stripRequest.php");
+require_once(dirname(__FILE__)."/../classes/class_weldMaps2PNG.php");
+
+$ajaxResponse  = new AjaxResponse($_REQUEST);
+
+$wmcId =  $ajaxResponse->getParameter("wmcId");
+$mapUrls = $ajaxResponse->getParameter("mapUrls");
+
+if (!$wmcId) {
+	$ajaxResponse->setSuccess(false);
+	$ajaxResponse->setMessage('wmcId not set');
+	$ajaxResponse->send();
+}
+
+if(!$mapUrls){
+	$ajaxResponse->setSuccess(false);
+	$ajaxResponse->setMessage('mapURLs not set');
+	$ajaxResponse->send();
+}
+
+switch ($ajaxResponse->getMethod()) {
+	case "saveWmcPreview":			
+		$img = new weldMaps2PNG(implode("___",$mapUrls), PREVIEW_DIR."/".$wmcId."_wmc_preview.png");
+		if(!$img) {
+			$ajaxResponse->setSuccess(false);
+			$ajaxResponse->setMessage('Preview could not be created');
+			$ajaxResponse->send();
+		} 
+		else {
+			$ajaxResponse->setSuccess(true);
+			$ajaxResponse->setMessage('Preview saved');
+			$ajaxResponse->send();
+		}
+
+		break;
+
+	default:
+		$ajaxResponse->setSuccess(false);
+		$ajaxResponse->setMessage("invalid method");
+}
+$ajaxResponse->send();
+?>
\ No newline at end of file



More information about the Mapbender_commits mailing list