Revision 220
Added by stefan about 19 years ago
trunk/wb/framework/class.frontend.php | ||
---|---|---|
305 | 305 |
if (!isset($wb->menu_current_class)) { |
306 | 306 |
$wb->menu_current_class = ' class="menu_current"'; |
307 | 307 |
} |
308 |
if (!isset($wb->menu_parent)) {
|
|
309 |
$wb->menu_parent = 0;
|
|
308 |
if (!isset($wb->menu_parent)) {
|
|
309 |
$wb->menu_parent = 0;
|
|
310 | 310 |
} |
311 | 311 |
$wb->show_menu(); |
312 |
if ($start_level>0) { |
|
313 |
$key_array=array_keys($wb->page_trail); |
|
314 |
$real_start=$key_array[$start_level-1]; |
|
315 |
if (isset($real_start)) |
|
316 |
{ |
|
317 |
$wb->menu_parent=$real_start; |
|
318 |
$wb->show_menu(); |
|
319 |
} |
|
320 |
return; |
|
321 |
} |
|
322 |
|
|
323 | 312 |
} |
324 | 313 |
|
325 | 314 |
function show_menu() { |
326 | 315 |
global $database; |
327 |
global $wb; |
|
328 |
if ($wb->menu_recurse==0) |
|
316 |
if ($this->menu_start_level>0) { |
|
317 |
$key_array=array_keys($this->page_trail); |
|
318 |
$real_start=$key_array[$this->menu_start_level-1]; |
|
319 |
if (isset($real_start)) { |
|
320 |
$this->menu_parent=$real_start; |
|
321 |
$this->menu_start_level=0; |
|
322 |
} else { |
|
323 |
return; |
|
324 |
} |
|
325 |
} |
|
326 |
if ($this->menu_recurse==0) |
|
329 | 327 |
return; |
330 | 328 |
// Check if we should add menu number check to query |
331 |
if($menu_parent == 0) { |
|
332 |
$menu_number = "menu = '$wb->menu_number'";
|
|
329 |
if($this->menu_parent == 0) {
|
|
330 |
$menu_number = "menu = '$this->menu_number'";
|
|
333 | 331 |
} else { |
334 | 332 |
$menu_number = '1'; |
335 | 333 |
} |
336 | 334 |
// Query pages |
337 | 335 |
$query_menu = $database->query("SELECT page_id,menu_title,page_title,link,target,level,visibility FROM ". |
338 |
TABLE_PREFIX."pages WHERE parent = '$wb->menu_parent' AND $menu_number AND $wb->extra_where_sql ORDER BY position ASC");
|
|
336 |
TABLE_PREFIX."pages WHERE parent = '$this->menu_parent' AND $menu_number AND $this->extra_where_sql ORDER BY position ASC");
|
|
339 | 337 |
// Check if there are any pages to show |
340 | 338 |
if($query_menu->numRows() > 0) { |
341 | 339 |
// Print menu header |
342 |
echo "\n".$wb->menu_header;
|
|
340 |
echo "\n".$this->menu_header;
|
|
343 | 341 |
// Loop through pages |
344 | 342 |
while($page = $query_menu->fetchRow()) { |
345 | 343 |
// Check if this page should be shown |
... | ... | |
347 | 345 |
$vars = array('[class]','[a]', '[/a]', '[menu_title]', '[page_title]'); |
348 | 346 |
// Work-out class |
349 | 347 |
if($page['page_id'] == PAGE_ID) { |
350 |
$class = $wb->menu_current_class;
|
|
348 |
$class = $this->menu_current_class;
|
|
351 | 349 |
} else { |
352 |
$class = $wb->menu_default_class;
|
|
350 |
$class = $this->menu_default_class;
|
|
353 | 351 |
} |
354 | 352 |
// Check if link is same as first page link, and if so change to WB URL |
355 |
if($page['link'] == $wb->default_link AND !INTRO_PAGE) {
|
|
353 |
if($page['link'] == $this->default_link AND !INTRO_PAGE) {
|
|
356 | 354 |
$link = WB_URL; |
357 | 355 |
} else { |
358 |
$link = $wb->page_link($page['link']);
|
|
356 |
$link = $this->page_link($page['link']);
|
|
359 | 357 |
} |
360 | 358 |
// Create values |
361 | 359 |
$values = array($class,'<a href="'.$link.'" target="'.$page['target'].'" '.$class.'>', '</a>', ($page['menu_title']), ($page['page_title'])); |
362 | 360 |
// Replace vars with value and print |
363 |
echo "\n".str_replace($vars, $values, $wb->menu_item_template);
|
|
361 |
echo "\n".str_replace($vars, $values, $this->menu_item_template);
|
|
364 | 362 |
// Generate sub-menu |
365 |
if($wb->menu_collapse==false OR ($wb->menu_collapse==true AND isset($wb->page_trail[$page['page_id']]))) {
|
|
366 |
$wb->menu_recurse--;
|
|
367 |
$wb->menu_parent=$page['page_id'];
|
|
368 |
$wb->show_menu();
|
|
363 |
if($this->menu_collapse==false OR ($this->menu_collapse==true AND isset($this->page_trail[$page['page_id']]))) {
|
|
364 |
$this->menu_recurse--;
|
|
365 |
$this->menu_parent=$page['page_id'];
|
|
366 |
$this->show_menu();
|
|
369 | 367 |
} |
370 |
echo "\n".$wb->menu_item_footer;
|
|
368 |
echo "\n".$this->menu_item_footer;
|
|
371 | 369 |
} |
372 | 370 |
// Print menu footer |
373 |
echo "\n".$wb->menu_footer;
|
|
371 |
echo "\n".$this->menu_footer;
|
|
374 | 372 |
} |
375 | 373 |
} |
376 | 374 |
|
trunk/wb/framework/frontend.functions.php | ||
---|---|---|
67 | 67 |
|
68 | 68 |
// Old menu call invokes new menu function |
69 | 69 |
if (!function_exists('page_menu')) { |
70 |
function page_menu($parent = 0, $menu_number = 1, $item_template = '<li><span[class]>[a][menu_title][/a]</span>', $menu_header = '<ul>', $menu_footer = '</ul>', $default_class = ' class="menu_default"', $current_class = ' class="menu_current"', $recurse = LEVEL) {
|
|
70 |
function page_menu($parent = 0, $menu_number = 1, $item_template = '<li[class]>[a][menu_title][/a]</li>', $menu_header = '<ul>', $menu_footer = '</ul>', $default_class = ' class="menu_default"', $current_class = ' class="menu_current"', $recurse = LEVEL) {
|
|
71 | 71 |
global $wb; |
72 | 72 |
$wb->menu_number=$menu_number; |
73 | 73 |
$wb->menu_item_template=$item_template; |
74 |
$wb->menu_item_footer=''; |
|
74 | 75 |
$wb->menu_parent = $parent; |
75 | 76 |
$wb->menu_header = $menu_header; |
76 | 77 |
$wb->menu_footer = $menu_footer; |
... | ... | |
78 | 79 |
$wb->menu_current_class = $current_class; |
79 | 80 |
$wb->menu_recurse = $recurse+2; |
80 | 81 |
$wb->menu(); |
82 |
unset($wb->menu_parent); |
|
83 |
unset($wb->menu_number); |
|
84 |
unset($wb->menu_item_template); |
|
85 |
unset($wb->menu_item_footer); |
|
86 |
unset($wb->menu_header); |
|
87 |
unset($wb->menu_footer); |
|
88 |
unset($wb->menu_default_class); |
|
89 |
unset($wb->menu_current_class); |
|
90 |
unset($wb->menu_start_level); |
|
91 |
unset($wb->menu_collapse); |
|
92 |
unset($wb->menu_recurse); |
|
81 | 93 |
} |
82 | 94 |
} |
83 | 95 |
|
96 |
if (!function_exists('show_menu')) { |
|
97 |
function show_menu($menu_number = NULL, $start_level=NULL, $recurse = NULL, $collapse = NULL, $item_template = NULL, $item_footer = NULL, $menu_header = NULL, $menu_footer = NULL, $default_class = NULL, $current_class = NULL, $parent = NULL) { |
|
98 |
global $wb; |
|
99 |
if (isset($menu_number)) |
|
100 |
$wb->menu_number=$menu_number; |
|
101 |
if (isset($start_level)) |
|
102 |
$wb->menu_start_level=$start_level; |
|
103 |
if (isset($recurse)) |
|
104 |
$wb->menu_recurse=$recurse; |
|
105 |
if (isset($collapse)) |
|
106 |
$wb->menu_collapse=$collapse; |
|
107 |
if (isset($item_template)) |
|
108 |
$wb->menu_item_template=$item_template; |
|
109 |
if (isset($item_footer)) |
|
110 |
$wb->menu_item_footer=$item_footer; |
|
111 |
if (isset($menu_header)) |
|
112 |
$wb->menu_header=$menu_header; |
|
113 |
if (isset($menu_footer)) |
|
114 |
$wb->menu_footer=$menu_footer; |
|
115 |
if (isset($default_class)) |
|
116 |
$wb->menu_default_class=$default_class; |
|
117 |
if (isset($current_class)) |
|
118 |
$wb->menu_current_class=$current_class; |
|
119 |
if (isset($parent)) |
|
120 |
$wb->menu_parent=$parent; |
|
121 |
$wb->menu(); |
|
122 |
unset($wb->menu_recurse); |
|
123 |
unset($wb->menu_parent); |
|
124 |
unset($wb->menu_start_level); |
|
125 |
} |
|
126 |
} |
|
127 |
|
|
84 | 128 |
if (!function_exists('page_content')) { |
85 | 129 |
function page_content($block = 1) { |
86 | 130 |
// Get outside objects |
Also available in: Unified diff
Some changes and fixes to menu code