]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/newnotice.php
Change the title of NewnoticeAction if replying
[quix0rs-gnu-social.git] / actions / newnotice.php
index 81438502fa67639d4ba28a9934ff22bae960dcd0..ff1af6344255a13626f84181a2e24a16e551f9e2 100644 (file)
@@ -62,6 +62,9 @@ class NewnoticeAction extends FormAction
             // TRANS: Page title after sending a notice.
             return _('Notice posted');
         }
+        if ($this->int('inreplyto')) {
+            return _m('TITLE', 'New reply');
+        }
         // TRANS: Page title for sending a new notice.
         return _m('TITLE','New notice');
     }
@@ -69,10 +72,14 @@ class NewnoticeAction extends FormAction
     protected function doPreparation()
     {
         foreach(array('inreplyto') as $opt) {
-            if (!empty($this->trimmed($opt))) {
+            if ($this->trimmed($opt)) {
                 $this->formOpts[$opt] = $this->trimmed($opt);
             }
         }
+
+        // Backwards compatibility for "share this" widget things.
+        // If no 'content', use 'status_textarea'
+        $this->formOpts['content'] = $this->trimmed('content') ?: $this->trimmed('status_textarea');
     }
 
     /**
@@ -106,7 +113,7 @@ class NewnoticeAction extends FormAction
         $cmd = $inter->handle_command($user, $content);
 
         if ($cmd) {
-            if (StatusNet::isAjax()) {
+            if (GNUsocial::isAjax()) {
                 $cmd->execute(new AjaxWebChannel($this));
             } else {
                 $cmd->execute(new WebChannel($this));
@@ -124,15 +131,15 @@ class NewnoticeAction extends FormAction
                                        Notice::maxContent()));
         }
 
-        $replyto = intval($this->trimmed('inreplyto'));
+        $replyto = $this->int('inreplyto');
         if ($replyto) {
             $options['reply_to'] = $replyto;
         }
 
-        $upload = MediaFile::fromUpload('attach', $this->scoped);
-
-        if (isset($upload)) {
-
+        $upload = null;
+        try {
+            // throws exception on failure
+            $upload = MediaFile::fromUpload('attach', $this->scoped);
             if (Event::handle('StartSaveNewNoticeAppendAttachment', array($this, $upload, &$content_shortened, &$options))) {
                 $content_shortened .= ' ' . $upload->shortUrl();
             }
@@ -147,8 +154,11 @@ class NewnoticeAction extends FormAction
                                               Notice::maxContent()),
                                            Notice::maxContent()));
             }
+        } catch (NoUploadedMediaException $e) {
+            // simply no attached media to the new notice
         }
 
+
         if ($this->scoped->shareLocation()) {
             // use browser data if checked; otherwise profile data
             if ($this->arg('notice_data-geo')) {
@@ -179,7 +189,7 @@ class NewnoticeAction extends FormAction
 
             $this->stored = Notice::saveNew($this->scoped->id, $content_shortened, 'web', $options);
 
-            if (isset($upload)) {
+            if ($upload instanceof MediaFile) {
                 $upload->attachToNotice($this->stored);
             }
 
@@ -188,15 +198,8 @@ class NewnoticeAction extends FormAction
 
         Event::handle('EndSaveNewNoticeWeb', array($this, $user, &$content_shortened, &$options));
 
-        if (!StatusNet::isAjax()) {
-            $returnto = $this->trimmed('returnto');
-
-            if ($returnto) {
-                $url = common_local_url($returnto,
-                                        array('nickname' => $this->scoped->getNickname()));
-            } else {
-                $url = common_local_url('shownotice', array('notice' => $this->stored->id));
-            }
+        if (!GNUsocial::isAjax()) {
+            $url = common_local_url('shownotice', array('notice' => $this->stored->id));
             common_redirect($url, 303);
         }
 
@@ -226,4 +229,9 @@ class NewnoticeAction extends FormAction
         $nli = new NoticeListItem($notice, $this);
         $nli->show();
     }
+
+    public function showNoticeForm()
+    {
+        // pass
+    }
 }