Tidied up logs HTML a bit, to make it more readable.
[moodle-linuxchix.git] / blocks / site_main_menu / block_site_main_menu.php
blob9df47dfe9b8ea02050eec83a2cc3950777c6769d
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);
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);
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;
55 $modinfo = unserialize($course->modinfo);
56 $editbuttons = '';
58 if ($ismoving) {
59 $this->content->icons[] = '&nbsp;<img align="bottom" src="'.$CFG->pixpath.'/t/move.gif" height="11" width="11" alt="" />';
60 $this->content->items[] = $USER->activitycopyname.'&nbsp;(<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true&amp;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])) {
67 continue;
69 $mod = $mods[$modnumber];
70 if ($isediting && !$ismoving) {
71 if ($groupbuttons) {
72 if (! $mod->groupmodelink = $groupbuttonslink) {
73 $mod->groupmode = $course->groupmode;
76 } else {
77 $mod->groupmode = false;
79 $editbuttons = '<br />'.make_editing_buttons($mod, true, true);
80 } else {
81 $editbuttons = '';
83 if ($mod->visible || $isteacher) {
84 if ($ismoving) {
85 if ($mod->id == $USER->activitycopy) {
86 continue;
88 $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?moveto='.$mod->id.'&amp;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);
97 } else {
98 $extra = '';
100 if (!empty($modinfo[$modnumber]->icon)) {
101 $icon = $CFG->pixpath.'/'.urldecode($modinfo[$modnumber]->icon);
102 } else {
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[] = '';
109 } else {
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.'" />';
118 if ($ismoving) {
119 $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?movetosection='.$section->id.'&amp;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);
126 } else {
127 $this->content->footer = '';
130 return $this->content;