/** * Returns all English help files in non-standard location. * * Searches for lang/en_utf8/help/* files in various types of plugins (blocks, database presets, question types, * 3rd party modules etc.) and returns an array of found files details. * * The English version of the file may be found in * $CFG->dirroot/location/plugin/lang/en_utf8/help/filename * The localised version of the found file should be saved into * $CFG->dataroot/lang/currentlang[_local]/help/prefix_plugin/filename (XXX is "prefix" here right?) * where "location", "plugin", "prefix" and "filename" are returned as a part of the file record. * * @return array Array of a file information. Compatible format with {@link lang_standard_locations()} */ function lang_help_extra_locations() { global $CFG; $files = array(); $places = string_manager::instance()->get_registered_plugin_types(); foreach ($places as $prefix => $directories) { foreach ($directories as $directory) { foreach (get_list_of_plugins($directory) as $plugin) { $enlangdirlocation = $CFG->dirroot . '/' . $directory . '/' . $plugin . '/lang/en_utf8/help'; foreach (get_directory_list($enlangdirlocation, 'CVS') as $file) { if (substr($file, -5) == '.html' || substr($file, -4) == '.txt') { $fullpath = $enlangdirlocation . '/' . $file; $files[$fullpath] = array('filename' => $file, 'location' => $directory, 'plugin' => $plugin, 'prefix' => $prefix); } } } } } return $files; }
/** * Creates a new instance of string_manager * * @global object * @return object Returns a new instance of string_manager */ public static function instance() { if (is_null(self::$singletoninstance)) { global $CFG; self::$singletoninstance = new self($CFG->dirroot, $CFG->dataroot, isset($CFG->running_installer), !empty($CFG->debugstringids)); // Uncomment the followign line to log every call to get_string // to a file in $CFG->dataroot/temp/getstringlog/... // self::$singletoninstance->start_logging(); } return self::$singletoninstance; }
public function get_string_from_file($identifier, $langfile, $a) { return parent::get_string_from_file($identifier, $langfile, $a); }
function include_help_for_each_resource($forcelang, $skiplocal) { global $CFG; require_once $CFG->dirroot . '/mod/resource/lib.php'; $typelist = resource_get_types(); //add label type $labelType = new object(); $labelType->modclass = MOD_CLASS_RESOURCE; $resourcetype = 'label'; $labelType->name = $resourcetype; $labelType->type = "resource&type={$resourcetype}"; $labelType->typestr = get_string("resourcetype{$resourcetype}", 'resource'); $typelist[] = $labelType; foreach ($typelist as $type) { list($filepath, $foundlang) = string_manager::instance()->find_help_file('type/' . $type->name . '.html', 'resource', $forcelang, $skiplocal); if ($filepath) { echo '<hr />'; include $filepath; } } }
function include_help_for_each_module($file, $forcelang, $skiplocal) { global $CFG, $DB; if (!($modules = $DB->get_records('modules', array('visible' => 1)))) { print_error('nomodules', 'debug'); // Should never happen } // Horrible hack to show the help about grades here too. $grade = new stdClass(); $grade->name = 'grade'; $modules[] = $grade; foreach ($modules as $mod) { $strmodulename = get_string('modulename', $mod->name); $modulebyname[$strmodulename] = $mod; } ksort($modulebyname, SORT_LOCALE_STRING); foreach ($modulebyname as $mod) { list($filepath, $foundlang) = string_manager::instance()->find_help_file($file, $mod->name, $forcelang, $skiplocal); if ($filepath) { echo '<hr />'; include $filepath; } } }