/
var
/
www
/
html
/
gte
/
theme
/
lambda
/
renderers
/
Upload File
HOME
<?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Parent theme: Bootstrapbase by Bas Brands * Built on: Essential by Julian Ridden * * @package theme_lambda * @copyright 2018 redPIthemes * */ class theme_lambda_core_renderer extends theme_bootstrapbase_core_renderer { protected function render_custom_menu(custom_menu $menu) { global $CFG; $hasdisplaymycourses = theme_lambda_get_setting('mycourses_dropdown'); if (isloggedin() && !isguestuser() && $hasdisplaymycourses) { $branchlabel = get_string('mycourses') ; $branchurl = new moodle_url(''); $branchtitle = $branchlabel; $branchsort = 10000 ; $branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort); if (!$sortorder = $CFG->navsortmycoursessort) { $sortorder = 'sortorder'; } $courses_limit = $CFG->navcourselimit; if ($mycourses = enrol_get_my_courses(NULL, 'visible DESC, '.$sortorder.' ASC', $courses_limit)) { foreach ($mycourses as $mycourse) { if ($CFG->navshowfullcoursenames) { $current_menu_item = $mycourse->fullname; } else { $current_menu_item = $mycourse->shortname; } $branch->add($current_menu_item, new moodle_url('/course/view.php', array('id' => $mycourse->id)), $mycourse->fullname); } } else { $hometext = get_string('myhome'); $homelabel = $hometext; $branch->add($homelabel, new moodle_url('/my/index.php'), $hometext); } } return parent::render_custom_menu($menu); } public function footer() { global $CFG, $DB, $USER; $output = $this->container_end_all(true); $footer = $this->opencontainers->pop('header/footer'); if (debugging() and $DB and $DB->is_transaction_started()) { } $footer = str_replace($this->unique_end_html_token, $this->page->requires->get_end_code(), $footer); $this->page->set_state(moodle_page::STATE_DONE); if(!empty($this->page->theme->settings->persistentedit) && property_exists($USER, 'editing') && $USER->editing && !$this->really_editing) { $USER->editing = false; } return $output . $footer; } public function footerblocks($region, $classes = array(), $tag = 'aside') { $classes = (array)$classes; $classes[] = 'block-region'; $attributes = array( 'id' => 'block-region-'.preg_replace('#[^a-zA-Z0-9_\-]+#', '-', $region), 'class' => join(' ', $classes), 'data-blockregion' => $region, 'data-droptarget' => '1' ); return html_writer::tag($tag, $this->blocks_for_region($region), $attributes); } public function edit_button(moodle_url $url) { $context = $this->page->context; $menu = new action_menu(); $items = $this->page->navbar->get_items(); $currentnode = end($items); $showcoursemenu = false; // We are on the course home page. if (($context->contextlevel == CONTEXT_COURSE) && !empty($currentnode) && ($currentnode->type == navigation_node::TYPE_COURSE || $currentnode->type == navigation_node::TYPE_SECTION)) { $showcoursemenu = true; } $courseformat = course_get_format($this->page->course); // This is a single activity course format, always show the course menu on the activity main page. if ($context->contextlevel == CONTEXT_MODULE && !$courseformat->has_view_page()) { $this->page->navigation->initialise(); $activenode = $this->page->navigation->find_active_node(); // If the settings menu has been forced then show the menu. if ($this->page->is_settings_menu_forced()) { $showcoursemenu = true; } else if (!empty($activenode) && ($activenode->type == navigation_node::TYPE_ACTIVITY || $activenode->type == navigation_node::TYPE_RESOURCE)) { // We only want to show the menu on the first page of the activity. This means // the breadcrumb has no additional nodes. if ($currentnode && ($currentnode->key == $activenode->key && $currentnode->type == $activenode->type)) { $showcoursemenu = true; } } } if ($showcoursemenu) { $settingsnode = $this->page->settingsnav->find('courseadmin', navigation_node::TYPE_COURSE); if ($settingsnode) { // Build an action menu based on the visible nodes from this navigation tree. $skipped = $this->build_action_menu_from_navigation($menu, $settingsnode, false, true); // We only add a list to the full settings menu if we didn't include every node in the short menu. if ($skipped) { $text = get_string('morenavigationlinks'); $url = new moodle_url('/course/admin.php', array('courseid' => $this->page->course->id)); $link = new action_link($url, $text, null, null, new pix_icon('t/edit', $text)); $menu->add_secondary_action($link); } } } return $this->render($menu); } public function context_header_settings_menu() { $context = $this->page->context; $menu = new action_menu(); $showusermenu = false; $buildmenu = false; $participantsmenu = false; $items = $this->page->navbar->get_items(); $currentnode = end($items); // This is the user profile page. if ($context->contextlevel == CONTEXT_USER && !empty($currentnode) && ($currentnode->key === 'myprofile')) { $showusermenu = true; } if ($showusermenu) { // Get the course admin node from the settings navigation. $settingsnode = $this->page->settingsnav->find('useraccount', navigation_node::TYPE_CONTAINER); if ($settingsnode) { // Build an action menu based on the visible nodes from this navigation tree. $this->build_action_menu_from_navigation($menu, $settingsnode); } } if ($context->contextlevel == CONTEXT_MODULE) { $this->page->navigation->initialise(); $node = $this->page->navigation->find_active_node(); // If the settings menu has been forced then show the menu. if ($this->page->is_settings_menu_forced()) { $buildmenu = true; } else if (!empty($node) && ($node->type == navigation_node::TYPE_ACTIVITY || $node->type == navigation_node::TYPE_RESOURCE)) { $items = $this->page->navbar->get_items(); $navbarnode = end($items); // We only want to show the menu on the first page of the activity. This means // the breadcrumb has no additional nodes. if ($navbarnode && ($navbarnode->key === $node->key && $navbarnode->type == $node->type)) { $buildmenu = true; } } if ($buildmenu) { // Get the course admin node from the settings navigation. $node = $this->page->settingsnav->find('modulesettings', navigation_node::TYPE_SETTING); if ($node) { // Build an action menu based on the visible nodes from this navigation tree. $this->build_action_menu_from_navigation($menu, $node); } } } else if ($context->contextlevel == CONTEXT_COURSECAT) { // For course category context, show category settings menu, if we're on the course category page. if ($this->page->pagetype === 'course-index-category') { $node = $this->page->settingsnav->find('categorysettings', navigation_node::TYPE_CONTAINER); if ($node) { // Build an action menu based on the visible nodes from this navigation tree. $this->build_action_menu_from_navigation($menu, $node); } } } else { $items = $this->page->navbar->get_items(); $navbarnode = end($items); if ($navbarnode && ($navbarnode->key === 'participants')) { $participantsmenu = true; $node = $this->page->settingsnav->find('users', navigation_node::TYPE_CONTAINER); if ($node) { // Build an action menu based on the visible nodes from this navigation tree. $this->build_action_menu_from_navigation($menu, $node); } } } if ((!$menu->is_empty()) && ($showusermenu || $buildmenu || $participantsmenu)) {return $this->render($menu);} } private function build_action_menu_from_navigation(action_menu $menu, navigation_node $node, $indent = false, $onlytopleafnodes = false) { $skipped = false; // Build an action menu based on the visible nodes from this navigation tree. foreach ($node->children as $menuitem) { if ($menuitem->display) { if ($onlytopleafnodes && $menuitem->children->count()) { $skipped = true; continue; } if ($menuitem->action) { if ($menuitem->action instanceof action_link) { $link = $menuitem->action; // Give preference to setting icon over action icon. if (!empty($menuitem->icon)) { $link->icon = $menuitem->icon; } } else { $link = new action_link($menuitem->action, $menuitem->text, null, null, $menuitem->icon); } } else { if ($onlytopleafnodes) { $skipped = true; continue; } $link = new action_link(new moodle_url('#'), $menuitem->text, null, ['disabled' => true], $menuitem->icon); } if ($indent) { $link->add_class('m-l-1'); } if (!empty($menuitem->classes)) { $link->add_class(implode(" ", $menuitem->classes)); } $menu->add_secondary_action($link); $skipped = $skipped || $this->build_action_menu_from_navigation($menu, $menuitem, true); } } return $skipped; } }