View source
<?php
require_once drupal_get_path('module', 'themekey') . '/themekey_base.inc';
function themekey_theme() {
return array(
'themekey_table' => array(
'arguments' => array(
'form' => NULL,
),
),
);
}
function themekey_perm() {
return array(
'administer theme assignments',
'administer themekey settings',
);
}
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_paths_form',
),
);
$items['admin/settings/themekey/paths'] = array(
'title' => 'Paths',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 0,
);
$items['admin/settings/themekey/properties'] = array(
'title' => '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',
),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
);
$items['admin/settings/themekey/settings'] = array(
'title' => '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' => 'General',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 0,
);
return $items;
}
function themekey_themekey_properties() {
require_once drupal_get_path('module', 'themekey') . '/themekey_build.inc';
return _themekey_invoke_modules('themekey_properties');
}
function themekey_themekey_global() {
require_once drupal_get_path('module', 'themekey') . '/themekey_build.inc';
return _themekey_invoke_modules('themekey_global');
}
function themekey_themekey_paths() {
require_once drupal_get_path('module', 'themekey') . '/themekey_build.inc';
return _themekey_invoke_modules('themekey_paths');
}
function themekey_init() {
global $custom_theme;
$theme = NULL;
$theme = _themekey_match_paths($_GET['q']);
if (!$theme) {
$offset = (variable_get('clean_url', 0) ? 0 : 3) + strlen(base_path());
$alias_uri = substr(request_uri(), $offset);
if ($alias_uri == $_GET['q'] && module_exists('path')) {
$alias_uri = drupal_get_path_alias($_GET['q']);
}
$theme = _themekey_match_paths($alias_uri);
}
if (!$theme && isset($_SESSION['themekey_theme']) && (!$custom_theme || $custom_theme == variable_get('theme_default', 'bluemarine'))) {
$custom_theme = $_SESSION['themekey_theme'];
}
if ($theme && $theme != 'default') {
if (variable_get('themekey_theme_maintain', 0)) {
$_SESSION['themekey_theme'] = $theme;
}
$custom_theme = $theme;
init_theme();
}
}