From f8859aa3aa30bc5f9cce62675cf4a94e9c8a3dad Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 16 Mar 2011 15:55:40 -0700 Subject: [PATCH] Tag subscriptions management UI for TagSub plugin --- plugins/TagSub/TagSubPlugin.php | 15 +++++---- plugins/TagSub/tagsubsaction.php | 57 ++++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 25 deletions(-) diff --git a/plugins/TagSub/TagSubPlugin.php b/plugins/TagSub/TagSubPlugin.php index ff6c038bc3..53a06ab5bf 100644 --- a/plugins/TagSub/TagSubPlugin.php +++ b/plugins/TagSub/TagSubPlugin.php @@ -78,6 +78,7 @@ class TagSubPlugin extends Plugin return false; case 'TagsubAction': case 'TagunsubAction': + case 'TagsubsAction': case 'TagSubForm': case 'TagUnsubForm': include_once $dir.'/'.strtolower($cls).'.php'; @@ -196,12 +197,12 @@ class TagSubPlugin extends Plugin $action = $widget->out; $action_name = $action->trimmed('action'); - $widget->item('tagsubs', - array(), - // 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->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; } @@ -222,7 +223,7 @@ class TagSubPlugin extends Plugin $entry = array( 'id' => 'tagsubs', 'label' => _m('Tag subscriptions'), - 'link' => common_local_url('tagsubs'), + 'link' => common_local_url('tagsubs', array('nickname' => $profile->nickname)), 'value' => $tagsub->count(), ); diff --git a/plugins/TagSub/tagsubsaction.php b/plugins/TagSub/tagsubsaction.php index 78156fa7b0..f11935229b 100644 --- a/plugins/TagSub/tagsubsaction.php +++ b/plugins/TagSub/tagsubsaction.php @@ -65,12 +65,12 @@ class TagSubsAction extends GalleryAction $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.')); + _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.'), + sprintf(_m('%s has subscribed to receive all notices on this site containing the following tags:'), $this->profile->nickname)); } } @@ -87,8 +87,7 @@ class TagSubsAction extends GalleryAction $tagsub = new TagSub(); $tagsub->profile_id = $this->user->id; - $tagsub->limit($limit); - $tagsub->offset($offset); + $tagsub->limit($limit, $offset); $tagsub->find(); if ($tagsub->N) { @@ -97,6 +96,8 @@ class TagSubsAction extends GalleryAction if (0 == $cnt) { $this->showEmptyListMessage(); } + } else { + $this->showEmptyListMessage(); } $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE, @@ -113,18 +114,13 @@ class TagSubsAction extends GalleryAction if (common_logged_in()) { $current_user = common_current_user(); if ($this->user->id === $current_user->id) { - // TRANS: Subscription list text when the logged in user has no subscriptions. - // TRANS: This message contains Markdown URLs. The link description is between - // TRANS: square brackets, and the link between parentheses. Do not separate "](" - // TRANS: and do not change the URL part. - $message = _('You\'re not listening to anyone\'s notices right now, try subscribing to people you know. '. - 'Try [people search](%%action.peoplesearch%%), look for members in groups you\'re interested '. - 'in and in our [featured users](%%action.featured%%). '. - 'If you\'re a [Twitter user](%%action.twittersettings%%), you can automatically subscribe to '. - 'people you already follow there.'); + // TRANS: Tag subscription list text when the logged in user has no tag subscriptions. + $message = _('You\'re 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\'re not subscribed to the poster.'); } else { - // TRANS: Subscription list text when looking at the subscriptions for a of a user other - // TRANS: than the logged in user that has no subscriptions. %s is the user nickname. + // 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(_('%s is not listening to any tags.'), $this->user->nickname); } } @@ -152,22 +148,47 @@ class TagSubscriptionsList extends SubscriptionList class TagSubscriptionsListItem extends SubscriptionListItem { + function startItem() + { + $this->out->elementStart('li', array('class' => 'tagsub')); + } + function showProfile() { - $this->startProfile(); + $tagsub = $this->profile; + $tag = $tagsub->tag; + // Relevant portion! $cur = common_current_user(); if (!empty($cur) && $cur->id == $this->owner->id) { $this->showOwnerControls(); } - $this->endProfile(); + + $url = common_local_url('tag', array('tag' => $tag)); + $linkline = sprintf(_m('#%s since %s'), + 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() + { } function showOwnerControls() { + $this->out->elementStart('div', 'entity_actions'); + $tagsub = $this->profile; // ? - $form = new TagSubForm($this->out, $tagsub->tag); + $form = new TagUnsubForm($this->out, $tagsub->tag); $form->show(); + + $this->out->elementEnd('div'); return; } } -- 2.39.5