4 * Laconica, the distributed open-source microblogging tool
6 * Widget to show a 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 Evan Prodromou <evan@controlyourself.ca>
26 * @copyright 2008-2009 Control Yourself, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28 * @link http://laconi.ca/
31 if (!defined('LACONICA')) {
35 require_once INSTALLDIR.'/lib/widget.php';
37 define('PROFILES_PER_PAGE', 20);
40 * Widget to show a list of profiles
44 * @author Zach Copley <zach@controlyourself.ca>
45 * @author Evan Prodromou <evan@controlyourself.ca>
46 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
47 * @link http://laconi.ca/
50 class ProfileList extends Widget
52 /** Current profile, profile query. */
54 /** Owner of this list */
56 /** Action object using us. */
59 function __construct($profile, $owner=null, $action=null)
61 parent::__construct($action);
63 $this->profile = $profile;
64 $this->owner = $owner;
65 $this->action = $action;
71 $this->out->elementStart('ul', 'profiles');
75 while ($this->profile->fetch()) {
77 if($cnt > PROFILES_PER_PAGE) {
83 $this->out->elementEnd('ul');
88 function showProfile()
90 $this->out->elementStart('li', array('class' => 'profile',
91 'id' => 'profile-' . $this->profile->id));
93 $user = common_current_user();
95 $this->out->elementStart('div', 'entity_profile vcard');
97 $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
98 $this->out->elementStart('a', array('href' => $this->profile->profileurl,
100 $this->out->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE),
101 'class' => 'photo avatar',
102 'width' => AVATAR_STREAM_SIZE,
103 'height' => AVATAR_STREAM_SIZE,
105 ($this->profile->fullname) ? $this->profile->fullname :
106 $this->profile->nickname));
107 $hasFN = ($this->profile->fullname) ? 'nickname' : 'fn nickname';
108 $this->out->elementStart('span', $hasFN);
109 $this->out->raw($this->highlight($this->profile->nickname));
110 $this->out->elementEnd('span');
111 $this->out->elementEnd('a');
113 if ($this->profile->fullname) {
114 $this->out->elementStart('dl', 'entity_fn');
115 $this->out->element('dt', null, 'Full name');
116 $this->out->elementStart('dd');
117 $this->out->elementStart('span', 'fn');
118 $this->out->raw($this->highlight($this->profile->fullname));
119 $this->out->elementEnd('span');
120 $this->out->elementEnd('dd');
121 $this->out->elementEnd('dl');
123 if ($this->profile->location) {
124 $this->out->elementStart('dl', 'entity_location');
125 $this->out->element('dt', null, _('Location'));
126 $this->out->elementStart('dd', 'label');
127 $this->out->raw($this->highlight($this->profile->location));
128 $this->out->elementEnd('dd');
129 $this->out->elementEnd('dl');
131 if ($this->profile->homepage) {
132 $this->out->elementStart('dl', 'entity_url');
133 $this->out->element('dt', null, _('URL'));
134 $this->out->elementStart('dd');
135 $this->out->elementStart('a', array('href' => $this->profile->homepage,
137 $this->out->raw($this->highlight($this->profile->homepage));
138 $this->out->elementEnd('a');
139 $this->out->elementEnd('dd');
140 $this->out->elementEnd('dl');
142 if ($this->profile->bio) {
143 $this->out->elementStart('dl', 'entity_note');
144 $this->out->element('dt', null, _('Note'));
145 $this->out->elementStart('dd', 'note');
146 $this->out->raw($this->highlight($this->profile->bio));
147 $this->out->elementEnd('dd');
148 $this->out->elementEnd('dl');
151 # If we're on a list with an owner (subscriptions or subscribers)...
155 $tags = Profile_tag::getTags($this->owner->id, $this->profile->id);
157 $this->out->elementStart('dl', 'entity_tags');
158 $this->out->elementStart('dt');
159 if ($user->id == $this->owner->id) {
160 $this->out->element('a', array('href' => common_local_url('tagother',
161 array('id' => $this->profile->id))),
164 $this->out->text(_('Tags'));
166 $this->out->elementEnd('dt');
167 $this->out->elementStart('dd');
169 $this->out->elementStart('ul', 'tags xoxo');
170 foreach ($tags as $tag) {
171 $this->out->elementStart('li');
172 $this->out->element('span', 'mark_hash', '#');
173 $this->out->element('a', array('rel' => 'tag',
174 'href' => common_local_url($this->action->trimmed('action'),
175 array('nickname' => $this->owner->nickname,
178 $this->out->elementEnd('li');
180 $this->out->elementEnd('ul');
182 $this->out->text(_('(none)'));
184 $this->out->elementEnd('dd');
185 $this->out->elementEnd('dl');
188 if ($user && $user->id == $this->owner->id) {
189 $this->showOwnerControls($this->profile);
192 $this->out->elementEnd('div');
194 $this->out->elementStart('div', 'entity_actions');
196 $this->out->elementStart('ul');
198 if ($user && $user->id != $this->profile->id) {
199 # XXX: special-case for user looking at own
201 $this->out->elementStart('li', 'entity_subscribe');
202 if ($user->isSubscribed($this->profile)) {
203 $usf = new UnsubscribeForm($this->out, $this->profile);
206 $sf = new SubscribeForm($this->out, $this->profile);
209 $this->out->elementEnd('li');
210 $this->out->elementStart('li', 'entity_block');
211 if ($user && $user->id == $this->owner->id) {
212 $this->showBlockForm();
214 $this->out->elementEnd('li');
217 $this->out->elementEnd('ul');
219 $this->out->elementEnd('div');
221 $this->out->elementEnd('li');
224 /* Override this in subclasses. */
226 function showOwnerControls($profile)
231 function highlight($text)
233 return htmlspecialchars($text);
236 function showBlockForm()