function context_reaction_menu::options_form in Context 6
Same name and namespace in other branches
- 6.3 plugins/context_reaction_menu.inc \context_reaction_menu::options_form()
- 7.3 plugins/context_reaction_menu.inc \context_reaction_menu::options_form()
Provide a form element that allow the admin to chose a menu item.
Overrides context_reaction::options_form
File
- plugins/
context_reaction_menu.inc, line 10
Class
- context_reaction_menu
- Expose menu items as context reactions.
Code
function options_form($context) {
if (module_exists('menu')) {
$menus = menu_parent_options(menu_get_menus(), array(
'mlid' => 0,
));
$root_menus = array();
foreach ($menus as $key => $name) {
$id = explode(':', $key);
if ($id[1] == '0') {
$root_menus[$id[0]] = check_plain($name);
}
else {
$link = menu_link_load($id[1]);
$identifier = $link['link_path'];
$root_menu = $root_menus[$id[0]];
while (isset($menus[$root_menu][$identifier])) {
$identifier .= "'";
}
$menus[$root_menu][$identifier] = $name;
}
unset($menus[$key]);
}
array_unshift($menus, "-- " . t('None') . " --");
}
else {
$menus = array();
}
return array(
'#title' => $this->title,
'#description' => $this->description,
'#options' => $menus,
'#type' => 'select',
'#default_value' => $this
->fetch_from_context($context),
);
}