| 1 |
<?php |
<?php |
| 2 |
// $Id: tagadelic.module,v 1.40.2.7 2009/09/14 20:19:47 ber Exp $ |
// $Id: tagadelic.module,v 1.40.2.8 2009/09/14 20:21:45 ber Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Implementation of hook_help |
* Implementation of hook_help |
| 210 |
*/ |
*/ |
| 211 |
function tagadelic_get_weighted_tags($vids, $steps = 6, $size = 60) { |
function tagadelic_get_weighted_tags($vids, $steps = 6, $size = 60) { |
| 212 |
// build the options so we can cache multiple versions |
// build the options so we can cache multiple versions |
| 213 |
$options = implode('_',$vids) .'_'. $steps .'_'. $size; |
global $language; |
| 214 |
|
$options = implode('_',$vids) .'_'. $language->language .'_'. $steps .'_'. $size; |
| 215 |
// Check if the cache exists |
// Check if the cache exists |
| 216 |
$cache_name = 'tagadelic_cache_'. $options; |
$cache_name = 'tagadelic_cache_'. $options; |
| 217 |
$cache = cache_get($cache_name, 'cache_page'); |
$cache = cache_get($cache_name, 'cache_page'); |
| 225 |
if (!is_array($vids) || count($vids) == 0) { |
if (!is_array($vids) || count($vids) == 0) { |
| 226 |
return array(); |
return array(); |
| 227 |
} |
} |
| 228 |
$result = db_query_range('SELECT COUNT(*) AS count, d.tid, d.name, d.vid, d.description 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); |
$result = db_query_range(db_rewrite_sql('SELECT COUNT(*) AS count, td.tid, td.vid, td.name, td.description FROM {term_data} td INNER JOIN {term_node} tn ON td.tid = tn.tid INNER JOIN {node} n ON tn.vid = n.vid WHERE td.vid IN ('. db_placeholders($vids) .') GROUP BY td.tid, td.vid, td.name, td.description HAVING COUNT(*) > 0 ORDER BY count DESC'), $vids, 0, $size); |
| 229 |
|
|
| 230 |
$tags = tagadelic_build_weighted_tags($result, $steps); |
$tags = tagadelic_build_weighted_tags($result, $steps); |
| 231 |
|
|