$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";
/// 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=",
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) {
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;
$text = stri_replace($tag, "", $text);
}
return $text;
+
+ case FORMAT_PLAIN:
+ return $text;
}
}