Overview
  • Namespace
  • Class

Namespaces

  • MatthiasWeb
    • RealMediaLibrary
      • api
      • attachment
      • base
      • comp
        • complexquery
      • folder
      • general
      • metadata
      • order
      • rest
      • usersettings
  • None

Interfaces

  • IFolder
  • IFolderActions
  • IFolderContent
  • IMetadata
  • IStructure
  • IUserSettings

Interface IFolder

This interface provides elementary getter and setter methods for folder objects. All folder types (Folder, Collection, Gallery, ...) have implemented this interface. Also the root ("Unorganized") is a folder and implements this interface. Usually, the root acts as "-1" but you should use the _wp_rml_root() function to get the root id. If this interface does not provide an expected method, yet, have a look at the other API files. For example to create a folder use wp_rml_create().

Check if a variable is surely a IFolder interface object:

$folder = wp_rml_get_object_by_id(5);
if (is_rml_folder($folder)) {
     // It is an interface implementation of IFolder
}

Register own folder type:

You can create your own implementation of a folder type (Gallery, Collection, Root, ...) just have a look at the wp-content/plugins/real-media-library/inc/folder files. Here is a very basic example and the static methods you must create for your class:

/*
 * ABSTRACT METHODS YOU MUST IMPLEMENT IN YOUR FOLDER CLASS!
 *
/*
 * Creates an instance for this folder type. This line is commented out,
 * because PHP does not support abstract static functions. Please implement
 * this function in your folder class.
 *
 * @param $rowData The row data from the database row
 * @return Instance or null
 *
/* public abstract static function instance($rowData); *

/*
 * (optional) If you use wp_rml_register_creatable() with the parameter $onRegister = true then
 * this function is called in your folder type class.
 *
/* public abstract static function onRegister(); *

/*
 * Creates a new instance for this folder type. This line is commented out,
 * because PHP does not support abstract static functions. Please implement
 * this function in your folder class.
 *
 * @param $rowData The row data from the database row
 * @throws Exception when something went wrong by creating
 * @return Instance or null
 * @see Creatable::persist
 *
/* public abstract static function create($rowData); *

Also have a look at the wp_rml_register_creatable() function to register your class (RML_TYPE_FOLDER is an unique defined integer for your folder type):

wp_rml_register_creatable(RML_NS . '\\folder\\Folder', RML_TYPE_FOLDER);
MatthiasWeb\RealMediaLibrary\api\IFolder implements MatthiasWeb\RealMediaLibrary\api\IFolderActions, MatthiasWeb\RealMediaLibrary\api\IFolderContent

Direct known implementers

MatthiasWeb\RealMediaLibrary\folder\BaseFolder

Indirect known implementers

MatthiasWeb\RealMediaLibrary\folder\Collection, MatthiasWeb\RealMediaLibrary\folder\Creatable, MatthiasWeb\RealMediaLibrary\folder\Folder, MatthiasWeb\RealMediaLibrary\folder\Gallery, MatthiasWeb\RealMediaLibrary\folder\Root, MatthiasWeb\RealMediaLibrary\order\Sortable

Namespace: MatthiasWeb\RealMediaLibrary\api
See: wp_rml_root_childs()
See: wp_rml_get_object_by_id()
See: wp_rml_get_by_id()
See: wp_rml_get_by_absolute_path()
See: wp_rml_objects()
See: is_rml_folder()
See: MatthiasWeb\RealMediaLibrary\api\IFolderActions
Located at api/IFolder.interface.php

Methods summary

public
# anyParentHas( string $column, mixed $value = null, string $valueFormat = "%s", boolean $includeSelf = false, integer $until = null )

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

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

Parameters

$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
$value
The value the column should have
$valueFormat
The value format for $value ($wpdb->prepare) This string is not escaped when you pass it through this function
$includeSelf
Set true to add self to list
$until
The highest allowed folder id. If null _wp_rml_root() is used

Since

3.3

Returns

array folderId => columnValue, first id is the first found parent
public
# anyParentHasMetadata( string $meta_key, mixed $meta_value = null, string $valueFormat = "%s", boolean $includeSelf = false, integer $until = null )

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

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

Parameters

$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
$meta_value
The value the meta key should have
$valueFormat
The value format for $value ($wpdb->prepare) This string is not escaped when you pass it through this function
$includeSelf
Set true to add self to list
$until
The highest allowed folder id. If null _wp_rml_root() is used

Since

3.3

Returns

array Array with keys: id (meta_id), folderId, value (meta_value), first id is the first found parent
public
# anyChildrenHas( string $column, mixed $value = null, string $valueFormat = "%s", boolean $includeSelf = false )

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

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

Parameters

$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
$value
The value the column should have
$valueFormat
The value format for $value ($wpdb->prepare) This string is not escaped when you pass it through this function
$includeSelf
Set true to add self to list

Since

3.3

Returns

array folderId => columnValue, first id is the first found child
public
# anyChildrenHasMetadata( string $meta_key, mixed $meta_value = null, string $valueFormat = "%s", boolean $includeSelf = false )

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

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

Parameters

$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
$meta_value
The value the meta key should have
$valueFormat
The value format for $value ($wpdb->prepare) This string is not escaped when you pass it through this function
$includeSelf
Set true to add self to list

Since

3.3

Returns

array Array with keys: id (meta_id), folderId, value (meta_value), first id is the first found child
public
# hasChildren( string $name, boolean $returnObject = false )

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

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

Parameters

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

Since

3.3 Now it checks for a given folder name instead the slug

Returns

boolean
public
# getType( )

Return the type for the given folder. For example: 0 = Folder, 1 = Collection, 2 = Gallery

Return the type for the given folder. For example: 0 = Folder, 1 = Collection, 2 = Gallery

Returns

int
public boolean|int[]
# getAllowedChildrenTypes( )

Get all allowed children folder types.

Get all allowed children folder types.

Returns

boolean|int[]
Array with allowed types or TRUE for all types allowed
public
# getId( )

Get the folder id.

Get the folder id.

Returns

int
public
# getParent( )

Get the parent folder id.

Get the parent folder id.

Returns

int
public
# getAllParents( integer $until = null, integer $colIdx = 0 )

Get all parents of this folder.

Get all parents of this folder.

Parameters

$until
The highest allowed folder id. If null _wp_rml_root() is used
$colIdx
The index returning for the wp_rml_create_all_parents_sql() query

Since

3.3

Returns

int[] Folder ids, first id is the first parent
public
# getName( boolean $htmlentities = false )

Get the folder name.

Get the folder name.

Parameters

$htmlentities
If true the name is returned htmlentitied for output

Returns

string
public
# getSlug( boolean $force = false, $fromSetName = false )

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

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

Parameters

$force
Forces to regenerate the slug
$fromSetName

Returns

string
public
# getPath( string $implode = "/", callable $map = "htmlentities" )

Creates a absolute path without slugging' the names.

Creates a absolute path without slugging' the names.

Parameters

$implode
Delimitter for the folder names
$map
Map the names with this function. Pass null to skip this map function

Example

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

Returns

string htmlentitied path
public
# getOwner( )

Get the creator/owner of the folder.

Get the creator/owner of the folder.

Since

3.3

Returns

int ID of the user
public
# getAbsolutePath( boolean $force = false, $fromSetName = false )

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

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

Parameters

$force
Forces to regenerate the absolute path
$fromSetName

Returns

string
public
# getCnt( boolean $forceReload = false )

Gets the count of the files in this folder.

Gets the count of the files in this folder.

Parameters

$forceReload
If true the count cache gets reloaded

Since

3.3.1

Returns

int
public MatthiasWeb\RealMediaLibrary\api\IFolder[]
# getChildren( )

Get children of this folder.

Get children of this folder.

Returns

MatthiasWeb\RealMediaLibrary\api\IFolder[]
public
# getOrder( )

Get the order number.

Get the order number.

Since

3.3.1

Returns

int
public
# getMaxOrder( )

Get the maximal order number of the children.

Get the maximal order number of the children.

Since

3.3.1

Returns

integer Max order number
public
# getRestrictions( )

Get the restrictions of this folder.

Get the restrictions of this folder.

Returns

string[]
public
# getRestrictionsCount( )

Get the count of the restrictions.

Get the count of the restrictions.

Returns

int
public
# getPlain( boolean $deep = false )

Gets a plain array with folder properties.

Gets a plain array with folder properties.

Parameters

$deep
Return the children as plain object array

Returns

array
public
# getRowData( string $field = null )

Get the full row of the SQL query.

Get the full row of the SQL query.

Parameters

$field
The field name

Since

3.3

Returns

mixed Any object or false
public
# getTypeName( string $default = null )

Get the type name for this folder. For example: Folder, Collection, Gallery, Unorganized.

Get the type name for this folder. For example: Folder, Collection, Gallery, Unorganized.

Parameters

$default
The default (if null "Folder" is used as default)

Since

3.3.1

See

Filter RML/Folder/Type/Name

Returns

string
public
# getTypeDescription( string $default = null )

Get the type description for this folder.

Get the type description for this folder.

Parameters

$default
The default (if null folder description is used as default)

Since

3.3.1

See

Filter RML/Folder/Type/Description

Returns

string
public
# is( integer $folder_type )

Check if the folder object is a given type.

Check if the folder object is a given type.

Parameters

$folder_type
The folder type

Returns

boolean
public
# isRestrictFor( string $restriction )

Checks if this folder has a special restriction.

Checks if this folder has a special restriction.

Parameters

$restriction
The restriction to check

See

IFolder::setRestrictions()

Returns

boolean
public
# isValidChildrenType( integer $type )

Checks if a given folder type is allowed in this folder.

Checks if a given folder type is allowed in this folder.

Parameters

$type
The type

See

IFolder::getAllowedChildrenTypes()

Returns

boolean

Methods inherited from MatthiasWeb\RealMediaLibrary\api\IFolderActions

insert(), read(), reindexChildrens(), relocate(), setName(), setParent(), setRestrictions(), updateThisAndChildrensAbsolutePath()

Methods inherited from MatthiasWeb\RealMediaLibrary\api\IFolderContent

contentDeleteOrder(), contentEnableOrder(), contentIndex(), contentOrder(), contentReindex(), contentRestoreOldCustomNr(), getAttachmentNextTo(), getContentAggregationNr(), getContentCustomOrder(), getContentNrOf(), getContentOldCustomNrCount(), getContentOrderNumbers(), isContentCustomOrderAllowed()

API documentation generated by ApiGen