variable_mobile.module in Variable Extra 7
Internationalization (i18n) package. Multilingual variables API.
File
variable_mobile/variable_mobile.moduleView source
<?php
/**
* @file
* Internationalization (i18n) package. Multilingual variables API.
*/
/**
* Implements hook_boot()
*/
function variable_mobile_boot() {
module_invoke('variable_realm', 'initialize', 'mobile');
}
/**
* Implements hook_variable_realm_info().
*/
function variable_mobile_variable_realm_info() {
$realm['mobile'] = array(
'title' => t('Mobile'),
'weight' => 200,
'controller class' => 'VariableMobileRealmController',
'store class' => 'VariableStoreRealmStore',
// Variables for this realm can be selected from a list.
'select' => TRUE,
'select path' => 'admin/config/system/browscap/variable',
// Name for variables that belong to this realm: 'multilingual' variable/s
'variable name' => t('mobile switch'),
'variable class' => 'mobile-variable',
// Automatically handle these variables in system settings forms.
'form settings' => FALSE,
'form switcher' => TRUE,
'default key' => 'standard',
);
return $realm;
}
/**
* Get current realm key for mobile variable.
*/
function variable_mobile_current_realm() {
return variable_mobile_check_browser() ? 'mobile' : 'standard';
}
/**
* Check whether we are on a mobile device.
*
* Bootstrap safe: Load browscap module if not loaded.
*/
function variable_mobile_check_browser() {
static $mobile;
if (!isset($mobile)) {
if (!function_exists('browscap_get_browser')) {
drupal_load('module', 'browscap');
}
$browser = browscap_get_browser(NULL);
$mobile = !empty($browser['ismobiledevice']);
}
return $mobile;
}
Functions
Name![]() |
Description |
---|---|
variable_mobile_boot | Implements hook_boot() |
variable_mobile_check_browser | Check whether we are on a mobile device. |
variable_mobile_current_realm | Get current realm key for mobile variable. |
variable_mobile_variable_realm_info | Implements hook_variable_realm_info(). |