File
extends Entity
in package
Uses
WithDatabase
Content class
This class maps the content_files table.
Table of Contents
Properties
Methods
- __construct() : mixed
- Initializes a new File instance
- __toString() : string
- Returns a string representation of current File instance
- create_directory() : mixed
- Creates a directory
- generate_thumbnail() : bool
- Generates a thumbnail using ImageMagick binary
- getDatabase() : DatabaseEngine
- handle_uploaded_file() : bool
- Handles uploaded file
- is_valid_audio_extension() : bool
- Determines if the extension is a valid audio file one
- is_valid_extension() : bool
- Determines if the extension is valid
- is_valid_image_extension() : bool
- Determines if the extension is valid
- is_valid_video_extension() : bool
- Determines if the extension is a valid video file one
- load_from_database() : bool
- Loads the object File (ie fill the properties) from the database
- load_from_form() : mixed
- Loads the object File (ie fill the properties) from the $_POST array
- load_from_row() : mixed
- Loads the object from row
- save_to_database() : void
- Saves to database
- setDatabase() : void
Properties
$id
public
mixed
$id
$path
public
mixed
$path
$perso_id
public
mixed
$perso_id
$title
public
mixed
$title
$user_id
public
mixed
$user_id
$db
private
DatabaseEngine
$db
Methods
__construct()
Initializes a new File instance
public
__construct(DatabaseEngine $db[, int $id = null ]) : mixed
Parameters
- $db : DatabaseEngine
- $id : int = null
-
the primary key
__toString()
Returns a string representation of current File instance
public
__toString() : string
Return values
string —the content title or path if title is blank.
create_directory()
Creates a directory
public
create_directory(mixed $directory) : mixed
Parameters
- $directory : mixed
Tags
generate_thumbnail()
Generates a thumbnail using ImageMagick binary
public
generate_thumbnail() : bool
Return values
bool —true if the thumbnail command returns 0 as program exit code ; otherwise, false
getDatabase()
public
getDatabase() : DatabaseEngine
Return values
DatabaseEnginehandle_uploaded_file()
Handles uploaded file
public
handle_uploaded_file(mixed $fileArray) : bool
Parameters
- $fileArray : mixed
Return values
bool —true if the file have been handled
is_valid_audio_extension()
Determines if the extension is a valid audio file one
public
is_valid_audio_extension(string $ext) : bool
Parameters
- $ext : string
-
The extension (without dot)
Return values
bool —true if this extension is valid ; otherwise, false.
is_valid_extension()
Determines if the extension is valid
public
is_valid_extension(string $ext) : bool
Parameters
- $ext : string
-
The extension (without dot)
Return values
bool —true if this extension is valid ; otherwise, false.
is_valid_image_extension()
Determines if the extension is valid
public
is_valid_image_extension(string $ext) : bool
Parameters
- $ext : string
-
The extension (without dot)
Return values
bool —true if this extension is valid ; otherwise, false.
is_valid_video_extension()
Determines if the extension is a valid video file one
public
is_valid_video_extension(string $ext) : bool
Parameters
- $ext : string
-
The extension (without dot)
Tags
Return values
bool —true if this extension is valid ; otherwise, false.
load_from_database()
Loads the object File (ie fill the properties) from the database
public
load_from_database() : bool
Return values
boolload_from_form()
Loads the object File (ie fill the properties) from the $_POST array
public
load_from_form([bool $allowSensibleFields = false ]) : mixed
Parameters
- $allowSensibleFields : bool = false
-
if false, allow only title to be defined ; otherwise, allow all fields.
load_from_row()
Loads the object from row
public
load_from_row(mixed $row) : mixed
Parameters
- $row : mixed
save_to_database()
Saves to database
public
save_to_database() : void
setDatabase()
public
setDatabase(DatabaseEngine $db) : void
Parameters
- $db : DatabaseEngine