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 @@
Zurzeit sind keine Bewertungen vorhanden.
+
+
+ Die Bewertung lesen: %s
+