[Mapbender-commits] r8667 - trunk/mapbender/http/geoportal

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Jul 1 11:28:37 PDT 2013


Author: armin11
Date: 2013-07-01 11:28:26 -0700 (Mon, 01 Jul 2013)
New Revision: 8667

Modified:
   trunk/mapbender/http/geoportal/mod_initialStartWmc.php
Log:
Enhancement to give qrcode url to initial wmc json. Then there is a possibility to start the mobile extension by code.

Modified: trunk/mapbender/http/geoportal/mod_initialStartWmc.php
===================================================================
--- trunk/mapbender/http/geoportal/mod_initialStartWmc.php	2013-07-01 18:18:27 UTC (rev 8666)
+++ trunk/mapbender/http/geoportal/mod_initialStartWmc.php	2013-07-01 18:28:26 UTC (rev 8667)
@@ -1,6 +1,8 @@
 <?php
 require_once(dirname(__FILE__)."/../../core/globalSettings.php");
 require_once(dirname(__FILE__)."/../classes/class_json.php");
+require_once dirname(__FILE__) . "/../classes/class_Uuid.php";
+require_once dirname(__FILE__) . "/../extensions/phpqrcode/phpqrcode.php";
 $con = db_connect(DBSERVER,OWNER,PW);
 db_select_db(DB,$con);
 $languageCode = 'de';
@@ -14,7 +16,7 @@
 if (isset($_REQUEST["outputFormat"]) & $_REQUEST["outputFormat"] != "") {
 	$testMatch = $_REQUEST["outputFormat"];	
  	if (!($testMatch == 'html' or $testMatch == 'json')){ 
-		echo 'outputFormat is not valid.<br/>'; 
+		echo '<b>outputFormat</b> is not valid.<br/>'; 
 		die(); 		
  	}
 	$outputFormat = $testMatch;
@@ -24,12 +26,12 @@
 	$testMatch = $_REQUEST["maxObjects"];	
  	$pattern = '/^[0-9]*$/';  
         if (!preg_match($pattern,$testMatch)){
-                echo 'maxObjects is not valid.<br/>';
+                echo '<b>maxObjects</b> is not valid.<br/>';
                 die();
         }	
 	$maxObjects = (integer)$testMatch;
 	if ($maxObjects > 15){
-                echo 'objects are too much, at maximum 15 ojects are allowed.<br/>';
+                echo '<b>Number</b> of objects are too much, at maximum 15 ojects are allowed.<br/>';
                 die();
         }	
 	$testMatch = NULL;
@@ -38,7 +40,7 @@
 	$testMatch = $_REQUEST["maxAge"];	
  	$pattern = '/^[0-9]*$/';  
         if (!preg_match($pattern,$testMatch)){
-                echo 'maxAge is not valid.<br/>';
+                echo '<b>maxAge</b> is not valid.<br/>';
                 die();
         }	
 	$maxAge = (integer)$testMatch;
@@ -48,7 +50,7 @@
 	//validate to wms, wfs
 	$testMatch = $_REQUEST["languageCode"];	
  	if (!($testMatch == 'de' or $testMatch == 'en'  or $testMatch == 'fr')){ 
-		echo 'languageCode is not valid.<br/>'; 
+		echo '<b>languageCode</b> is not valid.<br/>'; 
 		die(); 		
  	}
 	$languageCode = $testMatch;
@@ -60,7 +62,7 @@
 	//look for whitelist in mapbender.conf
 	$HOSTNAME_WHITELIST_array = explode(",",HOSTNAME_WHITELIST);
 	if (!in_array($testMatch,$HOSTNAME_WHITELIST_array)) {
-		echo "Requested hostname not in whitelist! Please control your mapbender.conf.";
+		echo "Requested <b>hostname</b> not whitelist! Please control your mapbender.conf.";
 		$e = new mb_notice("Whitelist: ".HOSTNAME_WHITELIST);
 		$e = new mb_notice("hostname not found in whitelist!");
 		die(); 	
@@ -105,7 +107,29 @@
 $initialWmc = array();
 $i = 0;
 while($row = db_fetch_array($res)){
-	$initialWmc[$i] = array('id'  =>$row['wmc_serial_id'], 'title' =>$row['wmc_title'], 'abstract' =>$row['wmc_abstract'],'loadUrl'=>'http://'.$hostName.$pathToLoadScript.$row['wmc_serial_id'],'metadataUrl'=>'http://'.$hostName.$pathToMetadata."languageCode=".$languageCode."&resource=wmc&id=".$row['wmc_serial_id'], 'previewUrl'=>'http://'.$hostName.$pathToPreview."resource=wmc&id=".$row['wmc_serial_id'],'timestamp' => $row['timestamp'],'loadCount' => $row['load_count']);
+	$mobileUrl = $row['wmc_serial_id'];
+	//$uuid = new Uuid;
+	$filename = "qr_wmc_".$row['wmc_serial_id'].".png";
+	//generate qr on the fly in tmp folder if not already exists
+	//check if exists
+	if (file_exists(TMPDIR."/".$filename)) {
+    		$mobileUrl = MAPBENDER_PATH."/extensions/mobilemap/map.php?wmcid=".$row['wmc_serial_id'];
+		$mobileQrImageUrl = MAPBENDER_PATH."/tmp/".$filename;
+	} else {
+    		//link to invoke wmc per get api if wrapper path isset
+		if (defined("MAPBENDER_PATH") && MAPBENDER_PATH != "") {
+			$mobileUrl = MAPBENDER_PATH."/extensions/mobilemap/map.php?wmcid=".$row['wmc_serial_id'];
+			//$invokeLink = "http://www.geoportal.rlp.de/mapbender/extensions/mobilemap/map.php";
+			QRcode::png($mobileUrl,TMPDIR."/".$filename);
+			$mobileQrImageUrl = MAPBENDER_PATH."/tmp/".$filename;
+		} else {
+			$mobileUrl = "";
+			$mobileQrImageUrl = "";
+		}
+	}
+	$initialWmc[$i] = array('id'  =>$row['wmc_serial_id'], 'title' =>$row['wmc_title'], 'abstract' =>$row['wmc_abstract'],'loadUrl'=>'http://'.$hostName.$pathToLoadScript.$row['wmc_serial_id'],'metadataUrl'=>'http://'.$hostName.$pathToMetadata."languageCode=".$languageCode."&resource=wmc&id=".$row['wmc_serial_id'], 'previewUrl'=>'http://'.$hostName.$pathToPreview."resource=wmc&id=".$row['wmc_serial_id'],'timestamp' => $row['timestamp'],'loadCount' => $row['load_count'], 'mobileUrl' => $mobileUrl, 'mobileQrImageUrl' => $mobileQrImageUrl);
+	//generate qr images
+	
 	$i++;
 }
 if ($outputFormat == 'html'){
@@ -137,6 +161,8 @@
 		$wmcJSON->initialWmcDocs[$i]->previewUrl = $initialWmc[$i]['previewUrl'];
 		$wmcJSON->initialWmcDocs[$i]->loadCount = $initialWmc[$i]['loadCount'];
 		$wmcJSON->initialWmcDocs[$i]->timestamp = $initialWmc[$i]['timestamp'];
+		$wmcJSON->initialWmcDocs[$i]->mobileUrl = $initialWmc[$i]['mobileUrl'];
+		$wmcJSON->initialWmcDocs[$i]->mobileQrImageUrl = $initialWmc[$i]['mobileQrImageUrl'];
    	 }
 	$wmcJSON = $classJSON->encode($wmcJSON);
 	echo $wmcJSON;



More information about the Mapbender_commits mailing list