2011-03-16 21:49:27 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* StatusNet, the distributed open-source microblogging tool
|
|
|
|
*
|
|
|
|
* List of a user's subscriptions
|
|
|
|
*
|
|
|
|
* 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 Social
|
|
|
|
* @package StatusNet
|
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @author Sarven Capadisli <csarven@status.net>
|
|
|
|
* @copyright 2008-2009 StatusNet, Inc.
|
|
|
|
* @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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A list of the user's subscriptions
|
|
|
|
*
|
|
|
|
* @category Social
|
|
|
|
* @package StatusNet
|
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
|
|
|
* @link http://status.net/
|
|
|
|
*/
|
|
|
|
class TagSubsAction extends GalleryAction
|
|
|
|
{
|
|
|
|
function title()
|
|
|
|
{
|
|
|
|
if ($this->page == 1) {
|
|
|
|
// TRANS: Header for subscriptions overview for a user (first page).
|
|
|
|
// TRANS: %s is a user nickname.
|
|
|
|
return sprintf(_m('%s\'s tag subscriptions'), $this->user->nickname);
|
|
|
|
} else {
|
|
|
|
// TRANS: Header for subscriptions overview for a user (not first page).
|
|
|
|
// TRANS: %1$s is a user nickname, %2$d is the page number.
|
|
|
|
return sprintf(_m('%1$s\'s tag subscriptions, page %2$d'),
|
|
|
|
$this->user->nickname,
|
|
|
|
$this->page);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function showPageNotice()
|
|
|
|
{
|
|
|
|
$user = common_current_user();
|
|
|
|
if ($user && ($user->id == $this->profile->id)) {
|
|
|
|
$this->element('p', null,
|
|
|
|
// TRANS: Page notice for page with an overview of all tag subscriptions
|
|
|
|
// TRANS: of the logged in user's own profile.
|
2011-03-16 22:55:40 +00:00
|
|
|
_m('You have subscribed to receive all notices on this site containing the following tags:'));
|
2011-03-16 21:49:27 +00:00
|
|
|
} else {
|
|
|
|
$this->element('p', null,
|
|
|
|
// TRANS: Page notice for page with an overview of all subscriptions of a user other
|
|
|
|
// TRANS: than the logged in user. %s is the user nickname.
|
2011-03-16 22:55:40 +00:00
|
|
|
sprintf(_m('%s has subscribed to receive all notices on this site containing the following tags:'),
|
2011-03-16 21:49:27 +00:00
|
|
|
$this->profile->nickname));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function showContent()
|
|
|
|
{
|
|
|
|
if (Event::handle('StartShowTagSubscriptionsContent', array($this))) {
|
|
|
|
parent::showContent();
|
|
|
|
|
|
|
|
$offset = ($this->page-1) * PROFILES_PER_PAGE;
|
|
|
|
$limit = PROFILES_PER_PAGE + 1;
|
|
|
|
|
|
|
|
$cnt = 0;
|
|
|
|
|
|
|
|
$tagsub = new TagSub();
|
|
|
|
$tagsub->profile_id = $this->user->id;
|
2011-03-16 22:55:40 +00:00
|
|
|
$tagsub->limit($limit, $offset);
|
2011-03-16 21:49:27 +00:00
|
|
|
$tagsub->find();
|
|
|
|
|
|
|
|
if ($tagsub->N) {
|
|
|
|
$list = new TagSubscriptionsList($tagsub, $this->user, $this);
|
|
|
|
$cnt = $list->show();
|
|
|
|
if (0 == $cnt) {
|
|
|
|
$this->showEmptyListMessage();
|
|
|
|
}
|
2011-03-16 22:55:40 +00:00
|
|
|
} else {
|
|
|
|
$this->showEmptyListMessage();
|
2011-03-16 21:49:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
|
|
|
|
$this->page, 'tagsubs',
|
|
|
|
array('nickname' => $this->user->nickname));
|
|
|
|
|
|
|
|
|
|
|
|
Event::handle('EndShowTagSubscriptionsContent', array($this));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function showEmptyListMessage()
|
|
|
|
{
|
|
|
|
if (common_logged_in()) {
|
|
|
|
$current_user = common_current_user();
|
|
|
|
if ($this->user->id === $current_user->id) {
|
2011-03-16 22:55:40 +00:00
|
|
|
// TRANS: Tag subscription list text when the logged in user has no tag subscriptions.
|
2011-03-30 21:30:23 +01:00
|
|
|
$message = _m('You are not listening to any hash tags right now. You can push the "Subscribe" button ' .
|
2011-06-17 21:35:45 +01:00
|
|
|
'on any hashtag page to automatically receive any public messages on this site that use that ' .
|
|
|
|
'tag, even if you are not subscribed to the poster.');
|
2011-03-16 21:49:27 +00:00
|
|
|
} else {
|
2011-03-16 22:55:40 +00:00
|
|
|
// TRANS: Tag subscription list text when looking at the subscriptions for a of a user other
|
|
|
|
// TRANS: than the logged in user that has no tag subscriptions. %s is the user nickname.
|
2011-06-17 21:35:45 +01:00
|
|
|
$message = sprintf(_m('%s is not following any tags.'), $this->user->nickname);
|
2011-03-16 21:49:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// TRANS: Subscription list text when looking at the subscriptions for a of a user that has none
|
|
|
|
// TRANS: as an anonymous user. %s is the user nickname.
|
2011-06-17 21:35:45 +01:00
|
|
|
$message = sprintf(_m('%s is not following any tags.'), $this->user->nickname);
|
2011-03-16 21:49:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->elementStart('div', 'guide');
|
|
|
|
$this->raw(common_markup_to_html($message));
|
|
|
|
$this->elementEnd('div');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX SubscriptionsList and SubscriptionList are dangerously close
|
|
|
|
|
|
|
|
class TagSubscriptionsList extends SubscriptionList
|
|
|
|
{
|
|
|
|
function newListItem($tagsub)
|
|
|
|
{
|
|
|
|
return new TagSubscriptionsListItem($tagsub, $this->owner, $this->action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class TagSubscriptionsListItem extends SubscriptionListItem
|
|
|
|
{
|
2011-03-16 22:55:40 +00:00
|
|
|
function startItem()
|
|
|
|
{
|
|
|
|
$this->out->elementStart('li', array('class' => 'tagsub'));
|
|
|
|
}
|
|
|
|
|
2011-03-16 21:49:27 +00:00
|
|
|
function showProfile()
|
|
|
|
{
|
2011-03-16 22:55:40 +00:00
|
|
|
$tagsub = $this->profile;
|
|
|
|
$tag = $tagsub->tag;
|
|
|
|
|
2011-03-16 21:49:27 +00:00
|
|
|
// Relevant portion!
|
|
|
|
$cur = common_current_user();
|
|
|
|
if (!empty($cur) && $cur->id == $this->owner->id) {
|
|
|
|
$this->showOwnerControls();
|
|
|
|
}
|
2011-06-17 21:35:45 +01:00
|
|
|
|
2011-03-16 22:55:40 +00:00
|
|
|
$url = common_local_url('tag', array('tag' => $tag));
|
2011-06-17 21:35:45 +01:00
|
|
|
// TRANS: %1$s is a URL to a tag, %2$s is a tag,
|
|
|
|
// TRANS: %3$s a date string.
|
|
|
|
$linkline = sprintf(_m('#<a href="%1$s">%2$s</a> since %3$s'),
|
2011-03-16 22:55:40 +00:00
|
|
|
htmlspecialchars($url),
|
|
|
|
htmlspecialchars($tag),
|
|
|
|
common_date_string($tagsub->created));
|
|
|
|
|
|
|
|
$this->out->elementStart('div', 'tagsub-item');
|
|
|
|
$this->out->raw($linkline);
|
|
|
|
$this->out->element('div', array('style' => 'clear: both'));
|
|
|
|
$this->out->elementEnd('div');
|
|
|
|
}
|
|
|
|
|
|
|
|
function showActions()
|
|
|
|
{
|
2011-03-16 21:49:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function showOwnerControls()
|
|
|
|
{
|
2011-03-16 22:55:40 +00:00
|
|
|
$this->out->elementStart('div', 'entity_actions');
|
|
|
|
|
2011-03-16 21:49:27 +00:00
|
|
|
$tagsub = $this->profile; // ?
|
2011-03-16 22:55:40 +00:00
|
|
|
$form = new TagUnsubForm($this->out, $tagsub->tag);
|
2011-03-16 21:49:27 +00:00
|
|
|
$form->show();
|
2011-03-16 22:55:40 +00:00
|
|
|
|
|
|
|
$this->out->elementEnd('div');
|
2011-03-16 21:49:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|