]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/conversation.php
conversation action is readonly
[quix0rs-gnu-social.git] / actions / conversation.php
index 0d7cb9a8744189935e76c7ff5242698f2f5f4d91..c8755ba6ef3df29e9c9821b28b56ac6595f66653 100644 (file)
@@ -31,6 +31,9 @@ if (!defined('LACONICA')) {
     exit(1);
 }
 
+// XXX: not sure how to do paging yet,
+// so set a 60-notice limit
+
 require_once INSTALLDIR.'/lib/noticelist.php';
 
 /**
@@ -63,6 +66,7 @@ class ConversationAction extends Action
         if (empty($this->id)) {
             return false;
         }
+        $this->id = $this->id+0;
         $this->page = $this->trimmed('page');
         if (empty($this->page)) {
             $this->page = 1;
@@ -106,27 +110,17 @@ class ConversationAction extends Action
 
     function showContent()
     {
-        // FIXME this needs to be a tree, not a list
-
-        $qry = 'SELECT * FROM notice WHERE conversation = %s ';
-
-        $offset = ($this->page-1) * NOTICES_PER_PAGE;
-        $limit  = NOTICES_PER_PAGE + 1;
-
-        $txt = sprintf($qry, $this->id);
-
-        $notices = Notice::getStream($txt,
-                                     'notice:conversation:'.$this->id,
-                                     $offset, $limit);
+        $notices = Notice::conversationStream($this->id, null, null);
 
         $ct = new ConversationTree($notices, $this);
 
         $cnt = $ct->show();
-
-        $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
-                          $this->page, 'conversation', array('id' => $this->id));
     }
 
+    function isReadOnly()
+    {
+        return true;
+    }
 }
 
 /**
@@ -154,8 +148,25 @@ class ConversationTree extends NoticeList
 
     function show()
     {
-        $cnt = 0;
+        $cnt = $this->_buildTree();
+
+        $this->out->elementStart('div', array('id' =>'notices_primary'));
+        $this->out->element('h2', null, _('Notices'));
+        $this->out->elementStart('ol', array('class' => 'notices xoxo'));
+
+        if (array_key_exists('root', $this->tree)) {
+            $rootid = $this->tree['root'][0];
+            $this->showNoticePlus($rootid);
+        }
+
+        $this->out->elementEnd('ol');
+        $this->out->elementEnd('div');
+
+        return $cnt;
+    }
 
+    function _buildTree()
+    {
         $this->tree  = array();
         $this->table = array();
 
@@ -177,18 +188,6 @@ class ConversationTree extends NoticeList
             }
         }
 
-        $this->out->elementStart('div', array('id' =>'notices_primary'));
-        $this->out->element('h2', null, _('Notices'));
-        $this->out->elementStart('ol', array('class' => 'notices xoxo'));
-
-        if (array_key_exists('root', $this->tree)) {
-            $rootid = $this->tree['root'][0];
-            $this->showNoticePlus($rootid);
-        }
-
-        $this->out->elementEnd('ol');
-        $this->out->elementEnd('div');
-
         return $cnt;
     }
 
@@ -207,7 +206,7 @@ class ConversationTree extends NoticeList
         // We take responsibility for doing the li
 
         $this->out->elementStart('li', array('class' => 'hentry notice',
-                                             'id' => 'notice-' . $this->notice->id));
+                                             'id' => 'notice-' . $id));
 
         $item = $this->newListItem($notice);
         $item->show();
@@ -217,6 +216,8 @@ class ConversationTree extends NoticeList
 
             $this->out->elementStart('ol', array('class' => 'notices'));
 
+            sort($children);
+
             foreach ($children as $child) {
                 $this->showNoticePlus($child);
             }