function cctags_build_level_tags in cctags 7
Same name and namespace in other branches
- 6 cctags.module \cctags_build_level_tags()
1 call to cctags_build_level_tags()
- cctags_get_level_tags in ./
cctags.module - Function that gets the information from the database, passes it along to the weight builder and returns these weighted tags. Note that the tags are unordered at this stage, hence they need orndering either by calling our api or by your own ordering data.
File
- ./
cctags.module, line 189
Code
function cctags_build_level_tags($terms, $steps) {
$tags = array();
$min = 1000000000.0;
$max = -1000000000.0;
foreach ($terms as $key => $term) {
if (is_object($term)) {
$term->weight = log($term->count + 1);
$min = min($min, $term->weight);
$max = max($max, $term->weight);
$tags[$term->vid][$term->tid] = $term;
}
}
$range = max(0.01, $max - $min) * 1.0001;
foreach ($tags as $vid => $terms) {
$vocabulary = taxonomy_vocabulary_load($vid);
$tags[$vid]['vocname'] = check_plain($vocabulary->name);
foreach ($terms as $key => $value) {
$tags[$vid][$key]->level = 1 + floor(($steps - 1) * ($value->weight - $min) / $range);
}
}
return $tags;
}