TYPO3 CMS  TYPO3_8-7
TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor Class Reference
Inheritance diagram for TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor:
TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

 $contentObjectRenderer
 
 $processorConfiguration
 
 $availableGalleryPositions
 
 $galleryData
 
 $numberOfColumns
 
 $mediaOrientation
 
 $maxGalleryWidth
 
 $maxGalleryWidthInText
 
 $equalMediaHeight
 
 $equalMediaWidth
 
 $columnSpacing
 
 $borderEnabled
 
 $borderWidth
 
 $borderPadding
 
 $cropVariant = 'default'
 
 $fileObjects = []
 
 $mediaDimensions = []
 

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 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 dimensions { width = 600 height = 400 } } } } 2 { columns { 1 { media = TYPO3 dimensions { width = 600 height = 400 } } } } } columnSpacing = 0 border { enabled = FALSE width = 0 padding = 0 } }

Definition at line 95 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 377 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 347 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 317 of file GalleryProcessor.php.

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

◆ determineMaximumGalleryWidth()

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

◆ getConfigurationValue()

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 298 of file GalleryProcessor.php.

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

◆ getCroppedDimensionalProperty()

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
FileInterface$fileObject
string$dimensionalProperty'width' or 'height'
Returns
int

Definition at line 474 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()

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$cObjThe content object renderer, which contains data of the content element
array$contentObjectConfigurationThe configuration of Content Object
array$processorConfigurationThe configuration of this processor
array$processedDataKey/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 234 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

TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::$availableGalleryPositions
protected
Initial value:
= [
'horizontal' => [
'center' => [0, 8]

Definition at line 116 of file GalleryProcessor.php.

◆ $borderEnabled

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

◆ $borderPadding

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

◆ $borderWidth

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

◆ $columnSpacing

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

◆ $contentObjectRenderer

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

Definition at line 102 of file GalleryProcessor.php.

◆ $cropVariant

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

Definition at line 208 of file GalleryProcessor.php.

◆ $equalMediaHeight

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

Definition at line 178 of file GalleryProcessor.php.

◆ $equalMediaWidth

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

◆ $fileObjects

TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::$fileObjects = []
protected

Definition at line 215 of file GalleryProcessor.php.

◆ $galleryData

TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::$galleryData
protected
Initial value:
= [
'position' => [
'horizontal' => ''

Definition at line 134 of file GalleryProcessor.php.

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

◆ $maxGalleryWidth

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

◆ $maxGalleryWidthInText

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

◆ $mediaDimensions

TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor::$mediaDimensions = []
protected

Definition at line 222 of file GalleryProcessor.php.

◆ $mediaOrientation

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

Definition at line 163 of file GalleryProcessor.php.

◆ $numberOfColumns

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

Definition at line 158 of file GalleryProcessor.php.

◆ $processorConfiguration

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