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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Mar 28 04:50:08 EDT 2007


Author: christoph
Date: 2007-03-28 04:50:08 -0400 (Wed, 28 Mar 2007)
New Revision: 1247

Modified:
   trunk/mapbender/http/classes/class_wmc.php
Log:
refactoring
removed obsolete code

Modified: trunk/mapbender/http/classes/class_wmc.php
===================================================================
--- trunk/mapbender/http/classes/class_wmc.php	2007-03-28 08:49:09 UTC (rev 1246)
+++ trunk/mapbender/http/classes/class_wmc.php	2007-03-28 08:50:08 UTC (rev 1247)
@@ -16,9 +16,11 @@
 # 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("../../conf/mapbender.conf");
 require_once("../classes/class_wms.php");
 require_once("../classes/class_mb_exception.php");
+
 function mb_utf8_encode ($str) {
 	if(CHARSET=="UTF-8") return utf8_encode($str);
 	return $str;
@@ -97,177 +99,167 @@
 		var $wmc_layer_style_sld_url = array();
 		var $wmc_layer_style_sld_type = array();
 		var $wmc_layer_style_sld_title = array();
-		
 		var $wmc_wms_count = 0;
 			
-	/*	
-	 	var $data_type = array(); 
-		var $data_format = array();
-		
-		var $objLayer = array(); 
-		  
-		var $gui_wms_mapformat;
-		var $gui_wms_featureinfoformat;
-		var $gui_wms_exceptionformat;
-		var $gui_wms_epsg;
-		  
-		var $default_epsg = 0;
-  */
-  function wmc() {
+	function wmc() {	
+	} 
 	
-  } 
-
-function getTitle() {
-	return $this->wmc_title;
-}
-
-function getNumberOfWms () {
-	return $this->wmc_wms_count;
-}
-
-function createObjFromWMC_id($wmc_id){
+	function getTitle() {
+		return $this->wmc_title;
+	}
 	
-	global $DBSERVER,$DB,$OWNER,$PW;
-	$con = db_connect($DBSERVER,$OWNER,$PW);
-	db_select_db(DB, $con);
-	
-	$sql = "SELECT wmc FROM mb_user_wmc WHERE wmc_id = '" . $wmc_id . "'";
-	$res = db_query($sql);
-	$wmc = db_fetch_row($res);
-	$this->createObjFromWMC_xml($wmc[0]);
-
-}
-function createObjFromWMC_xml($data){
-	$data = str_replace("&", "&", $data);
-	$values = NULL;
-	$tags = NULL;
-	$parser = xml_parser_create(CHARSET);
-	xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
-	xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
-	xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING,CHARSET);
-	xml_parse_into_struct($parser,$data,$values,$tags);
-	$code = xml_get_error_code ($parser);
-	if ($code) {
-		$line = xml_get_current_line_number($parser); 
-		$mb_exception = new mb_exception(xml_error_string($code) .  " in line " . $line);
-		return false;
+	function getNumberOfWms () {
+		return $this->wmc_wms_count;
 	}
-	xml_parser_free($parser);
+
+	function createObjFromWMC_id($wmc_id){
+		
+		$con = db_connect(DBSERVER,OWNER,PW);
+		db_select_db(DB, $con);
+		
+		$sql = "SELECT wmc FROM mb_user_wmc WHERE wmc_id = $1";
+		$v = array($wmc_id);
+		$t = array("s");
+		$res = db_prep_query($sql, $v, $t);
+		$wmc = db_fetch_array($res);
+		$this->createObjFromWMC_xml($wmc[0]);
 	
-	$section = NULL;
-	$format = NULL;
-	$cnt_format = 0;
-	$parent = array();
-	$myParent = array();
-	$cnt_layer = -1;
-	$request = NULL; 
-	$layer_style = array();
-	$cnt_styles = -1;
-	$extension = false;
-	
-	$general = false;
-	$layerlist = false;
-	$layer = false;
-	
-	foreach ($values as $element) {
-					$verbose .= ".";
-		if(strtoupper($element[tag]) == "VIEWCONTEXT" && $element[type] == "open"){
-				$this->wmc_id = $element[attributes]["id"];
-				$this->wmc_version = $element[attributes]["version"];
+	}
+
+	function createObjFromWMC_xml($data){
+		$data = str_replace("&", "&", $data);
+		$values = NULL;
+		$tags = NULL;
+		$parser = xml_parser_create(CHARSET);
+		xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
+		xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
+		xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING,CHARSET);
+		xml_parse_into_struct($parser,$data,$values,$tags);
+		$code = xml_get_error_code ($parser);
+		if ($code) {
+			$line = xml_get_current_line_number($parser); 
+			$mb_exception = new mb_exception(xml_error_string($code) .  " in line " . $line);
+			return false;
 		}
-		if(strtoupper($element[tag]) == "GENERAL" && $element[type] == "open"){
-		   $general = true;
-		}
-		if(strtoupper($element[tag]) == "LAYERLIST" && $element[type] == "open"){
-		   $layerlist = true;
-		}
-		if ($general) {
+		xml_parser_free($parser);
+		
+		$section = NULL;
+		$format = NULL;
+		$cnt_format = 0;
+		$parent = array();
+		$myParent = array();
+		$cnt_layer = -1;
+		$request = NULL; 
+		$layer_style = array();
+		$cnt_style = -1;
+		$extension = false;
+		
+		$general = false;
+		$layerlist = false;
+		$layer = false;
+		$formatlist = false;
+		$metadataurl = false;
+		$dataurl = false;
+		$stylelist = false;
+		
+		foreach ($values as $element) {
+			if(strtoupper($element[tag]) == "VIEWCONTEXT" && $element[type] == "open"){
+					$this->wmc_id = $element[attributes]["id"];
+					$this->wmc_version = $element[attributes]["version"];
+			}
+			if(strtoupper($element[tag]) == "GENERAL" && $element[type] == "open"){
+			   $general = true;
+			}
+			if(strtoupper($element[tag]) == "LAYERLIST" && $element[type] == "open"){
+			   $layerlist = true;
+			}
+			if ($general) {
 				if(strtoupper($element[tag]) == "WINDOW"){
-						$this->wmc_windowWidth = $element[attributes]["width"];
-						$this->wmc_windowHeight = $element[attributes]["height"];
+					$this->wmc_windowWidth = $element[attributes]["width"];
+					$this->wmc_windowHeight = $element[attributes]["height"];
 				}
 				if(strtoupper($element[tag]) == "BOUNDINGBOX"){
-						$this->wmc_bBox_SRS = $element[attributes]["SRS"];
-						$this->wmc_bBox_minx = $element[attributes]["minx"];
-						$this->wmc_bBox_miny = $element[attributes]["miny"];
-						$this->wmc_bBox_maxx = $element[attributes]["maxx"];
-						$this->wmc_bBox_maxy = $element[attributes]["maxy"];
+					$this->wmc_bBox_SRS = $element[attributes]["SRS"];
+					$this->wmc_bBox_minx = $element[attributes]["minx"];
+					$this->wmc_bBox_miny = $element[attributes]["miny"];
+					$this->wmc_bBox_maxx = $element[attributes]["maxx"];
+					$this->wmc_bBox_maxy = $element[attributes]["maxy"];
 				}
 				if(strtoupper($element[tag]) == "NAME"){
-						$this->wmc_name = mb_utf8_decode(html_entity_decode($element[value]));
+					$this->wmc_name = mb_utf8_decode(html_entity_decode($element[value]));
 				}
 				if(strtoupper($element[tag]) == "TITLE"){
-						$this->wmc_title = mb_utf8_decode(html_entity_decode($element[value]));
+					$this->wmc_title = mb_utf8_decode(html_entity_decode($element[value]));
 				}
 				if(strtoupper($element[tag]) == "ABSTRACT"){
-						$this->wmc_abstract = mb_utf8_decode(html_entity_decode($element[value]));
+					$this->wmc_abstract = mb_utf8_decode(html_entity_decode($element[value]));
 				}
 				if(strtoupper($element[tag]) == "CONTACTINFORMATION" && $element['type'] == "open"){
-						$contactinformation = true;
+					$contactinformation = true;
 				}
 				if ($contactinformation) {
 					if(strtoupper($element[tag]) == "CONTACTPOSITION"){
-							$this->wmc_contactposition = mb_utf8_decode(html_entity_decode($element[value]));
+						$this->wmc_contactposition = mb_utf8_decode(html_entity_decode($element[value]));
 					}
 					if(strtoupper($element[tag]) == "CONTACTVOICETELEPHONE"){
-							$this->wmc_contactvoicetelephone = $element[value];
+						$this->wmc_contactvoicetelephone = $element[value];
 					}
 					if(strtoupper($element[tag]) == "CONTACTFACSIMILETELEPHONE"){
-							$this->wmc_contactfacsimiletelephone = $element[value];
+						$this->wmc_contactfacsimiletelephone = $element[value];
 					}
 					if(strtoupper($element[tag]) == "CONTACTELECTRONICMAILADDRESS"){
-							$this->wmc_contactemail = mb_utf8_decode(html_entity_decode($element[value]));
+						$this->wmc_contactemail = mb_utf8_decode(html_entity_decode($element[value]));
 					}
 					if(strtoupper($element[tag]) == "CONTACTPERSONPRIMARY" && $element['type'] == "open"){
-							$contactpersonprimary = true;
+						$contactpersonprimary = true;
 					}
 					if ($contactpersonprimary) {
 						if(strtoupper($element[tag]) == "CONTACTPERSON"){
-								$this->wmc_contactperson = mb_utf8_decode(html_entity_decode($element[value]));
+							$this->wmc_contactperson = mb_utf8_decode(html_entity_decode($element[value]));
 						}
 						if(strtoupper($element[tag]) == "CONTACTORGANIZATION"){
-								$this->wmc_contactorganization = mb_utf8_decode(html_entity_decode($element[value]));
+							$this->wmc_contactorganization = mb_utf8_decode(html_entity_decode($element[value]));
 						}
 						if(strtoupper($element[tag]) == "CONTACTPERSONPRIMARY" && $element['type'] == "close"){
-								$contactpersonprimary = false;
+							$contactpersonprimary = false;
 						}
 					}
 					if(strtoupper($element[tag]) == "CONTACTADDRESS" && $element['type'] == "open"){
-							$contactaddress = true;
+						$contactaddress = true;
 					}
 					if ($contactaddress) {
 						if(strtoupper($element[tag]) == "ADDRESSTYPE"){
-								$this->wmc_contactaddresstype = mb_utf8_decode(html_entity_decode($element[value]));
+							$this->wmc_contactaddresstype = mb_utf8_decode(html_entity_decode($element[value]));
 						}
 						if(strtoupper($element[tag]) == "ADDRESS"){
-								$this->wmc_contactaddress = mb_utf8_decode(html_entity_decode($element[value]));
+							$this->wmc_contactaddress = mb_utf8_decode(html_entity_decode($element[value]));
 						}
 						if(strtoupper($element[tag]) == "CITY"){
-								$this->wmc_contactcity = mb_utf8_decode(html_entity_decode($element[value]));
+							$this->wmc_contactcity = mb_utf8_decode(html_entity_decode($element[value]));
 						}
 						if(strtoupper($element[tag]) == "STATEORPROVINCE"){
-								$this->wmc_contactstateorprovince = mb_utf8_decode(html_entity_decode($element[value]));
+							$this->wmc_contactstateorprovince = mb_utf8_decode(html_entity_decode($element[value]));
 						}
 						if(strtoupper($element[tag]) == "POSTCODE"){
-								$this->wmc_contactpostcode = $element[value];
+							$this->wmc_contactpostcode = $element[value];
 						}
 						if(strtoupper($element[tag]) == "COUNTRY"){
-								$this->wmc_contactcountry = mb_utf8_decode(html_entity_decode($element[value]));
+							$this->wmc_contactcountry = mb_utf8_decode(html_entity_decode($element[value]));
 						}
 						if(strtoupper($element[tag]) == "CONTACTADDRESS" && $element['type'] == "close"){
-								$contactaddress = false;
+							$contactaddress = false;
 						}
 					}
 				}
 				if(strtoupper($element[tag]) == "LOGOURL" && $element['type'] == "open"){
-						$logourl = true;
-						$this->wmc_logourl_width = $element[attributes]["width"];
-						$this->wmc_logourl_height = $element[attributes]["height"];
-						$this->wmc_logourl_format = $element[attributes]["format"];
+					$logourl = true;
+					$this->wmc_logourl_width = $element[attributes]["width"];
+					$this->wmc_logourl_height = $element[attributes]["height"];
+					$this->wmc_logourl_format = $element[attributes]["format"];
 				}
 				if ($logourl) {
 					if(strtoupper($element[tag]) == "LOGOURL" && $element['type'] == "close"){
-							$logourl = false;
+						$logourl = false;
 					}
 					if(strtoupper($element[tag]) == "ONLINERESOURCE"){
 						$this->wmc_logourl_type = $element[attributes]["xlink:type"];
@@ -275,12 +267,12 @@
 					}
 				}
 				if(strtoupper($element[tag]) == "DESCRIPTIONURL" && $element['type'] == "open"){
-						$descriptionurl = true;
-						$this->wmc_descriptionurl_format = $element[attributes]["format"];
+					$descriptionurl = true;
+					$this->wmc_descriptionurl_format = $element[attributes]["format"];
 				}
 				if ($descriptionurl) {
 					if(strtoupper($element[tag]) == "DESCRIPTIONURL" && $element['type'] == "close"){
-							$descriptionurl = false;
+						$descriptionurl = false;
 					}
 					if(strtoupper($element[tag]) == "ONLINERESOURCE"){
 						$this->wmc_descriptionurl_type = $element[attributes]["xlink:type"];
@@ -288,12 +280,12 @@
 					}
 				}
 				if(strtoupper($element[tag]) == "KEYWORDLIST" && $element['type'] == "open"){
-						$keywordlist = true;
+					$keywordlist = true;
 				}
 				if ($keywordlist) {
 					if(strtoupper($element[tag]) == "KEYWORDLIST" && $element['type'] == "close"){
-							$keywordlist = false;
-							$cnt_keyword = -1;
+						$keywordlist = false;
+						$cnt_keyword = -1;
 					}
 					if(strtoupper($element[tag]) == "KEYWORD"){
 						$cnt_keyword++;
@@ -304,8 +296,8 @@
 				if(strtoupper($element[tag]) == "GENERAL" && $element['type'] == "close"){
 		   			$general = false;
 			 	}
-		}
-		if ($layerlist) {
+			}
+			if ($layerlist) {
 				if(strtoupper($element[tag]) == "LAYERLIST" && $element['type'] == "close"){
 				   $layerlist = false;
 				}
@@ -317,9 +309,9 @@
       		 		 $cnt_epsg = 0;
 				}
 				if ($layer) {
-					 if(strtoupper($element[tag]) == "LAYER" && $element[type] == "close"){
-					 		$layer = false;
-					 }
+					if(strtoupper($element[tag]) == "LAYER" && $element[type] == "close"){
+						$layer = false;
+					}
 					 if ($formatlist) {
 						 if(strtoupper($element[tag]) == "FORMAT"){
 						 	$cnt_format++;
@@ -332,10 +324,10 @@
 					 }
 					 elseif ($metadataurl) {
 						 if(strtoupper($element[tag]) == "ONLINERESOURCE"){
-						 	$this->wmc_layer_metadataurl[$cnt_layer] = $element[attributes]["xlink:href"];
+							$this->wmc_layer_metadataurl[$cnt_layer] = $element[attributes]["xlink:href"];
 						 }
 						 if(strtoupper($element[tag]) == "METADATAURL" && $element[type] == "close"){
-							 $metadataurl = false;
+							$metadataurl = false;
 						 }
 					 }
 					 elseif ($dataurl) {
@@ -466,7 +458,6 @@
 			}
 		}
 		return true;
-	  //return $verbose;
 	}
 
 	function createJsObjFromWMC($target, $mapObj, $action){
@@ -570,7 +561,7 @@
 									$wmc_string .= "if (!wms_exists) {\n\t";
 								} 
 								// add parent layer
-								$wmc_string .= $target . "wms_add_layer('','".$this->wmc_layer_id[$i]."','','". $this->wmc_wms_title[$i] ."','','0','0','0','0','','".$id."','1','1','1','0','0','0','0');\n";
+								$wmc_string .= $target . "wms_add_layer('','".$this->wmc_layer_id[$i]."','','". $this->wmc_wms_title[$i] ."','','0','0','0','0','','".$this->wmc_wms_id[$i]."','1','1','1','0','0','0','0');\n";
 								if ($action == "merge") {
 									$wmc_string .= "}\n";
 								} 
@@ -616,7 +607,7 @@
 								$this->wmc_layer_minscale[$ii]  ."','". 
 								$this->wmc_layer_maxscale[$ii]  ."','". 
 								$this->wmc_layer_metadataurl[$ii] ."','". 
-								$id ."','1','1','". 
+								$this->wmc_wms_id[$ii] ."','1','1','". 
 								intval(!$this->wmc_layer_hidden[$ii]) ."','". 
 								$this->wmc_layer_queryable[$ii] ."','". 
 								$this->wmc_layer_queryable[$ii] ."','".



More information about the Mapbender_commits mailing list