You are here

function advagg_generate_filesize_processed in Advanced CSS/JS Aggregation 7.2

Given a filename calculate the processed filesize.

Parameters

string $filename: String; filename containing path information as well.

string $type: String; css or js.

Return value

int Processed filesize.

2 calls to advagg_generate_filesize_processed()
advagg_insert_update_files in ./advagg.inc
Insert/Update data in the advagg_files table.
advagg_update_7211 in ./advagg.install
Populate the filesize_processed field in the advagg_files table.

File

./advagg.inc, line 293
Advanced CSS/JS aggregation module.

Code

function advagg_generate_filesize_processed($filename, $type) {
  $files =& drupal_static(__FUNCTION__, array());
  if (!isset($files[$type][$filename])) {

    // Make advagg_get_*_aggregate_contents() available.
    module_load_include('inc', 'advagg', 'advagg.missing');
    $aggregate_settings = advagg_current_hooks_hash_array();
    $file_aggregate = array(
      $filename => array(),
    );
    if ($type === 'css') {
      list($contents) = advagg_get_css_aggregate_contents($file_aggregate, $aggregate_settings);
    }
    elseif ($type === 'js') {
      list($contents) = advagg_get_js_aggregate_contents($file_aggregate, $aggregate_settings);
    }
    if (!empty($contents)) {
      $files[$type][$filename] = strlen(gzencode($contents, 9, FORCE_GZIP));
    }
    else {
      $files[$type][$filename] = 0;
    }
  }
  return $files[$type][$filename];
}