PHP Класс Habari\Vocabulary

Наследование: extends QueryRecord
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$features of strings $features. An array of the features that limit the behaviour of the vocabulary. Default values can include: hierarchical: The vocabulary's terms exist in a parent child hierarchy required: multiple: More than one term in the vocabulary can be associated with an object free: Terms within the vocabulary can have any value unique: A term may be associated with exactly 0 or 1 object

Открытые методы

Метод Описание
__construct ( array $paramarray = [] ) Vocabulary constructor Creates a Vocabulary instance
__get ( $name ) : mixed function __get Overrides QueryRecord __get to implement custom object properties
add_object_type ( $type ) : none inserts a new object type into the database, if it doesn't exist
add_term ( $term, $target_term = null, $before = false ) : Term Adds a term to the vocabulary. Returns a Term object. null parameters append the term to the end of any hierarchies.
count_total ( ) : integer Returns the number of tags in the database.
create ( array $paramarray ) : Vocabulary Create a vocabulary and save it.
default_fields ( ) : array Return the defined database columns for a Vocabulary.
delete ( ) Delete an existing vocabulary
delete_term ( Term | integer | string $term ) Remove the term from the vocabulary. Convenience method to ->get_term('foo')->delete().
exists ( string $name ) : boolean Determine whether a vocabulary exists
get ( $name ) : Vocabulary Return a Vocabulary by name.
get_all ( ) : array Return all vocabularies as Vocabulary objects
get_all_object_terms ( $object_type, $id ) : array Return the Term objects associated to that type of object with that id in any vocabulary.
get_associations ( $object_id, $object_type = 'post' ) : Terms Get the tags associated with this object
get_by_id ( integer $id ) : Vocabulary Return a Vocabulary by id
get_object_terms ( String $object_type, integer $id ) : Array Gets the Term objects associated to that type of object with that id in this vocabulary For example, return all terms in this vocabulary that are associated with a particular post
get_options ( ) : Array Retrieve the vocabulary as an associative array suitable for FormUI select controls
get_root_terms ( ) : Array Get all root elements in this vocabulary
get_search ( string $search, $orderby = 'mptt_left ASC' ) : Terms Retrieve the terms in the vocabulary that match the specified criteria
get_term ( Term | integer | string | null $term = null, string $term_class = '\Habari\Term' ) : Term Gets the term object by id. No parameter returns the root Term object.
get_tree ( $orderby = 'mptt_left ASC' ) : Terms Retrieve the vocabulary
insert ( ) function insert Saves a new vocabulary to the vocabularies table
is_empty ( ) Check if this vocabulary is empty.
max_count ( ) : integer Returns the number of times the most used tag is used.
merge ( mixed $master, Array $tags, $object_type = 'post' ) Renames terms.
min_count ( ) : integer Returns the number of times the least used tag is used.
move_term ( Term $term, Term | null $target_term = null, boolean $before = false ) : Term Moves a term within the vocabulary. Returns a Term object. null parameters append the term to the end of any hierarchies.
names ( ) : array Return the names of all vocabularies
object_type_id ( $type ) : integer Return the object type id for a named object, such as a post
post_count ( mixed $term, $object_type = 'post' ) : integer Returns the count of times a tag is used.
prep_update ( Terms $terms ) Moves all of the terms into a temporary area so that they can be moved
rename ( $newname ) : boolean Rename a Vocabulary.
search_term ( string $term, string $term_class = '\Habari\Term' ) : Terms Search for matching term objects.
set_object_terms ( String $object_type, integer $id, Array $terms = [] ) : boolean. Sets the Term objects associated to that type of object with that id in this vocabulary
update ( ) function update Updates an existing vocabulary in the vocabularies table

Описание методов

__construct() публичный Метод

Vocabulary constructor Creates a Vocabulary instance
public __construct ( array $paramarray = [] )
$paramarray array an associative array of initial vocabulary values

__get() публичный Метод

function __get Overrides QueryRecord __get to implement custom object properties
public __get ( $name ) : mixed
Результат mixed The requested field value

add_object_type() публичный статический Метод

inserts a new object type into the database, if it doesn't exist
public static add_object_type ( $type ) : none
Результат none

add_term() публичный Метод

Adds a term to the vocabulary. Returns a Term object. null parameters append the term to the end of any hierarchies.
public add_term ( $term, $target_term = null, $before = false ) : Term
Результат Term The Term object added

count_total() публичный Метод

Returns the number of tags in the database.
public count_total ( ) : integer
Результат integer The number of tags in the database.

create() статический публичный Метод

Create a vocabulary and save it.
static public create ( array $paramarray ) : Vocabulary
$paramarray array An associative array of vocabulary fields
Результат Vocabulary The new vocabulary object

default_fields() публичный статический Метод

Return the defined database columns for a Vocabulary.
public static default_fields ( ) : array
Результат array Array of columns in the Vocabulary table

delete() публичный Метод

Delete an existing vocabulary
public delete ( )

delete_term() публичный Метод

Remove the term from the vocabulary. Convenience method to ->get_term('foo')->delete().
public delete_term ( Term | integer | string $term )
$term Term | integer | string The term to delete

exists() публичный статический Метод

Determine whether a vocabulary exists
public static exists ( string $name ) : boolean
$name string a vocabulary name
Результат boolean whether the vocabulary exists or not

get() публичный статический Метод

Return a Vocabulary by name.
public static get ( $name ) : Vocabulary
Результат Vocabulary The requested vocabulary

get_all() публичный статический Метод

Return all vocabularies as Vocabulary objects
public static get_all ( ) : array
Результат array An array of Vocabulary objects

get_all_object_terms() публичный статический Метод

For example, return all terms associated with a particular post, from all vocabularies.
public static get_all_object_terms ( $object_type, $id ) : array
Результат array Array of Vocabulary names

get_associations() публичный Метод

Get the tags associated with this object
public get_associations ( $object_id, $object_type = 'post' ) : Terms
Результат Terms The terms associated with this object

get_by_id() публичный статический Метод

Return a Vocabulary by id
public static get_by_id ( integer $id ) : Vocabulary
$id integer The id of the vocabulary
Результат Vocabulary The object requested

get_object_terms() публичный Метод

Gets the Term objects associated to that type of object with that id in this vocabulary For example, return all terms in this vocabulary that are associated with a particular post
public get_object_terms ( String $object_type, integer $id ) : Array
$object_type String the name of the object type
$id integer The id of the object for which you want the terms
Результат Array The Term objects requested

get_options() публичный Метод

Retrieve the vocabulary as an associative array suitable for FormUI select controls
public get_options ( ) : Array
Результат Array The Term objects in the vocabulary, in tree order

get_root_terms() публичный Метод

Get all root elements in this vocabulary
public get_root_terms ( ) : Array
Результат Array The root Term objects in the vocabulary

get_term() публичный Метод

Gets the term object by id. No parameter returns the root Term object.
public get_term ( Term | integer | string | null $term = null, string $term_class = '\Habari\Term' ) : Term
$term Term | integer | string | null A Term object, null (for the first node in the tree), a string (for a term slug or display), or an integer (for a Term ID).
$term_class string The class of the returned term object.
Результат Term The Term object requested

get_tree() публичный Метод

Retrieve the vocabulary
public get_tree ( $orderby = 'mptt_left ASC' ) : Terms
Результат Terms The Term objects in the vocabulary, in tree order

insert() публичный Метод

function insert Saves a new vocabulary to the vocabularies table
public insert ( )

is_empty() публичный Метод

Check if this vocabulary is empty.
public is_empty ( )

max_count() публичный Метод

Returns the number of times the most used tag is used.
public max_count ( ) : integer
Результат integer The number of times the most used tag is used.

merge() публичный Метод

If the master term exists, the terms will be merged with it. If not, it will be created first.
public merge ( mixed $master, Array $tags, $object_type = 'post' )
$master mixed The Term to which they should be renamed, or the slug, text or id of it
$tags Array The tag text, slugs or ids to be renamed

min_count() публичный Метод

Returns the number of times the least used tag is used.
public min_count ( ) : integer
Результат integer The number of times the least used tag is used.

move_term() публичный Метод

The MPTT operations can seem complex, but they're actually pretty simple: 1: Find our insertion point: Either at the very end of the vocabulary, or before / after the given term 2: Create a gap at that point: We'll bump everything at that point or after up enough to fit in the term we're moving 3: Move the term: We know the offset between the old point and the new point, so move the range up that number of spaces. 4: Close the original gap: Now we've got all our terms moved, but we need to bump everything back down to close the gap it left, similar to #2.
public move_term ( Term $term, Term | null $target_term = null, boolean $before = false ) : Term
$term Term The term to move.
$target_term Term | null The term to move $term before or after, or null to move it to the very end of the vocabulary.
$before boolean True to move $term BEFORE $target_term, false (the default) to move $term AFTER $target_term.
Результат Term The Term object moved

names() публичный статический Метод

Return the names of all vocabularies
public static names ( ) : array
Результат array Array of Vocabulary names

object_type_id() публичный статический Метод

Return the object type id for a named object, such as a post
public static object_type_id ( $type ) : integer
Результат integer The id of the object type

post_count() публичный Метод

Returns the count of times a tag is used.
public post_count ( mixed $term, $object_type = 'post' ) : integer
$term mixed The tag to count usage.
Результат integer The number of times a tag is used.

prep_update() публичный статический Метод

Moves all of the terms into a temporary area so that they can be moved
public static prep_update ( Terms $terms )
$terms Terms An array of Term objects

rename() публичный Метод

Rename a Vocabulary.
public rename ( $newname ) : boolean
Результат boolean true if the Vocabulary was renamed, false otherwise

search_term() публичный Метод

Wildcards (eg "%term%") must be passed in; They're not added automatically.
public search_term ( string $term, string $term_class = '\Habari\Term' ) : Terms
$term string The string to search for as a term slug or text
$term_class string The class of the returned term object.
Результат Terms The matching Term objects

set_object_terms() публичный Метод

Sets the Term objects associated to that type of object with that id in this vocabulary
public set_object_terms ( String $object_type, integer $id, Array $terms = [] ) : boolean.
$object_type String the name of the object type
$id integer The id of the object for which you want the terms
$terms Array The names of the terms to associate
Результат boolean.

update() публичный Метод

function update Updates an existing vocabulary in the vocabularies table
public update ( )

Описание свойств

$features публичное статическое свойство

of strings $features. An array of the features that limit the behaviour of the vocabulary. Default values can include: hierarchical: The vocabulary's terms exist in a parent child hierarchy required: multiple: More than one term in the vocabulary can be associated with an object free: Terms within the vocabulary can have any value unique: A term may be associated with exactly 0 or 1 object
public static $features