]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
message input form correctly shows and check max length
authorEvan Prodromou <evan@controlyourself.ca>
Fri, 21 Aug 2009 11:23:27 +0000 (07:23 -0400)
committerEvan Prodromou <evan@controlyourself.ca>
Fri, 21 Aug 2009 11:23:27 +0000 (07:23 -0400)
actions/newmessage.php
lib/messageform.php

index 52d4899ba2d453d8012465eaa60def69458df4a2..cd26e1640b5b5f64219fd4af82146ad29e06bfbf 100644 (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;
             }
         }
index 8ea2b36c27b21df3006297edeb2ded887d205d50..044fdc719d31c43c79608162d7ac4102ba948f04 100644 (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');
+        }
     }
 
     /**