You are here

function cctags_build_level_tags in cctags 6

Same name and namespace in other branches
  1. 7 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 335

Code

function cctags_build_level_tags($terms, $steps = 6) {
  $tags = array();
  foreach ($terms as $key => $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'] = $vocabulary->name;
    foreach ($terms as $key => $value) {
      $tags[$vid][$key]->level = 1 + floor($steps * ($value->weight - $min) / $range);
    }
  }
  return $tags;
}