123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- <?php
- if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
- }
- class SubscriptionsAction extends GalleryAction
- {
- function title()
- {
- if ($this->page == 1) {
-
-
- return sprintf(_('%s subscriptions'), $this->target->getNickname());
- } else {
-
-
- return sprintf(_('%1$s subscriptions, page %2$d'),
- $this->target->getNickname(),
- $this->page);
- }
- }
- function showPageNotice()
- {
- if ($this->scoped instanceof Profile && $this->scoped->id === $this->target->id) {
- $this->element('p', null,
-
-
- _('These are the people whose notices '.
- 'you listen to.'));
- } else {
- $this->element('p', null,
-
-
- sprintf(_('These are the people whose '.
- 'notices %s listens to.'),
- $this->target->getNickname()));
- }
- }
- function getAllTags()
- {
- return $this->getTags('subscribed', 'subscriber');
- }
- function showContent()
- {
- if (Event::handle('StartShowSubscriptionsContent', array($this))) {
- parent::showContent();
- $offset = ($this->page-1) * PROFILES_PER_PAGE;
- $limit = PROFILES_PER_PAGE + 1;
- $cnt = 0;
- if ($this->tag) {
- $subscriptions = $this->target->getTaggedSubscriptions($this->tag, $offset, $limit);
- } else {
- $subscriptions = $this->target->getSubscribed($offset, $limit);
- }
- if ($subscriptions) {
- $subscriptions_list = new SubscriptionsList($subscriptions, $this->target, $this);
- $cnt = $subscriptions_list->show();
- if (0 == $cnt) {
- $this->showEmptyListMessage();
- }
- }
- $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
- $this->page, 'subscriptions',
- array('nickname' => $this->target->getNickname()));
- Event::handle('EndShowSubscriptionsContent', array($this));
- }
- }
- function showScripts()
- {
- parent::showScripts();
- $this->autofocus('tag');
- }
- function showEmptyListMessage()
- {
- if ($this->scoped instanceof Profile && $this->target->id === $this->scoped->id) {
-
-
-
-
- $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%%).');
- } else {
-
-
- $message = sprintf(_('%s is not listening to anyone.'), $this->target->getNickname());
- }
- $this->elementStart('div', 'guide');
- $this->raw(common_markup_to_html($message));
- $this->elementEnd('div');
- }
-
- function getFeeds()
- {
- return array(new Feed(Feed::ATOM,
- common_local_url('AtomPubSubscriptionFeed',
- array('subscriber' => $this->target->id)),
-
- sprintf(_('Subscription feed for %s (Atom)'),
- $this->target->getNickname())));
- }
- }
- class SubscriptionsList extends SubscriptionList
- {
- function newListItem($profile)
- {
- return new SubscriptionsListItem($profile, $this->owner, $this->action);
- }
- }
- class SubscriptionsListItem extends SubscriptionListItem
- {
- function showOwnerControls()
- {
- $sub = Subscription::pkeyGet(array('subscriber' => $this->owner->id,
- 'subscribed' => $this->profile->id));
- if (!$sub) {
- return;
- }
- $transports = array();
- Event::handle('GetImTransports', array(&$transports));
- if (!$transports && !common_config('sms', 'enabled')) {
- return;
- }
- $this->out->elementStart('form', array('id' => 'subedit-' . $this->profile->id,
- 'method' => 'post',
- 'class' => 'form_subscription_edit',
- 'action' => common_local_url('subedit')));
- $this->out->hidden('token', common_session_token());
- $this->out->hidden('profile', $this->profile->id);
- if ($transports) {
- $attrs = array('name' => 'jabber',
- 'type' => 'checkbox',
- 'class' => 'checkbox',
- 'id' => 'jabber-'.$this->profile->id);
- if ($sub->jabber) {
- $attrs['checked'] = 'checked';
- }
- $this->out->element('input', $attrs);
-
- $this->out->element('label', array('for' => 'jabber-'.$this->profile->id), _m('LABEL','IM'));
- } else {
- $this->out->hidden('jabber', $sub->jabber);
- }
- if (common_config('sms', 'enabled')) {
- $attrs = array('name' => 'sms',
- 'type' => 'checkbox',
- 'class' => 'checkbox',
- 'id' => 'sms-'.$this->profile->id);
- if ($sub->sms) {
- $attrs['checked'] = 'checked';
- }
- $this->out->element('input', $attrs);
-
- $this->out->element('label', array('for' => 'sms-'.$this->profile->id), _('SMS'));
- } else {
- $this->out->hidden('sms', $sub->sms);
- }
-
- $this->out->submit('save', _m('BUTTON','Save'));
- $this->out->elementEnd('form');
- }
- }
|