'.$testMatch.' is not valid.
';
echo 'Parameter type is not valid (keywords,topicCategories,inspireCategories).
';
die();
}
$type = $testMatch;
$testMatch = NULL;
}
if (isset($_REQUEST["outputFormat"]) & $_REQUEST["outputFormat"] != "") {
$testMatch = $_REQUEST["outputFormat"];
if (!($testMatch == 'html' or $testMatch == 'json')){
//echo 'outputFormat: '.$testMatch.' is not valid.
';
echo 'Parameter outputFormat is not valid (html or json).
';
die();
}
$outputFormat = $testMatch;
$testMatch = NULL;
}
if (isset($_REQUEST["scale"]) & $_REQUEST["scale"] != "") {
$testMatch = $_REQUEST["scale"];
if (!($testMatch == 'linear' or $testMatch == 'absolute')){
//echo 'scale: '.$testMatch.' is not valid.
';
echo 'Parameter scale is not valid (linear, absolute).
';
die();
}
$scale = $testMatch;
$testMatch = NULL;
}
if (isset($_REQUEST["maxObjects"]) & $_REQUEST["maxObjects"] != "") {
$testMatch = $_REQUEST["maxObjects"];
if (!(($testMatch == '10') or ($testMatch == '15') or ($testMatch == 20) or ($testMatch == '25') or ($testMatch == '30') or ($testMatch == '35'))){
//echo 'maxObjects: '.$testMatch.' is not valid.
';
echo 'Parameter maxObjects is not valid (10,15,20,25,30,35).
';
die();
}
$maxObjects = (integer)$testMatch;
$testMatch = NULL;
}
if (isset($_REQUEST["maxFontSize"]) & $_REQUEST["maxFontSize"] != "") {
$testMatch = $_REQUEST["maxFontSize"];
if (!(($testMatch == '10') or ($testMatch == '20') or ($testMatch == '30') or ($testMatch == '40'))){
//echo 'maxFontSize: '.$testMatch.' is not valid.
';
echo 'Parameter maxFontSize is not valid (10,20,30,40).
';
die();
}
$maxFontSize = (integer)$testMatch;
$testMatch = NULL;
}
//
if (isset($_REQUEST["languageCode"]) & $_REQUEST["languageCode"] != "") {
//validate to wms, wfs
$testMatch = $_REQUEST["languageCode"];
if (!($testMatch == 'de' or $testMatch == 'en' or $testMatch == 'fr')){
//echo 'languageCode: '.$testMatch.' is not valid.
';
echo 'Parameter languageCode is not valid (de,fr,en).
';
die();
}
$languageCode = $testMatch;
$testMatch = NULL;
}
/*
if (isset($_REQUEST["hostName"]) & $_REQUEST["hostName"] != "") {
//validate to some hosts
$testMatch = $_REQUEST["hostName"];
if (!($testMatch == 'www.geoportal.rlp' or $testMatch == 'www.geoportal.rlp.de' or $testMatch == 'www.gdi-rp-dienste3.rlp.de' or $testMatch == '10.7.101.151' or $testMatch == '10.7.101.252' )){
echo 'hostName: '.$testMatch.' is not a valid server of gdi-rp.
';
die();
}
$hostName = $testMatch;
$testMatch = NULL;
}
*/
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;
}
if ($outputFormat == 'json'){
$classJSON = new Mapbender_JSON;
}
if ($languageCode == 'en'){
$pathToSearchScript = '/portal/en/service/search.html?cat=dienste&searchfilter=';
}
if ($type == 'keywords'){
$sql = "select a.keyword, sum(a.count) from (";
$sql .= "(select keyword, count(*) from keyword INNER JOIN layer_keyword ON (layer_keyword.fkey_keyword_id = keyword.keyword_id) GROUP BY keyword.keyword) union ";
$sql .= "(select keyword, count(*) from keyword INNER JOIN wmc_keyword ON (wmc_keyword.fkey_keyword_id = keyword.keyword_id) GROUP BY keyword.keyword) union ";
$sql .= "(select keyword, count(*) from keyword INNER JOIN wfs_featuretype_keyword ON (wfs_featuretype_keyword.fkey_keyword_id = keyword.keyword_id)";
$sql .= " GROUP BY keyword.keyword)) as a WHERE a.keyword <> '' GROUP BY a.keyword ORDER BY sum DESC LIMIT $1";
$showName = 'keyword';
}
if ($type == 'topicCategories' || $type == 'inspireCategories') {
if ($type == 'topicCategories') {
$categoryFilter = "md_topic_category";
} else {
$categoryFilter = "inspire_category";
}
$sql = "select a.".$categoryFilter."_code_".$languageCode.", a.".$categoryFilter."_description_".$languageCode.", a.".$categoryFilter."_uri, a.".$categoryFilter."_id,sum(a.count) from (";
$sql .= "(select ".$categoryFilter."_code_".$languageCode.",".$categoryFilter."_description_".$languageCode.",".$categoryFilter."_uri,".$categoryFilter."_id, count(*) from ".$categoryFilter." INNER JOIN layer_".$categoryFilter." ON (layer_".$categoryFilter.".fkey_".$categoryFilter."_id = ".$categoryFilter.".".$categoryFilter."_id) ";
$sql .= " WHERE layer_".$categoryFilter.".fkey_layer_id IN (select layer_id from layer where layer_searchable = 1)";
$sql .= " GROUP BY ".$categoryFilter.".".$categoryFilter."_code_".$languageCode.",".$categoryFilter.".".$categoryFilter."_id)";
$sql .= " union ";
$sql .= "(select ".$categoryFilter."_code_".$languageCode.",".$categoryFilter."_description_".$languageCode.",".$categoryFilter."_uri,".$categoryFilter."_id, count(*) from ".$categoryFilter." INNER JOIN wfs_featuretype_".$categoryFilter." ON (wfs_featuretype_".$categoryFilter.".fkey_".$categoryFilter."_id = ".$categoryFilter.".".$categoryFilter."_id)";
$sql .= " WHERE wfs_featuretype_".$categoryFilter.".fkey_featuretype_id IN (select featuretype_id from wfs_featuretype where featuretype_searchable = 1)";
$sql .= " GROUP BY ".$categoryFilter.".".$categoryFilter."_code_".$languageCode.",".$categoryFilter.".".$categoryFilter."_id)";
$sql .= " union ";
$sql .= "(select ".$categoryFilter."_code_".$languageCode.",".$categoryFilter."_description_".$languageCode.",".$categoryFilter."_uri,".$categoryFilter."_id, count(*) from ".$categoryFilter." INNER JOIN wmc_".$categoryFilter." ON (wmc_".$categoryFilter.".fkey_".$categoryFilter."_id = ".$categoryFilter.".".$categoryFilter."_id)";
$sql .= " WHERE wmc_".$categoryFilter.".fkey_wmc_serial_id IN (select wmc_serial_id from mb_user_wmc where wmc_public = 1)";
$sql .= " GROUP BY ".$categoryFilter.".".$categoryFilter."_code_".$languageCode.",".$categoryFilter.".".$categoryFilter."_id)";
$sql .= " union ";
$sql .= "(select ".$categoryFilter."_code_".$languageCode.",".$categoryFilter."_description_".$languageCode.",".$categoryFilter."_uri,".$categoryFilter."_id, count(*) from ".$categoryFilter." INNER JOIN mb_metadata_".$categoryFilter." ON (mb_metadata_".$categoryFilter.".fkey_".$categoryFilter."_id = ".$categoryFilter.".".$categoryFilter."_id)";
$sql .= " WHERE mb_metadata_".$categoryFilter.".fkey_metadata_id IN (select metadata_id from mb_metadata where searchable = true) ";
$sql .= " GROUP BY ".$categoryFilter.".".$categoryFilter."_code_".$languageCode.",".$categoryFilter.".".$categoryFilter."_id)";
$sql .= ") as a";
$sql .= " WHERE a.".$categoryFilter."_code_".$languageCode." <> '' GROUP BY a.".$categoryFilter."_code_".$languageCode.", a.".$categoryFilter."_description_".$languageCode.", a.".$categoryFilter."_uri, a.".$categoryFilter."_id "; $sql .= "ORDER BY ";
switch ($orderBy) {
case "rank":
$sql .= "sum";
break;
case "":
break;
default:
$sql .= "sum";
break;
}
$sql .= " DESC LIMIT $1";
$showName = $categoryFilter.'_code_'.$languageCode;
}
//$e = new mb_exception($sql);
$v = array($maxObjects);
$t = array('i');
$res = db_prep_query($sql,$v,$t);
$tags = array();
$i = 0;
//max pixelsize
$inc = ($maxFontSize-$minFontSize)/$maxObjects;//maybe 10 or 5 or ...
$maxWeight = 0;
while($row = db_fetch_array($res)){
if ((integer)$row['sum'] >= $maxWeight ) {
$maxWeight = (integer)$row['sum'];
}
if ($type == 'topicCategories') {
$tags[$i] = array('weight' =>$row['sum'], 'tagname' =>$row[$showName], 'url'=>'http://'.$hostName.$pathToSearchScript.urlencode('searchText=*&resultTarget=file&outputFormat=json&isoCategories='.$row['md_topic_category_id'].'&languageCode='.$languageCode));
}
if ($type == 'inspireCategories') {
$tags[$i] = array('weight' =>$row['sum'], 'tagname' =>$row[$showName], 'url'=>'http://'.$hostName.$pathToSearchScript.urlencode('searchText=*&resultTarget=file&outputFormat=json&inspireCategories='.$row[$categoryFilter.'_id'].'&languageCode='.$languageCode), 'description'=>$row[$categoryFilter.'_description_'.$languageCode], 'info'=>$row[$categoryFilter.'_uri'], 'mbId'=>$row[$categoryFilter.'_id']);
}
if ($type == 'keywords') {
$tags[$i] = array('weight' =>$row['sum'], 'tagname' =>$row[$showName], 'url'=>'http://'.$hostName.$pathToSearchScript.urlencode('searchText='.$row[$showName].'&resultTarget=file&outputFormat=json&languageCode='.$languageCode));
}
$i++;
}
//normalize the tag cloud with some max value for pixelsize or set them to linear scale!
for($i=0; $i";
echo "Mapbender Tag Cloud";
echo "";
echo "";
echo "";
echo "