FRED™  3.0
FRED™: Framework for Rapid and Easy Development
File Class Reference
Inheritance diagram for File:
Widget Thing

Public Member Functions

 clientConfig ()
 Public configuration. More...
 
 check ($value, $index=null)
 
 preview ($filename=null, &$count=null, &$rotate=null)
 Generate a preview. More...
 
 rotate ($angle=90, $filename=null)
 Rotate a file. More...
 
- Public Member Functions inherited from Widget
 __construct ($config=null)
 
 update ($config)
 Update the widget configuration. More...
 
 caption ($id=null)
 
 hint ($id=null)
 
 meta ($key, $default=null)
 Get a meta data value. More...
 
 convert ($value)
 Convert a value from user format to standard, internal format. More...
 
 clientConvert ($value)
 Convert a value from client format to standard, internal format. More...
 
 dataConvert ($value)
 Convert an internal value before it is stored in the request data. More...
 
 format ($value)
 Format a value from standard, internal format to user format. More...
 
 clientFormat ($value)
 Format a value from standard, internal format to client format. More...
 
 formatTag ($value)
 Format a tag value. More...
 
 purge ($value)
 Purge a value. More...
 
 expect ($action)
 Note if an action is expected. More...
 
 execute ($id)
 Execute an action on this widget. More...
 
 nothing ($value)
 Check if a value is empty. More...
 
 check ($value)
 Check a value. More...
 
- Public Member Functions inherited from Thing
 propertyExists ($property)
 Check if a property exists (public or published). More...
 
 constants ($prefix=null)
 Return all constants. More...
 
 get ($key)
 Get one or more properties. More...
 
 set ($key, $value=null)
 Set one or more properties. More...
 
 __get ($key)
 
 __set ($key, $value)
 

Data Fields

const TYPES = 'types'
 Allowed file types (mime or extension; mime can have asterisk wildcards or even be a complete. More...
 
const FILENAME = 'filename'
 Fixed filename for the upload. If everything is OK, file will be overwitten directly, and. More...
 
const MULTI = 'multi'
 Allow multiple files to be uploaded. More...
 
const PREVIEW_SIZE = 'previewSize'
 Size (width) of preview image (false = no preview). More...
 
const USER_FILES = 'userFiles'
 Show user files. More...
 
const EVENT_UPLOAD = 'controller:widget:file:upload'
 
const TUS_VERSION = '1.0.0'
 
const TUS_EXTENSIONS = 'creation,termination,checksum'
 
 $types = []
 
 $filename = null
 
 $multi = false
 
 $previewSize = false
 
 $previewTtl = null
 
 $previewKeyPrefix = 'fred-controller-widget-file-preview-'
 
 $previewMax = 3
 Maximum number of preview images. More...
 
 $memoryMargin = 20 * 1048576
 Spare memory for async file upload processing. More...
 
 $memoryFactor = 0.5
 Factor memory for async file upload processing. More...
 
 $userFiles = false
 
 $sideloadControllerName = null
 Controller that provides the sideloading. More...
 
 $sideloadPath = null
 Path to temporarily store sideload files. More...
 
 $sideloadExt = '.side'
 Extension for sideload files. More...
 
 $sideloadMode = 0666
 File mode for sideload files. More...
 
 $sideloadTokenLength = 32
 Length of the sideload token. More...
 
 $sideloadHint = null
 Hint to show during sideloading (translated). More...
 
 $sideloadInterval = 5
 Poll interval for sideloading check (seconds). More...
 
 $sideloadGarbageChance = 100
 Clear sideloading path once every ... times. More...
 
 $sideloadSkip = 5
 Stop scanning for new files after this number of misses. More...
 
 $tusPath = null
 Path to temporarily store TUS data. More...
 
 $tusExt = '.tus'
 Extension for TUS data files. More...
 
 $tusTempExt = '.file'
 Extension for TUS partial file upload. More...
 
 $tusMode = 0666
 File mode for TUS data files. More...
 
 $tusTokenLength = 32
 Length of the TUS token. More...
 
 $tusTimeout = 3600
 Time after which an inactive upload is removed (seconds). More...
 
 $tusGarbageChance = 100
 Clear TUS path once every ... times. More...
 
 $tusChunkSize = null
 Upload chunk size for TUS upload (empty = calculate). More...
 
 $tusScriptSrc = '/fred/js/tus.min.js'
 Script to load for TUS upload (set to empty when already loaded). More...
 
- Data Fields inherited from Widget
const CHILD_ID_SEPARATOR = '__'
 
const CAPTION = 'caption'
 
const DEFAULT_VALUE = 'defaultValue'
 
const DISPLAY = 'display'
 Display type (see DISPLAY_* constants). More...
 
const HELP = 'help'
 Help string (translated). More...
 
const HINT = 'hint'
 Hint string (translated). More...
 
const META = 'meta'
 Meta data (array). More...
 
const PARAMS = 'params'
 Extra parameters for async calls (prefix the key with a '@' to point to the value of another. More...
 
const RIGHT = 'right'
 Optional different right with respect to the controller. If the user has the right, then (s)he. More...
 
const TRAILER = 'trailer'
 Trailer string (translated). More...
 
const TAGS = 'tags'
 Extra tags for help, hint, and trailer. More...
 
const WIDGET_HELP = 'widgetHelp'
 General widget help (translated). More...
 
const CLASS_NAME = 'className'
 
const MIN = 'min'
 Minimum value. More...
 
const MAX = 'max'
 Maximum value. More...
 
const REQUIRED = 'required'
 True for required. Set to self::VALID_FUNC to let the validation function handle this. Use. More...
 
const VALID_FUNC = 'validFunc'
 Specific validation function (called with value and index; returns true if OK). More...
 
const WIDGETS = 'widgets'
 Optional child widgets (key = name, value = widget object). More...
 
const SECURITY_CHECKS_IGNORE = 'securityChecksIgnore'
 Security checks to ignore (array with checks to ignore, true =. More...
 
const DISPLAY_HIDDEN = 'h'
 Do not show (only hidden) More...
 
const DISPLAY_MINIMAL = 'm'
 Show only value (without input element(s)). More...
 
const DISPLAY_READABLE = 'r'
 Show input element(s), but read-only. More...
 
const DISPLAY_WRITEABLE = 'w'
 Show editable input element(s). More...
 
const EVENT_ACTION_PREFIX = 'controller:widget:action:'
 
 $defaultValue = null
 
 $help = null
 
 $min = null
 
 $max = null
 
 $required = null
 
 $trailer = null
 
 $widgetHelp = null
 
 $validFunc = null
 
 $parent = null
 Optional parent widget. More...
 
 $indexes = []
 
- Data Fields inherited from Thing
const HIDDEN = 0
 Property is hidden. More...
 
const READABLE = 1
 Property is readable. More...
 
const WRITEABLE = 2
 Property is writeable. More...
 
const READWRITE = 3
 Property is readable and writeable. More...
 

Protected Member Functions

 purgeBase ($value)
 Purge uploaded filename from possible array construction. More...
 
 uploadEvent ($name)
 
 checkMin ($value, $index=null)
 
 checkMax ($value, $index=null)
 
 checkUpload ($value, $index=null)
 
 checkTypes ($value, $index=null)
 
 previewFile ($filename)
 
 processUpload ($temp, $name)
 Process upload data. More...
 
 sideloadFilename ($token, $index=null)
 Filename for a sideload file. More...
 
 sideloadUrl ($token)
 Sideload URL. More...
 
 sideloadGarbage ()
 Clear old sideload tokens. More...
 
 tusError ($code, $message)
 
 tusIndex ($header)
 
 tusFilename ($token)
 
 tusGarbage ()
 
 actionPreview ()
 
 actionDownload ()
 
 actionUpload ()
 
 actionRotate ()
 
 actionDelete ()
 
 actionUserFiles ()
 
 actionUserFilePreview ()
 
 actionUserFile ()
 
 actionSideload ()
 
 actionSideloadImage ()
 
 actionSideloadCheck ()
 
 actionTus ()
 
 getFilenames ()
 
 getSideloadToken ()
 
- Protected Member Functions inherited from Widget
 init ()
 
 config ($key, $default=null)
 Get single configuration value. More...
 
 executeChild ($id)
 Execute an action on a child widget. More...
 
 indexId ($id, $join=false)
 Add indexes to an ID (with wildcards). More...
 
 checkMin ($value)
 
 checkMax ($value)
 
 checkRequired ($value)
 Required check. More...
 
 checkValidFunc ($value)
 
 actionHelp ()
 
 setController ($value)
 
 getDisplay ()
 
 getFred ()
 
 getId ()
 
 getParams ()
 
 getReadable ()
 
 getRight ()
 
 getTags ()
 
 getWidgets ()
 
 getWriteable ()
 
 _get ($key)
 Default getter if no specific setter is defined, and the property is also not published (readable). More...
 
- Protected Member Functions inherited from Thing
 publish ($property, $visibility=self::READABLE)
 Publish a property (or hide it again). More...
 
 alias ($alias, $property, $object=null)
 Define an alias for a property (of another object). More...
 
 configure ($config)
 Configure the object. More...
 
 _set ($key, $value)
 Default setter if no specific setter is defined, and the property is also not published (writeable). More...
 

Protected Attributes

 $_raw = null
 
 $_multiRaw = null
 
- Protected Attributes inherited from Widget
 $_controller = null
 
 $_id = null
 
 $_widgets = null
 Optional child widgets. More...
 
 $_securityChecksIgnore = []
 Security checks to ignore. More...
 
 $_config = []
 Widget configuration (see constants). More...
 
 $_display = null
 
 $_meta = []
 
 $_params = []
 
 $_right = null
 
 $_tags = null
 
 $_executing = false
 Executing an direct action on the widget. More...
 
- Protected Attributes inherited from Thing
 $_published = []
 Published properties (key = name of property, value = visibility). More...
 
 $_aliases = []
 Alias properties (key = alias, value = [object,property]). More...
 

Detailed Description

Definition at line 7 of file File.php.

Member Function Documentation

◆ actionDelete()

actionDelete ( )
protected

Definition at line 359 of file File.php.

◆ actionDownload()

actionDownload ( )
protected

Definition at line 329 of file File.php.

◆ actionPreview()

actionPreview ( )
protected

Definition at line 321 of file File.php.

◆ actionRotate()

actionRotate ( )
protected

Definition at line 348 of file File.php.

◆ actionSideload()

actionSideload ( )
protected

Definition at line 392 of file File.php.

◆ actionSideloadCheck()

actionSideloadCheck ( )
protected

Definition at line 427 of file File.php.

◆ actionSideloadImage()

actionSideloadImage ( )
protected

Definition at line 419 of file File.php.

◆ actionTus()

actionTus ( )
protected

Definition at line 445 of file File.php.

◆ actionUpload()

actionUpload ( )
protected

Definition at line 340 of file File.php.

◆ actionUserFile()

actionUserFile ( )
protected

Definition at line 384 of file File.php.

◆ actionUserFilePreview()

actionUserFilePreview ( )
protected

Definition at line 373 of file File.php.

◆ actionUserFiles()

actionUserFiles ( )
protected

Definition at line 366 of file File.php.

◆ check()

check (   $value,
  $index = null 
)

Definition at line 124 of file File.php.

◆ checkMax()

checkMax (   $value,
  $index = null 
)
protected

Definition at line 107 of file File.php.

◆ checkMin()

checkMin (   $value,
  $index = null 
)
protected

Definition at line 103 of file File.php.

◆ checkTypes()

checkTypes (   $value,
  $index = null 
)
protected

Definition at line 115 of file File.php.

◆ checkUpload()

checkUpload (   $value,
  $index = null 
)
protected

Definition at line 111 of file File.php.

◆ clientConfig()

clientConfig ( )

Public configuration.

Returns
array Public configuration for this widget in key => value pairs.

Reimplemented from Widget.

Definition at line 56 of file File.php.

◆ getFilenames()

getFilenames ( )
protected

Definition at line 549 of file File.php.

◆ getSideloadToken()

getSideloadToken ( )
protected

Definition at line 555 of file File.php.

◆ preview()

preview (   $filename = null,
$count = null,
$rotate = null 
)

Generate a preview.

Parameters
string$filenameFile to generate a preview for (empty = fixed upload filename).
int$countWill be set to the number of pages in the file.
bool$rotateWill be set to true if the image can be rotated.
Returns
array Preview PNG images.

Definition at line 189 of file File.php.

◆ previewFile()

previewFile (   $filename)
protected

Definition at line 140 of file File.php.

◆ processUpload()

processUpload (   $temp,
  $name 
)
protected

Process upload data.

Parameters
mixed$tempTemporarily file with uploaded data.
string$nameOriginal filename.

Definition at line 240 of file File.php.

◆ purgeBase()

purgeBase (   $value)
protected

Purge uploaded filename from possible array construction.

If all details are needed you can call fred->request->file(['widget','id']) (where $id can also be multiple levels deep).

Reimplemented from Widget.

Definition at line 87 of file File.php.

◆ rotate()

rotate (   $angle = 90,
  $filename = null 
)

Rotate a file.

Parameters
int$angleRotation angle (positive: degrees clockwise; -1: flip horizontal, -2: flip vertical).
string$filenameFile to rotate (empty = fixed upload filename).
Returns
bool True if the operation was successful (file will be replaced).

Definition at line 218 of file File.php.

◆ sideloadFilename()

sideloadFilename (   $token,
  $index = null 
)
protected

Filename for a sideload file.

Parameters
string$tokenSideload token.
int$indexUpload index.
Returns
string

Definition at line 261 of file File.php.

◆ sideloadGarbage()

sideloadGarbage ( )
protected

Clear old sideload tokens.

Definition at line 275 of file File.php.

◆ sideloadUrl()

sideloadUrl (   $token)
protected

Sideload URL.

Parameters
string$tokenSideload token.
Returns
string Full URL.

Definition at line 269 of file File.php.

◆ tusError()

tusError (   $code,
  $message 
)
protected

Definition at line 290 of file File.php.

◆ tusFilename()

tusFilename (   $token)
protected

Definition at line 304 of file File.php.

◆ tusGarbage()

tusGarbage ( )
protected

Definition at line 308 of file File.php.

◆ tusIndex()

tusIndex (   $header)
protected

Definition at line 297 of file File.php.

◆ uploadEvent()

uploadEvent (   $name)
protected

Definition at line 99 of file File.php.

Field Documentation

◆ $_multiRaw

$_multiRaw = null
protected

Definition at line 54 of file File.php.

◆ $_raw

$_raw = null
protected

Definition at line 53 of file File.php.

◆ $filename

$filename = null

Definition at line 23 of file File.php.

◆ $memoryFactor

$memoryFactor = 0.5

Factor memory for async file upload processing.

Definition at line 30 of file File.php.

◆ $memoryMargin

$memoryMargin = 20 * 1048576

Spare memory for async file upload processing.

Definition at line 29 of file File.php.

◆ $multi

$multi = false

Definition at line 24 of file File.php.

◆ $previewKeyPrefix

$previewKeyPrefix = 'fred-controller-widget-file-preview-'

Definition at line 27 of file File.php.

◆ $previewMax

$previewMax = 3

Maximum number of preview images.

Definition at line 28 of file File.php.

◆ $previewSize

$previewSize = false

Definition at line 25 of file File.php.

◆ $previewTtl

$previewTtl = null

Definition at line 26 of file File.php.

◆ $sideloadControllerName

$sideloadControllerName = null

Controller that provides the sideloading.

Definition at line 33 of file File.php.

◆ $sideloadExt

$sideloadExt = '.side'

Extension for sideload files.

Definition at line 35 of file File.php.

◆ $sideloadGarbageChance

$sideloadGarbageChance = 100

Clear sideloading path once every ... times.

Definition at line 40 of file File.php.

◆ $sideloadHint

$sideloadHint = null

Hint to show during sideloading (translated).

Definition at line 38 of file File.php.

◆ $sideloadInterval

$sideloadInterval = 5

Poll interval for sideloading check (seconds).

Definition at line 39 of file File.php.

◆ $sideloadMode

$sideloadMode = 0666

File mode for sideload files.

Definition at line 36 of file File.php.

◆ $sideloadPath

$sideloadPath = null

Path to temporarily store sideload files.

Definition at line 34 of file File.php.

◆ $sideloadSkip

$sideloadSkip = 5

Stop scanning for new files after this number of misses.

Definition at line 41 of file File.php.

◆ $sideloadTokenLength

$sideloadTokenLength = 32

Length of the sideload token.

Definition at line 37 of file File.php.

◆ $tusChunkSize

$tusChunkSize = null

Upload chunk size for TUS upload (empty = calculate).

Definition at line 50 of file File.php.

◆ $tusExt

$tusExt = '.tus'

Extension for TUS data files.

Definition at line 44 of file File.php.

◆ $tusGarbageChance

$tusGarbageChance = 100

Clear TUS path once every ... times.

Definition at line 49 of file File.php.

◆ $tusMode

$tusMode = 0666

File mode for TUS data files.

Definition at line 46 of file File.php.

◆ $tusPath

$tusPath = null

Path to temporarily store TUS data.

Definition at line 43 of file File.php.

◆ $tusScriptSrc

$tusScriptSrc = '/fred/js/tus.min.js'

Script to load for TUS upload (set to empty when already loaded).

Definition at line 51 of file File.php.

◆ $tusTempExt

$tusTempExt = '.file'

Extension for TUS partial file upload.

Definition at line 45 of file File.php.

◆ $tusTimeout

$tusTimeout = 3600

Time after which an inactive upload is removed (seconds).

Definition at line 48 of file File.php.

◆ $tusTokenLength

$tusTokenLength = 32

Length of the TUS token.

Definition at line 47 of file File.php.

◆ $types

$types = []

Definition at line 22 of file File.php.

◆ $userFiles

$userFiles = false

Definition at line 31 of file File.php.

◆ EVENT_UPLOAD

const EVENT_UPLOAD = 'controller:widget:file:upload'

Definition at line 17 of file File.php.

◆ FILENAME

const FILENAME = 'filename'

Fixed filename for the upload. If everything is OK, file will be overwitten directly, and.

Definition at line 11 of file File.php.

◆ MULTI

const MULTI = 'multi'

Allow multiple files to be uploaded.

Definition at line 13 of file File.php.

◆ PREVIEW_SIZE

const PREVIEW_SIZE = 'previewSize'

Size (width) of preview image (false = no preview).

Definition at line 14 of file File.php.

◆ TUS_EXTENSIONS

const TUS_EXTENSIONS = 'creation,termination,checksum'

Definition at line 20 of file File.php.

◆ TUS_VERSION

const TUS_VERSION = '1.0.0'

Definition at line 19 of file File.php.

◆ TYPES

const TYPES = 'types'

Allowed file types (mime or extension; mime can have asterisk wildcards or even be a complete.

Definition at line 9 of file File.php.

◆ USER_FILES

const USER_FILES = 'userFiles'

Show user files.

Definition at line 15 of file File.php.


The documentation for this class was generated from the following file: