Newer
Older
Digital_Repository / Repositories / statistics / includes / inc.html.show_detail_eprint.es.php
  1. <?php
  2. // NJS 2005-12-08: Grab document title on the fly if necessary.
  3. if ($title == '')
  4. {
  5. // NJS 2006-06-14: Added archive name as argument.
  6. $title = $sql->getEPrintTitle($GLOBALS["config_vars"]["archivename"],$_REQUEST["id"]);
  7. if ($title == '')
  8. $title = 'Eprint #' . sprintf("%08d", $_REQUEST["id"]) . ' (title is not available)';
  9. }
  10. // Create link to eprint.
  11. // NJS 2006-06-14: Added archive name as index.
  12. $title_link = '<a href="'.
  13. $GLOBALS["config_vars"]["general"]["eprints_location"][$GLOBALS["config_vars"]["archivename"]] .
  14. '/archive/' .
  15. sprintf("%08d", $_REQUEST["id"]) .
  16. '/" target="_blank">' .
  17. $title .
  18. '</a>';
  19. ?>
  20.  
  21. <h3><?php print $title_link; ?></h3>
  22.  
  23. <?php
  24. /*
  25. NJS 2005-11-27: Note that we load the eprint-specific navigation
  26. bar manually rather than through the actions/includes array in
  27. inc.vars.es.php. This is (currently) the only place that it's
  28. used, and adding it to the array would require us to break this
  29. file into two parts.
  30. */
  31. require("inc.html.navbar_eprint.es.php");
  32.  
  33. $max_width = '400'; // Max pixel width of barcharts
  34. ?>
  35. <h4>Abstract views and document downloads for <?php print $show_date; ?></h4>
  36. <?php
  37. $count0 = 0;
  38. $count1 = 0;
  39.  
  40. // NJS 2006-01-18: Calculate number of distinct countries for views/downloads.
  41. $count0c = 0;
  42. $count1c = 0;
  43.  
  44. if (isset($type_count["0"]["count"])) {
  45. if ($type_count["0"]["view_type"] != "download") {
  46. $count0 = $type_count["0"]["count"];
  47. $count0c = $type_count["0"]["countries"];
  48. } else {
  49. $count1 = $type_count["0"]["count"];
  50. $count1c = $type_count["0"]["countries"];
  51. }
  52. }
  53. if (isset($type_count["1"]["count"])) {
  54. if ($type_count["1"]["view_type"] != "download") {
  55. $count0 = $type_count["1"]["count"];
  56. $count0c = $type_count["1"]["countries"];
  57. } else {
  58. $count1 = $type_count["1"]["count"];
  59. $count1c = $type_count["1"]["countries"];
  60. }
  61. }
  62. $max_count = max($count0, $count1, 1);
  63. if ($count0 + $count1 > 0)
  64. {
  65. print "<table cellspacing='0' cellpadding='4'>\n";
  66. print '<tr><td colspan="6"><span style="font-size:small;">The numbers in (parentheses) are the number of distinct countries that views/downloads originated from.</span></td></tr>';
  67. print '<tr><th align="left" width="150" style="background-color:#cccccc;">&nbsp;</th>
  68. <th colspan="2" style="background-color:#66ddee;">Abstracts</th>
  69. <th colspan="2" style="background-color:#4477dd;color:#ffffff;">Downloads</th>
  70. <th style="background-color:#cccccc;">&nbsp;</th></tr>';
  71. 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;">'.
  72. $count0.
  73. '</td><td align="right" style="font-size:small;border-right:1px solid #dddddd;">(' .
  74. $count0c.
  75. ')</td><td align="right" style="font-size:small;">' .
  76. $count1 .
  77. '</td><td align="right" style="font-size:small;border-right:1px solid #dddddd;">(' .
  78. $count1c.
  79. ')</td>';
  80. $cur_count = $count0;
  81. $col_width = (int) ($cur_count/$max_count * $max_width);
  82. $col_width = max($col_width,1);
  83. $col_width .= "px";
  84. print '<td align=left><img src="bars/hh.png" alt="abstracts" height="9" width="'. $col_width . '" /><br />';
  85. $cur_count = $count1;
  86. $col_width = (int) ($cur_count/$max_count * $max_width);
  87. $col_width = max($col_width,1);
  88. $col_width .= "px";
  89. print '<img src="bars/hp.png" alt="downloads" height="9" width="'. $col_width . '" /></td></tr>';
  90. print "</table>\n";
  91. } else {
  92. print '<p><strong style="color:#ff0000;">This document has not been viewed in this period.</strong></p>';
  93. }
  94. ?>
  95.  
  96. <h4>Views by country (derived from IP address of query) for <?php print $show_date; ?></h4>
  97. <?php
  98. if (isset($GLOBALS["db_values"]["0"]["country_downloads"])) {
  99. $max_count = $GLOBALS["db_values"]["0"]["country_downloads"];
  100. for ($rs=0;$rs<count($GLOBALS["db_values"]);$rs++) {
  101. if ($GLOBALS["db_values"][$rs]["country_abstracts"] > $max_count){
  102. $max_count = $GLOBALS["db_values"][$rs]["country_abstracts"];
  103. }
  104. }
  105. print "<table cellspacing='0' cellpadding='4'>\n";
  106. print '<tr><th colspan="2" style="background-color:#cccccc;" width="150">Country</th>
  107. <th style="background-color:#66ddee;">Abstracts</th>
  108. <th style="background-color:#4477dd;color:#ffffff;">Downloads</th>
  109. <th style="background-color:#cccccc;">&nbsp;</th></tr>';
  110. }
  111. else {
  112. print '<p><strong style="color:#ff0000;">No statistics are available.</strong></p>';
  113. }
  114.  
  115. // NJS 2006-01-18: Accumulate total number of downloads and views.
  116. $total_downloads = 0;
  117. $total_abstracts = 0;
  118.  
  119. for ($rs=0;$rs<count($GLOBALS["db_values"]);$rs++)
  120. {
  121. // NJS 2006-01-18: Accumulate total number of downloads and views.
  122. $total_downloads += $GLOBALS["db_values"][$rs]["country_downloads"];
  123. $total_abstracts += $GLOBALS["db_values"][$rs]["country_abstracts"];
  124. if ($GLOBALS["db_values"][$rs]["country_name"]=='') { $GLOBALS["db_values"][$rs]["country_name"]='unknown'; }
  125. if ($GLOBALS["db_values"][$rs]["country_name"]=='N/A') { $GLOBALS["db_values"][$rs]["country_name"]='unknown'; }
  126. // NJS 2005-12-15: subtly highlight every alternate row
  127. print '<tr';
  128. if ($rs % 2) print ' style="background-color:#EDF3FE;"';
  129. print '><td>';
  130. // select a flag
  131. // NJS 2005-12-15 make flags and country names links to detail page
  132. $ccode = strtolower($GLOBALS["db_values"][$rs]["country_code"]);
  133. $c_flag = 'flags18x14/' . $ccode . '.png';
  134. // NJS 2006-06-14: Added archive name to URL and only generate
  135. // a link if there are actually some downloads.
  136. if ( $GLOBALS["db_values"][$rs]["country_downloads"] > 0 )
  137. print '<a href="' . $_SERVER['PHP_SELF'] .
  138. '?action=show_detail_country;code=' . $ccode . ';archive=' .
  139. $GLOBALS["config_vars"]["archivename"] . '">';
  140. if (file_exists($c_flag)) {
  141. print '<img src="'. $c_flag . '" width="18" height="14" alt="'. $ccode . '" />';
  142. } else {
  143. print '<img src="flags18x14/unknown.png" width="18" height="14" alt="' . $ccode . '" />';
  144. };
  145. if ( $GLOBALS["db_values"][$rs]["country_downloads"] > 0 )
  146. print '</a>';
  147. // NJS 2006-06-14: Added archive name to URL and only generate
  148. // a link if there are actually some downloads.
  149. print '</td><td style="font-size:small;border-right:1px solid #dddddd;">';
  150. if ( $GLOBALS["db_values"][$rs]["country_downloads"] > 0 )
  151. print '<a href="' . $_SERVER['PHP_SELF'] .
  152. '?action=show_detail_country;code=' . $ccode . ';archive=' .
  153. $GLOBALS["config_vars"]["archivename"] . '">';
  154. print $GLOBALS["db_values"][$rs]["country_name"];
  155. if ( $GLOBALS["db_values"][$rs]["country_downloads"] > 0 )
  156. print '</a>';
  157. print '</td><td align="right" style="font-size:small;border-right:1px solid #dddddd;">'.
  158. $GLOBALS["db_values"][$rs]["country_abstracts"].
  159. '</td><td align="right" style="font-size:small;border-right:1px solid #dddddd;">' .
  160. $GLOBALS["db_values"][$rs]["country_downloads"].
  161. '</td>';
  162.  
  163. $cur_count = $GLOBALS["db_values"][$rs]["country_abstracts"];
  164. $col_width = (int) ($cur_count/$max_count * $max_width);
  165. $col_width = max($col_width,1);
  166. $col_width .= "px";
  167. print '<td align="left"><img src="bars/hh.png" alt="views" height="9" width="'.
  168. $col_width .
  169. '" /><br />';
  170.  
  171. $cur_count = $GLOBALS["db_values"][$rs]["country_downloads"];
  172. $col_width = (int) ($cur_count/$max_count * $max_width);
  173. $col_width = max($col_width,1);
  174. $col_width .= "px";
  175. print '<img src="bars/hp.png" alt="views" height="9" width="'.
  176. $col_width .
  177. '" /></td></tr>';
  178. }
  179. // NJS 2006-01-18: Display grand totals.
  180. if (isset($GLOBALS["db_values"]["0"]["country_downloads"])) {
  181. print '<tr><th rowspan="2" colspan="2" style="background-color:#cccccc;">Grand Totals:</th>
  182. <th align="right" style="background-color:#66ddee;">'.
  183. $total_abstracts.
  184. '</th><th align="right" style="background-color:#cccccc;">&nbsp;</th>
  185. <th align="left" style="background-color:#cccccc;"> abstract views originating from '.
  186. $total_abstract_countries.
  187. ' distinct countries</td></tr>';
  188. print '<tr><th align="right" style="background-color:#cccccc;">&nbsp;</th>
  189. <th align="right" style="background-color:#4477dd;color:#ffffff;">'.
  190. $total_downloads.
  191. '</th><th align="left" style="background-color:#cccccc;"> document downloads originating from '.
  192. $total_download_countries.
  193. ' distinct countries</td></tr>';
  194.  
  195. print "</table>\n";
  196. }
  197.  
  198. ?>
  199.  
  200. <h4>History of views for this ePrint</h4>
  201. <?php
  202. if (count($month_tally) > 0)
  203. {
  204. $max_count = 1;
  205. for ($rs=0;$rs<count($month_tally);$rs++) {
  206. if($max_count < $month_tally[$rs]["abstracts"])
  207. $max_count = $month_tally[$rs]["abstracts"];
  208. if($max_count < $month_tally[$rs]["downloads"])
  209. $max_count = $month_tally[$rs]["downloads"];
  210. }
  211. print "<table cellspacing='0' cellpadding='4'>\n";
  212. print '<tr><td colspan="6"><span style="font-size:small;">The numbers in (parentheses) are the number of distinct countries that views/downloads originated from.</span></td></tr>';
  213. print '<tr><th style="background-color:#cccccc;" width="150">Period</th><th colspan="2" style="background-color:#66ddee;">Abstracts</th><th colspan="2" style="background-color:#4477dd;color:#ffffff;">Downloads</th><th style="background-color:#cccccc;">&nbsp;</th></tr>';
  214. for ($rs=0;$rs<count($month_tally);$rs++)
  215. {
  216.  
  217. $str_posn = strpos('JanFebMarAprMayJunJulAugSepOctNovDec',$month_tally[$rs]["month"]);
  218. if ($str_posn === false) $str_posn = 0;
  219. $month_number = (int) ($str_posn / 3) + 1;
  220.  
  221. // NJS 2005-12-15: subtly highlight every alternate row
  222. print '<tr';
  223. if ($rs % 2) print ' style="background-color:#EDF3FE;"';
  224. // NJS 2006-06-14: Added archive name to URL and only generate
  225. // a link if there are actually some downloads.
  226. print '><td style="font-size:small;border-right:1px solid #dddddd;">';
  227. if ( $month_tally[$rs]["downloads"] > 0 )
  228. print '<a href="'.
  229. $_SERVER['PHP_SELF'].
  230. '?action=show_detail_eprint;id=' .
  231. $_REQUEST["id"] .
  232. ';year=' .
  233. (int) $month_tally[$rs]["year"] .
  234. ';month='.
  235. $month_number .
  236. ';archive=' .
  237. $GLOBALS["config_vars"]["archivename"] . '">';
  238. print (int) $month_tally[$rs]["year"] .
  239. ' '.
  240. $month_tally[$rs]["month"];
  241. if ( $month_tally[$rs]["downloads"] > 0 )
  242. print '</a>';
  243. print '</td>';
  244. print '<td align="right" style="font-size:small;">'.
  245. $month_tally[$rs]["abstracts"].
  246. '</td><td align="right" style="font-size:small;border-right:1px solid #dddddd;">('.
  247. $month_tally[$rs]["acountries"].
  248. ')</td>';
  249. print '<td align="right" style="font-size:small;">'.
  250. $month_tally[$rs]["downloads"].
  251. '</td><td align="right" style="font-size:small;border-right:1px solid #dddddd;">('.
  252. $month_tally[$rs]["dcountries"].
  253. ')</td>';
  254. // abstract views bar
  255. $cur_count = $month_tally[$rs]["abstracts"];
  256. $col_width = (int) ($cur_count/$max_count * $max_width);
  257. $col_width = max($col_width,1);
  258. $col_width .= "px";
  259. print '<td align="left"><img src="bars/hh.png" alt="views" height="9" width="'.
  260. $col_width .
  261. '" /><br />';
  262. // download views bar
  263. $cur_count = $month_tally[$rs]["downloads"];
  264. $col_width = (int) ($cur_count/$max_count * $max_width);
  265. $col_width = max($col_width,1);
  266. $col_width .= "px";
  267. print '<img src="bars/hp.png" alt="views" height="9" width="'.
  268. $col_width .
  269. '" /></td></tr>';
  270. }
  271. print "</table>\n";
  272. } else {
  273. print '<p><strong style="color:#ff0000;">No statistics are available.</strong></p>';
  274. }
  275. ?>