TYPO3 CMS  TYPO3_7-6
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 ($existingFilesConflictMode)
 
 start ($fileCmds)
 
 setActionPermissions (array $permissions=[])
 
 processData ()
 
 pushErrorMessagesToFlashMessageQueue ()
 
 getErrorMessages ()
 
 writeLog ($action, $error, $details_nr, $details, $data)
 
 func_rename ($cmds)
 
 func_newfolder ($cmds)
 
 func_newfile ($cmds)
 
 func_edit ($cmds)
 
 func_unzip ($cmds)
 
- Public Member Functions inherited from TYPO3\CMS\Core\Utility\File\BasicFileUtility
 init ($mounts, $f_ext)
 
 is_allowed ($iconkey, $type)
 
 checkIfFullAccess ($theDest)
 
 is_webpath ($path)
 
 checkIfAllowed ($ext, $theDest, $filename='')
 
 is_directory ($theDir)
 
 getUniqueName ($theFile, $theDest, $dontCheckForUnique=0)
 
 checkPathAgainstMounts ($thePath)
 
 findFirstWebFolder ()
 
 slashPath ($path)
 
 cleanFileName ($fileName, $charset='')
 

Public Attributes

 $unzipPath = ''
 
 $dontCheckForUnique = 0
 
 $actionPerms
 
 $recyclerFN = '_recycler_'
 
 $internalUploadMap = []
 
 $lastError = ''
 
- Public Attributes inherited from TYPO3\CMS\Core\Utility\File\BasicFileUtility
const UNSAFE_FILENAME_CHARACTER_EXPRESSION = '\\x00-\\x2C\\/\\x3A-\\x3F\\x5B-\\x60\\x7B-\\xBF'
 
 $getUniqueNamePrefix = ''
 
 $maxNumber = 99
 
 $uniquePrecision = 6
 
 $maxInputNameLen = 60
 
 $tempFN = '_temp_'
 
 $f_ext = []
 
 $mounts = []
 
 $webPath = ''
 
 $isInit = 0
 
 $csConvObj
 

Protected Member Functions

 addMessageToFlashMessageQueue ($localizationKey, array $replaceMarkers=[], $severity=FlashMessage::ERROR)
 
 transformFileReferenceToRecordReference (array $referenceRecord)
 
 getFileObject ($identifier)
 
 func_move ($cmds)
 
 replaceFile (array $cmdArr)
 
 getIndexer (ResourceStorage $storage)
 
 getDatabaseConnection ()
 
 getBackendUser ()
 
 getLanguageService ()
 

Protected Attributes

 $existingFilesConflictMode
 
 $errorMessages = []
 
 $flashMessages = []
 
 $fileCmdMap
 
 $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...

Important internal variables:

$filemounts (see basicFileFunctions) $f_ext (see basicFileFunctions)

All fileoperations must be within the filemount-paths. Further the fileextension MUST validate TRUE with the f_ext array

The unzip-function allows unzip only if the destination path has it's f_ext[]['allow'] set to '*'!! You are allowed to copy/move folders within the same 'space' (web/ftp). You are allowed to copy/move folders between spaces (web/ftp) IF the destination has it's f_ext[]['allow'] set to '*'!

Advice: You should always exclude php-files from the webspace. This will keep people from uploading, copy/moving and renaming files to become executable php scripts. You should never mount a ftp_space 'below' the webspace so that it reaches into the webspace. This is because if somebody unzips a zip-file in the ftp-space so that it reaches out into the webspace this will be a violation of the safety For example this is a bad idea: you have an ftp-space that is '/www/' and a web-space that is '/www/htdocs/'

Definition at line 69 of file ExtendedFileUtility.php.

Member Function Documentation

◆ addMessageToFlashMessageQueue()

TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::addMessageToFlashMessageQueue (   $localizationKey,
array  $replaceMarkers = [],
  $severity = FlashMessage::ERROR 
)
protected

Adds a localized FlashMessage to the message queue

Parameters
string$localizationKey
array$replaceMarkers
int$severity
Returns
void
Exceptions

Definition at line 397 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Messaging\AbstractMessage\ERROR, TYPO3\CMS\Core\Resource\Folder\FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS, TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getDatabaseConnection(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getFileObject(), TYPO3\CMS\Core\Resource\Folder\getFiles(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getLanguageService(), TYPO3\CMS\Backend\Utility\BackendUtility\getRecord(), TYPO3\CMS\Core\Messaging\AbstractMessage\INFO, TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance(), TYPO3\CMS\Core\Messaging\AbstractMessage\OK, TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\transformFileReferenceToRecordReference(), TYPO3\CMS\Core\Messaging\AbstractMessage\WARNING, and TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\writeLog().

Referenced by 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_unzip(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getFileObject(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\processData(), and TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\replaceFile().

◆ func_edit()

◆ func_move()

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

Definition at line 762 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()

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 968 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_newfolder()

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

Definition at line 923 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\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
Returns the new file upon success

Definition at line 858 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_unzip()

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

Unzipping file (action=7) This is permitted only if the user has fullAccess or if the file resides

Parameters
array$cmds$cmds['data'] is the zip-file. $cmds['target'] is the target directory. If not set we'll default to the same directory as the file is in.
Returns
bool Returns TRUE on success

Definition at line 1172 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\addMessageToFlashMessageQueue(), TYPO3\CMS\Core\Utility\File\BasicFileUtility\checkIfFullAccess(), TYPO3\CMS\Core\Utility\File\BasicFileUtility\checkPathAgainstMounts(), TYPO3\CMS\Core\Utility\CommandUtility\exec(), TYPO3\CMS\Core\Utility\File\BasicFileUtility\is_directory(), TYPO3\CMS\Core\Messaging\AbstractMessage\OK, TYPO3\CMS\Core\Utility\GeneralUtility\split_fileref(), 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

◆ getDatabaseConnection()

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

◆ getErrorMessages()

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

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

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

◆ getExistingFilesConflictMode()

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

Get existingFilesConflictMode

Returns
string

Definition at line 174 of file ExtendedFileUtility.php.

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

◆ getFileObject()

◆ getIndexer()

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

Gets Indexer

Parameters
\TYPO3\CMS\Core\Resource\ResourceStorage$storage
Returns

Definition at line 1322 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

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

◆ getLanguageService()

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

Returns LanguageService

Returns
LanguageService

Definition at line 1350 of file ExtendedFileUtility.php.

References $GLOBALS.

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

◆ processData()

◆ pushErrorMessagesToFlashMessageQueue()

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

Adds all log error messages from the operations of this script instance to the FlashMessageQueue

Returns
void

Definition at line 343 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Messaging\AbstractMessage\ERROR, TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getErrorMessages(), and TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

◆ replaceFile()

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

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

Definition at line 228 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$existingFilesConflictModeInstance or constant of
Returns
void
Exceptions
Exception

Definition at line 186 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$fileCmdsArray with the commands to execute. See "TYPO3 Core API" document
Returns
void

Definition at line 207 of file ExtendedFileUtility.php.

References $GLOBALS, TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$unzipPath, and TYPO3\CMS\Core\Resource\ResourceFactory\getInstance().

◆ transformFileReferenceToRecordReference()

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

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

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

◆ writeLog()

TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::writeLog (   $action,
  $error,
  $details_nr,
  $details,
  $data 
)
Parameters
int$actionThe action number. See the functions in the class for a hint. Eg. edit is '9', upload is '1' ...
int$errorThe severity: 0 = message, 1 = error, 2 = System Error, 3 = security notice (admin)
int$details_nrThis 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$detailsThis is the default, raw error message in english
array$dataArray with special information that may go into $details by "%s" marks / sprintf() when the log is shown
Returns
void

Definition at line 375 of file ExtendedFileUtility.php.

References TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$lastError, and TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getBackendUser().

Referenced by TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\addMessageToFlashMessageQueue(), 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_unzip(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getFileObject(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\processData(), and TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\replaceFile().

Member Data Documentation

◆ $actionPerms

TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::$actionPerms
Initial value:
= [
'addFile' => false

Definition at line 103 of file ExtendedFileUtility.php.

◆ $dontCheckForUnique

TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::$dontCheckForUnique = 0

Definition at line 86 of file ExtendedFileUtility.php.

◆ $errorMessages

TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::$errorMessages = []
protected

◆ $existingFilesConflictMode

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

◆ $fileCmdMap

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

Definition at line 160 of file ExtendedFileUtility.php.

◆ $fileFactory

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

Definition at line 167 of file ExtendedFileUtility.php.

◆ $flashMessages

TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::$flashMessages = []
protected

Definition at line 155 of file ExtendedFileUtility.php.

◆ $internalUploadMap

TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::$internalUploadMap = []

Definition at line 136 of file ExtendedFileUtility.php.

◆ $lastError

TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::$lastError = ''

◆ $recyclerFN

TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::$recyclerFN = '_recycler_'

Definition at line 129 of file ExtendedFileUtility.php.

◆ $unzipPath

TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::$unzipPath = ''