. /** * Squared theme. * * @package theme * @subpackage squared * @copyright © 2015-onwards G J Barnard in respect to modifications of the Clean theme. * @copyright © 2015-onwards Work undertaken for David Bogner of Edulabs.org. * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace theme_squared\output; defined('MOODLE_INTERNAL') || die; use html_writer; use navigation_node; class block_settings_renderer extends \block_settings_renderer { protected function navigation_node(navigation_node $node, $attrs=array(), $depth = 1) { $items = $node->children; // Exit if empty, we don't want an empty ul element. if ($items->count() == 0) { return ''; } // Array of nested li elements. $lis = array(); foreach ($items as $item) { if (!$item->display) { continue; } $isbranch = ($item->children->count() > 0 || $item->nodetype == navigation_node::NODETYPE_BRANCH); $hasicon = (!$isbranch && $item->icon instanceof renderable); if ($isbranch) { $item->hideicon = true; } $content = $this->output->render($item); // This applies to the li item which contains all child lists too. $liclasses = array($item->get_css_type()); $liexpandable = array(); if ($isbranch) { $liclasses[] = 'collapsed'; $liclasses[] = 'contains_branch'; $liexpandable = array('aria-expanded' => in_array('collapsed', $liclasses) ? "false" : "true"); } else if ($hasicon) { $liclasses[] = 'item_with_icon'; } if ($item->isactive === true) { $liclasses[] = 'current_branch'; } $liattr = array('class' => join(' ', $liclasses)) + $liexpandable; // Class attribute on the div item which only contains the item content. $divclasses = array('tree_item'); if ($isbranch) { $divclasses[] = 'branch'; } else { $divclasses[] = 'leaf'; } if (!empty($item->classes) && count($item->classes) > 0) { $divclasses[] = join(' ', $item->classes); } $divattr = array('class' => join(' ', $divclasses)); if (!empty($item->id)) { $divattr['id'] = $item->id; } $content = html_writer::tag('p', $content, $divattr) . $this->navigation_node($item); if (!empty($item->preceedwithhr) && $item->preceedwithhr === true) { $content = html_writer::empty_tag('hr') . $content; } $content = html_writer::tag('li', $content, $liattr); $lis[] = $content; } if (count($lis)) { return html_writer::tag('ul', implode("\n", $lis), $attrs); } else { return ''; } } }