conversation.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * Display a conversation in the browser
  4. *
  5. * PHP version 5
  6. *
  7. * @category Action
  8. * @package StatusNet
  9. * @author Evan Prodromou <evan@status.net>
  10. * @author Mikael Nordfeldth <mmn@hethane.se>
  11. * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
  12. * @link http://status.net/
  13. *
  14. * StatusNet - the distributed open-source microblogging tool
  15. * Copyright (C) 2009, StatusNet, Inc.
  16. *
  17. * This program is free software: you can redistribute it and/or modify
  18. * it under the terms of the GNU Affero General Public License as published by
  19. * the Free Software Foundation, either version 3 of the License, or
  20. * (at your option) any later version.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU Affero General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU Affero General Public License
  28. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  29. */
  30. if (!defined('GNUSOCIAL')) {
  31. exit(1);
  32. }
  33. /**
  34. * Conversation tree in the browser
  35. *
  36. * Will always try to show the entire conversation, since that's how our
  37. * ConversationNoticeStream works.
  38. *
  39. * @category Action
  40. * @package StatusNet
  41. * @author Evan Prodromou <evan@status.net>
  42. * @author Mikael Nordfeldth <mmn@hethane.se>
  43. * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
  44. * @link http://status.net/
  45. */
  46. class ConversationAction extends ManagedAction
  47. {
  48. protected $redirectAfterLogin = true;
  49. public $conv = null;
  50. public $page = null;
  51. public $notices = null;
  52. protected function doPreparation()
  53. {
  54. $this->conv = Conversation::getByID($this->int('id'));
  55. }
  56. /**
  57. * Returns the page title
  58. *
  59. * @return string page title
  60. */
  61. public function title()
  62. {
  63. // TRANS: Title for page with a conversion (multiple notices in context).
  64. return _('Conversation');
  65. }
  66. /**
  67. * Show content.
  68. *
  69. * NoticeList extended classes do most heavy lifting. Plugins can override.
  70. *
  71. * @return void
  72. */
  73. public function showContent()
  74. {
  75. if (Event::handle('StartShowConversation', [$this, $this->conv, $this->scoped])) {
  76. $notices = $this->conv->getNotices($this->scoped);
  77. $nl = new FullThreadedNoticeList($notices, $this, $this->scoped);
  78. $cnt = $nl->show();
  79. }
  80. Event::handle('EndShowConversation', [$this, $this->conv, $this->scoped]);
  81. }
  82. public function isReadOnly($args)
  83. {
  84. return true;
  85. }
  86. public function getFeeds()
  87. {
  88. return [
  89. new Feed(Feed::JSON,
  90. common_local_url('apiconversation',
  91. ['id' => $this->conv->getID(),
  92. 'format' => 'as']),
  93. // TRANS: Title for link to notice feed.
  94. // TRANS: %s is a user nickname.
  95. _('Conversation feed (Activity Streams JSON)')
  96. ),
  97. new Feed(Feed::RSS2,
  98. common_local_url('apiconversation',
  99. ['id' => $this->conv->getID(),
  100. 'format' => 'rss']),
  101. // TRANS: Title for link to notice feed.
  102. // TRANS: %s is a user nickname.
  103. _('Conversation feed (RSS 2.0)')
  104. ),
  105. new Feed(Feed::ATOM,
  106. common_local_url('apiconversation',
  107. ['id' => $this->conv->getID(),
  108. 'format' => 'atom']),
  109. // TRANS: Title for link to notice feed.
  110. // TRANS: %s is a user nickname.
  111. _('Conversation feed (Atom)')
  112. )
  113. ];
  114. }
  115. }