]> git.mjollnir.org Git - moodle.git/commitdiff
Added benchmark and test for replace_smilies
authorgregb_cc <gregb_cc>
Wed, 12 Mar 2003 20:36:55 +0000 (20:36 +0000)
committergregb_cc <gregb_cc>
Wed, 12 Mar 2003 20:36:55 +0000 (20:36 +0000)
lib/weblib.php

index f12cbfa46d26e5bca7dfaeecf8c085e3bae7d3ff..3a010c1221303c7d2f32bede148bac3cd62ea32b 100644 (file)
@@ -473,7 +473,9 @@ function replace_smilies($text) {
 /// Replaces all known smileys in the text with image equivalents
     global $CFG;
 
-    $emoticons = array(
+    static $runonce = false;
+    static $smilies = false;
+    static $emoticons = array(
         ':-)'  => 'smiley.gif',
         ':)'   => 'smiley.gif',
         ':-D'  => 'biggrin.gif',
@@ -498,9 +500,12 @@ function replace_smilies($text) {
         '}-]'  => 'evil.gif',
         );
 
-    foreach ($emoticons as $emoticon => $image){
-        $smilies[$emoticon] = "<IMG ALT=\"$emoticon\" WIDTH=15 HEIGHT=15 SRC=\"{$CFG->wwwroot}/pix/s/{$image}\">";
-    }
+    if($runonce == false):
+        foreach ($emoticons as $emoticon => $image){
+            $smilies[$emoticon] = "<IMG ALT=\"$emoticon\" WIDTH=15 HEIGHT=15 SRC=\"{$CFG->wwwroot}/pix/s/{$image}\">";
+        }
+        $runonce = true;
+    endif;
 
     return strtr($text, $smilies);
 }