Globale Live-Suche, Kontaktkarten-Personensuche, neue Beitragsansicht, Termine mit Seitenleiste, Demo-Inhalte, Plugin-Upload-Fix
Some checks failed
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m24s
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m26s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m41s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 3m46s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m31s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 5m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m16s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m18s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m14s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-26 19:07:13 +00:00
parent 9b06e65802
commit b276e1c6d0
211 changed files with 3580 additions and 1072 deletions

View file

@ -0,0 +1,31 @@
<?php
namespace Inhaus\Plugins\Downloads;
use App\Models\User;
use App\Search\GlobalSearch;
use Inhaus\Plugins\Downloads\Models\Download;
/** Suchquelle für die globale Suche: Dateien in sichtbaren Ordnern */
class DownloadSearch
{
public function __construct(private readonly FolderTree $tree) {}
/**
* @return list<array<string, mixed>>
*/
public function __invoke(User $user, string $search, int $limit): array
{
$query = Download::query()->whereIn('folder_id', $this->tree->visibleIds($user) ?: [0])->whereNotNull('current_version_id')->with('currentVersion');
GlobalSearch::whereTerms($query, ['title', 'description'], $search);
return $query->orderBy('title')->limit($limit)->get()->map(fn (Download $download) => [
'title' => $download->title,
'url' => $download->downloadUrl(),
'external' => true,
'excerpt' => GlobalSearch::excerpt($download->description, $search),
'meta' => collect([$this->tree->get($download->folder_id)['name'] ?? null, strtoupper($download->currentVersion?->extension() ?? '')])->filter()->implode(' · '),
'file' => $download->currentVersion?->extension(),
])->all();
}
}

View file

@ -8,6 +8,7 @@ use App\Pagebuilder\Blocks;
use App\Pagebuilder\BlockType;
use App\Pagebuilder\Field;
use App\Plugins\Plugin;
use App\Search\GlobalSearch;
use App\Support\Abilities;
use App\Support\Navigation;
use Illuminate\Support\Facades\DB;
@ -20,6 +21,8 @@ class DownloadsPlugin extends Plugin
{
public function register(): void
{
$this->app->make(GlobalSearch::class)->add('downloads', 'Downloads', 'folder-down', fn (...$args) => app(DownloadSearch::class)(...$args), sort: 40);
$this->app->singleton(FolderTree::class);
$this->app->make(Navigation::class)->add('downloads', 'Downloads', '/downloads', active: 'downloads.*', sort: 50);

View file

@ -4,12 +4,14 @@ import { Link } from '@inertiajs/vue3';
import { CalendarDays, MapPin, Video } from '@lucide/vue';
import EmptyState from '@/components/EmptyState.vue';
import EventDateBlock from '../components/EventDateBlock.vue';
import DashboardSidebar from '@/components/DashboardSidebar.vue';
import PageHeader from '@/components/PageHeader.vue';
import AppLayout from '@/layouts/AppLayout.vue';
import { formatEventRange, formatMonthYear } from '@/lib/format';
const props = defineProps({
events: { type: Object, required: true },
sidebar: { type: Array, default: () => [] },
});
// Nach Monaten gruppieren – laufende Termine erscheinen im aktuellen Monat.
@ -37,30 +39,42 @@ const groups = computed(() => {
<AppLayout title="Termine">
<PageHeader title="Termine" description="Veranstaltungen, Fortbildungen und Treffen." />
<div v-if="groups.length" class="grid max-w-4xl gap-8">
<section v-for="group in groups" :key="group.label">
<h2 class="mb-3 text-sm font-semibold text-muted-foreground">{{ group.label }}</h2>
<ul class="divide-y rounded-lg border bg-card">
<li v-for="event in group.events" :key="event.id">
<Link :href="`/termine/${event.id}`" class="group flex items-center gap-4 p-4 transition-colors hover:bg-accent/60">
<EventDateBlock :date="event.starts_at" class="w-14" />
<div class="min-w-0 flex-1">
<h3 class="text-[15px] font-semibold group-hover:underline">{{ event.title }}</h3>
<p class="mt-0.5 text-[13px] text-muted-foreground">{{ formatEventRange(event) }}</p>
<p v-if="event.location || event.online_url" class="mt-0.5 flex items-center gap-1.5 text-[13px] text-muted-foreground">
<MapPin v-if="event.location" class="size-3.5" />
<Video v-else class="size-3.5" />
{{ event.location || 'Online' }}
</p>
</div>
<img v-if="event.thumb_url" :src="event.thumb_url" alt="" loading="lazy" class="hidden h-16 w-28 shrink-0 rounded-md object-cover sm:block" />
</Link>
</li>
</ul>
</section>
</div>
<div v-else class="max-w-4xl rounded-lg border border-dashed bg-card">
<EmptyState :icon="CalendarDays" title="Keine anstehenden Termine" text="Neue Termine erscheinen hier, sobald sie eingetragen sind." />
<div class="grid gap-6 lg:grid-cols-12">
<div class="min-w-0" :class="sidebar.length ? 'lg:col-span-8 xl:col-span-9' : 'lg:col-span-12'">
<div v-if="groups.length" class="grid gap-8">
<section v-for="group in groups" :key="group.label">
<h2 class="mb-3 text-sm font-semibold text-muted-foreground">
{{ group.label }}
</h2>
<ul class="divide-y rounded-lg border bg-card">
<li v-for="event in group.events" :key="event.id">
<Link :href="`/termine/${event.id}`" class="group flex items-center gap-4 p-4 transition-colors hover:bg-accent/60">
<EventDateBlock :date="event.starts_at" class="w-14" />
<div class="min-w-0 flex-1">
<h3 class="text-[15px] font-semibold group-hover:underline">
{{ event.title }}
</h3>
<p class="mt-0.5 text-[13px] text-muted-foreground">
{{ formatEventRange(event) }}
</p>
<p v-if="event.location || event.online_url" class="mt-0.5 flex items-center gap-1.5 text-[13px] text-muted-foreground">
<MapPin v-if="event.location" class="size-3.5" />
<Video v-else class="size-3.5" />
{{ event.location || 'Online' }}
</p>
</div>
<img v-if="event.thumb_url" :src="event.thumb_url" alt="" loading="lazy" class="hidden h-16 w-28 shrink-0 rounded-md object-cover sm:block" />
</Link>
</li>
</ul>
</section>
</div>
<div v-else class="rounded-lg border border-dashed bg-card">
<EmptyState :icon="CalendarDays" title="Keine anstehenden Termine" text="Neue Termine erscheinen hier, sobald sie eingetragen sind." />
</div>
</div>
<DashboardSidebar v-if="sidebar.length" :widgets="sidebar" class="lg:col-span-4 xl:col-span-3" />
</div>
</AppLayout>
</template>

View file

@ -0,0 +1,31 @@
<?php
namespace Inhaus\Plugins\Events;
use App\Models\User;
use App\Search\GlobalSearch;
use Inhaus\Plugins\Events\Models\Event;
/** Suchquelle für die globale Suche: anstehende Termine zuerst, dann vergangene */
class EventSearch
{
/**
* @return list<array<string, mixed>>
*/
public function __invoke(User $user, string $search, int $limit): array
{
$query = Event::query()->visibleTo($user)->where('is_published', true);
GlobalSearch::whereTerms($query, ['title', 'description', 'location'], $search);
return $query->orderByRaw('COALESCE(ends_at, starts_at) < ?', [now()])->orderBy('starts_at')->limit($limit)->get()->map(fn (Event $event) => [
'title' => $event->title,
'url' => '/termine/'.$event->id,
'excerpt' => GlobalSearch::excerpt($event->description, $search),
'meta' => collect([
$event->all_day ? $event->starts_at->translatedFormat('j. F Y') : $event->starts_at->translatedFormat('j. F Y, H:i').' Uhr',
$event->location,
])->filter()->implode(' · '),
'image' => $event->imageUrl('thumb'),
])->all();
}
}

View file

@ -8,6 +8,7 @@ use App\Pagebuilder\Blocks;
use App\Pagebuilder\BlockType;
use App\Pagebuilder\Field;
use App\Plugins\Plugin;
use App\Search\GlobalSearch;
use App\Support\Abilities;
use App\Support\Navigation;
use Illuminate\Support\Facades\Gate;
@ -19,6 +20,8 @@ class EventsPlugin extends Plugin
{
public function register(): void
{
$this->app->make(GlobalSearch::class)->add('events', 'Termine', 'calendar-days', fn (...$args) => app(EventSearch::class)(...$args), sort: 20);
$this->app->make(Navigation::class)->add('events', 'Termine', '/termine', active: 'events.*', sort: 30);
$this->app->make(Abilities::class)->define('events.manage', 'Termine verwalten', 'Termine');
Gate::policy(Event::class, EventPolicy::class);

View file

@ -2,8 +2,10 @@
namespace Inhaus\Plugins\Events\Http\Controllers;
use App\Dashboard\Widgets;
use App\Http\Controllers\Controller;
use App\Support\Branding;
use Illuminate\Http\Request;
use Illuminate\Http\Response as HttpResponse;
use Inertia\Inertia;
use Inertia\Response;
@ -13,12 +15,14 @@ use Inhaus\Plugins\Events\Models\Event;
class EventController extends Controller
{
public function index(): Response
public function index(Request $request, Widgets $widgets): Response
{
return Inertia::render('events::Index', [
'events' => EventResource::collection(
Event::query()->upcoming()->visibleTo(request()->user())->limit(200)->get()
Event::query()->upcoming()->visibleTo($request->user())->limit(200)->get()
),
// Seitenleiste der Startseite (ohne die Termin-Kachel selbst)
'sidebar' => $widgets->sidebar($request->user(), $request, except: ['events.upcoming']),
]);
}

View file

@ -0,0 +1,28 @@
<?php
namespace Inhaus\Plugins\Forms;
use App\Models\User;
use App\Search\GlobalSearch;
use Inhaus\Plugins\Forms\Models\Form;
/** Suchquelle für die globale Suche: offene Formulare */
class FormSearch
{
/**
* @return list<array<string, mixed>>
*/
public function __invoke(User $user, string $search, int $limit): array
{
$query = Form::query()->visibleTo($user)->where('is_open', true)
->where(fn ($q) => $q->whereNull('closes_at')->orWhere('closes_at', '>', now()));
GlobalSearch::whereTerms($query, ['title', 'description'], $search);
return $query->orderBy('title')->limit($limit)->get()->map(fn (Form $form) => [
'title' => $form->title,
'url' => $form->url(),
'excerpt' => GlobalSearch::excerpt($form->description, $search),
'meta' => 'Formular',
])->all();
}
}

View file

@ -8,6 +8,7 @@ use App\Pagebuilder\Blocks;
use App\Pagebuilder\BlockType;
use App\Pagebuilder\Field;
use App\Plugins\Plugin;
use App\Search\GlobalSearch;
use App\Support\Abilities;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Schedule;
@ -18,6 +19,8 @@ class FormsPlugin extends Plugin
{
public function register(): void
{
$this->app->make(GlobalSearch::class)->add('forms', 'Formulare', 'clipboard-list', fn (...$args) => app(FormSearch::class)(...$args), sort: 60);
// Kein eigener Menüpunkt im Portal: Formulare werden in Seiten und Beiträge eingebunden.
// /formulare/{slug} bleibt als direkte Adresse (z. B. für Links in E-Mails).

View file

@ -1,63 +1,142 @@
<script setup>
import { ref, watch } from 'vue';
import { Link } from '@inertiajs/vue3';
import { ArrowLeft, Clock, PenLine } from '@lucide/vue';
import { useWindowScroll } from '@vueuse/core';
import { ArrowLeft, CalendarDays, Check, Clock, Link2, Mail, PenLine } from '@lucide/vue';
import { Button } from '@/components/ui/button';
import CategoryLabel from '../components/CategoryLabel.vue';
import NewsCard from '../components/NewsCard.vue';
import PersonAvatar from '@/components/PersonAvatar.vue';
import AppLayout from '@/layouts/AppLayout.vue';
import PageContent from '@/pagebuilder/PageContent.vue';
import { formatDate } from '@/lib/format';
import { formatDate, formatShortDate } from '@/lib/format';
defineProps({
const props = defineProps({
post: { type: Object, required: true },
related: { type: Object, required: true },
editUrl: { type: String, default: null },
form: { type: Object, default: null },
});
// Lesefortschritt: Anteil des Artikels, der schon oben aus dem Bild gescrollt ist
const article = ref(null);
const progress = ref(0);
const { y } = useWindowScroll();
const updateProgress = () => {
const el = article.value;
if (!el) return;
const rect = el.getBoundingClientRect();
const total = rect.height - window.innerHeight * 0.6;
progress.value = Math.min(100, Math.max(0, (-rect.top / Math.max(total, 1)) * 100));
};
watch(y, updateProgress);
const copied = ref(false);
async function copyLink() {
try {
await navigator.clipboard.writeText(window.location.href);
copied.value = true;
setTimeout(() => (copied.value = false), 2000);
} catch {
window.prompt('Link zum Beitrag:', window.location.href);
}
}
const mailLink = () => `mailto:?subject=${encodeURIComponent(props.post.title)}&body=${encodeURIComponent(window.location.href)}`;
</script>
<template>
<AppLayout :title="post.title">
<article class="mx-auto max-w-3xl">
<div class="mb-6 flex items-center justify-between gap-4">
<Link href="/neuigkeiten" class="inline-flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground">
<ArrowLeft class="size-4" /> Alle Neuigkeiten
</Link>
<Button v-if="editUrl" variant="outline" size="sm" as-child><Link :href="editUrl"><PenLine /> Bearbeiten</Link></Button>
<!-- Lesefortschritt -->
<div class="fixed inset-x-0 top-0 z-50 h-1 bg-transparent" aria-hidden="true">
<div class="h-full bg-brand transition-[width] duration-150" :style="{ width: `${progress}%` }" />
</div>
<div class="mb-4 flex items-center justify-between gap-4">
<Link href="/neuigkeiten" class="inline-flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground">
<ArrowLeft class="size-4" /> Alle Neuigkeiten
</Link>
<Button v-if="editUrl" variant="outline" size="sm" as-child><Link :href="editUrl"><PenLine /> Bearbeiten</Link></Button>
</div>
<!-- Kopf: großes Titelbild mit Titel darüber, ohne Bild eine Fläche in der Markenfarbe -->
<header class="relative isolate overflow-hidden rounded-xl bg-brand text-white shadow-sm">
<img v-if="post.cover_url" :src="post.cover_url" :alt="post.title" class="absolute inset-0 -z-10 size-full object-cover" />
<div v-if="post.cover_url" class="absolute inset-0 -z-10 bg-gradient-to-t from-black/85 via-black/45 to-black/5" />
<div v-else class="absolute inset-0 -z-10 opacity-20 [background-image:radial-gradient(circle_at_85%_15%,white_0,transparent_45%),radial-gradient(circle_at_10%_110%,white_0,transparent_40%)]" />
<div class="flex min-h-[260px] flex-col justify-end gap-3 p-6 sm:min-h-[360px] sm:p-10 lg:min-h-[420px]">
<span v-if="post.category" class="w-fit rounded-full bg-white/15 px-3 py-1 text-[11px] font-semibold tracking-wider uppercase ring-1 ring-white/30 backdrop-blur">
{{ post.category.name }}
</span>
<h1 class="max-w-4xl text-3xl leading-tight font-semibold tracking-tight text-balance sm:text-4xl lg:text-[44px]">{{ post.title }}</h1>
<p v-if="post.teaser" class="max-w-3xl text-base leading-relaxed text-white/85 sm:text-lg">{{ post.teaser }}</p>
<div class="mt-2 flex flex-wrap items-center gap-x-5 gap-y-2 text-sm text-white/80">
<span class="inline-flex items-center gap-1.5"><CalendarDays class="size-4" /> {{ formatDate(post.published_at) }}</span>
<span class="inline-flex items-center gap-1.5"><Clock class="size-4" /> {{ post.reading_minutes }} Min. Lesezeit</span>
</div>
</div>
</header>
<header>
<CategoryLabel :category="post.category" />
<h1 class="mt-2 text-3xl leading-tight font-semibold tracking-tight sm:text-[34px]">{{ post.title }}</h1>
<p v-if="post.teaser" class="mt-4 text-lg leading-relaxed text-muted-foreground">{{ post.teaser }}</p>
<div class="mt-6 grid gap-6 lg:grid-cols-12">
<!-- Inhalt in einer weißen Karte -->
<article ref="article" class="min-w-0 rounded-xl border bg-card p-6 shadow-xs sm:p-10 lg:col-span-8">
<!-- Am Handy steht die Seitenleiste unten – dort den Autor gleich oben zeigen -->
<div v-if="post.author" class="mb-8 flex items-center gap-3 border-b pb-6 lg:hidden">
<PersonAvatar :person="post.author" class="size-11" />
<div class="min-w-0 text-sm">
<Link :href="`/personen/${post.author.id}`" class="font-semibold hover:underline">{{ post.author.name }}</Link>
<p v-if="post.author.job_title" class="text-muted-foreground">{{ post.author.job_title }}</p>
</div>
</div>
<div class="mt-6 flex flex-wrap items-center gap-x-6 gap-y-3 border-y py-4 text-sm">
<Link v-if="post.author" :href="`/personen/${post.author.id}`" class="flex items-center gap-3 hover:underline">
<PersonAvatar :person="post.author" class="size-9" />
<span>
<span class="block font-medium">{{ post.author.name }}</span>
<span v-if="post.author.job_title" class="block text-xs text-muted-foreground">{{ post.author.job_title }}</span>
<div
class="prose prose-neutral max-w-none prose-headings:tracking-tight prose-h2:mt-10 prose-a:text-brand-text prose-blockquote:border-l-brand prose-blockquote:bg-brand-soft/50 prose-blockquote:py-1 prose-blockquote:not-italic prose-img:rounded-lg dark:prose-invert first-of-type:prose-p:text-lg"
v-html="post.body_html"
/>
<!-- Eingebundenes Formular (Pagebuilder-Block des Formular-Plugins) -->
<PageContent v-if="form" :content="form" class="mt-10" />
<footer class="mt-10 flex flex-wrap items-center gap-2 border-t pt-6">
<span class="mr-2 text-sm text-muted-foreground">Beitrag teilen:</span>
<Button variant="outline" size="sm" @click="copyLink">
<component :is="copied ? Check : Link2" /> {{ copied ? 'Link kopiert' : 'Link kopieren' }}
</Button>
<Button variant="outline" size="sm" as-child><a :href="mailLink()"><Mail /> Per E-Mail</a></Button>
</footer>
</article>
<aside class="grid content-start gap-6 lg:col-span-4">
<section v-if="post.author" class="rounded-xl border bg-card p-5 shadow-xs">
<h2 class="mb-3 text-xs font-semibold tracking-wider text-muted-foreground uppercase">Geschrieben von</h2>
<Link :href="`/personen/${post.author.id}`" class="flex items-center gap-3 rounded-lg p-1 hover:bg-accent/50">
<PersonAvatar :person="post.author" class="size-14" />
<span class="min-w-0">
<span class="block font-semibold">{{ post.author.name }}</span>
<span v-if="post.author.job_title" class="block text-[13px] text-muted-foreground">{{ post.author.job_title }}</span>
</span>
</Link>
<span class="text-muted-foreground">{{ formatDate(post.published_at) }}</span>
<span class="inline-flex items-center gap-1.5 text-muted-foreground"><Clock class="size-4" /> {{ post.reading_minutes }} Min. Lesezeit</span>
</div>
</header>
</section>
<img v-if="post.cover_url" :src="post.cover_url" :alt="post.title" class="mt-8 aspect-video w-full rounded-lg object-cover" />
<div class="prose prose-neutral mt-8 max-w-none prose-headings:tracking-tight prose-img:rounded-lg" v-html="post.body_html" />
<!-- Eingebundenes Formular (Pagebuilder-Block des Formular-Plugins) -->
<PageContent v-if="form" :content="form" class="mt-10" />
</article>
<section v-if="related.data.length" class="mx-auto mt-16 max-w-5xl">
<h2 class="mb-4 text-lg font-semibold">Weitere Beiträge</h2>
<div class="grid gap-5 sm:grid-cols-2 lg:grid-cols-3">
<NewsCard v-for="item in related.data" :key="item.id" :post="item" />
</div>
</section>
<section v-if="related.data.length" class="rounded-xl border bg-card p-5 shadow-xs lg:sticky lg:top-20">
<h2 class="mb-3 text-xs font-semibold tracking-wider text-muted-foreground uppercase">Weitere Beiträge</h2>
<ul class="grid gap-1">
<li v-for="item in related.data" :key="item.id">
<Link :href="`/neuigkeiten/${item.slug}`" class="group flex gap-3 rounded-lg p-2 hover:bg-accent/50">
<img v-if="item.thumb_url" :src="item.thumb_url" alt="" loading="lazy" class="h-16 w-20 shrink-0 rounded-md object-cover" />
<span v-else class="grid h-16 w-20 shrink-0 place-items-center rounded-md bg-brand-soft text-brand-text"><CalendarDays class="size-5" /></span>
<span class="min-w-0">
<span v-if="item.category" class="block text-[10px] font-semibold tracking-wider text-accent2-text uppercase">{{ item.category.name }}</span>
<span class="line-clamp-2 text-sm leading-snug font-medium group-hover:underline">{{ item.title }}</span>
<span class="block text-xs text-muted-foreground">{{ formatShortDate(item.published_at) }}</span>
</span>
</Link>
</li>
</ul>
<Link href="/neuigkeiten" class="mt-3 block border-t pt-3 text-[13px] font-medium text-brand-text hover:underline">Alle Neuigkeiten</Link>
</section>
</aside>
</div>
</AppLayout>
</template>

View file

@ -61,9 +61,9 @@ class NewsController extends Controller
->visibleTo(request()->user())
->with('category')
->whereKeyNot($post->id)
->when($post->category_id, fn ($query) => $query->where('category_id', $post->category_id))
->orderByRaw('category_id = ? DESC', [$post->category_id ?? 0])
->latest('published_at')
->limit(3)
->limit(5)
->get()
),
]);

View file

@ -9,6 +9,7 @@ use App\Pagebuilder\Blocks;
use App\Pagebuilder\BlockType;
use App\Pagebuilder\Field;
use App\Plugins\Plugin;
use App\Search\GlobalSearch;
use App\Support\Abilities;
use App\Support\Navigation;
use Illuminate\Database\Eloquent\Collection;
@ -24,6 +25,8 @@ class NewsPlugin extends Plugin
{
public function register(): void
{
$this->app->make(GlobalSearch::class)->add('news', 'Neuigkeiten', 'newspaper', fn (...$args) => app(NewsSearch::class)(...$args), sort: 10);
$this->app->make(Navigation::class)->add('news', 'Neuigkeiten', '/neuigkeiten', active: ['news.index', 'news.show'], sort: 20);
$abilities = $this->app->make(Abilities::class);

View file

@ -0,0 +1,28 @@
<?php
namespace Inhaus\Plugins\News;
use App\Models\User;
use App\Search\GlobalSearch;
use Inhaus\Plugins\News\Models\NewsPost;
/** Suchquelle für die globale Suche */
class NewsSearch
{
/**
* @return list<array<string, mixed>>
*/
public function __invoke(User $user, string $search, int $limit): array
{
$query = NewsPost::query()->published()->visibleTo($user)->with('category');
GlobalSearch::whereTerms($query, ['title', 'teaser', 'body'], $search);
return $query->latest('published_at')->limit($limit)->get()->map(fn (NewsPost $post) => [
'title' => $post->title,
'url' => route('news.show', $post->slug),
'excerpt' => GlobalSearch::excerpt($post->teaser.' '.$post->body_html, $search),
'meta' => collect([$post->category?->name, $post->published_at?->translatedFormat('j. F Y')])->filter()->implode(' · '),
'image' => $post->coverUrl('thumb'),
])->all();
}
}

View file

@ -0,0 +1,53 @@
<?php
namespace Inhaus\Plugins\Pages;
use App\Models\User;
use App\Search\GlobalSearch;
use Inhaus\Plugins\Pages\Models\Page;
/** Suchquelle für die globale Suche: veröffentlichte, sichtbare Seiten */
class PageSearch
{
public function __construct(private readonly PageTree $tree) {}
/**
* @return list<array<string, mixed>>
*/
public function __invoke(User $user, string $search, int $limit): array
{
$query = Page::query()->whereNotNull('published_at');
// Inhalt liegt als JSON vor (Umlaute als ü) – daher zusätzlich die JSON-Schreibweise suchen
$encoded = trim((string) json_encode($search), '"');
$query->where(function ($q) use ($search, $encoded) {
GlobalSearch::whereTerms($q, ['title', 'content'], $search);
if ($encoded !== $search) {
$q->orWhere(fn ($w) => GlobalSearch::whereTerms($w, ['content'], $encoded));
}
});
return $query->orderBy('title')->limit($limit * 3)->get()
->filter(fn (Page $page) => $this->tree->isVisible($page->id, $user))
->take($limit)
->map(fn (Page $page) => [
'title' => $page->title,
'url' => $page->url(),
'excerpt' => GlobalSearch::excerpt($this->text($page->content), $search),
'meta' => collect($this->tree->ancestors($page->id))->pluck('title')->filter()->implode(' › ') ?: 'Seite',
])->values()->all();
}
/** Alle Texte aus den Pagebuilder-Blöcken */
private function text(mixed $content): string
{
$parts = [];
array_walk_recursive($content, function ($value, $key) use (&$parts) {
if (is_string($value) && ! in_array($key, ['type', 'id', 'url', 'image', 'icon', 'layout', 'variant'], true) && ! preg_match('#^(https?:|/|[a-z0-9_.-]+$)#i', $value)) {
$parts[] = $value;
}
});
return implode(' ', $parts);
}
}

View file

@ -8,6 +8,7 @@ use App\Pagebuilder\Blocks;
use App\Pagebuilder\BlockType;
use App\Pagebuilder\Field;
use App\Plugins\Plugin;
use App\Search\GlobalSearch;
use App\Support\Abilities;
use App\Support\Navigation;
use Illuminate\Http\Request;
@ -21,6 +22,8 @@ class PagesPlugin extends Plugin
{
public function register(): void
{
$this->app->make(GlobalSearch::class)->add('pages', 'Seiten', 'file-text', fn (...$args) => app(PageSearch::class)(...$args), sort: 30);
$this->app->singleton(PageTree::class);
$abilities = $this->app->make(Abilities::class);

View file

@ -3,7 +3,7 @@
namespace Inhaus\Plugins\Qm;
use App\Models\User;
use App\Support\ProfileFields;
use App\Support\ContactCards;
use App\Support\Settings;
use Inhaus\Plugins\Qm\Models\QmEntry;
@ -15,14 +15,7 @@ class Presenter
public const CONTACT_FIELDS = 'qm.contact_fields';
/** Kernfelder des Profils, die bei Ansprechpartnern erscheinen können. */
public const CORE_FIELDS = [
'job_title' => 'Funktion',
'department' => 'Abteilung',
'location' => 'Standort',
'phone' => 'Telefon',
'mobile' => 'Mobil',
'email' => 'E-Mail-Adresse',
];
public const CORE_FIELDS = ContactCards::CORE_FIELDS;
public const DEFAULT_CONTACT_FIELDS = ['job_title', 'phone', 'email'];
@ -33,7 +26,7 @@ class Presenter
public const OFFICERS = 'qm.home.officers';
public function __construct(private readonly QmTree $tree, private readonly Settings $settings, private readonly ProfileFields $profileFields) {}
public function __construct(private readonly QmTree $tree, private readonly Settings $settings, private readonly ContactCards $cards) {}
/**
* @param array<int, int> $counts Ordner => Anzahl Einträge
@ -115,38 +108,8 @@ class Presenter
public function contacts(iterable $people, ?User $viewer): array
{
$fields = (array) $this->settings->get(self::CONTACT_FIELDS, self::DEFAULT_CONTACT_FIELDS);
$result = [];
foreach ($people as $person) {
if (! $person->is_active) {
continue;
}
$values = [];
$custom = collect($this->profileFields->visibleValues($person, $viewer))->keyBy('key');
foreach ($fields as $field) {
if (isset(self::CORE_FIELDS[$field])) {
$value = $person->{$field};
if (filled($value)) {
$values[] = ['key' => $field, 'label' => self::CORE_FIELDS[$field], 'value' => $value, 'type' => in_array($field, ['phone', 'mobile'], true) ? 'phone' : ($field === 'email' ? 'email' : 'text')];
}
} elseif (str_starts_with($field, 'custom.') && ($item = $custom->get(substr($field, 7)))) {
$values[] = ['key' => $field, 'label' => $item['label'], 'value' => $item['value'], 'type' => $item['type'] ?? 'text'];
}
}
$result[] = [
'id' => $person->id,
'name' => $person->name,
'initials' => $person->initials,
'avatar_url' => $person->avatarUrl(160),
'fields' => $values,
];
}
return $result;
return array_map(fn (array $card) => array_diff_key($card, ['subtitle' => true]), $this->cards->cards($people, $viewer, $fields));
}
/**
@ -197,7 +160,7 @@ class Presenter
*/
public function contactFieldOptions(): array
{
return self::CORE_FIELDS + collect($this->profileFields->options())->mapWithKeys(fn ($label, $key) => ['custom.'.$key => $label.' (Profilfeld)'])->all();
return $this->cards->options();
}
private function formUrl(int $id): ?string

View file

@ -4,6 +4,7 @@ namespace Inhaus\Plugins\Qm;
use App\Models\User;
use App\Plugins\Plugin;
use App\Search\GlobalSearch;
use App\Support\Abilities;
use App\Support\Navigation;
use Illuminate\Support\Facades\Schedule;
@ -15,6 +16,8 @@ class QmPlugin extends Plugin
{
public function register(): void
{
$this->app->make(GlobalSearch::class)->add('qm', 'Qualitätsmanagement', 'shield-check', fn (...$args) => app(QmSearch::class)(...$args), sort: 50);
foreach ([QmTree::class, QmAccess::class, Presenter::class, Search::class, Library::class, Indexer::class, TextExtractor::class, Ocr::class] as $class) {
$this->app->singleton($class);
}

View file

@ -0,0 +1,35 @@
<?php
namespace Inhaus\Plugins\Qm;
use App\Models\User;
use App\Search\GlobalSearch;
/** Suchquelle für die globale Suche: QM-Dokumente inkl. Volltext */
class QmSearch
{
public function __construct(private readonly Search $search, private readonly Presenter $presenter, private readonly QmAccess $access) {}
/**
* @return list<array<string, mixed>>
*/
public function __invoke(User $user, string $search, int $limit): array
{
if (! $this->access->allows($user)) {
return [];
}
return $this->search->run($search, $user)->take($limit)->map(function (array $hit) use ($search) {
$entry = $this->presenter->entry($hit['entry']);
return [
'title' => $hit['entry']->title,
'url' => $entry['open_url'] ?? $this->presenter->folderLabel($hit['entry']->folder_id)['url'],
'external' => ($entry['open_kind'] ?? null) === 'download' || ($entry['open_kind'] ?? null) === 'link',
'excerpt' => $hit['snippet'] ?? GlobalSearch::excerpt($hit['entry']->description, $search),
'meta' => collect([$this->presenter->folderLabel($hit['entry']->folder_id)['path'], $hit['entry']->version ? 'Version '.$hit['entry']->version : null])->filter()->implode(' · '),
'file' => $entry['extension'] ?? null,
];
})->values()->all();
}
}