PluginProbe
Disk Usage Insights / 1.7
Disk Usage Insights v1.7
trunk 1.0 1.10 1.11 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9
← All changes | src/Frontend/Table.php +34 -2 1.01.7 View file →
@@ -5,10 +5,13 @@
5 5
6 6 private /** @var string */ $headline;
7 7 private /** @var array */ $columnNames = [];
8 8 private /** @var array */ $columnCss = [];
9 + private /** @var array */ $percentBar = null; // [$colDisplay, $colSource]
10 + private /** @var array */ $data = [];
11 + private ?Pagination $pagination = null;
9 12
10 - public function __construct(string $headline, array $columnNames = null, array $columnCss = null)
13 + public function __construct(string $headline, array $columnNames = [], array $columnCss = [])
11 14 {
12 15 $this->headline = $headline;
13 16 if ($columnNames !== null) {
14 17 $this->columnNames = $columnNames;
@@ -17,9 +20,38 @@
17 20 $this->columnCss = $columnCss;
18 21 }
19 22 }
20 23
21 - public function output(array $table) {
24 + public function withData(array $data): self {
25 + $this->data = $data;
26 +
27 + return $this;
28 + }
29 +
30 + public function output() {
31 + $table = $this->data;
32 + $pagination = $this->pagination;
22 33 include __DIR__ . '/../../views/blocks/table.php';
34 + }
35 +
36 + public function withPercentBar(int $colDisplay, int $colSource): self {
37 + $this->percentBar = [$colDisplay, $colSource];
38 +
39 + return $this;
40 + }
41 +
42 + public function withPagination(Pagination $pagination): self {
43 + $this->pagination = $pagination;
44 +
45 + return $this;
46 + }
47 +
48 + public function hasPercentBar($col): bool {
49 + return $this->percentBar !== null
50 + && $this->percentBar[0] === $col;
51 + }
52 +
53 + public function getPercentBar(int $row): float {
54 + return floatval($this->data[$row][$this->percentBar[1]]);
23 55 }
24 56
25 57 }