|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00032 function callback_weeks_uses_sections() { 00033 return true; 00034 } 00035 00046 function callback_weeks_load_content(&$navigation, $course, $coursenode) { 00047 return $navigation->load_generic_course_sections($course, $coursenode, 'weeks'); 00048 } 00049 00056 function callback_weeks_definition() { 00057 return get_string('week'); 00058 } 00059 00066 function callback_weeks_request_key() { 00067 return 'week'; 00068 } 00069 00077 function callback_weeks_get_section_name($course, $section) { 00078 // We can't add a node without text 00079 if (!empty($section->name)) { 00080 // Return the name the user set 00081 return format_string($section->name, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))); 00082 } else if ($section->section == 0) { 00083 // Return the section0name 00084 return get_string('section0name', 'format_weeks'); 00085 } else { 00086 // Got to work out the date of the week so that we can show it 00087 $sections = get_all_sections($course->id); 00088 $weekdate = $course->startdate+7200; 00089 foreach ($sections as $sec) { 00090 if ($sec->id == $section->id) { 00091 break; 00092 } else if ($sec->section != 0) { 00093 $weekdate += 604800; 00094 } 00095 } 00096 $strftimedateshort = ' '.get_string('strftimedateshort'); 00097 $weekday = userdate($weekdate, $strftimedateshort); 00098 $endweekday = userdate($weekdate+518400, $strftimedateshort); 00099 return $weekday.' - '.$endweekday; 00100 } 00101 } 00102 00109 function callback_weeks_ajax_support() { 00110 $ajaxsupport = new stdClass(); 00111 $ajaxsupport->capable = true; 00112 $ajaxsupport->testedbrowsers = array('MSIE' => 6.0, 'Gecko' => 20061111, 'Safari' => 531, 'Chrome' => 6.0); 00113 return $ajaxsupport; 00114 } 00115 00123 function callback_weeks_get_section_url($courseid, $sectionnum) { 00124 return new moodle_url('/course/view.php', array('id' => $courseid, 'week' => $sectionnum)); 00125 }