function cctags_get_level_tags in cctags 7
Same name and namespace in other branches
- 8 cctags.module \cctags_get_level_tags()
- 6 cctags.module \cctags_get_level_tags()
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.
Parameters
$cctid. Cctags IDs items.:
$mode. block or page parameters settings.:
Return value
An <em>unordered</em> array with tags-objects, containing the attribute $tag->weight,$tags->level ...;
2 calls to cctags_get_level_tags()
- cctags_page in ./
cctags.page.inc - @file
- theme_cctags_block in ./
cctags.module
File
- ./
cctags.module, line 319
Code
function cctags_get_level_tags($cctid, $mode = 'page') {
global $language;
$terms = array();
if ($mode == 'page') {
$cache_name = 'cctags_cache_page_' . $cctid . ':' . $language->language;
}
if ($mode == 'block') {
$cache_name = 'cctags_cache_block_' . $cctid . ':' . $language->language;
}
$cache = cache_get($cache_name);
// make sure cache has data
if (isset($cache->data) && CACHE_ON) {
$terms = $cache->data;
}
else {
$items = _cctags_get_settings($cctid);
$item = $items[$cctid];
$tree = array();
if ($item['page'] && $mode == 'page' || $item['block'] && $mode == 'block') {
foreach ($item['item_data']['vocs'] as $key => $value) {
if (is_numeric($key) && $value == 1) {
$tree = taxonomy_get_tree($key, 0, NULL, TRUE);
foreach ($item['item_data']['level'][$key] as $k => $v) {
if ($v == 1) {
foreach ($tree as $t => $vt) {
if ($vt->depth == $k) {
$term = $tree[$t];
cctags_invoke_cctags_term_count($term);
$uri = taxonomy_term_uri($term);
$term->path = $uri['path'];
$term->name = check_plain($term->name);
if ($term->count > 0) {
$terms[] = $term;
}
}
}
}
}
}
}
$terms = cctags_build_level_tags($terms, $item['page_level'] + 1);
if ($mode == 'page') {
$terms = cctags_sort_tags($terms, $item['page_sort'], $item['page_mode']);
}
else {
$terms = cctags_sort_tags($terms, 'level,desc', 'mixed');
$terms = $terms[0];
$settings_data = variable_get('cctags_settings_block', '');
$settings_block = empty($settings_data) ? array() : unserialize($settings_data);
$sort = isset($settings_block[$cctid]['tags_sort']) ? $settings_block[$cctid]['tags_sort'] : 'title,asc';
$level = isset($settings_block[$cctid]['level']) ? $settings_block[$cctid]['level'] : 6;
$level++;
$amount = isset($settings_block[$cctid]['tags']) ? $settings_block[$cctid]['tags'] : 40;
$t = array_chunk($terms, $amount);
$terms = $t[0];
$terms = cctags_build_level_tags($terms, $level);
$terms = cctags_sort_tags($terms, $sort, 'mixed');
$count = 0;
$block_terms = array();
foreach ($terms as $key => $value) {
foreach ($value as $tid => $term) {
if ($amount > 0) {
$block_terms[$cctid][$tid] = $term;
}
$amount--;
$count++;
}
}
$terms['count'] = $count;
}
}
cache_set($cache_name, $terms, 'cache', CACHE_TEMPORARY);
}
return $terms;
}