[Mapbender-commits] r2541 - trunk/mapbender/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Jun 23 11:59:26 EDT 2008


Author: christoph
Date: 2008-06-23 11:59:25 -0400 (Mon, 23 Jun 2008)
New Revision: 2541

Modified:
   trunk/mapbender/http/classes/class_gui.php
   trunk/mapbender/http/classes/class_wms.php
Log:


Modified: trunk/mapbender/http/classes/class_gui.php
===================================================================
--- trunk/mapbender/http/classes/class_gui.php	2008-06-23 15:58:56 UTC (rev 2540)
+++ trunk/mapbender/http/classes/class_gui.php	2008-06-23 15:59:25 UTC (rev 2541)
@@ -18,6 +18,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+require_once(dirname(__FILE__)."/../classes/class_element.php");
 
 $con = db_connect($DBSERVER,$OWNER,$PW);
 db_select_db(DB,$con);
@@ -27,9 +28,51 @@
  */
 class gui {
 
-	public function __construct () {
+	var $id;
+	var $elementArray = array();
+	
+	public function __construct ($id) {
+		if ($id) {
+			$this->id = $id;
+			$this->elementArray = $this->selectElements();
+		}
 	}
 
+	public function selectElements () {
+		$sql = "SELECT e_id FROM gui_element WHERE fkey_gui_id = $1 " . 
+				"ORDER BY e_pos";
+		$v = array($this->id);
+		$t = array('s');
+		$res = db_prep_query($sql,$v,$t);
+		$elementArray = array();
+		while ($row = db_fetch_array($res)) {
+			array_push($elementArray, $row[0]);
+		}
+
+		$this->elementArray = array();
+		for ($i = 0; $i < count($elementArray); $i++) {
+			$currentElement = new Element();
+			$currentElement->select($elementArray[$i], $this->id);
+			array_push($this->elementArray, $currentElement);
+		}
+		return $this->elementArray;
+	}
+
+	public function toHtml () {
+		$htmlString = "";
+		$htmlString .= $this->elementsToHtml();
+		return $htmlString;
+	}
+
+	public function getJavaScriptModules () {
+		$jsArray = array();
+		for ($i = 0; $i < count($this->elementArray); $i++) {
+			$currentElement = $this->elementArray[$i];
+			array_merge($jsArray, $currentElement->getJavaScriptModules());			
+		}
+		return $jsArray;
+	}
+	
  	/**
  	 * Checks if a GUI with a given ID exists in the database
  	 * 
@@ -221,5 +264,33 @@
 	      return false;
 		}
 	}
+
+	private function elementsToHtml () {
+		$bodyStringArray = array();
+		$elementString = "";
+		for ($i = 0; $i < count($this->elementArray); $i++) {
+			$currentElement = $this->elementArray[$i];
+			if ($currentElement->id != "body") {
+				$elementString .= $currentElement->toHtml();
+			}
+			else {
+				$bodyStringArray = $currentElement->toHtmlArray();
+			}
+		}
+		$elementString .= "<form id='sendData' name='sendData' action='' " .
+						  "method='POST' target='loadData' " .
+						  "style='position:absolute;left:800px'>" .
+						  "<input type='hidden' name='data'></form>";
+
+		if (count($bodyStringArray) == 3) {
+			$elementString = $bodyStringArray[0] . 
+				$bodyStringArray[1] .
+				$elementString . 
+				$bodyStringArray[2];
+			
+		}
+		return $elementString;			
+	}
+	
 }
 ?>
\ No newline at end of file

Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php	2008-06-23 15:58:56 UTC (rev 2540)
+++ trunk/mapbender/http/classes/class_wms.php	2008-06-23 15:59:25 UTC (rev 2541)
@@ -75,6 +75,31 @@
 	  
 	function wms() {
 	} 
+
+	function createOlObjFromWMS($base){
+	 	if(!$this->wms_title || $this->wms_title == ""){
+			echo "alert('Error: no valid capabilities-document !!');";
+			die; exit;
+		}
+		// wms_title and abstract have previously been urlencoded
+		// this solution may not yet be the ultimate one
+		
+		$add_wms_string = "var wms_".$this->wms_id." = new OpenLayers.Layer.WMS.Untiled(" .
+				"'" . addslashes($this->wms_title) . "'," .
+				"'" . $this->wms_getmap ."'," ."{layers:'";
+				for($i=1;$i<count($this->objLayer);$i++){
+					$add_wms_string .= addslashes($this->objLayer[$i]->layer_name);
+					if($i!=count($this->objLayer)-1)
+						$add_wms_string .= ",";
+				}
+				$add_wms_string .= "', transparent: 'true'";
+				$add_wms_string .= ",format: '".$this->gui_wms_mapformat."'});\n";
+				if($base)
+					$add_wms_string .= 	"wms_".$this->wms_id.".isBaseLayer=true;\n";
+				$add_wms_string .= 	"wms_".$this->wms_id.".setVisibility(".($this->gui_wms_visible=="1"?"true":"false").");\n";
+				$add_wms_string .= "ol_map.addLayer(wms_".$this->wms_id.");\n";
+		echo $add_wms_string;
+	}	
 	
 	/**
 	 * Compares this WMS to another WMS.



More information about the Mapbender_commits mailing list