PHP Класс MetaModels\Helper\ToolboxFile

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$acceptedExtensions array Allowed file extensions.
$baseLanguage string Base language, used for retrieving meta.txt information.
$blnShowImages boolean Determines if we want to generate images or not.
$fallbackLanguage string The fallback language, used for retrieving meta.txt information.
$foundFiles array The files to process in this instance.
$metaInformation array Meta information for files.
$modifiedTime array Buffered modification timestamps.
$outputBuffer array Buffered file information.
$pendingIds array The pending uuids to collect from DB.
$pendingPaths string[] The pending paths to collect from DB.
$resizeImages array Image resize information.
$strLightboxId string The id to use in lightboxes.
$uuidMap string[] File id mapping for files.

Открытые методы

Метод Описание
__construct ( ) Create a new instance.
addPath ( string $strPath ) : ToolboxFile Add path to file or folder list.
addPathById ( string $strId ) : ToolboxFile Contao 3 DBAFS Support.
convertUuidsOrPathsToMetaModels ( array $values ) : array Convert an uuid or path to a value to be handled by MetaModels.
convertValueToPath ( string $varValue ) : string Translate the file ID to file path.
convertValuesToDatabase ( array $values ) : array Convert an array of values handled by MetaModels to a value to be stored in the database (array of bin uuid).
convertValuesToMetaModels ( array $values ) : array Convert an array of values stored in the database (array of bin uuid) to a value to be handled by MetaModels.
getAcceptedExtensions ( ) : array Retrieve the allowed file extensions.
getBaseLanguage ( ) : string Retrieve the base language.
getFallbackLanguage ( ) : string Retrieve the fallback language.
getFiles ( ) : array Returns the file list.
getLightboxId ( ) : string Retrieve the lightbox id to use.
getResizeImages ( ) : array Retrieve the resize information.
getShowImages ( ) : boolean Retrieve the flag if images shall be rendered as images.
resolveFiles ( ) : ToolboxFile Process all folders and resolve to a valid file list.
setAcceptedExtensions ( string | array $acceptedExtensions ) : void Set the allowed file extensions.
setBaseLanguage ( string $baseLanguage ) : ToolboxFile Set the base language.
setFallbackLanguage ( string $fallbackLanguage ) : ToolboxFile Set the fallback language.
setLightboxId ( string $strLightboxId ) : ToolboxFile Sets the Id to use for the lightbox.
setResizeImages ( array $resizeImages ) : ToolboxFile Set the resize information.
setShowImages ( boolean $blnShowImages ) : ToolboxFile Set to show/prepare images or not.
sortFiles ( string $sortType, array $sortIds = [] ) : array Sorts the internal file list by a given condition.

Защищенные методы

Метод Описание
addClasses ( array &$arrSource ) : void Attach first, last and even/odd classes to the given array.
collectFiles ( ) : void Walks the list of pending folders via ToolboxFile::addPath().
fetchAdditionalData ( ) : void Walk all files and fetch desired additional information like image sizes etc.
getDownloadLink ( string $strFile ) : string Generate an URL for downloading the given file.
remapSorting ( array $arrFiles, array $arrSource ) : array Maps the sorting from the files to the source.
sortByDate ( boolean $blnAscending = true ) : array Sort by modification time.
sortByIdList ( array $sortIds ) : array Sort by passed id list.
sortByName ( boolean $blnAscending = true ) : array Sort by filename.
sortByRandom ( ) : array Shuffle the file list.

Приватные методы

Метод Описание
addFileModels ( FilesModel[] $files, array $skipPaths = [] ) : void Add the passed file model collection to the current buffer if the extension is allowed.
stringToUuid ( string $uuid ) : string Map a string to it's binary uuid representation.
uuidToString ( string $uuid ) : string Map a binary uuid to it's string representation.

Описание методов

__construct() публичный метод

Create a new instance.
public __construct ( )

addClasses() защищенный метод

Attach first, last and even/odd classes to the given array.
protected addClasses ( array &$arrSource ) : void
$arrSource array The array reference of the array to which the classes shall be added to.
Результат void

addPath() публичный метод

Add path to file or folder list.
public addPath ( string $strPath ) : ToolboxFile
$strPath string The path to be added.
Результат ToolboxFile

addPathById() публичный метод

Contao 3 DBAFS Support.
public addPathById ( string $strId ) : ToolboxFile
$strId string String uuid of the file.
Результат ToolboxFile

collectFiles() защищенный метод

Walks the list of pending folders via ToolboxFile::addPath().
protected collectFiles ( ) : void
Результат void

convertUuidsOrPathsToMetaModels() публичный статический метод

The output array will have the following layout: array( 'bin' => array() // the binary id. 'value' => array() // the uuid. 'path' => array() // the path. )
public static convertUuidsOrPathsToMetaModels ( array $values ) : array
$values array The binary uuids or paths to convert.
Результат array

convertValueToPath() публичный статический метод

Translate the file ID to file path.
public static convertValueToPath ( string $varValue ) : string
$varValue string The file id.
Результат string

convertValuesToDatabase() публичный статический метод

The input array must have the following layout: array( 'bin' => array() // list of the binary ids. 'value' => array() // list of the uuids. 'path' => array() // list of the paths. )
public static convertValuesToDatabase ( array $values ) : array
$values array The values to convert.
Результат array

convertValuesToMetaModels() публичный статический метод

The output array will have the following layout: array( 'bin' => array() // list of the binary ids. 'value' => array() // list of the uuids. 'path' => array() // list of the paths. )
public static convertValuesToMetaModels ( array $values ) : array
$values array The binary uuid values to convert.
Результат array

fetchAdditionalData() защищенный метод

Walk all files and fetch desired additional information like image sizes etc.
protected fetchAdditionalData ( ) : void
Результат void

getAcceptedExtensions() публичный метод

Retrieve the allowed file extensions.
public getAcceptedExtensions ( ) : array
Результат array

getBaseLanguage() публичный метод

Retrieve the base language.
public getBaseLanguage ( ) : string
Результат string

getFallbackLanguage() публичный метод

Retrieve the fallback language.
public getFallbackLanguage ( ) : string
Результат string

getFiles() публичный метод

NOTE: you must call resolveFiles() beforehand as otherwise folders are not being evaluated.
public getFiles ( ) : array
Результат array

getLightboxId() публичный метод

Retrieve the lightbox id to use.
public getLightboxId ( ) : string
Результат string

getResizeImages() публичный метод

Retrieve the resize information.
public getResizeImages ( ) : array
Результат array

getShowImages() публичный метод

Retrieve the flag if images shall be rendered as images.
public getShowImages ( ) : boolean
Результат boolean

remapSorting() защищенный метод

All files from $arrFiles are being walked and the corresponding entry from source gets pulled in. Additionally, the css classes are applied to the returned 'source' array. This returns an array like: array('files' => array(), 'source' => array())
protected remapSorting ( array $arrFiles, array $arrSource ) : array
$arrFiles array The files to sort.
$arrSource array The source list.
Результат array The mapped result.

resolveFiles() публичный метод

Process all folders and resolve to a valid file list.
public resolveFiles ( ) : ToolboxFile
Результат ToolboxFile

setAcceptedExtensions() публичный метод

Set the allowed file extensions.
public setAcceptedExtensions ( string | array $acceptedExtensions ) : void
$acceptedExtensions string | array The list of accepted file extensions.
Результат void

setBaseLanguage() публичный метод

Set the base language.
public setBaseLanguage ( string $baseLanguage ) : ToolboxFile
$baseLanguage string The base language to use.
Результат ToolboxFile

setFallbackLanguage() публичный метод

Set the fallback language.
public setFallbackLanguage ( string $fallbackLanguage ) : ToolboxFile
$fallbackLanguage string The fallback language to use.
Результат ToolboxFile

setLightboxId() публичный метод

Sets the Id to use for the lightbox.
public setLightboxId ( string $strLightboxId ) : ToolboxFile
$strLightboxId string The lightbox id to use.
Результат ToolboxFile

setResizeImages() публичный метод

Set the resize information.
public setResizeImages ( array $resizeImages ) : ToolboxFile
$resizeImages array The resize information. Array of 3 elements: 0: Width, 1: Height, 2: Mode.
Результат ToolboxFile

setShowImages() публичный метод

Set to show/prepare images or not.
public setShowImages ( boolean $blnShowImages ) : ToolboxFile
$blnShowImages boolean True to show images, false otherwise.
Результат ToolboxFile

sortByDate() защищенный метод

Sort by modification time.
protected sortByDate ( boolean $blnAscending = true ) : array
$blnAscending boolean Flag to determine if sorting shall be applied ascending (default) or descending.
Результат array

sortByIdList() защищенный метод

Sort by passed id list.
protected sortByIdList ( array $sortIds ) : array
$sortIds array The list of binary ids to sort by.
Результат array

sortByName() защищенный метод

Sort by filename.
protected sortByName ( boolean $blnAscending = true ) : array
$blnAscending boolean Flag to determine if sorting shall be applied ascending (default) or descending.
Результат array

sortByRandom() защищенный метод

Shuffle the file list.
protected sortByRandom ( ) : array
Результат array

sortFiles() публичный метод

Allowed sort types are: name_asc - Sort by filename ascending. name_desc - Sort by filename descending date_asc - Sort by modification time ascending. date_desc - Sort by modification time descending. manual - Sort by passed id array, the array must contain the binary ids of the files. random - Shuffle all the files around.
public sortFiles ( string $sortType, array $sortIds = [] ) : array
$sortType string The sort condition to be applied.
$sortIds array The list of binary ids to sort by (sort type "manual" only).
Результат array The sorted file list.

Описание свойств

$acceptedExtensions защищенное свойство

Allowed file extensions.
protected array $acceptedExtensions
Результат array

$baseLanguage защищенное свойство

Base language, used for retrieving meta.txt information.
protected string $baseLanguage
Результат string

$blnShowImages защищенное свойство

Determines if we want to generate images or not.
protected bool $blnShowImages
Результат boolean

$fallbackLanguage защищенное свойство

The fallback language, used for retrieving meta.txt information.
protected string $fallbackLanguage
Результат string

$foundFiles защищенное свойство

The files to process in this instance.
protected array $foundFiles
Результат array

$metaInformation защищенное свойство

Meta information for files.
protected array $metaInformation
Результат array

$modifiedTime защищенное свойство

Buffered modification timestamps.
protected array $modifiedTime
Результат array

$outputBuffer защищенное свойство

Buffered file information.
protected array $outputBuffer
Результат array

$pendingIds защищенное свойство

The pending uuids to collect from DB.
protected array $pendingIds
Результат array

$pendingPaths защищенное свойство

The pending paths to collect from DB.
protected string[] $pendingPaths
Результат string[]

$resizeImages защищенное свойство

Image resize information.
protected array $resizeImages
Результат array

$strLightboxId защищенное свойство

The id to use in lightboxes.
protected string $strLightboxId
Результат string

$uuidMap защищенное свойство

File id mapping for files.
protected string[] $uuidMap
Результат string[]