Feeds.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. * Handle network public feed
  21. *
  22. * @package GNUsocial
  23. * @category Controller
  24. *
  25. * @author Hugo Sales <hugo@hsal.es>
  26. * @author Eliseu Amaro <eliseu@fc.up.pt>
  27. * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org
  28. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  29. */
  30. namespace Component\Feed\Controller;
  31. use function App\Core\I18n\_m;
  32. use App\Util\Common;
  33. use App\Util\HTML\Heading;
  34. use Component\Collection\Util\Controller\FeedController;
  35. use Symfony\Component\HttpFoundation\Request;
  36. /**
  37. * @extends FeedController<\App\Entity\Note>
  38. */
  39. class Feeds extends FeedController
  40. {
  41. /**
  42. * The Planet feed represents every local post. Which is what this instance has to share with the universe.
  43. *
  44. * @return ControllerResultType
  45. */
  46. public function public(Request $request): array
  47. {
  48. $data = $this->query('note-local:true');
  49. $page_title = _m(\is_null(Common::user()) ? 'Feed' : 'Planet');
  50. return [
  51. '_template' => 'collection/notes.html.twig',
  52. 'page_title' => $page_title,
  53. 'notes_feed_title' => (new Heading(level: 1, classes: ['feed-title'], text: $page_title)),
  54. 'notes' => $data['notes'],
  55. ];
  56. }
  57. /**
  58. * The Home feed represents everything that concerns a certain actor (its subscriptions)
  59. *
  60. * @return ControllerResultType
  61. */
  62. public function home(Request $request): array
  63. {
  64. Common::ensureLoggedIn();
  65. $data = $this->query('note-from:subscribed-person,subscribed-group,subscribed-organisation');
  66. return [
  67. '_template' => 'collection/notes.html.twig',
  68. 'page_title' => _m('Home'),
  69. 'notes_feed_title' => (new Heading(level: 1, classes: ['feed-title'], text: 'Home')),
  70. 'notes' => $data['notes'],
  71. ];
  72. }
  73. }