-
Notifications
You must be signed in to change notification settings - Fork 3
/
cosmetics.php
104 lines (70 loc) · 3.67 KB
/
cosmetics.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
103
104
<?php
$this->on('admin.init', function() use ($cosmetics) {
if (!empty($cosmetics['widgets_timer_disabled'])) {
// disable time widget in dashboard
$this->on('admin.dashboard.widgets', function($widgets) {
foreach($widgets as $key => $widget) {
if ($widget['name'] == 'time') {
unset($widgets[$key]);
break;
}
}
}, 0);
}
if (!empty($cosmetics['entry_default_group_main'])) {
// Set default group in entry view to "Main" (default: "All")
// When the page loads, `this.group` is an empty string. After the first
// call of `toggleGroup()` it is 'GroupName' or false.
$this->on('collections.entry.aside', function() {
echo '<span if="{ group === \'\' && !(group = \'Main\') }" class="">test</span>';
});
}
if (!empty($cosmetics['entry_language_buttons'])) {
// add big language buttons to action bar (collection entry)
$this->on('collections.entry.aside', function() {
$this->renderView($this->path('rljutils:views/partials/entry_language_buttons.php'));
});
// add big language buttons to action bar (singleton form)
$this->on('singletons.form.aside', function() {
$this->renderView($this->path('rljutils:views/partials/singletons_language_buttons.php'));
});
}
if (!empty($cosmetics['wysiwyg_entity_encoding_raw'])) {
// Set "raw" encoding for wysiwyg editor to preserve utf8 characters like ä, ö, ü etc.
// The default is "named", so the full text search doesn't fint text with "ä" etc.
$this->on('app.layout.header', function() {
echo '<script>App.$(document).on("init-wysiwyg-editor", function(e, editor) {editor.settings.entity_encoding = "raw";});</script>';
});
}
if (!empty($cosmetics['dark_mode_switch'])) {
$this->bind('/darkmode/toggle', function() {
$user_id = $this->module('cockpit')->getUser('_id');
$on = $this->storage->getKey('cockpit/options', 'darkmode.'.$user_id, false);
$this->storage->setKey('cockpit/options', 'darkmode.'.$user_id, !$on);
return ['darkmode' => !$on];
});
$user_id = $this->module('cockpit')->getUser('_id');
$on = $this->storage->getKey('cockpit/options', 'darkmode.'.$user_id, false);
if ($on) {
$this('admin')->addassets('rljutils:DarkMode/assets/style.min.css');
$this('admin')->addassets('rljutils:DarkMode/assets/darkmode.js');
}
$this->on('cockpit.menu.system', function() {
$user_id = $this->module('cockpit')->getUser('_id');
$on = $this->storage->getKey('cockpit/options', 'darkmode.'.$user_id, false);
$style_url = $this->pathToUrl('rljutils:DarkMode/assets/style.min.css', true);
$script_url = $this->pathToUrl('rljutils:DarkMode/assets/darkmode.js', true);
$this->renderView('rljutils:DarkMode/views/partials/menu_toggle.php', compact('on', 'style_url', 'script_url'));
});
}
if (!empty($cosmetics['display_sortable_entries'])) {
$this('admin')->addassets('rljutils:assets/display_sortable_entries.css');
}
if (!empty($cosmetics['autofocus_login'])) {
$this->on(['app.render.view/cockpit:views/layouts/forgotpassword.php', 'app.render.view/cockpit:views/layouts/login.php'], function($template, $slots) {
$assets = $this['app.assets.base'];
$assets[] = 'rljutils:assets/login-autofocus.js';
$this['app.assets.base'] = $assets;
});
}
});