1
|
<?php
|
2
|
// $Id: dhtml_menu.admin.inc,v 1.22 2010/11/09 21:24:51 arancaytar Exp $
|
3
|
|
4
|
|
5
|
/**
|
6
|
* @file dhtml_menu.admin.inc
|
7
|
* Functions that are only called on the admin pages.
|
8
|
*/
|
9
|
|
10
|
/**
|
11
|
* Module settings form.
|
12
|
*/
|
13
|
function dhtml_menu_settings($form, &$form_state) {
|
14
|
$settings = variable_get('dhtml_menu_settings');
|
15
|
|
16
|
$options['nav'] = array(
|
17
|
'#type' => 'radios',
|
18
|
'#title' => t('Static navigation'),
|
19
|
'#options' => array(
|
20
|
'open' => t('<strong>No Collapsing:</strong> Menu items cannot be collapsed dynamically. Instead, clicking on an already expanded item will take you to the page.'),
|
21
|
'bullet' => t('<strong>Expand on Bullet:</strong> All links will continue to function as static links. To expand an item, click the bullet icon next to the link.'),
|
22
|
'clone' => t('<strong>Cloned Menu Link:</strong> At the top of each menu, an extra link will be generated that leads to the page of the parent item.'),
|
23
|
'hover' => t('<strong>Expand on Hover:</strong> Items expand when the cursor hovers over them. Links function normally. <em>This is unfamiliar and causes accessibility problems!</em>'),
|
24
|
'double-click' => t('<strong>Doubleclick:</strong> To expand an item, click the link once. To navigate to the page, click it twice. <em>This will be difficult to find for your users!</em>'),
|
25
|
'none' => t('<strong>None:</strong> Clicking the link will expand the item. Navigating to the page is not possible at all. <em>This will make pages with sub-items very difficult to reach!</em>'),
|
26
|
),
|
27
|
'#default_value' => $settings['nav'],
|
28
|
'#description' => t('Dynamic expansion of menus competes with the static navigation of content. Choose how to resolve this conflict.'),
|
29
|
);
|
30
|
|
31
|
$options['animation'] = array(
|
32
|
'#type' => 'fieldset',
|
33
|
'#title' => t('Animation'),
|
34
|
'#collapsible' => TRUE,
|
35
|
'#collapsed' => TRUE,
|
36
|
);
|
37
|
|
38
|
$options['animation']['effects'] = array(
|
39
|
'#type' => 'checkboxes',
|
40
|
'#title' => t('Effects'),
|
41
|
'#options' => array(
|
42
|
'height' => t('Slide in vertically'),
|
43
|
'width' => t('Slide in horizontally'),
|
44
|
'opacity' => t('Fade in'),
|
45
|
),
|
46
|
'#description' => t('You may pick any number of animation effects that will accompany the opening and closing of a menu.'),
|
47
|
'#default_value' => $settings['animation']['effects'],
|
48
|
);
|
49
|
|
50
|
$options['animation']['speed'] = array(
|
51
|
'#type' => 'select',
|
52
|
'#title' => t('Speed'),
|
53
|
'#options' => array(
|
54
|
100 => t('Very Fast (@seconds s)', array('@seconds' => 0.1)),
|
55
|
500 => t('Fast (@seconds s)', array('@seconds' => 0.5)),
|
56
|
1000 => t('Medium (@seconds s)', array('@seconds' => 1)),
|
57
|
1500 => t('Slow (@seconds s)', array('@seconds' => 1.5)),
|
58
|
2000 => t('Very Slow (@seconds s)', array('@seconds' => 2)),
|
59
|
),
|
60
|
'#default_value' => $settings['animation']['speed'],
|
61
|
'#description' => t('Choose how quickly the menus should expand and collapse.'),
|
62
|
);
|
63
|
|
64
|
$options['effects'] = array(
|
65
|
'#type' => 'fieldset',
|
66
|
'#title' => t('Other effects'),
|
67
|
'#collapsible' => TRUE,
|
68
|
'#collapsed' => TRUE,
|
69
|
);
|
70
|
|
71
|
$options['effects']['siblings'] = array(
|
72
|
'#type' => 'radios',
|
73
|
'#title' => t('When a menu opens'),
|
74
|
'#options' => array(
|
75
|
'none' => t('Keep other menus open.'),
|
76
|
'close-all' => t('Close all other open menus on the page.'),
|
77
|
'close-same-tree' => t('Close other open menus in the same tree.'),
|
78
|
),
|
79
|
'#default_value' => $settings['effects']['siblings'],
|
80
|
);
|
81
|
|
82
|
$options['effects']['children'] = array(
|
83
|
'#type' => 'radios',
|
84
|
'#title' => t('When a menu closes'),
|
85
|
'#options' => array(
|
86
|
'none' => t('Remember which sub-items were expanded when it next opens.'),
|
87
|
'close-children' => t('Close all its sub-items, too.'),
|
88
|
),
|
89
|
'#default_value' => $settings['effects']['children'],
|
90
|
);
|
91
|
|
92
|
$options['effects']['remember'] = array(
|
93
|
'#type' => 'radios',
|
94
|
'#title' => t('When a new page is loaded'),
|
95
|
'#options' => array(
|
96
|
'remember' => t('Remember which items were expanded on the last page.'),
|
97
|
0 => t('Expand only the currently active path.'),
|
98
|
),
|
99
|
'#default_value' => $settings['effects']['remember'],
|
100
|
);
|
101
|
|
102
|
$options['filter'] = array(
|
103
|
'#type' => 'fieldset',
|
104
|
'#title' => t('Disabling DHTML'),
|
105
|
'#collapsible' => TRUE,
|
106
|
'#collapsed' => TRUE,
|
107
|
);
|
108
|
|
109
|
$options['filter']['type'] = array(
|
110
|
'#type' => 'radios',
|
111
|
'#title' => t('Filter type'),
|
112
|
'#options' => array(
|
113
|
'blacklist' => t('Disable DHTML on the menus checked below.'),
|
114
|
'whitelist' => t('Enable DHTML on the menus checked below.'),
|
115
|
),
|
116
|
'#default_value' => $settings['filter']['type'],
|
117
|
);
|
118
|
|
119
|
$options['filter']['list'] = array(
|
120
|
'#type' => 'checkboxes',
|
121
|
'#title' => t('List'),
|
122
|
'#options' => _dhtml_menu_menus(),
|
123
|
'#default_value' => $settings['filter']['list'],
|
124
|
'#description' => t('DHTML will be used for all menus by default, but can be switched off for specific menus.'),
|
125
|
);
|
126
|
|
127
|
$options['#tree'] = TRUE;
|
128
|
$form['dhtml_menu_settings'] = $options;
|
129
|
|
130
|
// Disable automatic defaults, which don't work with nested values.
|
131
|
return system_settings_form($form, FALSE);
|
132
|
}
|
133
|
|
134
|
/**
|
135
|
* Build a human-readable option list for all non-empty menus.
|
136
|
* Custom menus and book menus are included if the respective modules are enabled.
|
137
|
*/
|
138
|
function _dhtml_menu_menus() {
|
139
|
if (function_exists('menu_get_menus')) {
|
140
|
// If the menu module is enabled, list custom menus.
|
141
|
$menus = menu_get_menus();
|
142
|
}
|
143
|
else {
|
144
|
// Otherwise, list only system menus.
|
145
|
$menus = menu_list_system_menus();
|
146
|
}
|
147
|
|
148
|
// If the book module is enabled, also include book menus.
|
149
|
if (function_exists('book_get_books')) {
|
150
|
foreach (book_get_books() as $bid => $link) {
|
151
|
$menus["book-toc-$bid"] = t('Book: %title', array('%title' => $link['title']));
|
152
|
}
|
153
|
}
|
154
|
|
155
|
// menu_get_names() filters out empty menus, and adds any menus not found using the above calls (edge case).
|
156
|
foreach (menu_get_names() as $menu) {
|
157
|
$menu_names[$menu] = isset($menus[$menu]) ? $menus[$menu] : t('Other menu: %menu', array('%menu' => $menu));
|
158
|
}
|
159
|
|
160
|
return $menu_names;
|
161
|
}
|
162
|
|