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);
31 function __construct($profile, $owner=NULL, $action=NULL) {
32 $this->profile = $profile;
33 $this->owner = $owner;
34 $this->action = $action;
37 function show_list() {
39 common_element_start('ul', array('id' => 'profiles', 'class' => 'profile_list'));
43 while ($this->profile->fetch()) {
45 if($cnt > PROFILES_PER_PAGE) {
51 common_element_end('ul');
58 $this->profile = $this->profile;
60 common_element_start('li', array('class' => 'profile_single',
61 'id' => 'profile-' . $this->profile->id));
63 $user = common_current_user();
64 if ($user && $user->id != $this->profile->id) {
65 # XXX: special-case for user looking at own
67 if ($user->isSubscribed($this->profile)) {
68 common_unsubscribe_form($this->profile);
70 common_subscribe_form($this->profile);
74 $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
75 common_element_start('a', array('href' => $this->profile->profileurl));
76 common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE),
77 'class' => 'avatar stream',
78 'width' => AVATAR_STREAM_SIZE,
79 'height' => AVATAR_STREAM_SIZE,
81 ($this->profile->fullname) ? $this->profile->fullname :
82 $this->profile->nickname));
83 common_element_end('a');
84 common_element_start('p');
85 common_element_start('a', array('href' => $this->profile->profileurl,
86 'class' => 'nickname'));
87 common_raw($this->highlight($this->profile->nickname));
88 common_element_end('a');
89 if ($this->profile->fullname) {
91 common_element_start('span', 'fullname');
92 common_raw($this->highlight($this->profile->fullname));
93 common_element_end('span');
95 if ($this->profile->location) {
97 common_element_start('span', 'location');
98 common_raw($this->highlight($this->profile->location));
99 common_element_end('span');
101 common_element_end('p');
102 if ($this->profile->homepage) {
103 common_element_start('p', 'website');
104 common_element_start('a', array('href' => $this->profile->homepage));
105 common_raw($this->highlight($this->profile->homepage));
106 common_element_end('a');
107 common_element_end('p');
109 if ($this->profile->bio) {
110 common_element_start('p', 'bio');
111 common_raw($this->highlight($this->profile->bio));
112 common_element_end('p');
115 # If we're on a list with an owner (subscriptions or subscribers)...
119 $tags = Profile_tag::getTags($this->owner->id, $this->profile->id);
121 common_element_start('div', 'tags_user');
122 common_element_start('dl');
123 common_element_start('dt');
124 if ($user->id == $this->owner->id) {
125 common_element('a', array('href' => common_local_url('tagother',
126 array('id' => $this->profile->id))),
129 common_text(_('Tags'));
132 common_element_end('dt');
133 common_element_start('dd');
135 common_element_start('ul', 'tags xoxo');
136 foreach ($tags as $tag) {
137 common_element_start('li');
138 common_element('a', array('rel' => 'tag',
139 'href' => common_local_url($this->action,
140 array('nickname' => $this->owner->nickname,
143 common_element_end('li');
145 common_element_end('ul');
147 common_text(_('(none)'));
149 common_element_end('dd');
150 common_element_end('dl');
151 common_element_end('div');
156 if ($user->isSubscribed($this->profile)) {
157 $action = 'subscriptions';
158 } else if (Subscription::pkeyGet(array('subscriber' => $this->profile->id,
159 'subscribed' => $user->id))) {
160 $action = 'subscribers';
164 common_element_end('li');
167 function highlight($text) {
168 return htmlspecialchars($text);