You are here

function query_parameters_to_url_path_should_be_rewritten in Query Parameters To URL 7

Check whether given path should be rewritten.

2 calls to query_parameters_to_url_path_should_be_rewritten()
query_parameters_to_url_url_inbound_alter in ./query_parameters_to_url.module
Implements hook_url_inbound_alter().
query_parameters_to_url_url_outbound_alter in ./query_parameters_to_url.module
Implements hook_url_outbound_alter().

File

./query_parameters_to_url.module, line 139
Query Arguments To URL module.

Code

function query_parameters_to_url_path_should_be_rewritten($path = '', $options = array(), $original_path = NULL, $path_language = NULL) {

  // If the URL is indicated as external, skip it.
  if (!empty($options['external'])) {
    return FALSE;
  }

  // Ignore administration paths.
  if (query_parameters_to_url_ignore_admin_paths() && path_is_admin($path)) {
    return FALSE;
  }

  // Ignore batch URLs.
  if ($path == 'batch') {
    return FALSE;
  }

  // Use the current path as the path to be rewritten.
  if (empty($path)) {
    $path = current_path();
  }

  // Invoke hooks to see if any module allows or denies a rewrite for the given
  // path.
  $additional_paths_hooks_enabled =& drupal_static(__FUNCTION__, query_parameters_to_url_additional_paths_hooks_enabled());
  if ($additional_paths_hooks_enabled) {
    $rewrites = module_invoke_all('query_parameters_to_url_rewrite_access', $path, $options, $original_path, $path_language);
    if (in_array(QUERY_PARAMETERS_TO_URL_REWRITE_DENY, $rewrites, TRUE)) {
      return FALSE;
    }
    elseif (in_array(QUERY_PARAMETERS_TO_URL_REWRITE_ALLOW, $rewrites, TRUE)) {
      return TRUE;
    }
  }

  // Use configured Reg Exp to check if path should be rewritten.
  $pattern = query_parameters_to_url_path_reg_exp();
  $regexp_allow_result = FALSE;
  if (!empty($pattern) && preg_match($pattern, $path, $matches)) {
    $regexp_allow_result = TRUE;
  }
  return $regexp_allow_result;
}