PHP 클래스 Habari\Vocabulary

상속: extends QueryRecord
파일 보기 프로젝트 열기: habari/system

공개 프로퍼티들

프로퍼티 타입 설명
$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