[Mapbender-commits] r9981 - trunk/mapbender/tools

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Oct 22 06:55:53 PDT 2018


Author: armin11
Date: 2018-10-22 06:55:53 -0700 (Mon, 22 Oct 2018)
New Revision: 9981

Added:
   trunk/mapbender/tools/registerOwsCli.php
Log:
Simple script which allows the registration of initial wms while use the cli

Added: trunk/mapbender/tools/registerOwsCli.php
===================================================================
--- trunk/mapbender/tools/registerOwsCli.php	                        (rev 0)
+++ trunk/mapbender/tools/registerOwsCli.php	2018-10-22 13:55:53 UTC (rev 9981)
@@ -0,0 +1,72 @@
+<?php
+require_once(dirname(__FILE__)."/../core/globalSettings.php");
+require_once(dirname(__FILE__)."/../http/classes/class_wms.php");
+//require_once(dirname(__FILE__)."/../http/classes/class_administration.php");
+//require_once dirname(__FILE__) . "/../http/php/mb_validatePermission.php";
+//require_once(dirname(__FILE__)."/../http/classes/class_user.php");
+
+//***************************************************************
+//script to register ows into mapbenders database from cli - give back the created database id
+//***************************************************************
+//serviceType - string - examples 'wms', 'wfs'
+//serviceAccessUrl - example: ''
+//userId - integer - example 3
+//guiId - string - example 'service_container1'
+//authorization - test if user is allowed to register ows - check modules
+//
+//example: php registerOwsCli.php userId=1 guiId="Geoportal-RLP" serviceType="wms" serviceAccessUrl="http://www.geoportal.rlp.de/mapbender/php/mod_showMetadata.php/../wms.php?layer_id=61681&REQUEST=GetCapabilities&VERSION=1.1.1&SERVICE=WMS&withChilds=1"
+//example for integration in bash script: wms_id_1=`/usr/bin/php -f registerOwsCli.php userId=1 guiId='Geoportal-RLP' serviceType='wms' serviceAccessUrl='http://www.geoportal.rlp.de/mapbender/php/mod_showMetadata.php/../wms.php?layer_id=61681&REQUEST=GetCapabilities&VERSION=1.1.1&SERVICE=WMS&withChilds=1'`
+//***************************************************************
+//parse arguments
+$arguments = $argv;
+array_shift($arguments);
+foreach($arguments as $value) {
+    $pieces = explode('=',$value);
+    if(count($pieces) >= 2) {
+        $real_key = $pieces[0];
+        array_shift($pieces);
+        $real_value = implode('=', $pieces);
+        $real_arguments[$real_key] = $real_value;
+    }
+}
+//***************************************************************
+//read values
+$userId = $real_arguments['userId'];
+$guiId = $real_arguments['guiId'];
+$serviceType = $real_arguments['serviceType'];
+$serviceAccessUrl = $real_arguments['serviceAccessUrl'];
+//***************************************************************
+//TBD later
+//$admin = new administration();
+//$ownguis = $admin->getGuisByOwner(Mapbender::session()->get("mb_user_id"),true);
+$authType = "";
+$authUser = "";
+$authPassword = "";
+//test if guiId exists and is owned by user with id userId
+//***************************************************************
+//register
+switch ($serviceType) {
+    case "wms":
+	$mywms = new wms();
+	$mywms->setGeoRss = false;
+        $mywms->twitterNews = false;
+	$mywms->harvestCoupledDatasetMetadata = true;
+	$mywms->owner = $userId;
+	$result = $mywms->createObjFromXML($serviceAccessUrl);
+	if ($result['success']) {
+		$mywms->writeObjInDB($guiId, true, 1);  
+	} else {
+		//echo $result['message'];
+		echo "error";
+		die();
+	}
+        break;
+    case "wfs":
+        break;
+}
+//$mywms->displayWMS();
+//echo "\n";
+//echo $serviceType." registered with id: ".$mywms->wms_id."\n";
+echo $mywms->wms_id;
+die();
+?>


Property changes on: trunk/mapbender/tools/registerOwsCli.php
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property


More information about the Mapbender_commits mailing list