-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathupdate.php
More file actions
95 lines (72 loc) · 2.69 KB
/
Copy pathupdate.php
File metadata and controls
95 lines (72 loc) · 2.69 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
<?php
$addon = rex_addon::get('cropper');
$configEnabled = static function ($value) use (&$configEnabled): bool {
if (is_bool($value)) {
return $value;
}
if (is_int($value) || is_float($value)) {
return (int) $value === 1;
}
if (is_string($value)) {
$normalized = strtolower(trim($value));
if (in_array($normalized, ['1', 'true', 'yes', 'on'], true)) {
return true;
}
if (in_array($normalized, ['0', 'false', 'no', 'off', ''], true)) {
return false;
}
$unserialized = @unserialize($value, ['allowed_classes' => false]);
if (false !== $unserialized || 'b:0;' === $value) {
return $configEnabled($unserialized);
}
return str_contains($normalized, '"1"') || str_contains($normalized, "'1'");
}
if (is_array($value)) {
return in_array(1, $value, true) || in_array('1', $value, true);
}
return false;
};
if (!$addon->hasConfig()) {
$addon->setConfig('aspect_ratios', '16:9
4:3
1:1
2:3');
}
$configuredToolbarMode = $addon->getConfig('toolbar_mode');
if (!is_string($configuredToolbarMode) || '' === trim($configuredToolbarMode)) {
$addon->setConfig('toolbar_mode', 'legacy');
} elseif (trim($configuredToolbarMode) === 'compact') {
$addon->setConfig('toolbar_mode', 'legacy');
}
if (null === $addon->getConfig('show_info_sidebar_initially')) {
$addon->setConfig('show_info_sidebar_initially', 0);
}
if (null === $addon->getConfig('stage_max_height')) {
$addon->setConfig('stage_max_height', '70vh');
}
if (null === $addon->getConfig('default_jpg_quality')) {
$addon->setConfig('default_jpg_quality', 100);
}
if (null === $addon->getConfig('default_png_compression')) {
$addon->setConfig('default_png_compression', 9);
}
if (null === $addon->getConfig('show_original_ratio')) {
$addon->setConfig('show_original_ratio', 1);
}
if (null === $addon->getConfig('show_free_ratio')) {
$addon->setConfig('show_free_ratio', 1);
}
if (null === $addon->getConfig('show_compression_settings_in_mediapool')) {
$legacyShowJpg = $addon->getConfig('show_jpg_quality_in_mediapool', null);
$legacyShowPng = $addon->getConfig('show_png_compression_in_mediapool', null);
if (null === $legacyShowJpg && null === $legacyShowPng) {
$addon->setConfig('show_compression_settings_in_mediapool', 1);
} else {
$show = ((int) $legacyShowJpg === 1) || ((int) $legacyShowPng === 1);
$addon->setConfig('show_compression_settings_in_mediapool', $show ? 1 : 0);
}
}
$addon->setConfig(
'show_compression_settings_in_mediapool',
$configEnabled($addon->getConfig('show_compression_settings_in_mediapool', 1)) ? 1 : 0
);