Bugfix
This commit is contained in:
@@ -21,7 +21,7 @@ class MeilisearchPageMarkerListener
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* =====================
|
* =====================
|
||||||
* PAGE
|
* PAGE (Basisdaten)
|
||||||
* =====================
|
* =====================
|
||||||
*/
|
*/
|
||||||
$pageImageUuid = null;
|
$pageImageUuid = null;
|
||||||
@@ -40,15 +40,22 @@ class MeilisearchPageMarkerListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($page->searchimage)) {
|
if (!empty($page->searchimage)) {
|
||||||
|
$raw = (string) $page->searchimage;
|
||||||
|
|
||||||
|
// UUID-String oder BINARY(16)
|
||||||
|
if (preg_match('/^[a-f0-9-]{36}$/i', $raw)) {
|
||||||
|
$pageImageUuid = $raw;
|
||||||
|
} else {
|
||||||
try {
|
try {
|
||||||
$pageImageUuid = StringUtil::binToUuid((string) $page->searchimage);
|
$pageImageUuid = StringUtil::binToUuid($raw);
|
||||||
} catch (\Throwable) {}
|
} catch (\Throwable) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* =====================
|
* =====================
|
||||||
* JSON-LD (SAUBER!)
|
* JSON-LD AUSWERTEN (ohne Regex-Fallen)
|
||||||
* =====================
|
* =====================
|
||||||
*/
|
*/
|
||||||
preg_match_all(
|
preg_match_all(
|
||||||
@@ -92,13 +99,10 @@ class MeilisearchPageMarkerListener
|
|||||||
$data['event']['searchimage'] = StringUtil::binToUuid($event->singleSRC);
|
$data['event']['searchimage'] = StringUtil::binToUuid($event->singleSRC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ✅ STARTDATE (Unix Timestamp)
|
||||||
if (!empty($event->startDate)) {
|
if (!empty($event->startDate)) {
|
||||||
$data['event']['startDate'] = (int) $event->startDate;
|
$data['event']['startDate'] = (int) $event->startDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($event->endDate)) {
|
|
||||||
$data['event']['endDate'] = (int) $event->endDate;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,16 +136,26 @@ class MeilisearchPageMarkerListener
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* =====================
|
* =====================
|
||||||
* SEARCHIMAGE
|
* FINALE SEARCHIMAGE-ENTSCHEIDUNG
|
||||||
* =====================
|
* =====================
|
||||||
*/
|
*/
|
||||||
$finalSearchImageUuid =
|
$finalSearchImageUuid = null;
|
||||||
$data['event']['searchimage']
|
|
||||||
?? $data['news']['searchimage']
|
|
||||||
?? $pageImageUuid
|
|
||||||
?? Config::get('meilisearch_fallback_image');
|
|
||||||
|
|
||||||
if ($finalSearchImageUuid) {
|
if (!empty($data['event']['searchimage'])) {
|
||||||
|
$finalSearchImageUuid = $data['event']['searchimage'];
|
||||||
|
} elseif (!empty($data['news']['searchimage'])) {
|
||||||
|
$finalSearchImageUuid = $data['news']['searchimage'];
|
||||||
|
} elseif ($pageImageUuid) {
|
||||||
|
$finalSearchImageUuid = $pageImageUuid;
|
||||||
|
} else {
|
||||||
|
$fallback = Config::get('meilisearch_fallback_image');
|
||||||
|
if ($fallback) {
|
||||||
|
$finalSearchImageUuid = $fallback;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($finalSearchImageUuid !== null) {
|
||||||
|
$data['page'] ??= [];
|
||||||
$data['page']['searchimage'] = $finalSearchImageUuid;
|
$data['page']['searchimage'] = $finalSearchImageUuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,28 +165,57 @@ class MeilisearchPageMarkerListener
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* =====================
|
* =====================
|
||||||
* META-SPAN (Checksum!)
|
* META-SPAN (ALLES REIN!)
|
||||||
* =====================
|
* =====================
|
||||||
*/
|
*/
|
||||||
$meta = [];
|
$metaParts = [];
|
||||||
|
|
||||||
|
// PAGE
|
||||||
|
if (!empty($data['page']['priority'])) {
|
||||||
|
$metaParts[] = 'page_priority=' . (int) $data['page']['priority'];
|
||||||
|
}
|
||||||
|
if (!empty($data['page']['keywords'])) {
|
||||||
|
$metaParts[] = 'page_keywords=' . (string) $data['page']['keywords'];
|
||||||
|
}
|
||||||
|
if (!empty($data['page']['searchimage'])) {
|
||||||
|
$metaParts[] = 'page_searchimage=' . (string) $data['page']['searchimage'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// EVENT
|
||||||
|
if (!empty($data['event']['priority'])) {
|
||||||
|
$metaParts[] = 'event_priority=' . (int) $data['event']['priority'];
|
||||||
|
}
|
||||||
|
if (!empty($data['event']['keywords'])) {
|
||||||
|
$metaParts[] = 'event_keywords=' . (string) $data['event']['keywords'];
|
||||||
|
}
|
||||||
|
if (!empty($data['event']['searchimage'])) {
|
||||||
|
$metaParts[] = 'event_searchimage=' . (string) $data['event']['searchimage'];
|
||||||
|
}
|
||||||
if (!empty($data['event']['startDate'])) {
|
if (!empty($data['event']['startDate'])) {
|
||||||
$meta[] = 'event_startDate=' . $data['event']['startDate'];
|
$metaParts[] = 'event_startDate=' . (int) $data['event']['startDate'];
|
||||||
}
|
|
||||||
if (!empty($data['event']['endDate'])) {
|
|
||||||
$meta[] = 'event_endDate=' . $data['event']['endDate'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$hidden =
|
$metaText = 'MEILISEARCH_META ' . implode(' | ', $metaParts);
|
||||||
|
|
||||||
|
$hiddenMeta =
|
||||||
"\n<span class=\"meilisearch-meta\" style=\"display:none !important\">" .
|
"\n<span class=\"meilisearch-meta\" style=\"display:none !important\">" .
|
||||||
'MEILISEARCH_META ' . implode(' | ', $meta) .
|
htmlspecialchars($metaText, ENT_QUOTES) .
|
||||||
"</span>\n";
|
"</span>\n";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* =====================
|
||||||
|
* JSON-MARKER
|
||||||
|
* =====================
|
||||||
|
*/
|
||||||
$marker =
|
$marker =
|
||||||
"\n<!--\nMEILISEARCH_JSON\n" .
|
"\n<!--\nMEILISEARCH_JSON\n" .
|
||||||
json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) .
|
json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) .
|
||||||
"\n-->\n";
|
"\n-->\n";
|
||||||
|
|
||||||
return str_replace('</body>', $hidden . $marker . '</body>', $buffer);
|
$injection = $hiddenMeta . $marker;
|
||||||
|
|
||||||
|
return str_contains($buffer, '</body>')
|
||||||
|
? str_replace('</body>', $injection . '</body>', $buffer)
|
||||||
|
: $buffer . $injection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,11 +34,3 @@ $GLOBALS['TL_DCA']['tl_search']['fields']['startDate'] = [
|
|||||||
'eval' => ['tl_class' => 'w50', 'rgxp' => 'digit'],
|
'eval' => ['tl_class' => 'w50', 'rgxp' => 'digit'],
|
||||||
'sql' => "bigint(20) NOT NULL default '0'",
|
'sql' => "bigint(20) NOT NULL default '0'",
|
||||||
];
|
];
|
||||||
|
|
||||||
$GLOBALS['TL_DCA']['tl_search']['fields']['endDate'] = [
|
|
||||||
'label' => ['Enddatum', 'Enddatum für die Suchergebnisse (Unix-Timestamp)'],
|
|
||||||
'exclude' => true,
|
|
||||||
'inputType' => 'text',
|
|
||||||
'eval' => ['tl_class' => 'w50', 'rgxp' => 'digit'],
|
|
||||||
'sql' => "bigint(20) NOT NULL default '0'",
|
|
||||||
];
|
|
||||||
Reference in New Issue
Block a user