function i18n_menu_parent_options in Internationalization 7
Return a list of menu items that are valid possible parents for the given menu item.
@todo This has to be turned into a #process form element callback. The 'menu_override_parent_selector' variable is entirely superfluous.
Parameters
$menus: An array of menu names and titles, such as from menu_get_menus().
$item: The menu item or the node type for which to generate a list of parents. If $item['mlid'] == 0 then the complete tree is returned.
Return value
An array of menu link titles keyed on the a string containing the menu name and mlid. The list excludes the given item and its children.
1 call to i18n_menu_parent_options()
- i18n_menu_translation_form in i18n_menu/
i18n_menu.admin.inc - Produces a menu translation form.
File
- i18n_menu/
i18n_menu.admin.inc, line 130 - Helper functions for menu administration.
Code
function i18n_menu_parent_options($menus, $item, $langcode) {
// The menu_links table can be practically any size and we need a way to
// allow contrib modules to provide more scalable pattern choosers.
// hook_form_alter is too late in itself because all the possible parents are
// retrieved here, unless menu_override_parent_selector is set to TRUE.
if (variable_get('i18n_menu_override_parent_selector', FALSE)) {
return array();
}
// If no menu item, create a dummy one
$item = $item ? $item : array(
'mlid' => 0,
);
// Get menus that have a language or have language for terms
$available_menus = array();
foreach (menu_load_all() as $name => $menu) {
if ($menu['i18n_mode'] & I18N_MODE_TRANSLATE) {
$available_menus[$name] = $menu;
}
elseif ($menu['i18n_mode'] & I18N_MODE_LANGUAGE && $menu['language'] == $langcode) {
$available_menus[$name] = $menu;
}
}
// Disable i18n selection, enable after the query.
$previous = i18n_select(FALSE);
$options = _i18n_menu_get_options($menus, $available_menus, $item, $langcode);
i18n_select($previous);
return $options;
}