Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Site main menu block. 19 * 20 * @package block_site_main_menu 21 * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 class block_site_main_menu extends block_list { 26 function init() { 27 $this->title = get_string('pluginname', 'block_site_main_menu'); 28 } 29 30 function applicable_formats() { 31 return array('site' => true); 32 } 33 34 function get_content() { 35 global $USER, $CFG, $DB, $OUTPUT; 36 37 if ($this->content !== NULL) { 38 return $this->content; 39 } 40 41 $this->content = new stdClass(); 42 $this->content->items = array(); 43 $this->content->icons = array(); 44 $this->content->footer = ''; 45 46 if (empty($this->instance)) { 47 return $this->content; 48 } 49 50 $course = get_site(); 51 require_once($CFG->dirroot.'/course/lib.php'); 52 $context = context_course::instance($course->id); 53 $isediting = $this->page->user_is_editing() && has_capability('moodle/course:manageactivities', $context); 54 $courserenderer = $this->page->get_renderer('core', 'course'); 55 56 /// extra fast view mode 57 if (!$isediting) { 58 $modinfo = get_fast_modinfo($course); 59 if (!empty($modinfo->sections[0])) { 60 foreach($modinfo->sections[0] as $cmid) { 61 $cm = $modinfo->cms[$cmid]; 62 if (!$cm->uservisible || !$cm->is_visible_on_course_page()) { 63 continue; 64 } 65 66 if ($cm->indent > 0) { 67 $indent = '<div class="mod-indent mod-indent-'.$cm->indent.'"></div>'; 68 } else { 69 $indent = ''; 70 } 71 72 if (!empty($cm->url)) { 73 $content = html_writer::div($courserenderer->course_section_cm_name($cm), 'activity'); 74 } else { 75 $content = $courserenderer->course_section_cm_text($cm); 76 } 77 78 $this->content->items[] = $indent . html_writer::div($content, 'main-menu-content'); 79 } 80 } 81 return $this->content; 82 } 83 84 // Slow & hacky editing mode. 85 $ismoving = ismoving($course->id); 86 course_create_sections_if_missing($course, 0); 87 $modinfo = get_fast_modinfo($course); 88 $section = $modinfo->get_section_info(0); 89 90 if ($ismoving) { 91 $strmovefull = strip_tags(get_string('movefull', '', "'$USER->activitycopyname'")); 92 $strcancel= get_string('cancel'); 93 } else { 94 $strmove = get_string('move'); 95 } 96 97 if ($ismoving) { 98 $this->content->icons[] = $OUTPUT->pix_icon('t/move', get_string('move')); 99 $this->content->items[] = $USER->activitycopyname.' (<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true&sesskey='.sesskey().'">'.$strcancel.'</a>)'; 100 } 101 102 if (!empty($modinfo->sections[0])) { 103 foreach ($modinfo->sections[0] as $modnumber) { 104 $mod = $modinfo->cms[$modnumber]; 105 if (!$mod->uservisible || !$mod->is_visible_on_course_page()) { 106 continue; 107 } 108 if (!$ismoving) { 109 $actions = course_get_cm_edit_actions($mod, $mod->indent); 110 111 // Prepend list of actions with the 'move' action. 112 $actions = array('move' => new action_menu_link_primary( 113 new moodle_url('/course/mod.php', array('sesskey' => sesskey(), 'copy' => $mod->id)), 114 new pix_icon('t/move', $strmove, 'moodle', array('class' => 'iconsmall', 'title' => '')), 115 $strmove 116 )) + $actions; 117 118 $editbuttons = html_writer::tag('div', 119 $courserenderer->course_section_cm_edit_actions($actions, $mod, array('donotenhance' => true)), 120 array('class' => 'buttons') 121 ); 122 } else { 123 $editbuttons = ''; 124 } 125 if ($mod->visible || has_capability('moodle/course:viewhiddenactivities', $mod->context)) { 126 if ($ismoving) { 127 if ($mod->id == $USER->activitycopy) { 128 continue; 129 } 130 $movingurl = new moodle_url('/course/mod.php', array('moveto' => $mod->id, 'sesskey' => sesskey())); 131 $this->content->items[] = html_writer::link($movingurl, '', array('title' => $strmovefull, 132 'class' => 'movehere')); 133 $this->content->icons[] = ''; 134 } 135 if ($mod->indent > 0) { 136 $indent = '<div class="mod-indent mod-indent-'.$mod->indent.'"></div>'; 137 } else { 138 $indent = ''; 139 } 140 if (!$mod->url) { 141 $content = $courserenderer->course_section_cm_text($mod); 142 } else { 143 $content = html_writer::div($courserenderer->course_section_cm_name($mod), ' activity'); 144 } 145 $this->content->items[] = $indent . html_writer::div($content . $editbuttons, 'main-menu-content'); 146 } 147 } 148 } 149 150 if ($ismoving) { 151 $movingurl = new moodle_url('/course/mod.php', array('movetosection' => $section->id, 'sesskey' => sesskey())); 152 $this->content->items[] = html_writer::link($movingurl, '', array('title' => $strmovefull, 'class' => 'movehere')); 153 $this->content->icons[] = ''; 154 } 155 156 if ($this->page->course->id === SITEID) { 157 $this->content->footer = $courserenderer->course_section_add_cm_control($course, 158 0, null, array('inblock' => true)); 159 } 160 return $this->content; 161 } 162 } 163 164
title
Description
Body
title
Description
Body
title
Description
Body
title
Body