diff --git a/contao/modules/ModuleRecommendation.php b/contao/modules/ModuleRecommendation.php index c58ad0f..dcae232 100644 --- a/contao/modules/ModuleRecommendation.php +++ b/contao/modules/ModuleRecommendation.php @@ -9,6 +9,7 @@ namespace Oveleon\ContaoRecommendationBundle; use Contao\Config; +use Contao\CoreBundle\ContaoCoreBundle; use Contao\CoreBundle\Security\ContaoCorePermissions; use Contao\Date; use Contao\FilesModel; @@ -252,7 +253,7 @@ protected function generateRecommendationUrl(RecommendationModel $objRecommendat { $objPage = PageModel::findByPk($objRecommendation->getRelated('pid')->jumpTo); - return StringUtil::ampersand($objPage->getFrontendUrl((Config::get('useAutoItem') ? '/' : '/items/') . ($objRecommendation->alias ?: $objRecommendation->id))); + return StringUtil::ampersand($objPage->getFrontendUrl(($this->useAutoItem() ? '/' : '/items/') . ($objRecommendation->alias ?: $objRecommendation->id))); } /** @@ -343,4 +344,15 @@ protected function translateElapsedTime(int $value, string $strUnit = 'justNow') { return sprintf($GLOBALS['TL_LANG']['tl_recommendation'][$strUnit][!($value>1)], $value); } + + /** + * Checks weather auto_item should be used to provide BC + * + * @deprecated - To be removed when contao 4.13 support ends + * @internal + */ + protected function useAutoItem(): bool + { + return version_compare(ContaoCoreBundle::getVersion(), '5', '<') ? Config::get('useAutoItem') : true; + } } diff --git a/contao/modules/ModuleRecommendationList.php b/contao/modules/ModuleRecommendationList.php index 5ae38ac..80a6cad 100644 --- a/contao/modules/ModuleRecommendationList.php +++ b/contao/modules/ModuleRecommendationList.php @@ -66,7 +66,7 @@ public function generate(): string } // Show the recommendation reader if an item has been selected - if ($this->recommendation_readerModule > 0 && (isset($_GET['items']) || (Config::get('useAutoItem') && isset($_GET['auto_item'])))) + if ($this->recommendation_readerModule > 0 && (isset($_GET['items']) || ($this->useAutoItem() && isset($_GET['auto_item'])))) { return $this->getFrontendModule($this->recommendation_readerModule, $this->strColumn); } diff --git a/contao/modules/ModuleRecommendationReader.php b/contao/modules/ModuleRecommendationReader.php index afe756f..f684ed7 100644 --- a/contao/modules/ModuleRecommendationReader.php +++ b/contao/modules/ModuleRecommendationReader.php @@ -10,6 +10,7 @@ use Contao\BackendTemplate; use Contao\Config; +use Contao\CoreBundle\ContaoCoreBundle; use Contao\CoreBundle\Exception\InternalServerErrorException; use Contao\CoreBundle\Exception\PageNotFoundException; use Contao\Environment; @@ -18,6 +19,7 @@ use Contao\System; use Oveleon\ContaoRecommendationBundle\Model\RecommendationArchiveModel; use Oveleon\ContaoRecommendationBundle\Model\RecommendationModel; +use Symfony\Component\HttpFoundation\Response; /** * Front end module "recommendation reader". @@ -54,14 +56,21 @@ public function generate() return $objTemplate->parse(); } - // Set the item from the auto_item parameter - if (!isset($_GET['items']) && isset($_GET['auto_item']) && Config::get('useAutoItem')) - { + $auto_item = Input::get('auto_item'); + + if ( + version_compare(ContaoCoreBundle::getVersion(), '5', '<') && + !isset($_GET['items']) && + isset($_GET['auto_item']) && + $this->useAutoItem() + ) { + // Set the item from the auto_item parameter - Contao 4.13 BC Input::setGet('items', Input::get('auto_item')); + $auto_item = Input::get('items'); } // Return an empty string if "items" is not set (to combine list and reader on same page) - if (!Input::get('items')) + if (null === $auto_item) { return ''; }