]> git.mjollnir.org Git - moodle.git/commitdiff
Smiley conversion is now optional (better for html mail)
authormartin <martin>
Sat, 18 May 2002 05:22:48 +0000 (05:22 +0000)
committermartin <martin>
Sat, 18 May 2002 05:22:48 +0000 (05:22 +0000)
lib/weblib.php

index eb0904483a4f396ca33654c8ece3159c84fb2ffd..2e1201889c67a52d01ce6ce514a31e0a01c13d98 100644 (file)
@@ -264,7 +264,7 @@ function cleantext($text) {
 }
 
 
-function text_to_html($text) {
+function text_to_html($text, $smiley=true) {
 // Given plain text, makes it into HTML as nicely as possible.
 
     global $CFG;
@@ -282,16 +282,18 @@ function text_to_html($text) {
 
     // Turn smileys into images.
 
-    $text = ereg_replace(":)", "<IMG ALT=smile SRC=$CFG->wwwroot/pix/s/smiley.gif>", $text);
-    $text = ereg_replace(":-)", "<IMG ALT=smile SRC=$CFG->wwwroot/pix/s/smiley.gif>", $text);
-    $text = ereg_replace(":-D", "<IMG ALT=grin SRC=$CFG->wwwroot/pix/s/biggrin.gif>", $text);
-    $text = ereg_replace(";-)", "<IMG ALT=wink SRC=$CFG->wwwroot/pix/s/wink.gif>", $text);
-    $text = ereg_replace("8-)", "<IMG ALT=wide-eyed SRC=$CFG->wwwroot/pix/s/wideeyes.gif>", $text);
-    $text = ereg_replace(":-\(", "<IMG ALT=sad SRC=$CFG->wwwroot/pix/s/sad.gif>", $text);
-    $text = ereg_replace(":-P", "<IMG ALT=tongue-out SRC=$CFG->wwwroot/pix/s/tongueout.gif>", $text);
-    $text = ereg_replace(":-/", "<IMG ALT=mixed SRC=$CFG->wwwroot/pix/s/mixed.gif>", $text);
-    $text = ereg_replace(":-o", "<IMG ALT=surprised SRC=$CFG->wwwroot/pix/s/surprise.gif>", $text);
-    $text = ereg_replace("B-)", "<IMG ALT=cool SRC=$CFG->wwwroot/pix/s/cool.gif>", $text);
+    if ($smiley) {
+        $text = ereg_replace(":)",  "<IMG ALT=\"{smile}\" SRC=\"$CFG->wwwroot/pix/s/smiley.gif\">", $text);
+        $text = ereg_replace(":-)", "<IMG ALT=\"{smile}\" SRC=\"$CFG->wwwroot/pix/s/smiley.gif\">", $text);
+        $text = ereg_replace(":-D", "<IMG ALT=\"{grin}\" SRC=\"$CFG->wwwroot/pix/s/biggrin.gif\">", $text);
+        $text = ereg_replace(";-)", "<IMG ALT=\"{wink}\" SRC=\"$CFG->wwwroot/pix/s/wink.gif\">", $text);
+        $text = ereg_replace("8-)", "<IMG ALT=\"{wide-eyed}\" SRC=\"$CFG->wwwroot/pix/s/wideeyes.gif\">", $text);
+        $text = ereg_replace(":-\(","<IMG ALT=\"{sad}\" SRC=\"$CFG->wwwroot/pix/s/sad.gif\">", $text);
+        $text = ereg_replace(":-P", "<IMG ALT=\"{tongue-out}\" SRC=\"$CFG->wwwroot/pix/s/tongueout.gif\">", $text);
+        $text = ereg_replace(":-/", "<IMG ALT=\"{mixed}\" SRC=\"$CFG->wwwroot/pix/s/mixed.gif\">", $text);
+        $text = ereg_replace(":-o", "<IMG ALT=\"{surprised}\" SRC=\"$CFG->wwwroot/pix/s/surprise.gif\">", $text);
+        $text = ereg_replace("B-)", "<IMG ALT=\"{cool}\" SRC=\"$CFG->wwwroot/pix/s/cool.gif\">", $text);
+    }
 
     return "<P>".$text."</P>";
 }