]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Web UI for notices correctly shows and checks max content length
authorEvan Prodromou <evan@controlyourself.ca>
Fri, 21 Aug 2009 12:13:17 +0000 (08:13 -0400)
committerEvan Prodromou <evan@controlyourself.ca>
Fri, 21 Aug 2009 12:13:17 +0000 (08:13 -0400)
actions/newnotice.php
lib/noticeform.php

index e254eac4999852389b8623b36db62d10826f5bb3..f773fc880e5328ae1f232252c84e8d79d6703eb9 100644 (file)
@@ -162,9 +162,10 @@ class NewnoticeAction extends Action
             $this->clientError(_('No content!'));
         } else {
             $content_shortened = common_shorten_links($content);
-            if (mb_strlen($content_shortened) > 140) {
-                $this->clientError(_('That\'s too long. '.
-                                     'Max notice size is 140 chars.'));
+            if (Notice::contentTooLong($content_shortened)) {
+                $this->clientError(sprintf(_('That\'s too long. '.
+                                             'Max notice size is %d chars.'),
+                                           Notice::maxContent()));
             }
         }
 
@@ -241,9 +242,10 @@ class NewnoticeAction extends Action
             $short_fileurl = common_shorten_url($fileurl);
             $content_shortened .= ' ' . $short_fileurl;
 
-            if (mb_strlen($content_shortened) > 140) {
+            if (Notice::contentTooLong($content_shortened)) {
                 $this->deleteFile($filename);
-                $this->clientError(_('Max notice size is 140 chars, including attachment URL.'));
+                $this->clientError(sprintf(_('Max notice size is %d chars, including attachment URL.'),
+                                           Notice::maxContent()));
             }
 
             // Also, not sure this is necessary -- Zach
index 4e2a2edd61ff78c085d46e5c7419228e7a83a57a..35a21c6bd00518bf52ed0c6a6f98cb65c5abe80e 100644 (file)
@@ -83,7 +83,7 @@ class NoticeForm extends Form
 
         $this->action  = $action;
         $this->content = $content;
-        
+
         if ($user) {
             $this->user = $user;
         } else {
@@ -117,7 +117,6 @@ class NoticeForm extends Form
         return common_local_url('newnotice');
     }
 
-
     /**
      * Legend of the Form
      *
@@ -128,7 +127,6 @@ class NoticeForm extends Form
         $this->out->element('legend', null, _('Send a notice'));
     }
 
-
     /**
      * Data elements
      *
@@ -145,11 +143,20 @@ class NoticeForm extends Form
                                               'rows' => 4,
                                               'name' => 'status_textarea'),
                             ($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 = Notice::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');
+        }
+
         if (common_config('attachments', 'uploads')) {
             $this->out->element('label', array('for' => 'notice_data-attach'),_('Attach'));
             $this->out->element('input', array('id' => 'notice_data-attach',