[Mapbender-commits] r4650 - in trunk/mapbender: conf http/classes http/php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Sep 17 11:25:23 EDT 2009


Author: christoph
Date: 2009-09-17 11:25:23 -0400 (Thu, 17 Sep 2009)
New Revision: 4650

Modified:
   trunk/mapbender/conf/mapbender.conf-dist
   trunk/mapbender/http/classes/class_administration.php
   trunk/mapbender/http/classes/class_georss.php
   trunk/mapbender/http/classes/class_georss_factory.php
   trunk/mapbender/http/classes/class_rss.php
   trunk/mapbender/http/classes/class_rss_factory.php
   trunk/mapbender/http/classes/class_rss_item.php
   trunk/mapbender/http/classes/class_universal_rss_factory.php
   trunk/mapbender/http/classes/class_wms.php
   trunk/mapbender/http/php/mod_deleteWMS.php
Log:
http://trac.osgeo.org/mapbender/ticket/533

Modified: trunk/mapbender/conf/mapbender.conf-dist
===================================================================
--- trunk/mapbender/conf/mapbender.conf-dist	2009-09-17 15:23:16 UTC (rev 4649)
+++ trunk/mapbender/conf/mapbender.conf-dist	2009-09-17 15:25:23 UTC (rev 4650)
@@ -162,6 +162,12 @@
 define("LANGUAGE", "en");   // only available if USE_I18N is "true". 
 							// "en", "de", "bg", "gr", "nl", "hu", "it", "es","fr","pt"
 
+# --------------------------------------------
+# RSS
+# --------------------------------------------
+define("GEO_RSS_FILE", "../tmp/georss.xml");
+
+
 ###HACK for GLOBALS
 $DBSERVER=DBSERVER;
   $DB=DB;

Modified: trunk/mapbender/http/classes/class_administration.php
===================================================================
--- trunk/mapbender/http/classes/class_administration.php	2009-09-17 15:23:16 UTC (rev 4649)
+++ trunk/mapbender/http/classes/class_administration.php	2009-09-17 15:25:23 UTC (rev 4650)
@@ -1454,6 +1454,36 @@
 			
 			return $r;		
 	}
-	 
+	
+	public static function saveFile ($fullFilename, $content) {
+		if (file_exists($fullFilename)) {
+			if (!is_writable($fullFilename)) {
+				$e = new mb_exception(__FILE__ . 
+					": saveAsFile(): File not writable: " . $fullFilename);
+				return false;
+			}
+		}
+		else {
+			$parts = pathinfo($fullFilename);
+			if (!is_writable($parts["dirname"])) {
+				$e = new mb_exception(__FILE__ . 
+					": saveAsFile(): Folder not writable: " . 
+					$parts["dirname"]);
+				return false;
+			}
+		}
+		
+		if($h = fopen($fullFilename,"w")){
+			if(!fwrite($h, $content)){
+				$e = new mb_exception(__FILE__ . 
+					": saveAsFile(): failed to write file: " . $fullFilename);
+				return false;
+			}
+			fclose($h);
+		}
+		$e = new mb_notice(__FILE__ . 
+			": saveAsFile(): saving RSS at " . $fullFilename);
+		return true;		
+	} 
 }
 ?>

Modified: trunk/mapbender/http/classes/class_georss.php
===================================================================
--- trunk/mapbender/http/classes/class_georss.php	2009-09-17 15:23:16 UTC (rev 4649)
+++ trunk/mapbender/http/classes/class_georss.php	2009-09-17 15:25:23 UTC (rev 4650)
@@ -14,6 +14,10 @@
  */
 class GeoRss extends Rss {
 	
+	protected function createItem () {
+		return new GeoRssItem();
+	}
+	
 	protected function getNamespaceString () {
 		return parent::getNamespaceString() . 
 			' xmlns:georss="http://www.georss.org/georss"';

Modified: trunk/mapbender/http/classes/class_georss_factory.php
===================================================================
--- trunk/mapbender/http/classes/class_georss_factory.php	2009-09-17 15:23:16 UTC (rev 4649)
+++ trunk/mapbender/http/classes/class_georss_factory.php	2009-09-17 15:25:23 UTC (rev 4650)
@@ -11,28 +11,15 @@
 
 class GeoRssFactory extends RssFactory {
 
-	public function createFromUrl ($url) {
-		$rss = $this->parseDocument($url, new GeoRss());
-		if (is_null($rss)) {
-			return null;
-		}
-		return $this->parseItems($url, $rss);
-	}
-	
-	protected function parseItems ($url, $rss) {
-		$domxpath = $this->createDomXpathFromUrl($url, $rss);
-		if (is_null($domxpath)) {
-			return null;
-		}
-		
-		$nodeList = $domxpath->query("/rss/channel/item");
-		foreach ($nodeList as $node) {
-			$item = new GeoRssItem();
-			$item = $this->parseItem($node, $item);
-			$rss->append($item);
-		}
+	protected function createRss () {
+		$rss = new GeoRss();
 		return $rss;
 	}
+
+	protected function createRssItem () {
+		$rssItem = new GeoRssItem();
+		return $rssItem;
+	}
 	
 	protected function parseItem ($node, $item) {
 		

Modified: trunk/mapbender/http/classes/class_rss.php
===================================================================
--- trunk/mapbender/http/classes/class_rss.php	2009-09-17 15:23:16 UTC (rev 4649)
+++ trunk/mapbender/http/classes/class_rss.php	2009-09-17 15:25:23 UTC (rev 4650)
@@ -6,13 +6,16 @@
 # http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
 
 require_once dirname(__FILE__) . "/../../core/globalSettings.php";
+require_once dirname(__FILE__) . "/../classes/class_administration.php";
 require_once dirname(__FILE__) . "/../classes/class_rss_item.php";
 
 /**
  * Creates an RSS Feed.
  */
 class Rss {
-    var $channel_url;
+    var $filename;
+	
+	var $channel_url;
     var $channel_title;
     var $channel_description;
     var $channel_lang;
@@ -26,18 +29,44 @@
 	
 	const MAX_ENTRIES = 10;
 	
-	public function append ($item) {
+	protected function createItem () {
+		return new RssItem();
+	}
+	
+	public function append () {
+		if (func_num_args() === 0) {
+			$item = $this->createItem();
+		}
+		else {
+			$item = func_get_arg(0);
+		}
 		$this->items[]= $item;
 		$this->nritems++;
+		return $item;
 	}
 	
+	public function saveAsFile() {
+		if (func_num_args() === 1) {
+			$pathAndFilename = func_get_arg(0);
+		}
+		else {
+			if ($this->filename) {
+				$pathAndFilename = $this->filename;
+			}
+			else {
+				new mb_exception(__FILE__ . 
+					": saveAsFile(): must specify a filename!");
+				return false;
+			}
+		}
+		return administration::saveFile($pathAndFilename, $this->__toString());
+	}	
 	
-	
     public function __construct() {
         $this->nritems=0;
-        $this->channel_url='';
-        $this->channel_title='';
-        $this->channel_description='';
+        $this->channel_url=LOGIN;
+        $this->channel_title="Mapbender GeoRSS";
+        $this->channel_description="New and updated WMS";
         $this->channel_lang='';
         $this->channel_copyright='';
         $this->channel_date='';
@@ -46,6 +75,18 @@
         $this->image_url='';
     }   
 	
+	public function setTitle ($title) {
+        $this->channel_title=$title;
+	}
+	
+	public function setDescription ($description) {
+        $this->channel_description=$description;
+	}
+	
+	public function setUrl ($url) {
+        $this->channel_url=$url;
+	}
+	
     public function setChannel($url, $title, $description, $lang, $copyright, $creator, $subject) {
         $this->channel_url=$url;
         $this->channel_title=$title;
@@ -115,10 +156,10 @@
 #        $output .= '</rdf:Seq>'."\n";
 #        $output .= '</items>'."\n";
 #        $output .= '<image rdf:resource="'.$this->image_url.'"/>'."\n";
-        $output .= '</channel>'."\n";
         for($k=0; $k<$this->nritems; $k++) {
             $output .= $this->items[$k];  
         };
+        $output .= '</channel>'."\n";
 //        $output .= '</rdf:RDF>'."\n";
         $output .= '</rss>'."\n";
         return $output;

Modified: trunk/mapbender/http/classes/class_rss_factory.php
===================================================================
--- trunk/mapbender/http/classes/class_rss_factory.php	2009-09-17 15:23:16 UTC (rev 4649)
+++ trunk/mapbender/http/classes/class_rss_factory.php	2009-09-17 15:25:23 UTC (rev 4650)
@@ -10,11 +10,42 @@
 
 class RssFactory {
 
+	protected function createRss () {
+		$rss = new Rss();
+		return $rss;
+	}
+
+	protected function createRssItem () {
+		$rssItem = new RssItem();
+		return $rssItem;
+	}
+
+	public function loadOrCreate ($pathAndFilename) {
+		$rss = $this->createFromUrl($pathAndFilename);
+		if (is_null($rss)) {
+			$rss = $this->createAt($pathAndFilename);
+			if (is_null($rss)) {
+				return null;
+			}
+		}
+		return $rss;
+	}
+		
+	public function createAt ($pathAndFilename) {
+		$rss = $this->createRss();
+		if ($rss->saveAsFile($pathAndFilename)) {
+			$rss->filename = $pathAndFilename;
+			return $rss;
+		};
+		return null;
+	}
+
 	public function createFromUrl ($url) {
-		$rss = $this->parseDocument($url, new Rss());
+		$rss = $this->parseDocument($url, $this->createRss());
 		if (is_null($rss)) {
 			return null;
 		}
+		$rss->filename = $url;
 		return $this->parseItems($url, $rss);
 	}
 	
@@ -70,7 +101,7 @@
 		
 		$nodeList = $domxpath->query("/rss/channel/item");
 		foreach ($nodeList as $node) {
-			$item = new RssItem();
+			$item = $this->createRssItem();
 			$item = $this->parseItem($node, $item);
 			$rss->append($item);
 		}

Modified: trunk/mapbender/http/classes/class_rss_item.php
===================================================================
--- trunk/mapbender/http/classes/class_rss_item.php	2009-09-17 15:23:16 UTC (rev 4649)
+++ trunk/mapbender/http/classes/class_rss_item.php	2009-09-17 15:25:23 UTC (rev 4650)
@@ -42,9 +42,9 @@
 	protected function getItemString () {
         return '<title>' . $this->title . '</title>' . "\n" . 
 			'<link>' . htmlentities($this->url, ENT_QUOTES, CHARSET) . '</link>' . "\n" . 
-			'<description>' . $this->description . '</description>' . "\n" . 
+			'<description>' . $this->description . '</description>' . "\n";
 //			'<feedburner:origLink>' . $this->url . '</feedburner:origLink>' . 
-			"\n";
+//			"\n";
 	}
 }
 ?>
\ No newline at end of file

Modified: trunk/mapbender/http/classes/class_universal_rss_factory.php
===================================================================
--- trunk/mapbender/http/classes/class_universal_rss_factory.php	2009-09-17 15:23:16 UTC (rev 4649)
+++ trunk/mapbender/http/classes/class_universal_rss_factory.php	2009-09-17 15:25:23 UTC (rev 4650)
@@ -17,20 +17,19 @@
 		$success = $dom->load($url);
 		if (!$success) {
 			new mb_exception(__FILE__ . ": createFromUrl(): Could not load " . $url);
-			return false;
+			return null;
 		}
 
-		$domxpath = new DOMXPath($dom);		
-		$nodeList = $domxpath->query("/rss/channel/item/georss:box");
-
+		$nodeList = $dom->getElementsByTagName("rss");
 		if ($nodeList->length > 0) {
-			$geoRssFactory = new GeoRssFactory();
-			return $geoRssFactory->createFromUrl($url);
+			$node = $nodeList->item(0);
+			if ($node->hasAttribute("xmlns:georss")) {
+				$geoRssFactory = new GeoRssFactory();
+				return $geoRssFactory->createFromUrl($url);
+			}
 		}
-		else {
-			$rssFactory = new RssFactory();
-			return $rssFactory->createFromUrl($url);
-		}
+		$rssFactory = new RssFactory();
+		return $rssFactory->createFromUrl($url);
 	}
 }
 

Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php	2009-09-17 15:23:16 UTC (rev 4649)
+++ trunk/mapbender/http/classes/class_wms.php	2009-09-17 15:25:23 UTC (rev 4650)
@@ -21,6 +21,7 @@
 require_once(dirname(__FILE__)."/class_connector.php");
 require_once(dirname(__FILE__)."/class_user.php");
 require_once(dirname(__FILE__)."/class_administration.php");
+require_once(dirname(__FILE__)."/class_georss_factory.php");
 
 class wms {
 	var $lastURL;
@@ -69,10 +70,28 @@
 	  
 	var $default_epsg = 0;
 	var $overwrite = true;
+	
+	// write a GeoRSS feed?
+	const GEORSS = true;
+	// append items to the feed when a new WMS is inserted?
+	const GEORSS_APPEND_ON_INSERT = true;
+	// append items to the feed when an existing WMS is updated?
+	const GEORSS_APPEND_ON_UPDATE = true;
+	// append items to the feed only when an existing WMS is updated 
+	// and new layers have been added?
+	const GEORSS_APPEND_ON_UPDATE_NEWLAYERS = true;
 	  
 	function wms() {
 	} 
 
+	public static function getWmsMetadataUrl ($wmsId) {
+		return preg_replace(
+			"/(.*)frames\/login.php/", 
+			"$1php/mod_layerMetadata.php?id=", 
+			LOGIN
+		) . $wmsId;
+	}
+
 	public static function isOwsProxyUrl ($getmap) {
 //		$e = new mb_notice("isOwsProxyUrl? " . $getmap);
 		$result = preg_match("/^.*owsproxy.([^i][\w\d]+)\/([\w\d]{32})\/?.*$/", $getmap);
@@ -738,7 +757,7 @@
 				
 				if(mb_strtoupper($element[tag]) == "SRS"){
 					// unique srs only, see http://www.mapbender.org/index.php/Arrays_with_unique_entries
-					$this->wms_srs = array_keys(array_flip(array_merge($this->wms_srs, explode(" ", $element[value]))));
+					$this->wms_srs = array_keys(array_flip(array_merge($this->wms_srs, explode(" ", strtoupper($element[value])))));
 				}						      
 				if(mb_strtoupper($element[tag]) == "LATLONBOUNDINGBOX"){
 					$cnt_epsg++;
@@ -1270,7 +1289,7 @@
 	function writeObjInDB($gui_id){
 		global $con;
 		if (func_num_args() == 2) { //new for HTTP Authentication
-            		$auth = func_get_arg(1);
+			$auth = func_get_arg(1);
 			$username = $auth['username'];
 			$password = $auth['password'];
 			$authType = $auth['auth_type'];
@@ -1293,17 +1312,47 @@
 		$sql .= "wms_owner,wms_timestamp,wms_username,wms_password,wms_auth_type,";
 		$sql .= "wms_supportsld, wms_userlayer, wms_userstyle, wms_remotewfs) ";
 		$sql .= "VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31)";
-		$v = array($this->wms_version,$this->wms_title,$this->wms_abstract,$this->wms_getcapabilities,
-			$this->wms_getmap,$this->wms_getfeatureinfo,$this->wms_getlegendurl,$admin->char_encode($this->wms_getcapabilities_doc),
-			$this->wms_upload_url,$this->fees,$this->accessconstraints,$this->contactperson,$this->contactposition,
-			$this->contactorganization,$this->address,$this->city,$this->stateorprovince,$this->postcode,$this->country,
-			$this->contactvoicetelephone,$this->contactfacsimiletelephone,$this->contactelectronicmailaddress,
-			Mapbender::session()->get('mb_user_id'),strtotime("now"),$username,$password,$authType,
-			$this->wms_supportsld,$this->wms_userlayer,$this->wms_userstyle,$this->wms_remotewfs );
-		$t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','i','i','s','s','s','s','s','s','s');
+		$v = array(
+			$this->wms_version,
+			$this->wms_title,
+			$this->wms_abstract,
+			$this->wms_getcapabilities,
+			$this->wms_getmap,
+			$this->wms_getfeatureinfo,
+			$this->wms_getlegendurl,
+			$admin->char_encode($this->wms_getcapabilities_doc),
+			$this->wms_upload_url,
+			$this->fees,
+			$this->accessconstraints,
+			$this->contactperson,
+			$this->contactposition,
+			$this->contactorganization,
+			$this->address,
+			$this->city,
+			$this->stateorprovince,
+			$this->postcode,
+			$this->country,
+			$this->contactvoicetelephone,
+			$this->contactfacsimiletelephone,
+			$this->contactelectronicmailaddress,
+			Mapbender::session()->get('mb_user_id'),
+			strtotime("now"),
+			$username,
+			$password,
+			$authType,
+			$this->wms_supportsld,
+			$this->wms_userlayer,
+			$this->wms_userstyle,
+			$this->wms_remotewfs
+		);
+		$t = array(
+			's','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s',
+			's','s','s','s','s','s','i','i','s','s','s','s','s','s','s'
+		);
 		$res = db_prep_query($sql,$v,$t);
 		if(!$res){
 			db_rollback();
+			return null;
 		}
 		
 		$myWMS = db_insert_id($con,'wms', 'wms_id');
@@ -1334,22 +1383,62 @@
 		$v = array($gui_id);
 		$t = array('s');
 		$res = db_prep_query($sql,$v,$t);
-		if(db_result($res, 0,"pos") > -1){
+		if (db_result($res, 0,"pos") > -1) {
 			$position = db_result($res, 0,"pos") + 1;
-		} else{ $position = 0; }
+		} 
+		else { 
+			$position = 0; 
+		}
 		
 		$sql ="INSERT INTO gui_wms (fkey_gui_id, fkey_wms_id, gui_wms_position, gui_wms_mapformat, ";
 		$sql .= "gui_wms_featureinfoformat, gui_wms_exceptionformat, gui_wms_epsg)";
 		$sql .= "VALUES($1,$2,$3,$4,$5,$6,$7)";
-		$v = array($gui_id,$myWMS,$position,$this->gui_wms_mapformat,$this->gui_wms_featureinfoformat,
-				$this->gui_wms_exceptionformat,$this->gui_wms_epsg
-				);
+		$v = array(
+			$gui_id,
+			$myWMS,
+			$position,
+			$this->gui_wms_mapformat,
+			$this->gui_wms_featureinfoformat,
+			$this->gui_wms_exceptionformat,
+			$this->gui_wms_epsg
+		);
 		$t = array('s','i','i','s','s','s','s');
 		$res = db_prep_query($sql,$v,$t);
 		if(!$res){
 			db_rollback();	
+			return null;
 		}
 		db_commit();
+
+		//
+		// update GeoRSS feed
+		//
+		$geoRssFactory = new GeoRssFactory();
+		$geoRss = $geoRssFactory->loadOrCreate(GEO_RSS_FILE);
+		if (!is_null($geoRss)) {
+			$geoRssItem = new GeoRssItem();
+			$geoRssItem->setTitle("NEW: " . $this->wms_title);
+			$geoRssItem->setDescription($this->wms_abstract);
+			$geoRssItem->setUrl(self::getWmsMetadataUrl($myWMS));
+
+			for ($j = 0; $j < count($this->objLayer[0]->layer_epsg); $j++) {
+				$currentEpsg = $this->objLayer[0]->layer_epsg[$j];
+				if ($currentEpsg["epsg"] === "EPSG:4326") {
+					$currentBbox = new Mapbender_bbox(
+						$currentEpsg["minx"],
+						$currentEpsg["miny"],
+						$currentEpsg["maxx"],
+						$currentEpsg["maxy"],
+						$currentEpsg["epsg"]
+					);
+					$geoRssItem->setBbox($currentBbox);
+					break;
+				}
+			}
+
+			$geoRss->append($geoRssItem);
+			$geoRss->saveAsFile();
+		}
 	    
 	    #Changes JW
 	    $this->wms_id = $myWMS;
@@ -1702,6 +1791,29 @@
 		$this->update_gui_wms($myWMS);
 		
 		# update TABLE layer	
+		$oldLayerNameArray = array();
+		$v = array($myWMS);
+		$t = array('i');
+		$c = 2;
+		$sql = "SELECT layer_name, layer_title, layer_abstract FROM layer WHERE fkey_wms_id = $1 AND NOT layer_name IN(";
+		for($i=0; $i<count($this->objLayer); $i++){
+			if($i>0){$sql .= ',';}
+			$sql .= "$".$c;
+			array_push($v,$this->objLayer[$i]->layer_name);
+			array_push($t,'s');		
+			$c++;
+		}
+		$sql .= ")";
+		$res = db_prep_query($sql,$v,$t);
+		while ($row = db_fetch_array($res)) {
+			$oldLayerNameArray[]= array(
+				"name" => $row["layer_name"],
+				"title" => $row["layer_title"],
+				"abstract" => $row["layer_abstract"]
+			);
+			
+		}
+		
 		# delete all layer which are outdated
 		$v = array($myWMS);
 		$t = array('i');
@@ -1739,7 +1851,7 @@
 		while($row = db_fetch_array($res)){
 			array_push($exGui,$row["fkey_gui_id"]);
 		}
-		
+		$newLayerArray = array();
 		for($i=0; $i<count($this->objLayer); $i++){
 			if(in_array($this->objLayer[$i]->layer_name,$exLayer)){
 				//echo "<br>update: ".$this->objLayer[$i]->layer_name;
@@ -1751,14 +1863,76 @@
 			else{
 				//echo "<br>append: ".$this->objLayer[$i]->layer_name;
 				$this->insertLayer($i,$myWMS);
+				$newLayerArray[]= $i;
 				for($j=0; $j<count($exGui); $j++){
 					$this->appendGuiLayer($i,$myWMS,$exGui[$j]);
 				}
 			}
 		}
 		db_commit();
+		//
+		// update GeoRSS feed
+		//
+		$geoRssFactory = new GeoRssFactory();
+		$geoRss = $geoRssFactory->loadOrCreate(GEO_RSS_FILE);
+		
+		if (!is_null($geoRss)) {
+
+			$geoRssItem = new GeoRssItem();
+			$geoRssItem->setTitle("UPDATED WMS: " . $this->wms_title);
+			$geoRssItem->setDescription($this->wms_abstract);
+			$geoRssItem->setUrl(self::getWmsMetadataUrl($myWMS));
+			for ($j = 0; $j < count($this->objLayer[0]->layer_epsg); $j++) {
+				$currentEpsg = $this->objLayer[0]->layer_epsg[$j];
+				if ($currentEpsg["epsg"] === "EPSG:4326") {
+					$currentBbox = new Mapbender_bbox(
+						$currentEpsg["minx"],
+						$currentEpsg["miny"],
+						$currentEpsg["maxx"],
+						$currentEpsg["maxy"],
+						$currentEpsg["epsg"]
+					);
+					$geoRssItem->setBbox($currentBbox);
+					break;
+				}
+			}
+			$geoRss->append($geoRssItem);
+
+			foreach ($newLayerArray as $newLayer) {
+				$currentLayer = $this->objLayer[$newLayer];
+				$geoRssItem = new GeoRssItem();
+				$geoRssItem->setTitle("ADDED LAYER: " . $currentLayer->layer_title);
+				$geoRssItem->setDescription($currentLayer->layer_abstract);
+				$geoRssItem->setUrl(layer::getLayerMetadataUrl($currentLayer->layer_id));
+				
+				for ($j = 0; $j < count($currentLayer->layer_epsg); $j++) {
+					$currentEpsg = $currentLayer->layer_epsg[$j];
+					if ($currentEpsg["epsg"] === "EPSG:4326") {
+						$currentBbox = new Mapbender_bbox(
+							$currentEpsg["minx"],
+							$currentEpsg["miny"],
+							$currentEpsg["maxx"],
+							$currentEpsg["maxy"],
+							$currentEpsg["epsg"]
+						);
+						$geoRssItem->setBbox($currentBbox);
+						break;
+					}
+				}
+				$geoRss->append($geoRssItem);
+			}
+			foreach ($oldLayerNameArray as $oldLayer) {
+				$geoRssItem = new GeoRssItem();
+				$geoRssItem->setTitle("DELETED LAYER: " . $oldLayer["title"]);
+				$geoRssItem->setDescription($oldLayer["abstract"]);
+//				$geoRssItem->setUrl();
+				$geoRss->append($geoRssItem);
+			}
+			$geoRss->saveAsFile();
+		}
 		return;	
 	}
+
 	function updateGuiLayer($i,$myWMS,$gui_id){
 		$sql = "SELECT layer_id FROM layer WHERE fkey_wms_id = $1 AND layer_name = $2";
 		$v = array($myWMS,$this->objLayer[$i]->layer_name);
@@ -2381,6 +2555,14 @@
 		//var_dump($this);	
 	}
 
+	public static function getLayerMetadataUrl ($layerId) {
+		return preg_replace(
+			"/(.*)frames\/login.php/", 
+			"$1php/mod_layerMetadata.php?id=", 
+			LOGIN
+		) . $layerId;
+	}
+
 	public function __toString () {
 		$e = new mb_exception("TITLE: " . $this->layer_title);
 		return $this->layer_title;

Modified: trunk/mapbender/http/php/mod_deleteWMS.php
===================================================================
--- trunk/mapbender/http/php/mod_deleteWMS.php	2009-09-17 15:23:16 UTC (rev 4649)
+++ trunk/mapbender/http/php/mod_deleteWMS.php	2009-09-17 15:25:23 UTC (rev 4650)
@@ -19,6 +19,8 @@
 
 import_request_variables("PG");
 require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+require_once(dirname(__FILE__)."/../classes/class_georss_factory.php");
 ?>
 
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
@@ -167,10 +169,34 @@
 	  			 $res1 = db_prep_query($sql,$v,$t);			
 	    		 $cnt++;				
 	 	 }
+		$sql = "SELECT wms_title, wms_abstract FROM wms WHERE wms_id = $1";
+	   $v = array($wmsList);
+	   $t = array('i');
+	   $res = db_prep_query($sql,$v,$t);
+	   if ($res) {
+	   		$row = db_fetch_array($res);
+			$wms_title = $row["wms_title"];
+			$wms_abstract = $row["wms_abstract"];
+	   }
+		
+
 	   $sql = "DELETE FROM wms WHERE wms_id = $1";
 	   $v = array($wmsList);
 	   $t = array('i');
 	   $res = db_prep_query($sql,$v,$t);
+	   
+	   if ($res) {
+			//
+			// update GeoRSS feed
+			//
+			$geoRssFactory = new GeoRssFactory();
+			$geoRss = $geoRssFactory->loadOrCreate(GEO_RSS_FILE);
+			$geoRssItem = new GeoRssItem();
+			$geoRssItem->setTitle("DELETED WMS: " . $wms_title);
+			$geoRssItem->setDescription($wms_abstract);
+			$geoRss->append($geoRssItem);
+			$geoRss->saveAsFile();	   
+		}
 	}
 	// display WMS List
 	



More information about the Mapbender_commits mailing list