2015-07-04 07:02:05 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
|
|
|
|
2015-07-05 02:48:35 +09:00
|
|
|
abstract class NoticestreamAction extends ProfileAction
|
2015-07-04 07:02:05 +09:00
|
|
|
{
|
2015-07-10 19:34:06 +09:00
|
|
|
protected $notice = null; // holds the stream result
|
2015-07-05 02:48:35 +09:00
|
|
|
|
|
|
|
protected function prepare(array $args=array()) {
|
|
|
|
parent::prepare($args);
|
|
|
|
|
2015-09-28 06:46:30 +09:00
|
|
|
// In case we need more info than ProfileAction->doPreparation() gives us
|
|
|
|
$this->doStreamPreparation();
|
|
|
|
|
2015-07-05 02:48:35 +09:00
|
|
|
// fetch the actual stream stuff
|
2016-01-04 03:05:49 +09: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-05 02:48:35 +09: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-28 06:46:30 +09:00
|
|
|
protected function doStreamPreparation()
|
|
|
|
{
|
|
|
|
// pass by default
|
|
|
|
}
|
|
|
|
|
2016-02-25 00:48:44 +09: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-04 07:02:05 +09:00
|
|
|
// this fetches the NoticeStream
|
2015-07-05 02:48:35 +09:00
|
|
|
abstract public function getStream();
|
2015-07-04 07:02:05 +09:00
|
|
|
}
|