diff --git a/lang/en/help/textformat.html b/lang/en/help/textformat.html
index 8ef87f74242..147132aba18 100644
--- a/lang/en/help/textformat.html
+++ b/lang/en/help/textformat.html
@@ -50,4 +50,17 @@
It still translates smilies and new lines, but otherwise your
text isn't touched.
+
+
+
+
4. Wiki text format
+
+This format uses a special way of typing text known as the
+ Wiki format.
+
This format allows you to type text in a way that still looks
+ very readable, but can also be automatically converted into
+ HTML text with headings, lists and other complex formatting.
+
+
helpbutton("wiki", get_string("helpwiki")) ?> More info about Wiki
+
diff --git a/lang/en/moodle.php b/lang/en/moodle.php
index 75018cf0bb0..81ab3e611c0 100644
--- a/lang/en/moodle.php
+++ b/lang/en/moodle.php
@@ -224,6 +224,7 @@ $string['formattext'] = "Moodle auto-format";
$string['formattexttype'] = "Formatting";
$string['formattopics'] = "Topics format";
$string['formatweeks'] = "Weekly format";
+$string['formatwiki'] = "Wiki format";
$string['frontpagedescription'] = "Front page description";
$string['frontpageformat'] = "Front page format";
$string['fulllistofcourses'] = "All courses";
diff --git a/lib/weblib.php b/lib/weblib.php
index 5fe0f6f61a5..3bbe13a629f 100644
--- a/lib/weblib.php
+++ b/lib/weblib.php
@@ -33,8 +33,9 @@
/// Define text formatting types ... eventually we can add Wiki, BBcode etc
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)
+define("FORMAT_HTML", "1"); // Plain HTML (with some tags stripped)
+define("FORMAT_PLAIN", "2"); // Plain text (even tags are printed in full)
+define("FORMAT_WIKI", "3"); // Wiki-formatted text
$JAVASCRIPT_TAGS = array("javascript:", "onclick=", "ondblclick=", "onkeydown=", "onkeypress=", "onkeyup=",
"onmouseover=", "onmouseout=", "onmousedown=", "onmouseup=",
@@ -421,7 +422,8 @@ 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_PLAIN => get_string("formatplain"));
+ FORMAT_PLAIN => get_string("formatplain"),
+ FORMAT_WIKI => get_string("formatwiki"));
}
function format_text($text, $format=FORMAT_MOODLE, $options=NULL) {
@@ -444,6 +446,13 @@ function format_text($text, $format=FORMAT_MOODLE, $options=NULL) {
return $text;
break;
+ case FORMAT_WIKI:
+ $text = wiki_to_html($text);
+ $text = replace_smilies($text);
+ return $text;
+ break;
+
+
default: // FORMAT_MOODLE or anything else
if (!isset($options->smiley)) {
$options->smiley=true;
@@ -456,6 +465,30 @@ function format_text($text, $format=FORMAT_MOODLE, $options=NULL) {
}
}
+function format_text_email($text, $format) {
+/// Given text in a variety of format codings, this function returns
+/// the text as plain text suitable for plain email.
+///
+/// $text is raw text (originally from a user)
+/// $format is one of the format constants, defined above
+
+ switch ($format) {
+
+ case FORMAT_PLAIN:
+ return $text;
+ break;
+
+ case FORMAT_WIKI:
+ $text = wiki_to_html($text);
+ return strip_tags($text);
+ break;
+
+ default: // FORMAT_MOODLE or anything else
+ // Need to add something in here to create a text-friendly way of presenting URLs
+ return strip_tags($text);
+ break;
+ }
+}
function clean_text($text, $format) {
/// Given raw text (eg typed in by a user), this function cleans it up
@@ -463,15 +496,10 @@ function clean_text($text, $format) {
global $JAVASCRIPT_TAGS, $ALLOWED_TAGS;
- switch ($format) { // Does the same thing, currently, but it's nice to have the option
+ switch ($format) {
case FORMAT_MOODLE:
- $text = strip_tags($text, $ALLOWED_TAGS);
- foreach ($JAVASCRIPT_TAGS as $tag) {
- $text = stri_replace($tag, "", $text);
- }
- return $text;
-
case FORMAT_HTML:
+ case FORMAT_WIKI:
$text = strip_tags($text, $ALLOWED_TAGS);
foreach ($JAVASCRIPT_TAGS as $tag) {
$text = stri_replace($tag, "", $text);
diff --git a/mod/forum/lib.php b/mod/forum/lib.php
index 2d949cef6c4..247dfefd6a9 100644
--- a/mod/forum/lib.php
+++ b/mod/forum/lib.php
@@ -220,7 +220,7 @@ function forum_cron () {
$posttext .= "$post->subject\n";
$posttext .= $strbynameondate."\n";
$posttext .= "---------------------------------------------------------------------\n";
- $posttext .= strip_tags($post->message);
+ $posttext .= format_text_email($post->message, $post->format);
$posttext .= "\n\n";
if ($post->attachment) {
$post->course = $course->id;