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);
29 function __construct($profile) {
30 $this->profile = $profile;
33 function show_list() {
35 common_element_start('ul', array('id' => 'profiles'));
39 while ($this->profile->fetch()) {
41 if($cnt > PROFILES_PER_PAGE) {
47 common_element_end('ul');
54 $this->profile = $this->profile;
56 common_element_start('li', array('class' => 'profile_single',
57 'id' => 'profile-' . $this->profile->id));
59 $user = common_current_user();
60 if ($user && $user->id != $this->profile->id) {
61 # XXX: special-case for user looking at own
63 if ($user->isSubscribed($this->profile)) {
64 common_unsubscribe_form($this->profile);
66 common_subscribe_form($this->profile);
70 $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
71 common_element_start('a', array('href' => $this->profile->profileurl));
72 common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE),
73 'class' => 'avatar stream',
74 'width' => AVATAR_STREAM_SIZE,
75 'height' => AVATAR_STREAM_SIZE,
77 ($this->profile->fullname) ? $this->profile->fullname :
78 $this->profile->nickname));
79 common_element_end('a');
80 common_element_start('p');
81 common_element_start('a', array('href' => $this->profile->profileurl,
82 'class' => 'nickname'));
83 common_raw($this->highlight($this->profile->nickname));
84 common_element_end('a');
85 if ($this->profile->fullname) {
87 common_element_start('span', 'fullname');
88 common_raw($this->highlight($this->profile->fullname));
89 common_element_end('span');
91 if ($this->profile->location) {
93 common_element_start('span', 'location');
94 common_raw($this->highlight($this->profile->location));
95 common_element_end('span');
97 common_element_end('p');
98 if ($this->profile->homepage) {
99 common_element_start('p', 'website');
100 common_element_start('a', array('href' => $this->profile->homepage));
101 common_raw($this->highlight($this->profile->homepage));
102 common_element_end('a');
103 common_element_end('p');
105 if ($this->profile->bio) {
106 common_element_start('p', 'bio');
107 common_raw($this->highlight($this->profile->bio));
108 common_element_end('p');
111 $tags = Profile_tag::getTags($this->profile->id, $this->profile->id);
115 common_element_start('div', 'tags_self');
116 common_element_start('dl');
117 common_element('dt', null, _("User's tags:"));
118 common_element_start('dd');
119 common_element_start('ul', 'tags xoxo');
120 foreach ($tags as $tag) {
121 common_element_start('li');
122 common_element('a', array('rel' => 'tag',
123 'href' => common_local_url('peopletag',
124 array('tag' => $tag))),
126 common_element_end('li');
128 common_element_end('ul');
129 common_element_end('dd');
130 common_element_end('dl');
131 common_element_end('div');
137 if ($user->isSubscribed($this->profile)) {
138 $action = 'subscriptions';
139 } else if (Subscription::pkeyGet(array('subscriber' => $this->profile->id,
140 'subscribed' => $user->id))) {
141 $action = 'subscribers';
146 $tags = Profile_tag::getTags($user->id, $this->profile->id);
149 common_element_start('div', 'tags_user');
150 common_element_start('dl');
151 common_element_start('dt');
152 common_element('a', array('href' => common_local_url('tagother',
153 array('id' => $this->profile->id))),
156 common_element_end('dt');
157 common_element_start('dd');
158 common_element_start('ul', 'tags xoxo');
159 foreach ($tags as $tag) {
160 common_element_start('li');
161 common_element('a', array('rel' => "tag",
162 'href' => common_local_url($action,
163 array('nickname' => $user->nickname,
166 common_element_end('li');
168 common_element_end('ul');
169 common_element_end('dd');
170 common_element_end('dl');
171 common_element_end('div');
176 common_element_end('li');
179 function highlight($text) {
180 return htmlspecialchars($text);