Files
FreshRSS/lib/core-extensions/UserJS/extension.php
Inverle 5ef8756e49 Update user modify date when changing UserJS/UserCSS (#8607)
UserCSS textarea wasn't being updated after changing the CSS until clearing cache
(while using Chromium with a normal browser window)
2026-03-15 13:52:57 +01:00

40 lines
908 B
PHP

<?php
declare(strict_types=1);
final class UserJSExtension extends Minz_Extension {
public string $js_rules = '';
private const FILENAME = 'script.js';
#[\Override]
public function init(): void {
parent::init();
$this->registerTranslates();
if ($this->hasFile(self::FILENAME)) {
Minz_View::appendScript($this->getFileUrl(self::FILENAME, isStatic: false));
}
}
#[\Override]
public function handleConfigureAction(): void {
parent::init();
$this->registerTranslates();
if (FreshRSS_Auth::requestReauth()) {
return;
}
if (Minz_Request::isPost()) {
$js_rules = Minz_Request::paramString('js-rules', plaintext: true);
$this->saveFile(self::FILENAME, $js_rules);
FreshRSS_UserDAO::touch();
}
$this->js_rules = '';
if ($this->hasFile(self::FILENAME)) {
$this->js_rules = htmlspecialchars($this->getFile(self::FILENAME) ?? '', ENT_NOQUOTES, 'UTF-8');
}
}
}