function devel_generate_menu_form
Generates menus using FormAPI.
1 string reference to 'devel_generate_menu_form'
- devel_generate_menu in devel_generate/
devel_generate.module - Implements hook_menu().
File
-
devel_generate/
devel_generate.module, line 419
Code
function devel_generate_menu_form() {
$menu_enabled = module_exists('menu');
if ($menu_enabled) {
$menus = array(
'__new-menu__' => t('Create new menu(s)'),
) + menu_get_menus();
}
else {
$menus = menu_list_system_menus();
}
$form['existing_menus'] = array(
'#type' => 'checkboxes',
'#title' => t('Generate links for these menus'),
'#options' => $menus,
'#default_value' => array(
'__new-menu__',
),
'#required' => TRUE,
);
if ($menu_enabled) {
$form['num_menus'] = array(
'#type' => 'textfield',
'#title' => t('Number of new menus to create'),
'#default_value' => 2,
'#size' => 10,
'#states' => array(
'visible' => array(
':input[name="existing_menus[__new-menu__]"]' => array(
'checked' => TRUE,
),
),
),
);
}
$form['num_links'] = array(
'#type' => 'textfield',
'#title' => t('Number of links to generate'),
'#default_value' => 50,
'#size' => 10,
'#required' => TRUE,
);
$form['title_length'] = array(
'#type' => 'textfield',
'#title' => t('Maximum number of characters in menu and menu link names'),
'#description' => t("The minimum length is 2."),
'#default_value' => 12,
'#size' => 10,
'#required' => TRUE,
);
$form['link_types'] = array(
'#type' => 'checkboxes',
'#title' => t('Types of links to generate'),
'#options' => array(
'node' => t('Nodes'),
'front' => t('Front page'),
'external' => t('External'),
),
'#default_value' => array(
'node',
'front',
'external',
),
'#required' => TRUE,
);
$form['max_depth'] = array(
'#type' => 'select',
'#title' => t('Maximum link depth'),
'#options' => range(0, MENU_MAX_DEPTH),
'#default_value' => floor(MENU_MAX_DEPTH / 2),
'#required' => TRUE,
);
unset($form['max_depth']['#options'][0]);
$form['max_width'] = array(
'#type' => 'textfield',
'#title' => t('Maximum menu width'),
'#default_value' => 6,
'#size' => 10,
'#description' => t("Limit the width of the generated menu's first level of links to a certain number of items."),
'#required' => TRUE,
);
$form['kill'] = array(
'#type' => 'checkbox',
'#title' => t('Delete existing custom generated menus and menu links before generating new ones.'),
'#default_value' => FALSE,
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Generate'),
);
return $form;
}