Here it is:
https://github.com/emanuele45/Dialogo/commit/4c1aa6f8ea1dfb6e67219fd1aa89e4ebad322c36
Example of how to add a new item to any menu:
// Grab all the menus we have
$allMenus = Standard_Menu::context();
// Find the admin menu
$admin_menu = $allMenus->get('Admin_Menu');
// Find the submenu you want (this get is a shortcut that will find menus at any nesting level and any position,
// if a sort of getElementById in javascript terms.
// Though if you know where your menu is you can do the "extended" version with childOf that should be slightly faster
$submenu = $admin_menu->get('manageboards_sub');
// Add the new menu item
$submenu->add('my_new_menu', array($txt['menu_name'], 'optional_permissions'));
This is the very basic usage.
Then you may want to add for example an entire new menu at the first level, after config, with a droppy with a submenu, then you should do something like:
// Grab all the menus we have
$allMenus = Standard_Menu::context();
// Find the admin menu
$admin_menu = $allMenus->get('Admin_Menu');
// Add the "visible" item (i.e.the label)
$admin_menu->after('config')->add('your_main_item', array(
'title' => $txt['main_item_name'],
'permission' => array('admin_forum')
));
// Now create your new sub-menu and add it to the main one:
$my_item = $admin_menu->childOf('forum')->add('your_main_item');
// Finally populate it. addBulk is a shortcut (again) for add that loops through an array of menus and adds them one by one)
$my_item->addBulk(
array(
'index' => array(
'label' => $txt['admin_center'],
'controller' => 'Admin_Controller',
'function' => 'action_home',
'icon' => 'transparent.png',
'class' => 'admin_img_administration',
),
)
);
Now that I look at the code, I think the first two lines could be "merged" into a single call... Will work on that.
There is still a distinction between a "menu" (i.e. a "collection" of entries) and an "entry" (i.e. the "text" visible in the menu/droppy), and the two behave slightly differently (actually quite a bit differently). I think this should be polished up, not sure yet how...
Yes, it's not the same as an array.