From 24262675676092511eb3abcd7f8c16863d6197b0 Mon Sep 17 00:00:00 2001 From: Dirk Date: Mon, 11 Nov 2019 12:43:50 +0100 Subject: [PATCH] Refactoring --- Classes/Controller/DateController.php | 59 ++--- Configuration/FlexForms/DateList.xml | 236 ++++++++++++++++++ Configuration/FlexForms/Search.xml | 29 +++ Configuration/TCA/Overrides/tt_content.php | 32 +++ .../Private/Partials/Date/ListDefault.html | 12 +- .../Private/Partials/Date/ListTable.html | 33 ++- ...rchForm.html => ~OBSOLETE-SearchForm.html} | 6 +- Resources/Private/Templates/Date/Search.html | 114 +++++---- .../Private/Templates/Date/SearchHtml.html | 68 +++++ .../ViewHelpers/Widget/Paginate/Index.html | 162 ++++++------ ext_localconf.php | 35 ++- 11 files changed, 589 insertions(+), 197 deletions(-) create mode 100644 Configuration/FlexForms/DateList.xml create mode 100644 Configuration/FlexForms/Search.xml rename Resources/Private/Partials/Date/{SearchForm.html => ~OBSOLETE-SearchForm.html} (94%) create mode 100644 Resources/Private/Templates/Date/SearchHtml.html diff --git a/Classes/Controller/DateController.php b/Classes/Controller/DateController.php index 601bb9c..90e8444 100644 --- a/Classes/Controller/DateController.php +++ b/Classes/Controller/DateController.php @@ -1,6 +1,7 @@ createDemandFromSettings(); - $dates = $this->dateRepository->findByDemand($demand); + if (($this->request->hasArgument('searchword') && $this->request->getArgument('searchword') != '') || + ($this->request->hasArgument('region') && $this->request->getArgument('region') != '') || + ($this->request->hasArgument('start') && $this->request->getArgument('start') != '') || + ($this->request->hasArgument('end') && $this->request->getArgument('end') != '')) + { + $demand = $this->createDemandFromSearch(); + $dates = $this->dateRepository->findByDemand($demand); + } else { + $demand = $this->createDemandFromSettings(); + $dates = $this->dateRepository->findByDemand($demand); + } $this->view->assign('dates', $dates); } @@ -73,42 +83,19 @@ class DateController extends ActionController */ public function searchAction() { - - $searchword = null; - $regions = null; - $selRegion = null; - $dates = null; - $start = null; - $end = null; - - if ($this->request->hasArgument('searchword') && $this->request->getArgument('searchword') != '') { - $searchword = $this->request->getArgument('searchword'); - } - - if ($this->request->hasArgument('region') && $this->request->getArgument('region') != '') { - $selRegion = $this->request->getArgument('region'); - } - - if ($this->request->hasArgument('start') && $this->request->getArgument('start') != '') { - $start = date( "d.m.y", strtotime( $this->request->getArgument('start'))); - } - - if ($this->request->hasArgument('end') && $this->request->getArgument('end') != '') { - $end = date( "d.m.y", strtotime( $this->request->getArgument('end'))); - } - - $demand = $this->createDemandFromSearch(); - $dates = $this->dateRepository->findByDemand($demand); + $arguments = GeneralUtility::_GET('tx_events_datelist'); + $searchword = $arguments['searchword']; + $selRegion = $arguments['region']; + $start = $arguments['start']; + $end = $arguments['end']; $regions = $this->regionRepository->findAll(); + $this->view->assign('regions', $regions); $this->view->assign('searchword', $searchword); - $this->view->assign('regions', $regions); $this->view->assign('selRegion', $selRegion); - $this->view->assign('dates', $dates); $this->view->assign('start', $start); $this->view->assign('end', $end); - } /** @@ -172,13 +159,11 @@ class DateController extends ActionController if ($this->request->hasArgument('searchword') && $this->request->getArgument('searchword') != '') $demand->setSearchword((string)$this->request->getArgument('searchword')); - if ($this->request->hasArgument('start') && $this->request->getArgument('start') != '') { - $demand->setStart(date( "Y-m-d", strtotime( $this->request->getArgument('start')))); - } + if ($this->request->hasArgument('start') && $this->request->getArgument('start') != '') + $demand->setStart(strtotime($this->request->getArgument('start'))); - if ($this->request->hasArgument('end') && $this->request->getArgument('end') != '') { - $demand->setEnd(date( "Y-m-d", strtotime( $this->request->getArgument('end')))); - } + if ($this->request->hasArgument('end') && $this->request->getArgument('end') != '') + $demand->setEnd(strtotime($this->request->getArgument('end'))); $demand->setSortBy((string)$this->settings['sortByDate']); $demand->setSortOrder((string)$this->settings['sortOrder']); diff --git a/Configuration/FlexForms/DateList.xml b/Configuration/FlexForms/DateList.xml new file mode 100644 index 0000000..e971c51 --- /dev/null +++ b/Configuration/FlexForms/DateList.xml @@ -0,0 +1,236 @@ + + + + + + Options + + array + + + + 1 + + + select + + + Start + start + + + End + end + + + + + + + + + 1 + + + select + + + + Ascending + + ASC + + + + Descending + + DESC + + + ASC + + + + + + + 1 + + + input + 10 + 30 + trim + + + + + + + 1 + + + check + 0 + + + + + + + 1 + + + check + 0 + + + + + + + 1 + + + check + 0 + + + + + + + 1 + + + group + db + pages + 1 + 1 + 0 + 1 + + + + + + + + + + Template + + array + + + 1 + + + select + + + Default + default + + + Costum + costum + + + Table + table + + + Grid + grid + + + default + + + + + + + + + Regions & Categories + + array + + + + + + select + tx_events_domain_model_region + AND tx_events_domain_model_region.deleted = 0 AND tx_events_domain_model_region.hidden = 0 + 3 + 0 + 2 + + + + + + + 1 + + + select + + + And + 0 + + + Or + 1 + + + 0 + + + + + + + 1 + + + select + 20 + sys_category + AND sys_category.sys_language_uid IN (-1, 0) ORDER BY sys_category.title ASC + 1 + tree + 8 + + + 1 + 1 + + parent + + + + + + + + 1 + + + check + 0 + + + + + + + + \ No newline at end of file diff --git a/Configuration/FlexForms/Search.xml b/Configuration/FlexForms/Search.xml new file mode 100644 index 0000000..dfaf631 --- /dev/null +++ b/Configuration/FlexForms/Search.xml @@ -0,0 +1,29 @@ + + + + + + Options + + array + + + + 1 + + + group + db + pages + 1 + 1 + 0 + 1 + + + + + + + + \ No newline at end of file diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index f83f45a..d6ae958 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -20,5 +20,37 @@ call_user_func(function () { 'FILE:EXT:events/Configuration/FlexForms/Pi1.xml' ); + /* Search Plugin */ + + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( + 'Wrm.Events', + 'DateSearch', + 'Events Date Search', + 'EXT:events/Resources/Public/Icons/user_plugin_events.svg' + ); + + $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['events_datesearch'] = 'pi_flexform'; + + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue( + 'events_datesearch', + 'FILE:EXT:events/Configuration/FlexForms/Search.xml' + ); + + /* Date List Plugin */ + + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( + 'Wrm.Events', + 'DateList', + 'Events Date List', + 'EXT:events/Resources/Public/Icons/user_plugin_events.svg' + ); + + $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['events_datelist'] = 'pi_flexform'; + + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue( + 'events_datelist', + 'FILE:EXT:events/Configuration/FlexForms/DateList.xml' + ); + }); diff --git a/Resources/Private/Partials/Date/ListDefault.html b/Resources/Private/Partials/Date/ListDefault.html index 972152c..27013fc 100644 --- a/Resources/Private/Partials/Date/ListDefault.html +++ b/Resources/Private/Partials/Date/ListDefault.html @@ -21,11 +21,13 @@ {date.event.region.title} | {date.start}

{date.event.title}

{date.event.teaser}

- - - Hightlight - - + + + + Hightlight + + + diff --git a/Resources/Private/Partials/Date/ListTable.html b/Resources/Private/Partials/Date/ListTable.html index 284110f..6cffa86 100644 --- a/Resources/Private/Partials/Date/ListTable.html +++ b/Resources/Private/Partials/Date/ListTable.html @@ -1,9 +1,9 @@ - - -
+ + +
{date.start}
{date.start}
@@ -11,30 +11,45 @@ {date.event.region.title}
-

{date.event.title}

-
{date.event.teaser}
- {date.event.details} Hightlight +

+ + {date.event.title} + +

+

{date.event.teaser}

+ {date.event.details} +
+DEBUGGING:
+GLOBAL EVENT ID: {date.event.globalId}
+                
-
+
- + - + Dummy
+ + + + +
+
+
diff --git a/Resources/Private/Partials/Date/SearchForm.html b/Resources/Private/Partials/Date/~OBSOLETE-SearchForm.html similarity index 94% rename from Resources/Private/Partials/Date/SearchForm.html rename to Resources/Private/Partials/Date/~OBSOLETE-SearchForm.html index 315748f..f920cb8 100644 --- a/Resources/Private/Partials/Date/SearchForm.html +++ b/Resources/Private/Partials/Date/~OBSOLETE-SearchForm.html @@ -1,9 +1,10 @@ {namespace wrm=Wrm\Events\ViewHelpers} +
-
+
- +
@@ -60,6 +61,5 @@
-
\ No newline at end of file diff --git a/Resources/Private/Templates/Date/Search.html b/Resources/Private/Templates/Date/Search.html index cd26875..3937095 100644 --- a/Resources/Private/Templates/Date/Search.html +++ b/Resources/Private/Templates/Date/Search.html @@ -1,60 +1,68 @@ + + +
+
+ + - +
+
+
+ + +
+
+
-
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
- - -
-
- {date.start}
- {date.start}
- {date.start}
- {date.event.region.title}
-
-
- - - Hightlight - - -

- - {date.event.title} - -

-

{date.event.teaser}

- {date.event.details} -
-DEBUGGING:
-GLOBAL EVENT ID: {date.event.globalId}
-                
-
-
- - - - - - - - - Dummy - - - -
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+ +
+
- - - - -
-
-
-
-
- +
+ \ No newline at end of file diff --git a/Resources/Private/Templates/Date/SearchHtml.html b/Resources/Private/Templates/Date/SearchHtml.html new file mode 100644 index 0000000..8ea1438 --- /dev/null +++ b/Resources/Private/Templates/Date/SearchHtml.html @@ -0,0 +1,68 @@ + + + +
+
+ + +
+
+
+ + \ No newline at end of file diff --git a/Resources/Private/Templates/ViewHelpers/Widget/Paginate/Index.html b/Resources/Private/Templates/ViewHelpers/Widget/Paginate/Index.html index 899196f..c8c84b1 100644 --- a/Resources/Private/Templates/ViewHelpers/Widget/Paginate/Index.html +++ b/Resources/Private/Templates/ViewHelpers/Widget/Paginate/Index.html @@ -1,91 +1,91 @@ - + - + - + diff --git a/ext_localconf.php b/ext_localconf.php index 35e873e..b8c39cc 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -18,6 +18,31 @@ call_user_func( ] ); + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'Wrm.Events', + 'DateSearch', + [ + 'Date' => 'search' + ] + ); + + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'Wrm.Events', + 'DateList', + [ + 'Date' => 'list' + ] + ); + + /* + $iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class); + + $iconRegistry->registerIcon( + 'events-plugin', + \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + ['source' => 'EXT:events/Resources/Public/Icons/user_plugin_events.svg'] + ); + // wizards \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig( 'mod { @@ -37,14 +62,6 @@ call_user_func( } }' ); - - $iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class); - - $iconRegistry->registerIcon( - 'events-plugin', - \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, - ['source' => 'EXT:events/Resources/Public/Icons/user_plugin_events.svg'] - ); - + */ } );