/[drupal]/contributions/modules/dhtml_menu/dhtml_menu.admin.inc
ViewVC logotype

Contents of /contributions/modules/dhtml_menu/dhtml_menu.admin.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.19 - (show annotations) (download) (as text)
Sun Oct 25 14:58:28 2009 UTC (4 weeks, 6 days ago) by arancaytar
Branch: MAIN
CVS Tags: DRUPAL-7--1-0-ALPHA4, HEAD
Branch point for: DRUPAL-6--4
Changes since 1.18: +8 -7 lines
File MIME type: text/x-php
#473356: Big string update, adding new help strings and an explanatory installation message too.
1 <?php
2 // $Id: dhtml_menu.admin.inc,v 1.18 2009/10/25 14:36:43 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_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(100 => 'Very Fast (0.1s)', 500 => 'Fast (0.5s)', 1000 => 'Medium (1s)', 1500 => 'Slow (1.5s)', 2000 => 'Very Slow (2s)'),
54 '#default_value' => $settings['animation']['speed'],
55 '#description' => t('Choose how quickly the menus should expand and collapse.'),
56 );
57
58 $options['effects'] = array(
59 '#type' => 'fieldset',
60 '#title' => t('Other effects'),
61 '#collapsible' => TRUE,
62 '#collapsed' => TRUE,
63 );
64
65 $options['effects']['siblings'] = array(
66 '#type' => 'radios',
67 '#title' => t('When a menu opens'),
68 '#options' => array(
69 'none' => t('Keep other menus open.'),
70 'close-all' => t('Close all other open menus on the page.'),
71 'close-same-tree' => t('Close other open menus in the same tree.'),
72 ),
73 '#default_value' => $settings['effects']['siblings'],
74 );
75
76 $options['effects']['children'] = array(
77 '#type' => 'radios',
78 '#title' => t('When a menu closes'),
79 '#options' => array(
80 'none' => t('Remember which sub-items were expanded when it next opens.'),
81 'close-children' => t('Close all its sub-items, too.'),
82 ),
83 '#default_value' => $settings['effects']['children'],
84 );
85
86 $options['effects']['remember'] = array(
87 '#type' => 'radios',
88 '#title' => t('When a new page is loaded'),
89 '#options' => array(
90 'remember' => t('Remember which items were expanded on the last page.'),
91 0 => t('Expand only the currently active path.'),
92 ),
93 '#default_value' => $settings['effects']['remember'],
94 );
95
96 $options['filter'] = array(
97 '#type' => 'fieldset',
98 '#title' => t('Disabling DHTML'),
99 '#collapsible' => TRUE,
100 '#collapsed' => TRUE,
101 );
102
103 $options['filter']['type'] = array(
104 '#type' => 'radios',
105 '#title' => t('Filter type'),
106 '#options' => array(
107 'blacklist' => t('Disable DHTML on the menus checked below.'),
108 'whitelist' => t('Enable DHTML on the menus checked below.'),
109 ),
110 '#default_value' => $settings['filter']['type'],
111 );
112
113 $options['filter']['list'] = array(
114 '#type' => 'checkboxes',
115 '#title' => t('List'),
116 '#options' => _dhtml_menu_menus(),
117 '#default_value' => $settings['filter']['list'],
118 '#description' => t('DHTML will be used for all menus by default, but can be switched off for specific menus.'),
119 );
120
121 $options['#tree'] = TRUE;
122 $form['dhtml_menu_settings'] = $options;
123
124 // Disable automatic defaults, which don't work with nested values.
125 return system_settings_form($form, FALSE);
126 }
127
128 /**
129 * Build a human-readable option list for all non-empty menus.
130 * Custom menus and book menus are included if the respective modules are enabled.
131 */
132 function _dhtml_menu_menus() {
133 if (function_exists('menu_get_menus')) {
134 // If the menu module is enabled, list custom menus.
135 $menus = menu_get_menus();
136 }
137 else {
138 // Otherwise, list only system menus.
139 $menus = menu_list_system_menus();
140 }
141
142 // If the book module is enabled, also include book menus.
143 if (function_exists('book_get_books')) {
144 foreach (book_get_books() as $bid => $link) {
145 $menus["book-toc-$bid"] = t('Book: %title', array('%title' => $link['title']));
146 }
147 }
148
149 // @TODO: Critical core bug #473240 does not let us call menu_get_names();
150 return $menus;
151
152 // menu_get_names() filters out empty menus, and adds any menus not found using the above calls (edge case).
153 foreach (menu_get_names() as $menu) {
154 $opts[$menu] = isset($menus[$menu]) ? $menus[$menu] : t('Other menu: %menu', array('%menu' => $menu));
155 }
156
157 return $opts;
158 }
159

  ViewVC Help
Powered by ViewVC 1.1.2