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 common_element_start('li', array('class' => 'profile_single',
59 'id' => 'profile-' . $this->profile->id));
61 $user = common_current_user();
63 if ($user && $user->id != $this->profile->id) {
64 # XXX: special-case for user looking at own
66 if ($user->isSubscribed($this->profile)) {
67 common_unsubscribe_form($this->profile);
69 common_subscribe_form($this->profile);
73 $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
74 common_element_start('a', array('href' => $this->profile->profileurl));
75 common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE),
76 'class' => 'avatar stream',
77 'width' => AVATAR_STREAM_SIZE,
78 'height' => AVATAR_STREAM_SIZE,
80 ($this->profile->fullname) ? $this->profile->fullname :
81 $this->profile->nickname));
82 common_element_end('a');
83 common_element_start('p');
84 common_element_start('a', array('href' => $this->profile->profileurl,
85 'class' => 'nickname'));
86 common_raw($this->highlight($this->profile->nickname));
87 common_element_end('a');
88 if ($this->profile->fullname) {
90 common_element_start('span', 'fullname');
91 common_raw($this->highlight($this->profile->fullname));
92 common_element_end('span');
94 if ($this->profile->location) {
96 common_element_start('span', 'location');
97 common_raw($this->highlight($this->profile->location));
98 common_element_end('span');
100 common_element_end('p');
101 if ($this->profile->homepage) {
102 common_element_start('p', 'website');
103 common_element_start('a', array('href' => $this->profile->homepage));
104 common_raw($this->highlight($this->profile->homepage));
105 common_element_end('a');
106 common_element_end('p');
108 if ($this->profile->bio) {
109 common_element_start('p', 'bio');
110 common_raw($this->highlight($this->profile->bio));
111 common_element_end('p');
114 # If we're on a list with an owner (subscriptions or subscribers)...
118 $tags = Profile_tag::getTags($this->owner->id, $this->profile->id);
120 common_element_start('div', 'tags_user');
121 common_element_start('dl');
122 common_element_start('dt');
123 if ($user->id == $this->owner->id) {
124 common_element('a', array('href' => common_local_url('tagother',
125 array('id' => $this->profile->id))),
128 common_text(_('Tags'));
131 common_element_end('dt');
132 common_element_start('dd');
134 common_element_start('ul', 'tags xoxo');
135 foreach ($tags as $tag) {
136 common_element_start('li');
137 common_element('a', array('rel' => 'tag',
138 'href' => common_local_url($this->action,
139 array('nickname' => $this->owner->nickname,
142 common_element_end('li');
144 common_element_end('ul');
146 common_text(_('(none)'));
148 common_element_end('dd');
149 common_element_end('dl');
150 common_element_end('div');
153 if ($user && $user->id == $this->owner->id) {
154 $this->show_owner_controls($this->profile);
157 common_element_end('li');
160 /* Override this in subclasses. */
162 function show_owner_controls($profile) {
166 function highlight($text) {
167 return htmlspecialchars($text);