function themekey_browscap_themekey_global in ThemeKey 7.3
Implements hook_themekey_global().
File
- modules/
themekey.browscap.inc, line 111 - Provides some browsecap attributes as ThemeKey properties.
Code
function themekey_browscap_themekey_global() {
$browser = browscap_get_browser();
$parameters = array();
$parameters['browscap:comment'] = array_key_exists('comment', $browser) ? $browser['comment'] : NULL;
$parameters['browscap:browser'] = array_key_exists('browser', $browser) ? $browser['browser'] : NULL;
$parameters['browscap:version'] = array_key_exists('version', $browser) ? $browser['version'] : NULL;
$parameters['browscap:majorver'] = array_key_exists('majorver', $browser) ? $browser['majorver'] : NULL;
$parameters['browscap:minorver'] = array_key_exists('minorver', $browser) ? $browser['minorver'] : NULL;
$parameters['browscap:platform'] = array_key_exists('platform', $browser) ? $browser['platform'] : NULL;
$parameters['browscap:platform_version'] = array_key_exists('platform_version', $browser) ? $browser['platform_version'] : NULL;
$parameters['browscap:ismobiledevice'] = array_key_exists('ismobiledevice', $browser) ? $browser['ismobiledevice'] : NULL;
$parameters['browscap:istablet'] = array_key_exists('istablet', $browser) ? $browser['istablet'] : NULL;
$parameters['browscap:issyndicationreader'] = array_key_exists('issyndicationreader', $browser) ? $browser['issyndicationreader'] : NULL;
$parameters['browscap:crawler'] = array_key_exists('crawler', $browser) ? $browser['crawler'] : NULL;
$parameters['browscap:cssversion'] = array_key_exists('cssversion', $browser) ? $browser['cssversion'] : NULL;
$parameters['browscap:parent'] = array_key_exists('parent', $browser) ? $browser['parent'] : NULL;
$parameters['browscap:useragent'] = array_key_exists('useragent', $browser) ? $browser['useragent'] : NULL;
$parameters['browscap:browser_name_pattern'] = array_key_exists('browser_name_pattern', $browser) ? $browser['browser_name_pattern'] : NULL;
foreach ($parameters as $key => $value) {
if (strpos($key, 'browscap:is') === 0 && is_numeric($value)) {
// In some setups browsecap returns integers instead of strings. We have
// to convert them back to strings to keep rules exportable.
// See https://drupal.org/node/2118987
$parameters[$key] = $value ? 'true' : 'false';
}
}
return $parameters;
}