noticestreamaction.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. // this fetches the NoticeStream
  29. abstract public function getStream();
  30. }