function fe_taxonomy_get_vocabularies in Features Extra 6
Copied from taxonomy_get_vocabularies(), modified query.
Return an array of all vocabulary objects.
Parameters
$type: If set, return only those vocabularies associated with this node type.
File
- ./
fe_taxonomy.module, line 294
Code
function fe_taxonomy_get_vocabularies($type = NULL) {
$table = 'fe_taxonomy_vocabulary';
if ($type) {
$result = db_query("SELECT v.*, {$table}.machine_name, n.type FROM {vocabulary} v\n INNER JOIN {{$table}} {$table} ON v.vid = {$table}.vid\n LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid\n WHERE n.type = '%s' ORDER BY v.weight, v.name", $type);
}
else {
$result = db_query("SELECT v.*, {$table}.machine_name, n.type FROM {vocabulary} v\n INNER JOIN {{$table}} {$table} ON v.vid = {$table}.vid\n LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid ORDER BY v.weight, v.name");
}
$vocabularies = array();
$node_types = array();
while ($voc = db_fetch_object($result)) {
// If no node types are associated with a vocabulary, the LEFT JOIN will
// return a NULL value for type.
if (isset($voc->type)) {
$node_types[$voc->vid][$voc->type] = $voc->type;
unset($voc->type);
$voc->nodes = $node_types[$voc->vid];
}
elseif (!isset($voc->nodes)) {
$voc->nodes = array();
}
$vocabularies[$voc->vid] = $voc;
}
return $vocabularies;
}