From 9fde5ad783f40ecf59c7251d6db9ca577e2a430b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helmut=20Schottm=C3=BCller?= Date: Thu, 13 Apr 2023 11:00:07 +0200 Subject: [PATCH] Added array key checks to prevent PHP warnings --- dca/tl_calendar_events.php | 4 +++- dca/tl_faq.php | 4 +++- dca/tl_member.php | 4 +++- dca/tl_module.php | 24 ++++++++++++++++++------ 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/dca/tl_calendar_events.php b/dca/tl_calendar_events.php index a93137e..108735d 100644 --- a/dca/tl_calendar_events.php +++ b/dca/tl_calendar_events.php @@ -57,7 +57,9 @@ public function onCopy($insertID, \DataContainer $dc) { $GLOBALS['TL_DCA']['tl_calendar_events']['config']['ondelete_callback'][] = array('tl_calendar_events_tags', 'deleteEvents'); $GLOBALS['TL_DCA']['tl_calendar_events']['config']['oncopy_callback'][] = array('tl_calendar_events_tags', 'onCopy'); - $GLOBALS['TL_DCA']['tl_calendar_events']['palettes']['default'] = str_replace("author", "author,tags", $GLOBALS['TL_DCA']['tl_calendar_events']['palettes']['default']); + if (array_key_exists('tl_calendar_events', $GLOBALS['TL_DCA'])) { + $GLOBALS['TL_DCA']['tl_calendar_events']['palettes']['default'] = str_replace("author", "author,tags", $GLOBALS['TL_DCA']['tl_calendar_events']['palettes']['default']); + } } $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['tags'] = array ( diff --git a/dca/tl_faq.php b/dca/tl_faq.php index 1eea773..efc4139 100644 --- a/dca/tl_faq.php +++ b/dca/tl_faq.php @@ -21,7 +21,9 @@ } if (!in_array('tl_article', $disabledObjects)) { - $GLOBALS['TL_DCA']['tl_faq']['palettes']['default'] = str_replace("author", "author,tags", $GLOBALS['TL_DCA']['tl_faq']['palettes']['default']); + if (array_key_exists('tl_faq', $GLOBALS['TL_DCA'])) { + $GLOBALS['TL_DCA']['tl_faq']['palettes']['default'] = str_replace("author", "author,tags", $GLOBALS['TL_DCA']['tl_faq']['palettes']['default']); + } $GLOBALS['TL_DCA']['tl_faq']['config']['ondelete_callback'][] = array('tl_faq_tags', 'removeFAQ'); $GLOBALS['TL_DCA']['tl_faq']['config']['oncopy_callback'][] = array('tl_faq_tags', 'onCopy'); } diff --git a/dca/tl_member.php b/dca/tl_member.php index 4ebbc95..a217077 100644 --- a/dca/tl_member.php +++ b/dca/tl_member.php @@ -41,7 +41,9 @@ public function onCopy($insertID, \DataContainer $dc) { $GLOBALS['TL_DCA']['tl_member']['config']['ondelete_callback'][] = array('tl_member_tags', 'deleteMember'); $GLOBALS['TL_DCA']['tl_member']['config']['oncopy_callback'][] = array('tl_member_tags', 'onCopy'); - $GLOBALS['TL_DCA']['tl_member']['palettes']['default'] = str_replace("{address_legend", "{categories_legend},tags;{address_legend", $GLOBALS['TL_DCA']['tl_member']['palettes']['default']); + if (array_key_exists('tl_member', $GLOBALS['TL_DCA'])) { + $GLOBALS['TL_DCA']['tl_member']['palettes']['default'] = str_replace("{address_legend", "{categories_legend},tags;{address_legend", $GLOBALS['TL_DCA']['tl_member']['palettes']['default']); + } } $GLOBALS['TL_DCA']['tl_member']['fields']['tags'] = array diff --git a/dca/tl_module.php b/dca/tl_module.php index 348983d..3751f83 100644 --- a/dca/tl_module.php +++ b/dca/tl_module.php @@ -173,12 +173,24 @@ public function getNewsArchives() $GLOBALS['TL_DCA']['tl_module']['palettes']['globalArticleList'] = '{title_legend},name,headline,type;{template_legend:hide},articlelist_template;{showtags_legend},hide_on_empty;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space'; $GLOBALS['TL_DCA']['tl_module']['palettes']['tagcontentlist'] = '{title_legend},name,headline,type;{object_selection_legend},objecttype,tagsource,pagesource;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space'; $GLOBALS['TL_DCA']['tl_module']['palettes']['taglistbycategory'] = '{title_legend},name,headline,type;{datasource_legend},tag_sourcetables,pagesource;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space'; -$GLOBALS['TL_DCA']['tl_module']['palettes']['newsreader'] = str_replace('{template_legend', '{showtags_legend},tag_filter,tag_ignore,news_showtags;{template_legend', $GLOBALS['TL_DCA']['tl_module']['palettes']['newsreader']); -$GLOBALS['TL_DCA']['tl_module']['palettes']['newsarchive'] = str_replace('{template_legend', '{showtags_legend},tag_filter,tag_ignore,news_showtags;{template_legend', $GLOBALS['TL_DCA']['tl_module']['palettes']['newsarchive']); -$GLOBALS['TL_DCA']['tl_module']['palettes']['newslist'] = str_replace('{template_legend', '{showtags_legend},tag_filter,tag_ignore,news_showtags;{template_legend', $GLOBALS['TL_DCA']['tl_module']['palettes']['newslist']); -$GLOBALS['TL_DCA']['tl_module']['palettes']['eventlist'] = str_replace('{template_legend', '{showtags_legend},tag_filter,tag_ignore,event_showtags;{template_legend', $GLOBALS['TL_DCA']['tl_module']['palettes']['eventlist']); -$GLOBALS['TL_DCA']['tl_module']['palettes']['calendar'] = str_replace('{template_legend', '{showtags_legend},tag_filter,tag_ignore;{template_legend', $GLOBALS['TL_DCA']['tl_module']['palettes']['calendar']); -$GLOBALS['TL_DCA']['tl_module']['palettes']['eventreader'] = str_replace('{template_legend', '{showtags_legend},event_showtags;{template_legend', $GLOBALS['TL_DCA']['tl_module']['palettes']['eventreader']); +if (array_key_exists('newsreader', $GLOBALS['TL_DCA']['tl_module']['palettes'])) { + $GLOBALS['TL_DCA']['tl_module']['palettes']['newsreader'] = str_replace('{template_legend', '{showtags_legend},tag_filter,tag_ignore,news_showtags;{template_legend', $GLOBALS['TL_DCA']['tl_module']['palettes']['newsreader']); +} +if (array_key_exists('newsarchive', $GLOBALS['TL_DCA']['tl_module']['palettes'])) { + $GLOBALS['TL_DCA']['tl_module']['palettes']['newsarchive'] = str_replace('{template_legend', '{showtags_legend},tag_filter,tag_ignore,news_showtags;{template_legend', $GLOBALS['TL_DCA']['tl_module']['palettes']['newsarchive']); +} +if (array_key_exists('newslist', $GLOBALS['TL_DCA']['tl_module']['palettes'])) { + $GLOBALS['TL_DCA']['tl_module']['palettes']['newslist'] = str_replace('{template_legend', '{showtags_legend},tag_filter,tag_ignore,news_showtags;{template_legend', $GLOBALS['TL_DCA']['tl_module']['palettes']['newslist']); +} +if (array_key_exists('eventlist', $GLOBALS['TL_DCA']['tl_module']['palettes'])) { + $GLOBALS['TL_DCA']['tl_module']['palettes']['eventlist'] = str_replace('{template_legend', '{showtags_legend},tag_filter,tag_ignore,event_showtags;{template_legend', $GLOBALS['TL_DCA']['tl_module']['palettes']['eventlist']); +} +if (array_key_exists('calendar', $GLOBALS['TL_DCA']['tl_module']['palettes'])) { + $GLOBALS['TL_DCA']['tl_module']['palettes']['calendar'] = str_replace('{template_legend', '{showtags_legend},tag_filter,tag_ignore;{template_legend', $GLOBALS['TL_DCA']['tl_module']['palettes']['calendar']); +} +if (array_key_exists('eventreader', $GLOBALS['TL_DCA']['tl_module']['palettes'])) { + $GLOBALS['TL_DCA']['tl_module']['palettes']['eventreader'] = str_replace('{template_legend', '{showtags_legend},event_showtags;{template_legend', $GLOBALS['TL_DCA']['tl_module']['palettes']['eventreader']); +} $GLOBALS['TL_DCA']['tl_module']['palettes']['__selector__'][] = 'tag_topten'; $GLOBALS['TL_DCA']['tl_module']['palettes']['__selector__'][] = 'news_showtags'; $GLOBALS['TL_DCA']['tl_module']['palettes']['__selector__'][] = 'event_showtags';