You are here

function _cdn_devel_page_stats in CDN 5

Same name and namespace in other branches
  1. 6.2 cdn.stats.inc \_cdn_devel_page_stats()
  2. 6 cdn.stats.inc \_cdn_devel_page_stats()
  3. 7.2 cdn.stats.inc \_cdn_devel_page_stats()

Collects per-page CDN integration statistics.

Parameters

$file: The local file path.

$remote_file: The remote file path.

$remote_file_exists: TRUE if the remote file exists, FALSE otherwise.

Return value

Only if no parameters were passed: the collected statistics.

2 calls to _cdn_devel_page_stats()
cdn_exit in ./cdn.module
Implementation of hook_exit().
cdn_file_server in ./cdn.inc
Implementation of hook_file_server().

File

./cdn.module, line 312

Code

function _cdn_devel_page_stats($file = FALSE, $remote_file = '', $remote_file_exists = FALSE) {
  static $file_count, $remote_file_count, $all_requests, $local_files, $remote_files, $synced_files, $unsynced_files;
  if (!isset($all_requests)) {
    $file_count = 0;
    $remote_file_count = 0;
    $all_requests = array();
    $local_files = array();
    $remote_files = array();
    $synced_files = array();
    $unsynced_files = array();
  }

  // If the function is called with parameters set, save the statistics. If no
  // parameters are passed, return the collected statistics.
  if ($file && !isset($all_requests[$file])) {
    $all_requests[$file] = TRUE;
    $file_count++;
    $local_files[] = $file;
    $remote_files[$file] = $remote_file;
    if ($remote_file_exists) {
      $remote_file_count++;
      $synced_files[] = $file;
    }
    else {
      $unsynced_files[] = $file;
    }
  }
  elseif (!$file) {
    return array(
      $file_count,
      $remote_file_count,
      $local_files,
      $remote_files,
      $synced_files,
      $unsynced_files,
    );
  }
}