/// help.php - prints a very simple page and includes a
/// page content or a string from elsewhere
/// Usually this will appear in a popup
- /// See help() in lib/moodlelib.php
+ /// See helpbutton() in lib/moodlelib.php
include("config.php");
+ optional_variable($file, "");
+ optional_variable($text, "No text to display");
+ optional_variable($module, "moodle");
+
if (ereg("\\.\\.", $file)) {
error("Error: Filenames can not contain \"..\"");
}
-
?>
<HTML>
<HEAD>
<LINK rel="stylesheet" href="<?=$CFG->wwwroot?>/theme/<?=$CFG->theme?>/styles.css">
</HEAD>
<BODY BGCOLOR="<?=$THEME->body ?>">
-<? if (file_exists("lang/$CFG->lang/page/$file")) {
- include("lang/$CFG->lang/page/$file");
- } else {
- include("lang/en/page/$file");
- }
+<? if ($file) {
+ if ($module == "moodle") {
+ $langpath = "$CFG->dirroot/lang";
+ } else {
+ $langpath = "$CFG->dirroot/mod/$module/lang";
+ }
+
+ if (file_exists("$langpath/$CFG->lang/page/$file")) {
+ include("$langpath/$CFG->lang/page/$file");
+ } else {
+ include("$langpath/en/page/$file");
+ }
+ } else {
+ echo "<P>";
+ echo $text;
+ echo "</P>";
+ }
?>
</BODY>
</HTML>
$string[fullname] = "Full name";
$string[guestsno] = "No, do not allow guests in";
$string[guestsyes] = "Yes, allow 'guest' student in";
+$string[helppicture] = "How to upload a picture";
+$string[helptext] = "How to write text";
+$string[helpquestions] = "How to ask questions";
$string[home] = "Home";
$string[htmlformat] = "Pretty HTML format";
$string[icqnumber] = "ICQ number";
die;
}
-function helpbutton ($info, $type="file") {
+function helpbutton ($page, $title="", $module="moodle", $image=true, $text="") {
+ // $page = the keyword that defines a help page
+ // $title = the title of links, rollover tips, alt tags etc
+ // $module = which module is the page defined in
+ // $image = use a help image for the link? (otherwise uses text)
+ // $text = if defined then this text is used in the page, and
+ // the $page variable is ignored.
global $CFG;
- $url = "/help.php?$type=help.$info.php";
- $image = "<IMG BORDER=0 ALT=help SRC=\"$CFG->wwwroot/pix/help.gif\">";
- link_to_popup_window ($url, "popup", $image, $height=400, $width=500);
+ if ($module == "") {
+ $module = "moodle";
+ }
+ if ($image) {
+ $linkobject = "<IMG BORDER=0 ALT=\"$title\" SRC=\"$CFG->wwwroot/pix/help.gif\">";
+ } else {
+ $linkobject = $title;
+ }
+ if ($text) {
+ $url = "/help.php?module=$module&text=$text";
+ } else {
+ $url = "/help.php?module=$module&file=help.$page.php";
+ }
+ link_to_popup_window ($url, "popup", $linkobject, 400, 500, $title);
}
function notice ($message, $link="") {
/// PARAMETER HANDLING ////////////////////////////////////////////////////
function require_variable($var) {
-
if (! isset($var)) {
error("A required parameter was missing");
}
return "now";
}
-
?>
}
-function link_to_popup_window ($url, $name="popup", $linkname="click here", $height=400, $width=500) {
+function link_to_popup_window ($url, $name="popup", $linkname="click here", $height=400, $width=500, $title="Popup window") {
// This will create a HTML link that will work on both
// Javascript and non-javascript browsers.
// Relies on the Javascript function openpopup in javascript.php
echo "\n<SCRIPT language=\"Javascript\">";
echo "\n<!--";
- echo "\ndocument.write('<A TITLE=\"Popup\" HREF=javascript:openpopup(\"$url\",\"$name\",\"$height\",\"$width\") >$linkname</A>');";
+ echo "\ndocument.write('<A TITLE=\"$title\" HREF=javascript:openpopup(\"$url\",\"$name\",\"$height\",\"$width\") >$linkname</A>');";
echo "\n//-->";
echo "\n</SCRIPT>";
- echo "\n<NOSCRIPT>\n<A TARGET=\"$name\" TITLE=\"Popup\" HREF=\"$url\">$linkname</A>\n</NOSCRIPT>\n";
+ echo "\n<NOSCRIPT>\n<A TARGET=\"$name\" TITLE=\"$title\" HREF=\"$url\">$linkname</A>\n</NOSCRIPT>\n";
}
<td><P><? print_string("newpicture") ?>:</td>
<td>
<INPUT type="hidden" name="MAX_FILE_SIZE" value="4000000">
- <input type="file" name="imagefile" size=40> ( .jpg / .png ) <? helpbutton("picture") ?>
+ <input type="file" name="imagefile" size=40> ( .jpg / .png ) <? helpbutton("picture", get_string("helppicture") ) ?>
<? formerr($err["imagefile"]) ?>
</td>
</tr>
<tr valign=top>
<td><P><? print_string("userdescription") ?>:</td>
<td><TEXTAREA NAME=description COLS=50 ROWS=10 WRAP=virtual><? p($user->description) ?></TEXTAREA>
- <? helpbutton("text") ?>
+ <? helpbutton("text", get_string("helptext")) ?>
</td>
</tr>
<tr valign=top>