2011-03-17 06:49:27 +09: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/
|
|
|
|
*/
|
|
|
|
|
2019-06-13 07:44:40 +09:00
|
|
|
if (!defined('GNUSOCIAL')) {
|
|
|
|
exit(1);
|
|
|
|
}
|
2011-03-17 06:49:27 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
{
|
2019-06-13 07:44:40 +09:00
|
|
|
public function title()
|
2011-03-17 06:49:27 +09:00
|
|
|
{
|
|
|
|
if ($this->page == 1) {
|
|
|
|
// TRANS: Header for subscriptions overview for a user (first page).
|
|
|
|
// TRANS: %s is a user nickname.
|
2015-07-11 05:54:14 +09:00
|
|
|
return sprintf(_m('%s\'s tag subscriptions'), $this->getTarget()->getNickname());
|
2011-03-17 06:49:27 +09:00
|
|
|
} 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.
|
2019-06-13 07:44:40 +09:00
|
|
|
return sprintf(
|
|
|
|
_m('%1$s\'s tag subscriptions, page %2$d'),
|
|
|
|
$this->getTarget()->getNickname(),
|
|
|
|
$this->page
|
|
|
|
);
|
2011-03-17 06:49:27 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-13 07:44:40 +09:00
|
|
|
public function showPageNotice()
|
2011-03-17 06:49:27 +09:00
|
|
|
{
|
2015-07-11 05:54:14 +09:00
|
|
|
if ($this->scoped instanceof Profile && $this->scoped->sameAs($this->getTarget())) {
|
2019-06-13 07:44:40 +09:00
|
|
|
$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.
|
|
|
|
_m('You have subscribed to receive all notices on this site containing the following tags:')
|
|
|
|
);
|
2011-03-17 06:49:27 +09:00
|
|
|
} else {
|
2019-06-13 07:44:40 +09:00
|
|
|
$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.
|
|
|
|
sprintf(
|
|
|
|
_m('%s has subscribed to receive all notices on this site containing the following tags:'),
|
|
|
|
$this->getTarget()->getNickname()
|
|
|
|
)
|
|
|
|
);
|
2011-03-17 06:49:27 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-13 07:44:40 +09:00
|
|
|
public function showContent()
|
2011-03-17 06:49:27 +09:00
|
|
|
{
|
|
|
|
if (Event::handle('StartShowTagSubscriptionsContent', array($this))) {
|
|
|
|
parent::showContent();
|
|
|
|
|
2019-06-13 07:44:40 +09:00
|
|
|
$offset = ($this->page - 1) * PROFILES_PER_PAGE;
|
|
|
|
$limit = PROFILES_PER_PAGE + 1;
|
2011-03-17 06:49:27 +09:00
|
|
|
|
|
|
|
$cnt = 0;
|
|
|
|
|
|
|
|
$tagsub = new TagSub();
|
2015-07-11 05:54:14 +09:00
|
|
|
$tagsub->profile_id = $this->getTarget()->getID();
|
2011-03-17 07:55:40 +09:00
|
|
|
$tagsub->limit($limit, $offset);
|
2011-03-17 06:49:27 +09:00
|
|
|
$tagsub->find();
|
|
|
|
|
|
|
|
if ($tagsub->N) {
|
2015-07-11 05:54:14 +09:00
|
|
|
$list = new TagSubscriptionsList($tagsub, $this->getTarget(), $this);
|
2011-03-17 06:49:27 +09:00
|
|
|
$cnt = $list->show();
|
|
|
|
if (0 == $cnt) {
|
|
|
|
$this->showEmptyListMessage();
|
|
|
|
}
|
2011-03-17 07:55:40 +09:00
|
|
|
} else {
|
|
|
|
$this->showEmptyListMessage();
|
2011-03-17 06:49:27 +09:00
|
|
|
}
|
|
|
|
|
2019-06-13 07:44:40 +09:00
|
|
|
$this->pagination(
|
|
|
|
$this->page > 1,
|
|
|
|
$cnt > PROFILES_PER_PAGE,
|
|
|
|
$this->page,
|
|
|
|
'tagsubs',
|
|
|
|
array('nickname' => $this->getTarget()->getNickname())
|
|
|
|
);
|
2011-03-17 06:49:27 +09:00
|
|
|
|
|
|
|
|
|
|
|
Event::handle('EndShowTagSubscriptionsContent', array($this));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-13 07:44:40 +09:00
|
|
|
public function showEmptyListMessage()
|
2011-03-17 06:49:27 +09:00
|
|
|
{
|
|
|
|
if (common_logged_in()) {
|
2015-07-11 05:54:14 +09:00
|
|
|
if ($this->scoped->sameAs($this->getTarget())) {
|
2011-03-17 07:55:40 +09:00
|
|
|
// TRANS: Tag subscription list text when the logged in user has no tag subscriptions.
|
2011-03-31 05:30:23 +09:00
|
|
|
$message = _m('You are not listening to any hash tags right now. You can push the "Subscribe" button ' .
|
2019-06-13 07:44:40 +09: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-17 06:49:27 +09:00
|
|
|
} else {
|
2011-03-17 07:55:40 +09: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.
|
2015-07-11 05:54:14 +09:00
|
|
|
$message = sprintf(_m('%s is not following any tags.'), $this->getTarget()->getNickname());
|
2011-03-17 06:49:27 +09:00
|
|
|
}
|
2019-06-13 07:44:40 +09:00
|
|
|
} else {
|
2011-03-17 06:49:27 +09:00
|
|
|
// 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.
|
2015-07-11 05:54:14 +09:00
|
|
|
$message = sprintf(_m('%s is not following any tags.'), $this->getTarget()->getNickname());
|
2011-03-17 06:49:27 +09: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
|
|
|
|
{
|
2019-06-13 07:44:40 +09:00
|
|
|
public function newListItem($tagsub)
|
2011-03-17 06:49:27 +09:00
|
|
|
{
|
|
|
|
return new TagSubscriptionsListItem($tagsub, $this->owner, $this->action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class TagSubscriptionsListItem extends SubscriptionListItem
|
|
|
|
{
|
2019-06-13 07:44:40 +09:00
|
|
|
public function startItem()
|
2011-03-17 07:55:40 +09:00
|
|
|
{
|
|
|
|
$this->out->elementStart('li', array('class' => 'tagsub'));
|
|
|
|
}
|
|
|
|
|
2019-06-13 07:44:40 +09:00
|
|
|
public function showProfile()
|
2011-03-17 06:49:27 +09:00
|
|
|
{
|
2019-06-13 07:44:40 +09:00
|
|
|
$tagsub = $this->getTarget();
|
2011-03-17 07:55:40 +09:00
|
|
|
$tag = $tagsub->tag;
|
|
|
|
|
2011-03-17 06:49:27 +09:00
|
|
|
// Relevant portion!
|
|
|
|
$cur = common_current_user();
|
|
|
|
if (!empty($cur) && $cur->id == $this->owner->id) {
|
|
|
|
$this->showOwnerControls();
|
|
|
|
}
|
2011-06-18 05:35:45 +09:00
|
|
|
|
2011-03-17 07:55:40 +09:00
|
|
|
$url = common_local_url('tag', array('tag' => $tag));
|
2011-06-18 05:35:45 +09:00
|
|
|
// TRANS: %1$s is a URL to a tag, %2$s is a tag,
|
|
|
|
// TRANS: %3$s a date string.
|
2019-06-13 07:44:40 +09:00
|
|
|
$linkline = sprintf(
|
|
|
|
_m('#<a href="%1$s">%2$s</a> since %3$s'),
|
|
|
|
htmlspecialchars($url),
|
|
|
|
htmlspecialchars($tag),
|
|
|
|
common_date_string($tagsub->created)
|
|
|
|
);
|
2011-03-17 07:55:40 +09:00
|
|
|
|
|
|
|
$this->out->elementStart('div', 'tagsub-item');
|
|
|
|
$this->out->raw($linkline);
|
|
|
|
$this->out->element('div', array('style' => 'clear: both'));
|
|
|
|
$this->out->elementEnd('div');
|
|
|
|
}
|
|
|
|
|
2019-06-13 07:44:40 +09:00
|
|
|
public function showActions()
|
2011-03-17 07:55:40 +09:00
|
|
|
{
|
2011-03-17 06:49:27 +09:00
|
|
|
}
|
|
|
|
|
2019-06-13 07:44:40 +09:00
|
|
|
public function showOwnerControls()
|
2011-03-17 06:49:27 +09:00
|
|
|
{
|
2011-03-17 07:55:40 +09:00
|
|
|
$this->out->elementStart('div', 'entity_actions');
|
|
|
|
|
2019-06-13 07:44:40 +09:00
|
|
|
$tagsub = $this->target;
|
2011-03-17 07:55:40 +09:00
|
|
|
$form = new TagUnsubForm($this->out, $tagsub->tag);
|
2011-03-17 06:49:27 +09:00
|
|
|
$form->show();
|
2011-03-17 07:55:40 +09:00
|
|
|
|
|
|
|
$this->out->elementEnd('div');
|
2011-03-17 06:49:27 +09:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|