You are here

function mobile_tools_switch_theme in Mobile Tools 6.2

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

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().

File

./mobile_tools.module, line 292
Primarily Drupal hooks.

Code

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

  // check if theme switching is forced
  $current_url_type = mobile_tools_site_type();
  $mobile_detection_module = variable_get('mobile-tools-device-detection', NULL);
  $group = $device['group'];
  if (isset($mobile_detection_module)) {
    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') {
      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
      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;
}