function themekey_validator_regex in ThemeKey 7
Same name and namespace in other branches
- 6.4 themekey_validators.inc \themekey_validator_regex()
- 6.2 themekey_validators.inc \themekey_validator_regex()
- 6.3 themekey_validators.inc \themekey_validator_regex()
- 7.3 themekey_validators.inc \themekey_validator_regex()
- 7.2 themekey_validators.inc \themekey_validator_regex()
Validates a Theme Switching Rule. Allowed Operators: "~" Allowed values: valid regular expression
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.
See also
http://php.net/manual/en/pcre.pattern.php
9 calls to themekey_validator_regex()
- themekey_rule_chain_form_validate in ./
themekey_admin.inc - Validation of
- themekey_validator_date in ./
themekey_validators.inc - Validates a Theme Switching Rule. Allowed Operators: any Allowed values:
- themekey_validator_date_time in ./
themekey_validators.inc - Validates a Theme Switching Rule. Allowed Operators: "<", "<=", ">", ">=" and "~" Allowed values:
- themekey_validator_http_host in ./
themekey_validators.inc - Validates a Theme Switching Rule. Allowed Operators: any Allowed values:
- themekey_validator_ip_address in ./
themekey_validators.inc - Validates a Theme Switching Rule. Allowed Operators: any Allowed values:
File
- ./
themekey_validators.inc, line 580 - Non-displayable characters.
Code
function themekey_validator_regex($rule) {
$errors = array();
switch ($rule['operator']) {
case '~':
case '!~':
if (FALSE === @preg_match($rule['value'], 'dummy')) {
$errors['value'] = t('Regular expression seems to be malformed. See !link for details', array(
'!link' => l(t('PHP Manual'), 'http://php.net/manual/en/pcre.pattern.php'),
));
}
break;
default:
$errors['operator'] = t('The only possible operators are "~" and "!~"');
break;
}
return $errors;
}