This commit is contained in:
@@ -377,9 +377,40 @@ final class AccountPages
|
||||
if (!$listingCatalog) {
|
||||
throw new \RuntimeException('Die neue Eintragslogik ist aktuell nicht verfügbar.');
|
||||
}
|
||||
$payload = $_POST;
|
||||
$street = trim((string)($_POST['street'] ?? ''));
|
||||
$zip = trim((string)($_POST['zip'] ?? ''));
|
||||
$city = trim((string)($_POST['city'] ?? ''));
|
||||
$region = trim((string)($_POST['region'] ?? ''));
|
||||
$lat = isset($_POST['lat']) && $_POST['lat'] !== '' ? (float)$_POST['lat'] : null;
|
||||
$lng = isset($_POST['lng']) && $_POST['lng'] !== '' ? (float)$_POST['lng'] : null;
|
||||
$hasAddress = $street !== '' || $zip !== '' || $city !== '' || $region !== '';
|
||||
if ($hasAddress) {
|
||||
$resolvedAddress = null;
|
||||
if ($lat !== null && $lng !== null) {
|
||||
$resolvedAddress = self::reverseGeocodeAddress($lat, $lng);
|
||||
}
|
||||
if ($resolvedAddress === null) {
|
||||
$searchResults = self::geocodeAddressCandidates($street, $zip, $city, $region, 5);
|
||||
if (!$searchResults) {
|
||||
throw new \RuntimeException('Die Adresse konnte nicht validiert werden. Bitte wähle einen passenden Adress-Treffer.');
|
||||
}
|
||||
$resolvedAddress = $searchResults[0];
|
||||
}
|
||||
$payload['street'] = $resolvedAddress['street'] !== '' ? $resolvedAddress['street'] : $street;
|
||||
$payload['zip'] = $resolvedAddress['zip'] !== '' ? $resolvedAddress['zip'] : $zip;
|
||||
$payload['city'] = $resolvedAddress['city'] !== '' ? $resolvedAddress['city'] : $city;
|
||||
$payload['region'] = $resolvedAddress['region'] !== '' ? $resolvedAddress['region'] : $region;
|
||||
$payload['lat'] = $resolvedAddress['lat'];
|
||||
$payload['lng'] = $resolvedAddress['lng'];
|
||||
}
|
||||
$payload['teaser'] = self::generateTeaser(
|
||||
trim((string)($payload['description'] ?? '')),
|
||||
trim((string)($payload['title'] ?? ''))
|
||||
);
|
||||
$listingCatalog->saveDashboardEntry(
|
||||
$userId,
|
||||
$_POST,
|
||||
$payload,
|
||||
$action === 'event_update' ? (int)($_POST['listing_id'] ?? 0) : null
|
||||
);
|
||||
$info = $entryKind === 'place' ? 'Ort gespeichert.' : 'Veranstaltung gespeichert.';
|
||||
@@ -403,7 +434,7 @@ final class AccountPages
|
||||
$stmt?->execute([
|
||||
'uid' => $userId,
|
||||
'title' => trim((string)$_POST['title']),
|
||||
'teaser' => trim((string)$_POST['teaser']),
|
||||
'teaser' => self::generateTeaser(trim((string)$_POST['description']), trim((string)$_POST['title'])),
|
||||
'descr' => trim((string)$_POST['description']),
|
||||
'loc' => trim((string)$_POST['location_label']),
|
||||
'street' => $street ?: null,
|
||||
@@ -432,7 +463,7 @@ final class AccountPages
|
||||
'id' => $eventId,
|
||||
'uid' => $userId,
|
||||
'title' => trim((string)$_POST['title']),
|
||||
'teaser' => trim((string)$_POST['teaser']),
|
||||
'teaser' => self::generateTeaser(trim((string)$_POST['description']), trim((string)$_POST['title'])),
|
||||
'descr' => trim((string)$_POST['description']),
|
||||
'loc' => trim((string)$_POST['location_label']),
|
||||
'street' => $street ?: null,
|
||||
@@ -605,6 +636,7 @@ final class AccountPages
|
||||
$otherListings = [];
|
||||
$editListing = null;
|
||||
$listingCategories = $listingCatalog ? $listingCatalog->listCategories(['place', 'food', 'event', 'family']) : [];
|
||||
$placeSuggestions = $listingCatalog ? $listingCatalog->listPlaceSuggestions(60) : [];
|
||||
$stmt = $pdo?->prepare(
|
||||
'SELECT e.id, e.title, e.teaser_public, e.description, e.location_label, e.street, e.zip, e.city, e.region, e.starts_at, e.allow_kids, e.visibility, e.status, e.lat, e.lng,
|
||||
(SELECT COUNT(*) FROM event_participants ep WHERE ep.event_id = e.id) AS participant_count
|
||||
@@ -671,6 +703,7 @@ final class AccountPages
|
||||
'otherListings',
|
||||
'editListing',
|
||||
'listingCategories',
|
||||
'placeSuggestions',
|
||||
'communityPoints',
|
||||
'communityLevel',
|
||||
'communityRoles',
|
||||
@@ -702,6 +735,22 @@ final class AccountPages
|
||||
return $birthDateValue->diff($today)->y;
|
||||
}
|
||||
|
||||
private static function generateTeaser(string $description, string $title = ''): string
|
||||
{
|
||||
$source = trim($description) !== '' ? trim($description) : trim($title);
|
||||
if ($source === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
$collapsed = preg_replace('/\s+/u', ' ', $source) ?: $source;
|
||||
$collapsed = trim($collapsed);
|
||||
if (mb_strlen($collapsed) <= 140) {
|
||||
return $collapsed;
|
||||
}
|
||||
|
||||
return rtrim(mb_substr($collapsed, 0, 137)) . '...';
|
||||
}
|
||||
|
||||
private static function requireCrypto(?Crypto $crypto, string $context): Crypto
|
||||
{
|
||||
if ($crypto instanceof Crypto) {
|
||||
|
||||
Reference in New Issue
Block a user