function modMainMenuArtXMLCallback(&$node, $args) { if (!$GLOBALS['menu_showSubmenus'] && $node->name() == 'li' && $node->level() == 1) { if ($ul = $node->getElementByPath('ul')) { $node->removeChild($ul); } } if ($node->name() == 'a') { $linkChildren =& $node->children(); $span =& $linkChildren[0]; if ($node->level() == 2) { $secondSpan =& $span->addChild('span'); $secondSpan->setData($span->data()); $span->setData(''); } else { $node->removeAttribute('class'); $node->setData($span->data()); $node->removeChild($span); } } modMainMenuXMLCallback($node, $args); if ($node->name() == 'li') { $class = $node->attributes('class'); if ($class && false !== strpos(' ' . $class, ' active')) { $itemChildren =& $node->children(); $itemChildren[0]->addAttribute('class', 'active'); } } }
function modMainMenuArtXMLCallback(&$node, $args) { if (!$GLOBALS['menu_showSubmenus'] && $node->name() == 'li' && $node->level() == 1) { if ($ul = $node->getElementByPath('ul')) { $node->removeChild($ul); } } if ($node->name() == 'li') { $liChildren =& $node->_children; if (count($liChildren) > 0) { $liFirstChild =& $liChildren[0]; $linkChildren =& $liFirstChild->_children; $span =& $linkChildren[0]; $text = $span->data(); if ($liFirstChild->name() == 'span' && $liFirstChild->attributes('class') == 'separator') { $liFirstChild->_name = 'a'; $liFirstChild->addAttribute('href', '#'); $liFirstChild->addAttribute('onclick', 'return false;'); } if ($liFirstChild->name() == 'a') { if ($liFirstChild->level() == 2) { $liFirstChild->removeChild($span); $lspan =& $liFirstChild->addChild('span', array('class' => 'l')); $lspan->setData(' '); $rspan =& $liFirstChild->addChild('span', array('class' => 'r')); $rspan->setData(' '); $tspan =& $liFirstChild->addChild('span', array('class' => 't')); $tspan->setData($text); } else { $liFirstChild->removeAttribute('class'); $liFirstChild->setData($text); $liFirstChild->removeChild($span); } } } } modMainMenuXMLCallback($node, $args); if ($node->name() == 'li') { $class = $node->attributes('class'); if ($class && false !== strpos(' ' . $class, ' active')) { $itemChildren =& $node->_children; $itemChildren[0]->addAttribute('class', 'active'); } } }
function modMainMenuArtXMLCallback(&$node, $args) { $options = $GLOBALS['modMainMenuArtXMLCallbackOptions']; if ($node->name() == 'li') { if (!$options['show_submenus'] && $node->level() == 1) { if ($ul = $node->getElementByPath('ul')) { $node->removeChild($ul); } } $liChildren =& $node->_children; if (count($liChildren) > 0) { // element ( $img?, $span ( $text ) ) ) // <a href="..."> <img src="..." (align="left|right")? alt="..." />?<span><![CDATA[...]]></span></a> // <span class="separator"><img src="..." (align="left|right")? alt="..." />?<span><![CDATA[...]]></span></span> $element =& $liChildren[0]; if ($element->_children[0]->name() == 'img') { $img =& $element->_children[0]; $span =& $element->_children[1]; $element->removeChild($img); } else { $img = null; $span =& $element->_children[0]; } $element->removeChild($span); // convert separator to anchor if ($element->name() == 'span' && $element->attributes('class') == 'separator') { $element->_name = 'a'; $element->addAttribute('href', '#'); $element->addAttribute('onclick', 'return false;'); } // add extra spans for top level items, required for design if ($element->level() == ($options['start'] + 1) * 2) { $lspan =& $element->addChild('span', array('class' => 'l')); $lspan->setData(' '); $rspan =& $element->addChild('span', array('class' => 'r')); $rspan->setData(' '); $tspan =& $element->addChild('span', array('class' => 't')); $container =& $tspan; } else { $container =& $element; } // to prevent span from collapsing $text = strlen($span->data()) == 0 ? ' ' : $span->data(); // container is always <a ...>...</a> here if ($img != null) { $align = $img->attributes('align'); if ($align == 'left' || $align == '') { $container->addChild('img', array('class' => 'art-metadata-icon', 'src' => $img->attributes('src'), 'style' => 'margin-right: 5px; vertical-align: middle;', 'alt' => $img->attributes('alt'))); $extraArtxSpan =& $container->addChild('artx-extra-span'); $extraArtxSpan->setData($text); } else { if ($align == 'right') { $extraArtxSpan =& $container->addChild('artx-extra-span'); $extraArtxSpan->setData($text); $container->addChild('img', array('class' => 'art-metadata-icon', 'src' => $img->attributes('src'), 'style' => 'margin-left: 5px; vertical-align: middle;', 'alt' => $img->attributes('alt'))); } } } else { $container->setData($text); } } modMainMenuXMLCallback($node, $args); // this should be after modMainMenuXMLCallback, because the callback sets class='active' and id='current' if ($options['vmenu'] !== null && !$options['vmenu']['simple']) { $class = $node->attributes('class'); $isActive = $class && false !== strpos(' ' . $class, ' active'); if ($node->attributes('id') != 'current' && !$isActive) { if ($ul = $node->getElementByPath('ul')) { $node->removeChild($ul); } } } $class = $node->attributes('class'); if ($class && false !== strpos(' ' . $class, ' active')) { $element->addAttribute('class', 'active'); } } else { modMainMenuXMLCallback($node, $args); } }