‪TYPO3CMS  11.5
TYPO3\CMS\Filelist\FileList Class Reference

Public Member Functions

 __construct (?ServerRequestInterface $request=null)
 
 start (Folder $folderObject, $pointer, $sort, $sortRev)
 
 setColumnsToRender (array $additionalFields=[])
 
string getTable (?FileSearchDemand $searchDemand=null)
 
string addElement (array $data, array $attributes=[], bool $isTableHeader=false)
 
string fwd_rwd_nav (int $currentItemCount)
 
string getFolderInfo ()
 
string formatDirList (array $folders)
 
string linkWrapDir ($title, Folder $folderObject)
 
string linkWrapFile ($code, File $fileObject)
 
string listURL (array $params=[])
 
string formatFileList (array $files)
 
string linkWrapSort (string $fieldName, string $label='')
 
array makeClip ($fileOrFolderObject)
 
string makeEdit ($fileOrFolderObject)
 
 makeRef (File $file)
 

Public Attributes

int $iLimit = 40
 
bool $thumbs = false
 
string $spaceIcon
 
int $fixedL = 30
 
string $sort = ''
 
bool $sortRev = true
 
int $firstElementNumber = 0
 
int $totalbytes = 0
 
int $totalItems = 0
 
array $fieldArray = array( )
 
int $counter = 0
 
TranslationConfigurationProvider $translateTools
 
array $addElement_tdCssClass
 
array $CBnames = array( )
 
Clipboard $clipObj
 
 $translationRecords
 
 $translations = []
 
foreach($translationRecords as $record) return $translations
 

Protected Member Functions

array< int, getTranslationsForMetaData( $metaDataRecord) { $languageField=$GLOBALS[ 'TCA'][ 'sys_file_metadata'][ 'ctrl'][ 'languageField'] ?? '';$languageParentField=$GLOBALS[ 'TCA'][ 'sys_file_metadata'][ 'ctrl'][ 'transOrigPointerField'] ?? '';$queryBuilder=GeneralUtility::makeInstance(ConnectionPool::class) -> getQueryBuilderForTable ('sys_file_metadata')
 
string makeCheckbox ($fileOrFolderObject)
 
string makePath (ResourceInterface $resource)
 
string makeTranslations (File $file)
 
 isEditMetadataAllowed (File $file)
 
string getFileOrFolderIcon (string $title, $fileOrFolderObject)
 
string renderCheckboxActions ()
 
 getBackendUserInformation (int $backendUserId)
 
string getConcreteTableName (string $fieldName)
 
bool fileDownloadEnabled ()
 
File[] sortFiles (array $files)
 
Folder[] sortFolders (array $folders)
 
 getFileReferenceCount (File $file)
 
LanguageService getLanguageService ()
 
BackendUserAuthentication getBackendUser ()
 

Protected Attributes

Folder $folderObject
 
ResourceFactory $resourceFactory
 
IconFactory $iconFactory
 
int $id = 0
 
UriBuilder $uriBuilder
 
FileSearchDemand $searchDemand = null
 
FileExtensionFilter $fileExtensionFilter = null
 
array $backendUserCache = []
 
EventDispatcherInterface $eventDispatcher
 

Detailed Description

Class for rendering of File>Filelist (basically used in FileListController)

See also
‪\TYPO3\CMS\Filelist\Controller\FileListController

this is a concrete TYPO3 controller implementation and solely used for EXT:filelist and not part of TYPO3's Core API.

Definition at line 55 of file FileList.php.

Constructor & Destructor Documentation

◆ __construct()

Member Function Documentation

◆ addElement()

string TYPO3\CMS\Filelist\FileList::addElement ( array  $data,
array  $attributes = [],
bool  $isTableHeader = false 
)

Returns a table-row with the content from the fields in the input data array. OBS: $this->fieldArray MUST be set! (represents the list of fields to display)

Parameters
array$data‪Is the data array, record with the fields. Notice: These fields are (currently) NOT htmlspecialchar'ed before being wrapped in

-tags

Parameters
array$attributes‪Attributes for the table row. Values will be htmlspecialchar'ed!
bool$isTableHeader‪Whether the element to be added is a table header
Returns
‪string HTML content for the table row

Definition at line 395 of file FileList.php.

Referenced by TYPO3\CMS\Filelist\FileList\formatDirList(), TYPO3\CMS\Filelist\FileList\formatFileList(), TYPO3\CMS\Filelist\FileList\fwd_rwd_nav(), and TYPO3\CMS\Filelist\FileList\getTable().

◆ fileDownloadEnabled()

bool TYPO3\CMS\Filelist\FileList::fileDownloadEnabled ( )
protected

Whether file download is enabled for the user

Returns
‪bool

Definition at line 1406 of file FileList.php.

References TYPO3\CMS\Filelist\FileList\getBackendUser(), and TYPO3\CMS\Core\Authentication\BackendUserAuthentication\getTSConfig().

◆ formatDirList()

◆ formatFileList()

◆ fwd_rwd_nav()

string TYPO3\CMS\Filelist\FileList::fwd_rwd_nav ( int  $currentItemCount)

Creates a forward/reverse button based on the status of ->eCounter, ->firstElementNumber, ->iLimit

Returns
‪string the table-row code for the element

Definition at line 437 of file FileList.php.

References TYPO3\CMS\Filelist\FileList\addElement(), TYPO3\CMS\Filelist\FileList\listURL(), and TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL.

Referenced by TYPO3\CMS\Filelist\FileList\getTable().

◆ getBackendUser()

◆ getBackendUserInformation()

TYPO3\CMS\Filelist\FileList::getBackendUserInformation ( int  $backendUserId)
protected

Helper method around fetching a "cruser_id" information for a record, with a cache, so the same information does not have to be processed for the same user over and over again.

Definition at line 1373 of file FileList.php.

Referenced by TYPO3\CMS\Filelist\FileList\formatFileList().

◆ getConcreteTableName()

string TYPO3\CMS\Filelist\FileList::getConcreteTableName ( string  $fieldName)
protected

Determine the concrete table name by checking if the field exists, while sys_file takes precedence.

Parameters
string$fieldName
Returns
‪string

Definition at line 1396 of file FileList.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Filelist\FileList\formatFileList(), and TYPO3\CMS\Filelist\FileList\linkWrapSort().

◆ getFileOrFolderIcon()

string TYPO3\CMS\Filelist\FileList::getFileOrFolderIcon ( string  $title,
  $fileOrFolderObject 
)
protected

Get the icon for a file or folder object

Parameters
string$title‪The icon title
File | Folder$fileOrFolderObject
Returns
‪string The wrapped icon for the file or folder

Definition at line 1315 of file FileList.php.

References TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL.

Referenced by TYPO3\CMS\Filelist\FileList\formatDirList(), and TYPO3\CMS\Filelist\FileList\formatFileList().

◆ getFileReferenceCount()

TYPO3\CMS\Filelist\FileList::getFileReferenceCount ( File  $file)
protected

Counts how often the given file is referenced. This is done by looking up the file in the "sys_refindex" table, while excluding sys_file_metadata relations as these are no such references.

Definition at line 1509 of file FileList.php.

References TYPO3\CMS\Core\Resource\AbstractFile\getUid(), and TYPO3\CMS\Core\Database\Connection\PARAM_INT.

Referenced by TYPO3\CMS\Filelist\FileList\makeRef(), and TYPO3\CMS\Filelist\FileList\sortFiles().

◆ getFolderInfo()

string TYPO3\CMS\Filelist\FileList::getFolderInfo ( )

Gets the number of files and total size of a folder

Returns
‪string

Definition at line 471 of file FileList.php.

References TYPO3\CMS\Filelist\FileList\getLanguageService().

◆ getLanguageService()

◆ getQueryBuilderForTable()

array<int, getTranslationsForMetaData($metaDataRecord) { $languageField = $GLOBALS['TCA']['sys_file_metadata']['ctrl']['languageField'] ?? ''; $languageParentField = $GLOBALS['TCA']['sys_file_metadata']['ctrl']['transOrigPointerField'] ?? ''; $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)-> TYPO3\CMS\Filelist\FileList::getQueryBuilderForTable ( 'sys_file_metadata'  )
protected

Fetch the translations for a sys_file_metadata record

Parameters
array$metaDataRecord
Returns
‪array<int, array<string, mixed>> keys are the sys_language uids, values are the $rows

◆ getTable()

◆ isEditMetadataAllowed()

◆ linkWrapDir()

string TYPO3\CMS\Filelist\FileList::linkWrapDir (   $title,
Folder  $folderObject 
)

Wraps the directory-titles

Parameters
string$title‪String to be wrapped in links
Folder$folderObject‪Folder to work on
Returns
‪string HTML

Definition at line 578 of file FileList.php.

References TYPO3\CMS\Core\Resource\Folder\getCombinedIdentifier(), and TYPO3\CMS\Filelist\FileList\listURL().

Referenced by TYPO3\CMS\Filelist\FileList\formatDirList().

◆ linkWrapFile()

string TYPO3\CMS\Filelist\FileList::linkWrapFile (   $code,
File  $fileObject 
)

Wraps filenames in links which opens the metadata editor.

Parameters
string$code‪String to be wrapped in links
File$fileObject‪File to be linked
Returns
‪string HTML

Definition at line 595 of file FileList.php.

References TYPO3\CMS\Filelist\FileList\getLanguageService(), TYPO3\CMS\Core\Resource\File\getMetaData(), TYPO3\CMS\Filelist\FileList\isEditMetadataAllowed(), TYPO3\CMS\Filelist\FileList\listURL(), and TYPO3\CMS\Core\Resource\MetaDataAspect\offsetGet().

Referenced by TYPO3\CMS\Filelist\FileList\formatFileList().

◆ linkWrapSort()

string TYPO3\CMS\Filelist\FileList::linkWrapSort ( string  $fieldName,
string  $label = '' 
)

Wraps a field label for the header row into a link to the filelist with sorting commands

Parameters
string$fieldName‪The field to sort
string$label‪The label to be wrapped - will be determined if not given
Returns
‪string The constructed link - HTML

Definition at line 795 of file FileList.php.

References TYPO3\CMS\Filelist\FileList\getConcreteTableName(), TYPO3\CMS\Filelist\FileList\getLanguageService(), TYPO3\CMS\Filelist\FileList\listURL(), and TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL.

Referenced by TYPO3\CMS\Filelist\FileList\getTable().

◆ listURL()

string TYPO3\CMS\Filelist\FileList::listURL ( array  $params = [])

Returns list URL; This is the URL of the current script with id and imagemode parameters, that's all.

Returns
‪string URL

Definition at line 624 of file FileList.php.

Referenced by TYPO3\CMS\Filelist\FileList\fwd_rwd_nav(), TYPO3\CMS\Filelist\FileList\linkWrapDir(), TYPO3\CMS\Filelist\FileList\linkWrapFile(), TYPO3\CMS\Filelist\FileList\linkWrapSort(), and TYPO3\CMS\Filelist\FileList\makeEdit().

◆ makeCheckbox()

string TYPO3\CMS\Filelist\FileList::makeCheckbox (   $fileOrFolderObject)
protected

Adds the checkbox to select a file/folder in the listing

Parameters
File | Folder$fileOrFolderObject
Returns
‪string

Definition at line 909 of file FileList.php.

Referenced by TYPO3\CMS\Filelist\FileList\formatDirList(), and TYPO3\CMS\Filelist\FileList\formatFileList().

◆ makeClip()

array TYPO3\CMS\Filelist\FileList::makeClip (   $fileOrFolderObject)

Creates the clipboard actions

Parameters
File | Folder$fileOrFolderObject‪Array with information about the file/directory for which to make the clipboard actions for the listing.
Returns
‪array clipboard actions

Definition at line 834 of file FileList.php.

References TYPO3\CMS\Core\Resource\Folder\checkActionPermission(), TYPO3\CMS\Filelist\FileList\getLanguageService(), TYPO3\CMS\Core\Localization\LanguageService\getLL(), TYPO3\CMS\Core\Resource\Folder\getStorage(), TYPO3\CMS\Core\Resource\ResourceStorage\isWithinFolder(), TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL, and TYPO3\CMS\Core\Localization\LanguageService\sL().

Referenced by TYPO3\CMS\Filelist\FileList\makeEdit().

◆ makeEdit()

◆ makePath()

string TYPO3\CMS\Filelist\FileList::makePath ( ResourceInterface  $resource)
protected

Generate readable path

Parameters
ResourceInterface$resource
Returns
‪string

Definition at line 1192 of file FileList.php.

References TYPO3\CMS\Core\Resource\ResourceInterface\getParentFolder().

Referenced by TYPO3\CMS\Filelist\FileList\formatDirList(), and TYPO3\CMS\Filelist\FileList\formatFileList().

◆ makeRef()

TYPO3\CMS\Filelist\FileList::makeRef ( File  $file)

Make reference count. Wraps the count into a button to open the element information in case references exists.

Definition at line 1165 of file FileList.php.

References TYPO3\CMS\Core\Resource\AbstractFile\getCombinedIdentifier(), TYPO3\CMS\Filelist\FileList\getFileReferenceCount(), TYPO3\CMS\Filelist\FileList\getLanguageService(), and TYPO3\CMS\Core\Localization\LanguageService\sL().

Referenced by TYPO3\CMS\Filelist\FileList\formatFileList().

◆ makeTranslations()

string TYPO3\CMS\Filelist\FileList::makeTranslations ( File  $file)
protected

Creates the file metadata translation dropdown. Each item links to the corresponding metadata translation, while depending on the current state, either a new translation can be created or an existing translation can be edited.

Parameters
File$file
Returns
‪string

Definition at line 1219 of file FileList.php.

References $GLOBALS, TYPO3\CMS\Filelist\FileList\$translations, TYPO3\CMS\Core\Resource\File\checkActionPermission(), TYPO3\CMS\Core\Resource\MetaDataAspect\get(), TYPO3\CMS\Filelist\FileList\getBackendUser(), TYPO3\CMS\Core\Resource\AbstractFile\getHashedIdentifier(), TYPO3\CMS\Filelist\FileList\getLanguageService(), TYPO3\CMS\Core\Resource\File\getMetaData(), TYPO3\CMS\Core\Resource\File\isIndexed(), and TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL.

Referenced by TYPO3\CMS\Filelist\FileList\makeEdit().

◆ renderCheckboxActions()

string TYPO3\CMS\Filelist\FileList::renderCheckboxActions ( )
protected

Render convenience actions, such as "check all"

Returns
‪string HTML markup for the checkbox actions

Definition at line 1328 of file FileList.php.

References TYPO3\CMS\Filelist\FileList\getLanguageService(), and TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL.

Referenced by TYPO3\CMS\Filelist\FileList\getTable().

◆ setColumnsToRender()

TYPO3\CMS\Filelist\FileList::setColumnsToRender ( array  $additionalFields = [])

Definition at line 226 of file FileList.php.

◆ sortFiles()

File [] TYPO3\CMS\Filelist\FileList::sortFiles ( array  $files)
protected
Parameters
File[]$files
Returns
‪File[]

Definition at line 1415 of file FileList.php.

References TYPO3\CMS\Filelist\FileList\getFileReferenceCount().

Referenced by TYPO3\CMS\Filelist\FileList\getTable().

◆ sortFolders()

Folder [] TYPO3\CMS\Filelist\FileList::sortFolders ( array  $folders)
protected
Parameters
Folder[]$folders
Returns
‪Folder[]

Definition at line 1461 of file FileList.php.

Referenced by TYPO3\CMS\Filelist\FileList\getTable().

◆ start()

TYPO3\CMS\Filelist\FileList::start ( Folder  $folderObject,
  $pointer,
  $sort,
  $sortRev 
)

Initialization of class

Parameters
Folder$folderObject‪The folder to work on
int$pointer‪Pointer
string$sort‪Sorting column
bool$sortRev‪Sorting direction

Definition at line 213 of file FileList.php.

References TYPO3\CMS\Filelist\FileList\$folderObject, TYPO3\CMS\Filelist\FileList\$sort, and TYPO3\CMS\Filelist\FileList\$sortRev.

Member Data Documentation

◆ $addElement_tdCssClass

array TYPO3\CMS\Filelist\FileList::$addElement_tdCssClass
Initial value:
= array(
'_CONTROL_' => 'col-control',
'_SELECTOR_' => 'col-selector',
'icon' => 'col-icon',
'name' => 'col-title col-responsive',
)

Keys are fieldnames and values are td-css-classes to add in addElement();

Definition at line 127 of file FileList.php.

◆ $backendUserCache

array TYPO3\CMS\Filelist\FileList::$backendUserCache = []
protected

Definition at line 169 of file FileList.php.

◆ $CBnames

array TYPO3\CMS\Filelist\FileList::$CBnames = array( )

Definition at line 140 of file FileList.php.

◆ $clipObj

Clipboard TYPO3\CMS\Filelist\FileList::$clipObj

$clipObj

Definition at line 144 of file FileList.php.

◆ $counter

int TYPO3\CMS\Filelist\FileList::$counter = 0

Counter increased for each element. Used to index elements for the JavaScript-code that transfers to the clipboard

Definition at line 117 of file FileList.php.

◆ $eventDispatcher

EventDispatcherInterface TYPO3\CMS\Filelist\FileList::$eventDispatcher
protected

Definition at line 171 of file FileList.php.

◆ $fieldArray

array TYPO3\CMS\Filelist\FileList::$fieldArray = array( )

Decides the columns shown. Filled with values that refers to the keys of the data-array. $this->fieldArray[0] is the title column.

Definition at line 111 of file FileList.php.

◆ $fileExtensionFilter

FileExtensionFilter TYPO3\CMS\Filelist\FileList::$fileExtensionFilter = null
protected

Definition at line 163 of file FileList.php.

◆ $firstElementNumber

int TYPO3\CMS\Filelist\FileList::$firstElementNumber = 0

Definition at line 95 of file FileList.php.

Referenced by TYPO3\CMS\Filelist\FileList\getTable().

◆ $fixedL

int TYPO3\CMS\Filelist\FileList::$fixedL = 30

Max length of strings

Definition at line 79 of file FileList.php.

◆ $folderObject

Folder TYPO3\CMS\Filelist\FileList::$folderObject
protected

◆ $iconFactory

IconFactory TYPO3\CMS\Filelist\FileList::$iconFactory
protected

Definition at line 152 of file FileList.php.

◆ $id

int TYPO3\CMS\Filelist\FileList::$id = 0
protected

Definition at line 156 of file FileList.php.

◆ $iLimit

int TYPO3\CMS\Filelist\FileList::$iLimit = 40

Default Max items shown

Definition at line 61 of file FileList.php.

Referenced by TYPO3\CMS\Filelist\FileList\getTable().

◆ $resourceFactory

ResourceFactory TYPO3\CMS\Filelist\FileList::$resourceFactory
protected

Definition at line 148 of file FileList.php.

◆ $searchDemand

FileSearchDemand TYPO3\CMS\Filelist\FileList::$searchDemand = null
protected

Definition at line 162 of file FileList.php.

Referenced by TYPO3\CMS\Filelist\FileList\getTable().

◆ $sort

string TYPO3\CMS\Filelist\FileList::$sort = ''

The field to sort by

Definition at line 85 of file FileList.php.

Referenced by TYPO3\CMS\Filelist\FileList\start().

◆ $sortRev

bool TYPO3\CMS\Filelist\FileList::$sortRev = true

Reverse sorting flag

Definition at line 91 of file FileList.php.

Referenced by TYPO3\CMS\Filelist\FileList\start().

◆ $spaceIcon

string TYPO3\CMS\Filelist\FileList::$spaceIcon

Space icon used for alignment when no button is available

Definition at line 73 of file FileList.php.

Referenced by TYPO3\CMS\Filelist\FileList\makeEdit().

◆ $thumbs

bool TYPO3\CMS\Filelist\FileList::$thumbs = false

Thumbnails on records containing files (pictures)

Definition at line 67 of file FileList.php.

◆ $totalbytes

int TYPO3\CMS\Filelist\FileList::$totalbytes = 0

Definition at line 99 of file FileList.php.

◆ $totalItems

int TYPO3\CMS\Filelist\FileList::$totalItems = 0

This could be set to the total number of items. Used by the fwd_rew_navigation...

Definition at line 105 of file FileList.php.

◆ $translateTools

TranslationConfigurationProvider TYPO3\CMS\Filelist\FileList::$translateTools

Definition at line 121 of file FileList.php.

◆ $translationRecords

TYPO3\CMS\Filelist\FileList::$translationRecords
Initial value:
= $queryBuilder->select('*')
->from('sys_file_metadata')
->where(
$queryBuilder->expr()->eq(
$languageParentField,
$queryBuilder->createNamedParameter($metaDataRecord['uid'] ?? 0, ‪Connection::PARAM_INT)
),
$queryBuilder->expr()->gt(
$languageField,
$queryBuilder->createNamedParameter(0, ‪Connection::PARAM_INT)
)
)
->executeQuery()
->fetchAllAssociative()

Definition at line 765 of file FileList.php.

◆ $translations [1/2]

TYPO3\CMS\Filelist\FileList::$translations = []

◆ $translations [2/2]

foreach ( $translationRecords as $record) return TYPO3\CMS\Filelist\FileList::$translations

Definition at line 785 of file FileList.php.

◆ $uriBuilder

UriBuilder TYPO3\CMS\Filelist\FileList::$uriBuilder
protected

Definition at line 160 of file FileList.php.

‪TYPO3\CMS\Core\Database\Connection\PARAM_INT
‪const PARAM_INT
Definition: Connection.php:49