Sync global-autoresponder current state
This commit is contained in:
+60
-7
@@ -33,9 +33,10 @@ final class AppContext
|
||||
return $url;
|
||||
}
|
||||
|
||||
public function t(string $key): string
|
||||
/** @param array<string,string|int|float> $vars */
|
||||
public function t(string $key, array $vars = []): string
|
||||
{
|
||||
return $this->lang->t($key);
|
||||
return $this->lang->t($key, $vars);
|
||||
}
|
||||
|
||||
public function post(string $key, string $default = ''): string
|
||||
@@ -70,11 +71,8 @@ final class AppContext
|
||||
}
|
||||
}
|
||||
|
||||
public function syncActiveBackend(): void
|
||||
public function syncDirectAdminVacations(): void
|
||||
{
|
||||
if ($this->settings->backendMode() !== 'da') {
|
||||
return;
|
||||
}
|
||||
$service = new DirectAdminVacationSyncService(
|
||||
$this->rules,
|
||||
new DirectAdminSyncRepository(),
|
||||
@@ -98,7 +96,7 @@ final class AppContext
|
||||
echo '<meta name="viewport" content="width=device-width, initial-scale=1">';
|
||||
echo '<title>' . self::e($this->t($title)) . '</title><style>' . $this->styles() . '</style></head><body>';
|
||||
echo '<div class="wrap"><div class="breadcrumbs">' . self::e($this->t('Dashboard')) . ' <span>></span> ' . self::e($this->t('Global autoresponders')) . '</div>';
|
||||
echo '<header><h1>' . self::e($this->t($title)) . '</h1><p>' . self::e($this->t('Manage automatic replies for account mailboxes')) . '</p></header>';
|
||||
echo '<header><h1>' . self::e($this->t($title)) . '</h1></header>';
|
||||
echo '<div class="top-actions"><a class="btn amber' . ($this->action() === 'index' ? ' active' : '') . '" href="' . self::e($this->url('index.html')) . '">' . self::e($this->t('AUTORESPONDERS')) . '</a>';
|
||||
echo '<a class="btn amber' . ($this->action() === 'create' ? ' active' : '') . '" href="' . self::e($this->url('create.html')) . '">' . self::e($this->t('ADD AUTORESPONDER')) . '</a></div>';
|
||||
echo '<section class="main-section">' . $alerts . $body . '</section></div>';
|
||||
@@ -113,6 +111,12 @@ final class AppContext
|
||||
private function styles(): string
|
||||
{
|
||||
$skin = $this->daUser->skin();
|
||||
if ($skin === 'evolution') {
|
||||
$base = PLUGIN_ROOT . '/user/enhanced.css';
|
||||
$override = PLUGIN_ROOT . '/user/evolution.css';
|
||||
return (is_file($base) ? (string)file_get_contents($base) : '') . "\n" .
|
||||
(is_file($override) ? (string)file_get_contents($override) : '');
|
||||
}
|
||||
$path = PLUGIN_ROOT . '/user/' . $skin . '.css';
|
||||
if (!is_file($path)) {
|
||||
$path = PLUGIN_ROOT . '/user/enhanced.css';
|
||||
@@ -122,14 +126,39 @@ final class AppContext
|
||||
|
||||
private function scripts(): string
|
||||
{
|
||||
$skin = json_encode($this->daUser->skin(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT);
|
||||
$selectedLabel = json_encode($this->t('Selected'), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT);
|
||||
$monthNames = json_encode($this->lang->code() === 'pl'
|
||||
? ['Styczeń', 'Luty', 'Marzec', 'Kwiecień', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpień', 'Wrzesień', 'Październik', 'Listopad', 'Grudzień']
|
||||
: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT);
|
||||
return <<<JS
|
||||
(function () {
|
||||
var pluginSkin = {$skin};
|
||||
var selectedLabel = {$selectedLabel};
|
||||
var monthNames = {$monthNames};
|
||||
function expandDirectAdminPluginContainers() {
|
||||
if (pluginSkin !== 'evolution') { return; }
|
||||
var wrap = document.querySelector('.wrap');
|
||||
if (!wrap) { return; }
|
||||
wrap.style.width = '100%';
|
||||
wrap.style.maxWidth = 'none';
|
||||
wrap.style.marginLeft = '0';
|
||||
wrap.style.marginRight = '0';
|
||||
var node = wrap.parentElement;
|
||||
var guard = 0;
|
||||
while (node && node !== document.body && guard < 12) {
|
||||
var id = node.id || '';
|
||||
var className = typeof node.className === 'string' ? node.className : '';
|
||||
var matchesDirectAdminContainer = id === 'content' || /(^|\\s)(container|container-fluid|main-content|page-content|content|content-wrapper|main-content-wrapper)(\\s|$)/.test(className);
|
||||
var computed = window.getComputedStyle ? window.getComputedStyle(node) : null;
|
||||
if (matchesDirectAdminContainer || (computed && computed.maxWidth && computed.maxWidth !== 'none')) {
|
||||
node.style.maxWidth = 'none';
|
||||
node.style.width = '100%';
|
||||
}
|
||||
node = node.parentElement;
|
||||
guard++;
|
||||
}
|
||||
}
|
||||
function pad(value) { return value < 10 ? '0' + value : String(value); }
|
||||
function updateCanonical(name) {
|
||||
var date = document.getElementById(name + '_date');
|
||||
@@ -195,6 +224,11 @@ final class AppContext
|
||||
document.querySelectorAll('[data-date-value]').forEach(function (btn) {
|
||||
bindDateButton(btn);
|
||||
});
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', expandDirectAdminPluginContainers);
|
||||
} else {
|
||||
expandDirectAdminPluginContainers();
|
||||
}
|
||||
document.querySelectorAll('[data-calendar-picker]').forEach(function (calendar) {
|
||||
var name = calendar.getAttribute('data-calendar-name');
|
||||
calendar.querySelectorAll('[data-calendar-prev],[data-calendar-next]').forEach(function (btn) {
|
||||
@@ -214,6 +248,25 @@ final class AppContext
|
||||
control.addEventListener('input', function () { updateCanonical(name); });
|
||||
});
|
||||
});
|
||||
document.querySelectorAll('[data-modal-close]').forEach(function (btn) {
|
||||
btn.addEventListener('click', function () {
|
||||
var overlay = btn.closest('.br-overlay');
|
||||
if (overlay) {
|
||||
overlay.style.display = 'none';
|
||||
}
|
||||
document.body.classList.remove('modal-open');
|
||||
});
|
||||
});
|
||||
if (document.querySelector('.br-overlay')) {
|
||||
document.body.classList.add('modal-open');
|
||||
}
|
||||
document.addEventListener('keydown', function (event) {
|
||||
if (event.key !== 'Escape') { return; }
|
||||
document.querySelectorAll('.br-overlay').forEach(function (overlay) {
|
||||
overlay.style.display = 'none';
|
||||
});
|
||||
document.body.classList.remove('modal-open');
|
||||
});
|
||||
})();
|
||||
JS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user