networkpublic.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. if (!defined('GNUSOCIAL')) { exit(1); }
  3. class NetworkpublicAction extends SitestreamAction
  4. {
  5. protected function streamPrepare()
  6. {
  7. if (!$this->scoped instanceof Profile && common_config('public', 'localonly')) {
  8. $this->clientError(_('Network wide public feed is not permitted without authorization'), 403);
  9. }
  10. if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
  11. $this->stream = new NetworkPublicNoticeStream($this->scoped);
  12. } else {
  13. $this->stream = new ThreadingNetworkPublicNoticeStream($this->scoped);
  14. }
  15. }
  16. function title()
  17. {
  18. if ($this->page > 1) {
  19. // TRANS: Title for all public timeline pages but the first.
  20. // TRANS: %d is the page number.
  21. return sprintf(_('Network public timeline, page %d'), $this->page);
  22. } else {
  23. // TRANS: Title for the first public timeline page.
  24. return _('Network public timeline');
  25. }
  26. }
  27. function showSections()
  28. {
  29. // Show invite button, as long as site isn't closed, and
  30. // we have a logged in user.
  31. if (common_config('invite', 'enabled') && !common_config('site', 'closed') && common_logged_in()) {
  32. if (!common_config('site', 'private')) {
  33. $ibs = new InviteButtonSection(
  34. $this,
  35. // TRANS: Button text for inviting more users to the StatusNet instance.
  36. // TRANS: Less business/enterprise-oriented language for public sites.
  37. _m('BUTTON', 'Send invite')
  38. );
  39. } else {
  40. $ibs = new InviteButtonSection($this);
  41. }
  42. $ibs->show();
  43. }
  44. // Network public tag cloud?
  45. }
  46. /**
  47. * Output <head> elements for RSS and Atom feeds
  48. *
  49. * @return array
  50. */
  51. function getFeeds()
  52. {
  53. return [
  54. new Feed(Feed::ATOM,
  55. common_local_url('ApiTimelinePublic',
  56. array('format' => 'atom')),
  57. // TRANS: Link description for public timeline feed.
  58. _('Public Timeline Feed (Atom)')
  59. ),
  60. new Feed(Feed::JSON,
  61. common_local_url('ApiTimelinePublic',
  62. array('format' => 'as')),
  63. // TRANS: Link description for public timeline feed.
  64. _('Public Timeline Feed (Activity Streams JSON)')
  65. ),
  66. new Feed(Feed::RSS1, common_local_url('publicrss'),
  67. // TRANS: Link description for public timeline feed.
  68. _('Public Timeline Feed (RSS 1.0)')
  69. ),
  70. new Feed(Feed::RSS2,
  71. common_local_url('ApiTimelinePublic',
  72. array('format' => 'rss')),
  73. // TRANS: Link description for public timeline feed.
  74. _('Public Timeline Feed (RSS 2.0)')
  75. ),
  76. ];
  77. }
  78. }