2004-09-29 18:19:39 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* help.php - Displays help page.
|
|
|
|
*
|
|
|
|
* Prints a very simple page and includes
|
|
|
|
* page content or a string from elsewhere.
|
2005-04-10 05:08:31 +00:00
|
|
|
* Usually this will appear in a popup
|
2004-09-29 18:19:39 +00:00
|
|
|
* See {@link helpbutton()} in {@link lib/moodlelib.php}
|
|
|
|
*
|
|
|
|
* @author Martin Dougiamas
|
|
|
|
* @version $Id$
|
|
|
|
* @package moodlecore
|
|
|
|
*/
|
2005-04-10 05:08:31 +00:00
|
|
|
|
2004-09-29 18:19:39 +00:00
|
|
|
|
|
|
|
require_once('config.php');
|
|
|
|
|
2006-07-11 13:19:52 +00:00
|
|
|
$file = optional_param('file', '', PARAM_PATH);
|
2005-12-05 04:23:50 +00:00
|
|
|
$text = optional_param('text', 'No text to display', PARAM_CLEAN);
|
2005-09-25 20:46:43 +00:00
|
|
|
$module = optional_param('module', 'moodle', PARAM_ALPHAEXT);
|
2006-03-22 03:16:27 +00:00
|
|
|
$forcelang = optional_param('forcelang', '', PARAM_ALPHAEXT);
|
2002-07-21 08:34:25 +00:00
|
|
|
|
2003-06-12 11:35:12 +00:00
|
|
|
print_header();
|
2002-10-13 10:06:01 +00:00
|
|
|
|
2004-09-29 18:19:39 +00:00
|
|
|
print_simple_box_start('center', '96%');
|
2003-10-21 02:30:42 +00:00
|
|
|
|
2003-06-12 11:35:12 +00:00
|
|
|
$helpfound = false;
|
2006-03-22 03:16:27 +00:00
|
|
|
if (empty($forcelang)) {
|
|
|
|
$langs = array(current_language(), get_string('parentlanguage'), 'en_utf8'); // Fallback
|
|
|
|
} else {
|
|
|
|
$langs = array($forcelang);
|
|
|
|
}
|
2003-06-12 11:35:12 +00:00
|
|
|
if (!empty($file)) {
|
|
|
|
foreach ($langs as $lang) {
|
|
|
|
if (empty($lang)) {
|
|
|
|
continue;
|
|
|
|
}
|
2004-09-29 18:19:39 +00:00
|
|
|
if ($module == 'moodle') {
|
2006-02-15 01:55:04 +00:00
|
|
|
if ($lang == 'en_utf8') {
|
|
|
|
$filepath = $CFG->dirroot .'/lang/'. $lang .'/help/'. $file;
|
|
|
|
} else {
|
|
|
|
$filepath = $CFG->dataroot .'/lang/'. $lang .'/help/'. $file;
|
|
|
|
}
|
2002-08-11 14:22:38 +00:00
|
|
|
} else {
|
2006-02-15 01:55:04 +00:00
|
|
|
if ($lang == 'en_utf8') {
|
|
|
|
$filepath = $CFG->dirroot .'/lang/'. $lang .'/help/'. $module .'/'. $file;
|
|
|
|
} else {
|
|
|
|
$filepath = $CFG->dataroot .'/lang/'. $lang .'/help/'. $module .'/'. $file;
|
2006-02-20 01:30:30 +00:00
|
|
|
if (!file_exists($filepath)) {
|
|
|
|
$filepath = $CFG->dirroot .'/lang/en_utf8/help/'. $module .'/'. $file;
|
|
|
|
}
|
2006-02-15 01:55:04 +00:00
|
|
|
}
|
2005-04-10 05:08:31 +00:00
|
|
|
if (!file_exists($filepath)) {
|
2006-02-20 01:30:30 +00:00
|
|
|
$filepath = $CFG->dirroot.'/mod/'.$module.'/lang/'. $lang .'/help/'. $module .'/'. $file;
|
2005-04-10 05:08:31 +00:00
|
|
|
}
|
2002-08-11 14:22:38 +00:00
|
|
|
}
|
2005-04-10 05:08:31 +00:00
|
|
|
|
2006-08-14 20:08:52 +00:00
|
|
|
if (file_exists($filepath) and is_file($filepath) and is_readable($filepath)) {
|
2003-06-12 11:35:12 +00:00
|
|
|
$helpfound = true;
|
2006-08-14 20:08:52 +00:00
|
|
|
@include($filepath); // The actual helpfile
|
2003-07-24 12:56:17 +00:00
|
|
|
|
2004-09-29 18:19:39 +00:00
|
|
|
if ($module == 'moodle' and ($file == 'index.html' or $file == 'mods.html')) {
|
2003-07-24 12:56:17 +00:00
|
|
|
// include file for each module
|
|
|
|
|
2004-09-29 18:19:39 +00:00
|
|
|
if (!$modules = get_records('modules', 'visible', 1)) {
|
|
|
|
error('No modules found!!'); // Should never happen
|
2003-07-24 12:56:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($modules as $mod) {
|
2004-09-29 18:19:39 +00:00
|
|
|
$strmodulename = get_string('modulename', $mod->name);
|
2003-07-24 12:56:17 +00:00
|
|
|
$modulebyname[$strmodulename] = $mod;
|
|
|
|
}
|
|
|
|
ksort($modulebyname);
|
|
|
|
|
|
|
|
foreach ($modulebyname as $mod) {
|
|
|
|
foreach ($langs as $lang) {
|
|
|
|
if (empty($lang)) {
|
|
|
|
continue;
|
|
|
|
}
|
2006-02-15 01:55:04 +00:00
|
|
|
if ($lang == 'en_utf8') {
|
|
|
|
$filepath = $CFG->dirroot .'/lang/'. $lang .'/help/'. $mod->name .'/'. $file;
|
|
|
|
} else {
|
|
|
|
$filepath = $CFG->dataroot .'/lang/'. $lang .'/help/'. $mod->name .'/'. $file;
|
|
|
|
}
|
2003-07-24 12:56:17 +00:00
|
|
|
|
2004-09-29 18:19:39 +00:00
|
|
|
if (file_exists($filepath)) {
|
2004-08-02 19:11:15 +00:00
|
|
|
echo '<hr size="1" />';
|
2004-09-29 18:19:39 +00:00
|
|
|
include($filepath); // The actual helpfile
|
2004-08-02 19:11:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-18 09:30:45 +00:00
|
|
|
// Some horrible hardcoded stuff follows, should be delegated to modules to handle
|
|
|
|
|
2004-09-29 18:19:39 +00:00
|
|
|
if ($module == 'moodle' and ($file == 'resource/types.html')) { // RESOURCES
|
|
|
|
require_once($CFG->dirroot .'/mod/resource/lib.php');
|
2004-08-02 19:11:15 +00:00
|
|
|
$typelist = resource_get_resource_types();
|
|
|
|
$typelist['label'] = get_string('resourcetypelabel', 'resource');
|
|
|
|
|
|
|
|
foreach ($typelist as $type => $name) {
|
|
|
|
foreach ($langs as $lang) {
|
|
|
|
if (empty($lang)) {
|
|
|
|
continue;
|
|
|
|
}
|
2006-02-15 01:55:04 +00:00
|
|
|
if ($lang == 'en_utf8') {
|
|
|
|
$filepath = $CFG->dirroot .'/lang/'. $lang .'/help/resource/type/'. $type .'.html';
|
|
|
|
} else {
|
|
|
|
$filepath = $CFG->dataroot .'/lang/'. $lang .'/help/resource/type/'. $type .'.html';
|
|
|
|
}
|
2004-09-29 18:19:39 +00:00
|
|
|
if (file_exists($filepath)) {
|
2004-08-02 19:11:15 +00:00
|
|
|
echo '<hr size="1" />';
|
2004-09-29 18:19:39 +00:00
|
|
|
include($filepath); // The actual helpfile
|
2003-07-24 12:56:17 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-04-18 09:30:45 +00:00
|
|
|
if ($module == 'moodle' and ($file == 'assignment/types.html')) { // ASSIGNMENTS
|
|
|
|
require_once($CFG->dirroot .'/mod/assignment/lib.php');
|
|
|
|
$typelist = assignment_types();
|
|
|
|
|
|
|
|
foreach ($typelist as $type => $name) {
|
|
|
|
echo '<p><b>'.$name.'</b></p>';
|
|
|
|
echo get_string('help'.$type, 'assignment');
|
|
|
|
echo '<hr size="1" />';
|
|
|
|
}
|
|
|
|
}
|
2003-06-12 11:35:12 +00:00
|
|
|
break;
|
2002-08-11 14:22:38 +00:00
|
|
|
}
|
2002-07-21 08:34:25 +00:00
|
|
|
}
|
|
|
|
} else {
|
2005-12-05 04:23:50 +00:00
|
|
|
echo '<p>'.s($text).'</p>'; // This param was already cleaned
|
2003-06-12 11:35:12 +00:00
|
|
|
$helpfound = true;
|
|
|
|
}
|
|
|
|
|
2003-10-21 02:30:42 +00:00
|
|
|
print_simple_box_end();
|
|
|
|
|
2003-06-12 11:35:12 +00:00
|
|
|
if (!$helpfound) {
|
2006-01-09 01:55:42 +00:00
|
|
|
//$file = clean_text($file); // Keep it clean!
|
2004-09-29 18:19:39 +00:00
|
|
|
notify('Help file "'. $file .'" could not be found!');
|
2002-07-21 08:34:25 +00:00
|
|
|
}
|
2002-10-21 03:00:40 +00:00
|
|
|
|
|
|
|
close_window_button();
|
2003-06-14 03:52:23 +00:00
|
|
|
|
2005-03-27 05:44:31 +00:00
|
|
|
echo '<p align="center"><a href="help.php?file=index.html">'. get_string('helpindex') .'</a></p>';
|
2006-04-24 01:58:31 +00:00
|
|
|
|
|
|
|
$CFG->docroot = ''; // We don't want a doc link here
|
|
|
|
|
2005-03-27 05:44:31 +00:00
|
|
|
print_footer('none');
|
2002-07-02 07:09:26 +00:00
|
|
|
?>
|