MediaDb
in package
Media files database
Tags
Table of Contents
Properties
- $mark : string
- $previewExt : string
- $sanitize : bool
- $table : string
- $tableSizes : string
- $tableTags : string
- $tableTagsId : string
- $db : SQL
- $dependents : array<int, array<string, mixed>>
- $fetch : array<int, int>
- $list : array<int, mixed>
- $more : int|null
- $sizePreview : array<string, mixed>
- $sizes : array<int, array<string, mixed>>
- $tags : array<int, array<string, string|int>>
Methods
- __construct() : mixed
- addDependent() : void
- Adds dependent records to check for existence on deletion
- convertToSave() : string
- Converts links from editor to id marks
- convertToView() : string
- Converts ID marks into links with optional additional info for editing
- fetchIds() : void
- Adds items ids to queue, witch will be loaded at first request
- getAltById() : string
- Returns record alt description
- getImgAttr() : array<string, string|int>|null
- Returns record attributes
- getImgSizes() : array<string, int>|null
- NOTE: its return incorrect size, if crop is set and original image width/height is smaller than applied (max)size in settings
- getItem() : array<string, array<string|int, int>|string|int>|null
- Get media item
- getItemTags() : array<string|int, int>|null
- Get item tags
- getList() : array<int, mixed>
- Get list of records for administration purposes
- getMimeById() : string
- Returns record mime
- getSize() : array<string, mixed>
- Size settings
- getSizePreview() : array<string, mixed>|null
- Get preview size settings
- getSizes() : array<int, array<string, mixed>>
- Get all sizes or all exept default one
- getSrcById() : string
- Return record url
- getTags() : array<int, array<string, string|int>>
- Get tag list
- hasPreview() : bool
- Checks if non image record has preview
- isImage() : bool
- Checks if mime is image
- isMore() : bool
- Is there more records to load
- isVector() : bool
- Checks if mime is vector image
- loadId() : bool
- Load selected record and pending preloaded
- checkId() : bool
- Check record existence
- getPath() : string
- Returns root path for records
- loadFoundMedia() : void
- Prefetch records from regexes in texts
- loadSizes() : void
- Load and set image sizes
- loadTags() : void
- Load tag list
Properties
$mark
public
static string
$mark
= 'media-id'
$previewExt
public
static string
$previewExt
= '.jpg'
$sanitize
public
static bool
$sanitize
= true
$table
public
static string
$table
= 'media'
$tableSizes
public
static string
$tableSizes
= 'media_sizes'
$tableTags
public
static string
$tableTags
= 'media_tags'
$tableTagsId
public
static string
$tableTagsId
= 'media_tags_id'
$db
protected
SQL
$db
Database connection
$dependents
protected
array<int, array<string, mixed>>
$dependents
= []
Depended tables
$fetch
protected
array<int, int>
$fetch
= []
List of waiting ids to load
$list
protected
array<int, mixed>
$list
= []
Loaded media files
$more
protected
int|null
$more
= null
Are there more items to load
$sizePreview
private
array<string, mixed>
$sizePreview
Default preview size of images
$sizes
private
array<int, array<string, mixed>>
$sizes
List of size settings for images
$tags
private
array<int, array<string, string|int>>
$tags
Methods
__construct()
public
__construct(SQL $db) : mixed
Parameters
- $db : SQL
addDependent()
Adds dependent records to check for existence on deletion
public
addDependent(string $table, array<string, string>|string $mixed[, string $mode = 'column' ]) : void
Parameters
- $table : string
- $mixed : array<string, string>|string
- $mode : string = 'column'
convertToSave()
Converts links from editor to id marks
public
convertToSave(string $text) : string
Parameters
- $text : string
Return values
stringconvertToView()
Converts ID marks into links with optional additional info for editing
public
convertToView(string $text[, bool $edit = false ]) : string
Parameters
- $text : string
- $edit : bool = false
Return values
stringfetchIds()
Adds items ids to queue, witch will be loaded at first request
public
fetchIds(array<string|int, int> $ids) : void
Parameters
- $ids : array<string|int, int>
getAltById()
Returns record alt description
public
getAltById(int $id) : string
Parameters
- $id : int
Return values
stringgetImgAttr()
Returns record attributes
public
getImgAttr(int $id, int $type[, array<string, int> $srcset = null ]) : array<string, string|int>|null
Parameters
- $id : int
- $type : int
- $srcset : array<string, int> = null
Return values
array<string, string|int>|nullgetImgSizes()
NOTE: its return incorrect size, if crop is set and original image width/height is smaller than applied (max)size in settings
public
getImgSizes(int $id, int $type) : array<string, int>|null
Parameters
- $id : int
- $type : int
Return values
array<string, int>|nullgetItem()
Get media item
public
getItem(int $id) : array<string, array<string|int, int>|string|int>|null
Parameters
- $id : int
Return values
array<string, array<string|int, int>|string|int>|nullgetItemTags()
Get item tags
public
getItemTags(int $id) : array<string|int, int>|null
Parameters
- $id : int
Return values
array<string|int, int>|nullgetList()
Get list of records for administration purposes
public
getList(int $perPage[, int $from = 0 ][, array<string, string|int> $order = [] ][, array<string, string|array<string|int, int>|int> $search = [] ]) : array<int, mixed>
Parameters
- $perPage : int
- $from : int = 0
- $order : array<string, string|int> = []
- $search : array<string, string|array<string|int, int>|int> = []
-
NAME, MIME, TAG
Return values
array<int, mixed>getMimeById()
Returns record mime
public
getMimeById(int $id) : string
Parameters
- $id : int
Return values
stringgetSize()
Size settings
public
getSize([int $i = 0 ]) : array<string, mixed>
Parameters
- $i : int = 0
Return values
array<string, mixed>getSizePreview()
Get preview size settings
public
getSizePreview() : array<string, mixed>|null
Return values
array<string, mixed>|nullgetSizes()
Get all sizes or all exept default one
public
getSizes([bool $all = true ]) : array<int, array<string, mixed>>
Parameters
- $all : bool = true
Return values
array<int, array<string, mixed>>getSrcById()
Return record url
public
getSrcById(int $id[, int|null $type = null ][, bool $edit = false ]) : string
Parameters
- $id : int
- $type : int|null = null
- $edit : bool = false
Return values
stringgetTags()
Get tag list
public
getTags() : array<int, array<string, string|int>>
Return values
array<int, array<string, string|int>>hasPreview()
Checks if non image record has preview
public
hasPreview(array<string, mixed> $rec) : bool
Parameters
- $rec : array<string, mixed>
Return values
boolisImage()
Checks if mime is image
public
isImage(string $mime) : bool
Parameters
- $mime : string
Return values
boolisMore()
Is there more records to load
public
isMore() : bool
Return values
boolisVector()
Checks if mime is vector image
public
isVector(string $mime) : bool
Parameters
- $mime : string
Return values
boolloadId()
Load selected record and pending preloaded
public
loadId(int $id) : bool
Parameters
- $id : int
Return values
boolcheckId()
Check record existence
protected
checkId(int $id) : bool
Parameters
- $id : int
Return values
boolgetPath()
Returns root path for records
protected
getPath() : string
Return values
stringloadFoundMedia()
Prefetch records from regexes in texts
protected
loadFoundMedia(array<int, array<int, mixed>> $matches) : void
Parameters
- $matches : array<int, array<int, mixed>>
loadSizes()
Load and set image sizes
protected
loadSizes() : void
loadTags()
Load tag list
protected
loadTags() : void