Public Member Functions | Public Attributes

BeFileHandlerComponent Class Reference

File upload, save, modify, delete, manage (remote as well). More...

List of all members.

Public Member Functions

 startup (&$controller)
 save (&$data, $clone=false, $getInfoUrl=true)
 Save object $data If $data['id'] modify otherwise create If file is already present, throw an exception.
 del ($id)
 Delete object.
 url ($id)
 Return URL of file object.
 path ($id)
 Return object path, URL if remote file.
 isPresent ($path, $id=null)
 Return object id (object that contains file $path).
 getInfoURL (&$data)
 put mime type checking uri
 getMimeType ($data)
 get mime type of stream
 getPathTargetFile (&$name, $prefix=null)
 Get path where to save uploaded file.
 buildNameFromFile ($filename)
 build friendly url name from filename nameFile.ext become name-file.jpg nameFile become name-file
 splitFilename ($filename)
 Split file name by dot [to separate file name from file extension].

Public Attributes

 $components = array('Transaction')
 $paranoid = true
 $validateErrors = false

Detailed Description

File upload, save, modify, delete, manage (remote as well).

Uses Transaction component.

Data to be passed to save an object with a file:

path temporary file path or URL name Name of original file mime_type MIME type, if not set, try to get from file name (

Exceptions: BEditaFileExistException // File already exists (thrown in creation) BEditaInfoException // File info not readable (access denied or no data) BEditaMIMEException // MIME type not found or not corresponding to object type BEditaURLRxception // URL rules violated BEditaSaveStreamObjException // Error creating/modifying object BEditaDeleteStreamObjException // Error deleting object

If paranoid == false: remote info not loaded ['allow_php_fopen' not necessary]. Mime info should be passed with data for URLs.

File paths saved on DB are relative to $config['mediaRoot']

Version:
$Revision$ $LastChangedBy$ $LastChangedDate$

$Id$

Definition at line 52 of file be_file_handler.php.


Member Function Documentation

BeFileHandlerComponent::buildNameFromFile ( filename  ) 

build friendly url name from filename nameFile.ext become name-file.jpg nameFile become name-file

Parameters:
string $filename
Returns:
string

Definition at line 613 of file be_file_handler.php.

BeFileHandlerComponent::del ( id  ) 

Delete object.

Parameters:
integer $id object id
Returns:
boolean
Exceptions:
BEditaDeleteStreamObjException 

Definition at line 110 of file be_file_handler.php.

BeFileHandlerComponent::getInfoURL ( &$  data  ) 

put mime type checking uri

Parameters:
array $data
Exceptions:
BEditaInfoException 

Definition at line 451 of file be_file_handler.php.

BeFileHandlerComponent::getMimeType ( data  ) 

get mime type of stream

Parameters:
array $data
Returns:
string

Definition at line 486 of file be_file_handler.php.

BeFileHandlerComponent::getPathTargetFile ( &$  name,
prefix = null 
)

Get path where to save uploaded file.

Parameters:
string $name, file name
Returns:
string, path

Definition at line 578 of file be_file_handler.php.

Referenced by isPresent().

BeFileHandlerComponent::isPresent ( path,
id = null 
)

Return object id (object that contains file $path).

Parameters:
string $path File name or URL
Returns:
int

Definition at line 155 of file be_file_handler.php.

References getPathTargetFile().

BeFileHandlerComponent::path ( id  ) 

Return object path, URL if remote file.

Parameters:
integer $id object id
Returns:
string

Definition at line 143 of file be_file_handler.php.

BeFileHandlerComponent::save ( &$  data,
clone = false,
getInfoUrl = true 
)

Save object $data If $data['id'] modify otherwise create If file is already present, throw an exception.

File data: path: local path or URL (\.+//:\.+) [remote file] if "allow_url_fopen" is not activated, remote file is not accepted name Name of file. Empty if path == URL mime_type MIME type. Empty if path == URL file_size File size. Empty if path == URL

Parameters:
array $data object data
Returns:
integer or false (id of the object created or modified)

Definition at line 92 of file be_file_handler.php.

BeFileHandlerComponent::splitFilename ( filename  ) 

Split file name by dot [to separate file name from file extension].

Parameters:
string $filename
Returns:
array

Definition at line 629 of file be_file_handler.php.

BeFileHandlerComponent::url ( id  ) 

Return URL of file object.

Parameters:
integer $id object id
Returns:
string

Definition at line 132 of file be_file_handler.php.


The documentation for this class was generated from the following file:
Generated on Fri Dec 11 2015 15:29:46 by Doxygen 1.7.1  BEditaBEdita 3.7 Corylus