Révision c304a780
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/adminimal_admin_menu/adminimal_admin_menu.module | ||
---|---|---|
20 | 20 |
); |
21 | 21 |
|
22 | 22 |
return $items; |
23 |
|
|
24 | 23 |
} |
25 | 24 |
|
26 | 25 |
/** |
... | ... | |
31 | 30 |
return; |
32 | 31 |
} |
33 | 32 |
$path = drupal_get_path('module', 'adminimal_admin_menu'); |
34 |
$load_slicknav = variable_get('adminimal_admin_menu_slicknav', TRUE );
|
|
35 |
$load_jQuery = variable_get('adminimal_admin_menu_jquery', TRUE );
|
|
33 |
$load_slicknav = variable_get('adminimal_admin_menu_slicknav', TRUE);
|
|
34 |
$load_jquery = variable_get('adminimal_admin_menu_jquery', TRUE);
|
|
36 | 35 |
|
37 | 36 |
// Attach the CSS and JavaScript assets. |
38 | 37 |
drupal_add_css($path . '/adminimal_admin_menu.css'); |
39 | 38 |
|
40 |
// Support for the Environment Indicator module. |
|
41 |
if (module_exists('environment_indicator')) { |
|
42 |
$environment_info = environment_indicator_get_active(); |
|
43 |
drupal_add_css(' |
|
44 |
div.slicknav_menu a.slicknav_btn:after { |
|
45 |
content: "' . $environment_info['name']. '"; |
|
46 |
margin-left: 1em; |
|
47 |
color: ' . $environment_info['text_color'] . '; |
|
48 |
font-size: 12px; |
|
49 |
background-color: ' . $environment_info['color'] . '; |
|
50 |
padding: 2px 5px; |
|
51 |
} |
|
52 |
#admin-menu-wrapper {background: #222 !important;} |
|
53 |
', |
|
54 |
array( |
|
55 |
'group' => CSS_DEFAULT, |
|
56 |
'type' => 'inline', |
|
57 |
'preprocess' => FALSE, |
|
58 |
'weight' => '100', |
|
59 |
)); |
|
60 |
} |
|
61 |
|
|
62 |
// Check if both slicknav and custom jQuery must be loaded. |
|
63 |
if ($load_slicknav and $load_jQuery) { |
|
64 |
drupal_add_js($path . '/js/jquery.min.js', array( 'type' => 'file', 'scope' => 'header', 'weight' => 888 )); |
|
65 |
drupal_add_js($path . '/js/slicknav/jquery-no-conflict.slicknav.js', array( 'type' => 'file', 'scope' => 'header', 'weight' => 888 )); |
|
66 |
drupal_add_css($path . '/js/slicknav/slicknav.css'); |
|
67 |
} |
|
68 |
elseif ($load_slicknav and !$load_jQuery) { |
|
69 |
drupal_add_js($path . '/js/slicknav/jquery.slicknav.js', array( 'type' => 'file', 'scope' => 'header', 'weight' => 888 )); |
|
70 |
drupal_add_css($path . '/js/slicknav/slicknav.css'); |
|
71 |
} |
|
72 |
|
|
73 |
drupal_add_js($path . '/js/adminimal_admin_menu.js', array( 'type' => 'file', 'scope' => 'header', 'weight' => 888 )); |
|
39 |
_adminimal_admin_menu_support_environment_indicator(); |
|
40 |
|
|
41 |
// Check if both slicknav and custom jQuery must be loaded. |
|
42 |
if ($load_slicknav and $load_jquery) { |
|
43 |
drupal_add_js($path . '/js/jquery.min.js', array( |
|
44 |
'type' => 'file', |
|
45 |
'scope' => 'header', |
|
46 |
'weight' => 888, |
|
47 |
)); |
|
48 |
drupal_add_js($path . '/js/slicknav/jquery-no-conflict.slicknav.js', array( |
|
49 |
'type' => 'file', |
|
50 |
'scope' => 'header', |
|
51 |
'weight' => 888, |
|
52 |
)); |
|
53 |
drupal_add_css($path . '/js/slicknav/slicknav.css'); |
|
54 |
} |
|
55 |
elseif ($load_slicknav and !$load_jquery) { |
|
56 |
drupal_add_js($path . '/js/slicknav/jquery.slicknav.js', array( |
|
57 |
'type' => 'file', |
|
58 |
'scope' => 'header', |
|
59 |
'weight' => 888, |
|
60 |
)); |
|
61 |
drupal_add_css($path . '/js/slicknav/slicknav.css'); |
|
62 |
} |
|
63 |
|
|
64 |
drupal_add_js($path . '/js/adminimal_admin_menu.js', array( |
|
65 |
'type' => 'file', |
|
66 |
'scope' => 'header', |
|
67 |
'weight' => 888, |
|
68 |
)); |
|
74 | 69 |
|
75 | 70 |
if (!isset($page['page_bottom']['admin_menu'])) { |
76 | 71 |
return; |
... | ... | |
99 | 94 |
'data' => array('admin_menu' => array('toolbar' => $settings)), |
100 | 95 |
'type' => 'setting', |
101 | 96 |
); |
97 |
} |
|
98 |
|
|
99 |
/** |
|
100 |
* Add CSS for module environment_indicator. |
|
101 |
*/ |
|
102 |
function _adminimal_admin_menu_support_environment_indicator() { |
|
103 |
if (!module_exists('environment_indicator')) { |
|
104 |
return; |
|
105 |
} |
|
106 |
|
|
107 |
$environment_info = environment_indicator_get_active(); |
|
102 | 108 |
|
109 |
if (!environment_indicator_check_access($environment_info)) { |
|
110 |
return; |
|
111 |
} |
|
112 |
|
|
113 |
drupal_add_css(' |
|
114 |
div.slicknav_menu a.slicknav_btn:after { |
|
115 |
content: "' . $environment_info['name'] . '"; |
|
116 |
margin-left: 1em; |
|
117 |
color: ' . $environment_info['text_color'] . '; |
|
118 |
font-size: 12px; |
|
119 |
background-color: ' . $environment_info['color'] . '; |
|
120 |
padding: 2px 5px; |
|
121 |
} |
|
122 |
#admin-menu-wrapper {background: #222 !important;} |
|
123 |
', |
|
124 |
array( |
|
125 |
'group' => CSS_DEFAULT, |
|
126 |
'type' => 'inline', |
|
127 |
'preprocess' => FALSE, |
|
128 |
'weight' => '100', |
|
129 |
)); |
|
103 | 130 |
} |
104 | 131 |
|
105 | 132 |
/** |
... | ... | |
140 | 167 |
unset($content['icon']['icon']['#theme']); |
141 | 168 |
$content['icon']['icon']['#title'] = '<span class="admin-menu-home-icon"> </span>'; |
142 | 169 |
$content['icon']['icon']['#attributes']['class'][] = 'admin-menu-toolbar-home-menu'; |
170 |
// @todo Fix this CS-issue. |
|
143 | 171 |
$page['#attributes']['class'][] = 'adminimal-menu'; |
144 | 172 |
|
145 | 173 |
// Hide the menu. |
... | ... | |
152 | 180 |
} |
153 | 181 |
} |
154 | 182 |
|
155 |
// Create the responsive menu. |
|
156 |
if (variable_get('adminimal_admin_menu_slicknav', 'TRUE')) { |
|
157 |
// Prepare the responsive menu and Join the Icon menu with the administration menu. |
|
158 |
$responsivemenu = array_merge($content['icon'], $content['menu']); |
|
159 |
|
|
160 |
// Give it ID to target it later with js and css. |
|
161 |
$responsivemenu['#wrapper_attributes']['id'] = 'admin-menu-menu-responsive'; |
|
162 |
|
|
163 |
// Move the icon menu to the top. |
|
164 |
$responsivemenu['icon']['#weight'] = '-100'; |
|
165 |
|
|
166 |
// Change the link title to Administration. |
|
167 |
$responsivemenu['admin/index']['#title'] = t('Administration'); |
|
168 |
|
|
169 |
// Bind the responsive menu the the content varable so it can be rendered. |
|
170 |
$content['responsive-menu'] = $responsivemenu; |
|
171 |
|
|
172 |
// Create the responsive shortucts. |
|
173 |
$content['responsive']['shortcuts'] = array( |
|
174 |
'#prefix' => '<div id="admin-menu-shortcuts-responsive">', |
|
175 |
'#suffix' => '</div>', |
|
176 |
'#pre_render' => array('shortcut_toolbar_pre_render'), |
|
177 |
); |
|
178 |
} |
|
183 |
// Create the responsive menu. |
|
184 |
if (variable_get('adminimal_admin_menu_slicknav', TRUE)) { |
|
185 |
// Join the Icon menu with the administration menu. |
|
186 |
$responsivemenu = array_merge($content['icon'], $content['menu']); |
|
187 |
|
|
188 |
// Give it ID to target it later with js and css. |
|
189 |
$responsivemenu['#wrapper_attributes']['id'] = 'admin-menu-menu-responsive'; |
|
190 |
|
|
191 |
// Move the icon menu to the top. |
|
192 |
$responsivemenu['icon']['#weight'] = '-100'; |
|
193 |
|
|
194 |
// Change the link title for 'admin/index' to Administration if it exists. |
|
195 |
if (!empty($responsivemenu['admin/index'])) { |
|
196 |
$responsivemenu['admin/index']['#title'] = t('Administration'); |
|
197 |
} |
|
198 |
|
|
199 |
// Add the account menu, and push account and logout links toward bottom. |
|
200 |
$responsivemenu = array_merge($content['account'], $responsivemenu); |
|
201 |
$responsivemenu['account']['#weight'] = 99; |
|
202 |
$responsivemenu['logout']['#weight'] = 100; |
|
203 |
|
|
204 |
// Bind the responsive menu the the content varable so it can be rendered. |
|
205 |
$content['responsive-menu'] = $responsivemenu; |
|
206 |
|
|
207 |
// Create the responsive shortucts. |
|
208 |
$content['responsive']['shortcuts'] = array( |
|
209 |
'#prefix' => '<div id="admin-menu-shortcuts-responsive">', |
|
210 |
'#suffix' => '</div>', |
|
211 |
'#pre_render' => array('shortcut_toolbar_pre_render'), |
|
212 |
); |
|
213 |
} |
|
179 | 214 |
} |
180 | 215 |
|
181 | 216 |
/** |
... | ... | |
199 | 234 |
// Add the shortcut render mode class. |
200 | 235 |
$vars['classes_array'][] = 'menu-render-' . variable_get('adminimal_admin_menu_render', 'collapsed'); |
201 | 236 |
|
202 |
// Fix the viewport, correcting the mobile device zoom. |
|
203 |
/** @todo - Mybre remove this and let the theme manage the view pont. |
|
204 |
* But i was suprised that only few "responsive" drupal themes were fixing |
|
205 |
* the viewport. |
|
237 |
/* |
|
238 |
* Fix the viewport, correcting the mobile device zoom. |
|
239 |
* |
|
240 |
* @todo Maybe remove this and let the theme manage the view point. |
|
241 |
* But i was suprised that only few "responsive" drupal themes were fixing |
|
242 |
* the viewport. |
|
206 | 243 |
*/ |
207 | 244 |
$viewport = array( |
208 |
'#tag' => 'meta', |
|
209 |
'#attributes' => array( |
|
210 |
'name' => 'viewport', |
|
211 |
'content' => 'width=device-width, initial-scale=1, maximum-scale=1', |
|
212 |
), |
|
245 |
'#tag' => 'meta',
|
|
246 |
'#attributes' => array(
|
|
247 |
'name' => 'viewport',
|
|
248 |
'content' => 'width=device-width, initial-scale=1, maximum-scale=1',
|
|
249 |
),
|
|
213 | 250 |
); |
214 | 251 |
drupal_add_html_head($viewport, 'viewport'); |
215 | 252 |
|
... | ... | |
217 | 254 |
|
218 | 255 |
/** |
219 | 256 |
* Check if the user has access to use the admin menu. |
220 |
* @return boolean Result of access checks. |
|
257 |
* |
|
258 |
* @return bool |
|
259 |
* Result of access checks. |
|
221 | 260 |
*/ |
222 | 261 |
function _adminimal_admin_menu_access() { |
223 | 262 |
if (!user_access('access administration menu') || admin_menu_suppress(FALSE)) { |
Formats disponibles : Unified diff
Weekly update of contrib modules