\n$meta\n"; // Specify character set ... default is iso-8859-1 but some languages might need something else // Could be optimised by carrying the charset variable around in $USER if (current_language() == "en") { $meta = "\n$meta\n"; } else { $meta = "\n$meta\n"; } if ( get_string("thisdirection") == "rtl" ) { $direction = " dir=\"rtl\""; } else { $direction = " dir=\"ltr\""; } if (!$cache) { // Do everything we can to prevent clients and proxies caching @header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); @header("Pragma: no-cache"); $meta .= "\n"; $meta .= "\n"; } if ($usexml) { // Added by Gustav Delius / Mad Alex for MathML output $currentlanguage = current_language(); @header("Content-type: text/xml"); echo "\n"; if (!empty($CFG->xml_stylesheets)) { $stylesheets = explode(";", $CFG->xml_stylesheets); foreach ($stylesheets as $stylesheet) { echo "wwwroot/$stylesheet\" ?>\n"; } } echo "xml_doctype_extra)) { echo " plus $CFG->xml_doctype_extra"; } echo "//" . strtoupper($currentlanguage) . "\" \"$CFG->xml_dtd\">\n"; $direction = " xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"$currentlanguage\" $direction"; } $title = str_replace('"', '"', $title); include ("$CFG->dirroot/theme/$CFG->theme/header.html"); } function print_footer ($course=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; /// Course links if ($course) { if ($course == "home") { // special case for site home page - please do not remove $homelink = "release ($CFG->version)\" href=\"http://moodle.org/\" target=\"_blank\">"; $homelink .= ""; $course = get_site(); $homepage = true; } else { $homelink = "framename}\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname"; } } else { $homelink = "framename}\" href=\"$CFG->wwwroot/\">".get_string("home").""; $course = get_site(); } /// User links $loggedinas = user_login_string($course, $USER); include ("$CFG->dirroot/theme/$CFG->theme/footer.html"); } function style_sheet_setup($lastmodified=0, $lifetime=300, $themename="") { /// This function is called by stylesheets to set up the header /// approriately as well as the current path global $CFG; if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { // May not need to send stylesheet // Following lines from Wolfram Kriesing and John Dell $months = array_flip(array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')); preg_match('~[^,]*,\s(\d+)\s(\w+)\s(\d+)\s(\d+):(\d+):(\d+).*~', $_SERVER['HTTP_IF_MODIFIED_SINCE'], $splitDate); $timestamp = gmmktime($splitDate[4], $splitDate[5], $splitDate[6], $months[$splitDate[2]]+1, $splitDate[1], $splitDate[3]); if ($lastmodified <= $timestamp) { header('HTTP/1.x 304 Not Modified'); exit; } } header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodified) . " GMT"); header("Expires: " . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT"); header("Cache-control: max_age = $lifetime"); header("Pragma: "); header("Content-type: text/css"); // Correct MIME type if (!empty($themename)) { $CFG->theme = $themename; } return "$CFG->wwwroot/theme/$CFG->theme"; } function user_login_string($course, $user=NULL) { global $USER, $CFG; if (empty($user)) { $user = $USER; } if (isset($user->realuser)) { if ($realuser = get_record("user", "id", $user->realuser)) { $fullname = fullname($realuser, true); $realuserinfo = " [framename}\" href=\"$CFG->wwwroot/course/loginas.php?id=$course->id&return=$realuser->id\">$fullname] "; } } else { $realuserinfo = ""; } if (isset($user->id) and $user->id) { $fullname = fullname($user, true); $username = "framename}\" href=\"$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id\">$fullname"; $loggedinas = $realuserinfo.get_string("loggedinas", "moodle", "$username"). " (framename}\" href=\"$CFG->wwwroot/login/logout.php\">".get_string("logout").")"; } else { $loggedinas = get_string("loggedinnot", "moodle"). " (framename}\" href=\"$CFG->wwwroot/login/index.php\">".get_string("login").")"; } return $loggedinas; } function print_navigation ($navigation) { global $CFG; if ($navigation) { if (! $site = get_site()) { $site->shortname = get_string("home");; } echo "framename}\" href=\"$CFG->wwwroot/\">$site->shortname -> $navigation"; } } function print_headline($text, $size=2) { echo "$text\n"; } function print_heading($text, $align="center", $size=3) { echo "".stripslashes_safe($text).""; } function print_heading_with_help($text, $helppage, $module="moodle", $icon="") { // Centered heading with attached help button (same title text) // and optional icon attached echo "$icon".stripslashes_safe($text); helpbutton($helppage, $text, $module); echo ""; } function print_continue($link) { if (!$link) { $link = $_SERVER["HTTP_REFERER"]; } print_heading("".get_string("continue").""); } function print_simple_box($message, $align="", $width="", $color="#FFFFFF", $padding=5, $class="generalbox") { print_simple_box_start($align, $width, $color, $padding, $class); echo stripslashes_safe($message); print_simple_box_end(); } function print_simple_box_start($align="", $width="", $color="#FFFFFF", $padding=5, $class="generalbox") { global $THEME; if ($align) { $align = "align=\"$align\""; } if ($width) { $width = "width=\"$width\""; } echo ""; } function print_simple_box_end() { echo ""; } function print_single_button($link, $options, $label="OK", $method="get") { echo ""; if ($options) { foreach ($options as $name => $value) { echo ""; } } echo ""; } function print_spacer($height=1, $width=1, $br=true) { global $CFG; echo "wwwroot/pix/spacer.gif\" alt=\"\" />"; if ($br) { echo "\n"; } } function print_file_picture($path, $courseid=0, $height="", $width="", $link="") { // Given the path to a picture file in a course, or a URL, // this function includes the picture in the page. global $CFG; if ($height) { $height = "height=\"$height\""; } if ($width) { $width = "width=\"$width\""; } if ($link) { echo ""; } if (substr(strtolower($path), 0, 7) == "http://") { echo ""; } else if ($courseid) { echo "slasharguments) { // Use this method if possible for better caching echo "$CFG->wwwroot/file.php/$courseid/$path"; } else { echo "$CFG->wwwroot/file.php?file=/$courseid/$path"; } echo "\" />"; } else { echo "Error: must pass URL or course"; } if ($link) { echo ""; } } function print_user_picture($userid, $courseid, $picture, $large=false, $returnstring=false, $link=true) { global $CFG; if ($link) { $output = "wwwroot/user/view.php?id=$userid&course=$courseid\">"; } else { $output = ""; } if ($large) { $file = "f1"; $size = 100; } else { $file = "f2"; $size = 35; } if ($picture) { // Print custom user picture if ($CFG->slasharguments) { // Use this method if possible for better caching $output .= "wwwroot/user/pix.php/$userid/$file.jpg\"". " border=\"0\" width=\"$size\" height=\"$size\" alt=\"\" />"; } else { $output .= "wwwroot/user/pix.php?file=/$userid/$file.jpg\"". " border=\"0\" width=\"$size\" height=\"$size\" alt=\"\" />"; } } else { // Print default user pictures (use theme version if available) $output .= "pixpath/u/$file.png\"". " border=\"0\" width=\"$size\" height=\"$size\" alt=\"\" />"; } if ($link) { $output .= ""; } if ($returnstring) { return $output; } else { echo $output; } } function print_user($user, $course) { /// Prints a summary of a user in a nice little box global $CFG; static $string; static $datestring; static $countries; static $isteacher; if (empty($string)) { // Cache all the strings for the rest of the page $string->email = get_string("email"); $string->location = get_string("location"); $string->lastaccess = get_string("lastaccess"); $string->activity = get_string("activity"); $string->unenrol = get_string("unenrol"); $string->loginas = get_string("loginas"); $string->fullprofile = get_string("fullprofile"); $string->role = get_string("role"); $string->name = get_string("name"); $string->never = get_string("never"); $datestring->day = get_string("day"); $datestring->days = get_string("days"); $datestring->hour = get_string("hour"); $datestring->hours = get_string("hours"); $datestring->min = get_string("min"); $datestring->mins = get_string("mins"); $datestring->sec = get_string("sec"); $datestring->secs = get_string("secs"); $countries = get_list_of_countries(); $isteacher = isteacher($course->id); } echo ''; echo ''; echo ''; print_user_picture($user->id, $course->id, $user->picture, true); echo ''; echo ''; echo ''; echo ''.fullname($user, $isteacher).''; echo ''; if (!empty($user->role) and ($user->role <> $course->teacher)) { echo "$string->role: $user->role"; } if ($user->maildisplay == 1 or ($user->maildisplay == 2 and $course->category) or $isteacher) { echo "$string->email: email\">$user->email"; } if ($user->city or $user->country) { echo "$string->location: $user->city, ".$countries["$user->country"].""; } if ($user->lastaccess) { echo "$string->lastaccess: ".userdate($user->lastaccess); echo "  (".format_time(time() - $user->lastaccess, $datestring).")"; } else { echo "$string->lastaccess: $string->never"; } echo ''; echo ''; if ($isteacher) { $timemidnight = usergetmidnight(time()); echo "wwwroot/course/user.php?id=$course->id&user=$user->id\">$string->activity"; if (isstudent($course->id, $user->id) and !iscreator($user->id)) { // Includes admins echo "wwwroot/course/unenrol.php?id=$course->id&user=$user->id\">$string->unenrol"; echo "wwwroot/course/loginas.php?id=$course->id&user=$user->id\">$string->loginas"; } } echo "wwwroot/user/view.php?id=$user->id&course=$course->id\">$string->fullprofile..."; echo ''; echo ''; } function print_group_picture($group, $courseid, $large=false, $returnstring=false, $link=true) { global $CFG; static $isteacheredit; if (!isset($isteacheredit)) { $isteacheredit = isteacheredit($courseid); } if ($group->hidepicture and !$isteacheredit) { return ''; } if ($link or $isteacheredit) { $output = "wwwroot/course/group.php?id=$courseid&group=$group->id\">"; } else { $output = ''; } if ($large) { $file = "f1"; $size = 100; } else { $file = "f2"; $size = 35; } if ($group->picture) { // Print custom group picture if ($CFG->slasharguments) { // Use this method if possible for better caching $output .= "wwwroot/user/pixgroup.php/$group->id/$file.jpg\"". " border=\"0\" width=\"$size\" height=\"$size\" alt=\"\" title=\"$group->name\"/>"; } else { $output .= "wwwroot/user/pixgroup.php?file=/$group->id/$file.jpg\"". " border=\"0\" width=\"$size\" height=\"$size\" alt=\"\" title=\"$group->name\"/>"; } } if ($link or $isteacheredit) { $output .= ""; } if ($returnstring) { return $output; } else { echo $output; } } function print_png($url, $sizex, $sizey, $returnstring, $parameters='alt=""') { global $CFG; static $recentIE; if (!isset($recentIE)) { $recentIE = check_browser_version('MSIE', '5.0'); } if ($recentIE) { // work around the HORRIBLE bug IE has with alpha transparencies $output .= "pixpath/spacer.gif\" width=\"$sizex\" height=\"$sizey\"". " border=\"0\" style=\"width: {$sizex}px; height: {$sizey}px; ". " filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='$url', sizingMethod='scale') ". " $parameters />"; } else { $output .= ""; } if ($returnstring) { return $output; } else { echo $output; } } function print_table($table) { // Prints a nicely formatted table. // $table is an object with several properties. // $table->head is an array of heading names. // $table->align is an array of column alignments // $table->size is an array of column sizes // $table->wrap is an array of "nowrap"s or nothing // $table->data[] is an array of arrays containing the data. // $table->width is an percentage of the page // $table->cellpadding padding on each cell // $table->cellspacing spacing between cells global $THEME; if (isset($table->align)) { foreach ($table->align as $key => $aa) { if ($aa) { $align[$key] = " align=\"$aa\""; } else { $align[$key] = ""; } } } if (isset($table->size)) { foreach ($table->size as $key => $ss) { if ($ss) { $size[$key] = " width=\"$ss\""; } else { $size[$key] = ""; } } } if (isset($table->wrap)) { foreach ($table->wrap as $key => $ww) { if ($ww) { $wrap[$key] = " nowrap=\"nowrap\" "; } else { $wrap[$key] = ""; } } } if (empty($table->width)) { $table->width = "80%"; } if (empty($table->cellpadding)) { $table->cellpadding = "5"; } if (empty($table->cellspacing)) { $table->cellspacing = "1"; } print_simple_box_start("center", "$table->width", "#ffffff", 0); echo "cellpadding\" cellspacing=\"$table->cellspacing\" class=\"generaltable\">\n"; $countcols = 0; if (!empty($table->head)) { $countcols = count($table->head);; echo ""; foreach ($table->head as $key => $heading) { if (!isset($size[$key])) { $size[$key] = ""; } if (!isset($align[$key])) { $align[$key] = ""; } echo "$heading"; } echo "\n"; } if (!empty($table->data)) { foreach ($table->data as $row) { echo ""; if ($row == "hr" and $countcols) { echo ""; } else { /// it's a normal row of data foreach ($row as $key => $item) { if (!isset($size[$key])) { $size[$key] = ""; } if (!isset($align[$key])) { $align[$key] = ""; } if (!isset($wrap[$key])) { $wrap[$key] = ""; } echo "$item"; } } echo "\n"; } } echo "\n"; print_simple_box_end(); return true; } function make_table($table) { // Creates a nicely formatted table and returns it // $table is an object with several properties. // $table->head is an array of heading names. // $table->align is an array of column alignments // $table->size is an array of column sizes // $table->wrap is an array of "nowrap"s or nothing // $table->data[] is an array of arrays containing the data. // $table->width is an percentage of the page // $table->class is a class // $table->fontsize is the size of all the text // $table->tablealign align the whole table // $table->cellpadding padding on each cell // $table->cellspacing spacing between cells if (isset($table->align)) { foreach ($table->align as $key => $aa) { if ($aa) { $align[$key] = " align=\"$aa\""; } else { $align[$key] = ""; } } } if (isset($table->size)) { foreach ($table->size as $key => $ss) { if ($ss) { $size[$key] = " width=\"$ss\""; } else { $size[$key] = ""; } } } if (isset($table->wrap)) { foreach ($table->wrap as $key => $ww) { if ($ww) { $wrap[$key] = " nowrap=\"nowrap\" "; } else { $wrap[$key] = ""; } } } if (empty($table->width)) { $table->width = "80%"; } if (empty($table->tablealign)) { $table->tablealign = "center"; } if (empty($table->cellpadding)) { $table->cellpadding = "5"; } if (empty($table->cellspacing)) { $table->cellspacing = "1"; } if (empty($table->class)) { $table->class = "generaltable"; } if (empty($table->fontsize)) { $fontsize = ""; } else { $fontsize = "fontsize\">"; } $output = "width\" valign=\"top\" align=\"$table->tablealign\" "; $output .= " cellpadding=\"$table->cellpadding\" cellspacing=\"$table->cellspacing\" class=\"$table->class\">\n"; if (!empty($table->head)) { $output .= ""; foreach ($table->head as $key => $heading) { if (!isset($size[$key])) { $size[$key] = ""; } if (!isset($align[$key])) { $align[$key] = ""; } $output .= "class}header\">$fontsize$heading"; } $output .= "\n"; } foreach ($table->data as $row) { $output .= ""; foreach ($row as $key => $item) { if (!isset($size[$key])) { $size[$key] = ""; } if (!isset($align[$key])) { $align[$key] = ""; } if (!isset($wrap[$key])) { $wrap[$key] = ""; } $output .= "class}cell\">$fontsize$item"; } $output .= "\n"; } $output .= "\n"; return $output; } function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value="", $courseid=0) { /// Prints a basic textarea field /// $width and height are legacy fields and no longer used global $CFG, $course; if (empty($courseid)) { if (!empty($course->id)) { // search for it in global context $courseid = $course->id; } } if ($usehtmleditor) { if (!empty($courseid) and isteacher($courseid)) { echo "\n"; } else { echo "\n"; } echo "\n"; echo "\n"; echo "\n"; if ($rows < 20) { $rows = 20; } if ($cols < 65) { $cols = 65; } } echo ""; p($value); echo "\n"; } function print_richedit_javascript($form, $name, $source="no") { /// Legacy function, provided for backward compatability use_html_editor($name); } function use_html_editor($name="") { /// Sets up the HTML editor on textareas in the current page. /// If a field name is provided, then it will only be /// applied to that field - otherwise it will be used /// on every textarea in the page. /// /// In most cases no arguments need to be supplied echo ""; } function update_course_icon($courseid) { // Used to be an icon, but it's now a simple form button global $CFG, $USER; if (isteacheredit($courseid)) { if (!empty($USER->editing)) { $string = get_string("turneditingoff"); $edit = "off"; } else { $string = get_string("turneditingon"); $edit = "on"; } return "framename\" method=\"get\" action=\"$CFG->wwwroot/course/view.php\">". "". "". ""; } } function update_module_button($moduleid, $courseid, $string) { // Prints the editing button on a module "view" page global $CFG; if (isteacheredit($courseid)) { $string = get_string("updatethis", "", $string); return "framename\" method=\"get\" action=\"$CFG->wwwroot/course/mod.php\">". "". "". ""; } else { return ""; } } function update_category_button($categoryid) { // Prints the editing button on a category page global $CFG, $USER; if (iscreator()) { if (!empty($USER->categoryediting)) { $string = get_string("turneditingoff"); $edit = "off"; } else { $string = get_string("turneditingon"); $edit = "on"; } return "framename\" method=\"get\" action=\"$CFG->wwwroot/course/category.php\">". "". "". ""; } } function update_categories_button() { // Prints the editing button on categories listing global $CFG, $USER; if (isadmin()) { if (!empty($USER->categoriesediting)) { $string = get_string("turneditingoff"); $edit = "off"; } else { $string = get_string("turneditingon"); $edit = "on"; } return "framename\" method=\"get\" action=\"$CFG->wwwroot/course/index.php\">". "". ""; } } function update_group_button($courseid, $groupid) { // Prints the editing button on group page global $CFG, $USER; if (isteacheredit($courseid)) { $string = get_string('editgroupprofile'); return "framename\" method=\"get\" action=\"$CFG->wwwroot/course/group.php\">". "". "". "". ""; } } function update_groups_button($courseid) { // Prints the editing button on groups page global $CFG, $USER; if (isteacheredit($courseid)) { if (!empty($USER->groupsediting)) { $string = get_string("turneditingoff"); $edit = "off"; } else { $string = get_string("turneditingon"); $edit = "on"; } return "framename\" method=\"get\" action=\"$CFG->wwwroot/course/groups.php\">". "". "". ""; } } function print_group_menu($groups, $groupmode, $currentgroup, $urlroot) { /// Prints an appropriate group selection menu echo ''; if ($groupmode == VISIBLEGROUPS) { print_string('groupsvisible'); } else { print_string('groupsseparate'); } echo ':'; echo ''; popup_form($urlroot.'&group=', $groups, 'selectgroup', $currentgroup, "", "", "", false, "self"); echo ''; } function navmenu($course, $cm=NULL, $targetwindow="self") { // Given a course and a (current) coursemodule // This function returns a small popup menu with all the // course activity modules in it, as a navigation menu // The data is taken from the serialised array stored in // the course record global $CFG; if ($cm) { $cm = $cm->id; } if ($course->format == 'weeks') { $strsection = get_string("week"); } else { $strsection = get_string("topic"); } if (!$modinfo = unserialize($course->modinfo)) { return ""; } $isteacher = isteacher($course->id); $section = -1; $selected = ""; $url = ""; $previousmod = NULL; $backmod = NULL; $nextmod = NULL; $selectmod = NULL; $logslink = NULL; $flag = false; foreach ($modinfo as $mod) { if ($mod->mod == "label") { continue; } if ($mod->section > 0 and $section <> $mod->section) { $menu[] = "-------------- $strsection $mod->section --------------"; } $section = $mod->section; //Only add visible or teacher mods to jumpmenu if ($mod->visible or $isteacher) { $url = "$mod->mod/view.php?id=$mod->cm"; if ($flag) { // the current mod is the "next" mod $nextmod = $mod; $flag = false; } if ($cm == $mod->cm) { $selected = $url; $selectmod = $mod; $backmod = $previousmod; $flag = true; // set flag so we know to use next mod for "next" } $mod->name = urldecode($mod->name); if (strlen($mod->name) > 55) { $mod->name = substr($mod->name, 0, 50)."..."; } if (!$mod->visible) { $mod->name = "(".$mod->name.")"; } $menu[$url] = $mod->name; $previousmod = $mod; } } if ($selectmod and $isteacher) { $logslink = "framename\" href=". "\"$CFG->wwwroot/course/log.php?chooselog=1&user=0&date=0&id=$course->id&modid=$selectmod->cm\">". "pixpath/i/log.gif\">"; } 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 "$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 = ""; 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 = ""; 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 = "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 = ""; } } 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: ?>
release ($CFG->version)\" href=\"http://moodle.org/\" target=\"_blank\">"; $homelink .= "
".stripslashes_safe($text)."
$icon".stripslashes_safe($text); helpbutton($helppage, $text, $module); echo "
'; if (!empty($user->role) and ($user->role <> $course->teacher)) { echo "$string->role: $user->role"; } if ($user->maildisplay == 1 or ($user->maildisplay == 2 and $course->category) or $isteacher) { echo "$string->email: email\">$user->email"; } if ($user->city or $user->country) { echo "$string->location: $user->city, ".$countries["$user->country"].""; } if ($user->lastaccess) { echo "$string->lastaccess: ".userdate($user->lastaccess); echo "  (".format_time(time() - $user->lastaccess, $datestring).")"; } else { echo "$string->lastaccess: $string->never"; } echo '
$message
"; echo "".get_string("yes").""; echo " "; echo "".get_string("no").""; echo "
( ".get_string("continue")." )
".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 "