function themekey_validator_string_boolean in ThemeKey 7.3
Same name and namespace in other branches
- 6.4 themekey_validators.inc \themekey_validator_string_boolean()
- 6.2 themekey_validators.inc \themekey_validator_string_boolean()
- 6.3 themekey_validators.inc \themekey_validator_string_boolean()
- 7 themekey_validators.inc \themekey_validator_string_boolean()
- 7.2 themekey_validators.inc \themekey_validator_string_boolean()
Validates a Theme Switching Rule. Allowed Operators: "=", "!" Allowed values: "true", "false" as string
Parameters
$rule: A Theme Switching Rule as associative array:
- property: ThemeKey property as string (e.g., "drupal:path")
- wildcard: optional string, only used if property is "drupal:path:wildcard"
- operator: ThemeKey operator as string ("=", "!", "*", "!*", "<", "<=", ">", ">=", "~", "!~")
- value: ThemeKey property value as string
Return value
An associative array of errors:
- property: translated error message as string describing a problem with the property
- wildcard: translated error message as string describing a problem with the wildcard
- operator: translated error message as string describing a problem with the operator
- value: translated error message as string describing a problem with the value
If no errors detected the array is empty.
3 string references to 'themekey_validator_string_boolean'
- themekey_browscap_themekey_properties in modules/
themekey.browscap.inc - Implements hook_themekey_properties().
- themekey_mobile_detect_api_themekey_properties_helper in modules/
themekey.mobile_detect_api.inc - Re-usable helper function to create the mobile_detect:is... properties.
- themekey_system_themekey_properties in modules/
themekey.system.inc - Implements hook_themekey_properties().
File
- ./
themekey_validators.inc, line 42 - Provides set of validators which can be used to validate ThemeKey Theme Switching Rules.
Code
function themekey_validator_string_boolean($rule) {
$errors = array();
switch ($rule['operator']) {
case '=':
case '!':
if ('true' !== $rule['value'] && 'false' !== $rule['value']) {
$errors['value'] = t('Possible values are "true" and "false"');
}
break;
default:
$errors['operator'] = t('Possible operators are "=" and "!"');
}
return $errors;
}