本文整理汇总了PHP中custom_menu::has_children方法的典型用法代码示例。如果您正苦于以下问题:PHP custom_menu::has_children方法的具体用法?PHP custom_menu::has_children怎么用?PHP custom_menu::has_children使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类custom_menu
的用法示例。
在下文中一共展示了custom_menu::has_children方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_custom_menu
/**
* 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 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;
}
示例2: render_custom_menu
protected function render_custom_menu(custom_menu $menu)
{
global $CFG;
// 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 (!$menu->has_children() && $addlangmenu === false) {
return '';
}
if ($addlangmenu) {
$strlang = get_string('language');
$currentlang = current_language();
if (isset($langs[$currentlang])) {
$currentlang = $langs[$currentlang];
} else {
$currentlang = $strlang;
}
$this->language = $menu->add($currentlang, new moodle_url('#'), $strlang, 10000);
foreach ($langs as $langtype => $langname) {
$this->language->add($langname, new moodle_url($this->page->url, array('lang' => $langtype)), $langname);
}
}
$content = '<ul class="nav">';
foreach ($menu->get_children() as $item) {
$content .= $this->render_custom_menu_item($item, 1);
}
return $content . '</ul>';
}
示例3: render_custom_menu
protected function render_custom_menu(custom_menu $menu)
{
$langs = get_string_manager()->get_list_of_translations();
$haslangmenu = $this->lang_menu() != '';
if (!$menu->has_children() && !$haslangmenu) {
return '';
}
if ($haslangmenu) {
$strlang = get_string('language');
$currentlang = current_language();
if (isset($langs[$currentlang])) {
$currentlang = $langs[$currentlang];
} else {
$currentlang = $strlang;
}
$this->language = $menu->add($currentlang, new moodle_url('#'), $strlang, 10000);
foreach ($langs as $langtype => $langname) {
$this->language->add($langname, new moodle_url($this->page->url, array('lang' => $langtype)), $langname);
}
}
$children = $menu->get_children();
if (count($children) == 0) {
return false;
}
$content = '';
foreach ($menu->get_children() as $item) {
$content .= $this->render_custom_menu_item($item, 1);
}
return $content;
}
示例4: render_custom_menu
/**
* 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 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'));
// Insert "Home" icon link into menu
$content .= html_writer::start_tag('li', array('class' => 'first'));
$content .= html_writer::tag('a', html_writer::empty_tag('img', array('src' => $this->pix_url('home_icon', 'theme'), 'alt' => 'Home')), array('href' => '/'));
$content .= html_writer::end_tag('li');
// Render each child from theme settings custom menu
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;
}
示例5: render_custom_menu
/**
* 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)
{
// Generate custom My Courses dropdown.
$mycourses = $this->page->navigation->get('mycourses');
$mycoursetitle = $this->page->theme->settings->mycoursetitle;
if (isloggedin() && $mycourses && $mycourses->has_children()) {
$branchurl = new moodle_url('/my/index.php');
$branchsort = 10000;
if ($mycoursetitle == 'module') {
$branchlabel = get_string('mymodules', 'theme_rocket');
} else {
if ($mycoursetitle == 'unit') {
$branchlabel = get_string('myunits', 'theme_rocket');
} else {
if ($mycoursetitle == 'class') {
$branchlabel = get_string('myclasses', 'theme_rocket');
} else {
$branchlabel = get_string('mycourses', 'theme_rocket');
}
}
}
$branchtitle = $branchlabel;
$branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
foreach ($mycourses->children as $coursenode) {
$branch->add($coursenode->get_content(), $coursenode->action, $coursenode->get_title());
}
} else {
if ($mycoursetitle == 'module') {
$branchlabel = get_string('allmodules', 'theme_rocket');
} else {
if ($mycoursetitle == 'unit') {
$branchlabel = get_string('allunits', 'theme_rocket');
} else {
if ($mycoursetitle == 'class') {
$branchlabel = get_string('allclasses', 'theme_rocket');
} else {
$branchlabel = get_string('allcourses', 'theme_rocket');
}
}
}
$branchtitle = $branchlabel;
$branchurl = new moodle_url('/course/index.php');
$branchsort = 10000;
$branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
}
// If the menu has no children return an empty string.
if (!$menu->has_children()) {
return '';
}
// 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;
}
示例6: render_custom_menu
/**
* 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 the menu has no children return an empty string
if (!$menu->has_children()) {
return '';
}
// 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;
}
示例7: render_custom_menu
protected function render_custom_menu(custom_menu $menu)
{
global $CFG;
require_once $CFG->dirroot . '/course/lib.php';
// 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 (!$menu->has_children() && $addlangmenu === false) {
return '';
}
if ($addlangmenu) {
$strlang = get_string('language');
$currentlang = current_language();
if (isset($langs[$currentlang])) {
$currentlang = $langs[$currentlang];
} else {
$currentlang = $strlang;
}
$this->language = $menu->add($currentlang, new moodle_url('#'), $strlang, 10000);
foreach ($langs as $langtype => $langname) {
$this->language->add($langname, new moodle_url($this->page->url, array('lang' => $langtype)), $langname);
}
}
// 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);
//
// Add My Courses to the menu form http://docs.moodle.org/dev/Adding_courses_and_categories_to_the_custom_menu
if (isloggedin() && !isguestuser() && ($mycourses = enrol_get_my_courses(NULL, 'visible DESC, fullname ASC'))) {
//which does work
$branchlabel = get_string('mycourses');
$branchurl = new moodle_url('/course/index.php');
$branchtitle = $branchlabel;
$branchsort = 8000;
// lower numbers = higher priority e.g. move this item to the left on the Custom Menu
$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);
}
}
//****************************https://moodle.org/mod/forum/discuss.php?d=219352***************************************
//global $CFG;
//require_once($CFG->dirroot.'/course/lib.php');
//
//$branch = $menu->add(get_string('courses', 'theme_warwickclean'), null, null, 1);
//
//$categorytree = get_course_category_tree();
//foreach ($categorytree as $category) {
//$this->add_category_to_custommenu($branch, $category);
//}
//
//$this->render_mycourses_custom_menu($menu, 0.5) ;
//return parent::render_custom_menu($menu);
//}
//
//protected function add_category_to_custommenu(custom_menu_item $parent, stdClass $category) {
//$branch = $parent->add($category->name, new moodle_url('/course/category.php', array('id' => $category->id)));
//if (!empty($category->categories)) {
//foreach ($category->categories as $subcategory) {
//$this->add_category_to_custommenu($branch, $subcategory);
//}
//}
//if (!empty($category->courses)) {
//foreach ($category->courses as $course) {
//$branch->add($course->shortname, new moodle_url('/course/view.php', array('id' => $course->id)), $course->fullname);
//}
//}
//}
//
//protected function render_mycourses_custom_menu(custom_menu_item $menu, $position) { //this function adds the mycourses branch to the navbar.
//
//
//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;
//$branch = $menu->add($branchlabel, $branchurl, $branchtitle);
//
//foreach ($mycourses as $mycourse) {
//$branch->add($mycourse->shortname, new moodle_url('/course/view.php', array('id' => $mycourse->id)), $mycourse->fullname);
//}
//}
//
//*******************************************************************
// Add a custom link to top navigation
$branchlabel = "Navigation";
$branchurl = new moodle_url('/courses.php');
$branch = $menu->add($branchlabel, $branchurl);
$branch->add("Nothing Here Yet", new moodle_url('/'), "Nothing Here Yet");
//.........这里部分代码省略.........
示例8: test_multilang_support
public function test_multilang_support()
{
$definition = <<<EOF
Start|http://school.info
Info
-English|http://school.info/en|Information in English|en
-Deutsch|http://school.info/de|Informationen in deutscher Sprache|de,de_du,de_kids
EOF;
// the menu without multilang support
$menu = new custom_menu($definition);
$this->assertTrue($menu->has_children());
$this->assertEqual(2, count($menu->get_children()));
$children = $menu->get_children();
$infomenu = array_pop($children);
$this->assertTrue($infomenu->has_children());
$children = $infomenu->get_children();
$this->assertEqual(2, count($children));
$children = $infomenu->get_children();
$langspecinfo = array_shift($children);
$this->assertEqual('Information in English', $langspecinfo->get_title());
// same menu for English language selected
$menu = new custom_menu($definition, 'en');
$this->assertTrue($menu->has_children());
$this->assertEqual(2, count($menu->get_children()));
$children = $menu->get_children();
$infomenu = array_pop($children);
$this->assertTrue($infomenu->has_children());
$this->assertEqual(1, count($infomenu->get_children()));
$children = $infomenu->get_children();
$langspecinfo = array_shift($children);
$this->assertEqual('Information in English', $langspecinfo->get_title());
// same menu for German (de_du) language selected
$menu = new custom_menu($definition, 'de_du');
$this->assertTrue($menu->has_children());
$this->assertEqual(2, count($menu->get_children()));
$children = $menu->get_children();
$infomenu = array_pop($children);
$this->assertTrue($infomenu->has_children());
$this->assertEqual(1, count($infomenu->get_children()));
$children = $infomenu->get_children();
$langspecinfo = array_shift($children);
$this->assertEqual('Informationen in deutscher Sprache', $langspecinfo->get_title());
// same menu for Czech language selected
$menu = new custom_menu($definition, 'cs');
$this->assertTrue($menu->has_children());
$this->assertEqual(2, count($menu->get_children()));
$children = $infomenu->get_children();
$infomenu = array_pop($children);
$this->assertFalse($infomenu->has_children());
}
示例9: render_custom_menu
/**
* Renders a custom menu object (located in outputcomponents.php)
*
* The custom menu this method produces makes use of the YUI3 menunav widget
* and requires very specific html elements and classes.
*
* @staticvar int $menucount
* @param custom_menu $menu
* @return string
*/
protected function render_custom_menu(custom_menu $menu) {
static $menucount = 0;
// If the menu has no children return an empty string
if (!$menu->has_children()) {
return '';
}
// Increment the menu count. This is used for ID's that get worked with
// in JavaScript as is essential
$menucount++;
// Initialise this custom menu (the custom menu object is contained in javascript-static
$jscode = js_writer::function_call_with_Y('M.core_custom_menu.init', array('custom_menu_'.$menucount));
$jscode = "(function(){{$jscode}})";
$this->page->requires->yui_module('node-menunav', $jscode);
// Build the root nodes as required by YUI
$content = html_writer::start_tag('div', array('id'=>'custom_menu_'.$menucount, 'class'=>'yui3-menu yui3-menu-horizontal javascript-disabled custom-menu'));
$content .= html_writer::start_tag('div', array('class'=>'yui3-menu-content'));
$content .= html_writer::start_tag('ul');
// 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');
$content .= html_writer::end_tag('div');
$content .= html_writer::end_tag('div');
// Return the custom menu
return $content;
}
示例10: render_custom_menu
/**
* Renders custom menu as a simple list.
* Any nesting gets flattened.
*
* @return string
*/
protected function render_custom_menu(\custom_menu $menu)
{
if (!$menu->has_children()) {
return '';
}
$content = '';
foreach ($menu->get_children() as $item) {
$content .= $this->render_custom_menu_item($item);
}
$class = 'list-unstyled';
$count = substr_count($content, '<li>');
if ($count > 11) {
$class .= ' list-large';
}
$content = html_writer::tag('ul', $content, array('class' => $class));
return $content;
}
示例11: render_custom_menu
protected function render_custom_menu(custom_menu $menu)
{
global $CFG;
// 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 (!$menu->has_children() && $addlangmenu === false) {
return '';
}
$content = '<ul class="nav">';
foreach ($menu->get_children() as $item) {
$content .= $this->render_custom_menu_item($item, 1);
}
return $content . '</ul>';
}
示例12: render_custom_menu
protected function render_custom_menu(custom_menu $menu) {
global $CFG,$USER;
// 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 (!$menu->has_children() && $addlangmenu === false) {
return '';
}
if ($addlangmenu) {
$language = $menu->add(get_string('language'), new moodle_url('#'), get_string('language'), 10000);
foreach ($langs as $langtype => $langname) {
$language->add($langname, new moodle_url($this->page->url, array('lang' => $langtype)), $langname);
}
}
$content = '<ul class="nav">';
foreach ($menu->get_children() as $item) {
$content .= $this->render_custom_menu_item($item, 1);
}
return $content;
// ."<li class='dropdown open'><span id='quicklinks'><img src= $CFG->wwwroot/theme/co/pix/quicklinks.png /></span></li></ul>";
}
示例13: render_custom_menu
protected function render_custom_menu(custom_menu $menu)
{
global $CFG;
require_once $CFG->dirroot . '/course/lib.php';
// 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 (!$menu->has_children() && $addlangmenu === false) {
return '';
}
if ($addlangmenu) {
$strlang = get_string('language');
$currentlang = current_language();
if (isset($langs[$currentlang])) {
$currentlang = $langs[$currentlang];
} else {
$currentlang = $strlang;
}
$this->language = $menu->add($currentlang, new moodle_url('#'), $strlang, 10000);
foreach ($langs as $langtype => $langname) {
$this->language->add($langname, new moodle_url($this->page->url, array('lang' => $langtype)), $langname);
}
}
// 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);
//
// Add My Courses to the menu form http://docs.moodle.org/dev/Adding_courses_and_categories_to_the_custom_menu
if (isloggedin() && !isguestuser() && ($mycourses = enrol_get_my_courses(NULL, 'visible DESC, fullname ASC'))) {
//which does work
$branchlabel = "My Moodle";
$branchurl = new moodle_url('/my');
$branchtitle = $branchlabel;
$branchsort = 1000;
// lower numbers = higher priority e.g. move this item to the left on the Custom Menu
$branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
$branch->add('Overview', new moodle_url('/my'));
foreach ($mycourses as $mycourse) {
$branch->add($mycourse->shortname, new moodle_url('/course/view.php', array('id' => $mycourse->id)), $mycourse->fullname);
}
}
// Add a custom link to top navigation
$branchlabel = "Categories";
$branchurl = new moodle_url('/course');
$branchtitle = "categories";
$branchsort = 2000;
$branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
$branch->add('All Categories', new moodle_url('/course'));
$branch->add('Arts', new moodle_url('/course/index.php?categoryid=3'));
$branch->add('Medicine', new moodle_url('/course/index.php?categoryid=31'));
$branch->add('Science', new moodle_url('/course/index.php?categoryid=50'));
$branch->add('Social Sciences', new moodle_url('/course/index.php?categoryid=60'));
$branch->add('Interdisciplinary/Cross-Faculty', new moodle_url('/course/index.php?categoryid=28'));
$branch->add('Services', new moodle_url('/course/index.php?categoryid=56'));
$branch->add('Sandbox', new moodle_url('/course/index.php?categoryid=51'));
// Add a custom link to top navigation
$branchlabel = "Help";
$branchurl = new moodle_url('/');
$branchtitle = "help";
$branchsort = 3000;
$branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
$branch->add("Medical School Help Pages", new moodle_url('http://www2.warwick.ac.uk/fac/med/study/cpd/current/moodle'), "medschool_help_cat_nav");
//$branch->add("Physics Help Pages", new moodle_url('http://www2.warwick.ac.uk/fac/sci/physics/current/teach/module_pages/moodle'),"physics_help_cat_nav");
$branch->add("Life Sciences Help Pages", new moodle_url('http://www2.warwick.ac.uk/fac/sci/lifesci/intranet/staffpg/moodle'), "life_sciences_help_cat_nav");
$branch->add("Moodle Support Pages", new moodle_url('http://www2.warwick.ac.uk/services/its/servicessupport/academictechnology/our-services/moodle/support-for-moodle/helpcontacts/'), "moodle_help_nav");
// Add a custom link to top navigation
//$branchlabel = '<i class="fa fa-link fa-lg"></i>';
$branchlabel = "Links";
$branchurl = new moodle_url('/');
$branchtitle = "links";
$branchsort = 5000;
$branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
$branch->add("Email", new moodle_url('http://go.warwick.ac.uk/mymail/'), "insite_link");
$branch->add("Insite", new moodle_url('http://www2.warwick.ac.uk/insite/'), "insite_link");
$branch->add("Mahara", new moodle_url('http://mahara.warwick.ac.uk/'), "mahara)link");
$branch->add("Start.Warwick", new moodle_url('/'), "start_warwick_link");
$branch->add("Tabula", new moodle_url('https://tabula.warwick.ac.uk/'), "tabula_link");
// Add a custom link to top navigation
// $branchlabel = '<i class="fa fa-cog fa-lg"></i>';
// $branchurl = new moodle_url('/course/');
// $branchtitle = "settings";
// $branchsort = 6000;
//
// $branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
// $branch->add('<i class="icon-user"></i>'.get_string('profile').' ',new moodle_url('/user/profile.php'),get_string('profile'));
// $branch->add('<i class="fa fa-user"></i>'." View Profile", new moodle_url('/user/profile.php/'),"view_profile_link");
// $branch->add('<i class="fa fa-pencil-square-o"></i>'." Edit Profile", new moodle_url('/user/edit.php'),"edit_profile_link");
// $branch->add('<i class="fa fa-comments"></i>'." View My Forum Posts", new moodle_url('/mod/forum/user.php/'),"forumposts_link");
// $branch->add('<i class="fa fa-envelope"></i>'." View My Messages", new moodle_url('/message/index.php'),"view_messages_link");
// $branch->add('<i class="fa fa-bullhorn"></i>'." Notification Settings", new moodle_url('/message/edit.php'),"notification_settings_link");;
//.........这里部分代码省略.........
示例14: render_custom_menu
/**
* Renders a custom menu object (located in outputcomponents.php)
*
* The custom menu this method produces makes use of the foundation
* top-bar element and requires specific markup and classes
*
* @staticvar int $menucount
* @param custom_menu $menu
* @return string
*/
protected function render_custom_menu(custom_menu $menu)
{
global $CFG, $OUTPUT, $USER, $PAGE;
$site = get_site();
$sitename = $site->fullname;
$siteurl = $CFG->wwwroot;
if (right_to_left()) {
$direction = array('left-side' => 'right', 'right-side' => 'left');
$dir = 'right';
} else {
$direction = array('left-side' => 'left', 'right-side' => 'right');
$dir = '';
}
// If the menu has no children return an empty string
if (!$menu->has_children()) {
return '';
}
// Start the title area that contains the Site Name Menu icon
$content = html_writer::start_tag('ul', array('class' => 'title-area ' . $dir));
$content .= html_writer::start_tag('li', array('class' => 'name'));
$content .= html_writer::start_tag('h1');
$content .= html_writer::tag('a', $sitename, array('href' => $siteurl));
$content .= html_writer::end_tag('h1');
$content .= html_writer::end_tag('li');
$content .= html_writer::start_tag('li', array('class' => 'toggle-topbar menu-icon'));
$content .= html_writer::start_tag('a', array('href' => '#'));
$content .= html_writer::empty_tag('span');
$content .= html_writer::end_tag('a');
$content .= html_writer::end_tag('li');
$content .= html_writer::end_tag('ul');
// Start the custommenu items
$content .= html_writer::start_tag('section', array('class' => 'top-bar-section'));
$content .= html_writer::start_tag('ul', array('class' => $direction['left-side']));
foreach ($menu->get_children() as $item) {
// Add dividers to top level items
$content .= html_writer::empty_tag('li', array('class' => 'divider ' . $dir));
// Render each child
$content .= $this->render_custom_menu_item($item);
}
$content .= html_writer::end_tag('ul');
// Start the right hand items
$content .= html_writer::start_tag('ul', array('class' => $direction['right-side']));
// Render login_info() (if the theme allows it...
if (empty($PAGE->layout_options['nologininfo'])) {
$content .= $this->login_info();
}
$content .= html_writer::end_tag('ul');
$content .= html_writer::end_tag('section');
// Return the custom menu
return $content;
}
示例15: render_custom_menu
protected function render_custom_menu(custom_menu $menu)
{
global $CFG, $PAGE, $OUTPUT, $COURSE;
if (isloggedin() && !isguestuser()) {
$branchtitle = get_string('home');
$branchlabel = '<i class="fa fa-home"></i> ' . $branchtitle;
$branchurl = new moodle_url('/');
$branchsort = 9998;
$branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
$branchtitle = get_string('myhome');
$branchlabel = '<i class="fa fa-dashboard"></i> ' . $branchtitle;
$branchurl = new moodle_url('/my/index.php');
$branchsort = 9999;
$branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
$mycoursetitle = "Events";
$branchtitle = "Events";
$branchlabel = '<i class="fa fa-calendar"></i> ' . $branchtitle;
$branchurl = new moodle_url('/calendar/view.php');
$branchsort = 10000;
$branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
$mycoursetitle = "我的课程";
$branchtitle = "我的课程";
$branchlabel = '<i class="fa fa-briefcase"></i>' . $branchtitle;
$branchurl = new moodle_url('/my/index.php');
$branchsort = 10001;
$branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
list($sortedcourses, $sitecourses, $totalcourses) = block_course_overview_get_sorted_courses();
if ($sortedcourses) {
foreach ($sortedcourses as $course) {
if ($course->visible) {
$branch->add(format_string($course->fullname), new moodle_url('/course/view.php?id=' . $course->id), format_string($course->shortname));
}
}
} else {
$noenrolments = get_string('noenrolments', 'theme_bcu');
$branch->add('<em>' . $noenrolments . '</em>', new moodle_url('/'), $noenrolments);
}
if (isset($COURSE->id) && $COURSE->id > 1) {
$branchtitle = get_string('thiscourse', 'theme_bcu');
$branchlabel = '<i class="fa fa-sitemap"></i>' . $branchtitle;
$branchurl = new moodle_url('#');
$branch = $menu->add($branchlabel, $branchurl, $branchtitle, 10002);
$branchtitle = "People";
$branchlabel = '<i class="fa fa-users"></i>' . $branchtitle;
$branchurl = new moodle_url('/user/index.php', array('id' => $PAGE->course->id));
$branch->add($branchlabel, $branchurl, $branchtitle, 100003);
$branchtitle = "Grades";
$branchlabel = $OUTPUT->pix_icon('i/grades', '', '', array('class' => 'icon')) . $branchtitle;
$branchurl = new moodle_url('/grade/report/index.php', array('id' => $PAGE->course->id));
$branch->add($branchlabel, $branchurl, $branchtitle, 100004);
$data = theme_bcu_get_course_activities();
foreach ($data as $modname => $modfullname) {
if ($modname === 'resources') {
$icon = $OUTPUT->pix_icon('icon', '', 'mod_page', array('class' => 'icon'));
$branch->add($icon . $modfullname, new moodle_url('/course/resources.php', array('id' => $PAGE->course->id)));
} else {
$icon = '<img src="' . $OUTPUT->pix_url('icon', $modname) . '" class="icon" alt="" />';
$branch->add($icon . $modfullname, new moodle_url('/mod/' . $modname . '/index.php', array('id' => $PAGE->course->id)));
}
}
}
if (!empty($PAGE->theme->settings->enablehelp)) {
$mycoursetitle = "Help";
$branchtitle = "Help";
$branchlabel = '<i class="fa fa-life-ring"></i>' . $branchtitle;
$branchurl = new moodle_url($PAGE->theme->settings->enablehelp);
$branchsort = 10003;
$branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
}
}
// 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 (!$menu->has_children() && $addlangmenu === false) {
return '';
}
$content = '<ul class="nav">';
foreach ($menu->get_children() as $item) {
$content .= $this->render_custom_menu_item($item, 1);
}
return $content . '</ul>';
}