Browse files

Added benchmark and test for replace_smilies

  • Loading branch information...
1 parent 4c31e7c commit 617778f2d32af138061f5f6596012954374f9bf9 gregb_cc committed Mar 12, 2003
Showing with 9 additions and 4 deletions.
  1. +9 −4 lib/weblib.php
View
13 lib/weblib.php
@@ -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);
}

0 comments on commit 617778f

Please sign in to comment.