Permalink
Browse files

Bug #4375 - did not work correctly in blocks.

  • Loading branch information...
1 parent f5a4f9a commit ef1c5c394e996ee175c7bf8903abed28ffaac75d thepurpleblob committed Jul 6, 2006
Showing with 9 additions and 5 deletions.
  1. +9 −5 filter/multilang/filter.php
View
14 filter/multilang/filter.php
@@ -47,15 +47,13 @@ function multilang_filter($courseid, $text) {
*/
// [pj] I don't know about you but I find this new implementation funny :P
-
$search = '/(<(?:lang|span) lang="[a-zA-Z0-9_-]*".*?>.+?<\/(?:lang|span)>\s*)+/is';
return preg_replace_callback($search, 'multilang_filter_impl', $text);
}
function multilang_filter_impl($langblock) {
global $CFG;
-
// This callbackis going to get called multiple times, so cache $preflangs
static $preflangs = NULL;
@@ -99,12 +97,10 @@ function multilang_filter_impl($langblock) {
$preflangs[] = 'en';
}
}
-
// Setup is done, now do multilang replacement on the match we 've been called for
$searchtosplit = '/<(?:lang|span) lang="([a-zA-Z0-9_-]*)".*?>(.+?)<\/(?:lang|span)>/is';
preg_match_all($searchtosplit, $langblock[0], $langlist);
-
/// Get the existing sections langs
$lang = '';
$minpref = count($preflangs);
@@ -124,7 +120,15 @@ function multilang_filter_impl($langblock) {
}
}
- return trim($langlist[2][$bestkey]);
+ // return result if we got some sort of match
+ if ($foundkey) {
+ $bestmatch = $langlist[2][$bestkey];
+ }
+ else {
+ $bestmatch = '';
+ }
+
+ return trim($bestmatch);
}
?>

0 comments on commit ef1c5c3

Please sign in to comment.