Skip to:
Content

bbPress.org

Changeset 99


Ignore:
Timestamp:
04/29/2005 06:49:29 PM (19 years ago)
Author:
matt
Message:

Better counting for tags

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bb-admin/upgrade-schema.php

    r81 r99  
    6767  tag varchar(30) NOT NULL default '',
    6868  raw_tag varchar(50) NOT NULL default '',
     69  tag_count bigint(20) unsigned NOT NULL default '0',
    6970  PRIMARY KEY  (`tag_id`)
    7071);
  • trunk/bb-includes/functions.php

    r90 r99  
    614614    VALUES
    615615    ( '$tag_id', '$current_user->user_id', '$topic_id', '$now')");
     616    $bbdb->query("UPDATE $bbdb->tags SET tag_count = tag_count + 1");
    616617    return true;
    617618}
  • trunk/bb-includes/template-functions.php

    r95 r99  
    499499}
    500500
     501function 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;
     514    }
     515    $spread = max($counts) - min($counts);
     516    if ($spread <= 0) { $spread = 1; };
     517    $fontspread = $largest - $smallest;
     518    $fontstep = $spread / $fontspread;
     519    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";
     525    }
     526}
     527
    501528?>
Note: See TracChangeset for help on using the changeset viewer.