aboutsummaryrefslogtreecommitdiffstats
path: root/include/taxonomy.php
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-05-04 19:39:39 -0700
committerredmatrix <git@macgirvin.com>2016-05-04 19:39:39 -0700
commit9eac9ef2b94533c7dbec3c13b1374a96bc88e4de (patch)
tree840987beb6c945c29e5cd448b54cbfc98dc05ad7 /include/taxonomy.php
parent566667a263abd6f4b2a8a24579323e65d0016d7c (diff)
downloadvolse-hubzilla-9eac9ef2b94533c7dbec3c13b1374a96bc88e4de.tar.gz
volse-hubzilla-9eac9ef2b94533c7dbec3c13b1374a96bc88e4de.tar.bz2
volse-hubzilla-9eac9ef2b94533c7dbec3c13b1374a96bc88e4de.zip
isolate all the tagadelic core code into a class and reuse it
Diffstat (limited to 'include/taxonomy.php')
-rw-r--r--include/taxonomy.php89
1 files changed, 4 insertions, 85 deletions
diff --git a/include/taxonomy.php b/include/taxonomy.php
index cc83f0605..e43f5e5d0 100644
--- a/include/taxonomy.php
+++ b/include/taxonomy.php
@@ -156,51 +156,16 @@ function tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0, $re
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['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');
-
- $range = max(.01, $max - $min) * 1.0001;
-
- for($x = 0; $x < count($tags); $x ++) {
- $tags[$x][2] = 1 + floor(9 * ($tags[$x][1] - $min) / $range);
- }
-
- return $tags;
-}
-
-
-
-
-
-
-function tags_sort($a,$b) {
- if(strtolower($a[0]) == strtolower($b[0]))
- return 0;
+ return Zotlabs\Text\Tagadelic::calc($r);
- return((strtolower($a[0]) < strtolower($b[0])) ? -1 : 1);
}
-
function dir_tagadelic($count = 0) {
$count = intval($count);
// Fetch tags
- $r = q("select xtag_term, count(xtag_term) as total from xtag where xtag_flags = 0
+ $r = q("select xtag_term as term, count(xtag_term) as total from xtag where xtag_flags = 0
group by xtag_term order by total desc %s",
((intval($count)) ? "limit $count" : '')
);
@@ -208,30 +173,9 @@ function dir_tagadelic($count = 0) {
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['xtag_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');
- $range = max(.01, $max - $min) * 1.0001;
+ return Zotlabs\Text\Tagadelic::calc($r);
- for($x = 0; $x < count($tags); $x ++) {
- $tags[$x][2] = 1 + floor(9 * ($tags[$x][1] - $min) / $range);
- }
-
- return $tags;
}
@@ -270,36 +214,11 @@ function app_tagadelic($count = 0) {
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['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');
+ return Zotlabs\Text\Tagadelic::calc($r);
- $range = max(.01, $max - $min) * 1.0001;
-
- for($x = 0; $x < count($tags); $x ++) {
- $tags[$x][2] = 1 + floor(9 * ($tags[$x][1] - $min) / $range);
- }
-
- return $tags;
}
-
-
-
function tagblock($link,$uid,$count = 0,$authors = '',$owner = '', $flags = 0,$restrict = 0,$type = TERM_HASHTAG) {
$o = '';