]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-8976 smilies alt text was cached in one static cache for all langs; merged from...
authorskodak <skodak>
Tue, 20 Mar 2007 20:47:57 +0000 (20:47 +0000)
committerskodak <skodak>
Tue, 20 Mar 2007 20:47:57 +0000 (20:47 +0000)
lib/weblib.php

index 4ad2020243e5e351845b07745063c4cf04bbc132..39a1d35a7142ff8ee189eb7538bb24fe47bdc4a7 100644 (file)
@@ -1774,8 +1774,9 @@ function replace_smilies(&$text) {
 ///
     global $CFG;
 
+    $lang = current_language();
+
 /// this builds the mapping array only once
-    static $runonce = false;
     static $e = array();
     static $img = array();
     static $emoticons = array(
@@ -1809,14 +1810,15 @@ function replace_smilies(&$text) {
         '( )'  => 'egg'
         );
 
-    if ($runonce == false) {  /// After the first time this is not run again
+    if (empty($img[$lang])) {  /// After the first time this is not run again
+        $e[$lang] = array();
+        $img[$lang] = array();
         foreach ($emoticons as $emoticon => $image){
             $alttext = get_string($image, 'pix');
 
-            $e[] = $emoticon;
-            $img[] = '<img alt="'. $alttext .'" width="15" height="15" src="'. $CFG->pixpath .'/s/'. $image .'.gif" />';
+            $e[$lang][] = $emoticon;
+            $img[$lang][] = '<img alt="'. $alttext .'" width="15" height="15" src="'. $CFG->pixpath .'/s/'. $image .'.gif" />';
         }
-        $runonce = true;
     }
 
     // Exclude from transformations all the code inside <script> tags
@@ -1837,7 +1839,7 @@ function replace_smilies(&$text) {
     }
 
 /// this is the meat of the code - this is run every time
-    $text = str_replace($e, $img, $text);
+    $text = str_replace($e[$lang], $img[$lang], $text);
 
     // Recover all the <script> zones to text
     if ($excludes) {