quickie inline reply posting form

This commit is contained in:
Brion Vibber 2011-02-28 12:41:03 -08:00
parent 934ae38acd
commit 2370208540

View File

@ -171,6 +171,10 @@ class ThreadedNoticeListItem extends NoticeListItem
$item = new ThreadedNoticeListSubItem($notice, $this->out); $item = new ThreadedNoticeListSubItem($notice, $this->out);
$item->show(); $item->show();
} }
if (common_current_user()) {
$item = new ThreadedNoticeListReplyItem($this->notice, $this->out);
$item->show();
}
$this->out->elementEnd('ul'); $this->out->elementEnd('ul');
} }
@ -196,3 +200,47 @@ class ThreadedNoticeListSubItem extends NoticeListItem
// //
} }
} }
/**
* Show a mini inline posting form for replies.
*/
class ThreadedNoticeListReplyItem extends NoticeListItem
{
/**
* recipe function for displaying a single notice.
*
* This uses all the other methods to correctly display a notice. Override
* it or one of the others to fine-tune the output.
*
* @return void
*/
function show()
{
$this->showStart();
$this->showMiniForm();
$this->showEnd();
}
function showMiniForm()
{
$replyToId = $this->notice->id;
$id = 'replyto-notice-' + $replyToId;
$url = common_local_url('newnotice');
// @fixme replace this with an ajax-friendly form pair?
$this->out->elementStart('form',
array('id' => $id,
'class' => 'replyform',
'method' => 'post',
'action' => $url));
$this->out->hidden('token', common_session_token());
$this->out->hidden("$id-inreplyto", $replyToId, "inreplyto");
$this->out->element('textarea', array('name' => 'status_textarea'));
$this->out->elementStart('div', array('class' => 'controls'));
$this->out->submit("$id-submit", _m('Send reply'));
$this->out->elementEnd('div');
$this->out->elementEnd('form');
}
}