You are here

function themekey_match_path_parts in ThemeKey 6.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. 7.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

2 calls to themekey_match_path_parts()
themekey_get_global_parameters in ./themekey_base.inc
Assigns global parameters' values to ThemeKey properties. Therefore, it calls hook_themekey_global()
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 131
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 ($part == $path_parts[$key] || $part == urldecode($path_parts[$key]) || $part == rawurldecode($path_parts[$key])) {
      continue;
    }
    return FALSE;
  }
  return $wildcards;
}