popularnoticesection.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * Base class for sections showing lists of notices
  6. *
  7. * PHP version 5
  8. *
  9. * LICENCE: This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. * @category Widget
  23. * @package StatusNet
  24. * @author Evan Prodromou <evan@status.net>
  25. * @copyright 2009,2011 StatusNet, Inc.
  26. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  27. * @link http://status.net/
  28. */
  29. if (!defined('STATUSNET') && !defined('LACONICA')) {
  30. exit(1);
  31. }
  32. /**
  33. * Base class for sections showing lists of notices
  34. *
  35. * These are the widgets that show interesting data about a person
  36. * group, or site.
  37. *
  38. * @category Widget
  39. * @package StatusNet
  40. * @author Evan Prodromou <evan@status.net>
  41. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  42. * @link http://status.net/
  43. */
  44. class PopularNoticeSection extends NoticeSection
  45. {
  46. protected $viewer;
  47. function __construct($out, Profile $viewer=null)
  48. {
  49. parent::__construct($out);
  50. $this->viewer = $viewer;
  51. }
  52. function getNotices()
  53. {
  54. $stream = new PopularNoticeStream($this->viewer);
  55. return $stream->getNotices(0, NOTICES_PER_SECTION + 1);
  56. }
  57. function title()
  58. {
  59. // TRANS: Title for favourited notices section.
  60. return _('Popular notices');
  61. }
  62. function divId()
  63. {
  64. return 'popular_section';
  65. }
  66. function moreUrl()
  67. {
  68. if (common_config('singleuser', 'enabled')) {
  69. $user = User::singleUser();
  70. common_local_url('showfavorites', array('nickname' =>
  71. $user->nickname));
  72. } else {
  73. return common_local_url('favorited');
  74. }
  75. }
  76. }