function admin_theme_menu in Administration theme 5
Implementation of hook_init().
File
- ./
admin_theme.module, line 117 - Enable the administration theme on more pages then possible with Drupal's default administration page.
Code
function admin_theme_menu($may_cache) {
if (!$may_cache) {
$admin_theme_disallow = FALSE;
$admin_theme = FALSE;
// check if some paths are disallow to get the theme
if (trim(variable_get('admin_theme_path_disallow', '')) != '') {
// pages that are defined by their normal path
$admin_theme_disallow = _admin_theme_drupal_match_path($_GET['q'], variable_get('admin_theme_path_disallow', ''));
// pages that are defined with their alias
$alias = drupal_get_path_alias($_GET['q']);
if ($alias != $_GET['q']) {
$admin_theme_disallow = $admin_theme || _admin_theme_drupal_match_path($alias, variable_get('admin_theme_path_disallow', ''));
}
}
// we should not show the admin theme if the user has no access or the path is in the disallow list
if (!user_access('access admin theme') || $admin_theme_disallow) {
global $custom_theme;
unset($_GLOBALS['custom_theme']);
return;
}
// check if an option is enabled and if it results to TRUE
$list = admin_theme_list();
foreach ($list as $info) {
$var = admin_theme_variable_name($info['module'], $info['option']);
if ((bool) variable_get($var, '0') && module_invoke($info['module'], 'admin_theme_options', 'check', $info['option'])) {
$admin_theme = TRUE;
}
}
// some custom defined pages should get admin theme
if (trim(variable_get('admin_theme_path', '')) != '') {
// pages that are defined by their normal path
$admin_theme = $admin_theme || _admin_theme_drupal_match_path($_GET['q'], variable_get('admin_theme_path', ''));
// pages that are defined with their alias
$alias = drupal_get_path_alias($_GET['q']);
if ($alias != $_GET['q']) {
$admin_theme = $admin_theme || _admin_theme_drupal_match_path($alias, variable_get('admin_theme_path', ''));
}
}
// Use the admin theme for the current request (if global admin theme setting is checked).
if ($admin_theme) {
global $custom_theme;
$custom_theme = variable_get('admin_theme', '0');
drupal_add_css(drupal_get_path('module', 'system') . '/admin.css', 'module');
}
}
}