Inheritances
Files
Overview
FRAMES
NO FRAMES

Abstract class Zend_File_Transfer_Adapter_Abstract

Zend_File_Transfer
|-abstract class Zend_File_Transfer_Adapter_Abstract
Abstract class for file transfers (Downloads and Uploads)
CategoryZend
PackageZend_File_Transfer
CopyrightCopyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
Licensehttp://framework.zend.com/license/new-bsd New BSD License

Summary

Class constants
FILTER
VALIDATE
Instance fields
# $_break Internal list of breaks
# $_files Internal list of files
# $_filters Internal list of filters
# $_loaders Plugin loaders for filter and validation chains
# $_messages Internal list of messages
# $_options Available options for file transfers
# $_tmpDir TMP directory
# $_translator
# $_translatorDisabled Is translation disabled?
# $_validators Internal list of validators
Static methods
# _toByteString() Returns the formatted size
+ getProgress() Retrieve progress of transfer
Instance methods
# _filter() Internal function to filter all given files
# _getFiles() Returns found files based on internal file array and given files
# _getFilterIdentifier() Retrieve internal identifier for a named filter
# _getTmpDir() Determine system TMP directory and detect if we have read access
# _getValidatorIdentifier() Retrieve internal identifier for a named validator
# _isPathWriteable() Tries to detect if we can read and write to the given path
+ addFile() Adds one or more files
+ addFilter() Adds a new filter for this class
+ addFilters() Add Multiple filters at once
+ addPrefixPath() Add prefix path for plugin loader
+ addPrefixPaths() Add many prefix paths at once
+ addType() Adds one or more type of files
+ addValidator() Adds a new validator for this class
+ addValidators() Add Multiple validators at once
+ clearFilters() Remove all filters
+ clearValidators() Remove all validators
+ getDestination() Retrieve destination directory value
+ getErrors() Retrieve error codes
+ getFile() Returns all set files
+ getFileInfo() Retrieve additional internal file informations for files
+ getFileName() Retrieves the filename of transferred files
+ getFileSize() Returns the real filesize of the file
+ getFilter() Retrieve individual filter
+ getFilters() Returns all set filters
+ getHash() Returns the hash for a given file
+ getMessages() Returns found validation messages
+ getMimeType() Returns the real mimetype of the file
+ getOptions() Returns set options for adapters or files
+ getPluginLoader() Retrieve plugin loader for validator or filter chain
+ getTranslator() Retrieve localization translator object
+ getType() Returns all set types
+ getValidator() Retrieve individual validator
+ getValidators() Returns all set validators
+ hasErrors() Are there errors registered?
+ hasFilter() Determine if a given filter has already been registered
+ hasValidator() Determine if a given validator has already been registered
+ isFiltered() Has the file been filtered ?
+ isReceived() Is file received?
+ isSent() Is file sent?
+ isUploaded() Has a file been uploaded ?
+ isValid() Checks if the files are valid
+ receive() Receive file
+ removeFilter() Remove an individual filter
+ removeValidator() Remove an individual validator
+ send() Send file
+ setDestination() Sets a new destination for the given files
+ setDisableTranslator() Indicate whether or not translation should be disabled
+ setFilters() Sets a filter for the class, erasing all previous set
+ setOptions() Sets Options for adapters
+ setPluginLoader() Set plugin loader to use for validator or filter chain
+ setTranslator() Set translator object for localization
+ setValidators() Sets a validator for the class, erasing all previous set
+ translatorIsDisabled() Is translation disabled?

Details

Class constants

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

Instance fields

$_break
protected $_break = array()
Internal list of breaks
Var array
$_files
protected $_files = array()
Internal list of files
This array looks like this:
array(form => array( - Form is the name within the form or, if not set the filename
name, - Original name of this file
type, - Mime type of this file
size, - Filesize in bytes
tmp_name, - Internalally temporary filename for uploaded files
error, - Error which has occured
destination, - New destination for this file
validators, - Set validator names for this file
files - Set file names for this file
))
Var array
$_filters
protected $_filters = array()
Internal list of filters
Var array
$_loaders
protected $_loaders = array()
Plugin loaders for filter and validation chains
Var array
$_messages
protected $_messages = array()
Internal list of messages
Var array
$_options
protected $_options = array( 'ignoreNoFile' => false, 'useByteString' => true, 'magicFile' => null )
Available options for file transfers
$_tmpDir
protected $_tmpDir
TMP directory
Var string
$_translatorDisabled
protected $_translatorDisabled = false
Is translation disabled?
Var bool
$_validators
protected $_validators = array()
Internal list of validators
Var array

Static methods

_toByteString()
protected static function _toByteString( $size)
Returns the formatted size
Parameters
integer $size
Returns string
getProgress()
public static function getProgress( )
Retrieve progress of transfer
Returns float
Overriden by getProgress() in class : Zend_File_Transfer_Adapter_Http

Instance methods

_filter()
protected function _filter( $files = null)
Internal function to filter all given files
Parameters
string|array $files (Optional) Files to check
Returns boolean False on error
_getFiles()
protected function _getFiles( $files
$names = false
$noexception = false
)
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
Throws Zend_File_Transfer_Exception On false filename
_getFilterIdentifier()
protected function _getFilterIdentifier( $name)
Retrieve internal identifier for a named filter
Parameters
string $name
Returns string
_getTmpDir()
protected function _getTmpDir( )
Determine system TMP directory and detect if we have read access
Returns string
Throws Zend_File_Transfer_Exception if unable to determine directory
_getValidatorIdentifier()
protected function _getValidatorIdentifier( $name)
Retrieve internal identifier for a named validator
Parameters
string $name
Returns string
_isPathWriteable()
protected function _isPathWriteable( $path)
Tries to detect if we can read and write to the given path
Parameters
string $path
addFile()
public function addFile( $file
$validator = null
$filter = null
)
Adds one or more files
Parameters
string|array $file File to add
string|array $validator Validators to use for this file, must be set before
string|array $filter Filters to use for this file, must be set before
Throws Zend_File_Transfer_Exception Not implemented
addFilter()
public function addFilter( $filter
$options = null
$files = null
)
Adds a new filter for this class
Parameters
string|array $filter Type of filter to add
string|array $options Options to set for the filter
string|array $files Files to limit this filter to
Returns Zend_File_Transfer_Adapter
addFilters()
public function addFilters( array $filters
$files = null
)
Add Multiple filters at once
Parameters
array $filters
string|array $files
addPrefixPath()
public function 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
Throws Zend_File_Transfer_Exception for invalid type
addPrefixPaths()
public function addPrefixPaths( array $spec)
Add many prefix paths at once
Parameters
array $spec
addType()
public function addType( $type
$validator = null
$filter = null
)
Adds one or more type of files
Parameters
string|array $type Type of files to add
string|array $validator Validators to use for this file, must be set before
string|array $filter Filters to use for this file, must be set before
Throws Zend_File_Transfer_Exception Not implemented
addValidator()
public function addValidator( $validator
$breakChainOnFailure = false
$options = null
$files = null
)
Adds a new validator for this class
Parameters
string|array $validator Type of validator to add
boolean $breakChainOnFailure If the validation chain should stop an failure
string|array $options Options to set for the validator
string|array $files Files to limit this validator to
Returns Zend_File_Transfer_Adapter
addValidators()
public function addValidators( array $validators
$files = null
)
Add Multiple validators at once
Parameters
array $validators
string|array $files
clearFilters()
public function clearFilters( )
Remove all filters
clearValidators()
public function clearValidators( )
Remove all validators
Overriden by clearValidators() in class : Zend_File_Transfer_Adapter_Http
getDestination()
public function getDestination( $files = null)
Retrieve destination directory value
Parameters
null|string|array $files
Returns null|string|array
getErrors()
public function getErrors( )
Retrieve error codes
Returns array
getFile()
public function getFile( )
Returns all set files
Returns array List of set files
Throws Zend_File_Transfer_Exception Not implemented
getFileInfo()
public function getFileInfo( $file = null)
Retrieve additional internal file informations for files
Parameters
string $file (Optional) File to get informations for
Returns array
getFileName()
public function getFileName( $file = null
$path = true
)
Retrieves the filename of transferred files.
Parameters
$file
boolean $path (Optional) Should the path also be returned ?
Returns string|array
getFileSize()
public function getFileSize( $files = null)
Returns the real filesize of the file
Parameters
string|array $files Files to get the filesize from
Returns string|array Filesize
Throws Zend_File_Transfer_Exception When the file does not exist
getFilter()
public function getFilter( $name)
Retrieve individual filter
Parameters
string $name
getFilters()
public function getFilters( $files = null)
Returns all set filters
Parameters
string|array $files (Optional) Returns the filter for this files
Returns array List of set filters
Throws Zend_File_Transfer_Exception When file not found
getHash()
public function getHash( $hash = 'crc32'
$files = null
)
Returns the hash for a given file
Parameters
string $hash Hash algorithm to use
string|array $files Files to return the hash for
Returns string|array Hashstring
Throws Zend_File_Transfer_Exception On unknown hash algorithm
getMessages()
public function getMessages( )
Returns found validation messages
Returns array
getMimeType()
public function 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 $files Files to get the mimetype from
Returns string|array MimeType
Throws Zend_File_Transfer_Exception When the file does not exist
getOptions()
public function 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()
public function 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
Throws Zend_File_Transfer_Exception on invalid type.
getTranslator()
public function getTranslator( )
Retrieve localization translator object
getType()
public function getType( )
Returns all set types
Returns array List of set types
Throws Zend_File_Transfer_Exception Not implemented
getValidator()
public function getValidator( $name)
Retrieve individual validator
Parameters
string $name
getValidators()
public function 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()
public function hasErrors( )
Are there errors registered?
Returns boolean
hasFilter()
public function hasFilter( $name)
Determine if a given filter has already been registered
Parameters
string $name
Returns bool
hasValidator()
public function hasValidator( $name)
Determine if a given validator has already been registered
Parameters
string $name
Returns bool
isFiltered()
abstract public function isFiltered( $files = null)
Has the file been filtered ?
Parameters
array|string|null $files
Returns bool
Overriden by isFiltered() in class : Zend_File_Transfer_Adapter_Http
isReceived()
abstract public function isReceived( $files = null)
Is file received?
Parameters
array|string|null $files
Returns bool
Overriden by isReceived() in class : Zend_File_Transfer_Adapter_Http
isSent()
abstract public function isSent( $files = null)
Is file sent?
Parameters
array|string|null $files
Returns bool
Overriden by isSent() in class : Zend_File_Transfer_Adapter_Http
isUploaded()
abstract public function isUploaded( $files = null)
Has a file been uploaded ?
Parameters
array|string|null $files
Returns bool
Overriden by isUploaded() in class : Zend_File_Transfer_Adapter_Http
isValid()
public function 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
Overriden by isValid() in class : Zend_File_Transfer_Adapter_Http
receive()
abstract public function receive( $options = null)
Receive file
Parameters
mixed $options
Returns bool
Overriden by receive() in class : Zend_File_Transfer_Adapter_Http
removeFilter()
public function removeFilter( $name)
Remove an individual filter
Parameters
string $name
removeValidator()
public function removeValidator( $name)
Remove an individual validator
Parameters
string $name
Overriden by removeValidator() in class : Zend_File_Transfer_Adapter_Http
send()
abstract public function send( $options = null)
Send file
Parameters
mixed $options
Returns bool
Overriden by send() in class : Zend_File_Transfer_Adapter_Http
setDestination() Deprecated
public function setDestination( $destination
$files = null
)
Sets a new destination for the given files
Parameters
string $destination New destination directory
string|array $files Files to set the new destination for
Returns Zend_File_Transfer_Abstract
Throws Zend_File_Transfer_Exception when the given destination is not a directory or does not exist
setDisableTranslator()
public function setDisableTranslator( $flag)
Indicate whether or not translation should be disabled
Parameters
bool $flag
Returns Zend_File_Transfer_Abstract
setFilters()
public function setFilters( array $filters
$files = null
)
Sets a filter for the class, erasing all previous set
Parameters
array $filters
string|array $files Files to limit this filter to
Returns Zend_File_Transfer_Adapter
setOptions()
public function setOptions( $options = array()
$files = null
)
Sets Options for adapters
Parameters
array $options Options to set
array $files (Optional) Files to set the options for
setPluginLoader()
public function 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'
Throws Zend_File_Transfer_Exception on invalid type
setTranslator()
public function setTranslator( $translator = null)
Set translator object for localization
Parameters
Zend_Translate|null $translator
Returns Zend_File_Transfer_Abstract
setValidators()
public function setValidators( array $validators
$files = null
)
Sets a validator for the class, erasing all previous set
Parameters
array $validators
string|array $files Files to limit this validator to
Returns Zend_File_Transfer_Adapter
Overriden by setValidators() in class : Zend_File_Transfer_Adapter_Http
translatorIsDisabled()
public function translatorIsDisabled( )
Is translation disabled?
Returns bool