]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
quickie inline reply posting form
authorBrion Vibber <brion@pobox.com>
Mon, 28 Feb 2011 20:41:03 +0000 (12:41 -0800)
committerBrion Vibber <brion@pobox.com>
Mon, 28 Feb 2011 20:41:03 +0000 (12:41 -0800)
lib/threadednoticelist.php

index 933a051f38e606d531353818b2d41584776947cb..871a0eb0685f056957710f8e9d036cb6a899a789 100644 (file)
@@ -171,6 +171,10 @@ class ThreadedNoticeListItem extends NoticeListItem
                 $item = new ThreadedNoticeListSubItem($notice, $this->out);
                 $item->show();
             }
+            if (common_current_user()) {
+                $item = new ThreadedNoticeListReplyItem($this->notice, $this->out);
+                $item->show();
+            }
             $this->out->elementEnd('ul');
         }
 
@@ -195,4 +199,48 @@ class ThreadedNoticeListSubItem extends NoticeListItem
     {
         //
     }
+}
+
+/**
+ * Show a mini inline posting form for replies.
+ */
+class ThreadedNoticeListReplyItem extends NoticeListItem
+{
+
+    /**
+     * recipe function for displaying a single notice.
+     *
+     * This uses all the other methods to correctly display a notice. Override
+     * it or one of the others to fine-tune the output.
+     *
+     * @return void
+     */
+
+    function show()
+    {
+        $this->showStart();
+        $this->showMiniForm();
+        $this->showEnd();
+    }
+
+    function showMiniForm()
+    {
+        $replyToId = $this->notice->id;
+        $id = 'replyto-notice-' + $replyToId;
+        $url = common_local_url('newnotice');
+
+        // @fixme replace this with an ajax-friendly form pair?
+        $this->out->elementStart('form',
+                                 array('id' => $id,
+                                       'class' => 'replyform',
+                                       'method' => 'post',
+                                       'action' => $url));
+        $this->out->hidden('token', common_session_token());
+        $this->out->hidden("$id-inreplyto", $replyToId, "inreplyto");
+        $this->out->element('textarea', array('name' => 'status_textarea'));
+        $this->out->elementStart('div', array('class' => 'controls'));
+        $this->out->submit("$id-submit", _m('Send reply'));
+        $this->out->elementEnd('div');
+        $this->out->elementEnd('form');
+    }
 }
\ No newline at end of file