You are here

function _get_time_from_url in Google Chart Tools 7

Retrieve the time period or interval from the URL

1 call to _get_time_from_url()
analytics_dashboard_charts in analytics_dashboard/analytics_dashboard.charts.inc
@file Provides the charts definitions.

File

analytics_dashboard/analytics_dashboard.module, line 79

Code

function _get_time_from_url() {

  // Get the option
  if (isset($_GET['option'])) {
    switch ($_GET['option']) {
      case 'custom':
        $from = strtotime($_GET['from']);
        $to = strtotime($_GET['to']);
        if (is_numeric($from) && is_numeric($to)) {

          // Move the 'to' date to 1 second before midnight
          return array(
            $from,
            $to + 86399,
          );
        }
        break;
      case 'period':
        $from = strtotime('-' . str_replace('_', ' ', filter_xss($_GET['period'])));
        if (is_numeric($from)) {
          return array(
            $from,
            time(),
          );
        }
    }
  }
  else {
    return array(
      strtotime('-1 month'),
      time(),
    );
  }
  return FALSE;
}