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