From 2f341867d4670b96cf8be1f4b77e9783e6655e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helmut=20Schottm=C3=BCller?= Date: Wed, 1 Jun 2022 16:09:28 +0200 Subject: [PATCH 1/3] Updated to Contao 4.13 FAQ list --- modules/ModuleFaqListTags.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/ModuleFaqListTags.php b/modules/ModuleFaqListTags.php index a9ca859..e660230 100644 --- a/modules/ModuleFaqListTags.php +++ b/modules/ModuleFaqListTags.php @@ -59,33 +59,43 @@ protected function compile() return; } + $tags = array(); $arrFaq = array_fill_keys($this->faq_categories, array()); // Add FAQs while ($objFaq->next()) { $arrTemp = $objFaq->row(); - $arrTemp['title'] = specialchars($objFaq->question, true); + $arrTemp['title'] = StringUtil::specialchars($objFaq->question, true); $arrTemp['href'] = $this->generateFaqLink($objFaq); - /** @var \FaqCategoryModel $objPid */ + /** @var FaqCategoryModel $objPid */ $objPid = $objFaq->getRelated('pid'); $arrFaq[$objFaq->pid]['items'][] = $arrTemp; $arrFaq[$objFaq->pid]['headline'] = $objPid->headline; $arrFaq[$objFaq->pid]['title'] = $objPid->title; + + $tags[] = 'contao.db.tl_faq.' . $objFaq->id; + } + + // Tag the FAQs (see #2137) + if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger')) + { + $responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger'); + $responseTagger->addTags($tags); } $arrFaq = array_values(array_filter($arrFaq)); $cat_count = 0; - $cat_limit = count($arrFaq); + $cat_limit = \count($arrFaq); // Add classes foreach ($arrFaq as $k=>$v) { $count = 0; - $limit = count($v['items']); + $limit = \count($v['items']); for ($i=0; $i<$limit; $i++) { From 100a40177b9813c4c564c743bd02705724b149a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helmut=20Schottm=C3=BCller?= Date: Mon, 13 Jun 2022 15:28:54 +0200 Subject: [PATCH 2/3] Fixed an error that can occur in PHP 8 when a value is too short --- dca/tl_content.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/dca/tl_content.php b/dca/tl_content.php index bf658b7..7adc525 100644 --- a/dca/tl_content.php +++ b/dca/tl_content.php @@ -13,16 +13,20 @@ } else { $disabledObjects = array(); } + if (!in_array('tl_content', $disabledObjects)) { foreach ($GLOBALS['TL_DCA']['tl_content']['palettes'] as $key => $palette) { if (strcmp($key, '__selector__') != 0) { - $pos = strpos($GLOBALS['TL_DCA']['tl_content']['palettes'][$key], '{', 2); - if ($pos !== FALSE) - { - $GLOBALS['TL_DCA']['tl_content']['palettes'][$key] = substr($GLOBALS['TL_DCA']['tl_content']['palettes'][$key],0,$pos) . "{tags_legend:hide},tags;" . substr($GLOBALS['TL_DCA']['tl_content']['palettes'][$key],$pos); + $value = $GLOBALS['TL_DCA']['tl_content']['palettes'][$key]; + if (strlen($value) >= 2) { + $pos = strpos($value, '{', 2); + if ($pos !== FALSE) + { + $GLOBALS['TL_DCA']['tl_content']['palettes'][$key] = substr($GLOBALS['TL_DCA']['tl_content']['palettes'][$key],0,$pos) . "{tags_legend:hide},tags;" . substr($GLOBALS['TL_DCA']['tl_content']['palettes'][$key],$pos); + } } } } From 35817cdf44c6807154ee1ed91385bd54ee0a5c5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helmut=20Schottm=C3=BCller?= Date: Mon, 18 Jul 2022 11:46:04 +0200 Subject: [PATCH 3/3] Added missing tables tl_faq and tl_files to global tags settings Fixed the injection for tl_content which caused a strange side effect for the "Module" content element --- config/config.php | 2 ++ dca/tl_calendar.php | 2 ++ dca/tl_calendar_events.php | 2 ++ dca/tl_content.php | 10 +++++----- dca/tl_news.php | 5 +++-- dca/tl_news_archive.php | 2 ++ 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/config/config.php b/config/config.php index 8990e05..c49dc14 100644 --- a/config/config.php +++ b/config/config.php @@ -100,6 +100,8 @@ $GLOBALS['tags_extension']['sourcetable'][] = 'tl_content'; $GLOBALS['tags_extension']['sourcetable'][] = 'tl_news'; $GLOBALS['tags_extension']['sourcetable'][] = 'tl_member'; +$GLOBALS['tags_extension']['sourcetable'][] = 'tl_faq'; +$GLOBALS['tags_extension']['sourcetable'][] = 'fl_files'; /** * Add 'tag' to the URL keywords to prevent problems with URL manipulating modules like folderurl diff --git a/dca/tl_calendar.php b/dca/tl_calendar.php index 78d6029..56fb8f1 100644 --- a/dca/tl_calendar.php +++ b/dca/tl_calendar.php @@ -11,6 +11,7 @@ if (@class_exists("tl_calendar")) { + /* if (is_array($GLOBALS['TL_DCA']['tl_calendar']['config']['onload_callback'])) { foreach ($GLOBALS['TL_DCA']['tl_calendar']['config']['onload_callback'] as $key => $arr) @@ -21,6 +22,7 @@ } } } +*/ } diff --git a/dca/tl_calendar_events.php b/dca/tl_calendar_events.php index a57ad5d..a93137e 100644 --- a/dca/tl_calendar_events.php +++ b/dca/tl_calendar_events.php @@ -11,6 +11,7 @@ if (@class_exists("tl_calendar_events")) { + /* if (is_array($GLOBALS['TL_DCA']['tl_calendar_events']['config']['onload_callback'])) { foreach ($GLOBALS['TL_DCA']['tl_calendar_events']['config']['onload_callback'] as $key => $arr) @@ -21,6 +22,7 @@ } } } +*/ class tl_calendar_events_tags extends \Backend { diff --git a/dca/tl_content.php b/dca/tl_content.php index 7adc525..4766cf3 100644 --- a/dca/tl_content.php +++ b/dca/tl_content.php @@ -16,20 +16,20 @@ if (!in_array('tl_content', $disabledObjects)) { - foreach ($GLOBALS['TL_DCA']['tl_content']['palettes'] as $key => $palette) + foreach ($GLOBALS['TL_DCA']['tl_content']['palettes'] as $key => &$palette) { if (strcmp($key, '__selector__') != 0) { - $value = $GLOBALS['TL_DCA']['tl_content']['palettes'][$key]; - if (strlen($value) >= 2) { - $pos = strpos($value, '{', 2); + if (strlen($palette) >= 2) { + $pos = strpos($palette, '{', 2); if ($pos !== FALSE) { - $GLOBALS['TL_DCA']['tl_content']['palettes'][$key] = substr($GLOBALS['TL_DCA']['tl_content']['palettes'][$key],0,$pos) . "{tags_legend:hide},tags;" . substr($GLOBALS['TL_DCA']['tl_content']['palettes'][$key],$pos); + $palette = substr($palette,0,$pos) . "{tags_legend:hide},tags;" . substr($palette,$pos); } } } } + unset($palette); $GLOBALS['TL_DCA']['tl_content']['palettes']['headline'] = str_replace('guests','guests,tagsonly', $GLOBALS['TL_DCA']['tl_content']['palettes']['headline']); $GLOBALS['TL_DCA']['tl_content']['config']['ondelete_callback'][] = array('tl_content_tags', 'removeContentElement'); diff --git a/dca/tl_news.php b/dca/tl_news.php index 2681eeb..08e3914 100644 --- a/dca/tl_news.php +++ b/dca/tl_news.php @@ -13,13 +13,14 @@ if (is_array($GLOBALS['TL_DCA']['tl_news']['config']['onload_callback'])) { - foreach ($GLOBALS['TL_DCA']['tl_news']['config']['onload_callback'] as $key => $arr) + foreach ($GLOBALS['TL_DCA']['tl_news']['config']['onload_callback'] as $key => &$arr) { if (is_array($arr) && strcmp($arr[0], 'tl_news') == 0 && strcmp($arr[1], 'generateFeed') == 0) { - $GLOBALS['TL_DCA']['tl_news']['config']['onload_callback'][$key] = array('TagHelper', 'generateNewsFeed'); + $arr = array('TagHelper', 'generateNewsFeed'); } } + unset($arr); } diff --git a/dca/tl_news_archive.php b/dca/tl_news_archive.php index ade4ca4..e1bb7dc 100644 --- a/dca/tl_news_archive.php +++ b/dca/tl_news_archive.php @@ -10,6 +10,7 @@ if (@class_exists("tl_news_archive")) { + /* if (is_array($GLOBALS['TL_DCA']['tl_news_archive']['config']['onload_callback'])) { foreach ($GLOBALS['TL_DCA']['tl_news_archive']['config']['onload_callback'] as $key => $arr) @@ -20,6 +21,7 @@ } } } + */ }