Skip to content

Commit

Permalink
Merge pull request #338 from t3solution/5.3.0
Browse files Browse the repository at this point in the history
New release v5.3.0
  • Loading branch information
t3solution authored Jul 11, 2023
2 parents ce52855 + 392a38e commit 148f07f
Show file tree
Hide file tree
Showing 90 changed files with 387 additions and 2,873 deletions.
3 changes: 2 additions & 1 deletion Classes/Backend/EventListener/FlexForm/NewsFlexformEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public function __invoke(AfterFlexFormDataStructureParsedEvent $event): void
&& ($identifier['dataStructureKey'] === '*,news_pi1' || $identifier['dataStructureKey'] === '*,news_newsliststicky')) {

$file = GeneralUtility::getFileAbsFileName('EXT:t3sbootstrap/Resources/Private/Extensions/news/Configuration/FlexForms/News.xml');
$content = @file_get_contents($file);
$content = file_get_contents($file);

if ($content) {
$extraDataStructure['sheets']['extraEntry'] = GeneralUtility::xml2array($content);
ArrayUtility::mergeRecursiveWithOverrule($dataStructure, $extraDataStructure);
Expand Down
2 changes: 2 additions & 0 deletions Classes/Command/CdnToLocal.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

# check FA version & settings
$extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('t3sbootstrap');

if ( !empty($extConf['fontawesomeCss']) ) {
if ( (int)$extConf['fontawesomeCss'] > 2 ) {
if ( (int)$settings['cdn']['fontawesome'] < 6 ) {
Expand All @@ -69,6 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
} else {
$settings['cdn']['fontawesome'] = $settings['cdn']['fontawesome6latest'];
}

if ( !empty($settings['cdn']['googlefonts']) && empty($settings['cdn']['noZip']) ) {
self::getGoogleFonts($settings['cdn']['googlefonts'], $settings['preloadGooleFonts'], $settings['gooleFontsWeights']);
} else {
Expand Down
15 changes: 8 additions & 7 deletions Classes/Command/CustomScss.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ protected function execute(InputInterface $input, OutputInterface $output)

$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
$result = $queryBuilder
->select('*')
->from('pages')
->where(
$queryBuilder->expr()->eq('sys_language_uid', 0),
->select('*')
->from('pages')
->where(
$queryBuilder->expr()->eq('sys_language_uid', 0),
$queryBuilder->expr()->eq('is_siteroot', $queryBuilder->createNamedParameter(1, \PDO::PARAM_INT))
)
->executeQuery();
)
->executeQuery();
$siteroots = $result->fetchAll();

foreach ($siteroots as $key=>$siteroot) {
Expand Down Expand Up @@ -210,7 +210,8 @@ private function writeCustomFile($customPath, $customFileName, $settings, $name)
mkdir($customPath, 0777, true);
}
$customContent = $name == '_variables' ? '// Overrides Bootstrap variables'.PHP_EOL.'// $enable-shadows: true;'.PHP_EOL.'// $enable-gradients: true;'.PHP_EOL.'// $enable-negative-margins: true;' : '// Your own SCSS';
if ( $settings['bootswatch'] ) {

if ( !empty($settings['bootswatch']) ) {
$customContent = @file_get_contents($settings['bootswatchURL'].strtolower($settings['bootswatch']).'/'.$name.'.scss');
if ($name == '_variables') {
$customContent = str_replace(' !default', '', $customContent);
Expand Down
6 changes: 3 additions & 3 deletions Classes/DataProcessing/BootstrapProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu
if ( str_contains(self::TX_CONTAINER_GRID, $cType) ) {
if ( $cType == 'two_columns' ) {
$processedData = GeneralUtility::makeInstance(TwoColumns::class)
->getProcessedData($processedData, $flexconf, (bool)$contentObjectConfiguration['settings.']['webp'], $contentObjectConfiguration['settings.']['bgMediaQueries']);
->getProcessedData($processedData, $flexconf, $contentObjectConfiguration['settings.']['bgMediaQueries']);
}
if ( $cType == 'three_columns' ) {
$processedData = GeneralUtility::makeInstance(ThreeColumns::class)
Expand Down Expand Up @@ -208,11 +208,11 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu
}
if ( $cType == 'background_wrapper' ) {
$processedData = GeneralUtility::makeInstance(BackgroundWrapper::class)
->getProcessedData($processedData, $flexconf, (bool)$contentObjectConfiguration['settings.']['webp'], $contentObjectConfiguration['settings.']['bgMediaQueries']);
->getProcessedData($processedData, $flexconf, $contentObjectConfiguration['settings.']['bgMediaQueries']);
}
if ( $cType == 'parallax_wrapper' ) {
$processedData = GeneralUtility::makeInstance(ParallaxWrapper::class)
->getProcessedData($processedData, $flexconf, (bool)$contentObjectConfiguration['settings.']['webp']);
->getProcessedData($processedData, $flexconf);
}
if ( $cType == 'collapsible_container' ) {
$processedData = GeneralUtility::makeInstance(CollapsibleContainer::class)
Expand Down
15 changes: 7 additions & 8 deletions Classes/DataProcessing/ConfigProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu
if (!$frontendController) {
$frontendController = self::getFrontendController();
}
$webp = (bool)$settings['webp'];

if ( !empty($contentObjectConfiguration['settings.']['config.']['uid'])
&& is_numeric($contentObjectConfiguration['settings.']['config.']['uid']) ) {
Expand Down Expand Up @@ -439,20 +438,20 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu
if (!empty($settings['multiplePagesMedia'])) {
// background images
$bgSlides = self::getBackgroundImageUtility()->getBgImage($uid, 'pages', TRUE, FALSE, [], FALSE,
$processedData['data']['uid'], $webp, $contentObjectConfiguration['settings.']['bgMediaQueries']);
$processedData['data']['uid'], $contentObjectConfiguration['settings.']['bgMediaQueries']);
$processedData['config']['jumbotron']['bgImage'] = $bgSlides;
$processedData['config']['jumbotron']['multiplePagesMedia'] = TRUE;
} else {
// slider
$processedData['config']['jumbotron']['alignItem'] = '';
$bgSlides = self::getBackgroundImageUtility()->getBgImage($uid, 'pages', TRUE, FALSE, [], FALSE, 0,
$webp, $contentObjectConfiguration['settings.']['bgMediaQueries']);
$contentObjectConfiguration['settings.']['bgMediaQueries']);
$processedData['bgSlides'] = $bgSlides;
}
} else {
// background image
$bgSlides = self::getBackgroundImageUtility()->getBgImage($uid, 'pages', TRUE, FALSE, [], FALSE,
$processedData['data']['uid'], $webp, $contentObjectConfiguration['settings.']['bgMediaQueries']);
$processedData['data']['uid'], $contentObjectConfiguration['settings.']['bgMediaQueries']);
$processedData['config']['jumbotron']['bgImage'] = $bgSlides;
if (!empty($settings['multiplePagesMedia'])) {
$processedData['config']['jumbotron']['multiplePagesMedia'] = FALSE;
Expand All @@ -466,12 +465,12 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu
// slider
$processedData['config']['jumbotron']['alignItem'] = '';
$bgSlides = self::getBackgroundImageUtility()->getBgImage($frontendController->id, 'pages', TRUE, FALSE, [], FALSE, 0,
$webp, $contentObjectConfiguration['settings.']['bgMediaQueries']);
$contentObjectConfiguration['settings.']['bgMediaQueries']);
$processedData['bgSlides'] = $bgSlides;
} else {
// background image
$bgSlides = self::getBackgroundImageUtility()->getBgImage($frontendController->id, 'pages', TRUE, FALSE, [], FALSE, 0,
$webp, $contentObjectConfiguration['settings.']['bgMediaQueries']);
$contentObjectConfiguration['settings.']['bgMediaQueries']);
$processedData['config']['jumbotron']['bgImage'] = $bgSlides;
}
}
Expand All @@ -491,11 +490,11 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu
if ( $contentObjectConfiguration['settings.']['config.']['backgroundImageEnable'] ) {

$BodyBgImage = self::getBackgroundImageUtility()->getBgImage($frontendController->id, 'pages', FALSE, FALSE, [], TRUE, 0,
$webp, $contentObjectConfiguration['settings.']['bgMediaQueries']);
$contentObjectConfiguration['settings.']['bgMediaQueries']);
$bgImage = is_array($BodyBgImage) ? $BodyBgImage[1] : '';
if ( empty($BodyBgImage) && $contentObjectConfiguration['settings.']['config.']['backgroundImageSlide'] ) {
foreach ($frontendController->rootLine as $page) {
$BodyBgImage = self::getBackgroundImageUtility()->getBgImage($page['uid'], 'pages', FALSE, FALSE, [], TRUE, $frontendController->id, $webp);
$BodyBgImage = self::getBackgroundImageUtility()->getBgImage($page['uid'], 'pages', FALSE, FALSE, [], TRUE, $frontendController->id);
if ($BodyBgImage) break;
}
}
Expand Down
8 changes: 1 addition & 7 deletions Classes/Helper/ClassHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public function getDefaultClass(array $data, array $flexconf, string $cTypeClass
} else {
$class = '';
}

// Spacing: padding
if ( $data['tx_t3sbootstrap_padding_sides'] ) {
// on all 4 sides of the element
Expand Down Expand Up @@ -61,6 +60,7 @@ public function getDefaultClass(array $data, array $flexconf, string $cTypeClass
$class .= ' m'.$marginSide.'-'.$data['tx_t3sbootstrap_margin_size'];
}
}

// Layout
if ($data['layout']) {
$pagesTSconfig = self::getFrontendController()->getPagesTSconfig();
Expand Down Expand Up @@ -173,19 +173,13 @@ public function getTxContainerClass(array $data, array $flexconf, bool $isVideo)
* Auto-layout row/column
*/
if ( $data['CType'] == 'autoLayout_row' ) {

if ( !empty($flexconf['horizontalGutters']) && $flexconf['horizontalGutters'] != 'gx-4') {
$class .= $flexconf['horizontalGutters'] ? ' '.$flexconf['horizontalGutters'] : '';
}

if (!empty($flexconf['verticalGutters'])) {

if ($flexconf['verticalGutters'] == 'gy-0') $flexconf['verticalGutters'] = 0;


$class .= !empty($flexconf['verticalGutters']) ? ' '.$flexconf['verticalGutters'] : '';
}

if (!empty($flexconf['responsiveVariations'])) {
$class .= !empty($flexconf['justify']) ? ' justify-content-'.$flexconf['responsiveVariations'].'-'.$flexconf['justify'] : '';
$class .= !empty($flexconf['alignItem']) ? ' align-items-'.$flexconf['responsiveVariations'].'-'.$flexconf['alignItem'] : '';
Expand Down
4 changes: 2 additions & 2 deletions Classes/Layouts/TwoColumns.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TwoColumns implements SingletonInterface
/**
* Returns the $processedData
*/
public function getProcessedData(array $processedData, array $flexconf, bool $webp=FALSE, string $bgMediaQueries='2560,1920,1200,992,768,576'): array
public function getProcessedData(array $processedData, array $flexconf, string $bgMediaQueries='2560,1920,1200,992,768,576'): array
{
$processedData = GeneralUtility::makeInstance(Gutters::class)->getGutters($processedData, $flexconf);
$processedData = GeneralUtility::makeInstance(Grid::class)->getGrid($processedData, $flexconf);
Expand All @@ -34,7 +34,7 @@ public function getProcessedData(array $processedData, array $flexconf, bool $we
if ( !empty($flexconf['bgimages']) ) {
$bgimages = GeneralUtility::makeInstance(BackgroundImageUtility::class)
->getBgImage($processedData['data']['uid'], 'tt_content', FALSE, FALSE,
$flexconf, FALSE, $processedData['data']['uid'], $webp,$bgMediaQueries);
$flexconf, FALSE, $processedData['data']['uid'], $bgMediaQueries);
if ($bgimages) {
$processedData['bgimages'] = $bgimages;
$processedData['bgimagePosition'] = $flexconf['bgimagePosition'];
Expand Down
26 changes: 18 additions & 8 deletions Classes/Utility/BackgroundImageUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use TYPO3\CMS\Extbase\Service\ImageService;
use TYPO3\CMS\Core\Page\AssetCollector;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\PathUtility;

/*
* This file is part of the TYPO3 extension t3sbootstrap.
Expand Down Expand Up @@ -44,7 +46,6 @@ public function getBgImage(
array $flexconf=[],
bool $body=FALSE,
int $currentUid=0,
bool $webp=FALSE,
string $bgMediaQueries='2560,1920,1200,992,768,576'
)
{
Expand All @@ -60,6 +61,10 @@ public function getBgImage(
}

$css = '';
$webp = false;
if ( ExtensionManagementUtility::isLoaded('webp') ) {
$webp = true;
}

if ( count($filesFromRepository) > 1 && $body == FALSE ) {

Expand All @@ -69,8 +74,9 @@ public function getBgImage(
$file = $filesFromRepository[0];
$image = $this->imageService->getImage($file->getOriginalFile()->getUid(), $file->getOriginalFile(), 1);
$bgImages = $this->generateSrcsetImages($file, $image);
$imageUri_mobile = $bgImages[576];
$imageUri_mobile = $webp ? $bgImages[576].'.webp' : $bgImages[576];
$css .= $this->generateCss('s'.$uid.'-'.$flexconf['bgimagePosition'], $file, $image, $webp, $flexconf, FALSE, $bgMediaQueries);
$css .= $this->generateCss('s'.$uid.'-'.$flexconf['bgimagePosition'], $file, $image, $flexconf, FALSE, $bgMediaQueries);

} else {
// slider in jumbotron or two bg-images in two-columns
Expand All @@ -82,7 +88,7 @@ public function getBgImage(
$image[$fileKey] = $this->imageService->getImage((string)$file->getOriginalFile()->getUid(), $file->getOriginalFile(), true);
$bgImages[$fileKey] = $this->generateSrcsetImages($file, $image[$fileKey]);
$imageUri_mobile[$fileKey] = $webp ? $bgImages[$fileKey][576].'.webp' : $bgImages[$fileKey][576];
$css .= $this->generateCss('s'.$uid.'-'.$fileKey, $file, $image[$fileKey], $webp, $flexconf, FALSE, $bgMediaQueries);
$css .= $this->generateCss('s'.$uid.'-'.$fileKey, $file, $image[$fileKey], $flexconf, FALSE, $bgMediaQueries);
}
}
} else {
Expand All @@ -95,9 +101,9 @@ public function getBgImage(
$uid = $uid . '-' . $flexconf['bgimagePosition'];
}
if ($jumbotron) {
$css = $this->generateCss('s'.$uid, $file, $image, $webp, $flexconf, FALSE, $bgMediaQueries);
$css = $this->generateCss('s'.$uid, $file, $image, $flexconf, FALSE, $bgMediaQueries);
} elseif ($body) {
$css = $this->generateCss('page-'.$uid, $file, $image, $webp, $flexconf, TRUE, $bgMediaQueries);
$css = $this->generateCss('page-'.$uid, $file, $image, $flexconf, TRUE, $bgMediaQueries);
} else {
if ( !empty($flexconf['enableAutoheight']) ) {
if ( $flexconf['addHeight'] ) {
Expand All @@ -106,9 +112,9 @@ public function getBgImage(
GeneralUtility::makeInstance(AssetCollector::class)
->addInlineJavaScript('addheight-'.$uid, $inline);
}
$css = $this->generateCss('bg-img-'.$uid, $file, $image, $webp, $flexconf, FALSE, $bgMediaQueries);
$css = $this->generateCss('bg-img-'.$uid, $file, $image, $flexconf, FALSE, $bgMediaQueries);
} else {
$css = $this->generateCss('s'.$uid, $file, $image, $webp, $flexconf, FALSE, $bgMediaQueries);
$css = $this->generateCss('s'.$uid, $file, $image, $flexconf, FALSE, $bgMediaQueries);
}
}
$bgImages = $this->generateSrcsetImages($file, $image);
Expand Down Expand Up @@ -143,7 +149,6 @@ private function generateCss(
string $uid,
FileReference $file,
File $image,
bool $webp,
array $flexconf=[],
bool $body=FALSE,
string $bgMediaQueries='2560,1920,1200,992,768,576'
Expand All @@ -153,6 +158,11 @@ private function generateCss(
$processingInstructions = ['crop' => $file instanceof FileReference ? $file->getReferenceProperty('crop') : null];
$cropVariantCollection = CropVariantCollection::create((string) $processingInstructions['crop']);

$webp = false;
if ( ExtensionManagementUtility::isLoaded('webp') ) {
$webp = true;
}

$css = '';
$mediaQueries = explode(',', $bgMediaQueries);
$minWidth = (int)$mediaQueries[0];
Expand Down
19 changes: 1 addition & 18 deletions Classes/Utility/ResponsiveImagesUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public function createPictureTag(
$fallbackTag = $fallbackTag ?: GeneralUtility::makeInstance(TagBuilder::class, 'img');

$settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
$webpIsLoaded = (bool)$settings['page.']['10.']['settings.']['webp'];

// Deal with file formats that can't be cropped separately
if ($this->hasIgnoredFileExtension($originalImage, $ignoreFileExtensions)) {
Expand Down Expand Up @@ -186,9 +185,6 @@ public function createPictureTag(
// Add metadata to fallback image
$this->addMetadataToImageTag($fallbackTag, $originalImage, $fallbackImage, $focusArea);

if ( $webpIsLoaded ) {
$types[0] = 'image/webp';
}
$types[1] = $originalImage->getProperties()['mime_type'];

// Generate source tags for image breakpoints
Expand All @@ -207,7 +203,6 @@ public function createPictureTag(
$cropArea,
$absoluteUri,
$lazyload,
$webpIsLoaded,
$type
);

Expand All @@ -234,7 +229,6 @@ public function createPictureTag(
* @param Area $cropArea
* @param bool $absoluteUri
* @param int $lazyload
* @param bool $webpIsLoaded
* @param string $type
*
* @return TagBuilder
Expand All @@ -248,13 +242,12 @@ public function createPictureSourceTag(
Area $cropArea = null,
bool $absoluteUri = false,
int $lazyload = 0,
bool $webpIsLoaded = false,
string $type = ''
): TagBuilder {
$cropArea = $cropArea ?: Area::createEmpty();

// Generate different image sizes for srcset attribute
$srcsetImages = $this->generateSrcsetImages($originalImage, $defaultWidth, $srcset, $cropArea, $absoluteUri, $webpIsLoaded, $type);
$srcsetImages = $this->generateSrcsetImages($originalImage, $defaultWidth, $srcset, $cropArea, $absoluteUri, $type);
$srcsetMode = substr(key($srcsetImages), -1); // x or w

// Create source tag for this breakpoint
Expand All @@ -271,9 +264,6 @@ public function createPictureSourceTag(
$sourceTag->addAttribute('sizes', sprintf($sizesQuery, $defaultWidth));
}

if ($webpIsLoaded && $type == 'image/webp')
$sourceTag->addAttribute('type', $type);

return $sourceTag;
}

Expand Down Expand Up @@ -384,7 +374,6 @@ public function addMetadataToImageTag(
* @param array|string $srcset
* @param Area $cropArea
* @param bool $absoluteUri
* @param bool $webpIsLoaded
* @param string $type
*
* @return array
Expand All @@ -395,7 +384,6 @@ public function generateSrcsetImages(
$srcset,
Area $cropArea = null,
bool $absoluteUri = false,
bool $webpIsLoaded = false,
string $type = ''
): array {
$cropArea = $cropArea ?: Area::createEmpty();
Expand Down Expand Up @@ -432,11 +420,6 @@ public function generateSrcsetImages(
];
$processedImage = $this->imageService->applyProcessingInstructions($image, $processingInstructions);

if ( $webpIsLoaded && $type == 'image/webp' ) {
$webpIdentifier = $processedImage->getIdentifier().'.webp';
$processedImage->setIdentifier($webpIdentifier);
}

// If processed file isn't as wide as it should be ([GFX][processor_allowUpscaling] set to false)
// then use final width of the image as widthDescriptor if not input case 3 is used
$processedWidth = $processedImage->getProperty('width');
Expand Down
7 changes: 0 additions & 7 deletions Classes/ViewHelpers/MediaViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ public function initializeArguments()
$this->registerArgument('loading', 'string', 'Native lazy-loading for images property. Can be "lazy", "eager" or "auto". Used on image files only.');
$this->registerArgument('decoding', 'string', 'Provides an image decoding hint to the browser. Can be "sync", "async" or "auto"', false);

# end new

$this->registerArgument('srcset', 'mixed', 'Image sizes that should be rendered.', false);
$this->registerArgument(
'sizes',
Expand Down Expand Up @@ -351,12 +349,7 @@ protected function renderImageTag(FileInterface $image, $width, $height, $fileEx
$processedImage = $imageService->applyProcessingInstructions($image, $processingInstructions);

$settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
$webpIsLoaded = (bool)$settings['page.']['10.']['settings.']['webp'];

if ( $webpIsLoaded ) {
$webpIdentifier = $processedImage->getIdentifier().'.webp';
$processedImage->setIdentifier($webpIdentifier);
}
$imageUri = $imageService->getImageUri($processedImage);

if (!$this->tag->hasAttribute('data-focus-area')) {
Expand Down
Loading

0 comments on commit 148f07f

Please sign in to comment.