[TagSub] Fix User's tags list issue

Issue introduced with 6d9f390b and 9a92b58057
This commit is contained in:
Diogo Cordeiro 2019-06-12 23:44:40 +01:00
parent 306d80de94
commit f2705180e0
14 changed files with 228 additions and 181 deletions

View File

@ -32,7 +32,7 @@ defined('GNUSOCIAL') || die();
define('GNUSOCIAL_ENGINE', 'GNU social'); define('GNUSOCIAL_ENGINE', 'GNU social');
define('GNUSOCIAL_ENGINE_URL', 'https://www.gnu.org/software/social/'); define('GNUSOCIAL_ENGINE_URL', 'https://www.gnu.org/software/social/');
define('GNUSOCIAL_BASE_VERSION', '1.20.2'); define('GNUSOCIAL_BASE_VERSION', '1.20.3');
define('GNUSOCIAL_LIFECYCLE', 'release'); // 'dev', 'alpha[0-9]+', 'beta[0-9]+', 'rc[0-9]+', 'release' define('GNUSOCIAL_LIFECYCLE', 'release'); // 'dev', 'alpha[0-9]+', 'beta[0-9]+', 'rc[0-9]+', 'release'
define('GNUSOCIAL_VERSION', GNUSOCIAL_BASE_VERSION . '-' . GNUSOCIAL_LIFECYCLE); define('GNUSOCIAL_VERSION', GNUSOCIAL_BASE_VERSION . '-' . GNUSOCIAL_LIFECYCLE);

View File

@ -37,14 +37,18 @@ class ProfileListItem extends Widget
/** Action object using us. */ /** Action object using us. */
var $action = null; var $action = null;
// FIXME: Directory plugin sends a User_group here, but should send a Profile and handle User_group specifics itself // FIXME: Directory plugin sends a User_group here, but should send a Profile and handle User_group specifics itself?
function __construct($target, HTMLOutputter $action) function __construct($target, HTMLOutputter $action, Profile $owner = null)
{ {
parent::__construct($action); parent::__construct($action);
$this->target = $target; $this->target = $target;
$this->profile = $this->target; if ($owner !== null) {
$this->action = $action; $this->profile = $owner;
} else {
$this->profile = $this->target;
}
$this->action = $action;
} }
function getTarget() function getTarget()
@ -165,7 +169,7 @@ class ProfileListItem extends Widget
{ {
$user = common_current_user(); $user = common_current_user();
if (!empty($user)) { if (!empty($user)) {
if ($user->id == $this->profile->id) { if ($user->id == $this->profile->getID()) {
$tags = new SelftagsWidget($this->out, $user, $this->profile); $tags = new SelftagsWidget($this->out, $user, $this->profile);
$tags->show(); $tags->show();
} else if ($user->getProfile()->canTag($this->profile)) { } else if ($user->getProfile()->canTag($this->profile)) {

View File

@ -44,7 +44,7 @@ class SubscriptionList extends ProfileList
/** Owner of this list */ /** Owner of this list */
var $owner = null; var $owner = null;
public function __construct(Profile $profile, $owner=null, $action=null) public function __construct($profile, $owner=null, $action=null)
{ {
parent::__construct($profile, $action); parent::__construct($profile, $action);

View File

@ -7,9 +7,14 @@ class SubscriptionListItem extends ProfileListItem
/** Owner of this list */ /** Owner of this list */
var $owner = null; var $owner = null;
function __construct(Profile $profile, $owner, $action) // FIXME: TagSubs plugin sends a TagSub here, but should send a Profile and handle TagSub specifics itself?
function __construct($target, $owner, HTMLOutputter $action)
{ {
parent::__construct($profile, $action); if ($owner instanceof Profile) {
parent::__construct($target, $action, $owner);
} else {
parent::__construct($target, $action);
}
$this->owner = $owner; $this->owner = $owner;
} }

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-06-11 18:37+0100\n" "POT-Creation-Date: 2019-06-17 15:27+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -44,16 +44,16 @@ if (!defined('STATUSNET')) {
*/ */
class TagSubPlugin extends Plugin class TagSubPlugin extends Plugin
{ {
const PLUGIN_VERSION = '0.1.0'; const PLUGIN_VERSION = '0.1.1';
/** /**
* Database schema setup * Database schema setup
* *
* @return bool hook value; true means continue processing, false means stop.
* @see Schema * @see Schema
* *
* @return boolean hook value; true means continue processing, false means stop.
*/ */
function onCheckSchema() public function onCheckSchema()
{ {
$schema = Schema::get(); $schema = Schema::get();
$schema->ensureTable('tagsub', TagSub::schemaDef()); $schema->ensureTable('tagsub', TagSub::schemaDef());
@ -69,16 +69,22 @@ class TagSubPlugin extends Plugin
*/ */
public function onRouterInitialized(URLMapper $m) public function onRouterInitialized(URLMapper $m)
{ {
$m->connect('tag/:tag/subscribe', $m->connect(
array('action' => 'tagsub'), 'tag/:tag/subscribe',
array('tag' => Router::REGEX_TAG)); array('action' => 'tagsub'),
$m->connect('tag/:tag/unsubscribe', array('tag' => Router::REGEX_TAG)
array('action' => 'tagunsub'), );
array('tag' => Router::REGEX_TAG)); $m->connect(
'tag/:tag/unsubscribe',
array('action' => 'tagunsub'),
array('tag' => Router::REGEX_TAG)
);
$m->connect(':nickname/tag-subscriptions', $m->connect(
array('action' => 'tagsubs'), ':nickname/tag-subscriptions',
array('nickname' => Nickname::DISPLAY_FMT)); array('action' => 'tagsubs'),
array('nickname' => Nickname::DISPLAY_FMT)
);
return true; return true;
} }
@ -87,17 +93,17 @@ class TagSubPlugin extends Plugin
* *
* @param array &$versions array of version data * @param array &$versions array of version data
* *
* @return value * @return bool true hook value
*/ */
function onPluginVersion(array &$versions) public function onPluginVersion(array &$versions)
{ {
$versions[] = array('name' => 'TagSub', $versions[] = ['name' => 'TagSub',
'version' => self::PLUGIN_VERSION, 'version' => self::PLUGIN_VERSION,
'author' => 'Brion Vibber', 'author' => 'Brion Vibber',
'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/TagSub', 'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/TagSub',
'rawdescription' => 'rawdescription' =>
// TRANS: Plugin description. // TRANS: Plugin description.
_m('Plugin to allow following all messages with a given tag.')); _m('Plugin to allow following all messages with a given tag.')];
return true; return true;
} }
@ -113,7 +119,7 @@ class TagSubPlugin extends Plugin
* @param array $ni in/out map of profile IDs to inbox constants * @param array $ni in/out map of profile IDs to inbox constants
* @return boolean hook result * @return boolean hook result
*/ */
function onStartNoticeWhoGets(Notice $notice, array &$ni) public function onStartNoticeWhoGets(Notice $notice, array &$ni)
{ {
foreach ($notice->getTags() as $tag) { foreach ($notice->getTags() as $tag) {
$tagsub = new TagSub(); $tagsub = new TagSub();
@ -133,13 +139,13 @@ class TagSubPlugin extends Plugin
* @param TagAction $action * @param TagAction $action
* @return boolean hook result * @return boolean hook result
*/ */
function onStartTagShowContent(TagAction $action) public function onStartTagShowContent(TagAction $action)
{ {
$user = common_current_user(); $user = common_current_user();
if ($user) { if ($user) {
$tag = $action->trimmed('tag'); $tag = $action->trimmed('tag');
$tagsub = TagSub::pkeyGet(array('tag' => $tag, $tagsub = TagSub::pkeyGet(array('tag' => $tag,
'profile_id' => $user->id)); 'profile_id' => $user->id));
if ($tagsub) { if ($tagsub) {
$form = new TagUnsubForm($action, $tag); $form = new TagUnsubForm($action, $tag);
} else { } else {
@ -162,28 +168,30 @@ class TagSubPlugin extends Plugin
* @param Widget $widget Widget being executed * @param Widget $widget Widget being executed
* *
* @return boolean hook return * @return boolean hook return
* @throws Exception
*/ */
function onEndSubGroupNav($widget) public function onEndSubGroupNav($widget)
{ {
$action = $widget->out; $action = $widget->out;
$action_name = $action->trimmed('action'); $action_name = $action->trimmed('action');
$action->menuItem(common_local_url('tagsubs', array('nickname' => $action->user->nickname)), $action->menuItem(
// TRANS: SubMirror plugin menu item on user settings page. common_local_url('tagsubs', array('nickname' => $action->user->nickname)),
_m('MENU', 'Tags'), // TRANS: SubMirror plugin menu item on user settings page.
// TRANS: SubMirror plugin tooltip for user settings menu item. _m('MENU', 'Tags'),
_m('Configure tag subscriptions'), // TRANS: SubMirror plugin tooltip for user settings menu item.
$action_name == 'tagsubs' && $action->arg('nickname') == $action->user->nickname); _m('Configure tag subscriptions'),
$action_name == 'tagsubs' && $action->arg('nickname') == $action->user->nickname
);
return true; return true;
} }
function onEndDefaultLocalNav($menu, $user) public function onEndDefaultLocalNav($menu, $user)
{ {
$user = common_current_user(); $user = $user ? $user : common_current_user();
if (!empty($user)) { if (!empty($user)) {
$tags = TagSub::forProfile($user->getProfile()); $tags = TagSub::forProfile($user->getProfile());
if (!empty($tags) && count($tags) > 0) { if (!empty($tags) && count($tags) > 0) {

View File

@ -53,8 +53,8 @@ if (!defined('STATUSNET')) {
*/ */
class TagsubAction extends Action class TagsubAction extends Action
{ {
var $user; public $user;
var $tag; public $tag;
/** /**
* Check pre-requisites and instantiate attributes * Check pre-requisites and instantiate attributes
@ -62,8 +62,9 @@ class TagsubAction extends Action
* @param Array $args array of arguments (URL, GET, POST) * @param Array $args array of arguments (URL, GET, POST)
* *
* @return boolean success flag * @return boolean success flag
* @throws ClientException
*/ */
function prepare(array $args = array()) public function prepare(array $args = array())
{ {
parent::prepare($args); parent::prepare($args);
if ($this->boolean('ajax')) { if ($this->boolean('ajax')) {
@ -84,8 +85,8 @@ class TagsubAction extends Action
if (!$token || $token != common_session_token()) { if (!$token || $token != common_session_token()) {
// TRANS: Client error displayed when the session token is not okay. // TRANS: Client error displayed when the session token is not okay.
$this->clientError(_m('There was a problem with your session token.'. $this->clientError(_m('There was a problem with your session token.' .
' Try again, please.')); ' Try again, please.'));
} }
// Only for logged-in users // Only for logged-in users
@ -114,16 +115,17 @@ class TagsubAction extends Action
* *
* Does the subscription and returns results. * Does the subscription and returns results.
* *
* @param Array $args unused.
*
* @return void * @return void
* @throws ClientException
*/ */
function handle() public function handle()
{ {
// Throws exception on error // Throws exception on error
TagSub::start($this->user->getProfile(), TagSub::start(
$this->tag); $this->user->getProfile(),
$this->tag
);
if ($this->boolean('ajax')) { if ($this->boolean('ajax')) {
$this->startHTML('text/xml;charset=utf-8'); $this->startHTML('text/xml;charset=utf-8');
@ -137,8 +139,10 @@ class TagsubAction extends Action
$this->elementEnd('body'); $this->elementEnd('body');
$this->endHTML(); $this->endHTML();
} else { } else {
$url = common_local_url('tag', $url = common_local_url(
array('tag' => $this->tag)); 'tag',
array('tag' => $this->tag)
);
common_redirect($url, 303); common_redirect($url, 303);
} }
} }

View File

@ -28,7 +28,9 @@
* @link http://status.net/ * @link http://status.net/
*/ */
if (!defined('GNUSOCIAL')) { exit(1); } if (!defined('GNUSOCIAL')) {
exit(1);
}
/** /**
* A list of the user's subscriptions * A list of the user's subscriptions
@ -41,7 +43,7 @@ if (!defined('GNUSOCIAL')) { exit(1); }
*/ */
class TagSubsAction extends GalleryAction class TagSubsAction extends GalleryAction
{ {
function title() public function title()
{ {
if ($this->page == 1) { if ($this->page == 1) {
// TRANS: Header for subscriptions overview for a user (first page). // TRANS: Header for subscriptions overview for a user (first page).
@ -50,35 +52,45 @@ class TagSubsAction extends GalleryAction
} else { } else {
// TRANS: Header for subscriptions overview for a user (not first page). // TRANS: Header for subscriptions overview for a user (not first page).
// TRANS: %1$s is a user nickname, %2$d is the page number. // TRANS: %1$s is a user nickname, %2$d is the page number.
return sprintf(_m('%1$s\'s tag subscriptions, page %2$d'), return sprintf(
$this->getTarget()->getNickname(), _m('%1$s\'s tag subscriptions, page %2$d'),
$this->page); $this->getTarget()->getNickname(),
$this->page
);
} }
} }
function showPageNotice() public function showPageNotice()
{ {
if ($this->scoped instanceof Profile && $this->scoped->sameAs($this->getTarget())) { if ($this->scoped instanceof Profile && $this->scoped->sameAs($this->getTarget())) {
$this->element('p', null, $this->element(
// TRANS: Page notice for page with an overview of all tag subscriptions 'p',
// TRANS: of the logged in user's own profile. null,
_m('You have subscribed to receive all notices on this site containing the following tags:')); // 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:')
);
} else { } else {
$this->element('p', null, $this->element(
// TRANS: Page notice for page with an overview of all subscriptions of a user other 'p',
// TRANS: than the logged in user. %s is the user nickname. null,
sprintf(_m('%s has subscribed to receive all notices on this site containing the following tags:'), // TRANS: Page notice for page with an overview of all subscriptions of a user other
$this->getTarget()->getNickname())); // 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()
)
);
} }
} }
function showContent() public function showContent()
{ {
if (Event::handle('StartShowTagSubscriptionsContent', array($this))) { if (Event::handle('StartShowTagSubscriptionsContent', array($this))) {
parent::showContent(); parent::showContent();
$offset = ($this->page-1) * PROFILES_PER_PAGE; $offset = ($this->page - 1) * PROFILES_PER_PAGE;
$limit = PROFILES_PER_PAGE + 1; $limit = PROFILES_PER_PAGE + 1;
$cnt = 0; $cnt = 0;
@ -97,30 +109,33 @@ class TagSubsAction extends GalleryAction
$this->showEmptyListMessage(); $this->showEmptyListMessage();
} }
$this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE, $this->pagination(
$this->page, 'tagsubs', $this->page > 1,
array('nickname' => $this->getTarget()->getNickname())); $cnt > PROFILES_PER_PAGE,
$this->page,
'tagsubs',
array('nickname' => $this->getTarget()->getNickname())
);
Event::handle('EndShowTagSubscriptionsContent', array($this)); Event::handle('EndShowTagSubscriptionsContent', array($this));
} }
} }
function showEmptyListMessage() public function showEmptyListMessage()
{ {
if (common_logged_in()) { if (common_logged_in()) {
if ($this->scoped->sameAs($this->getTarget())) { if ($this->scoped->sameAs($this->getTarget())) {
// TRANS: Tag subscription list text when the logged in user has no tag subscriptions. // TRANS: Tag subscription list text when the logged in user has no tag subscriptions.
$message = _m('You are not listening to any hash tags right now. You can push the "Subscribe" button ' . $message = _m('You are not listening to any hash tags right now. You can push the "Subscribe" button ' .
'on any hashtag page to automatically receive any public messages on this site that use that ' . '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.'); 'tag, even if you are not subscribed to the poster.');
} else { } else {
// TRANS: Tag subscription list text when looking at the subscriptions for a of a user other // 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. // TRANS: than the logged in user that has no tag subscriptions. %s is the user nickname.
$message = sprintf(_m('%s is not following any tags.'), $this->getTarget()->getNickname()); $message = sprintf(_m('%s is not following any tags.'), $this->getTarget()->getNickname());
} }
} } else {
else {
// TRANS: Subscription list text when looking at the subscriptions for a of a user that has none // 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. // TRANS: as an anonymous user. %s is the user nickname.
$message = sprintf(_m('%s is not following any tags.'), $this->getTarget()->getNickname()); $message = sprintf(_m('%s is not following any tags.'), $this->getTarget()->getNickname());
@ -136,7 +151,7 @@ class TagSubsAction extends GalleryAction
class TagSubscriptionsList extends SubscriptionList class TagSubscriptionsList extends SubscriptionList
{ {
function newListItem(Profile $tagsub) public function newListItem($tagsub)
{ {
return new TagSubscriptionsListItem($tagsub, $this->owner, $this->action); return new TagSubscriptionsListItem($tagsub, $this->owner, $this->action);
} }
@ -144,14 +159,14 @@ class TagSubscriptionsList extends SubscriptionList
class TagSubscriptionsListItem extends SubscriptionListItem class TagSubscriptionsListItem extends SubscriptionListItem
{ {
function startItem() public function startItem()
{ {
$this->out->elementStart('li', array('class' => 'tagsub')); $this->out->elementStart('li', array('class' => 'tagsub'));
} }
function showProfile() public function showProfile()
{ {
$tagsub = $this->profile; $tagsub = $this->getTarget();
$tag = $tagsub->tag; $tag = $tagsub->tag;
// Relevant portion! // Relevant portion!
@ -163,10 +178,12 @@ class TagSubscriptionsListItem extends SubscriptionListItem
$url = common_local_url('tag', array('tag' => $tag)); $url = common_local_url('tag', array('tag' => $tag));
// TRANS: %1$s is a URL to a tag, %2$s is a tag, // TRANS: %1$s is a URL to a tag, %2$s is a tag,
// TRANS: %3$s a date string. // TRANS: %3$s a date string.
$linkline = sprintf(_m('#<a href="%1$s">%2$s</a> since %3$s'), $linkline = sprintf(
htmlspecialchars($url), _m('#<a href="%1$s">%2$s</a> since %3$s'),
htmlspecialchars($tag), htmlspecialchars($url),
common_date_string($tagsub->created)); htmlspecialchars($tag),
common_date_string($tagsub->created)
);
$this->out->elementStart('div', 'tagsub-item'); $this->out->elementStart('div', 'tagsub-item');
$this->out->raw($linkline); $this->out->raw($linkline);
@ -174,15 +191,15 @@ class TagSubscriptionsListItem extends SubscriptionListItem
$this->out->elementEnd('div'); $this->out->elementEnd('div');
} }
function showActions() public function showActions()
{ {
} }
function showOwnerControls() public function showOwnerControls()
{ {
$this->out->elementStart('div', 'entity_actions'); $this->out->elementStart('div', 'entity_actions');
$tagsub = $this->profile; // ? $tagsub = $this->target;
$form = new TagUnsubForm($this->out, $tagsub->tag); $form = new TagUnsubForm($this->out, $tagsub->tag);
$form->show(); $form->show();

View File

@ -58,16 +58,17 @@ class TagunsubAction extends TagsubAction
* *
* Does the subscription and returns results. * Does the subscription and returns results.
* *
* @param Array $args unused.
*
* @return void * @return void
* @throws ClientException
*/ */
function handle() public function handle()
{ {
// Throws exception on error // Throws exception on error
TagSub::cancel($this->user->getProfile(), TagSub::cancel(
$this->tag); $this->user->getProfile(),
$this->tag
);
if ($this->boolean('ajax')) { if ($this->boolean('ajax')) {
$this->startHTML('text/xml;charset=utf-8'); $this->startHTML('text/xml;charset=utf-8');
@ -81,8 +82,10 @@ class TagunsubAction extends TagsubAction
$this->elementEnd('body'); $this->elementEnd('body');
$this->endHTML(); $this->endHTML();
} else { } else {
$url = common_local_url('tag', $url = common_local_url(
array('tag' => $this->tag)); 'tag',
array('tag' => $this->tag)
);
common_redirect($url, 303); common_redirect($url, 303);
} }
} }

View File

@ -79,7 +79,7 @@ class TagSub extends Managed_DataObject
* @param string $tag subscribee * @param string $tag subscribee
* @return TagSub * @return TagSub
*/ */
static function start(Profile $profile, $tag) public static function start(Profile $profile, $tag)
{ {
$ts = new TagSub(); $ts = new TagSub();
$ts->tag = $tag; $ts->tag = $tag;
@ -96,35 +96,35 @@ class TagSub extends Managed_DataObject
* @param profile $profile subscriber * @param profile $profile subscriber
* @param string $tag subscribee * @param string $tag subscribee
*/ */
static function cancel(Profile $profile, $tag) public static function cancel(Profile $profile, $tag)
{ {
$ts = TagSub::pkeyGet(array('tag' => $tag, $ts = TagSub::pkeyGet(array('tag' => $tag,
'profile_id' => $profile->id)); 'profile_id' => $profile->id));
if ($ts) { if ($ts) {
$ts->delete(); $ts->delete();
self::blow('tagsub:by_profile:%d', $profile->id); self::blow('tagsub:by_profile:%d', $profile->id);
} }
} }
static function forProfile(Profile $profile) public static function forProfile(Profile $profile)
{ {
$tags = array(); $tags = array();
$keypart = sprintf('tagsub:by_profile:%d', $profile->id); $keypart = sprintf('tagsub:by_profile:%d', $profile->id);
$tagstring = self::cacheGet($keypart); $tagstring = self::cacheGet($keypart);
if ($tagstring !== false) { // cache hit if ($tagstring !== false) { // cache hit
if (!empty($tagstring)) { if (!empty($tagstring)) {
$tags = explode(',', $tagstring); $tags = explode(',', $tagstring);
} }
} else { } else {
$tagsub = new TagSub(); $tagsub = new TagSub();
$tagsub->profile_id = $profile->id; $tagsub->profile_id = $profile->id;
$tagsub->selectAdd(); $tagsub->selectAdd();
$tagsub->selectAdd('tag'); $tagsub->selectAdd('tag');
if ($tagsub->find()) { if ($tagsub->find()) {
$tags = $tagsub->fetchAll('tag'); $tags = $tagsub->fetchAll('tag');
} }
self::cacheSet($keypart, implode(',', $tags)); self::cacheSet($keypart, implode(',', $tags));

View File

@ -51,15 +51,15 @@ class TagSubForm extends Form
/** /**
* Name of tag to subscribe to * Name of tag to subscribe to
*/ */
var $tag = ''; public $tag = '';
/** /**
* Constructor * Constructor
* *
* @param HTMLOutputter $out output channel * @param HTMLOutputter $out output channel
* @param string $tag name of tag to subscribe to * @param string $tag name of tag to subscribe to
*/ */
function __construct($out=null, $tag=null) public function __construct($out = null, $tag = null)
{ {
parent::__construct($out); parent::__construct($out);
@ -71,7 +71,7 @@ class TagSubForm extends Form
* *
* @return int ID of the form * @return int ID of the form
*/ */
function id() public function id()
{ {
return 'tag-subscribe-' . $this->tag; return 'tag-subscribe-' . $this->tag;
} }
@ -81,7 +81,7 @@ class TagSubForm extends Form
* *
* @return string of the form class * @return string of the form class
*/ */
function formClass() public function formClass()
{ {
// class to match existing styles... // class to match existing styles...
return 'form_user_subscribe ajax'; return 'form_user_subscribe ajax';
@ -92,7 +92,7 @@ class TagSubForm extends Form
* *
* @return string URL of the action * @return string URL of the action
*/ */
function action() public function action()
{ {
return common_local_url('tagsub', array('tag' => $this->tag)); return common_local_url('tagsub', array('tag' => $this->tag));
} }
@ -101,8 +101,9 @@ class TagSubForm extends Form
* Legend of the Form * Legend of the Form
* *
* @return void * @return void
* @throws Exception
*/ */
function formLegend() public function formLegend()
{ {
// TRANS: Form legend. // TRANS: Form legend.
$this->out->element('legend', null, _m('Subscribe to this tag')); $this->out->element('legend', null, _m('Subscribe to this tag'));
@ -113,23 +114,31 @@ class TagSubForm extends Form
* *
* @return void * @return void
*/ */
function formData() public function formData()
{ {
$this->out->hidden('subscribeto-' . $this->tag, $this->out->hidden(
$this->tag, 'subscribeto-' . $this->tag,
'subscribeto'); $this->tag,
'subscribeto'
);
} }
/** /**
* Action elements * Action elements
* *
* @return void * @return void
* @throws Exception
*/ */
function formActions() public function formActions()
{ {
// TRANS: Submit button text to subscribe to a tag. // TRANS: Submit button text to subscribe to a tag.
$this->out->submit('submit', _m('BUTTON','Subscribe'), $this->out->submit(
// TRANS: Submit button title to subscribe to a tag. 'submit',
'submit', null, _m('Subscribe to this tag.')); _m('BUTTON', 'Subscribe'),
// TRANS: Submit button title to subscribe to a tag.
'submit',
null,
_m('Subscribe to this tag.')
);
} }
} }

View File

@ -53,7 +53,7 @@ class TagUnsubForm extends TagSubForm
* *
* @return int ID of the form * @return int ID of the form
*/ */
function id() public function id()
{ {
return 'tag-unsubscribe-' . $this->tag; return 'tag-unsubscribe-' . $this->tag;
} }
@ -63,7 +63,7 @@ class TagUnsubForm extends TagSubForm
* *
* @return string of the form class * @return string of the form class
*/ */
function formClass() public function formClass()
{ {
// class to match existing styles... // class to match existing styles...
return 'form_user_unsubscribe ajax'; return 'form_user_unsubscribe ajax';
@ -74,7 +74,7 @@ class TagUnsubForm extends TagSubForm
* *
* @return string URL of the action * @return string URL of the action
*/ */
function action() public function action()
{ {
return common_local_url('tagunsub', array('tag' => $this->tag)); return common_local_url('tagunsub', array('tag' => $this->tag));
} }
@ -83,8 +83,9 @@ class TagUnsubForm extends TagSubForm
* Legend of the Form * Legend of the Form
* *
* @return void * @return void
* @throws Exception
*/ */
function formLegend() public function formLegend()
{ {
// TRANS: Form legend. // TRANS: Form legend.
$this->out->element('legend', null, _m('Unsubscribe from this tag')); $this->out->element('legend', null, _m('Unsubscribe from this tag'));
@ -94,12 +95,18 @@ class TagUnsubForm extends TagSubForm
* Action elements * Action elements
* *
* @return void * @return void
* @throws Exception
*/ */
function formActions() public function formActions()
{ {
// TRANS: Submit button text to unsubscribe from a tag. // TRANS: Submit button text to unsubscribe from a tag.
$this->out->submit('submit', _m('BUTTON','Unsubscribe'), $this->out->submit(
// TRANS: Submit button title to unsubscribe from a tag. 'submit',
'submit', null, _m('Unsubscribe from this tag.')); _m('BUTTON', 'Unsubscribe'),
// TRANS: Submit button title to unsubscribe from a tag.
'submit',
null,
_m('Unsubscribe from this tag.')
);
} }
} }

View File

@ -49,40 +49,40 @@ class TagSubMenu extends MoreMenu
protected $user; protected $user;
protected $tags; protected $tags;
function __construct($out, $user, $tags) public function __construct($out, $user, $tags)
{ {
parent::__construct($out); parent::__construct($out);
$this->user = $user; $this->user = $user;
$this->tags = $tags; $this->tags = $tags;
} }
function getItems() public function getItems()
{ {
$items = array(); $items = array();
foreach ($this->tags as $tag) { foreach ($this->tags as $tag) {
if (!empty($tag)) { if (!empty($tag)) {
$items[] = array('tag', $items[] = array('tag',
array('tag' => $tag), array('tag' => $tag),
sprintf('#%s', $tag), sprintf('#%s', $tag),
// TRANS: Menu item title. %s is a tag. // TRANS: Menu item title. %s is a tag.
sprintf(_('Notices tagged with "%s".'), $tag)); sprintf(_('Notices tagged with "%s".'), $tag));
} }
} }
return $items; return $items;
} }
function tag() public function tag()
{ {
return 'tagsubs'; return 'tagsubs';
} }
function seeAllItem() public function seeAllItem()
{ {
return array('tagsubs', return array('tagsubs',
array('nickname' => $this->user->nickname), array('nickname' => $this->user->nickname),
_('See all'), _('See all'),
_('See all tags you are following')); _('See all tags you are following'));
} }
} }

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-06-08 18:20+0100\n" "POT-Creation-Date: 2019-06-13 00:46+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -19,29 +19,25 @@ msgstr ""
#. TRANS: Header for subscriptions overview for a user (first page). #. TRANS: Header for subscriptions overview for a user (first page).
#. TRANS: %s is a user nickname. #. TRANS: %s is a user nickname.
#: actions/tagsubs.php:49 #: actions/tagsubs.php:51
#, php-format #, php-format
msgid "%s's tag subscriptions" msgid "%s's tag subscriptions"
msgstr "" msgstr ""
#. TRANS: Header for subscriptions overview for a user (not first page). #: actions/tagsubs.php:56
#. TRANS: %1$s is a user nickname, %2$d is the page number.
#: actions/tagsubs.php:53
#, php-format #, php-format
msgid "%1$s's tag subscriptions, page %2$d" msgid "%1$s's tag subscriptions, page %2$d"
msgstr "" msgstr ""
#. TRANS: Page notice for page with an overview of all tag subscriptions #. TRANS: Page notice for page with an overview of all tag subscriptions
#. TRANS: of the logged in user's own profile. #. TRANS: of the logged in user's own profile.
#: actions/tagsubs.php:65 #: actions/tagsubs.php:71
msgid "" msgid ""
"You have subscribed to receive all notices on this site containing the " "You have subscribed to receive all notices on this site containing the "
"following tags:" "following tags:"
msgstr "" msgstr ""
#. TRANS: Page notice for page with an overview of all subscriptions of a user other #: actions/tagsubs.php:80
#. TRANS: than the logged in user. %s is the user nickname.
#: actions/tagsubs.php:70
#, php-format #, php-format
msgid "" msgid ""
"%s has subscribed to receive all notices on this site containing the " "%s has subscribed to receive all notices on this site containing the "
@ -49,7 +45,7 @@ msgid ""
msgstr "" msgstr ""
#. TRANS: Tag subscription list text when the logged in user has no tag subscriptions. #. TRANS: Tag subscription list text when the logged in user has no tag subscriptions.
#: actions/tagsubs.php:114 #: actions/tagsubs.php:130
msgid "" msgid ""
"You are not listening to any hash tags right now. You can push the " "You are not listening to any hash tags right now. You can push the "
"\"Subscribe\" button on any hashtag page to automatically receive any public " "\"Subscribe\" button on any hashtag page to automatically receive any public "
@ -61,98 +57,92 @@ msgstr ""
#. TRANS: than the logged in user that has no tag subscriptions. %s is the user nickname. #. TRANS: than the logged in user that has no tag subscriptions. %s is the user nickname.
#. TRANS: Subscription list text when looking at the subscriptions for a of a user that has none #. 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. #. TRANS: as an anonymous user. %s is the user nickname.
#: actions/tagsubs.php:120 actions/tagsubs.php:126 #: actions/tagsubs.php:136 actions/tagsubs.php:141
#, php-format #, php-format
msgid "%s is not following any tags." msgid "%s is not following any tags."
msgstr "" msgstr ""
#. TRANS: %1$s is a URL to a tag, %2$s is a tag, #: actions/tagsubs.php:182
#. TRANS: %3$s a date string.
#: actions/tagsubs.php:166
#, php-format #, php-format
msgid "#<a href=\"%1$s\">%2$s</a> since %3$s" msgid "#<a href=\"%1$s\">%2$s</a> since %3$s"
msgstr "" msgstr ""
#. TRANS: Client error displayed trying to perform any request method other than POST. #. TRANS: Client error displayed trying to perform any request method other than POST.
#. TRANS: Do not translate POST. #. TRANS: Do not translate POST.
#: actions/tagsub.php:78 #: actions/tagsub.php:79
msgid "This action only accepts POST requests." msgid "This action only accepts POST requests."
msgstr "" msgstr ""
#. TRANS: Client error displayed when the session token is not okay. #. TRANS: Client error displayed when the session token is not okay.
#: actions/tagsub.php:87 #: actions/tagsub.php:88
msgid "There was a problem with your session token. Try again, please." msgid "There was a problem with your session token. Try again, please."
msgstr "" msgstr ""
#. TRANS: Error message displayed when trying to perform an action that requires a logged in user. #. TRANS: Error message displayed when trying to perform an action that requires a logged in user.
#: actions/tagsub.php:97 #: actions/tagsub.php:98
msgid "Not logged in." msgid "Not logged in."
msgstr "" msgstr ""
#. TRANS: Client error displayed trying to subscribe to a non-existing profile. #. TRANS: Client error displayed trying to subscribe to a non-existing profile.
#: actions/tagsub.php:106 #: actions/tagsub.php:107
msgid "No such profile." msgid "No such profile."
msgstr "" msgstr ""
#. TRANS: Page title when tag subscription succeeded. #. TRANS: Page title when tag subscription succeeded.
#: actions/tagsub.php:132 #: actions/tagsub.php:134
msgid "Subscribed" msgid "Subscribed"
msgstr "" msgstr ""
#. TRANS: Page title when tag unsubscription succeeded. #. TRANS: Page title when tag unsubscription succeeded.
#: actions/tagunsub.php:76 #: actions/tagunsub.php:77
msgid "Unsubscribed" msgid "Unsubscribed"
msgstr "" msgstr ""
#. TRANS: Plugin description. #. TRANS: Plugin description.
#: TagSubPlugin.php:100 #: TagSubPlugin.php:106
msgid "Plugin to allow following all messages with a given tag." msgid "Plugin to allow following all messages with a given tag."
msgstr "" msgstr ""
#. TRANS: SubMirror plugin menu item on user settings page. #. TRANS: SubMirror plugin menu item on user settings page.
#: TagSubPlugin.php:173 #: TagSubPlugin.php:181
msgctxt "MENU" msgctxt "MENU"
msgid "Tags" msgid "Tags"
msgstr "" msgstr ""
#. TRANS: SubMirror plugin tooltip for user settings menu item. #. TRANS: SubMirror plugin tooltip for user settings menu item.
#: TagSubPlugin.php:175 #: TagSubPlugin.php:183
msgid "Configure tag subscriptions" msgid "Configure tag subscriptions"
msgstr "" msgstr ""
#. TRANS: Menu item text for tags submenu. #. TRANS: Menu item text for tags submenu.
#: TagSubPlugin.php:192 #: TagSubPlugin.php:200
msgid "Tags" msgid "Tags"
msgstr "" msgstr ""
#. TRANS: Form legend. #. TRANS: Form legend.
#: forms/tagsub.php:108 #: forms/tagsub.php:109
msgid "Subscribe to this tag" msgid "Subscribe to this tag"
msgstr "" msgstr ""
#. TRANS: Submit button text to subscribe to a tag. #: forms/tagsub.php:137
#: forms/tagsub.php:131
msgctxt "BUTTON" msgctxt "BUTTON"
msgid "Subscribe" msgid "Subscribe"
msgstr "" msgstr ""
#. TRANS: Submit button title to subscribe to a tag. #: forms/tagsub.php:141
#: forms/tagsub.php:133
msgid "Subscribe to this tag." msgid "Subscribe to this tag."
msgstr "" msgstr ""
#. TRANS: Form legend. #. TRANS: Form legend.
#: forms/tagunsub.php:90 #: forms/tagunsub.php:91
msgid "Unsubscribe from this tag" msgid "Unsubscribe from this tag"
msgstr "" msgstr ""
#. TRANS: Submit button text to unsubscribe from a tag. #: forms/tagunsub.php:105
#: forms/tagunsub.php:101
msgctxt "BUTTON" msgctxt "BUTTON"
msgid "Unsubscribe" msgid "Unsubscribe"
msgstr "" msgstr ""
#. TRANS: Submit button title to unsubscribe from a tag. #: forms/tagunsub.php:109
#: forms/tagunsub.php:103
msgid "Unsubscribe from this tag." msgid "Unsubscribe from this tag."
msgstr "" msgstr ""