3 class theme_anomaly_core_renderer
extends core_renderer
{
6 * Prints a nice side block with an optional header.
8 * The content is described
9 * by a {@link block_contents} object.
11 * @param block_contents $bc HTML for the content
12 * @param string $region the region the block is appearing in.
13 * @return string the HTML to be output.
15 function block(block_contents
$bc, $region) {
17 $bc = clone($bc); // Avoid messing up the object passed in.
18 if (empty($bc->blockinstanceid
) ||
!strip_tags($bc->title
)) {
19 $bc->collapsible
= block_contents
::NOT_HIDEABLE
;
21 if ($bc->collapsible
== block_contents
::HIDDEN
) {
22 $bc->add_class('hidden');
24 if (!empty($bc->controls
)) {
25 $bc->add_class('block_with_controls');
28 $skiptitle = strip_tags($bc->title
);
29 if (empty($skiptitle)) {
33 $output = html_writer
::tag('a', get_string('skipa', 'access', $skiptitle), array('href' => '#sb-' . $bc->skipid
, 'class' => 'skip-block'));
34 $skipdest = html_writer
::tag('span', '', array('id' => 'sb-' . $bc->skipid
, 'class' => 'skip-block-to'));
37 $output .= html_writer
::start_tag('div', $bc->attributes
);
39 /** Rounded corners **/
40 $output .= html_writer
::start_tag('div', array('class'=>'corner-box'));
41 $output .= html_writer
::start_tag('div', array('class'=>'rounded-corner top-left')).html_writer
::end_tag('div');
42 $output .= html_writer
::start_tag('div', array('class'=>'rounded-corner top-right')).html_writer
::end_tag('div');
44 $controlshtml = $this->block_controls($bc->controls
);
48 $title = html_writer
::tag('h2', $bc->title
);
51 if ($title ||
$controlshtml) {
52 $output .= html_writer
::tag('div', html_writer
::tag('div', html_writer
::tag('div', '', array('class'=>'block_action')). $title . $controlshtml, array('class' => 'title')), array('class' => 'header'));
55 $output .= html_writer
::start_tag('div', array('class' => 'content'));
56 if (!$title && !$controlshtml) {
57 $output .= html_writer
::tag('div', '', array('class'=>'block_action notitle'));
59 $output .= $bc->content
;
62 $output .= html_writer
::tag('div', $bc->footer
, array('class' => 'footer'));
65 $output .= html_writer
::end_tag('div');
67 /** Four rounded corner ends **/
68 $output .= html_writer
::start_tag('div', array('class'=>'rounded-corner bottom-left')).html_writer
::end_tag('div');
69 $output .= html_writer
::start_tag('div', array('class'=>'rounded-corner bottom-right')).html_writer
::end_tag('div');
70 $output .= html_writer
::end_tag('div');
72 $output .= html_writer
::end_tag('div');
74 if ($bc->annotation
) {
75 $output .= html_writer
::tag('div', $bc->annotation
, array('class' => 'blockannotation'));
79 $this->init_block_hider_js($bc);
85 * Renders a custom menu object (located in outputcomponents.php)
87 * The custom menu this method override the render_custom_menu function
88 * in outputrenderers.php
89 * @staticvar int $menucount
90 * @param custom_menu $menu
93 protected function render_custom_menu(custom_menu
$menu) {
95 // If the menu has no children return an empty string
96 if (!$menu->has_children()) {
100 // Add a login or logout link
102 $branchlabel = get_string('logout');
103 $branchurl = new moodle_url('/login/logout.php');
105 $branchlabel = get_string('login');
106 $branchurl = new moodle_url('/login/index.php');
108 $branch = $menu->add($branchlabel, $branchurl, $branchlabel, -1);
110 // Initialise this custom menu
111 $content = html_writer
::start_tag('ul', array('class'=>'dropdown dropdown-horizontal'));
113 foreach ($menu->get_children() as $item) {
114 $content .= $this->render_custom_menu_item($item);
116 // Close the open tags
117 $content .= html_writer
::end_tag('ul');
118 // Return the custom menu
123 * Renders a custom menu node as part of a submenu
125 * The custom menu this method override the render_custom_menu_item function
126 * in outputrenderers.php
128 * @see render_custom_menu()
130 * @staticvar int $submenucount
131 * @param custom_menu_item $menunode
134 protected function render_custom_menu_item(custom_menu_item
$menunode) {
135 // Required to ensure we get unique trackable id's
136 static $submenucount = 0;
137 $content = html_writer
::start_tag('li');
138 if ($menunode->has_children()) {
139 // If the child has menus render it as a sub menu
141 if ($menunode->get_url() !== null) {
142 $url = $menunode->get_url();
144 $url = '#cm_submenu_'.$submenucount;
146 $content .= html_writer
::start_tag('span', array('class'=>'customitem'));
147 $content .= html_writer
::link($url, $menunode->get_text(), array('title'=>$menunode->get_title()));
148 $content .= html_writer
::end_tag('span');
149 $content .= html_writer
::start_tag('ul');
150 foreach ($menunode->get_children() as $menunode) {
151 $content .= $this->render_custom_menu_item($menunode);
153 $content .= html_writer
::end_tag('ul');
155 // The node doesn't have children so produce a final menuitem
157 if ($menunode->get_url() !== null) {
158 $url = $menunode->get_url();
162 $content .= html_writer
::link($url, $menunode->get_text(), array('title'=>$menunode->get_title()));
164 $content .= html_writer
::end_tag('li');
165 // Return the sub menu