vB_Library_Filedata
extends vB_Library
in package
Class to manage FileData. At the moment the only thing it does is to move filedata between the database and filesystem.
Tags
Table of Contents
Constants
- ATTACH_AS_DB = 0
- Supported types of storage
- ATTACH_AS_FILES_NEW = 2
- ATTACH_AS_FILES_OLD = 1
Methods
- __serialize() : array<string|int, mixed>
- __sleep() : array<string|int, mixed>
- __unserialize() : void
- __wakeup() : void
- clearCache() : mixed
- convertLengthToPixelsWithoutUnits() : mixed
- deleteFileData() : mixed
- Delete the filedata records
- deleteFileDataFiles() : mixed
- fetchAttachmentPath() : string
- Get the path for a user and make sure it exists
- fetchBestFitGTE() : string
- Returns the resize type (e.g. 'full', 'icon') that would require the minimal scale-down/shrink to fit inside a $targetLength pixel square.
- getContentInstance() : mixed
- instance() : static
- Returns singleton instance of self.
- monitorWords() : mixed
- Checks if the text contains monitored words, and if so, sends notifications to admins and moderators if the setting is on.
- moveToDb() : array<string|int, mixed>
- moves one record from the filesystem to the database
- moveToFs() : array<string|int, mixed>
- moves one record from the database to the filesystem
- sanitizeFiletype() : string
- Ensures that Sent in thumbnail type is valid
- trimEmptyFiledataDirectories() : mixed
Constants
ATTACH_AS_DB
Supported types of storage
public
mixed
ATTACH_AS_DB
= 0
These should match the legacy defines at the top of core/includes/functions_file.php
Tags
ATTACH_AS_FILES_NEW
public
mixed
ATTACH_AS_FILES_NEW
= 2
ATTACH_AS_FILES_OLD
public
mixed
ATTACH_AS_FILES_OLD
= 1
Methods
__serialize()
public
__serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>__sleep()
public
__sleep() : array<string|int, mixed>
Return values
array<string|int, mixed>__unserialize()
public
__unserialize(array<string|int, mixed> $serialized) : void
Parameters
- $serialized : array<string|int, mixed>
__wakeup()
public
__wakeup() : void
clearCache()
public
static clearCache() : mixed
convertLengthToPixelsWithoutUnits()
public
convertLengthToPixelsWithoutUnits(mixed $value) : mixed
Parameters
- $value : mixed
deleteFileData()
Delete the filedata records
public
deleteFileData(array<string|int, mixed>|int $filedataids) : mixed
Will also remove the files from disk if that option is being used.
Parameters
- $filedataids : array<string|int, mixed>|int
-
-- ids to delete. Takes either a single id or a list.
deleteFileDataFiles()
public
deleteFileDataFiles(mixed $userid, mixed $filedataid) : mixed
Parameters
- $userid : mixed
- $filedataid : mixed
fetchAttachmentPath()
Get the path for a user and make sure it exists
public
fetchAttachmentPath(int $userid, int $storageType[, bool $create = true ]) : string
Parameters
- $userid : int
- $storageType : int
-
-- Attachment storage type to use to generate the path needed because
- $create : bool = true
-
-- create the path if it doesn't exist.
Return values
string —path to user's storage.
fetchBestFitGTE()
Returns the resize type (e.g. 'full', 'icon') that would require the minimal scale-down/shrink to fit inside a $targetLength pixel square.
public
fetchBestFitGTE(int|float $targetLength) : string
Note that this function always looks for greater than or equal to, not minimum difference (e.g. not meant for enlarging or "fit inside without transform" types of usage)
Parameters
- $targetLength : int|float
-
Desired target length (measured in pixels) of the including box size.
Return values
stringgetContentInstance()
public
static getContentInstance(mixed $contenttypeid) : mixed
Parameters
- $contenttypeid : mixed
instance()
Returns singleton instance of self.
public
static instance(mixed $class) : static
Parameters
- $class : mixed
Return values
static —- Reference to singleton instance of the requested library class
monitorWords()
Checks if the text contains monitored words, and if so, sends notifications to admins and moderators if the setting is on.
public
monitorWords(mixed $text, mixed $type, mixed $nodeid[, mixed $userid = null ][, mixed $insertNotifications = true ][, mixed $currentuserid = 0 ]) : mixed
Parameters
- $text : mixed
- $type : mixed
- $nodeid : mixed
- $userid : mixed = null
- $insertNotifications : mixed = true
- $currentuserid : mixed = 0
Tags
moveToDb()
moves one record from the filesystem to the database
public
moveToDb([mixed &$filedata = false ][, mixed $filedataid = false ][, mixed $resize = array() ]) : array<string|int, mixed>
Parameters
- $filedata : mixed = false
- $filedataid : mixed = false
- $resize : mixed = array()
Return values
array<string|int, mixed> —has either 'success' or 'error'
moveToFs()
moves one record from the database to the filesystem
public
moveToFs([array<string|int, mixed> &$filedata = false ][, int $filedataid = false ][, mixed $resize = array() ]) : array<string|int, mixed>
Parameters
- $filedata : array<string|int, mixed> = false
-
(optional) -- filedata record
- $filedataid : int = false
-
(optional)
- $resize : mixed = array()
Return values
array<string|int, mixed> —has either 'success' or 'error'
sanitizeFiletype()
Ensures that Sent in thumbnail type is valid
public
sanitizeFiletype(mixed $type) : string
Parameters
- $type : mixed
Return values
string —Valid image size to get
trimEmptyFiledataDirectories()
public
trimEmptyFiledataDirectories() : mixed