From f2705180e0f3f0eecb17af7622a3fcedab9233a2 Mon Sep 17 00:00:00 2001 From: Diogo Cordeiro Date: Wed, 12 Jun 2019 23:44:40 +0100 Subject: [PATCH] [TagSub] Fix User's tags list issue Issue introduced with 6d9f390b and 9a92b58057 --- lib/framework.php | 2 +- lib/profilelistitem.php | 14 +++-- lib/subscriptionlist.php | 2 +- lib/subscriptionlistitem.php | 9 ++- locale/statusnet.pot | 2 +- plugins/TagSub/TagSubPlugin.php | 78 ++++++++++++++----------- plugins/TagSub/actions/tagsub.php | 28 +++++---- plugins/TagSub/actions/tagsubs.php | 91 +++++++++++++++++------------ plugins/TagSub/actions/tagunsub.php | 17 +++--- plugins/TagSub/classes/TagSub.php | 20 +++---- plugins/TagSub/forms/tagsub.php | 41 ++++++++----- plugins/TagSub/forms/tagunsub.php | 23 +++++--- plugins/TagSub/lib/tagsubmenu.php | 26 ++++----- plugins/TagSub/locale/TagSub.pot | 58 ++++++++---------- 14 files changed, 229 insertions(+), 182 deletions(-) diff --git a/lib/framework.php b/lib/framework.php index a7a3bac058..18fc84c2ff 100644 --- a/lib/framework.php +++ b/lib/framework.php @@ -32,7 +32,7 @@ defined('GNUSOCIAL') || die(); define('GNUSOCIAL_ENGINE', 'GNU 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_VERSION', GNUSOCIAL_BASE_VERSION . '-' . GNUSOCIAL_LIFECYCLE); diff --git a/lib/profilelistitem.php b/lib/profilelistitem.php index e0e2838f58..7f7a3bbd56 100644 --- a/lib/profilelistitem.php +++ b/lib/profilelistitem.php @@ -37,14 +37,18 @@ class ProfileListItem extends Widget /** Action object using us. */ var $action = null; - // FIXME: Directory plugin sends a User_group here, but should send a Profile and handle User_group specifics itself - function __construct($target, HTMLOutputter $action) + // FIXME: Directory plugin sends a User_group here, but should send a Profile and handle User_group specifics itself? + function __construct($target, HTMLOutputter $action, Profile $owner = null) { parent::__construct($action); $this->target = $target; - $this->profile = $this->target; - $this->action = $action; + if ($owner !== null) { + $this->profile = $owner; + } else { + $this->profile = $this->target; + } + $this->action = $action; } function getTarget() @@ -165,7 +169,7 @@ class ProfileListItem extends Widget { $user = common_current_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->show(); } else if ($user->getProfile()->canTag($this->profile)) { diff --git a/lib/subscriptionlist.php b/lib/subscriptionlist.php index cc12d7efe3..6f4d1a4a73 100644 --- a/lib/subscriptionlist.php +++ b/lib/subscriptionlist.php @@ -44,7 +44,7 @@ class SubscriptionList extends ProfileList /** Owner of this list */ var $owner = null; - public function __construct(Profile $profile, $owner=null, $action=null) + public function __construct($profile, $owner=null, $action=null) { parent::__construct($profile, $action); diff --git a/lib/subscriptionlistitem.php b/lib/subscriptionlistitem.php index e5f832af1e..5f5a770008 100644 --- a/lib/subscriptionlistitem.php +++ b/lib/subscriptionlistitem.php @@ -7,9 +7,14 @@ class SubscriptionListItem extends ProfileListItem /** Owner of this list */ 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; } diff --git a/locale/statusnet.pot b/locale/statusnet.pot index 6596093756..a6fa316ae2 100644 --- a/locale/statusnet.pot +++ b/locale/statusnet.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\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" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/plugins/TagSub/TagSubPlugin.php b/plugins/TagSub/TagSubPlugin.php index eaefa058f2..705ad2cc2c 100644 --- a/plugins/TagSub/TagSubPlugin.php +++ b/plugins/TagSub/TagSubPlugin.php @@ -44,16 +44,16 @@ if (!defined('STATUSNET')) { */ class TagSubPlugin extends Plugin { - const PLUGIN_VERSION = '0.1.0'; + const PLUGIN_VERSION = '0.1.1'; /** * Database schema setup * + * @return bool hook value; true means continue processing, false means stop. * @see Schema * - * @return boolean hook value; true means continue processing, false means stop. */ - function onCheckSchema() + public function onCheckSchema() { $schema = Schema::get(); $schema->ensureTable('tagsub', TagSub::schemaDef()); @@ -69,16 +69,22 @@ class TagSubPlugin extends Plugin */ public function onRouterInitialized(URLMapper $m) { - $m->connect('tag/:tag/subscribe', - array('action' => 'tagsub'), - array('tag' => Router::REGEX_TAG)); - $m->connect('tag/:tag/unsubscribe', - array('action' => 'tagunsub'), - array('tag' => Router::REGEX_TAG)); - - $m->connect(':nickname/tag-subscriptions', - array('action' => 'tagsubs'), - array('nickname' => Nickname::DISPLAY_FMT)); + $m->connect( + 'tag/:tag/subscribe', + array('action' => 'tagsub'), + array('tag' => Router::REGEX_TAG) + ); + $m->connect( + 'tag/:tag/unsubscribe', + array('action' => 'tagunsub'), + array('tag' => Router::REGEX_TAG) + ); + + $m->connect( + ':nickname/tag-subscriptions', + array('action' => 'tagsubs'), + array('nickname' => Nickname::DISPLAY_FMT) + ); return true; } @@ -87,17 +93,17 @@ class TagSubPlugin extends Plugin * * @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', - 'version' => self::PLUGIN_VERSION, - 'author' => 'Brion Vibber', - 'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/TagSub', - 'rawdescription' => - // TRANS: Plugin description. - _m('Plugin to allow following all messages with a given tag.')); + $versions[] = ['name' => 'TagSub', + 'version' => self::PLUGIN_VERSION, + 'author' => 'Brion Vibber', + 'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/TagSub', + 'rawdescription' => + // TRANS: Plugin description. + _m('Plugin to allow following all messages with a given tag.')]; return true; } @@ -113,7 +119,7 @@ class TagSubPlugin extends Plugin * @param array $ni in/out map of profile IDs to inbox constants * @return boolean hook result */ - function onStartNoticeWhoGets(Notice $notice, array &$ni) + public function onStartNoticeWhoGets(Notice $notice, array &$ni) { foreach ($notice->getTags() as $tag) { $tagsub = new TagSub(); @@ -133,13 +139,13 @@ class TagSubPlugin extends Plugin * @param TagAction $action * @return boolean hook result */ - function onStartTagShowContent(TagAction $action) + public function onStartTagShowContent(TagAction $action) { $user = common_current_user(); if ($user) { $tag = $action->trimmed('tag'); $tagsub = TagSub::pkeyGet(array('tag' => $tag, - 'profile_id' => $user->id)); + 'profile_id' => $user->id)); if ($tagsub) { $form = new TagUnsubForm($action, $tag); } else { @@ -162,28 +168,30 @@ class TagSubPlugin extends Plugin * @param Widget $widget Widget being executed * * @return boolean hook return + * @throws Exception */ - function onEndSubGroupNav($widget) + public function onEndSubGroupNav($widget) { $action = $widget->out; $action_name = $action->trimmed('action'); - $action->menuItem(common_local_url('tagsubs', array('nickname' => $action->user->nickname)), - // TRANS: SubMirror plugin menu item on user settings page. - _m('MENU', 'Tags'), - // TRANS: SubMirror plugin tooltip for user settings menu item. - _m('Configure tag subscriptions'), - $action_name == 'tagsubs' && $action->arg('nickname') == $action->user->nickname); + $action->menuItem( + common_local_url('tagsubs', array('nickname' => $action->user->nickname)), + // TRANS: SubMirror plugin menu item on user settings page. + _m('MENU', 'Tags'), + // TRANS: SubMirror plugin tooltip for user settings menu item. + _m('Configure tag subscriptions'), + $action_name == 'tagsubs' && $action->arg('nickname') == $action->user->nickname + ); return true; } - function onEndDefaultLocalNav($menu, $user) + public function onEndDefaultLocalNav($menu, $user) { - $user = common_current_user(); + $user = $user ? $user : common_current_user(); if (!empty($user)) { - $tags = TagSub::forProfile($user->getProfile()); if (!empty($tags) && count($tags) > 0) { diff --git a/plugins/TagSub/actions/tagsub.php b/plugins/TagSub/actions/tagsub.php index d3e359099d..4cd7b03ff2 100644 --- a/plugins/TagSub/actions/tagsub.php +++ b/plugins/TagSub/actions/tagsub.php @@ -53,8 +53,8 @@ if (!defined('STATUSNET')) { */ class TagsubAction extends Action { - var $user; - var $tag; + public $user; + public $tag; /** * Check pre-requisites and instantiate attributes @@ -62,8 +62,9 @@ class TagsubAction extends Action * @param Array $args array of arguments (URL, GET, POST) * * @return boolean success flag + * @throws ClientException */ - function prepare(array $args = array()) + public function prepare(array $args = array()) { parent::prepare($args); if ($this->boolean('ajax')) { @@ -84,8 +85,8 @@ class TagsubAction extends Action if (!$token || $token != common_session_token()) { // TRANS: Client error displayed when the session token is not okay. - $this->clientError(_m('There was a problem with your session token.'. - ' Try again, please.')); + $this->clientError(_m('There was a problem with your session token.' . + ' Try again, please.')); } // Only for logged-in users @@ -114,16 +115,17 @@ class TagsubAction extends Action * * Does the subscription and returns results. * - * @param Array $args unused. - * * @return void + * @throws ClientException */ - function handle() + public function handle() { // Throws exception on error - TagSub::start($this->user->getProfile(), - $this->tag); + TagSub::start( + $this->user->getProfile(), + $this->tag + ); if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); @@ -137,8 +139,10 @@ class TagsubAction extends Action $this->elementEnd('body'); $this->endHTML(); } else { - $url = common_local_url('tag', - array('tag' => $this->tag)); + $url = common_local_url( + 'tag', + array('tag' => $this->tag) + ); common_redirect($url, 303); } } diff --git a/plugins/TagSub/actions/tagsubs.php b/plugins/TagSub/actions/tagsubs.php index 2c56296a3e..a1d56a1c56 100644 --- a/plugins/TagSub/actions/tagsubs.php +++ b/plugins/TagSub/actions/tagsubs.php @@ -28,7 +28,9 @@ * @link http://status.net/ */ -if (!defined('GNUSOCIAL')) { exit(1); } +if (!defined('GNUSOCIAL')) { + exit(1); +} /** * A list of the user's subscriptions @@ -41,7 +43,7 @@ if (!defined('GNUSOCIAL')) { exit(1); } */ class TagSubsAction extends GalleryAction { - function title() + public function title() { if ($this->page == 1) { // TRANS: Header for subscriptions overview for a user (first page). @@ -50,35 +52,45 @@ class TagSubsAction extends GalleryAction } 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->getTarget()->getNickname(), - $this->page); + return sprintf( + _m('%1$s\'s tag subscriptions, page %2$d'), + $this->getTarget()->getNickname(), + $this->page + ); } } - function showPageNotice() + public function showPageNotice() { if ($this->scoped instanceof Profile && $this->scoped->sameAs($this->getTarget())) { - $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:')); + $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:') + ); } 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. - sprintf(_m('%s has subscribed to receive all notices on this site containing the following tags:'), - $this->getTarget()->getNickname())); + $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() + ) + ); } } - function showContent() + public function showContent() { if (Event::handle('StartShowTagSubscriptionsContent', array($this))) { parent::showContent(); - $offset = ($this->page-1) * PROFILES_PER_PAGE; - $limit = PROFILES_PER_PAGE + 1; + $offset = ($this->page - 1) * PROFILES_PER_PAGE; + $limit = PROFILES_PER_PAGE + 1; $cnt = 0; @@ -97,30 +109,33 @@ class TagSubsAction extends GalleryAction $this->showEmptyListMessage(); } - $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE, - $this->page, 'tagsubs', - array('nickname' => $this->getTarget()->getNickname())); + $this->pagination( + $this->page > 1, + $cnt > PROFILES_PER_PAGE, + $this->page, + 'tagsubs', + array('nickname' => $this->getTarget()->getNickname()) + ); Event::handle('EndShowTagSubscriptionsContent', array($this)); } } - function showEmptyListMessage() + public function showEmptyListMessage() { if (common_logged_in()) { if ($this->scoped->sameAs($this->getTarget())) { // 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 ' . - '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.'); + '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.'); } else { // 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. $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: as an anonymous user. %s is the user nickname. $message = sprintf(_m('%s is not following any tags.'), $this->getTarget()->getNickname()); @@ -136,7 +151,7 @@ class TagSubsAction extends GalleryAction class TagSubscriptionsList extends SubscriptionList { - function newListItem(Profile $tagsub) + public function newListItem($tagsub) { return new TagSubscriptionsListItem($tagsub, $this->owner, $this->action); } @@ -144,14 +159,14 @@ class TagSubscriptionsList extends SubscriptionList class TagSubscriptionsListItem extends SubscriptionListItem { - function startItem() + public function startItem() { $this->out->elementStart('li', array('class' => 'tagsub')); } - function showProfile() + public function showProfile() { - $tagsub = $this->profile; + $tagsub = $this->getTarget(); $tag = $tagsub->tag; // Relevant portion! @@ -163,10 +178,12 @@ class TagSubscriptionsListItem extends SubscriptionListItem $url = common_local_url('tag', array('tag' => $tag)); // TRANS: %1$s is a URL to a tag, %2$s is a tag, // TRANS: %3$s a date string. - $linkline = sprintf(_m('#%2$s since %3$s'), - htmlspecialchars($url), - htmlspecialchars($tag), - common_date_string($tagsub->created)); + $linkline = sprintf( + _m('#%2$s since %3$s'), + htmlspecialchars($url), + htmlspecialchars($tag), + common_date_string($tagsub->created) + ); $this->out->elementStart('div', 'tagsub-item'); $this->out->raw($linkline); @@ -174,15 +191,15 @@ class TagSubscriptionsListItem extends SubscriptionListItem $this->out->elementEnd('div'); } - function showActions() + public function showActions() { } - function showOwnerControls() + public function showOwnerControls() { $this->out->elementStart('div', 'entity_actions'); - $tagsub = $this->profile; // ? + $tagsub = $this->target; $form = new TagUnsubForm($this->out, $tagsub->tag); $form->show(); diff --git a/plugins/TagSub/actions/tagunsub.php b/plugins/TagSub/actions/tagunsub.php index 4e04a55b95..3e92f9ffe6 100644 --- a/plugins/TagSub/actions/tagunsub.php +++ b/plugins/TagSub/actions/tagunsub.php @@ -58,16 +58,17 @@ class TagunsubAction extends TagsubAction * * Does the subscription and returns results. * - * @param Array $args unused. - * * @return void + * @throws ClientException */ - function handle() + public function handle() { // Throws exception on error - TagSub::cancel($this->user->getProfile(), - $this->tag); + TagSub::cancel( + $this->user->getProfile(), + $this->tag + ); if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); @@ -81,8 +82,10 @@ class TagunsubAction extends TagsubAction $this->elementEnd('body'); $this->endHTML(); } else { - $url = common_local_url('tag', - array('tag' => $this->tag)); + $url = common_local_url( + 'tag', + array('tag' => $this->tag) + ); common_redirect($url, 303); } } diff --git a/plugins/TagSub/classes/TagSub.php b/plugins/TagSub/classes/TagSub.php index 5bc0c436ee..18023ac654 100644 --- a/plugins/TagSub/classes/TagSub.php +++ b/plugins/TagSub/classes/TagSub.php @@ -79,7 +79,7 @@ class TagSub extends Managed_DataObject * @param string $tag subscribee * @return TagSub */ - static function start(Profile $profile, $tag) + public static function start(Profile $profile, $tag) { $ts = new TagSub(); $ts->tag = $tag; @@ -96,35 +96,35 @@ class TagSub extends Managed_DataObject * @param profile $profile subscriber * @param string $tag subscribee */ - static function cancel(Profile $profile, $tag) + public static function cancel(Profile $profile, $tag) { $ts = TagSub::pkeyGet(array('tag' => $tag, - 'profile_id' => $profile->id)); + 'profile_id' => $profile->id)); if ($ts) { $ts->delete(); self::blow('tagsub:by_profile:%d', $profile->id); } } - static function forProfile(Profile $profile) + public static function forProfile(Profile $profile) { $tags = array(); $keypart = sprintf('tagsub:by_profile:%d', $profile->id); $tagstring = self::cacheGet($keypart); - + if ($tagstring !== false) { // cache hit - if (!empty($tagstring)) { - $tags = explode(',', $tagstring); - } + if (!empty($tagstring)) { + $tags = explode(',', $tagstring); + } } else { - $tagsub = new TagSub(); + $tagsub = new TagSub(); $tagsub->profile_id = $profile->id; $tagsub->selectAdd(); $tagsub->selectAdd('tag'); if ($tagsub->find()) { - $tags = $tagsub->fetchAll('tag'); + $tags = $tagsub->fetchAll('tag'); } self::cacheSet($keypart, implode(',', $tags)); diff --git a/plugins/TagSub/forms/tagsub.php b/plugins/TagSub/forms/tagsub.php index 22eed25801..9d193cbd8a 100644 --- a/plugins/TagSub/forms/tagsub.php +++ b/plugins/TagSub/forms/tagsub.php @@ -51,15 +51,15 @@ class TagSubForm extends Form /** * Name of tag to subscribe to */ - var $tag = ''; + public $tag = ''; /** * Constructor * - * @param HTMLOutputter $out output channel - * @param string $tag name of tag to subscribe to + * @param HTMLOutputter $out output channel + * @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); @@ -71,7 +71,7 @@ class TagSubForm extends Form * * @return int ID of the form */ - function id() + public function id() { return 'tag-subscribe-' . $this->tag; } @@ -81,7 +81,7 @@ class TagSubForm extends Form * * @return string of the form class */ - function formClass() + public function formClass() { // class to match existing styles... return 'form_user_subscribe ajax'; @@ -92,7 +92,7 @@ class TagSubForm extends Form * * @return string URL of the action */ - function action() + public function action() { return common_local_url('tagsub', array('tag' => $this->tag)); } @@ -101,8 +101,9 @@ class TagSubForm extends Form * Legend of the Form * * @return void + * @throws Exception */ - function formLegend() + public function formLegend() { // TRANS: Form legend. $this->out->element('legend', null, _m('Subscribe to this tag')); @@ -113,23 +114,31 @@ class TagSubForm extends Form * * @return void */ - function formData() + public function formData() { - $this->out->hidden('subscribeto-' . $this->tag, - $this->tag, - 'subscribeto'); + $this->out->hidden( + 'subscribeto-' . $this->tag, + $this->tag, + 'subscribeto' + ); } /** * Action elements * * @return void + * @throws Exception */ - function formActions() + public function formActions() { // TRANS: Submit button text to subscribe to a tag. - $this->out->submit('submit', _m('BUTTON','Subscribe'), - // TRANS: Submit button title to subscribe to a tag. - 'submit', null, _m('Subscribe to this tag.')); + $this->out->submit( + 'submit', + _m('BUTTON', 'Subscribe'), + // TRANS: Submit button title to subscribe to a tag. + 'submit', + null, + _m('Subscribe to this tag.') + ); } } diff --git a/plugins/TagSub/forms/tagunsub.php b/plugins/TagSub/forms/tagunsub.php index 6bec4b0ce1..95bdcd8fc2 100644 --- a/plugins/TagSub/forms/tagunsub.php +++ b/plugins/TagSub/forms/tagunsub.php @@ -53,7 +53,7 @@ class TagUnsubForm extends TagSubForm * * @return int ID of the form */ - function id() + public function id() { return 'tag-unsubscribe-' . $this->tag; } @@ -63,7 +63,7 @@ class TagUnsubForm extends TagSubForm * * @return string of the form class */ - function formClass() + public function formClass() { // class to match existing styles... return 'form_user_unsubscribe ajax'; @@ -74,7 +74,7 @@ class TagUnsubForm extends TagSubForm * * @return string URL of the action */ - function action() + public function action() { return common_local_url('tagunsub', array('tag' => $this->tag)); } @@ -83,8 +83,9 @@ class TagUnsubForm extends TagSubForm * Legend of the Form * * @return void + * @throws Exception */ - function formLegend() + public function formLegend() { // TRANS: Form legend. $this->out->element('legend', null, _m('Unsubscribe from this tag')); @@ -94,12 +95,18 @@ class TagUnsubForm extends TagSubForm * Action elements * * @return void + * @throws Exception */ - function formActions() + public function formActions() { // TRANS: Submit button text to unsubscribe from a tag. - $this->out->submit('submit', _m('BUTTON','Unsubscribe'), - // TRANS: Submit button title to unsubscribe from a tag. - 'submit', null, _m('Unsubscribe from this tag.')); + $this->out->submit( + 'submit', + _m('BUTTON', 'Unsubscribe'), + // TRANS: Submit button title to unsubscribe from a tag. + 'submit', + null, + _m('Unsubscribe from this tag.') + ); } } diff --git a/plugins/TagSub/lib/tagsubmenu.php b/plugins/TagSub/lib/tagsubmenu.php index 01fa372dd9..1472e78f77 100644 --- a/plugins/TagSub/lib/tagsubmenu.php +++ b/plugins/TagSub/lib/tagsubmenu.php @@ -49,40 +49,40 @@ class TagSubMenu extends MoreMenu protected $user; protected $tags; - function __construct($out, $user, $tags) + public function __construct($out, $user, $tags) { parent::__construct($out); $this->user = $user; $this->tags = $tags; } - function getItems() + public function getItems() { $items = array(); - + foreach ($this->tags as $tag) { if (!empty($tag)) { $items[] = array('tag', - array('tag' => $tag), - sprintf('#%s', $tag), - // TRANS: Menu item title. %s is a tag. - sprintf(_('Notices tagged with "%s".'), $tag)); + array('tag' => $tag), + sprintf('#%s', $tag), + // TRANS: Menu item title. %s is a tag. + sprintf(_('Notices tagged with "%s".'), $tag)); } } return $items; } - function tag() + public function tag() { return 'tagsubs'; } - - function seeAllItem() + + public function seeAllItem() { return array('tagsubs', - array('nickname' => $this->user->nickname), - _('See all'), - _('See all tags you are following')); + array('nickname' => $this->user->nickname), + _('See all'), + _('See all tags you are following')); } } diff --git a/plugins/TagSub/locale/TagSub.pot b/plugins/TagSub/locale/TagSub.pot index a659eea5bf..eb0998350a 100644 --- a/plugins/TagSub/locale/TagSub.pot +++ b/plugins/TagSub/locale/TagSub.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\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" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -19,29 +19,25 @@ msgstr "" #. TRANS: Header for subscriptions overview for a user (first page). #. TRANS: %s is a user nickname. -#: actions/tagsubs.php:49 +#: actions/tagsubs.php:51 #, php-format msgid "%s's tag subscriptions" msgstr "" -#. TRANS: Header for subscriptions overview for a user (not first page). -#. TRANS: %1$s is a user nickname, %2$d is the page number. -#: actions/tagsubs.php:53 +#: actions/tagsubs.php:56 #, php-format msgid "%1$s's tag subscriptions, page %2$d" msgstr "" #. TRANS: Page notice for page with an overview of all tag subscriptions #. TRANS: of the logged in user's own profile. -#: actions/tagsubs.php:65 +#: actions/tagsubs.php:71 msgid "" "You have subscribed to receive all notices on this site containing the " "following tags:" msgstr "" -#. 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. -#: actions/tagsubs.php:70 +#: actions/tagsubs.php:80 #, php-format msgid "" "%s has subscribed to receive all notices on this site containing the " @@ -49,7 +45,7 @@ msgid "" msgstr "" #. TRANS: Tag subscription list text when the logged in user has no tag subscriptions. -#: actions/tagsubs.php:114 +#: actions/tagsubs.php:130 msgid "" "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 " @@ -61,98 +57,92 @@ msgstr "" #. 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: 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 msgid "%s is not following any tags." msgstr "" -#. TRANS: %1$s is a URL to a tag, %2$s is a tag, -#. TRANS: %3$s a date string. -#: actions/tagsubs.php:166 +#: actions/tagsubs.php:182 #, php-format msgid "#%2$s since %3$s" msgstr "" #. TRANS: Client error displayed trying to perform any request method other than POST. #. TRANS: Do not translate POST. -#: actions/tagsub.php:78 +#: actions/tagsub.php:79 msgid "This action only accepts POST requests." msgstr "" #. 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." msgstr "" #. 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." msgstr "" #. TRANS: Client error displayed trying to subscribe to a non-existing profile. -#: actions/tagsub.php:106 +#: actions/tagsub.php:107 msgid "No such profile." msgstr "" #. TRANS: Page title when tag subscription succeeded. -#: actions/tagsub.php:132 +#: actions/tagsub.php:134 msgid "Subscribed" msgstr "" #. TRANS: Page title when tag unsubscription succeeded. -#: actions/tagunsub.php:76 +#: actions/tagunsub.php:77 msgid "Unsubscribed" msgstr "" #. TRANS: Plugin description. -#: TagSubPlugin.php:100 +#: TagSubPlugin.php:106 msgid "Plugin to allow following all messages with a given tag." msgstr "" #. TRANS: SubMirror plugin menu item on user settings page. -#: TagSubPlugin.php:173 +#: TagSubPlugin.php:181 msgctxt "MENU" msgid "Tags" msgstr "" #. TRANS: SubMirror plugin tooltip for user settings menu item. -#: TagSubPlugin.php:175 +#: TagSubPlugin.php:183 msgid "Configure tag subscriptions" msgstr "" #. TRANS: Menu item text for tags submenu. -#: TagSubPlugin.php:192 +#: TagSubPlugin.php:200 msgid "Tags" msgstr "" #. TRANS: Form legend. -#: forms/tagsub.php:108 +#: forms/tagsub.php:109 msgid "Subscribe to this tag" msgstr "" -#. TRANS: Submit button text to subscribe to a tag. -#: forms/tagsub.php:131 +#: forms/tagsub.php:137 msgctxt "BUTTON" msgid "Subscribe" msgstr "" -#. TRANS: Submit button title to subscribe to a tag. -#: forms/tagsub.php:133 +#: forms/tagsub.php:141 msgid "Subscribe to this tag." msgstr "" #. TRANS: Form legend. -#: forms/tagunsub.php:90 +#: forms/tagunsub.php:91 msgid "Unsubscribe from this tag" msgstr "" -#. TRANS: Submit button text to unsubscribe from a tag. -#: forms/tagunsub.php:101 +#: forms/tagunsub.php:105 msgctxt "BUTTON" msgid "Unsubscribe" msgstr "" -#. TRANS: Submit button title to unsubscribe from a tag. -#: forms/tagunsub.php:103 +#: forms/tagunsub.php:109 msgid "Unsubscribe from this tag." msgstr "" -- 2.39.5