TYPO3  7.6
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GalleryProcessor Class Reference
Inheritance diagram for GalleryProcessor:
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
 
 $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 ( )
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

Returns
void

Definition at line 379 of file GalleryProcessor.php.

References GalleryProcessor\$equalMediaWidth, elseif, and GalleryProcessor\getCroppedDimensionalProperty().

Referenced by GalleryProcessor\process().

calculateRowsAndColumns ( )
protected

Calculate the amount of rows and columns

Returns
void

Definition at line 347 of file GalleryProcessor.php.

Referenced by GalleryProcessor\process().

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.

Returns
void

Definition at line 313 of file GalleryProcessor.php.

Referenced by GalleryProcessor\process().

determineMaximumGalleryWidth ( )
protected

Get the gallery width based on vertical position

Returns
void

Definition at line 333 of file GalleryProcessor.php.

References GalleryProcessor\$maxGalleryWidth, and GalleryProcessor\$maxGalleryWidthInText.

Referenced by GalleryProcessor\process().

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

Referenced by GalleryProcessor\process().

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

References FileInterface\getProperty(), and FileInterface\hasProperty().

Referenced by GalleryProcessor\calculateMediaWidthsAndHeights().

prepareGalleryData ( )
protected

Prepare the gallery data

Make an array for rows, columns and configuration

Returns
void

Definition at line 492 of file GalleryProcessor.php.

References GalleryProcessor\$borderEnabled, GalleryProcessor\$borderPadding, GalleryProcessor\$borderWidth, and GalleryProcessor\$columnSpacing.

Referenced by GalleryProcessor\process().

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 DataProcessorInterface.

Definition at line 229 of file GalleryProcessor.php.

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

Member Data Documentation

$availableGalleryPositions
protected
Initial value:
= [
'horizontal' => [
'center' => [0, 8]

Definition at line 116 of file GalleryProcessor.php.

$borderEnabled
protected

Definition at line 193 of file GalleryProcessor.php.

Referenced by GalleryProcessor\prepareGalleryData().

$borderPadding
protected

Definition at line 203 of file GalleryProcessor.php.

Referenced by GalleryProcessor\prepareGalleryData().

$borderWidth
protected

Definition at line 198 of file GalleryProcessor.php.

Referenced by GalleryProcessor\prepareGalleryData().

$columnSpacing
protected

Definition at line 188 of file GalleryProcessor.php.

Referenced by GalleryProcessor\prepareGalleryData().

$contentObjectRenderer
protected

Definition at line 102 of file GalleryProcessor.php.

$equalMediaHeight
protected

Definition at line 178 of file GalleryProcessor.php.

$equalMediaWidth
protected
$fileObjects = []
protected

Definition at line 210 of file GalleryProcessor.php.

$galleryData
protected
Initial value:
= [
'position' => [
'horizontal' => ''

Definition at line 134 of file GalleryProcessor.php.

Referenced by GalleryProcessor\process().

$maxGalleryWidth
protected

Definition at line 168 of file GalleryProcessor.php.

Referenced by GalleryProcessor\determineMaximumGalleryWidth().

$maxGalleryWidthInText
protected

Definition at line 173 of file GalleryProcessor.php.

Referenced by GalleryProcessor\determineMaximumGalleryWidth().

$mediaDimensions = []
protected

Definition at line 217 of file GalleryProcessor.php.

$mediaOrientation
protected

Definition at line 163 of file GalleryProcessor.php.

$numberOfColumns
protected

Definition at line 158 of file GalleryProcessor.php.

$processorConfiguration
protected

Definition at line 109 of file GalleryProcessor.php.

Referenced by GalleryProcessor\process().