]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Threaded comments (replies) on the profile page
authorMax Shinn <trombonechamp@gmail.com>
Mon, 14 Feb 2011 00:15:54 +0000 (18:15 -0600)
committerMax Shinn <trombonechamp@gmail.com>
Mon, 14 Feb 2011 00:15:54 +0000 (18:15 -0600)
plugins/GNUsocialProfileExtensions/GNUsocialProfileExtensionsPlugin.php
plugins/GNUsocialProfileExtensions/actions/bio.php
plugins/GNUsocialProfileExtensions/actions/newresponse.php [new file with mode: 0644]
plugins/GNUsocialProfileExtensions/js/profile.js [new file with mode: 0644]
plugins/GNUsocialProfileExtensions/lib/noticetree.php [new file with mode: 0644]
plugins/GNUsocialProfileExtensions/res/bgstripe.gif [new file with mode: 0644]
plugins/GNUsocialProfileExtensions/res/style.css

index 468bc192046f0d307e86f2b55e0861f6c11b980c..27bf19336a6d354add10c62ad8368e914292159f 100644 (file)
@@ -22,7 +22,7 @@
  * @category  Widget
  * @package   GNU Social
  * @author    Max Shinn <trombonechamp@gmail.com>
- * @copyright 2010 Free Software Foundation, Inc.
+ * @copyright 2011 Free Software Foundation, Inc.
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  */
 
@@ -40,6 +40,7 @@ class GNUsocialProfileExtensionsPlugin extends Plugin
         switch ($cls)
         {
         case 'BioAction':
+        case 'NewresponseAction':
             include_once $dir . '/actions/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
             break;
         case 'ProfilefieldsAdminPanelAction':
@@ -51,6 +52,7 @@ class GNUsocialProfileExtensionsPlugin extends Plugin
         include_once $dir . '/classes/GNUsocialProfileExtensionField.php';
         include_once $dir . '/classes/GNUsocialProfileExtensionResponse.php';
         include_once $dir . '/lib/profiletools.php';
+        include_once $dir . '/lib/noticetree.php';
         return true;
     }
 
@@ -75,6 +77,7 @@ class GNUsocialProfileExtensionsPlugin extends Plugin
     {
         $m->connect(':nickname/bio', array('action' => 'bio'));
         $m->connect('admin/profilefields', array('action' => 'profilefieldsAdminPanel'));
+        $m->connect('notice/respond', array('action' => 'newresponse'));
         return true;
     }
 
@@ -135,6 +138,11 @@ class GNUsocialProfileExtensionsPlugin extends Plugin
         $action->cssLink('/plugins/GNUsocialProfileExtensions/res/style.css');
     }
 
+    function onEndShowScripts($action)
+    {
+        $action->script('plugins/GNUsocialProfileExtensions/js/profile.js');
+    }
+
     function onEndAdminPanelNav($nav)
     {
         if (AdminPanelAction::canAdmin('profilefields')) {
@@ -160,5 +168,12 @@ class GNUsocialProfileExtensionsPlugin extends Plugin
                            _('The user\'s extended profile'), $nav->action->trimmed('action') == 'bio', 'nav_bio');
     }
 
+    //Why the heck is this shoved into this plugin!?!?  It deserves its own!
+    function onShowStreamNoticeList($notice, $action, &$pnl)
+    {
+        $pnl = new NoticeTree($notice, $action);
+        return false;
+    }
+
 }
 
index 6cfded4e36d2dd0dd158301c1b1c2ca9a829c6d0..bc9f12cb132ee68250eaeee8aa24c790ce8ec00f 100644 (file)
@@ -22,7 +22,7 @@
  * @category  Widget
  * @package   GNU Social
  * @author    Max Shinn <trombonechamp@gmail.com>
- * @copyright 2010 Free Software Foundation, Inc.
+ * @copyright 2011 Free Software Foundation, Inc.
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  */
 
@@ -101,3 +101,5 @@ class BioAction extends Action
     }
 
 }
+
+
diff --git a/plugins/GNUsocialProfileExtensions/actions/newresponse.php b/plugins/GNUsocialProfileExtensions/actions/newresponse.php
new file mode 100644 (file)
index 0000000..0e71ee3
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+/**
+ * GNU Social
+ * Copyright (C) 2010, Free Software Foundation, Inc.
+ *
+ * PHP version 5
+ *
+ * LICENCE:
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category  Widget
+ * @package   GNU Social
+ * @author    Max Shinn <trombonechamp@gmail.com>
+ * @copyright 2011 Free Software Foundation, Inc.
+ * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
+ */
+
+require_once INSTALLDIR . '/actions/newnotice.php';
+
+class NewresponseAction extends NewnoticeAction
+{
+     /**
+     * Same as the parent, but not including the @-whoever in replies
+     *
+     * @return void
+     */
+
+    function showNoticeForm()
+    {
+        $content = $this->trimmed('status_textarea');
+        if (!$content) {
+            $replyto = $this->trimmed('replyto');
+            $inreplyto = $this->trimmed('inreplyto');
+        } else {
+            // @fixme most of these bits above aren't being passed on above
+            $inreplyto = null;
+        }
+
+        $notice_form = new NoticeForm($this, '', $content, null, $inreplyto);
+        $notice_form->show();
+    }
+}
\ No newline at end of file
diff --git a/plugins/GNUsocialProfileExtensions/js/profile.js b/plugins/GNUsocialProfileExtensions/js/profile.js
new file mode 100644 (file)
index 0000000..4a2f1c5
--- /dev/null
@@ -0,0 +1,4 @@
+SN.U.NoticeReplySet = function(nick,id) {
+    $('div.replyform').hide();
+    $('div#form'+id).show();
+}
diff --git a/plugins/GNUsocialProfileExtensions/lib/noticetree.php b/plugins/GNUsocialProfileExtensions/lib/noticetree.php
new file mode 100644 (file)
index 0000000..a8ee510
--- /dev/null
@@ -0,0 +1,151 @@
+<?php
+/**
+ * GNU Social
+ * Copyright (C) 2010, Free Software Foundation, Inc.
+ *
+ * PHP version 5
+ *
+ * LICENCE:
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category  Widget
+ * @package   GNU Social
+ * @author    Max Shinn <trombonechamp@gmail.com>
+ * @copyright 2011 Free Software Foundation, Inc.
+ * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
+ */
+
+class NoticeTree extends NoticeList
+{
+    function show()
+    {
+        $this->out->elementStart('div', array('id' =>'notices_primary'));
+        // TRANS: Header on conversation page. Hidden by default (h2).
+        $this->out->element('h2', null, _('Notices'));
+        $this->out->elementStart('ol', array('class' => 'notices xoxo'));
+
+        $cnt = 0;
+
+        while ($this->notice->fetch() && $cnt <= NOTICES_PER_PAGE) {
+            if (!empty($this->notice->reply_to))
+                continue;
+
+            $cnt++;
+
+            if ($cnt > NOTICES_PER_PAGE) {
+                break;
+            }
+
+            try {
+                $this->showNoticePlus($this->notice);
+            } catch (Exception $e) {
+                // we log exceptions and continue
+                common_log(LOG_ERR, $e->getMessage());
+                continue;
+            }
+        }
+
+        $this->out->elementEnd('ol');
+        $this->out->elementEnd('div');
+
+        return $cnt;
+    }
+
+
+    function showNoticePlus($notice)
+    {
+        $replies = new Notice();
+        $replies->reply_to = $notice->id;
+
+        // We take responsibility for doing the li
+
+         $this->out->elementStart('li', array('class' => 'hentry notice',
+                                             'id' => 'notice-' . $id));
+
+        $item = $this->newListItem($notice);
+        $item->show();
+
+        if ($replies->find()) {
+            $this->out->elementStart('ol', array('class' => 'notices'));
+
+            while ($replies->fetch()) {
+                $this->showNoticePlus($replies);
+            }
+
+            $this->out->elementEnd('ol');
+        }
+
+        $this->out->elementEnd('li');
+    }
+
+    function newListItem($notice)
+    {
+        return new NoticeTreeItem($notice, $this->out);
+    }
+}
+
+class NoticeTreeItem extends NoticeListItem
+{
+    function showStart()
+    {
+        return;
+    }
+
+    function showEnd()
+    {
+        //TODO: Rewrite this
+        //Showing number of favorites
+        $fave = new Fave();
+        $fave->notice_id = $this->notice->id;
+        $cnt = 0;
+        if ($fave->find()) {
+            while ($fave->fetch())
+                $cnt++;
+        }
+        if ($cnt > 0) {
+            $this->out->text(_m("Favorited by $cnt user"));
+            if ($cnt > 1) $this->out->text("s"); //there has to be a better way to do this...
+        }
+
+        //TODO: Rewrite this too
+        //Show response form
+        $this->out->elementStart('div', array('id' => 'form' . $this->notice->id, 'class' => 'replyform'));
+        $noticeform = new NoticeForm($this->out, null, null, null, $this->notice->id);
+        $noticeform->show();
+        $this->out->elementEnd('div');
+        return;
+    }
+
+    function showContext()
+    {
+        return;
+    }
+
+    //Just changing the link...
+    function showReplyLink()
+    {
+        if (common_logged_in()) {
+            $this->out->text(' ');
+            $reply_url = '/notice/respond?replyto=' . $this->profile->nickname . '&inreplyto=' . $this->notice->id;
+            $this->out->elementStart('a', array('href' => $reply_url,
+                                                'class' => 'notice_reply',
+                                                'title' => _('Reply to this notice')));
+            $this->out->text(_('Reply'));
+            $this->out->text(' ');
+            $this->out->element('span', 'notice_id', $this->notice->id);
+            $this->out->elementEnd('a');
+        }
+    }
+
+}
diff --git a/plugins/GNUsocialProfileExtensions/res/bgstripe.gif b/plugins/GNUsocialProfileExtensions/res/bgstripe.gif
new file mode 100644 (file)
index 0000000..035ef80
Binary files /dev/null and b/plugins/GNUsocialProfileExtensions/res/bgstripe.gif differ
index b7d746bd8dbb799b98f29072c3d2d9adb666f5b2..035b7fbea9fbb505ca4348e3421b7045bac8442a 100644 (file)
@@ -3,4 +3,17 @@
 }
 .biovalue {
     font-style: italic;
+}
+#showstream ol.notices ol.notices {
+    background-image: url(/plugins/GNUsocialProfileExtensions/res/bgstripe.gif); 
+    background-repeat: repeat-y;
+    background-position: left top;
+    padding-left: 15px;
+    color: #333333;
+}
+#showstream ol.notices ol.notices ol.notices {
+    padding-left: 5px;
+}
+div.replyform {
+    display: none;
 }
\ No newline at end of file