aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-01-04 22:40:35 -0800
committerfriendica <info@friendica.com>2013-01-04 22:40:35 -0800
commit5894a7db48179a1ff8752c7fdd264194f1297316 (patch)
tree15362e9dee56d771a36b0f7c8a3cf96de4a9907a /include/text.php
parent0d623f716cd1a1fd148321e087db6f924459a535 (diff)
downloadvolse-hubzilla-5894a7db48179a1ff8752c7fdd264194f1297316.tar.gz
volse-hubzilla-5894a7db48179a1ff8752c7fdd264194f1297316.tar.bz2
volse-hubzilla-5894a7db48179a1ff8752c7fdd264194f1297316.zip
tag cloud ported - except for putting into a template
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php77
1 files changed, 38 insertions, 39 deletions
diff --git a/include/text.php b/include/text.php
index 0d325f4a0..5438aae73 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1827,39 +1827,47 @@ function jindent($json) {
// Tag cloud functions - need to be adpated to this database format
-/*
-function tagadelic($author,$count = 0) {
- // Fetch tags
+function tagadelic($uid, $count = 0, $type = TERM_HASHTAG) {
+
+ // Fetch tags
+ $r = q("select term, count(term) as total from term
+ where uid = %d and type = %d
+ and otype = %d
+ group by term order by total desc %s",
+ intval($uid),
+ intval($type),
+ intval(TERM_OBJ_POST),
+ ((intval($count)) ? "limit $count" : '')
+ );
- $r = category::category_get_tags($author,$count);
- if(! count($r))
- return array();
+ if(! $r)
+ return array();
- // Find minimum and maximum log-count.
- $tags = array();
- $min = 1e9;
- $max = -1e9;
-
- $x = 0;
- foreach($r as $rr) {
- $tags[$x][0] = $rr['name'];
- $tags[$x][1] = log($rr['total']);
- $tags[$x][2] = 0;
- $min = min($min,$tags[$x][1]);
- $max = max($max,$tags[$x][1]);
- $x ++;
- }
+ // Find minimum and maximum log-count.
+ $tags = array();
+ $min = 1e9;
+ $max = -1e9;
+
+ $x = 0;
+ foreach($r as $rr) {
+ $tags[$x][0] = $rr['term'];
+ $tags[$x][1] = log($rr['total']);
+ $tags[$x][2] = 0;
+ $min = min($min,$tags[$x][1]);
+ $max = max($max,$tags[$x][1]);
+ $x ++;
+ }
- usort($tags,'tags_sort');
+ usort($tags,'tags_sort');
- $range = max(.01, $max - $min) * 1.0001;
+ $range = max(.01, $max - $min) * 1.0001;
- for($x = 0; $x < count($tags); $x ++) {
- $tags[$x][2] = 1 + floor(5 * ($tags[$x][1] - $min) / $range);
- }
+ for($x = 0; $x < count($tags); $x ++) {
+ $tags[$x][2] = 1 + floor(5 * ($tags[$x][1] - $min) / $range);
+ }
- return $tags;
+ return $tags;
}
function tags_sort($a,$b) {
@@ -1869,24 +1877,15 @@ function tags_sort($a,$b) {
}
-function tagblock($author,$count = 0) {
+function tagblock($link,$uid,$count = 0,$type = TERM_HASHTAG) {
$tab = 0;
- $r = tagadelic($author,$count);
- if(strlen($author)) {
- if($author == '[news]')
- $linkbase = 'forum/news-category';
- else
- $linkbase = 'weblog/'.$author;
- }
- else
- $linkbase = 'forum/category';
+ $r = tagadelic($uid,$count,$type);
- if(count($r)) {
+ if($r) {
echo '<div class="tags" align="center">';
foreach($r as $rr) {
- echo '<a href="'.$linkbase.'/'.urlencoder($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ';
+ echo '<a href="'.$link .'/' . '?f=&tag=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ';
}
echo '</div>';
}
}
-*/ \ No newline at end of file