4 * StatusNet, the distributed open-source microblogging tool
6 * Widget to show a sortable list of profiles
10 * LICENCE: This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Affero General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Affero General Public License for more details.
20 * You should have received a copy of the GNU Affero General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * @author Zach Copley <zach@status.net>
26 * @copyright 2011 StatusNet, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28 * @link http://status.net/
31 if (!defined('STATUSNET')) {
35 require_once INSTALLDIR . '/lib/subscriptionlist.php';
38 * Widget to show a sortable list of subscriptions
42 * @author Zach Copley <zach@status.net>
43 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
44 * @link http://status.net/
47 class SortableGroupList extends SortableSubscriptionList
49 /** Owner of this list */
52 function __construct($profile, $owner=null, $action=null)
54 parent::__construct($profile, $owner, $action);
56 $this->owner = $owner;
61 $this->out->elementStart('table', array('class' => 'profile_list xoxo'));
62 $this->out->elementStart('thead');
63 $this->out->elementStart('tr');
65 $tableHeaders = array(
66 'nickname' => _m('Nickname'),
67 'created' => _m('Created')
70 foreach ($tableHeaders as $id => $label) {
72 $attrs = array('id' => $id);
73 $current = (!empty($this->action->sort) && $this->action->sort == $id);
75 if ($current || empty($this->action->sort) && $id == 'nickname') {
76 $attrs['class'] = 'current';
79 if ($current && $this->action->reverse) {
80 $attrs['class'] .= ' reverse';
81 $attrs['class'] = trim($attrs['class']);
84 $this->out->elementStart('th', $attrs);
87 $params = array('sort' => $id);
89 if (!empty($this->action->q)) {
90 $params['q'] = $this->action->q;
93 if ($current && !$this->action->reverse) {
94 $params['reverse'] = 'true';
99 $filter = $this->action->arg('filter');
101 if (!empty($filter)) {
102 $args['filter'] = $filter;
105 $linkAttrs['href'] = common_local_url(
106 $this->action->arg('action'), $args, $params
109 $this->out->element('a', $linkAttrs, $label);
110 $this->out->elementEnd('th');
113 $this->out->element('th', array('id' => 'Members'), _m('Members'));
114 $this->out->element('th', array('id' => 'Admins'), _m('Admins'));
115 $this->out->element('th', array('id' => 'controls'), null);
117 $this->out->elementEnd('tr');
118 $this->out->elementEnd('thead');
120 $this->out->elementStart('tbody');
123 function newListItem($profile, $odd)
125 return new SortableGroupListItem($profile, $this->owner, $this->action, $odd);
129 class SortableGroupListItem extends SortableSubscriptionListItem
131 /** Owner of this list */
134 function __construct($profile, $owner, $action, $alt)
136 parent::__construct($profile, $owner, $action, $alt);
138 $this->alt = $alt; // is this row alternate?
139 $this->owner = $owner;
145 'class' => 'profile',
146 'id' => 'profile-' . $this->profile->id
150 $attr['class'] .= ' alt';
153 $this->out->elementStart('tr', $attr);
156 function showHomepage()
158 if (!empty($this->profile->homepage)) {
159 $this->out->text(' ');
160 $aAttrs = $this->homepageAttributes();
161 $this->out->elementStart('a', $aAttrs);
162 $this->out->raw($this->highlight($this->profile->homeUrl()));
163 $this->out->elementEnd('a');
167 function showAvatar()
169 $avatar = $this->profile->stream_logo;
170 $aAttrs = $this->linkAttributes();
171 $this->out->elementStart('a', $aAttrs);
175 'src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE),
176 'class' => 'photo avatar',
177 'width' => AVATAR_STREAM_SIZE,
178 'height' => AVATAR_STREAM_SIZE,
179 'alt' => ($this->profile->fullname) ? $this->profile->fullname : $this->profile->nickname
182 $this->out->text(' ');
183 $hasFN = (!empty($this->profile->fullname)) ? 'nickname' : 'fn nickname';
184 $this->out->elementStart('span', $hasFN);
185 $this->out->raw($this->highlight($this->profile->nickname));
186 $this->out->elementEnd('span');
187 $this->out->elementEnd('a');
192 $this->out->elementEnd('tr');
195 function startProfile()
197 $this->out->elementStart('td', 'entity_profile vcard entry-content');
200 function endProfile()
202 $this->out->elementEnd('td');
205 function startActions()
207 $this->out->elementStart('td', 'entity_actions');
208 $this->out->elementStart('ul');
211 function endActions()
213 $this->out->elementEnd('ul');
214 $this->out->elementEnd('td');
219 if (Event::handle('StartProfileListItem', array($this))) {
221 if (Event::handle('StartProfileListItemProfile', array($this))) {
222 $this->showProfile();
223 Event::handle('EndProfileListItemProfile', array($this));
227 $this->showCreatedDate();
228 $this->showMemberCount();
231 if (Event::handle('StartProfileListItemActions', array($this))) {
232 $this->showActions();
233 Event::handle('EndProfileListItemActions', array($this));
236 Event::handle('EndProfileListItem', array($this));
240 function showActions()
242 $this->startActions();
243 if (Event::handle('StartProfileListItemActionElements', array($this))) {
244 $this->showJoinButton();
245 Event::handle('EndProfileListItemActionElements', array($this));
250 function showJoinButton()
252 $user = $this->owner;
255 $this->out->elementStart('li', 'entity_subscribe');
256 // XXX: special-case for user looking at own
257 // subscriptions page
258 if ($user->isMember($this->profile)) {
259 $lf = new LeaveForm($this->out, $this->profile);
261 } else if (!Group_block::isBlocked($this->profile, $user->getProfile())) {
262 $jf = new JoinForm($this->out, $this->profile);
268 function showMemberCount()
270 $this->out->elementStart('td', 'entry_subscriber_count');
271 $this->out->raw($this->profile->getMemberCount());
272 $this->out->elementEnd('td');
275 function showCreatedDate()
277 $this->out->elementStart('td', 'entry_created');
278 $this->out->raw(date('j M Y', strtotime($this->profile->created)));
279 $this->out->elementEnd('td');
282 function showAdmins()
284 $this->out->elementStart('td', 'entry_notice_count');
286 $this->out->raw('gargargar');
287 $this->out->elementEnd('td');
291 * Only show the tags if we're logged in
295 if (common_logged_in()) {