1 | <?php |
||
12 | class ReportsHelper extends AppHelper |
||
13 | { |
||
14 | public $helpers = array('Incidents'); |
||
15 | |||
16 | 6 | public function __construct(View $view, $settings = array()) |
|
20 | |||
21 | 1 | public function entriesFromIncidents($entries, $totalCount, $key) |
|
37 | |||
38 | 1 | public function createReportsLinks($reports) |
|
39 | { |
||
40 | 1 | $links = array(); |
|
41 | 1 | foreach ($reports as $report) { |
|
42 | 1 | $links[] = $this->linkToReport($report); |
|
43 | } |
||
44 | 1 | $string = implode(', ', $links); |
|
45 | |||
46 | 1 | return $string; |
|
47 | } |
||
48 | |||
49 | 3 | public function linkToReport($report) |
|
50 | { |
||
51 | 3 | $reportId = $report['id']; |
|
52 | 3 | $link = '<a href=/' . BASE_DIR . "reports/view/$reportId>#$reportId</a>"; |
|
53 | |||
54 | 3 | return $link; |
|
55 | } |
||
56 | |||
57 | 1 | public function linkToReportFromIncident($incident) |
|
64 | |||
65 | public function getStacktracesForIncidents($incidents) |
||
66 | { |
||
67 | $count = 0; |
||
68 | $html = '<div class="row">'; |
||
69 | foreach ($incidents as $incident) { |
||
70 | $class = 'well span5'; |
||
71 | |||
72 | if ($count % 2 == 1) { |
||
73 | $class .= ' '; |
||
74 | } else { |
||
75 | $html .= "</div><div class='row'>"; |
||
76 | } |
||
77 | |||
78 | $html .= $this->Incidents->getStacktrace($incident, $class); |
||
79 | ++$count; |
||
80 | } |
||
81 | $html .= '</div>'; |
||
82 | |||
83 | return $html; |
||
84 | } |
||
85 | |||
86 | public function getChartArray($arrayName, $columns, $relatedEntries) |
||
87 | { |
||
88 | $html = "var $arrayName = [], chart = {};"; |
||
89 | foreach ($columns as $column) { |
||
90 | $column = htmlspecialchars($column, ENT_QUOTES | ENT_HTML5); |
||
91 | $html .= 'chart = {};'; |
||
92 | $html .= "chart.name = '$column';"; |
||
93 | $html .= "chart.title = '" . Inflector::humanize($column) . "';"; |
||
94 | $html .= 'chart.labels = []; chart.values = [];'; |
||
95 | foreach ($relatedEntries[$column] as $entry) { |
||
96 | $count = $entry['count']; |
||
97 | $html .= "chart.labels.push('$entry[$column] ($count)');"; |
||
98 | $html .= "chart.values.push($count);"; |
||
99 | } |
||
100 | $html .= "$arrayName.push(chart);"; |
||
101 | } |
||
102 | |||
103 | return $html; |
||
104 | } |
||
105 | |||
106 | public function getLineChartData($arrayName, $entries) |
||
116 | } |
||
117 |