View source
<?php
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);
}
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);
}
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);
}
function theme_analytics_event_overview($overview) {
$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;
}