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';
38 * Widget to show a list of profiles
42 * @author Zach Copley <zach@controlyourself.ca>
43 * @author Evan Prodromou <evan@controlyourself.ca>
44 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
45 * @link http://laconi.ca/
48 class ProfileList extends Widget
50 /** Current profile, profile query. */
52 /** Owner of this list */
54 /** Action object using us. */
57 function __construct($profile, $owner=null, $action=null)
59 parent::__construct($action);
61 $this->profile = $profile;
62 $this->owner = $owner;
63 $this->action = $action;
69 $this->out->elementStart('ul', 'profiles');
73 while ($this->profile->fetch()) {
75 if($cnt > PROFILES_PER_PAGE) {
81 $this->out->elementEnd('ul');
86 function showProfile()
88 $this->out->elementStart('li', array('class' => 'profile',
89 'id' => 'profile-' . $this->profile->id));
91 $user = common_current_user();
93 $this->out->elementStart('div', 'entity_profile vcard');
95 $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
96 $this->out->elementStart('a', array('href' => $this->profile->profileurl,
98 $this->out->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE),
99 'class' => 'photo avatar',
100 'width' => AVATAR_STREAM_SIZE,
101 'height' => AVATAR_STREAM_SIZE,
103 ($this->profile->fullname) ? $this->profile->fullname :
104 $this->profile->nickname));
105 $hasFN = ($this->profile->fullname !== '') ? 'nickname' : 'fn nickname';
106 $this->out->elementStart('span', $hasFN);
107 $this->out->raw($this->highlight($this->profile->nickname));
108 $this->out->elementEnd('span');
109 $this->out->elementEnd('a');
111 if ($this->profile->fullname !== '') {
112 $this->out->elementStart('dl', 'entity_fn');
113 $this->out->element('dt', null, 'Full name');
114 $this->out->elementStart('dd');
115 $this->out->elementStart('span', 'fn');
116 $this->out->raw($this->highlight($this->profile->fullname));
117 $this->out->elementEnd('span');
118 $this->out->elementEnd('dd');
119 $this->out->elementEnd('dl');
121 if ($this->profile->location !== '') {
122 $this->out->elementStart('dl', 'entity_location');
123 $this->out->element('dt', null, _('Location'));
124 $this->out->elementStart('dd', 'label');
125 $this->out->raw($this->highlight($this->profile->location));
126 $this->out->elementEnd('dd');
127 $this->out->elementEnd('dl');
129 if ($this->profile->homepage !== '') {
130 $this->out->elementStart('dl', 'entity_url');
131 $this->out->element('dt', null, _('URL'));
132 $this->out->elementStart('dd');
133 $this->out->elementStart('a', array('href' => $this->profile->homepage,
135 $this->out->raw($this->highlight($this->profile->homepage));
136 $this->out->elementEnd('a');
137 $this->out->elementEnd('dd');
138 $this->out->elementEnd('dl');
140 if ($this->profile->bio !== '') {
141 $this->out->elementStart('dl', 'entity_note');
142 $this->out->element('dt', null, _('Note'));
143 $this->out->elementStart('dd', 'note');
144 $this->out->raw($this->highlight($this->profile->bio));
145 $this->out->elementEnd('dd');
146 $this->out->elementEnd('dl');
149 # If we're on a list with an owner (subscriptions or subscribers)...
153 $tags = Profile_tag::getTags($this->owner->id, $this->profile->id);
155 $this->out->elementStart('dl', 'entity_tags');
156 $this->out->elementStart('dt');
157 if ($user->id == $this->owner->id) {
158 $this->out->element('a', array('href' => common_local_url('tagother',
159 array('id' => $this->profile->id))),
162 $this->out->text(_('Tags'));
164 $this->out->elementEnd('dt');
165 $this->out->elementStart('dd');
167 $this->out->elementStart('ul', 'tags xoxo');
168 foreach ($tags as $tag) {
169 $this->out->elementStart('li');
170 $this->out->element('span', 'mark_hash', '#');
171 $this->out->element('a', array('rel' => 'tag',
172 'href' => common_local_url($this->action->trimmed('action'),
173 array('nickname' => $this->owner->nickname,
176 $this->out->elementEnd('li');
178 $this->out->elementEnd('ul');
180 $this->out->text(_('(none)'));
182 $this->out->elementEnd('dd');
183 $this->out->elementEnd('dl');
186 if ($user && $user->id == $this->owner->id) {
187 $this->showOwnerControls($this->profile);
190 $this->out->elementEnd('div');
192 $this->out->elementStart('div', 'entity_actions');
194 $this->out->elementStart('ul');
196 if ($user && $user->id != $this->profile->id) {
197 # XXX: special-case for user looking at own
199 $this->out->elementStart('li', 'entity_subscribe');
200 if ($user->isSubscribed($this->profile)) {
201 $usf = new UnsubscribeForm($this->out, $this->profile);
204 $sf = new SubscribeForm($this->out, $this->profile);
207 $this->out->elementEnd('li');
208 $this->out->elementStart('li', 'entity_block');
209 if ($user && $user->id == $this->owner->id) {
210 $this->showBlockForm();
212 $this->out->elementEnd('li');
215 $this->out->elementEnd('ul');
217 $this->out->elementEnd('div');
219 $this->out->elementEnd('li');
222 /* Override this in subclasses. */
224 function showOwnerControls($profile)
229 function highlight($text)
231 return htmlspecialchars($text);
234 function showBlockForm()