From bea418fd03173392c2d74be1560d08c678435c1d Mon Sep 17 00:00:00 2001 From: moodler Date: Thu, 31 Jul 2008 07:29:01 +0000 Subject: [PATCH] Merged MDL-15892 Improved get_string - it can now handle paths as the module like 'mod/forum' or 'grade/import/txt' and will look in the right file automatically (eg forum.php and gradeimport_txt.php) --- lib/moodlelib.php | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index c0e050a678..880ebe80ed 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -5112,8 +5112,37 @@ function get_string($identifier, $module='', $a=NULL, $extralocations=NULL) { if ($module == '') { $module = 'moodle'; } + +/// If the "module" is actually a pathname, then automatically derive the proper module name + if (strpos($module, '/') !== false) { + $modulepath = split('/', $module); - // if $a happens to have % in it, double it so sprintf() doesn't break + switch ($modulepath[0]) { + + case 'mod': + $module = $modulepath[1]; + break; + + case 'blocks': + case 'block': + $module = 'block_'.$modulepath[1]; + break; + + case 'enrol': + $module = 'enrol_'.$modulepath[1]; + break; + + case 'format': + $module = 'format_'.$modulepath[1]; + break; + + case 'grade': + $module = 'grade'.$modulepath[1].'_'.$modulepath[2]; + break; + } + } + +/// if $a happens to have % in it, double it so sprintf() doesn't break if ($a) { $a = clean_getstring_data( $a ); } -- 2.39.5