function google_analytics_counter_gac_get_count in Google Analytics Counter 7
Same name and namespace in other branches
- 6.2 google_analytics_counter.module \google_analytics_counter_gac_get_count()
- 6 google_analytics_counter.module \google_analytics_counter_gac_get_count()
@todo Please document this function.
See also
1 string reference to 'google_analytics_counter_gac_get_count'
- google_analytics_counter_menu in ./
google_analytics_counter.module - Menu for this module
File
- ./
google_analytics_counter.module, line 146
Code
function google_analytics_counter_gac_get_count() {
$path = google_analytics_counter_get_searched_path();
// This gives the AJAX call URI, e.g. /google_analytics_counter/gac_get_count/node/264455. We need to get the calling page's URI.
$path = explode("gac_get_count", $path);
$path = $path[1];
// We have something like /node/264455. Remove the leading slash.
$path = trim(substr($path, 1));
$sumarray = google_analytics_counter_get_sum_per_path($path);
/**
* Show manner of retrieval in debug.
*/
if (GOOGLE_ANALYTICS_COUNTER_DEBUG == 1) {
if (!empty($sumarray)) {
$sumarray[3] .= " Data retrieved using AJAX.";
}
}
// Return Data
$json = array();
if (!empty($sumarray)) {
$json['#google-analytics-counter-' . md5($path)] = google_analytics_counter_construct_content($sumarray);
# . ' (AJAX)';
}
else {
$json['#google-analytics-counter-' . md5($path)] = NULL;
}
// Send JSON Back
drupal_json_output($json);
exit;
}