function ga_stats_ga_timeframes in Google Analytics Statistics 7.2
Same name and namespace in other branches
- 7 ga_stats.module \ga_stats_ga_timeframes()
- 7.x inc/ga.inc \ga_stats_ga_timeframes()
Retrieve timeframes which are used to delimit the range of GA data.
@todo add forever
Parameters
bool $form_options: Default to FALSE to provide form elements. When TRUE, provides complete data suitable for use with data requests.
bool $all: Default is FALSE. If TRUE, will return all timeframes including inactive ones.
Return value
array
4 calls to ga_stats_ga_timeframes()
- drush_ga_stats_generate_validate in ./
ga_stats.drush.inc - Implements hook_drush_COMMAND_validate().
- ga_stats_admin_settings in ./
ga_stats.admin.inc - Callback for the GA Stats admin form.
- ga_stats_collect_data in includes/
ga.inc - Retrieve data for all configured metrics and time-frames.
- ga_stats_views_data in ./
ga_stats.views.inc - Implements hook_views_data().
File
- ./
ga_stats.module, line 152
Code
function ga_stats_ga_timeframes($form_options = FALSE, $all = FALSE) {
if ($form_options) {
$timeframes = array(
'hour' => 'in the past hour',
'today' => 'in the past 24 hours',
'2days' => 'in the past 48 hours',
'week' => 'in the past 7 days',
'month' => 'in the past 31 days',
'year' => 'in the past 365 days',
'forever' => 'since 2005 began',
);
}
else {
$timeframes = array(
'hour' => array(
'secsToSub' => 60 * 60,
'filter' => 'hour==' . date('G'),
'title' => 'in the past hour',
),
'today' => array(
'secsToSub' => 60 * 60 * 24,
'filter' => 'day==' . date('j'),
'title' => 'in the past 24 hours',
),
'2days' => array(
'secsToSub' => 60 * 60 * 24 * 2,
'title' => 'in the past 48 hours',
),
'week' => array(
'secsToSub' => 60 * 60 * 24 * 7,
'title' => 'in the past 7 days',
),
'month' => array(
'secsToSub' => 60 * 60 * 24 * 31,
'title' => 'in the past 31 days',
),
'year' => array(
'secsToSub' => 60 * 60 * 24 * 365,
'title' => 'in the past 365 days',
),
'forever' => array(
'secsToSub' => time() - strtotime('2005-01-01'),
'title' => 'since 2005 began',
),
);
}
if (!$all) {
$enabled = variable_get('ga_stats_enabled_timeframes', array(
'today' => TRUE,
'month' => TRUE,
));
$timeframes = array_intersect_key($timeframes, array_filter($enabled));
}
return $timeframes;
}