protected function getLabel(MenuElem $menu_elem) { $label = $this->translateLabel($menu_elem->getLabel()); if ($menu_elem->hasChildren() and $level == 0) { $label .= ' <b class="right-caret"></b>'; } return $label; }
private function serializeElem(DOMDocument $doc_xml, DOMElement $parent_xml, $id, MenuElem $menu_elem) { $menu_elem_xml = $doc_xml->createElement('menu-elem'); $menu_elem_xml->setAttribute('id', $id); $label_xml = $doc_xml->createElement('label', $menu_elem->getLabel()); $url_xml = $doc_xml->createElement('url', $menu_elem->getUrl()); $menu_elem_xml->appendChild($label_xml); $menu_elem_xml->appendChild($url_xml); $menu_children = $menu_elem->getChildren(); if ($menu_children) { $submenu_xml = $doc_xml->createElement('submenu'); $menu_elem_xml->appendChild($submenu_xml); foreach ($menu_children as $child_id => $child_elem) { $this->serializeElem($doc_xml, $submenu_xml, $child_id, $child_elem); } } $parent_xml->appendChild($menu_elem_xml); }
protected function buildAttrs(MenuElem $menu_elem) { $attr_li = $attr_a = array(); if ($menu_elem->hasChildren()) { if ($level > 0) { $attr_li['class'][] = 'dropdown-submenu'; if (!$this->isParentElemClickable()) { $attr_a['class'][] = 'dropdown-toggle'; } else { $attr_a['class'][] = 'dropdown-submenu-toggle'; } } else { $attr_li['class'][] = 'dropdown'; } $attr_a['data-toggle'][] = 'dropdown'; } if ($this->getActiveLink() and $this->getActiveLink() == $menu_elem->getUrl()) { $attr_li['class'][] = 'active'; } else { if ($menu_elem->getLabel() == 'divider' && $menu_elem->getUrl() == 'divider') { $attr_li['class'] = 'divider'; } } $attr_string_li = $this->attrToString($attr_li); $attr_string_a = $this->attrToString($attr_a); return array('li' => $attr_string_li, 'a' => $attr_string_a); }