--- /tagadelic/tagadelic.module Wed Mar 16 18:30:32 2011 +++ /tagadelic/tagadelic.module Thu Mar 24 10:09:33 2011 @@ -207,17 +207,18 @@ } /** - * 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. + * 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 ordering either by calling our api or by your own ordering data. * @param $vids. Vocabulary IDs representing the vocabularies where you want the tags from. * @param $steps. The amount of tag-sizes you will be using. If you give "12" you sill get six different "weights". Defaults to 6 and is optional. * @return An unordered array with tags-objects, containing the attribute $tag->weight; */ -function tagadelic_get_weighted_tags($vids, $steps = 6, $size = 60) { +function tagadelic_get_weighted_tags($vids, $steps = 6, $size = 60, $lang_sel = NULL) +{ // build the options so we can cache multiple versions $options = implode($vids) .'_'. $steps .'_'. $size; // Check if the cache exists - $cache_name = 'tagadelic_cache_'. $options; + $cache_name = 'tagadelic_cache_'. $options . '_' . $lang_sel; $cache = cache_get($cache_name); // make sure cache has data @@ -229,7 +230,15 @@ if (!is_array($vids) || count($vids) == 0) { return array(); } - $result = db_query_range('SELECT COUNT(*) AS count, d.tid, d.name, d.vid FROM {term_data} d INNER JOIN {term_node} n ON d.tid = n.tid WHERE d.vid IN ('. substr(str_repeat('%d,', count($vids)), 0, -1) .') GROUP BY d.tid, d.name, d.vid ORDER BY count DESC', $vids, 0, $size); + if ( $lang_sel === NULL ) + { + $lang_sel_q = ''; + } + else + { + $lang_sel_q = ' AND (language = "'.$lang_sel.'" OR language = "") '; + } + $result = db_query_range('SELECT COUNT(*) AS count, d.tid, d.name, d.vid FROM {term_data} d INNER JOIN {term_node} n ON d.tid = n.tid WHERE d.vid IN ('. substr(str_repeat('%d,', count($vids)), 0, -1) .') '.$lang_sel_q.' GROUP BY d.tid, d.name, d.vid ORDER BY count DESC', $vids, 0, $size); $tags = tagadelic_build_weighted_tags($result, $steps); @@ -346,11 +355,13 @@ * implementation of hook_block */ function tagadelic_block($op = 'list', $delta = 0, $edit = array()) { + global $language; + $l = $language->language; $blocks = array(); if ($op == 'view') { if ($voc = taxonomy_vocabulary_load($delta)) { $blocks['subject'] = variable_get('tagadelic_block_title_'. $delta, t('Tags in @voc', array('@voc' => $voc->name))); - $tags = tagadelic_get_weighted_tags(array($voc->vid), variable_get('tagadelic_levels', 6), variable_get('tagadelic_block_tags_'. $delta, 12)); + $tags = tagadelic_get_weighted_tags(array($voc->vid), variable_get('tagadelic_levels', 6), variable_get('tagadelic_block_tags_'. $delta, 12), $l); $tags = tagadelic_sort_tags($tags); $blocks['content'] = theme('tagadelic_weighted', $tags);//return a chunk of 12 tags if (count($tags) >= variable_get('tagadelic_block_tags_'. $delta, 12)) {