You are here

function themekey_match_path in ThemeKey 7

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

Detects if a ThemeKey rule for property drupal:path matches to the current page request.

Parameters

$condition: ThemeKey rule as object:

  • property (must be "drupal:path")
  • operator
  • value

$parameters: reference to an array containing all ThemeKey properties and their values

Return value

boolean

1 call to themekey_match_path()
themekey_match_condition in ./themekey_base.inc
Detects if a ThemeKey rule matches to the current page request.

File

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

Code

function themekey_match_path($condition, &$parameters) {
  static $alias_uri = '';
  if ('drupal:path' != $condition->property) {
    return FALSE;
  }
  $get_q = $get_q_to_split = themekey_get_q();
  if (!variable_get('themekey_path_case_sensitive', 0)) {
    $condition->value = drupal_strtolower($condition->value);
    $get_q_to_split = drupal_strtolower($get_q_to_split);
  }
  $condition_parts = explode('/', $condition->value);
  $get_q_parts = explode('/', $get_q_to_split);
  $wildcards = themekey_match_path_parts($get_q_parts, $condition_parts);
  if (FALSE === $wildcards && module_exists('path')) {
    if (empty($alias_uri)) {

      // Derive path from request_uri
      $offset = (variable_get('clean_url', 0) ? 0 : 3) + drupal_strlen(base_path());
      $alias_uri = drupal_substr(request_uri(), $offset);
      if (strpos($alias_uri, '?') !== FALSE) {

        // Remove query string from request uri
        $alias_uri_parts = explode('?', $alias_uri);
        $alias_uri = $alias_uri_parts[0];
      }

      // For $alias_uri != $_GET['q'] the page was requested using an
      // aliased path, otherwise get the path alias internally
      if ($alias_uri == $get_q) {
        $alias_uri = drupal_get_path_alias($get_q);
      }
    }
    if ($alias_uri != $get_q) {
      $alias_parts = explode('/', $alias_uri);
      $wildcards = themekey_match_path_parts($alias_parts, $condition_parts);
    }
  }
  if (is_array($wildcards)) {
    $parameters['internal:temp_wildcards'] = $wildcards;
    return TRUE;
  }
  $parameters['internal:temp_wildcards'] = array();
  return FALSE;
}