]> git.mjollnir.org Git - moodle.git/commitdiff
New plain text format.
authormoodler <moodler>
Sun, 27 Apr 2003 10:46:16 +0000 (10:46 +0000)
committermoodler <moodler>
Sun, 27 Apr 2003 10:46:16 +0000 (10:46 +0000)
Translates smileys and carriage returns, but prints all other tags and code
as plain text

lang/en/moodle.php
lib/weblib.php

index c2f33ca8814aba6ba4b0accdc3a1482b26055601..db5249e7126b1f85f34ee26df527a35daf4ec63f 100644 (file)
@@ -187,6 +187,7 @@ $string['followingrequired'] = "The following items are required";
 $string['forgotten'] = "Forgotten your username or password?";
 $string['format'] = "Format";
 $string['formathtml'] = "HTML format";
+$string['formatplain'] = "Plain text format";
 $string['formatsocial'] = "Social format";
 $string['formattext'] = "Moodle auto-format";
 $string['formattexttype'] = "Formatting";
index 8bb6c47a1ab4f412cd7ac6a5367afccd15617778..73a44bf8c118ff11a43c837b656b63e360ebd86d 100644 (file)
@@ -32,8 +32,9 @@
 /// Constants
 
 /// Define text formatting types ... eventually we can add Wiki, BBcode etc
-define("FORMAT_MOODLE", "0");
-define("FORMAT_HTML", "1");
+define("FORMAT_MOODLE", "0");   // Does all sorts of transformations and filtering
+define("FORMAT_HTML", "1");     // Plain HTML (with some tags stripped)
+define("FORMAT_PLAIN", "2");    // Plain text (even tags are printed in full)
 
 $JAVASCRIPT_TAGS = array("javascript:", "onclick=", "ondblclick=", "onkeydown=", "onkeypress=", "onkeyup=", 
                          "onmouseover=", "onmouseout=", "onmousedown=", "onmouseup=",
@@ -419,7 +420,8 @@ function parse_slash_arguments($string, $i=0) {
 function format_text_menu() {
 /// Just returns an array of formats suitable for a popup menu
     return array (FORMAT_MOODLE => get_string("formattext"), 
-                  FORMAT_HTML   => get_string("formathtml") );
+                  FORMAT_HTML   => get_string("formathtml"),
+                  FORMAT_PLAIN  => get_string("formatplain"));
 }
 
 function format_text($text, $format=FORMAT_MOODLE, $options=NULL) {
@@ -435,6 +437,13 @@ function format_text($text, $format=FORMAT_MOODLE, $options=NULL) {
             return $text;
             break;
 
+        case FORMAT_PLAIN:
+            $text = htmlentities($text);
+            $text = replace_smilies($text);
+            $text = nl2br($text);
+            return $text;
+            break;
+
         default:  // FORMAT_MOODLE or anything else
             if (!isset($options->smiley)) {
                 $options->smiley=true;
@@ -468,6 +477,9 @@ function clean_text($text, $format) {
                 $text = stri_replace($tag, "", $text);
             }
             return $text;
+
+        case FORMAT_PLAIN:
+            return $text;
     }
 }