]> git.mjollnir.org Git - moodle.git/commitdiff
Improvements to the help system
authormartin <martin>
Sun, 21 Jul 2002 08:34:25 +0000 (08:34 +0000)
committermartin <martin>
Sun, 21 Jul 2002 08:34:25 +0000 (08:34 +0000)
help.php
lang/en/strings.php
lib/moodlelib.php
lib/weblib.php
user/edit.html

index a16f4416fcee0f76f96acdfe2353abf0df8c7141..3070e850a4daef7dbc10b76d4e9b67f005604e2f 100644 (file)
--- a/help.php
+++ b/help.php
@@ -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>
index aff87ca9ee0fdb3c22289fa026772b5bb3bbedc0..ae05a28a6ddecfdd00a8f068bc0a65eebb4a36f8 100644 (file)
@@ -65,6 +65,9 @@ $string[fullprofile] = "Full profile";
 $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";
index 84f2def616bdd155ebd3dc5e8a077da378689d53..a54d44370ce177910588392c0df0a5eacfa7937e 100644 (file)
@@ -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";
 }
 
-
 ?>
index 376a821f271f1dd66ab79c266c8a019d9a9d52e1..7052741908278e9afa459d57b0d3083a702bbbf9 100644 (file)
@@ -123,7 +123,7 @@ 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
@@ -131,10 +131,10 @@ function link_to_popup_window ($url, $name="popup", $linkname="click here", $hei
 
        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";
 
 }
 
index f2e2b74f4dbd298740b7d05e5f2eca4f24dd5570..0f6b139582326c10e32c50dc1b0ec8725f32b3bd 100644 (file)
@@ -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>