You are here

function theme_cdn_page_stats in CDN 5

Same name and namespace in other branches
  1. 6.2 theme.inc \theme_cdn_page_stats()
  2. 6 theme.inc \theme_cdn_page_stats()
  3. 7.2 theme.inc \theme_cdn_page_stats()

Render the CDN integration page statistics.

Parameters

$file_count: The number of files detected on this page.

$remote_file_count: The number of files on this page that are served from the CDN.

$local_files: Array of local files.

$remote_files: Array of remote files (i.e. on the CDN), keys are local files.

$synced_files: Array of synchronized files.

$unsynced_files: Array of unsynchronized files.

Return value

The rendered HTML.

1 theme call to theme_cdn_page_stats()
cdn_exit in ./cdn.module
Implementation of hook_exit().

File

./cdn.module, line 505

Code

function theme_cdn_page_stats($file_count, $remote_file_count, $local_files, $remote_files, $synced_files, $unsynced_files) {
  $output = '';
  $items = array();
  $output .= '<div id="cdn-integration-page-stats">';
  $items[] = 'Total number of files on this page: <strong>' . $file_count . '</strong>';
  $percentage = $file_count == 0 ? '100' : number_format($remote_file_count / $file_count * 100);
  $items[] = 'Number of files available on the CDN: <strong>' . $remote_file_count . '</strong> (' . $percentage . '% coverage)';

  // Nested list of unsynced files.
  if (count($unsynced_files)) {
    $unsynced_items = array();
    foreach ($unsynced_files as $file) {
      $unsynced_items[] = array(
        l($file, $file),
      );
    }
    $items[] = 'The files that are not (yet?) synchronized to the CDN:' . theme('item_list', $unsynced_items, NULL, 'ol');
  }

  // Nested list of synced files.
  if (count($synced_files)) {
    $synced_items = array();
    foreach ($synced_files as $file) {
      $synced_items[] = array(
        l($file, $remote_files[$file]),
      );
    }
    $items[] = 'The files that are synchronized to the CDN:' . theme('item_list', $synced_items, NULL, 'ol');
  }
  $output .= theme('item_list', $items, '<strong>' . t('CDN integration statistics') . '</strong>');
  $output .= '</div>';
  return $output;
}