[Mapbender-commits] r1192 - trunk/mapbender/http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Mar 6 03:56:37 EST 2007
Author: christoph
Date: 2007-03-06 03:56:37 -0500 (Tue, 06 Mar 2007)
New Revision: 1192
Modified:
trunk/mapbender/http/php/mod_gazetteerMetadata.php
trunk/mapbender/http/php/mod_gazetteerMetadata_search.php
Log:
changed from html to json output
Modified: trunk/mapbender/http/php/mod_gazetteerMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_gazetteerMetadata.php 2007-03-06 08:55:42 UTC (rev 1191)
+++ trunk/mapbender/http/php/mod_gazetteerMetadata.php 2007-03-06 08:56:37 UTC (rev 1192)
@@ -127,13 +127,41 @@
}
else{
document.getElementById("resultDivTag").innerHTML = "<table><tr><td><img src='../img/indicator_wheel.gif></td><td>Searching...</td></tr></table>";
- parent.mb_ajax_post("mod_gazetteerMetadata_search.php", {"search":document.form1.search.value}, function(text, status){
- document.getElementById("resultDivTag").innerHTML = text;
+ parent.mb_ajax_json("mod_gazetteerMetadata_search.php", {"search":document.form1.search.value}, function(jsonObj, status){
+ document.getElementById("resultDivTag").innerHTML = displayTable(jsonObj);
});
return false;
}
}
+function displayTable(obj) {
+ var text = "<table>";
+ for (var attr in obj) {
+ var resultObj = obj[attr];
+ if (typeof(resultObj) != 'function') {
+ text += "<tr><td valign='top'>";
+ if (typeof(resultObj.layer_name) !== "undefined") {
+ text += "<a href='#' onClick='mod_addWMSLayerfromfilteredList(\""+resultObj.wms_getcapabilities+"\",\""+resultObj.wms_version+"\", \""+resultObj.layer_name+"\");'>";
+ text += "<img name='add_wms' src='../img/button_gray/metadata_layer.gif' border='0'></a>";
+ text += "</td><td>";
+ text += "<a href='#' onmouseover='javascript:showHighlight();' onmouseout='javascript:hideHighlight();' ";
+ text += "onClick='javascript:window.open(\"mod_layerMetadata.php?id="+resultObj.layer_id+"\", \"metadata\", \"width=450, height=600\");'>";
+ text += resultObj.title+"</a>";
+ }
+ else {
+ text += "<a href='#' onClick='mod_addWMSfromfilteredList(\""+resultObj.wms_getcapabilities+"\",\""+resultObj.wms_version+"\")'>";
+ text += "<img name='add_wms' src='../img/button_gray/metadata_wms.gif' border='0'></a>";
+ text += "</td><td>";
+ text += "<a href='#' onmouseover='javascript:showHighlight();' onmouseout='javascript:hideHighlight();' onClick='javascript:window.open(\"mod_layerMetadata.php?id="+resultObj.layer_id+"\", \"metadata\", \"width=450, height=600\");'>";
+ text += resultObj.title+"</a>"
+ }
+ text += "</td></tr>";
+ }
+ }
+ text += "</table>";
+ return text;
+}
+
function showHighlight(wms_title){
parent.parent.mb_showHighlight("mapframe1",wms_title);
parent.parent.mb_showHighlight("overview",wms_title);
Modified: trunk/mapbender/http/php/mod_gazetteerMetadata_search.php
===================================================================
--- trunk/mapbender/http/php/mod_gazetteerMetadata_search.php 2007-03-06 08:55:42 UTC (rev 1191)
+++ trunk/mapbender/http/php/mod_gazetteerMetadata_search.php 2007-03-06 08:56:37 UTC (rev 1192)
@@ -6,9 +6,8 @@
require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
require_once(dirname(__FILE__)."/../classes/class_administration.php");
+require_once(dirname(__FILE__)."/../extensions/JSON.php");
-
-
$n = new administration();
$myguis = $n->getGuisByPermission($user_id, true);
$mywms = $n->getWmsByOwnGuis($myguis);
@@ -18,19 +17,18 @@
}
$mylayer = array();
-for($i=0; $i<count($mywms); $i++){
+for($i = 0; $i < count($mywms); $i++){
$mylayer = array_merge($mylayer,$n->getLayerByWms($mywms[$i]));
}
$res_container_wms = array();
$res_container_layer = array();
+$obj = array();
if(preg_match("/\*/",$_REQUEST["search"])){
$search = trim(preg_replace("/\*/i","", $_REQUEST["search"]));
}
-$resultStr = "";
-
if (count($mywms) > 0) {
$v = array();
$t = array();
@@ -48,13 +46,7 @@
$res_wms = db_prep_query($sql_wms,$v,$t);
while ($row = db_fetch_array($res_wms)) {
- $resultStr .= "<tr><td valign='top'>";
- $resultStr .= "<a href='#' onClick='mod_addWMSfromfilteredList(\"".$row['wms_getcapabilities']."\",\"".$row['wms_version']."\")'>";
- $resultStr .= "<img name='add_wms' src='../img/button_gray/metadata_wms.gif' border='0'></a> ";
- $resultStr .= "</td><td>";
- $resultStr .= "<a href='#' onmouseover='javascript:showHighlight();' onmouseout='javascript:hideHighlight();' onClick='javascript:window.open(\"mod_layerMetadata.php?id=".$row['layer_id']."\", \"metadata\", \"width=450, height=600\");'> ";
- $resultStr .= $row['wms_title']."</a>"; # = WMS-ID: ".$result_id1."
- $resultStr .= "</td></tr>";
+ array_push($obj, array('wms_getcapabilities' => $row['wms_getcapabilities'], 'wms_version' => $row['wms_version'], 'layer_id' => $row['layer_id'], 'title' => $row['wms_title']));
}
}
@@ -71,28 +63,15 @@
array_push($v, $mylayer[$i]);
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;";
-
$res_layer = db_prep_query($sql_layer,$v,$t);
while ($row = db_fetch_array($res_layer)) {
- $resultStr .= "<tr><td valign='top'>";
- $resultStr .= "<a href='#' onClick='mod_addWMSLayerfromfilteredList(\"".$row['wms_getcapabilities']."\",\"".$row['wms_version']."\", \"".$row['layer_name']."\");'>";
- $resultStr .= "<img name='add_wms' src='../img/button_gray/metadata_layer.gif' border='0'></a> ";
- $resultStr .= "</td><td>";
- $resultStr .= "<a href='#' onmouseover='javascript:showHighlight();' onmouseout='javascript:hideHighlight();' ";
- $resultStr .= "onClick='javascript:window.open(\"mod_layerMetadata.php?id=".$row['layer_id']."\", \"metadata\", \"width=450, height=600\");'>";
- $resultStr .= $row['layer_title']."</a>"; # = LAYER-ID (aus Suche layer_abstract): ".$result_id2."
- $resultStr .= "</td></tr>";
+ array_push($obj, array('wms_getcapabilities' => $row['wms_getcapabilities'], 'wms_version' => $row['wms_version'], 'layer_name' => $row['layer_name'], 'layer_id' => $row['layer_id'], 'title' => $row['layer_title']));
}
}
-
-if ($resultStr != "") {
- echo "<table>".$resultStr."</table>";
-}
-else {
- echo " No result.";
-}
+$json = new Services_JSON();
+$output = $json->encode($obj);
+echo $output;
?>
\ No newline at end of file
More information about the Mapbender_commits
mailing list