FormAction updates, also fixing NoticeForm CSS

This commit is contained in:
Mikael Nordfeldth 2014-07-03 14:00:40 +02:00
parent 1f97376813
commit 2e77cbfa86
6 changed files with 51 additions and 93 deletions

View File

@ -47,6 +47,8 @@ if (!defined('STATUSNET')) {
*/
class NewnoticeAction extends FormAction
{
protected $form = 'Notice';
/**
* Title of the page
*
@ -276,69 +278,6 @@ class NewnoticeAction extends FormAction
parent::showForm($msg, $success);
}
/**
* // XXX: Should we be showing the notice form with microapps here?
*
* Overload for replies or bad results
*
* We show content in the notice form if there were replies or results.
*
* @return void
*/
function showNoticeForm()
{
$content = $this->trimmed('status_textarea');
if (!$content) {
$replyto = $this->trimmed('replyto');
$inreplyto = $this->trimmed('inreplyto');
$profile = Profile::getKV('nickname', $replyto);
if ($profile) {
$content = '@' . $profile->nickname . ' ';
}
} else {
// @fixme most of these bits above aren't being passed on above
$inreplyto = null;
}
$this->elementStart('div', 'input_forms');
$this->elementStart(
'div',
array(
'id' => 'input_form_status',
'class' => 'input_form current nonav'
)
);
$notice_form = new NoticeForm(
$this,
array(
'content' => $content,
'inreplyto' => $inreplyto
)
);
$notice_form->show();
$this->elementEnd('div');
$this->elementEnd('div');
}
/**
* Show an error message
*
* Shows an error message if there is one.
*
* @return void
*
* @todo maybe show some instructions?
*/
function showPageNotice()
{
if ($this->msg) {
$this->element('p', array('id' => 'error'), $this->msg);
}
}
/**
* Output a notice
*

View File

@ -206,6 +206,10 @@ class Action extends HTMLOutputter // lawsuit
*/
function showPage()
{
if (StatusNet::isAjax()) {
self::showAjax();
return;
}
if (Event::handle('StartShowHTML', array($this))) {
$this->startHTML();
$this->flush();
@ -226,6 +230,19 @@ class Action extends HTMLOutputter // lawsuit
}
}
public function showAjax()
{
$this->startHTML('text/xml;charset=utf-8');
$this->elementStart('head');
// TRANS: Title for conversation page.
$this->element('title', null, _m('TITLE','Notice'));
$this->elementEnd('head');
$this->elementStart('body');
$this->showContent();
$this->elementEnd('body');
$this->endHTML();
}
function endHTML()
{
global $_startTime;

View File

@ -98,6 +98,26 @@ class FormAction extends ManagedAction
return null;
}
public function showForm($msg=null, $success=false)
{
$this->msg = $msg;
$this->success = $success;
$this->showPage();
}
public function showContent()
{
$form = $this->getForm();
$form->show();
}
protected function getForm()
{
$class = $this->form.'Form';
$form = new $class($this);
return $form;
}
/**
* Gets called from handle() if isPost() is true;
* @return void

View File

@ -47,28 +47,11 @@ class ManagedAction extends Action
}
}
if (StatusNet::isAjax()) {
$this->showAjax();
} else {
$this->showPage();
}
}
protected function handlePost()
{
// This will only be run if the Action has the property canPost==true
}
public function showAjax()
{
$this->startHTML('text/xml;charset=utf-8');
$this->elementStart('head');
// TRANS: Title for conversation page.
$this->element('title', null, _m('TITLE','Notice'));
$this->elementEnd('head');
$this->elementStart('body');
$this->showContent();
$this->elementEnd('body');
$this->endHTML();
}
}

View File

@ -107,7 +107,7 @@ class NoticeForm extends Form
// Do we have to worry about sub-second race conditions?
// XXX: Needs to be above the parent::__construct() call...?
$this->id_suffix = time();
$this->id_suffix = rand();
parent::__construct($action);

View File

@ -123,6 +123,11 @@ option {
border-right: 1px solid #ccc;
}
#content_inner {
display: block;
position: relative;
}
#site_nav_local_views_wrapper {
width: 100%;
float: left;
@ -279,10 +284,6 @@ address .poweredby {
display: block;
}
#input_form_status, #input_form_direct {
padding-bottom: 50px;
}
.form_notice {
margin-bottom: 10px;
}
@ -544,9 +545,8 @@ address .poweredby {
.form_notice input.submit {
position: absolute;
top: 100%;
left: 0px;
margin-top: -49px;
right: 0px;
margin-top: -1.5em;
float: left;
width: 100px;
padding: 0px;
@ -959,9 +959,8 @@ content: ":";
right: 50px;
}
.threaded-replies .form_notice #notice_action-submit {
left: 10px;
margin-top: -44px;
.threaded-replies .form_notice input.submit {
bottom: 0;
}
.threaded-replies .form_notice .error,