123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- <?php
- if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
- }
- class SearchSubsAction extends GalleryAction
- {
- function title()
- {
- if ($this->page == 1) {
-
-
- return sprintf(_m('%s\'s search subscriptions'), $this->user->nickname);
- } else {
-
-
- return sprintf(_m('%1$s\'s search subscriptions, page %2$d'),
- $this->user->nickname,
- $this->page);
- }
- }
- function showPageNotice()
- {
- $user = common_current_user();
- if ($user && ($user->id == $this->profile->id)) {
- $this->element('p', null,
-
-
- _m('You have subscribed to receive all notices on this site matching the following searches:'));
- } else {
- $this->element('p', null,
-
-
- sprintf(_m('%s has subscribed to receive all notices on this site matching the following searches:'),
- $this->profile->nickname));
- }
- }
- function showContent()
- {
- if (Event::handle('StartShowTagSubscriptionsContent', array($this))) {
- parent::showContent();
- $offset = ($this->page-1) * PROFILES_PER_PAGE;
- $limit = PROFILES_PER_PAGE + 1;
- $cnt = 0;
- $searchsub = new SearchSub();
- $searchsub->profile_id = $this->user->id;
- $searchsub->limit($limit, $offset);
- $searchsub->find();
- if ($searchsub->N) {
- $list = new SearchSubscriptionsList($searchsub, $this->user, $this);
- $cnt = $list->show();
- if (0 == $cnt) {
- $this->showEmptyListMessage();
- }
- } else {
- $this->showEmptyListMessage();
- }
- $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
- $this->page, 'searchsubs',
- array('nickname' => $this->user->nickname));
- Event::handle('EndShowTagSubscriptionsContent', array($this));
- }
- }
- function showEmptyListMessage()
- {
- if (common_logged_in()) {
- $current_user = common_current_user();
- if ($this->user->id === $current_user->id) {
-
- $message = _m('You are not subscribed to any text searches right now. You can push the "Subscribe" button ' .
- 'on any notice text search to automatically receive any public messages on this site that match that ' .
- 'search, even if you are not subscribed to the poster.');
- } else {
-
-
- $message = sprintf(_m('%s is not subscribed to any searches.'), $this->user->nickname);
- }
- }
- else {
-
-
- $message = sprintf(_m('%s is not subscribed to any searches.'), $this->user->nickname);
- }
- $this->elementStart('div', 'guide');
- $this->raw(common_markup_to_html($message));
- $this->elementEnd('div');
- }
- }
- class SearchSubscriptionsList extends SubscriptionList
- {
- function newListItem($searchsub)
- {
- return new SearchSubscriptionsListItem($searchsub, $this->owner, $this->action);
- }
- }
- class SearchSubscriptionsListItem extends SubscriptionListItem
- {
- function startItem()
- {
- $this->out->elementStart('li', array('class' => 'searchsub'));
- }
- function showProfile()
- {
- $searchsub = $this->profile;
- $search = $searchsub->search;
-
- $cur = common_current_user();
- if (!empty($cur) && $cur->id == $this->owner->id) {
- $this->showOwnerControls();
- }
- $url = common_local_url('noticesearch', array('q' => $search));
-
-
- $linkline = sprintf(_m('"<a href="%1$s">%2$s</a>" since %3$s'),
- htmlspecialchars($url),
- htmlspecialchars($search),
- common_date_string($searchsub->created));
- $this->out->elementStart('div', 'searchsub-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');
- $searchsub = $this->profile;
- $form = new SearchUnsubForm($this->out, $searchsub->search);
- $form->show();
- $this->out->elementEnd('div');
- return;
- }
- }
|