OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / templates / FishNew / html / mod_mainmenu / default.php
1 <?php
2 defined('_JEXEC') or die('Restricted access'); // no direct access
3
4 if (!defined('modMainMenuXMLCallbackDefined'))
5 {
6 function modMainMenuXMLCallback(&$node, $args)
7 {
8         $user   = &JFactory::getUser();
9         $menu   = &JSite::getMenu();
10         $active = $menu->getActive();
11         $path   = isset($active) ? array_reverse($active->tree) : null;
12
13         if (($args['end']) && ($node->attributes('level') >= $args['end']))
14         {
15                 $children = $node->children();
16                 foreach ($node->children() as $child)
17                 {
18                         if ($child->name() == 'ul') {
19                                 $node->removeChild($child);
20                         }
21                 }
22         }
23
24         if ($node->name() == 'ul') {
25                 foreach ($node->children() as $child)
26                 {
27                         if ($child->attributes('access') > $user->get('aid', 0)) {
28                                 $node->removeChild($child);
29                         }
30                 }
31         }
32
33         if (($node->name() == 'li') && isset($node->ul)) {
34                 $node->addAttribute('class', 'parent');
35         }
36
37         if (isset($path) && (in_array($node->attributes('id'), $path) || in_array($node->attributes('rel'), $path)))
38         {
39                 if ($node->attributes('class')) {
40                         $node->addAttribute('class', $node->attributes('class').' active');
41                 } else {
42                         $node->addAttribute('class', 'active');
43                 }
44         }
45         else
46         {
47                 if (isset($args['children']) && !$args['children'])
48                 {
49                         $children = $node->children();
50                         foreach ($node->children() as $child)
51                         {
52                                 if ($child->name() == 'ul') {
53                                         $node->removeChild($child);
54                                 }
55                         }
56                 }
57         }
58
59         if (($node->name() == 'li') && ($id = $node->attributes('id'))) {
60                 if ($node->attributes('class')) {
61                         $node->addAttribute('class', $node->attributes('class').' item'.$id);
62                 } else {
63                         $node->addAttribute('class', 'item'.$id);
64                 }
65         }
66
67         if (isset($path) && $node->attributes('id') == $path[0]) {
68                 $node->addAttribute('id', 'current');
69         } else {
70                 $node->removeAttribute('id');
71         }
72         $node->removeAttribute('rel');
73         $node->removeAttribute('level');
74         $node->removeAttribute('access');
75 }
76         define('modMainMenuXMLCallbackDefined', true);
77 }
78
79 if (!defined('modMainMenuArtXMLCallbackDefined'))
80 {
81 function modMainMenuArtXMLCallback(&$node, $args)
82 {
83                 if (!$GLOBALS['menu_showSubmenus'] && $node->name() == 'li' && $node->level() == 1) {
84                         if ($ul = $node->getElementByPath('ul'))
85                                 $node->removeChild($ul);
86                 }
87                 
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;');
99                                 }
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);
109                                         } else {
110                                                 $liFirstChild->removeAttribute('class');
111                                                 $liFirstChild->setData($text);
112                                                 $liFirstChild->removeChild($span);
113                                         }
114                                 }
115                         }
116                 }
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');
123                         }
124                 }
125         }
126
127         define('modMainMenuArtXMLCallbackDefined', true);
128 }
129
130 if ($attribs['name'] == 'user3') {
131         $GLOBALS['menu_showSubmenus'] = true && 1 == $params->get('showAllChildren');
132         $xml = modMainMenuHelper::getXML($params->get('menutype'), $params, 'modMainMenuArtXMLCallback');
133         if ($xml) {
134                 $xml->addAttribute('class', 'artmenu');
135                 if ($tagId = $params->get('tag_id')) {
136                         $xml->addAttribute('id', $tagId);
137                 }
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>';
141         }
142 } else {
143         modMainMenuHelper::render($params, 'modMainMenuXMLCallback');
144 }