aboutsummaryrefslogtreecommitdiff
path: root/lib/core-extensions/UserCSS/extension.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/core-extensions/UserCSS/extension.php')
-rw-r--r--lib/core-extensions/UserCSS/extension.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/core-extensions/UserCSS/extension.php b/lib/core-extensions/UserCSS/extension.php
new file mode 100644
index 000000000..5343fd39a
--- /dev/null
+++ b/lib/core-extensions/UserCSS/extension.php
@@ -0,0 +1,34 @@
+<?php
+declare(strict_types=1);
+
+final class UserCSSExtension extends Minz_Extension {
+ public string $css_rules = '';
+ private const FILENAME = 'style.css';
+
+ #[\Override]
+ public function init(): void {
+ parent::init();
+
+ $this->registerTranslates();
+ if ($this->hasFile(self::FILENAME)) {
+ Minz_View::appendStyle($this->getFileUrl(self::FILENAME, 'css', false));
+ }
+ }
+
+ #[\Override]
+ public function handleConfigureAction(): void {
+ parent::init();
+
+ $this->registerTranslates();
+
+ if (Minz_Request::isPost()) {
+ $css_rules = html_entity_decode(Minz_Request::paramString('css-rules'));
+ $this->saveFile(self::FILENAME, $css_rules);
+ }
+
+ $this->css_rules = '';
+ if ($this->hasFile(self::FILENAME)) {
+ $this->css_rules = htmlentities($this->getFile(self::FILENAME) ?? '');
+ }
+ }
+}