From 14a82dae61286a07413c944c37fdc030bf22b940 Mon Sep 17 00:00:00 2001 From: Shashi Gowda Date: Fri, 8 Apr 2011 16:22:27 +0530 Subject: [PATCH] Sidebar sections to show peopletags and tag subscriptions. FIXME: currently you can see the subscriptions section only on *your* profileaction pages, is this OK? --- lib/peopletagsection.php | 2 +- lib/peopletagsforusersection.php | 89 +++++++++++++++++++++++++++ lib/peopletagsubscriptionssection.php | 83 +++++++++++++++++++++++++ lib/profileaction.php | 28 +++++++++ lib/section.php | 16 ++++- 5 files changed, 215 insertions(+), 3 deletions(-) create mode 100644 lib/peopletagsforusersection.php create mode 100644 lib/peopletagsubscriptionssection.php diff --git a/lib/peopletagsection.php b/lib/peopletagsection.php index 6722f3a149..a96863c04b 100644 --- a/lib/peopletagsection.php +++ b/lib/peopletagsection.php @@ -112,7 +112,7 @@ class PeopletagSectionItem extends PeopletagListItem $this->showPeopletag(); $this->out->elementEnd('td'); - if ($this->peopletag->value) { + if (isset($this->peopletag->value)) { $this->out->element('td', 'value', $this->peopletag->value); } $this->out->elementEnd('tr'); diff --git a/lib/peopletagsforusersection.php b/lib/peopletagsforusersection.php new file mode 100644 index 0000000000..f074248728 --- /dev/null +++ b/lib/peopletagsforusersection.php @@ -0,0 +1,89 @@ +. + * + * @category Widget + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +/** + * People tags a user has been tagged with + * + * @category Widget + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class PeopletagsForUserSection extends PeopletagSection +{ + var $profile=null; + + function __construct($out, Profile $profile) + { + parent::__construct($out); + $this->profile = $profile; + } + + function getPeopletags() + { + $limit = PEOPLETAGS_PER_SECTION+1; + $offset = 0; + + $auth_user = common_current_user(); + $ptags = $this->profile->getOtherTags($auth_user, $offset, $limit); + + return $ptags; + } + + function title() + { + $name = $this->profile->getBestName(); + if ($this->profile->id == common_current_user()->id) { + $name = 'you'; + } + return sprintf(_('People tags for %s'), $name); + } + + + function link() + { + return common_local_url('peopletagsforuser', + array('nickname' => $this->profile->nickname)); + } + + function moreUrl() + { + return $this->link(); + } + + function divId() + { + return 'peopletag_subscriptions'; + } +} diff --git a/lib/peopletagsubscriptionssection.php b/lib/peopletagsubscriptionssection.php new file mode 100644 index 0000000000..63a0d1363c --- /dev/null +++ b/lib/peopletagsubscriptionssection.php @@ -0,0 +1,83 @@ +. + * + * @category Widget + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +/** + * Peopletags a user has subscribed to + * + * @category Widget + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class PeopletagSubscriptionsSection extends PeopletagSection +{ + var $profile=null; + + function __construct($out, Profile $profile) + { + parent::__construct($out); + $this->profile = $profile; + } + + function getPeopletags() + { + $limit = PEOPLETAGS_PER_SECTION+1; + $offset = 0; + + $ptags = $this->profile->getTagSubscriptions($offset, $limit); + + return $ptags; + } + + function title() + { + return _('People tag subscriptions'); + } + + function link() + { + return common_local_url('peopletagsubscriptions', + array('nickname' => $this->profile->nickname)); + } + + function moreUrl() + { + return $this->link(); + } + + function divId() + { + return 'peopletag_subscriptions'; + } +} diff --git a/lib/profileaction.php b/lib/profileaction.php index f777edd319..cd3f5bcde5 100644 --- a/lib/profileaction.php +++ b/lib/profileaction.php @@ -97,6 +97,8 @@ class ProfileAction extends OwnerDesignAction $this->showSubscriptions(); $this->showSubscribers(); $this->showGroups(); + $this->showPeopletagSubs(); + $this->showPeopletags(); $this->showStatistics(); } @@ -188,6 +190,32 @@ class ProfileAction extends OwnerDesignAction $this->elementEnd('div'); } + function showPeopletagSubs() + { + $user = common_current_user(); + if (!empty($user) && $this->profile->id == $user->id) { + if (Event::handle('StartShowPeopletagSubscriptionsSection', array($this))) { + + $profile = $user->getProfile(); + $section = new PeopletagSubscriptionsSection($this, $profile); + $section->show(); + + Event::handle('EndShowPeopletagSubscriptionsSection', array($this)); + } + } + } + + function showPeopletags() + { + if (Event::handle('StartShowPeopletagsSection', array($this))) { + + $section = new PeopletagsForUserSection($this, $this->profile); + $section->show(); + + Event::handle('EndShowPeopletagsSection', array($this)); + } + } + function showStatistics() { $notice_count = $this->profile->noticeCount(); diff --git a/lib/section.php b/lib/section.php index 753a37efa4..d77673898a 100644 --- a/lib/section.php +++ b/lib/section.php @@ -61,8 +61,15 @@ class Section extends Widget array('id' => $this->divId(), 'class' => 'section')); - $this->out->element('h2', null, - $this->title()); + $link = $this->link(); + if (!empty($link)) { + $this->out->elementStart('h2'); + $this->out->element('a', array('href' => $link), $this->title()); + $this->out->elementEnd('h2'); + } else { + $this->out->element('h2', null, + $this->title()); + } $have_more = $this->showContent(); @@ -88,6 +95,11 @@ class Section extends Widget return _('Untitled section'); } + function link() + { + return null; + } + function showContent() { $this->out->element('p', null, -- 2.39.5