/** * Renders an action menu component. * * ARIA references: * - http://www.w3.org/WAI/GL/wiki/Using_ARIA_menus * - http://stackoverflow.com/questions/12279113/recommended-wai-aria-implementation-for-navigation-bar-menu * * @param action_menu $menu * @return string HTML */ public function render_action_menu(action_menu $menu) { $menu->initialise_js($this->page); $output = html_writer::start_tag('div', $menu->attributes); $output .= html_writer::start_tag('ul', $menu->attributesprimary); foreach ($menu->get_primary_actions($this) as $action) { if ($action instanceof renderable) { $content = $this->render($action); } else { $content = $action; } $output .= html_writer::tag('li', $content, array('role' => 'presentation')); } $output .= html_writer::end_tag('ul'); $output .= html_writer::start_tag('ul', $menu->attributessecondary); foreach ($menu->get_secondary_actions() as $action) { if ($action instanceof renderable) { $content = $this->render($action); } else { $content = $action; } $output .= html_writer::tag('li', $content, array('role' => 'presentation')); } $output .= html_writer::end_tag('ul'); $output .= html_writer::end_tag('div'); return $output; }