]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/subscriptionlist.php
change LACONICA to STATUSNET
[quix0rs-gnu-social.git] / lib / subscriptionlist.php
1 <?php
2
3 /**
4  * StatusNet, the distributed open-source microblogging tool
5  *
6  * Widget to show a list of profiles
7  *
8  * PHP version 5
9  *
10  * LICENCE: This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Affero General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Affero General Public License for more details.
19  *
20  * You should have received a copy of the GNU Affero General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  * @category  Public
24  * @package   StatusNet
25  * @author    Evan Prodromou <evan@status.net>
26  * @copyright 2008-2009 StatusNet, Inc.
27  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28  * @link      http://status.net/
29  */
30
31 if (!defined('STATUSNET')) {
32     exit(1);
33 }
34
35 require_once INSTALLDIR.'/lib/profilelist.php';
36
37 /**
38  * Widget to show a list of subscriptions
39  *
40  * @category Public
41  * @package  StatusNet
42  * @author   Zach Copley <zach@status.net>
43  * @author   Evan Prodromou <evan@status.net>
44  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
45  * @link     http://status.net/
46  */
47
48 class SubscriptionList extends ProfileList
49 {
50     /** Owner of this list */
51     var $owner = null;
52
53     function __construct($profile, $owner=null, $action=null)
54     {
55         parent::__construct($profile, $action);
56
57         $this->owner = $owner;
58     }
59
60     function newListItem($profile)
61     {
62         return new SubscriptionListItem($profile, $this->owner, $this->action);
63     }
64 }
65
66 class SubscriptionListItem extends ProfileListItem
67 {
68     /** Owner of this list */
69     var $owner = null;
70
71     function __construct($profile, $owner, $action)
72     {
73         parent::__construct($profile, $action);
74
75         $this->owner = $owner;
76     }
77
78     function showProfile()
79     {
80         $this->startProfile();
81         $this->showAvatar();
82         $this->showFullName();
83         $this->showLocation();
84         $this->showHomepage();
85         $this->showBio();
86         // Relevant portion!
87         $this->showTags();
88         $this->endProfile();
89     }
90
91     function isOwn()
92     {
93         $user = common_current_user();
94         return (!empty($user) && ($this->owner->id == $user->id));
95     }
96
97     function showTags()
98     {
99         $tags = Profile_tag::getTags($this->owner->id, $this->profile->id);
100
101         $this->out->elementStart('dl', 'entity_tags');
102         $this->out->elementStart('dt');
103         if ($this->isOwn()) {
104             $this->out->element('a', array('href' => common_local_url('tagother',
105                                                                       array('id' => $this->profile->id))),
106                                 _('Tags'));
107         } else {
108             $this->out->text(_('Tags'));
109         }
110         $this->out->elementEnd('dt');
111         $this->out->elementStart('dd');
112         if ($tags) {
113             $this->out->elementStart('ul', 'tags xoxo');
114             foreach ($tags as $tag) {
115                 $this->out->elementStart('li');
116                 $this->out->element('span', 'mark_hash', '#');
117                 $this->out->element('a', array('rel' => 'tag',
118                                                'href' => common_local_url($this->action->trimmed('action'),
119                                                                           array('nickname' => $this->owner->nickname,
120                                                                                 'tag' => $tag))),
121                                     $tag);
122                 $this->out->elementEnd('li');
123             }
124             $this->out->elementEnd('ul');
125         } else {
126             $this->out->text(_('(none)'));
127         }
128         $this->out->elementEnd('dd');
129         $this->out->elementEnd('dl');
130     }
131 }