mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
Added Wiki format as a system-wide format (forums, journals, etc)
Also, added better formatting to plain-text emails via a new function in weblib.php - format_text_email
This commit is contained in:
parent
d7c8a46bc5
commit
d342c76370
@ -50,4 +50,17 @@
|
||||
|
||||
<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>
|
||||
|
||||
|
@ -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";
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user