You are here

function themekey_validator_regex in ThemeKey 6.2

Same name and namespace in other branches
  1. 6.4 themekey_validators.inc \themekey_validator_regex()
  2. 6.3 themekey_validators.inc \themekey_validator_regex()
  3. 7.3 themekey_validators.inc \themekey_validator_regex()
  4. 7 themekey_validators.inc \themekey_validator_regex()
  5. 7.2 themekey_validators.inc \themekey_validator_regex()

Validates a Theme Switichng Rule. Allowed Operators: "~" Allowed values: valid regular expression

Parameters

$rule: A Theme Switching Rule as associative array:

  • property: ThemeKey property as string (p.e. "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

6 calls to themekey_validator_regex()
themekey_validator_date in ./themekey_validators.inc
Validates a Theme Switichng Rule. Allowed Operators: any Allowed values:
themekey_validator_date_time in ./themekey_validators.inc
Validates a Theme Switichng Rule. Allowed Operators: "<", "<=", ">", ">=" and "~" Allowed values:
themekey_validator_http_host in ./themekey_validators.inc
Validates a Theme Switichng Rule. Allowed Operators: any Allowed values:
themekey_validator_language in ./themekey_validators.inc
Validates a Theme Switichng Rule. Allowed Operators: any Allowed values:
themekey_validator_node_type in ./themekey_validators.inc
Validates a Theme Switichng Rule. Allowed Operators: any Allowed values:

... See full list

File

./themekey_validators.inc, line 551
Provides set of validators which could be used to validate ThemeKey Theme Switching Rules.

Code

function themekey_validator_regex($rule) {
  $errors = array();
  switch ($rule['operator']) {
    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('Only possible operators is "~"');
      break;
  }
  return $errors;
}