Rev 801 | Rev 820 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 801 | Rev 819 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | <?php |
1 | <?php |
2 | 2 | ||
3 | /* |
3 | /* |
4 | * OIDplus 2.0 |
4 | * OIDplus 2.0 |
5 | * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft |
5 | * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft |
6 | * |
6 | * |
7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
8 | * you may not use this file except in compliance with the License. |
8 | * you may not use this file except in compliance with the License. |
9 | * You may obtain a copy of the License at |
9 | * You may obtain a copy of the License at |
10 | * |
10 | * |
Line 19... | Line 19... | ||
19 | 19 | ||
20 | if (!defined('INSIDE_OIDPLUS')) die(); |
20 | if (!defined('INSIDE_OIDPLUS')) die(); |
21 | 21 | ||
22 | class OIDplusPageAdminColors extends OIDplusPagePluginAdmin { |
22 | class OIDplusPageAdminColors extends OIDplusPagePluginAdmin { |
23 | 23 | ||
- | 24 | public function htmlHeaderUpdate(&$head_elems) { |
|
- | 25 | foreach ($head_elems as &$line) { |
|
- | 26 | if (strpos($line,'oidplus.min.css.php') !== false) { |
|
- | 27 | $add_css_args = array(); |
|
- | 28 | $add_css_args[] = 'theme='.urlencode(OIDplus::config()->getValue('design','default')); |
|
- | 29 | $add_css_args[] = 'invert='.urlencode(OIDplus::config()->getValue('color_invert',0)); |
|
- | 30 | $add_css_args[] = 'h_shift='.urlencode(number_format(OIDplus::config()->getValue('color_hue_shift',0)/360,5,'.','')); |
|
- | 31 | $add_css_args[] = 's_shift='.urlencode(number_format(OIDplus::config()->getValue('color_sat_shift',0)/100,5,'.','')); |
|
- | 32 | $add_css_args[] = 'v_shift='.urlencode(number_format(OIDplus::config()->getValue('color_val_shift',0)/100,5,'.','')); |
|
- | 33 | $add_css_args = count($add_css_args) > 0 ? '?'.implode('&',$add_css_args) : ''; |
|
- | 34 | $line = str_replace('oidplus.min.css.php', 'oidplus.min.css.php'.htmlentities($add_css_args), $line); |
|
- | 35 | } |
|
- | 36 | ||
- | 37 | if (strpos($line,'name="theme-color"') !== false) { |
|
- | 38 | if (preg_match('@content="(.+)"@ismU', $line, $m)) { |
|
- | 39 | $theme_color = $m[1]; |
|
- | 40 | $hs = OIDplus::config()->getValue('color_hue_shift',0)/360; |
|
- | 41 | $ss = OIDplus::config()->getValue('color_sat_shift',0)/100; |
|
- | 42 | $vs = OIDplus::config()->getValue('color_val_shift',0)/100; |
|
- | 43 | $theme_color = changeHueOfCSS($theme_color, $hs, $ss, $vs); // "changeHueOfCSS" can also change a single color value if it has the form #xxyyzz or #xyz |
|
- | 44 | if (OIDplus::config()->getValue('color_invert',0)) { |
|
- | 45 | $theme_color = invertColorsOfCSS($theme_color); |
|
- | 46 | } |
|
- | 47 | $line = preg_replace('@content="(.+)"@ismU', 'content="'.$theme_color.'"', $line); |
|
- | 48 | ||
- | 49 | } |
|
- | 50 | } |
|
- | 51 | } |
|
- | 52 | } |
|
- | 53 | ||
24 | public function action($actionID, $params) { |
54 | public function action($actionID, $params) { |
25 | if ($actionID == 'color_update') { |
55 | if ($actionID == 'color_update') { |
26 | if (!OIDplus::authUtils()->isAdminLoggedIn()) { |
56 | if (!OIDplus::authUtils()->isAdminLoggedIn()) { |
27 | throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin'))); |
57 | throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin'))); |
28 | } |
58 | } |