Bugfix
This commit is contained in:
@@ -6,126 +6,26 @@ class IndexPageListener
|
|||||||
{
|
{
|
||||||
public function onIndexPage(string $content, array &$data, array &$set): void
|
public function onIndexPage(string $content, array &$data, array &$set): void
|
||||||
{
|
{
|
||||||
$debug = (PHP_SAPI === 'cli');
|
if (PHP_SAPI === 'cli') {
|
||||||
|
echo "\n=== HARD OVERRIDE TEST ===\n";
|
||||||
if ($debug) {
|
echo "URL: " . ($set['url'] ?? '-') . "\n";
|
||||||
echo "\n=============================\n";
|
|
||||||
echo "INDEXPAGE HOOK START\n";
|
|
||||||
echo "URL: " . ($set['url'] ?? '[no url]') . "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// 🔥 HART GESETZT – KEINE LOGIK
|
||||||
// 1. MEILISEARCH_JSON finden
|
$set['priority'] = 9;
|
||||||
// --------------------------------------------------
|
$set['keywords'] = 'HARDCODED_KEYWORDS_TEST';
|
||||||
if (
|
$set['imagepath'] = 'HARDCODED-IMAGE-UUID-123';
|
||||||
!preg_match(
|
$set['startDate'] = 1234567890;
|
||||||
'#<!--\s*MEILISEARCH_JSON\s*(.*?)\s*-->#s',
|
|
||||||
$content,
|
|
||||||
$m
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
if ($debug) {
|
|
||||||
echo "❌ MEILISEARCH_JSON not found\n";
|
|
||||||
echo "INDEXPAGE HOOK END\n";
|
|
||||||
echo "=============================\n";
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$json = trim($m[1]);
|
if (PHP_SAPI === 'cli') {
|
||||||
$meta = json_decode($json, true);
|
echo "SET WRITTEN:\n";
|
||||||
|
|
||||||
if (!is_array($meta)) {
|
|
||||||
if ($debug) {
|
|
||||||
echo "❌ Invalid JSON in MEILISEARCH_JSON\n";
|
|
||||||
echo "RAW JSON:\n$json\n";
|
|
||||||
echo "JSON ERROR: " . json_last_error_msg() . "\n";
|
|
||||||
echo "INDEXPAGE HOOK END\n";
|
|
||||||
echo "=============================\n";
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($debug) {
|
|
||||||
echo "✅ MEILISEARCH_JSON parsed\n";
|
|
||||||
var_dump($meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------
|
|
||||||
// 2. PRIORITY (event > news > page)
|
|
||||||
// --------------------------------------------------
|
|
||||||
foreach (['event', 'news', 'page'] as $scope) {
|
|
||||||
if (!empty($meta[$scope]['priority'])) {
|
|
||||||
$set['priority'] = (int) $meta[$scope]['priority'];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------
|
|
||||||
// 3. KEYWORDS (kombinieren)
|
|
||||||
// --------------------------------------------------
|
|
||||||
$keywords = [];
|
|
||||||
|
|
||||||
foreach (['event', 'news', 'page'] as $scope) {
|
|
||||||
if (!empty($meta[$scope]['keywords'])) {
|
|
||||||
$parts = preg_split(
|
|
||||||
'/\s+/',
|
|
||||||
trim((string) $meta[$scope]['keywords'])
|
|
||||||
) ?: [];
|
|
||||||
|
|
||||||
$keywords = array_merge($keywords, $parts);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($keywords) {
|
|
||||||
$set['keywords'] = implode(' ', array_unique($keywords));
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------
|
|
||||||
// 4. IMAGEPATH
|
|
||||||
// Reihenfolge: custom > event > news > page
|
|
||||||
// --------------------------------------------------
|
|
||||||
foreach (
|
|
||||||
[
|
|
||||||
$meta['custom']['searchimage'] ?? null,
|
|
||||||
$meta['event']['searchimage'] ?? null,
|
|
||||||
$meta['news']['searchimage'] ?? null,
|
|
||||||
$meta['page']['searchimage'] ?? null,
|
|
||||||
] as $img
|
|
||||||
) {
|
|
||||||
if ($img) {
|
|
||||||
$set['imagepath'] = trim((string) $img);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------
|
|
||||||
// 5. STARTDATE
|
|
||||||
// --------------------------------------------------
|
|
||||||
foreach (['event', 'news'] as $scope) {
|
|
||||||
if (!empty($meta[$scope]['date'])) {
|
|
||||||
$ts = strtotime((string) $meta[$scope]['date']);
|
|
||||||
if ($ts !== false) {
|
|
||||||
$set['startDate'] = $ts;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------
|
|
||||||
// DEBUG
|
|
||||||
// --------------------------------------------------
|
|
||||||
if ($debug) {
|
|
||||||
echo "---- FINAL \$set ----\n";
|
|
||||||
var_dump([
|
var_dump([
|
||||||
'priority' => $set['priority'] ?? null,
|
'priority' => $set['priority'],
|
||||||
'keywords' => $set['keywords'] ?? null,
|
'keywords' => $set['keywords'],
|
||||||
'imagepath' => $set['imagepath'] ?? null,
|
'imagepath' => $set['imagepath'],
|
||||||
'startDate' => $set['startDate'] ?? null,
|
'startDate' => $set['startDate'],
|
||||||
]);
|
]);
|
||||||
|
echo "=== END HARD OVERRIDE ===\n";
|
||||||
echo "INDEXPAGE HOOK END\n";
|
|
||||||
echo "=============================\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user