]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Favorite/lib/threadednoticelistfavesitem.php
Possibly replace weirdly capitalized htTPs: too
[quix0rs-gnu-social.git] / plugins / Favorite / lib / threadednoticelistfavesitem.php
1 <?php
2 /**
3  * GNU Social - a federating social network
4  * Copyright (C) 2014, Free Software Foundation, Inc.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 if (!defined('GNUSOCIAL')) { exit(1); }
21
22 /**
23  * Placeholder for showing faves...
24  */
25 class ThreadedNoticeListFavesItem extends NoticeListActorsItem
26 {
27     function getProfiles()
28     {
29         $faves = Fave::byNotice($this->notice);
30         $profiles = array();
31         foreach ($faves as $fave) {
32             $profiles[] = $fave->user_id;
33         }   
34         return $profiles;
35     }
36
37     function magicList($items)
38     {
39         if (count($items) > 4) {
40             return parent::magicList(array_slice($items, 0, 3));
41         } else {
42             return parent::magicList($items);
43         }   
44     }
45
46     function getListMessage($count, $you)
47     {
48         if ($count == 1 && $you) {
49             // darn first person being different from third person!
50             // TRANS: List message for notice favoured by logged in user.
51             return _m('FAVELIST', 'You like this.');
52         } else if ($count > 4) {
53             // TRANS: List message for when more than 4 people like something.
54             // TRANS: %%s is a list of users liking a notice, %d is the number over 4 that like the notice.
55             // TRANS: Plural is decided on the total number of users liking the notice (count of %%s + %d).
56             return sprintf(_m('%%s and %d others like this.',
57                               '%%s and %d others like this.',
58                               $count),
59                            $count - 3);
60         } else {           
61             // TRANS: List message for favoured notices.
62             // TRANS: %%s is a list of users liking a notice.
63             // TRANS: Plural is based on the number of of users that have favoured a notice.
64             return sprintf(_m('%%s likes this.',
65                               '%%s like this.',
66                               $count),
67                            $count);
68         }                  
69     }
70
71     function showStart()
72     {
73         $this->out->elementStart('li', array('class' => 'notice-data notice-faves'));
74     }   
75
76     function showEnd()
77     {
78         $this->out->elementEnd('li');
79     }   
80 }