public.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * Action for displaying the public stream
  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 Public
  23. * @package StatusNet
  24. * @author Evan Prodromou <evan@status.net>
  25. * @copyright 2008-2009 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('GNUSOCIAL')) { exit(1); }
  30. /**
  31. * Action for displaying the public stream
  32. *
  33. * @category Public
  34. * @package StatusNet
  35. * @author Evan Prodromou <evan@status.net>
  36. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  37. * @link http://status.net/
  38. *
  39. * @see PublicrssAction
  40. */
  41. class PublicAction extends SitestreamAction
  42. {
  43. protected function streamPrepare()
  44. {
  45. if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
  46. $this->stream = new PublicNoticeStream($this->scoped);
  47. } else {
  48. $this->stream = new ThreadingPublicNoticeStream($this->scoped);
  49. }
  50. }
  51. /**
  52. * Title of the page
  53. *
  54. * @return page title, including page number if over 1
  55. */
  56. function title()
  57. {
  58. if ($this->page > 1) {
  59. // TRANS: Title for all public timeline pages but the first.
  60. // TRANS: %d is the page number.
  61. return sprintf(_('Public timeline, page %d'), $this->page);
  62. } else {
  63. // TRANS: Title for the first public timeline page.
  64. return _('Public timeline');
  65. }
  66. }
  67. function showSections()
  68. {
  69. // Show invite button, as long as site isn't closed, and
  70. // we have a logged in user.
  71. if (common_config('invite', 'enabled') && !common_config('site', 'closed') && common_logged_in()) {
  72. if (!common_config('site', 'private')) {
  73. $ibs = new InviteButtonSection(
  74. $this,
  75. // TRANS: Button text for inviting more users to the StatusNet instance.
  76. // TRANS: Less business/enterprise-oriented language for public sites.
  77. _m('BUTTON', 'Send invite')
  78. );
  79. } else {
  80. $ibs = new InviteButtonSection($this);
  81. }
  82. $ibs->show();
  83. }
  84. $feat = new FeaturedUsersSection($this);
  85. $feat->show();
  86. }
  87. /**
  88. * Output <head> elements for RSS and Atom feeds
  89. *
  90. * @return array
  91. */
  92. function getFeeds()
  93. {
  94. return [
  95. new Feed(Feed::ATOM,
  96. common_local_url('ApiTimelinePublic',
  97. array('format' => 'atom')),
  98. // TRANS: Link description for public timeline feed.
  99. _('Public Timeline Feed (Atom)')
  100. ),
  101. new Feed(Feed::JSON,
  102. common_local_url('ApiTimelinePublic',
  103. array('format' => 'as')),
  104. // TRANS: Link description for public timeline feed.
  105. _('Public Timeline Feed (Activity Streams JSON)')
  106. ),
  107. new Feed(Feed::RSS1, common_local_url('publicrss'),
  108. // TRANS: Link description for public timeline feed.
  109. _('Public Timeline Feed (RSS 1.0)')
  110. ),
  111. new Feed(Feed::RSS2,
  112. common_local_url('ApiTimelinePublic',
  113. array('format' => 'rss')),
  114. // TRANS: Link description for public timeline feed.
  115. _('Public Timeline Feed (RSS 2.0)')
  116. ),
  117. ];
  118. }
  119. }