[Mapbender-commits] r9015 - trunk/mapbender/http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Aug 4 04:59:41 PDT 2014
Author: armin11
Date: 2014-08-04 04:59:41 -0700 (Mon, 04 Aug 2014)
New Revision: 9015
Modified:
trunk/mapbender/http/php/mod_getWmcDisclaimer.php
Log:
Bugfix for wrong encoding of mod_getWmcDisclaimer.php - added optional html header and integrated gettext translation
Modified: trunk/mapbender/http/php/mod_getWmcDisclaimer.php
===================================================================
--- trunk/mapbender/http/php/mod_getWmcDisclaimer.php 2014-08-01 09:25:09 UTC (rev 9014)
+++ trunk/mapbender/http/php/mod_getWmcDisclaimer.php 2014-08-04 11:59:41 UTC (rev 9015)
@@ -21,6 +21,7 @@
$hostName = $_SERVER['HTTP_HOST'];
//$userId = PUBLIC_USER;
$id = 4373; //dummy id
+$withHeader = false;
//TODO give requesting hostname to this script
if (isset($_REQUEST["id"]) & $_REQUEST["id"] != "") {
//validate to integer
@@ -33,6 +34,23 @@
$id = (integer)$testMatch;
$testMatch = NULL;
}
+
+if (isset($_REQUEST["withHeader"]) & $_REQUEST["withHeader"] != "") {
+ //validate to wms, wfs
+ $testMatch = $_REQUEST["withHeader"];
+ if (!($testMatch == 'true' or $testMatch == 'false')){
+ echo 'languageCode is not a valid boolean.<br/>';
+ die();
+ } else {
+ switch ($testMatch) {
+ case "true":
+ $withHeader = true;
+ break;
+ }
+ }
+ $testMatch = NULL;
+}
+
//TODO give requesting hostname to this script
if (isset($_REQUEST["hostName"]) & $_REQUEST["hostName"] != "") {
//validate to some hosts
@@ -50,48 +68,59 @@
}
$e = new mb_notice("mod_getWmcDisclaimer.php: requested wmc id: ".$_REQUEST["id"]);
//
-//
+$sessionLang = Mapbender::session()->get("mb_lang");
+if (isset($sessionLang) && ($sessionLang!='')) {
+ $e = new mb_notice("mod_showMetadata.php: language found in session: ".$sessionLang);
+ $language = $sessionLang;
+ $langCode = explode("_", $language);
+ $langCode = $langCode[0]; # Hopefully de or s.th. else
+ $languageCode = $langCode; #overwrite the GET Parameter with the SESSION information
+}
+
if (isset($_REQUEST["languageCode"]) & $_REQUEST["languageCode"] != "") {
- //validate to wms, wfs
- $testMatch = $_REQUEST["languageCode"];
- if (!($testMatch == 'de' or $testMatch == 'en' or $testMatch == 'fr')){
- echo 'languageCode is not valid.<br/>';
+ //validate to csv integer list
+ $testMatch = $_REQUEST["languageCode"];
+ if (!($testMatch == 'de' or $testMatch == 'fr' or $testMatch == 'en')){
+ //echo 'languageCode: <b>'.$testMatch.'</b> is not valid.<br/>';
+ echo 'Parameter <b>languageCode</b> is not valid (de,fr,en).<br/>';
die();
}
$languageCode = $testMatch;
+ $e = new mb_exception("mod_showMetadata.php: languageCode from GET parameter: ".$languageCode);
$testMatch = NULL;
}
-//Array with translations:
-switch ($languageCode) {
- case "de":
- $translation['wmcDisclaimerHeader'] = 'Das vorliegende Dokument enthält Datenquellen von unterschiedlichen Stellen. Diese unterliegen den im folgenden aufgeführten Nutzungsbedingungen:';
- $translation['wms'] = "Kartendienst";
- $translation['wfs'] = "Datendienst";
- $translation['noTouInformation'] = 'Es sind keine Informationen über Nutzungsbedingungen verfügbar!';
- break;
- case "en":
- $translation['wmcDisclaimerHeader'] = 'The document includes data resources from different organizations. The following parapgraph shows the different terms of use for the includes resources:';
- $translation['wms'] = "Web Map Service";
- $translation['wfs'] = "Web Feature Service";
- $translation['noTouInformation'] = 'No informations about terms of use are available!';
- break;
- default: #to english
- $translation['wmcDisclaimerHeader'] = 'The document includes data resources from different organizations. The following parapgraph shows the different terms of use for the includes resources:';
- $translation['wms'] = "Web Map Service";
- $translation['wfs'] = "Web Feature Service";
- $translation['noTouInformation'] = 'No informations about terms of use are available!';
-}
+$localeObj->setCurrentLocale($languageCode);
+
//javascript:openwindow("../php/mod_showMetadata.php?resource=layer&layout=tabs&redirectToMetadataUrl=1&id=20655");
//Generate wmc document by id
$wmcFactory = new WmcFactory;
$e = new mb_notice("mod_getWmcDisclaimer.php: wmcid: ".$id);
$wmcObj = $wmcFactory->createFromDb($id);
+//generate HTML Header
+if ($withHeader){
+ //e.g. tabs and their content
+ $html = '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.$languageCode.'">';
+ $html .= '<body>';
+ $metadataStr .= '<head>' .
+ '<title>'._mb('Use Constraints').'</title>' .
+ '<meta name="description" content="'._mb('Disclaimer').'" xml:lang="'.$languageCode.'" />'.
+ '<meta name="keywords" content="'._mb('Use limitations and access constraints').'" xml:lang="'.$languageCode.'" />' .
+ '<meta http-equiv="cache-control" content="no-cache">'.
+ '<meta http-equiv="pragma" content="no-cache">'.
+ '<meta http-equiv="expires" content="0">'.
+ '<meta http-equiv="content-language" content="'.$languageCode.'" />'.
+ '<meta http-equiv="content-style-type" content="text/css" />'.
+ '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">' .
+ '</head>';
+ echo $html.$metadataStr;
+
+}
//generate header for disclaimer:
-echo "<b>".$translation['wmcDisclaimerHeader']."</b><br><br>";#
+echo "<b>"._mb('The document includes data resources from different organizations. The following parapgraph shows the different terms of use for the includes resources:')."</b><br><br>";#
//Part for wms
-$resourceSymbol = "<img src='../img/osgeo_graphics/geosilk/server_map.png' alt='".$translation['wms']." - picture' title='".$translation['wms']."'>";
+$resourceSymbol = "<img src='../img/osgeo_graphics/geosilk/server_map.png' alt='"._mb('Web Map Service')." - picture' title='"._mb('Web Map Service')."'>";
//read out all wms id's
$validWMS = $wmcObj->getValidWms();
if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
@@ -115,12 +144,15 @@
$constraints->returnDirect = false;
$touForWMS = $constraints->getDisclaimer();
if ($touForWMS == 'free'){
- $wmstou = $translation['noTouInformation'];
+ $wmstou = _mb('No informations about terms of use are available!');
} else {
$wmstou = $touForWMS;
}
echo $wmstou."<br>";
}
+if ($withHeader){
+ echo "</body></html>";
+}
//var_dump($validWMS);
//module to read out all service ids which are stored in mapbender wmc documents and generate a Big Disclaimer for those Docs.
//It integrates all known disclaimers for the used webservices who are stored in the mapbender registry
More information about the Mapbender_commits
mailing list