Removed THEME from many course files
[moodle.git] / course / format / weeks / format.php
CommitLineData
24f2b65a 1<?php // $Id$
600149be 2 // Display the whole course as "weeks" made of of modules
3 // Included from "view.php"
f9903ed0 4
b0e3a925 5 require_once("$CFG->dirroot/mod/forum/lib.php");
f9903ed0 6
0f3fe4b6 7 // Bounds for block widths
8 define('BLOCK_L_MIN_WIDTH', 100);
9 define('BLOCK_L_MAX_WIDTH', 210);
10 define('BLOCK_R_MIN_WIDTH', 100);
11 define('BLOCK_R_MAX_WIDTH', 210);
12
9b4b78fd 13 optional_variable($preferred_width_left, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]));
14 optional_variable($preferred_width_right, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]));
0f3fe4b6 15 $preferred_width_left = min($preferred_width_left, BLOCK_L_MAX_WIDTH);
16 $preferred_width_left = max($preferred_width_left, BLOCK_L_MIN_WIDTH);
17 $preferred_width_right = min($preferred_width_right, BLOCK_R_MAX_WIDTH);
18 $preferred_width_right = max($preferred_width_right, BLOCK_R_MIN_WIDTH);
f9903ed0 19
72e62a9e 20 if (isset($week)) {
b86fc0e2 21 $displaysection = course_set_display($course->id, $week);
22 } else {
23 if (isset($USER->display[$course->id])) {
24 $displaysection = $USER->display[$course->id];
600149be 25 } else {
b86fc0e2 26 $displaysection = course_set_display($course->id, 0);
600149be 27 }
28 }
29
9a223597 30 if ($course->newsitems) {
31 $news = forum_get_course_forum($course->id, "news");
32 }
0f3fe4b6 33
1ea7c627 34 $streditsummary = get_string("editsummary");
35 $stradd = get_string("add");
36 $stractivities = get_string("activities");
37 $strshowallweeks = get_string("showallweeks");
584ec10e 38 $strweek = get_string("week");
f374fb10 39 $strgroups = get_string("groups");
40 $strgroupmy = get_string("groupmy");
0f3fe4b6 41 if ($editing) {
1ea7c627 42 $strstudents = moodle_strtolower($course->students);
43 $strweekhide = get_string("weekhide", "", $strstudents);
44 $strweekshow = get_string("weekshow", "", $strstudents);
d7b97e43 45 $strmoveup = get_string("moveup");
46 $strmovedown = get_string("movedown");
1ea7c627 47 }
9a223597 48
600149be 49
9a223597 50/// Layout the whole page as three big columns.
dc140b6c 51 echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" width=\"100%\" id=\"layout-table\">";
f9903ed0 52
24f2b65a 53 echo "<tr valign=\"top\">\n";
13c7e271 54
0f3fe4b6 55/// The left column ...
f374fb10 56
9b4b78fd 57 if(blocks_have_content($pageblocks[BLOCK_POS_LEFT]) || $editing) {
dc140b6c 58 echo '<td style="vertical-align: top; width: '.$preferred_width_left.'px;" id="left-column">';
f032aa7a 59 blocks_print_group($PAGE, $pageblocks[BLOCK_POS_LEFT]);
0f3fe4b6 60 echo '</td>';
2c0411e2 61 }
9a223597 62
63/// Start main column
dc140b6c 64 echo '<td valign="top" width="*" id="middle-column">';
7541bc3e 65 print_heading_block(get_string("weeklyoutline"), "100%", "outlineheadingblock");
e5454458 66 print_spacer(8, 1, true);
9a223597 67
7541bc3e 68 echo "<table class=\"weeklyoutline\" border=\"0\" cellpadding=\"8\" cellspacing=\"0\" width=\"100%\">";
9a223597 69
7977cffd 70/// If currently moving a file then show the current clipboard
71 if (ismoving($course->id)) {
adcedde7 72 $stractivityclipboard = strip_tags(get_string("activityclipboard", "", addslashes($USER->activitycopyname)));
7977cffd 73 $strcancel= get_string("cancel");
74 echo "<tr>";
24f2b65a 75 echo "<td colspan=\"3\" valign=\"top\" bgcolor=\"$THEME->cellcontent\" class=\"weeklyoutlineclip\" width=\"100%\">";
76 echo "<p><font size=\"2\">";
8b92f5bb 77 echo "$stractivityclipboard&nbsp;&nbsp;(<a href=\"mod.php?cancelcopy=true&amp;sesskey=$USER->sesskey\">$strcancel</a>)";
7977cffd 78 echo "</font></p>";
79 echo "</td>";
80 echo "</tr>";
839f2456 81 echo "<tr><td colspan=\"3\"><img src=\"../pix/spacer.gif\" width=\"1\" height=\"1\" alt=\"\" /></td></tr>";
7977cffd 82 }
83
1ea7c627 84/// Print Section 0 with general activities
9a223597 85
1ea7c627 86 $section = 0;
87 $thissection = $sections[$section];
9a223597 88
1ea7c627 89 if ($thissection->summary or $thissection->sequence or isediting($course->id)) {
dc0dc7d5 90 echo "<tr>";
44ff1b87 91 echo "<td nowrap=\"nowrap\" bgcolor=\"$THEME->cellheading\" class=\"weeklyoutlineside\" valign=\"top\" width=\"20\">&nbsp;</td>";
24f2b65a 92 echo "<td valign=\"top\" bgcolor=\"$THEME->cellcontent\" class=\"weeklyoutlinecontent\" width=\"100%\">";
9a223597 93
179c9a50 94 $summaryformatoptions->noclean = true;
95 echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
5f850588 96
9a223597 97 if (isediting($course->id)) {
5f850588 98 echo " <a title=\"$streditsummary\" ".
24f2b65a 99 " href=\"editsection.php?id=$thissection->id\"><img height=\"11\" width=\"11\" src=\"$CFG->pixpath/t/edit.gif\" ".
dfc12289 100 " border=\"0\" alt=\"$streditsummary\" /></a><br /><br />";
9a223597 101 }
5f850588 102
1ea7c627 103 print_section($course, $thissection, $mods, $modnamesused);
9a223597 104
105 if (isediting($course->id)) {
e0161bff 106 print_section_add_menus($course, $section, $modnames);
9a223597 107 }
108
b86fc0e2 109 echo "</td>";
44ff1b87 110 echo "<td nowrap=\"nowrap\" bgcolor=\"$THEME->cellheading\" class=\"weeklyoutlineside\" valign=\"top\" align=\"center\" width=\"10\">";
1ea7c627 111 echo "&nbsp;</td></tr>";
839f2456 112 echo "<tr><td colspan=\"3\"><img src=\"../pix/spacer.gif\" width=\"1\" height=\"1\" alt=\"\" /></td></tr>";
9a223597 113 }
114
115
116/// Now all the weekly sections
f9903ed0 117 $timenow = time();
118 $weekdate = $course->startdate; // this should be 0:00 Monday of that week
674416ea 119 $weekdate += 7200; // Add two hours to avoid possible DST problems
1ea7c627 120 $section = 1;
584ec10e 121 $sectionmenu = array();
f9903ed0 122 $weekofseconds = 604800;
b5fe4c93 123 $course->enddate = $course->startdate + ($weekofseconds * $course->numsections);
f9903ed0 124
dcde9f02 125 $strftimedateshort = " ".get_string("strftimedateshort");
126
e3f0a6a7 127 while ($weekdate < $course->enddate) {
f9903ed0 128
129 $nextweekdate = $weekdate + ($weekofseconds);
1ea7c627 130 $weekday = userdate($weekdate, $strftimedateshort);
131 $endweekday = userdate($weekdate+518400, $strftimedateshort);
600149be 132
1ea7c627 133 if (!empty($displaysection) and $displaysection != $section) { // Check this week is visible
584ec10e 134 $sectionmenu["week=$section"] = s("$strweek $section | $weekday - $endweekday");
1ea7c627 135 $section++;
b86fc0e2 136 $weekdate = $nextweekdate;
137 continue;
600149be 138 }
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;
147 $thissection->summary = "";
148 $thissection->visible = 1;
149 if (!$thissection->id = insert_record("course_sections", $thissection)) {
150 notify("Error inserting new week!");
151 }
152 }
f9903ed0 153
db7da819 154 $showsection = (isteacher($course->id) or $thissection->visible or !$course->hiddensections);
f9903ed0 155
db7da819 156 if ($showsection) {
f9903ed0 157
db7da819 158 $currentweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate));
f9903ed0 159
db7da819 160 if (!$thissection->visible) {
161 $colorsides = "bgcolor=\"$THEME->hidden\" class=\"weeklyoutlinesidehidden\"";
162 $colormain = "bgcolor=\"$THEME->cellcontent\" class=\"weeklyoutlinecontenthidden\"";
163 } else if ($currentweek) {
164 $colorsides = "bgcolor=\"$THEME->cellheading2\" class=\"weeklyoutlinesidehighlight\"";
165 $colormain = "bgcolor=\"$THEME->cellcontent\" class=\"weeklyoutlinecontenthighlight\"";
166 } else {
167 $colorsides = "bgcolor=\"$THEME->cellheading\" class=\"weeklyoutlineside\"";
168 $colormain = "bgcolor=\"$THEME->cellcontent\" class=\"weeklyoutlinecontent\"";
1ea7c627 169 }
170
db7da819 171 echo "<tr>";
44ff1b87 172 echo "<td nowrap=\"nowrap\" $colorsides valign=\"top\" width=\"20\">";
24f2b65a 173 echo "<p align=\"center\"><font size=\"3\"><a name=\"$section\">$section</a></font></p>";
1ea7c627 174 echo "</td>";
dc140b6c 175
24f2b65a 176 echo "<td valign=\"top\" $colormain width=\"100%\">";
dc140b6c 177
db7da819 178 if (!isteacher($course->id) and !$thissection->visible) { // Hidden for students
179 echo "<p class=\"weeklydatetext\">$weekday - $endweekday ";
180 echo "(".get_string("notavailable").")";
181 echo "</p>";
182 echo "</td>";
dc140b6c 183
1ea7c627 184 } else {
dc140b6c 185
db7da819 186 echo "<p class=\"weeklydatetext\">$weekday - $endweekday</p>";
dc140b6c 187
179c9a50 188 $summaryformatoptions->noclean = true;
189 echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
dc140b6c 190
db7da819 191 if (isediting($course->id)) {
192 echo " <a title=\"$streditsummary\" href=\"editsection.php?id=$thissection->id\">".
dfc12289 193 "<img src=\"$CFG->pixpath/t/edit.gif\" height=\"11\" width=\"11\" border=\"0\" /></a><br /><br />";
db7da819 194 }
dc140b6c 195
db7da819 196 print_section($course, $thissection, $mods, $modnamesused);
dc140b6c 197
db7da819 198 if (isediting($course->id)) {
e0161bff 199 print_section_add_menus($course, $section, $modnames);
db7da819 200 }
dc140b6c 201
db7da819 202 echo "</td>";
1ea7c627 203 }
44ff1b87 204 echo "<td nowrap=\"nowrap\" $colorsides valign=\"top\" align=\"center\" width=\"10\">";
24f2b65a 205 echo "<font size=\"1\">";
12905134 206
db7da819 207 if ($displaysection == $section) {
839f2456 208 echo "<a href=\"view.php?id=$course->id&amp;week=all\" title=\"$strshowallweeks\">".
209 "<img src=\"$CFG->pixpath/i/all.gif\" height=\"25\" width=\"16\" border=\"0\" alt=\"\" /></a><br />";
db7da819 210 } else {
211 $strshowonlyweek = get_string("showonlyweek", "", $section);
839f2456 212 echo "<a href=\"view.php?id=$course->id&amp;week=$section\" title=\"$strshowonlyweek\">".
213 "<img src=\"$CFG->pixpath/i/one.gif\" height=\"16\" width=\"16\" border=\"0\" alt=\"\" /></a><br />";
12905134 214 }
dc140b6c 215
db7da819 216 if (isediting($course->id)) {
217 if ($thissection->visible) { // Show the hide/show eye
5b224948 218 echo "<a href=\"view.php?id=$course->id&amp;hide=$section&amp;sesskey=$USER->sesskey\" title=\"$strweekhide\">".
839f2456 219 "<img src=\"$CFG->pixpath/i/hide.gif\" vspace=\"3\" height=\"16\" width=\"16\" border=\"0\" alt=\"\" /></a><br />";
db7da819 220 } else {
5b224948 221 echo "<a href=\"view.php?id=$course->id&amp;show=$section&amp;sesskey=$USER->sesskey\" title=\"$strweekshow\">".
839f2456 222 "<img src=\"$CFG->pixpath/i/show.gif\" vspace=\"3\" height=\"16\" width=\"16\" border=\"0\" alt=\"\" /></a><br />";
db7da819 223 }
dc140b6c 224
db7da819 225 if ($section > 1) { // Add a arrow to move section up
5b224948 226 echo "<a href=\"view.php?id=$course->id&amp;section=$section&amp;move=-1&amp;sesskey=$USER->sesskey\" title=\"$strmoveup\">".
839f2456 227 "<img src=\"$CFG->pixpath/t/up.gif\" vspace=\"3\" height=\"11\" width=\"11\" border=\"0\" alt=\"\" /></a><br />";
db7da819 228 }
dc140b6c 229
db7da819 230 if ($section < $course->numsections) { // Add a arrow to move section down
5b224948 231 echo "<a href=\"view.php?id=$course->id&amp;section=$section&amp;move=1&amp;sesskey=$USER->sesskey\" title=\"$strmovedown\">".
839f2456 232 "<img src=\"$CFG->pixpath/t/down.gif\" vspace=\"3\" height=\"11\" width=\"11\" border=\"0\" alt=\"\" /></a><br />";
db7da819 233 }
dc140b6c 234
12905134 235 }
dc140b6c 236
44ff1b87 237 echo "</font>";
db7da819 238 echo "</td>";
239 echo "</tr>";
839f2456 240 echo "<tr><td colspan=\"3\"><img src=\"../pix/spacer.gif\" width=\"1\" height=\"1\" alt=\"\"></td></tr>";
1ea7c627 241 }
242
1ea7c627 243 $section++;
f9903ed0 244 $weekdate = $nextweekdate;
245 }
dc0dc7d5 246 echo "</table>";
584ec10e 247
248 if (!empty($sectionmenu)) {
249 echo "<center>";
0f3fe4b6 250 echo popup_form("$CFG->wwwroot/course/view.php?id=$course->id&", $sectionmenu,
584ec10e 251 "sectionmenu", "", get_string("jumpto"), "", "", true);
252 echo "</center>";
253 }
0f3fe4b6 254
255
256 echo "</td>";
257
258 // The right column
9b4b78fd 259 if(blocks_have_content($pageblocks[BLOCK_POS_RIGHT]) || $editing) {
dc140b6c 260 echo '<td style="vertical-align: top; width: '.$preferred_width_right.'px;" id="right-column">';
f032aa7a 261 blocks_print_group($PAGE, $pageblocks[BLOCK_POS_RIGHT]);
0f3fe4b6 262 if ($editing && !empty($missingblocks)) {
f032aa7a 263 blocks_print_adminblock($PAGE, $missingblocks);
13beeacb 264 }
9b4b78fd 265 echo '</td>';
13beeacb 266 }
19a55d67 267
0f3fe4b6 268 echo "</tr>\n";
269 echo "</table>\n";
f9903ed0 270?>