- Impressum: echte Anbieterdaten (adametz.media, Bielefeld, USt-ID) statt erfundener GmbH; DDG statt TMG, MStV-Verantwortlicher, Verbund-Absatz, DSA-Kontaktpunkt (Art. 11/12) mit neuem REPORT_EMAIL_*-Melde-Postfach - AGB: B2B-Fassung v0.6 (03.07.2026) vollstaendig gerendert (par. 1-16, interne Anwalts-Anmerkungen entfernt, Variablen je Host aufgeloest); ersetzt den widerspruechlichen Platzhalter (30-Tage-Frist etc.) - Neu: /richtlinien (Rahmentext + Ablehnungskategorien K1-K6 mit Ankern, statisch bis zum rejection_categories-System) und /melden (DSA/DSGVO/ Aenderung/Depublikation, verdrahtet mit den bestehenden Melde-Links an jeder Mitteilung; eigenstaendige Formulare = Backlog T10/T12) - Footer beider Gerueste + Sitemap um Richtlinien/Melden ergaenzt - Versioniertes legal_documents-System (E3) bleibt R3.1-Folgeausbau Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
127 lines
4.3 KiB
PHP
127 lines
4.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Web;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Category;
|
|
use App\Models\Company;
|
|
use App\Models\PressRelease;
|
|
use App\Scopes\PortalScope;
|
|
use App\Support\WebPortalContext;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Response;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
/**
|
|
* Host-aware XML-Sitemap: Der Hub listet Landing- und Rechts-/Info-Seiten,
|
|
* die Spokes (presseecho, businessportal24) zusätzlich Kategorien, Newsrooms
|
|
* und alle im Archiv sichtbaren Pressemitteilungen ihres Portals. Marketing-
|
|
* Platzhalterseiten (team, presse, karriere, partner, kontakt, ueber-uns)
|
|
* und die Suche bleiben bewusst draußen (R2.4/R3.2). Pro Host eine Stunde
|
|
* gecacht.
|
|
*/
|
|
class SitemapController extends Controller
|
|
{
|
|
/** @var list<string> */
|
|
private const HUB_PAGES = [
|
|
'faq', 'hilfe', 'api', 'kuendigung',
|
|
'impressum', 'datenschutz', 'agb', 'cookies', 'richtlinien', 'melden',
|
|
];
|
|
|
|
/** @var list<string> */
|
|
private const PORTAL_PAGES = [
|
|
'preise', 'veroeffentlichen', 'newsrooms', 'faq', 'hilfe', 'api',
|
|
'impressum', 'datenschutz', 'agb', 'cookies', 'richtlinien', 'melden',
|
|
];
|
|
|
|
public function __invoke(Request $request): Response
|
|
{
|
|
$host = $request->getHost();
|
|
$base = rtrim($request->getSchemeAndHttpHost(), '/');
|
|
$isHub = str_contains($host, 'pressekonto');
|
|
|
|
$xml = Cache::remember('web.sitemap.'.$host, 3600, function () use ($base, $isHub): string {
|
|
$urls = $isHub ? $this->hubUrls($base) : $this->portalUrls($base);
|
|
|
|
return view('web.sitemap', ['urls' => $urls])->render();
|
|
});
|
|
|
|
return response($xml, 200, ['Content-Type' => 'application/xml; charset=UTF-8']);
|
|
}
|
|
|
|
/**
|
|
* @return list<array{loc: string, lastmod: ?string}>
|
|
*/
|
|
private function hubUrls(string $base): array
|
|
{
|
|
$urls = [['loc' => $base.'/', 'lastmod' => null]];
|
|
|
|
foreach (self::HUB_PAGES as $page) {
|
|
$urls[] = ['loc' => $base.'/de/'.$page, 'lastmod' => null];
|
|
}
|
|
|
|
return $urls;
|
|
}
|
|
|
|
/**
|
|
* @return list<array{loc: string, lastmod: ?string}>
|
|
*/
|
|
private function portalUrls(string $base): array
|
|
{
|
|
$context = WebPortalContext::fromRequest();
|
|
|
|
$urls = [['loc' => $base.'/de', 'lastmod' => null]];
|
|
|
|
foreach (self::PORTAL_PAGES as $page) {
|
|
$urls[] = ['loc' => $base.'/de/'.$page, 'lastmod' => null];
|
|
}
|
|
|
|
// Kategorien über die lokalisierten Slugs (CategoryTranslation).
|
|
$categorySlugs = Category::query()
|
|
->where('is_active', true)
|
|
->whereIn('portal', $context->portalValues)
|
|
->with('translations')
|
|
->get()
|
|
->map(fn (Category $category) => $category->translations->firstWhere('locale', 'de')?->slug)
|
|
->filter()
|
|
->unique();
|
|
|
|
foreach ($categorySlugs as $slug) {
|
|
$urls[] = ['loc' => $base.'/de/category/'.$slug, 'lastmod' => null];
|
|
}
|
|
|
|
// Öffentliche Newsrooms: aktive Firmen mit mindestens einer im Archiv
|
|
// sichtbaren PM des Portals (gleiche Regel wie NewsroomsPageData).
|
|
$companies = Company::query()
|
|
->where('is_active', true)
|
|
->whereHas('pressReleases', fn ($query) => $query
|
|
->withoutGlobalScope(PortalScope::class)
|
|
->visibleInArchive()
|
|
->forPortalValues($context->portalValues))
|
|
->get(['slug', 'updated_at']);
|
|
|
|
foreach ($companies as $company) {
|
|
$urls[] = [
|
|
'loc' => $base.'/de/newsroom/'.$company->slug,
|
|
'lastmod' => $company->updated_at?->toAtomString(),
|
|
];
|
|
}
|
|
|
|
// Alle im Archiv sichtbaren Pressemitteilungen des Portals.
|
|
$releases = PressRelease::query()
|
|
->withoutGlobalScope(PortalScope::class)
|
|
->visibleInArchive()
|
|
->forPortalValues($context->portalValues)
|
|
->orderByDesc('published_at')
|
|
->get(['slug', 'published_at', 'updated_at']);
|
|
|
|
foreach ($releases as $release) {
|
|
$urls[] = [
|
|
'loc' => $base.'/de/press-release/'.$release->slug,
|
|
'lastmod' => ($release->updated_at ?? $release->published_at)?->toAtomString(),
|
|
];
|
|
}
|
|
|
|
return $urls;
|
|
}
|
|
}
|