expFile

Extends \expRecord

This is the class expRecord

define

"BASE" "../../.."

package

Modules

Methods

__construct

__construct(null $params = null, boolean $get_assoc = true, boolean $get_attached = true) 
inherited
Throws
\ReflectionException

Arguments

$params

null

$get_assoc

boolean

$get_attached

boolean

after creating item

afterCreate() 
inherited

is run after deleting item, should delete associated items here if needed

afterDelete() 
inherited

after saving item

afterSave() 
inherited

after updating item

afterUpdate() 
inherited

after validating item

afterValidation() 
inherited

after validating item during creation

afterValidationOnCreate() 
inherited

after validating item during update

afterValidationOnUpdate() 
inherited

get objects this item belongs to ??

associateWith( $datatype,  $id) 
inherited

Type of associations has_and_belongs_to_many

Arguments

$datatype

$id

attach to item

attachItem( $item, string $subtype = '', boolean $replace = true) : boolean
inherited

Arguments

$item

$subtype

string

$replace

boolean

Response

boolean

before creating item

beforeCreate() 
inherited

is run before deleting item

beforeDelete() 
inherited

before saving item

beforeSave() 
inherited

before updating item

beforeUpdate() 
inherited

before validating item

beforeValidation() 
inherited

before validating item during creation

beforeValidationOnCreate() 
inherited

before validating item during update

beforeValidationOnUpdate() 
inherited

Adds table fields as class properties to current "record" class.

build(mixed $params = array()) 
inherited

Loads Table schema data and creates new class properties based upon the fields in given table.

Additionally, if a record ID is given, that record is pulled and field values are also populated into class properties.

category

db_record

uses

Builds a data definition from existing table.

requires

$db

access

protected

final
PHPUnit

Not Defined

global

object $db

Arguments

$params

mixed

array or Object for table selection

exdoc Looks at the filesystem structure surrounding the destination and determines if the web server can create a new file there.

canCreate(string $dest) : integer
static

Returns one of the following:
SYS_FILES_NOTWRITABLE - unable to create files in destination
SYS_FILES_SUCCESS - A file or directory can be created in destination
SYS_FILES_FOUNDFILE - Found destination to be a file, not a directory

node

Model:expFile

Arguments

$dest

string

Path to the directory to check

Response

integer

Test if file can be uploaded using tmp folder

canUpload(string $tmp = 'tmp', string $dest = 'files/uploads') : boolean
static

Arguments

$tmp

string

$dest

string

Response

boolean

check for what objects may be attached

checkForAttachableItems( $params) : boolean
inherited

Arguments

$params

Response

boolean

exdoc Copies just the directory structure (including subdirectories) of a given directory.

copyDirectoryStructure(string $src, string $dest, array $exclude_dirs = array()) 
static

Any files in the source directory are ignore, and duplicate copies are made (no symlinks).

node

Model:expFile

Arguments

$src

string

The directory to copy structure from. This must be a full path.

$dest

string

The directory to create duplicate structure in. If this directory is not empty, you may run into some problems, because of file/directory conflicts.

$exclude_dirs

array

An array of directory names to exclude. These names are path-independent. Specifying "dir" will ignore all directories and sub-directories named "dir", regardless of their parent.

copyToDirectory

copyToDirectory( $destination) 

Arguments

$destination

delete item

delete(string $where = '') : boolean
inherited

Arguments

$where

string

Response

boolean

prompts the user to download a file

download(string $file) : boolean
static
static
access

public

uses

download() Built-in PHP method

PHPUnit

Not Defined|Implement|Completed

Arguments

$file

string

Full path to file to download

Response

boolean

exdoc This function takes a database object and dumps all of the records in all of the tables into a string.

dumpDatabase(\null/array $tables = null, \null/string $type = null, \null/string/array $opts = null) : string
static

The contents of the string are suitable for storage in a file or other permanent mechanism, and is in the EQL format naively handled by the current implementation.

node

Model:expFile

Arguments

$tables

\null/array

$type

\null/string

The type of dump

$opts

\null/string/array

Record descimiator

Response

string

The content of export file

exists

exists() 

Performs a system level check on the file and retrieves its size

fileSize(boolean|string $_path = false) : integer
static
static
access

public

uses

filesize() Built-in PHP method

PHPUnit

Not Defined|Implement|Completed

Throws
void

Arguments

$_path

boolean|string

Full path to file to pull info from

Response

integer

$_fileSize Size of file in bytes

File ($_POST) UPLOAD that also optionally inserts File info into database.

fileUpload(string $_postName = null, boolean|string $_force = false, boolean|string $_save = true, string $_destFile = null, string $_destDir = null, null $_max_width = null) : object
static

File UPLOAD is a straight forward uploader and processor. It can accept filename and destination directory overrides as well. It has an additional pair of flags that allow for an upload NOT to be inserted into the database (default to INSERT) and if it previous file, with the same name, should be overwritten (default to NO overwrite)

static
access

public

uses

description

requires

class_name

PHPUnit

Not Defined|Implement|Completed

TODO

Have file upload overwrite make sure not to duplicate its record in the DB

Arguments

$_postName

string

The name of the _FILE upload array

$_force

boolean|string

Force the uploaded to overwrite existing file of same name

$_save

boolean|string

Save file info to database, defaults to TRUE

$_destFile

string

Override the uploaded file name

$_destDir

string

Override the default FILE UPLOAD location

$_max_width

null

Response

object

$_objFile expFile Object

XHR (HTML5) File UPLOAD that also inserts File info into database.

fileXHRUpload(null $fileName = null, boolean|string $_force = false, boolean|string $_save = true, string $_destFile = null, string $_destDir = null, null $_max_width = null) : object
static

File UPLOAD is a straight forward uploader and processor. It can accept filename and destination directory overrides as well. It has an additional pair of flags that allow for an upload NOT to be inserted into the database (default to INSERT) and if it previous file, with the same name, should be overwritten (default to NO overwrite)

static
access

public

uses

description

requires

class_name

PHPUnit

Not Defined|Implement|Completed

TODO

Have file upload overwrite make sure not to duplicate its record in the DB

Arguments

$fileName

null

$_force

boolean|string

Force the uploaded to overwrite existing file of same name

$_save

boolean|string

Save file info to database, defaults to TRUE

$_destFile

string

Override the uploaded file name

$_destDir

string

Override the default FILE UPLOAD location

$_max_width

null

Response

object

$_objFile expFile Object

find an item or items

find(string $range = 'all', null $where = null, null $order = null, null $limit = null, integer $limitstart, boolean $get_assoc = true, boolean $get_attached = true, array $except = array(), boolean $cascade_except = false) : array|integer
inherited

Arguments

$range

string

$where

null

$order

null

$limit

null

$limitstart

integer

$get_assoc

boolean

$get_attached

boolean

$except

array

$cascade_except

boolean

Response

array|integer

find an item by column

findBy( $column,  $value, boolean $get_assoc = true, boolean $get_attached = true, array $except = array(), boolean $cascade_except = false) : array
inherited

Arguments

$column

$value

$get_assoc

boolean

$get_attached

boolean

$except

array

$cascade_except

boolean

Response

array

find a value(s) by column

findValue(string $range = 'all', string $column, string $where = null, string $order = null, boolean $distinct = false) : array|boolean
inherited

Arguments

$range

string

$column

string

$where

string

$order

string

$distinct

boolean

Response

array|boolean

this function finds models that have this attachable item attached

findWhereAttachedTo( $content_type) : array
inherited

Arguments

$content_type

Response

array

Replace anything but alphanumeric characters with an UNDERSCORE

fixName(string $name) : string
static
static
access

public

uses

preg_replace built-in PHP Function

PHPUnit

Not Defined|Implement|Completed

Throws
void

Arguments

$name

string

File name to 'fix'

Response

string

$name the correct filename

get item's associated objects

getAssociatedObjects(null $obj = null) : null
inherited

Type of associations has_one has_many has_and_belongs_to_many

Arguments

$obj

null

Response

null

gets associated objects for this model

getAssociatedObjectsForThisModel(array $except = array(), boolean $cascade_except = false) 
inherited

Type of associations has_extended_fields has_one has_many has_many_self has_and_belongs_to_many has_and_belongs_to_self

Arguments

$except

array

$cascade_except

boolean

get attached objects for this item

getAttachableItems() 
inherited

used for import/export

getAttachableItemTables() : array
inherited

Response

array

Return size and mimetype information about an image file, given its path/filename. This is a wrapper around the built-in PHP 'getimagesize' function, to make all implementations work identically.

getImageInfo(boolean|string $_path = false) : array
static
static
access

public

uses

getimagesize() Built-in PHP function

PHPUnit

Not Defined|Implement|Completed

Arguments

$_path

boolean|string

Full path to file to pull info from

Response

array

$_sizeinfo An array of Image File info

Return the mimetype for the passed filename

getMimeType(string $filename) : string
static

Arguments

$filename

string

Response

string

return the item poster

getPoster(null $display = null) : null|string
inherited

Arguments

$display

null

Response

null|string

return the item timestamp

getTimestamp(integer $type) : mixed
inherited

Arguments

$type

integer

Response

mixed

exdoc Create a captcha type image from a string

imageCaptcha( $w,  $h,  $string) : null|resource
static

Arguments

$w

$h

$string

Response

null|resource

Copy and resize and image

imageCopyresized( $dest,  $src,  $dst_x,  $dst_y,  $src_x,  $src_y,  $dst_w,  $dst_h,  $src_w,  $src_h) : boolean|null
static

Arguments

$dest

$src

$dst_x

$dst_y

$src_x

$src_y

$dst_w

$dst_h

$src_w

$src_h

Response

boolean|null

exdoc Create a new blank image resource, with the specified width and height.

imageCreate(integer $w, integer $h) : null|resource
static

This is a wrapper around various GD functions, to provide Exponent programmers a single point of entry. It also handles situations where there is no GD support compiled into the server. (In this case, null is returned).

node

Model:expFile

Arguments

$w

integer

Width of the image resource to create (in pixels)

$h

integer

Height of the image resource to create (in pixels)

Response

null|resource

Flip an image file

imageFlip( $filename, boolean $is_horizontal = false) : array|null|resource|string
static

Arguments

$filename

$is_horizontal

boolean

Response

array|null|resource|string

exdoc Output an image based on its mimetype

imageOutput( $img,  $sizeinfo, null $filename = null, integer $quality = 75) 
static

Arguments

$img

$sizeinfo

$filename

null

$quality

integer

Rotate an image file

imageRotate( $filename,  $degrees) : array|null|resource|string
static

Arguments

$filename

$degrees

Response

array|null|resource|string

exdoc Proportionally scale an image by a specific percentage This is a wrapper around various GD functions, to provide Exponent programmers a single point of entry. It also handles situations where there is no GD support compiled into the server. (In this case, null is returned).

imageScaleByPercent(string $filename, float $scale) : array|null|resource|string
static
node

Model:expFile

Arguments

$filename

string

The path/filename of the image to scale.

$scale

float

The scaling factor, as a decimal (i.e. 0.5 for 50%)

Response

array|null|resource|string

exdoc Scale an image to a given width and height, without regard to aspect ratio.

imageScaleManually(string $filename, integer $width, integer $height) : array|null|resource|string
static

This is a wrapper around various GD functions, to provide Exponent programmers a single point of entry. It also handles situations where there is no GD support compiled into the server. (In this case, null is returned).

node

Model:expFile

Arguments

$filename

string

The path/filename of the image to scale.

$width

integer

The desired width of the scaled image, in pixels.

$height

integer

The desired height of the scaled image, in pixels.

Response

array|null|resource|string

exdoc Proportionally scale an image to fit within the given width / height.

imageScaleToConstraint(string $filename, integer $width, integer $height) : array|null|resource|string
static

This is a wrapper around various GD functions, to provide Exponent programmers a single point of entry. It also handles situations where there is no GD support compiled into the server. (In this case, null is returned).

node

Model:expFile

Arguments

$filename

string

The path/filename of the image to scale.

$width

integer

The maximum width of the scaled image, in pixels.

$height

integer

The maximum height of the scaled image, in pixels.

Response

array|null|resource|string

exdoc Proportionally scale an image to a given height. Width adjusts accordingly.

imageScaleToHeight(string $filename, integer $height) : array|null|resource|string
static

This is a wrapper around various GD functions, to provide Exponent programmers a single point of entry. It also handles situations where there is no GD support compiled into the server. (In this case, null is returned).

node

Model:expFile

Arguments

$filename

string

The path/filename of the image to scale.

$height

integer

The desired height of the scaled image, in pixels.

Response

array|null|resource|string

exdoc Proportionally scale an image to a given width. Height adjusts accordingly.

imageScaleToWidth(string $filename, integer $width) : array|null|resource|string
static

This is a wrapper around various GD functions, to provide Exponent programmers a single point of entry. It also handles situations where there is no GD support compiled into the server. (In this case, null is returned).

node

Model:expFile

Arguments

$filename

string

The path/filename of the image to scale.

$width

integer

The desired width of the scaled image, in pixels.

Response

array|null|resource|string

exdoc Checks to see if the file exists case-insensitive. This is to circumvent the case sensitive php is_file.

is_file(string $filename) : boolean
static

Returns true if the file already exists, and false if it does not.

node

Model:expFile

Arguments

$filename

string

The file (with path) to check.

Response

boolean

is model content searchable?

isSearchable() : boolean
inherited static

Response

boolean

exdoc Lists files and directories under a given parent directory. Returns an associative, flat array of files and directories. The key is the full file or directory name, and the value is the file or directory name.

listFlat(string $dir, boolean $recurse = false, string $ext = null, array $exclude_dirs = array(), string $relative = "") : array
static
node

Model:expFile

Arguments

$dir

string

The path of the directory to look at.

$recurse

boolean

A boolean dictating whether to descend into subdirectories recursively, and list files and subdirectories.

$ext

string

An optional file extension. If specified, only files ending with that file extension will show up in the list. Directories are not affected.

$exclude_dirs

array

An array of directory names to exclude. These names are path-independent. Specifying "dir" will ignore all directories and sub-directories named "dir", regardless of their parent.

$relative

string

Response

array

Return expFile object for given path either an existing or a new expFile prevents duplication of existing expFile objects

make_expFile( $path) : array|\expFile|integer
static

Arguments

$path

Response

array|\expFile|integer

exdoc This method creates a directory and all of its parent directories, if they do not exist, emulating the behavior of the -p option to mkdir on UNIX systems. Returns a SYS_FILES_* constant, indicating its status.

makeDirectory(string $dir, null $mode = null, boolean $is_full = false) : integer
static
node

Model:expFile

Arguments

$dir

string

The directory to create. This path must be relative to BASE

$mode

null

$is_full

boolean

Response

integer

create a many to many table relationship

makeManyToManyTablename( $assoc_table) : string
inherited

Arguments

$assoc_table

Response

string

make an sef_url for item

makeSefUrl() 
inherited

exdoc Move an uploaded temporary file to a more permanent home inside of the Exponent files/ directory.

moveUploadedFile(string $tmp_name, string $dest) : null|string
static

This function takes into account the default file modes specified in the site configuration.

node

Model:expFile

Arguments

$tmp_name

string

The temporary path of the uploaded file.

$dest

string

The full path to the destination file (including the destination filename).

Response

null|string

The destination file if it exists, otherwise null

name of module for backwards compat with old modules

name() : string
inherited

Response

string

exdoc Create an image resource handle (from GD) for a given filename.

openImageFile(string $filename, null $sizeinfo = null) : null|resource|string
static

This is a wrapper around various GD functions, to provide Exponent programmers a single point of entry. It also handles situations where there is no GD support compiled into the server. (In this case, null is returned).

At this point, the user should have called self::getImageInfo on the filename and verified that the file does indeed exist, and is readable. A safeguard check is in place, however.

node

Model:expFile

Arguments

$filename

string

The path/filename of the image.

$sizeinfo

null

Response

null|resource|string

exdoc This function reads a database EQL object dump file and returns an array of the database tables and records, or false if something went horribly wrong (unable to read file, etc.) Even if an array is returned, there is a chance that some errors were encountered. Check $errors to be sure everything was fine.

parseDatabase(string $file, array &$errors, \null/string/array $type = null) : \array/bool
static
node

Model:expFile

Arguments

$file

string

The filename of the EQL file to parse

$errors

array

A referenced array that stores errors. Whatever variable is passed in this argument will contain all errors encountered during the parse/restore.

$type

\null/string/array

The list of tables to return, empty = entire file

Response

\array/bool

Recursively copy file(s)

recurse_copy( $src,  $dst) : boolean
static

Arguments

$src

$dst

Response

boolean

re-construct the item from the database

refresh() : boolean
inherited
Throws
\ReflectionException

Response

boolean

Recursively removes the given directory, and all of the files and directories underneath it.

removeDirectory(string $dir) : integer
static
node

Model:expFile

Arguments

$dir

string

directory to work with

Response

integer

Recursively removes all files in a given directory, and all the files and directories underneath it.

removeFilesInDirectory(string $dir, boolean $dot_files = false) : array
static

Optionally can skip dotfiles

Arguments

$dir

string

directory to work with

$dot_files

boolean

should dotfiles be removed?

Response

array

rerank items

rerank( $direction, string $where = '') 
inherited

Arguments

$direction

$where

string

check for duplicate files and returns a file name that's not already in the system

resolveDuplicateFilename(string $filepath) : integer
static
static
access

public

uses

filesize() Built-in PHP method

PHPUnit

Not Defined|Implement|Completed

Throws
void

Arguments

$filepath

string

direct path of the file to check against

Response

integer

$newFileName Name of the file that isn't a duplicate

exdoc This function restores a database (overwriting all data in any existing tables) from an EQL object dump. Returns true if the restore was a success and false if something went horribly wrong (unable to read file, etc.) Even if true is returned, there is a chance that some errors were encountered. Check $errors to be sure everything was fine.

restoreDatabase(string $file, array &$errors, null $type = null) : boolean
static
node

Model:expFile

Throws
\ReflectionException

Arguments

$file

string

The filename of the EQL file to restore from

$errors

array

A referenced array that stores errors. Whatever variable is passed in this argument will contain all errors encountered during the parse/restore.

$type

null

Response

boolean

save item

save(boolean $validate = false, boolean $force_no_revisions = false) 
inherited

Arguments

$validate

boolean

$force_no_revisions

boolean

save associated objects

saveAssociatedObjects() 
inherited

Type of associations has_one

selectAllFiles

selectAllFiles() 
static

update item

update(array|object $params = array()) 
inherited

Arguments

$params

array|object

recreates a deprecated formbuilder data table needed to import form data from eql file exported prior to v2.1.4 this is just the old formbuilder_form::updateTable method

updateFormbuilderTable( $object) : mixed
static
static

Arguments

$object

Response

mixed

exdoc Checks to see if the upload destination file exists. This is to prevent accidentally uploading over the top of another file.

uploadDestinationFileExists(string $dir, string $name) : boolean
static

Returns true if the file already exists, and false if it does not.

node

Model:expFile

Arguments

$dir

string

The directory to contain the existing directory.

$name

string

The name of the file control used to upload the file. The files subsystem will look to the $_FILES array to get the filename of the uploaded file.

Response

boolean

validate item sef_url

validate() : boolean
inherited

Response

boolean

Constants

SYS_IMAGE

SYS_IMAGE

IMAGE_ERR_NOGD

IMAGE_ERR_NOGD

IMAGE_ERR_NOTSUPPORTED

IMAGE_ERR_NOTSUPPORTED

IMAGE_ERR_FILENOTFOUND

IMAGE_ERR_FILENOTFOUND

IMAGE_ERR_PERMISSIONDENIED

IMAGE_ERR_PERMISSIONDENIED

Mode to use for reading from files

FILE_MODE_READ
constant

string FILE_MODE_READ

access

private

PHPUnit

Not Defined

Mode to use for truncating files, then writing

FILE_MODE_WRITE
constant

string FILE_MODE_WRITE

access

private

PHPUnit

Not Defined

Mode to use for appending to files

FILE_MODE_APPEND
constant

string FILE_MODE_APPEND

access

private

PHPUnit

Not Defined

Use this when a shared (read) lock is required.

FILE_LOCK_SHARED

This is a "relabel" of the PHP 'LOCK_SH' constant

constant

string FILE_LOCK_SHARED

access

private

PHPUnit

Not Defined

Use this when an exclusive (write) lock is required This is a "relabel" of the PHP 'LOCK_EX' constant

FILE_LOCK_EXCLUSIVE
constant

string FILE_LOCK_EXCLUSIVE

access

private

PHPUnit

Not Defined

Properties

Database Table Name to store File info

table : 
public
property

Database Table Name

Type(s)

attachable_table

attachable_table : 

Type(s)

attachable_item_types

attachable_item_types : 
inherited

Type(s)

Relative OS System File path to where $filename is [to be] located

directory : 
protected
property

Relative OS System File path

Type(s)

File Name of File to process

filename : 
public
property

Name of File to process

Type(s)

Size of File, in Bytes

filesize : 
protected
property

Size of File, in Bytes.

Type(s)

Mime Type of File.

mimetype : 
public
property

File MIME Type

Type(s)

Image width in pixels.

image_width : 
public
property

Image width in pixels

Type(s)

Image height in pixels.

image_height : 
public
property

Image height in pixels

Type(s)

Is this file an image.

is_image : 

Defaults to FALSE

public
property

Is this file an image

Type(s)

Determines if this file can be overwritten.

fileOverWrite : 

Also if it can be "moved" or "renamed" over Default set to FALSE, no it can't

protected

boolean

property

Determines if this file be overwritten

access

protected

since

Type(s)

Web based Path for current File

url : 
public
property

Web based Path

Type(s)

Full File System Path for current File. Also used to in FILE Record

path : 
public
property

Full File System Path

Type(s)

Relative File System Path for current File

path_relative : 
public
property

Relative File System Path

Type(s)

classinfo

classinfo : 
inherited

Type(s)

classname

classname : 
inherited

Type(s)

tablename

tablename : 
inherited

Type(s)

identifier

identifier : 
inherited

Type(s)

rank_by_field

rank_by_field : 
inherited

Type(s)

grouping_sql

grouping_sql : 
inherited

Type(s)

has_extended_fields

has_extended_fields : 
inherited

Type(s)

has_one

has_one : 
inherited

Type(s)

has_many

has_many : 
inherited

Type(s)

has_many_self

has_many_self : 
inherited

Type(s)

has_and_belongs_to_many

has_and_belongs_to_many : 
inherited

Type(s)

has_and_belongs_to_self

has_and_belongs_to_self : 
inherited

Type(s)

default_sort_field

default_sort_field : 
inherited

Type(s)

default_sort_direction

default_sort_direction : 
inherited

Type(s)

get_assoc_for

get_assoc_for : 
inherited

Type(s)

attachable_items_to_save

attachable_items_to_save : 
inherited

Type(s)

get_attachable_for

get_attachable_for : 
inherited

Type(s)

validate

validate : 
inherited

Type(s)

do_not_validate

do_not_validate : 
inherited

Type(s)

supports_revisions

supports_revisions : 
inherited

Type(s)

needs_approval

needs_approval : 
inherited

Type(s)