\MatthiasWeb\RealMediaLibrary\orderSortable

Handles the sortable content in the folder. The methods of this class contains always the keyword "content".

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

Summary

Methods
Properties
Constants
contentDeleteOrder()
contentRestoreOldCustomNr()
contentOrder()
contentOrderBy()
contentIndex()
contentReindex()
contentEnableOrder()
getAttachmentNextTo()
getContentAggregationNr()
getContentNrOf()
getContentOldCustomNrCount()
__construct()
read()
insert()
persist()
updateThisAndChildrensAbsolutePath()
getMaxOrder()
getRowData()
getTypeName()
getTypeDescription()
setVisible()
setName()
isValidName()
xread()
getAvailableSubfolderOrders()
resetSubfolderOrder()
orderSubfolders()
persistCheckParent()
reindexChildrens()
isValidChildrenType()
setParent()
relocate()
anyParentHas()
anyParentHasMetadata()
anyChildrenHas()
anyChildrenHasMetadata()
hasChildren()
getId()
getParent()
getAllParents()
getName()
getSlug()
getPath()
getOwner()
getAbsolutePath()
getCnt()
getChildren()
getOrder()
getRestrictions()
getRestrictionsCount()
getPlain()
setRestrictions()
is()
isVisible()
isRestrictFor()
getPluginConstantPrefix()
isContentCustomOrderAllowed()
getContentCustomOrder()
forceContentCustomOrder()
postsClauses()
getAvailableContentOrders()
$cachedOrders
$cachedContentOrders
No constants found
singleCheckInsertPermissions()
singleCheckInsert()
applySubfolderOrderBy()
$id
$parent
$name
$cnt
$order
$slug
$absolutePath
$row
$children
$visible
$restrictions
$restrictionsCount
$systemReservedFolders
$contentCustomOrder
N/A
No private methods found
No private properties found
N/A

Properties

$cachedOrders

$cachedOrders :

Type

$cachedContentOrders

$cachedContentOrders :

Type

$id

$id :

Type

$parent

$parent :

Type

$name

$name :

Type

$cnt

$cnt :

Type

$order

$order :

Type

$slug

$slug :

Type

$absolutePath

$absolutePath :

Type

$row

$row :

Type

$children

$children :

Type

$visible

$visible :

Type

$restrictions

$restrictions :

Type

$restrictionsCount

$restrictionsCount :

Type

$systemReservedFolders

$systemReservedFolders :

Type

$contentCustomOrder

$contentCustomOrder :

Type

Methods

contentDeleteOrder()

contentDeleteOrder()

contentRestoreOldCustomNr()

contentRestoreOldCustomNr()

contentOrder()

contentOrder(  $attachmentId,  $nextId,  $lastIdInView = false)

Parameters

$attachmentId
$nextId
$lastIdInView

contentOrderBy()

contentOrderBy(  $orderby,  $writeMetadata = true)

Parameters

$orderby
$writeMetadata

contentIndex()

contentIndex(  $delete = true)

Parameters

$delete

contentReindex()

contentReindex()

contentEnableOrder()

contentEnableOrder()

getAttachmentNextTo()

getAttachmentNextTo(  $attachmentId)

Parameters

$attachmentId

getContentAggregationNr()

getContentAggregationNr(  $function = 'MAX')

Parameters

$function

getContentNrOf()

getContentNrOf(  $attachmentId)

Parameters

$attachmentId

getContentOldCustomNrCount()

getContentOldCustomNrCount()

__construct()

__construct(integer  $id,integer  $parent = -1,string  $name = '',string  $slug = '',string  $absolute = '',integer  $order = -1,integer  $cnt,array  $row = array())

C'tor with the main properties.

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

integer $id
integer $parent
string $name
string $slug
string $absolute
integer $order
integer $cnt
array $row

read()

read(  $order = null,  $orderby = null)

Parameters

$order
$orderby

insert()

insert(  $ids,  $supress_validation = false,  $isShortcut = false)

Parameters

$ids
$supress_validation
$isShortcut

persist()

persist(): integer

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).

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

Throws

\Exception

Returns

integer —

ID of the newly created folder

updateThisAndChildrensAbsolutePath()

updateThisAndChildrensAbsolutePath()

getMaxOrder()

getMaxOrder()

getRowData()

getRowData(  $field = null)

Parameters

$field

getTypeName()

getTypeName(  $default = null)

Parameters

$default

getTypeDescription()

getTypeDescription(  $default = null)

Parameters

$default

setVisible()

setVisible(  $visible)

Parameters

$visible

setName()

setName(  $name,  $supress_validation = false)

Parameters

$name
$supress_validation

isValidName()

isValidName(string  $name): boolean

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

Parameters

string $name

The folder name

Returns

boolean

xread()

xread(integer  $id,string  $order = null,string  $orderby = null): array

Read ids for a given folder id.

Parameters

integer $id

The folder id (-1 for root)

string $order

The order

string $orderby

The order by

Returns

array —

with ids

getAvailableSubfolderOrders()

getAvailableSubfolderOrders(boolean  $asMap = false): array

Get all available order methods for subfolders.

Parameters

boolean $asMap

Returns

array

resetSubfolderOrder()

resetSubfolderOrder()

orderSubfolders()

orderSubfolders(  $orderby,  $writeMetadata = true)

Parameters

$orderby
$writeMetadata

persistCheckParent()

persistCheckParent()

reindexChildrens()

reindexChildrens(  $resetData = false)

Parameters

$resetData

isValidChildrenType()

isValidChildrenType(  $type)

Parameters

$type

setParent()

setParent(  $id,  $ord = -1,  $force = false)

Parameters

$id
$ord
$force

relocate()

relocate(  $parentId,  $nextFolderId = false)

Parameters

$parentId
$nextFolderId

anyParentHas()

anyParentHas(string  $column,mixed  $value = null,string  $valueFormat = '%s',boolean  $includeSelf = false,integer  $until = null): array

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

Parameters

string $column

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

mixed $value

The value the column should have

string $valueFormat

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

boolean $includeSelf

Set true to add self to list

integer $until

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

Returns

array —

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

anyParentHasMetadata()

anyParentHasMetadata(string  $meta_key,mixed  $meta_value = null,string  $valueFormat = '%s',boolean  $includeSelf = false,integer  $until = null): array

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

Parameters

string $meta_key

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

mixed $meta_value

The value the meta key should have

string $valueFormat

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

boolean $includeSelf

Set true to add self to list

integer $until

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

Returns

array —

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

anyChildrenHas()

anyChildrenHas(string  $column,mixed  $value = null,string  $valueFormat = '%s',boolean  $includeSelf = false): array

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

Parameters

string $column

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

mixed $value

The value the column should have

string $valueFormat

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

boolean $includeSelf

Set true to add self to list

Returns

array —

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

anyChildrenHasMetadata()

anyChildrenHasMetadata(string  $meta_key,mixed  $meta_value = null,string  $valueFormat = '%s',boolean  $includeSelf = false): array

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

Parameters

string $meta_key

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

mixed $meta_value

The value the meta key should have

string $valueFormat

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

boolean $includeSelf

Set true to add self to list

Returns

array —

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

hasChildren()

hasChildren(string  $name,boolean  $returnObject = false): boolean

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

Parameters

string $name

Name of folder

boolean $returnObject

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

Returns

boolean

getId()

getId(): integer

Get the folder id.

Returns

integer

getParent()

getParent(): integer

Get the parent folder id.

Returns

integer

getAllParents()

getAllParents(integer  $until = null,integer  $colIdx): array<mixed,integer>

Get all parents of this folder.

Parameters

integer $until

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

integer $colIdx

The index returning for the wp_rml_create_all_parents_sql() query

Returns

array<mixed,integer> —

Folder ids, first id is the first parent

getName()

getName(boolean  $htmlentities = false): string

Get the folder name.

Parameters

boolean $htmlentities

If true the name is returned htmlentitied for output

Returns

string

getSlug()

getSlug(boolean  $force = false,boolean  $fromSetName = false): string

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

Parameters

boolean $force

Forces to regenerate the slug

boolean $fromSetName

For internal usage only

Returns

string

getPath()

getPath(string  $implode = '/',callable  $map = 'htmlentities',callable  $filter = null): string

Creates a absolute path without slugging' the names.

// Get valid physical folder name
$folder->getPath("/", "_wp_rml_sanitize_filename");

Parameters

string $implode

Delimiter for the folder names

callable $map

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

callable $filter

Filter folders

Returns

string —

htmlentitied path

getOwner()

getOwner(): integer

Get the creator/owner of the folder.

Returns

integer —

ID of the user

getAbsolutePath()

getAbsolutePath(boolean  $force = false,boolean  $fromSetName = false): string

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

Parameters

boolean $force

Forces to regenerate the absolute path

boolean $fromSetName

For internal usage only

Returns

string

getCnt()

getCnt(boolean  $forceReload = false): integer

Gets the count of the files in this folder.

Parameters

boolean $forceReload

If true the count cache gets reloaded

Returns

integer

getOrder()

getOrder(): integer

Get the order number.

Returns

integer

getRestrictions()

getRestrictions(): array<mixed,string>

Get the restrictions of this folder.

Returns

array<mixed,string>

getRestrictionsCount()

getRestrictionsCount(): integer

Get the count of the restrictions.

Returns

integer

getPlain()

getPlain(boolean  $deep = false): array

Gets a plain array with folder properties.

Parameters

boolean $deep

Return the children as plain object array

Returns

array —

or null when not visible

setRestrictions()

setRestrictions(  $restrictions = array())

Parameters

$restrictions

is()

is(integer  $folder_type): boolean

Check if the folder object is a given type.

Parameters

integer $folder_type

The folder type

Returns

boolean

isVisible()

isVisible(): boolean

Check if the folder object is visible to the user.

Returns

boolean

isRestrictFor()

isRestrictFor(string  $restriction): boolean

Checks if this folder has a special restriction.

Parameters

string $restriction

The restriction to check

Returns

boolean

getPluginConstantPrefix()

getPluginConstantPrefix(): string

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

Returns

string

isContentCustomOrderAllowed()

isContentCustomOrderAllowed()

getContentCustomOrder()

getContentCustomOrder()

forceContentCustomOrder()

forceContentCustomOrder()

postsClauses()

postsClauses(  $pieces)

Parameters

$pieces

getAvailableContentOrders()

getAvailableContentOrders(boolean  $asMap = false): array

Get all available order methods.

Parameters

boolean $asMap

Returns

array

singleCheckInsertPermissions()

singleCheckInsertPermissions(integer  $id)

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

Parameters

integer $id

The id

Throws

\Exception

singleCheckInsert()

singleCheckInsert(integer  $id)

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

Parameters

integer $id

The id

Throws

\Exception

applySubfolderOrderBy()

applySubfolderOrderBy()