adding some strings
[moodle-linuxchix.git] / blocks / site_main_menu / block_site_main_menu.php
blob061ad97e1fe41be7146362100dadf54c8e857467
1 <?php //$Id$
3 class block_site_main_menu extends block_list {
4 function init() {
5 $this->title = get_string('mainmenu');
6 $this->version = 2005061300;
9 function applicable_formats() {
10 return array('site' => true);
13 function get_content() {
14 global $USER, $CFG;
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);
30 $context = get_context_instance(CONTEXT_COURSE, $course->id);
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);
48 if ($ismoving) {
49 $strmovehere = get_string('movehere');
50 $strmovefull = strip_tags(get_string('movefull', '', "'$USER->activitycopyname'"));
51 $strcancel= get_string('cancel');
52 $stractivityclipboard = $USER->activitycopyname;
54 /// Casting $course->modinfo to string prevents one notice when the field is null
55 $modinfo = unserialize((string)$course->modinfo);
57 $editbuttons = '';
59 if ($ismoving) {
60 $this->content->icons[] = '<img src="'.$CFG->pixpath.'/t/move.gif" class="iconsmall" alt="" />';
61 $this->content->items[] = $USER->activitycopyname.'&nbsp;(<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true&amp;sesskey='.$USER->sesskey.'">'.$strcancel.'</a>)';
64 if (!empty($section) && !empty($section->sequence)) {
65 $sectionmods = explode(',', $section->sequence);
66 foreach ($sectionmods as $modnumber) {
67 if (empty($mods[$modnumber])) {
68 continue;
70 $mod = $mods[$modnumber];
71 if ($isediting && !$ismoving) {
72 if ($groupbuttons) {
73 if (! $mod->groupmodelink = $groupbuttonslink) {
74 $mod->groupmode = $course->groupmode;
77 } else {
78 $mod->groupmode = false;
80 $editbuttons = '<div class="buttons">'.make_editing_buttons($mod, true, true).'</div>';
81 } else {
82 $editbuttons = '';
84 if ($mod->visible || has_capability('moodle/course:viewhiddenactivities', $context)) {
85 if ($ismoving) {
86 if ($mod->id == $USER->activitycopy) {
87 continue;
89 $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?moveto='.$mod->id.'&amp;sesskey='.$USER->sesskey.'">'.
90 '<img style="height:16px; width:80px; border:0px" src="'.$CFG->pixpath.'/movehere.gif" alt="'.$strmovehere.'" /></a>';
91 $this->content->icons[] = '';
93 $instancename = urldecode($modinfo[$modnumber]->name);
94 $instancename = format_string($instancename, true, $this->instance->pageid);
95 $linkcss = $mod->visible ? '' : ' class="dimmed" ';
96 if (!empty($modinfo[$modnumber]->extra)) {
97 $extra = urldecode($modinfo[$modnumber]->extra);
98 } else {
99 $extra = '';
101 if (!empty($modinfo[$modnumber]->icon)) {
102 $icon = $CFG->pixpath.'/'.urldecode($modinfo[$modnumber]->icon);
103 } else {
104 $icon = $CFG->modpixpath.'/'.$mod->modname.'/icon.gif';
107 if ($mod->modname == 'label') {
108 $this->content->items[] = format_text($extra, FORMAT_HTML).$editbuttons;
109 $this->content->icons[] = '';
110 } else {
111 $this->content->items[] = '<a title="'.$mod->modfullname.'" '.$linkcss.' '.$extra.
112 ' href="'.$CFG->wwwroot.'/mod/'.$mod->modname.'/view.php?id='.$mod->id.'">'.$instancename.'</a>'.$editbuttons;
113 //Accessibility: incidental image - should be empty Alt text
114 $this->content->icons[] = '<img src="'.$icon.'" class="icon" alt="" />';
120 if ($ismoving) {
121 $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?movetosection='.$section->id.'&amp;sesskey='.$USER->sesskey.'">'.
122 '<img style="height:16px; width:80px; border:0px" src="'.$CFG->pixpath.'/movehere.gif" alt="'.$strmovehere.'" /></a>';
123 $this->content->icons[] = '';
126 if ($isediting && $modnames) {
127 $this->content->footer = print_section_add_menus($course, 0, $modnames, true, true);
128 } else {
129 $this->content->footer = '';
132 return $this->content;