function include_help_for_each_resource($file, $langs, $helpdir) { global $CFG; require_once $CFG->dirroot . '/mod/resource/lib.php'; $typelist = resource_get_types(); $typelist['label'] = get_string('resourcetypelabel', 'resource'); foreach ($typelist as $type => $name) { foreach ($langs as $lang) { if (empty($lang)) { continue; } $filepath = "{$helpdir}/resource/type/{$type}.html"; if (file_exists_and_readable($filepath)) { echo '<hr size="1" />'; @(include $filepath); // The actual helpfile break; // Out of loop over languages. } } } }
function include_help_for_each_resource($file, $langs, $helpdir) { 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) { foreach ($langs as $lang) { if (empty($lang)) { continue; } $filepath = "{$helpdir}/resource/type/" . $type->name . ".html"; if (file_exists_and_readable($filepath)) { echo '<hr />'; @(include $filepath); // The actual helpfile break; // Out of loop over languages. } } } }
/** * Find a desired help file in the correct language * * @param string $file The helpd file to locate * @param string $module The module the help file is associated with * @param string $forcelang override the default language * @param bool $skiplocal Skip local help files * @return array An array containing the filepath, and then the language */ public function find_help_file($file, $module, $forcelang, $skiplocal) { if ($forcelang) { $langs = array($forcelang, 'en_utf8'); } else { $langs = array(); for ($lang = current_language(); $lang; $lang = $this->get_parent_language($lang)) { $langs[] = $lang; } } $locations = $this->locations_to_search($module); if ($skiplocal) { $localsuffices = array(''); } else { $localsuffices = array('_local', ''); } foreach ($langs as $lang) { foreach ($locations as $location => $locationsuffix) { foreach ($localsuffices as $localsuffix) { $filepath = $location . $lang . $localsuffix . '/help/' . $locationsuffix . $file; // Now, try to include the help text from this file, if we can. if (file_exists_and_readable($filepath)) { return array($filepath, $lang); } } } } return array('', ''); }