123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class SortableSubscriptionList extends SubscriptionList
- {
- function startList()
- {
- $this->out->elementStart('table', array('class' => 'profile_list xoxo'));
- $this->out->elementStart('thead');
- $this->out->elementStart('tr');
- $tableHeaders = array(
-
- 'nickname' => _m('Nickname'),
-
- 'created' => _m('Created')
- );
- foreach ($tableHeaders as $id => $label) {
- $attrs = array('id' => $id);
- $current = (!empty($this->action->sort) && $this->action->sort == $id);
- if ($current || empty($this->action->sort) && $id == 'nickname') {
- $attrs['class'] = 'current';
- }
- if ($current && $this->action->reverse) {
- $attrs['class'] .= ' reverse';
- $attrs['class'] = trim($attrs['class']);
- }
- $this->out->elementStart('th', $attrs);
- $linkAttrs = array();
- $params = array('sort' => $id);
- if (!empty($this->action->q)) {
- $params['q'] = $this->action->q;
- }
- if ($current && !$this->action->reverse) {
- $params['reverse'] = 'true';
- }
- $args = array();
- $filter = $this->action->arg('filter');
- if (!empty($filter)) {
- $args['filter'] = $filter;
- }
- $linkAttrs['href'] = common_local_url(
- $this->action->arg('action'), $args, $params
- );
- $this->out->element('a', $linkAttrs, $label);
- $this->out->elementEnd('th');
- }
-
- $this->out->element('th', array('id' => 'subscriptions'), _m('Subscriptions'));
-
- $this->out->element('th', array('id' => 'notices'), _m('Notices'));
- $this->out->element('th', array('id' => 'controls'));
- $this->out->elementEnd('tr');
- $this->out->elementEnd('thead');
- $this->out->elementStart('tbody');
- }
- function endList()
- {
- $this->out->elementEnd('tbody');
- $this->out->elementEnd('table');
- }
- function newListItem(Profile $profile)
- {
- return new SortableSubscriptionListItem($profile, $this->owner, $this->action);
- }
- }
- class SortableSubscriptionListItem extends SubscriptionListItem
- {
- function startItem()
- {
- $attr = array(
- 'class' => 'profile',
- 'id' => 'profile-' . $this->profile->id
- );
- $this->out->elementStart('tr', $attr);
- }
- function endItem()
- {
- $this->out->elementEnd('tr');
- }
- function startProfile()
- {
- $this->out->elementStart('td', 'entity_profile h-card');
- }
- function endProfile()
- {
- $this->out->elementEnd('td');
- }
- function startActions()
- {
- $this->out->elementStart('td', 'entity_actions');
- $this->out->elementStart('ul');
- }
- function endActions()
- {
-
-
- $cur = common_current_user();
- list($action, $r2args) = $this->out->returnToArgs();
- $r2args['action'] = $action;
- if ($cur instanceof User && $cur->hasRight(Right::DELETEUSER)) {
- $this->out->elementStart('li', 'entity_delete');
- $df = new DeleteUserForm($this->out, $this->profile, $r2args);
- $df->show();
- $this->out->elementEnd('li');
- }
-
- $this->out->elementEnd('ul');
- $this->out->elementEnd('td');
- }
- function show()
- {
- if (Event::handle('StartProfileListItem', array($this))) {
- $this->startItem();
- if (Event::handle('StartProfileListItemProfile', array($this))) {
- $this->showProfile();
- Event::handle('EndProfileListItemProfile', array($this));
- }
-
- $this->showCreatedDate();
- $this->showSubscriberCount();
- $this->showNoticeCount();
- if (Event::handle('StartProfileListItemActions', array($this))) {
- $this->showActions();
- Event::handle('EndProfileListItemActions', array($this));
- }
- $this->endItem();
- Event::handle('EndProfileListItem', array($this));
- }
- }
- function showSubscriberCount()
- {
- $this->out->elementStart('td', 'entry_subscriber_count');
- $this->out->text($this->profile->subscriberCount());
- $this->out->elementEnd('td');
- }
- function showCreatedDate()
- {
- $this->out->elementStart('td', 'entry_created');
- $this->out->text(date('j M Y', strtotime($this->profile->created)));
- $this->out->elementEnd('td');
- }
- function showNoticeCount()
- {
- $this->out->elementStart('td', 'entry_notice_count');
- $this->out->text($this->profile->noticeCount());
- $this->out->elementEnd('td');
- }
- function showBio()
- {
- if ($this->profile->getDescription()) {
- $this->out->elementStart('p', 'note');
- $this->out->text($this->profile->getDescription());
- $this->out->elementEnd('p');
- }
- }
-
- function showTags()
- {
- if (common_logged_in()) {
- parent::showTags();
- }
- }
- }
|