Kaynağa Gözat

[svn r10959] convert text -> HTML width WCAG editor

Patrick Vandermaesen 18 yıl önce
ebeveyn
işleme
71a3a17ad6

+ 18 - 0
main/WCAG/WCAG_rendering.php

@@ -29,6 +29,21 @@ include_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'
 * @version     1.0
 */
 class WCAG_Rendering {
+	
+	
+/**
+* Converter Plaintext to (x)HTML
+*/
+function text2HTML ($Text)
+{
+		$t = $Text;
+		$t = stripslashes($t);
+		$t = htmlentities($t);
+
+		$t = preg_replace("/(\015\012)|(\015)|(\012)/", "<br />\n", $t);
+		$t = str_replace("  ", " &nbsp;", $t);
+        return $t;
+}
 
 /**
 *	add a form for set WCAG content (replace FCK)
@@ -39,6 +54,9 @@ function &prepare_admin_form( $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);
 	
 	$startImgURL = stripos ($xhtml, "src=\"");
 	$endImgURL = stripos ($xhtml, "\" ");

+ 2 - 1
main/admin/configure_homepage.php

@@ -1,4 +1,4 @@
-<?php // $Id: configure_homepage.php 10956 2007-01-29 09:39:46Z pvandermaesen $
+<?php // $Id: configure_homepage.php 10959 2007-01-29 10:48:41Z pvandermaesen $
 /*
 ==============================================================================
 	Dokeos - elearning and course management software
@@ -70,6 +70,7 @@ if(!empty($action))
 			$home_top='';
 			if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
 				$text = $_POST['text'];
+				$text = WCAG_Rendering::text2HTML ( $text );
 				$imageFile = $_POST['imagefile'];				
 				$imageLabel = $_POST['imageLabel'];
 				$link = $_POST['link'];