function taxonomy_colors_classes in Colors 7
Implements hook_colors_classes().
File
- includes/
taxonomy.colors.inc, line 43 - Provides Color integration on behalf of taxonomy.module.
Code
function taxonomy_colors_classes($entity) {
if (!variable_get('colors_taxonomy_term_enabled', FALSE)) {
return array();
}
$filtered_entity = array_intersect_key((array) $entity, field_info_instances($entity->entity_type, $entity->bundle));
$tids = array();
foreach ($filtered_entity as $key => $value) {
foreach ($value as $language => $term) {
foreach ($term as $content) {
if (isset($content['tid'])) {
$tids[] = $content['tid'];
}
}
}
}
$class_names = array();
foreach (taxonomy_get_vocabularies() as $vid => $vocab) {
if (variable_get('colors_taxonomy_term_' . $vid . '_enabled', FALSE)) {
// If enabled, get all the terms in the taxonomy.
foreach (taxonomy_get_tree($vid) as $term) {
if (in_array($term->tid, $tids)) {
$class_names[] = 'colors-taxonomy-term-' . $term->tid;
}
}
}
}
return $class_names;
}