"; } if ($backmod) { $backmod = "
wwwroot/mod/$backmod->mod/view.php\" target=\"$CFG->framename\">". "cm\">". ""; } if ($nextmod) { $nextmod = "
wwwroot/mod/$nextmod->mod/view.php\" target=\"$CFG->framename\">". "cm\">". ""; } return "
framename\" href=". "\"$CFG->wwwroot/course/log.php?chooselog=1&user=0&date=0&id=$course->id&modid=$selectmod->cm\">". "pixpath/i/log.gif\">
$logslink
$backmod" . popup_form("$CFG->wwwroot/mod/", $menu, "navmenu", $selected, get_string("jumpto"), "", "", true, $targetwindow). "$nextmod
"; } function print_date_selector($day, $month, $year, $currenttime=0) { // Currenttime is a default timestamp in GMT // Prints form items with the names $day, $month and $year if (!$currenttime) { $currenttime = time(); } $currentdate = usergetdate($currenttime); for ($i=1; $i<=31; $i++) { $days[$i] = "$i"; } for ($i=1; $i<=12; $i++) { $months[$i] = userdate(gmmktime(12,0,0,$i,1,2000), "%B"); } for ($i=2000; $i<=2010; $i++) { $years[$i] = $i; } choose_from_menu($days, $day, $currentdate['mday'], ""); choose_from_menu($months, $month, $currentdate['mon'], ""); choose_from_menu($years, $year, $currentdate['year'], ""); } function print_time_selector($hour, $minute, $currenttime=0, $step=5) { // Currenttime is a default timestamp in GMT // Prints form items with the names $hour and $minute if (!$currenttime) { $currenttime = time(); } $currentdate = usergetdate($currenttime); if ($step != 1) { $currentdate['minutes'] = ceil($currentdate['minutes']/$step)*$step; } for ($i=0; $i<=23; $i++) { $hours[$i] = sprintf("%02d",$i); } for ($i=0; $i<=59; $i+=$step) { $minutes[$i] = sprintf("%02d",$i); } choose_from_menu($hours, $hour, $currentdate['hours'], ""); choose_from_menu($minutes, $minute, $currentdate['minutes'], ""); } function print_grade_menu($courseid, $name, $current, $includenograde=true) { /// Prints a grade menu (as part of an existing form) with help /// Showing all possible numerical grades and scales global $CFG; $strscale = get_string("scale"); $strscales = get_string("scales"); $scales = get_scales_menu($courseid); foreach ($scales as $i => $scalename) { $grades[-$i] = "$strscale: $scalename"; } if ($includenograde) { $grades[0] = get_string("nograde"); } for ($i=100; $i>=1; $i--) { $grades[$i] = $i; } choose_from_menu($grades, "$name", "$current", ""); $helpicon = "$CFG->pixpath/help.gif"; $linkobject = "\"$strscales\""; link_to_popup_window ("/course/scales.php?id=$courseid&list=true", "ratingscales", $linkobject, 400, 500, $strscales); } function print_scale_menu($courseid, $name, $current) { /// Prints a scale menu (as part of an existing form) including help button /// Just like print_grade_menu but without the numerical grades global $CFG; $strscales = get_string("scales"); choose_from_menu(get_scales_menu($courseid), "$name", $current, ""); $helpicon = "$CFG->pixpath/help.gif"; $linkobject = "\"$strscales\""; link_to_popup_window ("/course/scales.php?id=$courseid&list=true", "ratingscales", $linkobject, 400, 500, $strscales); } function print_scale_menu_helpbutton($courseid, $scale) { /// Prints a help button about a scale /// scale is an object global $CFG; $strscales = get_string("scales"); $helpicon = "$CFG->pixpath/help.gif"; $linkobject = "\"$scale-name\" src=\"$helpicon\" />"; link_to_popup_window ("/course/scales.php?id=$courseid&list=true&scale=$scale->id", "ratingscale", $linkobject, 400, 500, $scale->name); } function error ($message, $link="") { global $CFG, $SESSION; print_header(get_string("error")); echo "
"; print_simple_box($message, "center", "", "#FFBBBB"); if (!$link) { if ( !empty($SESSION->fromurl) ) { $link = "$SESSION->fromurl"; unset($SESSION->fromurl); } else { $link = "$CFG->wwwroot/"; } } print_continue($link); print_footer(); die; } function helpbutton ($page, $title="", $module="moodle", $image=true, $linktext=false, $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? (true/false/"both") // $text = if defined then this text is used in the page, and // the $page variable is ignored. global $CFG, $THEME; if ($module == "") { $module = "moodle"; } if ($image) { $icon = "$CFG->pixpath/help.gif"; if ($linktext) { $linkobject = "$title\"\""; } else { $linkobject = "\"$title\""; } } else { $linkobject = "$title"; } if ($text) { $url = "/help.php?module=$module&text=".htmlentities(urlencode($text)); } else { $url = "/help.php?module=$module&file=$page.html"; } link_to_popup_window ($url, "popup", $linkobject, 400, 500, $title); } function emoticonhelpbutton($form, $field) { /// Prints a special help button that is a link to the "live" emoticon popup global $CFG, $SESSION; $SESSION->inserttextform = $form; $SESSION->inserttextfield = $field; helpbutton("emoticons", get_string("helpemoticons"), "moodle", false, true); echo " "; link_to_popup_window ("/help.php?module=moodle&file=emoticons.html", "popup", "pixpath/s/smiley.gif\" border=\"0\" align=\"absmiddle\" width=\"15\" height=\"15\" />", 400, 500, get_string("helpemoticons")); echo "
"; } function notice ($message, $link="") { global $CFG, $THEME; if (!$link) { if (!empty($_SERVER["HTTP_REFERER"])) { $link = $_SERVER["HTTP_REFERER"]; } else { $link = "$CFG->wwwroot/"; } } echo "
"; print_simple_box($message, "center", "50%", "$THEME->cellheading", "20", "noticebox"); print_heading("
".get_string("continue").""); print_footer(get_site()); die; } function notice_yesno ($message, $linkyes, $linkno) { global $THEME; print_simple_box_start("center", "60%", "$THEME->cellheading"); echo "

$message

"; echo "

"; echo "".get_string("yes").""; echo "      "; echo "".get_string("no").""; echo "

"; print_simple_box_end(); } function redirect($url, $message="", $delay="0") { // Redirects the user to another page, after printing a notice if (empty($message)) { echo ""; echo ""; // To cope with Mozilla bug } else { if (empty($delay)) { $delay = 3; // There's no point having a message with no delay } print_header("", "", "", "", ""); echo "
"; echo "

$message

"; echo "

( ".get_string("continue")." )

"; echo "
"; flush(); sleep($delay); echo ""; // To cope with Mozilla bug } die; } function notify ($message, $color="red", $align="center") { echo "

$message

\n"; } function obfuscate_email($email) { /// Given an email address, this function will return an obfuscated version of it $i = 0; $length = strlen($email); $obfuscated = ""; while ($i < $length) { if (rand(0,2)) { $obfuscated.='%'.dechex(ord($email{$i})); } else { $obfuscated.=$email{$i}; } $i++; } return $obfuscated; } function obfuscate_text($plaintext) { /// This function takes some text and replaces about half of the characters /// with HTML entity equivalents. Return string is obviously longer. $i=0; $length = strlen($plaintext); $obfuscated=""; $prev_obfuscated = false; while ($i < $length) { $c = ord($plaintext{$i}); $numerical = ($c >= ord('0')) && ($c <= ord('9')); if ($prev_obfuscated and $numerical ) { $obfuscated.='&#'.ord($plaintext{$i}); } else if (rand(0,2)) { $obfuscated.='&#'.ord($plaintext{$i}); $prev_obfuscated = true; } else { $obfuscated.=$plaintext{$i}; $prev_obfuscated = false; } $i++; } return $obfuscated; } function obfuscate_mailto($email, $label="") { /// This function uses the above two functions to generate a fully /// obfuscated email link, ready to use. if (empty($label)) { $label = $email; } return sprintf('%s', obfuscate_text('mailto'), obfuscate_email($email), obfuscate_text($email), obfuscate_text($label)); } function print_paging_bar($totalcount, $page, $perpage, $baseurl) { /// Prints a single paging bar to provide access to other pages (usually in a search) $maxdisplay = 18; if ($totalcount > $perpage) { echo "
"; echo "

".get_string("page").":"; if ($page > 0) { $pagenum=$page-1; echo " (".get_string("previous").") "; } $lastpage = ceil($totalcount / $perpage); if ($page > 15) { $startpage = $page - 10; echo " 1 ..."; } else { $startpage = 0; } $currpage = $startpage; $displaycount = 0; while ($displaycount < $maxdisplay and $currpage < $lastpage) { $displaypage = $currpage+1; if ($page == $currpage) { echo "  $displaypage"; } else { echo "  $displaypage"; } $displaycount++; $currpage++; } if ($currpage < $lastpage) { $lastpageactual = $lastpage - 1; echo " ...$lastpage "; } $pagenum = $page + 1; if ($pagenum != $displaypage) { echo "  (".get_string("next").")"; } echo "

"; echo "
"; } } // vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140: ?>