3 * GNU Social - a federating social network
4 * Copyright (C) 2014, Free Software Foundation, Inc.
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.
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.
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/>.
20 if (!defined('GNUSOCIAL')) { exit(1); }
23 * Placeholder for showing faves...
25 abstract class NoticeListActorsItem extends NoticeListItem
28 * @return array of profile IDs
30 abstract function getProfiles();
32 abstract function getListMessage($count, $you);
38 $cur = common_current_user();
39 foreach ($this->getProfiles() as $id) {
40 if ($cur && $cur->id == $id) {
42 // TRANS: Reference to the logged in user in favourite list.
43 array_unshift($links, _m('FAVELIST', 'You'));
45 $profile = Profile::getKV('id', $id);
46 if ($profile instanceof Profile) {
47 $links[] = sprintf('<a class="h-card" href="%s">%s</a>',
48 htmlspecialchars($profile->getUrl()),
49 htmlspecialchars($profile->getBestName()));
55 $count = count($links);
56 $msg = $this->getListMessage($count, $you);
57 $out = sprintf($msg, $this->magicList($links));
60 $this->out->raw($out);
68 function magicList($items)
70 if (count($items) == 0) {
72 } else if (count($items) == 1) {
75 $first = array_slice($items, 0, -1);
76 $last = array_slice($items, -1, 1);
77 // TRANS: Separator in list of user names like "Jim, Bob, Mary".
79 // TRANS: For building a list such as "Jim, Bob, Mary and 5 others like this".
80 // TRANS: %1$s is a list of users, separated by a separator (default: ", "), %2$s is the last user in the list.
81 return sprintf(_m('FAVELIST', '%1$s and %2$s'), implode($separator, $first), implode($separator, $last));