false, 'write_cache_function' => 'write_form_menu_cache', 'title' => 'Formelements menu', 'description' => 'Menus using form elements', 'web_link' => '', 'browser_requirements' => 'This menu should work in all browsers that support javascript', 'edit_label' => 'Menus using form elements', 'include_js_in_head' => '/nexus/plugins/menu.formelements.js', 'plugin_type' => 'nexus_plugin', 'menu_types' => [ 'sdd' => [ 'label' => 'Standard DropDown', 'note' => 'drop-down menu using select with menu name on top' ], 'qdd' => [ 'label' => 'Quick DropDown', 'note' => 'drop-down menu using select with menu name in drop-down select box'], 's3' => [ 'label' => '3-Line Box', 'note' => 'select menu with 3 lines showing' ], 's5' => [ 'label' => '5-Line Box', 'note' => 'select menu with 5 lines showing' ], 'sal' => [ 'label' => 'Full Text Box', 'note' => 'select menu with all menu items showing' ], ], ]; $gNexusSystem->registerPlugin( NEXUS_PLUGIN_GUID_FORMELEMENTSMENU, $pluginParams ); /** * bloody mad function to write a custom cache file for an individual menu * @param $pMenuId menu id of the menu for which we want to create a cache file * @return number of errors encountered * @public */ function write_form_menu_cache( $pMenuHash ) { global $gBitSmarty; $menu_name = preg_replace( "/ +/", "_", trim( $pMenuHash->mInfo['title'] ) ); $menu_name = strtolower( $menu_name ); $menu_file = $pMenuHash->mInfo['cache']['file']; if ( $pMenuHash->mInfo['menu_type'] != 'qdd' ) { $data = '{bitmodule title="'.$pMenuHash->mInfo['title'].'" name="'.$menu_name.'"}'; } else { $data = '{bitmodule name="'.$menu_name.'"}'; } // if a permission has been set, we need to work out when to close the {if} clause $permCloseIds = []; $perm_close = false; $next_cycle = false; foreach( $pMenuHash->mInfo['tree'] as $key => $item ) { if( !empty( $item['perm'] ) ) { $perm_open = '{if $gBitUser->hasPermission("'.$item['perm'].'")}'; } if( $item['first'] ) { $data .= '' ; } else { if( !empty( $item['perm'] ) ) { // open permission if clause $data .= $perm_open; if( !$item['head'] ) { $perm_close = true; } else { $permCloseIds[] = $item['item_id']; } } $gBitSmarty->assign( 'item', $item ); $data .= $gBitSmarty->fetch( NEXUS_PKG_PATH.'templates/formelements/item.tpl' ); } } $data .= '{/bitmodule}'; $ret[$menu_file] = $data; return $ret; } ?>