Sidebar sections to show peopletags and tag subscriptions.

FIXME: currently you can see the subscriptions section only on *your* profileaction pages, is this OK?
This commit is contained in:
Shashi Gowda 2011-04-08 16:22:27 +05:30
parent c44a94e8f5
commit 14a82dae61
5 changed files with 215 additions and 3 deletions

View File

@ -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');

View File

@ -0,0 +1,89 @@
<?php
/**
* StatusNet, the distributed open-source microblogging tool
*
* People tags a user has been tagged with
*
* PHP version 5
*
* LICENCE: This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Widget
* @package StatusNet
* @author Shashi Gowda <connect2shashi@gmail.com>
* @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 <connect2shashi@gmail.com>
* @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';
}
}

View File

@ -0,0 +1,83 @@
<?php
/**
* StatusNet, the distributed open-source microblogging tool
*
* Peopletags a user has subscribed to
*
* PHP version 5
*
* LICENCE: This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Widget
* @package StatusNet
* @author Shashi Gowda <connect2shashi@gmail.com>
* @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 <connect2shashi@gmail.com>
* @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';
}
}

View File

@ -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();

View File

@ -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,