Skip to:
Content

Changeset 100


Ignore:
Timestamp:
04/29/05 19:12:42 (9 years ago)
Author:
matt
Message:

Tag heat map

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bb-includes/functions.php

    r99 r100  
    701701} 
    702702 
     703function get_top_tags( $recent = true, $limit = 30 ) { 
     704    global $bbdb; 
     705    $tags = $bbdb->get_results("SELECT * FROM $bbdb->tags ORDER BY tag_count DESC LIMIT $limit"); 
     706    return $tags; 
     707} 
     708 
    703709?> 
  • trunk/bb-includes/template-functions.php

    r99 r100  
    499499} 
    500500 
    501 function tag_heat_map($smallest=10, $largest=48, $unit="pt") { 
    502     $cats = list_cats(1, 'all', 'name', 'asc', '', 0, 0, 1, 1, 0, 1, 1, 0, 1, '', '', $exclude, 0); 
    503  
    504     $cats = explode("\n", $cats); 
    505     foreach ($cats as $cat) 
    506     { 
    507         eregi("a href=\"(.+)\" ", $cat, $regs); 
    508         $catlink = $regs[1]; 
    509         $cat = trim(strip_tags($cat)); 
    510         eregi("(.*) \(([0-9]+)\)$", $cat, $regs); 
    511         $catname = $regs[1]; $count = $regs[2]; 
    512         $counts{$catname} = $count; 
    513         $catlinks{$catname} = $catlink; 
     501function tag_heat_map($smallest=8, $largest=26, $unit="pt") { 
     502    $tags = get_top_tags(); 
     503 
     504    foreach ( $tags as $tag ) { 
     505        $counts{$tag->tag} = $tag->tag_count; 
     506        $taglinks{$tag->tag} = get_tag_link(); 
    514507    } 
    515508    $spread = max($counts) - min($counts);  
     
    518511    $fontstep = $spread / $fontspread; 
    519512    if ($fontspread <= 0) { $fontspread = 1; } 
    520     foreach ($counts as $catname => $count) 
    521     { 
    522         $catlink = $catlinks{$catname}; 
    523         print "<a href=\"$catlink\" title=\"$count entries\" style=\"font-size: ". 
    524         ($smallest + ($count/$fontstep))."$unit;\">$catname</a> \n"; 
     513    ksort($counts); 
     514    foreach ($counts as $tag => $count) { 
     515        $taglink = $taglinks{$tag}; 
     516        print "<a href='$taglink' title='$count topics' style='font-size: ". 
     517        ($smallest + ($count/$fontstep))."$unit;'>$tag</a> \n"; 
    525518    } 
    526519} 
  • trunk/bb-templates/front-page.php

    r2 r100  
    22 
    33<?php login_form(); ?> 
     4 
     5<?php tag_heat_map(); ?> 
    46 
    57<?php if ( $forums ) : ?> 
Note: See TracChangeset for help on using the changeset viewer.