You are here

function ga_stats_ga_timeframes in Google Analytics Statistics 7.x

Same name and namespace in other branches
  1. 7.2 ga_stats.module \ga_stats_ga_timeframes()
  2. 7 ga_stats.module \ga_stats_ga_timeframes()

Parameters

$just_keys : whether we should return all the data or just the keys->values array: TODO: add forever

3 calls to ga_stats_ga_timeframes()
ga_stats_admin_settings in ./ga_stats.module
ga_stats_update_counts in ./ga_stats.module
ga_stats_views_data in ./ga_stats.views.inc
Implementation of hook_views_data

File

inc/ga.inc, line 72

Code

function ga_stats_ga_timeframes($just_keys = false, $all = false) {
  if ($just_keys) {
    $timeframes = array(
      'hour' => 'in the past hour',
      'today' => 'in the past 24 hours',
      'week' => 'in the past 7 days',
      'month' => 'in the past 31 days',
      'forever' => 'for all time',
    );
  }
  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',
      ),
      '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',
      ),
      'forever' => array(
        'secsToSub' => time() - strtotime('2005-01-01'),
        'title' => 'for all time',
      ),
    );
  }
  if (!$all) {
    $enabled = variable_get('ga_stats_enabled_timeframes', array(
      'today',
      'month',
    ));
    foreach ($timeframes as $k => $v) {
      if (!$enabled[$k]) {
        unset($timeframes[$k]);
      }
    }
  }
  return $timeframes;
}