message input form correctly shows and check max length

This commit is contained in:
Evan Prodromou 2009-08-21 07:23:27 -04:00
parent 6dcded4129
commit de5382d4ca
2 changed files with 16 additions and 8 deletions

View File

@ -144,9 +144,10 @@ class NewmessageAction extends Action
} else {
$content_shortened = common_shorten_links($this->content);
if (mb_strlen($content_shortened) > 140) {
$this->showForm(_('That\'s too long. ' .
'Max message size is 140 chars.'));
if (Message::contentTooLong($content_shortened)) {
$this->showForm(sprintf(_('That\'s too long. ' .
'Max message size is %d chars.'),
Message::maxContent()));
return;
}
}

View File

@ -140,12 +140,19 @@ class MessageForm extends Form
'rows' => 4,
'name' => 'content'),
($this->content) ? $this->content : '');
$this->out->elementStart('dl', 'form_note');
$this->out->element('dt', null, _('Available characters'));
$this->out->element('dd', array('id' => 'notice_text-count'),
'140');
$this->out->elementEnd('dl');
$contentLimit = Message::maxContent();
$this->out->element('script', array('type' => 'text/javascript'),
'maxLength = ' . $contentLimit . ';');
if ($contentLimit > 0) {
$this->out->elementStart('dl', 'form_note');
$this->out->element('dt', null, _('Available characters'));
$this->out->element('dd', array('id' => 'notice_text-count'),
$contentLimit);
$this->out->elementEnd('dl');
}
}
/**