|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 class block_site_main_menu extends block_list { 00004 function init() { 00005 $this->title = get_string('pluginname', 'block_site_main_menu'); 00006 } 00007 00008 function applicable_formats() { 00009 return array('site' => true); 00010 } 00011 00012 function get_content() { 00013 global $USER, $CFG, $DB, $OUTPUT; 00014 00015 if ($this->content !== NULL) { 00016 return $this->content; 00017 } 00018 00019 $this->content = new stdClass(); 00020 $this->content->items = array(); 00021 $this->content->icons = array(); 00022 $this->content->footer = ''; 00023 00024 if (empty($this->instance)) { 00025 return $this->content; 00026 } 00027 00028 $course = $this->page->course; 00029 require_once($CFG->dirroot.'/course/lib.php'); 00030 $context = get_context_instance(CONTEXT_COURSE, $course->id); 00031 $isediting = $this->page->user_is_editing() && has_capability('moodle/course:manageactivities', $context); 00032 $modinfo = get_fast_modinfo($course); 00033 00035 if (!$isediting) { 00036 if (!empty($modinfo->sections[0])) { 00037 $options = array('overflowdiv'=>true); 00038 foreach($modinfo->sections[0] as $cmid) { 00039 $cm = $modinfo->cms[$cmid]; 00040 if (!$cm->uservisible) { 00041 continue; 00042 } 00043 00044 list($content, $instancename) = 00045 get_print_section_cm_text($cm, $course); 00046 00047 if (!($url = $cm->get_url())) { 00048 $this->content->items[] = $content; 00049 $this->content->icons[] = ''; 00050 } else { 00051 $linkcss = $cm->visible ? '' : ' class="dimmed" '; 00052 //Accessibility: incidental image - should be empty Alt text 00053 $icon = '<img src="' . $cm->get_icon_url() . '" class="icon" alt="" /> '; 00054 $this->content->items[] = '<a title="'.$cm->modplural.'" '.$linkcss.' '.$cm->extra. 00055 ' href="' . $url . '">' . $icon . $instancename . '</a>'; 00056 } 00057 } 00058 } 00059 return $this->content; 00060 } 00061 00063 $ismoving = ismoving($course->id); 00064 $section = get_course_section(0, $course->id); 00065 00066 get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused); 00067 00068 $groupbuttons = $course->groupmode; 00069 $groupbuttonslink = (!$course->groupmodeforce); 00070 00071 if ($ismoving) { 00072 $strmovehere = get_string('movehere'); 00073 $strmovefull = strip_tags(get_string('movefull', '', "'$USER->activitycopyname'")); 00074 $strcancel= get_string('cancel'); 00075 $stractivityclipboard = $USER->activitycopyname; 00076 } 00078 $editbuttons = ''; 00079 00080 if ($ismoving) { 00081 $this->content->icons[] = '<img src="'.$OUTPUT->pix_url('t/move') . '" class="iconsmall" alt="" />'; 00082 $this->content->items[] = $USER->activitycopyname.' (<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true&sesskey='.sesskey().'">'.$strcancel.'</a>)'; 00083 } 00084 00085 if (!empty($section->sequence)) { 00086 $sectionmods = explode(',', $section->sequence); 00087 $options = array('overflowdiv'=>true); 00088 foreach ($sectionmods as $modnumber) { 00089 if (empty($mods[$modnumber])) { 00090 continue; 00091 } 00092 $mod = $mods[$modnumber]; 00093 if (!$ismoving) { 00094 if ($groupbuttons) { 00095 if (! $mod->groupmodelink = $groupbuttonslink) { 00096 $mod->groupmode = $course->groupmode; 00097 } 00098 00099 } else { 00100 $mod->groupmode = false; 00101 } 00102 $editbuttons = '<div class="buttons">'.make_editing_buttons($mod, true, true).'</div>'; 00103 } else { 00104 $editbuttons = ''; 00105 } 00106 if ($mod->visible || has_capability('moodle/course:viewhiddenactivities', $context)) { 00107 if ($ismoving) { 00108 if ($mod->id == $USER->activitycopy) { 00109 continue; 00110 } 00111 $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?moveto='.$mod->id.'&sesskey='.sesskey().'">'. 00112 '<img style="height:16px; width:80px; border:0px" src="'.$OUTPUT->pix_url('movehere') . '" alt="'.$strmovehere.'" /></a>'; 00113 $this->content->icons[] = ''; 00114 } 00115 list($content, $instancename) = 00116 get_print_section_cm_text($modinfo->cms[$modnumber], $course); 00117 $linkcss = $mod->visible ? '' : ' class="dimmed" '; 00118 00119 if (!($url = $mod->get_url())) { 00120 $this->content->items[] = $content . $editbuttons; 00121 $this->content->icons[] = ''; 00122 } else { 00123 //Accessibility: incidental image - should be empty Alt text 00124 $icon = '<img src="' . $mod->get_icon_url() . '" class="icon" alt="" /> '; 00125 $this->content->items[] = '<a title="' . $mod->modfullname . '" ' . $linkcss . ' ' . $mod->extra . 00126 ' href="' . $url . '">' . $icon . $instancename . '</a>' . $editbuttons; 00127 } 00128 } 00129 } 00130 } 00131 00132 if ($ismoving) { 00133 $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?movetosection='.$section->id.'&sesskey='.sesskey().'">'. 00134 '<img style="height:16px; width:80px; border:0px" src="'.$OUTPUT->pix_url('movehere') . '" alt="'.$strmovehere.'" /></a>'; 00135 $this->content->icons[] = ''; 00136 } 00137 00138 if (!empty($modnames)) { 00139 $this->content->footer = print_section_add_menus($course, 0, $modnames, true, true); 00140 } else { 00141 $this->content->footer = ''; 00142 } 00143 00144 return $this->content; 00145 } 00146 } 00147 00148