You are here

function themekey_match_path_parts in ThemeKey 7.3

Same name and namespace in other branches
  1. 6.4 themekey_base.inc \themekey_match_path_parts()
  2. 6.2 themekey_base.inc \themekey_match_path_parts()
  3. 6.3 themekey_base.inc \themekey_match_path_parts()
  4. 7 themekey_base.inc \themekey_match_path_parts()
  5. 7.2 themekey_base.inc \themekey_match_path_parts()

Compares if two paths are identical accepting wildcards "%" and "#".

Parameters

$path_parts: array containing single parts of a path

$condition_parts: array containing single parts of a path whereas a part could be a wildcard

Return value

FALSE if paths doesn't match or array containing the wildcards if paths matched

1 call to themekey_match_path_parts()
themekey_match_path in ./themekey_base.inc
Detects if a ThemeKey rule for property drupal:path matches to the current page request.

File

./themekey_base.inc, line 177
The functions in this file are the back end of ThemeKey.

Code

function themekey_match_path_parts($path_parts, $condition_parts) {
  if (count($path_parts) < count($condition_parts)) {
    return FALSE;
  }
  $wildcards = array();
  foreach ($condition_parts as $key => $part) {
    if ('#' == $part) {
      if (ctype_digit($path_parts[$key])) {
        $wildcards[$key] = $path_parts[$key];
        continue;
      }
      return FALSE;
    }
    if ('%' == $part) {
      if (isset($path_parts[$key])) {
        $wildcards[$key] = $path_parts[$key];
        continue;
      }
      return FALSE;
    }
    if (!variable_get('themekey_path_case_sensitive', 0)) {
      $part = drupal_strtolower($part);
      $path_parts[$key] = drupal_strtolower($path_parts[$key]);
    }
    if ($part == $path_parts[$key] || $part == urldecode($path_parts[$key]) || $part == rawurldecode($path_parts[$key])) {
      continue;
    }
    return FALSE;
  }
  return $wildcards;
}