Changeset 1017

Show
Ignore:
Timestamp:
03/10/07 03:44:52 (2 years ago)
Author:
sven
Message:

lib/templates.php: account for not having any tags in toptags/populartags

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/lib/templates.php

    r999 r1017  
    14241424                $vars[1] = "'town'"; 
    14251425            } 
    1426             $tags = get_records_sql("SELECT tag, count(ident) as numtags FROM `".$CFG->prefix."tags` WHERE access = 'public' and tagtype=".$vars[1]." group by tag order by numtags desc limit 20"); 
    1427             $tag_count = 0; 
    1428             foreach($tags as $tag) { 
    1429                 $result .= "<a href=\"".url."tag/".urlencode(htmlspecialchars(strtolower($tag->tag), ENT_COMPAT, 'utf-8'))."\" title=\"".htmlspecialchars($tag->tag, ENT_COMPAT, 'utf-8')." (" .$tag->numtags. ")\">"; 
    1430                 $result .= $tag->tag . "</a>"; 
    1431                 if ($tag_count < sizeof($tags) - 1) { 
    1432                     $result .= ", "; 
     1426            if ($tags = get_records_sql("SELECT tag, count(ident) as numtags FROM `".$CFG->prefix."tags` WHERE access = 'public' and tagtype=".$vars[1]." group by tag order by numtags desc limit 20")) { 
     1427                $tag_count = 0; 
     1428                foreach($tags as $tag) { 
     1429                    $result .= "<a href=\"".url."tag/".urlencode(htmlspecialchars(strtolower($tag->tag), ENT_COMPAT, 'utf-8'))."\" title=\"".htmlspecialchars($tag->tag, ENT_COMPAT, 'utf-8')." (" .$tag->numtags. ")\">"; 
     1430                    $result .= $tag->tag . "</a>"; 
     1431                    if ($tag_count < sizeof($tags) - 1) { 
     1432                        $result .= ", "; 
     1433                    } 
     1434                    $tag_count++; 
    14331435                } 
    1434                 $tag_count++; 
    14351436            } 
    14361437             
     
    14391440        case "populartags": 
    14401441            $result = ""; 
    1441             $tags = get_records_sql("SELECT tag, count(ident) as numtags FROM `".$CFG->prefix."tags` WHERE access = 'public' and tag!='' group by tag having numtags > 1 order by ident desc limit 20"); 
    1442             $max = 0; 
    1443             foreach($tags as $tag) { 
    1444                 if ($tag->numtags > $max) { 
    1445                     $max = $tag->numtags; 
    1446                 } 
    1447             } 
    1448              
    1449             $tag_count = 0; 
    1450             foreach($tags as $tag) { 
    1451                  
    1452                 if ($max > 1) { 
    1453                     $size = round((log($tag->numtags) / log($max)) * 300); 
    1454                 } else { 
    1455                     $size = 100; 
     1442            if ($tags = get_records_sql("SELECT tag, count(ident) as numtags FROM `".$CFG->prefix."tags` WHERE access = 'public' and tag!='' group by tag having numtags > 1 order by ident desc limit 20")) { 
     1443                $max = 0; 
     1444                foreach($tags as $tag) { 
     1445                    if ($tag->numtags > $max) { 
     1446                        $max = $tag->numtags; 
     1447                    } 
    14561448                } 
    14571449                 
    1458                 $result .= "<a href=\"".url."tag/".urlencode(htmlspecialchars(strtolower($tag->tag), ENT_COMPAT, 'utf-8'))."\" style=\"font-size: $size%\" title=\"".htmlspecialchars($tag->tag, ENT_COMPAT, 'utf-8')." (" .$tag->numtags. ")\">"; 
    1459                 $result .= $tag->tag . "</a>"; 
    1460                 if ($tag_count < sizeof($tags) - 1) { 
    1461                     $result .= ", "; 
     1450                $tag_count = 0; 
     1451                foreach($tags as $tag) { 
     1452                     
     1453                    if ($max > 1) { 
     1454                        $size = round((log($tag->numtags) / log($max)) * 300); 
     1455                    } else { 
     1456                        $size = 100; 
     1457                    } 
     1458                     
     1459                    $result .= "<a href=\"".url."tag/".urlencode(htmlspecialchars(strtolower($tag->tag), ENT_COMPAT, 'utf-8'))."\" style=\"font-size: $size%\" title=\"".htmlspecialchars($tag->tag, ENT_COMPAT, 'utf-8')." (" .$tag->numtags. ")\">"; 
     1460                    $result .= $tag->tag . "</a>"; 
     1461                    if ($tag_count < sizeof($tags) - 1) { 
     1462                        $result .= ", "; 
     1463                    } 
     1464                    $tag_count++; 
    14621465                } 
    1463                 $tag_count++; 
    14641466            } 
    14651467