Permalink
Browse files

Improvements to the help system

  • Loading branch information...
1 parent c31ebf2 commit 65cf9fc3906ccdf946381278addf6f7ddbf7b3eb martin committed Jul 21, 2002
Showing with 51 additions and 18 deletions.
  1. +22 −7 help.php
  2. +3 −0 lang/en/strings.php
  3. +21 −6 lib/moodlelib.php
  4. +3 −3 lib/weblib.php
  5. +2 −2 user/edit.html
View
@@ -2,26 +2,41 @@
/// 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>
View
@@ -65,6 +65,9 @@
$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";
View
@@ -311,11 +311,28 @@ function error ($message, $link="") {
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="") {
@@ -370,7 +387,6 @@ function notify ($message) {
/// PARAMETER HANDLING ////////////////////////////////////////////////////
function require_variable($var) {
-
if (! isset($var)) {
error("A required parameter was missing");
}
@@ -1324,5 +1340,4 @@ function format_time($totalsecs) {
return "now";
}
-
?>
View
@@ -123,18 +123,18 @@ function frmchecked(&$var, $true_value = "checked", $false_value = "") {
}
-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
// $url must be relative to home page eg /mod/survey/stuff.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";
}
View
@@ -4,14 +4,14 @@
<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>

0 comments on commit 65cf9fc

Please sign in to comment.