Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/theme/afterburner/renderers.php
Go to the documentation of this file.
00001 <?php
00002 
00003 class theme_afterburner_core_renderer extends core_renderer {
00004 
00014     protected function render_custom_menu(custom_menu $menu) {
00015 
00016         // If the menu has no children return an empty string
00017         if (!$menu->has_children()) {
00018             return '';
00019         }
00020 
00021         // Add a login or logout link
00022         if (isloggedin()) {
00023             $branchlabel = get_string('logout');
00024             $branchurl   = new moodle_url('/login/logout.php');
00025         } else {
00026             $branchlabel = get_string('login');
00027             $branchurl   = new moodle_url('/login/index.php');
00028         }
00029         $branch = $menu->add($branchlabel, $branchurl, $branchlabel, -1);
00030 
00031         // Initialise this custom menu
00032         $content = html_writer::start_tag('ul', array('class'=>'dropdown dropdown-horizontal'));
00033         // Render each child
00034         foreach ($menu->get_children() as $item) {
00035             $content .= $this->render_custom_menu_item($item);
00036         }
00037         // Close the open tags
00038         $content .= html_writer::end_tag('ul');
00039         // Return the custom menu
00040         return $content;
00041     }
00042 
00055     protected function render_custom_menu_item(custom_menu_item $menunode) {
00056         // Required to ensure we get unique trackable id's
00057         static $submenucount = 0;
00058         $content = html_writer::start_tag('li');
00059         if ($menunode->has_children()) {
00060             // If the child has menus render it as a sub menu
00061             $submenucount++;
00062             if ($menunode->get_url() !== null) {
00063                 $url = $menunode->get_url();
00064             } else {
00065                 $url = '#cm_submenu_'.$submenucount;
00066             }
00067             $content .= html_writer::start_tag('span', array('class'=>'customitem'));
00068             $content .= html_writer::link($url, $menunode->get_text(), array('title'=>$menunode->get_title()));
00069             $content .= html_writer::end_tag('span');
00070             $content .= html_writer::start_tag('ul');
00071             foreach ($menunode->get_children() as $menunode) {
00072                 $content .= $this->render_custom_menu_item($menunode);
00073             }
00074             $content .= html_writer::end_tag('ul');
00075         } else {
00076             // The node doesn't have children so produce a final menuitem
00077 
00078             if ($menunode->get_url() !== null) {
00079                 $url = $menunode->get_url();
00080             } else {
00081                 $url = '#';
00082             }
00083             $content .= html_writer::link($url, $menunode->get_text(), array('title'=>$menunode->get_title()));
00084         }
00085         $content .= html_writer::end_tag('li');
00086         // Return the sub menu
00087         return $content;
00088     }
00089 
00096     protected function render_navigation_node(navigation_node $item) {
00097         $content = $item->get_content();
00098         $title = $item->get_title();
00099         if ($item->icon instanceof renderable && !$item->hideicon) {
00100             $icon = $this->render($item->icon);
00101             $content = $icon.$content; // use CSS for spacing of icons
00102         }
00103         if ($item->helpbutton !== null) {
00104             $content = trim($item->helpbutton).html_writer::tag('span', $content, array('class'=>'clearhelpbutton'));
00105         }
00106         if ($content === '') {
00107             return '';
00108         }
00109         if ($item->action instanceof action_link) {
00110             //adds class dimmed to hidden courses and categories
00111             $link = $item->action;
00112             if ($item->hidden) {
00113                 $link->add_class('dimmed');
00114             }
00115             $content = $this->render($link);
00116         } else if ($item->action instanceof moodle_url) {
00117             $attributes = array();
00118             if ($title !== '') {
00119                 $attributes['title'] = $title;
00120             }
00121             if ($item->hidden) {
00122                 $attributes['class'] = 'dimmed_text';
00123             }
00124             $content = html_writer::link($item->action, $content, $attributes);
00125 
00126         } else if (is_string($item->action) || empty($item->action)) {
00127             $attributes = array();
00128             if ($title !== '') {
00129                 $attributes['title'] = $title;
00130             }
00131             if ($item->hidden) {
00132                 $attributes['class'] = 'dimmed_text';
00133             }
00134             $content = html_writer::tag('span', $content, $attributes);
00135         }
00136         return $content;
00137     }
00138 
00139 }
 All Data Structures Namespaces Files Functions Variables Enumerations