' . intval($excat) . ' '; } } } $results = $wpdb->get_results("SELECT $tablecategories.cat_ID AS `id`, $tablecategories.cat_name AS `name`, $tablecategories.category_nicename AS `nicename`, count($tablepost2cat.rel_id) as `posts` FROM $tablecategories, $tablepost2cat WHERE $tablecategories.cat_ID = $tablepost2cat.category_id $exclusions GROUP BY $tablecategories.cat_id ORDER BY cat_name ASC"); foreach ($results as $result) { $counts[] = $result->posts; } $min = min($counts); $max = max($counts); $spread = $max - $min; if ($largest != $smallest) { $fontspread = $largest - $smallest; if ($spread != 0) { $fontstep = $fontspread / $spread; } else { $fontstep = 0; } } if ($hot != $cold) { for ($i = 0; $i < 3; $i++) { $coldval[] = hexdec($cold[$i]); $hotval[] = hexdec($hot[$i]); $colorspread[] = hexdec($hot[$i]) - hexdec($cold[$i]); if ($spread != 0) { $colorstep[] = (hexdec($hot[$i]) - hexdec($cold[$i])) / $spread; } else { $colorstep[] = 0; } } } foreach ($results as $result) { $url = get_category_link($result->id); $text = stripslashes($result->name); $fraction = ($result->posts - $min); $fontsize = $smallest + ($fontstep * $fraction); $color = ""; for ($i = 0; $i < 3; $i++) { $color .= dechex($coldval[$i] + ($colorstep[$i] * $fraction)); } $style = "style=\""; if ($largest != $smallest) { $style .= "font-size:".round($fontsize).$unit.";"; } if ($hot != $cold) { $style .= "color:#".$color.";"; } $style .= "\""; echo $before ."posts ." entries\" " .$style .">" .$text ."" .$after ."\n"; } } function heatmap_archives($smallest=10, $largest=36, $unit="pt", $cold="00f", $hot="f00", $before='', $after=' ') { global $tableposts; global $querystring_start, $querystring_equal, $querystring_separator, $month, $wpdb; $now = current_time('mysql'); $now_date = getdate(); $year_min = $now_date['year']-1; $results = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) AS `posts` FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' AND YEAR(post_date) > '$year_min' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit); foreach ($results as $result) { $counts[] = $result->posts; } $min = min($counts); $max = max($counts); $spread = $max - $min; if ($largest != $smallest) { $fontspread = $largest - $smallest; if ($spread != 0) { $fontstep = $fontspread / $spread; } else { $fontstep = 0; } } if ($hot != $cold) { for ($i = 0; $i < 3; $i++) { $coldval[] = hexdec($cold[$i]); $hotval[] = hexdec($hot[$i]); $colorspread[] = hexdec($hot[$i]) - hexdec($cold[$i]); if ($spread != 0) { $colorstep[] = (hexdec($hot[$i]) - hexdec($cold[$i])) / $spread; } else { $colorstep[] = 0; } } } foreach ($results as $result) { $url = get_month_link($result->year, $result->month); $text = sprintf('%s %d', $month[zeroise($result->month,2)], $result->year); $fraction = ($result->posts - $min); $fontsize = $smallest + ($fontstep * $fraction); $color = ""; for ($i = 0; $i < 3; $i++) { $color .= dechex($coldval[$i] + ($colorstep[$i] * $fraction)); } $style = "style=\""; if ($largest != $smallest) { $style .= "font-size:".round($fontsize).$unit.";"; } if ($hot != $cold) { $style .= "color:#".$color.";"; } $style .= "\""; echo $before ."posts ." entries\" " .$style .">" .$text ."" .$after ."\n"; } } /* create a heatmap out of your BunnysTechnoratiTags and link to a Technorati search */ function heatmap_bunnytags($smallest=10, $largest=36, $unit="pt", $cold="00f", $hot="f00", $before='', $after=' ') { global $querystring_start, $querystring_equal, $querystring_separator, $wpdb; $myblogurl = "http://yourblog.com"; $results = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='tags'"); foreach ($results as $result) { $bunnytags .= $result." "; } $bunnytags = explode(" ", trim($bunnytags)); sort($bunnytags); $bunnytags = array_count_values($bunnytags); $min = min($bunnytags); $max = max($bunnytags); $spread = $max - $min; if ($largest != $smallest) { $fontspread = $largest - $smallest; if ($spread != 0) { $fontstep = $fontspread / $spread; } else { $fontstep = 0; } } if ($hot != $cold) { for ($i = 0; $i < 3; $i++) { $coldval[] = hexdec($cold[$i]); $hotval[] = hexdec($hot[$i]); $colorspread[] = hexdec($hot[$i]) - hexdec($cold[$i]); if ($spread != 0) { $colorstep[] = (hexdec($hot[$i]) - hexdec($cold[$i])) / $spread; } else { $colorstep[] = 0; } } } foreach ($bunnytags as $bunnytag) { $url = "http://www.technorati.com/search/".key($bunnytags)."?from=".$myblogurl; $fraction = ($bunnytag - $min); $fontsize = $smallest + ($fontstep * $fraction); $color = ""; for ($i = 0; $i < 3; $i++) { $color .= dechex($coldval[$i] + ($colorstep[$i] * $fraction)); } $style = "style=\""; if ($largest != $smallest) { $style .= "font-size:".round($fontsize).$unit.";"; } if ($hot != $cold) { $style .= "color:#".$color.";"; } $style .= "\""; echo $before ."" .str_replace("+", " ", key($bunnytags)) ."" .$after; next($bunnytags); } } ?>