noticestreamaction.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. if (!defined('GNUSOCIAL')) { exit(1); }
  3. abstract class NoticestreamAction extends ProfileAction
  4. {
  5. protected $notice = null; // holds the stream result
  6. protected function prepare(array $args=array()) {
  7. parent::prepare($args);
  8. // In case we need more info than ProfileAction->doPreparation() gives us
  9. $this->doStreamPreparation();
  10. // fetch the actual stream stuff
  11. try {
  12. $stream = $this->getStream();
  13. $this->notice = $stream->getNotices(($this->page-1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
  14. } catch (PrivateStreamException $e) {
  15. $this->notice = new Notice();
  16. $this->notice->whereAdd('FALSE');
  17. }
  18. if ($this->page > 1 && $this->notice->N == 0) {
  19. // TRANS: Client error when page not found (404).
  20. $this->clientError(_('No such page.'), 404);
  21. }
  22. return true;
  23. }
  24. protected function doStreamPreparation()
  25. {
  26. // pass by default
  27. }
  28. public function extraHeaders()
  29. {
  30. parent::extraHeaders();
  31. foreach ($this->getFeeds() as $feed) {
  32. header('Link: <'.htmlspecialchars($feed->getUrl()).'>;' .
  33. ' rel="'.htmlspecialchars($feed->rel()).'";' .
  34. ' type="'.htmlspecialchars($feed->mimeType()).'"',
  35. false // don't overwrite previous headers of this sort
  36. );
  37. }
  38. }
  39. // this fetches the NoticeStream
  40. abstract public function getStream();
  41. }