TYPO3  7.6
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Folder Class Reference
Inheritance diagram for Folder:
FolderInterface ResourceInterface InaccessibleFolder

Public Member Functions

 __construct (ResourceStorage $storage, $identifier, $name)
 
 getName ()
 
 getReadablePath ($rootId=null)
 
 setName ($name)
 
 getStorage ()
 
 getIdentifier ()
 
 getHashedIdentifier ()
 
 getCombinedIdentifier ()
 
 getPublicUrl ($relativeToCurrentScript=false)
 
 getFiles ($start=0, $numberOfItems=0, $filterMode=self::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS, $recursive=false, $sort= '', $sortRev=false)
 
 getFileCount (array $filterMethods=array(), $recursive=false)
 
 getSubfolder ($name)
 
 getSubfolders ($start=0, $numberOfItems=0, $filterMode=self::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS, $recursive=false)
 
 addFile ($localFilePath, $fileName=null, $conflictMode=DuplicationBehavior::CANCEL)
 
 addUploadedFile (array $uploadedFileData, $conflictMode=DuplicationBehavior::CANCEL)
 
 rename ($newName)
 
 delete ($deleteRecursively=true)
 
 createFile ($fileName)
 
 createFolder ($folderName)
 
 copyTo (Folder $targetFolder, $targetFolderName=null, $conflictMode=DuplicationBehavior::RENAME)
 
 moveTo (Folder $targetFolder, $targetFolderName=null, $conflictMode=DuplicationBehavior::RENAME)
 
 hasFile ($name)
 
 hasFolder ($name)
 
 checkActionPermission ($action)
 
 updateProperties (array $properties)
 
 setFileAndFolderNameFilters (array $filters)
 
 getRole ()
 
 getParentFolder ()
 
- Public Member Functions inherited from FolderInterface
 getSubfolders ()
 
 delete ()
 

Public Attributes

const FILTER_MODE_NO_FILTERS = 0
 
const FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS = 1
 
const FILTER_MODE_USE_STORAGE_FILTERS = 2
 
const FILTER_MODE_USE_OWN_FILTERS = 3
 
- Public Attributes inherited from FolderInterface
const ROLE_DEFAULT = 'default'
 
const ROLE_RECYCLER = 'recycler'
 
const ROLE_PROCESSING = 'processing'
 
const ROLE_TEMPORARY = 'temporary'
 
const ROLE_USERUPLOAD = 'userupload'
 
const ROLE_MOUNT = 'mount'
 
const ROLE_READONLY_MOUNT = 'readonly-mount'
 
const ROLE_USER_MOUNT = 'user-mount'
 

Protected Member Functions

 prepareFiltersInStorage ($filterMode)
 
 restoreBackedUpFiltersInStorage ($backedUpFilters)
 

Protected Attributes

 $storage
 
 $identifier
 
 $name
 
 $fileAndFolderNameFilters = array()
 

Detailed Description

A folder that groups files in a storage. This may be a folder on the local disk, a bucket in Amazon S3 or a user or a tag in Flickr.

This object is not persisted in TYPO3 locally, but created on the fly by storage drivers for the folders they "offer".

Some folders serve as a physical container for files (e.g. folders on the local disk, S3 buckets or Flickr users). Other folders just group files by a certain criterion, e.g. a tag. The way this is implemented depends on the storage driver.

Definition at line 31 of file core/Classes/Resource/Folder.php.

Constructor & Destructor Documentation

__construct ( ResourceStorage  $storage,
  $identifier,
  $name 
)

Initialization of the folder

Parameters
ResourceStorage$storage
$identifier
$name

Definition at line 81 of file core/Classes/Resource/Folder.php.

References Folder\$identifier, Folder\$name, and Folder\$storage.

Member Function Documentation

addFile (   $localFilePath,
  $fileName = null,
  $conflictMode = DuplicationBehavior::CANCEL 
)

Adds a file from the local server disk. If the file already exists and overwriting is disabled,

Parameters
string$localFilePath
string$fileName
string$conflictModea value of the enumeration
Returns
File The file object

Definition at line 281 of file core/Classes/Resource/Folder.php.

References PathUtility\basename().

Referenced by AbstractOnlineMediaHelper\createNewFile().

addUploadedFile ( array  $uploadedFileData,
  $conflictMode = DuplicationBehavior::CANCEL 
)

Adds an uploaded file into the Storage.

Parameters
array$uploadedFileDatacontains information about the uploaded file given by $_FILES['file1']
string$conflictModea value of the enumeration
Returns
File The file object

Definition at line 294 of file core/Classes/Resource/Folder.php.

checkActionPermission (   $action)
copyTo ( Folder  $targetFolder,
  $targetFolderName = null,
  $conflictMode = DuplicationBehavior::RENAME 
)

Copies folder to a target folder

Parameters
Folder$targetFolderTarget folder to copy to.
string$targetFolderNamean optional destination fileName
string$conflictModea value of the enumeration
Returns
Folder New (copied) folder object.

Definition at line 351 of file core/Classes/Resource/Folder.php.

References Folder\getStorage().

createFile (   $fileName)

Creates a new blank file

Parameters
string$fileName
Returns
File The new file object

Definition at line 327 of file core/Classes/Resource/Folder.php.

createFolder (   $folderName)

Creates a new folder

Parameters
string$folderName
Returns
Folder The new folder object

Definition at line 338 of file core/Classes/Resource/Folder.php.

delete (   $deleteRecursively = true)

Deletes this folder from its storage. This also means that this object becomes useless.

Parameters
bool$deleteRecursively
Returns
bool TRUE if deletion succeeded

Definition at line 316 of file core/Classes/Resource/Folder.php.

getCombinedIdentifier ( )

Returns a combined identifier of this folder, i.e. the storage UID and the folder identifier separated by a colon ":".

Returns
string Combined storage and folder identifier, e.g. StorageUID:folder/path/

Definition at line 172 of file core/Classes/Resource/Folder.php.

References Folder\getIdentifier(), and Folder\getStorage().

Referenced by FolderUtilityRenderer\createFolder(), FileLinkHandler\expandFolder(), FileList\getButtonsAndOtherMarkers(), ResourceStorage\isProcessingFolder(), FileList\linkWrapDir(), FolderBrowser\renderFolders(), and FolderUtilityRenderer\uploadForm().

getFileCount ( array  $filterMethods = array(),
  $recursive = false 
)

Returns amount of all files within this folder, optionally filtered by the given pattern

Parameters
array$filterMethods
bool$recursive
Returns
int
Exceptions
Exception\InsufficientFolderAccessPermissionsException

Definition at line 235 of file core/Classes/Resource/Folder.php.

getFiles (   $start = 0,
  $numberOfItems = 0,
  $filterMode = self::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS,
  $recursive = false,
  $sort = '',
  $sortRev = false 
)

Returns a list of files in this folder, optionally filtered. There are several filter modes available, see the FILTER_MODE_* constants for more information.

For performance reasons the returned items can also be limited to a given range

Parameters
int$startThe item to start at
int$numberOfItemsThe number of items to return
int$filterModeThe filter mode to use for the filelist.
bool$recursive
string$sortProperty name used to sort the items. Among them may be: '' (empty, no sorting), name, fileext, size, tstamp and rw. If a driver does not support the given property, it should fall back to "name".
bool$sortRevTRUE to indicate reverse sorting (last to first)
Returns
[]

Definition at line 209 of file core/Classes/Resource/Folder.php.

References Folder\prepareFiltersInStorage(), and Folder\restoreBackedUpFiltersInStorage().

getHashedIdentifier ( )

Get hashed identifier

Returns
string

Implements ResourceInterface.

Definition at line 161 of file core/Classes/Resource/Folder.php.

Referenced by AbstractOnlineMediaHelper\findExistingFileByOnlineMediaId().

getIdentifier ( )
getName ( )

Returns the name of this folder.

Returns
string

Implements ResourceInterface.

Definition at line 93 of file core/Classes/Resource/Folder.php.

References Folder\$name.

Referenced by ResourceStorage\assureFolderDeletePermission(), ResourceStorage\moveFolder(), and FolderBrowser\renderFolders().

getParentFolder ( )

Returns the parent folder.

In non-hierarchical storages, that always is the root folder.

The parent folder of the root folder is the root folder.

Returns
Folder

Implements ResourceInterface.

Definition at line 511 of file core/Classes/Resource/Folder.php.

References Folder\getIdentifier(), and Folder\getStorage().

Referenced by Folder\getReadablePath(), and ResourceStorage\moveFolder().

getPublicUrl (   $relativeToCurrentScript = false)

Returns a publicly accessible URL for this folder

WARNING: Access to the folder may be restricted by further means, e.g. some web-based authentication. You have to take care of this yourself.

Parameters
bool$relativeToCurrentScriptDetermines whether the URL returned should be relative to the current script, in case it is relative at all (only for the LocalDriver)
Returns
string

Definition at line 186 of file core/Classes/Resource/Folder.php.

References Folder\getStorage().

getReadablePath (   $rootId = null)

Returns the full path of this folder, from the root.

Parameters
string$rootIdID of the root folder, NULL to auto-detect
Returns
string

Definition at line 105 of file core/Classes/Resource/Folder.php.

References Folder\getParentFolder().

Referenced by FileList\getButtonsAndOtherMarkers(), and FileList\start().

getRole ( )

Returns the role of this folder (if any). See FolderInterface::ROLE_* constants for possible values.

Returns
int

Definition at line 497 of file core/Classes/Resource/Folder.php.

getStorage ( )
getSubfolder (   $name)

Returns the object for a subfolder of the current folder, if it exists.

Parameters
string$nameName of the subfolder
Returns
Folder
Exceptions
\InvalidArgumentException

Implements FolderInterface.

Definition at line 247 of file core/Classes/Resource/Folder.php.

References Folder\$name.

getSubfolders (   $start = 0,
  $numberOfItems = 0,
  $filterMode = self::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS,
  $recursive = false 
)

Returns a list of subfolders

Parameters
int$startThe item to start at
int$numberOfItemsThe number of items to return
int$filterModeThe filter mode to use for the filelist.
bool$recursive
Returns
Folder[]

Definition at line 264 of file core/Classes/Resource/Folder.php.

References Folder\prepareFiltersInStorage(), and Folder\restoreBackedUpFiltersInStorage().

Referenced by FolderLinkHandler\getFolderContent(), FolderTreeView\getNumberOfSubfolders(), and FolderBrowser\renderFolders().

hasFile (   $name)

Checks if a file exists in this folder

Parameters
string$name
Returns
bool

Implements FolderInterface.

Definition at line 375 of file core/Classes/Resource/Folder.php.

References Folder\$name.

hasFolder (   $name)

Checks if a folder exists in this folder.

Parameters
string$name
Returns
bool

Implements FolderInterface.

Definition at line 386 of file core/Classes/Resource/Folder.php.

References Folder\$name.

moveTo ( Folder  $targetFolder,
  $targetFolderName = null,
  $conflictMode = DuplicationBehavior::RENAME 
)

Moves folder to a target folder

Parameters
Folder$targetFolderTarget folder to move to.
string$targetFolderNamean optional destination fileName
string$conflictModea value of the enumeration
Returns
Folder New (copied) folder object.

Definition at line 364 of file core/Classes/Resource/Folder.php.

References Folder\getStorage().

prepareFiltersInStorage (   $filterMode)
protected

Prepares the filters in this folder's storage according to a set filter mode.

Parameters
int$filterModeThe filter mode to use; one of the FILTER_MODE_* constants
Returns
array The backed up filters as an array (NULL if filters were not backed up) and whether to use filters or not (bool)

Definition at line 432 of file core/Classes/Resource/Folder.php.

Referenced by Folder\getFiles(), and Folder\getSubfolders().

rename (   $newName)

Renames this folder.

Parameters
string$newName
Returns
Folder

Implements FolderInterface.

Definition at line 305 of file core/Classes/Resource/Folder.php.

restoreBackedUpFiltersInStorage (   $backedUpFilters)
protected

Restores the filters of a storage.

Parameters
array$backedUpFiltersThe filters to restore; might be NULL if no filters have been backed up, in which case this method does nothing.
See Also
prepareFiltersInStorage()

Definition at line 474 of file core/Classes/Resource/Folder.php.

Referenced by Folder\getFiles(), and Folder\getSubfolders().

setFileAndFolderNameFilters ( array  $filters)

Sets the filters to use when listing files. These are only used if the filter mode is one of FILTER_MODE_USE_OWN_FILTERS and FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS

Parameters
array$filters

Definition at line 487 of file core/Classes/Resource/Folder.php.

setName (   $name)

Sets a new name of the folder currently this does not trigger the "renaming process" as the name is more seen as a label

Parameters
string$nameThe new name
Returns
void

Definition at line 130 of file core/Classes/Resource/Folder.php.

References Folder\$name.

updateProperties ( array  $properties)

Updates the properties of this folder, e.g. after re-indexing or moving it.

NOTE: This method should not be called from outside the File Abstraction Layer (FAL)!

Parameters
array$properties
Returns
void

Definition at line 415 of file core/Classes/Resource/Folder.php.

Member Data Documentation

$fileAndFolderNameFilters = array()
protected

Definition at line 61 of file core/Classes/Resource/Folder.php.

$identifier
protected

Definition at line 47 of file core/Classes/Resource/Folder.php.

Referenced by Folder\__construct(), and Folder\getIdentifier().

$name
protected
$storage
protected

Definition at line 38 of file core/Classes/Resource/Folder.php.

Referenced by Folder\__construct(), and Folder\getStorage().

const FILTER_MODE_NO_FILTERS = 0

Modes for filter usage in getFiles()/getFolders()

Definition at line 66 of file core/Classes/Resource/Folder.php.

const FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS = 1
const FILTER_MODE_USE_OWN_FILTERS = 3

Definition at line 72 of file core/Classes/Resource/Folder.php.

const FILTER_MODE_USE_STORAGE_FILTERS = 2

Definition at line 70 of file core/Classes/Resource/Folder.php.