]> git.mjollnir.org Git - moodle.git/commitdiff
Added Wiki format as a system-wide format (forums, journals, etc)
authormoodler <moodler>
Sun, 4 May 2003 04:07:36 +0000 (04:07 +0000)
committermoodler <moodler>
Sun, 4 May 2003 04:07:36 +0000 (04:07 +0000)
Also, added better formatting to plain-text emails via a new function
in weblib.php  -  format_text_email

lang/en/help/textformat.html
lang/en/moodle.php
lib/weblib.php
mod/forum/lib.php

index 8ef87f74242a06ffefde222fdd0e8533d5004e1d..147132aba180c951b981205bab77abfb700fa9ed 100644 (file)
 
 <P>It still translates smilies and new lines, but otherwise your 
    text isn't touched.
+</UL>
+
+
+<P><B>4. Wiki text format</B></P>
+<UL>
+<P>This format uses a special way of typing text known as the 
+   Wiki format.
+<P>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.
+
+<P ALIGN=RIGHT><? helpbutton("wiki", get_string("helpwiki")) ?> More info about Wiki</P>
+</UL>
 
index 75018cf0bb0a75854908c646b927d7e91e0846c1..81ab3e611c0edb4be132a8275b4de5f36f7c92bd 100644 (file)
@@ -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";
index 5fe0f6f61a55ab8ff2262f0615800ffc2c68edc7..3bbe13a629f9f3a328797790e915b6250b9be828 100644 (file)
@@ -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);
index 2d949cef6c4f74259527bfac49d8f3ba19c9bf04..247dfefd6a9b601943f43722d7d892fa9711675e 100644 (file)
@@ -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;