OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / templates / s / art_test / html / mod_mainmenu / default.php
1 <?php
2 defined('_JEXEC') or die('Restricted access'); // no direct access
3
4 ob_start();
5 require_once realpath(dirname(__FILE__) . str_replace('/', DIRECTORY_SEPARATOR, '/../../../../modules/mod_mainmenu/tmpl/default.php'));
6 ob_clean();
7
8 if (!defined('modMainMenuArtxExtensions'))
9 {
10
11         function modMainMenuArtXMLCallback(&$node, $args)
12         {
13                 $options = $GLOBALS['modMainMenuArtXMLCallbackOptions'];
14                 if ($node->name() == 'li') {
15                         if (!$options['show_submenus'] && $node->level() == 1) {
16                                 if ($ul = $node->getElementByPath('ul'))
17                                         $node->removeChild($ul);
18                         }
19                         $liChildren = & $node->_children;
20                         if (count($liChildren) > 0) {
21                                 // element                 ( $img?,                                          $span ( $text     )  )      )
22                                 // <a href="...">          <img src="..." (align="left|right")? alt="..." />?<span><![CDATA[...]]></span></a>
23                                 // <span class="separator"><img src="..." (align="left|right")? alt="..." />?<span><![CDATA[...]]></span></span>
24                                 $element = & $liChildren[0];
25                                 if ($element->_children[0]->name() == 'img') {
26                                         $img = & $element->_children[0];
27                                         $span = & $element->_children[1];
28                                         $element->removeChild($img);
29                                 } else {
30                                         $img = null;
31                                         $span = & $element->_children[0];
32                                 }
33                                 $element->removeChild($span);
34                                 // convert separator to anchor
35                                 if ($element->name() == 'span' && $element->attributes('class') == 'separator') {
36                                         $element->_name = 'a';
37                                         $element->addAttribute('href', '#');
38                                         $element->addAttribute('onclick', 'return false;');
39                                 }
40                                 // add extra spans for top level items, required for design
41                                 if ($element->level() == ($options['start'] + 1) * 2) {
42                                         $lspan = & $element->addChild('span', array('class' => 'l'));
43                                         $lspan->setData(' ');
44                                         $rspan = & $element->addChild('span', array('class' => 'r'));
45                                         $rspan->setData(' ');
46                                         $tspan = & $element->addChild('span', array('class' => 't'));
47                                         $container = & $tspan;
48                                 } else {
49                                         $container = & $element;
50                                 }
51                                 // to prevent span from collapsing
52                                 $text = strlen($span->data()) == 0 ? ' ' : $span->data();
53                                 // container is always <a ...>...</a> here
54                                 if ($img != null) {
55                                         $align = $img->attributes('align');
56                                         if ($align == 'left' || $align == '') {
57                                                 $container->addChild('img', array('class' => 'art-metadata-icon',
58                                                         'src' => $img->attributes('src'),
59                                                         'style' => 'margin-right: 5px; vertical-align: middle;',
60                                                         'alt' => $img->attributes('alt')));
61                                                 $extraArtxSpan = & $container->addChild('artx-extra-span');
62                                                 $extraArtxSpan->setData($text);
63                                         } else if ($align == 'right') {
64                                                 $extraArtxSpan = & $container->addChild('artx-extra-span');
65                                                 $extraArtxSpan->setData($text);
66                                                 $container->addChild('img', array('class' => 'art-metadata-icon',
67                                                         'src' => $img->attributes('src'),
68                                                         'style' => 'margin-left: 5px; vertical-align: middle;',
69                                                         'alt' => $img->attributes('alt')));
70                                         }
71                                 } else {
72                                         $container->setData($text);
73                                 }
74                         }
75
76                         modMainMenuXMLCallback($node, $args);
77
78                         // this should be after modMainMenuXMLCallback, because the callback sets class='active' and id='current'
79                         if ($options['vmenu'] !== null && !$options['vmenu']['simple']) {
80                                 $class = $node->attributes('class');
81                                 $isActive = $class && false !== strpos(' ' . $class, ' active');
82                                 if ($node->attributes('id') != 'current' && !$isActive) {
83                                         if ($ul = $node->getElementByPath('ul'))
84                                                 $node->removeChild($ul);
85                                 }
86                         }
87
88                         $class = $node->attributes('class');
89                         if ($class && false !== strpos(' ' . $class, ' active')) {
90                                 $element->addAttribute('class', 'active');
91                         }
92                 } else {
93                         modMainMenuXMLCallback($node, $args);
94                 }
95
96         }
97
98         function artxMenuDecorator($content)
99         {
100                 $result = '';
101                 ob_start();
102 ?>
103 <div class="art-nav">
104         <div class="l"></div>
105         <div class="r"></div>
106 <?php
107                 $result .= ob_get_clean() . $content;
108                 ob_start();
109 ?>
110 </div>
111 <?php
112                 $result .= ob_get_clean();
113                 return $result;
114         }
115
116
117         define('modMainMenuArtxExtensions', true);
118 }
119
120 if (isset($attribs['name']) && $attribs['name'] == 'user3') {
121         $GLOBALS['modMainMenuArtXMLCallbackOptions'] = array(
122                 'show_submenus' => $GLOBALS['artx_settings']['menu']['show_submenus'] && 1 == $params->get('showAllChildren'),
123                 'vmenu' => null,
124                 'start' => $params->get('startLevel')
125         );
126         $xml = modMainMenuHelper::getXML($params->get('menutype'), $params, 'modMainMenuArtXMLCallback');
127         if ($xml) {
128                 $xml->addAttribute('class', 'art-menu');
129                 if ($tagId = $params->get('tag_id')) {
130                         $xml->addAttribute('id', $tagId);
131                 }
132                 $result = JFilterOutput::ampReplace($xml->toString((bool)$params->get('show_whitespace')));
133                 $result = str_replace(array('<ul/>', '<ul />', '<artx-extra-span>', '</artx-extra-span>'), '', $result);
134                 echo artxMenuDecorator($result);
135         }
136         unset($GLOBALS['tmp_menu_show_submenus']);
137 } else if ($params->get('moduleclass_sfx') == 'art-vmenu') {
138         $GLOBALS['modMainMenuArtXMLCallbackOptions'] = array(
139                 'show_submenus' => $GLOBALS['artx_settings']['vmenu']['show_submenus'] && 1 == $params->get('showAllChildren'),
140                 'vmenu' => array('simple' => $GLOBALS['artx_settings']['vmenu']['simple']),
141                 'start' => $params->get('startLevel')
142         );
143         $xml = modMainMenuHelper::getXML($params->get('menutype'), $params, 'modMainMenuArtXMLCallback');
144         if ($xml) {
145                 $xml->addAttribute('class', 'art-vmenu');
146                 if ($tagId = $params->get('tag_id')) {
147                         $xml->addAttribute('id', $tagId);
148                 }
149                 $result = JFilterOutput::ampReplace($xml->toString((bool)$params->get('show_whitespace')));
150                 $result = str_replace(array('<ul/>', '<ul />', '<artx-extra-span>', '</artx-extra-span>'), '', $result);
151                 echo $result;
152         }
153         unset($GLOBALS['tmp_menu_show_submenus']);
154 } else {
155         modMainMenuHelper::render($params, 'modMainMenuXMLCallback');
156 }