8, 'largest' => 22, 'unit' => 'pt', 'limit' => 45, 'format' => 'flat', 'minimum' => 0, 'maximum' => 0, 'forums' => 0, 'since' => 0, 'sort' => 0, 'colors' => 0 ); $args = wp_parse_args( $args, $defaults ); if ($args['colors']===0) {$args['colors']=array('24244C','600000','C00000');} if ( 1 < $fn = func_num_args() ) { // legacy $args['smallest'] = func_get_arg(0); $args['largest'] = func_get_arg(1); $args['unit'] = 2 < $fn ? func_get_arg(2) : $unit; $args['limit'] = 3 < $fn ? func_get_arg(3) : $limit; } if ($hot_tags_plus['cache']) { $filename=""; foreach ($args as $key=>$value) {if (is_array($value)) {$value=implode("_",$value);} $filename .= "_".$key."_".$value;} $filename=$hot_tags_plus['cache_dir'].$hot_tags_plus['prefix'].bb_slug_sanitize($filename); if (file_exists($filename)) {return file_get_contents($filename);} } extract($args, EXTR_SKIP); // turn arguments into strings // $tags = bb_get_top_tags( false, $limit ); // print " "; // diagnostic $limit=intval($limit); if (empty($since)) {$since="";} else { if (intval($since)<99999) { $since=strtotime($since." GMT"); } $since=" AND topic_time >= '".gmdate('Y-m-d H:i:s',intval($since))."' "; } if (empty($forums)) {$forums="";} else { if (is_array($forums)) {foreach ($forums as $key=>$value) {$forums[$key]=intval($value);}} else {$forums=intval($forums);} $forums=" AND forum_id IN (".implode(',',(array) $forums).") "; } if (empty($maximum)) {$maximum=""; $having="";} else { $maximum=" tcount <= ".intval($maximum); $having=" HAVING $maximum ";} if (empty($minimum)) {$minimum="";} else { $minimum=" tcount >= ".intval($minimum); $having=($having ? " AND " : " HAVING ").$minimum;} if (defined('BACKPRESS_PATH')) { $query="SELECT COUNT( relationships.term_taxonomy_id ) AS tcount, terms.name AS raw_tag, terms.slug AS tag, terms.term_id AS id FROM $bbdb->term_relationships AS relationships LEFT JOIN $bbdb->term_taxonomy AS taxonomy ON relationships.term_taxonomy_id = taxonomy.term_taxonomy_id LEFT JOIN $bbdb->terms AS terms ON taxonomy.term_taxonomy_id = terms.term_id LEFT JOIN $bbdb->topics AS topics ON object_id = topic_id WHERE topic_status = 0 $forums $since GROUP BY relationships.term_taxonomy_id $having ORDER BY tcount DESC, topic_time DESC LIMIT $limit"; // WHERE term_taxonomy_id IN ($ids) // AND term_taxonomy_id NOT IN (".$related_topics['exclude_tags'].") // AND object_id NOT IN (".$related_topics['exclude_topics'].") } else { $query="SELECT COUNT(relationships.tag_id) as tcount, terms.raw_tag AS raw_tag, terms.tag AS tag,terms.tag_id AS id FROM $bbdb->tagged AS relationships LEFT JOIN $bbdb->tags AS terms ON relationships.tag_id = terms.tag_id LEFT JOIN $bbdb->topics AS topics ON relationships.topic_id = topics.topic_id WHERE topic_status = 0 $forums $since GROUP BY relationships.tag_id $having ORDER BY tcount DESC, topic_time DESC LIMIT $limit"; // WHERE tag_id IN ($ids) // AND tag_id NOT IN (".$related_topics['exclude_tags'].") // AND topic_id NOT IN (".$related_topics['exclude_topics'].") } $tags=$bbdb->get_results($query); if (empty($tags)) {return '';} if ( bb_get_option('mod_rewrite') ) { $path = bb_get_option('uri' )."tags/"; } else { $path = bb_get_option('uri' )."tags.php?tag=";} foreach ( (array) $tags as $tag ) { $ids{$tag->raw_tag} = $tag->id; $counts{$tag->raw_tag} = $tag->tcount; $taglinks{$tag->raw_tag} = apply_filters( 'bb_get_tag_link', $path.$tag->tag, $tag->tag, 1 ); // $taglinks{$tag->raw_tag} = bb_get_tag_link( $tag->tag ); } $min_count = min($counts); $spread = max($counts) - $min_count; if ( $spread <= 0 ) { $spread = 1; } $fontspread = $largest - $smallest; if ( $fontspread <= 0 ) { $fontspread = 1; } $fontstep = $fontspread / $spread; $sort=strtolower($sort); if ($sort==="alphabetical") { uksort($counts, 'strnatcasecmp'); } elseif ( $sort==="highest" || $sort==="count" || $sort==="counts" || $sort==="numeric" ) { arsort($counts, SORT_NUMERIC); } elseif ( $sort==="raw" ) { // do nothing - use db sort } else { do_action_ref_array( 'sort_tag_heat_map', array(&$counts) ); } if ($colors!==0) { if (is_array($colors) && count($colors)>1) {$gradient = hot_tags_plus_gradient($colors,$spread);} // calculate color ranges max($counts) else { if (is_array($colors)) {$colors=reset($colors);} for ($i = 0; $i <= $spread ; $i++) { $gradient[$i]=$colors;} } } if ($hot_tags_plus['related']) { if (defined('BACKPRESS_PATH')) { $query="SELECT id, GROUP_CONCAT(DISTINCT CAST( related_id AS CHAR )) AS related FROM ( SELECT t2.term_taxonomy_id AS id, t1.term_taxonomy_id AS related_id FROM $bbdb->term_relationships AS t1 LEFT JOIN $bbdb->term_relationships AS t2 ON ( t1.object_id = t2.object_id ) LEFT JOIN $bbdb->term_taxonomy AS t3 ON ( t1.term_taxonomy_id = t3.term_taxonomy_id ) WHERE t2.term_taxonomy_id IN (".implode(',',$ids).") AND t1.term_taxonomy_id IN (".implode(',',$ids).") ORDER BY id,related_id ASC ) AS tags WHERE id!=related_id GROUP BY id"; // maybe WHERE t3. term_id IN ? taxonomy_id is not really = term_id } else { $query="SELECT id, GROUP_CONCAT(DISTINCT CAST( related_id AS CHAR )) AS related FROM ( SELECT t2.tag_id AS id, t1.tag_id AS related_id FROM $bbdb->tagged AS t1 LEFT JOIN $bbdb->tagged AS t2 ON ( t1.topic_id = t2.topic_id ) LEFT JOIN $bbdb->tags AS t3 ON ( t1.tag_id = t3.tag_id ) WHERE t2.tag_id IN (".implode(',',$ids).") AND t1.tag_id IN (".implode(',',$ids).") ORDER BY id,related_id ASC ) AS tags WHERE id!=related_id GROUP BY id"; } $results=$bbdb->get_results($query); if (!empty($results) && is_array($results) && count($results)) { foreach ($results as $result) {$HTP_related[$result->id]=$result->related;} $output .= <<< HTPJSEOF HTPJSEOF; } // previous line MUST be blank because of heredoc } foreach ( $counts as $tag => $count ) { $id=($hot_tags_plus['related'] ? " id='tag_".$ids[$tag]."'" : ""); $taglink = attribute_escape($taglinks{$tag}); $tag = wp_specialchars( $tag ); // str_replace(' ', ' ', wp_specialchars( $tag )); $a[] = "" ."$tag"; } switch ( $format ) : case 'array' : $output .= $a; break; case 'list' : $output .= "