From 38a76b26f9868ae98ec5969b9dbd723b5419cdf1 Mon Sep 17 00:00:00 2001 From: Dirk Date: Wed, 13 Nov 2019 10:46:21 +0100 Subject: [PATCH] Add show plugin, prepare consider date --- Classes/Controller/DateController.php | 5 ++ Classes/Domain/Model/Dto/DateDemand.php | 21 +++++++ Classes/Domain/Repository/DateRepository.php | 2 +- .../FlexForms/{Search.xml => DateSearch.xml} | 0 Configuration/FlexForms/DateShow.xml | 57 +++++++++++++++++++ Configuration/TCA/Overrides/tt_content.php | 22 ++++++- Resources/Private/Templates/Date/Search.html | 10 ++++ ext_localconf.php | 11 ++++ 8 files changed, 124 insertions(+), 4 deletions(-) rename Configuration/FlexForms/{Search.xml => DateSearch.xml} (100%) create mode 100644 Configuration/FlexForms/DateShow.xml diff --git a/Classes/Controller/DateController.php b/Classes/Controller/DateController.php index 90e8444..ea5446e 100644 --- a/Classes/Controller/DateController.php +++ b/Classes/Controller/DateController.php @@ -88,6 +88,7 @@ class DateController extends ActionController $selRegion = $arguments['region']; $start = $arguments['start']; $end = $arguments['end']; + $considerDate = $arguments['considerDate']; $regions = $this->regionRepository->findAll(); $this->view->assign('regions', $regions); @@ -96,6 +97,7 @@ class DateController extends ActionController $this->view->assign('selRegion', $selRegion); $this->view->assign('start', $start); $this->view->assign('end', $end); + $this->view->assign('considerDate', $considerDate); } /** @@ -165,6 +167,9 @@ class DateController extends ActionController if ($this->request->hasArgument('end') && $this->request->getArgument('end') != '') $demand->setEnd(strtotime($this->request->getArgument('end'))); + if ($this->request->hasArgument('considerDate') && $this->request->getArgument('considerDate') != '') + $demand->setConsiderDate(strtotime($this->request->getArgument('considerDate'))); + $demand->setSortBy((string)$this->settings['sortByDate']); $demand->setSortOrder((string)$this->settings['sortOrder']); diff --git a/Classes/Domain/Model/Dto/DateDemand.php b/Classes/Domain/Model/Dto/DateDemand.php index 0f0a538..a1c3087 100644 --- a/Classes/Domain/Model/Dto/DateDemand.php +++ b/Classes/Domain/Model/Dto/DateDemand.php @@ -59,6 +59,11 @@ class DateDemand { */ protected $searchword = ''; + /** + * @var bool + */ + protected $considerDate = 0; + /** * @return string */ @@ -235,4 +240,20 @@ class DateDemand { $this->end = $end; } + /** + * @return bool + */ + public function getConsiderDate(): bool + { + return $this->considerDate; + } + + /** + * @param bool $considerDate + */ + public function setConsiderDate(string $considerDate): void + { + $this->considerDate = $considerDate; + } + } \ No newline at end of file diff --git a/Classes/Domain/Repository/DateRepository.php b/Classes/Domain/Repository/DateRepository.php index 0061396..86ac8e3 100644 --- a/Classes/Domain/Repository/DateRepository.php +++ b/Classes/Domain/Repository/DateRepository.php @@ -82,7 +82,7 @@ class DateRepository extends \TYPO3\CMS\Extbase\Persistence\Repository $constraints['daterange'] = $query->logicalAnd( [ $query->greaterThanOrEqual('start', $demand->getStart()), - $query->lessThanOrEqual('start', $demand->getEnd()) + $query->lessThanOrEqual('end', $demand->getEnd()) ] ); } else { diff --git a/Configuration/FlexForms/Search.xml b/Configuration/FlexForms/DateSearch.xml similarity index 100% rename from Configuration/FlexForms/Search.xml rename to Configuration/FlexForms/DateSearch.xml diff --git a/Configuration/FlexForms/DateShow.xml b/Configuration/FlexForms/DateShow.xml new file mode 100644 index 0000000..b3eea3d --- /dev/null +++ b/Configuration/FlexForms/DateShow.xml @@ -0,0 +1,57 @@ + + + + + + Options + + array + + + + 1 + + + group + db + pages + 1 + 1 + 0 + 1 + + + + + + + + + + Template + + array + + + 1 + + + select + + + Default + default + + + Costum + costum + + + default + + + + + + + \ No newline at end of file diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index d6ae958..ab4974d 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -25,7 +25,7 @@ call_user_func(function () { \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( 'Wrm.Events', 'DateSearch', - 'Events Date Search', + 'Events: Date Search', 'EXT:events/Resources/Public/Icons/user_plugin_events.svg' ); @@ -33,7 +33,7 @@ call_user_func(function () { \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue( 'events_datesearch', - 'FILE:EXT:events/Configuration/FlexForms/Search.xml' + 'FILE:EXT:events/Configuration/FlexForms/DateSearch.xml' ); /* Date List Plugin */ @@ -41,7 +41,7 @@ call_user_func(function () { \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( 'Wrm.Events', 'DateList', - 'Events Date List', + 'Events: Date List', 'EXT:events/Resources/Public/Icons/user_plugin_events.svg' ); @@ -52,5 +52,21 @@ call_user_func(function () { 'FILE:EXT:events/Configuration/FlexForms/DateList.xml' ); + /* Date Show Plugin */ + + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( + 'Wrm.Events', + 'DateShow', + 'Events: Date Show', + 'EXT:events/Resources/Public/Icons/user_plugin_events.svg' + ); + + $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['events_dateshow'] = 'pi_flexform'; + + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue( + 'events_dateshow', + 'FILE:EXT:events/Configuration/FlexForms/DateShow.xml' + ); + }); diff --git a/Resources/Private/Templates/Date/Search.html b/Resources/Private/Templates/Date/Search.html index 633f815..e26d859 100644 --- a/Resources/Private/Templates/Date/Search.html +++ b/Resources/Private/Templates/Date/Search.html @@ -12,6 +12,16 @@ +
diff --git a/ext_localconf.php b/ext_localconf.php index 42eeecf..fee4d97 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -40,6 +40,17 @@ call_user_func( ] ); + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'Wrm.Events', + 'DateShow', + [ + 'Date' => 'show' + ], + [ + 'Date' => 'show' + ] + ); + /* $iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);