3 class theme_afterburner_core_renderer
extends core_renderer
{
6 * Renders a custom menu object (located in outputcomponents.php)
8 * The custom menu this method override the render_custom_menu function
9 * in outputrenderers.php
10 * @staticvar int $menucount
11 * @param custom_menu $menu
14 protected function render_custom_menu(custom_menu
$menu) {
16 // If the menu has no children return an empty string
17 if (!$menu->has_children()) {
21 // Add a login or logout link
23 $branchlabel = get_string('logout');
24 $branchurl = new moodle_url('/login/logout.php');
26 $branchlabel = get_string('login');
27 $branchurl = new moodle_url('/login/index.php');
29 $branch = $menu->add($branchlabel, $branchurl, $branchlabel, -1);
31 // Initialise this custom menu
32 $content = html_writer
::start_tag('ul', array('class'=>'dropdown dropdown-horizontal'));
34 foreach ($menu->get_children() as $item) {
35 $content .= $this->render_custom_menu_item($item);
37 // Close the open tags
38 $content .= html_writer
::end_tag('ul');
39 // Return the custom menu
44 * Renders a custom menu node as part of a submenu
46 * The custom menu this method override the render_custom_menu_item function
47 * in outputrenderers.php
49 * @see render_custom_menu()
51 * @staticvar int $submenucount
52 * @param custom_menu_item $menunode
55 protected function render_custom_menu_item(custom_menu_item
$menunode) {
56 // Required to ensure we get unique trackable id's
57 static $submenucount = 0;
58 $content = html_writer
::start_tag('li');
59 if ($menunode->has_children()) {
60 // If the child has menus render it as a sub menu
62 if ($menunode->get_url() !== null) {
63 $url = $menunode->get_url();
65 $url = '#cm_submenu_'.$submenucount;
67 $content .= html_writer
::start_tag('span', array('class'=>'customitem'));
68 $content .= html_writer
::link($url, $menunode->get_text(), array('title'=>$menunode->get_title()));
69 $content .= html_writer
::end_tag('span');
70 $content .= html_writer
::start_tag('ul');
71 foreach ($menunode->get_children() as $menunode) {
72 $content .= $this->render_custom_menu_item($menunode);
74 $content .= html_writer
::end_tag('ul');
76 // The node doesn't have children so produce a final menuitem
78 if ($menunode->get_url() !== null) {
79 $url = $menunode->get_url();
83 $content .= html_writer
::link($url, $menunode->get_text(), array('title'=>$menunode->get_title()));
85 $content .= html_writer
::end_tag('li');
86 // Return the sub menu
91 * Copied from core_renderer with one minor change - changed $this->output->render() call to $this->render()
93 * @param navigation_node $item
96 protected function render_navigation_node(navigation_node
$item) {
97 $content = $item->get_content();
98 $title = $item->get_title();
99 if ($item->icon
instanceof renderable
&& !$item->hideicon
) {
100 $icon = $this->render($item->icon
);
101 $content = $icon.$content; // use CSS for spacing of icons
103 if ($item->helpbutton
!== null) {
104 $content = trim($item->helpbutton
).html_writer
::tag('span', $content, array('class'=>'clearhelpbutton'));
106 if ($content === '') {
109 if ($item->action
instanceof action_link
) {
110 //adds class dimmed to hidden courses and categories
111 $link = $item->action
;
113 $link->add_class('dimmed');
115 $content = $this->render($link);
116 } else if ($item->action
instanceof moodle_url
) {
117 $attributes = array();
119 $attributes['title'] = $title;
122 $attributes['class'] = 'dimmed_text';
124 $content = html_writer
::link($item->action
, $content, $attributes);
126 } else if (is_string($item->action
) ||
empty($item->action
)) {
127 $attributes = array();
129 $attributes['title'] = $title;
132 $attributes['class'] = 'dimmed_text';
134 $content = html_writer
::tag('span', $content, $attributes);