You are here

function esi_build_uri in ESI: Edge Side Includes 6.2

1 call to esi_build_uri()
theme_esi_tag in ./esi.theme.inc
Create the ESI-tag for a particular block.

File

./esi.inc, line 224
Helper functions for the ESI module.

Code

function esi_build_uri($path) {
  static $hook_file_url_alter = array();

  // If the current path is an absolute path, return immediately.
  $fragments = parse_url($path);
  if (isset($fragments['host'])) {
    return $path;
  }

  // If Use a CDN for AJAXed fragments is disabled then do not CDN path.
  if (!variable_get('esi_cdn_ajax', ESI_CDN_AJAX)) {
    return url($path);
  }
  $original_path = $path;

  // CDN Support.
  if (module_exists('cdn')) {
    $status = variable_get(CDN_STATUS_VARIABLE, CDN_DISABLED);
    if ($status == CDN_ENABLED || $status == CDN_TESTING && user_access(CDN_PERM_ACCESS_TESTING)) {

      // Alter URL when the file_create_url() patch is not there.
      if (variable_get(CDN_THEME_LAYER_FALLBACK_VARIABLE, FALSE)) {
        cdn_file_url_alter($path);
      }
      else {
        $path = file_create_url($path);
      }

      // Return here if the path was changed above.
      if (strcmp($original_path, $path) != 0) {
        return $path;
      }
    }
  }

  // Other modules besides CDN might want to use hook_file_url_alter.
  if (empty($hook_file_url_alter)) {
    $hook_file_url_alter = module_implements('file_url_alter');
  }
  if (!empty($hook_file_url_alter)) {
    $path = file_create_url($path);

    // Return here if the path was changed above.
    if (strcmp($original_path, $path) != 0) {
      return $path;
    }
  }

  // If nothing was altered then use the drupal default.
  return url($path);
}