]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/profilelist.php
Removing empty element no longer in use
[quix0rs-gnu-social.git] / lib / profilelist.php
1 <?php
2
3 /*
4  * Laconica - a distributed open-source microblogging tool
5  * Copyright (C) 2008, Controlez-Vous, Inc.
6  *
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.
11  *
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.
16  *
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/>.
19  */
20
21 if (!defined('LACONICA')) { exit(1); }
22
23 define('PROFILES_PER_PAGE', 20);
24
25 class ProfileList {
26
27         var $profile = NULL;
28         
29         function __construct($profile) {
30                 $this->profile = $profile;
31         }
32         
33         function show_list() {
34                 
35                 common_element_start('ul', array('id' => 'profiles'));
36
37                 $cnt = 0;
38                 
39                 while ($this->profile->fetch()) {
40                         $cnt++;
41                         if($cnt > PROFILES_PER_PAGE) {
42                                 break;
43                         }
44                         $this->show();
45                 }
46                 
47                 common_element_end('ul');
48                 
49                 return $cnt;
50         }
51         
52         function show() {
53
54                 $this->profile = $this->profile;
55                 
56                 common_element_start('li', array('class' => 'profile_single',
57                                                                                  'id' => 'profile-' . $this->profile->id));
58                 
59                 $user = common_current_user();
60                 if ($user && $user->id != $this->profile->id) {
61                         # XXX: special-case for user looking at own
62                         # subscriptions page
63                         if ($user->isSubscribed($this->profile)) {
64                                 common_unsubscribe_form($this->profile);
65                         } else {
66                                 common_subscribe_form($this->profile);
67                         }
68                 }
69                 
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,
76                                                                         'alt' =>
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) {
86                         common_text(' | ');
87                         common_element_start('span', 'fullname');
88                         common_raw($this->highlight($this->profile->fullname));
89                         common_element_end('span');
90                 }
91                 if ($this->profile->location) {
92                         common_text(' | ');
93                         common_element_start('span', 'location');
94                         common_raw($this->highlight($this->profile->location));
95                         common_element_end('span');
96                 }
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');
104                 }
105                 if ($this->profile->bio) {
106                         common_element_start('p', 'bio');
107                         common_raw($this->highlight($this->profile->bio));
108                         common_element_end('p');
109                 }
110                 
111                 $tags = Profile_tag::getTags($this->profile->id, $this->profile->id);
112
113
114                 if ($tags) {
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))),
125                                                            $tag);
126                                 common_element_end('li');
127                         }
128                         common_element_end('ul');
129                         common_element_end('dd');
130                         common_element_end('dl');
131                         common_element_end('div');
132                 }
133
134                 if ($user) {
135                         $action = NULL;
136                         
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';
142                         }
143                         
144                         
145                         if ($action) {
146                                 $tags = Profile_tag::getTags($user->id, $this->profile->id);
147                                 
148                                 if ($tags) {
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))),
154                                                            _('Your tags'));
155                                         common_text(":");
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,
164                                                                                                                                                                    'tag' => $tag))),
165                                                                            $tag);
166                                                 common_element_end('li');
167                                         }                                       
168                                         common_element_end('ul');
169                                         common_element_end('dd');
170                                         common_element_end('dl');
171                                         common_element_end('div');
172                                 }
173                         }
174                 }
175                 
176                 common_element_end('li');
177         }
178
179         function highlight($text) {
180                 return htmlspecialchars($text);
181         }
182 }