From 1f2eec7b651ec53797d364987928c13e6cf30f00 Mon Sep 17 00:00:00 2001 From: moodler Date: Mon, 2 Aug 2004 19:09:06 +0000 Subject: [PATCH] Fixes to helpbuttons and popups --- lib/weblib.php | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index 0fb1dfb361..252285339d 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -314,7 +314,7 @@ function frmchecked(&$var, $true_value = "checked", $false_value = "") { function link_to_popup_window ($url, $name="popup", $linkname="click here", - $height=400, $width=500, $title="Popup window", $options="none") { + $height=400, $width=500, $title="Popup window", $options="none", $return=false) { /// 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 @@ -327,8 +327,13 @@ function link_to_popup_window ($url, $name="popup", $linkname="click here", } $fullscreen = 0; - echo "wwwroot$url\" ". - "onClick=\"return openpopup('$url', '$name', '$options', $fullscreen);\">$linkname\n"; + $link = "wwwroot$url\" ". + "onClick=\"return openpopup('$url', '$name', '$options', $fullscreen);\">$linkname\n"; + if ($return) { + return $link; + } else { + echo $link; + } } @@ -487,14 +492,16 @@ function popup_form ($common, $options, $formname, $selected="", $nothing="choos $output .= ""; $output .= "\n"; + if ($help) { + $button = helpbutton($help, $helptext, 'moodle', true, false, '', true); + } else { + $button = ''; + } + if ($return) { - return $startoutput.$output; + return $startoutput.$button.$output; } else { - echo $startoutput; - if ($help) { - helpbutton($help, $helptext); - } - echo $output; + echo $startoutput.$button.$output; } } @@ -1085,7 +1092,7 @@ function print_header ($title="", $heading="", $navigation="", $focus="", $meta= include ("$CFG->dirroot/theme/$CFG->theme/header.html"); } -function print_footer ($course=NULL) { +function print_footer ($course=NULL, $usercourse=NULL) { // Can provide a course object to make the footer contain a link to // to the course home page, otherwise the link will go to the site home global $USER, $CFG, $THEME; @@ -1105,8 +1112,12 @@ function print_footer ($course=NULL) { $course = get_site(); } + if (!$usercourse) { + $usercourse = $course; + } + /// User links - $loggedinas = user_login_string($course, $USER); + $loggedinas = user_login_string($usercourse, $USER); include ("$CFG->dirroot/theme/$CFG->theme/footer.html"); } @@ -2132,7 +2143,7 @@ function error ($message, $link="") { die; } -function helpbutton ($page, $title="", $module="moodle", $image=true, $linktext=false, $text="") { +function helpbutton ($page, $title="", $module="moodle", $image=true, $linktext=false, $text="", $return=false) { // $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 @@ -2162,7 +2173,14 @@ function helpbutton ($page, $title="", $module="moodle", $image=true, $linktext= } else { $url = "/help.php?module=$module&file=$page.html"; } - link_to_popup_window ($url, "popup", $linkobject, 400, 500, $title); + + $link = link_to_popup_window ($url, "popup", $linkobject, 400, 500, $title, 'none', true); + + if ($return) { + return $link; + } else { + echo $link; + } } function emoticonhelpbutton($form, $field) { -- 2.39.5