function mobile_switch_boot in Mobile Switch 7
Same name and namespace in other branches
- 6 mobile_switch.module \mobile_switch_boot()
- 7.2 mobile_switch.module \mobile_switch_boot()
Implements hook_boot().
Alter specific entries in the 'variable' table:
- theme_default: If mobile mobile device the value are changed to the configured mobile theme.
Insert new entries in the 'variable' table:
- mobile_switch_ismobiledevice: The default value is FALSE. If the browscap value 'ismobiledevice' are 1 the value is TRUE.
- mobile_switch_ismobiletheme: The default value is FALSE. If used mobile theme the value is TRUE.
- theme_mobile: The default value is FALSE. If used mobile theme the value is the machine name of the used theme.
File
- ./
mobile_switch.module, line 49 - Simple theme switch for mobile devices, detected by browscap.
Code
function mobile_switch_boot() {
global $conf;
// Initialize the new variables here (as fallback) if configured the
// 'Mobile theme' setting with the option 'Do not use'.
$conf['mobile_switch_ismobiledevice'] = FALSE;
$conf['mobile_switch_ismobiletheme'] = FALSE;
$conf['theme_mobile'] = FALSE;
// Preserve the configuration variables.
$conf['mobile_switch_theme_default'] = variable_get('theme_default', 'bartik');
$conf['mobile_switch_theme_mobile'] = variable_get('mobile_switch_mobile_theme', 'none');
// Use the mobile theme on admin pages.
$get['admin'] = (bool) variable_get('mobile_switch_admin_usage', FALSE);
if (defined('MAINTENANCE_MODE') || stristr($_GET['q'], 'admin') && $get['admin'] === FALSE || $conf['mobile_switch_theme_mobile'] == 'none') {
return;
}
$get['deskbrowser'] = (bool) variable_get('mobile_switch_deskbrowser', FALSE);
$get['developer'] = (bool) variable_get('mobile_switch_developer', FALSE);
$get['theme_default'] = $conf['mobile_switch_theme_default'];
$get['browser'] = mobile_switch_browscap_get_browser($get['developer']);
if ((bool) variable_get('mobile_switch_prevent_devices', FALSE) === TRUE) {
if ((bool) $get['browser']['prevent_device'] === TRUE) {
return;
}
}
$get['theme_cookie'] = FALSE;
if ((bool) $get['browser']['ismobiledevice'] === TRUE || (bool) $get['browser']['ismobiledevice'] === FALSE && $get['developer'] === TRUE && $get['deskbrowser'] === TRUE || $get['deskbrowser'] === TRUE) {
$conf['theme_mobile'] = $conf['theme_default'] = $conf['mobile_switch_theme_mobile'];
$conf['mobile_switch_ismobiletheme'] = TRUE;
// Use mobile theme on admin pages.
if (stristr($_GET['q'], 'admin') && $get['admin'] === TRUE) {
$conf['admin_theme'] = '0';
}
}
if ((bool) $get['browser']['ismobiledevice'] === TRUE) {
$conf['mobile_switch_ismobiledevice'] = TRUE;
}
drupal_alter('mobile_switch_boot', $conf, $get);
}