function tripal_add_term

3.x tripal.terms.api.inc tripal_add_term($details)

Adds a term to the vocabulary storage backend.

Use this function to add new terms dynamically to the vocabulary storage backend. If the term already exists no new term is added.

Parameters

$details: An array with at least the following keys: -vocabulary : An associative array with the following keys -name: The short name for the vocabulary (e.g. SO, PATO, etc). -description: The description of this vocabulary. -url: The URL for the vocabulary. -accession : The name unique ID of the term. -url : The URL for the term. -name : The name of the term. -definition : The term's description.

Return value

TRUE if the term was added, FALSE otherwise. If the term already exists it will be updated and the return value will be TRUE.

Related topics

File

tripal/api/tripal.terms.api.inc, line 332
Provides an application programming interface (API) for working with controlled vocaublary terms.

Code

function tripal_add_term($details) {
  // TODO: we need some sort of administrative interface that lets the user
  // switch to the desired vocabulary type. For now, we'll just use the
  // first one in the list.
  $stores = module_invoke_all('vocab_storage_info');
  if (is_array($stores) and count($stores) > 0) {
    $keys = array_keys($stores);
    $module = $stores[$keys[0]]['module'];
    $function = $module . '_vocab_add_term';
    if (function_exists($function)) {
      return $function($details);
    }
  }
}