[Mapbender-commits] r4540 - trunk/mapbender/http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Aug 28 08:27:20 EDT 2009
Author: christoph
Date: 2009-08-28 08:27:20 -0400 (Fri, 28 Aug 2009)
New Revision: 4540
Modified:
trunk/mapbender/http/php/mod_gazetteerMetadata.php
trunk/mapbender/http/php/mod_gazetteerMetadata_search.php
Log:
added customizations
http://trac.osgeo.org/mapbender/ticket/519
Modified: trunk/mapbender/http/php/mod_gazetteerMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_gazetteerMetadata.php 2009-08-28 12:23:53 UTC (rev 4539)
+++ trunk/mapbender/http/php/mod_gazetteerMetadata.php 2009-08-28 12:27:20 UTC (rev 4540)
@@ -29,12 +29,30 @@
<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-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<meta name="DC.Rights" content="WhereGroup GmbH & Co.KG, Bonn">
<title>Metadata search</title>
-<?
+<?php
include_once(dirname(__FILE__) . "/../include/dyn_css.php");
?>
+
+
+
+<script type="text/javascript">
+<?php
+$sql = "SELECT e_target FROM gui_element WHERE e_id = $1 AND fkey_gui_id = $2";
+$v = array($e_id, $gui_id);
+$t = array('s', "s");
+$res = db_prep_query($sql,$v,$t);
+
+$targetArray = explode(",", db_result($res,0,"e_target"));
+echo "var myTarget = '".$targetArray[0]."';";
+include_once(dirname(__FILE__) . "/../include/dyn_php.php");
+echo "var searchColumnsWms = '" . $searchColumnsWms . "';";
+echo "var searchColumnsLayer = '" . $searchColumnsLayer . "';";
+?>
+</script>
+
<style type="text/css">
<!--
body{
@@ -88,8 +106,142 @@
-->
</style>
<script type="text/javascript">
-<!--
+var keywordPopup;
+var metadataPopup;
+
+var loadWmsAndZoomCallback = function (opt) {
+ if (typeof opt === "object" && opt.success) {
+
+ var map = parent.getMapObjByName(myTarget);
+ var wms = map.wms[map.wms.length - 1];
+
+ if (wms === null) {
+ opt.msg = "Ein unbekannter Fehler ist aufgetreten.";
+ }
+ else {
+ var wmsId = wms.wms_id;
+
+ // activate
+ if (typeof opt.visible === "number" && opt.visible === 1) {
+ if (typeof addwms_showWMS === "number"
+ && addwms_showWMS < wms.objLayer.length) {
+
+ if (addwms_showWMS > 0) {
+ try {
+ var msg = "Der hinzugeladene Kartendienst " +
+ "verfügt über mehr als " + addwms_showWMS +
+ " Ebenen. Die Ebenen des Dienstes werden " +
+ "<b>nicht</b> aktiviert.";
+
+ parent.Mapbender.Modules.dialogManager.openDialog({
+ content: msg,
+ modal: false,
+ effectShow: 'puff'
+ });
+ }
+ catch (e) {
+ new parent.Mb_warning(e.message + ". " + msg);
+ }
+ }
+ }
+ else {
+ parent.handleSelectedWms(map.elementName, wmsId, "visible", 1);
+ parent.mb_restateLayers(map.elementName, wmsId);
+ }
+ }
+
+ // zoom to bbox
+ var bbox_minx, bbox_miny, bbox_maxx, bbox_maxy;
+ for (var i = 0; i < wms.gui_epsg.length; i++) {
+ if (map.epsg == wms.gui_epsg[i]) {
+ bbox_minx = parseFloat(wms.gui_minx[i]);
+ bbox_miny = parseFloat(wms.gui_miny[i]);
+ bbox_maxx = parseFloat(wms.gui_maxx[i]);
+ bbox_maxy = parseFloat(wms.gui_maxy[i]);
+ if (bbox_minx === null || bbox_miny === null || bbox_maxx === null || bbox_maxy === null) {
+ continue;
+ }
+
+ map.calculateExtent(new parent.Extent(
+ bbox_minx,
+ bbox_miny,
+ bbox_maxx,
+ bbox_maxy
+ ));
+ map.setMapRequest();
+ break;
+ }
+ }
+ }
+ }
+ loadWmsCallback(opt);
+
+};
+
+var loadWmsCallback = function (opt) {
+ var msg = typeof opt.msg === "string" ? opt.msg : "";
+
+ if (typeof opt !== "object" || !opt.success) {
+ msg = "Ein unbekannter Fehler ist aufgetreten. ";
+ }
+ else {
+ var map = parent.getMapObjByName(myTarget);
+ var wms = map.wms[map.wms.length - 1];
+
+ if (wms !== null) {
+ msg = "Der folgende Dienst wurde zu 'Aktive Dienste' " +
+ "hinzugefügt:<br><br>";
+ msg += "<b>" + wms.wms_title + "</b><br><br>";
+ }
+ else {
+ msg = "Ein unbekannter Fehler ist aufgetreten. ";
+ }
+ }
+ try {
+ parent.Mapbender.Modules.dialogManager.openDialog({
+ content: msg,
+ modal: false,
+ effectShow: 'puff'
+ });
+ }
+ catch (e) {
+ new parent.Mb_warning(e.message + ". " + msg);
+ }
+};
+
+
+
+function openKeywordPopup () {
+ if(typeof(keywordPopup) != "undefined") {
+ keywordPopup.destroy();
+ }
+ keywordPopup = new parent.mb_popup({
+ title : "SelectKeyword",
+ url : "../php/mod_SelectKeyword.php",
+ width : 550,
+ height : 260,
+ left : 300,
+ top : 100
+ });
+ keywordPopup.show();
+}
+
+function openMetadataPopup (layerId) {
+// if(typeof(metadataPopup) != "undefined") {
+// metadataPopup.destroy();
+// }
+ metadataPopup = new parent.mb_popup({
+ title : "Metadata",
+ url : "../php/mod_layerMetadata.php?id=" + layerId,
+ width : 450,
+ height : 600,
+ left : 400,
+ top : 100
+ });
+ metadataPopup.show();
+}
+
function validate(){
if(document.form1.search.value.length < 1){
@@ -105,7 +257,9 @@
"../php/mod_gazetteerMetadata_search.php",
{
"search" : document.form1.search.value,
- "srs" : parent.mb_mapObj[ind].epsg
+ "srs" : parent.mb_mapObj[ind].epsg,
+ "searchColumnsWms" : searchColumnsWms,
+ "searchColumnsLayer" : searchColumnsLayer
},
function(jsonObj, status){
document.getElementById("resultDivTag").innerHTML = displayTable(jsonObj);
@@ -115,12 +269,13 @@
}
}
+
function displayTable(obj) {
var text = "<table>";
for (var attr in obj) {
var resultObj = obj[attr];
if (typeof(resultObj) != 'function') {
- text += "<tr><td valign='top'>";
+ text += "<tr><td style='padding-left:0px padding-right:0px' valign='top'>";
var imgUrl = "";
var onclickFunction = "";
if (typeof(resultObj.layer_name) !== "undefined") {
@@ -128,33 +283,53 @@
onclickFunction = "mod_addWMSLayerfromfilteredList(\"" +
resultObj.wms_getcapabilities + "\",\"" +
resultObj.wms_version + "\", \"" +
- resultObj.layer_name+"\");";
+ resultObj.layer_name+"\", {" +
+ "zoomToExtent: 0, " +
+ "visible: 0, " +
+ "callback: loadWmsCallback" +
+ "});";
}
else {
imgUrl = "../img/button_gray/metadata_wms.gif";
onclickFunction = "mod_addWMSfromfilteredList(\"" +
resultObj.wms_getcapabilities + "\",\"" +
- resultObj.wms_version+"\");";
+ resultObj.wms_version+"\", {" +
+ "zoomToExtent: 0, " +
+ "visible: 0, " +
+ "callback: loadWmsCallback" +
+ "});";
}
- text += "<img name='add_wms' src='" + imgUrl + "' ";
+ text += "<img name='add_wms' style='cursor: pointer;' src='" + imgUrl + "' ";
text += "border='0' title='Load' ";
text += "onclick='" + onclickFunction + "'>";
- if (resultObj.extent && resultObj.extent[0] !== null) {
- text += "<img src='../img/tree_new/zoom.png' " +
- "onclick='" +
- "parent.mb_calculateExtent(\"mapframe1\", " +
- resultObj.extent[0] + "," +
- resultObj.extent[1] + "," +
- resultObj.extent[2] + "," +
- resultObj.extent[3] + ");" +
- "parent.zoom(\"mapframe1\", \"true\", 1.0);" +
- "'>";
+
+ if (typeof(resultObj.layer_name) !== "undefined") {
+ imgUrl = "../img/tree_new/zoom.png";
+ onclickFunction = "mod_addWMSLayerfromfilteredList(\"" +
+ resultObj.wms_getcapabilities + "\",\"" +
+ resultObj.wms_version + "\", \"" +
+ resultObj.layer_name+"\", {" +
+ "zoomToExtent: 1, " +
+ "visible: 1, " +
+ "callback: loadWmsAndZoomCallback" +
+ "});";
}
+ else {
+ imgUrl = "../img/tree_new/zoom.png";
+ onclickFunction = "mod_addWMSfromfilteredList(\"" +
+ resultObj.wms_getcapabilities + "\",\"" +
+ resultObj.wms_version+"\", {" +
+ "zoomToExtent: 1, " +
+ "visible: 1, " +
+ "callback: loadWmsAndZoomCallback" +
+ "});";
+ }
+ text += "<img src='../img/tree_zoom.png' ";
+ text += "border='0' title='WMS zu aktiven Diensten hinzufügen und auf Ausschnitt zoomen' ";
+ text += "onclick='" + onclickFunction + "'>";
text += "</td><td>";
text += "<a href='#' ";
- text += "onclick='javascript:window.open(\"mod_layerMetadata.php?id=" +
- resultObj.layer_id +
- "\", \"metadata\", \"width=450, height=600\");' title='Info'>";
+ text += "onclick='openMetadataPopup(" + resultObj.layer_id + ");' title='Info'>";
text += resultObj.title+"</a>";
text += "</td></tr>";
}
@@ -196,9 +371,9 @@
}
-function mod_addWMSfromfilteredList(pointer_name,version){
+function mod_addWMSfromfilteredList(pointer_name, version, options){
- pointer_name=pointer_name + parent.parent.mb_getConjunctionCharacter(pointer_name);
+ pointer_name=pointer_name + parent.mb_getConjunctionCharacter(pointer_name);
if (version == '1.0.0'){
var cap = pointer_name + "REQUEST=capabilities&WMTVER=1.0.0";
var load = cap;
@@ -211,55 +386,44 @@
var cap = pointer_name + "REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.1.1";
var load = cap;
}
- //alert (load);
-
if(load){
- if(load.charAt(0) == '/' && load.charAt(1) == 'c'){
- parent.parent.mod_addWMS_load('http://localhost' + load);
- }
- else{
- parent.parent.mod_addWMS_load(load);
- }
+ parent.mod_addWMS_load(load, options);
}
}
-function mod_addWMSLayerfromfilteredList(pointer_name,version,layer_name){
-
- pointer_name=pointer_name + parent.parent.mb_getConjunctionCharacter(pointer_name);
+function mod_addWMSLayerfromfilteredList(pointer_name,version,layer_name, options){
+
+ pointer_name=pointer_name + parent.mb_getConjunctionCharacter(pointer_name);
+ var load = null;
if (version == '1.0.0'){
- var cap = pointer_name + "REQUEST=capabilities&WMTVER=1.0.0";
- var load = cap;
- var layer_name = layer_name;
+ load = pointer_name + "REQUEST=capabilities&WMTVER=1.0.0";
}
else if (version == '1.1.0'){
- var cap = pointer_name + "REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.1.0";
- var load = cap;
- var layer_name = layer_name;
+ load = pointer_name + "REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.1.0";
}
else if (version == '1.1.1'){
- var cap = pointer_name + "REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.1.1";
- var load = cap;
- var layer_name = layer_name;
+ load = pointer_name + "REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.1.1";
}
//alert (load);
- if(load){
- if(load.charAt(0) == '/' && load.charAt(1) == 'c'){
- parent.parent.mod_addLayer_load('http://localhost' + load, layer_name);
+ if (typeof load === "string") {
+ if (load.charAt(0) == '/' && load.charAt(1) == 'c'){
+ parent.mod_addLayer_load('http://localhost' + load, layer_name, options);
}
- else{
- parent.parent.mod_addLayer_load(load, layer_name);
+ else {
+ parent.mod_addLayer_load(load, layer_name, options);
}
}
}
-// -->
+
</script>
</head>
<body leftmargin="2" topmargin="0" bgcolor="#ffffff">
<form name='form1' target='result' onsubmit='return validate();'>
<p>
-<input class='textfield' name='search' type='text' style='width:110px'>
-<img src="../img/add.png" title="keywords" onclick="window.open('mod_SelectKeyword.php','SelectKeyword','width=600,height=400,status=no');">
+<input class='textfield' id='metadataSearchString' name='search' type='text' style='width:110px'>
+
+<img src="../img/add.png" style="cursor: pointer;vertical-align:middle;" title="keywords" onclick="openKeywordPopup();">
<input type='submit' name='send' value='ok'>
</p>
</form>
Modified: trunk/mapbender/http/php/mod_gazetteerMetadata_search.php
===================================================================
--- trunk/mapbender/http/php/mod_gazetteerMetadata_search.php 2009-08-28 12:23:53 UTC (rev 4539)
+++ trunk/mapbender/http/php/mod_gazetteerMetadata_search.php 2009-08-28 12:27:20 UTC (rev 4540)
@@ -8,7 +8,17 @@
$user_id = Mapbender::session()->get("mb_user_id");
$query = stripslashes($_REQUEST["search"]);
$srs = stripslashes($_REQUEST["srs"]);
+$searchColumnsWms = stripslashes($_REQUEST["searchColumnsWms"]);
+$searchColumnsLayer = stripslashes($_REQUEST["searchColumnsLayer"]);
+if ($searchColumnsWms && !preg_match("/^[a-zA-Z_\-, ]+$/", $searchColumnsWms)) {
+ echo "[]"; die;
+}
+
+if ($searchColumnsLayer && !preg_match("/^[a-zA-Z_\-, ]+$/", $searchColumnsLayer)) {
+ echo "[]"; die;
+}
+
if (!preg_match("/^[a-zA-Z_\- ]+$/", $query)) {
echo "[]"; die;
}
@@ -43,11 +53,8 @@
$t = array();
$sql_wms = "SELECT DISTINCT layer.layer_id, wms.wms_title, " .
- "wms.wms_getcapabilities, wms.wms_version, " .
- "e.minx, e.miny, e.maxx, e.maxy " .
+ "wms.wms_getcapabilities, wms.wms_version " .
"FROM wms LEFT JOIN layer ON wms.wms_id = layer.fkey_wms_id " .
- "LEFT JOIN layer_epsg e ON layer.layer_id = e.fkey_layer_id " .
- "AND e.epsg = '$srs' " .
"WHERE layer.layer_pos = 0 AND wms.wms_id IN (";
for($i=0; $i<count($mywms); $i++){
if ($i > 0) {$sql_wms .= ",";}
@@ -55,7 +62,22 @@
array_push($v, $mywms[$i]);
array_push($t, 'i');
}
- $sql_wms .= ") AND (wms_title ILIKE '%".$query."%' OR wms_abstract ILIKE '%".$query."%') ORDER BY wms_title";
+
+ $sql_wms .= ") AND (";
+ if($searchColumnsWms == "") {
+ $sql_wms .= "wms_title ILIKE '%".$query."%' OR wms_abstract ILIKE '%".$query."%'";
+ }
+ else{
+ $wmsColumnArray = split(",", $searchColumnsWms);
+ for($j = 0; $j < count($wmsColumnArray); $j++) {
+ if ($j > 0) {
+ $sql_wms .= " OR ";
+ }
+ $sql_wms .= trim($wmsColumnArray[$j]) . " ILIKE '%".$query."%'";
+ }
+ }
+
+ $sql_wms .= ") ORDER BY wms_title";
$res_wms = db_prep_query($sql_wms,$v,$t);
while ($row = db_fetch_array($res_wms)) {
@@ -63,13 +85,7 @@
'wms_getcapabilities' => $row['wms_getcapabilities'],
'wms_version' => $row['wms_version'],
'layer_id' => $row['layer_id'],
- 'title' => $row['wms_title'],
- 'extent' => array(
- $row['minx'],
- $row['miny'],
- $row['maxx'],
- $row['maxy']
- )
+ 'title' => $row['wms_title']
));
}
}
@@ -78,14 +94,11 @@
$v = array();
$t = array();
$sql_layer = "SELECT DISTINCT l.layer_id, l.fkey_wms_id, l.layer_title, " .
- "l.layer_name, w.wms_getcapabilities, w.wms_version, " .
- "e.minx, e.miny, e.maxx, e.maxy " .
+ "l.layer_name, w.wms_getcapabilities, w.wms_version " .
"FROM layer l LEFT JOIN layer_keyword lkw " .
"LEFT JOIN keyword kw ON kw.keyword_id = lkw.fkey_keyword_id " .
"ON l.layer_id = lkw.fkey_layer_id " .
"LEFT JOIN wms w ON l.fkey_wms_id = w.wms_id " .
- "LEFT JOIN layer_epsg e ON l.layer_id = e.fkey_layer_id " .
- "AND e.epsg = '$srs' " .
"WHERE l.layer_id IN (";
for($i = 0; $i < count($mylayer); $i++){
@@ -95,12 +108,24 @@
array_push($t, 'i');
}
- $sql_layer .= ") AND (" .
- "layer_title ILIKE '%".$query."%' OR " .
- "layer_name ILIKE '%".$query."%' OR " .
- "layer_abstract ILIKE '%".$query."%' OR " .
- "kw.keyword ILIKE '%".$query."%') ";
- $sql_layer .= "ORDER BY l.layer_title;";
+ $sql_layer .= ") AND (";
+ if($searchColumnsLayer == "") {
+ $sql_layer .= "layer_title ILIKE '%".$query."%' OR " .
+ "layer_name ILIKE '%".$query."%' OR " .
+ "layer_abstract ILIKE '%".$query."%';";
+ }
+ else{
+ $layerColumnArray = split(",", $searchColumnsLayer);
+ for($k = 0; $k < count($layerColumnArray); $k++) {
+ if ($k > 0) {
+ $sql_layer .= " OR ";
+ }
+ $sql_layer .= trim($layerColumnArray[$k]) . " ILIKE '%".$query."%'";
+ }
+ }
+
+ $sql_layer .= " OR kw.keyword ILIKE '%".$query."%') ORDER BY l.layer_title;";
+
$res_layer = db_prep_query($sql_layer,$v,$t);
@@ -110,13 +135,7 @@
'wms_version' => $row['wms_version'],
'layer_name' => $row['layer_name'],
'layer_id' => $row['layer_id'],
- 'title' => $row['layer_title'],
- 'extent' => array(
- $row['minx'],
- $row['miny'],
- $row['maxx'],
- $row['maxy']
- )
+ 'title' => $row['layer_title']
));
}
}
More information about the Mapbender_commits
mailing list