‪TYPO3CMS  ‪main
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

 getExistingFilesConflictMode ()
 
 setExistingFilesConflictMode (DuplicationBehavior $existingFilesConflictMode)
 
 start ($fileCmds)
 
 setActionPermissions (array $permissions=[])
 
mixed processData ()
 
bool func_delete (array $cmds)
 
bool folderHasFilesInUse (Folder $folder)
 
TYPO3 CMS Core Resource File func_rename ($cmds)
 
Folder false func_newfolder ($cmds)
 
 func_newfile ($cmds)
 
bool func_edit ($cmds)
 
File[] bool func_upload ($cmds)
 
- ‪Public Member Functions inherited from ‪TYPO3\CMS\Core\Utility\File\BasicFileUtility
string null 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

 writeLog (int $action, int $severity, string $message, array $context=[])
 
 addMessageToFlashMessageQueue ($localizationKey, array $replaceMarkers=[], ContextualFeedbackSeverity $severity=ContextualFeedbackSeverity::ERROR)
 
array transformFileReferenceToRecordReference (array $referenceRecord)
 
 getFileObject (string $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)
 
 getBackendUser ()
 
 getLanguageService ()
 
- ‪Protected Member Functions inherited from ‪TYPO3\CMS\Core\Utility\File\BasicFileUtility
bool string sanitizeFolderPath ($theDir)
 

Protected Attributes

DuplicationBehavior $existingFilesConflictMode
 
array $flashMessages = array( )
 
array $fileCmdMap
 
TYPO3 CMS Core Resource ResourceFactory $fileFactory
 

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

All fileoperations must be within the filemount paths of the user.

Since TYPO3 v10, this class should not be used anymore outside of TYPO3 Core, and is considered internal, as the FAL API should be used instead.

Definition at line 75 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 584 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\addMessageToFlashMessageQueue(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getFileObject(), 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 933 of file ExtendedFileUtility.php.

References $GLOBALS, TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\addMessageToFlashMessageQueue(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getFileObject(), 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 674 of file ExtendedFileUtility.php.

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

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

◆ func_newfile()

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

Definition at line 888 of file ExtendedFileUtility.php.

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

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

◆ func_newfolder()

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
‪Folder|false Returns the new foldername upon success

Definition at line 847 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\addMessageToFlashMessageQueue(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getFileObject(), 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 folders (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 767 of file ExtendedFileUtility.php.

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

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

◆ func_upload()

File [] bool 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[]|bool Returns an array of new file objects upon success. False otherwise

Definition at line 1003 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\addMessageToFlashMessageQueue(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getFileObject(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getIndexer(), TYPO3\CMS\Core\Resource\Index\Indexer\updateIndexEntry(), and TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\writeLog().

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

◆ getBackendUser()

TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::getBackendUser ( )
protected

◆ getExistingFilesConflictMode()

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

Get existingFilesConflictMode

Definition at line 133 of file ExtendedFileUtility.php.

◆ getFileObject()

◆ getIndexer()

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

Gets Indexer

Returns
‪\TYPO3\CMS\Core\Resource\Index\Indexer

Definition at line 1163 of file ExtendedFileUtility.php.

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

◆ getLanguageService()

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

Returns
‪array|bool
Exceptions
Exception

Definition at line 1085 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\addMessageToFlashMessageQueue(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getFileObject(), 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 165 of file ExtendedFileUtility.php.

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

◆ setExistingFilesConflictMode()

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

Set existingFilesConflictMode

Definition at line 141 of file ExtendedFileUtility.php.

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

◆ 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 151 of file ExtendedFileUtility.php.

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

Returns
‪array

Definition at line 530 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Database\Connection\PARAM_INT.

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

◆ writeLog()

TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::writeLog ( int  $action,
int  $severity,
string  $message,
array  $context = [] 
)
protected

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 88 of file ExtendedFileUtility.php.

◆ $existingFilesConflictMode

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

Defines behaviour when uploading files with names that already exist;

Definition at line 80 of file ExtendedFileUtility.php.

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

◆ $fileCmdMap

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

Definition at line 122 of file ExtendedFileUtility.php.

◆ $fileFactory

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

The File Factory

Definition at line 128 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 118 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 112 of file ExtendedFileUtility.php.