You are here

function google_analytics_reports_summary_page in Google Analytics Reports 7

Same name and namespace in other branches
  1. 6 google_analytics_reports/google_analytics_reports.pages.inc \google_analytics_reports_summary_page()

Page callback for admin/reports/google-analytics.

Return value

An HTML summary of the site-wide statistics.

1 string reference to 'google_analytics_reports_summary_page'
google_analytics_reports_menu in google_analytics_reports/google_analytics_reports.module
Implementation of hook_menu().

File

google_analytics_reports/google_analytics_reports.pages.inc, line 12
Page callbacks for google analytics.

Code

function google_analytics_reports_summary_page() {
  if (!variable_get('google_analytics_reports_oauth_token', FALSE)) {
    drupal_set_message(t('You must <a href="!url">authorize</a> Drupal to use your Analytics account before you can view reports.', array(
      '!url' => url('admin/config/system/google-analytics-reports'),
    )), 'warning');
    return ' ';
  }
  $summary = array(
    'visit_chart' => _google_analytics_reports_visits(),
    'usage' => _google_analytics_reports_usage(),
    'pages' => _google_analytics_reports_top_pages(),
    'referrals' => _google_analytics_reports_top_referrals(),
    'keywords' => _google_analytics_reports_top_keywords(),
  );
  if (in_array(FALSE, $summary, TRUE)) {
    $menu_item = menu_get_item();
    if ($menu_item['href'] == 'admin/reports/google-analytics') {
      drupal_set_message(_google_analytics_reports_error_message(), 'error');
      return ' ';
    }
    else {
    }
    return '<p>' . _google_analytics_reports_error_message() . '</p>';
  }
  return theme('google_analytics_reports_summary', $summary);
}