Add import of blog comments (vB 5)
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 22 Sep 2020 11:42:45 +0000 (13:42 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 7 Oct 2020 07:47:14 +0000 (09:47 +0200)
files/lib/system/exporter/VB5xExporter.class.php

index a08b5f5cc0b52295f1bfe39f715b29524df6fa35..b73366f5d3f2b991ab5acf2313f34752a0642357 100644 (file)
@@ -120,9 +120,9 @@ class VB5xExporter extends AbstractExporter {
                        
                        'com.woltlab.blog.entry' => [
                        /*      'com.woltlab.blog.category',
-                               'com.woltlab.blog.entry.attachment',
+                               'com.woltlab.blog.entry.attachment',*/
                                'com.woltlab.blog.entry.comment',
-                               'com.woltlab.blog.entry.like'*/
+                       /*      'com.woltlab.blog.entry.like'*/
                        ],
                ];
        }
@@ -218,12 +218,12 @@ class VB5xExporter extends AbstractExporter {
                        $queue[] = 'com.woltlab.blog.blog';
                /*      if (in_array('com.woltlab.blog.category', $this->selectedData)) $queue[] = 'com.woltlab.blog.category';*/
                        $queue[] = 'com.woltlab.blog.entry';
-               /*      if (in_array('com.woltlab.blog.entry.attachment', $this->selectedData)) $queue[] = 'com.woltlab.blog.entry.attachment';
+               /*      if (in_array('com.woltlab.blog.entry.attachment', $this->selectedData)) $queue[] = 'com.woltlab.blog.entry.attachment';*/
                        if (in_array('com.woltlab.blog.entry.comment', $this->selectedData)) {
                                $queue[] = 'com.woltlab.blog.entry.comment';
-                               $queue[] = 'com.woltlab.blog.entry.comment.response';
+               /*              $queue[] = 'com.woltlab.blog.entry.comment.response';*/
                        }
-                       if (in_array('com.woltlab.blog.entry.like', $this->selectedData)) $queue[] = 'com.woltlab.blog.entry.like';*/
+               /*      if (in_array('com.woltlab.blog.entry.like', $this->selectedData)) $queue[] = 'com.woltlab.blog.entry.like';*/
                }
                
                // smiley
@@ -902,6 +902,47 @@ class VB5xExporter extends AbstractExporter {
                }
        }
        
+       /**
+        * Counts blog comments.
+        */
+       public function countBlogComments() {
+               return $this->__getMaxID($this->databasePrefix."node", 'nodeid');
+       }
+       
+       /**
+        * Exports blog comments.
+        *
+        * @param       integer         $offset
+        * @param       integer         $limit
+        */
+       public function exportBlogComments($offset, $limit) {
+               $sql = "SELECT          child.*, text.*
+                       FROM            ".$this->databasePrefix."node child
+                       INNER JOIN      ".$this->databasePrefix."node parent
+                       ON              child.parentid = parent.nodeid
+                       INNER JOIN      ".$this->databasePrefix."text text
+                       ON              child.nodeid = text.nodeid
+                       
+                       INNER JOIN      (SELECT contenttypeid FROM ".$this->databasePrefix."contenttype WHERE class = ?) x
+                       ON              x.contenttypeid = parent.contenttypeid
+                       INNER JOIN      (SELECT contenttypeid FROM ".$this->databasePrefix."contenttype WHERE class IN (?)) y
+                       ON              y.contenttypeid = child.contenttypeid
+                       
+                       WHERE           child.nodeid BETWEEN ? AND ?
+                       ORDER BY        child.nodeid ASC";
+               $statement = $this->database->prepareStatement($sql);
+               $statement->execute(['Text', 'Text', $offset + 1, $offset + $limit]);
+               while ($row = $statement->fetchArray()) {
+                       ImportHandler::getInstance()->getImporter('com.woltlab.blog.entry.comment')->import($row['nodeid'], [
+                               'objectID' => $row['parentid'],
+                               'userID' => $row['userid'] ?: null,
+                               'username' => $row['authorname'] ?: '',
+                               'message' => self::fixBBCodes($row['rawtext']),
+                               'time' => $row['created']
+                       ]);
+               }
+       }
+       
        /**
         * Counts smilies.
         */