[Mapbender-commits] r10363 - in trunk/mapbender/http: classes javascripts plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Dec 4 07:58:21 PST 2019
Author: armin11
Date: 2019-12-04 07:58:20 -0800 (Wed, 04 Dec 2019)
New Revision: 10363
Added:
trunk/mapbender/http/plugins/mb_appMetadataContainer.js
trunk/mapbender/http/plugins/mod_applicationMetadata.php
Modified:
trunk/mapbender/http/classes/class_administration.php
trunk/mapbender/http/javascripts/initWmcObj.php
Log:
New module to show application metadata (title/description/contact/logo) in published gui
Modified: trunk/mapbender/http/classes/class_administration.php
===================================================================
--- trunk/mapbender/http/classes/class_administration.php 2019-11-29 10:29:58 UTC (rev 10362)
+++ trunk/mapbender/http/classes/class_administration.php 2019-12-04 15:58:20 UTC (rev 10363)
@@ -2461,14 +2461,29 @@
}
}
- function getCombinedApplicationMetadata($guiId, $wmcId) {
+ function getCombinedApplicationMetadata($guiId, $wmcId=false) {
//GET first! metadata record for this combination - maybe better GET last
- $sql = "SELECT uuid FROM mb_metadata WHERE fkey_gui_id = $1 AND fkey_wmc_serial_id = $2 ORDER BY lastchanged DESC LIMIT 1";
- $v = array($guiId, $wmcId);
- $t = array('s', 'i');
+ if ($wmcId == false) {
+ $sql = "SELECT uuid, title, abstract, f_get_responsible_organization_for_ressource(metadata_id, 'metadata') as orga_id FROM mb_metadata WHERE fkey_gui_id = $1 AND fkey_wmc_serial_id is null ORDER BY lastchanged DESC LIMIT 1";
+ $v = array($guiId);
+ $t = array('s');
+ } else {
+ $sql = "SELECT uuid, title, abstract, f_get_responsible_organization_for_ressource(metadata_id, 'metadata') as orga_id FROM mb_metadata WHERE fkey_gui_id = $1 AND fkey_wmc_serial_id = $2 ORDER BY lastchanged DESC LIMIT 1";
+ $v = array($guiId, $wmcId);
+ $t = array('s', 'i');
+ }
$res = db_prep_query($sql,$v,$t);
$row = db_fetch_array($res);
- return $row["uuid"];
+ if ($row["uuid"] != false) {
+ $returnObject->uuid = $row["uuid"];
+ $returnObject->orgaId = $row["orga_id"];
+ $returnObject->title = $row["title"];
+ $returnObject->abstract = $row["abstract"];
+ $returnObject->success = true;
+ } else {
+ $returnObject->success = false;
+ }
+ return $returnObject;
}
/**
Modified: trunk/mapbender/http/javascripts/initWmcObj.php
===================================================================
--- trunk/mapbender/http/javascripts/initWmcObj.php 2019-11-29 10:29:58 UTC (rev 10362)
+++ trunk/mapbender/http/javascripts/initWmcObj.php 2019-12-04 15:58:20 UTC (rev 10363)
@@ -17,6 +17,8 @@
require_once(dirname(__FILE__)."/../classes/class_owsConstraints.php");
require_once(dirname(__FILE__)."/../classes/class_cache.php");
require_once(dirname(__FILE__)."/../classes/class_crs.php");
+require_once(dirname(__FILE__)."/../classes/class_iso19139.php");
+require_once(dirname(__FILE__)."/../classes/class_group.php");
/*check if key param can be found in SESSION, otherwise take it from $_GET
*/
@@ -82,6 +84,7 @@
$e = new mb_notice("javascript/initWmcObj.php: Current user name from session information: ".Mapbender::session()->get("mb_user_name"));
$app = Mapbender::session()->get("mb_user_gui"); // if gui was set!
+
//$wmcDocSession = Mapbender::session()->get("mb_wmc");
$wmcDocSession = false;
// check if wmc filename is in session - TODO only if should be loaded from session not else! (Module loadWMC)
@@ -122,10 +125,20 @@
$e = new mb_exception("javascript/initWmcObj.php: ERROR while loading WMC from session - test creating WMC from app: " . $app);
$wmc->createFromApplication($app);
}
-
+//*********************************************************************************************************
/*
-
+Check if session WMC module is defined in gui - TODO maybe do this before the other things are done!!!
*/
+//*********************************************************************************************************
+$e = new mb_notice("javascripts/initWmcObj.php: check if disclaimer should be set");
+$sql = "SELECT COUNT(e_id) AS i FROM gui_element WHERE fkey_gui_id = $1 AND e_id = $2";
+$v = array(Mapbender::session()->get("mb_user_gui"), "sessionWmc");
+$t = array("s", "s");
+$res = db_prep_query($sql, $v, $t);
+$row = db_fetch_assoc($res);
+$isSessionWmcModuleLoaded = intval($row["i"]);
+$e = new mb_notice("javascripts/initWmcObj.php: check for disclaimer done");
+//*********************************************************************************************************
$removeUnaccessableLayers = false;
$removeUnaccessableLayers = new ElementVar($app, "loadwmc", "removeUnaccessableLayers");
if ($removeUnaccessableLayers->success == true){
@@ -172,6 +185,7 @@
/*
WMC ID
*/
+$startWmcId = false;
$e = new mb_notice("javascript/initWmcObj.php: Check WMC GET API");
$inputWmcArray = $getApi->getWmc();
if ($inputWmcArray) {
@@ -181,9 +195,11 @@
try {
$wmcGetApi = WmcFactory::createFromDb($input["id"]);
// update urls from wmc with urls from database if id is given
- $e = new mb_exception("javascripts/initWmcObj.php: wmc->updateUrlsFromDb");
+ //$e = new mb_exception("javascripts/initWmcObj.php: wmc->updateUrlsFromDb");
$updatedWMC = $wmcGetApi->updateUrlsFromDb();
$wmcGetApi->createFromXml($updatedWMC);
+//set variable to decide if application metadata can be accessed afterwards NEW 2019-11-28
+$startWmcId = $input["id"];
// increment load count
$wmcGetApi->incrementWmcLoadCount();
}
@@ -528,6 +544,56 @@
$wmcGetApi->generalExtensionArray['kmlOrder'] = json_encode($kmlOrder);
}
}
+//*******************************************************************************************************
+/*
+GET information about application metadata if a combination of GUI and WMC is invoked and a special
+module for showing this metadata is available in the invoked GUI - NEW 2019-11-28
+*/
+//*******************************************************************************************************
+//
+if ($startWmcId != false) {
+ $e = new mb_exception("Initialize GUI from combination of GUI and WMC: gui_id='".$app."' - WMC='".$startWmcId."'");
+ $applicationMetadataResult = $admin->getCombinedApplicationMetadata($app, $startWmcId);
+ if ($applicationMetadataResult->success != false) {
+ $e = new mb_exception("Found mapbender application metadata with id ".$applicationMetadataResult->uuid);
+ //If metadata was found - get it via class metadata!
+ $metadataFileIdentifier = $applicationMetadataResult->uuid;
+ if (true && isset($applicationMetadataResult->orgaId)) {
+ $group = new Group($applicationMetadataResult->orgaId);
+ //$applicationMetadata->createFromDBInternalId($metadataId);
+ //initialize needed information from XML which will be called via php/mod_dataISOMetadata.php!!!
+ //connector - ....
+ //$e = new mb_exception("fileIdentifier: ".$metadataFileIdentifier);
+ //metadataUrlGenerator
+ //http://localhost/mapbender/php/.... maybe better via invoking direct!!
+ //$e = new mb_exception("url: ".MAPBENDER_PATH."/php/mod_dataISOMetadata.php?outputFormat=iso19139&id=".$metadataFileIdentifier);
+ /*$appMetadataRemote = new connector(MAPBENDER_PATH."/php/mod_dataISOMetadata.php?outputFormat=iso19139&id=".$metadataFileIdentifier);
+ $applicationMetadata = new Iso19139();
+ $applicationMetadata->createMapbenderMetadataFromXML($appMetadataRemote->file);*/
+ $applicationMetadata->fileIdentifier = $applicationMetadataResult->uuid;
+ $applicationMetadata->title = $applicationMetadataResult->title;
+ $applicationMetadata->abstract = $applicationMetadataResult->abstract;
+ $applicationMetadata->organization = array();
+ $applicationMetadata->organization['logo_path'] = $group->logo_path;
+ $applicationMetadata->organization['title'] = $group->title;
+ $applicationMetadata->organization['name'] = $group->name;
+ $applicationMetadata->organization['address'] = $group->address;
+ $applicationMetadata->organization['postcode'] = $group->postcode;
+ $applicationMetadata->organization['city'] = $group->city;
+ $applicationMetadata->organization['telephone'] = $group->voicetelephone;
+ $applicationMetadata->organization['email'] = $group->email;
+ $applicationMetadataJson = json_encode($applicationMetadata);
+ //$e = new mb_exception(json_encode($applicationMetadata));
+ //$jsonFile = new connector("http://localhost/mb_trunk/geoportal/testpolygon.json");
+ }
+ } else {
+ $e = new mb_exception("Found no mapbender application metadata!");
+ }
+}
+//*******************************************************************************************************
+
+
+
// TODO test following
// workaround to have a fully merged WMC for loading
$xml = $wmcGetApi->toXml();
@@ -658,7 +724,7 @@
Output
Check if session WMC module is loaded - TODO maybe do this before the other things are done!!!
*/
-$e = new mb_notice("javascripts/initWmcObj.php: check if disclaimer should be set");
+/*$e = new mb_notice("javascripts/initWmcObj.php: check if disclaimer should be set");
$sql = "SELECT COUNT(e_id) AS i FROM gui_element WHERE fkey_gui_id = $1 AND e_id = $2";
$v = array(Mapbender::session()->get("mb_user_gui"), "sessionWmc");
$t = array("s", "s");
@@ -665,7 +731,7 @@
$res = db_prep_query($sql, $v, $t);
$row = db_fetch_assoc($res);
$isSessionWmcModuleLoaded = intval($row["i"]);
-$e = new mb_notice("javascripts/initWmcObj.php: check for disclaimer done");
+$e = new mb_notice("javascripts/initWmcObj.php: check for disclaimer done");*/
/*
GML in session
check if Session contains a GML, and then zoom to it - same code as in mod_renderGML.php - sync it!
@@ -873,6 +939,21 @@
}
$KmlStr .="}); ";
$outputString .= $KmlStr;
+//applicationMetadata
+if (isset($applicationMetadataJson) && $applicationMetadataJson != "") {
+ //$e = new mb_exception($applicationMetadataJson);
+ $applicationMetadataStr = " Mapbender.events.afterInit.register(function () {";
+ $applicationMetadataStr .= 'try {Mapbender.modules.applicationMetadata.initForm('.$applicationMetadataJson.')} catch(e) {new Mb_warning("applicationMetadata module not loaded")}';
+ $applicationMetadataStr .="}); ";
+ $outputString .= $applicationMetadataStr;
+} else {
+ $applicationMetadataStr = " Mapbender.events.afterInit.register(function () {";
+ $applicationMetadataStr .= 'try {Mapbender.modules.applicationMetadata.initForm(false)} catch(e) {new Mb_warning("applicationMetadata module not loaded")}';
+ $applicationMetadataStr .="}); ";
+ $outputString .= $applicationMetadataStr;
+}
+
+
echo $outputString;
// logit($outputString,"javascript_old.store","w");
Mapbender::session()->delete("addwms_showWMS");
Added: trunk/mapbender/http/plugins/mb_appMetadataContainer.js
===================================================================
--- trunk/mapbender/http/plugins/mb_appMetadataContainer.js (rev 0)
+++ trunk/mapbender/http/plugins/mb_appMetadataContainer.js 2019-12-04 15:58:20 UTC (rev 10363)
@@ -0,0 +1,6 @@
+$(document).ready(function(){
+ $('.toggleAppMetadata').click(function(){
+ $('#appMetadataContainer').toggle();
+ $('#app_metadata').toggleClass('appMetadataContainerOpened');
+ })
+});
Added: trunk/mapbender/http/plugins/mod_applicationMetadata.php
===================================================================
--- trunk/mapbender/http/plugins/mod_applicationMetadata.php (rev 0)
+++ trunk/mapbender/http/plugins/mod_applicationMetadata.php 2019-12-04 15:58:20 UTC (rev 10363)
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Package: mod_metadataCarouselTinySlider
+ *
+ * Description:
+ * This module show metadata about the application(gui)/wmc combination in one div
+ *
+ * License:
+ * Copyright (c) 2009, Open Source Geospatial Foundation
+ * This program is dual licensed under the GNU General Public License
+ * and Simplified BSD license.
+ * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
+ */
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+$e_id = 'applicationMetadata';
+
+//include all element vars from the given element
+include '../include/dyn_js.php';
+include '../include/dyn_php.php';
+?>
+var applicationMetadata = function() {
+ var that = this;
+ this.id = options.id;
+ this.initForm = function(obj) {
+ /*if (obj == false) {
+ $('#app_metadata').hide();
+ }*/
+ //set new title
+ if (obj.title == '') {
+ $('#app_metadata').hide();
+ }
+ $(document).attr("title", obj.title);
+ $('#appMetadataLogo').find('img').attr('src', obj.organization.logo_path);
+ $('#appMetadataTitle').text(obj.title);
+ $('#appMetadataContainer').html(obj.abstract+'<hr>Kontakt:<hr><b>'+obj.organization.name+'</b><br>'+obj.organization.title+'<br>'+obj.organization.address+'<br><u>'+obj.organization.postcode+'</u> '+obj.organization.city+'<br>Telefon: '+obj.organization.telephone+'<br>Email: '+'<a href="mailto:'+obj.organization.email+'">'+obj.organization.email+'</a>'
+);
+ }
+}
+
+Mapbender.events.init.register(function() {
+ Mapbender.modules[options.id] = $.extend(new applicationMetadata(),Mapbender.modules[options.id]);
+});
More information about the Mapbender_commits
mailing list