Exemplo n.º 1
0
 /**
  * Renders a custom menu object (located in outputcomponents.php)
  *
  * The custom menu this method override the render_custom_menu function
  * in outputrenderers.php
  * @staticvar int $menucount
  * @param custom_menu $menu
  * @return string
  */
 protected function render_custom_menu(custom_menu $menu)
 {
     if (!right_to_left()) {
         // Keep YUI3 navmenu for LTR UI
         parent::render_custom_menu($menu);
     }
     // If the menu has no children return an empty string
     if (!$menu->has_children()) {
         return '';
     }
     // Add a login or logout link
     if (isloggedin()) {
         $branchlabel = get_string('logout');
         $branchurl = new moodle_url('/login/logout.php');
     } else {
         $branchlabel = get_string('login');
         $branchurl = new moodle_url('/login/index.php');
     }
     $branch = $menu->add($branchlabel, $branchurl, $branchlabel, -1);
     // Initialise this custom menu
     $content = html_writer::start_tag('ul', array('class' => 'dropdown dropdown-horizontal'));
     // Render each child
     foreach ($menu->get_children() as $item) {
         $content .= $this->render_custom_menu_item($item);
     }
     // Close the open tags
     $content .= html_writer::end_tag('ul');
     // Return the custom menu
     return $content;
 }
Exemplo n.º 2
0
 protected function render_custom_menu(custom_menu $menu)
 {
     global $CFG;
     require_once $CFG->dirroot . '/course/lib.php';
     //navigation mycourses is no supported since 2.4
     if (isloggedin() && !isguestuser() && ($mycourses = enrol_get_my_courses(NULL, 'visible DESC, fullname ASC'))) {
         $branchlabel = get_string('mycourses');
         $branchurl = new moodle_url('/course/index.php');
         $branchtitle = $branchlabel;
         $branchsort = 8000;
         $branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
         foreach ($mycourses as $mycourse) {
             $branch->add($mycourse->shortname, new moodle_url('/course/view.php', array('id' => $mycourse->id)), $mycourse->fullname);
         }
     }
     $course_id = $this->page->course->id;
     if (isloggedin() && $course_id > 1) {
         $branchlabel = get_string('grades');
         $branchurl = new moodle_url('/grade/report/index.php?id=' . $this->page->course->id);
         $branchtitle = $branchlabel;
         $branchsort = 10000;
         $branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
     }
     return parent::render_custom_menu($menu);
 }
 protected function render_custom_menu(custom_menu $menu)
 {
     global $CFG;
     require_once $CFG->dirroot . '/course/lib.php';
     //navigation mycourses is no supported since 2.4
     if (isloggedin() && !isguestuser() && ($mycourses = enrol_get_my_courses(NULL, 'visible DESC, fullname ASC'))) {
         $branchlabel = get_string('mycourses');
         $branchurl = new moodle_url('/course/index.php');
         $branchtitle = $branchlabel;
         $branchsort = 8000;
         $branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
         foreach ($mycourses as $mycourse) {
             $branch->add($mycourse->shortname, new moodle_url('/course/view.php', array('id' => $mycourse->id)), $mycourse->fullname);
         }
     }
     $course_id = $this->page->course->id;
     if (isloggedin() && $course_id > 1) {
         $branchlabel = get_string('grades');
         $branchurl = new moodle_url('/grade/report/index.php?id=' . $this->page->course->id);
         $branchtitle = $branchlabel;
         $branchsort = 9000;
         $branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
     }
     //From boostrapbase
     // TODO: eliminate this duplicated logic, it belongs in core, not
     // here. See MDL-39565.
     $addlangmenu = true;
     $langs = get_string_manager()->get_list_of_translations();
     if (count($langs) < 2 or empty($CFG->langmenu) or $this->page->course != SITEID and !empty($this->page->course->lang)) {
         $addlangmenu = false;
     }
     if ($addlangmenu) {
         $branchlabel = get_string('language');
         $branchurl = new moodle_url('#');
         $branch = $menu->add($branchlabel, $branchurl, $branchlabel, 10000);
         foreach ($langs as $langtype => $langname) {
             $branch->add($langname, new moodle_url($this->page->url, array('lang' => $langtype)), $langname);
         }
     }
     return parent::render_custom_menu($menu);
 }