MDL-22015 moving legacy stuff into the get_string() and making the function get_strin...
authorPetr Skoda <skodak@moodle.org>
Fri, 2 Apr 2010 08:23:08 +0000 (08:23 +0000)
committerPetr Skoda <skodak@moodle.org>
Fri, 2 Apr 2010 08:23:08 +0000 (08:23 +0000)
lib/moodlelib.php

index a8721e1..32c3f00 100644 (file)
@@ -5686,7 +5686,7 @@ function get_parent_language($lang=null) {
  * @param mixed $a An object, string or number that can be used within translation strings
  */
 function print_string($identifier, $module='', $a=NULL) {
-    echo get_string_manager()->get_string($identifier, $module, $a);
+    echo get_string($identifier, $module, $a);
 }
 
 /**
@@ -5828,34 +5828,6 @@ class legacy_string_manager implements string_manager {
         return fullclone($this->searchplacesbyplugintype);
     }
 
-    /**
-     * Correct deprecated module names
-     *
-     * @param string $module The module name that is deprecated
-     * @return string The current (now converted) module name
-     */
-    protected function fix_deprecated_module_name($module) {
-        debugging('The module name you passed to get_string is the deprecated format ' .
-                'like mod/mymod or block/myblock. The correct form looks like mymod, or block_myblock.' , DEBUG_DEVELOPER);
-        $modulepath = split('/', $module);
-
-        switch ($modulepath[0]) {
-            case 'mod':
-                return $modulepath[1];
-            case 'blocks':
-            case 'block':
-                return 'block_'.$modulepath[1];
-            case 'enrol':
-                return 'enrol_'.$modulepath[1];
-            case 'format':
-                return 'format_'.$modulepath[1];
-            case 'grade':
-                return 'grade'.$modulepath[1].'_'.$modulepath[2];
-            default:
-                return $module;
-        }
-    }
-
     /**
      * Returns an array of locations to search for modules
      *
@@ -6072,10 +6044,6 @@ class legacy_string_manager implements string_manager {
             $module = 'langconfig';
         }
 
-        if (strpos($module, '/') !== false) {
-            $module = $this->fix_deprecated_module_name($module);
-        }
-
         $locations = $this->locations_to_search($module);
 
         if (!is_null($this->installstrings) && in_array($identifier, $this->installstrings)) {
@@ -6231,6 +6199,31 @@ function get_string($identifier, $module='', $a=NULL, $extralocations=NULL) {
         debugging('extralocations parameter in get_string() is not supported any more, please use standard lang locations only.');
     }
 
+    if (strpos($module, '/') !== false) {
+        debugging('The module name you passed to get_string is the deprecated format ' .
+                'like mod/mymod or block/myblock. The correct form looks like mymod, or block_myblock.' , DEBUG_DEVELOPER);
+        $modulepath = split('/', $module);
+
+        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;
+        }
+    }
+    
     return get_string_manager()->get_string($identifier, $module, $a);
 }
 
@@ -6244,7 +6237,7 @@ function get_string($identifier, $module='', $a=NULL, $extralocations=NULL) {
 function get_strings($array, $module='') {
    $string = new stdClass;
    foreach ($array as $item) {
-       $string->$item = get_string_manager()->get_string($item, $module);
+       $string->$item = get_string($item, $module);
    }
    return $string;
 }