Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions contao/dca/tl_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@
'sql' => "int(10) unsigned NOT NULL default 0",
];

$dca['fields'][$jumpTo = ContentContainer::FIELD_JUMP_TO] = [
###> jump to page fields ###
$fieldJumpTo = [
'inputType' => 'pageTree',
'foreignKey' => 'tl_page.title',
'eval' => [
'mandatory' => false,
'fieldType' => 'radio',
'tl_class' => 'w50'
'tl_class' => 'w50',
],
'sql' => [
'type' => 'integer',
Expand All @@ -67,6 +68,10 @@
],
'relation' => ['type' => 'hasOne', 'load' => 'lazy'],
];
$dca['fields'][$jumpTo = ContentContainer::FIELD_JUMP_TO] = $fieldJumpTo;
$dca['fields'][$jumpToReader = ContentContainer::FIELD_JUMP_TO_READER] = $fieldJumpTo;
$dca['fields'][$jumpToListView = ContentContainer::FIELD_JUMP_TO_LISTVIEW] = $fieldJumpTo;
###< jump to page fields ###

$dca['fields'][$dcMultilingualDisplay = ContentContainer::FIELD_DC_MULTILINGUAL_DISPLAY] = [
'inputType' => 'select',
Expand All @@ -86,8 +91,9 @@

$dca['palettes'][ListViewController::TYPE] = '{type_legend},type,headline;'
. "{flare_list_legend},$list,$formName,$itemsPerPage,$jumpTo;"
. "{flare_reader_legend},$jumpToReader;"
. $commonPaletteEnd;

$dca['palettes'][ReaderController::TYPE] = '{type_legend},type,headline;'
. "{flare_list_legend},$list;"
. "{flare_list_legend},$list,$jumpToListView;"
. $commonPaletteEnd;
26 changes: 23 additions & 3 deletions contao/dca/tl_flare_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,32 @@
],
'sql' => "varchar(128) NULL default ''",
],
'jumpToListView' => [
'exclude' => true,
'inputType' => 'pageTree',
'foreignKey' => 'tl_page.title',
'eval' => ['fieldType' => 'radio', 'tl_class' => 'clr w50'],
'sql' => [
'type' => 'integer',
'unsigned' => true,
'length' => 10,
'notnull' => false,
'default' => null,
],
'relation' => ['type' => 'hasOne', 'load' => 'lazy'],
],
'jumpToReader' => [
'exclude' => true,
'inputType' => 'pageTree',
'foreignKey' => 'tl_page.title',
'eval' => ['fieldType' => 'radio', 'tl_class' => 'clr'],
'sql' => "int(10) unsigned NOT NULL default 0",
'eval' => ['fieldType' => 'radio', 'tl_class' => 'w50'],
'sql' => [
'type' => 'integer',
'unsigned' => true,
'length' => 10,
'notnull' => false,
'default' => null,
],
'relation' => ['type' => 'hasOne', 'load' => 'lazy'],
],
'sortSettings' => [
Expand Down Expand Up @@ -297,7 +317,7 @@
$dca['palettes'] = [
'__selector__' => ['type', 'whichPtable'],
'__prefix__' => '{title_legend},title,type',
'__suffix__' => '{flare_defaults_legend},sortSettings;{flare_reader_legend},jumpToReader;{advanced_legend:hide};{publish_legend},published',
'__suffix__' => '{flare_defaults_legend},sortSettings;{flare_jump_legend},jumpToListView,jumpToReader;{advanced_legend:hide};{publish_legend},published',
];

$dca['palettes']['default'] = Str::mergePalettes($dca['palettes']['__prefix__'], $dca['palettes']['__suffix__']);
Expand Down
3 changes: 3 additions & 0 deletions contao/languages/de/tl_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
$lang = &$GLOBALS['TL_LANG']['tl_content'];

$lang['flare_list_legend'] = 'Listen-Einstellungen';
$lang['flare_reader_legend'] = 'Leser-Einstellungen';
$lang[ContentContainer::FIELD_FORM_NAME] = ['Formularname', 'Geben Sie hier den Namen des Filter-Formulars ein.'];
$lang[ContentContainer::FIELD_ITEMS_PER_PAGE] = ['Elemente pro Seite', 'Geben Sie hier die Anzahl der Elemente pro Seite ein. 0 um alle anzuzeigen.'];
$lang[ContentContainer::FIELD_JUMP_TO] = ['Formular weiterleiten', 'Wählen Sie die "action"-Seite, auf die mit Absenden des Formulars weitergeleitet wird.'];
$lang[ContentContainer::FIELD_JUMP_TO_READER] = ['Detailleser-Seite überschreiben', 'Die Detailseite, auf die Listeneinträge verlinken.'];
$lang[ContentContainer::FIELD_JUMP_TO_LISTVIEW] = ['Listenansicht-Seite überschreiben', 'Die Seite, auf die der Zurück-Link führt.'];
$lang[ContentContainer::FIELD_LIST] = ['Liste', 'Bitte wählen Sie die anzuzeigende FLARE-Liste.'];
9 changes: 5 additions & 4 deletions contao/languages/de/tl_flare_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
$lang['sortSettings__direction'] = ['Sortierreihenfolge', 'Bitte wählen Sie die Sortierreihenfolge.'];
###< flare_defaults_legend ###

###> flare_reader_legend ###
$lang['flare_reader_legend'] = 'Leser-Einstellungen';
$lang['jumpToReader'] = ['Detailleserseite', 'Bitte wählen Sie die Seite aus, zu der Besucher weitergeleitet werden, wenn sie auf einen Listeneintrag klicken.'];
###< flare_reader_legend ###
###> flare_jump_legend ###
$lang['flare_jump_legend'] = 'Link-Einstellungen';
$lang['jumpToListView'] = ['Standard Listenansicht-Seite', 'Seite, die beim Klick auf den Zurück-Button geöffnet wird.'];
$lang['jumpToReader'] = ['Standard Detailleser-Seite', 'Seite, die beim Klick auf einen Listeneintrag geöffnet wird.'];
###< flare_jump_legend ###

###> meta_legend ###
$lang['meta_legend'] = 'Meta-Einstellungen';
Expand Down
3 changes: 3 additions & 0 deletions contao/languages/en/tl_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
$lang = &$GLOBALS['TL_LANG']['tl_content'];

$lang['flare_list_legend'] = 'List Settings';
$lang['flare_reader_legend'] = 'Reader Settings';
$lang[ContentContainer::FIELD_FORM_NAME] = ['Form Name', 'Enter the name of the filter form.'];
$lang[ContentContainer::FIELD_ITEMS_PER_PAGE] = ['Items per Page', 'Enter the number of items per page. Set to 0 to show all.'];
$lang[ContentContainer::FIELD_JUMP_TO] = ['Form Redirect', 'Choose the "action" page to which the form will redirect upon submission.'];
$lang[ContentContainer::FIELD_JUMP_TO_READER] = ['Override Detail Reader Page', 'The detail page to which list entries link.'];
$lang[ContentContainer::FIELD_JUMP_TO_LISTVIEW] = ['Override Back to List View Page', 'The page to which the back link points.'];
$lang[ContentContainer::FIELD_LIST] = ['List', 'Please choose the FLARE list to display.'];
9 changes: 5 additions & 4 deletions contao/languages/en/tl_flare_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
$lang['sortSettings__direction'] = ['Sorting Direction', 'Please choose the sorting direction.'];
###< flare_defaults_legend ###

###> flare_reader_legend ###
$lang['flare_reader_legend'] = 'Reader Settings';
$lang['jumpToReader'] = ['Detail Reader Page', 'Please choose the page to which visitors are redirected when clicking on a list entry.'];
###< flare_reader_legend ###
###> flare_jump_legend ###
$lang['flare_jump_legend'] = 'Link Settings';
$lang['jumpToListView'] = ['Default List View Page', 'Page opened when clicking the back button.'];
$lang['jumpToReader'] = ['Default Detail Reader Page', 'Page opened when clicking a list entry.'];
###< flare_jump_legend ###

###> meta_legend ###
$lang['meta_legend'] = 'Meta Settings';
Expand Down
2 changes: 2 additions & 0 deletions src/DataContainer/ContentContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ class ContentContainer
public const FIELD_FORM_NAME = 'flare_formName';
public const FIELD_ITEMS_PER_PAGE = 'flare_itemsPerPage';
public const FIELD_JUMP_TO = 'flare_jumpTo';
public const FIELD_JUMP_TO_READER = 'flare_jumpToReader';
public const FIELD_JUMP_TO_LISTVIEW = 'flare_jumpToListView';
public const FIELD_LIST = 'flare_list';
}
9 changes: 5 additions & 4 deletions src/Engine/Context/Factory/InteractiveContextFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace HeimrichHannot\FlareBundle\Engine\Context\Factory;

use Contao\ContentModel;
use HeimrichHannot\FlareBundle\DataContainer\ContentContainer;
use HeimrichHannot\FlareBundle\Engine\Context\InteractiveContext;
use HeimrichHannot\FlareBundle\Model\ListModel;
use HeimrichHannot\FlareBundle\Paginator\PaginatorConfig;
Expand All @@ -22,15 +23,15 @@ public function __construct(

public function createFromContent(ContentModel $contentModel, ListModel $listModel): InteractiveContext
{
$filterFormName = $contentModel->flare_formName ?: 'fl' . $listModel->id;
$filterFormName = $contentModel->{ContentContainer::FIELD_FORM_NAME} ?: ('fl' . $listModel->id);

$paginatorConfig = new PaginatorConfig(
itemsPerPage: (int) ($contentModel->flare_itemsPerPage ?: 0),
itemsPerPage: (int) ($contentModel->{ContentContainer::FIELD_ITEMS_PER_PAGE} ?: 0),
);

$sortOrderSequence = $this->sortOrderSequenceFactory->createFromListModel($listModel);

$jumpToReaderPageId = (int) ($listModel->jumpToReader ?: $contentModel->flare_jumpToReader);
$jumpToReaderPageId = (int) ($contentModel->{ContentContainer::FIELD_JUMP_TO_READER} ?: $listModel->jumpToReader);

$fieldAutoItem = DcaHelper::tryGetColumnName(
$listModel->dc,
Expand All @@ -42,7 +43,7 @@ public function createFromContent(ContentModel $contentModel, ListModel $listMod
paginatorConfig: $paginatorConfig,
sortOrderSequence: $sortOrderSequence,
contentModelId: (int) $contentModel->id,
formActionPage: (int) $contentModel->flare_jumpTo,
formActionPage: (int) $contentModel->{ContentContainer::FIELD_JUMP_TO},
formName: $filterFormName,
jumpToReaderPageId: $jumpToReaderPageId,
autoItemField: $fieldAutoItem,
Expand Down
5 changes: 4 additions & 1 deletion src/Engine/Context/Factory/ValidationContextFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace HeimrichHannot\FlareBundle\Engine\Context\Factory;

use Contao\ContentModel;
use HeimrichHannot\FlareBundle\DataContainer\ContentContainer;
use HeimrichHannot\FlareBundle\Engine\Context\ValidationContext;
use HeimrichHannot\FlareBundle\Engine\View\InteractiveView;
use HeimrichHannot\FlareBundle\Model\ListModel;
Expand All @@ -20,7 +21,8 @@ public function __construct(

public function createFromContent(ContentModel $contentModel, ListModel $listModel): ValidationContext
{
$jumpToReaderPageId = (int) ($listModel->jumpToReader ?: $contentModel->flare_jumpToReader);
$jumpToReaderPageId = (int) ($contentModel->{ContentContainer::FIELD_JUMP_TO_READER} ?: $listModel->jumpToReader);
$jumpToListViewPageId = (int) ($contentModel->{ContentContainer::FIELD_JUMP_TO_LISTVIEW} ?: $listModel->jumpToListView);

$fieldAutoItem = DcaHelper::tryGetColumnName(
$listModel->dc,
Expand All @@ -30,6 +32,7 @@ public function createFromContent(ContentModel $contentModel, ListModel $listMod

$config = new ValidationContext(
jumpToReaderPageId: $jumpToReaderPageId,
jumpToListViewPageId: $jumpToListViewPageId,
autoItemField: $fieldAutoItem,
);

Expand Down
2 changes: 2 additions & 0 deletions src/Engine/Context/ValidationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public static function getContextType(): string
public function __construct(
private ?\Closure $entryCache = null,
#[Assert\PositiveOrZero] public int $jumpToReaderPageId = 0,
#[Assert\PositiveOrZero] public int $jumpToListViewPageId = 0,
#[Assert\NotBlank] private string $autoItemField = 'id',
private array $filterValues = [],
) {
Expand Down Expand Up @@ -68,6 +69,7 @@ public function withFilterValues(array $values): self
return new self(
entryCache: $this->entryCache,
jumpToReaderPageId: $this->jumpToReaderPageId,
jumpToListViewPageId: $this->jumpToListViewPageId,
autoItemField: $this->autoItemField,
filterValues: $values,
);
Expand Down
26 changes: 10 additions & 16 deletions src/EventListener/Contao/LoadDataContainerListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ public function __construct(
*/
public function __invoke(string $table): void
{
if ($table !== 'tl_flare_filter' && $table !== 'tl_flare_list') {
$filterTable = FilterModel::getTable();
$listTable = ListModel::getTable();

if ($table !== $filterTable && $table !== $listTable) {
return;
}

Expand All @@ -40,29 +43,20 @@ public function __invoke(string $table): void
return;
}

$model = match ($table) {
'tl_flare_filter' => FilterModel::findByPk($id),
'tl_flare_list' => ListModel::findByPk($id),
[$modelType, $prefix, $container] = match ($table) {
$filterTable => [FilterModel::findByPk($id)?->type, 'filter.', $this->filterContainer],
$listTable => [ListModel::findByPk($id)?->type, 'list.', $this->listContainer],
default => [null, null, null],
};

if (!$model || !$model->type) {
if (!$modelType || $prefix || !$container) {
return;
}

$prefix = match ($table) {
'tl_flare_filter' => 'filter.',
'tl_flare_list' => 'list.',
};

if (!$callbacks = $this->registry->getNamespace($prefix . $model->type)) {
if (!$callbacks = $this->registry->getNamespace($prefix . $modelType)) {
return;
}

$container = match ($table) {
'tl_flare_filter' => $this->filterContainer,
'tl_flare_list' => $this->listContainer,
};

// @phpstan-ignore function.alreadyNarrowedType
if (!\is_subclass_of($container, FlareCallbackContainerInterface::class)) {
return;
Expand Down
3 changes: 2 additions & 1 deletion src/Model/DocumentsListModelTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
* @property bool $comments_enabled
* @property bool $comments_sendNativeEmails
* @property string $fieldAutoItem
* @property string $jumpToReader
* @property ?int $jumpToReader
* @property ?int $jumpToListView
* @property array $sortSettings
* @property string $metaTitleFormat
* @property string $metaDescriptionFormat
Expand Down
Loading