4 * Laconica - a distributed open-source microblogging tool
5 * Copyright (C) 2008, Controlez-Vous, Inc.
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 if (!defined('LACONICA')) { exit(1); }
23 define('PROFILES_PER_PAGE', 20);
32 function __construct($profile, $owner=null, $action=null)
34 $this->profile = $profile;
35 $this->owner = $owner;
36 $this->action = $action;
42 common_element_start('ul', array('id' => 'profiles', 'class' => 'profile_list'));
46 while ($this->profile->fetch()) {
48 if($cnt > PROFILES_PER_PAGE) {
54 common_element_end('ul');
62 common_element_start('li', array('class' => 'profile_single',
63 'id' => 'profile-' . $this->profile->id));
65 $user = common_current_user();
67 if ($user && $user->id != $this->profile->id) {
68 # XXX: special-case for user looking at own
70 if ($user->isSubscribed($this->profile)) {
71 common_unsubscribe_form($this->profile);
73 common_subscribe_form($this->profile);
77 $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
78 common_element_start('a', array('href' => $this->profile->profileurl));
79 common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE),
80 'class' => 'avatar stream',
81 'width' => AVATAR_STREAM_SIZE,
82 'height' => AVATAR_STREAM_SIZE,
84 ($this->profile->fullname) ? $this->profile->fullname :
85 $this->profile->nickname));
86 common_element_end('a');
87 common_element_start('p');
88 common_element_start('a', array('href' => $this->profile->profileurl,
89 'class' => 'nickname'));
90 common_raw($this->highlight($this->profile->nickname));
91 common_element_end('a');
92 if ($this->profile->fullname) {
94 common_element_start('span', 'fullname');
95 common_raw($this->highlight($this->profile->fullname));
96 common_element_end('span');
98 if ($this->profile->location) {
100 common_element_start('span', 'location');
101 common_raw($this->highlight($this->profile->location));
102 common_element_end('span');
104 common_element_end('p');
105 if ($this->profile->homepage) {
106 common_element_start('p', 'website');
107 common_element_start('a', array('href' => $this->profile->homepage));
108 common_raw($this->highlight($this->profile->homepage));
109 common_element_end('a');
110 common_element_end('p');
112 if ($this->profile->bio) {
113 common_element_start('p', 'bio');
114 common_raw($this->highlight($this->profile->bio));
115 common_element_end('p');
118 # If we're on a list with an owner (subscriptions or subscribers)...
122 $tags = Profile_tag::getTags($this->owner->id, $this->profile->id);
124 common_element_start('div', 'tags_user');
125 common_element_start('dl');
126 common_element_start('dt');
127 if ($user->id == $this->owner->id) {
128 common_element('a', array('href' => common_local_url('tagother',
129 array('id' => $this->profile->id))),
132 common_text(_('Tags'));
135 common_element_end('dt');
136 common_element_start('dd');
138 common_element_start('ul', 'tags xoxo');
139 foreach ($tags as $tag) {
140 common_element_start('li');
141 common_element('a', array('rel' => 'tag',
142 'href' => common_local_url($this->action,
143 array('nickname' => $this->owner->nickname,
146 common_element_end('li');
148 common_element_end('ul');
150 common_text(_('(none)'));
152 common_element_end('dd');
153 common_element_end('dl');
154 common_element_end('div');
157 if ($user && $user->id == $this->owner->id) {
158 $this->show_owner_controls($this->profile);
161 common_element_end('li');
164 /* Override this in subclasses. */
166 function show_owner_controls($profile)
171 function highlight($text)
173 return htmlspecialchars($text);