aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugins/default_colors/default_colors.php
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/default_colors/default_colors.php')
-rw-r--r--plugins/default_colors/default_colors.php26
1 files changed, 20 insertions, 6 deletions
diff --git a/plugins/default_colors/default_colors.php b/plugins/default_colors/default_colors.php
index e1fd5cfb..d3e1fa76 100644
--- a/plugins/default_colors/default_colors.php
+++ b/plugins/default_colors/default_colors.php
@@ -28,14 +28,14 @@ function default_colors_init($conf)
28{ 28{
29 $params = []; 29 $params = [];
30 foreach (DEFAULT_COLORS_PLACEHOLDERS as $placeholder) { 30 foreach (DEFAULT_COLORS_PLACEHOLDERS as $placeholder) {
31 $value = trim($conf->get('plugins.'. $placeholder, '')); 31 $value = trim($conf->get('plugins.' . $placeholder, ''));
32 if (strlen($value) > 0) { 32 if (strlen($value) > 0) {
33 $params[$placeholder] = $value; 33 $params[$placeholder] = $value;
34 } 34 }
35 } 35 }
36 36
37 if (empty($params)) { 37 if (empty($params)) {
38 $error = t('Default colors plugin error: '. 38 $error = t('Default colors plugin error: ' .
39 'This plugin is active and no custom color is configured.'); 39 'This plugin is active and no custom color is configured.');
40 return [$error]; 40 return [$error];
41 } 41 }
@@ -47,6 +47,20 @@ function default_colors_init($conf)
47} 47}
48 48
49/** 49/**
50 * When plugin parameters are saved, we regenerate the custom CSS file with provided settings.
51 *
52 * @param array $data $_POST array
53 *
54 * @return array Updated $_POST array
55 */
56function hook_default_colors_save_plugin_parameters($data)
57{
58 default_colors_generate_css_file($data);
59
60 return $data;
61}
62
63/**
50 * When linklist is displayed, include default_colors CSS file. 64 * When linklist is displayed, include default_colors CSS file.
51 * 65 *
52 * @param array $data - header data. 66 * @param array $data - header data.
@@ -56,7 +70,7 @@ function default_colors_init($conf)
56function hook_default_colors_render_includes($data) 70function hook_default_colors_render_includes($data)
57{ 71{
58 $file = PluginManager::$PLUGINS_PATH . '/default_colors/default_colors.css'; 72 $file = PluginManager::$PLUGINS_PATH . '/default_colors/default_colors.css';
59 if (file_exists($file )) { 73 if (file_exists($file)) {
60 $data['css_files'][] = $file ; 74 $data['css_files'][] = $file ;
61 } 75 }
62 76
@@ -75,7 +89,7 @@ function default_colors_generate_css_file($params): void
75 $content = ''; 89 $content = '';
76 foreach (DEFAULT_COLORS_PLACEHOLDERS as $rule) { 90 foreach (DEFAULT_COLORS_PLACEHOLDERS as $rule) {
77 $content .= !empty($params[$rule]) 91 $content .= !empty($params[$rule])
78 ? default_colors_format_css_rule($params, $rule) .';'. PHP_EOL 92 ? default_colors_format_css_rule($params, $rule) . ';' . PHP_EOL
79 : ''; 93 : '';
80 } 94 }
81 95
@@ -99,8 +113,8 @@ function default_colors_format_css_rule($data, $parameter)
99 } 113 }
100 114
101 $key = str_replace('DEFAULT_COLORS_', '', $parameter); 115 $key = str_replace('DEFAULT_COLORS_', '', $parameter);
102 $key = str_replace('_', '-', strtolower($key)) .'-color'; 116 $key = str_replace('_', '-', strtolower($key)) . '-color';
103 return ' --'. $key .': '. $data[$parameter]; 117 return ' --' . $key . ': ' . $data[$parameter];
104} 118}
105 119
106 120