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);
114 common_element_start('p', 'tags');
115 foreach ($tags as $tag) {
116 common_element('a', array('rel' => 'tag',
117 'href' => common_local_url('peopletag',
118 array('tag' => $tag))),
121 common_element_end('p');
127 if ($user->isSubscribed($this->profile)) {
128 $action = 'subscriptions';
129 } else if (Subscription::pkeyGet(array('subscriber' => $this->profile->id,
130 'subscribed' => $user->id))) {
131 $action = 'subscribers';
136 $tags = Profile_tag::getTags($user->id, $this->profile->id);
139 common_element_start('p', 'subtags');
141 foreach ($tags as $tag) {
142 common_element('a', array('href' => common_local_url($action,
143 array('nickname' => $user->nickname,
148 common_element_end('p');
151 common_element('a', array('href' => common_local_url('tagother',
152 array('id' => $this->profile->id)),
153 'class' => 'tagother'),
158 common_element_end('li');
161 function highlight($text) {
162 return htmlspecialchars($text);