You are here

function _filefield_paths_replace_path_get_prefixes in File (Field) Paths 7

Helper function; Returns all variations of the file path prefix.

Parameters

$scheme:

bool|FALSE $preg_quote:

bool|FALSE $reset:

Return value

mixed

2 calls to _filefield_paths_replace_path_get_prefixes()
filefield_paths_replace_path_callback in ./filefield_paths.module
Callback for regex string replacement functionality.
_filefield_paths_replace_path in ./filefield_paths.module
Run regular expression over all available text-based fields.

File

./filefield_paths.module, line 484
Contains core functions for the File (Field) Paths module.

Code

function _filefield_paths_replace_path_get_prefixes($scheme, $preg_quote = FALSE, $reset = FALSE) {
  $prefixes =& drupal_static(__FUNCTION__, array());

  // Force clean urls on.
  $clean_url = $GLOBALS['conf']['clean_url'];
  $GLOBALS['conf']['clean_url'] = TRUE;
  $id = $scheme . '::' . (string) $preg_quote;
  if (!isset($prefixes[$id]) || $reset) {
    $prefixes[$id]['uri'] = "{$scheme}://";
    $prefixes[$id]['absolute'] = file_create_url($prefixes[$id]['uri']);
    $prefixes[$id]['relative'] = parse_url($prefixes[$id]['absolute'], PHP_URL_PATH);
    $prefixes[$id]['unclean'] = '?q=' . drupal_substr($prefixes[$id]['relative'], drupal_strlen(base_path()));
    foreach ($prefixes[$id] as $key => $prefix) {
      $prefixes[$id]["{$key}-urlencode"] = urlencode($prefix);
      $prefixes[$id]["{$key}-drupal_encode_path"] = drupal_encode_path($prefix);
    }
    if ($preg_quote) {
      foreach ($prefixes[$id] as $key => $prefix) {
        $prefixes[$id][$key] = preg_quote($prefixes[$id][$key], '/');
      }
    }
  }

  // Restore clean url settings.
  $GLOBALS['conf']['clean_url'] = $clean_url;
  return $prefixes[$id];
}