]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/profilelist.php
b17b0ac9218af0d583cf6ba46e7fd27f96877032
[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', 10);
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         
50         function show() {
51
52                 $this->profile = $this->profile;
53                 
54                 common_element_start('li', array('class' => 'profile_single',
55                                                                                  'id' => 'profile-' . $this->profile->id));
56                 $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
57                 common_element_start('a', array('href' => $this->profile->profileurl));
58                 common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE),
59                                                                         'class' => 'avatar stream',
60                                                                         'width' => AVATAR_STREAM_SIZE,
61                                                                         'height' => AVATAR_STREAM_SIZE,
62                                                                         'alt' =>
63                                                                         ($this->profile->fullname) ? $this->profile->fullname :
64                                                                         $this->profile->nickname));
65                 common_element_end('a');
66                 common_element_start('p');
67                 common_element_start('a', array('href' => $this->profile->profileurl,
68                                                                                 'class' => 'nickname'));
69                 common_raw($this->highlight($this->profile->nickname));
70                 common_element_end('a');
71                 if ($this->profile->fullname) {
72                         common_text(' | ');
73                         common_element_start('span', 'fullname');
74                         common_raw($this->highlight($this->profile->fullname));
75                         common_element_end('span');
76                 }
77                 if ($this->profile->location) {
78                         common_text(' | ');
79                         common_element_start('span', 'location');
80                         common_raw($this->highlight($this->profile->location));
81                         common_element_end('span');
82                 }
83                 common_element_end('p');
84                 if ($this->profile->homepage) {
85                         common_element_start('p', 'website');
86                         common_element_start('a', array('href' => $this->profile->homepage));
87                         common_raw($this->highlight($this->profile->homepage));
88                         common_element_end('a');
89                         common_element_end('p');
90                 }
91                 if ($this->profile->bio) {
92                         common_element_start('p', 'bio');
93                         common_raw($this->highlight($this->profile->bio));
94                         common_element_end('p');
95                 }
96                 common_element_end('li');
97         }
98
99         function highlight($text) {
100                 return htmlspecialchars($text);
101         }
102 }