'portfolio_' => array('portfolio/type'),
'' => array('mod')
);
+ $this->restore_extra_locations_from_session();
if ($runninginstaller) {
$stringnames = file($dirroot . '/install/stringnames.txt');
$this->installstrings = array_map('trim', $stringnames);
}
}
+ protected function restore_extra_locations_from_session() {
+ global $SESSION;
+ if (!empty($SESSION->extralangsearchlocations)) {
+ foreach ($SESSION->extralangsearchlocations as $plugintype => $path) {
+ $this->register_plugin_type($plugintype, $path);
+ }
+ }
+ }
+
+ /**
+ * Register a new type of plugin with the string_manager class. A typical usage might be
+ * string_manager::instance()->register_plugin_type('mymodreport', 'mod/mymod/report');
+ * This should never be needed for standard plugin types. It is intended for third-party
+ * plugins that in turn want to register a sub-plugin type.
+ *
+ * @param string $plugintype a new type of plugin
+ * @param string $path the path where plugins of this type live.
+ */
+ public function register_plugin_type($plugintype, $path) {
+ global $SESSION;
+ $key = $plugintype . '_';
+ if (isset($this->searchplacesbyplugintype[$key]) && $path == reset($this->searchplacesbyplugintype[$key])) {
+ // Nothing to do.
+ return;
+ }
+ $this->searchplacesbyplugintype[$key] = array($path);
+ // We store all registered extra plugin types in the session in order to
+ // allow links to help files to work. I cannot think of a better way to
+ // make this information available to help.php. Putting it in the URL
+ // would be insecure.
+ $SESSION->extralangsearchlocations[$plugintype] = $path;
+ }
+
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);
));
}
+ public function test_register_plugin_type() {
+ $this->stringmanager->register_plugin_type('mymodreport', 'mod/mymod/report');
+ $this->assertEqual($this->stringmanager->locations_to_search('mymodreport_test'), array(
+ $this->basedir . 'moodle/lang/' => 'mymodreport_test/',
+ $this->basedir . 'moodledata/lang/' => 'mymodreport_test/',
+ $this->basedir . 'moodle/mod/mymod/report/test/lang/' => 'test/',
+ ));
+ }
+
+ public function test_register_plugin_type_session_usage() {
+ $this->stringmanager->register_plugin_type('mymodreport', 'mod/mymod/report');
+
+ // Create a new string_manager to see if it picks up the 'mymodreport'
+ // custom plugin type from session without us having to re-register it.
+ // This is required to make help files work.
+ $newstringmanager = new testable_string_manager($this->basedir . 'moodle',
+ $this->basedir . 'moodledata', 'adminpath', false);
+ $this->assertEqual($newstringmanager->locations_to_search('mymodreport_test'), array(
+ $this->basedir . 'moodle/lang/' => 'mymodreport_test/',
+ $this->basedir . 'moodledata/lang/' => 'mymodreport_test/',
+ $this->basedir . 'moodle/mod/mymod/report/test/lang/' => 'test/',
+ ));
+ }
+
public function test_parse_module_name_module() {
$this->assertEqual($this->stringmanager->parse_module_name('forum'),
array('', 'forum'));