You are here

function advagg_process_css_js_prep in Advanced CSS/JS Aggregation 6

Same name and namespace in other branches
  1. 7 advagg.module \advagg_process_css_js_prep()

Returns an array of values needed for aggregation

Parameters

$noagg: (optional) Bool indicating that aggregation should be disabled if TRUE.

$type: (optional) String. js or css.

Return value

array of values to be imported via list() function.

2 calls to advagg_process_css_js_prep()
advagg_process_css in ./advagg.module
Returns a themed representation of all stylesheets that should be attached to the page.
advagg_process_js in ./advagg.module
Returns a themed presentation of all JavaScript code for the current page.

File

./advagg.module, line 1920
Advanced CSS/JS aggregation module

Code

function advagg_process_css_js_prep($noagg = FALSE, $type = NULL) {
  global $conf;
  $preprocess = !defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update';

  // URL bypass.
  if ($noagg || isset($_GET['advagg']) && $_GET['advagg'] == 0 && user_access('bypass advanced aggregation')) {
    $preprocess = FALSE;
    $conf['advagg_use_full_cache'] = FALSE;
  }

  // Cookie bypass.
  $cookie_name = 'AdvAggDisabled';
  $key = md5(drupal_get_private_key());
  if (!empty($_COOKIE[$cookie_name]) && $_COOKIE[$cookie_name] == $key) {
    $preprocess = FALSE;
    $conf['advagg_use_full_cache'] = FALSE;
  }
  $public_downloads = variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC;
  if (!$public_downloads) {
    $custom_path = variable_get('advagg_custom_files_dir', ADVAGG_CUSTOM_FILES_DIR);
    if (!empty($custom_path)) {
      $public_downloads = TRUE;
    }
  }
  if ($preprocess) {
    if ($type == 'js' && !variable_get('advagg_preprocess_js', ADVAGG_PREPROCESS_JS)) {
      $preprocess = FALSE;
    }
    if ($type == 'css' && !variable_get('advagg_preprocess_css', ADVAGG_PREPROCESS_CSS)) {
      $preprocess = FALSE;
    }
  }

  // A dummy query-string is added to filenames, to gain control over
  // browser-caching. The string changes on every update or full cache
  // flush, forcing browsers to load a new copy of the files, as the
  // URL changed.
  $query_string = '?' . substr(variable_get('css_js_query_string', '0'), 0, 1);
  return array(
    $preprocess,
    $public_downloads,
    $query_string,
  );
}