2 // Display the whole course as "topics" made of of modules
3 // In fact, this is very similar to the "weeks" format, in that
4 // each "topic" is actually a week. The main difference is that
5 // the dates aren't printed - it's just an aesthetic thing for
6 // courses that aren't so rigidly defined by time.
7 // Included from "view.php"
10 require_once($CFG->libdir
.'/ajax/ajaxlib.php');
12 if (!empty($THEME->customcorners
)) {
13 require_once($CFG->dirroot
.'/lib/custom_corners_lib.php');
16 $topic = optional_param('topic', -1, PARAM_INT
);
18 // Bounds for block widths
19 // more flexible for theme designers taken from theme config.php
20 $lmin = (empty($THEME->block_l_min_width
)) ?
100 : $THEME->block_l_min_width
;
21 $lmax = (empty($THEME->block_l_max_width
)) ?
210 : $THEME->block_l_max_width
;
22 $rmin = (empty($THEME->block_r_min_width
)) ?
100 : $THEME->block_r_min_width
;
23 $rmax = (empty($THEME->block_r_max_width
)) ?
210 : $THEME->block_r_max_width
;
25 define('BLOCK_L_MIN_WIDTH', $lmin);
26 define('BLOCK_L_MAX_WIDTH', $lmax);
27 define('BLOCK_R_MIN_WIDTH', $rmin);
28 define('BLOCK_R_MAX_WIDTH', $rmax);
30 $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH
, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT
]),
32 $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH
, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT
]),
36 $displaysection = course_set_display($course->id
, $topic);
38 if (isset($USER->display
[$course->id
])) { // for admins, mostly
39 $displaysection = $USER->display
[$course->id
];
41 $displaysection = course_set_display($course->id
, 0);
45 $context = get_context_instance(CONTEXT_COURSE
, $course->id
);
47 if (($marker >=0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) {
48 $course->marker
= $marker;
49 if (! set_field("course", "marker", $marker, "id", $course->id
)) {
50 error("Could not mark that topic for this course");
54 $streditsummary = get_string('editsummary');
55 $stradd = get_string('add');
56 $stractivities = get_string('activities');
57 $strshowalltopics = get_string('showalltopics');
58 $strtopic = get_string('topic');
59 $strgroups = get_string('groups');
60 $strgroupmy = get_string('groupmy');
61 $editing = $PAGE->user_is_editing();
64 $strstudents = moodle_strtolower($course->students
);
65 $strtopichide = get_string('topichide', '', $strstudents);
66 $strtopicshow = get_string('topicshow', '', $strstudents);
67 $strmarkthistopic = get_string('markthistopic');
68 $strmarkedthistopic = get_string('markedthistopic');
69 $strmoveup = get_string('moveup');
70 $strmovedown = get_string('movedown');
74 /// Layout the whole page as three big columns.
75 echo '<table id="layout-table" cellspacing="0" summary="'.get_string('layouttable').'"><tr>';
77 /// The left column ...
78 $lt = (empty($THEME->layouttable
)) ?
array('left', 'middle', 'right') : $THEME->layouttable
;
79 foreach ($lt as $column) {
83 if (blocks_have_content($pageblocks, BLOCK_POS_LEFT
) ||
$editing) {
84 echo '<td style="width:'.$preferred_width_left.'px" id="left-column">';
85 if (!empty($THEME->customcorners
)) print_custom_corners_start();
86 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT
);
87 if (!empty($THEME->customcorners
)) print_custom_corners_end();
94 echo '<td id="middle-column">';
95 if (!empty($THEME->customcorners
)) print_custom_corners_start();
96 echo '<a name="startofcontent"></a>';
98 print_heading_block(get_string('topicoutline'), 'outline');
100 echo '<table class="topics" width="100%" summary="'.get_string('layouttable').'">';
102 /// If currently moving a file then show the current clipboard
103 if (ismoving($course->id
)) {
104 $stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname
)));
105 $strcancel= get_string('cancel');
106 echo '<tr class="clipboard">';
107 echo '<td colspan="3">';
108 echo $stractivityclipboard.' (<a href="mod.php?cancelcopy=true&sesskey='.$USER->sesskey
.'">'.$strcancel.'</a>)';
116 $thissection = $sections[$section];
118 if ($thissection->summary
or $thissection->sequence
or isediting($course->id
)) {
119 echo '<tr id="section-0" class="section main">';
120 echo '<td class="left side"> </td>';
121 echo '<td class="content">';
123 echo '<div class="summary">';
124 $summaryformatoptions->noclean
= true;
125 echo format_text($thissection->summary
, FORMAT_HTML
, $summaryformatoptions);
127 if (isediting($course->id
) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE
, $course->id
))) {
128 echo '<a title="'.$streditsummary.'" '.
129 ' href="editsection.php?id='.$thissection->id
.'"><img src="'.$CFG->pixpath
.'/t/edit.gif" '.
130 ' alt="'.$streditsummary.'" /></a><br /><br />';
134 print_section($course, $thissection, $mods, $modnamesused);
136 if (isediting($course->id
)) {
137 print_section_add_menus($course, $section, $modnames);
141 echo '<td class="right side"> </td>';
143 echo '<tr class="section separator"><td colspan="3" class="spacer"></td></tr>';
147 /// Now all the normal modules by topic
148 /// Everything below uses "section" terminology - each "section" is a topic.
152 $sectionmenu = array();
154 while ($section <= $course->numsections
) {
156 if (!empty($sections[$section])) {
157 $thissection = $sections[$section];
161 $thissection->course
= $course->id
; // Create a new section structure
162 $thissection->section
= $section;
163 $thissection->summary
= '';
164 $thissection->visible
= 1;
165 if (!$thissection->id
= insert_record('course_sections', $thissection)) {
166 notify('Error inserting new topic!');
170 $showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible
or !$course->hiddensections
);
172 if (!empty($displaysection) and $displaysection != $section) {
174 $strsummary = strip_tags(format_string($thissection->summary
,true));
175 if (strlen($strsummary) < 57) {
176 $strsummary = ' - '.$strsummary;
178 $strsummary = ' - '.substr($strsummary, 0, 60).'...';
180 $sectionmenu['topic='.$section] = s($section.$strsummary);
188 $currenttopic = ($course->marker
== $section);
190 if (!$thissection->visible
) {
191 $sectionstyle = ' hidden';
192 } else if ($currenttopic) {
193 $sectionstyle = ' current';
198 echo '<tr id="section-'.$section.'" class="section main'.$sectionstyle.'">';
199 echo '<td class="left side">'.$section.'</td>';
201 echo '<td class="content">';
202 if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible
) { // Hidden for students
203 echo get_string('notavailable');
205 echo '<div class="summary">';
206 $summaryformatoptions->noclean
= true;
207 echo format_text($thissection->summary
, FORMAT_HTML
, $summaryformatoptions);
209 if (isediting($course->id
) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE
, $course->id
))) {
210 echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id
.'">'.
211 '<img src="'.$CFG->pixpath
.'/t/edit.gif" alt="'.$streditsummary.'" /></a><br /><br />';
215 print_section($course, $thissection, $mods, $modnamesused);
217 if (isediting($course->id
)) {
218 print_section_add_menus($course, $section, $modnames);
223 echo '<td class="right side">';
224 if ($displaysection == $section) { // Show the zoom boxes
225 echo '<a href="view.php?id='.$course->id
.'&topic=0#section-'.$section.'" title="'.$strshowalltopics.'">'.
226 '<img src="'.$CFG->pixpath
.'/i/all.gif" alt="'.$strshowalltopics.'" /></a><br />';
228 $strshowonlytopic = get_string('showonlytopic', '', $section);
229 echo '<a href="view.php?id='.$course->id
.'&topic='.$section.'" title="'.$strshowonlytopic.'">'.
230 '<img src="'.$CFG->pixpath
.'/i/one.gif" alt="'.$strshowonlytopic.'" /></a><br />';
233 if (isediting($course->id
) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE
, $course->id
))) {
234 if ($course->marker
== $section) { // Show the "light globe" on/off
235 echo '<a href="view.php?id='.$course->id
.'&marker=0&sesskey='.$USER->sesskey
.'#section-'.$section.'" title="'.$strmarkedthistopic.'">'.
236 '<img src="'.$CFG->pixpath
.'/i/marked.gif" alt="'.$strmarkedthistopic.'" /></a><br />';
238 echo '<a href="view.php?id='.$course->id
.'&marker='.$section.'&sesskey='.$USER->sesskey
.'#section-'.$section.'" title="'.$strmarkthistopic.'">'.
239 '<img src="'.$CFG->pixpath
.'/i/marker.gif" alt="'.$strmarkthistopic.'" /></a><br />';
242 if ($thissection->visible
) { // Show the hide/show eye
243 echo '<a href="view.php?id='.$course->id
.'&hide='.$section.'&sesskey='.$USER->sesskey
.'#section-'.$section.'" title="'.$strtopichide.'">'.
244 '<img src="'.$CFG->pixpath
.'/i/hide.gif" alt="'.$strtopichide.'" /></a><br />';
246 echo '<a href="view.php?id='.$course->id
.'&show='.$section.'&sesskey='.$USER->sesskey
.'#section-'.$section.'" title="'.$strtopicshow.'">'.
247 '<img src="'.$CFG->pixpath
.'/i/show.gif" alt="'.$strtopicshow.'" /></a><br />';
250 if ($section > 1) { // Add a arrow to move section up
251 echo '<a href="view.php?id='.$course->id
.'&random='.rand(1,10000).'&section='.$section.'&move=-1&sesskey='.$USER->sesskey
.'#section-'.($section-1).'" title="'.$strmoveup.'">'.
252 '<img src="'.$CFG->pixpath
.'/t/up.gif" alt="'.$strmoveup.'" /></a><br />';
255 if ($section < $course->numsections
) { // Add a arrow to move section down
256 echo '<a href="view.php?id='.$course->id
.'&random='.rand(1,10000).'&section='.$section.'&move=1&sesskey='.$USER->sesskey
.'#section-'.($section+
1).'" title="'.$strmovedown.'">'.
257 '<img src="'.$CFG->pixpath
.'/t/down.gif" alt="'.$strmovedown.'" /></a><br />';
263 echo '<tr class="section separator"><td colspan="3" class="spacer"></td></tr>';
270 if (!empty($sectionmenu)) {
271 echo '<div align="center" class="jumpmenu">';
272 echo popup_form($CFG->wwwroot
.'/course/view.php?id='.$course->id
.'&', $sectionmenu,
273 'sectionmenu', '', get_string('jumpto'), '', '', true);
277 if (!empty($THEME->customcorners
)) print_custom_corners_end();
283 if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT
) ||
$editing) {
284 echo '<td style="width:'.$preferred_width_right.'px" id="right-column">';
285 if (!empty($THEME->customcorners
)) print_custom_corners_start();
286 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT
);
287 if (!empty($THEME->customcorners
)) print_custom_corners_end();
294 echo '</tr></table>';