You are here

function mobile_switch_handler_filter_check_theme_switch in Mobile Switch 7.2

Check theme cookie exists or a theme switch action by visitor.

This check is necessary to ensure a logical functionality when using the Mobile Switch Block module.

Return value

boolean|string Possible string values: standard, mobile

1 call to mobile_switch_handler_filter_check_theme_switch()
mobile_switch_handler_filter::query in views/mobile_switch_handler_filter.inc
Add this filter to the query.

File

views/mobile_switch_handler_filter.inc, line 105
mobile_switch_handler_filter_ismobile.inc

Code

function mobile_switch_handler_filter_check_theme_switch() {
  static $theme_switch;
  if (!$theme_switch) {
    $name = 'mobile_switch_mode';
    $theme_cookie = isset($_COOKIE[$name]) ? $_COOKIE[$name] : FALSE;

    // Theme switch from URL as visitor action.
    if (isset($_GET['mobile_switch'])) {
      switch ($_GET['mobile_switch']) {
        case 'standard':
          $theme_switch = 'standard';
          break;
        case 'standard-rm':
          $theme_switch = 'standard-rm';
          break;
        case 'mobile':
          $theme_switch = 'mobile';
          break;
        case 'mobile-rm':
          $theme_switch = 'mobile-rm';
          break;
      }
    }
    elseif ($theme_cookie) {
      switch ($theme_cookie) {
        case 'standard':
          $theme_switch = 'standard';
          break;
        case 'standard-rm':
          $theme_switch = 'standard-rm';
          break;
        case 'mobile':
          $theme_switch = 'mobile';
          break;
        case 'mobile-rm':
          $theme_switch = 'mobile-rm';
          break;
      }
    }
    else {
      $theme_switch = FALSE;
    }
  }
  return $theme_switch;
}