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 SortableSubscriptionList extends SubscriptionList
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) {
71 $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->boolean('asc')) {
80 $attrs['class'] .= ' asc';
81 $attrs['class'] = trim($attrs['class']);
84 $this->out->elementStart('th', $attrs);
87 $params = array('sort' => $id);
89 if ($current && !$this->action->boolean('asc')) {
90 $params['asc'] = "true";
95 $filter = $this->action->arg('filter');
97 if (!empty($filter)) {
98 $args['filter'] = $filter;
101 $linkAttrs['href'] = common_local_url(
102 $this->action->arg('action'), $args, $params
105 $this->out->element('a', $linkAttrs, $label);
106 $this->out->elementEnd('th');
109 $this->out->element('th', array('id' => 'subscriptions'), 'Subscriptions');
110 $this->out->element('th', array('id' => 'notices'), 'Notices');
111 //$this->out->element('th', array('id' => 'controls'), 'Controls');
113 $this->out->elementEnd('tr');
114 $this->out->elementEnd('thead');
116 $this->out->elementStart('tbody');
121 $this->out->elementEnd('tbody');
122 $this->out->elementEnd('table');
125 function showProfiles()
129 while ($this->profile->fetch()) {
131 if($cnt > PROFILES_PER_PAGE) {
135 $odd = ($cnt % 2 == 0); // for zebra striping
137 $pli = $this->newListItem($this->profile, $odd);
144 function newListItem($profile, $odd)
146 return new SortableSubscriptionListItem($profile, $this->owner, $this->action, $odd);
150 class SortableSubscriptionListItem extends SubscriptionListItem
152 /** Owner of this list */
155 function __construct($profile, $owner, $action, $alt)
157 parent::__construct($profile, $owner, $action);
159 $this->alt = $alt; // is this row alternate?
160 $this->owner = $owner;
166 'class' => 'profile',
167 'id' => 'profile-' . $this->profile->id
171 $attr['class'] .= ' alt';
174 $this->out->elementStart('tr', $attr);
179 $this->out->elementEnd('tr');
182 function startProfile()
184 $this->out->elementStart('td', 'entity_profile vcard entry-content');
187 function endProfile()
189 $this->out->elementEnd('td');
192 function startActions()
194 $this->out->elementStart('td', 'entity_actions');
195 $this->out->elementStart('ul');
198 function endActions()
200 $this->out->elementEnd('ul');
201 $this->out->elementEnd('td');
206 if (Event::handle('StartProfileListItem', array($this))) {
208 if (Event::handle('StartProfileListItemProfile', array($this))) {
209 $this->showProfile();
210 Event::handle('EndProfileListItemProfile', array($this));
214 $this->showCreatedDate();
215 $this->showSubscriberCount();
216 $this->showNoticeCount();
218 if (Event::handle('StartProfileListItemActions', array($this))) {
219 $this->showActions();
220 Event::handle('EndProfileListItemActions', array($this));
223 Event::handle('EndProfileListItem', array($this));
227 function showSubscriberCount()
229 $this->out->elementStart('td', 'entry_subscriber_count');
230 $this->out->raw($this->profile->subscriberCount());
231 $this->out->elementEnd('td');
234 function showCreatedDate()
236 $this->out->elementStart('td', 'entry_created');
237 $this->out->raw(date('j M Y', strtotime($this->profile->created)));
238 $this->out->elementEnd('td');
241 function showNoticeCount()
243 $this->out->elementStart('td', 'entry_notice_count');
244 $this->out->raw($this->profile->noticeCount());
245 $this->out->elementEnd('td');
249 * Only show the tags if we're logged in
253 if (common_logged_in()) {