[Mapbender-commits] r8631 - in trunk/mapbender/http: javascripts php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed May 29 03:35:34 PDT 2013


Author: armin11
Date: 2013-05-29 03:35:34 -0700 (Wed, 29 May 2013)
New Revision: 8631

Modified:
   trunk/mapbender/http/javascripts/mod_loadwmc.js
   trunk/mapbender/http/php/mod_loadwmc_server.php
   trunk/mapbender/http/php/mod_showMetadata.php
Log:
Bugfix and possibility to show a qr code for exporting a mapbender wmc to mobilemap extension from loadwmc module.

Modified: trunk/mapbender/http/javascripts/mod_loadwmc.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_loadwmc.js	2013-05-26 19:11:40 UTC (rev 8630)
+++ trunk/mapbender/http/javascripts/mod_loadwmc.js	2013-05-29 10:35:34 UTC (rev 8631)
@@ -16,6 +16,8 @@
 options.saveWmcTarget = typeof options.saveWmcTarget === "string" ? options.saveWmcTarget : "savewmc";
 options.editWmc = typeof options.editWmc === "number" ? options.editWmc : 0;
 options.showPublic = typeof options.showPublic === "number" ? options.showPublic : 0;
+options.mobileUrl = typeof options.mobileUrl === "number" ? options.mobileUrl : 0;
+options.mobileUrlNewWindow = typeof options.mobileUrlNewWindow === "number" ? options.mobileUrlNewWindow : 0;
 
 Mapbender.events.init.register(function () {
 	if(Mapbender.modules[options.saveWmcTarget] && Mapbender.modules[options.saveWmcTarget].overwrite === 1 && options.editWmc == 1) {
@@ -51,6 +53,7 @@
 	"labelEditWmc": "edit",
 	"labelOpenLayers": "OpenLayers",
 	"labelOpenLayersUrl": "Link",
+	"labelMobileUrl": "Mobile client",
 	"labelCurrentState": "currentState",
 	"labelDeleteWmc": "delete this WMC",
 	"confirmDelete": "Do you really want to delete WMC",
@@ -88,6 +91,7 @@
 	var $wmcDisplayPopup = null;
 	var $wmcOpenLayersPopup = null;
 	var $wmcOpenLayersUrlPopup = null;
+	var $wmcMobilePopup = null;
 	var wmcPopupHtml = null;
 	var wmcListTableInitialized = false;
 
@@ -144,6 +148,12 @@
 		method: "editWmc"
 	};
 
+	var MOBILEURL_WMC_OPTIONS = {
+		src: "../img/osgeo_graphics/geosilk/link.png",
+		title: translatedI18nObject.labelMobileUrl,
+		method: "getMobileUrl"
+	};
+
 	this.events = {
 		loaded: new Mapbender.Event()
 	};
@@ -258,6 +268,55 @@
 			$('.wmcOpenLayersUrlPopup').dialog('destroy');
 		}
 	};
+
+	this.showMobileUrl = function (id) {
+		this.hideMobileUrl();
+		var url = Mapbender.loginUrl;
+		url = url.replace("frames/login.php", "");
+		url = Mapbender.baseUrl + "/mapbender/";
+		url = url + "extensions/mobilemap/map.php?wmcid=" + id ;
+		//get qr code via ajax request - sync - not async!
+		var req = new Mapbender.Ajax.Request({
+			url: serverSideFileName,
+			method: "getQrCode",
+			parameters: {
+				"wmcid": id,
+				"newWindow": options.mobileUrlNewWindow
+			},
+			callback: function(obj, result, message){
+				if (!result) {
+					new Mapbender.Exception(obj.message);
+					return;
+				} else {
+					$("#mobile_url_popup").append(obj.qrCode);
+					$("#mobile_url_popup").dialog({height:200});
+				}
+			}
+		});
+		req.send();
+
+
+		var $wmcMobilePopup = $('<div id="mobile_url_popup"><input size="35" type="text" value="' + url + '"/></div>');
+		$wmcMobilePopup.dialog({
+			title: translatedI18nObject.labelMobileUrl,
+			bgiframe: true,
+			autoOpen: true,
+			modal: false,
+			width: 350,
+			height: 90,
+			pos: [600,40]
+		});
+	};
+	
+	this.hideMobileUrl = function () {
+		if($('.wmcMobilePopup').size() > 0) {
+			$('.wmcMobilePopup').dialog('destroy');
+		}
+		$('#mobile_url_popup').remove();
+	};
+
+
+
 	//end of the link-handle popup	
 	this.refreshList = function () {
 		//alert("Options showPublic: "+options.showPublic);
@@ -336,6 +395,7 @@
 				(options.showWmc ? "<th>" + t.labelShow + "</td>" : "") +
 				(options.openLayers ? "<th>" + t.labelOpenLayers + "</td>" : "") + 
 				(options.openLayersUrl ? "<th>" + t.labelOpenLayersUrl + "</td>" : "") + 
+				(options.mobileUrl ? "<th>" + t.labelMobileUrl + "</td>" : "") + 
 				(options.editWmc ? "<th>" + t.labelEditWmc + "</td>" : "") + 
 				(options.deleteWmc ? "<th>" + t.labelDelete + "</td>" : "") + 
 				"</tr></thead></table>";
@@ -532,7 +592,15 @@
 			}
 		);	
 	};
-	
+
+	var createMobileUrlWmcCell = function (wmc) {
+		return createTableCell(
+			MOBILEURL_WMC_OPTIONS, function(){
+				that.showMobileUrl(wmc.id);
+			}
+		);	
+	};
+
 	var createDisplayWmcCell = function (wmc) {
 		return createTableCell(
 			DISPLAY_WMC_OPTIONS,
@@ -646,6 +714,9 @@
 				if (options.openLayersUrl) {
 					$tr.append(createOpenLayersUrlWmcCell(currentWmc));
 				}
+				if (options.mobileUrl) {
+					$tr.append(createMobileUrlWmcCell(currentWmc));
+				}
 				if (options.editWmc) {
 					$tr.append(createEditWmcCell(currentWmc));
 				}

Modified: trunk/mapbender/http/php/mod_loadwmc_server.php
===================================================================
--- trunk/mapbender/http/php/mod_loadwmc_server.php	2013-05-26 19:11:40 UTC (rev 8630)
+++ trunk/mapbender/http/php/mod_loadwmc_server.php	2013-05-29 10:35:34 UTC (rev 8631)
@@ -5,6 +5,8 @@
 require_once(dirname(__FILE__) . "/../classes/class_wmcToXml.php");
 require_once(dirname(__FILE__) . "/../classes/class_json.php");
 require_once(dirname(__FILE__) . "/../classes/class_administration.php");
+require_once dirname(__FILE__) . "/../classes/class_Uuid.php";
+require_once(dirname(__FILE__) . "/../extensions/phpqrcode/phpqrcode.php");
 
 $ajaxResponse = new AjaxResponse($_POST);
 $json = new Mapbender_JSON();
@@ -26,6 +28,39 @@
 		$ajaxResponse->setSuccess(true);		
 	break;
 
+	// gets QR code for url 
+	case "getQrCode":
+		$wmcid = $ajaxResponse->getParameter("wmcid");
+		$newWindow = $ajaxResponse->getParameter("newWindow");
+		if ($newWindow == "1") {
+			$newWindow = true;
+		} else {
+			$newWindow = false;
+		}
+		//$e = new mb_notice("mod_loadwmc_server.php: showPublic: ".$showPublic);
+		//$resultObj["wmc"] = $wmc->selectByUser($currentUser,$showPublic);
+		//show qr for link 
+		//create uuid for qr graphic
+		$uuid = new Uuid;
+		$filename = "qr_wmc_".$uuid.".png";
+		//generate qr on the fly in tmp folder
+		//link to invoke wmc per get api if wrapper path isset
+		if (defined("MAPBENDER_PATH") && MAPBENDER_PATH != "") {
+			$invokeLink = MAPBENDER_PATH."/extensions/mobilemap/map.php?wmcid=".$wmcid;
+			//$invokeLink = "http://www.geoportal.rlp.de/mapbender/extensions/mobilemap/map.php";
+			QRcode::png($invokeLink,TMPDIR."/".$filename);
+			if ($newWindow) {
+				$html = "<a href = '".$invokeLink."' target='_blank'><img src='".TMPDIR."/".$filename."'></a>";
+			} else {
+				$html = "<a href = '".$invokeLink."'><img src='".TMPDIR."/".$filename."'></a>";
+			}
+		}
+	
+		$resultObj["qrCode"] = $html; 
+		$ajaxResponse->setResult($resultObj);
+		$ajaxResponse->setSuccess(true);		
+	break;
+
 	// gets XML document of a WMC
 	case "getWmcDocument":
 		$wmcId = $ajaxResponse->getParameter("id");

Modified: trunk/mapbender/http/php/mod_showMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_showMetadata.php	2013-05-26 19:11:40 UTC (rev 8630)
+++ trunk/mapbender/http/php/mod_showMetadata.php	2013-05-29 10:35:34 UTC (rev 8631)
@@ -1299,8 +1299,8 @@
 $capUrl = $resourceMetadata['wms_getcapabilities'].getConjunctionCharacter($resourceMetadata['wms_getcapabilities']).'REQUEST=GetCapabilities&VERSION=1.1.1&SERVICE=WMS';
 
 	//show only original url if the resource is not secured!
-	if (!$resourceSecured) {	
-		$html .= $t_a.$translation['originalCapabilities'].$t_b."<a href = '".$capUrl."' target=_blank>".$translation['capabilities']."</a>".$t_c;
+	if (!$resourceSecured) {
+		$html .= $t_a.$translation['originalCapabilities'].$t_b."<a href = '".$capUrl."' target=_blank>".$translation['capabilities']."</a> <img src='../img/osgeo_graphics/geosilk/link.png' onclick='showCapabilitiesUrl(\"".$capUrl."\",\"".$translation['mapbenderCapabilities']."\");'>".$t_c;
 	}
 
 	$html .= $t_a.$translation['inspireCapabilities'].$t_b."<a href = '../php/wms.php?layer_id=".$layerId."&PHPSESSID=".session_id()."&INSPIRE=1&REQUEST=GetCapabilities&VERSION=1.1.1&SERVICE=WMS' target=_blank>".$translation['capabilities']."</a> <img src='../img/osgeo_graphics/geosilk/link.png' onclick='showCapabilitiesUrl(\"".$mapbenderBaseUrl.$_SERVER['PHP_SELF']."/../wms.php?layer_id=".$layerId."&PHPSESSID=".session_id()."&INSPIRE=1&REQUEST=GetCapabilities&VERSION=1.1.1&SERVICE=WMS"."\",\"".$translation['inspireCapabilities']."\");'>".$t_c;



More information about the Mapbender_commits mailing list