From 1804ecb33dca957019be13cb042418a3acad9851 Mon Sep 17 00:00:00 2001 From: Sebastian Zoglowek <55794780+zoglo@users.noreply.github.com> Date: Mon, 15 Apr 2024 16:36:43 +0200 Subject: [PATCH 01/10] Fix reader page in contao 5 --- contao/modules/ModuleRecommendationReader.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/contao/modules/ModuleRecommendationReader.php b/contao/modules/ModuleRecommendationReader.php index f684ed7..dc00020 100644 --- a/contao/modules/ModuleRecommendationReader.php +++ b/contao/modules/ModuleRecommendationReader.php @@ -9,7 +9,6 @@ namespace Oveleon\ContaoRecommendationBundle; use Contao\BackendTemplate; -use Contao\Config; use Contao\CoreBundle\ContaoCoreBundle; use Contao\CoreBundle\Exception\InternalServerErrorException; use Contao\CoreBundle\Exception\PageNotFoundException; @@ -19,7 +18,6 @@ use Contao\System; use Oveleon\ContaoRecommendationBundle\Model\RecommendationArchiveModel; use Oveleon\ContaoRecommendationBundle\Model\RecommendationModel; -use Symfony\Component\HttpFoundation\Response; /** * Front end module "recommendation reader". @@ -95,7 +93,7 @@ protected function compile() $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; // Get the recommendation item - $objRecommendation = RecommendationModel::findPublishedByParentAndIdOrAlias(Input::get('items'), $this->recommendation_archives); + $objRecommendation = RecommendationModel::findPublishedByParentAndIdOrAlias(Input::get('auto_item'), $this->recommendation_archives); if (null === $objRecommendation) { From e335f97d608c00c73a12df746c218b06e02ab111 Mon Sep 17 00:00:00 2001 From: Sebastian Zoglowek <55794780+zoglo@users.noreply.github.com> Date: Mon, 15 Apr 2024 16:37:37 +0200 Subject: [PATCH 02/10] Do not show jumpTo link on reader pages --- contao/modules/ModuleRecommendation.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/contao/modules/ModuleRecommendation.php b/contao/modules/ModuleRecommendation.php index 18e6a6d..90a375f 100644 --- a/contao/modules/ModuleRecommendation.php +++ b/contao/modules/ModuleRecommendation.php @@ -67,7 +67,7 @@ protected function sortOutProtected(array $arrArchives): array /** * Parse an item and return it as string */ - protected function parseRecommendation(RecommendationModel $objRecommendation, RecommendationArchiveModel $objRecommendationArchive, string $strClass='', int $intCount=0): string + protected function parseRecommendation(RecommendationModel $objRecommendation, RecommendationArchiveModel $objRecommendationArchive, string $strClass='', int $intCount=0, bool $allowRedirect = false): string { $objTemplate = new FrontendTemplate($this->recommendation_template ?: 'recommendation_default'); $objTemplate->setData($objRecommendation->row()); @@ -85,7 +85,7 @@ protected function parseRecommendation(RecommendationModel $objRecommendation, R $objTemplate->class = $strClass; $objTemplate->archiveId = $objRecommendationArchive->id; - if ($objRecommendationArchive->jumpTo) + if ($allowRedirect) { $objTemplate->allowRedirect = true; $objTemplate->more = $this->generateLink($GLOBALS['TL_LANG']['MSC']['more'], $objRecommendation, $objRecommendation->title, true); @@ -203,7 +203,13 @@ protected function parseRecommendations(Collection $objRecommendations): array /** @var RecommendationArchiveModel $objRecommendationArchive */ $objRecommendationArchive = $recommendation->getRelated('pid'); - $arrRecommendations[] = $this->parseRecommendation($recommendation, $objRecommendationArchive, ((++$count == 1) ? ' first' : '') . (($count == $limit) ? ' last' : '') . ((($count % 2) == 0) ? ' odd' : ' even'), $count); + $arrRecommendations[] = $this->parseRecommendation( + $recommendation, + $objRecommendationArchive, + ((++$count == 1) ? ' first' : '') . (($count == $limit) ? ' last' : '') . ((($count % 2) == 0) ? ' odd' : ' even'), + $count, + (bool) $objRecommendationArchive->jumpTo + ); } return $arrRecommendations; From 31ff8dbcc8ec4ed611a6f2a77a55fd97b3c3c307 Mon Sep 17 00:00:00 2001 From: Sebastian Zoglowek <55794780+zoglo@users.noreply.github.com> Date: Mon, 15 Apr 2024 16:38:56 +0200 Subject: [PATCH 03/10] Properly check for `5.x` version as well --- contao/modules/ModuleRecommendation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contao/modules/ModuleRecommendation.php b/contao/modules/ModuleRecommendation.php index 90a375f..f1c3827 100644 --- a/contao/modules/ModuleRecommendation.php +++ b/contao/modules/ModuleRecommendation.php @@ -371,6 +371,6 @@ protected function translateElapsedTime(int $value, string $strUnit = 'justNow') */ protected function useAutoItem(): bool { - return version_compare(ContaoCoreBundle::getVersion(), '5', '<') ? Config::get('useAutoItem') : true; + return !str_starts_with(ContaoCoreBundle::getVersion(), '5.') ? Config::get('useAutoItem') : true; } } From 89420a755acd963df4ba94ed4a2ba285987829f7 Mon Sep 17 00:00:00 2001 From: Sebastian Zoglowek <55794780+zoglo@users.noreply.github.com> Date: Mon, 15 Apr 2024 17:15:44 +0200 Subject: [PATCH 04/10] Add overviewPage and customLabel --- contao/dca/tl_module.php | 4 ++-- contao/modules/ModuleRecommendationReader.php | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/contao/dca/tl_module.php b/contao/dca/tl_module.php index aa36199..ea12759 100644 --- a/contao/dca/tl_module.php +++ b/contao/dca/tl_module.php @@ -20,8 +20,8 @@ $GLOBALS['TL_DCA']['tl_module']['palettes']['__selector__'][] = 'recommendation_activate'; // Add palettes to tl_module -$GLOBALS['TL_DCA']['tl_module']['palettes']['recommendationlist'] = '{title_legend},name,headline,type;{config_legend},recommendation_archives,recommendation_readerModule,recommendation_minRating,recommendation_featured,recommendation_order,numberOfItems,perPage;{template_legend:hide},recommendation_metaFields,recommendation_template,customTpl;{image_legend:hide},imgSize,recommendation_externalSize;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; -$GLOBALS['TL_DCA']['tl_module']['palettes']['recommendationreader'] = '{title_legend},name,headline,type;{config_legend},recommendation_archives;{template_legend:hide},recommendation_metaFields,recommendation_template,customTpl;{image_legend:hide},imgSize,recommendation_externalSize;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; +$GLOBALS['TL_DCA']['tl_module']['palettes']['recommendationlist'] = '{title_legend},name,headline,type;{config_legend},recommendation_archives,recommendation_readerModule,recommendation_minRating,recommendation_featured,recommendation_order,numberOfItems,perPage,customLabel;{template_legend:hide},recommendation_metaFields,recommendation_template,customTpl;{image_legend:hide},imgSize,recommendation_externalSize;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; +$GLOBALS['TL_DCA']['tl_module']['palettes']['recommendationreader'] = '{title_legend},name,headline,type;{config_legend},recommendation_archives,overviewPage,customLabel;{template_legend:hide},recommendation_metaFields,recommendation_template,customTpl;{image_legend:hide},imgSize,recommendation_externalSize;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; $GLOBALS['TL_DCA']['tl_module']['palettes']['recommendationform'] = '{title_legend},name,headline,type;{config_legend},recommendation_archive,recommendation_optionalFormFields,recommendation_customFieldLabel,recommendation_notify,recommendation_moderate,recommendation_disableCaptcha;{privacy_legend},recommendation_privacyText;{redirect_legend:hide},jumpTo;{email_legend:hide},recommendation_activate;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; $GLOBALS['TL_DCA']['tl_module']['subpalettes']['recommendation_activate'] = 'recommendation_activateJumpTo,recommendation_activateText'; diff --git a/contao/modules/ModuleRecommendationReader.php b/contao/modules/ModuleRecommendationReader.php index dc00020..afb38e4 100644 --- a/contao/modules/ModuleRecommendationReader.php +++ b/contao/modules/ModuleRecommendationReader.php @@ -14,6 +14,7 @@ use Contao\CoreBundle\Exception\PageNotFoundException; use Contao\Environment; use Contao\Input; +use Contao\PageModel; use Contao\StringUtil; use Contao\System; use Oveleon\ContaoRecommendationBundle\Model\RecommendationArchiveModel; @@ -89,8 +90,17 @@ public function generate() protected function compile() { $this->Template->recommendation = ''; - $this->Template->referer = 'javascript:history.go(-1)'; - $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; + + if ($this->overviewPage) + { + $this->Template->referer = PageModel::findById($this->overviewPage)->getFrontendUrl(); + $this->Template->back = $this->customLabel ?: $GLOBALS['TL_LANG']['MSC']['goBack']; + } + else + { + $this->Template->referer = 'javascript:history.go(-1)'; + $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; + } // Get the recommendation item $objRecommendation = RecommendationModel::findPublishedByParentAndIdOrAlias(Input::get('auto_item'), $this->recommendation_archives); From a70a94a97971404d655e6ff66ac7a9a8f4566b46 Mon Sep 17 00:00:00 2001 From: Sebastian Zoglowek <55794780+zoglo@users.noreply.github.com> Date: Mon, 15 Apr 2024 17:15:55 +0200 Subject: [PATCH 05/10] Update translations for more --- contao/languages/de/default.xlf | 4 ++++ contao/languages/en/default.xlf | 3 +++ contao/modules/ModuleRecommendation.php | 5 +++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/contao/languages/de/default.xlf b/contao/languages/de/default.xlf index 97241b7..5da1932 100644 --- a/contao/languages/de/default.xlf +++ b/contao/languages/de/default.xlf @@ -5,6 +5,10 @@ Currently there are no recommendations. Zurzeit sind keine Bewertungen vorhanden. + + Read the recommendation: %s + Die Bewertung lesen: %s + diff --git a/contao/languages/en/default.xlf b/contao/languages/en/default.xlf index 7244fee..0520056 100644 --- a/contao/languages/en/default.xlf +++ b/contao/languages/en/default.xlf @@ -4,6 +4,9 @@ Currently there are no recommendations. + + Read the recommendation: %s + diff --git a/contao/modules/ModuleRecommendation.php b/contao/modules/ModuleRecommendation.php index f1c3827..2424fab 100644 --- a/contao/modules/ModuleRecommendation.php +++ b/contao/modules/ModuleRecommendation.php @@ -88,7 +88,8 @@ protected function parseRecommendation(RecommendationModel $objRecommendation, R if ($allowRedirect) { $objTemplate->allowRedirect = true; - $objTemplate->more = $this->generateLink($GLOBALS['TL_LANG']['MSC']['more'], $objRecommendation, $objRecommendation->title, true); + $moreLabel = $this->customLabel ?: $GLOBALS['TL_LANG']['MSC']['more']; + $objTemplate->more = $this->generateLink($moreLabel, $objRecommendation, $objRecommendation->title ?: $objRecommendation, true); } if ($objRecommendation->title) @@ -259,7 +260,7 @@ protected function generateLink(string $strLink, RecommendationModel $objRecomme { return sprintf('', $this->generateRecommendationUrl($objRecommendation), - StringUtil::specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['readMore'], $strTitle), true), + StringUtil::specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['readRecommendation'], $strTitle), true), $strLink, ($blnIsReadMore ? '' : '')); } From 679b3f4739d42b4ef5cf0482ebf2e934abc30806 Mon Sep 17 00:00:00 2001 From: Sebastian Zoglowek <55794780+zoglo@users.noreply.github.com> Date: Tue, 16 Apr 2024 15:44:09 +0200 Subject: [PATCH 06/10] Add dialog option for recommendations - Can be activated within module --- contao/dca/tl_module.php | 18 +++++++++--------- contao/languages/de/tl_module.xlf | 8 ++++++++ contao/languages/en/tl_module.xlf | 6 ++++++ contao/modules/ModuleRecommendation.php | 19 +++++++++++++------ src/Model/RecommendationArchiveModel.php | 7 +++++++ 5 files changed, 43 insertions(+), 15 deletions(-) diff --git a/contao/dca/tl_module.php b/contao/dca/tl_module.php index ea12759..1aecb9c 100644 --- a/contao/dca/tl_module.php +++ b/contao/dca/tl_module.php @@ -20,7 +20,7 @@ $GLOBALS['TL_DCA']['tl_module']['palettes']['__selector__'][] = 'recommendation_activate'; // Add palettes to tl_module -$GLOBALS['TL_DCA']['tl_module']['palettes']['recommendationlist'] = '{title_legend},name,headline,type;{config_legend},recommendation_archives,recommendation_readerModule,recommendation_minRating,recommendation_featured,recommendation_order,numberOfItems,perPage,customLabel;{template_legend:hide},recommendation_metaFields,recommendation_template,customTpl;{image_legend:hide},imgSize,recommendation_externalSize;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; +$GLOBALS['TL_DCA']['tl_module']['palettes']['recommendationlist'] = '{title_legend},name,headline,type;{config_legend},recommendation_archives,recommendation_readerModule,recommendation_minRating,recommendation_featured,recommendation_order,numberOfItems,perPage,customLabel;{template_legend:hide},recommendation_metaFields,recommendation_template,customTpl,recommendation_useDialog;{image_legend:hide},imgSize,recommendation_externalSize;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; $GLOBALS['TL_DCA']['tl_module']['palettes']['recommendationreader'] = '{title_legend},name,headline,type;{config_legend},recommendation_archives,overviewPage,customLabel;{template_legend:hide},recommendation_metaFields,recommendation_template,customTpl;{image_legend:hide},imgSize,recommendation_externalSize;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; $GLOBALS['TL_DCA']['tl_module']['palettes']['recommendationform'] = '{title_legend},name,headline,type;{config_legend},recommendation_archive,recommendation_optionalFormFields,recommendation_customFieldLabel,recommendation_notify,recommendation_moderate,recommendation_disableCaptcha;{privacy_legend},recommendation_privacyText;{redirect_legend:hide},jumpTo;{email_legend:hide},recommendation_activate;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; @@ -72,6 +72,14 @@ 'sql' => "varchar(255) NOT NULL default ''" ]; +$GLOBALS['TL_DCA']['tl_module']['fields']['recommendation_useDialog'] = [ + 'exclude' => true, + 'filter' => true, + 'inputType' => 'checkbox', + 'eval' => ['tl_class'=>'clr'], + 'sql' => "char(1) NOT NULL default ''" +]; + $GLOBALS['TL_DCA']['tl_module']['fields']['recommendation_order'] = [ 'exclude' => true, 'inputType' => 'select', @@ -178,14 +186,6 @@ 'sql' => "varchar(64) NOT NULL default ''" ]; -$GLOBALS['TL_DCA']['tl_module']['fields']['recommendation_template'] = [ - 'exclude' => true, - 'inputType' => 'select', - 'options_callback' => static fn () => Controller::getTemplateGroup('recommendation_'), - 'eval' => ['includeBlankOption' => true, 'chosen' => true, 'tl_class'=>'w50'], - 'sql' => "varchar(64) NOT NULL default ''" -]; - $GLOBALS['TL_DCA']['tl_module']['fields']['recommendation_externalSize'] = [ 'inputType' => 'text', 'eval' => ['multiple'=>true, 'size'=>2, 'rgxp'=>'natural', 'nospace'=>true, 'tl_class'=>'w50'], diff --git a/contao/languages/de/tl_module.xlf b/contao/languages/de/tl_module.xlf index 796414c..4574389 100644 --- a/contao/languages/de/tl_module.xlf +++ b/contao/languages/de/tl_module.xlf @@ -45,6 +45,14 @@ Here you can select the meta fields. Hier können Sie die Meta-Felder auswählen. + + Use dialog popup + Dialog-Popup nutzen + + + Adds a dialog popup for the recommendation and disables the forwarding page. You don't need a reader module for this feature. + Fügt ein Dialog-Popup für die Bewertung hinzu und deaktiviert die Weiterleitungsseite. Für diese Funktion benötigen Sie kein Lesemodul. + Optional recommendation fields Optionale Bewertungsfelder diff --git a/contao/languages/en/tl_module.xlf b/contao/languages/en/tl_module.xlf index 3232ae6..01f4b16 100644 --- a/contao/languages/en/tl_module.xlf +++ b/contao/languages/en/tl_module.xlf @@ -34,6 +34,12 @@ Here you can select the meta fields. + + Use dialog popup + + + Adds a dialog popup for the recommendation and disables the forwarding page. You don't need a reader module for this feature. + Optional recommendation fields diff --git a/contao/modules/ModuleRecommendation.php b/contao/modules/ModuleRecommendation.php index 2424fab..02a777d 100644 --- a/contao/modules/ModuleRecommendation.php +++ b/contao/modules/ModuleRecommendation.php @@ -30,6 +30,7 @@ * @property string $recommendation_template * @property mixed $recommendation_metaFields * @property mixed $recommendation_externalSize + * @property bool $recommendation_useDialog */ abstract class ModuleRecommendation extends Module { @@ -67,7 +68,7 @@ protected function sortOutProtected(array $arrArchives): array /** * Parse an item and return it as string */ - protected function parseRecommendation(RecommendationModel $objRecommendation, RecommendationArchiveModel $objRecommendationArchive, string $strClass='', int $intCount=0, bool $allowRedirect = false): string + protected function parseRecommendation(RecommendationModel $objRecommendation, RecommendationArchiveModel $objRecommendationArchive, string $strClass='', int $intCount=0): string { $objTemplate = new FrontendTemplate($this->recommendation_template ?: 'recommendation_default'); $objTemplate->setData($objRecommendation->row()); @@ -85,11 +86,18 @@ protected function parseRecommendation(RecommendationModel $objRecommendation, R $objTemplate->class = $strClass; $objTemplate->archiveId = $objRecommendationArchive->id; - if ($allowRedirect) + $moreLabel = $this->customLabel ?: $GLOBALS['TL_LANG']['MSC']['more']; + + if ($this->recommendation_useDialog) + { + $objTemplate->dialog = true; + $objTemplate->more = $moreLabel; + $objRecommendationArchive->jumpTo = null; + } + elseif ($objRecommendationArchive->jumpTo) { $objTemplate->allowRedirect = true; - $moreLabel = $this->customLabel ?: $GLOBALS['TL_LANG']['MSC']['more']; - $objTemplate->more = $this->generateLink($moreLabel, $objRecommendation, $objRecommendation->title ?: $objRecommendation, true); + $objTemplate->more = $this->generateLink($moreLabel, $objRecommendation, $objRecommendation->title ?: $objRecommendation->author, true); } if ($objRecommendation->title) @@ -208,8 +216,7 @@ protected function parseRecommendations(Collection $objRecommendations): array $recommendation, $objRecommendationArchive, ((++$count == 1) ? ' first' : '') . (($count == $limit) ? ' last' : '') . ((($count % 2) == 0) ? ' odd' : ' even'), - $count, - (bool) $objRecommendationArchive->jumpTo + $count ); } diff --git a/src/Model/RecommendationArchiveModel.php b/src/Model/RecommendationArchiveModel.php index d59c494..d88a5fc 100644 --- a/src/Model/RecommendationArchiveModel.php +++ b/src/Model/RecommendationArchiveModel.php @@ -19,6 +19,7 @@ * @property string $title * @property integer $jumpTo * @property boolean $protected + * @property boolean $useDialog * @property boolean $useAutoItem * @property string $groups * @@ -30,12 +31,16 @@ * @method static RecommendationArchiveModel|null findOneByTitle($val, array $opt=array()) * @method static RecommendationArchiveModel|null findOneByJumpTo($val, array $opt=array()) * @method static RecommendationArchiveModel|null findOneByProtected($val, array $opt=array()) + * @method static RecommendationArchiveModel|null findOneByUseDialog($val, array $opt=array()) + * @method static RecommendationArchiveModel|null findOneByUseAutoItem($val, array $opt=array()) * @method static RecommendationArchiveModel|null findOneByGroups($val, array $opt=array()) * * @method static Collection|RecommendationArchiveModel[]|RecommendationArchiveModel|null findByTstamp($val, array $opt=array()) * @method static Collection|RecommendationArchiveModel[]|RecommendationArchiveModel|null findByTitle($val, array $opt=array()) * @method static Collection|RecommendationArchiveModel[]|RecommendationArchiveModel|null findByJumpTo($val, array $opt=array()) * @method static Collection|RecommendationArchiveModel[]|RecommendationArchiveModel|null findByProtected($val, array $opt=array()) + * @method static Collection|RecommendationArchiveModel[]|RecommendationArchiveModel|null findByUseDialog($val, array $opt=array()) + * @method static Collection|RecommendationArchiveModel[]|RecommendationArchiveModel|null findByUseAutoItem($val, array $opt=array()) * @method static Collection|RecommendationArchiveModel[]|RecommendationArchiveModel|null findByGroups($val, array $opt=array()) * @method static Collection|RecommendationArchiveModel[]|RecommendationArchiveModel|null findMultipleByIds($val, array $opt=array()) * @method static Collection|RecommendationArchiveModel[]|RecommendationArchiveModel|null findBy($col, $val, array $opt=array()) @@ -46,6 +51,8 @@ * @method static integer countByTitle($val, array $opt=array()) * @method static integer countByJumpTo($val, array $opt=array()) * @method static integer countByProtected($val, array $opt=array()) + * @method static integer countByUseDialog($val, array $opt=array()) + * @method static integer countByUseAutoItem($val, array $opt=array()) * @method static integer countByGroups($val, array $opt=array()) */ class RecommendationArchiveModel extends Model From 7820cd4fddf7d986efb3151cb12bffd0e8f56bc3 Mon Sep 17 00:00:00 2001 From: Sebastian Zoglowek <55794780+zoglo@users.noreply.github.com> Date: Tue, 16 Apr 2024 15:44:21 +0200 Subject: [PATCH 07/10] Add dialog JS and update templates --- contao/templates/js/js_recommendation.html5 | 14 ++++++++++++++ .../recommendation/recommendation_default.html5 | 16 ++++++++++++++-- .../recommendation/recommendation_latest.html5 | 16 ++++++++++++++-- 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 contao/templates/js/js_recommendation.html5 diff --git a/contao/templates/js/js_recommendation.html5 b/contao/templates/js/js_recommendation.html5 new file mode 100644 index 0000000..f0665e5 --- /dev/null +++ b/contao/templates/js/js_recommendation.html5 @@ -0,0 +1,14 @@ + + window.addEventListener("load", () => { + new MutationObserver((mutations) => { + mutations.forEach((mutation) => { + const elements = mutation.target.matches(".rec_show-modal") ? mutation.target : mutation.target.querySelectorAll(".rec_show-modal"); + elements.forEach(element => { + element.addEventListener("click", (el) => { + document.querySelector(`.rec_dialog_${el.currentTarget.dataset?.id}`)?.showModal(); + }) + }); + }); + }).observe(document, { attributes: false, childList: true, subtree: true }); + }) +'; diff --git a/contao/templates/recommendation/recommendation_default.html5 b/contao/templates/recommendation/recommendation_default.html5 index 6802e5e..163694f 100644 --- a/contao/templates/recommendation/recommendation_default.html5 +++ b/contao/templates/recommendation/recommendation_default.html5 @@ -42,8 +42,8 @@
- teaser && $this->allowRedirect): ?> - teaser ?> + teaser && ($this->allowRedirect || $this->dialog)): ?> + cspInlineStyles($this->teaser) : $this->teaser ?> text ?> @@ -51,6 +51,18 @@ allowRedirect): ?>

more ?>

+ dialog): ?> +

+ more ?> +

+ +
+ text ?> +
+ +
+
+
diff --git a/contao/templates/recommendation/recommendation_latest.html5 b/contao/templates/recommendation/recommendation_latest.html5 index b624c5e..668492f 100644 --- a/contao/templates/recommendation/recommendation_latest.html5 +++ b/contao/templates/recommendation/recommendation_latest.html5 @@ -38,8 +38,8 @@
- teaser && $this->allowRedirect): ?> - teaser ?> + teaser && ($this->allowRedirect || $this->dialog)): ?> + cspInlineStyles($this->teaser) : $this->teaser ?> text ?> @@ -47,6 +47,18 @@ allowRedirect): ?>

more ?>

+ dialog): ?> +

+ more ?> +

+ +
+ text ?> +
+ +
+
+
From cc38f35dd20e422b81284800d1467fcb15809302 Mon Sep 17 00:00:00 2001 From: Sebastian Zoglowek <55794780+zoglo@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:02:32 +0200 Subject: [PATCH 08/10] Add library hint --- contao/dca/tl_module.php | 2 +- contao/languages/de/tl_module.xlf | 4 ++ contao/languages/en/tl_module.xlf | 3 ++ .../DataContainer/ModuleListener.php | 48 +++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 src/EventListener/DataContainer/ModuleListener.php diff --git a/contao/dca/tl_module.php b/contao/dca/tl_module.php index 1aecb9c..b9eef4d 100644 --- a/contao/dca/tl_module.php +++ b/contao/dca/tl_module.php @@ -76,7 +76,7 @@ 'exclude' => true, 'filter' => true, 'inputType' => 'checkbox', - 'eval' => ['tl_class'=>'clr'], + 'eval' => ['submitOnChange'=>true, 'tl_class'=>'clr'], 'sql' => "char(1) NOT NULL default ''" ]; diff --git a/contao/languages/de/tl_module.xlf b/contao/languages/de/tl_module.xlf index 4574389..473de74 100644 --- a/contao/languages/de/tl_module.xlf +++ b/contao/languages/de/tl_module.xlf @@ -157,6 +157,10 @@ Show only recommendations with a minimum rating. Nur Bewertungen mit einem Mindestrating anzeigen.
+ + To use the dialog-popup, the <em>%s</em> template needs to be included in the page layout. + Um das Dialog-Popup zu nutzen muss das <em>%s</em>-Template im Seitenlayout eingebunden sein. + diff --git a/contao/languages/en/tl_module.xlf b/contao/languages/en/tl_module.xlf index 01f4b16..630e74f 100644 --- a/contao/languages/en/tl_module.xlf +++ b/contao/languages/en/tl_module.xlf @@ -118,6 +118,9 @@ Show only recommendations with a minimum rating. + + To use the dialog-popup, the <em>%s</em> template needs to be included in the page layout. + diff --git a/src/EventListener/DataContainer/ModuleListener.php b/src/EventListener/DataContainer/ModuleListener.php new file mode 100644 index 0000000..f6ae080 --- /dev/null +++ b/src/EventListener/DataContainer/ModuleListener.php @@ -0,0 +1,48 @@ +get('security.helper'); + + if ( + !$security->isGranted(ContaoCorePermissions::USER_CAN_ACCESS_MODULE, 'themes') || + !$security->isGranted(ContaoCorePermissions::USER_CAN_ACCESS_LAYOUTS) + ) { + return; + } + + $objModule = ModuleModel::findByPk($dc->id); + + if (null !== $objModule && 'recommendationlist' === $objModule->type) + { + // Get module + $objModule = Database::getInstance()->prepare("SELECT * FROM " . $dc->table . " WHERE id=?") + ->limit(1) + ->execute($dc->id); + + if (null !== $objModule && !!$objModule->recommendation_useDialog) + { + Message::addInfo(sprintf(($GLOBALS['TL_LANG']['tl_module']['includeRecTemplate'] ?? null), 'js_recommendation')); + } + } + } +} From bad5a5136b85f5694494b4b393a2803ef715053b Mon Sep 17 00:00:00 2001 From: Sebastian Zoglowek <55794780+zoglo@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:04:34 +0200 Subject: [PATCH 09/10] Allow symfony 7 --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index f6a8420..e53af48 100644 --- a/composer.json +++ b/composer.json @@ -35,8 +35,8 @@ "contao/manager-plugin": "^2.3.1", "contao/test-case": "^5.1", "phpunit/phpunit": "^9.5", - "symfony/http-client": "^5.4 || ^6.0", - "symfony/phpunit-bridge": "^5.4 || ^6.0" + "symfony/http-client": "^5.4 || ^6.0 || ^7.0", + "symfony/phpunit-bridge": "^5.4 || ^6.0 || ^7.0" }, "conflict": { "contao/core": "*", @@ -61,7 +61,7 @@ }, "extra": { "branch-alias": { - "dev-main": "1.4.x-dev" + "dev-main": "1.5.x-dev" }, "contao-manager-plugin": "Oveleon\\ContaoRecommendationBundle\\ContaoManager\\Plugin" }, From 0377cb45186d8ff4e0681493895432105d97cb8e Mon Sep 17 00:00:00 2001 From: Sebastian Zoglowek <55794780+zoglo@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:19:17 +0200 Subject: [PATCH 10/10] Update documentation --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index e3e46df..aa9e32a 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,10 @@ The recommendation list can display published (and verified) recommendations fro Items per page Number of recommendations per page - Activates pagination + + Custom label + Allows customizing the translation to for the redirect link + Meta fields Here you can select meta fields to display @@ -175,6 +179,10 @@ The recommendation list can display published (and verified) recommendations fro Module template The modules template that is being used + + Use dialog popup + Does not output the redirect link and embeds a dialog box instead. The `js_recommendation` template has to be included in the page layout + Image settings You have the possibility to add pictures to your recommendations. These are the image settings for them @@ -203,6 +211,14 @@ The recommendation list can display published (and verified) recommendations fro Recommendation archives Here you can select one or more archives to read recommendations from + + Overview page + Adds the overview page to the template to not use ``javascript:history.go(-1)`` anymore + + + Custom label + Allows customizing the translation for the overview link + Meta fields Here you can select meta fields to display