This commit is contained in:
@@ -9,9 +9,13 @@ $dashboardUserId = (int)($_SESSION['user_id'] ?? 0);
|
||||
$requestedCreateListingKind = isset($_GET['create_listing']) && in_array((string)$_GET['create_listing'], ['place', 'editorial_event'], true)
|
||||
? (string)$_GET['create_listing']
|
||||
: null;
|
||||
$restoreEventDraftActive = !empty($restoreEventDraftActive);
|
||||
$editingEvent = isset($editEvent) && $editEvent !== null;
|
||||
$editingListing = isset($editListing) && $editListing !== null;
|
||||
$editing = $editingEvent || $editingListing;
|
||||
$eventDraftValues = (!$editing && (($section ?? '') === 'events') && $restoreEventDraftActive && is_array($restoredEventDraft ?? null))
|
||||
? $restoredEventDraft
|
||||
: [];
|
||||
$currentEntryKind = $editingListing
|
||||
? (string)($editListing['listing_type'] ?? 'editorial_event')
|
||||
: ((($section ?? 'events') === 'places') ? ($requestedCreateListingKind ?? 'place') : 'event');
|
||||
@@ -21,23 +25,27 @@ if ($editingEvent && !empty($editEvent['starts_at'])) {
|
||||
$startVal = date('Y-m-d', strtotime((string)$editEvent['starts_at']));
|
||||
} elseif ($editingListing && !empty($editListing['starts_at'])) {
|
||||
$startVal = date('Y-m-d', strtotime((string)$editListing['starts_at']));
|
||||
} elseif (!empty($eventDraftValues['starts_at'])) {
|
||||
$startVal = (string)$eventDraftValues['starts_at'];
|
||||
}
|
||||
$withChildrenValue = $editingEvent ? (((int)($editEvent['allow_kids'] ?? 1)) === 1 ? 'yes' : 'no') : (($editingListing && $currentEntryKind === 'editorial_event' && !empty($editListing['supports_registration'])) ? 'yes' : 'yes');
|
||||
$withChildrenValue = $editingEvent
|
||||
? (((int)($editEvent['allow_kids'] ?? 1)) === 1 ? 'yes' : 'no')
|
||||
: (!empty($eventDraftValues['with_children']) ? (string)$eventDraftValues['with_children'] : (($editingListing && $currentEntryKind === 'editorial_event' && !empty($editListing['supports_registration'])) ? 'yes' : 'yes'));
|
||||
$eventTitle = $editingEvent ? 'Event bearbeiten' : ($editingListing ? ($currentEntryKind === 'place' ? 'Änderung für Ort anfragen' : 'Änderung für Veranstaltung anfragen') : ((($section ?? 'events') === 'places') ? 'Ort oder Veranstaltung anlegen' : 'Neues Event anlegen'));
|
||||
$submitLabel = $editingEvent ? 'Event speichern' : ($editingListing ? 'Änderungsanfrage senden' : ((($section ?? 'events') === 'places') ? 'Eintrag zur Freigabe einreichen' : 'Event anlegen'));
|
||||
$titleValue = $editingEvent ? (string)($editEvent['title'] ?? '') : (string)($editListing['title'] ?? '');
|
||||
$titleValue = $editingEvent ? (string)($editEvent['title'] ?? '') : (!empty($eventDraftValues['title']) ? (string)$eventDraftValues['title'] : (string)($editListing['title'] ?? ''));
|
||||
$teaserValue = $editingEvent ? (string)($editEvent['teaser_public'] ?? '') : (string)($editListing['teaser_public'] ?? '');
|
||||
$descriptionValue = $editingEvent ? (string)($editEvent['description'] ?? '') : (string)($editListing['description'] ?? '');
|
||||
$streetValue = $editingEvent ? (string)($editEvent['street'] ?? '') : (string)($editListing['street'] ?? '');
|
||||
$zipValue = $editingEvent ? (string)($editEvent['zip'] ?? '') : (string)($editListing['zip'] ?? '');
|
||||
$cityValue = $editingEvent ? (string)($editEvent['city'] ?? '') : (string)($editListing['city'] ?? '');
|
||||
$regionValue = $editingEvent ? (string)($editEvent['region'] ?? '') : (string)($editListing['region'] ?? '');
|
||||
$latValue = $editingEvent ? (string)($editEvent['lat'] ?? '') : (string)($editListing['lat'] ?? '');
|
||||
$lngValue = $editingEvent ? (string)($editEvent['lng'] ?? '') : (string)($editListing['lng'] ?? '');
|
||||
$visibilityValue = $editingEvent ? (string)($editEvent['visibility'] ?? 'public') : (string)($editListing['visibility'] ?? 'public');
|
||||
$categorySlugValue = $editingEvent ? (string)($editEvent['category_slug'] ?? '') : (string)($editListing['category_slug'] ?? '');
|
||||
$descriptionValue = $editingEvent ? (string)($editEvent['description'] ?? '') : (!empty($eventDraftValues['description']) ? (string)$eventDraftValues['description'] : (string)($editListing['description'] ?? ''));
|
||||
$streetValue = $editingEvent ? (string)($editEvent['street'] ?? '') : (isset($eventDraftValues['street']) ? (string)$eventDraftValues['street'] : (string)($editListing['street'] ?? ''));
|
||||
$zipValue = $editingEvent ? (string)($editEvent['zip'] ?? '') : (isset($eventDraftValues['zip']) ? (string)$eventDraftValues['zip'] : (string)($editListing['zip'] ?? ''));
|
||||
$cityValue = $editingEvent ? (string)($editEvent['city'] ?? '') : (isset($eventDraftValues['city']) ? (string)$eventDraftValues['city'] : (string)($editListing['city'] ?? ''));
|
||||
$regionValue = $editingEvent ? (string)($editEvent['region'] ?? '') : (isset($eventDraftValues['region']) ? (string)$eventDraftValues['region'] : (string)($editListing['region'] ?? ''));
|
||||
$latValue = $editingEvent ? (string)($editEvent['lat'] ?? '') : (isset($eventDraftValues['lat']) ? (string)$eventDraftValues['lat'] : (string)($editListing['lat'] ?? ''));
|
||||
$lngValue = $editingEvent ? (string)($editEvent['lng'] ?? '') : (isset($eventDraftValues['lng']) ? (string)$eventDraftValues['lng'] : (string)($editListing['lng'] ?? ''));
|
||||
$visibilityValue = $editingEvent ? (string)($editEvent['visibility'] ?? 'public') : (!empty($eventDraftValues['visibility']) ? (string)$eventDraftValues['visibility'] : (string)($editListing['visibility'] ?? 'public'));
|
||||
$categorySlugValue = $editingEvent ? (string)($editEvent['category_slug'] ?? '') : (!empty($eventDraftValues['category_slug']) ? (string)$eventDraftValues['category_slug'] : (string)($editListing['category_slug'] ?? ''));
|
||||
$imagePathValue = $editingEvent ? (string)($editEvent['image_path'] ?? '') : (string)($editListing['image_path'] ?? '');
|
||||
$capacityValue = $editingEvent ? (string)($editEvent['max_participants'] ?? '') : (string)($editListing['capacity_total'] ?? '');
|
||||
$capacityValue = $editingEvent ? (string)($editEvent['max_participants'] ?? '') : (isset($eventDraftValues['max_participants']) ? (string)$eventDraftValues['max_participants'] : (string)($editListing['capacity_total'] ?? ''));
|
||||
$phoneValue = $editingListing ? (string)($editListing['phone'] ?? '') : '';
|
||||
$websiteValue = $editingListing ? (string)($editListing['website_url'] ?? '') : '';
|
||||
$specialConditionsValue = $editingListing ? (string)($editListing['special_conditions_note'] ?? '') : '';
|
||||
@@ -58,15 +66,11 @@ $categoryTitleMap = [];
|
||||
foreach (($listingCategories ?? []) as $categoryRow) {
|
||||
$categoryTitleMap[(string)($categoryRow['slug'] ?? '')] = (string)($categoryRow['title'] ?? '');
|
||||
}
|
||||
$categoryInputValue = $categoryTitleMap[$categorySlugValue] ?? $categorySlugValue;
|
||||
$eventLocationModeValue = $editingEvent ? (string)($editEvent['location_source_type'] ?? 'custom') : 'custom';
|
||||
$eventLocationSourceIdValue = $editingEvent && !empty($editEvent['location_source_listing_id']) ? (int)$editEvent['location_source_listing_id'] : 0;
|
||||
$usesDatabaseEventLocation = $currentEntryKind === 'event' && $eventLocationModeValue !== 'custom';
|
||||
$eventAddressInfoValue = trim(implode(', ', array_filter([
|
||||
$streetValue,
|
||||
trim($zipValue . ' ' . $cityValue),
|
||||
$regionValue,
|
||||
])));
|
||||
$categoryInputValue = !empty($eventDraftValues['category_input'])
|
||||
? (string)$eventDraftValues['category_input']
|
||||
: ($categoryTitleMap[$categorySlugValue] ?? $categorySlugValue);
|
||||
$eventLocationModeValue = $editingEvent ? (string)($editEvent['location_source_type'] ?? 'custom') : (!empty($eventDraftValues['event_location_mode']) ? (string)$eventDraftValues['event_location_mode'] : 'custom');
|
||||
$eventLocationSourceIdValue = $editingEvent && !empty($editEvent['location_source_listing_id']) ? (int)$editEvent['location_source_listing_id'] : (!empty($eventDraftValues['event_location_source_id']) ? (int)$eventDraftValues['event_location_source_id'] : 0);
|
||||
$eventLocationPlaceOptions = [];
|
||||
$eventLocationEditorialOptions = [];
|
||||
foreach (($eventLocationOptions ?? []) as $locationOption) {
|
||||
@@ -83,13 +87,24 @@ foreach (($eventLocationOptions ?? []) as $locationOption) {
|
||||
(string)($locationOption['street'] ?? ''),
|
||||
trim((string)($locationOption['zip'] ?? '') . ' ' . (string)($locationOption['city'] ?? '')),
|
||||
])));
|
||||
$optionDateLabel = !empty($locationOption['starts_at']) ? date('d.m.Y', strtotime((string)$locationOption['starts_at'])) : '';
|
||||
if ($eventLocationModeValue !== 'custom' && !empty($locationOption['category_title'])) {
|
||||
$categoryInputValue = (string)$locationOption['category_title'];
|
||||
$categorySlugValue = (string)($locationOption['category_slug'] ?? $categorySlugValue);
|
||||
$streetValue = (string)($locationOption['street'] ?? $streetValue);
|
||||
$zipValue = (string)($locationOption['zip'] ?? $zipValue);
|
||||
$cityValue = (string)($locationOption['city'] ?? $cityValue);
|
||||
$regionValue = (string)($locationOption['region'] ?? $regionValue);
|
||||
$latValue = (string)($locationOption['lat'] ?? $latValue);
|
||||
$lngValue = (string)($locationOption['lng'] ?? $lngValue);
|
||||
}
|
||||
break;
|
||||
}
|
||||
$usesDatabaseEventLocation = $currentEntryKind === 'event' && $eventLocationModeValue !== 'custom';
|
||||
$eventAddressInfoValue = trim(implode(', ', array_filter([
|
||||
$streetValue,
|
||||
trim($zipValue . ' ' . $cityValue),
|
||||
$regionValue,
|
||||
])));
|
||||
$priceRows = [];
|
||||
if ($editingListing && !empty($editListing['prices']) && is_array($editListing['prices'])) {
|
||||
foreach ($editListing['prices'] as $priceRow) {
|
||||
@@ -1127,7 +1142,7 @@ if (!empty($canManageSystemSettings)) {
|
||||
<h3><?= htmlspecialchars($eventTitle, ENT_QUOTES) ?></h3>
|
||||
<button class="btn ghost" type="button" data-modal-close>✕</button>
|
||||
</div>
|
||||
<form class="stack gap-12" style="margin-top: 10px;" method="post" action="/dashboard?section=<?= htmlspecialchars($modalSectionTarget, ENT_QUOTES) ?>#<?= htmlspecialchars($modalSectionTarget, ENT_QUOTES) ?>" enctype="multipart/form-data">
|
||||
<form id="eventEditorForm" class="stack gap-12" style="margin-top: 10px;" method="post" action="/dashboard?section=<?= htmlspecialchars($modalSectionTarget, ENT_QUOTES) ?>#<?= htmlspecialchars($modalSectionTarget, ENT_QUOTES) ?>" enctype="multipart/form-data">
|
||||
<input type="hidden" name="action" value="<?= htmlspecialchars($actionEvent, ENT_QUOTES) ?>">
|
||||
<input type="hidden" name="entry_kind" id="entryKind" value="<?= htmlspecialchars($currentEntryKind, ENT_QUOTES) ?>">
|
||||
<?php if ($editingEvent && $editEvent): ?>
|
||||
@@ -1204,8 +1219,8 @@ if (!empty($canManageSystemSettings)) {
|
||||
</div>
|
||||
<?php if (($section ?? 'events') === 'events' && !$editingListing): ?>
|
||||
<div class="flex gap-8" style="flex-wrap:wrap;" id="eventCreateListingActionsWrap">
|
||||
<a class="btn ghost" href="/dashboard?section=places&create_listing=place#places">Neuen Ort anlegen</a>
|
||||
<a class="btn ghost" href="/dashboard?section=places&create_listing=editorial_event#places">Neue Veranstaltung anlegen</a>
|
||||
<button class="btn ghost" type="button" data-event-create-listing="place">Neuen Ort anlegen</button>
|
||||
<button class="btn ghost" type="button" data-event-create-listing="editorial_event">Neue Veranstaltung anlegen</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="stack gap-6" id="categoryInputWrap"<?= $usesDatabaseEventLocation ? ' hidden' : '' ?>>
|
||||
@@ -1405,6 +1420,11 @@ if (!empty($canManageSystemSettings)) {
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<form id="eventDraftRedirectForm" method="post" action="/dashboard?section=events#events" hidden>
|
||||
<input type="hidden" name="action" value="event_draft_store">
|
||||
<input type="hidden" name="target_kind" id="eventDraftTargetKind" value="">
|
||||
</form>
|
||||
|
||||
<script>
|
||||
document.querySelectorAll('[data-modal-open]').forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
@@ -1451,6 +1471,10 @@ if (!empty($canManageSystemSettings)) {
|
||||
const eventCapacityWrap = document.getElementById('eventCapacityWrap');
|
||||
const eventLocationModeWrap = document.getElementById('eventLocationModeWrap');
|
||||
const eventLocationModeSelect = document.getElementById('eventLocationMode');
|
||||
const eventEditorForm = document.getElementById('eventEditorForm');
|
||||
const eventDraftRedirectForm = document.getElementById('eventDraftRedirectForm');
|
||||
const eventDraftTargetKind = document.getElementById('eventDraftTargetKind');
|
||||
const eventCreateListingButtons = document.querySelectorAll('[data-event-create-listing]');
|
||||
const eventLocationSourceWrap = document.getElementById('eventLocationSourceWrap');
|
||||
const eventLocationSourceSelect = document.getElementById('eventLocationSourceSelect');
|
||||
const eventLocationSourceIdInput = document.getElementById('eventLocationSourceId');
|
||||
@@ -1803,6 +1827,49 @@ if (!empty($canManageSystemSettings)) {
|
||||
});
|
||||
}
|
||||
|
||||
function submitEventDraftRedirect(targetKind) {
|
||||
if (!eventEditorForm || !eventDraftRedirectForm || !eventDraftTargetKind) return;
|
||||
const allowedFieldNames = new Set([
|
||||
'title',
|
||||
'description',
|
||||
'starts_at',
|
||||
'with_children',
|
||||
'max_participants',
|
||||
'visibility',
|
||||
'event_location_mode',
|
||||
'event_location_source_id',
|
||||
'street',
|
||||
'zip',
|
||||
'city',
|
||||
'region',
|
||||
'lat',
|
||||
'lng',
|
||||
'category_input',
|
||||
'category_slug',
|
||||
]);
|
||||
eventDraftRedirectForm.querySelectorAll('[data-event-draft-copy]').forEach((node) => node.remove());
|
||||
const formData = new FormData(eventEditorForm);
|
||||
formData.forEach((value, key) => {
|
||||
if (!allowedFieldNames.has(key) || typeof value !== 'string') {
|
||||
return;
|
||||
}
|
||||
const input = document.createElement('input');
|
||||
input.type = 'hidden';
|
||||
input.name = key;
|
||||
input.value = value;
|
||||
input.setAttribute('data-event-draft-copy', 'true');
|
||||
eventDraftRedirectForm.appendChild(input);
|
||||
});
|
||||
eventDraftTargetKind.value = targetKind;
|
||||
eventDraftRedirectForm.submit();
|
||||
}
|
||||
|
||||
eventCreateListingButtons.forEach((button) => {
|
||||
button.addEventListener('click', () => {
|
||||
submitEventDraftRedirect(button.getAttribute('data-event-create-listing') || 'place');
|
||||
});
|
||||
});
|
||||
|
||||
eventTabButtons.forEach((button) => {
|
||||
button.addEventListener('click', () => {
|
||||
setEventTab(button.getAttribute('data-event-tab-trigger') || 'my-events');
|
||||
@@ -2223,7 +2290,7 @@ if (!empty($canManageSystemSettings)) {
|
||||
setNeedsValidation(false);
|
||||
})();
|
||||
|
||||
<?php if ($editing || $requestedCreateListingKind !== null): ?>
|
||||
<?php if ($editing || $requestedCreateListingKind !== null || $restoreEventDraftActive): ?>
|
||||
(function(){
|
||||
const modal = document.getElementById('modalEvent');
|
||||
if (modal) {
|
||||
|
||||
Reference in New Issue
Block a user