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();
92 $is_own = !is_null($user) && isset($this->owner) && ($user->id === $this->owner->id);
94 $this->out->elementStart('div', 'entity_profile vcard');
96 $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
97 $this->out->elementStart('a', array('href' => $this->profile->profileurl,
99 $this->out->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE),
100 'class' => 'photo avatar',
101 'width' => AVATAR_STREAM_SIZE,
102 'height' => AVATAR_STREAM_SIZE,
104 ($this->profile->fullname) ? $this->profile->fullname :
105 $this->profile->nickname));
106 $hasFN = ($this->profile->fullname !== '') ? 'nickname' : 'fn nickname';
107 $this->out->elementStart('span', $hasFN);
108 $this->out->raw($this->highlight($this->profile->nickname));
109 $this->out->elementEnd('span');
110 $this->out->elementEnd('a');
112 if (!empty($this->profile->fullname)) {
113 $this->out->elementStart('dl', 'entity_fn');
114 $this->out->element('dt', null, 'Full name');
115 $this->out->elementStart('dd');
116 $this->out->elementStart('span', 'fn');
117 $this->out->raw($this->highlight($this->profile->fullname));
118 $this->out->elementEnd('span');
119 $this->out->elementEnd('dd');
120 $this->out->elementEnd('dl');
122 if (!empty($this->profile->location)) {
123 $this->out->elementStart('dl', 'entity_location');
124 $this->out->element('dt', null, _('Location'));
125 $this->out->elementStart('dd', 'label');
126 $this->out->raw($this->highlight($this->profile->location));
127 $this->out->elementEnd('dd');
128 $this->out->elementEnd('dl');
130 if (!empty($this->profile->homepage)) {
131 $this->out->elementStart('dl', 'entity_url');
132 $this->out->element('dt', null, _('URL'));
133 $this->out->elementStart('dd');
134 $this->out->elementStart('a', array('href' => $this->profile->homepage,
136 $this->out->raw($this->highlight($this->profile->homepage));
137 $this->out->elementEnd('a');
138 $this->out->elementEnd('dd');
139 $this->out->elementEnd('dl');
141 if (!empty($this->profile->bio)) {
142 $this->out->elementStart('dl', 'entity_note');
143 $this->out->element('dt', null, _('Note'));
144 $this->out->elementStart('dd', 'note');
145 $this->out->raw($this->highlight($this->profile->bio));
146 $this->out->elementEnd('dd');
147 $this->out->elementEnd('dl');
150 # If we're on a list with an owner (subscriptions or subscribers)...
154 $tags = Profile_tag::getTags($this->owner->id, $this->profile->id);
156 $this->out->elementStart('dl', 'entity_tags');
157 $this->out->elementStart('dt');
159 $this->out->element('a', array('href' => common_local_url('tagother',
160 array('id' => $this->profile->id))),
163 $this->out->text(_('Tags'));
165 $this->out->elementEnd('dt');
166 $this->out->elementStart('dd');
168 $this->out->elementStart('ul', 'tags xoxo');
169 foreach ($tags as $tag) {
170 $this->out->elementStart('li');
171 $this->out->element('span', 'mark_hash', '#');
172 $this->out->element('a', array('rel' => 'tag',
173 'href' => common_local_url($this->action->trimmed('action'),
174 array('nickname' => $this->owner->nickname,
177 $this->out->elementEnd('li');
179 $this->out->elementEnd('ul');
181 $this->out->text(_('(none)'));
183 $this->out->elementEnd('dd');
184 $this->out->elementEnd('dl');
188 $this->showOwnerControls($this->profile);
191 $this->out->elementEnd('div');
193 $this->out->elementStart('div', 'entity_actions');
195 $this->out->elementStart('ul');
197 // Is this a logged-in user, looking at someone else's
200 if (!empty($user) && $this->profile->id != $user->id) {
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->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()