You are here

protected function GoogleAnalyticsReportsApiFeed::sanitizeReport in Google Analytics Reports 7.3

Sanitize report data.

1 call to GoogleAnalyticsReportsApiFeed::sanitizeReport()
GoogleAnalyticsReportsApiFeed::queryReportFeed in google_analytics_reports_api/google_analytics_reports_api.lib.inc
Query and sanitize report data.

File

google_analytics_reports_api/google_analytics_reports_api.lib.inc, line 489
Provides the Google Analytics Reports API Feed object type and associated methods.

Class

GoogleAnalyticsReportsApiFeed
GoogleAnalyticsReportsApiFeed class to authorize access to and request data from the Google Analytics Core Reporting API.

Code

protected function sanitizeReport() {

  // Named keys for report values.
  $this->results->rawRows = isset($this->results->rows) ? $this->results->rows : array();
  $this->results->rows = array();
  foreach ($this->results->rawRows as $row_key => $row_value) {
    foreach ($row_value as $item_key => $item_value) {
      $field_without_ga = str_replace('ga:', '', $this->results->columnHeaders[$item_key]->name);

      // Allow other modules to alter executed data before display.
      drupal_alter('google_analytics_reports_api_reported_data', $field_without_ga, $item_value);
      $this->results->rows[$row_key][$field_without_ga] = $item_value;
    }
  }
  unset($this->results->rawRows);

  // Named keys for report totals.
  $this->results->rawTotals = $this->results->totalsForAllResults;
  $this->results->totalsForAllResults = array();
  foreach ($this->results->rawTotals as $row_key => $row_value) {
    $this->results->totalsForAllResults[str_replace('ga:', '', $row_key)] = $row_value;
  }
  unset($this->results->rawTotals);
}