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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Mar 8 11:18:34 EST 2012


Author: armin11
Date: 2012-03-08 08:18:34 -0800 (Thu, 08 Mar 2012)
New Revision: 8281

Modified:
   trunk/mapbender/http/geoportal/insertUserDataIntoDb.php
   trunk/mapbender/http/geoportal/mod_initialStartWmc.php
Log:
Bugfix and other handling of showing initial wmc (show newest first) - only for geoportal application

Modified: trunk/mapbender/http/geoportal/insertUserDataIntoDb.php
===================================================================
--- trunk/mapbender/http/geoportal/insertUserDataIntoDb.php	2012-03-08 16:17:33 UTC (rev 8280)
+++ trunk/mapbender/http/geoportal/insertUserDataIntoDb.php	2012-03-08 16:18:34 UTC (rev 8281)
@@ -60,10 +60,10 @@
 			$t = array('s', 's', 's', 's', 's', 's', 's', 's', 's', 'i', 's', 's', 's');
 			$res = db_prep_query($sql, $v, $t);
 	
-			$sql = "SELECT mb_group_id FROM mb_group WHERE mb_group_name = 'guest' LIMIT 1";
-			$res = db_prep_query($sql, array(), array());
-			$row = db_fetch_array($res);
-			$group_id = $row['mb_group_id'];
+			//$sql = "SELECT mb_group_id FROM mb_group WHERE mb_group_name = 'guest' LIMIT 1";
+			//$res = db_prep_query($sql, array(), array());
+			//$row = db_fetch_array($res);
+			$group_id = 37;
 			$sql = "INSERT INTO mb_user_mb_group (fkey_mb_user_id, fkey_mb_group_id) VALUES ($1, $2)";
 			$v = array($adm->getUserIdByUserName($mb_user_name), $group_id);
 			$t = array('i', 'i');

Modified: trunk/mapbender/http/geoportal/mod_initialStartWmc.php
===================================================================
--- trunk/mapbender/http/geoportal/mod_initialStartWmc.php	2012-03-08 16:17:33 UTC (rev 8280)
+++ trunk/mapbender/http/geoportal/mod_initialStartWmc.php	2012-03-08 16:18:34 UTC (rev 8281)
@@ -5,6 +5,7 @@
 db_select_db(DB,$con);
 $languageCode = 'de';
 $maxObjects = 10;
+$maxAge = 7;
 $outputFormat = 'json';
 $hostName = $_SERVER['HTTP_HOST'];
 $pathToLoadScript = '/portal/karten.html?WMC=';
@@ -33,6 +34,16 @@
         }	
 	$testMatch = NULL;
 }
+if (isset($_REQUEST["maxAge"]) & $_REQUEST["maxAge"] != "") {
+	$testMatch = $_REQUEST["maxAge"];	
+ 	$pattern = '/^[0-9]*$/';  
+        if (!preg_match($pattern,$testMatch)){
+                echo 'maxAge: <b>'.$testMatch.'</b> is not valid.<br/>';
+                die();
+        }	
+	$maxAge = (integer)$testMatch;
+	$testMatch = NULL;
+}
 if (isset($_REQUEST["languageCode"]) & $_REQUEST["languageCode"] != "") {
 	//validate to wms, wfs
 	$testMatch = $_REQUEST["languageCode"];	
@@ -77,16 +88,24 @@
 $sql .= "custom_category.custom_category_key = 'mbc1' ORDER BY search_wmc_view.load_count DESC LIMIT $1 ";
 */
 //define sql for selecting informations from database:
+//$sql = "";
+//$sql .= "SELECT search_wmc_view.wmc_serial_id,search_wmc_view.wmc_title,search_wmc_view.wmc_abstract, search_wmc_view.load_count ";
+//$sql .= "FROM search_wmc_view ORDER BY search_wmc_view.load_count DESC LIMIT $1 ";
+
 $sql = "";
-$sql .= "SELECT search_wmc_view.wmc_serial_id,search_wmc_view.wmc_title,search_wmc_view.wmc_abstract, search_wmc_view.load_count ";
-$sql .= "FROM search_wmc_view ORDER BY search_wmc_view.load_count DESC LIMIT $1 ";
-$v = array($maxObjects);
-$t = array('i');
+//select wmc_serial_id,wmc_title,wmc_abstract,CASE WHEN (wmc_timestamp  > (extract(epoch from now())- ((86400)*5))) THEN wmc_timestamp ELSE 0 END as timestamp, load_count from search_wmc_view  order by timestamp desc, load_count desc LIMIT 
+
+$sql .= "SELECT search_wmc_view.wmc_serial_id,search_wmc_view.wmc_title,search_wmc_view.wmc_abstract,";
+$sql .= " CASE WHEN (wmc_timestamp  > (extract(epoch from now())- ((86400) * $2))) THEN wmc_timestamp ELSE 0 END as timestamp,search_wmc_view.load_count ";
+$sql .= " from search_wmc_view  order by timestamp desc, load_count desc LIMIT $1";
+
+$v = array($maxObjects,$maxAge);
+$t = array('i','i');
 $res = db_prep_query($sql,$v,$t);
 $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']);
+	$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']);
 	$i++;
 }
 if ($outputFormat == 'html'){
@@ -116,7 +135,8 @@
 		$wmcJSON->initialWmcDocs[$i]->metadataUrl = $initialWmc[$i]['metadataUrl'];
 		$wmcJSON->initialWmcDocs[$i]->loadUrl = $initialWmc[$i]['loadUrl'];
 		$wmcJSON->initialWmcDocs[$i]->previewUrl = $initialWmc[$i]['previewUrl'];
-		$wmcJSON->initialWmcDocs[$i]->loadCount = 10;
+		$wmcJSON->initialWmcDocs[$i]->loadCount = $initialWmc[$i]['loadCount'];
+		$wmcJSON->initialWmcDocs[$i]->timestamp = $initialWmc[$i]['timestamp'];
    	 }
 	$wmcJSON = $classJSON->encode($wmcJSON);
 	echo $wmcJSON;



More information about the Mapbender_commits mailing list