Exemplo n.º 1
0
/**
 * 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;
}
Exemplo n.º 2
0
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;
        }
    }
}
Exemplo n.º 3
0
/**
 * Converts an array of strings to their localized value.
 *
 * @param array $array An array of strings
 * @param string $module The language module that these strings can be found in.
 * @return array and array of translated strings.
 */
function get_strings($array, $module = '')
{
    $string = new stdClass();
    foreach ($array as $item) {
        $string->{$item} = string_manager::instance()->get_string($item, $module);
    }
    return $string;
}
Exemplo n.º 4
0
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;
        }
    }
}