You are here

function cdn_get_blacklist in CDN 6.2

Same name and namespace in other branches
  1. 7.2 cdn.module \cdn_get_blacklist()

See if any installed modules need to exclude certain files from being accessed from the CDN. List gets updated on cron runs.

Typically, files that are loaded by JS through AJAX violate the same origin policy browsers have to comply with. Hence the browser refuses to load the file, causing a broken website. This blacklist allows module developers to specify which files should not be loaded from the CDN.

Parameters

$reset: Whether to force the stored blacklist to be regenerated.

Return value

string Every line is a path pattern (@see drupal_match_path()).

3 calls to cdn_get_blacklist()
cdn_admin_other_settings_form in ./cdn.admin.inc
Form definition; other settings.
cdn_check_file in ./cdn.module
Check if a file should be served from the CDN.
cdn_flush_caches in ./cdn.module
Implementation of hook_flush_caches().

File

./cdn.module, line 636

Code

function cdn_get_blacklist($reset = FALSE) {
  static $blacklist = NULL;
  if (is_null($blacklist) || $reset) {
    $cache = cache_get('cdn_blacklist');
    if (!isset($cache->data) || $reset) {

      // Query modules for a list of files to be included into the blacklist.
      $blacklist = module_invoke_all('cdn_blacklist');

      // Invoke hook_cdn_blacklist_alter.
      drupal_alter('cdn_blacklist', $blacklist);

      // Remove duplicates.
      $blacklist = array_unique($blacklist);

      // Convert array to string.
      $blacklist = implode("\n", $blacklist);

      // Save to the cache.
      cache_set('cdn_blacklist', $blacklist, 'cache', CACHE_TEMPORARY);
    }
    else {
      $blacklist = $cache->data;
    }
  }
  return $blacklist;
}