Newer
Older
Digital_Repository / Repositories / statistics / includes / inc.fns.show_detail_eprint.es.php
  1. <?php
  2. /*
  3. Usage by dates, countries, totals.
  4. */
  5. // If no id default to front page.
  6. if(!isset($_REQUEST["id"])) { return "pub_default"; }
  7.  
  8. // Get detail given year/month
  9. $show_date = 'all years';
  10. if(isset($_REQUEST["year"]) and $_REQUEST["year"]>2002) {
  11. if(isset($_REQUEST["month"]) and $_REQUEST["month"]>=1 and $_REQUEST["month"]<=12) {
  12. $dt = strtotime($_REQUEST["month"]."/1/".$_REQUEST["year"]);
  13. $show_date = date("F Y",$dt);
  14. } else {
  15. $show_date = $_REQUEST["year"];
  16. $_REQUEST["month"] = 0;
  17. }
  18. } else {
  19. $_REQUEST["year"] = 0;
  20. $_REQUEST["month"] = 0;
  21. }
  22. if(isset($_REQUEST["range"])) {
  23. // Work out current date
  24. if($_REQUEST["range"]=='4w') {
  25. $show_date = 'past 4 weeks';
  26. }
  27. } else {
  28. $_REQUEST["range"] = '';
  29. }
  30. // by country
  31. $country_abstracts = $sql->getCountryEprintType($_REQUEST["year"], $_REQUEST["month"], $_REQUEST["range"], 'abstract', $_REQUEST["id"]);
  32. $country_downloads = $sql->getCountryEprintType($_REQUEST["year"], $_REQUEST["month"], $_REQUEST["range"], 'download', $_REQUEST["id"]);
  33. // NJS 2006-01-18: Calculate total number of countries.
  34. $total_download_countries = count($country_downloads);
  35. $total_abstract_countries = count($country_abstracts);
  36. $GLOBALS["db_values"] = merge_countries($country_abstracts, $country_downloads);
  37. // title
  38. $title = $sql->getTitle($_REQUEST["id"]);
  39. // by type
  40. $type_count = $sql->getAbstractDownload($_REQUEST["year"], $_REQUEST["month"], $_REQUEST["range"], 'download', $_REQUEST["id"]);
  41. // by date
  42. $month_downloads = $sql->getCumulativeUsageType($_REQUEST["id"],'download');
  43. $month_abstracts = $sql->getCumulativeUsageType($_REQUEST["id"],'abstract');
  44. $month_tally = merge_dates($month_abstracts,$month_downloads);
  45. ?>