if (!defined('HABARI_PATH')) { die('No direct access'); } $max = intval($max); function tag_weight($count, $max) { return round(10 * log($count + 1) / log($max + 1.01)); } if (count($tags) != 0) { foreach ($tags as $tag) { ?> <li id="<?php echo 'tag_' . $tag->id; ?> " class="item tag wt<?php echo tag_weight($tag->count, $max); ?> "> <span class="checkbox"><input type="checkbox" class="checkbox" name="checkbox_ids[<?php echo $tag->id; ?> ]" id="checkbox_ids[<?php echo $tag->id; ?> ]"></span><label for="checkbox_ids[<?php echo $tag->id; ?> ]"><?php echo $tag->term_display; ?> </label><span class="count"><a href="<?php
function get_my_tags($limit = null, $cloud = true, $sort = 'freq') { global $USER; $id = $USER->get('id'); if ($limit || $sort != 'alpha') { $sort = 'COUNT(t.tag) DESC'; } else { $sort = 't.tag ASC'; } $tagrecords = get_records_sql_array("\n SELECT\n t.tag, COUNT(t.tag) AS count\n FROM (\n (SELECT at.tag, a.id, 'artefact' AS type\n FROM {artefact_tag} at JOIN {artefact} a ON a.id = at.artefact\n WHERE a.owner = ?)\n UNION\n (SELECT vt.tag, v.id, 'view' AS type\n FROM {view_tag} vt JOIN {view} v ON v.id = vt.view\n WHERE v.owner = ?)\n UNION\n (SELECT ct.tag, c.id, 'collection' AS type\n FROM {collection_tag} ct JOIN {collection} c ON c.id = ct.collection\n WHERE c.owner = ?)\n ) t\n GROUP BY t.tag\n ORDER BY " . $sort . (is_null($limit) ? '' : " LIMIT {$limit}"), array($id, $id, $id)); if (!$tagrecords) { return false; } if ($cloud) { $minfreq = $tagrecords[count($tagrecords) - 1]->count; $maxfreq = $tagrecords[0]->count; if ($minfreq != $maxfreq) { $minweight = tag_weight($minfreq); $maxweight = tag_weight($maxfreq); $minsize = 0.8; $maxsize = 2.5; foreach ($tagrecords as &$t) { $weight = (tag_weight($t->count) - $minweight) / ($maxweight - $minweight); $t->size = sprintf("%0.1f", $minsize + ($maxsize - $minsize) * $weight); } } usort($tagrecords, create_function('$a,$b', 'return strnatcasecmp($a->tag, $b->tag);')); } else { foreach ($tagrecords as &$t) { $t->tagurl = urlencode($t->tag); } } return $tagrecords; }