aboutsummaryrefslogtreecommitdiffstats
path: root/include/taxonomy.php
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2016-05-05 05:35:00 -0400
committerAndrew Manning <tamanning@zoho.com>2016-05-05 05:35:00 -0400
commit6ce939491bf932c20c9777a8518da5875e02a6b1 (patch)
treee49b75c9017015677e6d550d75e4ce62ffaddc75 /include/taxonomy.php
parent8cb06e7af8c3a14a6513d2aee2beba091f3ecfb5 (diff)
parent8ffdc4859baa9f2ae9567a4c443dfbb227919167 (diff)
downloadvolse-hubzilla-6ce939491bf932c20c9777a8518da5875e02a6b1.tar.gz
volse-hubzilla-6ce939491bf932c20c9777a8518da5875e02a6b1.tar.bz2
volse-hubzilla-6ce939491bf932c20c9777a8518da5875e02a6b1.zip
Merge remote-tracking branch 'upstream/dev' into plugin-repo
Diffstat (limited to 'include/taxonomy.php')
-rw-r--r--include/taxonomy.php88
1 files changed, 38 insertions, 50 deletions
diff --git a/include/taxonomy.php b/include/taxonomy.php
index 71ed6e91d..e43f5e5d0 100644
--- a/include/taxonomy.php
+++ b/include/taxonomy.php
@@ -156,78 +156,66 @@ 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 ++;
- }
+ return Zotlabs\Text\Tagadelic::calc($r);
- usort($tags,'tags_sort');
+}
- $range = max(.01, $max - $min) * 1.0001;
+function dir_tagadelic($count = 0) {
- for($x = 0; $x < count($tags); $x ++) {
- $tags[$x][2] = 1 + floor(9 * ($tags[$x][1] - $min) / $range);
- }
+ $count = intval($count);
+
+ // Fetch tags
+ $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" : '')
+ );
+
+ if(! $r)
+ return array();
+
+
+ return Zotlabs\Text\Tagadelic::calc($r);
- return $tags;
}
-function tags_sort($a,$b) {
- if(strtolower($a[0]) == strtolower($b[0]))
- return 0;
+function app_tagblock($link,$count = 0) {
+ $o = '';
+
+ $r = app_tagadelic($count);
- return((strtolower($a[0]) < strtolower($b[0])) ? -1 : 1);
+ if($r) {
+ $o = '<div class="tagblock widget"><h3>' . t('Categories') . '</h3><div class="tags" align="center">';
+ foreach($r as $rr) {
+ $o .= '<a href="'.$link .'/' . '?f=&cat=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
+ }
+ $o .= '</div></div>';
+ }
+
+ return $o;
}
+function app_tagadelic($count = 0) {
-function dir_tagadelic($count = 0) {
+ if(! local_channel())
+ return '';
$count = intval($count);
+
// Fetch tags
- $r = q("select xtag_term, count(xtag_term) as total from xtag where xtag_flags = 0
- group by xtag_term order by total desc %s",
+ $r = q("select term, count(term) as total from term left join app on term.uid = app_channel where term.uid = %d
+ and term.otype = %d group by term order by total desc %s",
+ intval(local_channel()),
+ intval(TERM_OBJ_APP),
((intval($count)) ? "limit $count" : '')
);
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;
-
- for($x = 0; $x < count($tags); $x ++) {
- $tags[$x][2] = 1 + floor(9 * ($tags[$x][1] - $min) / $range);
- }
+ return Zotlabs\Text\Tagadelic::calc($r);
- return $tags;
}