conversation.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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')) { exit(1); }
  31. /**
  32. * Conversation tree in the browser
  33. *
  34. * Will always try to show the entire conversation, since that's how our
  35. * ConversationNoticeStream works.
  36. *
  37. * @category Action
  38. * @package StatusNet
  39. * @author Evan Prodromou <evan@status.net>
  40. * @author Mikael Nordfeldth <mmn@hethane.se>
  41. * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
  42. * @link http://status.net/
  43. */
  44. class ConversationAction extends ManagedAction
  45. {
  46. var $conv = null;
  47. var $page = null;
  48. var $notices = null;
  49. /**
  50. * Initialization.
  51. *
  52. * @param array $args Web and URL arguments
  53. *
  54. * @return boolean false if id not passed in
  55. */
  56. protected function prepare(array $args=array())
  57. {
  58. parent::prepare($args);
  59. $convId = $this->int('id');
  60. $this->conv = Conversation::getKV('id', $convId);
  61. if (!$this->conv instanceof Conversation) {
  62. throw new ClientException('Could not find specified conversation');
  63. }
  64. return true;
  65. }
  66. /**
  67. * Returns the page title
  68. *
  69. * @return string page title
  70. */
  71. function title()
  72. {
  73. // TRANS: Title for page with a conversion (multiple notices in context).
  74. return _('Conversation');
  75. }
  76. /**
  77. * Show content.
  78. *
  79. * NoticeList extended classes do most heavy lifting. Plugins can override.
  80. *
  81. * @return void
  82. */
  83. function showContent()
  84. {
  85. if (Event::handle('StartShowConversation', array($this, $this->conv, $this->scoped))) {
  86. $notices = $this->conv->getNotices();
  87. $nl = new FullThreadedNoticeList($notices, $this, $this->scoped);
  88. $cnt = $nl->show();
  89. }
  90. Event::handle('EndShowConversation', array($this, $this->conv, $this->scoped));
  91. }
  92. function isReadOnly()
  93. {
  94. return true;
  95. }
  96. function getFeeds()
  97. {
  98. return array(new Feed(Feed::JSON,
  99. common_local_url('apiconversation',
  100. array(
  101. 'id' => $this->conv->id,
  102. 'format' => 'as')),
  103. // TRANS: Title for link to notice feed.
  104. // TRANS: %s is a user nickname.
  105. _('Conversation feed (Activity Streams JSON)')),
  106. new Feed(Feed::RSS2,
  107. common_local_url('apiconversation',
  108. array(
  109. 'id' => $this->conv->id,
  110. 'format' => 'rss')),
  111. // TRANS: Title for link to notice feed.
  112. // TRANS: %s is a user nickname.
  113. _('Conversation feed (RSS 2.0)')),
  114. new Feed(Feed::ATOM,
  115. common_local_url('apiconversation',
  116. array(
  117. 'id' => $this->conv->id,
  118. 'format' => 'atom')),
  119. // TRANS: Title for link to notice feed.
  120. // TRANS: %s is a user nickname.
  121. _('Conversation feed (Activity Streams JSON)')));
  122. }
  123. }