function taxonomy_get_vocabularies

You are here

7 taxonomy.module taxonomy_get_vocabularies()
4.6 taxonomy.module taxonomy_get_vocabularies($type = NULL)
4.7 taxonomy.module taxonomy_get_vocabularies($type = NULL)
5 taxonomy.module taxonomy_get_vocabularies($type = NULL)
6 taxonomy.module taxonomy_get_vocabularies($type = NULL)

Return an array of all vocabulary objects.

Parameters

$type: If set, return only those vocabularies associated with this node type.

2 calls to taxonomy_get_vocabularies()
taxonomy_form_all in modules/taxonomy.module
Generate a set of options for selecting a term from all vocabularies. Can be passed to form_select.
taxonomy_overview_vocabularies in modules/taxonomy.module
List and manage vocabularies.

File

modules/taxonomy.module, line 575
Enables the organization of content into categories.

Code

function taxonomy_get_vocabularies($type = NULL) {
  if ($type) {
    $result = db_query(db_rewrite_sql("SELECT v.vid, v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s' ORDER BY v.weight, v.name", 'v', 'vid'), $type);
  }
  else {
    $result = db_query(db_rewrite_sql('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid ORDER BY v.weight, v.name', 'v', 'vid'));
  }

  $vocabularies = array();
  $node_types = array();
  while ($voc = db_fetch_object($result)) {
    $node_types[$voc->vid][] = $voc->type;
    unset($voc->type);
    $voc->nodes = $node_types[$voc->vid];
    $vocabularies[$voc->vid] = $voc;
  }

  return $vocabularies;
}