1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category module
|
5
|
* @package show_menu2
|
6
|
* @author WebsiteBaker Project
|
7
|
* @copyright 2004-2009, Ryan Djurovich
|
8
|
* @copyright 2009-2011, Website Baker Org. e.V.
|
9
|
* @link http://www.websitebaker2.org/
|
10
|
* @license http://www.gnu.org/licenses/gpl.html
|
11
|
* @platform WebsiteBaker 2.7.0 | 2.8.x
|
12
|
* @requirements PHP 5.2.2 and higher
|
13
|
* @version $Id: legacy.php 2 2017-07-02 15:14:29Z Manuela $
|
14
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/trunk/modules/show_menu2/legacy.php $
|
15
|
* @lastmodified $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
|
16
|
*
|
17
|
*/
|
18
|
|
19
|
/*
|
20
|
This file provides backward compatibility between show_menu2 and the
|
21
|
old functions show_menu() and menu(). Note that it is highly recommended
|
22
|
for you to update your templates to use show_menu2 directly.
|
23
|
*/
|
24
|
|
25
|
/* ----------------------------------------------------------------------------
|
26
|
show_menu
|
27
|
|
28
|
From: http://forum.websitebaker.org/index.php/topic,2251.msg13978.html#msg13978
|
29
|
|
30
|
* By calling it multiple times, you can have one menu just
|
31
|
* showing the root level, one for the sub-pages, and so on
|
32
|
* The order of the arguments has been changed compared
|
33
|
* to the page_menu() function, so read carefully the list
|
34
|
* of arguments!
|
35
|
* To just display the standard menu, use
|
36
|
* <?php show_menu(); ?> within your template's html code.
|
37
|
* You don't normally need anymore than the first four arguments.
|
38
|
* Usual calls would be (inside php code!)
|
39
|
* show_menu(1,0,-1,false); - displays the complete page tree
|
40
|
* show_menu(1,1,1); - show only first sub level
|
41
|
* show_menu(1,1,-1); - show an expanding/collapsing menu tree starting at level 1
|
42
|
* Have fun experimenting!
|
43
|
*
|
44
|
* Full list of arguments:
|
45
|
* 1. $menu_number: With activitated "multiple menu" feature
|
46
|
* you can choose which menu will be displayed
|
47
|
* default: 1
|
48
|
* 2. $start_level: The depth level of the root of the displayed
|
49
|
* menu tree. Defaults to '0', which is the top level.
|
50
|
* '1' will show all pages starting from the first sub level.
|
51
|
* 3. $recurse: Gives the maximum number of levels to be displayed. Default
|
52
|
* is '-1' which means 'all'.
|
53
|
* 4. $collapse: Specifies, whether the menu tree shall be
|
54
|
* expandable/collapsible (if set to 'true')
|
55
|
* or complete (all pages being displayed) if set to 'false'
|
56
|
* 5. $item_template: Gives the possibility to specify the html code that is
|
57
|
* displayed before displaying sub-pages
|
58
|
* 6. $item_footer: The html code to appear after sub-pages were displayed.
|
59
|
* 7. $menu_header: The html code to appear before the entire menu code and each
|
60
|
* sub tree.
|
61
|
* 8. $menu_footer: The html code to appear after the entire menu code and each
|
62
|
* sub tree.
|
63
|
* 9. $default_class: The (CSS) class of every menu item except the currently viewed page
|
64
|
* 10. $current_class: The class of the currently viewed page
|
65
|
* 11. $parent: (used internally) The page_id of the menu's root node, defaults is '0' (root level)
|
66
|
*/
|
67
|
|
68
|
// Must include code to stop this file being access directly
|
69
|
if(defined('WB_PATH') == false) { die("Cannot access this file directly"); }
|
70
|
|
71
|
class SM2_ShowMenuFormatter
|
72
|
{
|
73
|
var $output;
|
74
|
var $itemTemplate;
|
75
|
var $itemFooter;
|
76
|
var $menuHeader;
|
77
|
var $menuFooter;
|
78
|
var $defaultClass;
|
79
|
var $currentClass;
|
80
|
|
81
|
function output($aString) {
|
82
|
if ($this->flags & SM2_BUFFER) {
|
83
|
$this->output .= $aString;
|
84
|
}
|
85
|
else {
|
86
|
echo $aString;
|
87
|
}
|
88
|
}
|
89
|
function initialize() { $this->output = ''; }
|
90
|
function startList($aPage, $aUrl) {
|
91
|
echo $this->menuHeader;
|
92
|
}
|
93
|
function startItem($aPage, $aUrl, $aCurrSib, $aSibCount) {
|
94
|
// determine the class string to use
|
95
|
$thisClass = $this->defaultClass;
|
96
|
if ($aPage['page_id'] == PAGE_ID) {
|
97
|
$thisClass = $this->currentClass;
|
98
|
}
|
99
|
|
100
|
// format and display this item
|
101
|
$item = str_replace(
|
102
|
array(
|
103
|
'[a]','[/a]','[menu_title]','[page_title]','[url]',
|
104
|
'[target]','[class]'
|
105
|
),
|
106
|
array(
|
107
|
"<a href='$aUrl' target='".$aPage['target']."'>", '</a>',
|
108
|
$aPage['menu_title'], $aPage['page_title'], $aUrl,
|
109
|
$aPage['target'], $thisClass
|
110
|
),
|
111
|
$this->itemTemplate);
|
112
|
echo $item;
|
113
|
}
|
114
|
function finishItem() {
|
115
|
echo $this->itemFooter;
|
116
|
}
|
117
|
function finishList() {
|
118
|
echo $this->menuFooter;
|
119
|
}
|
120
|
function finalize() { }
|
121
|
function getOutput() {
|
122
|
return $this->output;
|
123
|
}
|
124
|
}
|
125
|
|
126
|
function show_menu(
|
127
|
$aMenu = 1,
|
128
|
$aStartLevel = 0,
|
129
|
$aRecurse = -1,
|
130
|
$aCollapse = true,
|
131
|
$aItemTemplate = '<li><span[class]>[a][menu_title][/a]</span>',
|
132
|
$aItemFooter = '</li>',
|
133
|
$aMenuHeader = '<ul>',
|
134
|
$aMenuFooter = '</ul>',
|
135
|
$aDefaultClass = ' class="menu_default"',
|
136
|
$aCurrentClass = ' class="menu_current"',
|
137
|
$aParent = 0
|
138
|
)
|
139
|
{
|
140
|
static $formatter;
|
141
|
if (!isset($formatter)) {
|
142
|
$formatter = new SM2_ShowMenuFormatter;
|
143
|
}
|
144
|
|
145
|
$formatter->itemTemplate = $aItemTemplate;
|
146
|
$formatter->itemFooter = $aItemFooter;
|
147
|
$formatter->menuHeader = $aMenuHeader;
|
148
|
$formatter->menuFooter = $aMenuFooter;
|
149
|
$formatter->defaultClass = $aDefaultClass;
|
150
|
$formatter->currentClass = $aCurrentClass;
|
151
|
|
152
|
$start = SM2_ROOT + $aStartLevel;
|
153
|
if ($aParent != 0) {
|
154
|
$start = $aParent;
|
155
|
}
|
156
|
|
157
|
$maxLevel = 0;
|
158
|
if ($aRecurse == 0) {
|
159
|
return;
|
160
|
}
|
161
|
if ($aRecurse < 0) {
|
162
|
$maxLevel = SM2_ALL;
|
163
|
}
|
164
|
else {
|
165
|
$maxLevel = SM2_START + $aRecurse - 1;
|
166
|
}
|
167
|
|
168
|
$flags = $aCollapse ? SM2_TRIM : SM2_ALL;
|
169
|
|
170
|
// special case for default case
|
171
|
if ($aStartLevel == 0 && $aRecurse == -1 && $aCollapse) {
|
172
|
$maxLevel = SM2_CURR + 1;
|
173
|
}
|
174
|
|
175
|
show_menu2($aMenu, $start, $maxLevel, $flags, $formatter);
|
176
|
}
|
177
|
|
178
|
function page_menu(
|
179
|
$aParent = 0,
|
180
|
$menu_number = 1,
|
181
|
$item_template = '<li[class]>[a][menu_title][/a]</li>',
|
182
|
$menu_header = '<ul>',
|
183
|
$menu_footer = '</ul>',
|
184
|
$default_class = ' class="menu_default"',
|
185
|
$current_class = ' class="menu_current"',
|
186
|
$recurse = LEVEL // page['level']
|
187
|
)
|
188
|
{
|
189
|
show_menu($menu_number, 0, $recurse+2, true, $item_template, '',
|
190
|
$menu_header, $menu_footer, $default_class, $current_class, $aParent);
|
191
|
}
|
192
|
|
193
|
?>
|