You are here

function domain_get_path in Domain Access 7.3

Same name and namespace in other branches
  1. 5 domain.module \domain_get_path()
  2. 6.2 domain.module \domain_get_path()
  3. 7.2 domain.module \domain_get_path()

Determine an absolute path for a domain

Parameters

$domain: The currently active $domain array, provided by domain_lookup().

Return value

The base url of the requested domain.

8 calls to domain_get_path()
DomainTokenTest::testDomainTokens in tests/domain.test
Test the domain tokens.
domain_check_response in ./domain.module
Checks to see if the webserver returns a valid response for a request to a domain.
domain_content_list in domain_content/domain_content.admin.inc
List the available domains for this user.
domain_domain_load in ./domain.module
Implements hook_domain_load().
domain_overview_form_submit in ./domain.admin.inc
Submit handler for the domain overview form.

... See full list

1 string reference to 'domain_get_path'
domain_nav_render in domain_nav/domain_nav.module
Renders output for the block.

File

./domain.module, line 1623
Core module functions for the Domain Access suite.

Code

function domain_get_path($domain) {
  global $base_url;
  if (empty($base_url)) {
    return domain_check_scheme($domain['scheme']) . '://' . $domain['subdomain'];
  }

  // Badly malfored HTTP_HOST values can cause problems with PHP < 5.3.3,
  // so we have to suppress error warnings for parse_url here.
  // See php.net/manual/en/function.parse-url.php.
  // See http://drupal.org/node/848856.
  // With PHP > 5.1.2 we can pass a component parameter, too, but Drupal 6
  // still supports PHP 4 and this code was originally tested there.
  $url = array();
  if ($_url = @parse_url($base_url)) {
    $url = $_url;
  }

  // PHP 5 does not return an empty path element.
  if (!isset($url['path'])) {
    $url['path'] = '/';
  }

  // We need a trailing slash at the end of the path
  if (substr($url['path'], -1) != '/') {
    $url['path'] .= '/';
  }
  $path = domain_check_scheme($domain['scheme']) . '://' . $domain['subdomain'] . $url['path'];
  return $path;
}