‪TYPO3CMS  ‪main
TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor Class Reference
Inheritance diagram for TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor:
TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface

Public Member Functions

array process (ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData)
 

Protected Member Functions

string getConfigurationValue ($key, $dataArrayKey=null)
 
 determineGalleryPosition ()
 
 determineMaximumGalleryWidth ()
 
 calculateRowsAndColumns ()
 
 calculateMediaWidthsAndHeights ()
 
int getCroppedDimensionalProperty (FileInterface $fileObject, $dimensionalProperty)
 
 prepareGalleryData ()
 

Protected Attributes

TYPO3 CMS Frontend ContentObject ContentObjectRenderer $contentObjectRenderer
 
array $processorConfiguration
 
array $availableGalleryPositions
 
array $galleryData
 
int $numberOfColumns
 
int $mediaOrientation
 
int $maxGalleryWidth
 
int $maxGalleryWidthInText
 
int $equalMediaHeight
 
int $equalMediaWidth
 
int $columnSpacing
 
bool $borderEnabled
 
int $borderWidth
 
int $borderPadding
 
string $cropVariant = 'default'
 
FileInterface[] $fileObjects = array( )
 
array $mediaDimensions = array( )
 

Detailed Description

This data processor will calculate rows, columns and dimensions for a gallery based on several settings and can be used for f.i. the CType "textmedia"

The output will be an array which contains the rows and columns, including the file references and the calculated width and height for each media element, but also some more information of the gallery, like position, width and counters

Example TypoScript configuration:

10 = TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor 10 { filesProcessedDataKey = files mediaOrientation.field = imageorient numberOfColumns.field = imagecols equalMediaHeight.field = imageheight equalMediaWidth.field = imagewidth columnSpacing = 0 borderEnabled.field = imageborder borderPadding = 0 borderWidth = 0 maxGalleryWidth = {$styles.content.mediatext.maxW} maxGalleryWidthInText = {$styles.content.mediatext.maxWInText} as = gallery }

Output example:

gallery { position { horizontal = center vertical = above noWrap = FALSE } width = 600 count { files = 2 columns = 1 rows = 2 } rows { 1 { columns { 1 { media = TYPO3\CMS\Core\Resource\FileReference dimensions { width = 600 height = 400 } } } } 2 { columns { 1 { media = TYPO3\CMS\Core\Resource\FileReference dimensions { width = 600 height = 400 } } } } } columnSpacing = 0 border { enabled = FALSE width = 0 padding = 0 } }

Definition at line 96 of file GalleryProcessor.php.

Member Function Documentation

◆ calculateMediaWidthsAndHeights()

TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::calculateMediaWidthsAndHeights ( )
protected

Calculate the width/height of the media elements

Based on the width of the gallery, defined equal width or height by a user, the spacing between columns and the use of a border, defined by user, where the border width and padding are taken into account

File objects MUST already be filtered. They need a height and width to be shown in the gallery

Definition at line 360 of file GalleryProcessor.php.

References TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor\$equalMediaWidth, and TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor\getCroppedDimensionalProperty().

Referenced by TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor\process().

◆ calculateRowsAndColumns()

TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::calculateRowsAndColumns ( )
protected

Calculate the amount of rows and columns

Definition at line 331 of file GalleryProcessor.php.

Referenced by TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor\process().

◆ determineGalleryPosition()

TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::determineGalleryPosition ( )
protected

Define the gallery position

Gallery has a horizontal and a vertical position towards the text and a possible wrapping of the text around the gallery.

Definition at line 301 of file GalleryProcessor.php.

Referenced by TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor\process().

◆ determineMaximumGalleryWidth()

TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::determineMaximumGalleryWidth ( )
protected

◆ getConfigurationValue()

string TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::getConfigurationValue (   $key,
  $dataArrayKey = null 
)
protected

Get configuration value from processorConfiguration with when $dataArrayKey fallback to value from cObj->data array

Parameters
string$key
string | null$dataArrayKey
Returns
‪string

Definition at line 282 of file GalleryProcessor.php.

Referenced by TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor\process().

◆ getCroppedDimensionalProperty()

int TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::getCroppedDimensionalProperty ( FileInterface  $fileObject,
  $dimensionalProperty 
)
protected

When retrieving the height or width for a media file a possible cropping needs to be taken into account.

Parameters
string$dimensionalProperty‪'width' or 'height'
Returns
‪int

Definition at line 456 of file GalleryProcessor.php.

References TYPO3\CMS\Core\Imaging\ImageManipulation\CropVariantCollection\create(), TYPO3\CMS\Core\Resource\FileInterface\getProperty(), and TYPO3\CMS\Core\Resource\FileInterface\hasProperty().

Referenced by TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor\calculateMediaWidthsAndHeights().

◆ prepareGalleryData()

TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::prepareGalleryData ( )
protected

◆ process()

array TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::process ( ContentObjectRenderer  $cObj,
array  $contentObjectConfiguration,
array  $processorConfiguration,
array  $processedData 
)

Process data for a gallery, for instance the CType "textmedia"

Parameters
ContentObjectRenderer$cObj‪The content object renderer, which contains data of the content element
array$contentObjectConfiguration‪The configuration of Content Object
array$processorConfiguration‪The configuration of this processor
array$processedData‪Key/value store of processed data (e.g. to be passed to a Fluid View)
Returns
‪array the processed data as key/value store
Exceptions
ContentRenderingException

Implements TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface.

Definition at line 218 of file GalleryProcessor.php.

References TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor\$galleryData, TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor\$processorConfiguration, TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor\calculateMediaWidthsAndHeights(), TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor\calculateRowsAndColumns(), TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\checkIf(), TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor\determineGalleryPosition(), TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor\determineMaximumGalleryWidth(), TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor\getConfigurationValue(), TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor\prepareGalleryData(), and TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\stdWrapValue().

Member Data Documentation

◆ $availableGalleryPositions

array TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::$availableGalleryPositions
protected
Initial value:
= array(
'horizontal' => [
'center' => [0, 8],
'right' => [1, 9, 17, 25],
'left' => [2, 10, 18, 26],
],
'vertical' => [
'above' => [0, 1, 2],
'intext' => [17, 18, 25, 26],
'below' => [8, 9, 10],
],
)

Matching the tt_content field towards the imageOrient option

Definition at line 114 of file GalleryProcessor.php.

◆ $borderEnabled

bool TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::$borderEnabled
protected

◆ $borderPadding

int TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::$borderPadding
protected

◆ $borderWidth

int TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::$borderWidth
protected

◆ $columnSpacing

int TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::$columnSpacing
protected

◆ $contentObjectRenderer

TYPO3 CMS Frontend ContentObject ContentObjectRenderer TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::$contentObjectRenderer
protected

The content object renderer

Definition at line 102 of file GalleryProcessor.php.

◆ $cropVariant

string TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::$cropVariant = 'default'
protected

Definition at line 194 of file GalleryProcessor.php.

◆ $equalMediaHeight

int TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::$equalMediaHeight
protected

Definition at line 170 of file GalleryProcessor.php.

◆ $equalMediaWidth

int TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::$equalMediaWidth
protected

◆ $fileObjects

FileInterface [] TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::$fileObjects = array( )
protected

The (filtered) media files to be used in the gallery

Definition at line 200 of file GalleryProcessor.php.

◆ $galleryData

array TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::$galleryData
protected
Initial value:
= array(
'position' => [
'horizontal' => '',
'vertical' => '',
'noWrap' => false,
],
'width' => 0,
'count' => [
'files' => 0,
'columns' => 0,
'rows' => 0,
],
'columnSpacing' => 0,
'border' => [
'enabled' => false,
'width' => 0,
'padding' => 0,
],
'rows' => [],
)

Storage for processed data

Definition at line 131 of file GalleryProcessor.php.

Referenced by TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor\process().

◆ $maxGalleryWidth

int TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::$maxGalleryWidth
protected

◆ $maxGalleryWidthInText

int TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::$maxGalleryWidthInText
protected

◆ $mediaDimensions

array TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::$mediaDimensions = array( )
protected

The calculated dimensions for each media element

Definition at line 206 of file GalleryProcessor.php.

◆ $mediaOrientation

int TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::$mediaOrientation
protected

Definition at line 158 of file GalleryProcessor.php.

◆ $numberOfColumns

int TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::$numberOfColumns
protected

Definition at line 154 of file GalleryProcessor.php.

◆ $processorConfiguration

array TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::$processorConfiguration
protected

The processor configuration

Definition at line 108 of file GalleryProcessor.php.

Referenced by TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor\process().