Permalink
Browse files

Merge branch 'MDL-35654_M23' of git://github.com/lazydaisy/moodle int…

…o MOODLE_23_STABLE
  • Loading branch information...
2 parents 9228a5d + 14a695f commit 9289c14e0c81f1a044909b040cd6c68fc46f083a Sam Hemelryk committed Oct 2, 2012
@@ -7,7 +7,7 @@
$THEME->name = 'anomaly';
-$THEME->sheets = array('base', 'general', 'browser','dock');
+$THEME->sheets = array('base', 'general', 'browser', 'dock', 'menu');
/// This variable is an array containing the names of all the
/// stylesheet files you want included in this theme, and in what order
////////////////////////////////////////////////////////////////////////////////
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -81,4 +81,89 @@ function block(block_contents $bc, $region) {
return $output;
}
+ /**
+ * 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;
+ }
+
+ /**
+ * Renders a custom menu node as part of a submenu
+ *
+ * The custom menu this method override the render_custom_menu_item function
+ * in outputrenderers.php
+ *
+ * @see render_custom_menu()
+ *
+ * @staticvar int $submenucount
+ * @param custom_menu_item $menunode
+ * @return string
+ */
+ protected function render_custom_menu_item(custom_menu_item $menunode) {
+ // Required to ensure we get unique trackable id's
+ static $submenucount = 0;
+ $content = html_writer::start_tag('li');
+ if ($menunode->has_children()) {
+ // If the child has menus render it as a sub menu
+ $submenucount++;
+ if ($menunode->get_url() !== null) {
+ $url = $menunode->get_url();
+ } else {
+ $url = '#cm_submenu_'.$submenucount;
+ }
+ $content .= html_writer::start_tag('span', array('class'=>'customitem'));
+ $content .= html_writer::link($url, $menunode->get_text(), array('title'=>$menunode->get_title()));
+ $content .= html_writer::end_tag('span');
+ $content .= html_writer::start_tag('ul');
+ foreach ($menunode->get_children() as $menunode) {
+ $content .= $this->render_custom_menu_item($menunode);
+ }
+ $content .= html_writer::end_tag('ul');
+ } else {
+ // The node doesn't have children so produce a final menuitem
+
+ if ($menunode->get_url() !== null) {
+ $url = $menunode->get_url();
+ } else {
+ $url = '#';
+ }
+ $content .= html_writer::link($url, $menunode->get_text(), array('title'=>$menunode->get_title()));
+ }
+ $content .= html_writer::end_tag('li');
+ // Return the sub menu
+ return $content;
+ }
+
}
Oops, something went wrong.

0 comments on commit 9289c14

Please sign in to comment.