<?php // NJS 2005-12-08: Grab document title on the fly if necessary. if ($title == '') { $title = $sql->getEPrintTitle($_REQUEST["id"]); if ($title == '') $title = 'Eprint #' . sprintf("%08d", $_REQUEST["id"]) . ' (title is not available)'; } // Create link to eprint. $title_link = '<a href="'. $GLOBALS["config_vars"]["general"]["eprints_location"] . '/archive/' . sprintf("%08d", $_REQUEST["id"]) . '/" target="_blank">' . $title . '</a>'; ?> <h3><?php print $title_link; ?></h3> <?php /* NJS 2005-11-27: Note that we load the eprint-specific navigation bar manually rather than through the actions/includes array in inc.vars.es.php. This is (currently) the only place that it's used, and adding it to the array would require us to break this file into two parts. */ require("inc.html.navbar_eprint.es.php"); $max_width = '400'; // Max pixel width of barcharts ?> <h4>Abstract views and document downloads for <?php print $show_date; ?></h4> <?php $count0 = 0; $count1 = 0; // NJS 2006-01-18: Calculate number of distinct countries for views/downloads. $count0c = 0; $count1c = 0; if (isset($type_count["0"]["count"])) { if ($type_count["0"]["view_type"] != "download") { $count0 = $type_count["0"]["count"]; $count0c = $type_count["0"]["countries"]; } else { $count1 = $type_count["0"]["count"]; $count1c = $type_count["0"]["countries"]; } } if (isset($type_count["1"]["count"])) { if ($type_count["1"]["view_type"] != "download") { $count0 = $type_count["1"]["count"]; $count0c = $type_count["1"]["countries"]; } else { $count1 = $type_count["1"]["count"]; $count1c = $type_count["1"]["countries"]; } } $max_count = max($count0, $count1, 1); if ($count0 + $count1 > 0) { print "<table cellspacing='0' cellpadding='4'>\n"; 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>'; print '<tr><th align="left" width="150" style="background-color:#cccccc;"> </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;"> </th></tr>'; 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;">'. $count0. '</td><td align="right" style="font-size:small;border-right:1px solid #dddddd;">(' . $count0c. ')</td><td align="right" style="font-size:small;">' . $count1 . '</td><td align="right" style="font-size:small;border-right:1px solid #dddddd;">(' . $count1c. ')</td>'; $cur_count = $count0; $col_width = (int) ($cur_count/$max_count * $max_width); $col_width = max($col_width,1); $col_width .= "px"; print '<td align=left><img src="bars/hh.png" alt="abstracts" height="9" width="'. $col_width . '"><br />'; $cur_count = $count1; $col_width = (int) ($cur_count/$max_count * $max_width); $col_width = max($col_width,1); $col_width .= "px"; print '<img src="bars/hp.png" alt="downloads" height="9" width="'. $col_width . '"></td></tr>'; print "</table>\n"; } else { print '<p><strong style="color:#ff0000;">This document has not been viewed in this period.</strong></p>'; } ?> <h4>Views by country (derived from IP address of query) for <?php print $show_date; ?></h4> <?php if (isset($GLOBALS["db_values"]["0"]["country_downloads"])) { $max_count = $GLOBALS["db_values"]["0"]["country_downloads"]; for ($rs=0;$rs<count($GLOBALS["db_values"]);$rs++) { if ($GLOBALS["db_values"][$rs]["country_abstracts"] > $max_count){ $max_count = $GLOBALS["db_values"][$rs]["country_abstracts"]; } } print "<table cellspacing='0' cellpadding='4'>\n"; print '<tr><th colspan="2" style="background-color:#cccccc;" width="150">Country</th> <th style="background-color:#66ddee;">Abstracts</th> <th style="background-color:#4477dd;color:#ffffff;">Downloads</th> <th style="background-color:#cccccc;"> </th></tr>'; } else { print '<p><strong style="color:#ff0000;">No statistics are available.</strong></p>'; } // NJS 2006-01-18: Accumulate total number of downloads and views. $total_downloads = 0; $total_abstracts = 0; for ($rs=0;$rs<count($GLOBALS["db_values"]);$rs++) { // NJS 2006-01-18: Accumulate total number of downloads and views. $total_downloads += $GLOBALS["db_values"][$rs]["country_downloads"]; $total_abstracts += $GLOBALS["db_values"][$rs]["country_abstracts"]; if ($GLOBALS["db_values"][$rs]["country_name"]=='') { $GLOBALS["db_values"][$rs]["country_name"]='unknown'; } if ($GLOBALS["db_values"][$rs]["country_name"]=='N/A') { $GLOBALS["db_values"][$rs]["country_name"]='unknown'; } // NJS 2005-12-15: subtly highlight every alternate row print '<tr'; if ($rs % 2) print ' style="background-color:#EDF3FE;"'; print '><td>'; // select a flag // NJS 2005-12-15 make flags and country names links to detail page $ccode = strtolower($GLOBALS["db_values"][$rs]["country_code"]); $c_flag = 'flags18x14/' . $ccode . '.png'; print '<a href="' . $_SERVER['PHP_SELF'] . '?action=show_detail_country;code=' . $ccode . '">'; if (file_exists($c_flag)) { print '<img src="'. $c_flag . '" width="18" height="14" alt="'. $ccode . '">'; } else { print '<img src="flags18x14/unknown.png" width="18" height="14" alt="' . $ccode . '">'; }; print '</a>'; print '</td><td style="font-size:small;border-right:1px solid #dddddd;">' . '<a href="' . $_SERVER['PHP_SELF'] . '?action=show_detail_country;code=' . $ccode . '">' . $GLOBALS["db_values"][$rs]["country_name"]. '</a></td><td align="right" style="font-size:small;border-right:1px solid #dddddd;">'. $GLOBALS["db_values"][$rs]["country_abstracts"]. '</td><td align="right" style="font-size:small;border-right:1px solid #dddddd;">' . $GLOBALS["db_values"][$rs]["country_downloads"]. '</td>'; $cur_count = $GLOBALS["db_values"][$rs]["country_abstracts"]; $col_width = (int) ($cur_count/$max_count * $max_width); $col_width = max($col_width,1); $col_width .= "px"; print '<td align="left"><img src="bars/hh.png" alt="views" height="9" width="'. $col_width . '"><br />'; $cur_count = $GLOBALS["db_values"][$rs]["country_downloads"]; $col_width = (int) ($cur_count/$max_count * $max_width); $col_width = max($col_width,1); $col_width .= "px"; print '<img src="bars/hp.png" alt="views" height="9" width="'. $col_width . '"></td></tr>'; } // NJS 2006-01-18: Display grand totals. if (isset($GLOBALS["db_values"]["0"]["country_downloads"])) { print '<tr><th rowspan="2" colspan="2" style="background-color:#cccccc;">Grand Totals:</th> <th align="right" style="background-color:#66ddee;">'. $total_abstracts. '</th><th align="right" style="background-color:#cccccc;"> </th> <th align="left" style="background-color:#cccccc;"> abstract views originating from '. $total_abstract_countries. ' distinct countries</td></tr>'; print '<tr><th align="right" style="background-color:#cccccc;"> </th> <th align="right" style="background-color:#4477dd;color:#ffffff;">'. $total_downloads. '</th><th align="left" style="background-color:#cccccc;"> document downloads originating from '. $total_download_countries. ' distinct countries</td></tr>'; print "</table>\n"; } ?> <h4>History of views for this ePrint</h4> <?php if (count($month_tally) > 0) { $max_count = 1; for ($rs=0;$rs<count($month_tally);$rs++) { if($max_count < $month_tally[$rs]["abstracts"]) $max_count = $month_tally[$rs]["abstracts"]; if($max_count < $month_tally[$rs]["downloads"]) $max_count = $month_tally[$rs]["downloads"]; } print "<table cellspacing='0' cellpadding='4'>\n"; 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>'; 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;"> </th></tr>'; for ($rs=0;$rs<count($month_tally);$rs++) { $str_posn = strpos('JanFebMarAprMayJunJulAugSepOctNovDec',$month_tally[$rs]["month"]); if ($str_posn === false) $str_posn = 0; $month_number = (int) ($str_posn / 3) + 1; // NJS 2005-12-15: subtly highlight every alternate row print '<tr'; if ($rs % 2) print ' style="background-color:#EDF3FE;"'; print '><td style="font-size:small;border-right:1px solid #dddddd;"><a href="'. $_SERVER['PHP_SELF']. '?action=show_detail_eprint;id=' . $_REQUEST["id"] . ';year=' . (int) $month_tally[$rs]["year"] . ';month='. $month_number . '">'. (int) $month_tally[$rs]["year"] . ' '. $month_tally[$rs]["month"] . '</a></td>'; print '<td align="right" style="font-size:small;">'. $month_tally[$rs]["abstracts"]. '</td><td align="right" style="font-size:small;border-right:1px solid #dddddd;">('. $month_tally[$rs]["acountries"]. ')</td>'; print '<td align="right" style="font-size:small;">'. $month_tally[$rs]["downloads"]. '</td><td align="right" style="font-size:small;border-right:1px solid #dddddd;">('. $month_tally[$rs]["dcountries"]. ')</td>'; // abstract views bar $cur_count = $month_tally[$rs]["abstracts"]; $col_width = (int) ($cur_count/$max_count * $max_width); $col_width = max($col_width,1); $col_width .= "px"; print '<td align="left"><img src="bars/hh.png" alt="views" height="9" width="'. $col_width . '"><br />'; // download views bar $cur_count = $month_tally[$rs]["downloads"]; $col_width = (int) ($cur_count/$max_count * $max_width); $col_width = max($col_width,1); $col_width .= "px"; print '<img src="bars/hp.png" alt="views" height="9" width="'. $col_width . '"></td></tr>'; } print "</table>\n"; } else { print '<p><strong style="color:#ff0000;">No statistics are available.</strong></p>'; } ?>