Browse Source

[svn r10978] header and footer function for wcag editor

Patrick Vandermaesen 18 years ago
parent
commit
ee01c3a0ad
1 changed files with 21 additions and 5 deletions
  1. 21 5
      main/inc/lib/WCAG/WCAG_rendering.php

+ 21 - 5
main/inc/lib/WCAG/WCAG_rendering.php

@@ -30,9 +30,17 @@ include_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'
 */
 class WCAG_Rendering {
 	
+	function editor_header() {
+		return '<div id="WCAG-editor"><div class="title">WCAG editor</div><div class="body">';
+	}
+	
+	function editor_footer() {
+		return '</div></div>';
+	}
+	
 	function prepareXHTML() {
 		$text = $_POST['text'];
-		$text = WCAG_Rendering::text2HTML ( $text );
+		$text = WCAG_Rendering::text_to_HTML ( $text );
 		$imageFile = $_POST['imagefile'];				
 		$imageLabel = $_POST['imageLabel'];
 		$link = $_POST['link'];				
@@ -52,24 +60,32 @@ class WCAG_Rendering {
 /**
 * Converter Plaintext to (x)HTML
 */
-function text2HTML ($Text)
+function text_to_HTML ($Text)
 {
 		$t = $Text;
 		$t = stripslashes($t);
-		$t = htmlentities($t);
+		$t = str_replace(">", "&gt;", $t);
+		$t = str_replace("<", "&lt;", $t);
 
 		$t = preg_replace("/(\015\012)|(\015)|(\012)/", "<br />\n", $t);
 		$t = str_replace("  ", " &nbsp;", $t);
         return $t;
 }
 
+function HTML_to_text ($xhtml) {
+	// convert HTML to text.
+	$text = str_replace("<br />", "", $xhtml);
+	$text = str_replace("<br/>", "", $text);
+	$text = str_replace("&nbsp;", " ", $text);
+	return $text;
+}
+
 function extract_data ($xhtml) {
 	$startP = stripos ($xhtml, "<p>");
 	$endP =  stripos ($xhtml, "</p>");	
 	$text = substr ($xhtml, $startP+3, $endP-$startP-3 );
 	// convert HTML to text.
-	$text = str_replace("<br />", "", $text);
-	$text = str_replace("&nbsp;", " ", $text);
+	$text = WCAG_Rendering::HTML_to_text($text);
 	
 	$startImgURL = stripos ($xhtml, "src=\"");
 	$endImgURL = stripos ($xhtml, "\" ");