|
Revision 1615, 1.6 kB
(checked in by misja, 3 weeks ago)
|
Fixes #375
|
- Property svn:mime-type set to
text/plain
- Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
global $USER,$CFG; |
|---|
| 3 |
global $db; |
|---|
| 4 |
|
|---|
| 5 |
// Display popular tags |
|---|
| 6 |
|
|---|
| 7 |
$run_result .= "<p>" . __gettext("The following is a selection of keywords used within this site. Click one to see related users, weblog posts or objects.") . "</p>"; |
|---|
| 8 |
|
|---|
| 9 |
$searchline = "(" . run("users:access_level_sql_where",$USER->ident) . ")"; |
|---|
| 10 |
|
|---|
| 11 |
if ($tags = get_records_sql( "SELECT DISTINCT tag,count(ident) AS number FROM {$CFG->prefix}tags WHERE $searchline GROUP BY tag ASC having number > 1 ORDER BY number DESC LIMIT 200")) { |
|---|
| 12 |
$max = 0; |
|---|
| 13 |
foreach($tags as $tag) { |
|---|
| 14 |
if ($tag->number > $max) { |
|---|
| 15 |
$max = $tag->number; |
|---|
| 16 |
} |
|---|
| 17 |
} |
|---|
| 18 |
// Alpha sort the tags. This can't be done in SQL because we need to |
|---|
| 19 |
// sort by relevance (tag count) there and use a LIMIT. |
|---|
| 20 |
// We use keysort here because the key contains the tag. |
|---|
| 21 |
uksort($tags, strcasecmp); |
|---|
| 22 |
|
|---|
| 23 |
$tag_count = 0; |
|---|
| 24 |
$run_result .= "<div id=\"tagcloud\"><p>"; |
|---|
| 25 |
foreach($tags as $tag) { |
|---|
| 26 |
|
|---|
| 27 |
if ($max > 1) { |
|---|
| 28 |
$size = round((log($tag->number) / log($max)) * 200) + 100; |
|---|
| 29 |
} else { |
|---|
| 30 |
$size = 100; |
|---|
| 31 |
} |
|---|
| 32 |
|
|---|
| 33 |
$tag->tag = stripslashes($tag->tag); |
|---|
| 34 |
$run_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->number. ")\">"; |
|---|
| 35 |
$run_result .= $tag->tag . "</a>"; |
|---|
| 36 |
if ($tag_count < sizeof($tags) - 1) { |
|---|
| 37 |
$run_result .= ", "; |
|---|
| 38 |
} |
|---|
| 39 |
$tag_count++; |
|---|
| 40 |
} |
|---|
| 41 |
|
|---|
| 42 |
$run_result .= "</p></div>"; |
|---|
| 43 |
|
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
?> |
|---|