3 class block_site_main_menu
extends block_list
{
5 $this->title
= get_string('mainmenu');
6 $this->version
= 2005061300;
9 function applicable_formats() {
10 return array('site' => true);
13 function get_content() {
16 if ($this->content
!== NULL) {
17 return $this->content
;
20 $this->content
= new stdClass
;
21 $this->content
->items
= array();
22 $this->content
->icons
= array();
23 $this->content
->footer
= '';
25 if (empty($this->instance
)) {
26 return $this->content
;
29 $course = get_record('course', 'id', $this->instance
->pageid
);
31 $isteacher = isteacher($this->instance
->pageid
);
32 $isediting = isediting($this->instance
->pageid
);
33 $ismoving = ismoving($this->instance
->pageid
);
35 $sections = get_all_sections($this->instance
->pageid
);
37 if(!empty($sections) && isset($sections[0])) {
38 $section = $sections[0];
41 if (!empty($section) ||
$isediting) {
42 get_all_mods($this->instance
->pageid
, $mods, $modnames, $modnamesplural, $modnamesused);
45 $groupbuttons = $course->groupmode
;
46 $groupbuttonslink = (!$course->groupmodeforce
);
49 $strmovehere = get_string('movehere');
50 $strmovefull = strip_tags(get_string('movefull', '', "'$USER->activitycopyname'"));
51 $strcancel= get_string('cancel');
52 $stractivityclipboard = $USER->activitycopyname
;
55 $modinfo = unserialize($course->modinfo
);
59 $this->content
->icons
[] = ' <img align="bottom" src="'.$CFG->pixpath
.'/t/move.gif" height="11" width="11" alt="" />';
60 $this->content
->items
[] = $USER->activitycopyname
.' (<a href="'.$CFG->wwwroot
.'/course/mod.php?cancelcopy=true&sesskey='.$USER->sesskey
.'">'.$strcancel.'</a>)';
63 if (!empty($section) && !empty($section->sequence
)) {
64 $sectionmods = explode(',', $section->sequence
);
65 foreach ($sectionmods as $modnumber) {
66 if (empty($mods[$modnumber])) {
69 $mod = $mods[$modnumber];
70 if ($isediting && !$ismoving) {
72 if (! $mod->groupmodelink
= $groupbuttonslink) {
73 $mod->groupmode
= $course->groupmode
;
77 $mod->groupmode
= false;
79 $editbuttons = '<br />'.make_editing_buttons($mod, true, true);
83 if ($mod->visible ||
$isteacher) {
85 if ($mod->id
== $USER->activitycopy
) {
88 $this->content
->items
[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot
.'/course/mod.php?moveto='.$mod->id
.'&sesskey='.$USER->sesskey
.'">'.
89 '<img height="16" width="80" src="'.$CFG->pixpath
.'/movehere.gif" alt="'.$strmovehere.'" border="0" /></a>';
90 $this->content
->icons
[] = '';
92 $instancename = urldecode($modinfo[$modnumber]->name
);
93 $instancename = format_string($instancename, true, $this->instance
->pageid
);
94 $linkcss = $mod->visible ?
'' : ' class="dimmed" ';
95 if (!empty($modinfo[$modnumber]->extra
)) {
96 $extra = urldecode($modinfo[$modnumber]->extra
);
100 if (!empty($modinfo[$modnumber]->icon
)) {
101 $icon = $CFG->pixpath
.'/'.urldecode($modinfo[$modnumber]->icon
);
103 $icon = $CFG->modpixpath
.'/'.$mod->modname
.'/icon.gif';
106 if ($mod->modname
== 'label') {
107 $this->content
->items
[] = format_text($extra, FORMAT_HTML
).$editbuttons;
108 $this->content
->icons
[] = '';
110 $this->content
->items
[] = '<a title="'.$mod->modfullname
.'" '.$linkcss.' '.$extra.
111 ' href="'.$CFG->wwwroot
.'/mod/'.$mod->modname
.'/view.php?id='.$mod->id
.'">'.$instancename.'</a>'.$editbuttons;
112 $this->content
->icons
[] = '<img src="'.$icon.'" height="16" width="16" alt="'.$mod->modfullname
.'" />';
119 $this->content
->items
[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot
.'/course/mod.php?movetosection='.$section->id
.'&sesskey='.$USER->sesskey
.'">'.
120 '<img height="16" width="80" src="'.$CFG->pixpath
.'/movehere.gif" alt="'.$strmovehere.'" border="0" /></a>';
121 $this->content
->icons
[] = '';
124 if ($isediting && $modnames) {
125 $this->content
->footer
= print_section_add_menus($course, 0, $modnames, true, true);
127 $this->content
->footer
= '';
130 return $this->content
;