From 7cd275b982cc1e0255197b623bc54f86e1ba0d1e Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 22 Jan 2009 21:14:01 +0000 Subject: A tag cloud section for groups --- lib/grouptagcloudsection.php | 87 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 lib/grouptagcloudsection.php (limited to 'lib/grouptagcloudsection.php') diff --git a/lib/grouptagcloudsection.php b/lib/grouptagcloudsection.php new file mode 100644 index 000000000..f05be85cb --- /dev/null +++ b/lib/grouptagcloudsection.php @@ -0,0 +1,87 @@ +. + * + * @category Widget + * @package Laconica + * @author Evan Prodromou + * @copyright 2009 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +if (!defined('LACONICA')) { + exit(1); +} + +/** + * Personal tag cloud section + * + * @category Widget + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +class GroupTagCloudSection extends TagCloudSection +{ + var $group = null; + + function __construct($out=null, $group=null) + { + parent::__construct($out); + $this->group = $group; + } + + function title() + { + return sprintf(_('Tags in %s group\'s notices'), $this->group->nickname); + } + + function getTags() + { + $qry = 'SELECT notice_tag.tag, '. + 'sum(exp(-(now() - notice_tag.created)/%s)) as weight ' . + 'FROM notice_tag JOIN notice ' . + 'ON notice_tag.notice_id = notice.id ' . + 'JOIN group_inbox on group_inbox.notice_id = notice.id ' . + 'WHERE group_inbox.group_id = %d ' . + 'GROUP BY notice_tag.tag ' . + 'ORDER BY weight DESC '; + + $limit = TAGS_PER_SECTION; + $offset = 0; + + if (common_config('db','type') == 'pgsql') { + $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; + } else { + $qry .= ' LIMIT ' . $offset . ', ' . $limit; + } + + $tag = Memcached_DataObject::cachedQuery('Notice_tag', + sprintf($qry, + common_config('tag', 'dropoff'), + $this->group->id), + 3600); + return $tag; + } + +} -- cgit v1.2.3-54-g00ecf