You are here

function expire_get_base_urls in Cache Expiration 6

Same name and namespace in other branches
  1. 7 expire.domain.inc \expire_get_base_urls()

Get all base url's where this node can appear. Domain access support.

Parameters

$node: node object

Return value

array array(0 => array($base_url . '/'))

1 call to expire_get_base_urls()
expire_cache_derivative in ./expire.module
Finds all possible paths/redirects/aliases given the root path.

File

./expire.module, line 532
Provides logic for page cache expiration

Code

function expire_get_base_urls(&$node) {
  global $base_url, $base_path;

  // Get list of URL's if using domain access
  $base_urls = array();
  $domains = array();
  if (module_exists('domain') && isset($node->domains)) {

    // Get domains from node/user object
    foreach ($node->domains as $key => $domain_id) {
      if ($key != $domain_id) {
        continue;
      }
      $domains[$domain_id] = $domain_id;
    }

    // Get domains from database
    foreach (expire_get_domains($node) as $domain_id) {
      $domains[$domain_id] = $domain_id;
    }

    // Get aliases and set base url
    foreach ($domains as $domain_id) {
      $domain = domain_lookup($domain_id);
      if ($domain['valid'] == 1) {
        if (isset($domain['path'])) {
          $base_urls[$domain_id][] = $domain['path'];
        }
        if (is_array($domain['aliases'])) {
          foreach ($domain['aliases'] as $alias) {
            if ($alias['redirect'] != 1) {
              $temp_domain = array(
                'scheme' => $domain['scheme'],
                'subdomain' => $alias['pattern'],
              );
              $base_urls[$domain_id][] = domain_get_path($temp_domain);
            }
          }
        }
      }
    }
  }
  else {
    $base_urls[0][] = $base_url . '/';
  }
  return $base_urls;
}