Bugfix
This commit is contained in:
@@ -6,7 +6,6 @@ class IndexPageListener
|
||||
{
|
||||
public function onIndexPage(string $content, array &$data, array &$set): void
|
||||
{
|
||||
// Nur reagieren, wenn unser Marker existiert
|
||||
if (!str_contains($content, 'MEILISEARCH')) {
|
||||
return;
|
||||
}
|
||||
@@ -17,10 +16,8 @@ class IndexPageListener
|
||||
}
|
||||
|
||||
/*
|
||||
* =====================
|
||||
* PRIORITY
|
||||
* event/news > page
|
||||
* =====================
|
||||
*/
|
||||
if (isset($markers['event.priority'])) {
|
||||
$data['priority'] = (int) $markers['event.priority'];
|
||||
@@ -31,9 +28,7 @@ class IndexPageListener
|
||||
}
|
||||
|
||||
/*
|
||||
* =====================
|
||||
* KEYWORDS (kombiniert)
|
||||
* =====================
|
||||
* KEYWORDS – alle kombinieren
|
||||
*/
|
||||
$keywords = [];
|
||||
|
||||
@@ -46,66 +41,52 @@ class IndexPageListener
|
||||
}
|
||||
}
|
||||
|
||||
if ($keywords !== []) {
|
||||
if ($keywords) {
|
||||
$data['keywords'] = implode(' ', array_unique($keywords));
|
||||
}
|
||||
|
||||
/*
|
||||
* =====================
|
||||
* SEARCH IMAGE
|
||||
* WICHTIG:
|
||||
* -> Key heißt "image", NICHT "imagepath"
|
||||
* =====================
|
||||
* IMAGEPATH – UUID
|
||||
* event/news > page > custom
|
||||
*/
|
||||
foreach (
|
||||
['event.searchimage', 'news.searchimage', 'page.searchimage', 'custom.searchimage']
|
||||
as $key
|
||||
) {
|
||||
if (!empty($markers[$key])) {
|
||||
$data['image'] = trim($markers[$key]); // UUID
|
||||
$data['imagepath'] = trim($markers[$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* =====================
|
||||
* START DATE
|
||||
* WICHTIG:
|
||||
* -> Key heißt "startdate" (lowercase)
|
||||
* =====================
|
||||
* STARTDATE – Timestamp
|
||||
*/
|
||||
foreach (['event.date', 'news.date'] as $key) {
|
||||
if (!empty($markers[$key])) {
|
||||
$ts = strtotime($markers[$key]);
|
||||
if ($ts !== false) {
|
||||
$data['startdate'] = $ts;
|
||||
$data['startDate'] = $ts;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Liest die MEILISEARCH-Kommentare aus dem HTML
|
||||
*/
|
||||
private function extractMarkers(string $content): array
|
||||
{
|
||||
if (!preg_match('/<!--\s*MEILISEARCH(.*?)-->/s', $content, $match)) {
|
||||
if (!preg_match('/<!--\s*MEILISEARCH(.*?)-->/s', $content, $m)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$markers = [];
|
||||
$lines = preg_split('/\R/', trim($match[1])) ?: [];
|
||||
|
||||
foreach ($lines as $line) {
|
||||
$line = trim($line);
|
||||
|
||||
if ($line === '' || !str_contains($line, '=')) {
|
||||
foreach (preg_split('/\R/', trim($m[1])) as $line) {
|
||||
if (!str_contains($line, '=')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
[$key, $value] = explode('=', $line, 2);
|
||||
$markers[trim($key)] = trim($value);
|
||||
[$k, $v] = explode('=', $line, 2);
|
||||
$markers[trim($k)] = trim($v);
|
||||
}
|
||||
|
||||
return $markers;
|
||||
|
||||
Reference in New Issue
Block a user