-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
48 lines (45 loc) · 1.4 KB
/
index.php
File metadata and controls
48 lines (45 loc) · 1.4 KB
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
<?php
function siteDepth($index) {
foreach($index as $item) {
$depth[] = $item->depth();
}
return max($depth);
}
function countChildren($index) {
foreach($index as $item) {
$children[] = $item->children()->count();
}
return $children;
}
function countMime($files, $mime) {
$count = 0;
foreach($files as $item) {
if($item->mime() == $mime) $count++;
}
return $count;
}
Kirby::plugin('jenstornell/panelstats', [
'fields' => [
'panelstats' => [
'props' => [
'values' => function() {
$site = site();
$index = $site->index();
$count_children = countChildren($index);
$files = $index->files();
$data = [
'site_images' => $index->images()->count(),
'jpg' => countMime($files, 'image/jpeg'),
'png' => countMime($files, 'image/png'),
'site_pages_count' => $index->count(),
'site_pages_count_children' => $site->children()->count(),
'site_depth' => siteDepth($index),
'files' => $files->count(),
'children_max' => max($count_children)
];
return $data;
},
]
]
]
]);