url($isUpdate ? 'update.html' : 'create.html'); $intent = $isUpdate ? 'update:' . $id : 'create'; $csrf = $ctx->csrfField($intent); $hiddenId = $isUpdate ? '' : ''; return '
' . $csrf . $hiddenId . '

' . AppContext::e($ctx->t('Response content')) . '

' . '
' . '
' . render_calendar_picker($ctx, 'start_value', $ctx->t('Start date'), $startValue) . render_calendar_picker($ctx, 'end_value', $ctx->t('End date'), $endValue) . '
' . AppContext::e($ctx->t('Cancel')) . '
' . '
'; } /** @param array $post @return array */ function normalize_rule_post(array $post): array { foreach (['start_value', 'end_value'] as $key) { $date = trim((string)($post[$key . '_date'] ?? '')); $time = trim((string)($post[$key . '_time'] ?? '')); $period = trim((string)($post[$key . '_period'] ?? '')); if ($date !== '' && preg_match('/^[0-9]{2}:[0-9]{2}$/', $time)) { $post[$key] = $date . 'T' . $time; } elseif ($date !== '' && preg_match('/^(morning|afternoon|evening)$/', $period)) { $post[$key] = $date . '|' . $period; } } return $post; } function render_calendar_picker(AppContext $ctx, string $name, string $title, string $value): string { $mode = $ctx->settings->scheduleMode(); $selectedDate = substr($value, 0, 10); $selectedTime = '09:00'; $selectedPeriod = 'morning'; if ($mode === 'exact_hour' && preg_match('/T([0-9]{2}:[0-9]{2})$/', $value, $m)) { $selectedTime = $m[1]; } elseif ($mode === 'directadmin_period' && preg_match('/\|(morning|afternoon|evening)$/', $value, $m)) { $selectedPeriod = $m[1]; } $days = ''; for ($week = 0, $day = 1; $week < 4; $week++) { $days .= ''; for ($i = 0; $i < 7; $i++, $day++) { $date = sprintf('2026-06-%02d', $day); $class = $date === $selectedDate ? ' is-selected' : ''; $days .= ''; } $days .= ''; } if ($mode === 'exact_hour') { $timeControl = ''; } else { $timeControl = ''; } return '

' . AppContext::e($title) . '

' . AppContext::e($title) . '

Czerwiec 2026
' . '' . $days . '
PnWtŚrCzPtSbNd
' . '
Wybrano: ' . AppContext::e($selectedDate) . '
' . '

' . AppContext::e($ctx->t('Time')) . '

' . $timeControl . '
' . '
'; } function render_preview_box(array $rule): string { return '
Temat: ' . AppContext::e((string)$rule['subject']) . '

' . nl2br(AppContext::e((string)$rule['body'])) . '
'; }