Links
+ */
private function findAllLinks(string $content): array
{
if (!preg_match_all(
@@ -278,8 +270,12 @@ class IndexPageListener
return $result;
}
+ /**
+ * Ermittelt indexierbaren Dateityp (pdf|docx|xlsx|pptx) oder null
+ */
private function detectIndexableFileType(string $url): ?string
{
+ // Hash entfernen
$url = strtok($url, '#');
$parts = parse_url($url);
@@ -287,6 +283,7 @@ class IndexPageListener
return null;
}
+ // direkter Pfad (/files/…)
if (!empty($parts['path'])) {
$ext = strtolower(pathinfo($parts['path'], PATHINFO_EXTENSION));
if (in_array($ext, ['pdf', 'docx', 'xlsx', 'pptx'], true)) {
@@ -294,12 +291,18 @@ class IndexPageListener
}
}
+ // Query-Parameter (Contao 4 + 5)
if (!empty($parts['query'])) {
parse_str($parts['query'], $query);
foreach (['file', 'p', 'f'] as $param) {
if (!empty($query[$param])) {
- $candidate = rawurldecode(html_entity_decode((string) $query[$param], ENT_QUOTES));
+ $candidate = (string) $query[$param];
+
+ // sicher decodieren (Contao 4 + 5)
+ $candidate = html_entity_decode($candidate, ENT_QUOTES);
+ $candidate = rawurldecode($candidate);
+
$ext = strtolower(pathinfo($candidate, PATHINFO_EXTENSION));
if (in_array($ext, ['pdf', 'docx', 'xlsx', 'pptx'], true)) {
diff --git a/src/Resources/config/services.yaml b/src/Resources/config/services.yaml
index 79ae9db..b4e4b9e 100644
--- a/src/Resources/config/services.yaml
+++ b/src/Resources/config/services.yaml
@@ -3,7 +3,7 @@ services:
Psr\Container\ContainerInterface: '@service_container'
MummertMedia\ContaoMeilisearchBundle\:
- resource: '../../{Command,EventListener,Service}'
+ resource: '../../{Command,Cron,EventListener,Service}'
autowire: true
autoconfigure: true
@@ -19,6 +19,12 @@ services:
tags:
- { name: contao.hook, hook: indexPage, method: onIndexPage }
+ MummertMedia\ContaoMeilisearchBundle\Cron\MeilisearchIndexCron:
+ autowire: true
+ autoconfigure: false
+ tags:
+ - { name: contao.cron, interval: daily, method: __invoke }
+
MummertMedia\ContaoMeilisearchBundle\Controller\FrontendModule\MeilisearchSearchController:
autowire: true
autoconfigure: false
diff --git a/src/Resources/contao/dca/tl_search_files.php b/src/Resources/contao/dca/tl_search_files.php
index 8fdc052..3fb7f1b 100644
--- a/src/Resources/contao/dca/tl_search_files.php
+++ b/src/Resources/contao/dca/tl_search_files.php
@@ -2,7 +2,7 @@
use Contao\DC_Table;
-$GLOBALS['TL_DCA']['tl_search_files'] = [
+$GLOBALS['TL_DCA']['tl_search_pdf'] = [
'config' => [
'dataContainer' => DC_Table::class,
'sql' => [
diff --git a/src/Resources/contao/dca/tl_settings.php b/src/Resources/contao/dca/tl_settings.php
index d284ef3..1bde23e 100644
--- a/src/Resources/contao/dca/tl_settings.php
+++ b/src/Resources/contao/dca/tl_settings.php
@@ -4,17 +4,14 @@ use Contao\CoreBundle\DataContainer\PaletteManipulator;
use Contao\System;
/**
- * -------------------------------------------------
* Fields
- * -------------------------------------------------
*/
-
$GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_host'] = [
'inputType' => 'text',
'eval' => [
'mandatory' => true,
- 'rgxp' => 'url',
- 'tl_class' => 'w50',
+ 'rgxp' => 'url',
+ 'tl_class' => 'w50',
],
];
@@ -22,7 +19,7 @@ $GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_index'] = [
'inputType' => 'text',
'eval' => [
'mandatory' => true,
- 'tl_class' => 'w50',
+ 'tl_class' => 'w50',
],
];
@@ -30,7 +27,7 @@ $GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_api_write'] = [
'inputType' => 'text',
'eval' => [
'mandatory' => true,
- 'tl_class' => 'w50',
+ 'tl_class' => 'w50',
'hideInput' => true,
],
];
@@ -39,7 +36,7 @@ $GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_api_search'] = [
'inputType' => 'text',
'eval' => [
'mandatory' => true,
- 'tl_class' => 'w50',
+ 'tl_class' => 'w50',
'hideInput' => true,
],
];
@@ -58,71 +55,50 @@ $GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_imagesize'] = [
return $options;
},
'eval' => [
- 'tl_class' => 'w50',
- 'chosen' => true,
+ 'tl_class' => 'w50',
+ 'chosen' => true,
'includeBlankOption' => true,
],
+ // 🔥 DAS HAT GEFEHLT
'sql' => "int(10) unsigned NOT NULL default 0",
];
+$GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_index_past_events'] = [
+ 'inputType' => 'checkbox',
+ 'eval' => [
+ 'tl_class' => 'w50 clr',
+ ],
+];
+
$GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_fallback_image'] = [
'inputType' => 'fileTree',
'eval' => [
'filesOnly' => true,
'fieldType' => 'radio',
- 'tl_class' => 'w50',
+ 'tl_class' => 'w50',
],
'sql' => "varbinary(16) NULL",
];
-$GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_index_past_events'] = [
+$GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_index_pdfs'] = [
+ 'label' => &$GLOBALS['TL_LANG']['tl_settings']['meilisearch_index_pdfs'],
'inputType' => 'checkbox',
- 'eval' => [
- 'tl_class' => 'w50 clr',
+ 'eval' => [
+ 'tl_class' => 'w50',
],
+ 'sql' => "char(1) NOT NULL default '1'",
];
-/**
- * -------------------------------------------------
- * Datei-Indexierung (Tika)
- * -------------------------------------------------
- */
-
-$GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_index_files'] = [
+$GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_index_office'] = [
+ 'label' => &$GLOBALS['TL_LANG']['tl_settings']['meilisearch_index_office'],
'inputType' => 'checkbox',
- 'eval' => [
- 'tl_class' => 'w50',
- 'submitOnChange' => true,
- ],
- 'sql' => "char(1) NOT NULL default '0'",
-];
-
-$GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_tika_url'] = [
- 'inputType' => 'text',
- 'eval' => [
- 'rgxp' => 'url',
- 'mandatory' => true,
- 'tl_class' => 'w50 clr',
- ],
+ 'eval' => ['tl_class' => 'w50'],
+ 'sql' => "char(1) NOT NULL default '0'",
];
/**
- * -------------------------------------------------
- * Selector / Subpalette
- * -------------------------------------------------
- */
-
-$GLOBALS['TL_DCA']['tl_settings']['palettes']['__selector__'][] = 'meilisearch_index_files';
-
-$GLOBALS['TL_DCA']['tl_settings']['subpalettes']['meilisearch_index_files']
- = 'meilisearch_tika_url';
-
-/**
- * -------------------------------------------------
* Palette
- * -------------------------------------------------
*/
-
PaletteManipulator::create()
->addLegend('meilisearch_legend', null, PaletteManipulator::POSITION_AFTER, true)
->addField('meilisearch_host', 'meilisearch_legend')
@@ -132,5 +108,6 @@ PaletteManipulator::create()
->addField('meilisearch_imagesize', 'meilisearch_legend')
->addField('meilisearch_fallback_image', 'meilisearch_legend')
->addField('meilisearch_index_past_events', 'meilisearch_legend')
- ->addField('meilisearch_index_files', 'meilisearch_legend')
+ ->addField('meilisearch_index_pdfs', 'meilisearch_legend')
+ ->addField('meilisearch_index_office', 'meilisearch_legend')
->applyToPalette('default', 'tl_settings');
\ No newline at end of file
diff --git a/src/Resources/contao/languages/de/tl_settings.php b/src/Resources/contao/languages/de/tl_settings.php
index e5bdaf3..883f8cb 100644
--- a/src/Resources/contao/languages/de/tl_settings.php
+++ b/src/Resources/contao/languages/de/tl_settings.php
@@ -28,10 +28,10 @@ $GLOBALS['TL_LANG']['tl_settings']['meilisearch_index_past_events'][0]
$GLOBALS['TL_LANG']['tl_settings']['meilisearch_index_past_events'][1]
= 'Vergangene Kalender-Events werden ebenfalls in Meilisearch indexiert.';
-$GLOBALS['TL_LANG']['tl_settings']['meilisearch_index_files'] = [
- 'Dateien indexieren',
- 'Aktiviert die Indexierung von PDF-Dateien sowie DOCX, XLSX und PPTX.',
+$GLOBALS['TL_LANG']['tl_settings']['meilisearch_index_pdfs'] = [
+ 'PDFs indexieren',
+ 'Aktiviert die Indexierung von PDF-Dateien für die Suche.',
];
-$GLOBALS['TL_LANG']['tl_settings']['meilisearch_tika_url']
- = ['Apache Tika URL', 'URL der Apache Tika Instanz (z. B. https://tika.domain.tld).'];
\ No newline at end of file
+$GLOBALS['TL_LANG']['tl_settings']['meilisearch_index_office']
+ = ['Office-Dateien indexieren', 'DOCX, XLSX und PPTX in die Suche aufnehmen.'];
\ No newline at end of file
diff --git a/src/Resources/contao/templates/frontend_module/mod_meilisearch_search.html.twig b/src/Resources/contao/templates/frontend_module/mod_meilisearch_search.html.twig
index 5994299..68343fe 100644
--- a/src/Resources/contao/templates/frontend_module/mod_meilisearch_search.html.twig
+++ b/src/Resources/contao/templates/frontend_module/mod_meilisearch_search.html.twig
@@ -4,6 +4,7 @@ Contao 5 – Frontend Module Template
#}
+{% block meilisearch %}
+{% endblock %}
\ No newline at end of file