diff --git a/Classes/DataProcessing/ResponsiveImagesProcessor.php b/Classes/DataProcessing/ResponsiveImagesProcessor.php index fdb38ba..0d4dc8b 100644 --- a/Classes/DataProcessing/ResponsiveImagesProcessor.php +++ b/Classes/DataProcessing/ResponsiveImagesProcessor.php @@ -25,9 +25,7 @@ use Codappix\ResponsiveImages\Configuration\ConfigurationManager; use Codappix\ResponsiveImages\Sizes\Breakpoint; -use Codappix\ResponsiveImages\Sizes\Multiplier; use Codappix\ResponsiveImages\Sizes\Rootline; -use TYPO3\CMS\Core\Error\Exception; use TYPO3\CMS\Core\Resource\FileInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; @@ -37,11 +35,6 @@ final class ResponsiveImagesProcessor implements DataProcessorInterface { private readonly ConfigurationManager $configurationManager; - /** - * The processor configuration - */ - private array $processorConfiguration; - /** * @var FileInterface[] */ @@ -49,12 +42,8 @@ final class ResponsiveImagesProcessor implements DataProcessorInterface private array $calculatedFiles = []; - private array $contentElementData = []; - private array $contentElementSizes = []; - private array $contentElementFieldConfiguration = []; - public function __construct() { $this->configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class); @@ -69,14 +58,17 @@ public function process( if (isset($processorConfiguration['if.']) && !$cObj->checkIf($processorConfiguration['if.'])) { return $processedData; } - $this->processorConfiguration = $processorConfiguration; - $this->contentElementData = $processedData['data']; $filesDataKey = (string) $cObj->stdWrapValue( 'filesDataKey', $processorConfiguration, 'files' ); + $fieldName = (string) $cObj->stdWrapValue( + 'fieldName', + $processorConfiguration, + 'image' + ); if (isset($processedData[$filesDataKey]) && is_array($processedData[$filesDataKey])) { $this->files = $processedData[$filesDataKey]; } else { @@ -84,8 +76,7 @@ public function process( return $processedData; } - $this->contentElementSizes = (new Rootline($processedData['data']))->getFinalSizes(); - $this->fetchContentElementFieldConfiguration(); + $this->contentElementSizes = (new Rootline($processedData['data'], $fieldName))->getFinalSizes(); $this->calculateFileDimensions(); $targetFieldName = (string) $cObj->stdWrapValue( @@ -99,23 +90,6 @@ public function process( return $processedData; } - private function fetchContentElementFieldConfiguration(): void - { - $contentElementFieldPath = implode('.', [ - 'contentelements', - $this->contentElementData['CType'], - $this->processorConfiguration['fieldName'], - ]); - - if ($this->configurationManager->isValidPath($contentElementFieldPath) === false) { - throw new Exception("Field configuration '" . $contentElementFieldPath . "' missing."); - } - - if (is_array($this->configurationManager->getByPath($contentElementFieldPath))) { - $this->contentElementFieldConfiguration = $this->configurationManager->getByPath($contentElementFieldPath); - } - } - private function calculateFileDimensions(): void { foreach ($this->files as $file) { @@ -131,7 +105,6 @@ private function calculateFileDimensions(): void private function calculateFileDimensionForBreakpoints(): array { $fileDimensions = []; - $fieldConfiguration = $this->contentElementFieldConfiguration; $breakpoints = $this->getBreakpoints(); @@ -141,27 +114,10 @@ private function calculateFileDimensionForBreakpoints(): array continue; } - $contentElementSize = $this->contentElementSizes[$breakpoint->getIdentifier()]; $fileDimensions[$breakpoint->getIdentifier()] = [ 'breakpoint' => $breakpoint, + 'size' => $this->contentElementSizes[$breakpoint->getIdentifier()], ]; - - if (isset($fieldConfiguration['multiplier'])) { - $fileDimensions[$breakpoint->getIdentifier()]['size'] = $contentElementSize - * Multiplier::parse( - $fieldConfiguration['multiplier'][$breakpoint->getIdentifier()] - ); - - continue; - } - - if (isset($fieldConfiguration['sizes'])) { - $fileDimensions[$breakpoint->getIdentifier()]['size'] = Multiplier::parse( - $fieldConfiguration['sizes'][$breakpoint->getIdentifier()] - ); - - continue; - } } return $fileDimensions; diff --git a/Classes/Sizes/AbstractContentElement.php b/Classes/Sizes/AbstractContentElement.php new file mode 100644 index 0000000..71330e0 --- /dev/null +++ b/Classes/Sizes/AbstractContentElement.php @@ -0,0 +1,87 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Codappix\ResponsiveImages\Configuration\ConfigurationManager; +use Exception; +use TYPO3\CMS\Core\Utility\GeneralUtility; + +abstract class AbstractContentElement implements ContentElementInterface +{ + protected ConfigurationManager $configurationManager; + + protected int $colPos; + + protected string $contentType; + + protected array $data; + + protected ContentElementInterface $parent; + + public function __construct(array $data) + { + $this->configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class); + + $this->contentType = $data['CType']; + $this->colPos = $data['colPos']; + $this->data = $data; + } + + public function getData(?string $dataIdentifier = null): mixed + { + if ($dataIdentifier === null) { + return $this->data; + } + + if (isset($this->data[$dataIdentifier]) === false) { + throw new Exception('No data found for key ' . $dataIdentifier . ' in $this->data.'); + } + + return $this->data[$dataIdentifier]; + } + + public function getColPos(): int + { + return $this->colPos; + } + + public function getContentType(): string + { + return $this->contentType; + } + + public function getParent(): ?ContentElementInterface + { + return $this->parent; + } + + public function setParent(ContentElementInterface $contentElement): void + { + if ($contentElement instanceof Container) { + $contentElement->setActiveColumn($contentElement->getColumn($this->colPos)); + } + + $this->parent = $contentElement; + } +} diff --git a/Classes/Sizes/BackendLayout/Column.php b/Classes/Sizes/BackendLayout/Column.php index 8145b33..5fdccce 100644 --- a/Classes/Sizes/BackendLayout/Column.php +++ b/Classes/Sizes/BackendLayout/Column.php @@ -30,13 +30,24 @@ class Column /** * @var float[] */ - private readonly array $multiplier; + private array $multiplier = []; + + /** + * @var int[] + */ + private array $sizes = []; public function __construct( private readonly int $identifier, array $data ) { - $this->multiplier = array_map(static fn ($multiplier): float => Multiplier::parse($multiplier), $data['multiplier']); + if (isset($data['multiplier'])) { + $this->multiplier = array_map(static fn ($multiplier): float => Multiplier::parse($multiplier), $data['multiplier']); + } + + if (isset($data['sizes'])) { + $this->sizes = array_map(static fn ($size): int => (int) $size, $data['sizes']); + } } public function getIdentifier(): int @@ -51,4 +62,12 @@ public function getMultiplier(): array { return $this->multiplier; } + + /** + * @return int[] + */ + public function getSizes(): array + { + return $this->sizes; + } } diff --git a/Classes/Sizes/Container.php b/Classes/Sizes/Container.php index 642eb8a..3d7e590 100644 --- a/Classes/Sizes/Container.php +++ b/Classes/Sizes/Container.php @@ -23,28 +23,18 @@ * 02110-1301, USA. */ -use Codappix\ResponsiveImages\Configuration\ConfigurationManager; use Codappix\ResponsiveImages\Sizes\BackendLayout\Column; -use TYPO3\CMS\Core\Utility\GeneralUtility; -final class Container extends ContentElement +final class Container extends AbstractContentElement { - private readonly string $layout; - private array $columns = []; private Column $activeColumn; - private readonly ConfigurationManager $configurationManager; - public function __construct(array $data) { parent::__construct($data); - $this->layout = $data['CType']; - - $this->configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class); - $this->determineColumns(); } @@ -68,10 +58,27 @@ public function getActiveColumn(): Column return $this->activeColumn; } + /** + * @return float[] + */ + public function getMultiplier(): array + { + return $this->getActiveColumn()->getMultiplier(); + } + + /** + * @return int[] + */ + public function getSizes(): array + { + return $this->getActiveColumn()->getSizes(); + } + private function determineColumns(): void { $sizesPath = implode('.', [ - $this->layout, + 'container', + $this->contentType, 'columns', ]); diff --git a/Classes/Sizes/ContentElement.php b/Classes/Sizes/ContentElement.php index 7683de5..8d495ae 100644 --- a/Classes/Sizes/ContentElement.php +++ b/Classes/Sizes/ContentElement.php @@ -23,61 +23,55 @@ * 02110-1301, USA. */ -use TYPO3\CMS\Core\Error\Exception; - -/** - * This class represents the content elements in the rootline of the current - * content element which is rendered. - */ -class ContentElement implements ContentElementInterface +class ContentElement extends AbstractContentElement { - protected readonly string $contentType; + /** + * @var float[] + */ + private array $multiplier = []; - protected readonly int $colPos; - - protected ContentElementInterface $parent; + /** + * @var int[] + */ + private array $sizes = []; public function __construct( - private readonly array $data + array $data, + private readonly string $fieldName ) { - $this->contentType = $data['CType']; - $this->colPos = $data['colPos']; - } - - public function getData(?string $dataIdentifier = null): mixed - { - if ($dataIdentifier === null) { - return $this->data; - } + parent::__construct($data); - if (isset($this->data[$dataIdentifier]) === false) { - throw new Exception('No data found for key ' . $dataIdentifier . ' in $this->data.'); - } - - return $this->data[$dataIdentifier]; + $this->readConfiguration(); } - public function getContentType(): string + public function getSizes(): array { - return $this->contentType; + return $this->sizes; } - public function getColPos(): int + public function getMultiplier(): array { - return $this->colPos; + return $this->multiplier; } - public function setParent(ContentElementInterface $contentElement): void + public function readConfiguration(): void { - if ($contentElement instanceof Container) { - $contentElement->setActiveColumn($contentElement->getColumn($this->colPos)); + $configurationPath = implode('.', [ + 'contentelements', + $this->contentType, + $this->fieldName, + ]); + + $configuration = $this->configurationManager->getByPath($configurationPath); + + if (is_array($configuration)) { + if (isset($configuration['multiplier'])) { + $this->multiplier = array_map(static fn ($multiplier): float => Multiplier::parse($multiplier), $configuration['multiplier']); + } + + if (isset($configuration['sizes'])) { + $this->sizes = array_map(static fn ($size): int => (int) $size, $configuration['sizes']); + } } - - $this->parent = $contentElement; - } - - public function getParent(): ?ContentElementInterface - { - return $this->parent; } } diff --git a/Classes/Sizes/ContentElementInterface.php b/Classes/Sizes/ContentElementInterface.php index b931ca8..12842bb 100644 --- a/Classes/Sizes/ContentElementInterface.php +++ b/Classes/Sizes/ContentElementInterface.php @@ -10,8 +10,6 @@ */ interface ContentElementInterface { - public function __construct(array $data); - public function getData(?string $dataIdentifier = null): mixed; public function getContentType(): string; @@ -21,4 +19,8 @@ public function getColPos(): int; public function setParent(self $contentElement): void; public function getParent(): ?self; + + public function getSizes(): array; + + public function getMultiplier(): array; } diff --git a/Classes/Sizes/Rootline.php b/Classes/Sizes/Rootline.php index cf5613a..75dee48 100644 --- a/Classes/Sizes/Rootline.php +++ b/Classes/Sizes/Rootline.php @@ -42,9 +42,12 @@ final class Rootline private array $finalSizes = []; - public function __construct(array $data) + private string $fieldName; + + public function __construct(array $data, string $fieldName) { $this->determineBackendLayout(); + $this->fieldName = $fieldName; $this->contentElement = $this->determineContentElement($data); $this->determineRootline(); @@ -56,21 +59,6 @@ public function getFinalSizes(): array return $this->finalSizes; } - public function getMultiplier(): array - { - $multiplier = [ - $this->backendLayout->getActiveColumn()->getMultiplier(), - ]; - - foreach (array_reverse($this->rootline) as $contentElement) { - if ($contentElement instanceof Container) { - $multiplier[] = $contentElement->getActiveColumn()->getMultiplier(); - } - } - - return $multiplier; - } - private function determineBackendLayout(): void { $typoscriptFrontendController = $GLOBALS['TSFE']; @@ -91,7 +79,7 @@ class_exists(Registry::class) return new Container($data); } - return new ContentElement($data); + return new ContentElement($data, $this->fieldName); } private function determineRootline(): void @@ -148,10 +136,35 @@ private function fetchContentElementFromDatabase(int $identifier): ContentElemen private function calculateSizes(): void { - $sizes = $this->backendLayout->getSizes(); + [$sizes, $multiplier] = $this->getSizesAndMultiplierFromRootline(); - $multiplier = $this->getMultiplier(); + $this->calculateFinalSizes($sizes, $multiplier); + } + private function getSizesAndMultiplierFromRootline(): array + { + $multiplier = []; + $sizes = []; + + foreach ($this->rootline as $contentElement) { + if ($contentElement instanceof ContentElementInterface) { + $sizes = $contentElement->getSizes(); + if (!empty($sizes)) { + break; + } + $multiplier[] = $contentElement->getMultiplier(); + } + } + + if (empty($sizes)) { + $sizes = $this->backendLayout->getSizes(); + } + + return [$sizes, $multiplier]; + } + + private function calculateFinalSizes(array $sizes, array $multiplier): void + { foreach ($sizes as $sizeName => &$size) { foreach ($multiplier as $multiplierItem) { if (isset($multiplierItem[$sizeName]) === false) { diff --git a/Tests/Fixtures/base_example/Configuration/TypoScript/ContentElements/image.typoscript b/Tests/Fixtures/base_example/Configuration/TypoScript/ContentElements/image.typoscript index 3c2b33a..5a72e4f 100644 --- a/Tests/Fixtures/base_example/Configuration/TypoScript/ContentElements/image.typoscript +++ b/Tests/Fixtures/base_example/Configuration/TypoScript/ContentElements/image.typoscript @@ -26,7 +26,7 @@ plugin.tx_responsiveimages { sm = 1 md = 1 lg = 1 - xl = 1 + xl = 0.5 } } } diff --git a/Tests/Fixtures/base_example/Configuration/TypoScript/ContentElements/imageFixWidth.typoscript b/Tests/Fixtures/base_example/Configuration/TypoScript/ContentElements/imageFixWidth.typoscript new file mode 100644 index 0000000..7a353f9 --- /dev/null +++ b/Tests/Fixtures/base_example/Configuration/TypoScript/ContentElements/imageFixWidth.typoscript @@ -0,0 +1,36 @@ +tt_content.imageFixWidth < tt_content.image +tt_content.imageFixWidth { + templateRootPaths { + 110 = EXT:base_example/Resources/Private/Templates/FluidStyledContent + } + partialRootPaths { + 110 = EXT:base_example/Resources/Private/Partials/FluidStyledContent + } + + dataProcessing { + 20 > + 20 = Codappix\ResponsiveImages\DataProcessing\ResponsiveImagesProcessor + 20 { + fieldName = image + filesDataKey = files + } + } +} + +plugin.tx_responsiveimages { + settings { + contentelements { + imageFixWidth { + image { + sizes { + xs = 600 + sm = 900 + md = 1200 + lg = 1600 + xl = 1600 + } + } + } + } + } +} diff --git a/Tests/Fixtures/base_example/Test/Fixtures/0colImageFixWidthDatabase.php b/Tests/Fixtures/base_example/Test/Fixtures/0colImageFixWidthDatabase.php new file mode 100644 index 0000000..7912790 --- /dev/null +++ b/Tests/Fixtures/base_example/Test/Fixtures/0colImageFixWidthDatabase.php @@ -0,0 +1,32 @@ + [ + 1 => [ + 'uid' => '1', + 'pid' => '2', + 'hidden' => '0', + 'sorting' => '1', + 'CType' => 'imageFixWidth', + 'header' => 'imageFixWidth', + 'deleted' => '0', + 'starttime' => '0', + 'endtime' => '0', + 'colPos' => '0', + 'sys_language_uid' => '0', + 'image' => '1', + ], + ], + 'sys_file_reference' => [ + 0 => [ + 'uid' => '1', + 'pid' => '2', + 'uid_local' => '1', + 'uid_foreign' => '1', + 'tablenames' => 'tt_content', + 'fieldname' => 'image', + ], + ], +]; diff --git a/Tests/Fixtures/container_example/Configuration/TCA/Overrides/tt_content_container_1col_full_width.php b/Tests/Fixtures/container_example/Configuration/TCA/Overrides/tt_content_container_1col_full_width.php new file mode 100644 index 0000000..cb8e241 --- /dev/null +++ b/Tests/Fixtures/container_example/Configuration/TCA/Overrides/tt_content_container_1col_full_width.php @@ -0,0 +1,23 @@ +configureContainer(new ContainerConfiguration( + $cType, + '1 Column: 100', + '(100%)', + [ + [ + [ + 'name' => 'Column 101', + 'colPos' => 101, + ], + ], + ] + )); +})(); diff --git a/Tests/Fixtures/container_example/Configuration/TypoScript/Container/1col-full-witdh.typoscript b/Tests/Fixtures/container_example/Configuration/TypoScript/Container/1col-full-witdh.typoscript new file mode 100644 index 0000000..fde8aae --- /dev/null +++ b/Tests/Fixtures/container_example/Configuration/TypoScript/Container/1col-full-witdh.typoscript @@ -0,0 +1,24 @@ +plugin.tx_responsiveimages { + settings { + container { + example_container-1col-full-width { + columns { + 101 { + sizes { + xs = 1254 + sm = 1203 + md = 1578 + lg = 1920 + xl = 1920 + } + } + } + } + } + } +} + +tt_content.example_container-1col-full-width < lib.containerElement +tt_content.example_container-1col-full-width { + templateName = 1col +} diff --git a/Tests/Fixtures/container_example/Configuration/TypoScript/Container/1col.typoscript b/Tests/Fixtures/container_example/Configuration/TypoScript/Container/1col.typoscript index e77c473..6359bd0 100644 --- a/Tests/Fixtures/container_example/Configuration/TypoScript/Container/1col.typoscript +++ b/Tests/Fixtures/container_example/Configuration/TypoScript/Container/1col.typoscript @@ -1,14 +1,16 @@ plugin.tx_responsiveimages { settings { - example_container-1col { - columns { - 101 { - multiplier { - xs = 1 - sm = 1 - md = 1 - lg = 1 - xl = 1 + container { + example_container-1col { + columns { + 101 { + multiplier { + xs = 1 + sm = 1 + md = 1 + lg = 1 + xl = 1 + } } } } diff --git a/Tests/Fixtures/container_example/Configuration/TypoScript/Container/2col-33-66.typoscript b/Tests/Fixtures/container_example/Configuration/TypoScript/Container/2col-33-66.typoscript index 233ecad..789c1d7 100644 --- a/Tests/Fixtures/container_example/Configuration/TypoScript/Container/2col-33-66.typoscript +++ b/Tests/Fixtures/container_example/Configuration/TypoScript/Container/2col-33-66.typoscript @@ -1,24 +1,26 @@ plugin.tx_responsiveimages { settings { - example_container-2col-33-66 { - columns { - 101 { - multiplier { - xs = 1 - sm = 1 - md = 0,333 - lg = 0,333 - xl = 0,333 + container { + example_container-2col-33-66 { + columns { + 101 { + multiplier { + xs = 1 + sm = 1 + md = 0,333 + lg = 0,333 + xl = 0,333 + } } - } - 102 { - multiplier { - xs = 1 - sm = 1 - md = 0,666 - lg = 0,666 - xl = 0,666 + 102 { + multiplier { + xs = 1 + sm = 1 + md = 0,666 + lg = 0,666 + xl = 0,666 + } } } } diff --git a/Tests/Fixtures/container_example/Configuration/TypoScript/Container/2col-50-50.typoscript b/Tests/Fixtures/container_example/Configuration/TypoScript/Container/2col-50-50.typoscript index 451eb67..33a760c 100644 --- a/Tests/Fixtures/container_example/Configuration/TypoScript/Container/2col-50-50.typoscript +++ b/Tests/Fixtures/container_example/Configuration/TypoScript/Container/2col-50-50.typoscript @@ -1,24 +1,26 @@ plugin.tx_responsiveimages { settings { - example_container-2col-50-50 { - columns { - 101 { - multiplier { - xs = 1 - sm = 1 - md = 0,5 - lg = 0,5 - xl = 0,5 + container { + example_container-2col-50-50 { + columns { + 101 { + multiplier { + xs = 1 + sm = 1 + md = 0,5 + lg = 0,5 + xl = 0,5 + } } - } - 102 { - multiplier { - xs = 1 - sm = 1 - md = 0,5 - lg = 0,5 - xl = 0,5 + 102 { + multiplier { + xs = 1 + sm = 1 + md = 0,5 + lg = 0,5 + xl = 0,5 + } } } } diff --git a/Tests/Fixtures/container_example/Configuration/TypoScript/Container/2col-66-33.typoscript b/Tests/Fixtures/container_example/Configuration/TypoScript/Container/2col-66-33.typoscript index 68375a5..4266f20 100644 --- a/Tests/Fixtures/container_example/Configuration/TypoScript/Container/2col-66-33.typoscript +++ b/Tests/Fixtures/container_example/Configuration/TypoScript/Container/2col-66-33.typoscript @@ -1,24 +1,26 @@ plugin.tx_responsiveimages { settings { - example_container-2col-66-33 { - columns { - 101 { - multiplier { - xs = 1 - sm = 1 - md = 0,666 - lg = 0,666 - xl = 0,666 + container { + example_container-2col-66-33 { + columns { + 101 { + multiplier { + xs = 1 + sm = 1 + md = 0,666 + lg = 0,666 + xl = 0,666 + } } - } - 102 { - multiplier { - xs = 1 - sm = 1 - md = 0,333 - lg = 0,333 - xl = 0,333 + 102 { + multiplier { + xs = 1 + sm = 1 + md = 0,333 + lg = 0,333 + xl = 0,333 + } } } } diff --git a/Tests/Fixtures/container_example/Configuration/TypoScript/Container/3col.typoscript b/Tests/Fixtures/container_example/Configuration/TypoScript/Container/3col.typoscript index 9cf6190..2a283ea 100644 --- a/Tests/Fixtures/container_example/Configuration/TypoScript/Container/3col.typoscript +++ b/Tests/Fixtures/container_example/Configuration/TypoScript/Container/3col.typoscript @@ -1,34 +1,36 @@ plugin.tx_responsiveimages { settings { - example_container-3col { - columns { - 101 { - multiplier { - xs = 1 - sm = 1 - md = 0,333 - lg = 0,333 - xl = 0,333 + container { + example_container-3col { + columns { + 101 { + multiplier { + xs = 1 + sm = 1 + md = 0,333 + lg = 0,333 + xl = 0,333 + } } - } - 102 { - multiplier { - xs = 1 - sm = 1 - md = 0,333 - lg = 0,333 - xl = 0,333 + 102 { + multiplier { + xs = 1 + sm = 1 + md = 0,333 + lg = 0,333 + xl = 0,333 + } } - } - 103 { - multiplier { - xs = 1 - sm = 1 - md = 0,333 - lg = 0,333 - xl = 0,333 + 103 { + multiplier { + xs = 1 + sm = 1 + md = 0,333 + lg = 0,333 + xl = 0,333 + } } } } diff --git a/Tests/Fixtures/container_example/Test/Fixtures/0colImageFixWidthDatabase.php b/Tests/Fixtures/container_example/Test/Fixtures/0colImageFixWidthDatabase.php new file mode 100644 index 0000000..5503ce6 --- /dev/null +++ b/Tests/Fixtures/container_example/Test/Fixtures/0colImageFixWidthDatabase.php @@ -0,0 +1,33 @@ + [ + 1 => [ + 'uid' => '1', + 'pid' => '2', + 'hidden' => '0', + 'sorting' => '1', + 'CType' => 'imageFixWidth', + 'header' => 'imageFixWidth', + 'deleted' => '0', + 'starttime' => '0', + 'endtime' => '0', + 'colPos' => '0', + 'sys_language_uid' => '0', + 'image' => '1', + 'tx_container_parent' => '0', + ], + ], + 'sys_file_reference' => [ + 0 => [ + 'uid' => '1', + 'pid' => '2', + 'uid_local' => '1', + 'uid_foreign' => '1', + 'tablenames' => 'tt_content', + 'fieldname' => 'image', + ], + ], +]; diff --git a/Tests/Fixtures/container_example/Test/Fixtures/1col2colFullWidthDatabase.php b/Tests/Fixtures/container_example/Test/Fixtures/1col2colFullWidthDatabase.php new file mode 100644 index 0000000..f194339 --- /dev/null +++ b/Tests/Fixtures/container_example/Test/Fixtures/1col2colFullWidthDatabase.php @@ -0,0 +1,61 @@ + [ + 0 => [ + 'uid' => '1', + 'pid' => '2', + 'hidden' => '0', + 'sorting' => '1', + 'CType' => 'example_container-1col-full-width', + 'header' => '1col', + 'deleted' => '0', + 'starttime' => '0', + 'endtime' => '0', + 'colPos' => '0', + 'sys_language_uid' => '0', + 'tx_container_parent' => '0', + ], + 1 => [ + 'uid' => '2', + 'pid' => '2', + 'hidden' => '0', + 'sorting' => '1', + 'CType' => 'example_container-2col-50-50', + 'header' => '2col in 2col', + 'deleted' => '0', + 'starttime' => '0', + 'endtime' => '0', + 'colPos' => '101', + 'sys_language_uid' => '0', + 'tx_container_parent' => '1', + ], + 2 => [ + 'uid' => '3', + 'pid' => '2', + 'hidden' => '0', + 'sorting' => '1', + 'CType' => 'image', + 'header' => 'image in 2col in 1col', + 'deleted' => '0', + 'starttime' => '0', + 'endtime' => '0', + 'colPos' => '102', + 'sys_language_uid' => '0', + 'image' => '1', + 'tx_container_parent' => '2', + ], + ], + 'sys_file_reference' => [ + 0 => [ + 'uid' => '1', + 'pid' => '2', + 'uid_local' => '1', + 'uid_foreign' => '3', + 'tablenames' => 'tt_content', + 'fieldname' => 'image', + ], + ], +]; diff --git a/Tests/Fixtures/container_example/Test/Fixtures/1colFullWidthDatabase.php b/Tests/Fixtures/container_example/Test/Fixtures/1colFullWidthDatabase.php new file mode 100644 index 0000000..1f608a5 --- /dev/null +++ b/Tests/Fixtures/container_example/Test/Fixtures/1colFullWidthDatabase.php @@ -0,0 +1,47 @@ + [ + 0 => [ + 'uid' => '1', + 'pid' => '2', + 'hidden' => '0', + 'sorting' => '1', + 'CType' => 'example_container-1col-full-width', + 'header' => '1col', + 'deleted' => '0', + 'starttime' => '0', + 'endtime' => '0', + 'colPos' => '0', + 'sys_language_uid' => '0', + 'tx_container_parent' => '0', + ], + 1 => [ + 'uid' => '2', + 'pid' => '2', + 'hidden' => '0', + 'sorting' => '1', + 'CType' => 'image', + 'header' => 'image in 1col', + 'deleted' => '0', + 'starttime' => '0', + 'endtime' => '0', + 'colPos' => '101', + 'sys_language_uid' => '0', + 'image' => '1', + 'tx_container_parent' => '1', + ], + ], + 'sys_file_reference' => [ + 0 => [ + 'uid' => '1', + 'pid' => '2', + 'uid_local' => '1', + 'uid_foreign' => '2', + 'tablenames' => 'tt_content', + 'fieldname' => 'image', + ], + ], +]; diff --git a/Tests/Fixtures/container_example/Test/Fixtures/3colImageFixWidthDatabase.php b/Tests/Fixtures/container_example/Test/Fixtures/3colImageFixWidthDatabase.php new file mode 100644 index 0000000..5167e74 --- /dev/null +++ b/Tests/Fixtures/container_example/Test/Fixtures/3colImageFixWidthDatabase.php @@ -0,0 +1,47 @@ + [ + 0 => [ + 'uid' => '1', + 'pid' => '2', + 'hidden' => '0', + 'sorting' => '1', + 'CType' => 'example_container-3col', + 'header' => '3col', + 'deleted' => '0', + 'starttime' => '0', + 'endtime' => '0', + 'colPos' => '0', + 'sys_language_uid' => '0', + 'tx_container_parent' => '0', + ], + 1 => [ + 'uid' => '2', + 'pid' => '2', + 'hidden' => '0', + 'sorting' => '1', + 'CType' => 'imageFixWidth', + 'header' => 'imageFixWidth in 3col', + 'deleted' => '0', + 'starttime' => '0', + 'endtime' => '0', + 'colPos' => '101', + 'sys_language_uid' => '0', + 'image' => '1', + 'tx_container_parent' => '1', + ], + ], + 'sys_file_reference' => [ + 0 => [ + 'uid' => '1', + 'pid' => '2', + 'uid_local' => '1', + 'uid_foreign' => '2', + 'tablenames' => 'tt_content', + 'fieldname' => 'image', + ], + ], +]; diff --git a/Tests/Functional/BaseTest.php b/Tests/Functional/BaseTest.php index 6177aae..dcc5177 100644 --- a/Tests/Functional/BaseTest.php +++ b/Tests/Functional/BaseTest.php @@ -69,7 +69,17 @@ public static function imageScalingValuesDataProvider(): iterable '1' => 'mobile 704 (max-width: 767px)', '2' => 'tablet 924 (max-width: 991px)', '3' => 'default 1124 (max-width: 1479px)', - '4' => 'large 1124 (min-width: 1480px)', + '4' => 'large 562 (min-width: 1480px)', + ], + ]; + yield '0 Column with ImageFixWidth' => [ + '0colImageFixWidthDatabase.php', + [ + '0' => 'mobile 600 (max-width: 480px)', + '1' => 'mobile 900 (max-width: 767px)', + '2' => 'tablet 1200 (max-width: 991px)', + '3' => 'default 1600 (max-width: 1479px)', + '4' => 'large 1600 (min-width: 1480px)', ], ]; } diff --git a/Tests/Functional/ContainerTest.php b/Tests/Functional/ContainerTest.php index abc56ef..93e0f91 100644 --- a/Tests/Functional/ContainerTest.php +++ b/Tests/Functional/ContainerTest.php @@ -72,7 +72,7 @@ public static function imageScalingValuesDataProvider(): iterable '1' => 'mobile 704 (max-width: 767px)', '2' => 'tablet 924 (max-width: 991px)', '3' => 'default 1124 (max-width: 1479px)', - '4' => 'large 1124 (min-width: 1480px)', + '4' => 'large 562 (min-width: 1480px)', ], ]; yield '1 Column' => [ @@ -82,7 +82,7 @@ public static function imageScalingValuesDataProvider(): iterable '1' => 'mobile 704 (max-width: 767px)', '2' => 'tablet 924 (max-width: 991px)', '3' => 'default 1124 (max-width: 1479px)', - '4' => 'large 1124 (min-width: 1480px)', + '4' => 'large 562 (min-width: 1480px)', ], ]; yield '2 Column 50-50' => [ @@ -92,7 +92,7 @@ public static function imageScalingValuesDataProvider(): iterable '1' => 'mobile 704 (max-width: 767px)', '2' => 'tablet 462 (max-width: 991px)', '3' => 'default 562 (max-width: 1479px)', - '4' => 'large 562 (min-width: 1480px)', + '4' => 'large 281 (min-width: 1480px)', ], ]; yield '2 Column 66-33' => [ @@ -102,7 +102,7 @@ public static function imageScalingValuesDataProvider(): iterable '1' => 'mobile 704 (max-width: 767px)', '2' => 'tablet 615.384 (max-width: 991px)', '3' => 'default 748.584 (max-width: 1479px)', - '4' => 'large 748.584 (min-width: 1480px)', + '4' => 'large 374.292 (min-width: 1480px)', ], ]; yield '2 Column in 1 Column' => [ @@ -112,7 +112,7 @@ public static function imageScalingValuesDataProvider(): iterable '1' => 'mobile 704 (max-width: 767px)', '2' => 'tablet 462 (max-width: 991px)', '3' => 'default 562 (max-width: 1479px)', - '4' => 'large 562 (min-width: 1480px)', + '4' => 'large 281 (min-width: 1480px)', ], ]; yield '2 Column in 2 Column' => [ @@ -122,7 +122,7 @@ public static function imageScalingValuesDataProvider(): iterable '1' => 'mobile 704 (max-width: 767px)', '2' => 'tablet 231 (max-width: 991px)', '3' => 'default 281 (max-width: 1479px)', - '4' => 'large 281 (min-width: 1480px)', + '4' => 'large 140.5 (min-width: 1480px)', ], ]; yield '3 Column' => [ @@ -132,7 +132,47 @@ public static function imageScalingValuesDataProvider(): iterable '1' => 'mobile 704 (max-width: 767px)', '2' => 'tablet 307.692 (max-width: 991px)', '3' => 'default 374.292 (max-width: 1479px)', - '4' => 'large 374.292 (min-width: 1480px)', + '4' => 'large 187.146 (min-width: 1480px)', + ], + ]; + yield '1 Column Full Width' => [ + '1colFullWidthDatabase.php', + [ + '0' => 'mobile 1254 (max-width: 480px)', + '1' => 'mobile 1203 (max-width: 767px)', + '2' => 'tablet 1578 (max-width: 991px)', + '3' => 'default 1920 (max-width: 1479px)', + '4' => 'large 960 (min-width: 1480px)', + ], + ]; + yield '2 Column in 1 Column Full Width' => [ + '1col2colFullWidthDatabase.php', + [ + '0' => 'mobile 1254 (max-width: 480px)', + '1' => 'mobile 1203 (max-width: 767px)', + '2' => 'tablet 789 (max-width: 991px)', + '3' => 'default 960 (max-width: 1479px)', + '4' => 'large 480 (min-width: 1480px)', + ], + ]; + yield '0 Column with ImageFixWidth' => [ + '0colImageFixWidthDatabase.php', + [ + '0' => 'mobile 600 (max-width: 480px)', + '1' => 'mobile 900 (max-width: 767px)', + '2' => 'tablet 1200 (max-width: 991px)', + '3' => 'default 1600 (max-width: 1479px)', + '4' => 'large 1600 (min-width: 1480px)', + ], + ]; + yield '3 Column with ImageFixWidth' => [ + '3colImageFixWidthDatabase.php', + [ + '0' => 'mobile 600 (max-width: 480px)', + '1' => 'mobile 900 (max-width: 767px)', + '2' => 'tablet 1200 (max-width: 991px)', + '3' => 'default 1600 (max-width: 1479px)', + '4' => 'large 1600 (min-width: 1480px)', ], ]; }