From ee01c3a0ada47f848de70485561fadc6f0c1e95a Mon Sep 17 00:00:00 2001 From: Patrick Vandermaesen Date: Mon, 29 Jan 2007 22:56:46 +0100 Subject: [PATCH] [svn r10978] header and footer function for wcag editor --- main/inc/lib/WCAG/WCAG_rendering.php | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/main/inc/lib/WCAG/WCAG_rendering.php b/main/inc/lib/WCAG/WCAG_rendering.php index a62ed948ed..520e8b2284 100644 --- a/main/inc/lib/WCAG/WCAG_rendering.php +++ b/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 '
WCAG editor
'; + } + + function editor_footer() { + return '
'; + } + 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(">", ">", $t); + $t = str_replace("<", "<", $t); $t = preg_replace("/(\015\012)|(\015)|(\012)/", "
\n", $t); $t = str_replace(" ", "  ", $t); return $t; } +function HTML_to_text ($xhtml) { + // convert HTML to text. + $text = str_replace("
", "", $xhtml); + $text = str_replace("
", "", $text); + $text = str_replace(" ", " ", $text); + return $text; +} + function extract_data ($xhtml) { $startP = stripos ($xhtml, "

"); $endP = stripos ($xhtml, "

"); $text = substr ($xhtml, $startP+3, $endP-$startP-3 ); // convert HTML to text. - $text = str_replace("
", "", $text); - $text = str_replace(" ", " ", $text); + $text = WCAG_Rendering::HTML_to_text($text); $startImgURL = stripos ($xhtml, "src=\""); $endImgURL = stripos ($xhtml, "\" ");