Zend Framework  1.12
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Zend_File_Transfer_Adapter_Abstract Class Reference

Public Member Functions

 send ($options=null)
 Send file.
 
 receive ($options=null)
 Receive file.
 
 isSent ($files=null)
 Is file sent?
 
 isReceived ($files=null)
 Is file received?
 
 isUploaded ($files=null)
 Has a file been uploaded ?
 
 isFiltered ($files=null)
 Has the file been filtered ?
 
 setPluginLoader (Zend_Loader_PluginLoader_Interface $loader, $type)
 Set plugin loader to use for validator or filter chain.
 
 getPluginLoader ($type)
 Retrieve plugin loader for validator or filter chain.
 
 addPrefixPath ($prefix, $path, $type=null)
 Add prefix path for plugin loader.
 
 addPrefixPaths (array $spec)
 Add many prefix paths at once.
 
 addValidator ($validator, $breakChainOnFailure=false, $options=null, $files=null)
 Adds a new validator for this class.
 
 addValidators (array $validators, $files=null)
 Add Multiple validators at once.
 
 setValidators (array $validators, $files=null)
 Sets a validator for the class, erasing all previous set.
 
 hasValidator ($name)
 Determine if a given validator has already been registered.
 
 getValidator ($name)
 Retrieve individual validator.
 
 getValidators ($files=null)
 Returns all set validators.
 
 removeValidator ($name)
 Remove an individual validator.
 
 clearValidators ()
 Remove all validators.
 
 setOptions ($options=array(), $files=null)
 Sets Options for adapters.
 
 getOptions ($files=null)
 Returns set options for adapters or files.
 
 isValid ($files=null)
 Checks if the files are valid.
 
 getMessages ()
 Returns found validation messages.
 
 getErrors ()
 Retrieve error codes.
 
 hasErrors ()
 Are there errors registered?
 
 addFilter ($filter, $options=null, $files=null)
 Adds a new filter for this class.
 
 addFilters (array $filters, $files=null)
 Add Multiple filters at once.
 
 setFilters (array $filters, $files=null)
 Sets a filter for the class, erasing all previous set.
 
 hasFilter ($name)
 Determine if a given filter has already been registered.
 
 getFilter ($name)
 Retrieve individual filter.
 
 getFilters ($files=null)
 Returns all set filters.
 
 removeFilter ($name)
 Remove an individual filter.
 
 clearFilters ()
 Remove all filters.
 
 getFile ()
 Returns all set files.
 
 getFileName ($file=null, $path=true)
 Retrieves the filename of transferred files.
 
 getFileInfo ($file=null)
 Retrieve additional internal file informations for files.
 
 addFile ($file, $validator=null, $filter=null)
 Adds one or more files.
 
 getType ()
 Returns all set types.
 
 addType ($type, $validator=null, $filter=null)
 Adds one or more type of files.
 
 setDestination ($destination, $files=null)
 Sets a new destination for the given files.
 
 getDestination ($files=null)
 Retrieve destination directory value.
 
 setTranslator ($translator=null)
 Set translator object for localization.
 
 getTranslator ()
 Retrieve localization translator object.
 
 setDisableTranslator ($flag)
 Indicate whether or not translation should be disabled.
 
 translatorIsDisabled ()
 Is translation disabled?
 
 getHash ($hash= 'crc32', $files=null)
 Returns the hash for a given file.
 
 getFileSize ($files=null)
 Returns the real filesize of the file.
 
 getMimeType ($files=null)
 Returns the real mimetype of the file Uses fileinfo, when not available mime_magic and as last fallback a manual given mimetype.
 

Static Public Member Functions

static getProgress ()
 Retrieve progress of transfer.
 

Public Attributes

const FILTER = 'FILTER'
 @+ Plugin loader Constants
 
const VALIDATE = 'VALIDATE'
 

Protected Member Functions

 _detectFileSize ($value)
 Internal method to detect the size of a file.
 
 _detectMimeType ($value)
 Internal method to detect the mime type of a file.
 
 _filter ($files=null)
 Internal function to filter all given files.
 
 _getTmpDir ()
 Determine system TMP directory and detect if we have read access.
 
 _isPathWriteable ($path)
 Tries to detect if we can read and write to the given path.
 
 _getFiles ($files, $names=false, $noexception=false)
 Returns found files based on internal file array and given files.
 
 _getValidatorIdentifier ($name)
 Retrieve internal identifier for a named validator.
 
 _getFilterIdentifier ($name)
 Retrieve internal identifier for a named filter.
 

Static Protected Member Functions

static _toByteString ($size)
 Returns the formatted size.
 

Protected Attributes

 $_break = array()
 
 $_filters = array()
 
 $_loaders = array()
 
 $_messages = array()
 
 $_translator
 
 $_translatorDisabled = false
 
 $_validators = array()
 
 $_files = array()
 
 $_tmpDir
 
 $_options
 Available options for file transfers.
 

Member Function Documentation

_detectFileSize (   $value)
protected

Internal method to detect the size of a file.

Parameters
array$valueFile infos
Returns
string Filesize of given file
_detectMimeType (   $value)
protected

Internal method to detect the mime type of a file.

Parameters
array$valueFile infos
Returns
string Mimetype of given file
_filter (   $files = null)
protected

Internal function to filter all given files.

Parameters
string | array$files(Optional) Files to check
Returns
boolean False on error
_getFiles (   $files,
  $names = false,
  $noexception = false 
)
protected

Returns found files based on internal file array and given files.

Parameters
string | array$files(Optional) Files to return
boolean$names(Optional) Returns only names on true, else complete info
boolean$noexception(Optional) Allows throwing an exception, otherwise returns an empty array
Returns
array Found files
Exceptions
Zend_File_Transfer_ExceptionOn false filename
_getFilterIdentifier (   $name)
protected

Retrieve internal identifier for a named filter.

Parameters
string$name
Returns
string
_getTmpDir ( )
protected

Determine system TMP directory and detect if we have read access.

Returns
string
Exceptions
Zend_File_Transfer_Exceptionif unable to determine directory
_getValidatorIdentifier (   $name)
protected

Retrieve internal identifier for a named validator.

Parameters
string$name
Returns
string
_isPathWriteable (   $path)
protected

Tries to detect if we can read and write to the given path.

Parameters
string$path
Returns
bool
static _toByteString (   $size)
staticprotected

Returns the formatted size.

Parameters
integer$size
Returns
string
addFile (   $file,
  $validator = null,
  $filter = null 
)

Adds one or more files.

Parameters
string | array$fileFile to add
string | array$validatorValidators to use for this file, must be set before
string | array$filterFilters to use for this file, must be set before
Returns
Zend_File_Transfer_Adapter_Abstract
Exceptions
Zend_File_Transfer_ExceptionNot implemented
addFilter (   $filter,
  $options = null,
  $files = null 
)

Adds a new filter for this class.

Parameters
string | array$filterType of filter to add
string | array$optionsOptions to set for the filter
string | array$filesFiles to limit this filter to
Returns
Zend_File_Transfer_Adapter
addFilters ( array  $filters,
  $files = null 
)

Add Multiple filters at once.

Parameters
array$filters
string | array$files
Returns
Zend_File_Transfer_Adapter_Abstract
addPrefixPath (   $prefix,
  $path,
  $type = null 
)

Add prefix path for plugin loader.

If no $type specified, assumes it is a base path for both filters and validators, and sets each according to the following rules:

  • filters: $prefix = $prefix . '_Filter'
  • validators: $prefix = $prefix . '_Validate'

Otherwise, the path prefix is set on the appropriate plugin loader.

Parameters
string$prefix
string$path
string$type
Returns
Zend_File_Transfer_Adapter_Abstract
Exceptions
Zend_File_Transfer_Exceptionfor invalid type
addPrefixPaths ( array  $spec)

Add many prefix paths at once.

Parameters
array$spec
Returns
Zend_File_Transfer_Exception
addType (   $type,
  $validator = null,
  $filter = null 
)

Adds one or more type of files.

Parameters
string | array$typeType of files to add
string | array$validatorValidators to use for this file, must be set before
string | array$filterFilters to use for this file, must be set before
Returns
Zend_File_Transfer_Adapter_Abstract
Exceptions
Zend_File_Transfer_ExceptionNot implemented
addValidator (   $validator,
  $breakChainOnFailure = false,
  $options = null,
  $files = null 
)

Adds a new validator for this class.

Parameters
string | array$validatorType of validator to add
boolean$breakChainOnFailureIf the validation chain should stop an failure
string | array$optionsOptions to set for the validator
string | array$filesFiles to limit this validator to
Returns
Zend_File_Transfer_Adapter
addValidators ( array  $validators,
  $files = null 
)

Add Multiple validators at once.

Parameters
array$validators
string | array$files
Returns
Zend_File_Transfer_Adapter_Abstract
clearFilters ( )

Remove all filters.

Returns
Zend_File_Transfer_Adapter_Abstract
clearValidators ( )

Remove all validators.

Returns
Zend_File_Transfer_Adapter_Abstract
getDestination (   $files = null)

Retrieve destination directory value.

Parameters
null | string | array$files
Returns
null|string|array
Exceptions
Zend_File_Transfer_Exception
getErrors ( )

Retrieve error codes.

Returns
array
getFile ( )

Returns all set files.

Returns
array List of set files
Exceptions
Zend_File_Transfer_ExceptionNot implemented
getFileInfo (   $file = null)

Retrieve additional internal file informations for files.

Parameters
string$file(Optional) File to get informations for
Returns
array
getFileName (   $file = null,
  $path = true 
)

Retrieves the filename of transferred files.

Parameters
string | null$file
boolean$path(Optional) Should the path also be returned ?
Returns
string|array
getFileSize (   $files = null)

Returns the real filesize of the file.

Parameters
string | array$filesFiles to get the filesize from
Exceptions
Zend_File_Transfer_ExceptionWhen the file does not exist
Returns
string|array Filesize
getFilter (   $name)

Retrieve individual filter.

Parameters
string$name
Returns
Zend_Filter_Interface|null
getFilters (   $files = null)

Returns all set filters.

Parameters
string | array$files(Optional) Returns the filter for this files
Returns
array List of set filters
Exceptions
Zend_File_Transfer_ExceptionWhen file not found
getHash (   $hash = 'crc32',
  $files = null 
)

Returns the hash for a given file.

Parameters
string$hashHash algorithm to use
string | array$filesFiles to return the hash for
Returns
string|array Hashstring
Exceptions
Zend_File_Transfer_ExceptionOn unknown hash algorithm
getMessages ( )

Returns found validation messages.

Returns
array
getMimeType (   $files = null)

Returns the real mimetype of the file Uses fileinfo, when not available mime_magic and as last fallback a manual given mimetype.

Parameters
string | array$filesFiles to get the mimetype from
Exceptions
Zend_File_Transfer_ExceptionWhen the file does not exist
Returns
string|array MimeType
getOptions (   $files = null)

Returns set options for adapters or files.

Parameters
array$files(Optional) Files to return the options for
Returns
array Options for given files
getPluginLoader (   $type)

Retrieve plugin loader for validator or filter chain.

Instantiates with default rules if none available for that type. Use 'filter' or 'validate' for $type.

Parameters
string$type
Returns
Zend_Loader_PluginLoader
Exceptions
Zend_File_Transfer_Exceptionon invalid type.
static getProgress ( )
static

Retrieve progress of transfer.

Returns
float
getTranslator ( )

Retrieve localization translator object.

Returns
Zend_Translate_Adapter|null
getType ( )

Returns all set types.

Returns
array List of set types
Exceptions
Zend_File_Transfer_ExceptionNot implemented
getValidator (   $name)

Retrieve individual validator.

Parameters
string$name
Returns
Zend_Validate_Interface|null
getValidators (   $files = null)

Returns all set validators.

Parameters
string | array$files(Optional) Returns the validator for this files
Returns
null|array List of set validators
hasErrors ( )

Are there errors registered?

Returns
boolean
hasFilter (   $name)

Determine if a given filter has already been registered.

Parameters
string$name
Returns
bool
hasValidator (   $name)

Determine if a given validator has already been registered.

Parameters
string$name
Returns
bool
isFiltered (   $files = null)
abstract

Has the file been filtered ?

Parameters
array | string | null$files
Returns
bool
isReceived (   $files = null)
abstract

Is file received?

Parameters
array | string | null$files
Returns
bool
isSent (   $files = null)
abstract

Is file sent?

Parameters
array | string | null$files
Returns
bool
isUploaded (   $files = null)
abstract

Has a file been uploaded ?

Parameters
array | string | null$files
Returns
bool
isValid (   $files = null)

Checks if the files are valid.

Parameters
string | array$files(Optional) Files to check
Returns
boolean True if all checks are valid
receive (   $options = null)
abstract

Receive file.

Parameters
mixed$options
Returns
bool
removeFilter (   $name)

Remove an individual filter.

Parameters
string$name
Returns
Zend_File_Transfer_Adapter_Abstract
removeValidator (   $name)

Remove an individual validator.

Parameters
string$name
Returns
Zend_File_Transfer_Adapter_Abstract
send (   $options = null)
abstract

Send file.

Parameters
mixed$options
Returns
bool
setDestination (   $destination,
  $files = null 
)

Sets a new destination for the given files.

Deprecated:
Will be changed to be a filter!!!
Parameters
string$destinationNew destination directory
string | array$filesFiles to set the new destination for
Returns
Zend_File_Transfer_Abstract
Exceptions
Zend_File_Transfer_Exceptionwhen the given destination is not a directory or does not exist
setDisableTranslator (   $flag)

Indicate whether or not translation should be disabled.

Parameters
bool$flag
Returns
Zend_File_Transfer_Abstract
setFilters ( array  $filters,
  $files = null 
)

Sets a filter for the class, erasing all previous set.

Parameters
string | array$filterFilter to set
string | array$filesFiles to limit this filter to
Returns
Zend_File_Transfer_Adapter
setOptions (   $options = array(),
  $files = null 
)

Sets Options for adapters.

Parameters
array$optionsOptions to set
array$files(Optional) Files to set the options for
setPluginLoader ( Zend_Loader_PluginLoader_Interface  $loader,
  $type 
)

Set plugin loader to use for validator or filter chain.

Parameters
Zend_Loader_PluginLoader_Interface$loader
string$type'filter', or 'validate'
Returns
Zend_File_Transfer_Adapter_Abstract
Exceptions
Zend_File_Transfer_Exceptionon invalid type
setTranslator (   $translator = null)

Set translator object for localization.

Parameters
Zend_Translate | null$translator
Returns
Zend_File_Transfer_Abstract
Exceptions
Zend_File_Transfer_Exception
setValidators ( array  $validators,
  $files = null 
)

Sets a validator for the class, erasing all previous set.

Parameters
string | array$validatorValidator to set
string | array$filesFiles to limit this validator to
Returns
Zend_File_Transfer_Adapter
translatorIsDisabled ( )

Is translation disabled?

Returns
bool

Member Data Documentation

$_break = array()
protected
$_files = array()
protected
$_filters = array()
protected
$_loaders = array()
protected
$_messages = array()
protected
$_options
protected
Initial value:
= array(
'ignoreNoFile' => false,
'useByteString' => true,
'magicFile' => null,
'detectInfos' => true,
)

Available options for file transfers.

$_tmpDir
protected
$_translator
protected
$_translatorDisabled = false
protected
$_validators = array()
protected
const FILTER = 'FILTER'

@+ Plugin loader Constants

const VALIDATE = 'VALIDATE'