vBulletin 5.6.5 API

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
version

$Revision: 105757 $

date

$Date: 2020-07-29 16:02:55 -0700 (Wed, 29 Jul 2020) $

Table of Contents

ATTACH_AS_DB  = 0
Supported types of storage
ATTACH_AS_FILES_NEW  = 2
ATTACH_AS_FILES_OLD  = 1
$filePath  : mixed
$instance  : mixed
$storage  : string
Storage Type
$cachedLengthToSizeType  : mixed
$sortedAttachResizes  : mixed
__serialize()  : mixed
__sleep()  : mixed
__unserialize()  : mixed
__wakeup()  : mixed
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.
getAttachmentFile()  : mixed
getContentInstance()  : mixed
instance()  : vB_PageCache
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
__construct()  : mixed
Standard Constructor
cleanFileParams()  : mixed
getLibraryClassNameInternal()  : mixed
getAttachmentFileInternal()  : mixed
getExistingFile()  : mixed
trimEmptyDirectories()  : bool
Attempts to recursively trim empty subdirectories

Constants

ATTACH_AS_DB

Supported types of storage

public mixed ATTACH_AS_DB = ""

These should match the legacy defines at the top of core/includes/functions_file.php

Tags
constant

int

ATTACH_AS_FILES_NEW

public mixed ATTACH_AS_FILES_NEW = 2

ATTACH_AS_FILES_OLD

public mixed ATTACH_AS_FILES_OLD = 1

Properties

$filePath

protected mixed $filePath = alse

$instance

protected static mixed $instance = array()

$storage

Storage Type

protected string $storage = ull

$cachedLengthToSizeType

private mixed $cachedLengthToSizeType

$sortedAttachResizes

private mixed $sortedAttachResizes

Methods

__serialize()

public __serialize() : mixed
Return values
mixed

__sleep()

public __sleep() : mixed
Return values
mixed

__unserialize()

public __unserialize(mixed $serialized) : mixed
Parameters
$serialized : mixed
Return values
mixed

__wakeup()

public __wakeup() : mixed
Return values
mixed

clearCache()

public static clearCache() : mixed
Return values
mixed

convertLengthToPixelsWithoutUnits()

public convertLengthToPixelsWithoutUnits(mixed $value) : mixed
Parameters
$value : mixed
Return values
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.

Return values
mixed

deleteFileDataFiles()

public deleteFileDataFiles(mixed $userid, mixed $filedataid) : mixed
Parameters
$userid : mixed
$filedataid : mixed
Return values
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
string

getAttachmentFile()

public getAttachmentFile(mixed $userid, mixed $filedataid[, mixed $resizeType = vB_Api_Filedata::SIZE_FULL ]) : mixed
Parameters
$userid : mixed
$filedataid : mixed
$resizeType : mixed = vB_Api_Filedata::SIZE_FULL
Return values
mixed

getContentInstance()

public static getContentInstance(mixed $contenttypeid) : mixed
Parameters
$contenttypeid : mixed
Return values
mixed

instance()

Returns singleton instance of self.

public static instance(mixed $class) : vB_PageCache
Parameters
$class : mixed
Return values
vB_PageCache
  • Reference to singleton instance of the cache handler

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) : mixed
Parameters
$text : mixed
$type : mixed
$nodeid : mixed
$userid : mixed = null
$insertNotifications : mixed = true
$currentuserid : mixed
Return values
mixed

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
Return values
mixed

__construct()

Standard Constructor

protected __construct() : mixed
Return values
mixed

cleanFileParams()

protected cleanFileParams([mixed &$filedata = false ][, mixed $filedataid = false ]) : mixed
Parameters
$filedata : mixed = false
$filedataid : mixed = false
Return values
mixed

getLibraryClassNameInternal()

protected static getLibraryClassNameInternal(mixed $controller) : mixed
Parameters
$controller : mixed
Return values
mixed

getAttachmentFileInternal()

private getAttachmentFileInternal(mixed $path, mixed $filedataid, mixed $resizeType) : mixed
Parameters
$path : mixed
$filedataid : mixed
$resizeType : mixed
Return values
mixed

getExistingFile()

private getExistingFile(mixed $userid, mixed $filedataid, mixed $resizeType) : mixed
Parameters
$userid : mixed
$filedataid : mixed
$resizeType : mixed
Return values
mixed

trimEmptyDirectories()

Attempts to recursively trim empty subdirectories

private trimEmptyDirectories( $directory) : bool

Goes through a directory tree and attempts to delete any empty subdirectories Does depth first recursively so that we remove a directory that starts out with children if those children are removed

Parameters
$directory :

-- directory to trim

Return values
bool

-- true if we deleted the directory

Search results