-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathreport.php
executable file
·102 lines (88 loc) · 4.53 KB
/
report.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
require_once './bootstrap.php';
#require_once 'FirePHPCore/fb.php';
$config = new Zend_Config_Ini(CONFIG_PATH, ENV);
$dbCreds = new Zend_Config_Ini(CREDS_PATH, 'db');
$couch = new Couch_Client($dbCreds->dsn, $dbCreds->name);
$collectionId = $_REQUEST['id'];
$report = new Models_Reporter($couch, $collectionId);
$res = $report->fetch();
if (isset($_REQUEST['mode'])) {
$mode = $_REQUEST['mode'];
} else {
$mode = "base";
}
if ($mode == "list") {
//@@@TODO Make file format and name configurable
$rendered_report_text = $report->render_as_list();
$filename = "total-impact_" . $collectionId . "_" . date('Y-m-d') . ".tsv";
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Content-Type: text/tab-delimited-values; charset=utf-8');
echo $rendered_report_text;
} else {
if ($mode == "status") {
$rendered_report_text = $report->render_status();
$rendered_about_text = $report->render_about_text();
} else {
$mode = "base";
$rendered_report_text = $report->render(False); //don't show zeros
$rendered_about_text = $report->render_about_text();
}
// handle missing IDs more intelligently later
if (!$res) {
header('Location: ../');
}
define("PAGE_SUBTITLE", $report->getBestIdentifier());
include_once('./header.php');
?>
<div id="report">
<!-- START report-meta -->
<div class="wrapper">
<div id="report-meta">
<h2><span class="title"><?php echo $report->getBestIdentifier(); ?></span></h2>
<div id="report-button">
<a class="report-button" id="update-report-button" name="<?php echo $collectionId; ?>" href="#">run update</a>
<a class="report-button" href="/csv/<?php echo $collectionId; ?>">download data</a>
</div>
<div id="report-info">
<span class="badge artifacts-count"><span class="num"><?php echo $report->getArtifactsCount(); ?></span> artifacts;</span>
<span class="badge updated-at">updated <span class="date"><?php echo $report->getUpdatedAt('j M, Y'); ?></span></span>
</div>
<!--<span class="badge created-at">created <?php echo $report->getCreatedAt('j M, Y'); ?></span>-->
<!--a class="report-button" href="./?add-id=<?php echo $collectionId; ?>">refine</a-->
<div id="share">
<!-- based on code here: https://dev.twitter.com/docs/tweet-button -->
<span id="permalink"><span class="label"> Permalink: </span><a class="copyable", href="<?php echo "http://" . $_SERVER['HTTP_HOST'] . "/collection/" . $collectionId; ?>"><?php echo "http://" . $_SERVER['HTTP_HOST'] . "/collection/" . $collectionId; ?></a><a href="#" id="copy-permalink">copy</a></span>
<script src="//platform.twitter.com/widgets.js" type="text/javascript"></script>
<span class="tweet-this">
<a href="https://twitter.com/share" class="twitter-share-button"
data-url="<?php echo "http://total-impact.org/collection/" . $collectionId ?>"
data-via="mytotalImpact"
data-text="<?php echo "Check out the total-Impact of " . $report->getBestIdentifier() . ": "; ?>"
data-count="horizontal">Tweet</a>
</span>
</div>
</div>
</div>
<!-- END report-meta -->
<!-- START metrics -->
<!-- @@@ we could use large icons to visually identify different types of artifacts -->
<!-- @@@ it'd be useful to separate artifact metadata from artifact metrics, Slideshare and Dryad display both in the same element -->
<div id="metrics">
<?php
echo "$rendered_report_text";
?>
</div><!-- END metrics -->
</div><!-- END report -->
<!-- START footer -->
<p class="something-missing">More detail on <a href="./about/#whichmetrics">available metrics</a>. Missing some artifacts or metrics? See <a href="./about/#limitations">current limitations.</a> </p>
<div id="about-metrics" class="about-metrics">
<h3>Metrics are computed based on the following data sources:</h3>
<?php
echo "$rendered_about_text";
?>
</div>
<?php include_once('./footer.php'); ?>
</body>
</html>
<?php } ?>