Conversation.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. declare(strict_types = 1);
  3. // {{{ License
  4. // This file is part of GNU social - https://www.gnu.org/software/social
  5. //
  6. // GNU social is free software: you can redistribute it and/or modify
  7. // it under the terms of the GNU Affero General Public License as published by
  8. // the Free Software Foundation, either version 3 of the License, or
  9. // (at your option) any later version.
  10. //
  11. // GNU social is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU Affero General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU Affero General Public License
  17. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  18. // }}}
  19. /**
  20. * @author Hugo Sales <hugo@hsal.es>
  21. * @copyright 2021 Free Software Foundation, Inc http://www.fsf.org
  22. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  23. */
  24. namespace Component\Conversation\Controller;
  25. use function App\Core\I18n\_m;
  26. use Component\Feed\Feed;
  27. use Component\Feed\Util\FeedController;
  28. use Symfony\Component\HttpFoundation\Request;
  29. class Conversation extends FeedController
  30. {
  31. /**
  32. * Render conversation page
  33. *
  34. * @return array
  35. */
  36. public function showConversation(Request $request, int $conversation_id)
  37. {
  38. // TODO:
  39. // if note is root -> just link
  40. // if note is a reply -> link from above plus anchor
  41. /* $notes = DB::findBy(
  42. table: 'note',
  43. criteria: ['conversation_id' => $conversation_id],
  44. order_by: ['created' => 'DESC', 'id' => 'DESC']
  45. );*/
  46. $data = Feed::query(query: "note-conversation:{$conversation_id}", page: $this->int('p') ?? 1);
  47. $notes = $data['notes'];
  48. return [
  49. '_template' => 'feed/feed.html.twig',
  50. 'notes' => $notes,
  51. 'should_format' => false,
  52. 'page_title' => _m('Conversation'),
  53. ];
  54. }
  55. }