settings($moduleName); $notice = null; $error = null; $getValue = static function (array $source, string $path): mixed { $value = $source; foreach (explode('.', $path) as $segment) { if (!is_array($value) || !array_key_exists($segment, $value)) { return null; } $value = $value[$segment]; } return $value; }; $setValue = static function (array &$target, string $path, mixed $value): void { $segments = explode('.', $path); $cursor = &$target; foreach ($segments as $index => $segment) { if ($index === count($segments) - 1) { $cursor[$segment] = $value; return; } if (!isset($cursor[$segment]) || !is_array($cursor[$segment])) { $cursor[$segment] = []; } $cursor = &$cursor[$segment]; } }; if ($_SERVER['REQUEST_METHOD'] === 'POST' && (string) ($_POST['action'] ?? '') === 'save_setup') { try { $nextSettings = $settings; foreach ($fields as $field) { if (!is_array($field)) { continue; } $name = trim((string) ($field['name'] ?? '')); $type = trim((string) ($field['type'] ?? 'text')); if ($name === '') { continue; } $raw = $_POST['settings'][$name] ?? null; $value = match ($type) { 'checkbox' => $raw !== null, 'number' => ($raw === null || $raw === '') ? null : (is_numeric((string) $raw) ? 0 + $raw : null), default => is_string($raw) ? trim($raw) : '', }; $setValue($nextSettings, $name, $value); } modules()->saveSettings($moduleName, $nextSettings); $settings = modules()->settings($moduleName); $notice = 'Setup gespeichert.'; } catch (\Throwable $e) { $error = $e->getMessage(); } } echo module_shell_header('boersenchecker', [ 'title' => 'Setup', 'description' => 'Modulkonfiguration, API-Zugang und optionale separate Datenbank.', ]); ?>
Die Felder entsprechen dem alten Nexus-Modul und werden lokal in `data/module-settings/boersenchecker.json` gespeichert.