vB_Api_Filedata
extends vB_Api
in package
vB_Api_Filedata
Table of Contents
Constants
- SIZE_FULL = 'full'
- SIZE_ICON = 'icon'
- SIZE_LARGE = 'large'
- SIZE_MEDIUM = 'medium'
- SIZE_SMALL = 'small'
- SIZE_THUMB = 'thumb'
Methods
- __serialize() : array<string|int, mixed>
- __sleep() : array<string|int, mixed>
- __unserialize() : void
- __wakeup() : void
- callNamed() : The
- Call the given api function by name with a named arguments list.
- checkApiState() : mixed
- This method checks whether the API method is enabled.
- clearCache() : mixed
- Clears all previously loaded API objects.
- fetchAttachFiledataid() : array<string|int, mixed>
- fetch filedataid(s) for the passed attachment nodeid(s)
- 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.
- fetchFiledataByid() : array<string|int, mixed>
- fetch filedata records based on filedata ids
- fetchImageByFiledataid() : mixed
- Fetch image information about an attachment based on file data id
- fetchLegacyAttachments() : array<string|int, mixed>
- Returns filedataids, filenames & other publicly visible properties of requested legacy attachments.
- fetchPhotoFiledataid() : array<string|int, mixed>
- fetch filedataid(s) for the passed photo nodeid(s)
- getApiClassName() : mixed
- instance() : vB_Api
- Returns an instance of the API object which translates exceptions to an array Use this method for API clients.
- instanceInternal() : vB_Api
- Returns an instance of the API object which doesn't handle exceptions This should only be used in other API objects, not for clients of the API
- map_vb4_input_to_vb5() : string
- Returns vb5 api method name.
- map_vb5_errors_to_vb4() : mixed
- Alters the error array in any way necessary to interface correctly with vb4.
- map_vb5_output_to_vb4() : mixed
- Alters the output array in any way necessary to interface correctly with vb4.
- sanitizeFiletype() : string
- Ensures that Sent in thumbnail type is valid
Constants
SIZE_FULL
public
mixed
SIZE_FULL
= 'full'
SIZE_ICON
public
mixed
SIZE_ICON
= 'icon'
SIZE_LARGE
public
mixed
SIZE_LARGE
= 'large'
SIZE_MEDIUM
public
mixed
SIZE_MEDIUM
= 'medium'
SIZE_SMALL
public
mixed
SIZE_SMALL
= 'small'
SIZE_THUMB
public
mixed
SIZE_THUMB
= 'thumb'
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
callNamed()
Call the given api function by name with a named arguments list.
public
callNamed() : The
Used primarily to translate REST requests into API calls.
Return values
The —return of the method or an error if the method doesn't exist, or is static, a constructor or destructor, or otherwise shouldn't be callable as and API method. It is also an error if the value of a paramater is not provided and that parameter doesn't have a default value.
checkApiState()
This method checks whether the API method is enabled.
public
checkApiState(mixed $method) : mixed
For extensions check make sure $controller property is already set.
Parameters
- $method : mixed
clearCache()
Clears all previously loaded API objects.
public
static clearCache() : mixed
Intended for use in tests where the loading pattern can cause issues with objects that cache thier own data.
fetchAttachFiledataid()
fetch filedataid(s) for the passed attachment nodeid(s)
public
fetchAttachFiledataid(mixed $nodeid) : array<string|int, mixed>
@param mixed(array|int) $nodeids
Parameters
- $nodeid : mixed
Return values
array<string|int, mixed> —filedataids for the requested attachments
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 —Value to be used for the type= parameter for filedata/fetch image URLs
fetchFiledataByid()
fetch filedata records based on filedata ids
public
fetchFiledataByid(mixed $ids) : array<string|int, mixed>
Parameters
- $ids : mixed
Return values
array<string|int, mixed> —of data, includes filesize, dateline, htmltype, filename, extension, and filedataid
fetchImageByFiledataid()
Fetch image information about an attachment based on file data id
public
fetchImageByFiledataid(mixed $id[, mixed $type = vB_Api_Filedata::SIZE_FULL ][, mixed $includeData = true ][, mixed $attachmentnodeid = 0 ]) : mixed
Parameters
- $id : mixed
- $type : mixed = vB_Api_Filedata::SIZE_FULL
- $includeData : mixed = true
- $attachmentnodeid : mixed = 0
Tags
Return values
mixed —array of data, includes filesize, dateline, htmltype, filename, extension, and filedataid
fetchLegacyAttachments()
Returns filedataids, filenames & other publicly visible properties of requested legacy attachments.
public
fetchLegacyAttachments(array<string|int, int> $ids) : array<string|int, mixed>
Also contains 'cangetattachment' and 'cangetimgattachment' which is specific to the current user.
Parameters
- $ids : array<string|int, int>
-
Integer array of legacy attachment ids (stored in
node
.oldid in vB5)
Return values
array<string|int, mixed> —Array( {oldid1} => [attachment information], {oldid2} => [attachment information], ) Where attachment information contains - oldid - nodeid - parentid - filedataid - filename - filesize - settings - counter - dateline - resize_dateline - extension - cangetattachment - cangetimgattachment
fetchPhotoFiledataid()
fetch filedataid(s) for the passed photo nodeid(s)
public
fetchPhotoFiledataid(mixed $nodeid) : array<string|int, mixed>
@param mixed(array|int) photoid(s)
Parameters
- $nodeid : mixed
Return values
array<string|int, mixed> —filedataids for the requested photos
getApiClassName()
public
static getApiClassName(mixed $controller) : mixed
Parameters
- $controller : mixed
instance()
Returns an instance of the API object which translates exceptions to an array Use this method for API clients.
public
static instance(string $controller[, bool $refresh_cache = false ]) : vB_Api
Parameters
- $controller : string
-
-- name of the API controller to load
- $refresh_cache : bool = false
-
-- true if we want to force the cache to update with a new api object primarily intended for testing
Return values
vB_ApiinstanceInternal()
Returns an instance of the API object which doesn't handle exceptions This should only be used in other API objects, not for clients of the API
public
static instanceInternal(string $controller[, bool $refresh_cache = false ]) : vB_Api
Parameters
- $controller : string
-
-- name of the API controller to load
- $refresh_cache : bool = false
-
-- true if we want to force the cache to update with a new api object primarily intended for testing
Return values
vB_Apimap_vb4_input_to_vb5()
Returns vb5 api method name.
public
static map_vb4_input_to_vb5(string $method, array<string|int, mixed> &$request) : string
May alter request array.
Parameters
- $method : string
-
-- vb4 method name
- $request : array<string|int, mixed>
-
-- $_REQUEST array for this api request
Return values
stringmap_vb5_errors_to_vb4()
Alters the error array in any way necessary to interface correctly with vb4.
public
static map_vb5_errors_to_vb4(string $method, array<string|int, mixed> &$data) : mixed
Parameters
- $method : string
-
-- vb4 method name
- $data : array<string|int, mixed>
-
-- error array from vb5
map_vb5_output_to_vb4()
Alters the output array in any way necessary to interface correctly with vb4.
public
static map_vb5_output_to_vb4(string $method, array<string|int, mixed> &$data) : mixed
Parameters
- $method : string
-
-- vb4 method name
- $data : array<string|int, mixed>
-
-- output array from vb5
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