MDL-30362 Change icon class for editsection icons in course formats
[moodle.git] / course / format / weeks / format.php
CommitLineData
aa6c1ced 1<?php
600149be 2 // Display the whole course as "weeks" made of of modules
3 // Included from "view.php"
ab9ad21d 4/**
5 * Evaluation weekly format for course display - NO layout tables, for accessibility, etc.
aa6c1ced
PS
6 *
7 * A duplicate course format to enable the Moodle development team to evaluate
8 * CSS for the multi-column layout in place of layout tables.
ab9ad21d 9 * Less risk for the Moodle 1.6 beta release.
10 * 1. Straight copy of weeks/format.php
11 * 2. Replace <table> and <td> with DIVs; inline styles.
12 * 3. Reorder columns so that in linear view content is first then blocks;
13 * styles to maintain original graphical (side by side) view.
14 *
aa6c1ced 15 * Target: 3-column graphical view using relative widths for pixel screen sizes
ab9ad21d 16 * 800x600, 1024x768... on IE6, Firefox. Below 800 columns will shift downwards.
aa6c1ced 17 *
ab9ad21d 18 * http://www.maxdesign.com.au/presentation/em/ Ideal length for content.
19 * http://www.svendtofte.com/code/max_width_in_ie/ Max width in IE.
20 *
21 * @copyright &copy; 2006 The Open University
22 * @author N.D.Freear@open.ac.uk, and others.
23 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
aa6c1ced 24 * @package
ab9ad21d 25 */
f9903ed0 26
4cac68ab
PS
27defined('MOODLE_INTERNAL') || die();
28
644d506a 29 require_once($CFG->libdir.'/filelib.php');
516c5eca 30 require_once($CFG->libdir.'/completionlib.php');
ab9ad21d 31
0cdae0dc 32 $week = optional_param('week', -1, PARAM_INT);
33
0cdae0dc 34 if ($week != -1) {
b86fc0e2 35 $displaysection = course_set_display($course->id, $week);
36 } else {
13801a49 37 $displaysection = course_get_display($course->id);
600149be 38 }
39
a3f24f7c 40 $streditsummary = get_string('editsummary');
41 $stradd = get_string('add');
42 $stractivities = get_string('activities');
43 $strshowallweeks = get_string('showallweeks');
44 $strweek = get_string('week');
45 $strgroups = get_string('groups');
46 $strgroupmy = get_string('groupmy');
47 $editing = $PAGE->user_is_editing();
48
0f3fe4b6 49 if ($editing) {
9101efd3 50 $strweekhide = get_string('hideweekfromothers');
51 $strweekshow = get_string('showweekfromothers');
6cba878d 52 $strmoveup = get_string('moveup');
53 $strmovedown = get_string('movedown');
1ea7c627 54 }
9a223597 55
3924b988 56 $context = get_context_instance(CONTEXT_COURSE, $course->id);
e3568fde 57
58 //Print the Your progress icon if the track completion is enabled
59 $completioninfo = new completion_info($course);
563e97b8 60 echo $completioninfo->display_help_icon();
e3568fde 61
27ca34af 62 echo $OUTPUT->heading(get_string('weeklyoutline'), 2, 'headingblock header outline');
9a223597 63
ab9ad21d 64 // Note, an ordered list would confuse - "1" could be the clipboard or summary.
65 echo "<ul class='weeks'>\n";
9a223597 66
7977cffd 67/// If currently moving a file then show the current clipboard
68 if (ismoving($course->id)) {
294ce987 69 $stractivityclipboard = strip_tags(get_string('activityclipboard', '', $USER->activitycopyname));
6cba878d 70 $strcancel= get_string('cancel');
ab9ad21d 71 echo '<li class="clipboard">';
d4a1fcaf 72 echo $stractivityclipboard.'&nbsp;&nbsp;(<a href="mod.php?cancelcopy=true&amp;sesskey='.sesskey().'">'.$strcancel.'</a>)';
ab9ad21d 73 echo "</li>\n";
c63bf72a 74 }
7977cffd 75
1ea7c627 76/// Print Section 0 with general activities
9a223597 77
1ea7c627 78 $section = 0;
79 $thissection = $sections[$section];
4cac68ab 80 unset($sections[0]);
9a223597 81
830dd6e9 82 if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) {
ab9ad21d 83
84 // Note, 'right side' is BEFORE content.
7e184672 85 echo '<li id="section-0" class="section main clearfix" >';
d4a03c00 86 echo '<div class="left side">&nbsp;</div>';
aa6c1ced 87 echo '<div class="right side" >&nbsp;</div>';
ab9ad21d 88 echo '<div class="content">';
aa6c1ced 89
0f4ab67d 90 if (!empty($thissection->name)) {
71e0b3b5 91 echo $OUTPUT->heading(format_string($thissection->name, true, array('context' => $context)), 3, 'sectionname');
0f4ab67d
SH
92 }
93
40901069 94 echo '<div class="summary">';
644d506a 95
96 $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
64f93798 97 $summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course', 'section', $thissection->id);
367a75fa 98 $summaryformatoptions = new stdClass;
179c9a50 99 $summaryformatoptions->noclean = true;
367a75fa 100 $summaryformatoptions->overflowdiv = true;
e34a326f 101 echo format_text($summarytext, $thissection->summaryformat, $summaryformatoptions);
5f850588 102
830dd6e9 103 if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
ab9ad21d 104 echo '<p><a title="'.$streditsummary.'" '.
b5d0cafc 105 ' href="editsection.php?id='.$thissection->id.'"><img src="'.$OUTPUT->pix_url('t/edit') . '" '.
75cd9d2a 106 ' class="iconsmall edit" alt="'.$streditsummary.'" /></a></p>';
9a223597 107 }
40901069 108 echo '</div>';
aa6c1ced 109
1ea7c627 110 print_section($course, $thissection, $mods, $modnamesused);
f2991c6e 111
830dd6e9 112 if ($PAGE->user_is_editing()) {
e0161bff 113 print_section_add_menus($course, $section, $modnames);
9a223597 114 }
115
ab9ad21d 116 echo '</div>';
117 echo "</li>\n";
9a223597 118 }
119
120
6cba878d 121/// Now all the normal modules by week
122/// Everything below uses "section" terminology - each "section" is a week.
123
f9903ed0 124 $timenow = time();
125 $weekdate = $course->startdate; // this should be 0:00 Monday of that week
01e1f34e 126 $weekdate += 7200; // Add two hours to avoid possible DST problems
1ea7c627 127 $section = 1;
584ec10e 128 $sectionmenu = array();
01e1f34e 129 $weekofseconds = 604800;
b5fe4c93 130 $course->enddate = $course->startdate + ($weekofseconds * $course->numsections);
f9903ed0 131
6cba878d 132 $strftimedateshort = ' '.get_string('strftimedateshort');
dcde9f02 133
e3f0a6a7 134 while ($weekdate < $course->enddate) {
f9903ed0 135
136 $nextweekdate = $weekdate + ($weekofseconds);
1ea7c627 137 $weekday = userdate($weekdate, $strftimedateshort);
01e1f34e 138 $endweekday = userdate($weekdate+518400, $strftimedateshort);
600149be 139
1ea7c627 140 if (!empty($sections[$section])) {
141 $thissection = $sections[$section];
f9903ed0 142
1ea7c627 143 } else {
144 unset($thissection);
145 $thissection->course = $course->id; // Create a new week structure
146 $thissection->section = $section;
1459becf 147 $thissection->name = null;
6cba878d 148 $thissection->summary = '';
7a6f3c33 149 $thissection->summaryformat = FORMAT_HTML;
1ea7c627 150 $thissection->visible = 1;
a8f3a651 151 $thissection->id = $DB->insert_record('course_sections', $thissection);
1ea7c627 152 }
f9903ed0 153
3924b988 154 $showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible or !$course->hiddensections);
f9903ed0 155
8dc93b94 156 if (!empty($displaysection) and $displaysection != $section) { // Check this week is visible
157 if ($showsection) {
47e75d04 158 $sectionmenu[$section] = get_section_name($course, $thissection);
8dc93b94 159 }
160 $section++;
161 $weekdate = $nextweekdate;
162 continue;
163 }
164
db7da819 165 if ($showsection) {
f9903ed0 166
db7da819 167 $currentweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate));
f9903ed0 168
e9b9c1d8 169 $currenttext = '';
db7da819 170 if (!$thissection->visible) {
6cba878d 171 $sectionstyle = ' hidden';
db7da819 172 } else if ($currentweek) {
6cba878d 173 $sectionstyle = ' current';
e9b9c1d8 174 $currenttext = get_accesshide(get_string('currentweek','access'));
db7da819 175 } else {
6cba878d 176 $sectionstyle = '';
1ea7c627 177 }
178
7e184672 179 echo '<li id="section-'.$section.'" class="section main clearfix'.$sectionstyle.'" >';
dc140b6c 180
4454447d 181 echo '<div class="left side">&nbsp;'.$currenttext.'</div>';
12905134 182
ab9ad21d 183 // Note, 'right side' is BEFORE content.
184 echo '<div class="right side">';
aa6c1ced 185
db7da819 186 if ($displaysection == $section) {
0cdae0dc 187 echo '<a href="view.php?id='.$course->id.'&amp;week=0#section-'.$section.'" title="'.$strshowallweeks.'">'.
b5d0cafc 188 '<img src="'.$OUTPUT->pix_url('i/all') . '" class="icon wkall" alt="'.$strshowallweeks.'" /></a><br />';
db7da819 189 } else {
190 $strshowonlyweek = get_string("showonlyweek", "", $section);
6cba878d 191 echo '<a href="view.php?id='.$course->id.'&amp;week='.$section.'" title="'.$strshowonlyweek.'">'.
b5d0cafc 192 '<img src="'.$OUTPUT->pix_url('i/one') . '" class="icon wkone" alt="'.$strshowonlyweek.'" /></a><br />';
12905134 193 }
dc140b6c 194
830dd6e9 195 if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
db7da819 196 if ($thissection->visible) { // Show the hide/show eye
d4a1fcaf 197 echo '<a href="view.php?id='.$course->id.'&amp;hide='.$section.'&amp;sesskey='.sesskey().'#section-'.$section.'" title="'.$strweekhide.'">'.
b5d0cafc 198 '<img src="'.$OUTPUT->pix_url('i/hide') . '" class="icon hide" alt="'.$strweekhide.'" /></a><br />';
db7da819 199 } else {
d4a1fcaf 200 echo '<a href="view.php?id='.$course->id.'&amp;show='.$section.'&amp;sesskey='.sesskey().'#section-'.$section.'" title="'.$strweekshow.'">'.
b5d0cafc 201 '<img src="'.$OUTPUT->pix_url('i/show') . '" class="icon hide" alt="'.$strweekshow.'" /></a><br />';
db7da819 202 }
db7da819 203 if ($section > 1) { // Add a arrow to move section up
d4a1fcaf 204 echo '<a href="view.php?id='.$course->id.'&amp;random='.rand(1,10000).'&amp;section='.$section.'&amp;move=-1&amp;sesskey='.sesskey().'#section-'.($section-1).'" title="'.$strmoveup.'">'.
b5d0cafc 205 '<img src="'.$OUTPUT->pix_url('t/up') . '" class="icon up" alt="'.$strmoveup.'" /></a><br />';
db7da819 206 }
dc140b6c 207
db7da819 208 if ($section < $course->numsections) { // Add a arrow to move section down
d4a1fcaf 209 echo '<a href="view.php?id='.$course->id.'&amp;random='.rand(1,10000).'&amp;section='.$section.'&amp;move=1&amp;sesskey='.sesskey().'#section-'.($section+1).'" title="'.$strmovedown.'">'.
b5d0cafc 210 '<img src="'.$OUTPUT->pix_url('t/down') . '" class="icon down" alt="'.$strmovedown.'" /></a><br />';
ab9ad21d 211 }
212 }
213 echo '</div>';
214
0154653b 215 $weekperiod = $weekday.' - '.$endweekday;
216
ab9ad21d 217 echo '<div class="content">';
218 if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible) { // Hidden for students
7c5286cd 219 echo $OUTPUT->heading($currenttext.$weekperiod.' ('.get_string('notavailable').')', 3, 'weekdates');
ab9ad21d 220
221 } else {
83f1fa9c 222 if (isset($thissection->name) && ($thissection->name !== NULL)) { // empty string is ok
71e0b3b5 223 echo $OUTPUT->heading(format_string($thissection->name, true, array('context' => $context)), 3, 'weekdates');
0f4ab67d
SH
224 } else {
225 echo $OUTPUT->heading($currenttext.$weekperiod, 3, 'weekdates');
226 }
ab9ad21d 227 echo '<div class="summary">';
6597e6b7 228 $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
64f93798 229 $summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course', 'section', $thissection->id);
367a75fa 230 $summaryformatoptions = new stdClass;
ab9ad21d 231 $summaryformatoptions->noclean = true;
367a75fa 232 $summaryformatoptions->overflowdiv = true;
e34a326f 233 echo format_text($summarytext, $thissection->summaryformat, $summaryformatoptions);
ab9ad21d 234
830dd6e9 235 if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
ab9ad21d 236 echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id.'">'.
75cd9d2a 237 '<img src="'.$OUTPUT->pix_url('t/edit') . '" class="iconsmall edit" alt="'.$streditsummary.'" /></a><br /><br />';
ab9ad21d 238 }
239 echo '</div>';
240
241 print_section($course, $thissection, $mods, $modnamesused);
f2991c6e 242
830dd6e9 243 if ($PAGE->user_is_editing()) {
ab9ad21d 244 print_section_add_menus($course, $section, $modnames);
db7da819 245 }
12905134 246 }
dc140b6c 247
ab9ad21d 248 echo '</div>';
249 echo "</li>\n";
1ea7c627 250 }
251
4cac68ab 252 unset($sections[$section]);
1ea7c627 253 $section++;
f9903ed0 254 $weekdate = $nextweekdate;
255 }
4cac68ab 256
36b1c872 257 if (!$displaysection and $PAGE->user_is_editing() and has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
4cac68ab
PS
258 // print stealth sections if present
259 $modinfo = get_fast_modinfo($course);
260 foreach ($sections as $section=>$thissection) {
261 if (empty($modinfo->sections[$section])) {
262 continue;
263 }
264
4cac68ab
PS
265 echo '<li id="section-'.$section.'" class="section main clearfix stealth hidden">'; //'<div class="left side">&nbsp;</div>';
266
267 echo '<div class="left side">';
4cac68ab
PS
268 echo '</div>';
269 // Note, 'right side' is BEFORE content.
270 echo '<div class="right side">';
4cac68ab
PS
271 echo '</div>';
272 echo '<div class="content">';
46b2346b 273 echo $OUTPUT->heading(get_string('orphanedactivities'), 3, 'sectionname');
4cac68ab 274 print_section($course, $thissection, $mods, $modnamesused);
4cac68ab
PS
275 echo '</div>';
276 echo "</li>\n";
277 }
278 }
279
ab9ad21d 280 echo "</ul>\n";
584ec10e 281
282 if (!empty($sectionmenu)) {
6fe3775a
PS
283 $select = new single_select(new moodle_url('/course/view.php', array('id'=>$course->id)), 'week', $sectionmenu);
284 $select->label = get_string('jumpto');
285 $select->class = 'jumpmenu';
286 $select->formid = 'sectionmenu';
287 echo $OUTPUT->render($select);
584ec10e 288 }