‪TYPO3CMS  9.5
TYPO3\CMS\Core\Utility\File\ExtendedFileUtility Class Reference
Inheritance diagram for TYPO3\CMS\Core\Utility\File\ExtendedFileUtility:
TYPO3\CMS\Core\Utility\File\BasicFileUtility

Public Member Functions

string getExistingFilesConflictMode ()
 
 setExistingFilesConflictMode ($existingFilesConflictMode)
 
 start ($fileCmds)
 
 setActionPermissions (array $permissions=[])
 
mixed processData ()
 
array getErrorMessages ()
 
 writeLog ($action, $error, $details_nr, $details, $data)
 
bool func_delete (array $cmds)
 
bool folderHasFilesInUse (Folder $folder)
 
TYPO3 CMS Core Resource File func_rename ($cmds)
 
TYPO3 CMS Core Resource Folder false func_newfolder ($cmds)
 
string func_newfile ($cmds)
 
bool func_edit ($cmds)
 
File[] func_upload ($cmds)
 
- ‪Public Member Functions inherited from ‪TYPO3\CMS\Core\Utility\File\BasicFileUtility
 setFileExtensionPermissions ($allowedFilePermissions, $deniedFilePermissions)
 
bool checkIfAllowed ($ext, $_, $filename='')
 
string getUniqueName ($theFile, $theDest, $dontCheckForUnique=false)
 
string cleanFileName ($fileName)
 

Public Attributes

array $actionPerms
 
array $internalUploadMap = array( )
 
- ‪Public Attributes inherited from ‪TYPO3\CMS\Core\Utility\File\BasicFileUtility
const UNSAFE_FILENAME_CHARACTER_EXPRESSION = '\\x00-\\x2C\\/\\x3A-\\x3F\\x5B-\\x60\\x7B-\\xBF'
 
int $maxNumber = 99
 
int $uniquePrecision = 6
 

Protected Member Functions

 addMessageToFlashMessageQueue ($localizationKey, array $replaceMarkers=[], $severity=FlashMessage::ERROR)
 
array transformFileReferenceToRecordReference (array $referenceRecord)
 
File Folder getFileObject ($identifier)
 
TYPO3 CMS Core Resource File false func_copy ($cmds)
 
TYPO3 CMS Core Resource File false func_move ($cmds)
 
array bool replaceFile (array $cmdArr)
 
 addFlashMessage (FlashMessage $flashMessage)
 
TYPO3 CMS Core Resource Index Indexer getIndexer (ResourceStorage $storage)
 
TYPO3 CMS Core Authentication BackendUserAuthentication getBackendUser ()
 
LanguageService getLanguageService ()
 
- ‪Protected Member Functions inherited from ‪TYPO3\CMS\Core\Utility\File\BasicFileUtility
bool is_allowed ($fileExtension)
 
bool string is_directory ($theDir)
 

Protected Attributes

TYPO3 CMS Core Resource DuplicationBehavior $existingFilesConflictMode
 
array $errorMessages = array( )
 
array $flashMessages = array( )
 
array $fileCmdMap
 
TYPO3 CMS Core Resource ResourceFactory $fileFactory
 
- ‪Protected Attributes inherited from ‪TYPO3\CMS\Core\Utility\File\BasicFileUtility
array $fileExtensionPermissions
 

Detailed Description

Contains functions for performing file operations like copying, pasting, uploading, moving, deleting etc. through the TCE

See document "TYPO3 Core API" for syntax

This class contains functions primarily used by tce_file.php (TYPO3 Core Engine for file manipulation) Functions include copying, moving, deleting, uploading and so on...

Important internal variables:

$fileExtensionPermissions (see basicFileFunctions)

All fileoperations must be within the filemount paths of the user. Further the fileextension MUST validate TRUE with the fileExtensionPermissions array

Definition at line 62 of file ExtendedFileUtility.php.

Member Function Documentation

◆ addFlashMessage()

TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::addFlashMessage ( FlashMessage  $flashMessage)
protected

◆ addMessageToFlashMessageQueue()

◆ folderHasFilesInUse()

bool TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::folderHasFilesInUse ( Folder  $folder)

◆ func_copy()

TYPO3 CMS Core Resource File false TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::func_copy (   $cmds)
protected

Copying files and folders (action=2)

$cmds['data'] (string): The file/folder to copy

  • ‪example "4:mypath/tomyfolder/myfile.jpg")
  • ‪for backwards compatibility: the identifier was the path+filename $cmds['target'] (string): The path where to copy to.
  • ‪example "2:targetpath/targetfolder/" $cmds['altName'] (string): Use an alternative name if the target already exists
Parameters
array$cmdsCommand details as described above
Returns
‪\TYPO3\CMS\Core\Resource\File|false

Definition at line 630 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\addMessageToFlashMessageQueue(), TYPO3\CMS\Core\Resource\DuplicationBehavior\CANCEL, TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getFileObject(), TYPO3\CMS\Core\Messaging\AbstractMessage\OK, TYPO3\CMS\Core\Resource\DuplicationBehavior\RENAME, and TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\writeLog().

Referenced by TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\processData().

◆ func_delete()

◆ func_edit()

bool TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::func_edit (   $cmds)

Editing textfiles or folders (action=9)

Parameters
array$cmds‪$cmds['data'] is the new content. $cmds['target'] is the target (file or dir)
Returns
‪bool Returns TRUE on success

Definition at line 979 of file ExtendedFileUtility.php.

References $GLOBALS, TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\addMessageToFlashMessageQueue(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getFileObject(), TYPO3\CMS\Core\Messaging\AbstractMessage\OK, and TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\writeLog().

Referenced by TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\processData().

◆ func_move()

TYPO3 CMS Core Resource File false TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::func_move (   $cmds)
protected

Moving files and folders (action=3)

$cmds['data'] (string): The file/folder to move

  • ‪example "4:mypath/tomyfolder/myfile.jpg")
  • ‪for backwards compatibility: the identifier was the path+filename $cmds['target'] (string): The path where to move to.
  • ‪example "2:targetpath/targetfolder/" $cmds['altName'] (string): Use an alternative name if the target already exists
Parameters
array$cmdsCommand details as described above
Returns
‪\TYPO3\CMS\Core\Resource\File|false

Definition at line 720 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\addMessageToFlashMessageQueue(), TYPO3\CMS\Core\Resource\DuplicationBehavior\CANCEL, TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getFileObject(), TYPO3\CMS\Core\Messaging\AbstractMessage\OK, TYPO3\CMS\Core\Resource\DuplicationBehavior\RENAME, and TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\writeLog().

Referenced by TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\processData().

◆ func_newfile()

string TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::func_newfile (   $cmds)

This creates a new file. (action=8) $cmds['data'] (string): The new file name $cmds['target'] (string): The path where to create it.

  • ‪example "2:targetpath/targetfolder/"
Parameters
array$cmdsCommand details as described above
Returns
‪string Returns the new filename upon success

Definition at line 934 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\addMessageToFlashMessageQueue(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getFileObject(), TYPO3\CMS\Core\Messaging\AbstractMessage\OK, TYPO3\CMS\Core\Messaging\AbstractMessage\WARNING, and TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\writeLog().

Referenced by TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\processData().

◆ func_newfolder()

TYPO3 CMS Core Resource Folder false TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::func_newfolder (   $cmds)

This creates a new folder. (action=6)

$cmds['data'] (string): The new folder name $cmds['target'] (string): The path where to copy to.

  • ‪example "2:targetpath/targetfolder/"
Parameters
array$cmdsCommand details as described above
Returns
‪\TYPO3\CMS\Core\Resource\Folder|false Returns the new foldername upon success

Definition at line 893 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\addMessageToFlashMessageQueue(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getFileObject(), TYPO3\CMS\Core\Messaging\AbstractMessage\OK, and TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\writeLog().

Referenced by TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\processData().

◆ func_rename()

TYPO3 CMS Core Resource File TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::func_rename (   $cmds)

Renaming files or foldes (action=5)

$cmds['data'] (string): The file/folder to copy

  • ‪example "4:mypath/tomyfolder/myfile.jpg")
  • ‪for backwards compatibility: the identifier was the path+filename $cmds['target'] (string): New name of the file/folder
Parameters
array$cmdsCommand details as described above
Returns
‪\TYPO3\CMS\Core\Resource\File Returns the new file upon success

Definition at line 813 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\addMessageToFlashMessageQueue(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getFileObject(), TYPO3\CMS\Core\Messaging\AbstractMessage\INFO, TYPO3\CMS\Core\Messaging\AbstractMessage\OK, TYPO3\CMS\Core\Messaging\AbstractMessage\WARNING, and TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\writeLog().

Referenced by TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\processData().

◆ func_upload()

File [] TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::func_upload (   $cmds)

Upload of files (action=1) when having multiple uploads (HTML5-style), the array $_FILES looks like this: Array( [upload_1] => Array( [name] => Array( [0] => GData - Content-Elements and Media-Gallery.pdf [1] => CMS Expo 2011.txt ) [type] => Array( [0] => application/pdf [1] => text/plain ) [tmp_name] => Array( [0] => /Applications/MAMP/tmp/php/phpNrOB43 [1] => /Applications/MAMP/tmp/php/phpD2HQAK ) [size] => Array( [0] => 373079 [1] => 1291 ) ) ) in HTML you'd need sth like this: <input type="file" name="upload_1[]" multiple="true" >

Parameters
array$cmds‪$cmds['data'] is the ID-number (points to the global var that holds the filename-ref ($_FILES['upload_' . $id]['name']) . $cmds['target'] is the target directory, $cmds['charset'] is the the character set of the file name (utf-8 is needed for JS-interaction)
Returns
File[] | FALSE Returns an array of new file objects upon success. False otherwise

Definition at line 1053 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\addMessageToFlashMessageQueue(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getFileObject(), TYPO3\CMS\Core\Resource\ResourceFactory\getFileObjectByStorageAndIdentifier(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getIndexer(), TYPO3\CMS\Core\Resource\ResourceFactory\getInstance(), TYPO3\CMS\Core\Messaging\AbstractMessage\OK, TYPO3\CMS\Core\Resource\DuplicationBehavior\REPLACE, TYPO3\CMS\Core\Messaging\AbstractMessage\WARNING, and TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\writeLog().

Referenced by TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\processData().

◆ getBackendUser()

TYPO3 CMS Core Authentication BackendUserAuthentication TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::getBackendUser ( )
protected
Returns
‪\TYPO3\CMS\Core\Authentication\BackendUserAuthentication

Definition at line 1227 of file ExtendedFileUtility.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\setActionPermissions(), and TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\writeLog().

◆ getErrorMessages()

array TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::getErrorMessages ( )

Return all error messages from the file operations of this script instance

Returns
‪array all errorMessages as a numerical array

Definition at line 284 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$errorMessages.

◆ getExistingFilesConflictMode()

string TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::getExistingFilesConflictMode ( )

Get existingFilesConflictMode

Returns
‪string

Definition at line 130 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$existingFilesConflictMode.

◆ getFileObject()

◆ getIndexer()

TYPO3 CMS Core Resource Index Indexer TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::getIndexer ( ResourceStorage  $storage)
protected

Gets Indexer

Parameters
\TYPO3\CMS\Core\Resource\ResourceStorage$storage
Returns
‪\TYPO3\CMS\Core\Resource\Index\Indexer

Definition at line 1219 of file ExtendedFileUtility.php.

Referenced by TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_upload().

◆ getLanguageService()

LanguageService TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::getLanguageService ( )
protected

◆ processData()

◆ replaceFile()

array bool TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::replaceFile ( array  $cmdArr)
protected

Replaces a file on the filesystem and changes the identifier of the persisted file object in sys_file if keepFilename is not checked. If keepFilename is checked, only the file content will be replaced.

Parameters
array$cmdArr
Returns
‪array|bool
Exceptions
Exception

Definition at line 1137 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\addMessageToFlashMessageQueue(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getFileObject(), TYPO3\CMS\Core\Messaging\AbstractMessage\OK, TYPO3\CMS\Core\Resource\DuplicationBehavior\RENAME, TYPO3\CMS\Core\Resource\DuplicationBehavior\REPLACE, and TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\writeLog().

Referenced by TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\processData().

◆ setActionPermissions()

TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::setActionPermissions ( array  $permissions = [])

Sets the file action permissions. If no argument is given, permissions of the currently logged in backend user are taken into account.

Parameters
array$permissionsFile Permissions.

Definition at line 176 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getBackendUser().

◆ setExistingFilesConflictMode()

TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::setExistingFilesConflictMode (   $existingFilesConflictMode)

Set existingFilesConflictMode

Parameters
\TYPO3\CMS\Core\Resource\DuplicationBehavior | string$existingFilesConflictMode‪Instance or constant of \TYPO3\CMS\Core\Resource\DuplicationBehavior
Exceptions
Exception

Definition at line 141 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$existingFilesConflictMode, TYPO3\CMS\Core\Type\Enumeration\cast(), and TYPO3\CMS\Core\Type\Enumeration\getConstants().

◆ start()

TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::start (   $fileCmds)

Initialization of the class

Parameters
array$fileCmds‪Array with the commands to execute. See "TYPO3 Core API" document

Definition at line 162 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Resource\ResourceFactory\getInstance().

◆ transformFileReferenceToRecordReference()

array TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::transformFileReferenceToRecordReference ( array  $referenceRecord)
protected

Maps results from the fal file reference table on the structure of the normal reference index table.

Parameters
array$referenceRecord
Returns
‪array

Definition at line 571 of file ExtendedFileUtility.php.

Referenced by TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_delete().

◆ writeLog()

TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::writeLog (   $action,
  $error,
  $details_nr,
  $details,
  $data 
)
Parameters
int$action‪The action number. See the functions in the class for a hint. Eg. edit is '9', upload is '1' ...
int$error‪The severity: 0 = message, 1 = error, 2 = System Error, 3 = security notice (admin)
int$details_nr‪This number is unique for every combination of $type and $action. This is the error-message number, which can later be used to translate error messages.
string$details‪This is the default, raw error message in english
array$data‪Array with special information that may go into $details by "%s" marks / sprintf() when the log is shown

Definition at line 296 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getBackendUser().

Referenced by TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_copy(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_delete(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_edit(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_move(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_newfile(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_newfolder(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_rename(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_upload(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\processData(), and TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\replaceFile().

Member Data Documentation

◆ $actionPerms

array TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::$actionPerms
Initial value:
= array(
'addFile' => false,
'readFile' => false,
'writeFile' => false,
'copyFile' => false,
'moveFile' => false,
'renameFile' => false,
'deleteFile' => false,
'addFolder' => false,
'readFolder' => false,
'writeFolder' => false,
'copyFolder' => false,
'moveFolder' => false,
'renameFolder' => false,
'deleteFolder' => false,
'recursivedeleteFolder' => false
)

This array is self-explaining (look in the class below). It grants access to the functions. This could be set from outside in order to enabled functions to users. See also the function setActionPermissions() which takes input directly from the user-record

Definition at line 77 of file ExtendedFileUtility.php.

◆ $errorMessages

array TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::$errorMessages = array( )
protected

All error messages from the file operations of this script instance

Definition at line 107 of file ExtendedFileUtility.php.

Referenced by TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getErrorMessages().

◆ $existingFilesConflictMode

TYPO3 CMS Core Resource DuplicationBehavior TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::$existingFilesConflictMode
protected

Defines behaviour when uploading files with names that already exist; possible values are the values of the \TYPO3\CMS\Core\Resource\DuplicationBehavior enumeration

Definition at line 69 of file ExtendedFileUtility.php.

Referenced by TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getExistingFilesConflictMode(), and TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\setExistingFilesConflictMode().

◆ $fileCmdMap

array TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::$fileCmdMap
protected

Definition at line 117 of file ExtendedFileUtility.php.

◆ $fileFactory

TYPO3 CMS Core Resource ResourceFactory TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::$fileFactory
protected

The File Factory

Definition at line 123 of file ExtendedFileUtility.php.

◆ $flashMessages

array TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::$flashMessages = array( )
protected

Container for FlashMessages so they can be localized

Definition at line 113 of file ExtendedFileUtility.php.

◆ $internalUploadMap

array TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::$internalUploadMap = array( )

Will contain map between upload ID and the final filename

Definition at line 101 of file ExtendedFileUtility.php.