diff --git a/config/sites/ep-reisen/config.yaml b/config/sites/ep-reisen/config.yaml index 2492f0f..8d85bbb 100644 --- a/config/sites/ep-reisen/config.yaml +++ b/config/sites/ep-reisen/config.yaml @@ -284,6 +284,7 @@ routeEnhancers: /html: 1702 /form: 1704 /captcha: 3413 + /snowreport: 1705 .json: 1803 .ical: 1710 sitemap.xml: 1533906435 diff --git a/config/sites/ser/config.yaml b/config/sites/ser/config.yaml index f0e85d1..75a1a31 100644 --- a/config/sites/ser/config.yaml +++ b/config/sites/ser/config.yaml @@ -79,7 +79,7 @@ routeEnhancers: hotel_uid: \d+ date_from: '\d{4}\-\d{2}\-\d{2}' date_to: '\d{4}\-\d{2}\-\d{2}' - # Only for the form and captcha page types; default '' keeps the URLs without trailing slash + # Only for the form, captcha and snow report page types; default '' keeps the URLs without trailing slash PageTypeSuffix: type: PageType default: '' @@ -87,6 +87,7 @@ routeEnhancers: map: /form: 1704 /captcha: 3413 + /snowreport: 1705 routes: - route: robots.txt diff --git a/config/sites/ski-boarderweek/config.yaml b/config/sites/ski-boarderweek/config.yaml index 14dc166..ac0b8cb 100644 --- a/config/sites/ski-boarderweek/config.yaml +++ b/config/sites/ski-boarderweek/config.yaml @@ -68,6 +68,7 @@ routeEnhancers: /html: 1702 /form: 1704 /captcha: 3413 + /snowreport: 1705 sitemap.xml: 1533906435 yoast-snippetpreview.json: 1480321830 routes: diff --git a/config/sites/snowzone/config.yaml b/config/sites/snowzone/config.yaml index 9471f7a..65918a5 100644 --- a/config/sites/snowzone/config.yaml +++ b/config/sites/snowzone/config.yaml @@ -52,6 +52,7 @@ routeEnhancers: /html: 1702 /form: 1704 /captcha: 3413 + /snowreport: 1705 sitemap.xml: 1533906435 yoast-snippetpreview.json: 1480321830 routes: diff --git a/config/sites/unichamp/config.yaml b/config/sites/unichamp/config.yaml index 52469b7..4a54be1 100644 --- a/config/sites/unichamp/config.yaml +++ b/config/sites/unichamp/config.yaml @@ -52,6 +52,7 @@ routeEnhancers: /html: 1702 /form: 1704 /captcha: 3413 + /snowreport: 1705 sitemap.xml: 1533906435 yoast-snippetpreview.json: 1480321830 routes: diff --git a/packages/ep_products/Classes/Controller/SnowreportController.php b/packages/ep_products/Classes/Controller/SnowreportController.php new file mode 100644 index 0000000..bc81eff --- /dev/null +++ b/packages/ep_products/Classes/Controller/SnowreportController.php @@ -0,0 +1,23 @@ +settings['regionUids'] ?? ''), true); + $this->view->assign('data', $this->request->getAttribute('currentContentObject')?->data ?? []); + $this->view->assign('list', $this->snowreportRepository->getSnowreportsForRegions($regionUids)); + return $this->htmlResponse(); + } +} diff --git a/packages/ep_products/Classes/Domain/Repository/SnowreportRepository.php b/packages/ep_products/Classes/Domain/Repository/SnowreportRepository.php new file mode 100644 index 0000000..a13080b --- /dev/null +++ b/packages/ep_products/Classes/Domain/Repository/SnowreportRepository.php @@ -0,0 +1,43 @@ +getDbConnection()->createQueryBuilder(); + + $qb + ->select( + 'snowreport.*', + 'region.name as regionName', 'region.uid as regionUid', 'region.detail_page as regionDetailPage', + 'country.name as countryName', 'country.uid as countryUid', 'country.code as countryCode', + 'country.detail_page as countryDetailPage', + 'season_start as seasonStart', 'season_end as seasonEnd' + ) + ->addSelectLiteral('(UNIX_TIMESTAMP() >= snowreport.season_start AND UNIX_TIMESTAMP() <= snowreport.season_end) as inSeason') + ->from('tx_epproducts_domain_model_snowreport', 'snowreport') + ->innerJoin('snowreport', 'tx_epproducts_domain_model_region', 'region', 'snowreport.uid = region.snowreport') + ->innerJoin('region', 'tx_epproducts_domain_model_country', 'country', 'region.country = country.uid') + ->where('region.snowreport > 0') + ->groupBy('snowreport.vendor_uid') + ->orderBy('region.name') + ; + + if ($regionUids) { + $qb->andWhere($qb->expr()->in( + 'region.uid', + $qb->createNamedParameter($regionUids, Connection::PARAM_INT_ARRAY) + )); + } + + return $qb->executeQuery()->fetchAllAssociative(); + } +} diff --git a/packages/ep_products/Configuration/FlexForms/flexform_snowreport.xml b/packages/ep_products/Configuration/FlexForms/flexform_snowreport.xml new file mode 100644 index 0000000..d4e828b --- /dev/null +++ b/packages/ep_products/Configuration/FlexForms/flexform_snowreport.xml @@ -0,0 +1,28 @@ + + + + 1 + + + + + Konfiguration + array + + + + + select + selectMultipleSideBySide + tx_epproducts_domain_model_region + AND tx_epproducts_domain_model_region.snowreport > 0 ORDER BY name + 0 + 99 + 10 + + + + + + + diff --git a/packages/ep_products/Configuration/TCA/Overrides/tt_content.php b/packages/ep_products/Configuration/TCA/Overrides/tt_content.php index 6aae3d8..c60c9c7 100644 --- a/packages/ep_products/Configuration/TCA/Overrides/tt_content.php +++ b/packages/ep_products/Configuration/TCA/Overrides/tt_content.php @@ -43,6 +43,12 @@ call_user_func(function () { 'Buchungstabelle' ); + ExtensionUtility::registerPlugin( + 'EpProducts', + 'snowreport_list', + 'Schneehöhen' + ); + $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['epproducts_product_detail'] = 'pi_flexform'; ExtensionManagementUtility::addPiFlexFormValue( 'epproducts_product_detail', @@ -61,4 +67,10 @@ call_user_func(function () { 'FILE:EXT:ep_products/Configuration/FlexForms/flexform_product_pricetable.xml' ); + $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['epproducts_snowreport_list'] = 'pi_flexform'; + ExtensionManagementUtility::addPiFlexFormValue( + 'epproducts_snowreport_list', + 'FILE:EXT:ep_products/Configuration/FlexForms/flexform_snowreport.xml' + ); + }); diff --git a/packages/ep_products/ext_localconf.php b/packages/ep_products/ext_localconf.php index 1cdd5e0..c6c21d6 100644 --- a/packages/ep_products/ext_localconf.php +++ b/packages/ep_products/ext_localconf.php @@ -2,6 +2,7 @@ use TYPO3\CMS\Extbase\Utility\ExtensionUtility; use EP\EpProducts\Controller\ProductController; use EP\EpProducts\Controller\SearchController; +use EP\EpProducts\Controller\SnowreportController; use EP\EpProducts\Controller\TravelinfoController; use EP\EpProducts\Controller\WatchlistController; use EP\EpProducts\Controller\AjaxFilterPanelController; @@ -81,6 +82,14 @@ $boot = function () { ] ); + ExtensionUtility::configurePlugin( + 'EpProducts', + 'snowreport_list', + [ + SnowreportController::class => 'list', + ] + ); + ExtensionUtility::configurePlugin( 'EpProducts', 'ajax', diff --git a/packages/ep_theme/Configuration/TypoScript/Page/Snowreport.typoscript b/packages/ep_theme/Configuration/TypoScript/Page/Snowreport.typoscript new file mode 100644 index 0000000..0b97491 --- /dev/null +++ b/packages/ep_theme/Configuration/TypoScript/Page/Snowreport.typoscript @@ -0,0 +1,29 @@ +# The snow reports of a page without the page around them (/path/snowreport). The static pages of +# the hybrid setup load this with htmx and replace the snow reports of the export with it: the +# page URL itself is a static file that never reaches TYPO3, and the snow reports are imported +# daily (ep:import-snowreport, which flushes the page cache). Each list carries +# id="snowreport-" (Templates/Snowreport/List.html) for hx-select. + +tx_eptheme_snowreport = PAGE +tx_eptheme_snowreport { + typeNum = 1705 + config { + disableAllHeaderCode = 1 + disablePrefixComment = 1 + additionalHeaders.10.header = Content-Type: text/html; charset=utf-8 + additionalHeaders.20.header = X-Robots-Tag: noindex, nofollow + admPanel = 0 + debug = 0 + } + + 10 = CONTENT + 10 { + table = tt_content + select { + where = {#CType} = 'list' AND {#list_type} = 'epproducts_snowreport_list' + orderBy = sorting + } + # Only the plugin: header and frame stay on the static page + renderObj =< tt_content.list.20.epproducts_snowreport_list + } +} diff --git a/packages/ep_theme/Resources/Private/Templates/Snowreport/List.html b/packages/ep_theme/Resources/Private/Templates/Snowreport/List.html new file mode 100644 index 0000000..6b4cf4a --- /dev/null +++ b/packages/ep_theme/Resources/Private/Templates/Snowreport/List.html @@ -0,0 +1,61 @@ + + + + + + + The id lets the static pages of the hybrid setup pick this list, with the spacing of + ep:container, out of the snow report page type (/path/snowreport), which renders every + snow report plugin of a page. + +
+ +
+ +
+
+ {ep:icon(icon: 'flag-{snowreport.countryCode -> f:format.case(mode: \'lower\')}', class: 'w-8 h-6')} + + {snowreport.regionName} + +
+
+ + +
    +
  • + Berg/Tal: {snowreport.snow_level_mountain -> v:or(alternative: '-')}/{snowreport.snow_level_valley -> v:or(alternative: '-')} cm +
  • +
  • + Qualität: {snowreport.snow_quality} +
  • +
  • + Geöffnete Lifte: {snowreport.lifts_opened}/{snowreport.lifts_total}keine Angabe +
  • +
  • + Letzter Schneefall: {f:if(condition: snowreport.last_snowfall, then: '{snowreport.last_snowfall -> f:format.date(format: \'d.m.Y\')}', else: 'keine Angabe')} +
  • +
  • + Letzte Akt.: {snowreport.last_update -> f:format.date(format: 'd.m.Y')} +
  • +
+
+ + Saison vom {snowreport.seasonStart -> f:format.date(format: 'd.m.Y')} bis {snowreport.seasonEnd -> f:format.date(format: 'd.m.Y')} + +
+
+
+
+
+
+
+
+ +