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, $owner=NULL) {
30 $this->profile = $profile;
31 $this->owner = $owner;
34 function show_list() {
36 common_element_start('ul', array('id' => 'profiles'));
40 while ($this->profile->fetch()) {
42 if($cnt > PROFILES_PER_PAGE) {
48 common_element_end('ul');
55 $this->profile = $this->profile;
57 common_element_start('li', array('class' => 'profile_single',
58 'id' => 'profile-' . $this->profile->id));
60 $user = common_current_user();
62 if ($user && $user->id != $this->profile->id) {
63 # XXX: special-case for user looking at own
65 if ($user->isSubscribed($this->profile)) {
66 common_unsubscribe_form($this->profile);
68 common_subscribe_form($this->profile);
72 $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
73 common_element_start('a', array('href' => $this->profile->profileurl));
74 common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE),
75 'class' => 'avatar stream',
76 'width' => AVATAR_STREAM_SIZE,
77 'height' => AVATAR_STREAM_SIZE,
79 ($this->profile->fullname) ? $this->profile->fullname :
80 $this->profile->nickname));
81 common_element_end('a');
82 common_element_start('p');
83 common_element_start('a', array('href' => $this->profile->profileurl,
84 'class' => 'nickname'));
85 common_raw($this->highlight($this->profile->nickname));
86 common_element_end('a');
87 if ($this->profile->fullname) {
89 common_element_start('span', 'fullname');
90 common_raw($this->highlight($this->profile->fullname));
91 common_element_end('span');
93 if ($this->profile->location) {
95 common_element_start('span', 'location');
96 common_raw($this->highlight($this->profile->location));
97 common_element_end('span');
99 common_element_end('p');
100 if ($this->profile->homepage) {
101 common_element_start('p', 'website');
102 common_element_start('a', array('href' => $this->profile->homepage));
103 common_raw($this->highlight($this->profile->homepage));
104 common_element_end('a');
105 common_element_end('p');
107 if ($this->profile->bio) {
108 common_element_start('p', 'bio');
109 common_raw($this->highlight($this->profile->bio));
110 common_element_end('p');
113 $tags = Profile_tag::getTags($this->profile->id, $this->profile->id);
116 common_element_start('p', 'tags');
117 foreach ($tags as $tag) {
118 common_element('a', array('rel' => 'tag',
119 'href' => common_local_url('peopletag',
120 array('tag' => $tag))),
123 common_element_end('p');
129 if ($this->owner->isSubscribed($this->profile)) {
130 $action = 'subscriptions';
131 } else if (Subscription::pkeyGet(array('subscriber' => $this->profile->id,
132 'subscribed' => $this->owner->id))) {
133 $action = 'subscribers';
138 $tags = Profile_tag::getTags($this->owner->id, $this->profile->id);
141 common_element_start('p', 'subtags');
143 foreach ($tags as $tag) {
144 common_element('a', array('href' => common_local_url($action,
145 array('nickname' => $this->owner->nickname,
150 common_element_end('p');
153 if ($this->owner->id == $user->id) {
154 common_element('a', array('href' => common_local_url('tagother',
155 array('id' => $this->profile->id)),
156 'class' => 'tagother'),
162 common_element_end('li');
165 function highlight($text) {
166 return htmlspecialchars($text);