[Mapbender-commits] r8328 - trunk/mapbender/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Apr 26 10:00:54 EDT 2012


Author: verenadiewald
Date: 2012-04-26 07:00:53 -0700 (Thu, 26 Apr 2012)
New Revision: 8328

Modified:
   trunk/mapbender/http/classes/class_twitter.php
   trunk/mapbender/http/classes/class_wms.php
Log:
changes to enable control options for twitter and georss from scheduler

Modified: trunk/mapbender/http/classes/class_twitter.php
===================================================================
--- trunk/mapbender/http/classes/class_twitter.php	2012-04-26 13:58:03 UTC (rev 8327)
+++ trunk/mapbender/http/classes/class_twitter.php	2012-04-26 14:00:53 UTC (rev 8328)
@@ -1,8 +1,6 @@
 <?php
 require_once(dirname(__FILE__)."/../../core/globalSettings.php");
-if (TWITTER_NEWS) { 
-	require_once(dirname(__FILE__)."/../../conf/twitter.conf");
-}
+require_once(dirname(__FILE__)."/../../conf/twitter.conf");
 require_once(dirname(__FILE__)."/../extensions/tmhOAuth/tmhOAuth.php");
 
 /**

Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php	2012-04-26 13:58:03 UTC (rev 8327)
+++ trunk/mapbender/http/classes/class_wms.php	2012-04-26 14:00:53 UTC (rev 8328)
@@ -12,7 +12,6 @@
 require_once dirname(__FILE__) . "/class_administration.php";
 require_once dirname(__FILE__) . "/class_georss_factory.php";
 require_once dirname(__FILE__) . "/class_mb_exception.php";
-require_once dirname(__FILE__) . "/class_twitter.php";
 require_once dirname(__FILE__) . "/../classes/class_universal_wms_factory.php";
 
 class wms {
@@ -66,14 +65,10 @@
 	var $default_epsg = 0;
 	var $overwrite = true;
 	
-
-	//GeoRSS feed
-	//
+	var $twitterNews = false;
+	var $setGeoRss = false;
+	var $geoRss;
 	var $geoRssFactory; // = new GeoRssFactory();
- 	
-	var $geoRss; //= $this->geoRssFactory->loadOrCreate(GEO_RSS_FILE);
-
-	// write a GeoRSS feed?
 	const GEORSS = true;
 	// append items to the feed when a new WMS is inserted?
 	const GEORSS_APPEND_ON_INSERT = true;
@@ -83,7 +78,16 @@
 	// and new layers have been added?
 	const GEORSS_APPEND_ON_UPDATE_NEWLAYERS = true;
 	  
-	function wms() {
+	function _construct() {
+	    if (TWITTER_NEWS) {
+    	    $this->twitterNews = true;
+    	    require_once dirname(__FILE__) . "/class_twitter.php";
+    	}
+    	
+    	if(GEO_RSS_FILE && GEO_RSS_FILE != "") {
+        	//GeoRSS feed
+    	    $this->setGeoRss = true;
+    	}
 	} 
     /**
      *
@@ -973,8 +977,8 @@
 	/**
 	 * private function
 	 */
-	function optimizeWMS() {
-		/*define defaults for wms-version 1.0.0*/
+	function optimizeWMS($layerSearchable = null) {
+	    /*define defaults for wms-version 1.0.0*/
 		$map_default_ok = false;
 		$featureinfo_default_ok = false;
 		$exception_default_ok = false;
@@ -1038,7 +1042,12 @@
 			}
 			$this->objLayer[$i]->gui_layer_minscale = $this->objLayer[$i]->layer_minscale;
 			$this->objLayer[$i]->gui_layer_maxscale = $this->objLayer[$i]->layer_maxscale;
-			$this->objLayer[$i]->layer_searchable = 1;
+			if($layerSearchable != "") {
+			    $this->objLayer[$i]->layer_searchable = $layerSearchable;
+			}
+			else {
+			    $this->objLayer[$i]->layer_searchable = 1;
+			}
 		}
 		for($i=0;$i<count($this->data_format);$i++){
 			if(mb_strtolower($this->data_type[$i]) == 'map' && mb_strtoupper($this->data_format[$i]) == mb_strtoupper($map_default)){
@@ -1543,8 +1552,11 @@
 		$admin = new administration();
 		$uuid = new Uuid();
 		$this->checkObj();
-		$this->geoRssFactory = new GeoRssFactory();
-		$this->geoRss = $this->geoRssFactory->loadOrCreate(GEO_RSS_FILE);
+		if($this->setGeoRss == true){
+		    $this->geoRssFactory = new GeoRssFactory();
+		    $this->geoRss = $this->geoRssFactory->loadOrCreate(GEO_RSS_FILE);
+		}
+		
 		db_begin();
 	
 		# TABLE wms
@@ -1661,7 +1673,7 @@
 		//$geoRssFactory = new GeoRssFactory();
 		//$geoRss = $geoRssFactory->loadOrCreate(GEO_RSS_FILE);
 		$e = new mb_notice("class_wms.php: writeObjInDB: test if geoRss maybe null!");
-		if (!is_null($this->geoRss)) {
+		if ($this->setGeoRss == true && !is_null($this->geoRss)) {
 			$e = new mb_notice("class_wms.php: writeObjInDB: geoRss was not NULL!");
 			$geoRssItem = new GeoRssItem();
 			$geoRssItem->setTitle("NEW WMS: " . $this->wms_title." (".$myWMS.")");
@@ -1686,8 +1698,8 @@
 			$this->geoRss->appendTop($geoRssItem);
 			$this->geoRss->saveAsFile();
 		}
-		if (TWITTER_NEWS == true) {
-			//new WMS
+		if ($this->twitterNews == true) {
+		    //new WMS
 			$twitter_wms = new twitter();
 			$twUuid = new Uuid();
 			//combine text for tweet
@@ -1752,8 +1764,9 @@
 			$this->insertLayerMetadataUrls($i);
 			//update messages for twitter and georss
 			$currentLayer = $this->objLayer[$i];
-			$geoRssItemNewLayer = new GeoRssItem();
-			if (!is_null($this->geoRss)) {
+			
+			if ($this->setGeoRss == true && !is_null($this->geoRss)) {
+			    $geoRssItemNewLayer = new GeoRssItem();
 				$geoRssItemNewLayer->setTitle("NEW LAYER: " . $currentLayer->layer_title." (".$currentLayer->db_id.")");
 				$geoRssItemNewLayer->setDescription($currentLayer->layer_abstract);
 				$geoRssItemNewLayer->setUrl(self::getLayerMetadataUrl($currentLayer->db_id));
@@ -1774,7 +1787,7 @@
 				}
 				$this->geoRss->appendTop($geoRssItemNewLayer);
 			}
-			if (TWITTER_NEWS == true) {
+			if ($this->twitterNews == true) {
 				//new LAYER
 				$twitter_layer = new twitter();
 				//combine text for tweet
@@ -2546,8 +2559,12 @@
 		if (!isset($this->wms_network_access) || ($this->wms_network_access == '')) {
 			$this->wms_network_access = intval('0');
 		}
-		$this->geoRssFactory = new GeoRssFactory();
-		$this->geoRss = $this->geoRssFactory->loadOrCreate(GEO_RSS_FILE);
+		
+		if ($this->setGeoRss == true) {
+		    $this->geoRssFactory = new GeoRssFactory();
+		    $this->geoRss = $this->geoRssFactory->loadOrCreate(GEO_RSS_FILE);
+		}
+		
 		$admin = new administration();
 		db_begin();
 		
@@ -2559,23 +2576,23 @@
 		$sql .= "wms_getlegendurl  = $5 ,";
 		$sql .= "wms_getcapabilities_doc = $6 ,";
 		$sql .= "wms_upload_url = $7,  ";
-		$sql .= "wms_owner = $8, ";
-		$sql .= "wms_timestamp = $9, ";
-		$sql .= "wms_supportsld = $10, ";
-		$sql .= "wms_userlayer = $11, ";
-		$sql .= "wms_userstyle = $12, ";
-		$sql .= "wms_remotewfs = $13, ";
-		$sql .= "wms_network_access = $14, ";
-		$sql .= "fkey_mb_group_id = $15, ";
-		$sql .= "uuid = $16 ";
-		$sql .= " WHERE wms_id = $17";
+		#$sql .= "wms_owner = $8, ";
+		$sql .= "wms_timestamp = $8, ";
+		$sql .= "wms_supportsld = $9, ";
+		$sql .= "wms_userlayer = $10, ";
+		$sql .= "wms_userstyle = $11, ";
+		$sql .= "wms_remotewfs = $12, ";
+		$sql .= "wms_network_access = $13, ";
+		$sql .= "fkey_mb_group_id = $14, ";
+		$sql .= "uuid = $15 ";
+		$sql .= " WHERE wms_id = $16";
 	
 		$v = array($this->wms_version,$this->wms_getcapabilities,
 			$this->wms_getmap,$this->wms_getfeatureinfo,$this->wms_getlegendurl,
-			$admin->char_encode($this->wms_getcapabilities_doc),$this->wms_upload_url,Mapbender::session()->get("mb_user_id"),strtotime("now"),
+			$admin->char_encode($this->wms_getcapabilities_doc),$this->wms_upload_url,strtotime("now"),
 			$this->wms_supportsld,$this->wms_userlayer,$this->wms_userstyle,$this->wms_remotewfs,$this->wms_network_access, $this->fkey_mb_group_id ,$this->uuid ,$myWMS);
-		$t = array('s','s','s','s','s','s','s','i','i','s','s','s','s','i','i','s','i');
-	
+		$t = array('s','s','s','s','s','s','s','i','s','s','s','s','i','i','s','i');
+			
 		$res = db_prep_query($sql,$v,$t);
 		if(!$res){
 			db_rollback();	
@@ -2602,7 +2619,6 @@
 			$sql .= "fkey_mb_group_id = $17, ";
 			$sql .= "uuid = $18 ";
 			$sql .= " WHERE wms_id = $19";
-		
 			$v = array($this->wms_title,$this->wms_abstract,$this->fees,$this->accessconstraints,
 				$this->contactperson,$this->contactposition,$this->contactorganization,$this->address,
 				$this->city,$this->stateorprovince,$this->postcode,$this->country,$this->contactvoicetelephone,
@@ -2761,8 +2777,7 @@
 		//$geoRssFactory = new GeoRssFactory();
 		//$geoRss = $geoRssFactory->loadOrCreate(GEO_RSS_FILE);
 		
-		if (!is_null($this->geoRss)) {
-
+		if ($this->setGeoRss == true && !is_null($this->geoRss)) {
 			$geoRssItem = new GeoRssItem();
 			$geoRssItem->setTitle("UPDATED WMS: " . $this->wms_title." (".$myWMS.")");
 			$geoRssItem->setDescription($this->wms_abstract);
@@ -2793,10 +2808,10 @@
 //				$geoRssItem->setUrl();
 				$this->geoRss->appendTop($geoRssItemOldLayer);
 			}
-			
+			$this->geoRss->saveAsFile();
 		}
 		//twitter out changes
-		if (TWITTER_NEWS == true) {
+		if ($this->twitterNews == true) {
 			//updated WMS
 			$twitter_wms = new twitter();
 			$twUuid = new Uuid();
@@ -2818,8 +2833,8 @@
 			}
 			
 		}
-		$this->geoRss->saveAsFile();
-		return;	
+		
+		return true;	
 	}
 
 	function updateGuiLayer($i,$myWMS,$gui_id){



More information about the Mapbender_commits mailing list