get("mb_user_id");
if (!isset($userId) or $userId =='') {
$userId = PUBLIC_USER; //or public
Mapbender::session()->set("mb_user_id",$userId);
}
$languageCode = 'de';
//parameters:
//id - wmc id
//languageCode - language parameter 'de', 'en', 'fr'
//$wmsServiceDisclaimerUrl = "";
$admin = new administration();
//initialize variables
$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"] != "") {
if ($_REQUEST["id"] == "current") {
$id = "current";
} else {
//validate to integer
$testMatch = $_REQUEST["id"];
$pattern = '/^[\d]*$/';
if (!preg_match($pattern,$testMatch)){
echo 'id is not valid.
';
die();
}
$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 'withHeader is not a valid boolean.
';
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
$testMatch = $_REQUEST["hostName"];
//look for whitelist in mapbender.conf
$HOSTNAME_WHITELIST_array = explode(",",HOSTNAME_WHITELIST);
if (!in_array($testMatch,$HOSTNAME_WHITELIST_array)) {
echo "Requested hostname not in whitelist! Please control your mapbender.conf.";
$e = new mb_notice("Whitelist: ".HOSTNAME_WHITELIST);
$e = new mb_notice($testMatch." not found in whitelist!");
die();
}
$hostName = $testMatch;
$testMatch = NULL;
}
$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 csv integer list
$testMatch = $_REQUEST["languageCode"];
if (!($testMatch == 'de' or $testMatch == 'fr' or $testMatch == 'en')){
//echo 'languageCode: '.$testMatch.' is not valid.
';
echo 'Parameter languageCode is not valid (de,fr,en).
';
die();
}
$languageCode = $testMatch;
$e = new mb_notice("mod_showMetadata.php: languageCode from GET parameter: ".$languageCode);
$testMatch = NULL;
}
$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;
if ($id !== "current") {
//$e = new mb_notice("mod_getWmcDisclaimer.php: wmcid: ".$id);
$wmcObj = $wmcFactory->createFromDb($id);
} else {
//read wmc from session if available and fill the needed fields from wmc object
$wmcDocSession = false;
//check if wmc filename is in session - TODO only if should be loaded from session not else! (Module loadWMC)
if(Mapbender::session()->get("mb_wmc")) {
$wmc_filename = Mapbender::session()->get("mb_wmc");
//$time_start = microtime();
//load it from whereever it has been stored
$wmcDocSession = $admin->getFromStorage($wmc_filename, TMP_WMC_SAVE_STORAGE);
$wmcObj = $wmcFactory->createFromXml($wmcDocSession);
}
}
//generate HTML Header
if ($withHeader){
//e.g. tabs and their content
$html = '';
$html .= '