Revert r46068 " Enable language conversion in "alt" and "title" attributes."
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 27 Jan 2009 23:12:42 +0000 (23:12 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 27 Jan 2009 23:12:42 +0000 (23:12 +0000)
Use of eval is strongly discouraged, on penalty of death. :) Needs to be redone using preg_replace_callback

languages/LanguageConverter.php

index bc27d41..aad2963 100644 (file)
@@ -198,24 +198,6 @@ class LanguageConverter {
 
        }
        
-       /**
-        * caption convert, base on preg_replace
-        *
-        * to convert text in "title" or "alt", like '<img alt="text" ... '
-        * or '<span title="text" ... '
-        *
-        * @param string $title the "title" or "alt" text
-        * @param string $text the text to be converted
-        * @param string $toVariant the target language code
-        * @return string like ' alt="yyyy"' or ' title="yyyy"'
-        */
-       protected function captionConvert( $title, $text, $toVariant ) {
-               // we convert captions except URL
-               if( !strpos( $text, '://' ) )
-                       $text = $this->translate($text, $toVariant);
-               return " $title=\"$text\"";
-       }
-
        /**
         * dictionary-based conversion
         *
@@ -266,14 +248,8 @@ class LanguageConverter {
 
                $ret = $this->translate($m[0], $toVariant);
                $mstart = $m[1]+strlen($m[0]);
-               
-               // enable convertsion of '<img alt="xxxx" ... ' or '<span title="xxxx" ... '
-               $captionpattern  = '/\s(title|alt)\s*=\s*"([\s\S]*?)"/e';
-               $replacement = "\$this->captionConvert('\\1', '\\2', \$toVariant)";
                foreach($matches as $m) {
-                       $mark = substr($text, $mstart, $m[1]-$mstart);
-                       $mark = preg_replace($captionpattern, $replacement, $mark);
-                       $ret .= $mark;
+                       $ret .= substr($text, $mstart, $m[1]-$mstart);
                        $ret .= $this->translate($m[0], $toVariant);
                        $mstart = $m[1] + strlen($m[0]);
                }