From 4b54a418f3f26b44defdb42b8168ae43f4d1c66c Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Sat, 18 Apr 2009 19:08:33 +0000 Subject: [PATCH] trac#1215, 1216, 1217 and 1219: subscribers/subscriptions people tagclouds --- actions/subscribers.php | 10 +++ actions/subscriptions.php | 10 +++ lib/subpeopletagcloudsection.php | 76 +++++++++++++++++++ lib/subscriberspeopleselftagcloudsection.php | 54 +++++++++++++ lib/subscriberspeopletagcloudsection.php | 60 +++++++++++++++ ...subscriptionspeopleselftagcloudsection.php | 54 +++++++++++++ lib/subscriptionspeopletagcloudsection.php | 59 ++++++++++++++ 7 files changed, 323 insertions(+) create mode 100644 lib/subpeopletagcloudsection.php create mode 100644 lib/subscriberspeopleselftagcloudsection.php create mode 100644 lib/subscriberspeopletagcloudsection.php create mode 100644 lib/subscriptionspeopleselftagcloudsection.php create mode 100644 lib/subscriptionspeopletagcloudsection.php diff --git a/actions/subscribers.php b/actions/subscribers.php index d91a7d4fd3..4482de9a7c 100644 --- a/actions/subscribers.php +++ b/actions/subscribers.php @@ -118,6 +118,16 @@ class SubscribersAction extends GalleryAction $this->raw(common_markup_to_html($message)); $this->elementEnd('div'); } + + function showSections() + { + parent::showSections(); + $cloud = new SubscribersPeopleTagCloudSection($this); + $cloud->show(); + + $cloud2 = new SubscribersPeopleSelfTagCloudSection($this); + $cloud2->show(); + } } class SubscribersList extends ProfileList diff --git a/actions/subscriptions.php b/actions/subscriptions.php index e6f3c54db8..095b18ad87 100644 --- a/actions/subscriptions.php +++ b/actions/subscriptions.php @@ -125,6 +125,16 @@ class SubscriptionsAction extends GalleryAction $this->raw(common_markup_to_html($message)); $this->elementEnd('div'); } + + function showSections() + { + parent::showSections(); + $cloud = new SubscriptionsPeopleTagCloudSection($this); + $cloud->show(); + + $cloud2 = new SubscriptionsPeopleSelfTagCloudSection($this); + $cloud2->show(); + } } class SubscriptionsList extends ProfileList diff --git a/lib/subpeopletagcloudsection.php b/lib/subpeopletagcloudsection.php new file mode 100644 index 0000000000..d98f28afa7 --- /dev/null +++ b/lib/subpeopletagcloudsection.php @@ -0,0 +1,76 @@ +. + * + * @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 SubPeopleTagCloudSection extends TagCloudSection +{ + function getTags() + { + $qry = $this->query(); + $limit = TAGS_PER_SECTION; + $offset = 0; + + if (common_config('db','type') == 'pgsql') { + $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; + } else { + $qry .= ' LIMIT ' . $offset . ', ' . $limit; + } + + $profile_tag = Memcached_DataObject::cachedQuery('Profile_tag', + sprintf($qry, + $this->out->user->id)); + return $profile_tag; + } + + function tagUrl($tag) { + return common_local_url('peopletag', array('tag' => $tag)); + } + + function showTag($tag, $weight, $relative) { + $rel = 'tag-cloud-'; + $rel .= 1+intval(7 * $relative * $weight - 0.01); + + $this->out->elementStart('li', $rel); + $this->out->element('a', array('href' => $this->tagUrl($tag)), $tag); + $this->out->elementEnd('li'); + } +} diff --git a/lib/subscriberspeopleselftagcloudsection.php b/lib/subscriberspeopleselftagcloudsection.php new file mode 100644 index 0000000000..b5a39c6de6 --- /dev/null +++ b/lib/subscriberspeopleselftagcloudsection.php @@ -0,0 +1,54 @@ +. + * + * @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 SubscribersPeopleSelfTagCloudSection extends SubPeopleTagCloudSection +{ + function title() + { + return _('People Tagcloud as self-tagged'); + } + + function query() { + return 'select tag, count(tag) as weight from subscription left join profile_tag on tagger = subscriber where subscribed=%d and subscribed != subscriber and tagger = tagged group by tag order by weight desc'; + } +} diff --git a/lib/subscriberspeopletagcloudsection.php b/lib/subscriberspeopletagcloudsection.php new file mode 100644 index 0000000000..23011efdd3 --- /dev/null +++ b/lib/subscriberspeopletagcloudsection.php @@ -0,0 +1,60 @@ +. + * + * @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 SubscribersPeopleTagCloudSection extends SubPeopleTagCloudSection +{ + function title() + { + return _('People Tagcloud as tagged'); + } + + function tagUrl($tag) { + $nickname = $this->out->profile->nickname; + return common_local_url('subscribers', array('nickname' => $nickname, 'tag' => $tag)); + } + + + function query() { + return 'select tag, count(tag) as weight from subscription left join profile_tag on subscriber=tagged and subscribed=tagger where subscribed=%d and subscriber != subscribed group by tag order by weight desc'; + } +} diff --git a/lib/subscriptionspeopleselftagcloudsection.php b/lib/subscriptionspeopleselftagcloudsection.php new file mode 100644 index 0000000000..8ac65adb05 --- /dev/null +++ b/lib/subscriptionspeopleselftagcloudsection.php @@ -0,0 +1,54 @@ +. + * + * @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 SubscriptionsPeopleSelfTagCloudSection extends SubPeopleTagCloudSection +{ + function title() + { + return _('People Tagcloud as self-tagged'); + } + + function query() { + return 'select tag, count(tag) as weight from subscription left join profile_tag on tagger = subscriber where subscribed=%d and subscriber != subscribed and tagger = tagged group by tag order by weight desc'; + } +} diff --git a/lib/subscriptionspeopletagcloudsection.php b/lib/subscriptionspeopletagcloudsection.php new file mode 100644 index 0000000000..c3f7d1763e --- /dev/null +++ b/lib/subscriptionspeopletagcloudsection.php @@ -0,0 +1,59 @@ +. + * + * @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 SubscriptionsPeopleTagCloudSection extends SubPeopleTagCloudSection +{ + function title() + { + return _('People Tagcloud as tagged'); + } + + function tagUrl($tag) { + $nickname = $this->out->profile->nickname; + return common_local_url('subscriptions', array('nickname' => $nickname, 'tag' => $tag)); + } + + function query() { + return 'select tag, count(tag) as weight from subscription left join profile_tag on subscriber=tagger and subscribed=tagged where subscriber=%d and subscriber != subscribed group by tag order by weight desc'; + } +} -- 2.39.2