PHP Class ProtectedFile

The followings are the available columns in table 'protected_file':
Inheritance: extends BaseActiveRecordVersioned
ファイルを表示 Open project: openeyes/openeyes Class Usage Examples

Protected Properties

Property Type Description
$_source_path used in model creation
$_stored_path used in model delete
$_thumbnail

Public Methods

Method Description
afterDelete ( ) ensures file is removed from filesystem when deleting.
beforeDelete ( ) : boolean ensure we keep track of path to file before deleting from database.
beforeSave ( ) (non-PHPdoc).
beforeValidate ( ) ensures that mimetype and size are set based on the file that's been stored (unless the file is being copied from elsewhere, in which case this should have been taken care of).
createForWriting ( string $name ) : ProtectedFile create a new protected file object which has properties that can be used for writing an actual file to.
createFromFile ( string $path ) : ProtectedFile Create a new protected file from an existing file.
generateUID ( ) generate the UID for the file from the file name.
getBasePath ( ) : string Path to protected file storage.
getDownloadURL ( ) : string get URL for downloading this file.
getFilePath ( ) : string Path to file without filename.
getPath ( ) : string Path to file.
getThumbnail ( string $dimensions, $regenerate = false ) : boolean | array: Get thumbnail of image (generated automatically if not already created).
hasThumbnail ( ) : boolean Has the file got a thumbnail.
model ( $className = __CLASS__ ) : ProtectedFile Returns the static model of the specified AR class.
relations ( ) : array
rules ( ) : array
setSource ( string $path ) Initialise protected file from a source file.
tableName ( ) : string

Protected Methods

Method Description
generateThumbnail ( string $dimensions ) : boolean Generate a thumbnail.
getThumbnailPath ( string $dimensions ) : string Get the path for a thumbnail.
lookupMimetype ( string $path ) : string Get the mime type of the file.

Method Details

afterDelete() public method

ensures file is removed from filesystem when deleting.
public afterDelete ( )

beforeDelete() public method

ensure we keep track of path to file before deleting from database.
See also: BaseActiveRecord::beforeDelete()
public beforeDelete ( ) : boolean
return boolean (non-PHPdoc)

beforeSave() public method

(non-PHPdoc).
See also: BaseActiveRecord::beforeSave()
public beforeSave ( )

beforeValidate() public method

(non-PHPdoc)
See also: BaseActiveRecord::beforeSave()
public beforeValidate ( )

createForWriting() public static method

create a new protected file object which has properties that can be used for writing an actual file to.
public static createForWriting ( string $name ) : ProtectedFile
$name string
return ProtectedFile

createFromFile() public static method

Create a new protected file from an existing file.
public static createFromFile ( string $path ) : ProtectedFile
$path string Path to file
return ProtectedFile

generateThumbnail() protected method

Generate a thumbnail.
protected generateThumbnail ( string $dimensions ) : boolean
$dimensions string
return boolean

generateUID() public method

generate the UID for the file from the file name.
public generateUID ( )

getBasePath() public static method

Path to protected file storage.
public static getBasePath ( ) : string
return string

getDownloadURL() public method

get URL for downloading this file.
See also: ProtectedFileController::actionDownload
public getDownloadURL ( ) : string
return string

getFilePath() public method

Path to file without filename.
public getFilePath ( ) : string
return string

getPath() public method

Path to file.
public getPath ( ) : string
return string

getThumbnail() public method

Get thumbnail of image (generated automatically if not already created).
public getThumbnail ( string $dimensions, $regenerate = false ) : boolean | array:
$dimensions string
return boolean | array:

getThumbnailPath() protected method

Get the path for a thumbnail.
protected getThumbnailPath ( string $dimensions ) : string
$dimensions string
return string

hasThumbnail() public method

Has the file got a thumbnail.
public hasThumbnail ( ) : boolean
return boolean

lookupMimetype() protected method

Get the mime type of the file.
protected lookupMimetype ( string $path ) : string
$path string
return string

model() public static method

Returns the static model of the specified AR class.
public static model ( $className = __CLASS__ ) : ProtectedFile
return ProtectedFile the static model class

relations() public method

public relations ( ) : array
return array relational rules.

rules() public method

public rules ( ) : array
return array validation rules for model attributes.

setSource() public method

Initialise protected file from a source file.
public setSource ( string $path )
$path string

tableName() public method

public tableName ( ) : string
return string the associated database table name

Property Details

$_source_path protected_oe property

used in model creation
protected $_source_path

$_stored_path protected_oe property

used in model delete
protected $_stored_path

$_thumbnail protected_oe property

protected $_thumbnail