array( 'file' => 'themekey_admin.inc', 'arguments' => array('form' => NULL), ), ); return $items; } /** * Implementation of hook_perm(). */ function themekey_perm() { return array('administer theme assignments', 'administer themekey settings'); } /** * Implementation of hook_menu(). */ function themekey_menu() { $items = array(); $items['admin/settings/themekey'] = array( 'title' => 'ThemeKey', 'description' => 'Map themes to Drupal paths or object properties.', 'access callback' => 'user_access', 'access arguments' => array('administer theme assignments'), 'file' => 'themekey_admin.inc', 'page callback' => 'drupal_get_form', 'page arguments' => array('themekey_properties_form') ); $items['admin/settings/themekey/properties'] = array( 'title' => t('Theme Switching Rule Chain'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => 0 ); $items['admin/settings/themekey/properties/delete'] = array( 'title' => t('Delete ThemeKey Property'), 'page callback' => 'drupal_get_form', 'page arguments' => array('themekey_admin_delete_property_confirm', 1), 'access callback' => 'user_access', 'access arguments' => array('administer theme assignments'), 'file' => 'themekey_admin.inc', 'type' => MENU_CALLBACK, ); $items['admin/settings/themekey/settings'] = array( 'title' => t('Settings'), 'access callback' => 'user_access', 'access arguments' => array('administer themekey settings'), 'file' => 'themekey_admin.inc', 'page callback' => 'drupal_get_form', 'page arguments' => array('_themekey_settings_form'), 'type' => MENU_LOCAL_TASK, 'weight' => 5 ); $items['admin/settings/themekey/settings/general'] = array( 'title' => t('General'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => 0 ); return $items; } /** * Implementation of hook_themekey_properties(). */ function themekey_themekey_properties() { require_once(drupal_get_path('module', 'themekey') .'/themekey_build.inc'); return _themekey_invoke_modules('themekey_properties'); } /** * Implementation of hook_themekey_global(). */ function themekey_themekey_global() { require_once(drupal_get_path('module', 'themekey') .'/themekey_build.inc'); return _themekey_invoke_modules('themekey_global'); } /** * Implementation of hook_themekey_paths(). */ function themekey_themekey_paths() { require_once(drupal_get_path('module', 'themekey') .'/themekey_build.inc'); return _themekey_invoke_modules('themekey_paths'); } /** * Implementation of hook_init(). */ function themekey_init() { global $custom_theme; // don't change theme when another module already set a $custom_theme like system.module does (administration theme) // don't change theme when administer blocks if (!$custom_theme && strpos($_GET['q'], 'admin/build/block') !== 0) { $theme = _themekey_match_properties(); // If no theme has been triggered but a theme // is in the user's session, use that theme. if (!$theme && !empty($_SESSION['themekey_theme']) && (!$custom_theme || $custom_theme == variable_get('theme_default', 'garland'))) { $custom_theme = $_SESSION['themekey_theme']; } // We have a theme, apply it if (!empty($theme) && $theme != 'default') { if ((user_is_logged_in() && variable_get('themekey_theme_maintain', 0)) || (!user_is_logged_in() && variable_get('themekey_theme_maintain_anonymous', 0))) { $_SESSION['themekey_theme'] = $theme; } else { unset($_SESSION['themekey_theme']); } $custom_theme = $theme; } } }