-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextend.php
More file actions
45 lines (40 loc) · 2.05 KB
/
Copy pathextend.php
File metadata and controls
45 lines (40 loc) · 2.05 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
<?php
use Flarum\Extend;
return [
(new Extend\Frontend('forum'))
->js(__DIR__ . '/js/dist/forum.js')
->css(__DIR__ . '/less/forum.less'),
(new Extend\Frontend('admin'))
->js(__DIR__ . '/js/dist/admin.js')
->css(__DIR__ . '/less/admin.less'),
(new Extend\Settings())
// Clamp to the supported 100-150% range server-side so the forum
// payload can never carry an out-of-range or non-numeric value,
// whatever ends up in the settings table. Defense in depth: the
// frontend also clamps on read.
->serializeToForum('linkrobinsFontScale', 'linkrobins-font-sizer.scale', function ($value) {
return (string) max(100, min(150, (int) $value));
})
// Only ever emit one of the two known values.
->serializeToForum('linkrobinsFontSizerUi', 'linkrobins-font-sizer.ui', function ($value) {
return $value === 'large' ? 'large' : 'default';
})
// Base sizes (px) that scaling multiplies. Clamped to the same
// 10-32px range the admin inputs allow; the stylesheet falls back to
// the historical defaults (14/12/16) when these match them.
->serializeToForum('linkrobinsFontSizerTextBase', 'linkrobins-font-sizer.text_base', function ($value) {
return (string) max(10, min(32, (int) $value));
})
->serializeToForum('linkrobinsFontSizerTextSmall', 'linkrobins-font-sizer.text_small', function ($value) {
return (string) max(10, min(32, (int) $value));
})
->serializeToForum('linkrobinsFontSizerTextTitle', 'linkrobins-font-sizer.text_title', function ($value) {
return (string) max(10, min(32, (int) $value));
})
->default('linkrobins-font-sizer.scale', '100')
->default('linkrobins-font-sizer.ui', 'default')
->default('linkrobins-font-sizer.text_base', '14')
->default('linkrobins-font-sizer.text_small', '12')
->default('linkrobins-font-sizer.text_title', '16'),
new Extend\Locales(__DIR__ . '/locale'),
];