You are here

function mobile_tools_switch_theme in Mobile Tools 6.3

Same name and namespace in other branches
  1. 6 mobile_tools.module \mobile_tools_switch_theme()
  2. 6.2 mobile_tools.module \mobile_tools_switch_theme()

Being called in the hook_boot() implementation This function is in charge of changing to the mobile theme

1 call to mobile_tools_switch_theme()
mobile_tools_boot in ./mobile_tools.module
Implementation of hook_boot(). Redirecting if needed

File

./mobile_tools.module, line 315
Mobile Tools provides a range of functionality assisting in creating a mobile Drupal site . this functionality contains:

Code

function mobile_tools_switch_theme($device) {
  global $custom_theme, $conf;

  // check if theme switching is forced
  $current_url_type = mobile_tools_site_type();
  if ($current_url_type == 'mobile' && variable_get('mobile-tools-theme-switch', '') == 'mobile-tools-mobile-url' || variable_get('mobile-tools-theme-switch', '') == 'mobile-tools-mobile-device' && $device['type'] == 'mobile') {
    $group = $device['group'];
    $mobile_detection_module = variable_get('mobile-tools-device-detection', 'mobile_tools');
    if (variable_get($mobile_detection_module . '_' . $group . '_enable', '') == 1) {
      $custom_theme = variable_get($mobile_detection_module . '_' . $group . '_theme', $conf['theme_default']);
      return TRUE;
    }
    else {
      $custom_theme = variable_get('mobile_tools_theme_name', $conf['theme_default']);
      return TRUE;
    }
  }
  elseif (!empty($device['group'])) {

    //device groups are independent of device types

    // Allow custom themes for 'desktop' device types
    $group = $device['group'];
    $mobile_detection_module = variable_get('mobile-tools-device-detection', 'mobile_tools');
    if (variable_get($mobile_detection_module . '_' . $group . '_enable', '') == 1) {
      $custom_theme = variable_get($mobile_detection_module . '_' . $group . '_theme', $conf['theme_default']);
      return $custom_theme;
    }
  }
  return FALSE;
}