TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
ExtendedFileUtility Class Reference
Inheritance diagram for ExtendedFileUtility:
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)
 
- Public Member Functions inherited from BasicFileUtility
 __construct ()
 
 setFileExtensionPermissions ($allowedFilePermissions, $deniedFilePermissions)
 
 checkIfAllowed ($ext, $_, $filename= '')
 
 getUniqueName ($theFile, $theDest, $dontCheckForUnique=false)
 
 cleanFileName ($fileName)
 

Public Attributes

 $actionPerms
 
 $internalUploadMap = []
 
- Public Attributes inherited from BasicFileUtility
const UNSAFE_FILENAME_CHARACTER_EXPRESSION = '\\x00-\\x2C\\/\\x3A-\\x3F\\x5B-\\x60\\x7B-\\xBF'
 
 $maxNumber = 99
 
 $uniquePrecision = 6
 

Protected Member Functions

 addMessageToFlashMessageQueue ($localizationKey, array $replaceMarkers=[], $severity=FlashMessage::ERROR)
 
 transformFileReferenceToRecordReference (array $referenceRecord)
 
 getFileObject ($identifier)
 
 func_move ($cmds)
 
 replaceFile (array $cmdArr)
 
 getIndexer (ResourceStorage $storage)
 
 getBackendUser ()
 
 getLanguageService ()
 
- Protected Member Functions inherited from BasicFileUtility
 is_allowed ($fileExtension)
 
 is_directory ($theDir)
 

Protected Attributes

 $existingFilesConflictMode
 
 $errorMessages = []
 
 $flashMessages = []
 
 $fileCmdMap
 
 $fileFactory
 
- Protected Attributes inherited from BasicFileUtility
 $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 61 of file ExtendedFileUtility.php.

Member Function Documentation

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
InvalidArgumentException

Definition at line 349 of file ExtendedFileUtility.php.

References ExtendedFileUtility\getLanguageService(), and GeneralUtility\makeInstance().

Referenced by ExtendedFileUtility\func_edit(), ExtendedFileUtility\func_move(), ExtendedFileUtility\func_newfile(), ExtendedFileUtility\func_newfolder(), ExtendedFileUtility\func_rename(), ExtendedFileUtility\processData(), and ExtendedFileUtility\replaceFile().

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

References $GLOBALS, ExtendedFileUtility\addMessageToFlashMessageQueue(), ExtendedFileUtility\getFileObject(), GeneralUtility\inList(), AbstractMessage\OK, and ExtendedFileUtility\writeLog().

Referenced by ExtendedFileUtility\processData().

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

References ExtendedFileUtility\addMessageToFlashMessageQueue(), DuplicationBehavior\CANCEL, ExtendedFileUtility\getFileObject(), AbstractMessage\OK, DuplicationBehavior\RENAME, and ExtendedFileUtility\writeLog().

Referenced by ExtendedFileUtility\processData().

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

References ExtendedFileUtility\addMessageToFlashMessageQueue(), ExtendedFileUtility\getFileObject(), AbstractMessage\OK, and ExtendedFileUtility\writeLog().

Referenced by ExtendedFileUtility\processData().

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

References ExtendedFileUtility\addMessageToFlashMessageQueue(), ExtendedFileUtility\getFileObject(), AbstractMessage\OK, and ExtendedFileUtility\writeLog().

Referenced by ExtendedFileUtility\processData().

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

References ExtendedFileUtility\addMessageToFlashMessageQueue(), ExtendedFileUtility\getFileObject(), AbstractMessage\OK, and ExtendedFileUtility\writeLog().

Referenced by ExtendedFileUtility\processData().

getBackendUser ( )
protected
Returns

Definition at line 1224 of file ExtendedFileUtility.php.

References $GLOBALS.

Referenced by ExtendedFileUtility\setActionPermissions(), and ExtendedFileUtility\writeLog().

getErrorMessages ( )

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

Returns
array all errorMessages as a numerical array

Definition at line 315 of file ExtendedFileUtility.php.

References ExtendedFileUtility\$errorMessages.

Referenced by ExtendedFileUtility\pushErrorMessagesToFlashMessageQueue().

getExistingFilesConflictMode ( )

Get existingFilesConflictMode

Returns
string

Definition at line 136 of file ExtendedFileUtility.php.

References ExtendedFileUtility\$existingFilesConflictMode.

getFileObject (   $identifier)
protected

Gets a File or a Folder object from an identifier [storage]:[fileId]

Parameters
string$identifier
Returns
File|Folder
Exceptions
ExceptionInsufficientFileAccessPermissionsException
ExceptionInvalidFileException

Definition at line 628 of file ExtendedFileUtility.php.

Referenced by ExtendedFileUtility\func_edit(), ExtendedFileUtility\func_move(), ExtendedFileUtility\func_newfile(), ExtendedFileUtility\func_newfolder(), ExtendedFileUtility\func_rename(), and ExtendedFileUtility\replaceFile().

getIndexer ( ResourceStorage  $storage)
protected

Gets Indexer

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

Definition at line 1216 of file ExtendedFileUtility.php.

References GeneralUtility\makeInstance().

getLanguageService ( )
protected

Returns LanguageService

Returns
LanguageService

Definition at line 1234 of file ExtendedFileUtility.php.

References $GLOBALS.

Referenced by ExtendedFileUtility\addMessageToFlashMessageQueue().

processData ( )
pushErrorMessagesToFlashMessageQueue ( )

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

Returns
void
Deprecated:
since TYPO3 CMS 8, will be removed in TYPO3 CMS 9

Definition at line 295 of file ExtendedFileUtility.php.

References AbstractMessage\ERROR, ExtendedFileUtility\getErrorMessages(), GeneralUtility\logDeprecatedFunction(), and GeneralUtility\makeInstance().

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
ExceptionInsufficientFileAccessPermissionsException
ExceptionInvalidFileException
RuntimeException

Definition at line 1133 of file ExtendedFileUtility.php.

References ExtendedFileUtility\addMessageToFlashMessageQueue(), ExtendedFileUtility\getFileObject(), AbstractMessage\OK, DuplicationBehavior\RENAME, DuplicationBehavior\REPLACE, and ExtendedFileUtility\writeLog().

Referenced by ExtendedFileUtility\processData().

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

References ExtendedFileUtility\getBackendUser().

setExistingFilesConflictMode (   $existingFilesConflictMode)

Set existingFilesConflictMode

Parameters
\TYPO3\CMS\Core\Resource\DuplicationBehavior | string$existingFilesConflictModeInstance or constant of
Returns
void
Exceptions
Exception

Definition at line 148 of file ExtendedFileUtility.php.

References ExtendedFileUtility\$existingFilesConflictMode, Enumeration\cast(), and Enumeration\getConstants().

start (   $fileCmds)

Initialization of the class

Parameters
array$fileCmdsArray with the commands to execute. See "TYPO3 Core API" document
Returns
void

Definition at line 170 of file ExtendedFileUtility.php.

References ResourceFactory\getInstance().

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

References GeneralUtility\makeInstance().

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

References ExtendedFileUtility\getBackendUser().

Referenced by ExtendedFileUtility\func_edit(), ExtendedFileUtility\func_move(), ExtendedFileUtility\func_newfile(), ExtendedFileUtility\func_newfolder(), ExtendedFileUtility\func_rename(), ExtendedFileUtility\processData(), and ExtendedFileUtility\replaceFile().

Member Data Documentation

$actionPerms
Initial value:
= [
'addFile' => false

Definition at line 78 of file ExtendedFileUtility.php.

$errorMessages = []
protected

Definition at line 110 of file ExtendedFileUtility.php.

Referenced by ExtendedFileUtility\getErrorMessages().

$existingFilesConflictMode
protected
$fileCmdMap
protected

Definition at line 122 of file ExtendedFileUtility.php.

$fileFactory
protected

Definition at line 129 of file ExtendedFileUtility.php.

$flashMessages = []
protected

Definition at line 117 of file ExtendedFileUtility.php.

$internalUploadMap = []

Definition at line 103 of file ExtendedFileUtility.php.