Documentation

Creatable extends BaseFolder
in package
implements IOverrideCreatable Uses Creatable

AbstractYes

Abstract class for a creatable folder item. It handles all general actions for a folder item. If you want to add an new folder type, have a look at the api function wp_rml_register_creatable();

A new folder type MUST have the implementation with class FOLDERTYPE extends order\Sortable because every folder can also be sortable!

Table of Contents

Interfaces

IOverrideCreatable

Properties

$absolutePath  : mixed
$children  : mixed
$cnt  : mixed
$contentCustomOrder  : mixed
$id  : mixed
$name  : mixed
$order  : mixed
$owner  : mixed
$parent  : mixed
$restrictions  : mixed
$restrictionsCount  : mixed
$row  : mixed
$slug  : mixed
$systemReservedFolders  : mixed
$visible  : mixed
$cachedOrders  : mixed

Methods

__construct()  : mixed
C'tor with the main properties.
anyChildrenHas()  : array<string|int, mixed>
Get all children which meets a given column value or column value is not empty.
anyChildrenHasMetadata()  : array<string|int, mixed>
Get all chilren which meets a given meta key value or meta key value is not empty.
anyParentHas()  : array<string|int, mixed>
Get all parents which meets a given column value or column value is not empty.
anyParentHasMetadata()  : array<string|int, mixed>
Get all parents which meets a given meta key value or meta key value is not empty.
deleted_realmedialibrary_meta()  : mixed
Delete the subOrderAutomatically metadata when deleting the subfolder order and also reset the subfolder order. It also handles the content order.
getAbsolutePath()  : string
Creates a absolute path. If the absolute path is empty or forced to, it will be updated in the database, too.
getAllParents()  : array<string|int, int>
Get all parents of this folder.
getAvailableSubfolderOrders()  : array<string|int, mixed>
Get all available order methods for subfolders.
getChildren()  : IFolder
Get children of this folder.
getCnt()  : int
Gets the count of the files in this folder.
getId()  : int
Get the folder id.
getMaxOrder()  : mixed
getName()  : string
Get the folder name.
getOrder()  : int
Get the order number.
getOwner()  : int
Get the creator/owner of the folder.
getParent()  : int
Get the parent folder id.
getPath()  : string
Creates a absolute path without slugging' the names.
getPlain()  : array<string|int, mixed>
Gets a plain array with folder properties.
getPluginConstantPrefix()  : string
Get the prefix of this plugin so composer packages can dynamically build other constant values on it.
getRestrictions()  : array<string|int, string>
Get the restrictions of this folder.
getRestrictionsCount()  : int
Get the count of the restrictions.
getRowData()  : mixed
getSlug()  : string
Returns a sanitized title for the folder. If the slug is empty or forced to, it will be updated in the database, too.
getTypeDescription()  : mixed
getTypeName()  : mixed
hasChildren()  : bool
Checks if this folder has a children with a given name.
insert()  : mixed
is()  : bool
Check if the folder object is a given type.
isRestrictFor()  : bool
Checks if this folder has a special restriction.
isValidChildrenType()  : mixed
isValidName()  : bool
Checks, if a given folder name is valid. The name is also sanitized so there can be no problem for physical moves for example.
isVisible()  : bool
Check if the folder object is visible to the user.
orderSubfolders()  : mixed
persist()  : int
Persist the given creatable with the database. Think about it, that this only works, when the ID === -1 (that means, it will be a new folder).
persistCheckParent()  : mixed
read()  : mixed
reindexChildrens()  : mixed
relocate()  : mixed
resetSubfolderOrder()  : mixed
setName()  : mixed
setParent()  : mixed
setRestrictions()  : mixed
setVisible()  : mixed
updateThisAndChildrensAbsolutePath()  : mixed
xread()  : array<string|int, mixed>
Read ids for a given folder id.
applySubfolderOrderBy()  : bool
Check if the current folders parent is automatically ordered by a criteria so the order can be applied. This should be called when the hierarchy of the folder is changed or when a new folder is added to that parent.
singleCheckInsert()  : mixed
Simply check, if an id can be inserted in this folder. If something is wrong with the id, please throw an exception!
singleCheckInsertPermissions()  : mixed
Simply check, if an id can be inserted in this folder. If something is wrong with the id, please throw an exception!

Properties

$contentCustomOrder

protected mixed $contentCustomOrder

$restrictions

protected mixed $restrictions = []

$restrictionsCount

protected mixed $restrictionsCount = 0

$systemReservedFolders

protected mixed $systemReservedFolders = ['/', '..', '.']

$cachedOrders

private static mixed $cachedOrders = null

Methods

__construct()

C'tor with the main properties.

public __construct(int $id[, int $parent = -1 ][, string $name = '' ][, string $slug = '' ][, string $absolute = '' ][, int $order = -1 ][, int $cnt = 0 ][, object $row = [] ]) : mixed

The constructor does not throw any errors because when it is fully filled with parameters it expects the right properties from the database.

Only ::instance and ::create should create instances from this class!

Synced with order\Sortable::__construct

Parameters
$id : int
$parent : int = -1
$name : string = ''
$slug : string = ''
$absolute : string = ''
$order : int = -1
$cnt : int = 0
$row : object = []
Tags
throws
Exception

anyChildrenHas()

Get all children which meets a given column value or column value is not empty.

public anyChildrenHas(mixed $column[, mixed $value = null ][, mixed $valueFormat = '%s' ][, mixed $includeSelf = false ]) : array<string|int, mixed>
Parameters
$column : mixed

The column name for the wp_realmedialibrary SQL table. "slug", "name", "absolutePath", ... This string is not escaped when you pass it through this function

$value : mixed = null

The value the column should have

$valueFormat : mixed = '%s'

The value format for $value ($wpdb->prepare) This string is not escaped when you pass it through this function

$includeSelf : mixed = false

Set true to add self to list

Return values
array<string|int, mixed>

folderId => columnValue, first id is the first found child

anyChildrenHasMetadata()

Get all chilren which meets a given meta key value or meta key value is not empty.

public anyChildrenHasMetadata(mixed $meta_key[, mixed $meta_value = null ][, mixed $valueFormat = '%s' ][, mixed $includeSelf = false ]) : array<string|int, mixed>
Parameters
$meta_key : mixed

The meta key name for the wp_realmedialibrary_meta SQL table. This string is not escaped when you pass it through this function

$meta_value : mixed = null

The value the meta key should have

$valueFormat : mixed = '%s'

The value format for $value ($wpdb->prepare) This string is not escaped when you pass it through this function

$includeSelf : mixed = false

Set true to add self to list

Return values
array<string|int, mixed>

Array with keys: id (meta_id), folderId, value (meta_value), first id is the first found child

anyParentHas()

Get all parents which meets a given column value or column value is not empty.

public anyParentHas(mixed $column[, mixed $value = null ][, mixed $valueFormat = '%s' ][, mixed $includeSelf = false ][, mixed $until = null ]) : array<string|int, mixed>
Parameters
$column : mixed

The column name for the wp_realmedialibrary SQL table. "slug", "name", "absolutePath", ... This string is not escaped when you pass it through this function

$value : mixed = null

The value the column should have

$valueFormat : mixed = '%s'

The value format for $value ($wpdb->prepare) This string is not escaped when you pass it through this function

$includeSelf : mixed = false

Set true to add self to list

$until : mixed = null

The highest allowed folder id. If null _wp_rml_root() is used

Return values
array<string|int, mixed>

folderId => columnValue, first id is the first found parent

anyParentHasMetadata()

Get all parents which meets a given meta key value or meta key value is not empty.

public anyParentHasMetadata(mixed $meta_key[, mixed $meta_value = null ][, mixed $valueFormat = '%s' ][, mixed $includeSelf = false ][, mixed $until = null ]) : array<string|int, mixed>
Parameters
$meta_key : mixed

The meta key name for the wp_realmedialibrary_meta SQL table. This string is not escaped when you pass it through this function

$meta_value : mixed = null

The value the meta key should have

$valueFormat : mixed = '%s'

The value format for $value ($wpdb->prepare) This string is not escaped when you pass it through this function

$includeSelf : mixed = false

Set true to add self to list

$until : mixed = null

The highest allowed folder id. If null _wp_rml_root() is used

Return values
array<string|int, mixed>

Array with keys: id (meta_id), folderId, value (meta_value), first id is the first found parent

deleted_realmedialibrary_meta()

Delete the subOrderAutomatically metadata when deleting the subfolder order and also reset the subfolder order. It also handles the content order.

public static deleted_realmedialibrary_meta(array<string|int, int> $meta_ids, int $object_id, string $meta_key) : mixed
Parameters
$meta_ids : array<string|int, int>
$object_id : int
$meta_key : string

getAbsolutePath()

Creates a absolute path. If the absolute path is empty or forced to, it will be updated in the database, too.

public getAbsolutePath([mixed $force = false ][, mixed $fromSetName = false ]) : string
Parameters
$force : mixed = false

Forces to regenerate the absolute path

$fromSetName : mixed = false

For internal usage only

Return values
string

getAllParents()

Get all parents of this folder.

public getAllParents([mixed $until = null ][, mixed $colIdx = 0 ]) : array<string|int, int>
Parameters
$until : mixed = null

The highest allowed folder id. If null _wp_rml_root() is used

$colIdx : mixed = 0

The index returning for the wp_rml_create_all_parents_sql() query

Return values
array<string|int, int>

Folder ids, first id is the first parent

getAvailableSubfolderOrders()

Get all available order methods for subfolders.

public static getAvailableSubfolderOrders([bool $asMap = false ]) : array<string|int, mixed>
Parameters
$asMap : bool = false
Return values
array<string|int, mixed>

getCnt()

Gets the count of the files in this folder.

public getCnt([mixed $forceReload = false ]) : int
Parameters
$forceReload : mixed = false

If true the count cache gets reloaded

Return values
int

getId()

Get the folder id.

public getId() : int
Return values
int

getName()

Get the folder name.

public getName([mixed $htmlentities = false ]) : string
Parameters
$htmlentities : mixed = false

If true the name is returned htmlentitied for output

Return values
string

getOrder()

Get the order number.

public getOrder() : int
Return values
int

getOwner()

Get the creator/owner of the folder.

public getOwner() : int
Return values
int

ID of the user

getParent()

Get the parent folder id.

public getParent() : int
Return values
int

getPath()

Creates a absolute path without slugging' the names.

public getPath([mixed $implode = '/' ][, mixed $map = 'htmlentities' ][, mixed $filter = null ]) : string
// Get valid physical folder name
$folder->getPath("/", "_wp_rml_sanitize_filename");
Parameters
$implode : mixed = '/'

Delimiter for the folder names

$map : mixed = 'htmlentities'

Map the names with this function. Pass null to skip this map function

$filter : mixed = null

Filter folders

Return values
string

htmlentitied path

getPlain()

Gets a plain array with folder properties.

public getPlain([mixed $deep = false ]) : array<string|int, mixed>
Parameters
$deep : mixed = false

Return the children as plain object array

Return values
array<string|int, mixed>

or null when not visible

getPluginConstantPrefix()

Get the prefix of this plugin so composer packages can dynamically build other constant values on it.

public getPluginConstantPrefix() : string
Tags
codeCoverageIgnore

It only returns a string with the constant prefix

Return values
string

getRestrictions()

Get the restrictions of this folder.

public getRestrictions() : array<string|int, string>
Return values
array<string|int, string>

getRestrictionsCount()

Get the count of the restrictions.

public getRestrictionsCount() : int
Return values
int

getRowData()

public getRowData([mixed $field = null ]) : mixed
Parameters
$field : mixed = null

getSlug()

Returns a sanitized title for the folder. If the slug is empty or forced to, it will be updated in the database, too.

public getSlug([mixed $force = false ][, mixed $fromSetName = false ]) : string
Parameters
$force : mixed = false

Forces to regenerate the slug

$fromSetName : mixed = false

For internal usage only

Return values
string

getTypeDescription()

public getTypeDescription([mixed $default = null ]) : mixed
Parameters
$default : mixed = null

getTypeName()

public getTypeName([mixed $default = null ]) : mixed
Parameters
$default : mixed = null

hasChildren()

Checks if this folder has a children with a given name.

public hasChildren(mixed $name[, mixed $returnObject = false ]) : bool
Parameters
$name : mixed

Name of folder

$returnObject : mixed = false

If set to true and a children with this name is found, then return the object for this folder

Return values
bool

insert()

public insert(mixed $ids[, mixed $supress_validation = false ][, mixed $isShortcut = false ]) : mixed
Parameters
$ids : mixed
$supress_validation : mixed = false
$isShortcut : mixed = false

is()

Check if the folder object is a given type.

public is(mixed $folder_type) : bool
Parameters
$folder_type : mixed

The folder type

Return values
bool

isRestrictFor()

Checks if this folder has a special restriction.

public isRestrictFor(mixed $restriction) : bool
Parameters
$restriction : mixed

The restriction to check

Return values
bool

isValidChildrenType()

public isValidChildrenType(mixed $type) : mixed
Parameters
$type : mixed

isValidName()

Checks, if a given folder name is valid. The name is also sanitized so there can be no problem for physical moves for example.

public isValidName(string $name) : bool
Parameters
$name : string

The folder name

Return values
bool

isVisible()

Check if the folder object is visible to the user.

public isVisible() : bool
Return values
bool

orderSubfolders()

public orderSubfolders(mixed $orderby[, mixed $writeMetadata = true ]) : mixed
Parameters
$orderby : mixed
$writeMetadata : mixed = true

persist()

Persist the given creatable with the database. Think about it, that this only works, when the ID === -1 (that means, it will be a new folder).

public persist() : int

After the folder is created, this instance is useless, you must get the folder with the API wp_rml_get_by_id

Tags
throws
Exception
Return values
int

ID of the newly created folder

persistCheckParent()

public persistCheckParent() : mixed

read()

public read([mixed $order = null ][, mixed $orderby = null ]) : mixed
Parameters
$order : mixed = null
$orderby : mixed = null

reindexChildrens()

public reindexChildrens([mixed $resetData = false ]) : mixed
Parameters
$resetData : mixed = false

relocate()

public relocate(mixed $parentId[, mixed $nextFolderId = false ]) : mixed
Parameters
$parentId : mixed
$nextFolderId : mixed = false

resetSubfolderOrder()

public resetSubfolderOrder() : mixed

setName()

public setName(mixed $name[, mixed $supress_validation = false ]) : mixed
Parameters
$name : mixed
$supress_validation : mixed = false

setParent()

public setParent(mixed $id[, mixed $ord = -1 ][, mixed $force = false ]) : mixed
Parameters
$id : mixed
$ord : mixed = -1
$force : mixed = false

setRestrictions()

public setRestrictions([mixed $restrictions = [] ]) : mixed
Parameters
$restrictions : mixed = []

setVisible()

public setVisible(mixed $visible) : mixed
Parameters
$visible : mixed

updateThisAndChildrensAbsolutePath()

public updateThisAndChildrensAbsolutePath() : mixed

xread()

Read ids for a given folder id.

public static xread(int $id[, string $order = null ][, string $orderby = null ]) : array<string|int, mixed>
Parameters
$id : int

The folder id (-1 for root)

$order : string = null

The order

$orderby : string = null

The order by

Return values
array<string|int, mixed>

with ids

applySubfolderOrderBy()

Check if the current folders parent is automatically ordered by a criteria so the order can be applied. This should be called when the hierarchy of the folder is changed or when a new folder is added to that parent.

protected applySubfolderOrderBy() : bool
Return values
bool

singleCheckInsert()

Simply check, if an id can be inserted in this folder. If something is wrong with the id, please throw an exception!

protected singleCheckInsert(int $id) : mixed
Parameters
$id : int

The id

Tags
throws
Exception

singleCheckInsertPermissions()

Simply check, if an id can be inserted in this folder. If something is wrong with the id, please throw an exception!

protected singleCheckInsertPermissions(int $id) : mixed
Parameters
$id : int

The id

Tags
throws
Exception

        
On this page

Search results