Tag subscriptions management UI for TagSub plugin

This commit is contained in:
Brion Vibber 2011-03-16 15:55:40 -07:00
parent 09a4cebd47
commit f8859aa3aa
2 changed files with 47 additions and 25 deletions

View File

@ -78,6 +78,7 @@ class TagSubPlugin extends Plugin
return false; return false;
case 'TagsubAction': case 'TagsubAction':
case 'TagunsubAction': case 'TagunsubAction':
case 'TagsubsAction':
case 'TagSubForm': case 'TagSubForm':
case 'TagUnsubForm': case 'TagUnsubForm':
include_once $dir.'/'.strtolower($cls).'.php'; include_once $dir.'/'.strtolower($cls).'.php';
@ -196,12 +197,12 @@ class TagSubPlugin extends Plugin
$action = $widget->out; $action = $widget->out;
$action_name = $action->trimmed('action'); $action_name = $action->trimmed('action');
$widget->item('tagsubs', $action->menuItem(common_local_url('tagsubs', array('nickname' => $action->user->nickname)),
array(), // TRANS: SubMirror plugin menu item on user settings page.
// TRANS: SubMirror plugin menu item on user settings page. _m('MENU', 'Tags'),
_m('MENU', 'Tags'), // TRANS: SubMirror plugin tooltip for user settings menu item.
// TRANS: SubMirror plugin tooltip for user settings menu item. _m('Configure tag subscriptions'),
_m('Configure tag subscriptions')); $action_name == 'tagsubs' && $action->arg('nickname') == $action->user->nickname);
return true; return true;
} }
@ -222,7 +223,7 @@ class TagSubPlugin extends Plugin
$entry = array( $entry = array(
'id' => 'tagsubs', 'id' => 'tagsubs',
'label' => _m('Tag subscriptions'), 'label' => _m('Tag subscriptions'),
'link' => common_local_url('tagsubs'), 'link' => common_local_url('tagsubs', array('nickname' => $profile->nickname)),
'value' => $tagsub->count(), 'value' => $tagsub->count(),
); );

View File

@ -65,12 +65,12 @@ class TagSubsAction extends GalleryAction
$this->element('p', null, $this->element('p', null,
// 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.
_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 { } else {
$this->element('p', null, $this->element('p', null,
// TRANS: Page notice for page with an overview of all subscriptions of a user other // 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. // 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)); $this->profile->nickname));
} }
} }
@ -87,8 +87,7 @@ class TagSubsAction extends GalleryAction
$tagsub = new TagSub(); $tagsub = new TagSub();
$tagsub->profile_id = $this->user->id; $tagsub->profile_id = $this->user->id;
$tagsub->limit($limit); $tagsub->limit($limit, $offset);
$tagsub->offset($offset);
$tagsub->find(); $tagsub->find();
if ($tagsub->N) { if ($tagsub->N) {
@ -97,6 +96,8 @@ class TagSubsAction extends GalleryAction
if (0 == $cnt) { if (0 == $cnt) {
$this->showEmptyListMessage(); $this->showEmptyListMessage();
} }
} else {
$this->showEmptyListMessage();
} }
$this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE, $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
@ -113,18 +114,13 @@ class TagSubsAction extends GalleryAction
if (common_logged_in()) { if (common_logged_in()) {
$current_user = common_current_user(); $current_user = common_current_user();
if ($this->user->id === $current_user->id) { if ($this->user->id === $current_user->id) {
// TRANS: Subscription list text when the logged in user has no subscriptions. // TRANS: Tag subscription list text when the logged in user has no tag subscriptions.
// TRANS: This message contains Markdown URLs. The link description is between $message = _('You\'re not listening to any hash tags right now. You can push the "Subscribe" button ' .
// TRANS: square brackets, and the link between parentheses. Do not separate "](" 'on any hashtag page to automatically receive any public messages on this site that use that ' .
// TRANS: and do not change the URL part. 'tag, even if you\'re not subscribed to the poster.');
$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.');
} else { } else {
// TRANS: 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 subscriptions. %s is the user nickname. // 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); $message = sprintf(_('%s is not listening to any tags.'), $this->user->nickname);
} }
} }
@ -152,22 +148,47 @@ class TagSubscriptionsList extends SubscriptionList
class TagSubscriptionsListItem extends SubscriptionListItem class TagSubscriptionsListItem extends SubscriptionListItem
{ {
function startItem()
{
$this->out->elementStart('li', array('class' => 'tagsub'));
}
function showProfile() function showProfile()
{ {
$this->startProfile(); $tagsub = $this->profile;
$tag = $tagsub->tag;
// Relevant portion! // Relevant portion!
$cur = common_current_user(); $cur = common_current_user();
if (!empty($cur) && $cur->id == $this->owner->id) { if (!empty($cur) && $cur->id == $this->owner->id) {
$this->showOwnerControls(); $this->showOwnerControls();
} }
$this->endProfile();
$url = common_local_url('tag', array('tag' => $tag));
$linkline = sprintf(_m('#<a href="%s">%s</a> 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() function showOwnerControls()
{ {
$this->out->elementStart('div', 'entity_actions');
$tagsub = $this->profile; // ? $tagsub = $this->profile; // ?
$form = new TagSubForm($this->out, $tagsub->tag); $form = new TagUnsubForm($this->out, $tagsub->tag);
$form->show(); $form->show();
$this->out->elementEnd('div');
return; return;
} }
} }