@@ -37,58 +37,58 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | class Capabilities implements IPublicCapability { |
| 39 | 39 | |
| 40 | - /** @var ThemingDefaults */ |
|
| 41 | - protected $theming; |
|
| 40 | + /** @var ThemingDefaults */ |
|
| 41 | + protected $theming; |
|
| 42 | 42 | |
| 43 | - /** @var Util */ |
|
| 44 | - protected $util; |
|
| 43 | + /** @var Util */ |
|
| 44 | + protected $util; |
|
| 45 | 45 | |
| 46 | - /** @var IURLGenerator */ |
|
| 47 | - protected $url; |
|
| 46 | + /** @var IURLGenerator */ |
|
| 47 | + protected $url; |
|
| 48 | 48 | |
| 49 | - /** @var IConfig */ |
|
| 50 | - protected $config; |
|
| 49 | + /** @var IConfig */ |
|
| 50 | + protected $config; |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @param ThemingDefaults $theming |
|
| 54 | - * @param Util $util |
|
| 55 | - * @param IURLGenerator $url |
|
| 56 | - * @param IConfig $config |
|
| 57 | - */ |
|
| 58 | - public function __construct(ThemingDefaults $theming, Util $util, IURLGenerator $url, IConfig $config) { |
|
| 59 | - $this->theming = $theming; |
|
| 60 | - $this->util = $util; |
|
| 61 | - $this->url = $url; |
|
| 62 | - $this->config = $config; |
|
| 63 | - } |
|
| 52 | + /** |
|
| 53 | + * @param ThemingDefaults $theming |
|
| 54 | + * @param Util $util |
|
| 55 | + * @param IURLGenerator $url |
|
| 56 | + * @param IConfig $config |
|
| 57 | + */ |
|
| 58 | + public function __construct(ThemingDefaults $theming, Util $util, IURLGenerator $url, IConfig $config) { |
|
| 59 | + $this->theming = $theming; |
|
| 60 | + $this->util = $util; |
|
| 61 | + $this->url = $url; |
|
| 62 | + $this->config = $config; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Return this classes capabilities |
|
| 67 | - * |
|
| 68 | - * @return array |
|
| 69 | - */ |
|
| 70 | - public function getCapabilities() { |
|
| 71 | - $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', false); |
|
| 72 | - $color = $this->theming->getColorPrimary(); |
|
| 73 | - return [ |
|
| 74 | - 'theming' => [ |
|
| 75 | - 'name' => $this->theming->getName(), |
|
| 76 | - 'url' => $this->theming->getBaseUrl(), |
|
| 77 | - 'slogan' => $this->theming->getSlogan(), |
|
| 78 | - 'color' => $color, |
|
| 79 | - 'color-text' => $this->theming->getTextColorPrimary(), |
|
| 80 | - 'color-element' => $this->util->elementColor($color), |
|
| 81 | - 'color-element-bright' => $this->util->elementColor($color), |
|
| 82 | - 'color-element-dark' => $this->util->elementColor($color, false), |
|
| 83 | - 'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()), |
|
| 84 | - 'background' => $backgroundLogo === 'backgroundColor' || ($backgroundLogo === false && $this->theming->getColorPrimary() !== '#0082c9') ? |
|
| 85 | - $this->theming->getColorPrimary() : |
|
| 86 | - $this->url->getAbsoluteURL($this->theming->getBackground()), |
|
| 87 | - 'background-plain' => $backgroundLogo === 'backgroundColor' || ($backgroundLogo === false && $this->theming->getColorPrimary() !== '#0082c9'), |
|
| 88 | - 'background-default' => !$this->util->isBackgroundThemed(), |
|
| 89 | - 'logoheader' => $this->url->getAbsoluteURL($this->theming->getLogo()), |
|
| 90 | - 'favicon' => $this->url->getAbsoluteURL($this->theming->getLogo()), |
|
| 91 | - ], |
|
| 92 | - ]; |
|
| 93 | - } |
|
| 65 | + /** |
|
| 66 | + * Return this classes capabilities |
|
| 67 | + * |
|
| 68 | + * @return array |
|
| 69 | + */ |
|
| 70 | + public function getCapabilities() { |
|
| 71 | + $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', false); |
|
| 72 | + $color = $this->theming->getColorPrimary(); |
|
| 73 | + return [ |
|
| 74 | + 'theming' => [ |
|
| 75 | + 'name' => $this->theming->getName(), |
|
| 76 | + 'url' => $this->theming->getBaseUrl(), |
|
| 77 | + 'slogan' => $this->theming->getSlogan(), |
|
| 78 | + 'color' => $color, |
|
| 79 | + 'color-text' => $this->theming->getTextColorPrimary(), |
|
| 80 | + 'color-element' => $this->util->elementColor($color), |
|
| 81 | + 'color-element-bright' => $this->util->elementColor($color), |
|
| 82 | + 'color-element-dark' => $this->util->elementColor($color, false), |
|
| 83 | + 'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()), |
|
| 84 | + 'background' => $backgroundLogo === 'backgroundColor' || ($backgroundLogo === false && $this->theming->getColorPrimary() !== '#0082c9') ? |
|
| 85 | + $this->theming->getColorPrimary() : |
|
| 86 | + $this->url->getAbsoluteURL($this->theming->getBackground()), |
|
| 87 | + 'background-plain' => $backgroundLogo === 'backgroundColor' || ($backgroundLogo === false && $this->theming->getColorPrimary() !== '#0082c9'), |
|
| 88 | + 'background-default' => !$this->util->isBackgroundThemed(), |
|
| 89 | + 'logoheader' => $this->url->getAbsoluteURL($this->theming->getLogo()), |
|
| 90 | + 'favicon' => $this->url->getAbsoluteURL($this->theming->getLogo()), |
|
| 91 | + ], |
|
| 92 | + ]; |
|
| 93 | + } |
|
| 94 | 94 | } |
@@ -82,8 +82,7 @@ |
||
| 82 | 82 | 'color-element-dark' => $this->util->elementColor($color, false), |
| 83 | 83 | 'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()), |
| 84 | 84 | 'background' => $backgroundLogo === 'backgroundColor' || ($backgroundLogo === false && $this->theming->getColorPrimary() !== '#0082c9') ? |
| 85 | - $this->theming->getColorPrimary() : |
|
| 86 | - $this->url->getAbsoluteURL($this->theming->getBackground()), |
|
| 85 | + $this->theming->getColorPrimary() : $this->url->getAbsoluteURL($this->theming->getBackground()), |
|
| 87 | 86 | 'background-plain' => $backgroundLogo === 'backgroundColor' || ($backgroundLogo === false && $this->theming->getColorPrimary() !== '#0082c9'), |
| 88 | 87 | 'background-default' => !$this->util->isBackgroundThemed(), |
| 89 | 88 | 'logoheader' => $this->url->getAbsoluteURL($this->theming->getLogo()), |
@@ -38,225 +38,225 @@ |
||
| 38 | 38 | |
| 39 | 39 | class Util { |
| 40 | 40 | |
| 41 | - /** @var IConfig */ |
|
| 42 | - private $config; |
|
| 41 | + /** @var IConfig */ |
|
| 42 | + private $config; |
|
| 43 | 43 | |
| 44 | - /** @var IAppManager */ |
|
| 45 | - private $appManager; |
|
| 44 | + /** @var IAppManager */ |
|
| 45 | + private $appManager; |
|
| 46 | 46 | |
| 47 | - /** @var IAppData */ |
|
| 48 | - private $appData; |
|
| 47 | + /** @var IAppData */ |
|
| 48 | + private $appData; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Util constructor. |
|
| 52 | - * |
|
| 53 | - * @param IConfig $config |
|
| 54 | - * @param IAppManager $appManager |
|
| 55 | - * @param IAppData $appData |
|
| 56 | - */ |
|
| 57 | - public function __construct(IConfig $config, IAppManager $appManager, IAppData $appData) { |
|
| 58 | - $this->config = $config; |
|
| 59 | - $this->appManager = $appManager; |
|
| 60 | - $this->appData = $appData; |
|
| 61 | - } |
|
| 50 | + /** |
|
| 51 | + * Util constructor. |
|
| 52 | + * |
|
| 53 | + * @param IConfig $config |
|
| 54 | + * @param IAppManager $appManager |
|
| 55 | + * @param IAppData $appData |
|
| 56 | + */ |
|
| 57 | + public function __construct(IConfig $config, IAppManager $appManager, IAppData $appData) { |
|
| 58 | + $this->config = $config; |
|
| 59 | + $this->appManager = $appManager; |
|
| 60 | + $this->appData = $appData; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @param string $color rgb color value |
|
| 65 | - * @return bool |
|
| 66 | - */ |
|
| 67 | - public function invertTextColor($color) { |
|
| 68 | - $l = $this->calculateLuma($color); |
|
| 69 | - if ($l>0.6) { |
|
| 70 | - return true; |
|
| 71 | - } else { |
|
| 72 | - return false; |
|
| 73 | - } |
|
| 74 | - } |
|
| 63 | + /** |
|
| 64 | + * @param string $color rgb color value |
|
| 65 | + * @return bool |
|
| 66 | + */ |
|
| 67 | + public function invertTextColor($color) { |
|
| 68 | + $l = $this->calculateLuma($color); |
|
| 69 | + if ($l>0.6) { |
|
| 70 | + return true; |
|
| 71 | + } else { |
|
| 72 | + return false; |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * get color for on-page elements: |
|
| 78 | - * theme color by default, grey if theme color is to bright |
|
| 79 | - * @param string $color |
|
| 80 | - * @param bool $brightBackground |
|
| 81 | - * @return string |
|
| 82 | - */ |
|
| 83 | - public function elementColor($color, bool $brightBackground = true) { |
|
| 84 | - $luminance = $this->calculateLuminance($color); |
|
| 76 | + /** |
|
| 77 | + * get color for on-page elements: |
|
| 78 | + * theme color by default, grey if theme color is to bright |
|
| 79 | + * @param string $color |
|
| 80 | + * @param bool $brightBackground |
|
| 81 | + * @return string |
|
| 82 | + */ |
|
| 83 | + public function elementColor($color, bool $brightBackground = true) { |
|
| 84 | + $luminance = $this->calculateLuminance($color); |
|
| 85 | 85 | |
| 86 | - if ($brightBackground && $luminance > 0.8) { |
|
| 87 | - // If the color is too bright in bright mode, we fall back to a darker gray |
|
| 88 | - return '#aaaaaa'; |
|
| 89 | - } |
|
| 86 | + if ($brightBackground && $luminance > 0.8) { |
|
| 87 | + // If the color is too bright in bright mode, we fall back to a darker gray |
|
| 88 | + return '#aaaaaa'; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - if (!$brightBackground && $luminance < 0.2) { |
|
| 92 | - // If the color is too dark in dark mode, we fall back to a brighter gray |
|
| 93 | - return '#555555'; |
|
| 94 | - } |
|
| 91 | + if (!$brightBackground && $luminance < 0.2) { |
|
| 92 | + // If the color is too dark in dark mode, we fall back to a brighter gray |
|
| 93 | + return '#555555'; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - return $color; |
|
| 97 | - } |
|
| 96 | + return $color; |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * @param string $color rgb color value |
|
| 101 | - * @return float |
|
| 102 | - */ |
|
| 103 | - public function calculateLuminance($color) { |
|
| 104 | - list($red, $green, $blue) = $this->hexToRGB($color); |
|
| 105 | - $compiler = new Compiler(); |
|
| 106 | - $hsl = $compiler->toHSL($red, $green, $blue); |
|
| 107 | - return $hsl[3]/100; |
|
| 108 | - } |
|
| 99 | + /** |
|
| 100 | + * @param string $color rgb color value |
|
| 101 | + * @return float |
|
| 102 | + */ |
|
| 103 | + public function calculateLuminance($color) { |
|
| 104 | + list($red, $green, $blue) = $this->hexToRGB($color); |
|
| 105 | + $compiler = new Compiler(); |
|
| 106 | + $hsl = $compiler->toHSL($red, $green, $blue); |
|
| 107 | + return $hsl[3]/100; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * @param string $color rgb color value |
|
| 112 | - * @return float |
|
| 113 | - */ |
|
| 114 | - public function calculateLuma($color) { |
|
| 115 | - list($red, $green, $blue) = $this->hexToRGB($color); |
|
| 116 | - return (0.2126 * $red + 0.7152 * $green + 0.0722 * $blue) / 255; |
|
| 117 | - } |
|
| 110 | + /** |
|
| 111 | + * @param string $color rgb color value |
|
| 112 | + * @return float |
|
| 113 | + */ |
|
| 114 | + public function calculateLuma($color) { |
|
| 115 | + list($red, $green, $blue) = $this->hexToRGB($color); |
|
| 116 | + return (0.2126 * $red + 0.7152 * $green + 0.0722 * $blue) / 255; |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * @param string $color rgb color value |
|
| 121 | - * @return int[] |
|
| 122 | - */ |
|
| 123 | - public function hexToRGB($color) { |
|
| 124 | - $hex = preg_replace("/[^0-9A-Fa-f]/", '', $color); |
|
| 125 | - if (strlen($hex) === 3) { |
|
| 126 | - $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
|
| 127 | - } |
|
| 128 | - if (strlen($hex) !== 6) { |
|
| 129 | - return 0; |
|
| 130 | - } |
|
| 131 | - return [ |
|
| 132 | - hexdec(substr($hex, 0, 2)), |
|
| 133 | - hexdec(substr($hex, 2, 2)), |
|
| 134 | - hexdec(substr($hex, 4, 2)) |
|
| 135 | - ]; |
|
| 136 | - } |
|
| 119 | + /** |
|
| 120 | + * @param string $color rgb color value |
|
| 121 | + * @return int[] |
|
| 122 | + */ |
|
| 123 | + public function hexToRGB($color) { |
|
| 124 | + $hex = preg_replace("/[^0-9A-Fa-f]/", '', $color); |
|
| 125 | + if (strlen($hex) === 3) { |
|
| 126 | + $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
|
| 127 | + } |
|
| 128 | + if (strlen($hex) !== 6) { |
|
| 129 | + return 0; |
|
| 130 | + } |
|
| 131 | + return [ |
|
| 132 | + hexdec(substr($hex, 0, 2)), |
|
| 133 | + hexdec(substr($hex, 2, 2)), |
|
| 134 | + hexdec(substr($hex, 4, 2)) |
|
| 135 | + ]; |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - /** |
|
| 139 | - * @param $color |
|
| 140 | - * @return string base64 encoded radio button svg |
|
| 141 | - */ |
|
| 142 | - public function generateRadioButton($color) { |
|
| 143 | - $radioButtonIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16">' . |
|
| 144 | - '<path d="M8 1a7 7 0 0 0-7 7 7 7 0 0 0 7 7 7 7 0 0 0 7-7 7 7 0 0 0-7-7zm0 1a6 6 0 0 1 6 6 6 6 0 0 1-6 6 6 6 0 0 1-6-6 6 6 0 0 1 6-6zm0 2a4 4 0 1 0 0 8 4 4 0 0 0 0-8z" fill="'.$color.'"/></svg>'; |
|
| 145 | - return base64_encode($radioButtonIcon); |
|
| 146 | - } |
|
| 138 | + /** |
|
| 139 | + * @param $color |
|
| 140 | + * @return string base64 encoded radio button svg |
|
| 141 | + */ |
|
| 142 | + public function generateRadioButton($color) { |
|
| 143 | + $radioButtonIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16">' . |
|
| 144 | + '<path d="M8 1a7 7 0 0 0-7 7 7 7 0 0 0 7 7 7 7 0 0 0 7-7 7 7 0 0 0-7-7zm0 1a6 6 0 0 1 6 6 6 6 0 0 1-6 6 6 6 0 0 1-6-6 6 6 0 0 1 6-6zm0 2a4 4 0 1 0 0 8 4 4 0 0 0 0-8z" fill="'.$color.'"/></svg>'; |
|
| 145 | + return base64_encode($radioButtonIcon); |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | 148 | |
| 149 | - /** |
|
| 150 | - * @param $app string app name |
|
| 151 | - * @return string|ISimpleFile path to app icon / file of logo |
|
| 152 | - */ |
|
| 153 | - public function getAppIcon($app) { |
|
| 154 | - $app = str_replace(['\0', '/', '\\', '..'], '', $app); |
|
| 155 | - try { |
|
| 156 | - $appPath = $this->appManager->getAppPath($app); |
|
| 157 | - $icon = $appPath . '/img/' . $app . '.svg'; |
|
| 158 | - if (file_exists($icon)) { |
|
| 159 | - return $icon; |
|
| 160 | - } |
|
| 161 | - $icon = $appPath . '/img/app.svg'; |
|
| 162 | - if (file_exists($icon)) { |
|
| 163 | - return $icon; |
|
| 164 | - } |
|
| 165 | - } catch (AppPathNotFoundException $e) { |
|
| 166 | - } |
|
| 149 | + /** |
|
| 150 | + * @param $app string app name |
|
| 151 | + * @return string|ISimpleFile path to app icon / file of logo |
|
| 152 | + */ |
|
| 153 | + public function getAppIcon($app) { |
|
| 154 | + $app = str_replace(['\0', '/', '\\', '..'], '', $app); |
|
| 155 | + try { |
|
| 156 | + $appPath = $this->appManager->getAppPath($app); |
|
| 157 | + $icon = $appPath . '/img/' . $app . '.svg'; |
|
| 158 | + if (file_exists($icon)) { |
|
| 159 | + return $icon; |
|
| 160 | + } |
|
| 161 | + $icon = $appPath . '/img/app.svg'; |
|
| 162 | + if (file_exists($icon)) { |
|
| 163 | + return $icon; |
|
| 164 | + } |
|
| 165 | + } catch (AppPathNotFoundException $e) { |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - if ($this->config->getAppValue('theming', 'logoMime', '') !== '') { |
|
| 169 | - $logoFile = null; |
|
| 170 | - try { |
|
| 171 | - $folder = $this->appData->getFolder('images'); |
|
| 172 | - if ($folder !== null) { |
|
| 173 | - return $folder->getFile('logo'); |
|
| 174 | - } |
|
| 175 | - } catch (NotFoundException $e) { |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - return \OC::$SERVERROOT . '/core/img/logo/logo.svg'; |
|
| 179 | - } |
|
| 168 | + if ($this->config->getAppValue('theming', 'logoMime', '') !== '') { |
|
| 169 | + $logoFile = null; |
|
| 170 | + try { |
|
| 171 | + $folder = $this->appData->getFolder('images'); |
|
| 172 | + if ($folder !== null) { |
|
| 173 | + return $folder->getFile('logo'); |
|
| 174 | + } |
|
| 175 | + } catch (NotFoundException $e) { |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + return \OC::$SERVERROOT . '/core/img/logo/logo.svg'; |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - /** |
|
| 182 | - * @param $app string app name |
|
| 183 | - * @param $image string relative path to image in app folder |
|
| 184 | - * @return string|false absolute path to image |
|
| 185 | - */ |
|
| 186 | - public function getAppImage($app, $image) { |
|
| 187 | - $app = str_replace(['\0', '/', '\\', '..'], '', $app); |
|
| 188 | - $image = str_replace(['\0', '\\', '..'], '', $image); |
|
| 189 | - if ($app === "core") { |
|
| 190 | - $icon = \OC::$SERVERROOT . '/core/img/' . $image; |
|
| 191 | - if (file_exists($icon)) { |
|
| 192 | - return $icon; |
|
| 193 | - } |
|
| 194 | - } |
|
| 181 | + /** |
|
| 182 | + * @param $app string app name |
|
| 183 | + * @param $image string relative path to image in app folder |
|
| 184 | + * @return string|false absolute path to image |
|
| 185 | + */ |
|
| 186 | + public function getAppImage($app, $image) { |
|
| 187 | + $app = str_replace(['\0', '/', '\\', '..'], '', $app); |
|
| 188 | + $image = str_replace(['\0', '\\', '..'], '', $image); |
|
| 189 | + if ($app === "core") { |
|
| 190 | + $icon = \OC::$SERVERROOT . '/core/img/' . $image; |
|
| 191 | + if (file_exists($icon)) { |
|
| 192 | + return $icon; |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | - try { |
|
| 197 | - $appPath = $this->appManager->getAppPath($app); |
|
| 198 | - } catch (AppPathNotFoundException $e) { |
|
| 199 | - return false; |
|
| 200 | - } |
|
| 196 | + try { |
|
| 197 | + $appPath = $this->appManager->getAppPath($app); |
|
| 198 | + } catch (AppPathNotFoundException $e) { |
|
| 199 | + return false; |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - $icon = $appPath . '/img/' . $image; |
|
| 203 | - if (file_exists($icon)) { |
|
| 204 | - return $icon; |
|
| 205 | - } |
|
| 206 | - $icon = $appPath . '/img/' . $image . '.svg'; |
|
| 207 | - if (file_exists($icon)) { |
|
| 208 | - return $icon; |
|
| 209 | - } |
|
| 210 | - $icon = $appPath . '/img/' . $image . '.png'; |
|
| 211 | - if (file_exists($icon)) { |
|
| 212 | - return $icon; |
|
| 213 | - } |
|
| 214 | - $icon = $appPath . '/img/' . $image . '.gif'; |
|
| 215 | - if (file_exists($icon)) { |
|
| 216 | - return $icon; |
|
| 217 | - } |
|
| 218 | - $icon = $appPath . '/img/' . $image . '.jpg'; |
|
| 219 | - if (file_exists($icon)) { |
|
| 220 | - return $icon; |
|
| 221 | - } |
|
| 202 | + $icon = $appPath . '/img/' . $image; |
|
| 203 | + if (file_exists($icon)) { |
|
| 204 | + return $icon; |
|
| 205 | + } |
|
| 206 | + $icon = $appPath . '/img/' . $image . '.svg'; |
|
| 207 | + if (file_exists($icon)) { |
|
| 208 | + return $icon; |
|
| 209 | + } |
|
| 210 | + $icon = $appPath . '/img/' . $image . '.png'; |
|
| 211 | + if (file_exists($icon)) { |
|
| 212 | + return $icon; |
|
| 213 | + } |
|
| 214 | + $icon = $appPath . '/img/' . $image . '.gif'; |
|
| 215 | + if (file_exists($icon)) { |
|
| 216 | + return $icon; |
|
| 217 | + } |
|
| 218 | + $icon = $appPath . '/img/' . $image . '.jpg'; |
|
| 219 | + if (file_exists($icon)) { |
|
| 220 | + return $icon; |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - return false; |
|
| 224 | - } |
|
| 223 | + return false; |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - /** |
|
| 227 | - * replace default color with a custom one |
|
| 228 | - * |
|
| 229 | - * @param $svg string content of a svg file |
|
| 230 | - * @param $color string color to match |
|
| 231 | - * @return string |
|
| 232 | - */ |
|
| 233 | - public function colorizeSvg($svg, $color) { |
|
| 234 | - $svg = preg_replace('/#0082c9/i', $color, $svg); |
|
| 235 | - return $svg; |
|
| 236 | - } |
|
| 226 | + /** |
|
| 227 | + * replace default color with a custom one |
|
| 228 | + * |
|
| 229 | + * @param $svg string content of a svg file |
|
| 230 | + * @param $color string color to match |
|
| 231 | + * @return string |
|
| 232 | + */ |
|
| 233 | + public function colorizeSvg($svg, $color) { |
|
| 234 | + $svg = preg_replace('/#0082c9/i', $color, $svg); |
|
| 235 | + return $svg; |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | - /** |
|
| 239 | - * Check if a custom theme is set in the server configuration |
|
| 240 | - * |
|
| 241 | - * @return bool |
|
| 242 | - */ |
|
| 243 | - public function isAlreadyThemed() { |
|
| 244 | - $theme = $this->config->getSystemValue('theme', ''); |
|
| 245 | - if ($theme !== '') { |
|
| 246 | - return true; |
|
| 247 | - } |
|
| 248 | - return false; |
|
| 249 | - } |
|
| 238 | + /** |
|
| 239 | + * Check if a custom theme is set in the server configuration |
|
| 240 | + * |
|
| 241 | + * @return bool |
|
| 242 | + */ |
|
| 243 | + public function isAlreadyThemed() { |
|
| 244 | + $theme = $this->config->getSystemValue('theme', ''); |
|
| 245 | + if ($theme !== '') { |
|
| 246 | + return true; |
|
| 247 | + } |
|
| 248 | + return false; |
|
| 249 | + } |
|
| 250 | 250 | |
| 251 | - public function isBackgroundThemed() { |
|
| 252 | - $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime',false); |
|
| 251 | + public function isBackgroundThemed() { |
|
| 252 | + $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime',false); |
|
| 253 | 253 | |
| 254 | - $backgroundExists = true; |
|
| 255 | - try { |
|
| 256 | - $this->appData->getFolder('images')->getFile('background'); |
|
| 257 | - } catch (\Exception $e) { |
|
| 258 | - $backgroundExists = false; |
|
| 259 | - } |
|
| 260 | - return $backgroundLogo && $backgroundLogo !== 'backgroundColor' && $backgroundExists; |
|
| 261 | - } |
|
| 254 | + $backgroundExists = true; |
|
| 255 | + try { |
|
| 256 | + $this->appData->getFolder('images')->getFile('background'); |
|
| 257 | + } catch (\Exception $e) { |
|
| 258 | + $backgroundExists = false; |
|
| 259 | + } |
|
| 260 | + return $backgroundLogo && $backgroundLogo !== 'backgroundColor' && $backgroundExists; |
|
| 261 | + } |
|
| 262 | 262 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function invertTextColor($color) { |
| 68 | 68 | $l = $this->calculateLuma($color); |
| 69 | - if ($l>0.6) { |
|
| 69 | + if ($l > 0.6) { |
|
| 70 | 70 | return true; |
| 71 | 71 | } else { |
| 72 | 72 | return false; |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | list($red, $green, $blue) = $this->hexToRGB($color); |
| 105 | 105 | $compiler = new Compiler(); |
| 106 | 106 | $hsl = $compiler->toHSL($red, $green, $blue); |
| 107 | - return $hsl[3]/100; |
|
| 107 | + return $hsl[3] / 100; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function calculateLuma($color) { |
| 115 | 115 | list($red, $green, $blue) = $this->hexToRGB($color); |
| 116 | - return (0.2126 * $red + 0.7152 * $green + 0.0722 * $blue) / 255; |
|
| 116 | + return (0.2126 * $red + 0.7152 * $green + 0.0722 * $blue) / 255; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | public function hexToRGB($color) { |
| 124 | 124 | $hex = preg_replace("/[^0-9A-Fa-f]/", '', $color); |
| 125 | 125 | if (strlen($hex) === 3) { |
| 126 | - $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
|
| 126 | + $hex = $hex[0].$hex[0].$hex[1].$hex[1].$hex[2].$hex[2]; |
|
| 127 | 127 | } |
| 128 | 128 | if (strlen($hex) !== 6) { |
| 129 | 129 | return 0; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * @return string base64 encoded radio button svg |
| 141 | 141 | */ |
| 142 | 142 | public function generateRadioButton($color) { |
| 143 | - $radioButtonIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16">' . |
|
| 143 | + $radioButtonIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16">'. |
|
| 144 | 144 | '<path d="M8 1a7 7 0 0 0-7 7 7 7 0 0 0 7 7 7 7 0 0 0 7-7 7 7 0 0 0-7-7zm0 1a6 6 0 0 1 6 6 6 6 0 0 1-6 6 6 6 0 0 1-6-6 6 6 0 0 1 6-6zm0 2a4 4 0 1 0 0 8 4 4 0 0 0 0-8z" fill="'.$color.'"/></svg>'; |
| 145 | 145 | return base64_encode($radioButtonIcon); |
| 146 | 146 | } |
@@ -154,11 +154,11 @@ discard block |
||
| 154 | 154 | $app = str_replace(['\0', '/', '\\', '..'], '', $app); |
| 155 | 155 | try { |
| 156 | 156 | $appPath = $this->appManager->getAppPath($app); |
| 157 | - $icon = $appPath . '/img/' . $app . '.svg'; |
|
| 157 | + $icon = $appPath.'/img/'.$app.'.svg'; |
|
| 158 | 158 | if (file_exists($icon)) { |
| 159 | 159 | return $icon; |
| 160 | 160 | } |
| 161 | - $icon = $appPath . '/img/app.svg'; |
|
| 161 | + $icon = $appPath.'/img/app.svg'; |
|
| 162 | 162 | if (file_exists($icon)) { |
| 163 | 163 | return $icon; |
| 164 | 164 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | } catch (NotFoundException $e) { |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | - return \OC::$SERVERROOT . '/core/img/logo/logo.svg'; |
|
| 178 | + return \OC::$SERVERROOT.'/core/img/logo/logo.svg'; |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | /** |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $app = str_replace(['\0', '/', '\\', '..'], '', $app); |
| 188 | 188 | $image = str_replace(['\0', '\\', '..'], '', $image); |
| 189 | 189 | if ($app === "core") { |
| 190 | - $icon = \OC::$SERVERROOT . '/core/img/' . $image; |
|
| 190 | + $icon = \OC::$SERVERROOT.'/core/img/'.$image; |
|
| 191 | 191 | if (file_exists($icon)) { |
| 192 | 192 | return $icon; |
| 193 | 193 | } |
@@ -199,23 +199,23 @@ discard block |
||
| 199 | 199 | return false; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - $icon = $appPath . '/img/' . $image; |
|
| 202 | + $icon = $appPath.'/img/'.$image; |
|
| 203 | 203 | if (file_exists($icon)) { |
| 204 | 204 | return $icon; |
| 205 | 205 | } |
| 206 | - $icon = $appPath . '/img/' . $image . '.svg'; |
|
| 206 | + $icon = $appPath.'/img/'.$image.'.svg'; |
|
| 207 | 207 | if (file_exists($icon)) { |
| 208 | 208 | return $icon; |
| 209 | 209 | } |
| 210 | - $icon = $appPath . '/img/' . $image . '.png'; |
|
| 210 | + $icon = $appPath.'/img/'.$image.'.png'; |
|
| 211 | 211 | if (file_exists($icon)) { |
| 212 | 212 | return $icon; |
| 213 | 213 | } |
| 214 | - $icon = $appPath . '/img/' . $image . '.gif'; |
|
| 214 | + $icon = $appPath.'/img/'.$image.'.gif'; |
|
| 215 | 215 | if (file_exists($icon)) { |
| 216 | 216 | return $icon; |
| 217 | 217 | } |
| 218 | - $icon = $appPath . '/img/' . $image . '.jpg'; |
|
| 218 | + $icon = $appPath.'/img/'.$image.'.jpg'; |
|
| 219 | 219 | if (file_exists($icon)) { |
| 220 | 220 | return $icon; |
| 221 | 221 | } |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | public function isBackgroundThemed() { |
| 252 | - $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime',false); |
|
| 252 | + $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', false); |
|
| 253 | 253 | |
| 254 | 254 | $backgroundExists = true; |
| 255 | 255 | try { |