Changes for XHTML and accessibility compliance
[moodle.git] / blocks / site_main_menu / block_site_main_menu.php
CommitLineData
89adb174 1<?php //$Id$
2
3class CourseBlock_site_main_menu extends MoodleBlock {
4 function CourseBlock_site_main_menu ($course) {
5 $this->title = get_string('mainmenu');
6 $this->content_type = BLOCK_TYPE_LIST;
7 $this->course = $course;
8 $this->version = 2004052700;
9 }
10
11 function applicable_formats() {
2b0d60ec 12 return array('site' => true);
89adb174 13 }
14
15 function get_content() {
16 global $USER, $CFG;
17
2eb68e6f 18 if ($this->content !== NULL) {
89adb174 19 return $this->content;
20 }
21
2eb68e6f 22 if (empty($this->course)) {
23 return '';
24 }
25
89adb174 26 $this->content = New stdClass;
27 $this->content->items = array();
28 $this->content->icons = array();
29 $this->content->footer = '';
30
31 $isteacher = isteacher($this->course->id);
32 $isediting = isediting($this->course->id);
33 $ismoving = ismoving($this->course->id);
34
35 $sections = get_all_sections($this->course->id);
36 $section = $sections[0];
37
38 if($section->sequence || $isediting) {
39 get_all_mods($this->course->id, $mods, $modnames, $modnamesplural, $modnamesused);
40 }
41
42 $groupbuttons = $this->course->groupmode;
43 $groupbuttonslink = (!$this->course->groupmodeforce);
44
45 if ($ismoving) {
46 $strmovehere = get_string('movehere');
47 $strmovefull = strip_tags(get_string('movefull', '', "'$USER->activitycopyname'"));
48 $strcancel= get_string('cancel');
49 $stractivityclipboard = $USER->activitycopyname;
50 }
51
52 $modinfo = unserialize($this->course->modinfo);
53 $editbuttons = '';
54
55 if ($ismoving) {
839f2456 56 $this->content->icons[] = '&nbsp;<img align="bottom" src="'.$CFG->pixpath.'/t/move.gif" height="11" width="11" alt="" />';
8b92f5bb 57 $this->content->items[] = $USER->activitycopyname.'&nbsp;(<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true&amp;sesskey='.$USER->sesskey.'">'.$strcancel.'</a>)';
89adb174 58 }
59
60 if (!empty($section->sequence)) {
61 $sectionmods = explode(',', $section->sequence);
62 foreach ($sectionmods as $modnumber) {
63 if (empty($mods[$modnumber])) {
64 continue;
65 }
66 $mod = $mods[$modnumber];
67 if ($isediting && !$ismoving) {
68 if ($groupbuttons) {
69 if (! $mod->groupmodelink = $groupbuttonslink) {
70 $mod->groupmode = $this->course->groupmode;
71 }
72
73 } else {
74 $mod->groupmode = false;
75 }
76 $editbuttons = '<br />'.make_editing_buttons($mod, true, true);
77 } else {
78 $editbuttons = '';
79 }
80 if ($mod->visible || $isteacher) {
81 if ($ismoving) {
82 if ($mod->id == $USER->activitycopy) {
83 continue;
84 }
8b92f5bb 85 $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?moveto='.$mod->id.'&amp;sesskey='.$USER->sesskey.'">'.
98ea2a6e 86 '<img height="16" width="80" src="'.$CFG->pixpath.'/movehere.gif" alt="'.$strmovehere.'" border="0" /></a>';
89adb174 87 $this->content->icons[] = '';
88 }
89 $instancename = urldecode($modinfo[$modnumber]->name);
90 if (!empty($CFG->filterall)) {
91 $instancename = filter_text('<nolink>'.$instancename.'</nolink>', $this->course->id);
92 }
93 $linkcss = $mod->visible ? '' : ' class="dimmed" ';
94 if (!empty($modinfo[$modnumber]->extra)) {
95 $extra = urldecode($modinfo[$modnumber]->extra);
96 } else {
97 $extra = '';
98 }
facf75c1 99 if (!empty($modinfo[$modnumber]->icon)) {
100 $icon = $CFG->pixpath.'/'.urldecode($modinfo[$modnumber]->icon);
101 } else {
102 $icon = $CFG->modpixpath.'/'.$mod->modname.'/icon.gif';
103 }
89adb174 104
105 if ($mod->modname == 'label') {
106 $this->content->items[] = format_text($extra, FORMAT_HTML).$editbuttons;
107 $this->content->icons[] = '';
108 } else {
109 $this->content->items[] = '<a title="'.$mod->modfullname.'" '.$linkcss.' '.$extra.
110 ' href="'.$CFG->wwwroot.'/mod/'.$mod->modname.'/view.php?id='.$mod->id.'">'.$instancename.'</a>'.$editbuttons;
98ea2a6e 111 $this->content->icons[] = '<img src="'.$icon.'" height="16" width="16" alt="'.$mod->modfullname.'" />';
89adb174 112 }
113 }
114 }
115 }
116
117 if ($ismoving) {
8b92f5bb 118 $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?movetosection='.$section->id.'&amp;sesskey='.$USER->sesskey.'">'.
98ea2a6e 119 '<img height="16" width="80" src="'.$CFG->pixpath.'/movehere.gif" alt="'.$strmovehere.'" border="0" /></a>';
89adb174 120 $this->content->icons[] = '';
121 }
122
123 if ($isediting && $modnames) {
124 $this->content->footer = '<div style="text-align: right;">'.
cb57e6f4 125 print_section_add_menus($this->course, 0, $modnames, true, true).'</div>';
89adb174 126 } else {
127 $this->content->footer = '';
128 }
129
130 return $this->content;
131 }
132}
133
134?>