From 33c59496f974da1e6717ea0776e5a683ec731536 Mon Sep 17 00:00:00 2001 From: Helmut Hackbarth Date: Tue, 7 Jun 2022 20:26:42 +0200 Subject: [PATCH] New release v5.1.14 --- Classes/Components/Card.php | 63 +-- Classes/ContentElements/Table.php | 3 +- Classes/Controller/ConfigController.php | 10 +- Classes/DataProcessing/BootstrapProcessor.php | 3 +- Classes/DataProcessing/ConfigProcessor.php | 38 +- Classes/Domain/Model/Config.php | 39 ++ .../EventListener/AssetRenderer/IsInline.php | 55 ++- Classes/Helper/ClassHelper.php | 7 +- Classes/UserFunction/TcaMatcher.php | 12 +- Classes/Utility/BackgroundImageUtility.php | 2 - Classes/Utility/ResponsiveImagesUtility.php | 1 - Classes/ViewHelpers/MediaViewHelper.php | 9 +- Classes/Wrapper/BackgroundWrapper.php | 13 +- Classes/Wrapper/ButtonGroup.php | 2 + Configuration/FlexForms/Bootstrap.xml | 75 ---- Configuration/FlexForms/CardContent.xml | 6 +- Configuration/FlexForms/CardSetting.xml | 384 ++++++++++++++++-- Configuration/FlexForms/Carousel.xml | 11 +- .../FlexForms/Container/BackgroundWrapper.xml | 77 ++-- Configuration/FlexForms/Table.xml | 10 + .../tx_t3sbootstrap_domain_model_config.php | 14 + .../TypoScript/Page/IncludeDefault.typoscript | 16 - .../TypoScript/Page/Template.typoscript | 1 + Resources/Private/Language/locallang_m1.xlf | 2 +- .../Partials/Content/Card/FlipCard.html | 69 ++++ .../Partials/Content/Card/ProfileCard.html | 244 +++++++++++ .../Partials/Content/Table/Columns.html | 14 +- Resources/Private/Partials/Page/Assets.html | 4 +- .../Container/BackgroundWrapper.html | 20 +- .../Templates/Container/Buttongroup.html | 2 +- .../Templates/Container/CardWrapper.html | 20 +- .../Private/Templates/Content/Button.html | 2 + Resources/Private/Templates/Content/Card.html | 183 +++------ .../Private/Templates/Content/Table.html | 43 +- Resources/Private/Templates/Main.html | 53 ++- Resources/Public/Scripts/t3sbHelper.js | 61 ++- Resources/Public/Styles/t3sbootstrap.css | 2 +- ext_emconf.php | 2 +- ext_tables.php | 12 +- ext_tables.sql | 1 + readMe.md | 2 +- 41 files changed, 1089 insertions(+), 498 deletions(-) create mode 100644 Resources/Private/Partials/Content/Card/FlipCard.html create mode 100644 Resources/Private/Partials/Content/Card/ProfileCard.html diff --git a/Classes/Components/Card.php b/Classes/Components/Card.php index c2dd68ec..994ad004 100644 --- a/Classes/Components/Card.php +++ b/Classes/Components/Card.php @@ -9,7 +9,6 @@ use TYPO3\CMS\Backend\Utility\BackendUtility; use T3SBS\T3sbootstrap\Helper\FlexformHelper; - /* * This file is part of the TYPO3 extension t3sbootstrap. * @@ -22,7 +21,7 @@ class Card implements SingletonInterface /** * Returns the $processedData */ - public function getProcessedData(array $processedData, array $flexconf): array + public function getProcessedData(array $processedData, array $flexconf, array $parentflexconf): array { $flexformService = GeneralUtility::makeInstance(FlexFormService::class); $flexformHelper = GeneralUtility::makeInstance(FlexformHelper::class); @@ -38,7 +37,6 @@ public function getProcessedData(array $processedData, array $flexconf): array $parentflexconf =$flexformHelper->addMissingElements($parentflexconf, $parentFlexformData['CType'], TRUE); } } - $cardData = $flexconf; // crop max characters $cardData['cropMaxCharacters'] = !empty($parentflexconf['cropMaxCharacters']) ? $parentflexconf['cropMaxCharacters'] : ''; @@ -73,17 +71,13 @@ public function getProcessedData(array $processedData, array $flexconf): array // dimensions $cardData['dimensions']['width'] = $processedData['data']['imagewidth']; $cardData['dimensions']['height'] = $processedData['data']['imageheight']; + // class + $cardClass = 'card'.$processedData['class']; + $cardClass .= !empty($flexconf['button']['stretchedLink']) ? ' ce-link-content' : ''; // image if ( !empty($cardData['image']['overlay']) ) { - if ( $cardData['header']['text'] && $cardData['footer']['text'] ) { - $cardData['image']['class'] = 'img-fluid'; - } elseif ( $cardData['header']['text'] ) { - $cardData['image']['class'] = 'card-img-bottom img-fluid'; - } elseif ( $cardData['footer']['text'] ) { - $cardData['image']['class'] = 'card-img-top img-fluid'; - } else { - $cardData['image']['class'] = 'img-fluid'; - } + $cardClass .= ' overflow-hidden'; + $cardData['image']['class'] = 'img-fluid'; $cardData['image']['overlay'] = 'card-img-overlay d-flex'; $cardData['mobile']['overlay'] = FALSE; } else { @@ -111,17 +105,6 @@ public function getProcessedData(array $processedData, array $flexconf): array } else { $cardData['block']['enable'] = TRUE; } - // class - $cardClass = $processedData['class']; - $cardClass .= ' card'; - - if ( $processedData['data']['tx_t3sbootstrap_textcolor'] ) { - $cardClass .= ' text-'.$processedData['data']['tx_t3sbootstrap_textcolor']; - } - if ( $processedData['data']['tx_t3sbootstrap_contextcolor'] ) { - $cardClass .= ' bg-'.$processedData['data']['tx_t3sbootstrap_contextcolor']; - } - // flip card if ( !empty($flexconf['flipcard']) ) { $backstyle = ''; @@ -144,7 +127,36 @@ public function getProcessedData(array $processedData, array $flexconf): array } else { $cardClass .= $processedData['data']['tx_t3sbootstrap_header_position'] ? ' '.$processedData['data']['tx_t3sbootstrap_header_position']:''; } + // list group + if ( !empty($flexconf['list']['container']) && is_array($flexconf['list']['container']) ) { + foreach( $flexconf['list'] as $container ) { + foreach ($container as $list) + $listGroup[] = $list['list']['group']; + } + $cardData['list'] = $listGroup; + } + // profile card + $cardData['multiImage']['enable'] = FALSE; + if ( !empty($flexconf['multiImage']['enable']) ) { + $cardData['multiImage']['enable'] = TRUE; + $cardData['multiImage']['percent'] = '0.'.$flexconf['multiImage']['percent']; + $cardData['multiImage']['style'] = 'top: -' . $flexconf['multiImage']['percent']/2 .'px'; + $borderColor = $flexconf['multiImage']['borderColor'] ? ' border-'.$flexconf['multiImage']['borderColor'] : ''; + $shadow = $flexconf['multiImage']['shadow'] ? ' circularshadow' : ''; + $cardData['multiImage']['shadow'] = $flexconf['multiImage']['shadow'] ? TRUE : FALSE; + $cardData['multiImage']['border'] = $flexconf['multiImage']['borderWidth'].$borderColor.$shadow; + $cardData['multiImage']['slope'] = $flexconf['multiImage']['diagonal'] ? $flexconf['multiImage']['slope'] : 0; + $cardData['multiImage']['socialmedia']['enable'] = $flexconf['multiImage']['socialmedia']['enable']; + $cardData['multiImage']['socialmedia']['footer'] = $flexconf['multiImage']['socialmedia']['footer']; + if (!empty($flexconf['multiImage']['socialmedia']['enable'])) { + foreach ($flexconf['multiImage']['socialmedia'] as $key=>$socialmedia) { + if ($key != 'enable' && $key != 'footer' && !empty($socialmedia)) { + $cardData['multiImage']['socialmediaLinks'][$key] = $socialmedia; + } + } + } + } // header position if ( $processedData['data']['header_position'] ) { $headerPosition = $processedData['data']['header_position']; @@ -160,6 +172,11 @@ public function getProcessedData(array $processedData, array $flexconf): array if ( !empty($cardData['cardborder']) ) { $cardClass .= ' border-'.$cardData['cardborderstyle']; } + // parent equal Height + if ( !empty($parentflexconf['equalHeight']) ) { + $cardClass .= ' w-100'; + } + $processedData['class'] = trim($cardClass); // addmedia diff --git a/Classes/ContentElements/Table.php b/Classes/ContentElements/Table.php index 8bbfefc2..0edce944 100644 --- a/Classes/ContentElements/Table.php +++ b/Classes/ContentElements/Table.php @@ -4,8 +4,6 @@ namespace T3SBS\T3sbootstrap\ContentElements; use TYPO3\CMS\Core\SingletonInterface; -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Core\Resource\FileRepository; /* * This file is part of the TYPO3 extension t3sbootstrap. @@ -38,6 +36,7 @@ public function getProcessedData(array $processedData, array $flexconf): array $processedData['tableclass'] = trim($tableclass); $processedData['theadclass'] = $flexconf['theadClass']; $processedData['tableResponsive'] = $flexconf['tableResponsive'] ? TRUE : FALSE; + $processedData['tableResponsiveVariant'] = $flexconf['tableResponsiveVariant'] ? TRUE : FALSE; return $processedData; } diff --git a/Classes/Controller/ConfigController.php b/Classes/Controller/ConfigController.php index 7c2475e5..cb7bec7c 100644 --- a/Classes/Controller/ConfigController.php +++ b/Classes/Controller/ConfigController.php @@ -587,7 +587,11 @@ public function writeConstants(): void } else { $filecontent .= '[page["uid"] == '.$config->getPid().']'.PHP_EOL; } - $filecontent .= self::getConstants($config, FALSE); + if ($config->getGeneralOverride()) { + $filecontent .= self::getConstants($config, TRUE); + } else { + $filecontent .= self::getConstants($config, FALSE); + } $filecontent .= '[END]'.PHP_EOL.PHP_EOL; } } @@ -685,8 +689,6 @@ private function getUtilityColors(): array $scsscolor = GeneralUtility::trimExplode(':', $customvariables); if ( str_starts_with((string)$customvariables, '$') && GeneralUtility::inList($defaultUtilColorsList, $scsscolor[0]) ) { $scsscolor = GeneralUtility::trimExplode(':', $customvariables); - - $customScssArr[$scsscolor[0]] = $scsscolor[1]; } } @@ -711,8 +713,6 @@ private function getUtilityColors(): array if ( str_starts_with((string)$defaultVariables, '$') && GeneralUtility::inList($defaultUtilColorsList, $defaultScssColor[0]) && ( str_starts_with((string)$defaultScssColor[1], '$') || str_starts_with((string)$defaultScssColor[1], '#') ) ) { $scsscolor = GeneralUtility::trimExplode(':', $defaultVariables); - - $defaultUtilColors[$scsscolor[0]] = substr($scsscolor[1], 0, -9); } } diff --git a/Classes/DataProcessing/BootstrapProcessor.php b/Classes/DataProcessing/BootstrapProcessor.php index 4e7c9a46..fcc5f58c 100644 --- a/Classes/DataProcessing/BootstrapProcessor.php +++ b/Classes/DataProcessing/BootstrapProcessor.php @@ -52,7 +52,6 @@ class BootstrapProcessor implements DataProcessorInterface const T3SBS_ELEMENTS = 't3sbs_mediaobject,t3sbs_card,t3sbs_carousel,t3sbs_button,t3sbs_fluidtemplate,t3sbs_gallery,t3sbs_toast'; const TX_CONTAINER = 'button_group,background_wrapper,parallax_wrapper,autoLayout_row,container,carousel_container,collapsible_container,collapsible_accordion,modal,tabs_container,tabs_tab,listGroup_wrapper,masonry_wrapper,swiper_container,toast_container,card_wrapper'; - /** * Process data * @@ -133,7 +132,7 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu } if ( $cType == 't3sbs_card' ) { $processedData = GeneralUtility::makeInstance(Card::class) - ->getProcessedData($processedData, $flexconf); + ->getProcessedData($processedData, $flexconf, $parentflexconf); } if ( $cType == 't3sbs_carousel' ) { $processedData = GeneralUtility::makeInstance(Carousel::class) diff --git a/Classes/DataProcessing/ConfigProcessor.php b/Classes/DataProcessing/ConfigProcessor.php index 702186cd..fdf4372b 100644 --- a/Classes/DataProcessing/ConfigProcessor.php +++ b/Classes/DataProcessing/ConfigProcessor.php @@ -4,18 +4,16 @@ namespace T3SBS\T3sbootstrap\DataProcessing; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Core\Site\Entity\SiteInterface; -use TYPO3\CMS\Core\Routing\SiteMatcher; -use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; -use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface; -use T3SBS\T3sbootstrap\Utility\BackgroundImageUtility; use TYPO3\CMS\Core\Resource\FileRepository; -use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; use TYPO3\CMS\Core\Domain\Repository\PageRepository; -use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; +use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; use TYPO3\CMS\Core\Database\Query\QueryHelper; +use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; +use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; +use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface; +use T3SBS\T3sbootstrap\Utility\BackgroundImageUtility; /* * This file is part of the TYPO3 extension t3sbootstrap. @@ -38,8 +36,10 @@ class ConfigProcessor implements DataProcessorInterface */ public function process(ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData) { + + $request = $GLOBALS['TYPO3_REQUEST']; $settings = $contentObjectConfiguration['settings.']; - $frontendController = self::getFrontendController(); + $frontendController = $request->getAttribute('frontend.controller'); $webp = (bool)$settings['webp']; if ( is_numeric($contentObjectConfiguration['settings.']['config.']['uid']) ) { @@ -130,7 +130,7 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu * Language Navigation */ if( $processedRecordVariables['navbarEnable'] && $processedRecordVariables['navbarLangmenu'] ) { - $site = self::getCurrentSite(); + $site = $request->getAttribute('site'); $langUid = []; foreach ($site->getLanguages() as $lang ) { $langUid[$lang->getLanguageId()] = $lang->getLanguageId(); @@ -356,6 +356,8 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu # Image from pages media $hasBgImages = 0; $fileRepository = GeneralUtility::makeInstance(FileRepository::class); + + $fileObjects = []; $processedData['config']['jumbotron']['alignItem'] = 'd-flex align-items-'.$processedRecordVariables['jumbotronAlignitem']; $processedData['config']['jumbotron']['alignment'] = $processedRecordVariables['jumbotronAlignitem']; @@ -530,24 +532,6 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu } - /** - * Returns the currently configured "site" if a site is configured (= resolved) in the current request. - */ - protected function getCurrentSite(): SiteInterface - { - $matcher = GeneralUtility::makeInstance(SiteMatcher::class); - return $matcher->matchByPageId((int)self::getFrontendController()->id); - } - - /** - * Returns the frontend controller - */ - protected function getFrontendController(): TypoScriptFrontendController - { - return $GLOBALS['TSFE']; - } - - /** * Returns an instance of the rbackground image utility */ diff --git a/Classes/Domain/Model/Config.php b/Classes/Domain/Model/Config.php index 42499c92..4e4e06dd 100644 --- a/Classes/Domain/Model/Config.php +++ b/Classes/Domain/Model/Config.php @@ -659,6 +659,15 @@ class Config extends AbstractEntity */ protected $generalRootline = false; + + /** + * generalRootline + * + * @var bool + */ + protected $generalOverride = false; + + /** * contentOnlyOnRootpage * @@ -3126,6 +3135,36 @@ public function isGeneralRootline() return $this->generalRootline; } + /** + * Returns the generalOverride + * + * @return bool $generalOverride + */ + public function getGeneralOverride() + { + return $this->generalOverride; + } + + /** + * Sets the generalOverride + * + * @param bool $generalOverride + * @return void + */ + public function setGeneralOverride($generalOverride) + { + $this->generalOverride = $generalOverride; + } + + /** + * Returns the boolean state of generalOverride + * + * @return bool + */ + public function isGeneralOverride() + { + return $this->generalOverride; + } /** * Returns the contentOnlyOnRootpage diff --git a/Classes/EventListener/AssetRenderer/IsInline.php b/Classes/EventListener/AssetRenderer/IsInline.php index ae1e58b3..beee3475 100644 --- a/Classes/EventListener/AssetRenderer/IsInline.php +++ b/Classes/EventListener/AssetRenderer/IsInline.php @@ -7,6 +7,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Http\ApplicationType; use Psr\Http\Message\ServerRequestInterface; +use TYPO3\CMS\Core\Core\Environment; /* * This file is part of the TYPO3 extension t3sbootstrap. @@ -16,7 +17,6 @@ */ class IsInline { - public function __invoke(BeforeJavaScriptsRenderingEvent $event): void { if (($GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface @@ -39,10 +39,16 @@ public function __invoke(BeforeJavaScriptsRenderingEvent $event): void $css .= $source['source']. ' '; $event->getAssetCollector()->removeInlineStyleSheet($library); } - if ( $css ) - $event->getAssetCollector()->addInlineStyleSheet('t3sbInlineCSS', $css, [], ['priority' => true]); + + if ( $css ) { + $cssFile = self::inline2TempFile($css, 'css'); + if ($event->getAssetCollector()->getJavaScripts()['t3sbootstrap'] == NULL) { + $event->getAssetCollector()->addStyleSheet('t3sbootstrap', $cssFile); + } + } return; + } else { $assetJsInline = $event->getAssetCollector()->getInlineJavaScripts(); @@ -52,7 +58,6 @@ public function __invoke(BeforeJavaScriptsRenderingEvent $event): void $js = ''; foreach ($assetJsInline as $library => $source) { - if (substr($library, 0, 7) == 'vanilla' ) { $js .= $source['source'] .PHP_EOL; $event->getAssetCollector()->removeInlineJavaScript($library); @@ -78,12 +83,46 @@ public function __invoke(BeforeJavaScriptsRenderingEvent $event): void } if ($vanillaOnly) { - $event->getAssetCollector()->addInlineJavaScript("t3sbInlineJS", - $video.PHP_EOL.PHP_EOL."function ready(fn) {".PHP_EOL." if (document.readyState != 'loading'){".PHP_EOL." fn();".PHP_EOL." } else {".PHP_EOL." document.addEventListener('DOMContentLoaded', fn);".PHP_EOL." }".PHP_EOL."}".PHP_EOL."ready(() => {".$addheight.$js."});".PHP_EOL); +$source = $video.PHP_EOL.PHP_EOL."function ready(fn) {".PHP_EOL." if (document.readyState != 'loading'){".PHP_EOL." fn();".PHP_EOL." } else {".PHP_EOL." document.addEventListener('DOMContentLoaded', fn);".PHP_EOL." }".PHP_EOL."}".PHP_EOL."ready(() => {".$addheight.$js."});".PHP_EOL; } else { - $event->getAssetCollector()->addInlineJavaScript("t3sbInlineJS", - $video.PHP_EOL.PHP_EOL."function ready(fn) {".PHP_EOL." if (document.readyState != 'loading'){".PHP_EOL." fn();".PHP_EOL." } else {".PHP_EOL." document.addEventListener('DOMContentLoaded', fn);".PHP_EOL." }".PHP_EOL."}".PHP_EOL."ready(() => {".$addheight.$js."});".PHP_EOL.PHP_EOL."(function($){'use strict';".PHP_EOL. $jquery .PHP_EOL."})(jQuery);".PHP_EOL); +$source = $video.PHP_EOL.PHP_EOL."function ready(fn) {".PHP_EOL." if (document.readyState != 'loading'){".PHP_EOL." fn();".PHP_EOL." } else {".PHP_EOL." document.addEventListener('DOMContentLoaded', fn);".PHP_EOL." }".PHP_EOL."}".PHP_EOL."ready(() => {".$addheight.$js."});".PHP_EOL.PHP_EOL."(function($){'use strict';".PHP_EOL. $jquery .PHP_EOL."})(jQuery);".PHP_EOL; + } + + if (!empty($source)) { + $jsFile = self::inline2TempFile($source, 'js'); + if ($event->getAssetCollector()->getJavaScripts()['t3sbootstrap'] == NULL) { + $event->getAssetCollector()->addJavaScript('t3sbootstrap', $jsFile); + } } } } + + + /** + * Writes string to a temporary file named after the md5-hash of the string + * + * @param string $str CSS styles / JavaScript to write to file. + * @param string $ext Extension: "css" or "js + * @return string