function ga_stats_views_data in Google Analytics Statistics 7.2
Same name and namespace in other branches
- 7 ga_stats.views.inc \ga_stats_views_data()
- 7.x ga_stats.views.inc \ga_stats_views_data()
Implements hook_views_data().
File
- ./
ga_stats.views.inc, line 6
Code
function ga_stats_views_data() {
$data = array();
$times = ga_stats_ga_timeframes(true);
$metrics = ga_stats_ga_metrics();
foreach ($metrics as $mk => $mv) {
// Google provides camelCase key values but views requires lowercase identifiers.
$mkl = strtolower($mk);
foreach ($times as $tk => $tv) {
$data['ga_stats_count_' . $mkl . '_' . $tk]['table']['group'] = t('Statistics');
$data['ga_stats_count_' . $mkl . '_' . $tk]['table']['join'] = array(
'node' => array(
'table' => 'ga_stats_count',
'left_field' => 'nid',
'field' => 'nid',
'type' => 'LEFT OUTER',
'extra' => 'ga_stats_count_' . $mkl . '_' . $tk . '.metric=\'' . $mk . '\' AND ga_stats_count_' . $mkl . '_' . $tk . '.timeframe=\'' . $tk . '\'',
),
);
$data['ga_stats_count_' . $mkl . '_' . $tk]['count'] = array(
'title' => "{$mv} {$tv}",
'help' => t('Information retrieved from Google Analytics'),
'field' => array(
'handler' => 'views_handler_field_numeric',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_numeric',
),
);
}
}
return $data;
}