function themekey_validator_day_of_week in ThemeKey 7.3
Same name and namespace in other branches
- 7 themekey_validators.inc \themekey_validator_day_of_week()
- 7.2 themekey_validators.inc \themekey_validator_day_of_week()
Validates a Theme Switching Rule. Allowed Operators: "=", "!" Allowed values:
- a three letter day String if operator is "=" or "!"
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.
1 string reference to 'themekey_validator_day_of_week'
- themekey_system_themekey_properties in modules/
themekey.system.inc - Implements hook_themekey_properties().
File
- ./
themekey_validators.inc, line 809 - Provides set of validators which can be used to validate ThemeKey Theme Switching Rules.
Code
function themekey_validator_day_of_week($rule) {
static $days_of_week = array(
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat',
'Sun',
);
$errors = array();
switch ($rule['operator']) {
case '=':
case '!':
if (!in_array($rule['value'], $days_of_week)) {
$errors['value'] = t('The day %value is not valid. Possible days are "%days".', array(
'%value' => $rule['value'],
'%days' => implode('", "', $days_of_week),
));
}
break;
default:
$errors['operator'] = t('Possible operators are "=" and "!"');
break;
}
return $errors;
}