-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
130 lines (120 loc) · 5.19 KB
/
Copy pathindex.php
File metadata and controls
130 lines (120 loc) · 5.19 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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
use Kirby\Cms\App;
use Kirby\Toolkit\Str;
use Kirby\Data\Yaml;
Kirby::plugin('salinapl/libsigntool', [
'blueprints' => [
'fields/lst-times' => __DIR__ . '/blueprints/lst-times.yml',
'fields/lst-tags' => __DIR__ . '/blueprints/lst-tags.yml',
'files/lst-slide' => __DIR__ . '/blueprints/lst-slide.yml',
'pages/lst-placeholder' => __DIR__ . '/blueprints/lst-placeholder.yml',
'pages/lst-slideshows' => __DIR__ . '/blueprints/slideshows.yml',
'pages/lst-slideshow' => __DIR__ . '/blueprints/slideshow.yml',
'pages/lst-web-goal-bar' => __DIR__ . '/blueprints/lst-web-goal-bar.yml',
'pages/lst-web-goal-img' => __DIR__ . '/blueprints/lst-web-goal-img.yml',
'pages/lst-web-events' => __DIR__ . '/blueprints/lst-web-events.yml',
'pages/lst-web-error' => __DIR__ . '/blueprints/lst-web-error.yml',
'pages/lst-opac' => __DIR__ . '/blueprints/lst-opac.yml',
'pages/lst-gallery' => __DIR__ . '/blueprints/lst-gallery.yml',
],
'controllers' => [
'lst-slideshow' => require __DIR__ . '/controllers/slideshow.php',
'lst-web-events' => require __DIR__ . '/controllers/lst-web-events.php'
],
'templates' => [
'lst-web-error' => __DIR__ . '/templates/lst-web-error.php',
'lst-web-events' => __DIR__ . '/templates/lst-web-events.php',
'lst-web-goal-bar' => __DIR__ . '/templates/lst-web-goal-bar.php',
'lst-web-goal-img' => __DIR__ . '/templates/lst-web-goal-img.php',
'lst-opac' => __DIR__ . '/templates/lst-opac.php',
'lst-slideshow' => __DIR__ . '/templates/slideshow.php',
'lst-slideshows' => __DIR__ . '/templates/slideshows.php'
],
'snippets' => [
'lst-layout' => __DIR__ . '/snippets/lst-layout.php',
'lst-web-event-js' => __DIR__ . '/snippets/lst-web-event-js.php',
'lst-web-event-php' => __DIR__ . '/snippets/lst-web-event-php.php',
],
'fields' => [
'slideshowSelect' => [
'extends' => 'select',
'props' => [
// Kirby calls this to build your <select> options
'options' => function (): array {
$page = site()->find('slideshows');
return $page
? $page->children()->pluck('title', 'id')
: [];
}
]
]
],
'siteMethods' => [
// this method lives on the `site()` object
'tagsWithDays' => function (): array {
// fetch your slideshows page
$page = site()->find('slideshows');
// get its tags or an empty array
$tags = [];
if ($page && $page->tags()->isNotEmpty()) {
$tags = $page->tags()->split(',');
}
// the seven weekdays
$weekdays = [
'sunday', 'monday', 'tuesday',
'wednesday','thursday','friday',
'saturday'
];
// merge, dedupe, reindex
return array_values(array_unique(array_merge($tags, $weekdays)));
}
],
'hooks' => [
// fires after plugins are registered
'system.loadPlugins:after' => function () {
$kirby = kirby();
$parentSlug = 'slideshows';
$webslideSlug = 'web-slide-error';
// Check if slideshows exists, create if not
if (! $kirby->page($parentSlug)?->exists()) {
$kirby->impersonate('kirby', fn() =>
$kirby->site()->createChild([
'slug' => $parentSlug,
'template' => 'lst-placeholder',
'content' => [
'uuid' => $parentSlug,
]
])->changeStatus('unlisted')
);
}
$webslidePath = "$parentSlug/$webslideSlug";
// Check if web-slides exists, create if not
if (! $kirby->page($webslidePath)?->exists()) {
$body = <<<'EOT'
No active slides were found. Please contact staff in charge of digital signage to resolve the issue.
- Check that all Campaigns are not expired.
- Check Selected Campaign tags to make sure active Campaigns are not excluded.
EOT;
$kirby->impersonate('kirby', fn() =>
$kirby->page($parentSlug)->createChild([
'slug' => $webslideSlug,
'template' => 'lst-web-error',
'content' => [
'uuid' => $webslideSlug,
'title' => 'Error Slide',
'icon' => 'ri-error-warning-fill',
'headline' => 'No Active Slides Set',
'body' => $body,
]
])->changeStatus('unlisted')
);
}
if ($kirby->page($webslidePath)?->exists()) {
$result = $kirby->impersonate('kirby', function() {
page('slideshows')->changeTemplate('lst-slideshows');
return;
});
}
}
]
]);