[Mapbender-commits] r9050 - in trunk/mapbender/http: classes plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Aug 20 06:29:24 PDT 2014


Author: verenadiewald
Date: 2014-08-20 06:29:24 -0700 (Wed, 20 Aug 2014)
New Revision: 9050

Modified:
   trunk/mapbender/http/classes/class_wms_owsproxy_log.php
   trunk/mapbender/http/plugins/mb_owsproxy_log_csv.php
Log:
query type "getServiceLogs": Show only a summarized view of logs in table, list complete query result in csv file

Modified: trunk/mapbender/http/classes/class_wms_owsproxy_log.php
===================================================================
--- trunk/mapbender/http/classes/class_wms_owsproxy_log.php	2014-08-13 09:25:02 UTC (rev 9049)
+++ trunk/mapbender/http/classes/class_wms_owsproxy_log.php	2014-08-20 13:29:24 UTC (rev 9050)
@@ -149,7 +149,7 @@
             ." FROM mb_proxy_log AS m INNER JOIN wms AS w ON"
             		." (m.fkey_wms_id = w.wms_id AND w.wms_owner=$1"
             		.$wmsIdWhere." AND m.proxy_log_timestamp >= $2"
-                    ." AND m.proxy_log_timestamp <= $3)".$join
+            				." AND m.proxy_log_timestamp <= $3)".$join
             				." ". $groupByForDisplay;
             
             $result = db_prep_query($sql,$v,$t);
@@ -170,7 +170,7 @@
                         .",u.mb_user_city";
                 $join .= " INNER JOIN mb_user AS u  ON (u.mb_user_id = m.fkey_mb_user_id)";
                 $groupByForDisplay = " GROUP BY m.fkey_wms_id, w.wms_title,w.wms_version,w.wms_abstract,u.mb_user_firstname,mb_user_lastname,u.mb_user_department,u.mb_user_description,u.mb_user_email,u.mb_user_phone,u.mb_user_street,u.mb_user_housenumber,u.mb_user_postal_code,u.mb_user_city ORDER BY m.fkey_wms_id DESC";
-            }
+            }            
             
             $v = array($this->timeFrom, $this->timeTo, $this->mb_user_id);
             $t = array("t", "t", "i");
@@ -197,7 +197,7 @@
                     ." AND m.proxy_log_timestamp <= $2".$wmsIdWhere.")".$join;
 		    
             $sqlDisplay  = "SELECT".$selectColumnsDisplay
-                    ." FROM mb_proxy_log AS m INNER JOIN wms AS w ON"
+					." FROM mb_proxy_log AS m INNER JOIN wms AS w ON"
                     ." (m.fkey_wms_id = w.wms_id AND w.wms_owner=$3"
                     .$userWhere." AND m.proxy_log_timestamp >= $1"
                     ." AND m.proxy_log_timestamp <= $2".$wmsIdWhere.")".$join
@@ -333,43 +333,43 @@
     }
     
     private function readResult($result){
-        $offsetPixel = null;
-        $offsetPrice = null;
-        $sumPixel = 0;
-        $sumPrice = 0;
-        if ($result != false) {
-            $num_fields = pg_num_fields($result);
-            for ( $i = 0; $i < $num_fields; $i++ ){
-                $field_name = pg_field_name($result , $i);
-                $this->resultHeader[] = $field_name;
-
-                // keep offsets of prixel and price row
-                if($field_name === "pixel")        $offsetPixel = $i;
-                else if($field_name === "price")   $offsetPrice = $i;
-            }
-        }
-        $i = 0;
-        while($row = db_fetch_row($result)){
-            foreach( $row as $key=>$value){
-                $this->resultData[$i][] = $value;
-
-                if($key == $offsetPixel)        $sumPixel += $value;
-                else if($key == $offsetPrice)   $sumPrice += $value;
-            }
-
-            $i++;
-        }
-
-        if(!is_null($offsetPixel) || !is_null($offsetPrice)) {
-            for($j=0;$j<$num_fields;$j++) {
+    	$offsetPixel = null;
+    	$offsetPrice = null;
+    	$sumPixel = 0;
+    	$sumPrice = 0;
+    	if ($result != false) {
+    		$num_fields = pg_num_fields($result);
+    		for ( $i = 0; $i < $num_fields; $i++ ){
+    			$field_name = pg_field_name($result , $i);
+    			$this->resultHeader[] = $field_name;
+    			    
+    			// keep offsets of prixel and price row
+    			if($field_name === "pixel")        $offsetPixel = $i;
+    			else if($field_name === "price")   $offsetPrice = $i;
+    		}
+    	}
+    	$i = 0;
+    	while($row = db_fetch_row($result)){
+    		foreach( $row as $key=>$value){
+    			$this->resultData[$i][] = $value;
+    			    
+    			if($key == $offsetPixel)        $sumPixel += $value;
+    			else if($key == $offsetPrice)   $sumPrice += $value;
+    		}
+    
+    		$i++;
+    	}
+    
+    	if(!is_null($offsetPixel) || !is_null($offsetPrice)) {
+    		for($j=0;$j<$num_fields;$j++) {
     			if($j == $offsetPixel && !is_null($offsetPixel)) {
-                    $this->resultData[$i][] = (string)$sumPixel;
+    				$this->resultData[$i][] = (string)$sumPixel;
     			}
     			else if($j == $offsetPrice && !is_null($offsetPrice)) {
-                    $this->resultData[$i][] = (string)$sumPrice;
+    				$this->resultData[$i][] = (string)$sumPrice;
     			}
     			else {
-                    $this->resultData[$i][] = '---';
+    				$this->resultData[$i][] = '---';
     			}
     		}
     	}
@@ -414,7 +414,7 @@
         		else {
         			$this->resultDataDisplay[$i][] = '---';
         		}
-            }
+        	}
         }
     }
     
@@ -444,16 +444,29 @@
         return $header.WmsOwsLogCsv::$SEPARATOR_ROW.$data;
     }
     
-    public function getAsArray(){
-        return array(
-            "function"=> $this->function,
-            "header"=> $this->resultHeader,
-        	"headerDisplay"=> $this->resultHeaderDisplay,
-            "data" => $this->resultData,
-        	"dataDisplay" => $this->resultDataDisplay,
-            "message" => $this->resultMessage,
-            "error" => "",
-            "limit" => WmsOwsLogCsv::$LIMIT_INT);
+    public function getAsArray($function=null) {
+    	if($function == "getServiceLogs") {
+    		return array(
+    				"function"=> $this->function,
+    				"header"=> $this->resultHeader,
+    				"headerDisplay"=> $this->resultHeaderDisplay,
+    				"data" => $this->resultData,
+    				"dataDisplay" => $this->resultDataDisplay,
+    				"message" => $this->resultMessage,
+    				"error" => "",
+    				"limit" => WmsOwsLogCsv::$LIMIT_INT);
+    	}
+    	else {
+	        return array(
+	            "function"=> $this->function,
+	            "header"=> $this->resultHeader,
+	        	"headerDisplay"=> $this->resultHeaderDisplay,
+	            "data" => $this->resultData,
+	        	"dataDisplay" => $this->resultDataDisplay,
+	            "message" => $this->resultMessage,
+	            "error" => "",
+	            "limit" => WmsOwsLogCsv::$LIMIT_INT);
+    	}
     }
 }
 ?>

Modified: trunk/mapbender/http/plugins/mb_owsproxy_log_csv.php
===================================================================
--- trunk/mapbender/http/plugins/mb_owsproxy_log_csv.php	2014-08-13 09:25:02 UTC (rev 9049)
+++ trunk/mapbender/http/plugins/mb_owsproxy_log_csv.php	2014-08-20 13:29:24 UTC (rev 9050)
@@ -174,7 +174,7 @@
             $wmslog = WmsOwsLogCsv::create($mb_user_id, $function, $userId, $wmsId,
                 $listType, $timeFrom, $timeTo, $withContactData);
             $wmslog->handle();
-            print json_encode($wmslog->getAsArray());
+            print json_encode($wmslog->getAsArray($function));
             die();
         }
     } else {



More information about the Mapbender_commits mailing list