function themekey_mobile_detect_api_themekey_properties_helper in ThemeKey 7.3
Re-usable helper function to create the mobile_detect:is... properties.
Parameters
$mobile_detect: a mobile detect instance
Return value
array of themekey properties and mapping functions
2 calls to themekey_mobile_detect_api_themekey_properties_helper()
- themekey_mobile_detect_api_themekey_properties in modules/
themekey.mobile_detect_api.inc - Implements hook_themekey_properties().
- themekey_mobile_detect_themekey_properties in modules/
themekey.mobile_detect.inc - Implements hook_themekey_properties().
File
- modules/
themekey.mobile_detect_api.inc, line 37 - Provides mobile_detect rules as ThemeKey properties.
Code
function themekey_mobile_detect_api_themekey_properties_helper($mobile_detect) {
// Attributes of properties
$attributes = array();
// Mapping functions
$maps = array();
$rules = array_merge(array_keys($mobile_detect
->getRules()), array(
'Mobile',
'Tablet',
));
foreach ($rules as $rule) {
$property = 'mobile_detect:is' . $rule;
$attributes[$property] = array(
'description' => t("Mobile Detect: @rule - 'true' or 'false'", array(
'@rule' => $rule,
)),
'validator' => 'themekey_validator_string_boolean',
'page cache' => THEMEKEY_PAGECACHE_UNSUPPORTED,
);
$maps[] = array(
'src' => 'system:dummy',
'dst' => $property,
'callback' => 'themekey_mobile_detect_api_dummy2rule',
'args' => array(
'method' => 'is' . $rule,
),
);
}
return array(
'attributes' => $attributes,
'maps' => $maps,
);
}