Newer
Older
Digital_Repository / Repositories / statistics / includes / inc.html.cumulative_usage_country.es.php
nstanger on 27 Nov 2005 2 KB - Added intelligent navigation bars.
  1. <?php
  2. require("inc.html.navbar_global.es.php");
  3. ?>
  4.  
  5. <h3>Abstract views and document downloads by country (derived from IP address of query)</h3>
  6.  
  7. <?php
  8. $max_width=500;
  9. if (! isset($GLOBALS["db_values"]["0"]["country_downloads"])) {
  10. print "<table>\n";
  11. print '<tr><td align="left" width="200" style="color:#ff0000;"><b>No statistics available.</b></td></tr>';
  12. print "\n";
  13. } else {
  14. // Compute the longest bar
  15. $max_count = $GLOBALS["db_values"]["0"]["country_downloads"];
  16. for ($rs=0; $rs<count($GLOBALS["db_values"]); $rs++) {
  17. if ($GLOBALS["db_values"][$rs]["country_abstracts"] > $max_count) {
  18. $max_count = $GLOBALS["db_values"][$rs]["country_abstracts"];
  19. }
  20. }
  21. print "<table>\n";
  22. print '<tr><th colspan="2" align="left" style="background-color:#cccccc;">Country</th>
  23. <th style="background-color:#66ddee;">Abstracts</th>
  24. <th style="background-color:#4477dd;color:#ffffff;">Downloads</th>
  25. <th style="background-color:#cccccc;">&nbsp;</th></tr>';
  26. for ($rs=0;$rs<count($GLOBALS["db_values"]);$rs++)
  27. {
  28. if ($GLOBALS["db_values"][$rs]["country_name"]=='') { $GLOBALS["db_values"][$rs]["country_name"]='unknown'; }
  29. if ($GLOBALS["db_values"][$rs]["country_name"]=='N/A') { $GLOBALS["db_values"][$rs]["country_name"]='unknown'; }
  30. print '<tr><td>';
  31. // select a flag
  32. $ccode = strtolower($GLOBALS["db_values"][$rs]["country_code"]);
  33. $c_flag = 'flags18x14/' . $ccode . '.png';
  34. if (file_exists($c_flag)) {
  35. print '<img src="'. $c_flag . '" width="18" height="14" alt="'. $ccode . '">';
  36. } else {
  37. print '<img src="flags18x14/unknown.png" width="18" height="14" alt="' . $ccode . '">';
  38. };
  39. print '</td><td style="font-size:small;">' .
  40. $GLOBALS["db_values"][$rs]["country_name"].
  41. '</td><td align="right" style="font-size:small;">'.
  42. $GLOBALS["db_values"][$rs]["country_abstracts"].
  43. '</td><td align="right" style="font-size:small;">' .
  44. $GLOBALS["db_values"][$rs]["country_downloads"].
  45. '</td>';
  46.  
  47. $cur_count = $GLOBALS["db_values"][$rs]["country_abstracts"];
  48. $col_width = (int) ($cur_count/$max_count * $max_width);
  49. $col_width = max($col_width,1);
  50. $col_width .= "px";
  51. print '<td align="left"><img src="bars/hh.png" alt="views" height="9" width="'.
  52. $col_width .
  53. '"><br />';
  54.  
  55. $cur_count = $GLOBALS["db_values"][$rs]["country_downloads"];
  56. $col_width = (int) ($cur_count/$max_count * $max_width);
  57. $col_width = max($col_width,1);
  58. $col_width .= "px";
  59. print '<img src="bars/hp.png" alt="views" height="9" width="'.
  60. $col_width .
  61. '"></td></tr>';
  62. }
  63. } // of else
  64. print "</table>\n";
  65.  
  66. ?>