1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Functionality for Nice Menus administration.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Settings form as implemented by hook_menu.
|
10
|
*/
|
11
|
function nice_menus_admin_settings($form, &$form_state) {
|
12
|
$form['nice_menus_number'] = array(
|
13
|
'#type' => 'textfield',
|
14
|
'#description' => t('The total number of independent Nice menus blocks you want. Enter a number between 0 and 99. If you set this to 0, you will have no blocks created but you can still use the Nice menus theme functions directly in your theme.'),
|
15
|
'#default_value' => variable_get('nice_menus_number', '2'),
|
16
|
'#size' => 2,
|
17
|
);
|
18
|
$form['nice_menus_js'] = array(
|
19
|
'#type' => 'checkbox',
|
20
|
'#title' => t('Use JavaScript'),
|
21
|
'#description' => t('This will add Superfish jQuery to Nice menus. This is required for Nice menus to work properly in Internet Explorer.'),
|
22
|
'#default_value' => variable_get('nice_menus_js', 1),
|
23
|
);
|
24
|
$form['nice_menus_sf_options'] = array(
|
25
|
'#type' => 'fieldset',
|
26
|
'#title' => t('Advanced: Superfish options'),
|
27
|
'#description' => t('You can change the default Superfish options by filling out the desired values here. These only take effect if the Use JavaScript box above is checked.'),
|
28
|
'#collapsible' => TRUE,
|
29
|
'#collapsed' => TRUE,
|
30
|
);
|
31
|
$form['nice_menus_sf_options']['nice_menus_sf_delay'] = array(
|
32
|
'#type' => 'textfield',
|
33
|
'#title' => t('Mouse delay'),
|
34
|
'#description' => t('The delay in milliseconds that the mouse can remain outside a submenu without it closing.'),
|
35
|
'#default_value' => variable_get('nice_menus_sf_delay', 800),
|
36
|
'#size' => 5,
|
37
|
);
|
38
|
$form['nice_menus_sf_options']['nice_menus_sf_speed'] = array(
|
39
|
'#type' => 'select',
|
40
|
'#title' => t('Animation speed'),
|
41
|
'#multiple' => FALSE,
|
42
|
'#description' => t('Speed of the menu open/close animation.'),
|
43
|
'#options' => array(
|
44
|
'slow' => t('slow'),
|
45
|
'normal' => t('normal'),
|
46
|
'fast' => t('fast'),
|
47
|
),
|
48
|
'#default_value' => variable_get('nice_menus_sf_speed', 1),
|
49
|
);
|
50
|
|
51
|
// Custom validation to make sure the user is entering numbers.
|
52
|
$form['#validate'][] = 'nice_menus_settings_validate';
|
53
|
|
54
|
return system_settings_form($form);
|
55
|
}
|
56
|
|
57
|
/**
|
58
|
* Custom validation for the settings form.
|
59
|
*/
|
60
|
function nice_menus_settings_validate($form, &$form_state) {
|
61
|
$number = $form_state['values']['nice_menus_number'];
|
62
|
// Check to make sure it is a number and that is a maximum of 2 digits.
|
63
|
if (!is_numeric($number) || strlen($number) > 2) {
|
64
|
form_set_error('nice_menus_number', t('You must enter a number from 0 to 99.'));
|
65
|
}
|
66
|
}
|