[Mapbender-commits] r4820 - branches/2.6/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Oct 20 08:08:10 EDT 2009


Author: christoph
Date: 2009-10-20 08:08:10 -0400 (Tue, 20 Oct 2009)
New Revision: 4820

Modified:
   branches/2.6/http/classes/class_element.php
Log:
HTML valid

Modified: branches/2.6/http/classes/class_element.php
===================================================================
--- branches/2.6/http/classes/class_element.php	2009-10-20 12:07:30 UTC (rev 4819)
+++ branches/2.6/http/classes/class_element.php	2009-10-20 12:08:10 UTC (rev 4820)
@@ -137,34 +137,64 @@
 			$openTag .= "<" . $this->element . " ";
 			
 			// id and name
-			$openTag .= "id='" . $this->id . "' name='" . $this->id . "' ";
+			$openTag .= "id='" . $this->id . "' ";
 			
+			$validTags = array(
+				"form",
+				"iframe",
+				"img",
+				"applet",
+				"button",
+				"frame",
+				"input",
+				"map",
+				"object",
+				"param",
+				"select",
+				"textarea"
+			);
+			if (in_array($this->element, $validTags)) {
+				$openTag .= "name='" . htmlentities($this->id, ENT_QUOTES, CHARSET) . "' ";
+			}
+			
 			// attributes
 			if ($this->attributes) {
 				$openTag .= stripslashes($this->replaceSessionStringByUrlParameters($this->attributes)) . " ";
 			}
 			
+			if ($this->element === "img" && !preg_match("/alt( )*=/", $this->attributes)) {
+				$openTag .= "alt='" . htmlentities($this->title, ENT_QUOTES, CHARSET) . "' ";
+			}
+			
 			// title
 			if ($this->title) {
-				$openTag .= "title='" . $this->title . "' ";
+				$openTag .= "title='" . htmlentities($this->title, ENT_QUOTES, CHARSET) . "' ";
 			}
+			else {
+				// add a title for iframes
+				if ($this->element === "iframe") {
+					$openTag .= "title='" . $this->id . "' ";
+				}
+			}
 			
 			// src
 			if ($this->src) {
-   				$openTag .= "src = '" . $this->replaceSessionStringByUrlParameters($this->src);
+   				$openTag .= "src = '" . $this->replaceSessionStringByUrlParameters(
+					htmlentities($this->src, ENT_QUOTES, CHARSET)
+				);
 
 				// for iframes which are not "loadData", 
 				// add additional parameters
 				if ($this->closeTag == "iframe" && $this->id != "loadData") {
 					if(mb_strpos($this->src, "?")) {
-						$openTag .= "&";
+						$openTag .= "&amp;";
 					}
 					else {
 	      				$openTag .= "?";
       				}
-	      			$openTag .= "e_id_css=" . $this->id . "&" .
-	      					 "e_id=" . $this->id . "&" .
-	      					 "e_target=" . $this->target . "&" .
+	      			$openTag .= "e_id_css=" . $this->id . "&amp;" .
+	      					 "e_id=" . $this->id . "&amp;" .
+	      					 "e_target=" . $this->target . "&amp;" .
 	      					 $this->getUrlParameters();
 				}
    				$openTag .= "' ";
@@ -196,7 +226,7 @@
 				
 				$splashScreen = "";
 				
-				if ($use_load_message) {
+				if (isset($use_load_message)) {
 					$this->isBodyAndUsesSplashScreen = true;
 					if (isset($htmlWhileLoading) && $htmlWhileLoading != '') {
 						$splashScreen .= $htmlWhileLoading; 
@@ -207,10 +237,10 @@
 						ob_end_clean();
 					}
 					else {
-						$splashScreen .= "<img src='../img/indicator_wheel.gif'>&nbsp;" . 
-							"<b>Ma<font color='#0000CE'>p</font><font color='#C00000'>b</font>ender " . 
-							MB_VERSION_NUMBER . " " . strtolower(MB_VERSION_APPENDIX) . "</b>..." .
-							"loading application '" . $this->guiId . "'";
+						$splashScreen .= "<img alt='indicator wheel' src='../img/indicator_wheel.gif'>&nbsp;" . 
+	"<strong>Ma<span style='font-color:#0000CE'>p</span><span style='font-color:#C00000'>b</span>ender " . 
+	MB_VERSION_NUMBER . " " . strtolower(MB_VERSION_APPENDIX) . "</strong>..." .
+	"loading application '" . $this->guiId . "'";
 					}
 				}	
 				$openTag .= "<div id='loading_mapbender' " .
@@ -233,7 +263,7 @@
 	}
 	
 	private function getHtmlCloseTag () {
-		if ($this->element == "body" && $this->isBodyAndUsesSplashScreen) {
+		if ($this->element == "body") {
 			return "</div></body>";
 		}
 		if ($this->closeTag != "") {
@@ -250,7 +280,7 @@
 		if (isset($this->id)) {
 			$urlParameters .= "&elementID=" . $this->id;
 		}
-		return $urlParameters;
+		return htmlentities($urlParameters, ENT_QUOTES, CHARSET);
 	}
 	
 	private function replaceSessionStringByUrlParameters ($string) {



More information about the Mapbender_commits mailing list