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