<?php
/*
Usage by dates, countries, totals.
*/
// If no id default to front page.
if(!isset($_REQUEST["id"])) { return "pub_default"; }
// Get detail given year/month
$show_date = 'all years';
if(isset($_REQUEST["year"]) and $_REQUEST["year"]>2002) {
if(isset($_REQUEST["month"]) and $_REQUEST["month"]>=1 and $_REQUEST["month"]<=12) {
$dt = strtotime($_REQUEST["month"]."/1/".$_REQUEST["year"]);
$show_date = date("F Y",$dt);
} else {
$show_date = $_REQUEST["year"];
$_REQUEST["month"] = 0;
}
} else {
$_REQUEST["year"] = 0;
$_REQUEST["month"] = 0;
}
if(isset($_REQUEST["range"])) {
// Work out current date
if($_REQUEST["range"]=='4w') {
$show_date = 'past 4 weeks';
}
} else {
$_REQUEST["range"] = '';
}
// by country
$country_abstracts = $sql->getCountryEprintType($_REQUEST["year"], $_REQUEST["month"], $_REQUEST["range"], 'abstract', $_REQUEST["id"]);
$country_downloads = $sql->getCountryEprintType($_REQUEST["year"], $_REQUEST["month"], $_REQUEST["range"], 'download', $_REQUEST["id"]);
// NJS 2006-01-18: Calculate total number of countries.
$total_download_countries = count($country_downloads);
$total_abstract_countries = count($country_abstracts);
$GLOBALS["db_values"] = merge_countries($country_abstracts, $country_downloads);
// title
$title = $sql->getTitle($_REQUEST["id"]);
// by type
$type_count = $sql->getAbstractDownload($_REQUEST["year"], $_REQUEST["month"], $_REQUEST["range"], 'download', $_REQUEST["id"]);
// by date
$month_downloads = $sql->getCumulativeUsageType($_REQUEST["id"],'download');
$month_abstracts = $sql->getCumulativeUsageType($_REQUEST["id"],'abstract');
$month_tally = merge_dates($month_abstracts,$month_downloads);
?>