2015-07-03 23:02:05 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
|
|
|
|
2015-07-04 18:48:35 +01:00
|
|
|
abstract class NoticestreamAction extends ProfileAction
|
2015-07-03 23:02:05 +01:00
|
|
|
{
|
2015-07-10 11:34:06 +01:00
|
|
|
protected $notice = null; // holds the stream result
|
2015-07-04 18:48:35 +01:00
|
|
|
|
|
|
|
protected function prepare(array $args=array()) {
|
|
|
|
parent::prepare($args);
|
|
|
|
|
2015-09-27 22:46:30 +01:00
|
|
|
// In case we need more info than ProfileAction->doPreparation() gives us
|
|
|
|
$this->doStreamPreparation();
|
|
|
|
|
2015-07-04 18:48:35 +01:00
|
|
|
// fetch the actual stream stuff
|
2016-01-03 18:05:49 +00:00
|
|
|
try {
|
|
|
|
$stream = $this->getStream();
|
|
|
|
$this->notice = $stream->getNotices(($this->page-1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
|
|
|
|
} catch (PrivateStreamException $e) {
|
|
|
|
$this->notice = new Notice();
|
|
|
|
$this->notice->whereAdd('FALSE');
|
|
|
|
}
|
2015-07-04 18:48:35 +01:00
|
|
|
|
|
|
|
if ($this->page > 1 && $this->notice->N == 0) {
|
|
|
|
// TRANS: Client error when page not found (404).
|
|
|
|
$this->clientError(_('No such page.'), 404);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-09-27 22:46:30 +01:00
|
|
|
protected function doStreamPreparation()
|
|
|
|
{
|
|
|
|
// pass by default
|
|
|
|
}
|
|
|
|
|
2016-02-24 15:48:44 +00:00
|
|
|
public function extraHeaders()
|
|
|
|
{
|
|
|
|
parent::extraHeaders();
|
|
|
|
foreach ($this->getFeeds() as $feed) {
|
|
|
|
header('Link: <'.htmlspecialchars($feed->getUrl()).'>;' .
|
|
|
|
' rel="'.htmlspecialchars($feed->rel()).'";' .
|
|
|
|
' type="'.htmlspecialchars($feed->mimeType()).'"',
|
|
|
|
false // don't overwrite previous headers of this sort
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-03 23:02:05 +01:00
|
|
|
// this fetches the NoticeStream
|
2015-07-04 18:48:35 +01:00
|
|
|
abstract public function getStream();
|
2015-07-03 23:02:05 +01:00
|
|
|
}
|