From fc0fea409bdcfcbff20cb8062c8ade566899e3c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helmut=20Schottm=C3=BCller?= Date: Mon, 7 Mar 2016 17:00:39 +0100 Subject: [PATCH] Added support for tags in Calendar modules --- config/autoload.php | 3 ++- config/config.php | 1 + modules/ModuleCalendarTags.php | 46 ++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 modules/ModuleCalendarTags.php diff --git a/config/autoload.php b/config/autoload.php index 97ce0aa..ed7e494 100644 --- a/config/autoload.php +++ b/config/autoload.php @@ -3,7 +3,7 @@ /** * Contao Open Source CMS * - * Copyright (c) 2005-2015 Leo Feyer + * Copyright (c) 2005-2016 Leo Feyer * * @license LGPL-3.0+ */ @@ -41,6 +41,7 @@ // Modules 'Aurealis\ModuleArticle' => 'system/modules/tags/modules/ModuleArticle.php', + 'Contao\ModuleCalendarTags' => 'system/modules/tags/modules/ModuleCalendarTags.php', 'Contao\ModuleEventlistTags' => 'system/modules/tags/modules/ModuleEventlistTags.php', 'Contao\ModuleEventReaderTags' => 'system/modules/tags/modules/ModuleEventReaderTags.php', 'Contao\ModuleFaqListTags' => 'system/modules/tags/modules/ModuleFaqListTags.php', diff --git a/config/config.php b/config/config.php index 84489a5..e047961 100644 --- a/config/config.php +++ b/config/config.php @@ -59,6 +59,7 @@ $GLOBALS['FE_MOD']['news']['newslist'] = 'ModuleNewsListTags'; $GLOBALS['FE_MOD']['news']['newsarchive'] = 'ModuleNewsArchiveTags'; $GLOBALS['FE_MOD']['news']['newsreader'] = 'ModuleNewsReaderTags'; +$GLOBALS['FE_MOD']['events']['calendar'] = 'ModuleCalendarTags'; $GLOBALS['FE_MOD']['events']['eventlist'] = 'ModuleEventlistTags'; $GLOBALS['FE_MOD']['events']['eventreader'] = 'ModuleEventReaderTags'; $GLOBALS['FE_MOD']['faq']['faqlist'] = 'ModuleFaqListTags'; diff --git a/modules/ModuleCalendarTags.php b/modules/ModuleCalendarTags.php new file mode 100644 index 0000000..b4428a4 --- /dev/null +++ b/modules/ModuleCalendarTags.php @@ -0,0 +1,46 @@ + + */ +class ModuleCalendarTags extends \ModuleCalendar +{ + + /** + * Return all weeks of the current month as array + * + * @return array + */ + protected function compileWeeks() + { + $arrDays = parent::compileWeeks(); + $helper = new \TagHelper(); + foreach ($arrDays as $strWeekClass => $week) + { + foreach ($week as $i => $event) + { + foreach ($event['events'] as $eventindex => $vv) + { + $tagsandlist = $helper->getTagsAndTaglistForIdAndTable($vv['id'], 'tl_calendar_events', $this->jumpTo); + $vv['tags'] = $tagsandlist['tags']; + $vv['taglist'] = $tagsandlist['taglist']; + $arrDays[$strWeekClass][$i]['events'][$eventindex] = $vv; + } + } + } + return $arrDays; + } +} \ No newline at end of file