You are here

analytics_ui.admin.inc in Analytics 6

File

modules/analytics_ui/analytics_ui.admin.inc
View source
<?php

/**
 * @file
 */

/**
 * Page callback for analytics overview page.
 */
function analytics_reports_overview() {
  $list = Analytic::listEvents();
  $events = array();
  foreach ($list as $key => $value) {
    $events[$key] = new AnalyticData();
    $events[$key]
      ->setEventId($key);
  }
  $overview = array();
  foreach ($events as $id => $event) {
    $overview[] = array(
      'event_name' => $event
        ->getEventName(),
      'instances' => $event
        ->getCountEventInstance(),
      'daily_instances' => $event
        ->getCountEventInstance('daily'),
      'weekly_instances' => $event
        ->getCountEventInstance('weekly'),
      'event_link' => l('view more', 'admin/reports/analytics/event/' . $id),
    );
  }
  return theme('analytics_reports_overview', $overview);
}

/**
 * Theme function for analytics overview page.
 */
function theme_analytics_reports_overview($overview) {
  $rows = array();
  $header = array(
    t('event name'),
    t('total'),
    t('today'),
    t('this week'),
    '',
  );
  foreach ($overview as $event) {
    $row = array(
      'data' => array(
        array(
          'data' => filter_xss_admin($event['event_name']),
        ),
        array(
          'data' => $event['instances'] . ' times',
        ),
        array(
          'data' => $event['daily_instances'] . ' times',
        ),
        array(
          'data' => $event['weekly_instances'] . ' times',
        ),
        array(
          'data' => $event['event_link'],
        ),
      ),
    );
    $rows[] = $row;
  }
  return theme('table', $header, $rows);
}

/**
 * Page callback for a specific event overview.
 *
 * @param $event
 * @return unknown_type
 */
function analytics_event_overview($event) {
  $overview['total_points'] = $event
    ->getCountEventInstance();
  $overview['daily_data'] = $event
    ->getDailyHistoryEventInstance();
  $overview['property_names'] = $event
    ->getPropertyList();
  return theme('analytics_event_overview', $overview);
}

/**
 * Theme an individual event overview.
 *
 * @param $overview
 * @return unknown_type
 */
function theme_analytics_event_overview($overview) {

  // @TODO This whole function is just debugging crap. Fix it.
  $output = '';
  $chart = array(
    '#chart_id' => 'daily_chart',
    '#title' => chart_title(t('Data by day'), 'cc0000', 15),
    '#type' => CHART_TYPE_LINE,
    '#size' => chart_size(700, 400),
    '#adjust_resolution' => TRUE,
    '#grid_lines' => chart_grid_lines(16.66, 20, 1, 5),
  );
  $chart['#data']['total'] = $overview['daily_data'];
  $chart['#data_colors'][] = '00ff00';
  $chart['#legends'][] = 'times';
  foreach ($overview['daily_data'] as $date => $data) {
    $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] = chart_mixed_axis_label(date('D', $date));
  }
  $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][2][] = chart_mixed_axis_label(t('day'), 50);
  $output .= chart_render($chart);
  dsm($overview);
  return $output;
}

Functions

Namesort descending Description
analytics_event_overview Page callback for a specific event overview.
analytics_reports_overview Page callback for analytics overview page.
theme_analytics_event_overview Theme an individual event overview.
theme_analytics_reports_overview Theme function for analytics overview page.