2 defined('_JEXEC') or die('Restricted access'); // no direct access
4 if (!defined('modMainMenuXMLCallbackDefined'))
6 function modMainMenuXMLCallback(&$node, $args)
8 $user = &JFactory::getUser();
9 $menu = &JSite::getMenu();
10 $active = $menu->getActive();
11 $path = isset($active) ? array_reverse($active->tree) : null;
13 if (($args['end']) && ($node->attributes('level') >= $args['end']))
15 $children = $node->children();
16 foreach ($node->children() as $child)
18 if ($child->name() == 'ul') {
19 $node->removeChild($child);
24 if ($node->name() == 'ul') {
25 foreach ($node->children() as $child)
27 if ($child->attributes('access') > $user->get('aid', 0)) {
28 $node->removeChild($child);
33 if (($node->name() == 'li') && isset($node->ul)) {
34 $node->addAttribute('class', 'parent');
37 if (isset($path) && (in_array($node->attributes('id'), $path) || in_array($node->attributes('rel'), $path)))
39 if ($node->attributes('class')) {
40 $node->addAttribute('class', $node->attributes('class').' active');
42 $node->addAttribute('class', 'active');
47 if (isset($args['children']) && !$args['children'])
49 $children = $node->children();
50 foreach ($node->children() as $child)
52 if ($child->name() == 'ul') {
53 $node->removeChild($child);
59 if (($node->name() == 'li') && ($id = $node->attributes('id'))) {
60 if ($node->attributes('class')) {
61 $node->addAttribute('class', $node->attributes('class').' item'.$id);
63 $node->addAttribute('class', 'item'.$id);
67 if (isset($path) && $node->attributes('id') == $path[0]) {
68 $node->addAttribute('id', 'current');
70 $node->removeAttribute('id');
72 $node->removeAttribute('rel');
73 $node->removeAttribute('level');
74 $node->removeAttribute('access');
76 define('modMainMenuXMLCallbackDefined', true);
79 if (!defined('modMainMenuArtXMLCallbackDefined'))
81 function modMainMenuArtXMLCallback(&$node, $args)
83 if (!$GLOBALS['menu_showSubmenus'] && $node->name() == 'li' && $node->level() == 1) {
84 if ($ul = $node->getElementByPath('ul'))
85 $node->removeChild($ul);
88 if ($node->name() == 'li') {
89 $liChildren = & $node->_children;
90 if (count($liChildren) > 0) {
91 $liFirstChild = & $liChildren[0];
92 $linkChildren = & $liFirstChild->_children;
93 $span = & $linkChildren[0];
94 $text = $span->data();
95 if ($liFirstChild->name() == 'span' && $liFirstChild->attributes('class') == 'separator') {
96 $liFirstChild->_name = 'a';
97 $liFirstChild->addAttribute('href', '#');
98 $liFirstChild->addAttribute('onclick', 'return false;');
100 if ($liFirstChild->name() == 'a') {
101 if ($liFirstChild->level() == 2) {
102 $liFirstChild->removeChild($span);
103 $lspan = & $liFirstChild->addChild('span', array('class' => 'l'));
104 $lspan->setData(' ');
105 $rspan = & $liFirstChild->addChild('span', array('class' => 'r'));
106 $rspan->setData(' ');
107 $tspan = & $liFirstChild->addChild('span', array('class' => 't'));
108 $tspan->setData($text);
110 $liFirstChild->removeAttribute('class');
111 $liFirstChild->setData($text);
112 $liFirstChild->removeChild($span);
117 modMainMenuXMLCallback($node, $args);
118 if ($node->name() == 'li') {
119 $class = $node->attributes('class');
120 if ($class && false !== strpos(' ' . $class, ' active')) {
121 $itemChildren = & $node->_children;
122 $itemChildren[0]->addAttribute('class', 'active');
127 define('modMainMenuArtXMLCallbackDefined', true);
130 if ($attribs['name'] == 'user3') {
131 $GLOBALS['menu_showSubmenus'] = true && 1 == $params->get('showAllChildren');
132 $xml = modMainMenuHelper::getXML($params->get('menutype'), $params, 'modMainMenuArtXMLCallback');
134 $xml->addAttribute('class', 'artmenu');
135 if ($tagId = $params->get('tag_id')) {
136 $xml->addAttribute('id', $tagId);
138 $result = JFilterOutput::ampReplace($xml->toString((bool)$params->get('show_whitespace')));
139 $result = str_replace(array('<ul/>', '<ul />'), '', $result);
140 echo '<div class="nav"><div class="l"></div><div class="r"></div>' . $result . '</div>';
143 modMainMenuHelper::render($params, 'modMainMenuXMLCallback');