threadednoticelistfavesitem.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. if (!defined('GNUSOCIAL')) { exit(1); }
  20. /**
  21. * Placeholder for showing faves...
  22. */
  23. class ThreadedNoticeListFavesItem extends NoticeListActorsItem
  24. {
  25. function getProfiles()
  26. {
  27. $faves = Fave::byNotice($this->notice);
  28. $profiles = array();
  29. foreach ($faves as $fave) {
  30. $profiles[] = $fave->user_id;
  31. }
  32. return $profiles;
  33. }
  34. function magicList($items)
  35. {
  36. if (count($items) > 4) {
  37. return parent::magicList(array_slice($items, 0, 3));
  38. } else {
  39. return parent::magicList($items);
  40. }
  41. }
  42. function getListMessage($count, $you)
  43. {
  44. if ($count == 1 && $you) {
  45. // darn first person being different from third person!
  46. // TRANS: List message for notice favoured by logged in user.
  47. return _m('FAVELIST', 'You like this.');
  48. } else if ($count > 4) {
  49. // TRANS: List message for when more than 4 people like something.
  50. // TRANS: %%s is a list of users liking a notice, %d is the number over 4 that like the notice.
  51. // TRANS: Plural is decided on the total number of users liking the notice (count of %%s + %d).
  52. return sprintf(_m('%%s and %d others like this.',
  53. '%%s and %d others like this.',
  54. $count),
  55. $count - 3);
  56. } else {
  57. // TRANS: List message for favoured notices.
  58. // TRANS: %%s is a list of users liking a notice.
  59. // TRANS: Plural is based on the number of of users that have favoured a notice.
  60. return sprintf(_m('%%s likes this.',
  61. '%%s like this.',
  62. $count),
  63. $count);
  64. }
  65. }
  66. function showStart()
  67. {
  68. $this->out->elementStart('li', array('class' => 'notice-data notice-faves'));
  69. }
  70. function showEnd()
  71. {
  72. $this->out->elementEnd('li');
  73. }
  74. }