[Mapbender-commits] r7807 - trunk/mapbender/http/php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue May 10 09:30:15 EDT 2011


Author: armin11
Date: 2011-05-10 06:30:15 -0700 (Tue, 10 May 2011)
New Revision: 7807

Removed:
   trunk/mapbender/http/php/mod_layerISOMetadataWriteToFolder.php
Modified:
   trunk/mapbender/http/php/mod_exportISOMetadata.php
Log:
Bugfix

Modified: trunk/mapbender/http/php/mod_exportISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_exportISOMetadata.php	2011-05-10 12:48:41 UTC (rev 7806)
+++ trunk/mapbender/http/php/mod_exportISOMetadata.php	2011-05-10 13:30:15 UTC (rev 7807)
@@ -26,36 +26,54 @@
 
 //define the view or table where to read out the layer ids for which metadatafiles should be generated
 $wmsView = "search_wms_view";
-//parse request parameter
-//make all parameters available as upper case
-foreach($_REQUEST as $key => $val) {
-	$_REQUEST[strtoupper($key)] = $val;
+
+if (isset($argv[1])) {
+	if ($argv[1]=='ALL') {
+		
+		$invokedFromCli = true;
+		//command ok
+	} else {
+		echo $argv[0]."\n";
+		echo "Wrong invokation! Workflow terminated!\n";
+		die();
+	}
+} else {
+	//would have been called from web
+	//parse request parameter
+	//make all parameters available as upper case
+	foreach($_REQUEST as $key => $val) {
+		$_REQUEST[strtoupper($key)] = $val;
+	}
+	//validate request params
+	if (!isset($_REQUEST['TYPE'])) {
+		echo 'GET Parameter Type lacks'; 
+		die();
+	}
+	if (isset($_REQUEST['TYPE']) and $_REQUEST['TYPE'] != "ALL") {
+		//
+		echo 'validate: <b>'.$_REQUEST['TYPE'].'</b> is not valid.<br/>'; 
+		die();
+	}
 }
-//validate request params
 
-//
-if (!isset($_REQUEST['TYPE'])) {
-	echo 'GET Parameter Type lacks'; 
-	die();
-}
-if (isset($_REQUEST['TYPE']) and $_REQUEST['TYPE'] != "ALL") {
-	//
-	echo 'validate: <b>'.$_REQUEST['TYPE'].'</b> is not valid.<br/>'; 
-	die();
-}
 $sql = "SELECT layer_id ";
-$sql .= "FROM ".$wmsView;
-//$sql .= "FROM layer WHERE layer_id IN (20203,20202)";
+//$sql .= "FROM ".$wmsView;
+$sql .= "FROM layer WHERE layer_id IN (20203,20202)";
 $v = array();
 $t = array();
 $res = db_prep_query($sql,$v,$t);
 
 $generatorScript = '/mapbender/php/mod_layerISOMetadata.php?';
-$generatorBaseUrl = 'http://'.$_SERVER['HTTP_HOST'].$generatorScript;
-
 $generatorScriptMetadata = '/mapbender/php/mod_dataISOMetadata.php?';
-$generatorBaseUrlMetadata = 'http://'.$_SERVER['HTTP_HOST'].$generatorScriptMetadata;
 
+if ($invokedFromCli){
+	$generatorBaseUrl = 'http://localhost/'.$generatorScript;
+	$generatorBaseUrlMetadata = 'http://localhost/'.$generatorScriptMetadata;
+} else {
+	$generatorBaseUrl = 'http://'.$_SERVER['HTTP_HOST'].$generatorScript;
+	$generatorBaseUrlMetadata = 'http://'.$_SERVER['HTTP_HOST'].$generatorScriptMetadata;
+}
+
 $countLayer = 0;
 $countMetadataURL = 0;
 

Deleted: trunk/mapbender/http/php/mod_layerISOMetadataWriteToFolder.php
===================================================================
--- trunk/mapbender/http/php/mod_layerISOMetadataWriteToFolder.php	2011-05-10 12:48:41 UTC (rev 7806)
+++ trunk/mapbender/http/php/mod_layerISOMetadataWriteToFolder.php	2011-05-10 13:30:15 UTC (rev 7807)
@@ -1,110 +0,0 @@
-<?php
-#http://www.geoportal.rlp.de/mapbender/php/mod_exportISOMetadata.php?
-# $Id: mod_exportISOMetadata.php 235
-# http://www.mapbender.org/index.php/Inspire_Metadata_Editor
-# Copyright (C) 2002 CCGIS 
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require_once(dirname(__FILE__) . "/../../core/globalSettings.php");
-require_once(dirname(__FILE__) . "/../classes/class_connector.php");
-
-$con = db_connect(DBSERVER,OWNER,PW);
-db_select_db(DB,$con);
-
-//define the view or table where to read out the layer ids for which metadatafiles should be generated
-$wmsView = "search_wms_view";
-//$wmsView = '';
-//parse request parameter
-//make all parameters available as upper case
-
-foreach($_REQUEST as $key => $val) {
-	$_REQUEST[strtoupper($key)] = $val;
-}
-//validate request params
-
-//
-if (!isset($_REQUEST['TYPE'])) {
-	echo 'GET Parameter Type lacks'; 
-	die();
-}
-
-if (isset($_REQUEST['TYPE']) and $_REQUEST['TYPE'] != "ALL") {
-	//
-	echo 'validate: <b>'.$_REQUEST['TYPE'].'</b> is not valid.<br/>'; 
-	die();
-}
-
-$sql = "SELECT layer_id, uuid ";
-//$sql .= "FROM ".$wmsView;
-$sql .= "FROM layer WHERE layer_id IN (20203,20202)";
-$v = array();
-$t = array();
-$res = db_prep_query($sql,$v,$t);
-
-$generatorScript = '/mapbender/php/mod_layerISOMetadata.php?';
-$generatorBaseUrl = 'http://'.$_SERVER['HTTP_HOST'].$generatorScript;
-
-$generatorScriptMetadata = '/mapbender/php/mod_dataISOMetadata.php?';
-$generatorBaseUrlMetadata = 'http://'.$_SERVER['HTTP_HOST'].$generatorScriptMetadata;
-
-echo $generatorBaseUrl."<br>";
-
-while($row = db_fetch_array($res)){
-	$generatorUrl = $generatorBaseUrl."SERVICE=WMS&outputFormat=iso19139&id=".$row['layer_id'];
-	echo "URL requested : ".$generatorUrl."<br>";
-	$generatorInterfaceObject = new connector($generatorUrl);
-	$ISOFile = $generatorInterfaceObject->file;
-	$layerId = $row['layer_id'];
-	echo "File for layer ".$row['layer_id']." will be generated<br>";
-	//generate temporary files under tmp
-	if($h = fopen(TMPDIR."/metadata/mapbenderServiceMetadata_".$layerId."_iso19139.xml","w")){
-		if(!fwrite($h,$ISOFile)){
-			$e = new mb_exception("mod_exportISOMetadata.php: cannot write to file: ".TMPDIR."/mapbenderLayerMetadata_".$row['layer_id']."_iso19139.xml");
-		}
-	echo "Service metadata file for layer ".$row['layer_id']." written to TMP<br>";
-	fclose($h);
-	//get all connected metadata for this layer and save it too	
-	$sql = <<<SQL
-
-SELECT metadata_id, uuid, link, linktype, md_format, origin FROM mb_metadata 
-INNER JOIN (SELECT * from ows_relation_metadata 
-WHERE fkey_layer_id = $layerId ) as relation ON 
-mb_metadata.metadata_id = relation.fkey_metadata_id WHERE mb_metadata.export2csw = TRUE
-
-SQL;
-	$i = 0;
-	$res_metadata = db_query($sql);
-	while ($row_metadata = db_fetch_array($res_metadata)) {
-		$generatorUrlMetadata = $generatorBaseUrlMetadata."outputFormat=iso19139&id=".$row_metadata['uuid'];
-		echo "URL requested : ".$generatorUrlMetadata."<br>";
-		$generatorInterfaceObject = new connector($generatorUrlMetadata);
-		$ISOFile = $generatorInterfaceObject->file;
-		echo "Metadata uuid: ".$row_metadata['uuid']."<br>";
-		//generate temporary files under tmp
-		if($h = fopen(TMPDIR."/metadata/mapbenderMetadata_".$layerId."_".$row_metadata['uuid']."_iso19139.xml","w")){
-		if(!fwrite($h,$ISOFile)){
-			$e = new mb_exception("mod_exportISOMetadata.php: cannot write to file: ".TMPDIR."/metadata/mapbenderMetadata_".$layerId."_".$row_metadata['uuid']."_iso19139.xml");
-		}
-		echo "Data metadate file for layer ".$row['layer_id']." and metadata ".$row_metadata['uuid']." written to TMP<br>";
-		fclose($h);
-		$i++;	
-	}
-}
-
-
-
-
-



More information about the Mapbender_commits mailing list