1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
<?php
/**
* Plugin for Nexus creating a hierarchial set of items using <ul> and <li> items.
* using the appropriate css settings, this can be transformed into a dropdown menu
*
* @abstract creates a simple <ul> and <li> based list of items
* @author xing@synapse.plus.com
* @version $Revision: 1.13 $
* @package nexus
* @subpackage plugins
*/
global $gNexusSystem;
/**
* definitions
*/
// GUID should be a maximum of 16 chars
define( 'NEXUS_PLUGIN_GUID_SUCKERFISH', 'suckerfish' );
$pluginParams = array(
'auto_activate' => TRUE,
'write_cache_function' => 'write_suckerfish_cache',
'title' => 'Suckerfish Menus',
'description' => 'Sophisticated and flexible CSS driven dropdown menus',
'web_link' => '<a class="external" href = "http://www.htmldog.com/articles/suckerfish/">Sons of Suckerfish Menus</a>',
'browser_requirements' => 'Many modern browsers support suckerfish menus inherently using CSS.',
'edit_label' => 'CSS based menus',
'plugin_type' => 'nexus_plugin',
'menu_types' => array(
'nor' => array( 'label' => 'Normal', 'note' => 'Nested list of menu items using "ul" and "li" HTML tags.' ),
'ver' => array( 'label' => 'Vertical', 'note' => 'Vertical dropdown menu that usually resides in one of the side modules.' ),
'hor' => array( 'label' => 'Horizontal', 'note' => 'Horizontal menu which you can use to insert in or replace the top menu bar.' ),
),
);
$gNexusSystem->registerPlugin( NEXUS_PLUGIN_GUID_SUCKERFISH, $pluginParams );
/**
* bloody mad function to write a custom cache file for an individual menu
* @param $pMenuHash full menu hash
* @return full menu string ready for printing (key serves as cache file path)
*/
function write_suckerfish_cache( $pMenuHash ) {
global $gBitSmarty;
$menu_name = preg_replace( "/ +/", "_", trim( $pMenuHash->mInfo['title'] ) );
$menu_name = strtolower( $menu_name );
$menu_file = $pMenuHash->mInfo['cache']['file'];
$data = '{bitmodule title="{tr}'.$pMenuHash->mInfo['title'].'{/tr}" name="'.$menu_name.'" classplus="nexus-menu"}';
$data .= '<div class="suckerfish">';
// if a permission has been set, we need to work out when to close the {if} clause
$permCloseIds = array();
$perm_close = FALSE;
$next_cycle = FALSE;
$menu_id = 'nexus'.$pMenuHash->mInfo['menu_id'];
foreach( $pMenuHash->mInfo['tree'] as $key => $item ) {
if( $item['first'] ) {
if( $key == 0 ) {
$data .= '<ul id="'.$menu_id.'" class="menu '.$pMenuHash->mInfo['menu_type'].'">';
} else {
$data .= '<ul>';
}
} else {
$data .= '</li>';
// close permission clauses
if( $next_cycle ) {
$data .= '{/if}';
$next_cycle = FALSE;
}
if( in_array( $item['item_id'], $permCloseIds ) ) {
$next_cycle = TRUE;
}
if( $perm_close ) {
$data .= '{/if}';
$perm_close = FALSE;
}
}
if( $item['last'] ) {
$data .= '</ul>';
} else {
if( !empty( $item['perm'] ) ) {
// open permission if clause
$data .= '{if $gBitUser->hasPermission("'.$item['perm'].'")}';
if( !$item['head'] ) {
$perm_close = TRUE;
} else {
$permCloseIds[] = $item['item_id'];
}
}
if( $item['rsrc_type'] == 'content_id' ) {
$data .= '<li{if $gContent->mContentId == '.$item['rsrc'].'} class="selected"{/if}>';
} else {
$data .= '<li>';
}
$gBitSmarty->assign( 'item', $item );
$data .= $gBitSmarty->fetch( NEXUS_PKG_PATH.'templates/'.NEXUS_PLUGIN_GUID_SUCKERFISH.'/item.tpl' );
}
}
$data .= '<!--[if lt IE 8]><script type="text/javascript">BitBase.fixIEDropMenu("'.$menu_id.'");</script><![endif]-->';
$data .= '<div class="clear"></div>';
$data .= '</div>';
$data .= '{/bitmodule}';
$ret[$menu_file] = $data;
return $ret;
}
?>
|