Add conditional Tika URL setting
This commit is contained in:
@@ -4,14 +4,17 @@ use Contao\CoreBundle\DataContainer\PaletteManipulator;
|
|||||||
use Contao\System;
|
use Contao\System;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* -------------------------------------------------
|
||||||
* Fields
|
* Fields
|
||||||
|
* -------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_host'] = [
|
$GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_host'] = [
|
||||||
'inputType' => 'text',
|
'inputType' => 'text',
|
||||||
'eval' => [
|
'eval' => [
|
||||||
'mandatory' => true,
|
'mandatory' => true,
|
||||||
'rgxp' => 'url',
|
'rgxp' => 'url',
|
||||||
'tl_class' => 'w50',
|
'tl_class' => 'w50',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -19,7 +22,7 @@ $GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_index'] = [
|
|||||||
'inputType' => 'text',
|
'inputType' => 'text',
|
||||||
'eval' => [
|
'eval' => [
|
||||||
'mandatory' => true,
|
'mandatory' => true,
|
||||||
'tl_class' => 'w50',
|
'tl_class' => 'w50',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -27,7 +30,7 @@ $GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_api_write'] = [
|
|||||||
'inputType' => 'text',
|
'inputType' => 'text',
|
||||||
'eval' => [
|
'eval' => [
|
||||||
'mandatory' => true,
|
'mandatory' => true,
|
||||||
'tl_class' => 'w50',
|
'tl_class' => 'w50',
|
||||||
'hideInput' => true,
|
'hideInput' => true,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@@ -36,7 +39,7 @@ $GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_api_search'] = [
|
|||||||
'inputType' => 'text',
|
'inputType' => 'text',
|
||||||
'eval' => [
|
'eval' => [
|
||||||
'mandatory' => true,
|
'mandatory' => true,
|
||||||
'tl_class' => 'w50',
|
'tl_class' => 'w50',
|
||||||
'hideInput' => true,
|
'hideInput' => true,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@@ -55,50 +58,88 @@ $GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_imagesize'] = [
|
|||||||
return $options;
|
return $options;
|
||||||
},
|
},
|
||||||
'eval' => [
|
'eval' => [
|
||||||
'tl_class' => 'w50',
|
'tl_class' => 'w50',
|
||||||
'chosen' => true,
|
'chosen' => true,
|
||||||
'includeBlankOption' => true,
|
'includeBlankOption' => true,
|
||||||
],
|
],
|
||||||
// 🔥 DAS HAT GEFEHLT
|
|
||||||
'sql' => "int(10) unsigned NOT NULL default 0",
|
'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'] = [
|
$GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_fallback_image'] = [
|
||||||
'inputType' => 'fileTree',
|
'inputType' => 'fileTree',
|
||||||
'eval' => [
|
'eval' => [
|
||||||
'filesOnly' => true,
|
'filesOnly' => true,
|
||||||
'fieldType' => 'radio',
|
'fieldType' => 'radio',
|
||||||
'tl_class' => 'w50',
|
'tl_class' => 'w50',
|
||||||
],
|
],
|
||||||
'sql' => "varbinary(16) NULL",
|
'sql' => "varbinary(16) NULL",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_index_past_events'] = [
|
||||||
|
'inputType' => 'checkbox',
|
||||||
|
'eval' => [
|
||||||
|
'tl_class' => 'w50 clr',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDF / Office Indexierung
|
||||||
|
*/
|
||||||
|
|
||||||
$GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_index_pdfs'] = [
|
$GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_index_pdfs'] = [
|
||||||
'label' => &$GLOBALS['TL_LANG']['tl_settings']['meilisearch_index_pdfs'],
|
'label' => &$GLOBALS['TL_LANG']['tl_settings']['meilisearch_index_pdfs'],
|
||||||
'inputType' => 'checkbox',
|
'inputType' => 'checkbox',
|
||||||
'eval' => [
|
'eval' => [
|
||||||
'tl_class' => 'w50',
|
'tl_class' => 'w50',
|
||||||
|
'submitOnChange' => true,
|
||||||
],
|
],
|
||||||
'sql' => "char(1) NOT NULL default '1'",
|
'sql' => "char(1) NOT NULL default '1'",
|
||||||
];
|
];
|
||||||
|
|
||||||
$GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_index_office'] = [
|
$GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_index_office'] = [
|
||||||
'label' => &$GLOBALS['TL_LANG']['tl_settings']['meilisearch_index_office'],
|
'label' => &$GLOBALS['TL_LANG']['tl_settings']['meilisearch_index_office'],
|
||||||
'inputType' => 'checkbox',
|
'inputType' => 'checkbox',
|
||||||
'eval' => ['tl_class' => 'w50'],
|
'eval' => [
|
||||||
'sql' => "char(1) NOT NULL default '0'",
|
'tl_class' => 'w50',
|
||||||
|
'submitOnChange' => true,
|
||||||
|
],
|
||||||
|
'sql' => "char(1) NOT NULL default '0'",
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Palette
|
* Tika URL (nur sichtbar wenn PDFs oder Office aktiv)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_tika_url'] = [
|
||||||
|
'inputType' => 'text',
|
||||||
|
'eval' => [
|
||||||
|
'rgxp' => 'url',
|
||||||
|
'mandatory' => true,
|
||||||
|
'tl_class' => 'w50 clr',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -------------------------------------------------
|
||||||
|
* Selector / Subpalettes
|
||||||
|
* -------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
$GLOBALS['TL_DCA']['tl_settings']['palettes']['__selector__'][] = 'meilisearch_index_pdfs';
|
||||||
|
$GLOBALS['TL_DCA']['tl_settings']['palettes']['__selector__'][] = 'meilisearch_index_office';
|
||||||
|
|
||||||
|
$GLOBALS['TL_DCA']['tl_settings']['subpalettes']['meilisearch_index_pdfs']
|
||||||
|
= 'meilisearch_tika_url';
|
||||||
|
|
||||||
|
$GLOBALS['TL_DCA']['tl_settings']['subpalettes']['meilisearch_index_office']
|
||||||
|
= 'meilisearch_tika_url';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -------------------------------------------------
|
||||||
|
* Palette
|
||||||
|
* -------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
PaletteManipulator::create()
|
PaletteManipulator::create()
|
||||||
->addLegend('meilisearch_legend', null, PaletteManipulator::POSITION_AFTER, true)
|
->addLegend('meilisearch_legend', null, PaletteManipulator::POSITION_AFTER, true)
|
||||||
->addField('meilisearch_host', 'meilisearch_legend')
|
->addField('meilisearch_host', 'meilisearch_legend')
|
||||||
@@ -110,4 +151,22 @@ PaletteManipulator::create()
|
|||||||
->addField('meilisearch_index_past_events', 'meilisearch_legend')
|
->addField('meilisearch_index_past_events', 'meilisearch_legend')
|
||||||
->addField('meilisearch_index_pdfs', 'meilisearch_legend')
|
->addField('meilisearch_index_pdfs', 'meilisearch_legend')
|
||||||
->addField('meilisearch_index_office', 'meilisearch_legend')
|
->addField('meilisearch_index_office', 'meilisearch_legend')
|
||||||
->applyToPalette('default', 'tl_settings');
|
->applyToPalette('default', 'tl_settings');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -------------------------------------------------
|
||||||
|
* Optional: Absicherung beim Speichern
|
||||||
|
* -------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
$GLOBALS['TL_DCA']['tl_settings']['config']['onsubmit_callback'][] = static function () {
|
||||||
|
$indexPdf = (bool) \Contao\Config::get('meilisearch_index_pdfs');
|
||||||
|
$indexOffice = (bool) \Contao\Config::get('meilisearch_index_office');
|
||||||
|
$tikaUrl = \Contao\Config::get('meilisearch_tika_url');
|
||||||
|
|
||||||
|
if (($indexPdf || $indexOffice) && !$tikaUrl) {
|
||||||
|
throw new \RuntimeException(
|
||||||
|
'Die Tika-URL ist erforderlich, wenn PDF- oder Office-Indexierung aktiviert ist.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user