Stronger typing for NoticeListItem and so
This commit is contained in:
parent
49188e826c
commit
d596513e39
@ -170,6 +170,9 @@ class NewnoticeAction extends FormAction
|
|||||||
|
|
||||||
Event::handle('EndNoticeSaveWeb', array($this, $notice));
|
Event::handle('EndNoticeSaveWeb', array($this, $notice));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert($notice instanceof Notice);
|
||||||
|
|
||||||
Event::handle('EndSaveNewNoticeWeb', array($this, $user, &$content_shortened, &$options));
|
Event::handle('EndSaveNewNoticeWeb', array($this, $user, &$content_shortened, &$options));
|
||||||
|
|
||||||
if (StatusNet::isAjax()) {
|
if (StatusNet::isAjax()) {
|
||||||
@ -345,7 +348,7 @@ class NewnoticeAction extends FormAction
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function showNotice($notice)
|
function showNotice(Notice $notice)
|
||||||
{
|
{
|
||||||
$nli = new NoticeListItem($notice, $this);
|
$nli = new NoticeListItem($notice, $this);
|
||||||
$nli->show();
|
$nli->show();
|
||||||
|
@ -114,21 +114,20 @@ class ShownoticeAction extends Action
|
|||||||
$id = $this->arg('notice');
|
$id = $this->arg('notice');
|
||||||
|
|
||||||
$notice = Notice::getKV('id', $id);
|
$notice = Notice::getKV('id', $id);
|
||||||
|
if ($notice instanceof Notice) {
|
||||||
|
// Alright, got it!
|
||||||
|
return $notice;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$notice instanceof Notice) {
|
// Did we use to have it, and it got deleted?
|
||||||
// Did we used to have it, and it got deleted?
|
$deleted = Deleted_notice::getKV('id', $id);
|
||||||
$deleted = Deleted_notice::getKV($id);
|
|
||||||
if ($deleted instanceof Deleted_notice) {
|
if ($deleted instanceof Deleted_notice) {
|
||||||
// TRANS: Client error displayed trying to show a deleted notice.
|
// TRANS: Client error displayed trying to show a deleted notice.
|
||||||
$this->clientError(_('Notice deleted.'), 410);
|
$this->clientError(_('Notice deleted.'), 410);
|
||||||
} else {
|
}
|
||||||
// TRANS: Client error displayed trying to show a non-existing notice.
|
// TRANS: Client error displayed trying to show a non-existing notice.
|
||||||
$this->clientError(_('No such notice.'), 404);
|
$this->clientError(_('No such notice.'), 404);
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return $notice;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this action read-only?
|
* Is this action read-only?
|
||||||
|
@ -58,7 +58,7 @@ class NoticeList extends Widget
|
|||||||
*
|
*
|
||||||
* @param Notice $notice stream of notices from DB_DataObject
|
* @param Notice $notice stream of notices from DB_DataObject
|
||||||
*/
|
*/
|
||||||
function __construct($notice, $out=null)
|
function __construct(Notice $notice, $out=null)
|
||||||
{
|
{
|
||||||
parent::__construct($out);
|
parent::__construct($out);
|
||||||
$this->notice = $notice;
|
$this->notice = $notice;
|
||||||
@ -111,7 +111,7 @@ class NoticeList extends Widget
|
|||||||
*
|
*
|
||||||
* @return NoticeListItem a list item for displaying the notice
|
* @return NoticeListItem a list item for displaying the notice
|
||||||
*/
|
*/
|
||||||
function newListItem($notice)
|
function newListItem(Notice $notice)
|
||||||
{
|
{
|
||||||
return new NoticeListItem($notice, $this->out);
|
return new NoticeListItem($notice, $this->out);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ class NoticeListItem extends Widget
|
|||||||
*
|
*
|
||||||
* @param Notice $notice The notice we'll display
|
* @param Notice $notice The notice we'll display
|
||||||
*/
|
*/
|
||||||
function __construct($notice, $out=null)
|
function __construct(Notice $notice, HTMLOutputter $out=null)
|
||||||
{
|
{
|
||||||
parent::__construct($out);
|
parent::__construct($out);
|
||||||
if (!empty($notice->repeat_of)) {
|
if (!empty($notice->repeat_of)) {
|
||||||
|
@ -70,7 +70,7 @@ class NoticeSection extends Section
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showNotice($notice)
|
function showNotice(Notice $notice)
|
||||||
{
|
{
|
||||||
$profile = $notice->getProfile();
|
$profile = $notice->getProfile();
|
||||||
if (empty($profile)) {
|
if (empty($profile)) {
|
||||||
|
@ -50,7 +50,7 @@ class ThreadedNoticeList extends NoticeList
|
|||||||
{
|
{
|
||||||
protected $userProfile;
|
protected $userProfile;
|
||||||
|
|
||||||
function __construct($notice, $out=null, $profile=-1)
|
function __construct(Notice $notice, HTMLOutputter $out=null, $profile=-1)
|
||||||
{
|
{
|
||||||
parent::__construct($notice, $out);
|
parent::__construct($notice, $out);
|
||||||
if (is_int($profile) && $profile == -1) {
|
if (is_int($profile) && $profile == -1) {
|
||||||
@ -147,7 +147,7 @@ class ThreadedNoticeList extends NoticeList
|
|||||||
*
|
*
|
||||||
* @return NoticeListItem a list item for displaying the notice
|
* @return NoticeListItem a list item for displaying the notice
|
||||||
*/
|
*/
|
||||||
function newListItem($notice)
|
function newListItem(Notice $notice)
|
||||||
{
|
{
|
||||||
return new ThreadedNoticeListItem($notice, $this->out, $this->userProfile);
|
return new ThreadedNoticeListItem($notice, $this->out, $this->userProfile);
|
||||||
}
|
}
|
||||||
@ -174,7 +174,7 @@ class ThreadedNoticeListItem extends NoticeListItem
|
|||||||
{
|
{
|
||||||
protected $userProfile = null;
|
protected $userProfile = null;
|
||||||
|
|
||||||
function __construct($notice, $out=null, $profile=null)
|
function __construct(Notice $notice, HTMLOutputter $out=null, $profile=null)
|
||||||
{
|
{
|
||||||
parent::__construct($notice, $out);
|
parent::__construct($notice, $out);
|
||||||
$this->userProfile = $profile;
|
$this->userProfile = $profile;
|
||||||
@ -269,7 +269,7 @@ class ThreadedNoticeListSubItem extends NoticeListItem
|
|||||||
{
|
{
|
||||||
protected $root = null;
|
protected $root = null;
|
||||||
|
|
||||||
function __construct($notice, $root, $out)
|
function __construct(Notice $notice, $root, $out)
|
||||||
{
|
{
|
||||||
$this->root = $root;
|
$this->root = $root;
|
||||||
parent::__construct($notice, $out);
|
parent::__construct($notice, $out);
|
||||||
@ -327,7 +327,7 @@ class ThreadedNoticeListMoreItem extends NoticeListItem
|
|||||||
{
|
{
|
||||||
protected $cnt;
|
protected $cnt;
|
||||||
|
|
||||||
function __construct($notice, $out, $cnt)
|
function __construct(Notice $notice, HTMLOutputter $out, $cnt)
|
||||||
{
|
{
|
||||||
parent::__construct($notice, $out);
|
parent::__construct($notice, $out);
|
||||||
$this->cnt = $cnt;
|
$this->cnt = $cnt;
|
||||||
|
@ -191,7 +191,7 @@ class NewbookmarkAction extends Action
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function showNotice($notice)
|
function showNotice(Notice $notice)
|
||||||
{
|
{
|
||||||
class_exists('NoticeList'); // @fixme hack for autoloader
|
class_exists('NoticeList'); // @fixme hack for autoloader
|
||||||
$nli = new NoticeListItem($notice, $this);
|
$nli = new NoticeListItem($notice, $this);
|
||||||
|
@ -320,7 +320,7 @@ class NeweventAction extends Action
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function showNotice($notice)
|
function showNotice(Notice $notice)
|
||||||
{
|
{
|
||||||
$nli = new NoticeListItem($notice, $this);
|
$nli = new NoticeListItem($notice, $this);
|
||||||
$nli->show();
|
$nli->show();
|
||||||
|
@ -379,7 +379,7 @@ class PollPlugin extends MicroAppPlugin
|
|||||||
* open here, but we probably shouldn't open it here. Check parent class
|
* open here, but we probably shouldn't open it here. Check parent class
|
||||||
* and Bookmark plugin for if that's right.
|
* and Bookmark plugin for if that's right.
|
||||||
*/
|
*/
|
||||||
function showNotice($notice, $out)
|
function showNotice(Notice $notice, $out)
|
||||||
{
|
{
|
||||||
switch ($notice->object_type) {
|
switch ($notice->object_type) {
|
||||||
case self::POLL_OBJECT:
|
case self::POLL_OBJECT:
|
||||||
@ -393,7 +393,7 @@ class PollPlugin extends MicroAppPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showNoticePoll($notice, $out)
|
function showNoticePoll(Notice $notice, $out)
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
@ -425,7 +425,7 @@ class PollPlugin extends MicroAppPlugin
|
|||||||
$out->elementStart('div', array('class' => 'entry-content'));
|
$out->elementStart('div', array('class' => 'entry-content'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function showNoticePollResponse($notice, $out)
|
function showNoticePollResponse(Notice $notice, $out)
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ class NewPollAction extends Action
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function showNotice($notice)
|
function showNotice(Notice $notice)
|
||||||
{
|
{
|
||||||
class_exists('NoticeList'); // @fixme hack for autoloader
|
class_exists('NoticeList'); // @fixme hack for autoloader
|
||||||
$nli = new NoticeListItem($notice, $this);
|
$nli = new NoticeListItem($notice, $this);
|
||||||
|
@ -319,7 +319,7 @@ class QnAPlugin extends MicroAppPlugin
|
|||||||
* @param Notice $notice
|
* @param Notice $notice
|
||||||
* @param HTMLOutputter $out
|
* @param HTMLOutputter $out
|
||||||
*/
|
*/
|
||||||
function showNotice($notice, $out)
|
function showNotice(Notice $notice, $out)
|
||||||
{
|
{
|
||||||
switch ($notice->object_type) {
|
switch ($notice->object_type) {
|
||||||
case QnA_Question::OBJECT_TYPE:
|
case QnA_Question::OBJECT_TYPE:
|
||||||
@ -337,7 +337,7 @@ class QnAPlugin extends MicroAppPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showNoticeQuestion($notice, $out)
|
function showNoticeQuestion(Notice $notice, $out)
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
@ -427,7 +427,7 @@ class QnAPlugin extends MicroAppPlugin
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showNoticeAnswer($notice, $out)
|
function showNoticeAnswer(Notice $notice, $out)
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user