Public Member Functions | Static Public Member Functions | Static Public Attributes

Vocabulary Class Reference

Inheritance diagram for Vocabulary:
Collaboration diagram for Vocabulary:

List of all members.

Public Member Functions

 __construct ($paramarray=array())
 __get ($name)
 rename ($newname)
 insert ()
 update ()
 delete ()
 add_term ($term, $target_term=null, $before=false)
 get_term ($term=null, $term_class= 'Term')
 get_object_terms ($object_type, $id)
 set_object_terms ($object_type, $id, $terms)
 delete_term ($term)
 is_empty ()
 get_tree ($orderby= 'mptt_left ASC')
 get_options ()
 get_root_terms ()
 move_term ($term, $target_term=null, $before=false)
 count_total ()
 max_count ()
 merge ($master, $tags, $object_type= 'post')
 get_associations ($object_id, $object_type= 'post')
 post_count ($term, $object_type= 'post')

Static Public Member Functions

static default_fields ()
static create ($paramarray)
static get ($name)
static get_by_id ($id)
static get_all ()
static names ()
static get_all_object_terms ($object_type, $id)
static exists ($name)
static add_object_type ($type)
static object_type_id ($type)
static prep_update ($terms)

Static Public Attributes

static $features = array( 'hierarchical', 'required', 'multiple', 'free' )

Detailed Description

Vocabulary Class

Vocabulary is part of the taxonomy system. A vocabulary holds terms and has features.

Definition at line 10 of file vocabulary.php.


Constructor & Destructor Documentation

Vocabulary::__construct ( paramarray = array()  ) 

Vocabulary constructor Creates a Vocabulary instance

Parameters:
array $paramarray an associative array of initial vocabulary values

Reimplemented from QueryRecord.

Definition at line 43 of file vocabulary.php.


Member Function Documentation

Vocabulary::__get ( name  ) 

function __get Overrides QueryRecord __get to implement custom object properties

Parameters:
string Name of property to return
Returns:
mixed The requested field value

Reimplemented from QueryRecord.

Definition at line 78 of file vocabulary.php.

static Vocabulary::add_object_type ( type  )  [static]

inserts a new object type into the database, if it doesn't exist

Parameters:
string The name of the new post type
bool Whether the new post type is active or not
Returns:
none

Definition at line 600 of file vocabulary.php.

Vocabulary::add_term ( term,
target_term = null,
before = false 
)

Adds a term to the vocabulary. Returns a Term object. null parameters append the term to the end of any hierarchies.

Returns:
Term The Term object added

Definition at line 307 of file vocabulary.php.

Referenced by merge(), and set_object_terms().

Vocabulary::count_total (  ) 

Returns the number of tags in the database.

Returns:
int The number of tags in the database.

Definition at line 744 of file vocabulary.php.

static Vocabulary::create ( paramarray  )  [static]

Create a vocabulary and save it.

Parameters:
array $paramarray An associative array of vocabulary fields
Returns:
Vocabulary The new vocabulary object

Definition at line 65 of file vocabulary.php.

static Vocabulary::default_fields (  )  [static]

Return the defined database columns for a Vocabulary.

Returns:
array Array of columns in the Vocabulary table

Definition at line 27 of file vocabulary.php.

Vocabulary::delete (  ) 

Delete an existing vocabulary

Reimplemented from QueryRecord.

Definition at line 272 of file vocabulary.php.

Vocabulary::delete_term ( term  ) 

Remove the term from the vocabulary. Convenience method to ->get_term('foo')->delete().

Definition at line 491 of file vocabulary.php.

Referenced by merge().

static Vocabulary::exists ( name  )  [static]

Determine whether a vocabulary exists

Parameters:
string $name a vocabulary name
Returns:
bool whether the vocabulary exists or not

Definition at line 175 of file vocabulary.php.

Referenced by insert(), and update().

static Vocabulary::get ( name  )  [static]

Return a Vocabulary by name.

Returns:
Vocabulary The requested vocabulary

Definition at line 98 of file vocabulary.php.

Referenced by Tags::vocabulary().

static Vocabulary::get_all (  )  [static]

Return all vocabularies as Vocabulary objects

Returns:
array An array of Vocabulary objects

Definition at line 119 of file vocabulary.php.

static Vocabulary::get_all_object_terms ( object_type,
id 
) [static]

Return the Term objects associated to that type of object with that id in any vocabulary. For example, return all terms associated with a particular post, from all vocabularies.

Returns:
array Array of Vocabulary names

Definition at line 156 of file vocabulary.php.

Vocabulary::get_associations ( object_id,
object_type = 'post' 
)

Get the tags associated with this object

Parameters:
Integer $object_id. The id of the tagged object
String $object_type. The name of the type of the object being tagged. Defaults to post
Returns:
Terms The terms associated with this object

Definition at line 839 of file vocabulary.php.

static Vocabulary::get_by_id ( id  )  [static]

Return a Vocabulary by id

Parameters:
integer $id The id of the vocabulary
Returns:
Vocabulary The object requested

Reimplemented in Tags.

Definition at line 109 of file vocabulary.php.

Referenced by Term::__get().

Vocabulary::get_object_terms ( object_type,
id 
)

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

Parameters:
String the name of the object type
integer The id of the object for which you want the terms
Returns:
Array The Term objects requested

Definition at line 417 of file vocabulary.php.

Referenced by get_associations(), and set_object_terms().

Vocabulary::get_options (  ) 

Retrieve the vocabulary as an associative array suitable for FormUI select controls

Returns:
Array The Term objects in the vocabulary, in tree order

Definition at line 543 of file vocabulary.php.

Vocabulary::get_root_terms (  ) 

Get all root elements in this vocabulary

Returns:
Array The root Term objects in the vocabulary

If we INNER JOIN the terms table with itself on ALL the descendants, then descendants one level down are listed once, two levels down are listed twice, etc. If we return only those terms which appear once, we get root elements. ORDER BY NULL to avoid the MySQL filesort.

Definition at line 567 of file vocabulary.php.

Vocabulary::get_term ( term = null,
term_class = 'Term' 
)

Gets the term object by id. No parameter returns the root Term object.

Parameters:
mixed $term 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).
string $term_class The class of the returned term object.
Returns:
Term The Term object requested
Todo:
improve selective fetching by term slug vs term_display

Definition at line 385 of file vocabulary.php.

Referenced by delete_term(), merge(), post_count(), and set_object_terms().

Vocabulary::get_tree ( orderby = 'mptt_left ASC'  ) 

Retrieve the vocabulary

Returns:
Terms The Term objects in the vocabulary, in tree order

Definition at line 534 of file vocabulary.php.

Referenced by count_total(), and get_options().

Vocabulary::insert (  ) 

function insert Saves a new vocabulary to the vocabularies table

Reimplemented from QueryRecord.

Definition at line 184 of file vocabulary.php.

Referenced by add_object_type().

Vocabulary::is_empty (  ) 

Check if this vocabulary is empty.

Definition at line 524 of file vocabulary.php.

Referenced by add_term(), and move_term().

Vocabulary::max_count (  ) 

Returns the number of times the most used tag is used.

Returns:
int The number of times the most used tag is used.

Definition at line 754 of file vocabulary.php.

Vocabulary::merge ( master,
tags,
object_type = 'post' 
)

Renames terms. If the master term exists, the terms will be merged with it. If not, it will be created first.

Parameters:
mixed $master The Term to which they should be renamed, or the slug, text or id of it
Array $tags The tag text, slugs or ids to be renamed

Definition at line 767 of file vocabulary.php.

Vocabulary::move_term ( term,
target_term = null,
before = false 
)

Moves a term within the vocabulary. Returns a Term object. null parameters append the term to the end of any hierarchies.

Returns:
Term The Term object moved

Definition at line 625 of file vocabulary.php.

static Vocabulary::names (  )  [static]

Return the names of all vocabularies

Returns:
array Array of Vocabulary names

Definition at line 140 of file vocabulary.php.

static Vocabulary::object_type_id ( type  )  [static]

Return the object type id for a named object, such as a post

Parameters:
string $name The type of object
Returns:
integer The id of the object type

Definition at line 614 of file vocabulary.php.

Referenced by Term::associate(), Term::dissociate(), Posts::get(), merge(), Term::object_count(), Term::objects(), and Charcoal::theme_show_tags().

Vocabulary::post_count ( term,
object_type = 'post' 
)

Returns the count of times a tag is used.

Parameters:
mixed $term The tag to count usage.
Returns:
int The number of times a tag is used.

Definition at line 856 of file vocabulary.php.

static Vocabulary::prep_update ( terms  )  [static]

Moves all of the terms into a temporary area so that they can be moved

Parameters:
Terms $terms An array of Term objects

Definition at line 868 of file vocabulary.php.

Referenced by Terms::field_save().

Vocabulary::rename ( newname  ) 

Rename a Vocabulary.

Returns:
boolean true if the Vocabulary was renamed, false otherwise

Definition at line 128 of file vocabulary.php.

Vocabulary::set_object_terms ( object_type,
id,
terms 
)

Sets the Term objects associated to that type of object with that id in this vocabulary

Parameters:
String the name of the object type
Integer The id of the object for which you want the terms
Array. The names of the terms to associate
Returns:
boolean. Whether the associations were successful or not

Definition at line 441 of file vocabulary.php.

Vocabulary::update (  ) 

function update Updates an existing vocabulary in the vocabularies table

Reimplemented from QueryRecord.

Definition at line 233 of file vocabulary.php.

Referenced by rename().


The documentation for this class was generated from the following file: