You are here

function _themekey_match_conditions in ThemeKey 6

Function _themekey_match_conditions().

2 calls to _themekey_match_conditions()
_themekey_match_paths in ./themekey_base.inc
Function _themekey_match_paths().
_themekey_match_properties in ./themekey_base.inc
Function _themekey_match_properties().

File

./themekey_base.inc, line 185

Code

function _themekey_match_conditions($conditions, $parameters) {
  if (is_array($conditions) && count($conditions)) {
    foreach ($conditions as $condition) {

      //
      $value = _themekey_property_value($parameters, $condition['property']);
      if (is_array($value)) {

        //
        if (!in_array($condition['value'], $value)) {
          return FALSE;
        }
      }
      else {

        // Default operator is 'equal'
        if (!isset($condition['operator'])) {
          $condition['operator'] = '=';
        }

        // Supported operators for condition check:
        // smaller ('<'), greater ('>'), equal ('='), not equal ('!')
        if ($condition['operator'] == '<' && $value >= $condition['value']) {
          return FALSE;
        }
        else {
          if ($condition['operator'] == '>' && $value <= $condition['value']) {
            return FALSE;
          }
          else {
            if ($condition['operator'] == '=' && $value != $condition['value']) {
              return FALSE;
            }
            else {
              if ($condition['operator'] == '!' && $value == $condition['value']) {
                return FALSE;
              }
            }
          }
        }
      }
    }
  }
  return TRUE;
}