[Mapbender-commits] r4406 - branches/mifan_dev/mapbender/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jul 21 06:45:16 EDT 2009


Author: mifan
Date: 2009-07-21 06:45:15 -0400 (Tue, 21 Jul 2009)
New Revision: 4406

Added:
   branches/mifan_dev/mapbender/http/javascripts/mod_searchCSW_ajax.php
Log:
ajaxified search interface

Added: branches/mifan_dev/mapbender/http/javascripts/mod_searchCSW_ajax.php
===================================================================
--- branches/mifan_dev/mapbender/http/javascripts/mod_searchCSW_ajax.php	                        (rev 0)
+++ branches/mifan_dev/mapbender/http/javascripts/mod_searchCSW_ajax.php	2009-07-21 10:45:15 UTC (rev 4406)
@@ -0,0 +1,446 @@
+<?php
+# $Id$
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
+
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+
+<head>
+	<meta http-equiv="cache-control" content="no-cache" />
+	<meta http-equiv="pragma" content="no-cache" />
+	<meta http-equiv="expires" content="0" />
+	<?php printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\" />",CHARSET);	?>
+	<title>Search Catalog</title>
+	<style type="text/css">
+	<!--
+	div.form-container form { padding: 5px; background-color: #FFF; border: #EEE 1px solid; background-color: #FbFbFb; }
+	div.form-container p { margin: 0.5em 0 0 0; }
+	div.form-container form p { margin: 0; }
+	div.form-container form p.note { font-style: italic; margin-left: 18em; font-size: 80%; color: #666; }
+	div.form-container form fieldset { margin:0 0 10px 0; padding: 10px; border: #DDD 1px solid; background-color:#FFF;}
+	div.form-container form fieldset input:focus,
+	div.form-container form fieldset input.errorfield:focus,
+	div.form-container form fieldset textarea:focus { background-color: #FFC; border-color: #FC6;  }
+	div.form-container form fieldset label{ position:relative; margin-right: 10px; padding-right: 10px; width: 15em; display: block; float: left; text-align: right;min-height:1em;top:0.25em;}
+	div.form-container form fieldset label.errorfield,
+	div.form-container form fieldset span.errorfield { color: #C00; }
+	div.form-container form fieldset label.value{display:block;text-align:left;width:auto;}
+	
+	
+	
+	-->
+	</style>
+	<script type="text/javascript">
+	<!--
+	// Set default for element variables if they are undefined
+	option_dball      = (typeof(option_dball) !== 'undefined')      ? option_dball      : '1';
+	option_dbgroup    = (typeof(option_dbgroup) !== 'undefined')    ? option_dbgroup    : '0';
+	option_dbgui      = (typeof(option_dbgui) !== 'undefined')      ? option_dbgui      : '0';
+	capabilitiesInput = (typeof(capabilitiesInput) !== 'undefined') ? capabilitiesInput : '1';
+	gui_list          = (typeof(gui_list) !== 'undefined')          ? gui_list          : '';
+
+	var guis = gui_list.split(',');
+	
+	if(gui_list === '') {
+		guis = [];
+	}
+
+	var global_source = 'capabilities';  // [capabilities,db]
+
+	//set server side URL
+	var phpUrl        = '../php/mod_addWMSfromfilteredList_server.php?<?php echo $urlParameters;?>';
+
+	// Load service
+
+	function mod_addWMSfromDB(gui_id,wms_id) {
+		parent.mod_addWMSById_load(gui_id,wms_id);
+	}
+
+	function mod_addWMSfromfilteredList(pointer_name,version){
+		//TODO: load active
+		var load                 = false;
+		var conjunctionCharacter = parent.mb_getConjunctionCharacter(pointer_name);
+		
+		if(version == '1.0.0') {
+			load = pointer_name + conjunctionCharacter + 'REQUEST=capabilities&WMTVER=1.0.0';
+		}
+		else if(version == '1.1.0' || version == '1.1.1') {
+			load = pointer_name + conjunctionCharacter + 'REQUEST=GetCapabilities&SERVICE=WMS&VERSION=' + version;
+		}
+		if(load !== false) {
+			parent.mod_addWMS_load(load);
+		}
+	}
+
+	function mod_addWmsfromURL(){
+		var capabilities = document.getElementById('CapURL').value;
+		parent.mod_addWMS_load(capabilities);
+	}
+
+	// Retrieve data
+
+	function setSource(sourceValue) {
+		global_source = sourceValue;
+	}
+
+	function getGroups() {
+		imageOn();
+		parent.mb_ajax_json(phpUrl, {"command":"getGroups"}, function (json, status) {
+			imageOff();
+			displayGroups(json.group);
+		});
+	}
+
+	function getGUIs() {
+		imageOn();
+		parent.mb_ajax_json(phpUrl, {"command":"getGUIs"}, function (json, status) {
+			imageOff();
+			displayGUIs(json.gui);
+		});
+	}
+
+	function getWMSByGUI(guiId) {
+		if(guiId=="")
+			return getAllWMS();
+		imageOn();
+		parent.mb_ajax_json(phpUrl, {"command":"getWMSByGUI", "guiId":guiId}, function (json, status) {
+			imageOff();
+			displayWMS(json.wms, guiId);
+		});
+	}
+
+	function getWMSByGroup(groupId) {
+		imageOn();
+		parent.mb_ajax_json(phpUrl, {"command":"getWMSByGroup", "groupId":groupId}, function (json, status) {
+			imageOff();
+			displayWMS(json.wms);
+		});
+	}
+
+	function getAllWMS() {
+		imageOn();
+		parent.mb_ajax_json(phpUrl, {"command":"getAllWMS"}, function (json, status) {
+			imageOff();
+			displayWMS(json.wms);
+		});
+	}
+
+	// -----------------  Display results --------------------
+
+	function removeChildNodes(node) {
+		while (node.childNodes.length > 0) {
+			var childNode = node.firstChild;
+			node.removeChild(childNode);
+		}
+	}
+
+	function setTableHeader(text,titleLeft,titleRight) {
+		document.getElementById('resultString').innerHTML = text;
+		document.getElementById('titleLeft').innerHTML    = titleLeft;
+		document.getElementById('titleRight').innerHTML   = titleRight;
+		
+		removeChildNodes(document.getElementById('resultTableBody'));
+	}
+
+	function addTableRow(leftText,rightText,onClick) {
+		var resultTableBoy        = document.getElementById('resultTableBody');
+		var leftTableCell         = document.createElement('td');
+		var rightTableCell        = document.createElement('td');
+		var leftTableCellContent  = document.createElement('strong');
+		var rightTableCellContent = document.createElement('em');
+		var tableRow              = document.createElement('tr');
+				
+		leftTableCellContent.innerHTML  = leftText;
+		rightTableCellContent.innerHTML = rightText;
+
+		leftTableCell.appendChild(leftTableCellContent);
+		rightTableCell.appendChild(rightTableCellContent);
+		tableRow.appendChild(leftTableCell);
+		tableRow.appendChild(rightTableCell);
+		
+		tableRow.onclick = function () {
+			eval(onClick);
+		}
+
+		if(resultTableBoy.childNodes.length % 2 !== 0) {
+			tableRow.className += tableRow.className + ' alternate';
+		}
+
+		resultTableBoy.appendChild(tableRow);
+	}
+
+	function imageOn() {
+		document.getElementById("progressIndicator").style.visibility = "visible";
+		document.getElementById("progressIndicator").style.display = "block";
+		document.getElementById("resultTable").style.visibility = "hidden";
+		document.getElementById("resultTable").style.display = "none";
+		document.getElementById("resultString").style.visibility = "hidden";
+		document.getElementById("resultString").style.display = "none";
+	}
+
+	function imageOff() {
+		document.getElementById("progressIndicator").style.visibility = "hidden";
+		document.getElementById("progressIndicator").style.display = "none";
+		document.getElementById("resultTable").style.visibility = "visible";
+		document.getElementById("resultTable").style.display = "block";
+		document.getElementById("resultString").style.visibility = "visible";
+		document.getElementById("resultString").style.display = "block";
+	}
+
+	function noResult() {
+		document.getElementById("resultTable").style.visibility = 'hidden';
+		document.getElementById("resultString").innerHTML = noResultText;
+	}
+
+	function setButtons() {
+		var containerCapabilities = document.getElementById('container_capabilities');
+		var containerButtons      = document.getElementById('container_buttons');
+		var optionButton          = false;
+
+		// If only one is active load list imidiately
+		if(
+			parseInt(option_dbgui) + 
+			parseInt(option_dbgroup) + 
+			parseInt(option_dball)
+		=== 1) {
+			if(option_dball === '1'){
+				optionButton = document.getElementById('button_dbAll');
+			}
+			if(option_dbgroup === '1') {
+				optionButton = document.getElementById('button_dbGroup');
+			}
+			if(option_dbgui === '1') {
+				optionButton = document.getElementById('button_dbGui');
+			}
+
+			if(optionButton) {
+				optionButton.onclick();
+				containerButtons.parentNode.removeChild(containerButtons);
+				
+				return;
+			}
+		}
+
+		if(option_dball === '0') {
+			optionButton = document.getElementById('button_dbAll');
+			optionButton.parentNode.removeChild(optionButton);
+		}
+		if(option_dbgroup === '0') {
+			optionButton = document.getElementById('button_dbGroup');
+			optionButton.parentNode.removeChild(optionButton);
+		}
+		if(option_dbgui === '0') {
+			optionButton = document.getElementById('button_dbGui');
+			optionButton.parentNode.removeChild(optionButton);
+		}
+		
+		if(capabilitiesInput === '0') {
+			optionButton = document.getElementById('capabilitiesForm');
+			optionButton.parentNode.removeChild(optionButton);
+			containerCapabilities.parentNode.removeChild(containerCapabilities);
+		}
+	}
+
+	function displayGroups (groupArray) {
+		if (groupArray.length > 0) {
+			setTableHeader(selectGroupText, groupNameText, groupAbstractText);
+			
+			for (var i = 0; i < groupArray.length; i++) {
+				var onClick = "getWMSByGroup('" + groupArray[i].id + "')";
+				addTableRow(groupArray[i].name, groupArray[i].description, onClick);	
+			}
+		}
+		else {
+			noResult();
+		}
+	}
+
+	function displayGUIs (guiArray) {
+		if (guiArray.length > 0) {
+			setTableHeader(selectGuiText, guiNameText, guiAbstractText);
+			
+			for (var i = 0; i < guiArray.length; i++) {
+				var onClick = "getWMSByGUI('" + guiArray[i].id + "')";
+				if(guis.length>0){
+					for(var j=0; j < guis.length; j++){
+						if(guiArray[i].id==guis[j]){
+							addTableRow(guiArray[i].name, guiArray[i].description, onClick);	
+							break;
+						}
+					}
+				}
+				else
+					addTableRow(guiArray[i].name, guiArray[i].description, onClick);	
+			}
+		}
+		else {
+			noResult();
+		}
+	}
+
+	function hide_advanced_form(){
+		var html='';
+		html = html + "<fieldset>";
+		html = html + "<input type='button' id='adv_search_show' name='adv_search_show' value='<?php echo _mb('++ Advanced'); ?>' onclick='show_advanced_form();' />";
+		html = html + "</fieldset>";
+
+		document.getElementById('advanced_div').innerHTML=html;
+	}
+
+	function show_advanced_form(){
+		
+		var html = '';
+		html = html + "<fieldset>";
+		html = html + "<input type='button' value='--Advanced' onclick=hide_advanced_form() />";
+		html = html + "</fieldset>";
+		html = html + "<fieldset>";
+		html = html + "<legend>Advanced Search</legend>";
+		html = html + "<fieldset id='cont_adv_summary'>";
+		html = html + "<label for='adv_title'><?php echo _mb('Title '); ?>:</label>";
+		html = html + "<input type='text' id='adv_title' name='adv_title' /> <br /><br />";
+		html = html + "<label for='adv_abstract'><?php echo _mb('Abstract'); ?>:</label>";
+		html = html + "<input type='text' id='adv_abstract' name='adv_abstract' /><br /><br />";
+		html = html + "<label for='adv_keywords'><?php echo _mb('Keywords'); ?>:</label>";
+		html = html + "<input type='text' id='adv_keywords' name='adv_keywords' /><br /><br />";
+		html = html + "</fieldset>";
+
+		html = html + "<fieldset>";
+		html = html + "<label for='adv_title'><?php echo _mb('Lat-Min'); ?>:</label>";
+		html = html + "<input type='text' id='adv_title' name='adv_title' />";
+		html = html + "<label for='adv_title'><?php echo _mb('Lon-Min'); ?>:</label>";
+		html = html + "<input type='text' id='adv_title' name='adv_title' />";
+		html = html + "<label for='adv_title'><?php echo _mb('Lat-Max'); ?>:</label>";
+		html = html + "<input type='text' id='adv_title' name='adv_title' />";
+		html = html + "<label for='adv_title'><?php echo _mb('Lon-Max'); ?>:</label>";
+		html = html + "<input type='text' id='adv_title' name='adv_title' />";
+		html = html + "</fieldset>";
+
+		document.getElementById('advanced_div').innerHTML=html;	
+				  
+			
+			
+	}
+
+	function displayWMS (wmsArray, guiId) {
+		if (wmsArray.length > 0) {
+			setTableHeader(selectWmsText, wmsNameText, wmsAbstractText);
+
+			for (var i = 0; i < wmsArray.length; i++) {
+
+				if (global_source == "db" && typeof(guiId) !== "undefined" ) {
+					var onClick = "mod_addWMSfromDB('" + guiId + "', '" + wmsArray[i].id + "')";
+				}		
+				else {
+					var onClick = "mod_addWMSfromfilteredList('" + wmsArray[i].getCapabilitiesUrl + "', '" + wmsArray[i].version + "')";
+				}
+				addTableRow(wmsArray[i].title, wmsArray[i].abstract, onClick);
+			}
+		}
+		else {
+			noResult();
+		}
+	}
+	-->
+	</script>
+	<?php include("../include/dyn_css.php"); ?>
+	<script type="text/javascript">
+	var wmsNameText = '<?php echo _mb("WMS name");?>';
+	var wmsAbstractText = '<?php echo _mb("WMS abstract");?>';
+	var selectWmsText = '<?php echo _mb("Please select a WMS") . ":";?>';
+	var selectGuiText = '<?php echo _mb("Please select an application") . ":";?>';
+	var selectGroupText = '<?php echo _mb("Please select a group") . ":";?>';
+	var groupAbstractText = '<?php echo _mb("group abstract");?>';
+	var groupNameText = '<?php echo _mb("group name");?>';
+	var guiAbstractText = '<?php echo _mb("application abstract");?>';
+	var guiNameText = '<?php echo _mb("application name");?>';
+	var noResultText = '<?php echo _mb("no result");?>';
+	</script>
+
+</head>
+
+<body onLoad="setButtons();">
+<h1><?php echo _mb("Catalog Service for Web Client"); ?></h1>
+<div class='note'>
+	<?php echo _mb("Do a Basic or Advanced Search of Catalogs in the system. Please visit the Catalog Admin to add a Catalog"); ?>
+</div>
+
+<div class="form-container">
+<form id="capabilitiesForm" name="addURLForm" method="post" action="">
+	<fieldset id="container_capabilities">
+		<legend>Capabilities</legend>
+			<p>
+				<!-- 
+				<label for="CapURL"><?php echo _mb("Capabilities-URL"); ?>:</label> 
+				<input type="text" id="CapURL" name="CapURL" /> 
+				<input type="button" id="addCapURL" name="addCapURL" value="<?php echo _mb("Add WMS"); ?>" onclick="mod_addWmsfromURL();" />
+				 -->
+				 
+				<label for="basic_search"><?php echo _mb("Search for "); ?>:</label> 
+				<input type="text" id="basic_search" name="basic_search" />
+				<br /> 
+			</p>
+	</fieldset>
+		
+		<!-- Show via inner HTML -->
+		<div id="advanced_div">
+		<fieldset>
+			<input type="button" id="adv_search_show" name="adv_search_show" value="<?php echo _mb("+ Advanced"); ?>" onclick="show_advanced_form();" />
+		</fieldset>
+		</div>
+		
+		
+		<input type="button" id="basic_search_submit" name="addCapURL" value="<?php echo _mb("Search CSW"); ?>" onclick="mod_searchCSWSimple();" />
+</form>
+</div>
+
+<!-- 
+<form id="addWMSForm" name="addWMSForm" method="post" action="">
+<fieldset id="container_buttons">
+<legend>WMS list(s)</legend>
+	<p>
+		<input type="button" name="button_dbAll"   id="button_dbAll"   value="<?php echo _mb("List all WMS"); ?>" onclick="setSource('db');getWMSByGUI(gui_list)">
+		<input type="button" name="button_dbGroup" id="button_dbGroup" value="<?php echo _mb("List WMS by Group"); ?>"   onclick="setSource('db');getGroups()"> 
+		<input type="button" name="button_dbGui"   id="button_dbGui"   value="<?php echo _mb("List WMS by Application"); ?>"     onclick="setSource('db');getGUIs()"> 
+	</p>
+</fieldset>
+</form>
+ -->
+
+<p id="progressIndicator" name="progressIndicator">
+	<img src="../img/indicator_wheel.gif" />
+	<?php echo _mb("Loading"); ?> ... 
+</p>
+
+<h2 id="resultString" name="resultString"></h2>
+
+<table id="resultTable" name="resultTable">
+	<thead>
+		<tr>
+			<th id="titleLeft" name="titleLeft"></th>
+			<th id="titleRight" name="titleRight"></th>
+		</tr>
+	</thead>
+	<tbody id="resultTableBody" name="resultTableBody">
+	</tbody>
+</table>
+</body>
+
+</html>
\ No newline at end of file



More information about the Mapbender_commits mailing list