-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathformat.php
372 lines (293 loc) · 14.7 KB
/
format.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
<style type="text/css" media="screen">
/* <![CDATA[ */
@import url(<?php echo $CFG->wwwroot ?>/course/format/grid/grid.css);
/* ]]> */
</style>
<?php // $Id: format.php
require_once(dirname(__FILE__) . '/lib.php'); // for grid course format.
$streditsummary = get_string('editsummary');
$stradd = get_string('add');
$stractivities = get_string('activities');
$strshowallweeks = get_string('showallweeks');
$strweek = get_string('week');
$strgroups = get_string('groups');
$strgroupmy = get_string('groupmy');
$editing = $PAGE->user_is_editing();
if ($editing) {
$strstudents = moodle_strtolower($course->students);
$strweekhide = get_string('weekhide', '', $strstudents);
$strweekshow = get_string('weekshow', '', $strstudents);
$strmoveup = get_string('moveup');
$strmovedown = get_string('movedown');
}
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_js($CFG->wwwroot.'/course/format/grid/jslib.js');
/* Internet Explorer min-width fix. (See theme/standard/styles_layout.css: min-width for Firefox.)
Window width: 800px, Firefox 763px, IE 752px. (Window width: 640px, Firefox 602px, IE 588px.)
*/
?>
<!--[if IE]>
<style type="text/css">
.weekscss-format { width: expression(document.body.clientWidth < 800 ? "752px" : "auto"); }
</style>
<![endif]-->
<?php
/// Layout the whole page as three big columns (was, id="layout-table")
echo '<div class="weekscss-format">';
/// The left column ...
$has_left_col = false;
if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
$has_left_col = true;
echo '<div id="left-column">';
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
echo '</div>';
}
/// The right column, BEFORE the middle-column.
$has_right_col = false;
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing) {
$has_right_col = true;
echo '<div id="right-column">';
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
echo '</div>';
}
/// Start main column
$main_column_class = 'class="';
if(!$has_right_col) {
$main_column_class .= 'no_right_bar ';
}
if(!$has_left_col) {
$main_column_class .= 'no_left_bar ';
}
$main_column_class .= '"';
echo '<div id="middle-column" '. $main_column_class .'>'. skip_main_destination();
print_heading_block($course->fullname . '', '');
$summary_status = get_summary_visibility($course->id);
if($summary_status->show_summary == 1) {
/// Section 0 gets placed at the top.
$section = 0;
$thissection = $sections[$section];
if ($thissection->summary or $thissection->sequence or isediting($course->id)) {
echo '<ul class="weekscss">'."\n";
echo '<li id="section-0" class="section main">';
echo '<div class="right side"> </div>';
echo '<div class="content">';
echo '<div class="summary">';
$summaryformatoptions->noclean = true;
echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
echo '<p><a title="'.$streditsummary.'" '.
' href="editsection.php?id='.$thissection->id.'"><img src="'.$OUTPUT->pix_url('t/edit') . '" '.
' class="icon edit" alt="'.$streditsummary.'" /></a></p>';
}
echo '</div>';
print_section($course, $thissection, $mods, $modnamesused);
if (isediting($course->id)) {
print_section_add_menus($course, $section, $modnames);
echo ' <a title="'.get_string('hide_summary_alt','format_grid').'" href="format/grid/mod_summary.php?sesskey='.sesskey().'&course='.$course->id.'&showsummary=0">'.
'<img src="format/grid/images/into_grid.png" alt="'.get_string('hide_summary_alt','format_grid').'" /> '.get_string('hide_summary','format_grid').' </a>';
}
echo '</div>';
echo '</li>';
echo '</ul>';
}
}
/// Print all of the icons.
echo '<div id="iconContainer">'."\n";
echo '<ul class="icons">'."\n";
$section = 0; //start at 1 to skip the summary block
if($summary_status->show_summary == 1) {
$section = 1; //or include the summary block if it's in the grid display
}
$sectionmenu = array();
while ($section <= $course->numsections) {
if (!empty($sections[$section])) {
$thissection = $sections[$section];
} else {
// Create a new section structure
unset($thissection);
$thissection->course = $course->id;
$thissection->section = $section;
$thissection->summary = 'Course Topic ' . $section ."<br />";
$thissection->visible = 1;
if (!$thissection->id = insert_record('course_sections', $thissection)) {
notify('Error inserting new topic!');
}
$sections[$section] = $thissection;
}
//check if course is visible to user, if so show course
$showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible or !$course->hiddensections);
if ($showsection) {
$new_activity = new_activity($thissection, $course, $mods);
$sectionicon = grid_format_get_icon($course, $thissection->id, $section, $mods);
$strtitle = "";
if($section == 0) {
$strtitle = get_title($thissection);
if($strtitle == ' ' || strlen(trim($strtitle)) == 0) {
$strtitle = "General Information";
}
} else {
$strtitle = get_title($thissection);
}
//Get the module icon
if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
$onclickevent = 'select_topic_edit(event, '.$thissection->section.')';
} else {
$onclickevent = 'select_topic(event, '.$thissection->section.')';
}
echo '<li> <a href="#section-'.$thissection->section.'" class="icon_link" onclick="'. $onclickevent .'"><p class="icon_content">' . $strtitle.'</p>';
if($new_activity) {
echo '<img class="new_activity" src="'.$url = $CFG->wwwroot.'/course/format/grid/images/new_activity.png" />';
}
echo '<div class="image_holder">';
if($sectionicon && $sectionicon->imagepath) {
echo '<img src="'.$url = $CFG->wwwroot . '/pluginfile.php/' . $context->id . '/course/section/' . $thissection->id .
'/' . $sectionicon->imagepath .'"/>';
} else if($section == 0) {
echo '<img src="'.$url = $CFG->wwwroot.'/course/format/grid/info.png">';
}
/*
if($sectionicon->imagepath) {
echo '<img src="'.$url = $CFG->wwwroot . '/pluginfile.php/' . $context->id . '/course/section/' . $thissection->id .
'/' . $sectionicon->imagepath .'"/>';
}
*/
echo "</div></a>";
if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
//echo ' <a title="'.get_string('editimage','format_grid').'" href="format/grid/editimage.php?id='.$sectionicon->id.'">'.
echo ' <a title="'.get_string('editimage','format_grid').'" href="format/grid/editimage.php?sectionid='.$thissection->id.'&contextid='.$context->id.'&userid='.$USER->id.'">'.
'<img src="'.$OUTPUT->pix_url('t/edit').'" alt="'.get_string('editimage','format_grid').'" /> change image</a>';
if($section == 0) {
echo ' <a title="'.get_string('display_summary_alt','format_grid').'" href="format/grid/mod_summary.php?sesskey='.sesskey().'&course='.$course->id.'&showsummary=1">'.
'<img src="format/grid/images/out_of_grid.png" alt="'.get_string('display_summary_alt','format_grid').'" /> '.get_string('display_summary','format_grid').' </a>';
}
}
echo "</li>";
}
$section++;
}
echo '</ul>'."\n";
echo '</div>'."\n";
// Note, an ordered list would confuse - "1" could be the clipboard or summary.
echo '<div id="shadebox">';
echo '<div id="shadebox_overlay" style="display:none;" onclick="toggle_shadebox();"></div>';
//echo '<div id="shadebox_overlay" style="display:none;"></div>';
echo '<div id="shadebox_content">';
echo '<img id="shadebox_close" style="display: none;" src="'.$CFG->wwwroot.'/course/format/grid/close.png" onclick="toggle_shadebox();">';
echo '<ul class="weekscss">'."\n";
/// If currently moving a file then show the current clipboard
if (ismoving($course->id)) {
$stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname)));
$strcancel= get_string('cancel');
echo '<li class="clipboard">';
echo $stractivityclipboard.' (<a href="mod.php?cancelcopy=true&sesskey='.$USER->sesskey.'">'.$strcancel.'</a>)';
echo "</li>\n";
}
if($summary_status->show_summary == 0) {
$section = 0;
$thissection = $sections[$section];
if ($thissection->summary or $thissection->sequence or isediting($course->id)) {
//echo '<ul class="weekscss">'."\n";
echo '<li id="section-0" class="section main grid_section">';
echo '<div class="right side"> </div>';
echo '<div class="content">';
echo '<div class="summary">';
$summaryformatoptions->noclean = true;
echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
echo '<p><a title="'.$streditsummary.'" '.
' href="editsection.php?id='.$thissection->id.'"><img src="'.$OUTPUT->pix_url('t/edit') . '" '.
' class="icon edit" alt="'.$streditsummary.'" /></a></p>';
}
echo '</div>';
print_section($course, $thissection, $mods, $modnamesused);
if (isediting($course->id)) {
print_section_add_menus($course, $section, $modnames);
}
echo '</div>';
echo '</li>';
//echo '</ul>';
}
}
/// Now all the normal modules by topic
/// Everything below uses "section" terminology - each "section" is a topic/module.
$section = 1;
$sectionmenu = array();
while ($section <= $course->numsections) {
//if section doesnt exist create it. Set $thissection to point to it.
if (!empty($sections[$section])) {
$thissection = $sections[$section];
} else {
//Section should have been created in the icons section above. If it's empty then its an error.
unset($thissection);
notify('Error, section ' . $section . ' not found!');
$section++;
continue;
}
$showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible or !$course->hiddensections);
if ($showsection) {
$currenttext = '';
if (!$thissection->visible) {
$sectionstyle = ' hidden';
} else {
$sectionstyle = '';
}
echo '<li id="section-'.$section.'" class="section main'.$sectionstyle.' grid_section" >';
// Note, 'right side' is BEFORE content.
echo '<div class="right side">';
if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
if ($thissection->visible) { // Show the hide/show eye
echo '<a href="view.php?id='.$course->id.'&hide='.$section.'&sesskey='.sesskey().'#section-'.$section.'" title="'.$strweekhide.'">'.
'<img src="'.$OUTPUT->pix_url('i/hide') . '" class="icon hide" alt="'.$strweekhide.'" /></a><br />';
} else {
echo '<a href="view.php?id='.$course->id.'&show='.$section.'&sesskey='.sesskey().'#section-'.$section.'" title="'.$strweekshow.'">'.
'<img src="'.$OUTPUT->pix_url('i/show') . '" class="icon hide" alt="'.$strweekshow.'" /></a><br />';
}
if ($section > 1) { // Add a arrow to move section up
echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=-1&sesskey='.sesskey().'#section-'.($section-1).'" title="'.$strmoveup.'">'.
'<img src="'.$OUTPUT->pix_url('t/up') . '" class="icon up" alt="'.$strmoveup.'" /></a><br />';
}
if ($section < $course->numsections) { // Add a arrow to move section down
echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=1&sesskey='.sesskey().'#section-'.($section+1).'" title="'.$strmovedown.'">'.
'<img src="'.$OUTPUT->pix_url('t/down') . '" class="icon down" alt="'.$strmovedown.'" /></a><br />';
}
}
echo '</div>';
echo '<div class="content">';
if (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible) { //if visible
echo '<div class="summary">';
$summaryformatoptions->noclean = true;
echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id.'">'.
'<img src="'.$OUTPUT->pix_url('t/edit').'" class="icon edit" alt="'.$streditsummary.'" /></a><br /><br />';
}
echo '</div>';
print_section($course, $thissection, $mods, $modnamesused);
if (isediting($course->id)) {
print_section_add_menus($course, $section, $modnames);
}
} else {
$strtitle = get_title($thissection->summary);
echo '<h2>' . $strtitle . '</h2>';
echo '<p> This section has been hidden </p>';
}
echo '</div>';
echo "</li>\n";
}
$section++;
}
echo "</ul>\n";
echo '</div></div>';
if (!empty($sectionmenu)) {
echo '<div class="jumpmenu">';
echo popup_form($CFG->wwwroot.'/course/view.php?id='.$course->id.'&', $sectionmenu,
'sectionmenu', '', get_string('jumpto'), '', '', true);
echo '</div>';
}
echo '</div>';
echo '</div>';
echo '<div class="clearer"></div>';
if (!(isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id)))) {
echo '<script> hide_sections(); </script>';
}
?>