Newer
Older
Digital_Repository / Repositories / statistics / includes / inc.html.show_detail_eprint.es.php
nstanger on 27 Nov 2005 6 KB - Added intelligent navigation bars.
  1. <?php
  2. require("inc.html.navbar_global.es.php");
  3.  
  4. if ($title == '')
  5. $title = 'Eprint #' . sprintf("%08d", $_REQUEST["id"]) . ' (title is not available)';
  6. // Create link to eprint.
  7. $title_link = '<a href="'.
  8. $GLOBALS["config_vars"]["general"]["eprints_location"] .
  9. '/archive/' .
  10. sprintf("%08d", $_REQUEST["id"]) .
  11. '/" target="_blank">' .
  12. $title .
  13. '</a>';
  14. ?>
  15.  
  16. <h3><?php print $title_link; ?></h3>
  17.  
  18. <?php
  19. require("inc.html.navbar_eprint.es.php");
  20.  
  21. $max_width = '500'; // Max pixel width of barcharts
  22. ?>
  23. <h4>Abstract views and document downloads for <?php print $show_date; ?></h4>
  24. <?php
  25. $count0 = 0;
  26. $count1 = 0;
  27. if (isset($type_count["0"]["count"])) {
  28. if ($type_count["0"]["view_type"] != "download") {
  29. $count0 = $type_count["0"]["count"];
  30. } else {
  31. $count1 = $type_count["0"]["count"];
  32. }
  33. }
  34. if (isset($type_count["1"]["count"])) {
  35. if ($type_count["1"]["view_type"] != "download") {
  36. $count0 = $type_count["1"]["count"];
  37. } else {
  38. $count1 = $type_count["1"]["count"];
  39. }
  40. }
  41. $max_count = max($count0, $count1, 1);
  42. if ($count0 + $count1 > 0)
  43. {
  44. print "<table>\n";
  45. print '<tr><th align="left" width="150" style="background-color:#cccccc;">&nbsp;</th>
  46. <th style="background-color:#66ddee;">Abstracts</th>
  47. <th style="background-color:#4477dd;color:#ffffff;">Downloads</th>
  48. <th style="background-color:#cccccc;">&nbsp;</th></tr>';
  49. print '<tr><td align="left" style="background-color:#2ea495;color:#ffffff;font-size:small;"><b>Views</b></td><td align="right" style="font-size:small;">'.
  50. $count0.
  51. '</td><td align="right" style="font-size:small;">' .
  52. $count1 .
  53. '</td>';
  54. $cur_count = $count0;
  55. $col_width = (int) ($cur_count/$max_count * $max_width);
  56. $col_width = max($col_width,1);
  57. $col_width .= "px";
  58. print '<td align=left><img src="bars/hh.png" alt="abstracts" height="9" width="'. $col_width . '"><br />';
  59. $cur_count = $count1;
  60. $col_width = (int) ($cur_count/$max_count * $max_width);
  61. $col_width = max($col_width,1);
  62. $col_width .= "px";
  63. print '<img src="bars/hp.png" alt="downloads" height="9" width="'. $col_width . '"></td></tr>';
  64. print "</table>\n";
  65. } else {
  66. print '<b style="color:#ff0000;">This document has not been viewed in this period.</b>';
  67. }
  68. ?>
  69.  
  70. <h4>Views by country (derived from IP address of query) for <?php print $show_date; ?></h4>
  71. <?php
  72. if (isset($GLOBALS["db_values"]["0"]["country_downloads"])) {
  73. $max_count = $GLOBALS["db_values"]["0"]["country_downloads"];
  74. for ($rs=0;$rs<count($GLOBALS["db_values"]);$rs++) {
  75. if ($GLOBALS["db_values"][$rs]["country_abstracts"] > $max_count){
  76. $max_count = $GLOBALS["db_values"][$rs]["country_abstracts"];
  77. }
  78. }
  79. print "<table>\n";
  80. print '<tr><th colspan="2" align="left" style="background-color:#cccccc;" width="150">Country</th>
  81. <th style="background-color:#66ddee;">Abstracts</th>
  82. <th style="background-color:#4477dd;color:#ffffff;">Downloads</th>
  83. <th style="background-color:#cccccc;">&nbsp;</th></tr>';
  84. }
  85. else {
  86. print "<table>\n";
  87. print '<tr><td align="left" width="200"><b style="color:#ff0000;">No statistics are available.</b></td></tr>';
  88. }
  89. for ($rs=0;$rs<count($GLOBALS["db_values"]);$rs++)
  90. {
  91. if ($GLOBALS["db_values"][$rs]["country_name"]=='') { $GLOBALS["db_values"][$rs]["country_name"]='unknown'; }
  92. if ($GLOBALS["db_values"][$rs]["country_name"]=='N/A') { $GLOBALS["db_values"][$rs]["country_name"]='unknown'; }
  93. print '<tr><td>';
  94. // select a flag
  95. $ccode = strtolower($GLOBALS["db_values"][$rs]["country_code"]);
  96. $c_flag = 'flags18x14/' . $ccode . '.png';
  97. if (file_exists($c_flag)) {
  98. print '<img src="'. $c_flag . '" width="18" height="14" alt="'. $ccode . '">';
  99. } else {
  100. print '<img src="flags18x14/unknown.png" width="18" height="14" alt="' . $ccode . '">';
  101. };
  102. print '</td><td style="font-size:small;">' .
  103. $GLOBALS["db_values"][$rs]["country_name"].
  104. '</td><td align="right" style="font-size:small;">'.
  105. $GLOBALS["db_values"][$rs]["country_abstracts"].
  106. '</td><td align="right" style="font-size:small;">'.
  107. $GLOBALS["db_values"][$rs]["country_downloads"].
  108. '</td>';
  109.  
  110. $cur_count = $GLOBALS["db_values"][$rs]["country_abstracts"];
  111. $col_width = (int) ($cur_count/$max_count * $max_width);
  112. $col_width = max($col_width,1);
  113. $col_width .= "px";
  114. print '<td align="left"><img src="bars/hh.png" alt="views" height="9" width="'.
  115. $col_width .
  116. '"><br />';
  117.  
  118. $cur_count = $GLOBALS["db_values"][$rs]["country_downloads"];
  119. $col_width = (int) ($cur_count/$max_count * $max_width);
  120. $col_width = max($col_width,1);
  121. $col_width .= "px";
  122. print '<img src="bars/hp.png" alt="views" height="9" width="'.
  123. $col_width .
  124. '"></td></tr>';
  125. }
  126. print "</table>\n";
  127.  
  128. ?>
  129.  
  130. <h4>History of views for this ePrint</h4>
  131. <?php
  132. if (count($month_tally) > 0)
  133. {
  134. $max_count = 1;
  135. for ($rs=0;$rs<count($month_tally);$rs++) {
  136. if($max_count < $month_tally[$rs]["abstracts"])
  137. $max_count = $month_tally[$rs]["abstracts"];
  138. if($max_count < $month_tally[$rs]["downloads"])
  139. $max_count = $month_tally[$rs]["downloads"];
  140. }
  141. print "<table>\n";
  142. print '<tr><th style="background-color:#cccccc;" width="150">Period</th><th style="background-color:#66ddee;">Abstracts</th><th style="background-color:#4477dd;color:#ffffff;">Downloads</th><th style="background-color:#cccccc;">&nbsp;</th></tr>';
  143. for ($rs=0;$rs<count($month_tally);$rs++)
  144. {
  145.  
  146. $str_posn = strpos('JanFebMarAprMayJunJulAugSepOctNovDec',$month_tally[$rs]["month"]);
  147. if ($str_posn === false) $str_posn = 0;
  148. $month_number = (int) ($str_posn / 3) + 1;
  149.  
  150. print '<tr><td style="font-size:small;"><a href="'.
  151. $_SERVER['PHP_SELF'].
  152. '?action=show_detail_eprint;id=' .
  153. $_REQUEST["id"] .
  154. ';year=' .
  155. (int) $month_tally[$rs]["year"] .
  156. ';month='.
  157. $month_number .
  158. '">'.
  159. (int) $month_tally[$rs]["year"] .
  160. ' '.
  161. $month_tally[$rs]["month"] .
  162. '</a></td>';
  163. print '<td align="right" style="font-size:small;">'.
  164. $month_tally[$rs]["abstracts"].
  165. '</td>';
  166. print '<td align="right" style="font-size:small;">'.
  167. $month_tally[$rs]["downloads"].
  168. '</td>';
  169. // abstract views bar
  170. $cur_count = $month_tally[$rs]["abstracts"];
  171. $col_width = (int) ($cur_count/$max_count * $max_width);
  172. $col_width = max($col_width,1);
  173. $col_width .= "px";
  174. print '<td align="left"><img src="bars/hh.png" alt="views" height="9" width="'.
  175. $col_width .
  176. '"><br />';
  177. // download views bar
  178. $cur_count = $month_tally[$rs]["downloads"];
  179. $col_width = (int) ($cur_count/$max_count * $max_width);
  180. $col_width = max($col_width,1);
  181. $col_width .= "px";
  182. print '<img src="bars/hp.png" alt="views" height="9" width="'.
  183. $col_width .
  184. '"></td></tr>';
  185. }
  186. print "</table>\n";
  187. } else {
  188. print '<b style="color:#ff0000;">No statistics are available.</b>';
  189. }
  190. ?>