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