$query */ public function url(string $page, array $query = []): string { $url = $this->baseUrl() . '/' . ltrim($page, '/'); if ($query !== []) { $url .= '?' . http_build_query($query); } return $url; } public function t(string $key): string { return $this->lang->t($key); } public function post(string $key, string $default = ''): string { return Http::getString($_POST, $key, $default); } public function query(string $key, string $default = ''): string { return Http::getString($_GET, $key, $default); } public function requirePost(): void { if (!Http::isPost()) { throw new RuntimeException('Method not allowed'); } } public function csrfField(string $intent): string { $issued = $this->csrf->issue($intent); return '' . '' . ''; } public function requireCsrf(string $intent): void { if (!$this->csrf->validate($intent, $this->post('csrf_ts'), $this->post('csrf_token'), 3600, $this->post('csrf_sid'))) { throw new RuntimeException('Nieprawidłowy lub wygasły token CSRF.'); } } public function render(string $title, string $body, array $ok = [], array $errors = []): void { header('Content-Type: text/html; charset=UTF-8'); $alerts = ''; foreach ($ok as $msg) { $alerts .= '
' . self::e((string)$msg) . '
'; } foreach ($errors as $msg) { $alerts .= '
' . self::e((string)$msg) . '
'; } echo ''; echo ''; echo '' . self::e($this->t($title)) . ''; echo '
'; echo '

' . self::e($this->t($title)) . '

' . self::e($this->t('Manage automatic replies for account mailboxes')) . '

'; echo '
' . self::e($this->t('AUTORESPONDERS')) . ''; echo '' . self::e($this->t('ADD AUTORESPONDER')) . '
'; echo '
' . $alerts . $this->lang->translateHtml($body) . '
'; echo ''; } public static function e(string $value): string { return htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); } private function styles(): string { $skin = $this->daUser->skin(); $path = PLUGIN_ROOT . '/user/' . $skin . '.css'; if (!is_file($path)) { $path = PLUGIN_ROOT . '/user/enhanced.css'; } return is_file($path) ? (string)file_get_contents($path) : ''; } private function scripts(): string { return <<<'JS' (function () { document.querySelectorAll('[data-date-value]').forEach(function (btn) { btn.addEventListener('click', function () { var target = document.getElementById(btn.getAttribute('data-date-target')); var label = document.getElementById(btn.getAttribute('data-date-label')); if (target) { target.value = btn.getAttribute('data-date-value') || ''; } if (label) { label.textContent = 'Wybrano: ' + (btn.getAttribute('data-date-value') || ''); } btn.closest('.br-restore-calendar').querySelectorAll('.br-cal-day').forEach(function (d) { d.classList.remove('is-selected'); }); btn.classList.add('is-selected'); }); }); })(); JS; } }